diff --git "a/languages/lua/train.jsonl" "b/languages/lua/train.jsonl" new file mode 100644--- /dev/null +++ "b/languages/lua/train.jsonl" @@ -0,0 +1,1000 @@ +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s597659287", "group_id": "codeNet:p02537", "input_text": "local mfl, mce = math.floor, math.ceil\nlocal mmi, mma = math.min, math.max\nlocal bls, brs = bit.lshift, bit.rshift\nlocal SegTree = {}\nSegTree.updateAll = function(self)\n for i = self.stagenum - 1, 1, -1 do\n local cnt = bls(1, i - 1)\n for j = 1, cnt do\n self.stage[i][j] = self.func(self.stage[i + 1][j * 2 - 1], self.stage[i + 1][j * 2])\n end\n end\nend\nSegTree.create = function(self, n, func, emptyvalue)\n self.func, self.emptyvalue = func, emptyvalue\n local stagenum, mul = 1, 1\n self.stage = {{}}\n while mul < n do\n mul, stagenum = mul * 2, stagenum + 1\n self.stage[stagenum] = {}\n end\n self.stagenum = stagenum\n self.left_stage = {}\n for i = 1, n do\n local sp, sz = 1, bls(1, stagenum - 1)\n while(i - 1) % sz ~= 0 do\n sp, sz = sp + 1, brs(sz, 1)\n end\n self.left_stage[i] = sp\n end\n self.sz_stage = {}\n local tmp, sp = 1, stagenum\n for i = 1, n do\n if tmp * 2 == i then tmp, sp = tmp * 2, sp - 1 end\n self.sz_stage[i] = sp\n end\n for i = 1, mul do self.stage[stagenum][i] = emptyvalue end\n self:updateAll()\nend\nSegTree.getRange = function(self, left, right)\n if left == right then return self.stage[self.stagenum][left] end\n local stagenum = self.stagenum\n local ret = self.emptyvalue\n while left <= right do\n local stage = mma(self.left_stage[left], self.sz_stage[right - left + 1])\n local sz = bls(1, stagenum - stage)\n ret = self.func(ret, self.stage[stage][1 + brs(left - 1, stagenum - stage)])\n left = left + sz\n end\n return ret\nend\nSegTree.update = function(self, idx)\n for i = self.stagenum - 1, 1, -1 do\n local dst = brs(idx + 1, 1)\n local rem = dst * 4 - 1 - idx\n self.stage[i][dst] = self.func(self.stage[i + 1][idx], self.stage[i + 1][rem])\n idx = dst\n end\nend\nSegTree.setValue = function(self, idx, value, silent)\n self.stage[self.stagenum][idx] = mma(self.stage[self.stagenum][idx], value)\n if not silent then\n self:update(idx)\n end\nend\nSegTree.new = function(n, func, emptyvalue)\n local obj = {}\n setmetatable(obj, {__index = SegTree})\n obj:create(n, func, emptyvalue)\n return obj\nend\n\nlocal n, k = io.read(\"*n\", \"*n\")\nlocal a = {}\nfor i = 1, n do\n a[i] = io.read(\"*n\")\nend\nlocal z = 300000\nlocal st = SegTree.new(z + 1, mma, 0)\nfor i = 1, n do\n local ai = a[i]\n local left = mma(0, ai - k)\n local right = mmi(z, ai + k)\n local cur = st:getRange(left + 1, right + 1)\n st:setValue(ai + 1, cur + 1)\nend\nprint(st.stage[1][1])\n", "language": "Lua", "metadata": {"date": 1601168933, "filename_ext": "lua", "original_language": "Lua (LuaJIT 2.1.0)", "problem_description_relpath": "problem_descriptions/p02537.html", "problem_id": "p02537", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02537/input.txt", "sample_output_relpath": "derived/input_output/data/p02537/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02537/Lua/s597659287.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s597659287", "user_id": "u120582723"}, "prompt_components": {"gold_output": "7\n", "input_to_evaluate": "local mfl, mce = math.floor, math.ceil\nlocal mmi, mma = math.min, math.max\nlocal bls, brs = bit.lshift, bit.rshift\nlocal SegTree = {}\nSegTree.updateAll = function(self)\n for i = self.stagenum - 1, 1, -1 do\n local cnt = bls(1, i - 1)\n for j = 1, cnt do\n self.stage[i][j] = self.func(self.stage[i + 1][j * 2 - 1], self.stage[i + 1][j * 2])\n end\n end\nend\nSegTree.create = function(self, n, func, emptyvalue)\n self.func, self.emptyvalue = func, emptyvalue\n local stagenum, mul = 1, 1\n self.stage = {{}}\n while mul < n do\n mul, stagenum = mul * 2, stagenum + 1\n self.stage[stagenum] = {}\n end\n self.stagenum = stagenum\n self.left_stage = {}\n for i = 1, n do\n local sp, sz = 1, bls(1, stagenum - 1)\n while(i - 1) % sz ~= 0 do\n sp, sz = sp + 1, brs(sz, 1)\n end\n self.left_stage[i] = sp\n end\n self.sz_stage = {}\n local tmp, sp = 1, stagenum\n for i = 1, n do\n if tmp * 2 == i then tmp, sp = tmp * 2, sp - 1 end\n self.sz_stage[i] = sp\n end\n for i = 1, mul do self.stage[stagenum][i] = emptyvalue end\n self:updateAll()\nend\nSegTree.getRange = function(self, left, right)\n if left == right then return self.stage[self.stagenum][left] end\n local stagenum = self.stagenum\n local ret = self.emptyvalue\n while left <= right do\n local stage = mma(self.left_stage[left], self.sz_stage[right - left + 1])\n local sz = bls(1, stagenum - stage)\n ret = self.func(ret, self.stage[stage][1 + brs(left - 1, stagenum - stage)])\n left = left + sz\n end\n return ret\nend\nSegTree.update = function(self, idx)\n for i = self.stagenum - 1, 1, -1 do\n local dst = brs(idx + 1, 1)\n local rem = dst * 4 - 1 - idx\n self.stage[i][dst] = self.func(self.stage[i + 1][idx], self.stage[i + 1][rem])\n idx = dst\n end\nend\nSegTree.setValue = function(self, idx, value, silent)\n self.stage[self.stagenum][idx] = mma(self.stage[self.stagenum][idx], value)\n if not silent then\n self:update(idx)\n end\nend\nSegTree.new = function(n, func, emptyvalue)\n local obj = {}\n setmetatable(obj, {__index = SegTree})\n obj:create(n, func, emptyvalue)\n return obj\nend\n\nlocal n, k = io.read(\"*n\", \"*n\")\nlocal a = {}\nfor i = 1, n do\n a[i] = io.read(\"*n\")\nend\nlocal z = 300000\nlocal st = SegTree.new(z + 1, mma, 0)\nfor i = 1, n do\n local ai = a[i]\n local left = mma(0, ai - k)\n local right = mmi(z, ai + k)\n local cur = st:getRange(left + 1, right + 1)\n st:setValue(ai + 1, cur + 1)\nend\nprint(st.stage[1][1])\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nYou are given a sequence A_1, A_2, ..., A_N and an integer K.\n\nPrint the maximum possible length of a sequence B that satisfies the following conditions:\n\nB is a (not necessarily continuous) subsequence of A.\n\nFor each pair of adjacents elements of B, the absolute difference of the elements is at most K.\n\nConstraints\n\n1 \\leq N \\leq 300,000\n\n0 \\leq A_i \\leq 300,000\n\n0 \\leq K \\leq 300,000\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nA_1\nA_2\n:\nA_N\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n10 3\n1\n5\n4\n3\n8\n6\n9\n7\n2\n4\n\nSample Output 1\n\n7\n\nFor example, B = (1, 4, 3, 6, 9, 7, 4) satisfies the conditions.\n\nIt is a subsequence of A = (1, 5, 4, 3, 8, 6, 9, 7, 2, 4).\n\nAll of the absolute differences between two adjacent elements (|1-4|, |4-3|, |3-6|, |6-9|, |9-7|, |7-4|) are at most K = 3.", "sample_input": "10 3\n1\n5\n4\n3\n8\n6\n9\n7\n2\n4\n"}, "reference_outputs": ["7\n"], "source_document_id": "p02537", "source_text": "Score : 400 points\n\nProblem Statement\n\nYou are given a sequence A_1, A_2, ..., A_N and an integer K.\n\nPrint the maximum possible length of a sequence B that satisfies the following conditions:\n\nB is a (not necessarily continuous) subsequence of A.\n\nFor each pair of adjacents elements of B, the absolute difference of the elements is at most K.\n\nConstraints\n\n1 \\leq N \\leq 300,000\n\n0 \\leq A_i \\leq 300,000\n\n0 \\leq K \\leq 300,000\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nA_1\nA_2\n:\nA_N\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n10 3\n1\n5\n4\n3\n8\n6\n9\n7\n2\n4\n\nSample Output 1\n\n7\n\nFor example, B = (1, 4, 3, 6, 9, 7, 4) satisfies the conditions.\n\nIt is a subsequence of A = (1, 5, 4, 3, 8, 6, 9, 7, 2, 4).\n\nAll of the absolute differences between two adjacent elements (|1-4|, |4-3|, |3-6|, |6-9|, |9-7|, |7-4|) are at most K = 3.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2446, "cpu_time_ms": 273, "memory_kb": 23184}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s662206681", "group_id": "codeNet:p02540", "input_text": "local mfl, mce = math.floor, math.ceil\nlocal mmi, mma = math.min, math.max\nlocal bls, brs = bit.lshift, bit.rshift\nlocal SegTree = {}\nSegTree.updateAll = function(self)\n for i = self.stagenum - 1, 1, -1 do\n local cnt = bls(1, i - 1)\n for j = 1, cnt do\n self.stage[i][j] = self.func(self.stage[i + 1][j * 2 - 1], self.stage[i + 1][j * 2])\n end\n end\nend\nSegTree.create = function(self, n, func, emptyvalue)\n self.func, self.emptyvalue = func, emptyvalue\n local stagenum, mul = 1, 1\n self.stage = {{}}\n while mul < n do\n mul, stagenum = mul * 2, stagenum + 1\n self.stage[stagenum] = {}\n end\n self.stagenum = stagenum\n self.left_stage = {}\n for i = 1, n do\n local sp, sz = 1, bls(1, stagenum - 1)\n while(i - 1) % sz ~= 0 do\n sp, sz = sp + 1, brs(sz, 1)\n end\n self.left_stage[i] = sp\n end\n self.sz_stage = {}\n local tmp, sp = 1, stagenum\n for i = 1, n do\n if tmp * 2 == i then tmp, sp = tmp * 2, sp - 1 end\n self.sz_stage[i] = sp\n end\n for i = 1, mul do self.stage[stagenum][i] = emptyvalue end\n self:updateAll()\nend\nSegTree.getRange = function(self, left, right)\n if left == right then return self.stage[self.stagenum][left] end\n local stagenum = self.stagenum\n local ret = self.emptyvalue\n while left <= right do\n local stage = mma(self.left_stage[left], self.sz_stage[right - left + 1])\n local sz = bls(1, stagenum - stage)\n ret = self.func(ret, self.stage[stage][1 + brs(left - 1, stagenum - stage)])\n left = left + sz\n end\n return ret\nend\nSegTree.update = function(self, idx)\n for i = self.stagenum - 1, 1, -1 do\n local dst = brs(idx + 1, 1)\n local rem = dst * 4 - 1 - idx\n self.stage[i][dst] = self.func(self.stage[i + 1][idx], self.stage[i + 1][rem])\n idx = dst\n end\nend\nSegTree.setValue = function(self, idx, value, silent)\n self.stage[self.stagenum][idx] = value\n if not silent then\n self:update(idx)\n end\nend\nSegTree.right_bound = function(self, left, right)\n local retpos = left - 1\n local l, r = left, right\n local stage = mma(self.left_stage[left], self.sz_stage[right - left + 1])\n local stagenum = self.stagenum\n while true do\n local sz = bls(1, stagenum - stage)\n if not self.stage[stage][mce(l / sz)] then\n retpos = l + sz - 1\n if retpos == right then break end\n if l + sz <= r then\n l = l + sz\n stage = mma(self.left_stage[l], self.sz_stage[r - l + 1])\n else break end\n else\n if sz ~= 1 then stage, r = stage + 1, l + sz - 2\n else break end\n end\n end\n return retpos + 1\nend\nSegTree.left_bound = function(self, left, right)\n local retpos = right + 1\n local stage, l, r = 1, left, right\n local stagenum = self.stagenum\n while true do\n local sz = bls(1, stagenum - stage)\n while r % sz ~= 0 or r + 1 - l < sz do\n stage = stage + 1\n sz = bls(1, stagenum - stage)\n end\n if not self.stage[stage][mfl(r / sz)] then\n retpos = r - sz + 1\n if l + sz <= r then stage, l, r = 1, l, r - sz\n else break end\n else\n if sz ~= 1 then stage, l, r = stage + 1, r - sz + 2, r\n else break end\n end\n end\n return retpos - 1\nend\nSegTree.new = function(n, func, emptyvalue)\n local obj = {}\n setmetatable(obj, {__index = SegTree})\n obj:create(n, func, emptyvalue)\n return obj\nend\n\nlocal n = io.read(\"*n\")\nlocal xs, ys = {}, {}\nlocal xidx, yidx = {}, {}\nlocal parent = {}\nfor i = 1, n do\n xidx[i], yidx[i] = 0, 0\n parent[i] = i\nend\n\nlocal function uf_findroot(idx)\n local idx_update = idx\n while parent[idx] ~= idx do\n idx = parent[idx]\n end\n while parent[idx_update] ~= idx do\n parent[idx_update], idx_update = idx, parent[idx_update]\n end\n return idx\nend\n\nfor i = 1, n do\n xs[i], ys[i] = io.read(\"*n\", \"*n\")\n xidx[xs[i]] = i\n yidx[ys[i]] = i\nend\nlocal function orfunc(a, b) return a or b end\nlocal st1 = SegTree.new(n, orfunc, false)\nfor i = 1, n do\n local src = xidx[i]\n local v = st1:left_bound(1, ys[src])\n while 1 <= v do\n local dst = yidx[v]\n local rs, rd = uf_findroot(src), uf_findroot(dst)\n parent[rd], parent[dst] = rs, rs\n st1:setValue(v, false)\n if v == 1 then break end\n v = st1:left_bound(1, v - 1)\n end\n st1:setValue(ys[src], true)\nend\n\n\nlocal group = {}\nfor i = 1, n do\n group[i] = 0\nend\nfor i = 1, n do\n local r = uf_findroot(i)\n group[r] = group[r] + 1\nend\nfor i = 1, n do\n local r = uf_findroot(i)\n print(group[r])\nend\n", "language": "Lua", "metadata": {"date": 1600630793, "filename_ext": "lua", "original_language": "Lua (LuaJIT 2.1.0)", "problem_description_relpath": "problem_descriptions/p02540.html", "problem_id": "p02540", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02540/input.txt", "sample_output_relpath": "derived/input_output/data/p02540/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02540/Lua/s662206681.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s662206681", "user_id": "u120582723"}, "prompt_components": {"gold_output": "1\n1\n2\n2\n", "input_to_evaluate": "local mfl, mce = math.floor, math.ceil\nlocal mmi, mma = math.min, math.max\nlocal bls, brs = bit.lshift, bit.rshift\nlocal SegTree = {}\nSegTree.updateAll = function(self)\n for i = self.stagenum - 1, 1, -1 do\n local cnt = bls(1, i - 1)\n for j = 1, cnt do\n self.stage[i][j] = self.func(self.stage[i + 1][j * 2 - 1], self.stage[i + 1][j * 2])\n end\n end\nend\nSegTree.create = function(self, n, func, emptyvalue)\n self.func, self.emptyvalue = func, emptyvalue\n local stagenum, mul = 1, 1\n self.stage = {{}}\n while mul < n do\n mul, stagenum = mul * 2, stagenum + 1\n self.stage[stagenum] = {}\n end\n self.stagenum = stagenum\n self.left_stage = {}\n for i = 1, n do\n local sp, sz = 1, bls(1, stagenum - 1)\n while(i - 1) % sz ~= 0 do\n sp, sz = sp + 1, brs(sz, 1)\n end\n self.left_stage[i] = sp\n end\n self.sz_stage = {}\n local tmp, sp = 1, stagenum\n for i = 1, n do\n if tmp * 2 == i then tmp, sp = tmp * 2, sp - 1 end\n self.sz_stage[i] = sp\n end\n for i = 1, mul do self.stage[stagenum][i] = emptyvalue end\n self:updateAll()\nend\nSegTree.getRange = function(self, left, right)\n if left == right then return self.stage[self.stagenum][left] end\n local stagenum = self.stagenum\n local ret = self.emptyvalue\n while left <= right do\n local stage = mma(self.left_stage[left], self.sz_stage[right - left + 1])\n local sz = bls(1, stagenum - stage)\n ret = self.func(ret, self.stage[stage][1 + brs(left - 1, stagenum - stage)])\n left = left + sz\n end\n return ret\nend\nSegTree.update = function(self, idx)\n for i = self.stagenum - 1, 1, -1 do\n local dst = brs(idx + 1, 1)\n local rem = dst * 4 - 1 - idx\n self.stage[i][dst] = self.func(self.stage[i + 1][idx], self.stage[i + 1][rem])\n idx = dst\n end\nend\nSegTree.setValue = function(self, idx, value, silent)\n self.stage[self.stagenum][idx] = value\n if not silent then\n self:update(idx)\n end\nend\nSegTree.right_bound = function(self, left, right)\n local retpos = left - 1\n local l, r = left, right\n local stage = mma(self.left_stage[left], self.sz_stage[right - left + 1])\n local stagenum = self.stagenum\n while true do\n local sz = bls(1, stagenum - stage)\n if not self.stage[stage][mce(l / sz)] then\n retpos = l + sz - 1\n if retpos == right then break end\n if l + sz <= r then\n l = l + sz\n stage = mma(self.left_stage[l], self.sz_stage[r - l + 1])\n else break end\n else\n if sz ~= 1 then stage, r = stage + 1, l + sz - 2\n else break end\n end\n end\n return retpos + 1\nend\nSegTree.left_bound = function(self, left, right)\n local retpos = right + 1\n local stage, l, r = 1, left, right\n local stagenum = self.stagenum\n while true do\n local sz = bls(1, stagenum - stage)\n while r % sz ~= 0 or r + 1 - l < sz do\n stage = stage + 1\n sz = bls(1, stagenum - stage)\n end\n if not self.stage[stage][mfl(r / sz)] then\n retpos = r - sz + 1\n if l + sz <= r then stage, l, r = 1, l, r - sz\n else break end\n else\n if sz ~= 1 then stage, l, r = stage + 1, r - sz + 2, r\n else break end\n end\n end\n return retpos - 1\nend\nSegTree.new = function(n, func, emptyvalue)\n local obj = {}\n setmetatable(obj, {__index = SegTree})\n obj:create(n, func, emptyvalue)\n return obj\nend\n\nlocal n = io.read(\"*n\")\nlocal xs, ys = {}, {}\nlocal xidx, yidx = {}, {}\nlocal parent = {}\nfor i = 1, n do\n xidx[i], yidx[i] = 0, 0\n parent[i] = i\nend\n\nlocal function uf_findroot(idx)\n local idx_update = idx\n while parent[idx] ~= idx do\n idx = parent[idx]\n end\n while parent[idx_update] ~= idx do\n parent[idx_update], idx_update = idx, parent[idx_update]\n end\n return idx\nend\n\nfor i = 1, n do\n xs[i], ys[i] = io.read(\"*n\", \"*n\")\n xidx[xs[i]] = i\n yidx[ys[i]] = i\nend\nlocal function orfunc(a, b) return a or b end\nlocal st1 = SegTree.new(n, orfunc, false)\nfor i = 1, n do\n local src = xidx[i]\n local v = st1:left_bound(1, ys[src])\n while 1 <= v do\n local dst = yidx[v]\n local rs, rd = uf_findroot(src), uf_findroot(dst)\n parent[rd], parent[dst] = rs, rs\n st1:setValue(v, false)\n if v == 1 then break end\n v = st1:left_bound(1, v - 1)\n end\n st1:setValue(ys[src], true)\nend\n\n\nlocal group = {}\nfor i = 1, n do\n group[i] = 0\nend\nfor i = 1, n do\n local r = uf_findroot(i)\n group[r] = group[r] + 1\nend\nfor i = 1, n do\n local r = uf_findroot(i)\n print(group[r])\nend\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere are N cities on a 2D plane. The coordinate of the i-th city is (x_i, y_i). Here (x_1, x_2, \\dots, x_N) and (y_1, y_2, \\dots, y_N) are both permuations of (1, 2, \\dots, N).\n\nFor each k = 1,2,\\dots,N, find the answer to the following question:\n\nRng is in City k.\nRng can perform the following move arbitrarily many times:\n\nmove to another city that has a smaller x-coordinate and a smaller y-coordinate, or a larger x-coordinate and a larger y-coordinate, than the city he is currently in.\n\nHow many cities (including City k) are reachable from City k?\n\nConstraints\n\n1 \\leq N \\leq 200,000\n\n(x_1, x_2, \\dots, x_N) is a permutation of (1, 2, \\dots, N).\n\n(y_1, y_2, \\dots, y_N) is a permutation of (1, 2, \\dots, N).\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nx_1 y_1\nx_2 y_2\n:\nx_N y_N\n\nOutput\n\nPrint N lines. In i-th line print the answer to the question when k = i.\n\nSample Input 1\n\n4\n1 4\n2 3\n3 1\n4 2\n\nSample Output 1\n\n1\n1\n2\n2\n\nRng can reach City 4 from City 3, or conversely City 3 from City 4.\n\nSample Input 2\n\n7\n6 4\n4 3\n3 5\n7 1\n2 7\n5 2\n1 6\n\nSample Output 2\n\n3\n3\n1\n1\n2\n3\n2", "sample_input": "4\n1 4\n2 3\n3 1\n4 2\n"}, "reference_outputs": ["1\n1\n2\n2\n"], "source_document_id": "p02540", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere are N cities on a 2D plane. The coordinate of the i-th city is (x_i, y_i). Here (x_1, x_2, \\dots, x_N) and (y_1, y_2, \\dots, y_N) are both permuations of (1, 2, \\dots, N).\n\nFor each k = 1,2,\\dots,N, find the answer to the following question:\n\nRng is in City k.\nRng can perform the following move arbitrarily many times:\n\nmove to another city that has a smaller x-coordinate and a smaller y-coordinate, or a larger x-coordinate and a larger y-coordinate, than the city he is currently in.\n\nHow many cities (including City k) are reachable from City k?\n\nConstraints\n\n1 \\leq N \\leq 200,000\n\n(x_1, x_2, \\dots, x_N) is a permutation of (1, 2, \\dots, N).\n\n(y_1, y_2, \\dots, y_N) is a permutation of (1, 2, \\dots, N).\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nx_1 y_1\nx_2 y_2\n:\nx_N y_N\n\nOutput\n\nPrint N lines. In i-th line print the answer to the question when k = i.\n\nSample Input 1\n\n4\n1 4\n2 3\n3 1\n4 2\n\nSample Output 1\n\n1\n1\n2\n2\n\nRng can reach City 4 from City 3, or conversely City 3 from City 4.\n\nSample Input 2\n\n7\n6 4\n4 3\n3 5\n7 1\n2 7\n5 2\n1 6\n\nSample Output 2\n\n3\n3\n1\n1\n2\n3\n2", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 4393, "cpu_time_ms": 589, "memory_kb": 23484}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s430886987", "group_id": "codeNet:p02540", "input_text": "local mfl, mce = math.floor, math.ceil\nlocal mmi, mma = math.min, math.max\nlocal bls, brs = bit.lshift, bit.rshift\nlocal SegTree = {}\nSegTree.updateAll = function(self)\n for i = self.stagenum - 1, 1, -1 do\n local cnt = bls(1, i - 1)\n for j = 1, cnt do\n self.stage[i][j] = self.func(self.stage[i + 1][j * 2 - 1], self.stage[i + 1][j * 2])\n end\n end\nend\nSegTree.create = function(self, n, func, emptyvalue)\n self.func, self.emptyvalue = func, emptyvalue\n local stagenum, mul = 1, 1\n self.stage = {{}}\n while mul < n do\n mul, stagenum = mul * 2, stagenum + 1\n self.stage[stagenum] = {}\n end\n self.stagenum = stagenum\n self.left_stage = {}\n for i = 1, n do\n local sp, sz = 1, bls(1, stagenum - 1)\n while(i - 1) % sz ~= 0 do\n sp, sz = sp + 1, brs(sz, 1)\n end\n self.left_stage[i] = sp\n end\n self.sz_stage = {}\n local tmp, sp = 1, stagenum\n for i = 1, n do\n if tmp * 2 == i then tmp, sp = tmp * 2, sp - 1 end\n self.sz_stage[i] = sp\n end\n for i = 1, mul do self.stage[stagenum][i] = emptyvalue end\n self:updateAll()\nend\nSegTree.getRange = function(self, left, right)\n if left == right then return self.stage[self.stagenum][left] end\n local stagenum = self.stagenum\n local ret = self.emptyvalue\n while left <= right do\n local stage = mma(self.left_stage[left], self.sz_stage[right - left + 1])\n local sz = bls(1, stagenum - stage)\n ret = self.func(ret, self.stage[stage][1 + brs(left - 1, stagenum - stage)])\n left = left + sz\n end\n return ret\nend\nSegTree.update = function(self, idx)\n for i = self.stagenum - 1, 1, -1 do\n local dst = brs(idx + 1, 1)\n local rem = dst * 4 - 1 - idx\n self.stage[i][dst] = self.func(self.stage[i + 1][idx], self.stage[i + 1][rem])\n idx = dst\n end\nend\nSegTree.setValue = function(self, idx, value, silent)\n self.stage[self.stagenum][idx] = value\n if not silent then\n self:update(idx)\n end\nend\nSegTree.right_bound = function(self, left, right)\n local retpos = left - 1\n local l, r = left, right\n local stage = mma(self.left_stage[left], self.sz_stage[right - left + 1])\n local stagenum = self.stagenum\n while true do\n local sz = bls(1, stagenum - stage)\n if not self.stage[stage][mce(l / sz)] then\n retpos = l + sz - 1\n if retpos == right then break end\n if l + sz <= r then\n l = l + sz\n stage = mma(self.left_stage[l], self.sz_stage[r - l + 1])\n else break end\n else\n if sz ~= 1 then stage, r = stage + 1, l + sz - 2\n else break end\n end\n end\n return retpos + 1\nend\nSegTree.left_bound = function(self, left, right)\n local retpos = right + 1\n local stage, l, r = 1, left, right\n local stagenum = self.stagenum\n while true do\n local sz = bls(1, stagenum - stage)\n while r % sz ~= 0 or r + 1 - l < sz do\n stage = stage + 1\n sz = bls(1, stagenum - stage)\n end\n if not self.stage[stage][mfl(r / sz)] then\n retpos = r - sz + 1\n if l + sz <= r then stage, l, r = 1, l, r - sz\n else break end\n else\n if sz ~= 1 then stage, l, r = stage + 1, r - sz + 2, r\n else break end\n end\n end\n return retpos - 1\nend\nSegTree.new = function(n, func, emptyvalue)\n local obj = {}\n setmetatable(obj, {__index = SegTree})\n obj:create(n, func, emptyvalue)\n return obj\nend\n\nlocal n = io.read(\"*n\")\nlocal xs, ys = {}, {}\nlocal xidx, yidx = {}, {}\nlocal parent = {}\nfor i = 1, n do\n xidx[i], yidx[i] = 0, 0\n parent[i] = i\nend\n\nlocal function uf_findroot(idx)\n local idx_update = idx\n while parent[idx] ~= idx do\n idx = parent[idx]\n end\n while parent[idx_update] ~= idx do\n parent[idx_update], idx_update = idx, parent[idx_update]\n end\n return idx\nend\n\nfor i = 1, n do\n xs[i], ys[i] = io.read(\"*n\", \"*n\")\n xidx[xs[i]] = i\n yidx[ys[i]] = i\nend\nlocal function orfunc(a, b) return a or b end\nlocal st1 = SegTree.new(n, orfunc, false)\nfor i = 1, n do\n local src = xidx[i]\n local v = st1:left_bound(1, ys[src])\n if 1 <= v then\n local dst = yidx[v]\n local rs, rd = uf_findroot(src), uf_findroot(dst)\n parent[rd], parent[dst] = rs, rs\n end\n st1:setValue(ys[src], true)\nend\nlocal st2 = SegTree.new(n, orfunc, false)\nfor i = n, 1, -1 do\n local src = xidx[i]\n local v = st2:right_bound(ys[src], n)\n if v <= n then\n local dst = yidx[v]\n local rs, rd = uf_findroot(src), uf_findroot(dst)\n parent[rd], parent[dst] = rs, rs\n end\n st2:setValue(ys[src], true)\nend\nlocal group = {}\nfor i = 1, n do\n group[i] = 0\nend\nfor i = 1, n do\n local r = uf_findroot(i)\n group[r] = group[r] + 1\nend\nfor i = 1, n do\n local r = uf_findroot(i)\n print(group[r])\nend\n", "language": "Lua", "metadata": {"date": 1600630298, "filename_ext": "lua", "original_language": "Lua (LuaJIT 2.1.0)", "problem_description_relpath": "problem_descriptions/p02540.html", "problem_id": "p02540", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02540/input.txt", "sample_output_relpath": "derived/input_output/data/p02540/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02540/Lua/s430886987.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s430886987", "user_id": "u120582723"}, "prompt_components": {"gold_output": "1\n1\n2\n2\n", "input_to_evaluate": "local mfl, mce = math.floor, math.ceil\nlocal mmi, mma = math.min, math.max\nlocal bls, brs = bit.lshift, bit.rshift\nlocal SegTree = {}\nSegTree.updateAll = function(self)\n for i = self.stagenum - 1, 1, -1 do\n local cnt = bls(1, i - 1)\n for j = 1, cnt do\n self.stage[i][j] = self.func(self.stage[i + 1][j * 2 - 1], self.stage[i + 1][j * 2])\n end\n end\nend\nSegTree.create = function(self, n, func, emptyvalue)\n self.func, self.emptyvalue = func, emptyvalue\n local stagenum, mul = 1, 1\n self.stage = {{}}\n while mul < n do\n mul, stagenum = mul * 2, stagenum + 1\n self.stage[stagenum] = {}\n end\n self.stagenum = stagenum\n self.left_stage = {}\n for i = 1, n do\n local sp, sz = 1, bls(1, stagenum - 1)\n while(i - 1) % sz ~= 0 do\n sp, sz = sp + 1, brs(sz, 1)\n end\n self.left_stage[i] = sp\n end\n self.sz_stage = {}\n local tmp, sp = 1, stagenum\n for i = 1, n do\n if tmp * 2 == i then tmp, sp = tmp * 2, sp - 1 end\n self.sz_stage[i] = sp\n end\n for i = 1, mul do self.stage[stagenum][i] = emptyvalue end\n self:updateAll()\nend\nSegTree.getRange = function(self, left, right)\n if left == right then return self.stage[self.stagenum][left] end\n local stagenum = self.stagenum\n local ret = self.emptyvalue\n while left <= right do\n local stage = mma(self.left_stage[left], self.sz_stage[right - left + 1])\n local sz = bls(1, stagenum - stage)\n ret = self.func(ret, self.stage[stage][1 + brs(left - 1, stagenum - stage)])\n left = left + sz\n end\n return ret\nend\nSegTree.update = function(self, idx)\n for i = self.stagenum - 1, 1, -1 do\n local dst = brs(idx + 1, 1)\n local rem = dst * 4 - 1 - idx\n self.stage[i][dst] = self.func(self.stage[i + 1][idx], self.stage[i + 1][rem])\n idx = dst\n end\nend\nSegTree.setValue = function(self, idx, value, silent)\n self.stage[self.stagenum][idx] = value\n if not silent then\n self:update(idx)\n end\nend\nSegTree.right_bound = function(self, left, right)\n local retpos = left - 1\n local l, r = left, right\n local stage = mma(self.left_stage[left], self.sz_stage[right - left + 1])\n local stagenum = self.stagenum\n while true do\n local sz = bls(1, stagenum - stage)\n if not self.stage[stage][mce(l / sz)] then\n retpos = l + sz - 1\n if retpos == right then break end\n if l + sz <= r then\n l = l + sz\n stage = mma(self.left_stage[l], self.sz_stage[r - l + 1])\n else break end\n else\n if sz ~= 1 then stage, r = stage + 1, l + sz - 2\n else break end\n end\n end\n return retpos + 1\nend\nSegTree.left_bound = function(self, left, right)\n local retpos = right + 1\n local stage, l, r = 1, left, right\n local stagenum = self.stagenum\n while true do\n local sz = bls(1, stagenum - stage)\n while r % sz ~= 0 or r + 1 - l < sz do\n stage = stage + 1\n sz = bls(1, stagenum - stage)\n end\n if not self.stage[stage][mfl(r / sz)] then\n retpos = r - sz + 1\n if l + sz <= r then stage, l, r = 1, l, r - sz\n else break end\n else\n if sz ~= 1 then stage, l, r = stage + 1, r - sz + 2, r\n else break end\n end\n end\n return retpos - 1\nend\nSegTree.new = function(n, func, emptyvalue)\n local obj = {}\n setmetatable(obj, {__index = SegTree})\n obj:create(n, func, emptyvalue)\n return obj\nend\n\nlocal n = io.read(\"*n\")\nlocal xs, ys = {}, {}\nlocal xidx, yidx = {}, {}\nlocal parent = {}\nfor i = 1, n do\n xidx[i], yidx[i] = 0, 0\n parent[i] = i\nend\n\nlocal function uf_findroot(idx)\n local idx_update = idx\n while parent[idx] ~= idx do\n idx = parent[idx]\n end\n while parent[idx_update] ~= idx do\n parent[idx_update], idx_update = idx, parent[idx_update]\n end\n return idx\nend\n\nfor i = 1, n do\n xs[i], ys[i] = io.read(\"*n\", \"*n\")\n xidx[xs[i]] = i\n yidx[ys[i]] = i\nend\nlocal function orfunc(a, b) return a or b end\nlocal st1 = SegTree.new(n, orfunc, false)\nfor i = 1, n do\n local src = xidx[i]\n local v = st1:left_bound(1, ys[src])\n if 1 <= v then\n local dst = yidx[v]\n local rs, rd = uf_findroot(src), uf_findroot(dst)\n parent[rd], parent[dst] = rs, rs\n end\n st1:setValue(ys[src], true)\nend\nlocal st2 = SegTree.new(n, orfunc, false)\nfor i = n, 1, -1 do\n local src = xidx[i]\n local v = st2:right_bound(ys[src], n)\n if v <= n then\n local dst = yidx[v]\n local rs, rd = uf_findroot(src), uf_findroot(dst)\n parent[rd], parent[dst] = rs, rs\n end\n st2:setValue(ys[src], true)\nend\nlocal group = {}\nfor i = 1, n do\n group[i] = 0\nend\nfor i = 1, n do\n local r = uf_findroot(i)\n group[r] = group[r] + 1\nend\nfor i = 1, n do\n local r = uf_findroot(i)\n print(group[r])\nend\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere are N cities on a 2D plane. The coordinate of the i-th city is (x_i, y_i). Here (x_1, x_2, \\dots, x_N) and (y_1, y_2, \\dots, y_N) are both permuations of (1, 2, \\dots, N).\n\nFor each k = 1,2,\\dots,N, find the answer to the following question:\n\nRng is in City k.\nRng can perform the following move arbitrarily many times:\n\nmove to another city that has a smaller x-coordinate and a smaller y-coordinate, or a larger x-coordinate and a larger y-coordinate, than the city he is currently in.\n\nHow many cities (including City k) are reachable from City k?\n\nConstraints\n\n1 \\leq N \\leq 200,000\n\n(x_1, x_2, \\dots, x_N) is a permutation of (1, 2, \\dots, N).\n\n(y_1, y_2, \\dots, y_N) is a permutation of (1, 2, \\dots, N).\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nx_1 y_1\nx_2 y_2\n:\nx_N y_N\n\nOutput\n\nPrint N lines. In i-th line print the answer to the question when k = i.\n\nSample Input 1\n\n4\n1 4\n2 3\n3 1\n4 2\n\nSample Output 1\n\n1\n1\n2\n2\n\nRng can reach City 4 from City 3, or conversely City 3 from City 4.\n\nSample Input 2\n\n7\n6 4\n4 3\n3 5\n7 1\n2 7\n5 2\n1 6\n\nSample Output 2\n\n3\n3\n1\n1\n2\n3\n2", "sample_input": "4\n1 4\n2 3\n3 1\n4 2\n"}, "reference_outputs": ["1\n1\n2\n2\n"], "source_document_id": "p02540", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere are N cities on a 2D plane. The coordinate of the i-th city is (x_i, y_i). Here (x_1, x_2, \\dots, x_N) and (y_1, y_2, \\dots, y_N) are both permuations of (1, 2, \\dots, N).\n\nFor each k = 1,2,\\dots,N, find the answer to the following question:\n\nRng is in City k.\nRng can perform the following move arbitrarily many times:\n\nmove to another city that has a smaller x-coordinate and a smaller y-coordinate, or a larger x-coordinate and a larger y-coordinate, than the city he is currently in.\n\nHow many cities (including City k) are reachable from City k?\n\nConstraints\n\n1 \\leq N \\leq 200,000\n\n(x_1, x_2, \\dots, x_N) is a permutation of (1, 2, \\dots, N).\n\n(y_1, y_2, \\dots, y_N) is a permutation of (1, 2, \\dots, N).\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nx_1 y_1\nx_2 y_2\n:\nx_N y_N\n\nOutput\n\nPrint N lines. In i-th line print the answer to the question when k = i.\n\nSample Input 1\n\n4\n1 4\n2 3\n3 1\n4 2\n\nSample Output 1\n\n1\n1\n2\n2\n\nRng can reach City 4 from City 3, or conversely City 3 from City 4.\n\nSample Input 2\n\n7\n6 4\n4 3\n3 5\n7 1\n2 7\n5 2\n1 6\n\nSample Output 2\n\n3\n3\n1\n1\n2\n3\n2", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 4597, "cpu_time_ms": 533, "memory_kb": 31692}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s181244733", "group_id": "codeNet:p02541", "input_text": "local bls, brs = bit.lshift, bit.rshift\nlocal bxor = bit.bxor\nlocal mce, mfl, msq, mmi, mma, mab = math.ceil, math.floor, math.sqrt, math.min, math.max, math.abs\n\nlocal ffi = require(\"ffi\")\nlocal C = ffi.C\nffi.cdef[[\nlong long atoll(const char*);\n]]\n\nlocal function lltonumber(str)\n return C.atoll(str)\nend\n\nlocal n = io.read()\nn = lltonumber(n)\nn = 2LL * n\nlocal lim = 31622777\nlocal function getprimes(x)\n local primes = {}\n local allnums = {}\n for i = 1, x do allnums[i] = true end\n for i = 2, x do\n if allnums[i] then\n table.insert(primes, i)\n local lim = mfl(x / i)\n for j = 2, lim do\n allnums[j * i] = false\n end\n end\n end\n return primes\nend\n-- print(os.clock())\nlocal primes = getprimes(lim)\n-- print(os.clock())\nlocal function getdivisorparts(x, primes, lim)\n local prime_num = #primes\n local tmp = {}\n local raw = {}\n local primepos = 1\n local dv = primes[primepos]\n while primepos <= prime_num and dv <= lim do\n if x % dv == 0LL then\n local p = dv\n x = x / dv\n while x % dv == 0 do\n x = x / dv\n p = p * dv\n end\n table.insert(tmp, p)\n table.insert(raw, dv)\n -- lim = mce(msq(x))\n end\n if primepos == prime_num then break end\n primepos = primepos + 1\n dv = primes[primepos]\n end\n if x ~= 1LL then\n table.insert(tmp, x)\n table.insert(raw, x)\n end\n return tmp, raw\nend\n-- for i = 1, #dvs do\n-- print(dvs[i])-- maybe LL\n-- end\n\nlocal function grayCode(x)\n return bxor(x, brs(x, 1))\nend\n\n-- add_func(idx), rm_func(idx), work_func()\nlocal function grayWalk(size, add_func, rm_func, work_func)\n local prv = 0\n local total = bls(1, size) - 1\n local bpos = {}\n for i = 1, size do\n bpos[bls(1, i - 1)] = i\n end\n -- if need first work then use below\n -- work_func()\n for i = 1, total do\n local v = grayCode(i)\n if prv < v then\n prv, v = v, v - prv\n add_func(bpos[v])\n else\n prv, v = v, prv - v\n rm_func(bpos[v])\n end\n work_func()\n end\nend\n\nlocal dvs, raw = getdivisorparts(n, primes, lim)\nlocal tot = bls(1, #dvs)\nlocal left_use = {}\nlocal minfact = n\nlocal kcand = 1\nlocal left = 1LL\n\nlocal function solve(a, b, x, y)\n if b == 0LL then\n x[1] = 1LL\n y[1] = 0LL\n return a\n end\n local d = solve(b, a % b, y, x)\n y[1] = y[1] - (a / b) * x[1]\n return d\nend\n\nlocal function add_func(idx)\n left_use[tostring(raw[idx])] = true\n left = left * dvs[idx]\nend\nlocal function rm_func(idx)\n left_use[tostring(raw[idx])] = false\n left = left / dvs[idx]\nend\nlocal x, y = {0}, {0}\nlocal function work_func()\n local right = n / left\n solve(left, right, x, y)\n x[1] = -x[1]\n while x[1] < 0LL do\n x[1] = x[1] + right\n end\n local z = x[1] * left\n if 0LL < z and z < minfact then\n -- if x[1] * left < minfact then\n minfact = left * x[1]\n -- print(x[1], left, minfact)\n end\nend\ngrayWalk(#dvs, add_func, rm_func, work_func)\nlocal ans = minfact\nans = tostring(ans):gsub(\"LL\", \"\")\nprint(ans)\n", "language": "Lua", "metadata": {"date": 1600635328, "filename_ext": "lua", "original_language": "Lua (LuaJIT 2.1.0)", "problem_description_relpath": "problem_descriptions/p02541.html", "problem_id": "p02541", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02541/input.txt", "sample_output_relpath": "derived/input_output/data/p02541/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02541/Lua/s181244733.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s181244733", "user_id": "u120582723"}, "prompt_components": {"gold_output": "10\n", "input_to_evaluate": "local bls, brs = bit.lshift, bit.rshift\nlocal bxor = bit.bxor\nlocal mce, mfl, msq, mmi, mma, mab = math.ceil, math.floor, math.sqrt, math.min, math.max, math.abs\n\nlocal ffi = require(\"ffi\")\nlocal C = ffi.C\nffi.cdef[[\nlong long atoll(const char*);\n]]\n\nlocal function lltonumber(str)\n return C.atoll(str)\nend\n\nlocal n = io.read()\nn = lltonumber(n)\nn = 2LL * n\nlocal lim = 31622777\nlocal function getprimes(x)\n local primes = {}\n local allnums = {}\n for i = 1, x do allnums[i] = true end\n for i = 2, x do\n if allnums[i] then\n table.insert(primes, i)\n local lim = mfl(x / i)\n for j = 2, lim do\n allnums[j * i] = false\n end\n end\n end\n return primes\nend\n-- print(os.clock())\nlocal primes = getprimes(lim)\n-- print(os.clock())\nlocal function getdivisorparts(x, primes, lim)\n local prime_num = #primes\n local tmp = {}\n local raw = {}\n local primepos = 1\n local dv = primes[primepos]\n while primepos <= prime_num and dv <= lim do\n if x % dv == 0LL then\n local p = dv\n x = x / dv\n while x % dv == 0 do\n x = x / dv\n p = p * dv\n end\n table.insert(tmp, p)\n table.insert(raw, dv)\n -- lim = mce(msq(x))\n end\n if primepos == prime_num then break end\n primepos = primepos + 1\n dv = primes[primepos]\n end\n if x ~= 1LL then\n table.insert(tmp, x)\n table.insert(raw, x)\n end\n return tmp, raw\nend\n-- for i = 1, #dvs do\n-- print(dvs[i])-- maybe LL\n-- end\n\nlocal function grayCode(x)\n return bxor(x, brs(x, 1))\nend\n\n-- add_func(idx), rm_func(idx), work_func()\nlocal function grayWalk(size, add_func, rm_func, work_func)\n local prv = 0\n local total = bls(1, size) - 1\n local bpos = {}\n for i = 1, size do\n bpos[bls(1, i - 1)] = i\n end\n -- if need first work then use below\n -- work_func()\n for i = 1, total do\n local v = grayCode(i)\n if prv < v then\n prv, v = v, v - prv\n add_func(bpos[v])\n else\n prv, v = v, prv - v\n rm_func(bpos[v])\n end\n work_func()\n end\nend\n\nlocal dvs, raw = getdivisorparts(n, primes, lim)\nlocal tot = bls(1, #dvs)\nlocal left_use = {}\nlocal minfact = n\nlocal kcand = 1\nlocal left = 1LL\n\nlocal function solve(a, b, x, y)\n if b == 0LL then\n x[1] = 1LL\n y[1] = 0LL\n return a\n end\n local d = solve(b, a % b, y, x)\n y[1] = y[1] - (a / b) * x[1]\n return d\nend\n\nlocal function add_func(idx)\n left_use[tostring(raw[idx])] = true\n left = left * dvs[idx]\nend\nlocal function rm_func(idx)\n left_use[tostring(raw[idx])] = false\n left = left / dvs[idx]\nend\nlocal x, y = {0}, {0}\nlocal function work_func()\n local right = n / left\n solve(left, right, x, y)\n x[1] = -x[1]\n while x[1] < 0LL do\n x[1] = x[1] + right\n end\n local z = x[1] * left\n if 0LL < z and z < minfact then\n -- if x[1] * left < minfact then\n minfact = left * x[1]\n -- print(x[1], left, minfact)\n end\nend\ngrayWalk(#dvs, add_func, rm_func, work_func)\nlocal ans = minfact\nans = tostring(ans):gsub(\"LL\", \"\")\nprint(ans)\n", "problem_context": "Score : 600 points\n\nProblem Statement\n\nGiven is an integer N.\nFind the minimum possible positive integer k such that (1+2+\\cdots+k) is a multiple of N.\nIt can be proved that such a positive integer k always exists.\n\nConstraints\n\n1 \\leq N \\leq 10^{15}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the answer in a line.\n\nSample Input 1\n\n11\n\nSample Output 1\n\n10\n\n1+2+\\cdots+10=55 holds and 55 is indeed a multple of N=11.\nThere are no positive integers k \\leq 9 that satisfy the condition, so the answer is k = 10.\n\nSample Input 2\n\n20200920\n\nSample Output 2\n\n1100144", "sample_input": "11\n"}, "reference_outputs": ["10\n"], "source_document_id": "p02541", "source_text": "Score : 600 points\n\nProblem Statement\n\nGiven is an integer N.\nFind the minimum possible positive integer k such that (1+2+\\cdots+k) is a multiple of N.\nIt can be proved that such a positive integer k always exists.\n\nConstraints\n\n1 \\leq N \\leq 10^{15}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the answer in a line.\n\nSample Input 1\n\n11\n\nSample Output 1\n\n10\n\n1+2+\\cdots+10=55 holds and 55 is indeed a multple of N=11.\nThere are no positive integers k \\leq 9 that satisfy the condition, so the answer is k = 10.\n\nSample Input 2\n\n20200920\n\nSample Output 2\n\n1100144", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2970, "cpu_time_ms": 1518, "memory_kb": 281128}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s375639837", "group_id": "codeNet:p02547", "input_text": "-- Vicfred\n-- https://atcoder.jp/contests/abc179/tasks/abc179_b\n-- simulation\nn = io.read(\"*n\")\n\nb = {}\nd = {}\nfor i = 1, n do b[i], d[i] = io.read(\"*n\", \"*n\") end\n\nflag = false\n\nfor i = 1, n-3 do\n if b[i] == d[i] and\n b[i + 1] == d[i + 1] and\n b[i + 2] == d[i + 2] then\n flag = true\n end\nend\n\nif flag then\n print(\"Yes\")\nelse\n print(\"No\")\nend\n\n", "language": "Lua", "metadata": {"date": 1600678226, "filename_ext": "lua", "original_language": "Lua (Lua 5.3.5)", "problem_description_relpath": "problem_descriptions/p02547.html", "problem_id": "p02547", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02547/input.txt", "sample_output_relpath": "derived/input_output/data/p02547/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02547/Lua/s375639837.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s375639837", "user_id": "u737840172"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "-- Vicfred\n-- https://atcoder.jp/contests/abc179/tasks/abc179_b\n-- simulation\nn = io.read(\"*n\")\n\nb = {}\nd = {}\nfor i = 1, n do b[i], d[i] = io.read(\"*n\", \"*n\") end\n\nflag = false\n\nfor i = 1, n-3 do\n if b[i] == d[i] and\n b[i + 1] == d[i + 1] and\n b[i + 2] == d[i + 2] then\n flag = true\n end\nend\n\nif flag then\n print(\"Yes\")\nelse\n print(\"No\")\nend\n\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nTak performed the following action N times: rolling two dice.\nThe result of the i-th roll is D_{i,1} and D_{i,2}.\n\nCheck if doublets occurred at least three times in a row.\nSpecifically, check if there exists at lease one i such that D_{i,1}=D_{i,2}, D_{i+1,1}=D_{i+1,2} and D_{i+2,1}=D_{i+2,2} hold.\n\nConstraints\n\n3 \\leq N \\leq 100\n\n1\\leq D_{i,j} \\leq 6\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nD_{1,1} D_{1,2}\n\\vdots\nD_{N,1} D_{N,2}\n\nOutput\n\nPrint Yes if doublets occurred at least three times in a row. Print No otherwise.\n\nSample Input 1\n\n5\n1 2\n6 6\n4 4\n3 3\n3 2\n\nSample Output 1\n\nYes\n\nFrom the second roll to the fourth roll, three doublets occurred in a row.\n\nSample Input 2\n\n5\n1 1\n2 2\n3 4\n5 5\n6 6\n\nSample Output 2\n\nNo\n\nSample Input 3\n\n6\n1 1\n2 2\n3 3\n4 4\n5 5\n6 6\n\nSample Output 3\n\nYes", "sample_input": "5\n1 2\n6 6\n4 4\n3 3\n3 2\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p02547", "source_text": "Score : 200 points\n\nProblem Statement\n\nTak performed the following action N times: rolling two dice.\nThe result of the i-th roll is D_{i,1} and D_{i,2}.\n\nCheck if doublets occurred at least three times in a row.\nSpecifically, check if there exists at lease one i such that D_{i,1}=D_{i,2}, D_{i+1,1}=D_{i+1,2} and D_{i+2,1}=D_{i+2,2} hold.\n\nConstraints\n\n3 \\leq N \\leq 100\n\n1\\leq D_{i,j} \\leq 6\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nD_{1,1} D_{1,2}\n\\vdots\nD_{N,1} D_{N,2}\n\nOutput\n\nPrint Yes if doublets occurred at least three times in a row. Print No otherwise.\n\nSample Input 1\n\n5\n1 2\n6 6\n4 4\n3 3\n3 2\n\nSample Output 1\n\nYes\n\nFrom the second roll to the fourth roll, three doublets occurred in a row.\n\nSample Input 2\n\n5\n1 1\n2 2\n3 4\n5 5\n6 6\n\nSample Output 2\n\nNo\n\nSample Input 3\n\n6\n1 1\n2 2\n3 3\n4 4\n5 5\n6 6\n\nSample Output 3\n\nYes", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 372, "cpu_time_ms": 5, "memory_kb": 2628}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s594722544", "group_id": "codeNet:p02549", "input_text": "local mmi, mma = math.min, math.max\nlocal mod = 998244353\nlocal mfl = math.floor\nlocal function bmul(x, y)\n local x0, y0 = x % 31596, y % 31596\n local x1, y1 = mfl(x / 31596), mfl(y / 31596)\n return (x1 * y1 * 62863 + (x1 * y0 + x0 * y1) * 31596 + x0 * y0) % mod\nend\n\nlocal function badd(x, y)\n return (x + y) % mod\nend\n\nlocal function bsub(x, y)\n return x < y and x - y + mod or x - y\nend\n\nlocal n, k = io.read(\"*n\", \"*n\")\nlocal ls, rs = {}, {}\nfor i = 1, k do\n ls[i], rs[i] = io.read(\"*n\", \"*n\")\nend\nlocal t = {1}\nlocal imos = {0}\nfor i = 2, n + 1 do\n t[i] = 0\n imos[i] = 0\nend\nfor src = 1, n do\n if 1 < src then\n imos[src] = badd(imos[src], imos[src - 1])\n t[src] = imos[src]\n end\n if src < n then\n for j = 1, k do\n local dstmin = src + ls[j]\n local dstmax = mmi(n, src + rs[j])\n if dstmin <= dstmax then\n imos[dstmin] = badd(imos[dstmin], t[src])\n imos[dstmax + 1] = bsub(imos[dstmax + 1], t[src])\n end\n end\n end\nend\nprint(t[n])\n", "language": "Lua", "metadata": {"date": 1600544185, "filename_ext": "lua", "original_language": "Lua (LuaJIT 2.1.0)", "problem_description_relpath": "problem_descriptions/p02549.html", "problem_id": "p02549", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02549/input.txt", "sample_output_relpath": "derived/input_output/data/p02549/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02549/Lua/s594722544.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s594722544", "user_id": "u120582723"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "local mmi, mma = math.min, math.max\nlocal mod = 998244353\nlocal mfl = math.floor\nlocal function bmul(x, y)\n local x0, y0 = x % 31596, y % 31596\n local x1, y1 = mfl(x / 31596), mfl(y / 31596)\n return (x1 * y1 * 62863 + (x1 * y0 + x0 * y1) * 31596 + x0 * y0) % mod\nend\n\nlocal function badd(x, y)\n return (x + y) % mod\nend\n\nlocal function bsub(x, y)\n return x < y and x - y + mod or x - y\nend\n\nlocal n, k = io.read(\"*n\", \"*n\")\nlocal ls, rs = {}, {}\nfor i = 1, k do\n ls[i], rs[i] = io.read(\"*n\", \"*n\")\nend\nlocal t = {1}\nlocal imos = {0}\nfor i = 2, n + 1 do\n t[i] = 0\n imos[i] = 0\nend\nfor src = 1, n do\n if 1 < src then\n imos[src] = badd(imos[src], imos[src - 1])\n t[src] = imos[src]\n end\n if src < n then\n for j = 1, k do\n local dstmin = src + ls[j]\n local dstmax = mmi(n, src + rs[j])\n if dstmin <= dstmax then\n imos[dstmin] = badd(imos[dstmin], t[src])\n imos[dstmax + 1] = bsub(imos[dstmax + 1], t[src])\n end\n end\n end\nend\nprint(t[n])\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nThere are N cells arranged in a row, numbered 1, 2, \\ldots, N from left to right.\n\nTak lives in these cells and is currently on Cell 1. He is trying to reach Cell N by using the procedure described below.\n\nYou are given an integer K that is less than or equal to 10, and K non-intersecting segments [L_1, R_1], [L_2, R_2], \\ldots, [L_K, R_K].\nLet S be the union of these K segments.\nHere, the segment [l, r] denotes the set consisting of all integers i that satisfy l \\leq i \\leq r.\n\n\bWhen you are on Cell i, pick an integer d from S and move to Cell i + d. You cannot move out of the cells.\n\nTo help Tak, find the number of ways to go to Cell N, modulo 998244353.\n\nConstraints\n\n2 \\leq N \\leq 2 \\times 10^5\n\n1 \\leq K \\leq \\min(N, 10)\n\n1 \\leq L_i \\leq R_i \\leq N\n\n[L_i, R_i] and [L_j, R_j] do not intersect (i \\neq j)\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nL_1 R_1\nL_2 R_2\n:\nL_K R_K\n\nOutput\n\nPrint the number of ways for Tak to go from Cell 1 to Cell N, modulo 998244353.\n\nSample Input 1\n\n5 2\n1 1\n3 4\n\nSample Output 1\n\n4\n\nThe set S is the union of the segment [1, 1] and the segment [3, 4], therefore S = \\{ 1, 3, 4 \\} holds.\n\nThere are 4 possible ways to get to Cell 5:\n\n1 \\to 2 \\to 3 \\to 4 \\to 5,\n\n1 \\to 2 \\to 5,\n\n1 \\to 4 \\to 5 and\n\n1 \\to 5.\n\nSample Input 2\n\n5 2\n3 3\n5 5\n\nSample Output 2\n\n0\n\nBecause S = \\{ 3, 5 \\} holds, you cannot reach to Cell 5.\nPrint 0.\n\nSample Input 3\n\n5 1\n1 2\n\nSample Output 3\n\n5\n\nSample Input 4\n\n60 3\n5 8\n1 3\n10 15\n\nSample Output 4\n\n221823067\n\nNote that you have to print the answer modulo 998244353.", "sample_input": "5 2\n1 1\n3 4\n"}, "reference_outputs": ["4\n"], "source_document_id": "p02549", "source_text": "Score : 400 points\n\nProblem Statement\n\nThere are N cells arranged in a row, numbered 1, 2, \\ldots, N from left to right.\n\nTak lives in these cells and is currently on Cell 1. He is trying to reach Cell N by using the procedure described below.\n\nYou are given an integer K that is less than or equal to 10, and K non-intersecting segments [L_1, R_1], [L_2, R_2], \\ldots, [L_K, R_K].\nLet S be the union of these K segments.\nHere, the segment [l, r] denotes the set consisting of all integers i that satisfy l \\leq i \\leq r.\n\n\bWhen you are on Cell i, pick an integer d from S and move to Cell i + d. You cannot move out of the cells.\n\nTo help Tak, find the number of ways to go to Cell N, modulo 998244353.\n\nConstraints\n\n2 \\leq N \\leq 2 \\times 10^5\n\n1 \\leq K \\leq \\min(N, 10)\n\n1 \\leq L_i \\leq R_i \\leq N\n\n[L_i, R_i] and [L_j, R_j] do not intersect (i \\neq j)\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nL_1 R_1\nL_2 R_2\n:\nL_K R_K\n\nOutput\n\nPrint the number of ways for Tak to go from Cell 1 to Cell N, modulo 998244353.\n\nSample Input 1\n\n5 2\n1 1\n3 4\n\nSample Output 1\n\n4\n\nThe set S is the union of the segment [1, 1] and the segment [3, 4], therefore S = \\{ 1, 3, 4 \\} holds.\n\nThere are 4 possible ways to get to Cell 5:\n\n1 \\to 2 \\to 3 \\to 4 \\to 5,\n\n1 \\to 2 \\to 5,\n\n1 \\to 4 \\to 5 and\n\n1 \\to 5.\n\nSample Input 2\n\n5 2\n3 3\n5 5\n\nSample Output 2\n\n0\n\nBecause S = \\{ 3, 5 \\} holds, you cannot reach to Cell 5.\nPrint 0.\n\nSample Input 3\n\n5 1\n1 2\n\nSample Output 3\n\n5\n\nSample Input 4\n\n60 3\n5 8\n1 3\n10 15\n\nSample Output 4\n\n221823067\n\nNote that you have to print the answer modulo 998244353.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 991, "cpu_time_ms": 37, "memory_kb": 6876}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s211444936", "group_id": "codeNet:p02551", "input_text": "local mfl, mce = math.floor, math.ceil\nlocal mmi, mma = math.min, math.max\nlocal bls, brs = bit.lshift, bit.rshift\nlocal LazyRangeSeg = {}\nLazyRangeSeg.create = function(self, n, func)\n local stagenum, mul = 1, 1\n self.func = func\n self.n = n\n self.stage = {{n}}\n self.lazy = {{n}}\n while mul < n do\n mul, stagenum = mul * 2, stagenum + 1\n self.stage[stagenum] = {}\n self.lazy[stagenum] = {}\n for i = 1, mul do\n self.stage[stagenum][i] = n\n self.lazy[stagenum][i] = n\n end\n end\n self.left_stage = {}\n for i = 1, n do\n local sp, sz = 1, bls(1, stagenum - 1)\n while(i - 1) % sz ~= 0 do\n sp, sz = sp + 1, brs(sz, 1)\n end\n self.left_stage[i] = sp\n end\n self.sz_stage = {}\n local tmp, sp = 1, stagenum\n for i = 1, n do\n if tmp * 2 == i then tmp, sp = tmp * 2, sp - 1 end\n self.sz_stage[i] = sp\n end\n self.stagenum = stagenum\nend\nLazyRangeSeg.resolve = function(self, right)\n local stagenum = self.stagenum\n local offset = 0\n for i = 1, stagenum - 1 do\n local p = offset + bls(1, stagenum - i)\n if p < right then\n offset = p\n p = p + bls(1, stagenum - i)\n end\n if right < p then\n local curidx = brs(p, stagenum - i)\n local incval = self.lazy[i][curidx]\n if incval < self.n then\n self:resolveRange(i + 1, curidx * 2 - 1, incval, true)\n self:resolveRange(i + 1, curidx * 2, incval, true)\n self.lazy[i + 1][curidx * 2 - 1] = self.func(self.lazy[i + 1][curidx * 2 - 1], incval)\n self.lazy[i + 1][curidx * 2] = self.func(self.lazy[i + 1][curidx * 2], incval)\n self.lazy[i][curidx] = self.n\n end\n elseif p == right then\n break\n else\n assert(false)\n end\n end\nend\nLazyRangeSeg.resolveRange = function(self, stagepos, idx, value, shallow)\n self.stage[stagepos][idx] = self.func(self.stage[stagepos][idx], value)\n if shallow then return end\n for i = stagepos - 1, 1, -1 do\n local dst = brs(idx + 1, 1)\n local rem = dst * 4 - 1 - idx\n self.stage[i][dst] = self.func(self.stage[i + 1][idx], self.stage[i + 1][rem])\n idx = dst\n end\nend\nLazyRangeSeg.getRange = function(self, left, right)\n if 1 < left then self:resolve(left - 1) end\n self:resolve(right)\n local stagenum = self.stagenum\n local ret = self.n\n while left <= right do\n local stage = mma(self.left_stage[left], self.sz_stage[right - left + 1])\n local sz = bls(1, stagenum - stage)\n ret = self.func(ret, self.stage[stage][1 + brs(left - 1, stagenum - stage)])\n left = left + sz\n end\n return ret\nend\nLazyRangeSeg.setRange = function(self, left, right, value)\n if 1 < left then self:resolve(left - 1) end\n self:resolve(right)\n local stagenum = self.stagenum\n while left <= right do\n local stage = mma(self.left_stage[left], self.sz_stage[right - left + 1])\n local sz = bls(1, stagenum - stage)\n local len = right - left + 1\n local idx = 1 + brs(left - 1, stagenum - stage)\n self:resolveRange(stage, idx, value)\n self.lazy[stage][idx] = self.func(self.lazy[stage][idx], value)\n left = left + sz\n end\nend\nLazyRangeSeg.new = function(n, func)\n local obj = {}\n setmetatable(obj, {__index = LazyRangeSeg})\n obj:create(n, func)\n return obj\nend\n\nlocal n, q = io.read(\"*n\", \"*n\")\nlocal st_v = LazyRangeSeg.new(n, mmi)\nlocal st_h = LazyRangeSeg.new(n, mmi)\nlocal tot = 0\nfor iq = 1, q do\n local tp, x = io.read(\"*n\", \"*n\")\n if tp == 1 then\n local white_row = st_v:getRange(x, x)\n tot = tot + white_row - 2\n if 2 < white_row then\n st_h:setRange(2, white_row - 1, x)\n end\n else\n local white_col = st_h:getRange(x, x)\n tot = tot + white_col - 2\n if 2 < white_col then\n st_v:setRange(2, white_col - 1, x)\n end\n end\nend\nprint((n - 2) * (n - 2) - tot)\n", "language": "Lua", "metadata": {"date": 1600551125, "filename_ext": "lua", "original_language": "Lua (LuaJIT 2.1.0)", "problem_description_relpath": "problem_descriptions/p02551.html", "problem_id": "p02551", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02551/input.txt", "sample_output_relpath": "derived/input_output/data/p02551/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02551/Lua/s211444936.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s211444936", "user_id": "u120582723"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "local mfl, mce = math.floor, math.ceil\nlocal mmi, mma = math.min, math.max\nlocal bls, brs = bit.lshift, bit.rshift\nlocal LazyRangeSeg = {}\nLazyRangeSeg.create = function(self, n, func)\n local stagenum, mul = 1, 1\n self.func = func\n self.n = n\n self.stage = {{n}}\n self.lazy = {{n}}\n while mul < n do\n mul, stagenum = mul * 2, stagenum + 1\n self.stage[stagenum] = {}\n self.lazy[stagenum] = {}\n for i = 1, mul do\n self.stage[stagenum][i] = n\n self.lazy[stagenum][i] = n\n end\n end\n self.left_stage = {}\n for i = 1, n do\n local sp, sz = 1, bls(1, stagenum - 1)\n while(i - 1) % sz ~= 0 do\n sp, sz = sp + 1, brs(sz, 1)\n end\n self.left_stage[i] = sp\n end\n self.sz_stage = {}\n local tmp, sp = 1, stagenum\n for i = 1, n do\n if tmp * 2 == i then tmp, sp = tmp * 2, sp - 1 end\n self.sz_stage[i] = sp\n end\n self.stagenum = stagenum\nend\nLazyRangeSeg.resolve = function(self, right)\n local stagenum = self.stagenum\n local offset = 0\n for i = 1, stagenum - 1 do\n local p = offset + bls(1, stagenum - i)\n if p < right then\n offset = p\n p = p + bls(1, stagenum - i)\n end\n if right < p then\n local curidx = brs(p, stagenum - i)\n local incval = self.lazy[i][curidx]\n if incval < self.n then\n self:resolveRange(i + 1, curidx * 2 - 1, incval, true)\n self:resolveRange(i + 1, curidx * 2, incval, true)\n self.lazy[i + 1][curidx * 2 - 1] = self.func(self.lazy[i + 1][curidx * 2 - 1], incval)\n self.lazy[i + 1][curidx * 2] = self.func(self.lazy[i + 1][curidx * 2], incval)\n self.lazy[i][curidx] = self.n\n end\n elseif p == right then\n break\n else\n assert(false)\n end\n end\nend\nLazyRangeSeg.resolveRange = function(self, stagepos, idx, value, shallow)\n self.stage[stagepos][idx] = self.func(self.stage[stagepos][idx], value)\n if shallow then return end\n for i = stagepos - 1, 1, -1 do\n local dst = brs(idx + 1, 1)\n local rem = dst * 4 - 1 - idx\n self.stage[i][dst] = self.func(self.stage[i + 1][idx], self.stage[i + 1][rem])\n idx = dst\n end\nend\nLazyRangeSeg.getRange = function(self, left, right)\n if 1 < left then self:resolve(left - 1) end\n self:resolve(right)\n local stagenum = self.stagenum\n local ret = self.n\n while left <= right do\n local stage = mma(self.left_stage[left], self.sz_stage[right - left + 1])\n local sz = bls(1, stagenum - stage)\n ret = self.func(ret, self.stage[stage][1 + brs(left - 1, stagenum - stage)])\n left = left + sz\n end\n return ret\nend\nLazyRangeSeg.setRange = function(self, left, right, value)\n if 1 < left then self:resolve(left - 1) end\n self:resolve(right)\n local stagenum = self.stagenum\n while left <= right do\n local stage = mma(self.left_stage[left], self.sz_stage[right - left + 1])\n local sz = bls(1, stagenum - stage)\n local len = right - left + 1\n local idx = 1 + brs(left - 1, stagenum - stage)\n self:resolveRange(stage, idx, value)\n self.lazy[stage][idx] = self.func(self.lazy[stage][idx], value)\n left = left + sz\n end\nend\nLazyRangeSeg.new = function(n, func)\n local obj = {}\n setmetatable(obj, {__index = LazyRangeSeg})\n obj:create(n, func)\n return obj\nend\n\nlocal n, q = io.read(\"*n\", \"*n\")\nlocal st_v = LazyRangeSeg.new(n, mmi)\nlocal st_h = LazyRangeSeg.new(n, mmi)\nlocal tot = 0\nfor iq = 1, q do\n local tp, x = io.read(\"*n\", \"*n\")\n if tp == 1 then\n local white_row = st_v:getRange(x, x)\n tot = tot + white_row - 2\n if 2 < white_row then\n st_h:setRange(2, white_row - 1, x)\n end\n else\n local white_col = st_h:getRange(x, x)\n tot = tot + white_col - 2\n if 2 < white_col then\n st_v:setRange(2, white_col - 1, x)\n end\n end\nend\nprint((n - 2) * (n - 2) - tot)\n", "problem_context": "Score : 600 points\n\nProblem Statement\n\nThere is a grid with N rows and N columns of squares. Let (i, j) be the square at the i-th row from the top and the j-th column from the left.\n\nEach of the central (N-2) \\times (N-2) squares in the grid has a black stone on it.\nEach of the 2N - 1 squares on the bottom side and the right side has a white stone on it.\n\nQ queries are given. We ask you to process them in order.\nThere are two kinds of queries. Their input format and description are as follows:\n\n1 x: Place a white stone on (1, x). After that, for each black stone between (1, x) and the first white stone you hit if you go down from (1, x), replace it with a white stone.\n\n2 x: Place a white stone on (x, 1). After that, for each black stone between (x, 1) and the first white stone you hit if you go right from (x, 1), replace it with a white stone.\n\nHow many black stones are there on the grid after processing all Q queries?\n\nConstraints\n\n3 \\leq N \\leq 2\\times 10^5\n\n0 \\leq Q \\leq \\min(2N-4,2\\times 10^5)\n\n2 \\leq x \\leq N-1\n\nQueries are pairwise distinct.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN Q\nQuery_1\n\\vdots\nQuery_Q\n\nOutput\n\nPrint how many black stones there are on the grid after processing all Q queries.\n\nSample Input 1\n\n5 5\n1 3\n2 3\n1 4\n2 2\n1 2\n\nSample Output 1\n\n1\n\nAfter each query, the grid changes in the following way:\n\nSample Input 2\n\n200000 0\n\nSample Output 2\n\n39999200004\n\nSample Input 3\n\n176527 15\n1 81279\n2 22308\n2 133061\n1 80744\n2 44603\n1 170938\n2 139754\n2 15220\n1 172794\n1 159290\n2 156968\n1 56426\n2 77429\n1 97459\n2 71282\n\nSample Output 3\n\n31159505795", "sample_input": "5 5\n1 3\n2 3\n1 4\n2 2\n1 2\n"}, "reference_outputs": ["1\n"], "source_document_id": "p02551", "source_text": "Score : 600 points\n\nProblem Statement\n\nThere is a grid with N rows and N columns of squares. Let (i, j) be the square at the i-th row from the top and the j-th column from the left.\n\nEach of the central (N-2) \\times (N-2) squares in the grid has a black stone on it.\nEach of the 2N - 1 squares on the bottom side and the right side has a white stone on it.\n\nQ queries are given. We ask you to process them in order.\nThere are two kinds of queries. Their input format and description are as follows:\n\n1 x: Place a white stone on (1, x). After that, for each black stone between (1, x) and the first white stone you hit if you go down from (1, x), replace it with a white stone.\n\n2 x: Place a white stone on (x, 1). After that, for each black stone between (x, 1) and the first white stone you hit if you go right from (x, 1), replace it with a white stone.\n\nHow many black stones are there on the grid after processing all Q queries?\n\nConstraints\n\n3 \\leq N \\leq 2\\times 10^5\n\n0 \\leq Q \\leq \\min(2N-4,2\\times 10^5)\n\n2 \\leq x \\leq N-1\n\nQueries are pairwise distinct.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN Q\nQuery_1\n\\vdots\nQuery_Q\n\nOutput\n\nPrint how many black stones there are on the grid after processing all Q queries.\n\nSample Input 1\n\n5 5\n1 3\n2 3\n1 4\n2 2\n1 2\n\nSample Output 1\n\n1\n\nAfter each query, the grid changes in the following way:\n\nSample Input 2\n\n200000 0\n\nSample Output 2\n\n39999200004\n\nSample Input 3\n\n176527 15\n1 81279\n2 22308\n2 133061\n1 80744\n2 44603\n1 170938\n2 139754\n2 15220\n1 172794\n1 159290\n2 156968\n1 56426\n2 77429\n1 97459\n2 71282\n\nSample Output 3\n\n31159505795", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 3742, "cpu_time_ms": 783, "memory_kb": 27736}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s275482719", "group_id": "codeNet:p02552", "input_text": "local x = io.read(\"n\")\n\nprint(x == 0 and 1 or 0)", "language": "Lua", "metadata": {"date": 1600023694, "filename_ext": "lua", "original_language": "Lua (Lua 5.3.5)", "problem_description_relpath": "problem_descriptions/p02552.html", "problem_id": "p02552", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02552/input.txt", "sample_output_relpath": "derived/input_output/data/p02552/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02552/Lua/s275482719.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s275482719", "user_id": "u793881115"}, "prompt_components": {"gold_output": "0\n", "input_to_evaluate": "local x = io.read(\"n\")\n\nprint(x == 0 and 1 or 0)", "problem_context": "Score : 100 points\n\nProblem Statement\n\nGiven is an integer x that is greater than or equal to 0, and less than or equal to 1.\nOutput 1 if x is equal to 0, or 0 if x is equal to 1.\n\nConstraints\n\n0 \\leq x \\leq 1\n\nx is an integer\n\nInput\n\nInput is given from Standard Input in the following format:\n\nx\n\nOutput\n\nPrint 1 if x is equal to 0, or 0 if x is equal to 1.\n\nSample Input 1\n\n1\n\nSample Output 1\n\n0\n\nSample Input 2\n\n0\n\nSample Output 2\n\n1", "sample_input": "1\n"}, "reference_outputs": ["0\n"], "source_document_id": "p02552", "source_text": "Score : 100 points\n\nProblem Statement\n\nGiven is an integer x that is greater than or equal to 0, and less than or equal to 1.\nOutput 1 if x is equal to 0, or 0 if x is equal to 1.\n\nConstraints\n\n0 \\leq x \\leq 1\n\nx is an integer\n\nInput\n\nInput is given from Standard Input in the following format:\n\nx\n\nOutput\n\nPrint 1 if x is equal to 0, or 0 if x is equal to 1.\n\nSample Input 1\n\n1\n\nSample Output 1\n\n0\n\nSample Input 2\n\n0\n\nSample Output 2\n\n1", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 48, "cpu_time_ms": 7, "memory_kb": 2796}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s001305564", "group_id": "codeNet:p02553", "input_text": "local max = math.max\nlocal n_t = {}\nfor i = 1, 4 do\n\tn_t[i] = io.read(\"n\")\nend\n\nprint(max(n_t[1]*n_t[3], n_t[1]*n_t[4], n_t[2]*n_t[3], n_t[2]*n_t[4]))", "language": "Lua", "metadata": {"date": 1600024073, "filename_ext": "lua", "original_language": "Lua (Lua 5.3.5)", "problem_description_relpath": "problem_descriptions/p02553.html", "problem_id": "p02553", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02553/input.txt", "sample_output_relpath": "derived/input_output/data/p02553/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02553/Lua/s001305564.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s001305564", "user_id": "u793881115"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "local max = math.max\nlocal n_t = {}\nfor i = 1, 4 do\n\tn_t[i] = io.read(\"n\")\nend\n\nprint(max(n_t[1]*n_t[3], n_t[1]*n_t[4], n_t[2]*n_t[3], n_t[2]*n_t[4]))", "problem_context": "Score : 200 points\n\nProblem Statement\n\nGiven are integers a,b,c and d.\nIf x and y are integers and a \\leq x \\leq b and c\\leq y \\leq d hold, what is the maximum possible value of x \\times y?\n\nConstraints\n\n-10^9 \\leq a \\leq b \\leq 10^9\n\n-10^9 \\leq c \\leq d \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\na b c d\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n1 2 1 1\n\nSample Output 1\n\n2\n\nIf x = 1 and y = 1 then x \\times y = 1.\nIf x = 2 and y = 1 then x \\times y = 2.\nTherefore, the answer is 2.\n\nSample Input 2\n\n3 5 -4 -2\n\nSample Output 2\n\n-6\n\nThe answer can be negative.\n\nSample Input 3\n\n-1000000000 0 -1000000000 0\n\nSample Output 3\n\n1000000000000000000", "sample_input": "1 2 1 1\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02553", "source_text": "Score : 200 points\n\nProblem Statement\n\nGiven are integers a,b,c and d.\nIf x and y are integers and a \\leq x \\leq b and c\\leq y \\leq d hold, what is the maximum possible value of x \\times y?\n\nConstraints\n\n-10^9 \\leq a \\leq b \\leq 10^9\n\n-10^9 \\leq c \\leq d \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\na b c d\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n1 2 1 1\n\nSample Output 1\n\n2\n\nIf x = 1 and y = 1 then x \\times y = 1.\nIf x = 2 and y = 1 then x \\times y = 2.\nTherefore, the answer is 2.\n\nSample Input 2\n\n3 5 -4 -2\n\nSample Output 2\n\n-6\n\nThe answer can be negative.\n\nSample Input 3\n\n-1000000000 0 -1000000000 0\n\nSample Output 3\n\n1000000000000000000", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 150, "cpu_time_ms": 6, "memory_kb": 2792}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s863567214", "group_id": "codeNet:p02554", "input_text": "local n = io.read(\"n\")\n\n--nC1 * (n - 1)C1 10^(n - 2)\n\nif n == 1 then\n\tprint(0)\n\tos.exit()\nend\n\nlocal ten_pow, nin_pow = 1, 0\nlocal eig_pow_t, nin_pow_t = {8}, {9}\nfor i = 2, n do\n\teig_pow_t[i] = (eig_pow_t[i - 1] * 8) % 1000000007\n\tnin_pow_t[i] = (nin_pow_t[i - 1] * 9) % 1000000007\nend\n\nfor i = 1, n do\n\tten_pow = (ten_pow * 10) % 1000000007\nend\nprint(ten_pow)\nfor i = 1, n do\n\tprint(eig_pow_t[i - 1], nin_pow_t[n - i])\n\tlocal num = nin_pow + ((eig_pow_t[i - 1] or 1) * (nin_pow_t[n - i] or 1)) % 1000000007\n\tnin_pow = num % 1000000007\nend\nprint(nin_pow)\nprint(eig_pow_t[n])\nlocal out = ((nin_pow * 2) % 1000000007 + eig_pow_t[n]) % 1000000007\nout = out < 0 and out + 1000000007 or out\nout = ten_pow - out < 0 and ten_pow - out + 1000000007 or ten_pow - out\nprint(out)\n", "language": "Lua", "metadata": {"date": 1600029569, "filename_ext": "lua", "original_language": "Lua (Lua 5.3.5)", "problem_description_relpath": "problem_descriptions/p02554.html", "problem_id": "p02554", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02554/input.txt", "sample_output_relpath": "derived/input_output/data/p02554/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02554/Lua/s863567214.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s863567214", "user_id": "u793881115"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "local n = io.read(\"n\")\n\n--nC1 * (n - 1)C1 10^(n - 2)\n\nif n == 1 then\n\tprint(0)\n\tos.exit()\nend\n\nlocal ten_pow, nin_pow = 1, 0\nlocal eig_pow_t, nin_pow_t = {8}, {9}\nfor i = 2, n do\n\teig_pow_t[i] = (eig_pow_t[i - 1] * 8) % 1000000007\n\tnin_pow_t[i] = (nin_pow_t[i - 1] * 9) % 1000000007\nend\n\nfor i = 1, n do\n\tten_pow = (ten_pow * 10) % 1000000007\nend\nprint(ten_pow)\nfor i = 1, n do\n\tprint(eig_pow_t[i - 1], nin_pow_t[n - i])\n\tlocal num = nin_pow + ((eig_pow_t[i - 1] or 1) * (nin_pow_t[n - i] or 1)) % 1000000007\n\tnin_pow = num % 1000000007\nend\nprint(nin_pow)\nprint(eig_pow_t[n])\nlocal out = ((nin_pow * 2) % 1000000007 + eig_pow_t[n]) % 1000000007\nout = out < 0 and out + 1000000007 or out\nout = ten_pow - out < 0 and ten_pow - out + 1000000007 or ten_pow - out\nprint(out)\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nHow many integer sequences A_1,A_2,\\ldots,A_N of length N satisfy all of the following conditions?\n\n0 \\leq A_i \\leq 9\n\nThere exists some i such that A_i=0 holds.\n\nThere exists some i such that A_i=9 holds.\n\nThe answer can be very large, so output it modulo 10^9 + 7.\n\nConstraints\n\n1 \\leq N \\leq 10^6\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the answer modulo 10^9 + 7.\n\nSample Input 1\n\n2\n\nSample Output 1\n\n2\n\nTwo sequences \\{0,9\\} and \\{9,0\\} satisfy all conditions.\n\nSample Input 2\n\n1\n\nSample Output 2\n\n0\n\nSample Input 3\n\n869121\n\nSample Output 3\n\n2511445", "sample_input": "2\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02554", "source_text": "Score : 300 points\n\nProblem Statement\n\nHow many integer sequences A_1,A_2,\\ldots,A_N of length N satisfy all of the following conditions?\n\n0 \\leq A_i \\leq 9\n\nThere exists some i such that A_i=0 holds.\n\nThere exists some i such that A_i=9 holds.\n\nThe answer can be very large, so output it modulo 10^9 + 7.\n\nConstraints\n\n1 \\leq N \\leq 10^6\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the answer modulo 10^9 + 7.\n\nSample Input 1\n\n2\n\nSample Output 1\n\n2\n\nTwo sequences \\{0,9\\} and \\{9,0\\} satisfy all conditions.\n\nSample Input 2\n\n1\n\nSample Output 2\n\n0\n\nSample Input 3\n\n869121\n\nSample Output 3\n\n2511445", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 770, "cpu_time_ms": 2235, "memory_kb": 142508}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s075418530", "group_id": "codeNet:p02556", "input_text": "local n=io.read(\"n\")\nlocal maxz=0\nlocal minz=10^10\nlocal maxw=0\nlocal minw=10^10\nfor i=1,n do\n local x,y=io.read(\"n\",\"n\")\n maxz=math.max(maxz,x+y)\n minz=math.min(minz,x+y)\n maxw=math.max(maxw,x-y)\n minw=math.min(minw,x-y)\nend\nprint(math.max(maxz-minz,maxw-minw))", "language": "Lua", "metadata": {"date": 1600321447, "filename_ext": "lua", "original_language": "Lua (Lua 5.3.5)", "problem_description_relpath": "problem_descriptions/p02556.html", "problem_id": "p02556", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02556/input.txt", "sample_output_relpath": "derived/input_output/data/p02556/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02556/Lua/s075418530.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s075418530", "user_id": "u045238009"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "local n=io.read(\"n\")\nlocal maxz=0\nlocal minz=10^10\nlocal maxw=0\nlocal minw=10^10\nfor i=1,n do\n local x,y=io.read(\"n\",\"n\")\n maxz=math.max(maxz,x+y)\n minz=math.min(minz,x+y)\n maxw=math.max(maxw,x-y)\n minw=math.min(minw,x-y)\nend\nprint(math.max(maxz-minz,maxw-minw))", "problem_context": "Score : 500 points\n\nProblem Statement\n\nThere are N points on the 2D plane, i-th of which is located on (x_i, y_i).\nThere can be multiple points that share the same coordinate.\nWhat is the maximum possible Manhattan distance between two distinct points?\n\nHere, the Manhattan distance between two points (x_i, y_i) and (x_j, y_j) is defined by |x_i-x_j| + |y_i-y_j|.\n\nConstraints\n\n2 \\leq N \\leq 2 \\times 10^5\n\n1 \\leq x_i,y_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nx_1 y_1\nx_2 y_2\n:\nx_N y_N\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n3\n1 1\n2 4\n3 2\n\nSample Output 1\n\n4\n\nThe Manhattan distance between the first point and the second point is |1-2|+|1-4|=4, which is maximum possible.\n\nSample Input 2\n\n2\n1 1\n1 1\n\nSample Output 2\n\n0", "sample_input": "3\n1 1\n2 4\n3 2\n"}, "reference_outputs": ["4\n"], "source_document_id": "p02556", "source_text": "Score : 500 points\n\nProblem Statement\n\nThere are N points on the 2D plane, i-th of which is located on (x_i, y_i).\nThere can be multiple points that share the same coordinate.\nWhat is the maximum possible Manhattan distance between two distinct points?\n\nHere, the Manhattan distance between two points (x_i, y_i) and (x_j, y_j) is defined by |x_i-x_j| + |y_i-y_j|.\n\nConstraints\n\n2 \\leq N \\leq 2 \\times 10^5\n\n1 \\leq x_i,y_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nx_1 y_1\nx_2 y_2\n:\nx_N y_N\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n3\n1 1\n2 4\n3 2\n\nSample Output 1\n\n4\n\nThe Manhattan distance between the first point and the second point is |1-2|+|1-4|=4, which is maximum possible.\n\nSample Input 2\n\n2\n1 1\n1 1\n\nSample Output 2\n\n0", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 277, "cpu_time_ms": 108, "memory_kb": 2792}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s828149740", "group_id": "codeNet:p02558", "input_text": "local n, q = io.read(\"*n\", \"*n\")\nlocal parent = {}\nfor i = 1, n do parent[i] = i end\n\nlocal function uf_findroot(idx)\n local idx_update = idx\n while parent[idx] ~= idx do\n idx = parent[idx]\n end\n while parent[idx_update] ~= idx do\n parent[idx_update], idx_update = idx, parent[idx_update]\n end\n return idx\nend\n\nfor i = 1, q do\n local t, u, v = io.read(\"*n\", \"*n\", \"*n\")\n local ru, rv = uf_findroot(u), uf_findroot(v)\n if t == 0 then\n parent[rv], parent[v] = ru, ru\n else\n print(ru == rv and 1 or 0)\n end\nend\n", "language": "Lua", "metadata": {"date": 1599516204, "filename_ext": "lua", "original_language": "Lua (Lua 5.3.5)", "problem_description_relpath": "problem_descriptions/p02558.html", "problem_id": "p02558", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02558/input.txt", "sample_output_relpath": "derived/input_output/data/p02558/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02558/Lua/s828149740.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s828149740", "user_id": "u120582723"}, "prompt_components": {"gold_output": "0\n1\n0\n1\n", "input_to_evaluate": "local n, q = io.read(\"*n\", \"*n\")\nlocal parent = {}\nfor i = 1, n do parent[i] = i end\n\nlocal function uf_findroot(idx)\n local idx_update = idx\n while parent[idx] ~= idx do\n idx = parent[idx]\n end\n while parent[idx_update] ~= idx do\n parent[idx_update], idx_update = idx, parent[idx_update]\n end\n return idx\nend\n\nfor i = 1, q do\n local t, u, v = io.read(\"*n\", \"*n\", \"*n\")\n local ru, rv = uf_findroot(u), uf_findroot(v)\n if t == 0 then\n parent[rv], parent[v] = ru, ru\n else\n print(ru == rv and 1 or 0)\n end\nend\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nYou are given an undirected graph with N vertices and 0 edges. Process Q queries of the following types.\n\n0 u v: Add an edge (u, v).\n\n1 u v: Print 1 if u and v are in the same connected component, 0 otherwise.\n\nConstraints\n\n1 \\leq N \\leq 200,000\n\n1 \\leq Q \\leq 200,000\n\n0 \\leq u_i, v_i \\lt N\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN Q\nt_1 u_1 v_1\nt_2 u_2 v_2\n:\nt_Q u_Q v_Q\n\n出力\n\nFor each query of the latter type, print the answer.\n\nSample Input 1\n\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\n\n0\n1\n0\n1", "sample_input": "4 7\n1 0 1\n0 0 1\n0 2 3\n1 0 1\n1 1 2\n0 0 2\n1 1 3\n"}, "reference_outputs": ["0\n1\n0\n1\n"], "source_document_id": "p02558", "source_text": "Score : 100 points\n\nProblem Statement\n\nYou are given an undirected graph with N vertices and 0 edges. Process Q queries of the following types.\n\n0 u v: Add an edge (u, v).\n\n1 u v: Print 1 if u and v are in the same connected component, 0 otherwise.\n\nConstraints\n\n1 \\leq N \\leq 200,000\n\n1 \\leq Q \\leq 200,000\n\n0 \\leq u_i, v_i \\lt N\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN Q\nt_1 u_1 v_1\nt_2 u_2 v_2\n:\nt_Q u_Q v_Q\n\n出力\n\nFor each query of the latter type, print the answer.\n\nSample Input 1\n\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\n\n0\n1\n0\n1", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 531, "cpu_time_ms": 219, "memory_kb": 6196}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s558046402", "group_id": "codeNet:p02561", "input_text": "-- Hopcroft-Karp\nHKmatch = {}\n\nHKmatch.create = function(self, an, bn)\n self.dst = {}\n self.edge = {}\n for i = 1, an do\n self.dst[i] = false\n self.edge[i] = {}\n end\n self.src = {}\n self.invcnt = {}\n self.invs = {}\n self.invpos = {}\n self.padded = {}\n for i = 1, bn do\n self.src[i] = false\n self.invs[i] = {}\n end\n self.p = {}\n self.tasks = {}\n self.level = {}\nend\n\nHKmatch.addEdge = function(self, a, b)\n table.insert(self.edge[a], b)\n if not self.dst[a] and not self.src[b] then\n self.dst[a] = b\n self.src[b] = a\n end\nend\n\nHKmatch.makeAugPath = function(self)\n local tasknum = 0\n local tasks = self.tasks\n local level = self.level\n local edge = self.edge\n local src = self.src\n local an = #self.dst\n local bn = #src\n local invcnt, invs = self.invcnt, self.invs\n local p, psize = self.p, 0\n local padded = self.padded\n local lvinf = an + 1\n for i = 1, an do\n if self.dst[i] then\n level[i] = lvinf\n else\n tasknum = tasknum + 1\n tasks[tasknum] = i\n level[i] = 1\n end\n end\n for i = 1, bn do\n invcnt[i] = 0\n padded[i] = false\n end\n local done = 0\n local lvmax = lvinf\n while done < tasknum do\n done = done + 1\n local a = tasks[done]\n if lvmax < level[a] then break end\n for i = 1, #edge[a] do\n local b = edge[a][i]\n local sb = src[b]\n if sb then\n if level[sb] == lvinf then\n tasknum = tasknum + 1\n tasks[tasknum] = sb\n level[sb] = level[a] + 1\n invcnt[b] = invcnt[b] + 1\n invs[b][invcnt[b]] = a\n elseif level[sb] == level[a] + 1 then\n invcnt[b] = invcnt[b] + 1\n invs[b][invcnt[b]] = a\n end\n else\n if lvmax == lvinf then\n lvmax = level[a]\n end\n if padded[b] then\n else\n padded[b] = true\n psize = psize + 1\n p[psize] = b\n end\n invcnt[b] = invcnt[b] + 1\n invs[b][invcnt[b]] = a\n end\n end\n end\n self.psize = psize\n return lvmax\nend\n\nHKmatch.dfs = function(self, b, lv)\n for i = 1, self.invcnt[b] do\n local a = self.invs[b][i]\n if self.level[a] == 1 or (self.level[a] == lv and self:dfs(self.dst[a], lv - 1)) then\n self.dst[a], self.src[b] = b, a\n self.level[a] = -1\n return true\n end\n end\nend\n\nHKmatch.restore = function(self, bend, lvend)\n local invs, invcnt, invpos = self.invs, self.invcnt, self.invpos\n local dst, src = self.dst, self.src\n local level = self.level\n local bn = #src\n for i = 1, bn do\n invpos[i] = 0\n end\n local accept = false\n local tasks = self.tasks\n local taskpos = 1\n tasks[1] = bend\n while 0 < taskpos do\n local b = tasks[taskpos]\n if accept then\n local a = invs[b][invpos[b]]\n dst[a], src[b] = b, a\n level[a] = -1\n taskpos = taskpos - 1\n else\n if invpos[b] == invcnt[b] then\n taskpos = taskpos - 1\n else\n local ip = invpos[b] + 1\n invpos[b] = ip\n local a = invs[b][ip]\n if level[a] == 1 then\n accept = true\n dst[a], src[b] = b, a\n level[a] = -1\n taskpos = taskpos - 1\n elseif level[a] + taskpos == lvend + 1 then\n taskpos = taskpos + 1\n tasks[taskpos] = dst[a]\n end\n -- if self.level[a] == 1 or (self.level[a] == lv and self:dfs(self.dst[a], lv - 1)) then\n -- self.dst[a], self.src[b] = b, a\n -- self.level[a] = -1\n -- return true\n -- end\n end\n end\n end\nend\n\nHKmatch.matching = function(self)\n local an = #self.dst\n local lv = self:makeAugPath()\n while lv <= an do\n for i = 1, self.psize do\n self:restore(self.p[i], lv)\n -- self:dfs(self.p[i], lv)\n end\n lv = self:makeAugPath()\n end\nend\n\nHKmatch.new = function(an, bn)\n local obj = {}\n setmetatable(obj, {__index = HKmatch})\n obj:create(an, bn)\n return obj\nend\n\nlocal h, w = io.read(\"*n\", \"*n\", \"*l\")\nlocal an, bn = 0, 0\nlocal as, bs = {}, {}\nlocal invidx = {}\nfor i = 1, h do\n for j = 1, w do\n local idx = (i - 1) * w + j\n if (i + j) % 2 == 0 then\n an = an + 1\n as[an] = idx\n invidx[idx] = an\n else\n bn = bn + 1\n bs[bn] = idx\n invidx[idx] = bn\n end\n end\nend\nlocal hkm = HKmatch.new(an, bn)\nlocal map = {}\nfor i = 1, h do\n local s = io.read()\n for j = 1, w do\n local idx = (i - 1) * w + j\n map[idx] = s:sub(j, j)\n end\nend\nfor i = 1, h - 1 do\n for j = 1, w do\n local idx = (i - 1) * w + j\n local isleft = (i + j) % 2 == 0\n if map[idx] == \".\" and map[idx + w] == \".\" then\n if isleft then\n hkm:addEdge(invidx[idx], invidx[idx + w])\n else\n hkm:addEdge(invidx[idx + w], invidx[idx])\n end\n end\n end\nend\nfor i = 1, h do\n for j = 1, w - 1 do\n local idx = (i - 1) * w + j\n local isleft = (i + j) % 2 == 0\n if map[idx] == \".\" and map[idx + 1] == \".\" then\n if isleft then\n hkm:addEdge(invidx[idx], invidx[idx + 1])\n else\n hkm:addEdge(invidx[idx + 1], invidx[idx])\n end\n end\n end\nend\nhkm:matching()\nlocal cnt = 0\nfor i = 1, an do\n local d = hkm.dst[i]\n if d then\n cnt = cnt + 1\n local l, r = as[i], bs[d]\n if l + w == r then\n map[l] = \"v\"\n map[r] = \"^\"\n elseif l - w == r then\n map[r] = \"v\"\n map[l] = \"^\"\n elseif l + 1 == r then\n map[l] = \">\"\n map[r] = \"<\"\n elseif l - 1 == r then\n map[l] = \"<\"\n map[r] = \">\"\n end\n end\nend\nprint(cnt)\nfor i = 1, h do\n for j = 1, w do\n io.write(map[(i - 1) * w + j])\n end\n io.write(\"\\n\")\nend\n", "language": "Lua", "metadata": {"date": 1600291937, "filename_ext": "lua", "original_language": "Lua (LuaJIT 2.1.0)", "problem_description_relpath": "problem_descriptions/p02561.html", "problem_id": "p02561", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02561/input.txt", "sample_output_relpath": "derived/input_output/data/p02561/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02561/Lua/s558046402.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s558046402", "user_id": "u120582723"}, "prompt_components": {"gold_output": "3\n#><\nvv#\n^^.\n", "input_to_evaluate": "-- Hopcroft-Karp\nHKmatch = {}\n\nHKmatch.create = function(self, an, bn)\n self.dst = {}\n self.edge = {}\n for i = 1, an do\n self.dst[i] = false\n self.edge[i] = {}\n end\n self.src = {}\n self.invcnt = {}\n self.invs = {}\n self.invpos = {}\n self.padded = {}\n for i = 1, bn do\n self.src[i] = false\n self.invs[i] = {}\n end\n self.p = {}\n self.tasks = {}\n self.level = {}\nend\n\nHKmatch.addEdge = function(self, a, b)\n table.insert(self.edge[a], b)\n if not self.dst[a] and not self.src[b] then\n self.dst[a] = b\n self.src[b] = a\n end\nend\n\nHKmatch.makeAugPath = function(self)\n local tasknum = 0\n local tasks = self.tasks\n local level = self.level\n local edge = self.edge\n local src = self.src\n local an = #self.dst\n local bn = #src\n local invcnt, invs = self.invcnt, self.invs\n local p, psize = self.p, 0\n local padded = self.padded\n local lvinf = an + 1\n for i = 1, an do\n if self.dst[i] then\n level[i] = lvinf\n else\n tasknum = tasknum + 1\n tasks[tasknum] = i\n level[i] = 1\n end\n end\n for i = 1, bn do\n invcnt[i] = 0\n padded[i] = false\n end\n local done = 0\n local lvmax = lvinf\n while done < tasknum do\n done = done + 1\n local a = tasks[done]\n if lvmax < level[a] then break end\n for i = 1, #edge[a] do\n local b = edge[a][i]\n local sb = src[b]\n if sb then\n if level[sb] == lvinf then\n tasknum = tasknum + 1\n tasks[tasknum] = sb\n level[sb] = level[a] + 1\n invcnt[b] = invcnt[b] + 1\n invs[b][invcnt[b]] = a\n elseif level[sb] == level[a] + 1 then\n invcnt[b] = invcnt[b] + 1\n invs[b][invcnt[b]] = a\n end\n else\n if lvmax == lvinf then\n lvmax = level[a]\n end\n if padded[b] then\n else\n padded[b] = true\n psize = psize + 1\n p[psize] = b\n end\n invcnt[b] = invcnt[b] + 1\n invs[b][invcnt[b]] = a\n end\n end\n end\n self.psize = psize\n return lvmax\nend\n\nHKmatch.dfs = function(self, b, lv)\n for i = 1, self.invcnt[b] do\n local a = self.invs[b][i]\n if self.level[a] == 1 or (self.level[a] == lv and self:dfs(self.dst[a], lv - 1)) then\n self.dst[a], self.src[b] = b, a\n self.level[a] = -1\n return true\n end\n end\nend\n\nHKmatch.restore = function(self, bend, lvend)\n local invs, invcnt, invpos = self.invs, self.invcnt, self.invpos\n local dst, src = self.dst, self.src\n local level = self.level\n local bn = #src\n for i = 1, bn do\n invpos[i] = 0\n end\n local accept = false\n local tasks = self.tasks\n local taskpos = 1\n tasks[1] = bend\n while 0 < taskpos do\n local b = tasks[taskpos]\n if accept then\n local a = invs[b][invpos[b]]\n dst[a], src[b] = b, a\n level[a] = -1\n taskpos = taskpos - 1\n else\n if invpos[b] == invcnt[b] then\n taskpos = taskpos - 1\n else\n local ip = invpos[b] + 1\n invpos[b] = ip\n local a = invs[b][ip]\n if level[a] == 1 then\n accept = true\n dst[a], src[b] = b, a\n level[a] = -1\n taskpos = taskpos - 1\n elseif level[a] + taskpos == lvend + 1 then\n taskpos = taskpos + 1\n tasks[taskpos] = dst[a]\n end\n -- if self.level[a] == 1 or (self.level[a] == lv and self:dfs(self.dst[a], lv - 1)) then\n -- self.dst[a], self.src[b] = b, a\n -- self.level[a] = -1\n -- return true\n -- end\n end\n end\n end\nend\n\nHKmatch.matching = function(self)\n local an = #self.dst\n local lv = self:makeAugPath()\n while lv <= an do\n for i = 1, self.psize do\n self:restore(self.p[i], lv)\n -- self:dfs(self.p[i], lv)\n end\n lv = self:makeAugPath()\n end\nend\n\nHKmatch.new = function(an, bn)\n local obj = {}\n setmetatable(obj, {__index = HKmatch})\n obj:create(an, bn)\n return obj\nend\n\nlocal h, w = io.read(\"*n\", \"*n\", \"*l\")\nlocal an, bn = 0, 0\nlocal as, bs = {}, {}\nlocal invidx = {}\nfor i = 1, h do\n for j = 1, w do\n local idx = (i - 1) * w + j\n if (i + j) % 2 == 0 then\n an = an + 1\n as[an] = idx\n invidx[idx] = an\n else\n bn = bn + 1\n bs[bn] = idx\n invidx[idx] = bn\n end\n end\nend\nlocal hkm = HKmatch.new(an, bn)\nlocal map = {}\nfor i = 1, h do\n local s = io.read()\n for j = 1, w do\n local idx = (i - 1) * w + j\n map[idx] = s:sub(j, j)\n end\nend\nfor i = 1, h - 1 do\n for j = 1, w do\n local idx = (i - 1) * w + j\n local isleft = (i + j) % 2 == 0\n if map[idx] == \".\" and map[idx + w] == \".\" then\n if isleft then\n hkm:addEdge(invidx[idx], invidx[idx + w])\n else\n hkm:addEdge(invidx[idx + w], invidx[idx])\n end\n end\n end\nend\nfor i = 1, h do\n for j = 1, w - 1 do\n local idx = (i - 1) * w + j\n local isleft = (i + j) % 2 == 0\n if map[idx] == \".\" and map[idx + 1] == \".\" then\n if isleft then\n hkm:addEdge(invidx[idx], invidx[idx + 1])\n else\n hkm:addEdge(invidx[idx + 1], invidx[idx])\n end\n end\n end\nend\nhkm:matching()\nlocal cnt = 0\nfor i = 1, an do\n local d = hkm.dst[i]\n if d then\n cnt = cnt + 1\n local l, r = as[i], bs[d]\n if l + w == r then\n map[l] = \"v\"\n map[r] = \"^\"\n elseif l - w == r then\n map[r] = \"v\"\n map[l] = \"^\"\n elseif l + 1 == r then\n map[l] = \">\"\n map[r] = \"<\"\n elseif l - 1 == r then\n map[l] = \"<\"\n map[r] = \">\"\n end\n end\nend\nprint(cnt)\nfor i = 1, h do\n for j = 1, w do\n io.write(map[(i - 1) * w + j])\n end\n io.write(\"\\n\")\nend\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nYou are given a grid of N rows and M columns. The square at the i-th row and j-th column will be denoted as (i,j).\nSome of the squares contain an object. All the remaining squares are empty.\nThe state of the grid is represented by strings S_1,S_2,\\cdots,S_N. The square (i,j) contains an object if S_{i,j}= # and is empty if S_{i,j}= ..\n\nConsider placing 1 \\times 2 tiles on the grid. Tiles can be placed vertically or horizontally to cover two adjacent empty squares.\nTiles must not stick out of the grid, and no two different tiles may intersect. Tiles cannot occupy the square with an object.\n\nCalculate the maximum number of tiles that can be placed and any configulation that acheives the maximum.\n\nConstraints\n\n1 \\leq N \\leq 100\n\n1 \\leq M \\leq 100\n\nS_i is a string with length M consists of # and ..\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nS_1\nS_2\n\\vdots\nS_N\n\nOutput\n\nOn the first line, print the maximum number of tiles that can be placed.\n\nOn the next N lines, print a configulation that achieves the maximum.\nPrecisely, output the strings t_1,t_2,\\cdots,t_N constructed by the following way.\n\nt_i is initialized to S_i.\n\nFor each (i,j), if there is a tile that occupies (i,j) and (i+1,j), change t_{i,j}:=v, t_{i+1,j}:=^.\n\nFor each (i,j), if there is a tile that occupies (i,j) and (i,j+1), change t_{i,j}:=>, t_{i,j+1}:=<.\n\nSee samples for further information.\n\nYou may print any configulation that maximizes the number of tiles.\n\nSample Input 1\n\n3 3\n#..\n..#\n...\n\nSample Output 1\n\n3\n#><\nvv#\n^^.\n\nThe following output is also treated as a correct answer.\n\n3\n#><\nv.#\n^><", "sample_input": "3 3\n#..\n..#\n...\n"}, "reference_outputs": ["3\n#><\nvv#\n^^.\n"], "source_document_id": "p02561", "source_text": "Score : 100 points\n\nProblem Statement\n\nYou are given a grid of N rows and M columns. The square at the i-th row and j-th column will be denoted as (i,j).\nSome of the squares contain an object. All the remaining squares are empty.\nThe state of the grid is represented by strings S_1,S_2,\\cdots,S_N. The square (i,j) contains an object if S_{i,j}= # and is empty if S_{i,j}= ..\n\nConsider placing 1 \\times 2 tiles on the grid. Tiles can be placed vertically or horizontally to cover two adjacent empty squares.\nTiles must not stick out of the grid, and no two different tiles may intersect. Tiles cannot occupy the square with an object.\n\nCalculate the maximum number of tiles that can be placed and any configulation that acheives the maximum.\n\nConstraints\n\n1 \\leq N \\leq 100\n\n1 \\leq M \\leq 100\n\nS_i is a string with length M consists of # and ..\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nS_1\nS_2\n\\vdots\nS_N\n\nOutput\n\nOn the first line, print the maximum number of tiles that can be placed.\n\nOn the next N lines, print a configulation that achieves the maximum.\nPrecisely, output the strings t_1,t_2,\\cdots,t_N constructed by the following way.\n\nt_i is initialized to S_i.\n\nFor each (i,j), if there is a tile that occupies (i,j) and (i+1,j), change t_{i,j}:=v, t_{i+1,j}:=^.\n\nFor each (i,j), if there is a tile that occupies (i,j) and (i,j+1), change t_{i,j}:=>, t_{i,j+1}:=<.\n\nSee samples for further information.\n\nYou may print any configulation that maximizes the number of tiles.\n\nSample Input 1\n\n3 3\n#..\n..#\n...\n\nSample Output 1\n\n3\n#><\nvv#\n^^.\n\nThe following output is also treated as a correct answer.\n\n3\n#><\nv.#\n^><", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 5548, "cpu_time_ms": 31, "memory_kb": 4384}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s704866679", "group_id": "codeNet:p02562", "input_text": "local mmi, mma = math.min, math.max\nlocal MinCostFlow = {}\n\nMinCostFlow.initialize = function(self, n, spos, tpos, inf)\n self.n = n\n self.spos, self.tpos = spos, tpos\n self.inf = inf\n -- edge_dst[src][i] := dst\n self.edge_dst = {}\n -- edge_cost[src][i] := cost from src to edge_dst[src][i]\n self.edge_cost = {}\n -- edge_cap[src][i] := capacity from src to edge_dst[src][i]\n self.edge_cap = {}\n -- initial capacity. corresponding to edge_cap\n self.edge_initialcap = {}\n -- edge_dst_invedge_idx[src][i] := \"j\" where edge_dst[dst][j] == src\n -- in this case, edge_dst_invedge_idx[dst][j] should be \"i\".\n self.edge_dst_invedge_idx = {}\n -- len[v] := length from spos. len[spos] := 0\n self.len = {}\n -- sub_graph_flag[v] := whether to contains the vertex v in the sub-graph or not\n self.sub_graph_flag = {}\n -- sub_graph_v[i] := list of vertexes that are contained in the sub-graph. from tpos to spos.\n self.sub_graph_v = {}\n -- sub_graph_edgeidx[i] := edge index from sub_graph_v[i + 1] to sub_graph_v[i]\n self.sub_graph_edgeidx = {}\n -- sub_graph_size := the size of sub_graph_v.\n -- may not equal to #sub_graph_v (because not cleared).\n self.sub_graph_size = 0\n for i = 1, n do\n self.edge_dst[i] = {}\n self.edge_cost[i] = {}\n self.edge_cap[i] = {}\n self.edge_initialcap[i] = {}\n self.edge_dst_invedge_idx[i] = {}\n self.len[i] = 0\n self.sub_graph_flag[i] = false\n end\nend\n\nMinCostFlow.addEdge = function(self, src, dst, cost, cap)\n table.insert(self.edge_dst[src], dst)\n table.insert(self.edge_cost[src], cost)\n table.insert(self.edge_cap[src], cap)\n table.insert(self.edge_initialcap[src], cap)\n table.insert(self.edge_dst_invedge_idx[src], 1 + #self.edge_dst[dst])\n table.insert(self.edge_dst[dst], src)\n table.insert(self.edge_cost[dst], -cost)\n table.insert(self.edge_cap[dst], 0)--invcap\n table.insert(self.edge_initialcap[dst], 0)--invcap\n table.insert(self.edge_dst_invedge_idx[dst], #self.edge_dst[src])\nend\nMinCostFlow.invwalk_recursive = function(self, invsrc)\n if invsrc == self.spos then return true end\n for i = 1, #self.edge_dst[invsrc] do\n local invdst = self.edge_dst[invsrc][i]\n local j = self.edge_dst_invedge_idx[invsrc][i]\n if 0 < self.edge_cap[invdst][j]\n and self.len[invdst] + self.edge_cost[invdst][j] == self.len[invsrc]\n and not self.sub_graph_flag[invdst] then\n self.sub_graph_size = self.sub_graph_size + 1\n self.sub_graph_v[self.sub_graph_size] = invdst\n self.sub_graph_edgeidx[self.sub_graph_size - 1] = j\n self.sub_graph_flag[invdst] = true\n\n if self:invwalk_recursive(invdst) then\n return true\n else\n -- self.sub_graph_flag[invdst] = false\n self.sub_graph_size = self.sub_graph_size - 1\n end\n end\n end\n return false\nend\n\nMinCostFlow.makeSubGraph = function(self)\n local inf = self.inf\n local len = self.len\n local n = self.n\n local edge_dst, edge_cap = self.edge_dst, self.edge_cap\n local edge_dst_invedge_idx = self.edge_dst_invedge_idx\n local edge_cost = self.edge_cost\n local sub_graph_v = self.sub_graph_v\n local sub_graph_edgeidx = self.sub_graph_edgeidx\n local sub_graph_flag = self.sub_graph_flag\n for i = 1, self.n do\n len[i] = inf\n sub_graph_flag[i] = false\n end\n -- Bellman-Ford\n local updated1, updated2 = {}, {}\n for i = 1, n do\n updated1[i] = true\n end\n len[self.spos] = 0\n for irp = 1, n do\n local updsrc = irp % 2 == 1 and updated1 or updated2\n local upddst = irp % 2 == 1 and updated2 or updated1\n for i = 1, n do\n upddst[i] = false\n end\n for src = 1, n do\n if updsrc[src] then\n local eddst, edcap, edcost = edge_dst[src], edge_cap[src], edge_cost[src]\n for i = 1, #eddst do\n if 0 < edcap[i] then\n local dst = eddst[i]\n local cost = edcost[i]\n if len[src] + cost < len[dst] then\n len[dst] = len[src] + cost\n upddst[dst] = true\n end\n end\n end\n end\n end\n end\n self.sub_graph_size = 0\n if inf <= len[self.tpos] then\n return 0\n end\n -- restore route (from tpos to spos)\n self.sub_graph_size = 1\n sub_graph_v[1] = self.tpos\n self:invwalk_recursive(self.tpos)\n local min_capacity = inf\n for i = self.sub_graph_size, 2, -1 do\n local src = sub_graph_v[i]\n local j = sub_graph_edgeidx[i - 1]\n min_capacity = mmi(min_capacity, edge_cap[src][j])\n end\n return min_capacity\nend\n\nMinCostFlow.flow = function(self, capacity)\n local edge_dst, edge_cap = self.edge_dst, self.edge_cap\n local edge_dst_invedge_idx = self.edge_dst_invedge_idx\n local sub_graph_v = self.sub_graph_v\n local sub_graph_edgeidx = self.sub_graph_edgeidx\n for i = self.sub_graph_size, 2, -1 do\n local src = sub_graph_v[i]\n local dst = sub_graph_v[i - 1]\n local j = sub_graph_edgeidx[i - 1]\n edge_cap[src][j] = edge_cap[src][j] - capacity\n local k = edge_dst_invedge_idx[src][j]\n edge_cap[dst][k] = edge_cap[dst][k] + capacity\n end\nend\n\nMinCostFlow.getMinCostFlow = function(self, amount, invalid)\n local ret = 0\n local cap = self:makeSubGraph()\n while 0 < cap do\n cap = mmi(amount, cap)\n ret = ret + self.len[self.tpos] * cap\n self:flow(cap)\n amount = amount - cap\n if 0 < amount then\n cap = self:makeSubGraph()\n else\n break\n end\n end\n if 0 < amount then return invalid end\n return ret\nend\n\nlocal n, k = io.read(\"*n\", \"*n\")\nlocal sp, tp = 2 * n + 1, 2 * n + 2\nMinCostFlow:initialize(tp, sp, tp, 1000000007 * 1000)\nfor i = 1, n do\n MinCostFlow:addEdge(sp, i, 0, k)\n MinCostFlow:addEdge(n + i, tp, 0, k)\nend\nMinCostFlow:addEdge(n * 2 + 1, n * 2 + 2, 0, n * k)\nfor i = 1, n do\n for j = 1, n do\n local a = io.read(\"*n\")\n MinCostFlow:addEdge(i, n + j, -a, 1)\n end\nend\nlocal amount = -MinCostFlow:getMinCostFlow(n * k)\namount = math.abs(amount) -- \"-0\" to \"0\"\nprint(amount)\nlocal used = {}\nfor i = 1, n * n do used[i] = false end\nfor row = 1, n do\n local edge = MinCostFlow.edge_dst[row]\n local cap = MinCostFlow.edge_cap[row]\n local initcap = MinCostFlow.edge_initialcap[row]\n for j = 1, #edge do\n local col = edge[j] - n\n if cap[j] < initcap[j] then\n used[(row - 1) * n + col] = true\n end\n end\nend\nfor i = 1, n do\n for j = 1, n do\n io.write(used[(i - 1) * n + j] and \"X\" or \".\")\n end\n io.write(\"\\n\")\nend\n", "language": "Lua", "metadata": {"date": 1599927705, "filename_ext": "lua", "original_language": "Lua (LuaJIT 2.1.0)", "problem_description_relpath": "problem_descriptions/p02562.html", "problem_id": "p02562", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02562/input.txt", "sample_output_relpath": "derived/input_output/data/p02562/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02562/Lua/s704866679.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s704866679", "user_id": "u120582723"}, "prompt_components": {"gold_output": "19\nX..\n..X\n.X.\n", "input_to_evaluate": "local mmi, mma = math.min, math.max\nlocal MinCostFlow = {}\n\nMinCostFlow.initialize = function(self, n, spos, tpos, inf)\n self.n = n\n self.spos, self.tpos = spos, tpos\n self.inf = inf\n -- edge_dst[src][i] := dst\n self.edge_dst = {}\n -- edge_cost[src][i] := cost from src to edge_dst[src][i]\n self.edge_cost = {}\n -- edge_cap[src][i] := capacity from src to edge_dst[src][i]\n self.edge_cap = {}\n -- initial capacity. corresponding to edge_cap\n self.edge_initialcap = {}\n -- edge_dst_invedge_idx[src][i] := \"j\" where edge_dst[dst][j] == src\n -- in this case, edge_dst_invedge_idx[dst][j] should be \"i\".\n self.edge_dst_invedge_idx = {}\n -- len[v] := length from spos. len[spos] := 0\n self.len = {}\n -- sub_graph_flag[v] := whether to contains the vertex v in the sub-graph or not\n self.sub_graph_flag = {}\n -- sub_graph_v[i] := list of vertexes that are contained in the sub-graph. from tpos to spos.\n self.sub_graph_v = {}\n -- sub_graph_edgeidx[i] := edge index from sub_graph_v[i + 1] to sub_graph_v[i]\n self.sub_graph_edgeidx = {}\n -- sub_graph_size := the size of sub_graph_v.\n -- may not equal to #sub_graph_v (because not cleared).\n self.sub_graph_size = 0\n for i = 1, n do\n self.edge_dst[i] = {}\n self.edge_cost[i] = {}\n self.edge_cap[i] = {}\n self.edge_initialcap[i] = {}\n self.edge_dst_invedge_idx[i] = {}\n self.len[i] = 0\n self.sub_graph_flag[i] = false\n end\nend\n\nMinCostFlow.addEdge = function(self, src, dst, cost, cap)\n table.insert(self.edge_dst[src], dst)\n table.insert(self.edge_cost[src], cost)\n table.insert(self.edge_cap[src], cap)\n table.insert(self.edge_initialcap[src], cap)\n table.insert(self.edge_dst_invedge_idx[src], 1 + #self.edge_dst[dst])\n table.insert(self.edge_dst[dst], src)\n table.insert(self.edge_cost[dst], -cost)\n table.insert(self.edge_cap[dst], 0)--invcap\n table.insert(self.edge_initialcap[dst], 0)--invcap\n table.insert(self.edge_dst_invedge_idx[dst], #self.edge_dst[src])\nend\nMinCostFlow.invwalk_recursive = function(self, invsrc)\n if invsrc == self.spos then return true end\n for i = 1, #self.edge_dst[invsrc] do\n local invdst = self.edge_dst[invsrc][i]\n local j = self.edge_dst_invedge_idx[invsrc][i]\n if 0 < self.edge_cap[invdst][j]\n and self.len[invdst] + self.edge_cost[invdst][j] == self.len[invsrc]\n and not self.sub_graph_flag[invdst] then\n self.sub_graph_size = self.sub_graph_size + 1\n self.sub_graph_v[self.sub_graph_size] = invdst\n self.sub_graph_edgeidx[self.sub_graph_size - 1] = j\n self.sub_graph_flag[invdst] = true\n\n if self:invwalk_recursive(invdst) then\n return true\n else\n -- self.sub_graph_flag[invdst] = false\n self.sub_graph_size = self.sub_graph_size - 1\n end\n end\n end\n return false\nend\n\nMinCostFlow.makeSubGraph = function(self)\n local inf = self.inf\n local len = self.len\n local n = self.n\n local edge_dst, edge_cap = self.edge_dst, self.edge_cap\n local edge_dst_invedge_idx = self.edge_dst_invedge_idx\n local edge_cost = self.edge_cost\n local sub_graph_v = self.sub_graph_v\n local sub_graph_edgeidx = self.sub_graph_edgeidx\n local sub_graph_flag = self.sub_graph_flag\n for i = 1, self.n do\n len[i] = inf\n sub_graph_flag[i] = false\n end\n -- Bellman-Ford\n local updated1, updated2 = {}, {}\n for i = 1, n do\n updated1[i] = true\n end\n len[self.spos] = 0\n for irp = 1, n do\n local updsrc = irp % 2 == 1 and updated1 or updated2\n local upddst = irp % 2 == 1 and updated2 or updated1\n for i = 1, n do\n upddst[i] = false\n end\n for src = 1, n do\n if updsrc[src] then\n local eddst, edcap, edcost = edge_dst[src], edge_cap[src], edge_cost[src]\n for i = 1, #eddst do\n if 0 < edcap[i] then\n local dst = eddst[i]\n local cost = edcost[i]\n if len[src] + cost < len[dst] then\n len[dst] = len[src] + cost\n upddst[dst] = true\n end\n end\n end\n end\n end\n end\n self.sub_graph_size = 0\n if inf <= len[self.tpos] then\n return 0\n end\n -- restore route (from tpos to spos)\n self.sub_graph_size = 1\n sub_graph_v[1] = self.tpos\n self:invwalk_recursive(self.tpos)\n local min_capacity = inf\n for i = self.sub_graph_size, 2, -1 do\n local src = sub_graph_v[i]\n local j = sub_graph_edgeidx[i - 1]\n min_capacity = mmi(min_capacity, edge_cap[src][j])\n end\n return min_capacity\nend\n\nMinCostFlow.flow = function(self, capacity)\n local edge_dst, edge_cap = self.edge_dst, self.edge_cap\n local edge_dst_invedge_idx = self.edge_dst_invedge_idx\n local sub_graph_v = self.sub_graph_v\n local sub_graph_edgeidx = self.sub_graph_edgeidx\n for i = self.sub_graph_size, 2, -1 do\n local src = sub_graph_v[i]\n local dst = sub_graph_v[i - 1]\n local j = sub_graph_edgeidx[i - 1]\n edge_cap[src][j] = edge_cap[src][j] - capacity\n local k = edge_dst_invedge_idx[src][j]\n edge_cap[dst][k] = edge_cap[dst][k] + capacity\n end\nend\n\nMinCostFlow.getMinCostFlow = function(self, amount, invalid)\n local ret = 0\n local cap = self:makeSubGraph()\n while 0 < cap do\n cap = mmi(amount, cap)\n ret = ret + self.len[self.tpos] * cap\n self:flow(cap)\n amount = amount - cap\n if 0 < amount then\n cap = self:makeSubGraph()\n else\n break\n end\n end\n if 0 < amount then return invalid end\n return ret\nend\n\nlocal n, k = io.read(\"*n\", \"*n\")\nlocal sp, tp = 2 * n + 1, 2 * n + 2\nMinCostFlow:initialize(tp, sp, tp, 1000000007 * 1000)\nfor i = 1, n do\n MinCostFlow:addEdge(sp, i, 0, k)\n MinCostFlow:addEdge(n + i, tp, 0, k)\nend\nMinCostFlow:addEdge(n * 2 + 1, n * 2 + 2, 0, n * k)\nfor i = 1, n do\n for j = 1, n do\n local a = io.read(\"*n\")\n MinCostFlow:addEdge(i, n + j, -a, 1)\n end\nend\nlocal amount = -MinCostFlow:getMinCostFlow(n * k)\namount = math.abs(amount) -- \"-0\" to \"0\"\nprint(amount)\nlocal used = {}\nfor i = 1, n * n do used[i] = false end\nfor row = 1, n do\n local edge = MinCostFlow.edge_dst[row]\n local cap = MinCostFlow.edge_cap[row]\n local initcap = MinCostFlow.edge_initialcap[row]\n for j = 1, #edge do\n local col = edge[j] - n\n if cap[j] < initcap[j] then\n used[(row - 1) * n + col] = true\n end\n end\nend\nfor i = 1, n do\n for j = 1, n do\n io.write(used[(i - 1) * n + j] and \"X\" or \".\")\n end\n io.write(\"\\n\")\nend\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nYou are given a grid of N rows and M columns. The square at the i-th row and j-th column will be denoted as (i,j).\nA nonnegative integer A_{i,j} is written for each square (i,j).\n\nYou choose some of the squares so that each row and column contains at most K chosen squares.\nUnder this constraint, calculate the maximum value of the sum of the integers written on the chosen squares.\nAdditionally, calculate a way to choose squares that acheives the maximum.\n\nConstraints\n\n1 \\leq N \\leq 50\n\n1 \\leq K \\leq N\n\n0 \\leq A_{i,j} \\leq 10^9\n\nAll values in Input are integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nA_{1,1} A_{1,2} \\cdots A_{1,N}\nA_{2,1} A_{2,2} \\cdots A_{2,N}\n\\vdots\nA_{N,1} A_{N,2} \\cdots A_{N,N}\n\nOutput\n\nOn the first line, print the maximum value of the sum of the integers written on the chosen squares.\n\nOn the next N lines, print a way that achieves the maximum.\n\nPrecisely, output the strings t_1,t_2,\\cdots,t_N, that satisfies t_{i,j}=X if you choose (i,j) and t_{i,j}=. otherwise.\n\nYou may print any way to choose squares that maximizes the sum.\n\nSample Input 1\n\n3 1\n5 3 2\n1 4 8\n7 6 9\n\nSample Output 1\n\n19\nX..\n..X\n.X.\n\nSample Input 2\n\n3 2\n10 10 1\n10 10 1\n1 1 10\n\nSample Output 2\n\n50\nXX.\nXX.\n..X", "sample_input": "3 1\n5 3 2\n1 4 8\n7 6 9\n"}, "reference_outputs": ["19\nX..\n..X\n.X.\n"], "source_document_id": "p02562", "source_text": "Score : 100 points\n\nProblem Statement\n\nYou are given a grid of N rows and M columns. The square at the i-th row and j-th column will be denoted as (i,j).\nA nonnegative integer A_{i,j} is written for each square (i,j).\n\nYou choose some of the squares so that each row and column contains at most K chosen squares.\nUnder this constraint, calculate the maximum value of the sum of the integers written on the chosen squares.\nAdditionally, calculate a way to choose squares that acheives the maximum.\n\nConstraints\n\n1 \\leq N \\leq 50\n\n1 \\leq K \\leq N\n\n0 \\leq A_{i,j} \\leq 10^9\n\nAll values in Input are integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nA_{1,1} A_{1,2} \\cdots A_{1,N}\nA_{2,1} A_{2,2} \\cdots A_{2,N}\n\\vdots\nA_{N,1} A_{N,2} \\cdots A_{N,N}\n\nOutput\n\nOn the first line, print the maximum value of the sum of the integers written on the chosen squares.\n\nOn the next N lines, print a way that achieves the maximum.\n\nPrecisely, output the strings t_1,t_2,\\cdots,t_N, that satisfies t_{i,j}=X if you choose (i,j) and t_{i,j}=. otherwise.\n\nYou may print any way to choose squares that maximizes the sum.\n\nSample Input 1\n\n3 1\n5 3 2\n1 4 8\n7 6 9\n\nSample Output 1\n\n19\nX..\n..X\n.X.\n\nSample Input 2\n\n3 2\n10 10 1\n10 10 1\n1 1 10\n\nSample Output 2\n\n50\nXX.\nXX.\n..X", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 6325, "cpu_time_ms": 437, "memory_kb": 3508}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s372159608", "group_id": "codeNet:p02563", "input_text": "local mfl = math.floor\nlocal TranFFT = {}\n\nTranFFT.initialize = function(self)\n self.size = 20\n self.n = 1048576\n self.mod = 998244353\n self.w = 646\n self.ninv = 998243401\n self.winv = 208611436\n self.p2 = {1}\n for i = 2, self.size do\n self.p2[i] = self.p2[i - 1] * 2\n end\n self.binv = {}\n for i = 1, self.n do\n local y, z = 0, i - 1\n for j = 1, self.size do\n y = y + (z % 2) * self.p2[self.size + 1 - j]\n z = mfl(z / 2)\n end\n self.binv[i] = y + 1\n end\n self.wmul = {1}\n for i = 2, self.n do\n self.wmul[i] = self:mul(self.wmul[i - 1], self.w)\n end\n self.winvmul = {1}\n for i = 2, self.n do\n self.winvmul[i] = self:mul(self.winvmul[i - 1], self.winv)\n end\nend\n\nTranFFT.mul = function(self, x, y)\n local x0, y0 = x % 31596, y % 31596\n local x1, y1 = mfl(x / 31596), mfl(y / 31596)\n return (x1 * y1 * 62863 + (x1 * y0 + x0 * y1) * 31596 + x0 * y0) % self.mod\nend\n\nTranFFT.add = function(self, x, y) return (x + y) % self.mod end\n\nTranFFT.fft_common = function(self, ary, wmul)\n local ret = {}\n for i = 1, self.n do\n ret[i] = ary[self.binv[i]]\n end\n for i = 1, self.size do\n local step_size = self.p2[i]\n local step_count = self.p2[self.size + 1 - i]\n for istep = 1, step_count do\n local ofst = (istep - 1) * step_size * 2\n for j = 1, step_size do\n local a1, a2 = ret[ofst + j], ret[ofst + step_size + j]\n ret[ofst + j] = self:add(a1, self:mul(a2, wmul[1 + (j - 1) * step_count]))\n ret[ofst + step_size + j] = self:add(a1, self:mul(a2, wmul[1 + (j + step_size - 1) * step_count]))\n end\n end\n end\n return ret\nend\n\nTranFFT.fft = function(self, ary)\n return self:fft_common(ary, self.wmul)\nend\nTranFFT.ifft = function(self, ary)\n local ret = self:fft_common(ary, self.winvmul)\n for i = 1, self.n do\n ret[i] = self:mul(ret[i], self.ninv)\n end\n return ret\nend\n\n-- sample (ATC001-C)\nTranFFT:initialize()\nlocal a, b = {}, {}\nlocal n, m = io.read(\"*n\", \"*n\")\nfor i = 1, TranFFT.n do\n a[i] = 0\n b[i] = 0\nend\nfor i = 1, n do\n a[i] = io.read(\"*n\")\nend\nfor i = 1, m do\n b[i] = io.read(\"*n\")\nend\n\nlocal at = TranFFT:fft(a)\nlocal bt = TranFFT:fft(b)\nfor i = 1, TranFFT.n do\n at[i] = TranFFT:mul(at[i], bt[i])\nend\nlocal c = TranFFT:ifft(at)\nfor i = 1, n + m - 1 do\n io.write(c[i])\n io.write(i == n + m - 1 and \"\\n\" or \" \")\nend\n", "language": "Lua", "metadata": {"date": 1599600046, "filename_ext": "lua", "original_language": "Lua (LuaJIT 2.1.0)", "problem_description_relpath": "problem_descriptions/p02563.html", "problem_id": "p02563", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02563/input.txt", "sample_output_relpath": "derived/input_output/data/p02563/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02563/Lua/s372159608.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s372159608", "user_id": "u120582723"}, "prompt_components": {"gold_output": "5 16 34 60 70 70 59 36\n", "input_to_evaluate": "local mfl = math.floor\nlocal TranFFT = {}\n\nTranFFT.initialize = function(self)\n self.size = 20\n self.n = 1048576\n self.mod = 998244353\n self.w = 646\n self.ninv = 998243401\n self.winv = 208611436\n self.p2 = {1}\n for i = 2, self.size do\n self.p2[i] = self.p2[i - 1] * 2\n end\n self.binv = {}\n for i = 1, self.n do\n local y, z = 0, i - 1\n for j = 1, self.size do\n y = y + (z % 2) * self.p2[self.size + 1 - j]\n z = mfl(z / 2)\n end\n self.binv[i] = y + 1\n end\n self.wmul = {1}\n for i = 2, self.n do\n self.wmul[i] = self:mul(self.wmul[i - 1], self.w)\n end\n self.winvmul = {1}\n for i = 2, self.n do\n self.winvmul[i] = self:mul(self.winvmul[i - 1], self.winv)\n end\nend\n\nTranFFT.mul = function(self, x, y)\n local x0, y0 = x % 31596, y % 31596\n local x1, y1 = mfl(x / 31596), mfl(y / 31596)\n return (x1 * y1 * 62863 + (x1 * y0 + x0 * y1) * 31596 + x0 * y0) % self.mod\nend\n\nTranFFT.add = function(self, x, y) return (x + y) % self.mod end\n\nTranFFT.fft_common = function(self, ary, wmul)\n local ret = {}\n for i = 1, self.n do\n ret[i] = ary[self.binv[i]]\n end\n for i = 1, self.size do\n local step_size = self.p2[i]\n local step_count = self.p2[self.size + 1 - i]\n for istep = 1, step_count do\n local ofst = (istep - 1) * step_size * 2\n for j = 1, step_size do\n local a1, a2 = ret[ofst + j], ret[ofst + step_size + j]\n ret[ofst + j] = self:add(a1, self:mul(a2, wmul[1 + (j - 1) * step_count]))\n ret[ofst + step_size + j] = self:add(a1, self:mul(a2, wmul[1 + (j + step_size - 1) * step_count]))\n end\n end\n end\n return ret\nend\n\nTranFFT.fft = function(self, ary)\n return self:fft_common(ary, self.wmul)\nend\nTranFFT.ifft = function(self, ary)\n local ret = self:fft_common(ary, self.winvmul)\n for i = 1, self.n do\n ret[i] = self:mul(ret[i], self.ninv)\n end\n return ret\nend\n\n-- sample (ATC001-C)\nTranFFT:initialize()\nlocal a, b = {}, {}\nlocal n, m = io.read(\"*n\", \"*n\")\nfor i = 1, TranFFT.n do\n a[i] = 0\n b[i] = 0\nend\nfor i = 1, n do\n a[i] = io.read(\"*n\")\nend\nfor i = 1, m do\n b[i] = io.read(\"*n\")\nend\n\nlocal at = TranFFT:fft(a)\nlocal bt = TranFFT:fft(b)\nfor i = 1, TranFFT.n do\n at[i] = TranFFT:mul(at[i], bt[i])\nend\nlocal c = TranFFT:ifft(at)\nfor i = 1, n + m - 1 do\n io.write(c[i])\n io.write(i == n + m - 1 and \"\\n\" or \" \")\nend\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nYou are given two integer arrays a_0, a_1, ..., a_{N - 1} and b_0, b_1, ..., b_{M - 1}. Calculate the array c_0, c_1, ..., c_{(N - 1) + (M - 1)}, defined by c_i = \\sum_{j = 0}^i a_j b_{i - j} \\bmod 998244353.\n\nConstraints\n\n1 \\leq N, M \\leq 524288\n\n0 \\leq a_i, b_i < 998244353\n\nAll values in Input are integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\na_0 a_1 ... a_{N-1}\nb_0 b_1 ... b_{M-1}\n\nOutput\n\nPrint the answer in the following format:\n\nc_0 c_1 ... c_{(N - 1) + (M - 1)}\n\nSample Input 1\n\n4 5\n1 2 3 4\n5 6 7 8 9\n\nSample Output 1\n\n5 16 34 60 70 70 59 36\n\nSample Input 2\n\n1 1\n10000000\n10000000\n\nSample Output 2\n\n871938225", "sample_input": "4 5\n1 2 3 4\n5 6 7 8 9\n"}, "reference_outputs": ["5 16 34 60 70 70 59 36\n"], "source_document_id": "p02563", "source_text": "Score : 100 points\n\nProblem Statement\n\nYou are given two integer arrays a_0, a_1, ..., a_{N - 1} and b_0, b_1, ..., b_{M - 1}. Calculate the array c_0, c_1, ..., c_{(N - 1) + (M - 1)}, defined by c_i = \\sum_{j = 0}^i a_j b_{i - j} \\bmod 998244353.\n\nConstraints\n\n1 \\leq N, M \\leq 524288\n\n0 \\leq a_i, b_i < 998244353\n\nAll values in Input are integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\na_0 a_1 ... a_{N-1}\nb_0 b_1 ... b_{M-1}\n\nOutput\n\nPrint the answer in the following format:\n\nc_0 c_1 ... c_{(N - 1) + (M - 1)}\n\nSample Input 1\n\n4 5\n1 2 3 4\n5 6 7 8 9\n\nSample Output 1\n\n5 16 34 60 70 70 59 36\n\nSample Input 2\n\n1 1\n10000000\n10000000\n\nSample Output 2\n\n871938225", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2332, "cpu_time_ms": 1962, "memory_kb": 121652}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s216560543", "group_id": "codeNet:p02564", "input_text": "-- Strongly Connected Component Decomposition\nlocal n, m = io.read(\"*n\", \"*n\")\nlocal edge = {}\nlocal edge_asked = {}\nlocal invedge = {}\nlocal invedge_asked = {}\nfor i = 1, n do\n edge[i] = {}\n edge_asked[i] = 0\n invedge[i] = {}\n invedge_asked[i] = 0\nend\nlocal edgeinfo = {}\nfor i = 1, m do\n local a, b = io.read(\"*n\", \"*n\")\n a, b = a + 1, b + 1\n edgeinfo[i] = {a, b}\n table.insert(edge[a], b)\n table.insert(invedge[b], a)\nend\n\nlocal asked = {}\nlocal sccd_root = {}\nfor i = 1, n do\n asked[i] = false\n sccd_root[i] = 0\nend\n\nlocal function SCCD_dfs(spos, dfs_way)\n local tasks = {spos}\n while 0 < #tasks do\n local src = tasks[#tasks]\n asked[src] = true\n table.remove(tasks)\n if edge_asked[src] == #edge[src] then\n table.insert(dfs_way, src)\n else\n table.insert(tasks, src)\n edge_asked[src] = edge_asked[src] + 1\n local dst = edge[src][edge_asked[src]]\n if not asked[dst] then\n table.insert(tasks, dst)\n end\n end\n end\nend\n\nlocal function SCCD_invdfs(spos, rootid)\n local tasks = {spos}\n while 0 < #tasks do\n local src = tasks[#tasks]\n sccd_root[src] = rootid\n table.remove(tasks)\n while invedge_asked[src] < #invedge[src] do\n invedge_asked[src] = invedge_asked[src] + 1\n local dst = invedge[src][invedge_asked[src]]\n if asked[dst] and sccd_root[dst] == 0 then\n table.insert(tasks, src)\n table.insert(tasks, dst)\n break\n end\n end\n end\nend\n\nlocal function SCCD_make()\n for src = 1, n do\n if not asked[src] then\n local dfs_way = {}\n SCCD_dfs(src, dfs_way)\n for i = #dfs_way, 1, -1 do\n local src = dfs_way[i]\n if sccd_root[src] == 0 then\n SCCD_invdfs(src, src)\n end\n end\n end\n end\nend\n\nSCCD_make()\n\nlocal gsize = {}\nlocal gedge, ginvedge = {}, {}\nlocal glen = {}\nlocal gmember = {}\nfor i = 1, n do\n gsize[i] = 0\n gedge[i], ginvedge[i] = {}, {}\n glen[i] = 0\n gmember[i] = {}\nend\nfor i = 1, n do\n local r = sccd_root[i]\n gsize[r] = gsize[r] + 1\n table.insert(gmember[r], i)\nend\nfor i = 1, m do\n local a, b = edgeinfo[i][1], edgeinfo[i][2]\n local ra, rb = sccd_root[a], sccd_root[b]\n if ra ~= rb then\n table.insert(gedge[ra], rb)\n table.insert(ginvedge[rb], ra)\n end\nend\nlocal topo_tasks = {}\nlocal topo_asked_cnt = {}\nlocal retcnt = 0\nfor i = 1, n do\n topo_asked_cnt[i] = 0\n if 0 < gsize[i] then retcnt = retcnt + 1 end\n if 0 < gsize[i] and #ginvedge[i] == 0 then\n table.insert(topo_tasks, i)\n end\nend\nprint(retcnt)\nlocal topo_done = 0\nwhile topo_done < #topo_tasks do\n topo_done = topo_done + 1\n local g = topo_tasks[topo_done]\n io.write(#gmember[g])\n for i = 1, #gmember[g] do\n io.write(\" \" .. gmember[g][i] - 1)\n end\n io.write(\"\\n\")\n for i = 1, #gedge[g] do\n local dst = gedge[g][i]\n topo_asked_cnt[dst] = topo_asked_cnt[dst] + 1\n if topo_asked_cnt[dst] == #ginvedge[dst] then\n table.insert(topo_tasks, dst)\n end\n end\nend\n", "language": "Lua", "metadata": {"date": 1599549789, "filename_ext": "lua", "original_language": "Lua (LuaJIT 2.1.0)", "problem_description_relpath": "problem_descriptions/p02564.html", "problem_id": "p02564", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02564/input.txt", "sample_output_relpath": "derived/input_output/data/p02564/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02564/Lua/s216560543.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s216560543", "user_id": "u120582723"}, "prompt_components": {"gold_output": "4\n1 5\n2 4 1\n1 2\n2 3 0\n", "input_to_evaluate": "-- Strongly Connected Component Decomposition\nlocal n, m = io.read(\"*n\", \"*n\")\nlocal edge = {}\nlocal edge_asked = {}\nlocal invedge = {}\nlocal invedge_asked = {}\nfor i = 1, n do\n edge[i] = {}\n edge_asked[i] = 0\n invedge[i] = {}\n invedge_asked[i] = 0\nend\nlocal edgeinfo = {}\nfor i = 1, m do\n local a, b = io.read(\"*n\", \"*n\")\n a, b = a + 1, b + 1\n edgeinfo[i] = {a, b}\n table.insert(edge[a], b)\n table.insert(invedge[b], a)\nend\n\nlocal asked = {}\nlocal sccd_root = {}\nfor i = 1, n do\n asked[i] = false\n sccd_root[i] = 0\nend\n\nlocal function SCCD_dfs(spos, dfs_way)\n local tasks = {spos}\n while 0 < #tasks do\n local src = tasks[#tasks]\n asked[src] = true\n table.remove(tasks)\n if edge_asked[src] == #edge[src] then\n table.insert(dfs_way, src)\n else\n table.insert(tasks, src)\n edge_asked[src] = edge_asked[src] + 1\n local dst = edge[src][edge_asked[src]]\n if not asked[dst] then\n table.insert(tasks, dst)\n end\n end\n end\nend\n\nlocal function SCCD_invdfs(spos, rootid)\n local tasks = {spos}\n while 0 < #tasks do\n local src = tasks[#tasks]\n sccd_root[src] = rootid\n table.remove(tasks)\n while invedge_asked[src] < #invedge[src] do\n invedge_asked[src] = invedge_asked[src] + 1\n local dst = invedge[src][invedge_asked[src]]\n if asked[dst] and sccd_root[dst] == 0 then\n table.insert(tasks, src)\n table.insert(tasks, dst)\n break\n end\n end\n end\nend\n\nlocal function SCCD_make()\n for src = 1, n do\n if not asked[src] then\n local dfs_way = {}\n SCCD_dfs(src, dfs_way)\n for i = #dfs_way, 1, -1 do\n local src = dfs_way[i]\n if sccd_root[src] == 0 then\n SCCD_invdfs(src, src)\n end\n end\n end\n end\nend\n\nSCCD_make()\n\nlocal gsize = {}\nlocal gedge, ginvedge = {}, {}\nlocal glen = {}\nlocal gmember = {}\nfor i = 1, n do\n gsize[i] = 0\n gedge[i], ginvedge[i] = {}, {}\n glen[i] = 0\n gmember[i] = {}\nend\nfor i = 1, n do\n local r = sccd_root[i]\n gsize[r] = gsize[r] + 1\n table.insert(gmember[r], i)\nend\nfor i = 1, m do\n local a, b = edgeinfo[i][1], edgeinfo[i][2]\n local ra, rb = sccd_root[a], sccd_root[b]\n if ra ~= rb then\n table.insert(gedge[ra], rb)\n table.insert(ginvedge[rb], ra)\n end\nend\nlocal topo_tasks = {}\nlocal topo_asked_cnt = {}\nlocal retcnt = 0\nfor i = 1, n do\n topo_asked_cnt[i] = 0\n if 0 < gsize[i] then retcnt = retcnt + 1 end\n if 0 < gsize[i] and #ginvedge[i] == 0 then\n table.insert(topo_tasks, i)\n end\nend\nprint(retcnt)\nlocal topo_done = 0\nwhile topo_done < #topo_tasks do\n topo_done = topo_done + 1\n local g = topo_tasks[topo_done]\n io.write(#gmember[g])\n for i = 1, #gmember[g] do\n io.write(\" \" .. gmember[g][i] - 1)\n end\n io.write(\"\\n\")\n for i = 1, #gedge[g] do\n local dst = gedge[g][i]\n topo_asked_cnt[dst] = topo_asked_cnt[dst] + 1\n if topo_asked_cnt[dst] == #ginvedge[dst] then\n table.insert(topo_tasks, dst)\n end\n end\nend\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nYou are given a directed graph with N vertices and M edges, not necessarily simple. The i-th edge is oriented from the vertex a_i to the vertex b_i.\nDivide this graph into strongly connected components and print them in their topological order.\n\nConstraints\n\n1 \\leq N \\leq 500,000\n\n1 \\leq M \\leq 500,000\n\n0 \\leq a_i, b_i < N\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\na_0 b_0\na_1 b_1\n:\na_{M - 1} b_{M - 1}\n\nOutput\n\nPrint 1+K lines, where K is the number of strongly connected components.\nPrint K on the first line.\nPrint the information of each strongly connected component in next K lines in the following format, where l is the number of vertices in the strongly connected component and v_i is the index of the vertex in it.\n\nl v_0 v_1 ... v_{l-1}\n\nHere, for each edge (a_i, b_i), b_i should not appear in earlier line than a_i.\n\nIf there are multiple correct output, print any of them.\n\nSample Input 1\n\n6 7\n1 4\n5 2\n3 0\n5 5\n4 1\n0 3\n4 2\n\nSample Output 1\n\n4\n1 5\n2 4 1\n1 2\n2 3 0", "sample_input": "6 7\n1 4\n5 2\n3 0\n5 5\n4 1\n0 3\n4 2\n"}, "reference_outputs": ["4\n1 5\n2 4 1\n1 2\n2 3 0\n"], "source_document_id": "p02564", "source_text": "Score : 100 points\n\nProblem Statement\n\nYou are given a directed graph with N vertices and M edges, not necessarily simple. The i-th edge is oriented from the vertex a_i to the vertex b_i.\nDivide this graph into strongly connected components and print them in their topological order.\n\nConstraints\n\n1 \\leq N \\leq 500,000\n\n1 \\leq M \\leq 500,000\n\n0 \\leq a_i, b_i < N\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\na_0 b_0\na_1 b_1\n:\na_{M - 1} b_{M - 1}\n\nOutput\n\nPrint 1+K lines, where K is the number of strongly connected components.\nPrint K on the first line.\nPrint the information of each strongly connected component in next K lines in the following format, where l is the number of vertices in the strongly connected component and v_i is the index of the vertex in it.\n\nl v_0 v_1 ... v_{l-1}\n\nHere, for each edge (a_i, b_i), b_i should not appear in earlier line than a_i.\n\nIf there are multiple correct output, print any of them.\n\nSample Input 1\n\n6 7\n1 4\n5 2\n3 0\n5 5\n4 1\n0 3\n4 2\n\nSample Output 1\n\n4\n1 5\n2 4 1\n1 2\n2 3 0", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2952, "cpu_time_ms": 2870, "memory_kb": 318332}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s190635662", "group_id": "codeNet:p02567", "input_text": "local mfl, mce = math.floor, math.ceil\nlocal mmi, mma = math.min, math.max\nlocal bls, brs = bit.lshift, bit.rshift\nlocal SegTree = {}\nSegTree.updateAll = function(self)\n for i = self.stagenum - 1, 1, -1 do\n local cnt = bls(1, i - 1)\n for j = 1, cnt do\n self.stage[i][j] = self.func(self.stage[i + 1][j * 2 - 1], self.stage[i + 1][j * 2])\n end\n end\nend\nSegTree.create = function(self, n, func, emptyvalue)\n self.func, self.emptyvalue = func, emptyvalue\n local stagenum, mul = 1, 1\n self.stage = {{}}\n while mul < n do\n mul, stagenum = mul * 2, stagenum + 1\n self.stage[stagenum] = {}\n end\n self.stagenum = stagenum\n self.left_stage = {}\n for i = 1, n do\n local sp, sz = 1, bls(1, stagenum - 1)\n while(i - 1) % sz ~= 0 do\n sp, sz = sp + 1, brs(sz, 1)\n end\n self.left_stage[i] = sp\n end\n self.sz_stage = {}\n local tmp, sp = 1, stagenum\n for i = 1, n do\n if tmp * 2 == i then tmp, sp = tmp * 2, sp - 1 end\n self.sz_stage[i] = sp\n end\n for i = 1, mul do self.stage[stagenum][i] = emptyvalue end\n self:updateAll()\nend\nSegTree.getRange = function(self, left, right)\n if left == right then return self.stage[self.stagenum][left] end\n local stagenum = self.stagenum\n local ret = self.emptyvalue\n while left <= right do\n local stage = mma(self.left_stage[left], self.sz_stage[right - left + 1])\n local sz = bls(1, stagenum - stage)\n ret = self.func(ret, self.stage[stage][1 + brs(left - 1, stagenum - stage)])\n left = left + sz\n end\n return ret\nend\nSegTree.update = function(self, idx)\n for i = self.stagenum - 1, 1, -1 do\n local dst = brs(idx + 1, 1)\n local rem = dst * 4 - 1 - idx\n self.stage[i][dst] = self.func(self.stage[i + 1][idx], self.stage[i + 1][rem])\n idx = dst\n end\nend\nSegTree.setValue = function(self, idx, value, silent)\n self.stage[self.stagenum][idx] = value\n if not silent then\n self:update(idx)\n end\nend\n\nSegTree.right_bound = function(self, val, left, right)\n local ret, retpos = self.emptyvalue, left - 1\n local l, r = left, right\n local stage = mma(self.left_stage[left], self.sz_stage[right - left + 1])\n local stagenum = self.stagenum\n while true do\n local sz = bls(1, stagenum - stage)\n local tmp = self.func(ret, self.stage[stage][mce(l / sz)])\n if tmp < val then\n ret, retpos = tmp, l + sz - 1\n if retpos == right then break end\n if l + sz <= r then\n l = l + sz\n stage = mma(self.left_stage[l], self.sz_stage[r - l + 1])\n else break end\n else\n if sz ~= 1 then stage, r = stage + 1, l + sz - 2\n else break end\n end\n end\n return retpos + 1\nend\n\nSegTree.new = function(n, func, emptyvalue)\n local obj = {}\n setmetatable(obj, {__index = SegTree})\n obj:create(n, func, emptyvalue)\n return obj\nend\n\nlocal n, q = io.read(\"*n\", \"*n\")\nlocal st = SegTree.new(n, mma, -1)\nfor i = 1, n do\n local a = io.read(\"*n\")\n st:setValue(i, a, true)\nend\nst:updateAll()\nfor iq = 1, q do\n local a, b, c = io.read(\"*n\", \"*n\", \"*n\")\n if a == 1 then\n st:setValue(b, c)\n elseif a == 2 then\n print(st:getRange(b, c))\n else\n print(st:right_bound(c, b, n))\n end\nend\n", "language": "Lua", "metadata": {"date": 1599600465, "filename_ext": "lua", "original_language": "Lua (LuaJIT 2.1.0)", "problem_description_relpath": "problem_descriptions/p02567.html", "problem_id": "p02567", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02567/input.txt", "sample_output_relpath": "derived/input_output/data/p02567/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02567/Lua/s190635662.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s190635662", "user_id": "u120582723"}, "prompt_components": {"gold_output": "3\n3\n2\n6\n", "input_to_evaluate": "local mfl, mce = math.floor, math.ceil\nlocal mmi, mma = math.min, math.max\nlocal bls, brs = bit.lshift, bit.rshift\nlocal SegTree = {}\nSegTree.updateAll = function(self)\n for i = self.stagenum - 1, 1, -1 do\n local cnt = bls(1, i - 1)\n for j = 1, cnt do\n self.stage[i][j] = self.func(self.stage[i + 1][j * 2 - 1], self.stage[i + 1][j * 2])\n end\n end\nend\nSegTree.create = function(self, n, func, emptyvalue)\n self.func, self.emptyvalue = func, emptyvalue\n local stagenum, mul = 1, 1\n self.stage = {{}}\n while mul < n do\n mul, stagenum = mul * 2, stagenum + 1\n self.stage[stagenum] = {}\n end\n self.stagenum = stagenum\n self.left_stage = {}\n for i = 1, n do\n local sp, sz = 1, bls(1, stagenum - 1)\n while(i - 1) % sz ~= 0 do\n sp, sz = sp + 1, brs(sz, 1)\n end\n self.left_stage[i] = sp\n end\n self.sz_stage = {}\n local tmp, sp = 1, stagenum\n for i = 1, n do\n if tmp * 2 == i then tmp, sp = tmp * 2, sp - 1 end\n self.sz_stage[i] = sp\n end\n for i = 1, mul do self.stage[stagenum][i] = emptyvalue end\n self:updateAll()\nend\nSegTree.getRange = function(self, left, right)\n if left == right then return self.stage[self.stagenum][left] end\n local stagenum = self.stagenum\n local ret = self.emptyvalue\n while left <= right do\n local stage = mma(self.left_stage[left], self.sz_stage[right - left + 1])\n local sz = bls(1, stagenum - stage)\n ret = self.func(ret, self.stage[stage][1 + brs(left - 1, stagenum - stage)])\n left = left + sz\n end\n return ret\nend\nSegTree.update = function(self, idx)\n for i = self.stagenum - 1, 1, -1 do\n local dst = brs(idx + 1, 1)\n local rem = dst * 4 - 1 - idx\n self.stage[i][dst] = self.func(self.stage[i + 1][idx], self.stage[i + 1][rem])\n idx = dst\n end\nend\nSegTree.setValue = function(self, idx, value, silent)\n self.stage[self.stagenum][idx] = value\n if not silent then\n self:update(idx)\n end\nend\n\nSegTree.right_bound = function(self, val, left, right)\n local ret, retpos = self.emptyvalue, left - 1\n local l, r = left, right\n local stage = mma(self.left_stage[left], self.sz_stage[right - left + 1])\n local stagenum = self.stagenum\n while true do\n local sz = bls(1, stagenum - stage)\n local tmp = self.func(ret, self.stage[stage][mce(l / sz)])\n if tmp < val then\n ret, retpos = tmp, l + sz - 1\n if retpos == right then break end\n if l + sz <= r then\n l = l + sz\n stage = mma(self.left_stage[l], self.sz_stage[r - l + 1])\n else break end\n else\n if sz ~= 1 then stage, r = stage + 1, l + sz - 2\n else break end\n end\n end\n return retpos + 1\nend\n\nSegTree.new = function(n, func, emptyvalue)\n local obj = {}\n setmetatable(obj, {__index = SegTree})\n obj:create(n, func, emptyvalue)\n return obj\nend\n\nlocal n, q = io.read(\"*n\", \"*n\")\nlocal st = SegTree.new(n, mma, -1)\nfor i = 1, n do\n local a = io.read(\"*n\")\n st:setValue(i, a, true)\nend\nst:updateAll()\nfor iq = 1, q do\n local a, b, c = io.read(\"*n\", \"*n\", \"*n\")\n if a == 1 then\n st:setValue(b, c)\n elseif a == 2 then\n print(st:getRange(b, c))\n else\n print(st:right_bound(c, b, n))\n end\nend\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nYou are given an array a_0, a_1, ..., a_{N-1} of length N. Process Q queries of the following types.\n\nThe type of i-th query is represented by T_i.\n\nT_i=1: You are given two integers X_i,V_i. Replace the value of A_{X_i} with V_i.\n\nT_i=2: You are given two integers L_i,R_i. Calculate the maximum value among A_{L_i},A_{L_i+1},\\cdots,A_{R_i}.\n\nT_i=3: You are given two integers X_i,V_i. Calculate the minimum j such that X_i \\leq j \\leq N, V_i \\leq A_j. If there is no such j, answer j=N+1 instead.\n\nConstraints\n\n1 \\leq N \\leq 2 \\times 10^5\n\n0 \\leq A_i \\leq 10^9\n\n1 \\leq Q \\leq 2 \\times 10^5\n\n1 \\leq T_i \\leq 3\n\n1 \\leq X_i \\leq N, 0 \\leq V_i \\leq 10^9 (T_i=1,3)\n\n1 \\leq L_i \\leq R_i \\leq N (T_i=2)\n\nAll values in Input are integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN Q\nA_1 A_2 \\cdots A_N\nFirst query\nSecond query\n\\vdots\nQ-th query\n\nEach query is given in the following format:\n\nIf T_i=1,3,\n\nT_i X_i V_i\n\nIf T_i=2,\n\nT_i L_i R_i\n\nOutput\n\nFor each query with T_i=2, 3, print the answer.\n\nSample Input 1\n\n5 5\n1 2 3 2 1\n2 1 5\n3 2 3\n1 3 1\n2 2 4\n3 1 3\n\nSample Output 1\n\n3\n3\n2\n6\n\nFirst query: Print 3, which is the maximum of (A_1,A_2,A_3,A_4,A_5)=(1,2,3,2,1).\n\nSecond query: Since 3>A_2, j=2 does not satisfy the condition.Since 3 \\leq A_3, print j=3.\n\nThird query: Replace the value of A_3 with 1. It becomes A=(1,2,1,2,1).\n\nFourth query: Print 2, which is the maximum of (A_2,A_3,A_4)=(2,1,2).\n\nFifth query: Since there is no j that satisfies the condition, print j=N+1=6.", "sample_input": "5 5\n1 2 3 2 1\n2 1 5\n3 2 3\n1 3 1\n2 2 4\n3 1 3\n"}, "reference_outputs": ["3\n3\n2\n6\n"], "source_document_id": "p02567", "source_text": "Score : 100 points\n\nProblem Statement\n\nYou are given an array a_0, a_1, ..., a_{N-1} of length N. Process Q queries of the following types.\n\nThe type of i-th query is represented by T_i.\n\nT_i=1: You are given two integers X_i,V_i. Replace the value of A_{X_i} with V_i.\n\nT_i=2: You are given two integers L_i,R_i. Calculate the maximum value among A_{L_i},A_{L_i+1},\\cdots,A_{R_i}.\n\nT_i=3: You are given two integers X_i,V_i. Calculate the minimum j such that X_i \\leq j \\leq N, V_i \\leq A_j. If there is no such j, answer j=N+1 instead.\n\nConstraints\n\n1 \\leq N \\leq 2 \\times 10^5\n\n0 \\leq A_i \\leq 10^9\n\n1 \\leq Q \\leq 2 \\times 10^5\n\n1 \\leq T_i \\leq 3\n\n1 \\leq X_i \\leq N, 0 \\leq V_i \\leq 10^9 (T_i=1,3)\n\n1 \\leq L_i \\leq R_i \\leq N (T_i=2)\n\nAll values in Input are integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN Q\nA_1 A_2 \\cdots A_N\nFirst query\nSecond query\n\\vdots\nQ-th query\n\nEach query is given in the following format:\n\nIf T_i=1,3,\n\nT_i X_i V_i\n\nIf T_i=2,\n\nT_i L_i R_i\n\nOutput\n\nFor each query with T_i=2, 3, print the answer.\n\nSample Input 1\n\n5 5\n1 2 3 2 1\n2 1 5\n3 2 3\n1 3 1\n2 2 4\n3 1 3\n\nSample Output 1\n\n3\n3\n2\n6\n\nFirst query: Print 3, which is the maximum of (A_1,A_2,A_3,A_4,A_5)=(1,2,3,2,1).\n\nSecond query: Since 3>A_2, j=2 does not satisfy the condition.Since 3 \\leq A_3, print j=3.\n\nThird query: Replace the value of A_3 with 1. It becomes A=(1,2,1,2,1).\n\nFourth query: Print 2, which is the maximum of (A_2,A_3,A_4)=(2,1,2).\n\nFifth query: Since there is no j that satisfies the condition, print j=N+1=6.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 3136, "cpu_time_ms": 240, "memory_kb": 10908}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s560160058", "group_id": "codeNet:p02569", "input_text": "local mfl, mce = math.floor, math.ceil\nlocal mmi, mma = math.min, math.max\nlocal bls, brs = bit.lshift, bit.rshift\nlocal LazyRangeSeg = {}\nLazyRangeSeg.create = function(self, n)\n local stagenum, mul = 1, 1\n self.n0, self.n1 = {{0}}, {{0}}\n self.c01, self.c10 = {{0}}, {{0}}\n self.lazy = {{false}}\n while mul < n do\n mul, stagenum = mul * 2, stagenum + 1\n self.n0[stagenum], self.n1[stagenum] = {}, {}\n self.c01[stagenum], self.c10[stagenum] = {}, {}\n self.lazy[stagenum] = {}\n for i = 1, mul do\n self.n0[stagenum][i], self.n1[stagenum][i] = 0, 0\n self.c01[stagenum][i], self.c10[stagenum][i] = 0, 0\n self.lazy[stagenum][i] = false\n end\n end\n self.left_stage = {}\n for i = 1, n do\n local sp, sz = 1, bls(1, stagenum - 1)\n while(i - 1) % sz ~= 0 do\n sp, sz = sp + 1, brs(sz, 1)\n end\n self.left_stage[i] = sp\n end\n self.sz_stage = {}\n local tmp, sp = 1, stagenum\n for i = 1, n do\n if tmp * 2 == i then tmp, sp = tmp * 2, sp - 1 end\n self.sz_stage[i] = sp\n end\n self.stagenum = stagenum\nend\nLazyRangeSeg.resolve = function(self, right)\n local stagenum = self.stagenum\n local offset = 0\n for i = 1, stagenum - 1 do\n local p = offset + bls(1, stagenum - i)\n if p < right then\n offset = p\n p = p + bls(1, stagenum - i)\n end\n if right < p then\n local curidx = brs(p, stagenum - i)\n if self.lazy[i][curidx] then\n self:resolveRange(i + 1, curidx * 2 - 1, true)\n self:resolveRange(i + 1, curidx * 2, incval, true)\n self.lazy[i + 1][curidx * 2 - 1] = not self.lazy[i + 1][curidx * 2 - 1]\n self.lazy[i + 1][curidx * 2] = not self.lazy[i + 1][curidx * 2]\n self.lazy[i][curidx] = false\n end\n elseif p == right then\n break\n else\n assert(false)\n end\n end\nend\nlocal function merge(ln0, ln1, lc01, lc10, rn0, rn1, rc01, rc10)\n return ln0 + rn0, ln1 + rn1, lc01 + rc01 + ln0 * rn1, lc10 + rc10 + ln1 * rn0\nend\nLazyRangeSeg.resolveRange = function(self, stagepos, idx, shallow)\n self.n0[stagepos][idx], self.n1[stagepos][idx] = self.n1[stagepos][idx], self.n0[stagepos][idx]\n self.c01[stagepos][idx], self.c10[stagepos][idx] = self.c10[stagepos][idx], self.c01[stagepos][idx]\n if shallow then return end\n for i = stagepos - 1, 1, -1 do\n local dst = brs(idx + 1, 1)\n local rem = dst * 4 - 1 - idx\n if rem < idx then rem, idx = idx, rem end\n self.n0[i][dst], self.n1[i][dst], self.c01[i][dst], self.c10[i][dst]\n = merge(self.n0[i + 1][idx], self.n1[i + 1][idx],\n self.c01[i + 1][idx], self.c10[i + 1][idx],\n self.n0[i + 1][rem], self.n1[i + 1][rem],\n self.c01[i + 1][rem], self.c10[i + 1][rem])\n idx = dst\n end\nend\nLazyRangeSeg.getRange = function(self, left, right)\n if 1 < left then self:resolve(left - 1) end\n self:resolve(right)\n local stagenum = self.stagenum\n local n0, n1, c01, c10 = 0, 0, 0, 0\n while left <= right do\n local stage = mma(self.left_stage[left], self.sz_stage[right - left + 1])\n local sz = bls(1, stagenum - stage)\n local pos = 1 + brs(left - 1, stagenum - stage)\n n0, n1, c01, c10\n = merge(n0, n1, c01, c10, self.n0[stage][pos], self.n1[stage][pos], self.c01[stage][pos], self.c10[stage][pos])\n left = left + sz\n end\n return c10\nend\nLazyRangeSeg.setRange = function(self, left, right)\n if 1 < left then self:resolve(left - 1) end\n self:resolve(right)\n local stagenum = self.stagenum\n while left <= right do\n local stage = mma(self.left_stage[left], self.sz_stage[right - left + 1])\n local sz = bls(1, stagenum - stage)\n local len = right - left + 1\n local idx = 1 + brs(left - 1, stagenum - stage)\n self:resolveRange(stage, idx)\n self.lazy[stage][idx] = not self.lazy[stage][idx]\n left = left + sz\n end\nend\nLazyRangeSeg.setAll = function(self, s)\n local n = brs(#s + 1, 1)\n local stagenum = self.stagenum\n for i = 1, n do\n local b = s:byte(i * 2 - 1)\n if b == 48 then\n self.n0[stagenum][i] = 1\n else\n self.n1[stagenum][i] = 1\n end\n end\n for i = stagenum - 1, 1, -1 do\n local cnt = bls(1, i - 1)\n for j = 1, cnt do\n self.n0[i][j], self.n1[i][j], self.c01[i][j], self.c10[i][j]\n = merge(self.n0[i + 1][j * 2 - 1], self.n1[i + 1][j * 2 - 1],\n self.c01[i + 1][j * 2 - 1], self.c10[i + 1][j * 2 - 1],\n self.n0[i + 1][j * 2], self.n1[i + 1][j * 2],\n self.c01[i + 1][j * 2], self.c10[i + 1][j * 2])\n end\n end\nend\nLazyRangeSeg.new = function(n)\n local obj = {}\n setmetatable(obj, {__index = LazyRangeSeg})\n obj:create(n)\n return obj\nend\n\nlocal n, q = io.read(\"*n\", \"*n\", \"*l\")\nlocal lzst = LazyRangeSeg.new(n)\nlzst:setAll(io.read())\nfor iq = 1, q do\n-- while true do\n local t, l, r = io.read(\"*n\", \"*n\", \"*n\")\n -- if t == 0 then break end\n if t == 1 then\n lzst:setRange(l, r)\n else\n print(lzst:getRange(l, r))\n end\nend\n", "language": "Lua", "metadata": {"date": 1599860169, "filename_ext": "lua", "original_language": "Lua (LuaJIT 2.1.0)", "problem_description_relpath": "problem_descriptions/p02569.html", "problem_id": "p02569", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02569/input.txt", "sample_output_relpath": "derived/input_output/data/p02569/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02569/Lua/s560160058.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s560160058", "user_id": "u120582723"}, "prompt_components": {"gold_output": "2\n0\n1\n", "input_to_evaluate": "local mfl, mce = math.floor, math.ceil\nlocal mmi, mma = math.min, math.max\nlocal bls, brs = bit.lshift, bit.rshift\nlocal LazyRangeSeg = {}\nLazyRangeSeg.create = function(self, n)\n local stagenum, mul = 1, 1\n self.n0, self.n1 = {{0}}, {{0}}\n self.c01, self.c10 = {{0}}, {{0}}\n self.lazy = {{false}}\n while mul < n do\n mul, stagenum = mul * 2, stagenum + 1\n self.n0[stagenum], self.n1[stagenum] = {}, {}\n self.c01[stagenum], self.c10[stagenum] = {}, {}\n self.lazy[stagenum] = {}\n for i = 1, mul do\n self.n0[stagenum][i], self.n1[stagenum][i] = 0, 0\n self.c01[stagenum][i], self.c10[stagenum][i] = 0, 0\n self.lazy[stagenum][i] = false\n end\n end\n self.left_stage = {}\n for i = 1, n do\n local sp, sz = 1, bls(1, stagenum - 1)\n while(i - 1) % sz ~= 0 do\n sp, sz = sp + 1, brs(sz, 1)\n end\n self.left_stage[i] = sp\n end\n self.sz_stage = {}\n local tmp, sp = 1, stagenum\n for i = 1, n do\n if tmp * 2 == i then tmp, sp = tmp * 2, sp - 1 end\n self.sz_stage[i] = sp\n end\n self.stagenum = stagenum\nend\nLazyRangeSeg.resolve = function(self, right)\n local stagenum = self.stagenum\n local offset = 0\n for i = 1, stagenum - 1 do\n local p = offset + bls(1, stagenum - i)\n if p < right then\n offset = p\n p = p + bls(1, stagenum - i)\n end\n if right < p then\n local curidx = brs(p, stagenum - i)\n if self.lazy[i][curidx] then\n self:resolveRange(i + 1, curidx * 2 - 1, true)\n self:resolveRange(i + 1, curidx * 2, incval, true)\n self.lazy[i + 1][curidx * 2 - 1] = not self.lazy[i + 1][curidx * 2 - 1]\n self.lazy[i + 1][curidx * 2] = not self.lazy[i + 1][curidx * 2]\n self.lazy[i][curidx] = false\n end\n elseif p == right then\n break\n else\n assert(false)\n end\n end\nend\nlocal function merge(ln0, ln1, lc01, lc10, rn0, rn1, rc01, rc10)\n return ln0 + rn0, ln1 + rn1, lc01 + rc01 + ln0 * rn1, lc10 + rc10 + ln1 * rn0\nend\nLazyRangeSeg.resolveRange = function(self, stagepos, idx, shallow)\n self.n0[stagepos][idx], self.n1[stagepos][idx] = self.n1[stagepos][idx], self.n0[stagepos][idx]\n self.c01[stagepos][idx], self.c10[stagepos][idx] = self.c10[stagepos][idx], self.c01[stagepos][idx]\n if shallow then return end\n for i = stagepos - 1, 1, -1 do\n local dst = brs(idx + 1, 1)\n local rem = dst * 4 - 1 - idx\n if rem < idx then rem, idx = idx, rem end\n self.n0[i][dst], self.n1[i][dst], self.c01[i][dst], self.c10[i][dst]\n = merge(self.n0[i + 1][idx], self.n1[i + 1][idx],\n self.c01[i + 1][idx], self.c10[i + 1][idx],\n self.n0[i + 1][rem], self.n1[i + 1][rem],\n self.c01[i + 1][rem], self.c10[i + 1][rem])\n idx = dst\n end\nend\nLazyRangeSeg.getRange = function(self, left, right)\n if 1 < left then self:resolve(left - 1) end\n self:resolve(right)\n local stagenum = self.stagenum\n local n0, n1, c01, c10 = 0, 0, 0, 0\n while left <= right do\n local stage = mma(self.left_stage[left], self.sz_stage[right - left + 1])\n local sz = bls(1, stagenum - stage)\n local pos = 1 + brs(left - 1, stagenum - stage)\n n0, n1, c01, c10\n = merge(n0, n1, c01, c10, self.n0[stage][pos], self.n1[stage][pos], self.c01[stage][pos], self.c10[stage][pos])\n left = left + sz\n end\n return c10\nend\nLazyRangeSeg.setRange = function(self, left, right)\n if 1 < left then self:resolve(left - 1) end\n self:resolve(right)\n local stagenum = self.stagenum\n while left <= right do\n local stage = mma(self.left_stage[left], self.sz_stage[right - left + 1])\n local sz = bls(1, stagenum - stage)\n local len = right - left + 1\n local idx = 1 + brs(left - 1, stagenum - stage)\n self:resolveRange(stage, idx)\n self.lazy[stage][idx] = not self.lazy[stage][idx]\n left = left + sz\n end\nend\nLazyRangeSeg.setAll = function(self, s)\n local n = brs(#s + 1, 1)\n local stagenum = self.stagenum\n for i = 1, n do\n local b = s:byte(i * 2 - 1)\n if b == 48 then\n self.n0[stagenum][i] = 1\n else\n self.n1[stagenum][i] = 1\n end\n end\n for i = stagenum - 1, 1, -1 do\n local cnt = bls(1, i - 1)\n for j = 1, cnt do\n self.n0[i][j], self.n1[i][j], self.c01[i][j], self.c10[i][j]\n = merge(self.n0[i + 1][j * 2 - 1], self.n1[i + 1][j * 2 - 1],\n self.c01[i + 1][j * 2 - 1], self.c10[i + 1][j * 2 - 1],\n self.n0[i + 1][j * 2], self.n1[i + 1][j * 2],\n self.c01[i + 1][j * 2], self.c10[i + 1][j * 2])\n end\n end\nend\nLazyRangeSeg.new = function(n)\n local obj = {}\n setmetatable(obj, {__index = LazyRangeSeg})\n obj:create(n)\n return obj\nend\n\nlocal n, q = io.read(\"*n\", \"*n\", \"*l\")\nlocal lzst = LazyRangeSeg.new(n)\nlzst:setAll(io.read())\nfor iq = 1, q do\n-- while true do\n local t, l, r = io.read(\"*n\", \"*n\", \"*n\")\n -- if t == 0 then break end\n if t == 1 then\n lzst:setRange(l, r)\n else\n print(lzst:getRange(l, r))\n end\nend\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nYou are given a binary array A=(A_1,A_2,\\cdots,A_N) of length N.\n\nProcess Q queries of the following types. The i-th query is represented by three integers T_i,L_i,R_i.\n\nT_i=1: Replace the value of A_j with 1-A_j for each L_i \\leq j \\leq R_i.\n\nT_i=2: Calculate the inversion(*) of the array A_{L_i},A_{L_i+1},\\cdots,A_{R_i}.\n\nNote:The inversion of the array x_1,x_2,\\cdots,x_k is the number of the pair of integers i,j with 1 \\leq i < j \\leq k, x_i > x_j.\n\nConstraints\n\n1 \\leq N \\leq 2 \\times 10^5\n\n0 \\leq A_i \\leq 1\n\n1 \\leq Q \\leq 2 \\times 10^5\n\n1 \\leq T_i \\leq 2\n\n1 \\leq L_i \\leq R_i \\leq N\n\nAll values in Input are integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN Q\nA_1 A_2 \\cdots A_N\nT_1 L_1 R_1\nT_2 L_2 R_2\n\\vdots\nT_Q L_Q R_Q\n\nOutput\n\nFor each query with T_i=2, print the answer.\n\nSample Input 1\n\n5 5\n0 1 0 0 1\n2 1 5\n1 3 4\n2 2 5\n1 1 3\n2 1 2\n\nSample Output 1\n\n2\n0\n1\n\nFirst query: Print 2, which is the inversion of (A_1,A_2,A_3,A_4,A_5)=(0,1,0,0,1).\n\nSecond query: Replace the value of A_3 and A_4 with 1 and 1, respectively.\n\nThird query: Print 0, which is the inversion of (A_2,A_3,A_4,A_5)=(1,1,1,1).\n\nFourth query: Replace the value of A_1, A_2 and A_4 with 1, 0 and 0, respectively.\n\nFifth query: Print 1, which is the inversion of (A_1,A_2)=(1,0).", "sample_input": "5 5\n0 1 0 0 1\n2 1 5\n1 3 4\n2 2 5\n1 1 3\n2 1 2\n"}, "reference_outputs": ["2\n0\n1\n"], "source_document_id": "p02569", "source_text": "Score : 100 points\n\nProblem Statement\n\nYou are given a binary array A=(A_1,A_2,\\cdots,A_N) of length N.\n\nProcess Q queries of the following types. The i-th query is represented by three integers T_i,L_i,R_i.\n\nT_i=1: Replace the value of A_j with 1-A_j for each L_i \\leq j \\leq R_i.\n\nT_i=2: Calculate the inversion(*) of the array A_{L_i},A_{L_i+1},\\cdots,A_{R_i}.\n\nNote:The inversion of the array x_1,x_2,\\cdots,x_k is the number of the pair of integers i,j with 1 \\leq i < j \\leq k, x_i > x_j.\n\nConstraints\n\n1 \\leq N \\leq 2 \\times 10^5\n\n0 \\leq A_i \\leq 1\n\n1 \\leq Q \\leq 2 \\times 10^5\n\n1 \\leq T_i \\leq 2\n\n1 \\leq L_i \\leq R_i \\leq N\n\nAll values in Input are integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN Q\nA_1 A_2 \\cdots A_N\nT_1 L_1 R_1\nT_2 L_2 R_2\n\\vdots\nT_Q L_Q R_Q\n\nOutput\n\nFor each query with T_i=2, print the answer.\n\nSample Input 1\n\n5 5\n0 1 0 0 1\n2 1 5\n1 3 4\n2 2 5\n1 1 3\n2 1 2\n\nSample Output 1\n\n2\n0\n1\n\nFirst query: Print 2, which is the inversion of (A_1,A_2,A_3,A_4,A_5)=(0,1,0,0,1).\n\nSecond query: Replace the value of A_3 and A_4 with 1 and 1, respectively.\n\nThird query: Print 0, which is the inversion of (A_2,A_3,A_4,A_5)=(1,1,1,1).\n\nFourth query: Replace the value of A_1, A_2 and A_4 with 1, 0 and 0, respectively.\n\nFifth query: Print 1, which is the inversion of (A_1,A_2)=(1,0).", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 4887, "cpu_time_ms": 1922, "memory_kb": 28900}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s896225114", "group_id": "codeNet:p02570", "input_text": "-- Atcoder https://atcoder.jp/contests/abc177/tasks/abc177_a\n\nlocal input= io.read()\nlocal d, t, s = string.match(input, \"(%d+) (%d+)\")\n\nif t * s >= d then\n print(\"yes\")\nelse\n print(\"no\")\nend", "language": "Lua", "metadata": {"date": 1598952004, "filename_ext": "lua", "original_language": "Lua (Lua 5.3.5)", "problem_description_relpath": "problem_descriptions/p02570.html", "problem_id": "p02570", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02570/input.txt", "sample_output_relpath": "derived/input_output/data/p02570/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02570/Lua/s896225114.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s896225114", "user_id": "u185917698"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "-- Atcoder https://atcoder.jp/contests/abc177/tasks/abc177_a\n\nlocal input= io.read()\nlocal d, t, s = string.match(input, \"(%d+) (%d+)\")\n\nif t * s >= d then\n print(\"yes\")\nelse\n print(\"no\")\nend", "problem_context": "Score : 100 points\n\nProblem Statement\n\nTakahashi is meeting up with Aoki.\n\nThey have planned to meet at a place that is D meters away from Takahashi's house in T minutes from now.\n\nTakahashi will leave his house now and go straight to the place at a speed of S meters per minute.\n\nWill he arrive in time?\n\nConstraints\n\n1 \\leq D \\leq 10000\n\n1 \\leq T \\leq 10000\n\n1 \\leq S \\leq 10000\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nD T S\n\nOutput\n\nIf Takahashi will reach the place in time, print Yes; otherwise, print No.\n\nSample Input 1\n\n1000 15 80\n\nSample Output 1\n\nYes\n\nIt takes 12.5 minutes to go 1000 meters to the place at a speed of 80 meters per minute. They have planned to meet in 15 minutes so he will arrive in time.\n\nSample Input 2\n\n2000 20 100\n\nSample Output 2\n\nYes\n\nIt takes 20 minutes to go 2000 meters to the place at a speed of 100 meters per minute. They have planned to meet in 20 minutes so he will arrive just on time.\n\nSample Input 3\n\n10000 1 1\n\nSample Output 3\n\nNo\n\nHe will be late.", "sample_input": "1000 15 80\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p02570", "source_text": "Score : 100 points\n\nProblem Statement\n\nTakahashi is meeting up with Aoki.\n\nThey have planned to meet at a place that is D meters away from Takahashi's house in T minutes from now.\n\nTakahashi will leave his house now and go straight to the place at a speed of S meters per minute.\n\nWill he arrive in time?\n\nConstraints\n\n1 \\leq D \\leq 10000\n\n1 \\leq T \\leq 10000\n\n1 \\leq S \\leq 10000\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nD T S\n\nOutput\n\nIf Takahashi will reach the place in time, print Yes; otherwise, print No.\n\nSample Input 1\n\n1000 15 80\n\nSample Output 1\n\nYes\n\nIt takes 12.5 minutes to go 1000 meters to the place at a speed of 80 meters per minute. They have planned to meet in 15 minutes so he will arrive in time.\n\nSample Input 2\n\n2000 20 100\n\nSample Output 2\n\nYes\n\nIt takes 20 minutes to go 2000 meters to the place at a speed of 100 meters per minute. They have planned to meet in 20 minutes so he will arrive just on time.\n\nSample Input 3\n\n10000 1 1\n\nSample Output 3\n\nNo\n\nHe will be late.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 197, "cpu_time_ms": 6, "memory_kb": 2788}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s757177091", "group_id": "codeNet:p02570", "input_text": "local a = io.read(\"*n\")\nb, c = io.read(\"*n\", \"*n\")\nprint(a <= b * c and \"Yes\" or \"No\")", "language": "Lua", "metadata": {"date": 1598727666, "filename_ext": "lua", "original_language": "Lua (Lua 5.3.5)", "problem_description_relpath": "problem_descriptions/p02570.html", "problem_id": "p02570", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02570/input.txt", "sample_output_relpath": "derived/input_output/data/p02570/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02570/Lua/s757177091.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s757177091", "user_id": "u120582723"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "local a = io.read(\"*n\")\nb, c = io.read(\"*n\", \"*n\")\nprint(a <= b * c and \"Yes\" or \"No\")", "problem_context": "Score : 100 points\n\nProblem Statement\n\nTakahashi is meeting up with Aoki.\n\nThey have planned to meet at a place that is D meters away from Takahashi's house in T minutes from now.\n\nTakahashi will leave his house now and go straight to the place at a speed of S meters per minute.\n\nWill he arrive in time?\n\nConstraints\n\n1 \\leq D \\leq 10000\n\n1 \\leq T \\leq 10000\n\n1 \\leq S \\leq 10000\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nD T S\n\nOutput\n\nIf Takahashi will reach the place in time, print Yes; otherwise, print No.\n\nSample Input 1\n\n1000 15 80\n\nSample Output 1\n\nYes\n\nIt takes 12.5 minutes to go 1000 meters to the place at a speed of 80 meters per minute. They have planned to meet in 15 minutes so he will arrive in time.\n\nSample Input 2\n\n2000 20 100\n\nSample Output 2\n\nYes\n\nIt takes 20 minutes to go 2000 meters to the place at a speed of 100 meters per minute. They have planned to meet in 20 minutes so he will arrive just on time.\n\nSample Input 3\n\n10000 1 1\n\nSample Output 3\n\nNo\n\nHe will be late.", "sample_input": "1000 15 80\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p02570", "source_text": "Score : 100 points\n\nProblem Statement\n\nTakahashi is meeting up with Aoki.\n\nThey have planned to meet at a place that is D meters away from Takahashi's house in T minutes from now.\n\nTakahashi will leave his house now and go straight to the place at a speed of S meters per minute.\n\nWill he arrive in time?\n\nConstraints\n\n1 \\leq D \\leq 10000\n\n1 \\leq T \\leq 10000\n\n1 \\leq S \\leq 10000\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nD T S\n\nOutput\n\nIf Takahashi will reach the place in time, print Yes; otherwise, print No.\n\nSample Input 1\n\n1000 15 80\n\nSample Output 1\n\nYes\n\nIt takes 12.5 minutes to go 1000 meters to the place at a speed of 80 meters per minute. They have planned to meet in 15 minutes so he will arrive in time.\n\nSample Input 2\n\n2000 20 100\n\nSample Output 2\n\nYes\n\nIt takes 20 minutes to go 2000 meters to the place at a speed of 100 meters per minute. They have planned to meet in 20 minutes so he will arrive just on time.\n\nSample Input 3\n\n10000 1 1\n\nSample Output 3\n\nNo\n\nHe will be late.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 86, "cpu_time_ms": 7, "memory_kb": 2656}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s754874034", "group_id": "codeNet:p02573", "input_text": "local max = math.max\nlocal min = math.min\n--[[ https://www.slideshare.net/iwiwi/ss-3578491 3~18of73 ]]--\n\n--半分の実装のみ(これでも十分早いらしい)\nlocal UFT = {}\n\n---要素数nでpar[]を初期化\nfunction UFT.new(n)\n\tlocal obj = {par = {}}\n\tfor i = 1, n do\n\t\tobj.par[i] = i\n\tend\n\treturn setmetatable(obj,{__index = UFT})\nend\n\n---木の根を求める\nfunction UFT:find(x)\n\tif self.par[x] == x then\n\t\t-- 根\n\t\treturn x\n\telse\n\t\t-- 経路圧縮\n\t\tself.par[x] = self:find(self.par[x])\n\t\treturn self.par[x]\n\tend\nend\n\n---xとyが同じ集合に属するか否か\nfunction UFT:same(x, y)\n\treturn self:find(x) == self:find(y)\nend\n\n---xとyの属する集合を併合\nfunction UFT:union(x, y)\n\tx = self:find(x)\n\ty = self:find(y)\n\tif x == y then\n\t\treturn\n\tend\n\n\tself.par[max(x, y)] = min(x, y)\nend\n\n--[[ I referred until here. ]]--\n\nlocal read = io.read\n\nlocal n, m = read(\"n\", \"n\")\nlocal uft = UFT.new(n)\nfor i = 1, m do\n\tlocal a_i, b_i = read(\"n\", \"n\")\n\tuft:union(a_i, b_i)\nend\n\nlocal is_finded_num_t = {}\nfor i = 1, n do\n\tlocal par_num = uft.par[i]\n\tif is_finded_num_t[par_num] then\n\t\tis_finded_num_t[par_num] = is_finded_num_t[par_num] + 1\n\telse\n\t\tis_finded_num_t[par_num] = 1\n\tend\nend\n\nlocal uft_par_max = -1\nfor i = 1, n do\n\tif is_finded_num_t[i] then\n\t\tuft_par_max = max(uft_par_max, is_finded_num_t[i])\n\tend\nend\n\nprint(uft_par_max)\n", "language": "Lua", "metadata": {"date": 1598734211, "filename_ext": "lua", "original_language": "Lua (Lua 5.3.5)", "problem_description_relpath": "problem_descriptions/p02573.html", "problem_id": "p02573", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02573/input.txt", "sample_output_relpath": "derived/input_output/data/p02573/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02573/Lua/s754874034.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s754874034", "user_id": "u793881115"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "local max = math.max\nlocal min = math.min\n--[[ https://www.slideshare.net/iwiwi/ss-3578491 3~18of73 ]]--\n\n--半分の実装のみ(これでも十分早いらしい)\nlocal UFT = {}\n\n---要素数nでpar[]を初期化\nfunction UFT.new(n)\n\tlocal obj = {par = {}}\n\tfor i = 1, n do\n\t\tobj.par[i] = i\n\tend\n\treturn setmetatable(obj,{__index = UFT})\nend\n\n---木の根を求める\nfunction UFT:find(x)\n\tif self.par[x] == x then\n\t\t-- 根\n\t\treturn x\n\telse\n\t\t-- 経路圧縮\n\t\tself.par[x] = self:find(self.par[x])\n\t\treturn self.par[x]\n\tend\nend\n\n---xとyが同じ集合に属するか否か\nfunction UFT:same(x, y)\n\treturn self:find(x) == self:find(y)\nend\n\n---xとyの属する集合を併合\nfunction UFT:union(x, y)\n\tx = self:find(x)\n\ty = self:find(y)\n\tif x == y then\n\t\treturn\n\tend\n\n\tself.par[max(x, y)] = min(x, y)\nend\n\n--[[ I referred until here. ]]--\n\nlocal read = io.read\n\nlocal n, m = read(\"n\", \"n\")\nlocal uft = UFT.new(n)\nfor i = 1, m do\n\tlocal a_i, b_i = read(\"n\", \"n\")\n\tuft:union(a_i, b_i)\nend\n\nlocal is_finded_num_t = {}\nfor i = 1, n do\n\tlocal par_num = uft.par[i]\n\tif is_finded_num_t[par_num] then\n\t\tis_finded_num_t[par_num] = is_finded_num_t[par_num] + 1\n\telse\n\t\tis_finded_num_t[par_num] = 1\n\tend\nend\n\nlocal uft_par_max = -1\nfor i = 1, n do\n\tif is_finded_num_t[i] then\n\t\tuft_par_max = max(uft_par_max, is_finded_num_t[i])\n\tend\nend\n\nprint(uft_par_max)\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nThere are N persons called Person 1 through Person N.\n\nYou are given M facts that \"Person A_i and Person B_i are friends.\" The same fact may be given multiple times.\n\nIf X and Y are friends, and Y and Z are friends, then X and Z are also friends. There is no friendship that cannot be derived from the M given facts.\n\nTakahashi the evil wants to divide the N persons into some number of groups so that every person has no friend in his/her group.\n\nAt least how many groups does he need to make?\n\nConstraints\n\n2 \\leq N \\leq 2\\times 10^5\n\n0 \\leq M \\leq 2\\times 10^5\n\n1\\leq A_i,B_i\\leq N\n\nA_i \\neq B_i\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nA_1 B_1\n\\vdots\nA_M B_M\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n5 3\n1 2\n3 4\n5 1\n\nSample Output 1\n\n3\n\nDividing them into three groups such as \\{1,3\\}, \\{2,4\\}, and \\{5\\} achieves the goal.\n\nSample Input 2\n\n4 10\n1 2\n2 1\n1 2\n2 1\n1 2\n1 3\n1 4\n2 3\n2 4\n3 4\n\nSample Output 2\n\n4\n\nSample Input 3\n\n10 4\n3 1\n4 1\n5 9\n2 6\n\nSample Output 3\n\n3", "sample_input": "5 3\n1 2\n3 4\n5 1\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02573", "source_text": "Score : 400 points\n\nProblem Statement\n\nThere are N persons called Person 1 through Person N.\n\nYou are given M facts that \"Person A_i and Person B_i are friends.\" The same fact may be given multiple times.\n\nIf X and Y are friends, and Y and Z are friends, then X and Z are also friends. There is no friendship that cannot be derived from the M given facts.\n\nTakahashi the evil wants to divide the N persons into some number of groups so that every person has no friend in his/her group.\n\nAt least how many groups does he need to make?\n\nConstraints\n\n2 \\leq N \\leq 2\\times 10^5\n\n0 \\leq M \\leq 2\\times 10^5\n\n1\\leq A_i,B_i\\leq N\n\nA_i \\neq B_i\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nA_1 B_1\n\\vdots\nA_M B_M\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n5 3\n1 2\n3 4\n5 1\n\nSample Output 1\n\n3\n\nDividing them into three groups such as \\{1,3\\}, \\{2,4\\}, and \\{5\\} achieves the goal.\n\nSample Input 2\n\n4 10\n1 2\n2 1\n1 2\n2 1\n1 2\n1 3\n1 4\n2 3\n2 4\n3 4\n\nSample Output 2\n\n4\n\nSample Input 3\n\n10 4\n3 1\n4 1\n5 9\n2 6\n\nSample Output 3\n\n3", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1349, "cpu_time_ms": 176, "memory_kb": 10728}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s670575204", "group_id": "codeNet:p02576", "input_text": "local n,x,t=io.read(\"n\",\"n\",\"n\")\nprint(n*t//x)", "language": "Lua", "metadata": {"date": 1598198547, "filename_ext": "lua", "original_language": "Lua (Lua 5.3.5)", "problem_description_relpath": "problem_descriptions/p02576.html", "problem_id": "p02576", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02576/input.txt", "sample_output_relpath": "derived/input_output/data/p02576/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02576/Lua/s670575204.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s670575204", "user_id": "u045238009"}, "prompt_components": {"gold_output": "12\n", "input_to_evaluate": "local n,x,t=io.read(\"n\",\"n\",\"n\")\nprint(n*t//x)", "problem_context": "Score : 100 points\n\nProblem Statement\n\nTakahashi loves takoyaki - a ball-shaped snack.\n\nWith a takoyaki machine, he can make at most X pieces of takoyaki at a time, taking T minutes regardless of the number of pieces to make.\n\nHow long does it take to make N takoyaki?\n\nConstraints\n\n1 \\leq N,X,T \\leq 1000\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN X T\n\nOutput\n\nPrint an integer representing the minimum number of minutes needed to make N pieces of takoyaki.\n\nSample Input 1\n\n20 12 6\n\nSample Output 1\n\n12\n\nHe can make 12 pieces of takoyaki in the first 6 minutes and 8 more in the next 6 minutes, so he can make 20 in a total of 12 minutes.\n\nNote that being able to make 12 in 6 minutes does not mean he can make 2 in 1 minute.\n\nSample Input 2\n\n1000 1 1000\n\nSample Output 2\n\n1000000\n\nIt seems to take a long time to make this kind of takoyaki.", "sample_input": "20 12 6\n"}, "reference_outputs": ["12\n"], "source_document_id": "p02576", "source_text": "Score : 100 points\n\nProblem Statement\n\nTakahashi loves takoyaki - a ball-shaped snack.\n\nWith a takoyaki machine, he can make at most X pieces of takoyaki at a time, taking T minutes regardless of the number of pieces to make.\n\nHow long does it take to make N takoyaki?\n\nConstraints\n\n1 \\leq N,X,T \\leq 1000\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN X T\n\nOutput\n\nPrint an integer representing the minimum number of minutes needed to make N pieces of takoyaki.\n\nSample Input 1\n\n20 12 6\n\nSample Output 1\n\n12\n\nHe can make 12 pieces of takoyaki in the first 6 minutes and 8 more in the next 6 minutes, so he can make 20 in a total of 12 minutes.\n\nNote that being able to make 12 in 6 minutes does not mean he can make 2 in 1 minute.\n\nSample Input 2\n\n1000 1 1000\n\nSample Output 2\n\n1000000\n\nIt seems to take a long time to make this kind of takoyaki.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 46, "cpu_time_ms": 6, "memory_kb": 2672}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s395638773", "group_id": "codeNet:p02577", "input_text": "local N = io.read(\"l\")\nlocal diff = string.byte(\"0\")\n\nlocal dig_sum = 0\nfor i = 1, N:len() do\n\tdig_sum = dig_sum + N:byte(i) - diff\nend\n\nprint((dig_sum % 9 == 0) and \"Yes\" or \"No\")\n", "language": "Lua", "metadata": {"date": 1598123518, "filename_ext": "lua", "original_language": "Lua (Lua 5.3.5)", "problem_description_relpath": "problem_descriptions/p02577.html", "problem_id": "p02577", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02577/input.txt", "sample_output_relpath": "derived/input_output/data/p02577/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02577/Lua/s395638773.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s395638773", "user_id": "u793881115"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "local N = io.read(\"l\")\nlocal diff = string.byte(\"0\")\n\nlocal dig_sum = 0\nfor i = 1, N:len() do\n\tdig_sum = dig_sum + N:byte(i) - diff\nend\n\nprint((dig_sum % 9 == 0) and \"Yes\" or \"No\")\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nAn integer N is a multiple of 9 if and only if the sum of the digits in the decimal representation of N is a multiple of 9.\n\nDetermine whether N is a multiple of 9.\n\nConstraints\n\n0 \\leq N < 10^{200000}\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nIf N is a multiple of 9, print Yes; otherwise, print No.\n\nSample Input 1\n\n123456789\n\nSample Output 1\n\nYes\n\nThe sum of these digits is 1+2+3+4+5+6+7+8+9=45, which is a multiple of 9, so 123456789 is a multiple of 9.\n\nSample Input 2\n\n0\n\nSample Output 2\n\nYes\n\nSample Input 3\n\n31415926535897932384626433832795028841971693993751058209749445923078164062862089986280\n\nSample Output 3\n\nNo", "sample_input": "123456789\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p02577", "source_text": "Score : 200 points\n\nProblem Statement\n\nAn integer N is a multiple of 9 if and only if the sum of the digits in the decimal representation of N is a multiple of 9.\n\nDetermine whether N is a multiple of 9.\n\nConstraints\n\n0 \\leq N < 10^{200000}\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nIf N is a multiple of 9, print Yes; otherwise, print No.\n\nSample Input 1\n\n123456789\n\nSample Output 1\n\nYes\n\nThe sum of these digits is 1+2+3+4+5+6+7+8+9=45, which is a multiple of 9, so 123456789 is a multiple of 9.\n\nSample Input 2\n\n0\n\nSample Output 2\n\nYes\n\nSample Input 3\n\n31415926535897932384626433832795028841971693993751058209749445923078164062862089986280\n\nSample Output 3\n\nNo", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 181, "cpu_time_ms": 36, "memory_kb": 2648}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s078100426", "group_id": "codeNet:p02578", "input_text": "local mmi, mma = math.min, math.max\nlocal n = io.read(\"*n\")\nlocal r = 0\nlocal max = 0\nfor i = 1, n do\n local a = io.read(\"*n\")\n if a < max then r = r + max - a\n elseif max < a then max = a\n end\nend\nprint(r)", "language": "Lua", "metadata": {"date": 1598164248, "filename_ext": "lua", "original_language": "Lua (Lua 5.3.5)", "problem_description_relpath": "problem_descriptions/p02578.html", "problem_id": "p02578", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02578/input.txt", "sample_output_relpath": "derived/input_output/data/p02578/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02578/Lua/s078100426.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s078100426", "user_id": "u120582723"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "local mmi, mma = math.min, math.max\nlocal n = io.read(\"*n\")\nlocal r = 0\nlocal max = 0\nfor i = 1, n do\n local a = io.read(\"*n\")\n if a < max then r = r + max - a\n elseif max < a then max = a\n end\nend\nprint(r)", "problem_context": "Score : 300 points\n\nProblem Statement\n\nN persons are standing in a row. The height of the i-th person from the front is A_i.\n\nWe want to have each person stand on a stool of some heights - at least zero - so that the following condition is satisfied for every person:\n\nCondition: Nobody in front of the person is taller than the person. Here, the height of a person includes the stool.\n\nFind the minimum total height of the stools needed to meet this goal.\n\nConstraints\n\n1 \\leq N \\leq 2\\times 10^5\n\n1 \\leq A_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 \\ldots A_N\n\nOutput\n\nPrint the minimum total height of the stools needed to meet the goal.\n\nSample Input 1\n\n5\n2 1 5 4 3\n\nSample Output 1\n\n4\n\nIf the persons stand on stools of heights 0, 1, 0, 1, and 2, respectively, their heights will be 2, 2, 5, 5, and 5, satisfying the condition.\n\nWe cannot meet the goal with a smaller total height of the stools.\n\nSample Input 2\n\n5\n3 3 3 3 3\n\nSample Output 2\n\n0\n\nGiving a stool of height 0 to everyone will work.", "sample_input": "5\n2 1 5 4 3\n"}, "reference_outputs": ["4\n"], "source_document_id": "p02578", "source_text": "Score : 300 points\n\nProblem Statement\n\nN persons are standing in a row. The height of the i-th person from the front is A_i.\n\nWe want to have each person stand on a stool of some heights - at least zero - so that the following condition is satisfied for every person:\n\nCondition: Nobody in front of the person is taller than the person. Here, the height of a person includes the stool.\n\nFind the minimum total height of the stools needed to meet this goal.\n\nConstraints\n\n1 \\leq N \\leq 2\\times 10^5\n\n1 \\leq A_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 \\ldots A_N\n\nOutput\n\nPrint the minimum total height of the stools needed to meet the goal.\n\nSample Input 1\n\n5\n2 1 5 4 3\n\nSample Output 1\n\n4\n\nIf the persons stand on stools of heights 0, 1, 0, 1, and 2, respectively, their heights will be 2, 2, 5, 5, and 5, satisfying the condition.\n\nWe cannot meet the goal with a smaller total height of the stools.\n\nSample Input 2\n\n5\n3 3 3 3 3\n\nSample Output 2\n\n0\n\nGiving a stool of height 0 to everyone will work.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 210, "cpu_time_ms": 53, "memory_kb": 2740}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s142219841", "group_id": "codeNet:p02579", "input_text": "local List = {}\nfunction List.new ()\n return {first = 0, last = -1}\nend\n\nfunction List.pushleft (list, value)\n local first = list.first - 1\n list.first = first\n list[first] = value\nend\n\nfunction List.pushright (list, value)\n local last = list.last + 1\n list.last = last\n list[last] = value\nend\n\nfunction List.popleft (list)\n local first = list.first\n local value = list[first]\n list[first] = nil\n list.first = first + 1\n return value\nend\n\nfunction List.popright (list)\n local last = list.last\n local value = list[last]\n list[last] = nil\n list.last = last - 1\n return value\nend\n\nfunction List.empty (list)\n return list.first > list.last\nend\n\n----------\n\nlocal h,w=io.read(\"n\",\"n\")\nlocal ch,cw=io.read(\"n\",\"n\")\nlocal dh,dw=io.read(\"n\",\"n\",\"l\")\n\nlocal s={}\nfor i=1,h do\n local input=io.read()\n s[i]={}\n for j=1,w do\n s[i][j]=input:sub(j,j)\n end\nend\n\nlocal checkin=List.new()\nlocal checked=List.new()\nList.pushright(checkin,{ch,cw})\n\nlocal cost={}\nlocal INF=math.maxinteger\nfor i=1,h do\n cost[i]={}\n for j=1,w do\n cost[i][j]=INF\n end\nend\ncost[ch][cw]=0\nlocal dx={1,0,-1,0}\nlocal dy={0,1,0,-1}\n\nwhile (not List.empty(checkin)) or (not List.empty(checked)) do\n if not List.empty(checkin) then\n local q=List.popleft(checkin)\n List.pushright(checked,q)\n local x,y=q[1],q[2]\n for i=1,4 do\n local nx,ny=x+dx[i],y+dy[i]\n local checker=(nx<1 or nx>h or ny<1 or ny>w)\n if not checker and s[nx][ny]~=\"#\"then\n if cost[x][y]h or ny<1 or ny>w)\n if not checker and s[nx][ny]~=\"#\"then\n if cost[x][y]+1 list.last\nend\n\n----------\n\nlocal h,w=io.read(\"n\",\"n\")\nlocal ch,cw=io.read(\"n\",\"n\")\nlocal dh,dw=io.read(\"n\",\"n\",\"l\")\n\nlocal s={}\nfor i=1,h do\n local input=io.read()\n s[i]={}\n for j=1,w do\n s[i][j]=input:sub(j,j)\n end\nend\n\nlocal checkin=List.new()\nlocal checked=List.new()\nList.pushright(checkin,{ch,cw})\n\nlocal cost={}\nlocal INF=math.maxinteger\nfor i=1,h do\n cost[i]={}\n for j=1,w do\n cost[i][j]=INF\n end\nend\ncost[ch][cw]=0\nlocal dx={1,0,-1,0}\nlocal dy={0,1,0,-1}\n\nwhile (not List.empty(checkin)) or (not List.empty(checked)) do\n if not List.empty(checkin) then\n local q=List.popleft(checkin)\n List.pushright(checked,q)\n local x,y=q[1],q[2]\n for i=1,4 do\n local nx,ny=x+dx[i],y+dy[i]\n local checker=(nx<1 or nx>h or ny<1 or ny>w)\n if not checker and s[nx][ny]~=\"#\"then\n if cost[x][y]h or ny<1 or ny>w)\n if not checker and s[nx][ny]~=\"#\"then\n if cost[x][y]+1= k then\n print(math.abs(x) - k*d)\nelseif (k - x // d) % 2 == 0 then\n print(math.abs(x - x // d * d))\nelse\n print(math.min(math.abs(x - x // d * d - d), math.abs(x - x // d * d + d)))\nend\n", "language": "Lua", "metadata": {"date": 1599974183, "filename_ext": "lua", "original_language": "Lua (Lua 5.3.5)", "problem_description_relpath": "problem_descriptions/p02584.html", "problem_id": "p02584", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02584/input.txt", "sample_output_relpath": "derived/input_output/data/p02584/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02584/Lua/s333685840.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s333685840", "user_id": "u878654696"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "x, k, d = io.read(\"*n\",\"*n\",\"*n\")\n\nx = math.abs(x)\n\nif math.abs(x) // d >= k then\n print(math.abs(x) - k*d)\nelseif (k - x // d) % 2 == 0 then\n print(math.abs(x - x // d * d))\nelse\n print(math.min(math.abs(x - x // d * d - d), math.abs(x - x // d * d + d)))\nend\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nTakahashi, who lives on the number line, is now at coordinate X. He will make exactly K moves of distance D in the positive or negative direction.\n\nMore specifically, in one move, he can go from coordinate x to x + D or x - D.\n\nHe wants to make K moves so that the absolute value of the coordinate of the destination will be the smallest possible.\n\nFind the minimum possible absolute value of the coordinate of the destination.\n\nConstraints\n\n-10^{15} \\leq X \\leq 10^{15}\n\n1 \\leq K \\leq 10^{15}\n\n1 \\leq D \\leq 10^{15}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX K D\n\nOutput\n\nPrint the minimum possible absolute value of the coordinate of the destination.\n\nSample Input 1\n\n6 2 4\n\nSample Output 1\n\n2\n\nTakahashi is now at coordinate 6. It is optimal to make the following moves:\n\nMove from coordinate 6 to (6 - 4 =) 2.\n\nMove from coordinate 2 to (2 - 4 =) -2.\n\nHere, the absolute value of the coordinate of the destination is 2, and we cannot make it smaller.\n\nSample Input 2\n\n7 4 3\n\nSample Output 2\n\n1\n\nTakahashi is now at coordinate 7. It is optimal to make, for example, the following moves:\n\nMove from coordinate 7 to 4.\n\nMove from coordinate 4 to 7.\n\nMove from coordinate 7 to 4.\n\nMove from coordinate 4 to 1.\n\nHere, the absolute value of the coordinate of the destination is 1, and we cannot make it smaller.\n\nSample Input 3\n\n10 1 2\n\nSample Output 3\n\n8\n\nSample Input 4\n\n1000000000000000 1000000000000000 1000000000000000\n\nSample Output 4\n\n1000000000000000\n\nThe answer can be enormous.", "sample_input": "6 2 4\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02584", "source_text": "Score : 300 points\n\nProblem Statement\n\nTakahashi, who lives on the number line, is now at coordinate X. He will make exactly K moves of distance D in the positive or negative direction.\n\nMore specifically, in one move, he can go from coordinate x to x + D or x - D.\n\nHe wants to make K moves so that the absolute value of the coordinate of the destination will be the smallest possible.\n\nFind the minimum possible absolute value of the coordinate of the destination.\n\nConstraints\n\n-10^{15} \\leq X \\leq 10^{15}\n\n1 \\leq K \\leq 10^{15}\n\n1 \\leq D \\leq 10^{15}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX K D\n\nOutput\n\nPrint the minimum possible absolute value of the coordinate of the destination.\n\nSample Input 1\n\n6 2 4\n\nSample Output 1\n\n2\n\nTakahashi is now at coordinate 6. It is optimal to make the following moves:\n\nMove from coordinate 6 to (6 - 4 =) 2.\n\nMove from coordinate 2 to (2 - 4 =) -2.\n\nHere, the absolute value of the coordinate of the destination is 2, and we cannot make it smaller.\n\nSample Input 2\n\n7 4 3\n\nSample Output 2\n\n1\n\nTakahashi is now at coordinate 7. It is optimal to make, for example, the following moves:\n\nMove from coordinate 7 to 4.\n\nMove from coordinate 4 to 7.\n\nMove from coordinate 7 to 4.\n\nMove from coordinate 4 to 1.\n\nHere, the absolute value of the coordinate of the destination is 1, and we cannot make it smaller.\n\nSample Input 3\n\n10 1 2\n\nSample Output 3\n\n8\n\nSample Input 4\n\n1000000000000000 1000000000000000 1000000000000000\n\nSample Output 4\n\n1000000000000000\n\nThe answer can be enormous.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 264, "cpu_time_ms": 4, "memory_kb": 2696}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s874046374", "group_id": "codeNet:p02584", "input_text": "x, k, d = io.read(\"*n\",\"*n\",\"*n\")\n\nx = math.abs(x)\n\nif math.abs(x) // d >= k then\n print(math.abs(x) - k*d)\nelse\n k = k - x // d\n x = x - x // d * d\n if (k % 2 == 1) then x = math.abs(x - d) end\n print(x)\nend\n", "language": "Lua", "metadata": {"date": 1599973901, "filename_ext": "lua", "original_language": "Lua (Lua 5.3.5)", "problem_description_relpath": "problem_descriptions/p02584.html", "problem_id": "p02584", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02584/input.txt", "sample_output_relpath": "derived/input_output/data/p02584/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02584/Lua/s874046374.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s874046374", "user_id": "u878654696"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "x, k, d = io.read(\"*n\",\"*n\",\"*n\")\n\nx = math.abs(x)\n\nif math.abs(x) // d >= k then\n print(math.abs(x) - k*d)\nelse\n k = k - x // d\n x = x - x // d * d\n if (k % 2 == 1) then x = math.abs(x - d) end\n print(x)\nend\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nTakahashi, who lives on the number line, is now at coordinate X. He will make exactly K moves of distance D in the positive or negative direction.\n\nMore specifically, in one move, he can go from coordinate x to x + D or x - D.\n\nHe wants to make K moves so that the absolute value of the coordinate of the destination will be the smallest possible.\n\nFind the minimum possible absolute value of the coordinate of the destination.\n\nConstraints\n\n-10^{15} \\leq X \\leq 10^{15}\n\n1 \\leq K \\leq 10^{15}\n\n1 \\leq D \\leq 10^{15}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX K D\n\nOutput\n\nPrint the minimum possible absolute value of the coordinate of the destination.\n\nSample Input 1\n\n6 2 4\n\nSample Output 1\n\n2\n\nTakahashi is now at coordinate 6. It is optimal to make the following moves:\n\nMove from coordinate 6 to (6 - 4 =) 2.\n\nMove from coordinate 2 to (2 - 4 =) -2.\n\nHere, the absolute value of the coordinate of the destination is 2, and we cannot make it smaller.\n\nSample Input 2\n\n7 4 3\n\nSample Output 2\n\n1\n\nTakahashi is now at coordinate 7. It is optimal to make, for example, the following moves:\n\nMove from coordinate 7 to 4.\n\nMove from coordinate 4 to 7.\n\nMove from coordinate 7 to 4.\n\nMove from coordinate 4 to 1.\n\nHere, the absolute value of the coordinate of the destination is 1, and we cannot make it smaller.\n\nSample Input 3\n\n10 1 2\n\nSample Output 3\n\n8\n\nSample Input 4\n\n1000000000000000 1000000000000000 1000000000000000\n\nSample Output 4\n\n1000000000000000\n\nThe answer can be enormous.", "sample_input": "6 2 4\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02584", "source_text": "Score : 300 points\n\nProblem Statement\n\nTakahashi, who lives on the number line, is now at coordinate X. He will make exactly K moves of distance D in the positive or negative direction.\n\nMore specifically, in one move, he can go from coordinate x to x + D or x - D.\n\nHe wants to make K moves so that the absolute value of the coordinate of the destination will be the smallest possible.\n\nFind the minimum possible absolute value of the coordinate of the destination.\n\nConstraints\n\n-10^{15} \\leq X \\leq 10^{15}\n\n1 \\leq K \\leq 10^{15}\n\n1 \\leq D \\leq 10^{15}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX K D\n\nOutput\n\nPrint the minimum possible absolute value of the coordinate of the destination.\n\nSample Input 1\n\n6 2 4\n\nSample Output 1\n\n2\n\nTakahashi is now at coordinate 6. It is optimal to make the following moves:\n\nMove from coordinate 6 to (6 - 4 =) 2.\n\nMove from coordinate 2 to (2 - 4 =) -2.\n\nHere, the absolute value of the coordinate of the destination is 2, and we cannot make it smaller.\n\nSample Input 2\n\n7 4 3\n\nSample Output 2\n\n1\n\nTakahashi is now at coordinate 7. It is optimal to make, for example, the following moves:\n\nMove from coordinate 7 to 4.\n\nMove from coordinate 4 to 7.\n\nMove from coordinate 7 to 4.\n\nMove from coordinate 4 to 1.\n\nHere, the absolute value of the coordinate of the destination is 1, and we cannot make it smaller.\n\nSample Input 3\n\n10 1 2\n\nSample Output 3\n\n8\n\nSample Input 4\n\n1000000000000000 1000000000000000 1000000000000000\n\nSample Output 4\n\n1000000000000000\n\nThe answer can be enormous.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 214, "cpu_time_ms": 9, "memory_kb": 2792}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s593604484", "group_id": "codeNet:p02585", "input_text": "local mfl, mce = math.floor, math.ceil\nlocal n, k = io.read(\"*n\", \"*n\")\nlocal p, c = {}, {}\nfor i = 1, n do\n p[i] = io.read(\"*n\")\nend\nfor i = 1, n do\n c[i] = io.read(\"*n\")\nend\nlocal asked = {}\nfor i = 1, n do\n asked[i] = false\nend\nlocal function findstart()\n for i = 1, n do\n if not asked[i] then return i end\n end\n return false\nend\nlocal ret = -1000000007LL\nlocal function mma_l(a, b) return a < b and b or a end\nwhile true do\n local spos = findstart()\n if not spos then break end\n local route = {spos}\n local sum = 0LL + c[spos]\n local src = spos\n asked[spos] = true\n while true do\n local dst = p[src]\n if asked[dst] then break end\n asked[dst] = true\n table.insert(route, dst)\n sum = sum + c[dst]\n src = dst\n end\n local len = #route\n if 0LL < sum then\n local ofst = mfl(k / len)\n local rem = k - ofst * len\n ofst = sum * ofst\n ret = mma_l(ret, ofst)\n for i = 1, len do\n local v = 0LL\n local src = route[i]\n for j = 1, rem do\n local dst = p[src]\n v = v + c[dst]\n ret = mma_l(ret, ofst + v)\n src = dst\n end\n end\n else\n for i = 1, len do\n local v = 0LL\n local src = route[i]\n for j = 1, len do\n local dst = p[src]\n v = v + c[dst]\n ret = mma_l(ret, v)\n src = dst\n end\n end\n end\nend\nret = tostring(ret):gsub(\"LL\", \"\")\nprint(ret)\n", "language": "Lua", "metadata": {"date": 1597541355, "filename_ext": "lua", "original_language": "Lua (LuaJIT 2.1.0)", "problem_description_relpath": "problem_descriptions/p02585.html", "problem_id": "p02585", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02585/input.txt", "sample_output_relpath": "derived/input_output/data/p02585/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02585/Lua/s593604484.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s593604484", "user_id": "u120582723"}, "prompt_components": {"gold_output": "8\n", "input_to_evaluate": "local mfl, mce = math.floor, math.ceil\nlocal n, k = io.read(\"*n\", \"*n\")\nlocal p, c = {}, {}\nfor i = 1, n do\n p[i] = io.read(\"*n\")\nend\nfor i = 1, n do\n c[i] = io.read(\"*n\")\nend\nlocal asked = {}\nfor i = 1, n do\n asked[i] = false\nend\nlocal function findstart()\n for i = 1, n do\n if not asked[i] then return i end\n end\n return false\nend\nlocal ret = -1000000007LL\nlocal function mma_l(a, b) return a < b and b or a end\nwhile true do\n local spos = findstart()\n if not spos then break end\n local route = {spos}\n local sum = 0LL + c[spos]\n local src = spos\n asked[spos] = true\n while true do\n local dst = p[src]\n if asked[dst] then break end\n asked[dst] = true\n table.insert(route, dst)\n sum = sum + c[dst]\n src = dst\n end\n local len = #route\n if 0LL < sum then\n local ofst = mfl(k / len)\n local rem = k - ofst * len\n ofst = sum * ofst\n ret = mma_l(ret, ofst)\n for i = 1, len do\n local v = 0LL\n local src = route[i]\n for j = 1, rem do\n local dst = p[src]\n v = v + c[dst]\n ret = mma_l(ret, ofst + v)\n src = dst\n end\n end\n else\n for i = 1, len do\n local v = 0LL\n local src = route[i]\n for j = 1, len do\n local dst = p[src]\n v = v + c[dst]\n ret = mma_l(ret, v)\n src = dst\n end\n end\n end\nend\nret = tostring(ret):gsub(\"LL\", \"\")\nprint(ret)\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nTakahashi will play a game using a piece on an array of squares numbered 1, 2, \\cdots, N. Square i has an integer C_i written on it. Also, he is given a permutation of 1, 2, \\cdots, N: P_1, P_2, \\cdots, P_N.\n\nNow, he will choose one square and place the piece on that square. Then, he will make the following move some number of times between 1 and K (inclusive):\n\nIn one move, if the piece is now on Square i (1 \\leq i \\leq N), move it to Square P_i. Here, his score increases by C_{P_i}.\n\nHelp him by finding the maximum possible score at the end of the game. (The score is 0 at the beginning of the game.)\n\nConstraints\n\n2 \\leq N \\leq 5000\n\n1 \\leq K \\leq 10^9\n\n1 \\leq P_i \\leq N\n\nP_i \\neq i\n\nP_1, P_2, \\cdots, P_N are all different.\n\n-10^9 \\leq C_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nP_1 P_2 \\cdots P_N\nC_1 C_2 \\cdots C_N\n\nOutput\n\nPrint the maximum possible score at the end of the game.\n\nSample Input 1\n\n5 2\n2 4 5 1 3\n3 4 -10 -8 8\n\nSample Output 1\n\n8\n\nWhen we start at some square of our choice and make at most two moves, we have the following options:\n\nIf we start at Square 1, making one move sends the piece to Square 2, after which the score is 4. Making another move sends the piece to Square 4, after which the score is 4 + (-8) = -4.\n\nIf we start at Square 2, making one move sends the piece to Square 4, after which the score is -8. Making another move sends the piece to Square 1, after which the score is -8 + 3 = -5.\n\nIf we start at Square 3, making one move sends the piece to Square 5, after which the score is 8. Making another move sends the piece to Square 3, after which the score is 8 + (-10) = -2.\n\nIf we start at Square 4, making one move sends the piece to Square 1, after which the score is 3. Making another move sends the piece to Square 2, after which the score is 3 + 4 = 7.\n\nIf we start at Square 5, making one move sends the piece to Square 3, after which the score is -10. Making another move sends the piece to Square 5, after which the score is -10 + 8 = -2.\n\nThe maximum score achieved is 8.\n\nSample Input 2\n\n2 3\n2 1\n10 -7\n\nSample Output 2\n\n13\n\nSample Input 3\n\n3 3\n3 1 2\n-1000 -2000 -3000\n\nSample Output 3\n\n-1000\n\nWe have to make at least one move.\n\nSample Input 4\n\n10 58\n9 1 6 7 8 4 3 2 10 5\n695279662 988782657 -119067776 382975538 -151885171 -177220596 -169777795 37619092 389386780 980092719\n\nSample Output 4\n\n29507023469\n\nThe absolute value of the answer may be enormous.", "sample_input": "5 2\n2 4 5 1 3\n3 4 -10 -8 8\n"}, "reference_outputs": ["8\n"], "source_document_id": "p02585", "source_text": "Score : 400 points\n\nProblem Statement\n\nTakahashi will play a game using a piece on an array of squares numbered 1, 2, \\cdots, N. Square i has an integer C_i written on it. Also, he is given a permutation of 1, 2, \\cdots, N: P_1, P_2, \\cdots, P_N.\n\nNow, he will choose one square and place the piece on that square. Then, he will make the following move some number of times between 1 and K (inclusive):\n\nIn one move, if the piece is now on Square i (1 \\leq i \\leq N), move it to Square P_i. Here, his score increases by C_{P_i}.\n\nHelp him by finding the maximum possible score at the end of the game. (The score is 0 at the beginning of the game.)\n\nConstraints\n\n2 \\leq N \\leq 5000\n\n1 \\leq K \\leq 10^9\n\n1 \\leq P_i \\leq N\n\nP_i \\neq i\n\nP_1, P_2, \\cdots, P_N are all different.\n\n-10^9 \\leq C_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nP_1 P_2 \\cdots P_N\nC_1 C_2 \\cdots C_N\n\nOutput\n\nPrint the maximum possible score at the end of the game.\n\nSample Input 1\n\n5 2\n2 4 5 1 3\n3 4 -10 -8 8\n\nSample Output 1\n\n8\n\nWhen we start at some square of our choice and make at most two moves, we have the following options:\n\nIf we start at Square 1, making one move sends the piece to Square 2, after which the score is 4. Making another move sends the piece to Square 4, after which the score is 4 + (-8) = -4.\n\nIf we start at Square 2, making one move sends the piece to Square 4, after which the score is -8. Making another move sends the piece to Square 1, after which the score is -8 + 3 = -5.\n\nIf we start at Square 3, making one move sends the piece to Square 5, after which the score is 8. Making another move sends the piece to Square 3, after which the score is 8 + (-10) = -2.\n\nIf we start at Square 4, making one move sends the piece to Square 1, after which the score is 3. Making another move sends the piece to Square 2, after which the score is 3 + 4 = 7.\n\nIf we start at Square 5, making one move sends the piece to Square 3, after which the score is -10. Making another move sends the piece to Square 5, after which the score is -10 + 8 = -2.\n\nThe maximum score achieved is 8.\n\nSample Input 2\n\n2 3\n2 1\n10 -7\n\nSample Output 2\n\n13\n\nSample Input 3\n\n3 3\n3 1 2\n-1000 -2000 -3000\n\nSample Output 3\n\n-1000\n\nWe have to make at least one move.\n\nSample Input 4\n\n10 58\n9 1 6 7 8 4 3 2 10 5\n695279662 988782657 -119067776 382975538 -151885171 -177220596 -169777795 37619092 389386780 980092719\n\nSample Output 4\n\n29507023469\n\nThe absolute value of the answer may be enormous.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1385, "cpu_time_ms": 887, "memory_kb": 3476}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s397161546", "group_id": "codeNet:p02586", "input_text": "local read = setmetatable({}, {__index = function(t, k) local a = {} for i=1,#k do table.insert(a, '*'..string.sub(k, i, i)) end local r = io.read local u = table.unpack or unpack return function() return r(u(a)) end end})\nread.N = function(N) local t={} for i=1,N do t[i]=read.n() end return t end\nstring.totable = function(s) local t={} local u=string.sub for i=1,#s do t[i] = u(s, i, i) end return t end\nstring.split = function(s) local t={} for w in string.gmatch(s, \"[^%s]+\") do table.insert(t, w) end return (table.unpack or unpack)(t) end\nlocal function array(dimensi0n, default_val) assert(type(default_val) ~= 'table') local n=dimensi0n local m={}if default_val~=nil then m[1]={__index=function()return default_val end}end for i=2,n do m[i]={__index=function(p, k)local c=setmetatable({},m[i-1])rawset(p,k,c)return c end}end return setmetatable({},m[n])end\nlocal function tostringxx(o, depth) depth = depth or 0 if depth > 10 then return \"\" end if o == _G then return \"<_G>\" end local indent0 = (\" \"):rep((depth) * 2) local indent1 = (\" \"):rep((depth+1) * 2) local indent2= (\" \"):rep((depth+2) * 2) if type(o) == 'table' then local keys = {} local types = {} for k in pairs(o) do types[type(k)] = true table.insert(keys, k) end local types_count = 0 local lasttype for k in pairs(types) do types_count = types_count + 1 lasttype = k end if types_count == 1 and (lasttype == 'string' or lasttype == 'number') then table.sort(keys) end local inside = {} for i=1,#keys do local k = keys[i] local v = o[k] if type(k) == 'string' then k = string.format('%q', k) end table.insert(inside, indent1 .. '['..tostring(k)..'] = ' .. tostringxx(v, depth + 1)) end return '{\\n' .. table.concat(inside, ',\\n') .. '\\n' .. indent0 .. '}' else if type(o) == 'string' then o = string.format('%q', o) end return tostring(o) end end\nlocal function richtraceback() local x = 2 while true do local info = debug.getinfo(x) if not info then break end local fname = '<' .. info.short_src .. \":\" .. info.linedefined .. \">\" if info.name then fname = info.name end print(info.short_src .. \":\" .. info.currentline .. \": in \" .. (\"%q\"):format(fname)) print(\" LOCALS:\") local p = 1 while true do local name, val = debug.getlocal(x,p) if not name then break end print(\" \" .. name .. \": \" .. tostringxx(val, 3)) p = p + 1 end print(\" UPVALUES:\") for p=1,info.nups do local name, val = debug.getupvalue(info.func,p) if not name then break end print(\" \" .. name .. \": \" .. tostringxx(val, 3)) end x = x + 1 end end\nlocal function myassert(b) if not b then richtraceback() error(\"assertion failed\") end end \n--\nlocal max = math.max\n\nlocal R, C, K = read.nnn()\nlocal item = array(1,0)\nfor i=1,K do\n local r,c,v = read.nnn()\n item[r*C + c] = v\nend\n\nlocal target1\nlocal target2\nlocal function chmax1(g,val)\n target1[g] = max(target1[g], val)\nend\nlocal function chmax2(g,val)\n target2[g] = max(target2[g], val)\nend\nlocal dp = array(2,0)\n\ndp[1][0] = 0\ndp[1][1] = item[1*C+1]\nfor r=1,R do\n for c=1,C do\n target1 = dp[c]\n target2 = dp[c+1]\n local rval = item[r*C+c+1]\n local dval = item[(r+1)*C+c]\n local cur0 = target1[0]\n local cur1 = target1[1]\n local cur2 = target1[2]\n local cur3 = target1[3]\n target1[0] = 0\n target1[1] = 0\n target1[2] = 0\n target1[3] = 0\n chmax1(1,cur0+dval)\n chmax1(0,cur0)\n chmax1(1,cur1+dval)\n chmax1(0,cur1)\n chmax1(1,cur2+dval)\n chmax1(0,cur2)\n chmax1(1,cur3+dval)\n chmax1(0,cur3)\n chmax2(0+1,cur0+rval)\n chmax2(0,cur0)\n chmax2(1+1,cur1+rval)\n chmax2(1,cur1)\n chmax2(2+1,cur2+rval)\n chmax2(2,cur2)\n chmax2(3+1,cur3+rval)\n chmax2(3,cur3)\n end\nend\nprint(max(dp[C][0],dp[C][1],dp[C][2],dp[C][3]))", "language": "Lua", "metadata": {"date": 1597607931, "filename_ext": "lua", "original_language": "Lua (LuaJIT 2.1.0)", "problem_description_relpath": "problem_descriptions/p02586.html", "problem_id": "p02586", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02586/input.txt", "sample_output_relpath": "derived/input_output/data/p02586/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02586/Lua/s397161546.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s397161546", "user_id": "u162773977"}, "prompt_components": {"gold_output": "8\n", "input_to_evaluate": "local read = setmetatable({}, {__index = function(t, k) local a = {} for i=1,#k do table.insert(a, '*'..string.sub(k, i, i)) end local r = io.read local u = table.unpack or unpack return function() return r(u(a)) end end})\nread.N = function(N) local t={} for i=1,N do t[i]=read.n() end return t end\nstring.totable = function(s) local t={} local u=string.sub for i=1,#s do t[i] = u(s, i, i) end return t end\nstring.split = function(s) local t={} for w in string.gmatch(s, \"[^%s]+\") do table.insert(t, w) end return (table.unpack or unpack)(t) end\nlocal function array(dimensi0n, default_val) assert(type(default_val) ~= 'table') local n=dimensi0n local m={}if default_val~=nil then m[1]={__index=function()return default_val end}end for i=2,n do m[i]={__index=function(p, k)local c=setmetatable({},m[i-1])rawset(p,k,c)return c end}end return setmetatable({},m[n])end\nlocal function tostringxx(o, depth) depth = depth or 0 if depth > 10 then return \"\" end if o == _G then return \"<_G>\" end local indent0 = (\" \"):rep((depth) * 2) local indent1 = (\" \"):rep((depth+1) * 2) local indent2= (\" \"):rep((depth+2) * 2) if type(o) == 'table' then local keys = {} local types = {} for k in pairs(o) do types[type(k)] = true table.insert(keys, k) end local types_count = 0 local lasttype for k in pairs(types) do types_count = types_count + 1 lasttype = k end if types_count == 1 and (lasttype == 'string' or lasttype == 'number') then table.sort(keys) end local inside = {} for i=1,#keys do local k = keys[i] local v = o[k] if type(k) == 'string' then k = string.format('%q', k) end table.insert(inside, indent1 .. '['..tostring(k)..'] = ' .. tostringxx(v, depth + 1)) end return '{\\n' .. table.concat(inside, ',\\n') .. '\\n' .. indent0 .. '}' else if type(o) == 'string' then o = string.format('%q', o) end return tostring(o) end end\nlocal function richtraceback() local x = 2 while true do local info = debug.getinfo(x) if not info then break end local fname = '<' .. info.short_src .. \":\" .. info.linedefined .. \">\" if info.name then fname = info.name end print(info.short_src .. \":\" .. info.currentline .. \": in \" .. (\"%q\"):format(fname)) print(\" LOCALS:\") local p = 1 while true do local name, val = debug.getlocal(x,p) if not name then break end print(\" \" .. name .. \": \" .. tostringxx(val, 3)) p = p + 1 end print(\" UPVALUES:\") for p=1,info.nups do local name, val = debug.getupvalue(info.func,p) if not name then break end print(\" \" .. name .. \": \" .. tostringxx(val, 3)) end x = x + 1 end end\nlocal function myassert(b) if not b then richtraceback() error(\"assertion failed\") end end \n--\nlocal max = math.max\n\nlocal R, C, K = read.nnn()\nlocal item = array(1,0)\nfor i=1,K do\n local r,c,v = read.nnn()\n item[r*C + c] = v\nend\n\nlocal target1\nlocal target2\nlocal function chmax1(g,val)\n target1[g] = max(target1[g], val)\nend\nlocal function chmax2(g,val)\n target2[g] = max(target2[g], val)\nend\nlocal dp = array(2,0)\n\ndp[1][0] = 0\ndp[1][1] = item[1*C+1]\nfor r=1,R do\n for c=1,C do\n target1 = dp[c]\n target2 = dp[c+1]\n local rval = item[r*C+c+1]\n local dval = item[(r+1)*C+c]\n local cur0 = target1[0]\n local cur1 = target1[1]\n local cur2 = target1[2]\n local cur3 = target1[3]\n target1[0] = 0\n target1[1] = 0\n target1[2] = 0\n target1[3] = 0\n chmax1(1,cur0+dval)\n chmax1(0,cur0)\n chmax1(1,cur1+dval)\n chmax1(0,cur1)\n chmax1(1,cur2+dval)\n chmax1(0,cur2)\n chmax1(1,cur3+dval)\n chmax1(0,cur3)\n chmax2(0+1,cur0+rval)\n chmax2(0,cur0)\n chmax2(1+1,cur1+rval)\n chmax2(1,cur1)\n chmax2(2+1,cur2+rval)\n chmax2(2,cur2)\n chmax2(3+1,cur3+rval)\n chmax2(3,cur3)\n end\nend\nprint(max(dp[C][0],dp[C][1],dp[C][2],dp[C][3]))", "problem_context": "Score : 500 points\n\nProblem Statement\n\nThere are K items placed on a grid of squares with R rows and C columns. Let (i, j) denote the square at the i-th row (1 \\leq i \\leq R) and the j-th column (1 \\leq j \\leq C). The i-th item is at (r_i, c_i) and has the value v_i.\n\nTakahashi will begin at (1, 1), the start, and get to (R, C), the goal. When he is at (i, j), he can move to (i + 1, j) or (i, j + 1) (but cannot move to a non-existent square).\n\nHe can pick up items on the squares he visits, including the start and the goal, but at most three for each row. It is allowed to ignore the item on a square he visits.\n\nFind the maximum possible sum of the values of items he picks up.\n\nConstraints\n\n1 \\leq R, C \\leq 3000\n\n1 \\leq K \\leq \\min(2 \\times 10^5, R \\times C)\n\n1 \\leq r_i \\leq R\n\n1 \\leq c_i \\leq C\n\n(r_i, c_i) \\neq (r_j, c_j) (i \\neq j)\n\n1 \\leq v_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nR C K\nr_1 c_1 v_1\nr_2 c_2 v_2\n:\nr_K c_K v_K\n\nOutput\n\nPrint the maximum possible sum of the values of items Takahashi picks up.\n\nSample Input 1\n\n2 2 3\n1 1 3\n2 1 4\n1 2 5\n\nSample Output 1\n\n8\n\nHe has two ways to get to the goal:\n\nVisit (1, 1), (1, 2), and (2, 2), in this order. In this case, the total value of the items he can pick up is 3 + 5 = 8.\n\nVisit (1, 1), (2, 1), and (2, 2), in this order. In this case, the total value of the items he can pick up is 3 + 4 = 7.\n\nThus, the maximum possible sum of the values of items he picks up is 8.\n\nSample Input 2\n\n2 5 5\n1 1 3\n2 4 20\n1 2 1\n1 3 4\n1 4 2\n\nSample Output 2\n\n29\n\nWe have four items in the 1-st row. The optimal choices are as follows:\n\nVisit (1, 1) (1, 2), (1, 3), (1, 4), (2, 4), and (2, 5), in this order, and pick up all items except the one on (1, 2). Then, the total value of the items he picks up will be 3 + 4 + 2 + 20 = 29.\n\nSample Input 3\n\n4 5 10\n2 5 12\n1 5 12\n2 3 15\n1 2 20\n1 1 28\n2 4 26\n3 2 27\n4 5 21\n3 5 10\n1 3 10\n\nSample Output 3\n\n142", "sample_input": "2 2 3\n1 1 3\n2 1 4\n1 2 5\n"}, "reference_outputs": ["8\n"], "source_document_id": "p02586", "source_text": "Score : 500 points\n\nProblem Statement\n\nThere are K items placed on a grid of squares with R rows and C columns. Let (i, j) denote the square at the i-th row (1 \\leq i \\leq R) and the j-th column (1 \\leq j \\leq C). The i-th item is at (r_i, c_i) and has the value v_i.\n\nTakahashi will begin at (1, 1), the start, and get to (R, C), the goal. When he is at (i, j), he can move to (i + 1, j) or (i, j + 1) (but cannot move to a non-existent square).\n\nHe can pick up items on the squares he visits, including the start and the goal, but at most three for each row. It is allowed to ignore the item on a square he visits.\n\nFind the maximum possible sum of the values of items he picks up.\n\nConstraints\n\n1 \\leq R, C \\leq 3000\n\n1 \\leq K \\leq \\min(2 \\times 10^5, R \\times C)\n\n1 \\leq r_i \\leq R\n\n1 \\leq c_i \\leq C\n\n(r_i, c_i) \\neq (r_j, c_j) (i \\neq j)\n\n1 \\leq v_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nR C K\nr_1 c_1 v_1\nr_2 c_2 v_2\n:\nr_K c_K v_K\n\nOutput\n\nPrint the maximum possible sum of the values of items Takahashi picks up.\n\nSample Input 1\n\n2 2 3\n1 1 3\n2 1 4\n1 2 5\n\nSample Output 1\n\n8\n\nHe has two ways to get to the goal:\n\nVisit (1, 1), (1, 2), and (2, 2), in this order. In this case, the total value of the items he can pick up is 3 + 5 = 8.\n\nVisit (1, 1), (2, 1), and (2, 2), in this order. In this case, the total value of the items he can pick up is 3 + 4 = 7.\n\nThus, the maximum possible sum of the values of items he picks up is 8.\n\nSample Input 2\n\n2 5 5\n1 1 3\n2 4 20\n1 2 1\n1 3 4\n1 4 2\n\nSample Output 2\n\n29\n\nWe have four items in the 1-st row. The optimal choices are as follows:\n\nVisit (1, 1) (1, 2), (1, 3), (1, 4), (2, 4), and (2, 5), in this order, and pick up all items except the one on (1, 2). Then, the total value of the items he picks up will be 3 + 4 + 2 + 20 = 29.\n\nSample Input 3\n\n4 5 10\n2 5 12\n1 5 12\n2 3 15\n1 2 20\n1 1 28\n2 4 26\n3 2 27\n4 5 21\n3 5 10\n1 3 10\n\nSample Output 3\n\n142", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 3812, "cpu_time_ms": 694, "memory_kb": 16580}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s687044113", "group_id": "codeNet:p02586", "input_text": "local read = setmetatable({}, {__index = function(t, k) local a = {} for i=1,#k do table.insert(a, '*'..string.sub(k, i, i)) end local r = io.read local u = table.unpack or unpack return function() return r(u(a)) end end})\nread.N = function(N) local t={} for i=1,N do t[i]=read.n() end return t end\nstring.totable = function(s) local t={} local u=string.sub for i=1,#s do t[i] = u(s, i, i) end return t end\nstring.split = function(s) local t={} for w in string.gmatch(s, \"[^%s]+\") do table.insert(t, w) end return (table.unpack or unpack)(t) end\nlocal function array(dimensi0n, default_val) assert(type(default_val) ~= 'table') local n=dimensi0n local m={}if default_val~=nil then m[1]={__index=function()return default_val end}end for i=2,n do m[i]={__index=function(p, k)local c=setmetatable({},m[i-1])rawset(p,k,c)return c end}end return setmetatable({},m[n])end\nlocal function tostringxx(o, depth) depth = depth or 0 if depth > 10 then return \"\" end if o == _G then return \"<_G>\" end local indent0 = (\" \"):rep((depth) * 2) local indent1 = (\" \"):rep((depth+1) * 2) local indent2= (\" \"):rep((depth+2) * 2) if type(o) == 'table' then local keys = {} local types = {} for k in pairs(o) do types[type(k)] = true table.insert(keys, k) end local types_count = 0 local lasttype for k in pairs(types) do types_count = types_count + 1 lasttype = k end if types_count == 1 and (lasttype == 'string' or lasttype == 'number') then table.sort(keys) end local inside = {} for i=1,#keys do local k = keys[i] local v = o[k] if type(k) == 'string' then k = string.format('%q', k) end table.insert(inside, indent1 .. '['..tostring(k)..'] = ' .. tostringxx(v, depth + 1)) end return '{\\n' .. table.concat(inside, ',\\n') .. '\\n' .. indent0 .. '}' else if type(o) == 'string' then o = string.format('%q', o) end return tostring(o) end end\nlocal function richtraceback() local x = 2 while true do local info = debug.getinfo(x) if not info then break end local fname = '<' .. info.short_src .. \":\" .. info.linedefined .. \">\" if info.name then fname = info.name end print(info.short_src .. \":\" .. info.currentline .. \": in \" .. (\"%q\"):format(fname)) print(\" LOCALS:\") local p = 1 while true do local name, val = debug.getlocal(x,p) if not name then break end print(\" \" .. name .. \": \" .. tostringxx(val, 3)) p = p + 1 end print(\" UPVALUES:\") for p=1,info.nups do local name, val = debug.getupvalue(info.func,p) if not name then break end print(\" \" .. name .. \": \" .. tostringxx(val, 3)) end x = x + 1 end end\nlocal function myassert(b) if not b then richtraceback() error(\"assertion failed\") end end \n--\nlocal max = math.max\n\nlocal R, C, K = read.nnn()\nlocal item = array(1,0)\nfor i=1,K do\n local r,c,v = read.nnn()\n item[r*C + c] = v\nend\n\nlocal dp = array(2,0)\n\ndp[1][0] = 0\ndp[1][1] = item[1*C+1]\nfor r=1,R do\n for c=1,C do\n local target1 = dp[c]\n local target2 = dp[c+1]\n local function chmax1(g,val)\n target1[g] = max(target1[g], val)\n end\n local function chmax2(g,val)\n target2[g] = max(target2[g], val)\n end\n local rval = item[r*C+c+1]\n local dval = item[(r+1)*C+c]\n local cur0 = target1[0]\n local cur1 = target1[1]\n local cur2 = target1[2]\n local cur3 = target1[3]\n target1[0] = 0\n target1[1] = 0\n target1[2] = 0\n target1[3] = 0\n chmax1(1,cur0+dval)\n chmax1(0,cur0)\n chmax1(1,cur1+dval)\n chmax1(0,cur1)\n chmax1(1,cur2+dval)\n chmax1(0,cur2)\n chmax1(1,cur3+dval)\n chmax1(0,cur3)\n chmax2(0+1,cur0+rval)\n chmax2(0,cur0)\n chmax2(1+1,cur1+rval)\n chmax2(1,cur1)\n chmax2(2+1,cur2+rval)\n chmax2(2,cur2)\n chmax2(3+1,cur3+rval)\n chmax2(4,cur3)\n end\nend\nprint(max(dp[C][0],dp[C][1],dp[C][2],dp[C][3]))", "language": "Lua", "metadata": {"date": 1597606938, "filename_ext": "lua", "original_language": "Lua (LuaJIT 2.1.0)", "problem_description_relpath": "problem_descriptions/p02586.html", "problem_id": "p02586", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02586/input.txt", "sample_output_relpath": "derived/input_output/data/p02586/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02586/Lua/s687044113.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s687044113", "user_id": "u162773977"}, "prompt_components": {"gold_output": "8\n", "input_to_evaluate": "local read = setmetatable({}, {__index = function(t, k) local a = {} for i=1,#k do table.insert(a, '*'..string.sub(k, i, i)) end local r = io.read local u = table.unpack or unpack return function() return r(u(a)) end end})\nread.N = function(N) local t={} for i=1,N do t[i]=read.n() end return t end\nstring.totable = function(s) local t={} local u=string.sub for i=1,#s do t[i] = u(s, i, i) end return t end\nstring.split = function(s) local t={} for w in string.gmatch(s, \"[^%s]+\") do table.insert(t, w) end return (table.unpack or unpack)(t) end\nlocal function array(dimensi0n, default_val) assert(type(default_val) ~= 'table') local n=dimensi0n local m={}if default_val~=nil then m[1]={__index=function()return default_val end}end for i=2,n do m[i]={__index=function(p, k)local c=setmetatable({},m[i-1])rawset(p,k,c)return c end}end return setmetatable({},m[n])end\nlocal function tostringxx(o, depth) depth = depth or 0 if depth > 10 then return \"\" end if o == _G then return \"<_G>\" end local indent0 = (\" \"):rep((depth) * 2) local indent1 = (\" \"):rep((depth+1) * 2) local indent2= (\" \"):rep((depth+2) * 2) if type(o) == 'table' then local keys = {} local types = {} for k in pairs(o) do types[type(k)] = true table.insert(keys, k) end local types_count = 0 local lasttype for k in pairs(types) do types_count = types_count + 1 lasttype = k end if types_count == 1 and (lasttype == 'string' or lasttype == 'number') then table.sort(keys) end local inside = {} for i=1,#keys do local k = keys[i] local v = o[k] if type(k) == 'string' then k = string.format('%q', k) end table.insert(inside, indent1 .. '['..tostring(k)..'] = ' .. tostringxx(v, depth + 1)) end return '{\\n' .. table.concat(inside, ',\\n') .. '\\n' .. indent0 .. '}' else if type(o) == 'string' then o = string.format('%q', o) end return tostring(o) end end\nlocal function richtraceback() local x = 2 while true do local info = debug.getinfo(x) if not info then break end local fname = '<' .. info.short_src .. \":\" .. info.linedefined .. \">\" if info.name then fname = info.name end print(info.short_src .. \":\" .. info.currentline .. \": in \" .. (\"%q\"):format(fname)) print(\" LOCALS:\") local p = 1 while true do local name, val = debug.getlocal(x,p) if not name then break end print(\" \" .. name .. \": \" .. tostringxx(val, 3)) p = p + 1 end print(\" UPVALUES:\") for p=1,info.nups do local name, val = debug.getupvalue(info.func,p) if not name then break end print(\" \" .. name .. \": \" .. tostringxx(val, 3)) end x = x + 1 end end\nlocal function myassert(b) if not b then richtraceback() error(\"assertion failed\") end end \n--\nlocal max = math.max\n\nlocal R, C, K = read.nnn()\nlocal item = array(1,0)\nfor i=1,K do\n local r,c,v = read.nnn()\n item[r*C + c] = v\nend\n\nlocal dp = array(2,0)\n\ndp[1][0] = 0\ndp[1][1] = item[1*C+1]\nfor r=1,R do\n for c=1,C do\n local target1 = dp[c]\n local target2 = dp[c+1]\n local function chmax1(g,val)\n target1[g] = max(target1[g], val)\n end\n local function chmax2(g,val)\n target2[g] = max(target2[g], val)\n end\n local rval = item[r*C+c+1]\n local dval = item[(r+1)*C+c]\n local cur0 = target1[0]\n local cur1 = target1[1]\n local cur2 = target1[2]\n local cur3 = target1[3]\n target1[0] = 0\n target1[1] = 0\n target1[2] = 0\n target1[3] = 0\n chmax1(1,cur0+dval)\n chmax1(0,cur0)\n chmax1(1,cur1+dval)\n chmax1(0,cur1)\n chmax1(1,cur2+dval)\n chmax1(0,cur2)\n chmax1(1,cur3+dval)\n chmax1(0,cur3)\n chmax2(0+1,cur0+rval)\n chmax2(0,cur0)\n chmax2(1+1,cur1+rval)\n chmax2(1,cur1)\n chmax2(2+1,cur2+rval)\n chmax2(2,cur2)\n chmax2(3+1,cur3+rval)\n chmax2(4,cur3)\n end\nend\nprint(max(dp[C][0],dp[C][1],dp[C][2],dp[C][3]))", "problem_context": "Score : 500 points\n\nProblem Statement\n\nThere are K items placed on a grid of squares with R rows and C columns. Let (i, j) denote the square at the i-th row (1 \\leq i \\leq R) and the j-th column (1 \\leq j \\leq C). The i-th item is at (r_i, c_i) and has the value v_i.\n\nTakahashi will begin at (1, 1), the start, and get to (R, C), the goal. When he is at (i, j), he can move to (i + 1, j) or (i, j + 1) (but cannot move to a non-existent square).\n\nHe can pick up items on the squares he visits, including the start and the goal, but at most three for each row. It is allowed to ignore the item on a square he visits.\n\nFind the maximum possible sum of the values of items he picks up.\n\nConstraints\n\n1 \\leq R, C \\leq 3000\n\n1 \\leq K \\leq \\min(2 \\times 10^5, R \\times C)\n\n1 \\leq r_i \\leq R\n\n1 \\leq c_i \\leq C\n\n(r_i, c_i) \\neq (r_j, c_j) (i \\neq j)\n\n1 \\leq v_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nR C K\nr_1 c_1 v_1\nr_2 c_2 v_2\n:\nr_K c_K v_K\n\nOutput\n\nPrint the maximum possible sum of the values of items Takahashi picks up.\n\nSample Input 1\n\n2 2 3\n1 1 3\n2 1 4\n1 2 5\n\nSample Output 1\n\n8\n\nHe has two ways to get to the goal:\n\nVisit (1, 1), (1, 2), and (2, 2), in this order. In this case, the total value of the items he can pick up is 3 + 5 = 8.\n\nVisit (1, 1), (2, 1), and (2, 2), in this order. In this case, the total value of the items he can pick up is 3 + 4 = 7.\n\nThus, the maximum possible sum of the values of items he picks up is 8.\n\nSample Input 2\n\n2 5 5\n1 1 3\n2 4 20\n1 2 1\n1 3 4\n1 4 2\n\nSample Output 2\n\n29\n\nWe have four items in the 1-st row. The optimal choices are as follows:\n\nVisit (1, 1) (1, 2), (1, 3), (1, 4), (2, 4), and (2, 5), in this order, and pick up all items except the one on (1, 2). Then, the total value of the items he picks up will be 3 + 4 + 2 + 20 = 29.\n\nSample Input 3\n\n4 5 10\n2 5 12\n1 5 12\n2 3 15\n1 2 20\n1 1 28\n2 4 26\n3 2 27\n4 5 21\n3 5 10\n1 3 10\n\nSample Output 3\n\n142", "sample_input": "2 2 3\n1 1 3\n2 1 4\n1 2 5\n"}, "reference_outputs": ["8\n"], "source_document_id": "p02586", "source_text": "Score : 500 points\n\nProblem Statement\n\nThere are K items placed on a grid of squares with R rows and C columns. Let (i, j) denote the square at the i-th row (1 \\leq i \\leq R) and the j-th column (1 \\leq j \\leq C). The i-th item is at (r_i, c_i) and has the value v_i.\n\nTakahashi will begin at (1, 1), the start, and get to (R, C), the goal. When he is at (i, j), he can move to (i + 1, j) or (i, j + 1) (but cannot move to a non-existent square).\n\nHe can pick up items on the squares he visits, including the start and the goal, but at most three for each row. It is allowed to ignore the item on a square he visits.\n\nFind the maximum possible sum of the values of items he picks up.\n\nConstraints\n\n1 \\leq R, C \\leq 3000\n\n1 \\leq K \\leq \\min(2 \\times 10^5, R \\times C)\n\n1 \\leq r_i \\leq R\n\n1 \\leq c_i \\leq C\n\n(r_i, c_i) \\neq (r_j, c_j) (i \\neq j)\n\n1 \\leq v_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nR C K\nr_1 c_1 v_1\nr_2 c_2 v_2\n:\nr_K c_K v_K\n\nOutput\n\nPrint the maximum possible sum of the values of items Takahashi picks up.\n\nSample Input 1\n\n2 2 3\n1 1 3\n2 1 4\n1 2 5\n\nSample Output 1\n\n8\n\nHe has two ways to get to the goal:\n\nVisit (1, 1), (1, 2), and (2, 2), in this order. In this case, the total value of the items he can pick up is 3 + 5 = 8.\n\nVisit (1, 1), (2, 1), and (2, 2), in this order. In this case, the total value of the items he can pick up is 3 + 4 = 7.\n\nThus, the maximum possible sum of the values of items he picks up is 8.\n\nSample Input 2\n\n2 5 5\n1 1 3\n2 4 20\n1 2 1\n1 3 4\n1 4 2\n\nSample Output 2\n\n29\n\nWe have four items in the 1-st row. The optimal choices are as follows:\n\nVisit (1, 1) (1, 2), (1, 3), (1, 4), (2, 4), and (2, 5), in this order, and pick up all items except the one on (1, 2). Then, the total value of the items he picks up will be 3 + 4 + 2 + 20 = 29.\n\nSample Input 3\n\n4 5 10\n2 5 12\n1 5 12\n2 3 15\n1 2 20\n1 1 28\n2 4 26\n3 2 27\n4 5 21\n3 5 10\n1 3 10\n\nSample Output 3\n\n142", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 3844, "cpu_time_ms": 3308, "memory_kb": 18084}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s039535742", "group_id": "codeNet:p02586", "input_text": "local read = setmetatable({}, {__index = function(t, k) local a = {} for i=1,#k do table.insert(a, '*'..string.sub(k, i, i)) end local r = io.read local u = table.unpack or unpack return function() return r(u(a)) end end})\nread.N = function(N) local t={} for i=1,N do t[i]=read.n() end return t end\nstring.totable = function(s) local t={} local u=string.sub for i=1,#s do t[i] = u(s, i, i) end return t end\nstring.split = function(s) local t={} for w in string.gmatch(s, \"[^%s]+\") do table.insert(t, w) end return (table.unpack or unpack)(t) end\nlocal function array(dimensi0n, default_val) assert(type(default_val) ~= 'table') local n=dimensi0n local m={}if default_val~=nil then m[1]={__index=function()return default_val end}end for i=2,n do m[i]={__index=function(p, k)local c=setmetatable({},m[i-1])rawset(p,k,c)return c end}end return setmetatable({},m[n])end\nlocal function tostringxx(o, depth) depth = depth or 0 if depth > 10 then return \"\" end if o == _G then return \"<_G>\" end local indent0 = (\" \"):rep((depth) * 2) local indent1 = (\" \"):rep((depth+1) * 2) local indent2= (\" \"):rep((depth+2) * 2) if type(o) == 'table' then local keys = {} local types = {} for k in pairs(o) do types[type(k)] = true table.insert(keys, k) end local types_count = 0 local lasttype for k in pairs(types) do types_count = types_count + 1 lasttype = k end if types_count == 1 and (lasttype == 'string' or lasttype == 'number') then table.sort(keys) end local inside = {} for i=1,#keys do local k = keys[i] local v = o[k] if type(k) == 'string' then k = string.format('%q', k) end table.insert(inside, indent1 .. '['..tostring(k)..'] = ' .. tostringxx(v, depth + 1)) end return '{\\n' .. table.concat(inside, ',\\n') .. '\\n' .. indent0 .. '}' else if type(o) == 'string' then o = string.format('%q', o) end return tostring(o) end end\nlocal function richtraceback() local x = 2 while true do local info = debug.getinfo(x) if not info then break end local fname = '<' .. info.short_src .. \":\" .. info.linedefined .. \">\" if info.name then fname = info.name end print(info.short_src .. \":\" .. info.currentline .. \": in \" .. (\"%q\"):format(fname)) print(\" LOCALS:\") local p = 1 while true do local name, val = debug.getlocal(x,p) if not name then break end print(\" \" .. name .. \": \" .. tostringxx(val, 3)) p = p + 1 end print(\" UPVALUES:\") for p=1,info.nups do local name, val = debug.getupvalue(info.func,p) if not name then break end print(\" \" .. name .. \": \" .. tostringxx(val, 3)) end x = x + 1 end end\nlocal function myassert(b) if not b then richtraceback() error(\"assertion failed\") end end \n--\nlocal max = math.max\n\nlocal R, C, K = read.nnn()\nlocal item = array(1,0)\nfor i=1,K do\n local r,c,v = read.nnn()\n item[r*C + c] = v\nend\n\nlocal dp,dp_next = array(2,0),array(2,0)\nlocal function chmax1(c,g,val)\n dp[c][g] = max(dp[c][g], val)\nend\nlocal function chmax2(c,g,val)\n dp_next[c][g] = max(dp_next[c][g], val)\nend\n\ndp[1][0] = 0\ndp[1][1] = item[1*C+1]\nfor r=1,R do\n for c=1,C do\n for g=0,3 do\n dp_next[c][g] = 0\n end\n for g=0,3 do\n local curval = dp[c][g]\n chmax1(c+1,g+1,curval+item[r*C+c+1])\n chmax1(c+1,g,curval)\n chmax2(c,1,curval+item[(r+1)*C+c])\n chmax2(c,0,curval)\n end\n end\n dp, dp_next = dp_next, dp\nend\nprint(max(dp[C][0],dp[C][1],dp[C][2],dp[C][3]))", "language": "Lua", "metadata": {"date": 1597583602, "filename_ext": "lua", "original_language": "Lua (LuaJIT 2.1.0)", "problem_description_relpath": "problem_descriptions/p02586.html", "problem_id": "p02586", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02586/input.txt", "sample_output_relpath": "derived/input_output/data/p02586/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02586/Lua/s039535742.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s039535742", "user_id": "u162773977"}, "prompt_components": {"gold_output": "8\n", "input_to_evaluate": "local read = setmetatable({}, {__index = function(t, k) local a = {} for i=1,#k do table.insert(a, '*'..string.sub(k, i, i)) end local r = io.read local u = table.unpack or unpack return function() return r(u(a)) end end})\nread.N = function(N) local t={} for i=1,N do t[i]=read.n() end return t end\nstring.totable = function(s) local t={} local u=string.sub for i=1,#s do t[i] = u(s, i, i) end return t end\nstring.split = function(s) local t={} for w in string.gmatch(s, \"[^%s]+\") do table.insert(t, w) end return (table.unpack or unpack)(t) end\nlocal function array(dimensi0n, default_val) assert(type(default_val) ~= 'table') local n=dimensi0n local m={}if default_val~=nil then m[1]={__index=function()return default_val end}end for i=2,n do m[i]={__index=function(p, k)local c=setmetatable({},m[i-1])rawset(p,k,c)return c end}end return setmetatable({},m[n])end\nlocal function tostringxx(o, depth) depth = depth or 0 if depth > 10 then return \"\" end if o == _G then return \"<_G>\" end local indent0 = (\" \"):rep((depth) * 2) local indent1 = (\" \"):rep((depth+1) * 2) local indent2= (\" \"):rep((depth+2) * 2) if type(o) == 'table' then local keys = {} local types = {} for k in pairs(o) do types[type(k)] = true table.insert(keys, k) end local types_count = 0 local lasttype for k in pairs(types) do types_count = types_count + 1 lasttype = k end if types_count == 1 and (lasttype == 'string' or lasttype == 'number') then table.sort(keys) end local inside = {} for i=1,#keys do local k = keys[i] local v = o[k] if type(k) == 'string' then k = string.format('%q', k) end table.insert(inside, indent1 .. '['..tostring(k)..'] = ' .. tostringxx(v, depth + 1)) end return '{\\n' .. table.concat(inside, ',\\n') .. '\\n' .. indent0 .. '}' else if type(o) == 'string' then o = string.format('%q', o) end return tostring(o) end end\nlocal function richtraceback() local x = 2 while true do local info = debug.getinfo(x) if not info then break end local fname = '<' .. info.short_src .. \":\" .. info.linedefined .. \">\" if info.name then fname = info.name end print(info.short_src .. \":\" .. info.currentline .. \": in \" .. (\"%q\"):format(fname)) print(\" LOCALS:\") local p = 1 while true do local name, val = debug.getlocal(x,p) if not name then break end print(\" \" .. name .. \": \" .. tostringxx(val, 3)) p = p + 1 end print(\" UPVALUES:\") for p=1,info.nups do local name, val = debug.getupvalue(info.func,p) if not name then break end print(\" \" .. name .. \": \" .. tostringxx(val, 3)) end x = x + 1 end end\nlocal function myassert(b) if not b then richtraceback() error(\"assertion failed\") end end \n--\nlocal max = math.max\n\nlocal R, C, K = read.nnn()\nlocal item = array(1,0)\nfor i=1,K do\n local r,c,v = read.nnn()\n item[r*C + c] = v\nend\n\nlocal dp,dp_next = array(2,0),array(2,0)\nlocal function chmax1(c,g,val)\n dp[c][g] = max(dp[c][g], val)\nend\nlocal function chmax2(c,g,val)\n dp_next[c][g] = max(dp_next[c][g], val)\nend\n\ndp[1][0] = 0\ndp[1][1] = item[1*C+1]\nfor r=1,R do\n for c=1,C do\n for g=0,3 do\n dp_next[c][g] = 0\n end\n for g=0,3 do\n local curval = dp[c][g]\n chmax1(c+1,g+1,curval+item[r*C+c+1])\n chmax1(c+1,g,curval)\n chmax2(c,1,curval+item[(r+1)*C+c])\n chmax2(c,0,curval)\n end\n end\n dp, dp_next = dp_next, dp\nend\nprint(max(dp[C][0],dp[C][1],dp[C][2],dp[C][3]))", "problem_context": "Score : 500 points\n\nProblem Statement\n\nThere are K items placed on a grid of squares with R rows and C columns. Let (i, j) denote the square at the i-th row (1 \\leq i \\leq R) and the j-th column (1 \\leq j \\leq C). The i-th item is at (r_i, c_i) and has the value v_i.\n\nTakahashi will begin at (1, 1), the start, and get to (R, C), the goal. When he is at (i, j), he can move to (i + 1, j) or (i, j + 1) (but cannot move to a non-existent square).\n\nHe can pick up items on the squares he visits, including the start and the goal, but at most three for each row. It is allowed to ignore the item on a square he visits.\n\nFind the maximum possible sum of the values of items he picks up.\n\nConstraints\n\n1 \\leq R, C \\leq 3000\n\n1 \\leq K \\leq \\min(2 \\times 10^5, R \\times C)\n\n1 \\leq r_i \\leq R\n\n1 \\leq c_i \\leq C\n\n(r_i, c_i) \\neq (r_j, c_j) (i \\neq j)\n\n1 \\leq v_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nR C K\nr_1 c_1 v_1\nr_2 c_2 v_2\n:\nr_K c_K v_K\n\nOutput\n\nPrint the maximum possible sum of the values of items Takahashi picks up.\n\nSample Input 1\n\n2 2 3\n1 1 3\n2 1 4\n1 2 5\n\nSample Output 1\n\n8\n\nHe has two ways to get to the goal:\n\nVisit (1, 1), (1, 2), and (2, 2), in this order. In this case, the total value of the items he can pick up is 3 + 5 = 8.\n\nVisit (1, 1), (2, 1), and (2, 2), in this order. In this case, the total value of the items he can pick up is 3 + 4 = 7.\n\nThus, the maximum possible sum of the values of items he picks up is 8.\n\nSample Input 2\n\n2 5 5\n1 1 3\n2 4 20\n1 2 1\n1 3 4\n1 4 2\n\nSample Output 2\n\n29\n\nWe have four items in the 1-st row. The optimal choices are as follows:\n\nVisit (1, 1) (1, 2), (1, 3), (1, 4), (2, 4), and (2, 5), in this order, and pick up all items except the one on (1, 2). Then, the total value of the items he picks up will be 3 + 4 + 2 + 20 = 29.\n\nSample Input 3\n\n4 5 10\n2 5 12\n1 5 12\n2 3 15\n1 2 20\n1 1 28\n2 4 26\n3 2 27\n4 5 21\n3 5 10\n1 3 10\n\nSample Output 3\n\n142", "sample_input": "2 2 3\n1 1 3\n2 1 4\n1 2 5\n"}, "reference_outputs": ["8\n"], "source_document_id": "p02586", "source_text": "Score : 500 points\n\nProblem Statement\n\nThere are K items placed on a grid of squares with R rows and C columns. Let (i, j) denote the square at the i-th row (1 \\leq i \\leq R) and the j-th column (1 \\leq j \\leq C). The i-th item is at (r_i, c_i) and has the value v_i.\n\nTakahashi will begin at (1, 1), the start, and get to (R, C), the goal. When he is at (i, j), he can move to (i + 1, j) or (i, j + 1) (but cannot move to a non-existent square).\n\nHe can pick up items on the squares he visits, including the start and the goal, but at most three for each row. It is allowed to ignore the item on a square he visits.\n\nFind the maximum possible sum of the values of items he picks up.\n\nConstraints\n\n1 \\leq R, C \\leq 3000\n\n1 \\leq K \\leq \\min(2 \\times 10^5, R \\times C)\n\n1 \\leq r_i \\leq R\n\n1 \\leq c_i \\leq C\n\n(r_i, c_i) \\neq (r_j, c_j) (i \\neq j)\n\n1 \\leq v_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nR C K\nr_1 c_1 v_1\nr_2 c_2 v_2\n:\nr_K c_K v_K\n\nOutput\n\nPrint the maximum possible sum of the values of items Takahashi picks up.\n\nSample Input 1\n\n2 2 3\n1 1 3\n2 1 4\n1 2 5\n\nSample Output 1\n\n8\n\nHe has two ways to get to the goal:\n\nVisit (1, 1), (1, 2), and (2, 2), in this order. In this case, the total value of the items he can pick up is 3 + 5 = 8.\n\nVisit (1, 1), (2, 1), and (2, 2), in this order. In this case, the total value of the items he can pick up is 3 + 4 = 7.\n\nThus, the maximum possible sum of the values of items he picks up is 8.\n\nSample Input 2\n\n2 5 5\n1 1 3\n2 4 20\n1 2 1\n1 3 4\n1 4 2\n\nSample Output 2\n\n29\n\nWe have four items in the 1-st row. The optimal choices are as follows:\n\nVisit (1, 1) (1, 2), (1, 3), (1, 4), (2, 4), and (2, 5), in this order, and pick up all items except the one on (1, 2). Then, the total value of the items he picks up will be 3 + 4 + 2 + 20 = 29.\n\nSample Input 3\n\n4 5 10\n2 5 12\n1 5 12\n2 3 15\n1 2 20\n1 1 28\n2 4 26\n3 2 27\n4 5 21\n3 5 10\n1 3 10\n\nSample Output 3\n\n142", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 3373, "cpu_time_ms": 3308, "memory_kb": 16596}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s802969047", "group_id": "codeNet:p02586", "input_text": "local mmi, mma = math.min, math.max\nlocal r, c, k = io.read(\"*n\", \"*n\", \"*n\")\nlocal item_row = {}\nfor i = 1, r do\n item_row[i] = {}\nend\nfor i = 1, k do\n local ra, ca, v = io.read(\"*n\", \"*n\", \"*n\")\n table.insert(item_row[ra], {ca, v})\nend\nfor i = 1, r do\n table.sort(item_row[i], function(a, b) return a[1] < b[1] end)\nend\n\nlocal v1, v2, v3 = 0, 0, 0\nlocal function box_reset(val)\n v1, v2, v3 = val, 0, 0\nend\nlocal function box_update(val)\n if val <= v3 then return end\n v3 = val\n if val <= v2 then return end\n v2, v3 = val, v2\n if v1 < val then\n v1, v2 = val, v1\n end\nend\nlocal function getboxval()\n return v1 + v2 + v3\nend\n\nlocal tbl, tbl2 = {}, {}\nfor i = 1, r do\n if i == 1 then\n for j = 1, c do\n tbl[j] = 0\n tbl2[j] = 0\n end\n else\n for j = 1, c do\n tbl[j] = tbl2[j]\n end\n end\n local item = item_row[i]\n for j = 1, #item do\n local col, val = item[j][1], item[j][2]\n box_reset(val)\n local baseval = tbl[col]\n tbl2[col] = mma(tbl2[col], baseval + getboxval())\n for k = j + 1, #item do\n local c2, v2 = item[k][1], item[k][2]\n box_update(v2)\n tbl2[c2] = mma(tbl2[c2], baseval + getboxval())\n end\n end\n for j = 2, c do\n tbl2[j] = mma(tbl2[j], tbl2[j - 1])\n end\nend\nprint(tbl2[c])\n", "language": "Lua", "metadata": {"date": 1597544763, "filename_ext": "lua", "original_language": "Lua (LuaJIT 2.1.0)", "problem_description_relpath": "problem_descriptions/p02586.html", "problem_id": "p02586", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02586/input.txt", "sample_output_relpath": "derived/input_output/data/p02586/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02586/Lua/s802969047.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s802969047", "user_id": "u120582723"}, "prompt_components": {"gold_output": "8\n", "input_to_evaluate": "local mmi, mma = math.min, math.max\nlocal r, c, k = io.read(\"*n\", \"*n\", \"*n\")\nlocal item_row = {}\nfor i = 1, r do\n item_row[i] = {}\nend\nfor i = 1, k do\n local ra, ca, v = io.read(\"*n\", \"*n\", \"*n\")\n table.insert(item_row[ra], {ca, v})\nend\nfor i = 1, r do\n table.sort(item_row[i], function(a, b) return a[1] < b[1] end)\nend\n\nlocal v1, v2, v3 = 0, 0, 0\nlocal function box_reset(val)\n v1, v2, v3 = val, 0, 0\nend\nlocal function box_update(val)\n if val <= v3 then return end\n v3 = val\n if val <= v2 then return end\n v2, v3 = val, v2\n if v1 < val then\n v1, v2 = val, v1\n end\nend\nlocal function getboxval()\n return v1 + v2 + v3\nend\n\nlocal tbl, tbl2 = {}, {}\nfor i = 1, r do\n if i == 1 then\n for j = 1, c do\n tbl[j] = 0\n tbl2[j] = 0\n end\n else\n for j = 1, c do\n tbl[j] = tbl2[j]\n end\n end\n local item = item_row[i]\n for j = 1, #item do\n local col, val = item[j][1], item[j][2]\n box_reset(val)\n local baseval = tbl[col]\n tbl2[col] = mma(tbl2[col], baseval + getboxval())\n for k = j + 1, #item do\n local c2, v2 = item[k][1], item[k][2]\n box_update(v2)\n tbl2[c2] = mma(tbl2[c2], baseval + getboxval())\n end\n end\n for j = 2, c do\n tbl2[j] = mma(tbl2[j], tbl2[j - 1])\n end\nend\nprint(tbl2[c])\n", "problem_context": "Score : 500 points\n\nProblem Statement\n\nThere are K items placed on a grid of squares with R rows and C columns. Let (i, j) denote the square at the i-th row (1 \\leq i \\leq R) and the j-th column (1 \\leq j \\leq C). The i-th item is at (r_i, c_i) and has the value v_i.\n\nTakahashi will begin at (1, 1), the start, and get to (R, C), the goal. When he is at (i, j), he can move to (i + 1, j) or (i, j + 1) (but cannot move to a non-existent square).\n\nHe can pick up items on the squares he visits, including the start and the goal, but at most three for each row. It is allowed to ignore the item on a square he visits.\n\nFind the maximum possible sum of the values of items he picks up.\n\nConstraints\n\n1 \\leq R, C \\leq 3000\n\n1 \\leq K \\leq \\min(2 \\times 10^5, R \\times C)\n\n1 \\leq r_i \\leq R\n\n1 \\leq c_i \\leq C\n\n(r_i, c_i) \\neq (r_j, c_j) (i \\neq j)\n\n1 \\leq v_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nR C K\nr_1 c_1 v_1\nr_2 c_2 v_2\n:\nr_K c_K v_K\n\nOutput\n\nPrint the maximum possible sum of the values of items Takahashi picks up.\n\nSample Input 1\n\n2 2 3\n1 1 3\n2 1 4\n1 2 5\n\nSample Output 1\n\n8\n\nHe has two ways to get to the goal:\n\nVisit (1, 1), (1, 2), and (2, 2), in this order. In this case, the total value of the items he can pick up is 3 + 5 = 8.\n\nVisit (1, 1), (2, 1), and (2, 2), in this order. In this case, the total value of the items he can pick up is 3 + 4 = 7.\n\nThus, the maximum possible sum of the values of items he picks up is 8.\n\nSample Input 2\n\n2 5 5\n1 1 3\n2 4 20\n1 2 1\n1 3 4\n1 4 2\n\nSample Output 2\n\n29\n\nWe have four items in the 1-st row. The optimal choices are as follows:\n\nVisit (1, 1) (1, 2), (1, 3), (1, 4), (2, 4), and (2, 5), in this order, and pick up all items except the one on (1, 2). Then, the total value of the items he picks up will be 3 + 4 + 2 + 20 = 29.\n\nSample Input 3\n\n4 5 10\n2 5 12\n1 5 12\n2 3 15\n1 2 20\n1 1 28\n2 4 26\n3 2 27\n4 5 21\n3 5 10\n1 3 10\n\nSample Output 3\n\n142", "sample_input": "2 2 3\n1 1 3\n2 1 4\n1 2 5\n"}, "reference_outputs": ["8\n"], "source_document_id": "p02586", "source_text": "Score : 500 points\n\nProblem Statement\n\nThere are K items placed on a grid of squares with R rows and C columns. Let (i, j) denote the square at the i-th row (1 \\leq i \\leq R) and the j-th column (1 \\leq j \\leq C). The i-th item is at (r_i, c_i) and has the value v_i.\n\nTakahashi will begin at (1, 1), the start, and get to (R, C), the goal. When he is at (i, j), he can move to (i + 1, j) or (i, j + 1) (but cannot move to a non-existent square).\n\nHe can pick up items on the squares he visits, including the start and the goal, but at most three for each row. It is allowed to ignore the item on a square he visits.\n\nFind the maximum possible sum of the values of items he picks up.\n\nConstraints\n\n1 \\leq R, C \\leq 3000\n\n1 \\leq K \\leq \\min(2 \\times 10^5, R \\times C)\n\n1 \\leq r_i \\leq R\n\n1 \\leq c_i \\leq C\n\n(r_i, c_i) \\neq (r_j, c_j) (i \\neq j)\n\n1 \\leq v_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nR C K\nr_1 c_1 v_1\nr_2 c_2 v_2\n:\nr_K c_K v_K\n\nOutput\n\nPrint the maximum possible sum of the values of items Takahashi picks up.\n\nSample Input 1\n\n2 2 3\n1 1 3\n2 1 4\n1 2 5\n\nSample Output 1\n\n8\n\nHe has two ways to get to the goal:\n\nVisit (1, 1), (1, 2), and (2, 2), in this order. In this case, the total value of the items he can pick up is 3 + 5 = 8.\n\nVisit (1, 1), (2, 1), and (2, 2), in this order. In this case, the total value of the items he can pick up is 3 + 4 = 7.\n\nThus, the maximum possible sum of the values of items he picks up is 8.\n\nSample Input 2\n\n2 5 5\n1 1 3\n2 4 20\n1 2 1\n1 3 4\n1 4 2\n\nSample Output 2\n\n29\n\nWe have four items in the 1-st row. The optimal choices are as follows:\n\nVisit (1, 1) (1, 2), (1, 3), (1, 4), (2, 4), and (2, 5), in this order, and pick up all items except the one on (1, 2). Then, the total value of the items he picks up will be 3 + 4 + 2 + 20 = 29.\n\nSample Input 3\n\n4 5 10\n2 5 12\n1 5 12\n2 3 15\n1 2 20\n1 1 28\n2 4 26\n3 2 27\n4 5 21\n3 5 10\n1 3 10\n\nSample Output 3\n\n142", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1264, "cpu_time_ms": 2909, "memory_kb": 18080}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s877357129", "group_id": "codeNet:p02588", "input_text": "local mmi, mma = math.min, math.max\nlocal bls, brs = bit.lshift, bit.rshift\nlocal mfl, mce = math.floor, math.ceil\n\nlocal function getgcd(x, y)\n while 0 < x do\n x, y = y % x, x\n end\n return y\nend\n\nlocal t2, t5 = {}, {}\nlocal t2min, t2max, t5min, t5max = 0, 0, 0, 0\n\nlocal n = io.read(\"*n\", \"*l\")\nfor i = 1, n do\n local s = io.read()\n local c2, c5 = 0, 0\n if s:find(\"%.\") then\n local x, y = s:match(\"(%d+)%.(%d+)\")\n x = tonumber(x)\n local dig = #y\n local denom = 1\n for j = 1, #y do\n denom = denom * 10\n end\n y = tonumber(y)\n local gcd = getgcd(denom, y)\n denom = mfl(denom / gcd)\n y = mfl(y / gcd)\n local a = x * denom + y\n local b = denom\n\n while a % 2 == 0 do\n a = mfl(a / 2)\n c2 = c2 + 1\n end\n while a % 5 == 0 do\n a = mfl(a / 5)\n c5 = c5 + 1\n end\n while b % 2 == 0 do\n b = mfl(b / 2)\n c2 = c2 - 1\n end\n while b % 5 == 0 do\n b = mfl(b / 5)\n c5 = c5 - 1\n end\n else\n local x = tonumber(s)\n while x % 2 == 0 do\n x = mfl(x / 2)\n c2 = c2 + 1\n end\n while x % 5 == 0 do\n x = mfl(x / 5)\n c5 = c5 + 1\n end\n end\n t2[i] = c2\n t5[i] = c5\n t2min = mmi(t2min, c2)\n t2max = mma(t2max, c2)\n t5min = mmi(t5min, c5)\n t5max = mma(t5max, c5)\nend\nlocal t = {}\nlocal wid2 = t2max - t2min + 1\nlocal wid5 = t5max - t5min + 1\nlocal sz = wid2 * wid5\nfor i = 1, sz do\n t[i] = 0\nend\nlocal ret = 0\nfor i = 1, n do\n local c2, c5 = t2[i], t5[i]\n local need2, need5 = mma(t2min, -c2), mma(t5min, -c5)\n for j = need2, t2max do\n for k = need5, t5max do\n local idx = (j - t2min) * wid5 + (k - t5min + 1)\n ret = ret + t[idx]\n end\n end\n do\n local idx = (c2 - t2min) * wid5 + (c5 - t5min + 1)\n t[idx] = t[idx] + 1\n end\nend\nprint(ret)\n", "language": "Lua", "metadata": {"date": 1597030947, "filename_ext": "lua", "original_language": "Lua (LuaJIT 2.1.0)", "problem_description_relpath": "problem_descriptions/p02588.html", "problem_id": "p02588", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02588/input.txt", "sample_output_relpath": "derived/input_output/data/p02588/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02588/Lua/s877357129.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s877357129", "user_id": "u120582723"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "local mmi, mma = math.min, math.max\nlocal bls, brs = bit.lshift, bit.rshift\nlocal mfl, mce = math.floor, math.ceil\n\nlocal function getgcd(x, y)\n while 0 < x do\n x, y = y % x, x\n end\n return y\nend\n\nlocal t2, t5 = {}, {}\nlocal t2min, t2max, t5min, t5max = 0, 0, 0, 0\n\nlocal n = io.read(\"*n\", \"*l\")\nfor i = 1, n do\n local s = io.read()\n local c2, c5 = 0, 0\n if s:find(\"%.\") then\n local x, y = s:match(\"(%d+)%.(%d+)\")\n x = tonumber(x)\n local dig = #y\n local denom = 1\n for j = 1, #y do\n denom = denom * 10\n end\n y = tonumber(y)\n local gcd = getgcd(denom, y)\n denom = mfl(denom / gcd)\n y = mfl(y / gcd)\n local a = x * denom + y\n local b = denom\n\n while a % 2 == 0 do\n a = mfl(a / 2)\n c2 = c2 + 1\n end\n while a % 5 == 0 do\n a = mfl(a / 5)\n c5 = c5 + 1\n end\n while b % 2 == 0 do\n b = mfl(b / 2)\n c2 = c2 - 1\n end\n while b % 5 == 0 do\n b = mfl(b / 5)\n c5 = c5 - 1\n end\n else\n local x = tonumber(s)\n while x % 2 == 0 do\n x = mfl(x / 2)\n c2 = c2 + 1\n end\n while x % 5 == 0 do\n x = mfl(x / 5)\n c5 = c5 + 1\n end\n end\n t2[i] = c2\n t5[i] = c5\n t2min = mmi(t2min, c2)\n t2max = mma(t2max, c2)\n t5min = mmi(t5min, c5)\n t5max = mma(t5max, c5)\nend\nlocal t = {}\nlocal wid2 = t2max - t2min + 1\nlocal wid5 = t5max - t5min + 1\nlocal sz = wid2 * wid5\nfor i = 1, sz do\n t[i] = 0\nend\nlocal ret = 0\nfor i = 1, n do\n local c2, c5 = t2[i], t5[i]\n local need2, need5 = mma(t2min, -c2), mma(t5min, -c5)\n for j = need2, t2max do\n for k = need5, t5max do\n local idx = (j - t2min) * wid5 + (k - t5min + 1)\n ret = ret + t[idx]\n end\n end\n do\n local idx = (c2 - t2min) * wid5 + (c5 - t5min + 1)\n t[idx] = t[idx] + 1\n end\nend\nprint(ret)\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nYou are given N real values A_1, A_2, \\ldots, A_N.\nCompute the number of pairs of indices (i, j)\nsuch that i < j and the product A_i \\cdot A_j is integer.\n\nConstraints\n\n2 \\leq N \\leq 200\\,000\n\n0 < A_i < 10^4\n\nA_i is given with at most 9 digits after the decimal.\n\nInput\n\nInput is given from Standard Input in the following format.\n\nN\nA_1\nA_2\n\\vdots\nA_N\n\nOutput\n\nPrint the number of pairs with integer product A_i \\cdot A_j (and i < j).\n\nSample Input 1\n\n5\n7.5\n2.4\n17.000000001\n17\n16.000000000\n\nSample Output 1\n\n3\n\nThere are 3 pairs with integer product:\n\n7.5 \\cdot 2.4 = 18\n\n7.5 \\cdot 16 = 120\n\n17 \\cdot 16 = 272\n\nSample Input 2\n\n11\n0.9\n1\n1\n1.25\n2.30000\n5\n70\n0.000000001\n9999.999999999\n0.999999999\n1.000000001\n\nSample Output 2\n\n8", "sample_input": "5\n7.5\n2.4\n17.000000001\n17\n16.000000000\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02588", "source_text": "Score : 300 points\n\nProblem Statement\n\nYou are given N real values A_1, A_2, \\ldots, A_N.\nCompute the number of pairs of indices (i, j)\nsuch that i < j and the product A_i \\cdot A_j is integer.\n\nConstraints\n\n2 \\leq N \\leq 200\\,000\n\n0 < A_i < 10^4\n\nA_i is given with at most 9 digits after the decimal.\n\nInput\n\nInput is given from Standard Input in the following format.\n\nN\nA_1\nA_2\n\\vdots\nA_N\n\nOutput\n\nPrint the number of pairs with integer product A_i \\cdot A_j (and i < j).\n\nSample Input 1\n\n5\n7.5\n2.4\n17.000000001\n17\n16.000000000\n\nSample Output 1\n\n3\n\nThere are 3 pairs with integer product:\n\n7.5 \\cdot 2.4 = 18\n\n7.5 \\cdot 16 = 120\n\n17 \\cdot 16 = 272\n\nSample Input 2\n\n11\n0.9\n1\n1\n1.25\n2.30000\n5\n70\n0.000000001\n9999.999999999\n0.999999999\n1.000000001\n\nSample Output 2\n\n8", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1785, "cpu_time_ms": 282, "memory_kb": 9436}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s780419970", "group_id": "codeNet:p02590", "input_text": "local mfl = math.floor\nlocal TranFFT = {}\n\nTranFFT.initialize = function(self)\n self.size = 19\n -- 2^19 = 524288\n self.n = 524288\n -- 40003698689: prime,\n -- 40003698689 % 524288 = 1\n self.mod = 40003698689\n -- (463881^524288) % mod = 1\n self.w = 463881\n -- (40003622388 * 524288) % mod = 1\n self.ninv = 40003622388\n -- (1547695164 * 463881) % mod = 1\n self.winv = 1547695164\n\n self.p2 = {1}\n for i = 2, self.size do\n self.p2[i] = self.p2[i - 1] * 2\n end\n self.binv = {}\n for i = 1, self.n do\n local y, z = 0, i - 1\n for j = 1, self.size do\n y = y + (z % 2) * self.p2[self.size + 1 - j]\n z = mfl(z / 2)\n end\n self.binv[i] = y + 1\n end\n self.wmul = {1}\n local w1 = self.w % 10000\n local w2 = mfl(self.w / 10000) % 10000\n local w3 = mfl(self.w / 100000000)\n for i = 2, self.n do\n self.wmul[i] = self:mul_predef(self.wmul[i - 1], w1, w2, w3)\n end\n self.winvmul = {1}\n w1 = self.winv % 10000\n w2 = mfl(self.winv / 10000) % 10000\n w3 = mfl(self.winv / 100000000)\n for i = 2, self.n do\n self.winvmul[i] = self:mul_predef(self.winvmul[i - 1], w1, w2, w3)\n end\nend\nTranFFT.add = function(self, x, y) return (x + y) % self.mod end\n\n-- super slow multiply functions\nTranFFT.mul = function(self, x, y)\n local mod = self.mod\n local x1, y1 = x % 10000, y % 10000\n local x2, y2 = mfl(x / 10000) % 10000, mfl(y / 10000) % 10000\n local x3, y3 = mfl(x / 100000000), mfl(y / 100000000)\n local ret = (x1 * y1 + (x1 * y2 + x2 * y1) * 10000) % mod\n ret = (ret + (x1 * y3 + x2 * y2 + x3 * y1) * 10000 % mod * 10000 % mod) % mod\n ret = (ret + (x2 * y3 + x3 * y2) * 10000 % mod * 10000 % mod * 10000) % mod\n ret = (ret + x3 * y3 * 10000 % mod * 10000 % mod * 10000 % mod * 10000) % mod\n return ret\nend\n\nTranFFT.mul_predef = function(self, x, y1, y2, y3)\n local mod = self.mod\n local x1 = x % 10000\n local x2 = mfl(x / 10000) % 10000\n local x3 = mfl(x / 100000000)\n local ret = (x1 * y1 + (x1 * y2 + x2 * y1) * 10000) % mod\n ret = (ret + (x1 * y3 + x2 * y2 + x3 * y1) * 10000 % mod * 10000 % mod) % mod\n ret = (ret + (x2 * y3 + x3 * y2) * 10000 % mod * 10000 % mod * 10000) % mod\n ret = (ret + x3 * y3 * 10000 % mod * 10000 % mod * 10000 % mod * 10000) % mod\n return ret\nend\n\nTranFFT.twice = function(self, x)\n local mod = self.mod\n local x1 = x % 10000\n local x2 = mfl(x / 10000) % 10000\n local x3 = mfl(x / 100000000)\n local ret = (x1 * x1 + (2 * x1 * x2) * 10000) % mod\n ret = (ret + (2 * x1 * x3 + x2 * x2) * 10000 % mod * 10000 % mod) % mod\n ret = (ret + (2 * x2 * x3) * 10000 % mod * 10000 % mod * 10000) % mod\n ret = (ret + x3 * x3 * 10000 % mod * 10000 % mod * 10000 % mod * 10000) % mod\n return ret\nend\n\nTranFFT.fft_common = function(self, ary, wmul)\n local ret = {}\n for i = 1, self.n do\n ret[i] = ary[self.binv[i]]\n end\n for i = 1, self.size do\n local step_size = self.p2[i]\n local step_count = self.p2[self.size + 1 - i]\n for istep = 1, step_count do\n local ofst = (istep - 1) * step_size * 2\n for j = 1, step_size do\n local a1, a2 = ret[ofst + j], ret[ofst + step_size + j]\n ret[ofst + j] = self:add(a1, self:mul(a2, wmul[1 + (j - 1) * step_count]))\n ret[ofst + step_size + j] = self:add(a1, self:mul(a2, wmul[1 + (j + step_size - 1) * step_count]))\n end\n end\n end\n return ret\nend\n\nTranFFT.fft = function(self, ary)\n return self:fft_common(ary, self.wmul)\nend\nTranFFT.ifft = function(self, ary)\n local ret = self:fft_common(ary, self.winvmul)\n for i = 1, self.n do\n ret[i] = self:mul(ret[i], self.ninv)\n end\n return ret\nend\n\nTranFFT:initialize()\nlocal a = {}\nfor i = 1, TranFFT.n do\n a[i] = 0\nend\n\nlocal prime = 200003\nlocal function pmul(x, y) return (x * y) % prime end\nlocal function padd(x, y) return (x + y) % prime end\n\nlocal p2 = {1}\nlocal p2inv = {0}\nfor i = 2, prime - 1 do\n p2[i] = (p2[i - 1] * 2) % prime\n p2inv[i] = 0\nend\nfor i = 1, prime - 1 do\n p2inv[p2[i]] = i\nend\n\nlocal n = io.read(\"*n\")\nlocal t = {}\nfor i = 1, n do\n t[i] = io.read(\"*n\")\n if 0 < t[i] then\n local v = p2inv[t[i]]\n a[v] = a[v] + 1\n end\nend\nlocal at = TranFFT:fft(a)\nfor i = 1, TranFFT.n do\n -- at[i] = TranFFT:mul(at[i], at[i])\n at[i] = TranFFT:twice(at[i])\nend\nlocal c = TranFFT:ifft(at)\n\nlocal ret = {}\nfor i = 1, prime - 1 do\n ret[i] = 0\nend\nfor i = 1, prime * 2 - 2 do\n local ti = i\n if prime <= ti then\n ti = ti - (prime - 1)\n end\n local v = p2[ti]\n ret[v] = ret[v] + c[i]\nend\nfor i = 1, n do\n if 0 < t[i] then\n local v = pmul(t[i], t[i])\n ret[v] = ret[v] - 1\n end\nend\nlocal ans = 0\nfor i = 1, prime - 1 do\n ans = ans + i * mfl(ret[i] / 2)\nend\nprint(ans)\n-- print(os.clock())\n", "language": "Lua", "metadata": {"date": 1597244257, "filename_ext": "lua", "original_language": "Lua (LuaJIT 2.1.0)", "problem_description_relpath": "problem_descriptions/p02590.html", "problem_id": "p02590", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02590/input.txt", "sample_output_relpath": "derived/input_output/data/p02590/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02590/Lua/s780419970.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s780419970", "user_id": "u120582723"}, "prompt_components": {"gold_output": "474287\n", "input_to_evaluate": "local mfl = math.floor\nlocal TranFFT = {}\n\nTranFFT.initialize = function(self)\n self.size = 19\n -- 2^19 = 524288\n self.n = 524288\n -- 40003698689: prime,\n -- 40003698689 % 524288 = 1\n self.mod = 40003698689\n -- (463881^524288) % mod = 1\n self.w = 463881\n -- (40003622388 * 524288) % mod = 1\n self.ninv = 40003622388\n -- (1547695164 * 463881) % mod = 1\n self.winv = 1547695164\n\n self.p2 = {1}\n for i = 2, self.size do\n self.p2[i] = self.p2[i - 1] * 2\n end\n self.binv = {}\n for i = 1, self.n do\n local y, z = 0, i - 1\n for j = 1, self.size do\n y = y + (z % 2) * self.p2[self.size + 1 - j]\n z = mfl(z / 2)\n end\n self.binv[i] = y + 1\n end\n self.wmul = {1}\n local w1 = self.w % 10000\n local w2 = mfl(self.w / 10000) % 10000\n local w3 = mfl(self.w / 100000000)\n for i = 2, self.n do\n self.wmul[i] = self:mul_predef(self.wmul[i - 1], w1, w2, w3)\n end\n self.winvmul = {1}\n w1 = self.winv % 10000\n w2 = mfl(self.winv / 10000) % 10000\n w3 = mfl(self.winv / 100000000)\n for i = 2, self.n do\n self.winvmul[i] = self:mul_predef(self.winvmul[i - 1], w1, w2, w3)\n end\nend\nTranFFT.add = function(self, x, y) return (x + y) % self.mod end\n\n-- super slow multiply functions\nTranFFT.mul = function(self, x, y)\n local mod = self.mod\n local x1, y1 = x % 10000, y % 10000\n local x2, y2 = mfl(x / 10000) % 10000, mfl(y / 10000) % 10000\n local x3, y3 = mfl(x / 100000000), mfl(y / 100000000)\n local ret = (x1 * y1 + (x1 * y2 + x2 * y1) * 10000) % mod\n ret = (ret + (x1 * y3 + x2 * y2 + x3 * y1) * 10000 % mod * 10000 % mod) % mod\n ret = (ret + (x2 * y3 + x3 * y2) * 10000 % mod * 10000 % mod * 10000) % mod\n ret = (ret + x3 * y3 * 10000 % mod * 10000 % mod * 10000 % mod * 10000) % mod\n return ret\nend\n\nTranFFT.mul_predef = function(self, x, y1, y2, y3)\n local mod = self.mod\n local x1 = x % 10000\n local x2 = mfl(x / 10000) % 10000\n local x3 = mfl(x / 100000000)\n local ret = (x1 * y1 + (x1 * y2 + x2 * y1) * 10000) % mod\n ret = (ret + (x1 * y3 + x2 * y2 + x3 * y1) * 10000 % mod * 10000 % mod) % mod\n ret = (ret + (x2 * y3 + x3 * y2) * 10000 % mod * 10000 % mod * 10000) % mod\n ret = (ret + x3 * y3 * 10000 % mod * 10000 % mod * 10000 % mod * 10000) % mod\n return ret\nend\n\nTranFFT.twice = function(self, x)\n local mod = self.mod\n local x1 = x % 10000\n local x2 = mfl(x / 10000) % 10000\n local x3 = mfl(x / 100000000)\n local ret = (x1 * x1 + (2 * x1 * x2) * 10000) % mod\n ret = (ret + (2 * x1 * x3 + x2 * x2) * 10000 % mod * 10000 % mod) % mod\n ret = (ret + (2 * x2 * x3) * 10000 % mod * 10000 % mod * 10000) % mod\n ret = (ret + x3 * x3 * 10000 % mod * 10000 % mod * 10000 % mod * 10000) % mod\n return ret\nend\n\nTranFFT.fft_common = function(self, ary, wmul)\n local ret = {}\n for i = 1, self.n do\n ret[i] = ary[self.binv[i]]\n end\n for i = 1, self.size do\n local step_size = self.p2[i]\n local step_count = self.p2[self.size + 1 - i]\n for istep = 1, step_count do\n local ofst = (istep - 1) * step_size * 2\n for j = 1, step_size do\n local a1, a2 = ret[ofst + j], ret[ofst + step_size + j]\n ret[ofst + j] = self:add(a1, self:mul(a2, wmul[1 + (j - 1) * step_count]))\n ret[ofst + step_size + j] = self:add(a1, self:mul(a2, wmul[1 + (j + step_size - 1) * step_count]))\n end\n end\n end\n return ret\nend\n\nTranFFT.fft = function(self, ary)\n return self:fft_common(ary, self.wmul)\nend\nTranFFT.ifft = function(self, ary)\n local ret = self:fft_common(ary, self.winvmul)\n for i = 1, self.n do\n ret[i] = self:mul(ret[i], self.ninv)\n end\n return ret\nend\n\nTranFFT:initialize()\nlocal a = {}\nfor i = 1, TranFFT.n do\n a[i] = 0\nend\n\nlocal prime = 200003\nlocal function pmul(x, y) return (x * y) % prime end\nlocal function padd(x, y) return (x + y) % prime end\n\nlocal p2 = {1}\nlocal p2inv = {0}\nfor i = 2, prime - 1 do\n p2[i] = (p2[i - 1] * 2) % prime\n p2inv[i] = 0\nend\nfor i = 1, prime - 1 do\n p2inv[p2[i]] = i\nend\n\nlocal n = io.read(\"*n\")\nlocal t = {}\nfor i = 1, n do\n t[i] = io.read(\"*n\")\n if 0 < t[i] then\n local v = p2inv[t[i]]\n a[v] = a[v] + 1\n end\nend\nlocal at = TranFFT:fft(a)\nfor i = 1, TranFFT.n do\n -- at[i] = TranFFT:mul(at[i], at[i])\n at[i] = TranFFT:twice(at[i])\nend\nlocal c = TranFFT:ifft(at)\n\nlocal ret = {}\nfor i = 1, prime - 1 do\n ret[i] = 0\nend\nfor i = 1, prime * 2 - 2 do\n local ti = i\n if prime <= ti then\n ti = ti - (prime - 1)\n end\n local v = p2[ti]\n ret[v] = ret[v] + c[i]\nend\nfor i = 1, n do\n if 0 < t[i] then\n local v = pmul(t[i], t[i])\n ret[v] = ret[v] - 1\n end\nend\nlocal ans = 0\nfor i = 1, prime - 1 do\n ans = ans + i * mfl(ret[i] / 2)\nend\nprint(ans)\n-- print(os.clock())\n", "problem_context": "Score : 800 points\n\nProblem Statement\n\nLet’s take a prime P = 200\\,003.\nYou are given N integers A_1, A_2, \\ldots, A_N.\nFind the sum of ((A_i \\cdot A_j) \\bmod P) over all N \\cdot (N-1) / 2 unordered pairs of elements (i < j).\n\nPlease note that the sum isn't computed modulo P.\n\nConstraints\n\n2 \\leq N \\leq 200\\,000\n\n0 \\leq A_i < P = 200\\,003\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format.\n\nN\nA_1 A_2 \\cdots A_N\n\nOutput\n\nPrint one integer — the sum over ((A_i \\cdot A_j) \\bmod P).\n\nSample Input 1\n\n4\n2019 0 2020 200002\n\nSample Output 1\n\n474287\n\nThe non-zero products are:\n\n2019 \\cdot 2020 \\bmod P = 78320\n\n2019 \\cdot 200002 \\bmod P = 197984\n\n2020 \\cdot 200002 \\bmod P = 197983\n\nSo the answer is 0 + 78320 + 197984 + 0 + 0 + 197983 = 474287.\n\nSample Input 2\n\n5\n1 1 2 2 100000\n\nSample Output 2\n\n600013", "sample_input": "4\n2019 0 2020 200002\n"}, "reference_outputs": ["474287\n"], "source_document_id": "p02590", "source_text": "Score : 800 points\n\nProblem Statement\n\nLet’s take a prime P = 200\\,003.\nYou are given N integers A_1, A_2, \\ldots, A_N.\nFind the sum of ((A_i \\cdot A_j) \\bmod P) over all N \\cdot (N-1) / 2 unordered pairs of elements (i < j).\n\nPlease note that the sum isn't computed modulo P.\n\nConstraints\n\n2 \\leq N \\leq 200\\,000\n\n0 \\leq A_i < P = 200\\,003\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format.\n\nN\nA_1 A_2 \\cdots A_N\n\nOutput\n\nPrint one integer — the sum over ((A_i \\cdot A_j) \\bmod P).\n\nSample Input 1\n\n4\n2019 0 2020 200002\n\nSample Output 1\n\n474287\n\nThe non-zero products are:\n\n2019 \\cdot 2020 \\bmod P = 78320\n\n2019 \\cdot 200002 \\bmod P = 197984\n\n2020 \\cdot 200002 \\bmod P = 197983\n\nSo the answer is 0 + 78320 + 197984 + 0 + 0 + 197983 = 474287.\n\nSample Input 2\n\n5\n1 1 2 2 100000\n\nSample Output 2\n\n600013", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 4641, "cpu_time_ms": 1289, "memory_kb": 35524}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s726853286", "group_id": "codeNet:p02594", "input_text": "print(io.read\"*n\">=30 and \"Yes\" or \"No\")", "language": "Lua", "metadata": {"date": 1597538787, "filename_ext": "lua", "original_language": "Lua (LuaJIT 2.1.0)", "problem_description_relpath": "problem_descriptions/p02594.html", "problem_id": "p02594", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02594/input.txt", "sample_output_relpath": "derived/input_output/data/p02594/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02594/Lua/s726853286.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s726853286", "user_id": "u726173718"}, "prompt_components": {"gold_output": "No\n", "input_to_evaluate": "print(io.read\"*n\">=30 and \"Yes\" or \"No\")", "problem_context": "Score : 100 points\n\nProblem Statement\n\nYou will turn on the air conditioner if, and only if, the temperature of the room is 30 degrees Celsius or above.\n\nThe current temperature of the room is X degrees Celsius. Will you turn on the air conditioner?\n\nConstraints\n\n-40 \\leq X \\leq 40\n\nX is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX\n\nOutput\n\nPrint Yes if you will turn on the air conditioner; print No otherwise.\n\nSample Input 1\n\n25\n\nSample Output 1\n\nNo\n\nSample Input 2\n\n30\n\nSample Output 2\n\nYes", "sample_input": "25\n"}, "reference_outputs": ["No\n"], "source_document_id": "p02594", "source_text": "Score : 100 points\n\nProblem Statement\n\nYou will turn on the air conditioner if, and only if, the temperature of the room is 30 degrees Celsius or above.\n\nThe current temperature of the room is X degrees Celsius. Will you turn on the air conditioner?\n\nConstraints\n\n-40 \\leq X \\leq 40\n\nX is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX\n\nOutput\n\nPrint Yes if you will turn on the air conditioner; print No otherwise.\n\nSample Input 1\n\n25\n\nSample Output 1\n\nNo\n\nSample Input 2\n\n30\n\nSample Output 2\n\nYes", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 40, "cpu_time_ms": 2, "memory_kb": 2740}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s300394714", "group_id": "codeNet:p02596", "input_text": "local MOD\nlocal function add(a,b)return (a+b)%MOD end\nlocal function sub(a,b)return a>b and a-b or a-b+MOD end\nlocal function mul(a,b)return a*b%MOD end\nlocal function pow(a,b)local ret=1 while(b>0)do if(b%2==1)then ret=mul(ret,a)b=b-1 end a=mul(a,a)b=b*.5 end return ret end\nlocal function inv(x)local a,b,u,v=x,MOD,1,0 repeat local t=math.floor(a/b)a,b=b,a-t*b u,v=v,u-t*v until(b==0)return u%MOD end\nlocal function div(a,b)return mul(a,inv(b))end\nK=io.read\"*n\"\n\nif(K%2==0)then print(-1)return end\nMOD=K\na=0\ni=0\nwhile(true)do\na=add(a,mul(7,pow(10,i)))\nif(a==0)then break end\ni=i+1\nend\nprint(i+1)\n", "language": "Lua", "metadata": {"date": 1597539543, "filename_ext": "lua", "original_language": "Lua (LuaJIT 2.1.0)", "problem_description_relpath": "problem_descriptions/p02596.html", "problem_id": "p02596", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02596/input.txt", "sample_output_relpath": "derived/input_output/data/p02596/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02596/Lua/s300394714.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s300394714", "user_id": "u726173718"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "local MOD\nlocal function add(a,b)return (a+b)%MOD end\nlocal function sub(a,b)return a>b and a-b or a-b+MOD end\nlocal function mul(a,b)return a*b%MOD end\nlocal function pow(a,b)local ret=1 while(b>0)do if(b%2==1)then ret=mul(ret,a)b=b-1 end a=mul(a,a)b=b*.5 end return ret end\nlocal function inv(x)local a,b,u,v=x,MOD,1,0 repeat local t=math.floor(a/b)a,b=b,a-t*b u,v=v,u-t*v until(b==0)return u%MOD end\nlocal function div(a,b)return mul(a,inv(b))end\nK=io.read\"*n\"\n\nif(K%2==0)then print(-1)return end\nMOD=K\na=0\ni=0\nwhile(true)do\na=add(a,mul(7,pow(10,i)))\nif(a==0)then break end\ni=i+1\nend\nprint(i+1)\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nTakahashi loves the number 7 and multiples of K.\n\nWhere is the first occurrence of a multiple of K in the sequence 7,77,777,\\ldots? (Also see Output and Sample Input/Output below.)\n\nIf the sequence contains no multiples of K, print -1 instead.\n\nConstraints\n\n1 \\leq K \\leq 10^6\n\nK is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nK\n\nOutput\n\nPrint an integer representing the position of the first occurrence of a multiple of K. (For example, if the first occurrence is the fourth element of the sequence, print 4.)\n\nSample Input 1\n\n101\n\nSample Output 1\n\n4\n\nNone of 7, 77, and 777 is a multiple of 101, but 7777 is.\n\nSample Input 2\n\n2\n\nSample Output 2\n\n-1\n\nAll elements in the sequence are odd numbers; there are no multiples of 2.\n\nSample Input 3\n\n999983\n\nSample Output 3\n\n999982", "sample_input": "101\n"}, "reference_outputs": ["4\n"], "source_document_id": "p02596", "source_text": "Score : 300 points\n\nProblem Statement\n\nTakahashi loves the number 7 and multiples of K.\n\nWhere is the first occurrence of a multiple of K in the sequence 7,77,777,\\ldots? (Also see Output and Sample Input/Output below.)\n\nIf the sequence contains no multiples of K, print -1 instead.\n\nConstraints\n\n1 \\leq K \\leq 10^6\n\nK is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nK\n\nOutput\n\nPrint an integer representing the position of the first occurrence of a multiple of K. (For example, if the first occurrence is the fourth element of the sequence, print 4.)\n\nSample Input 1\n\n101\n\nSample Output 1\n\n4\n\nNone of 7, 77, and 777 is a multiple of 101, but 7777 is.\n\nSample Input 2\n\n2\n\nSample Output 2\n\n-1\n\nAll elements in the sequence are odd numbers; there are no multiples of 2.\n\nSample Input 3\n\n999983\n\nSample Output 3\n\n999982", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 598, "cpu_time_ms": 2205, "memory_kb": 2764}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s654820366", "group_id": "codeNet:p02597", "input_text": "local mmi, mma = math.min, math.max\nlocal n = io.read(\"*n\", \"*l\")\nlocal s = io.read()\nlocal t = {}\nfor i = 1, n do\n t[i] = s:sub(i, i) == \"W\"\nend\nlocal left, right = {}, {}\ndo\n local c = 0\n for i = 1, n do\n if t[i] then c = c + 1 end\n left[i] = c\n right[i] = 0\n end\n c = 0\n for i = n, 1, -1 do\n if t[i] then c = c + 1 end\n right[i] = c\n end\nend\nlocal ret = mmi(n - right[1], left[n])\nfor i = 1, n - 1 do\n local need_red = left[i]\n local need_white = n - i - right[i + 1]\n ret = mmi(ret, mma(need_red, need_white))\nend\nprint(ret)\n", "language": "Lua", "metadata": {"date": 1596547124, "filename_ext": "lua", "original_language": "Lua (Lua 5.3.5)", "problem_description_relpath": "problem_descriptions/p02597.html", "problem_id": "p02597", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02597/input.txt", "sample_output_relpath": "derived/input_output/data/p02597/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02597/Lua/s654820366.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s654820366", "user_id": "u120582723"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "local mmi, mma = math.min, math.max\nlocal n = io.read(\"*n\", \"*l\")\nlocal s = io.read()\nlocal t = {}\nfor i = 1, n do\n t[i] = s:sub(i, i) == \"W\"\nend\nlocal left, right = {}, {}\ndo\n local c = 0\n for i = 1, n do\n if t[i] then c = c + 1 end\n left[i] = c\n right[i] = 0\n end\n c = 0\n for i = n, 1, -1 do\n if t[i] then c = c + 1 end\n right[i] = c\n end\nend\nlocal ret = mmi(n - right[1], left[n])\nfor i = 1, n - 1 do\n local need_red = left[i]\n local need_white = n - i - right[i + 1]\n ret = mmi(ret, mma(need_red, need_white))\nend\nprint(ret)\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nAn altar enshrines N stones arranged in a row from left to right. The color of the i-th stone from the left (1 \\leq i \\leq N) is given to you as a character c_i; R stands for red and W stands for white.\n\nYou can do the following two kinds of operations any number of times in any order:\n\nChoose two stones (not necessarily adjacent) and swap them.\n\nChoose one stone and change its color (from red to white and vice versa).\n\nAccording to a fortune-teller, a white stone placed to the immediate left of a red stone will bring a disaster. At least how many operations are needed to reach a situation without such a white stone?\n\nConstraints\n\n2 \\leq N \\leq 200000\n\nc_i is R or W.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nc_{1}c_{2}...c_{N}\n\nOutput\n\nPrint an integer representing the minimum number of operations needed.\n\nSample Input 1\n\n4\nWWRR\n\nSample Output 1\n\n2\n\nFor example, the two operations below will achieve the objective.\n\nSwap the 1-st and 3-rd stones from the left, resulting in RWWR.\n\nChange the color of the 4-th stone from the left, resulting in RWWW.\n\nSample Input 2\n\n2\nRR\n\nSample Output 2\n\n0\n\nIt can be the case that no operation is needed.\n\nSample Input 3\n\n8\nWRWWRWRR\n\nSample Output 3\n\n3", "sample_input": "4\nWWRR\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02597", "source_text": "Score : 400 points\n\nProblem Statement\n\nAn altar enshrines N stones arranged in a row from left to right. The color of the i-th stone from the left (1 \\leq i \\leq N) is given to you as a character c_i; R stands for red and W stands for white.\n\nYou can do the following two kinds of operations any number of times in any order:\n\nChoose two stones (not necessarily adjacent) and swap them.\n\nChoose one stone and change its color (from red to white and vice versa).\n\nAccording to a fortune-teller, a white stone placed to the immediate left of a red stone will bring a disaster. At least how many operations are needed to reach a situation without such a white stone?\n\nConstraints\n\n2 \\leq N \\leq 200000\n\nc_i is R or W.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nc_{1}c_{2}...c_{N}\n\nOutput\n\nPrint an integer representing the minimum number of operations needed.\n\nSample Input 1\n\n4\nWWRR\n\nSample Output 1\n\n2\n\nFor example, the two operations below will achieve the objective.\n\nSwap the 1-st and 3-rd stones from the left, resulting in RWWR.\n\nChange the color of the 4-th stone from the left, resulting in RWWW.\n\nSample Input 2\n\n2\nRR\n\nSample Output 2\n\n0\n\nIt can be the case that no operation is needed.\n\nSample Input 3\n\n8\nWRWWRWRR\n\nSample Output 3\n\n3", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 554, "cpu_time_ms": 75, "memory_kb": 14788}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s277672768", "group_id": "codeNet:p02597", "input_text": "local mmi, mma = math.min, math.max\nlocal n = io.read(\"*n\", \"*l\")\nlocal s = io.read()\nlocal t = {}\nfor i = 1, n do\n t[i] = s:sub(i, i) == \"W\"\nend\nlocal left, right = {}, {}\ndo\n local c = 0\n for i = 1, n do\n if t[i] then c = c + 1 end\n left[i] = c\n right[i] = 0\n end\n c = 0\n for i = n, 1, -1 do\n if t[i] then c = c + 1 end\n right[i] = c\n end\nend\nlocal ret = mmi(n - right[1], left[n])\nfor i = 1, n - 1 do\n local need_red = left[i]\n local need_white = n - i - right[n - i]\n ret = mmi(ret, mma(need_red, need_white))\nend\nprint(ret)\n", "language": "Lua", "metadata": {"date": 1596546999, "filename_ext": "lua", "original_language": "Lua (Lua 5.3.5)", "problem_description_relpath": "problem_descriptions/p02597.html", "problem_id": "p02597", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02597/input.txt", "sample_output_relpath": "derived/input_output/data/p02597/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02597/Lua/s277672768.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s277672768", "user_id": "u120582723"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "local mmi, mma = math.min, math.max\nlocal n = io.read(\"*n\", \"*l\")\nlocal s = io.read()\nlocal t = {}\nfor i = 1, n do\n t[i] = s:sub(i, i) == \"W\"\nend\nlocal left, right = {}, {}\ndo\n local c = 0\n for i = 1, n do\n if t[i] then c = c + 1 end\n left[i] = c\n right[i] = 0\n end\n c = 0\n for i = n, 1, -1 do\n if t[i] then c = c + 1 end\n right[i] = c\n end\nend\nlocal ret = mmi(n - right[1], left[n])\nfor i = 1, n - 1 do\n local need_red = left[i]\n local need_white = n - i - right[n - i]\n ret = mmi(ret, mma(need_red, need_white))\nend\nprint(ret)\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nAn altar enshrines N stones arranged in a row from left to right. The color of the i-th stone from the left (1 \\leq i \\leq N) is given to you as a character c_i; R stands for red and W stands for white.\n\nYou can do the following two kinds of operations any number of times in any order:\n\nChoose two stones (not necessarily adjacent) and swap them.\n\nChoose one stone and change its color (from red to white and vice versa).\n\nAccording to a fortune-teller, a white stone placed to the immediate left of a red stone will bring a disaster. At least how many operations are needed to reach a situation without such a white stone?\n\nConstraints\n\n2 \\leq N \\leq 200000\n\nc_i is R or W.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nc_{1}c_{2}...c_{N}\n\nOutput\n\nPrint an integer representing the minimum number of operations needed.\n\nSample Input 1\n\n4\nWWRR\n\nSample Output 1\n\n2\n\nFor example, the two operations below will achieve the objective.\n\nSwap the 1-st and 3-rd stones from the left, resulting in RWWR.\n\nChange the color of the 4-th stone from the left, resulting in RWWW.\n\nSample Input 2\n\n2\nRR\n\nSample Output 2\n\n0\n\nIt can be the case that no operation is needed.\n\nSample Input 3\n\n8\nWRWWRWRR\n\nSample Output 3\n\n3", "sample_input": "4\nWWRR\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02597", "source_text": "Score : 400 points\n\nProblem Statement\n\nAn altar enshrines N stones arranged in a row from left to right. The color of the i-th stone from the left (1 \\leq i \\leq N) is given to you as a character c_i; R stands for red and W stands for white.\n\nYou can do the following two kinds of operations any number of times in any order:\n\nChoose two stones (not necessarily adjacent) and swap them.\n\nChoose one stone and change its color (from red to white and vice versa).\n\nAccording to a fortune-teller, a white stone placed to the immediate left of a red stone will bring a disaster. At least how many operations are needed to reach a situation without such a white stone?\n\nConstraints\n\n2 \\leq N \\leq 200000\n\nc_i is R or W.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nc_{1}c_{2}...c_{N}\n\nOutput\n\nPrint an integer representing the minimum number of operations needed.\n\nSample Input 1\n\n4\nWWRR\n\nSample Output 1\n\n2\n\nFor example, the two operations below will achieve the objective.\n\nSwap the 1-st and 3-rd stones from the left, resulting in RWWR.\n\nChange the color of the 4-th stone from the left, resulting in RWWW.\n\nSample Input 2\n\n2\nRR\n\nSample Output 2\n\n0\n\nIt can be the case that no operation is needed.\n\nSample Input 3\n\n8\nWRWWRWRR\n\nSample Output 3\n\n3", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 554, "cpu_time_ms": 73, "memory_kb": 14824}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s369063627", "group_id": "codeNet:p02599", "input_text": "local mfl, mce = math.floor, math.ceil\nlocal mmi, mma = math.min, math.max\nlocal bls, brs = bit.lshift, bit.rshift\nlocal SegTree = {}\nSegTree.updateAll = function(self)\n for i = self.stagenum - 1, 1, -1 do\n local cnt = bls(1, i - 1)\n for j = 1, cnt do\n self.stage[i][j] = self.func(self.stage[i + 1][j * 2 - 1], self.stage[i + 1][j * 2])\n end\n end\nend\nSegTree.create = function(self, n, func, emptyvalue)\n self.func, self.emptyvalue = func, emptyvalue\n local stagenum, mul = 1, 1\n self.stage = {{}}\n while mul < n do\n mul, stagenum = mul * 2, stagenum + 1\n self.stage[stagenum] = {}\n end\n self.stagenum = stagenum\n self.left_stage = {}\n for i = 1, n do\n local sp, sz = 1, bls(1, stagenum - 1)\n while(i - 1) % sz ~= 0 do\n sp, sz = sp + 1, brs(sz, 1)\n end\n self.left_stage[i] = sp\n end\n self.sz_stage = {}\n local tmp, sp = 1, stagenum\n for i = 1, n do\n if tmp * 2 == i then tmp, sp = tmp * 2, sp - 1 end\n self.sz_stage[i] = sp\n end\n for i = 1, mul do self.stage[stagenum][i] = emptyvalue end\n self:updateAll()\nend\nSegTree.getRange = function(self, left, right)\n if left == right then return self.stage[self.stagenum][left] end\n local stagenum = self.stagenum\n local ret = self.emptyvalue\n while left <= right do\n local stage = mma(self.left_stage[left], self.sz_stage[right - left + 1])\n local sz = bls(1, stagenum - stage)\n ret = self.func(ret, self.stage[stage][1 + brs(left - 1, stagenum - stage)])\n left = left + sz\n end\n return ret\nend\nSegTree.update = function(self, idx)\n for i = self.stagenum - 1, 1, -1 do\n local dst = brs(idx + 1, 1)\n local rem = dst * 4 - 1 - idx\n self.stage[i][dst] = self.func(self.stage[i + 1][idx], self.stage[i + 1][rem])\n idx = dst\n end\nend\nSegTree.addValue = function(self, idx, value, silent)\n self.stage[self.stagenum][idx] = self.stage[self.stagenum][idx] + value\n if not silent then\n self:update(idx)\n end\nend\nSegTree.new = function(n, func, emptyvalue)\n local obj = {}\n setmetatable(obj, {__index = SegTree})\n obj:create(n, func, emptyvalue)\n return obj\nend\n\nlocal n, q = io.read(\"*n\", \"*n\")\nlocal t = {}\nfor i = 1, n do\n t[i] = io.read(\"*n\")\nend\nlocal query = {}\nfor iq = 1, q do\n local a, b = io.read(\"*n\", \"*n\")\n query[iq] = {a, b, iq}\nend\ntable.sort(query, function(a, b) return a[2] < b[2] end)\nlocal p = {}\nfor i = 1, n do\n p[i] = 0\nend\nlocal st = SegTree.new(n, function(a, b) return a + b end, 0)\nlocal ti = 1\nfor iq = 1, q do\n local l, r = query[iq][1], query[iq][2]\n while ti <= r do\n local v = t[ti]\n local old = p[v]\n if 0 < old then\n st:addValue(old, -1)\n end\n p[v] = ti\n st:addValue(ti, 1)\n ti = ti + 1\n end\n query[iq][4] = st:getRange(l, r)\nend\ntable.sort(query, function(a, b) return a[3] < b[3] end)\nfor iq = 1, q do\n print(query[iq][4])\nend\n", "language": "Lua", "metadata": {"date": 1596510289, "filename_ext": "lua", "original_language": "Lua (LuaJIT 2.1.0)", "problem_description_relpath": "problem_descriptions/p02599.html", "problem_id": "p02599", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02599/input.txt", "sample_output_relpath": "derived/input_output/data/p02599/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02599/Lua/s369063627.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s369063627", "user_id": "u120582723"}, "prompt_components": {"gold_output": "2\n3\n1\n", "input_to_evaluate": "local mfl, mce = math.floor, math.ceil\nlocal mmi, mma = math.min, math.max\nlocal bls, brs = bit.lshift, bit.rshift\nlocal SegTree = {}\nSegTree.updateAll = function(self)\n for i = self.stagenum - 1, 1, -1 do\n local cnt = bls(1, i - 1)\n for j = 1, cnt do\n self.stage[i][j] = self.func(self.stage[i + 1][j * 2 - 1], self.stage[i + 1][j * 2])\n end\n end\nend\nSegTree.create = function(self, n, func, emptyvalue)\n self.func, self.emptyvalue = func, emptyvalue\n local stagenum, mul = 1, 1\n self.stage = {{}}\n while mul < n do\n mul, stagenum = mul * 2, stagenum + 1\n self.stage[stagenum] = {}\n end\n self.stagenum = stagenum\n self.left_stage = {}\n for i = 1, n do\n local sp, sz = 1, bls(1, stagenum - 1)\n while(i - 1) % sz ~= 0 do\n sp, sz = sp + 1, brs(sz, 1)\n end\n self.left_stage[i] = sp\n end\n self.sz_stage = {}\n local tmp, sp = 1, stagenum\n for i = 1, n do\n if tmp * 2 == i then tmp, sp = tmp * 2, sp - 1 end\n self.sz_stage[i] = sp\n end\n for i = 1, mul do self.stage[stagenum][i] = emptyvalue end\n self:updateAll()\nend\nSegTree.getRange = function(self, left, right)\n if left == right then return self.stage[self.stagenum][left] end\n local stagenum = self.stagenum\n local ret = self.emptyvalue\n while left <= right do\n local stage = mma(self.left_stage[left], self.sz_stage[right - left + 1])\n local sz = bls(1, stagenum - stage)\n ret = self.func(ret, self.stage[stage][1 + brs(left - 1, stagenum - stage)])\n left = left + sz\n end\n return ret\nend\nSegTree.update = function(self, idx)\n for i = self.stagenum - 1, 1, -1 do\n local dst = brs(idx + 1, 1)\n local rem = dst * 4 - 1 - idx\n self.stage[i][dst] = self.func(self.stage[i + 1][idx], self.stage[i + 1][rem])\n idx = dst\n end\nend\nSegTree.addValue = function(self, idx, value, silent)\n self.stage[self.stagenum][idx] = self.stage[self.stagenum][idx] + value\n if not silent then\n self:update(idx)\n end\nend\nSegTree.new = function(n, func, emptyvalue)\n local obj = {}\n setmetatable(obj, {__index = SegTree})\n obj:create(n, func, emptyvalue)\n return obj\nend\n\nlocal n, q = io.read(\"*n\", \"*n\")\nlocal t = {}\nfor i = 1, n do\n t[i] = io.read(\"*n\")\nend\nlocal query = {}\nfor iq = 1, q do\n local a, b = io.read(\"*n\", \"*n\")\n query[iq] = {a, b, iq}\nend\ntable.sort(query, function(a, b) return a[2] < b[2] end)\nlocal p = {}\nfor i = 1, n do\n p[i] = 0\nend\nlocal st = SegTree.new(n, function(a, b) return a + b end, 0)\nlocal ti = 1\nfor iq = 1, q do\n local l, r = query[iq][1], query[iq][2]\n while ti <= r do\n local v = t[ti]\n local old = p[v]\n if 0 < old then\n st:addValue(old, -1)\n end\n p[v] = ti\n st:addValue(ti, 1)\n ti = ti + 1\n end\n query[iq][4] = st:getRange(l, r)\nend\ntable.sort(query, function(a, b) return a[3] < b[3] end)\nfor iq = 1, q do\n print(query[iq][4])\nend\n", "problem_context": "Score : 600 points\n\nProblem Statement\n\nWe have N colored balls arranged in a row from left to right; the color of the i-th ball from the left is c_i.\n\nYou are given Q queries. The i-th query is as follows: how many different colors do the l_i-th through r_i-th balls from the left have?\n\nConstraints\n\n1\\leq N,Q \\leq 5 \\times 10^5\n\n1\\leq c_i \\leq N\n\n1\\leq l_i \\leq r_i \\leq N\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN Q\nc_1 c_2 \\cdots c_N\nl_1 r_1\nl_2 r_2\n:\nl_Q r_Q\n\nOutput\n\nPrint Q lines. The i-th line should contain the response to the i-th query.\n\nSample Input 1\n\n4 3\n1 2 1 3\n1 3\n2 4\n3 3\n\nSample Output 1\n\n2\n3\n1\n\nThe 1-st, 2-nd, and 3-rd balls from the left have the colors 1, 2, and 1 - two different colors.\n\nThe 2-st, 3-rd, and 4-th balls from the left have the colors 2, 1, and 3 - three different colors.\n\nThe 3-rd ball from the left has the color 1 - just one color.\n\nSample Input 2\n\n10 10\n2 5 6 5 2 1 7 9 7 2\n5 5\n2 4\n6 7\n2 2\n7 8\n7 9\n1 8\n6 9\n8 10\n6 8\n\nSample Output 2\n\n1\n2\n2\n1\n2\n2\n6\n3\n3\n3", "sample_input": "4 3\n1 2 1 3\n1 3\n2 4\n3 3\n"}, "reference_outputs": ["2\n3\n1\n"], "source_document_id": "p02599", "source_text": "Score : 600 points\n\nProblem Statement\n\nWe have N colored balls arranged in a row from left to right; the color of the i-th ball from the left is c_i.\n\nYou are given Q queries. The i-th query is as follows: how many different colors do the l_i-th through r_i-th balls from the left have?\n\nConstraints\n\n1\\leq N,Q \\leq 5 \\times 10^5\n\n1\\leq c_i \\leq N\n\n1\\leq l_i \\leq r_i \\leq N\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN Q\nc_1 c_2 \\cdots c_N\nl_1 r_1\nl_2 r_2\n:\nl_Q r_Q\n\nOutput\n\nPrint Q lines. The i-th line should contain the response to the i-th query.\n\nSample Input 1\n\n4 3\n1 2 1 3\n1 3\n2 4\n3 3\n\nSample Output 1\n\n2\n3\n1\n\nThe 1-st, 2-nd, and 3-rd balls from the left have the colors 1, 2, and 1 - two different colors.\n\nThe 2-st, 3-rd, and 4-th balls from the left have the colors 2, 1, and 3 - three different colors.\n\nThe 3-rd ball from the left has the color 1 - just one color.\n\nSample Input 2\n\n10 10\n2 5 6 5 2 1 7 9 7 2\n5 5\n2 4\n6 7\n2 2\n7 8\n7 9\n1 8\n6 9\n8 10\n6 8\n\nSample Output 2\n\n1\n2\n2\n1\n2\n2\n6\n3\n3\n3", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2834, "cpu_time_ms": 2208, "memory_kb": 89984}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s839160459", "group_id": "codeNet:p02600", "input_text": "local read = setmetatable({}, {__index = function(t, k) local a = {} for i=1,#k do table.insert(a, '*'..string.sub(k, i, i)) end local r = io.read local u = table.unpack or unpack return function() return r(u(a)) end end})\nread.N = function(N) local t={} for i=1,N do t[i]=read.n() end return t end\nstring.totable = function(s) local t={} local u=string.sub for i=1,#s do t[i] = u(s, i, i) end return t end\nstring.split = function(s) local t={} for w in string.gmatch(s, \"[^%s]+\") do table.insert(t, w) end return (table.unpack or unpack)(t) end\nlocal function array(dimensi0n, default_val) assert(type(default_val) ~= 'table') local n=dimensi0n local m={}if default_val~=nil then m[1]={__index=function()return default_val end}end for i=2,n do m[i]={__index=function(p, k)local c=setmetatable({},m[i-1])rawset(p,k,c)return c end}end return setmetatable({},m[n])end\n--\nx = read.n()\nif x < 400 then y = 0\nelseif x < 600 then y = 8 \nelseif x < 800 then y = 7 \nelseif x < 1000 then y = 6 \nelseif x < 1200 then y = 5 \nelseif x < 1400 then y = 4 \nelseif x < 1600 then y = 3 \nelseif x < 1800 then y = 2 \nelseif x < 2000 then y = 1 \nend\nprint(y)\n", "language": "Lua", "metadata": {"date": 1595725525, "filename_ext": "lua", "original_language": "Lua (Lua 5.3.5)", "problem_description_relpath": "problem_descriptions/p02600.html", "problem_id": "p02600", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02600/input.txt", "sample_output_relpath": "derived/input_output/data/p02600/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02600/Lua/s839160459.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s839160459", "user_id": "u162773977"}, "prompt_components": {"gold_output": "7\n", "input_to_evaluate": "local read = setmetatable({}, {__index = function(t, k) local a = {} for i=1,#k do table.insert(a, '*'..string.sub(k, i, i)) end local r = io.read local u = table.unpack or unpack return function() return r(u(a)) end end})\nread.N = function(N) local t={} for i=1,N do t[i]=read.n() end return t end\nstring.totable = function(s) local t={} local u=string.sub for i=1,#s do t[i] = u(s, i, i) end return t end\nstring.split = function(s) local t={} for w in string.gmatch(s, \"[^%s]+\") do table.insert(t, w) end return (table.unpack or unpack)(t) end\nlocal function array(dimensi0n, default_val) assert(type(default_val) ~= 'table') local n=dimensi0n local m={}if default_val~=nil then m[1]={__index=function()return default_val end}end for i=2,n do m[i]={__index=function(p, k)local c=setmetatable({},m[i-1])rawset(p,k,c)return c end}end return setmetatable({},m[n])end\n--\nx = read.n()\nif x < 400 then y = 0\nelseif x < 600 then y = 8 \nelseif x < 800 then y = 7 \nelseif x < 1000 then y = 6 \nelseif x < 1200 then y = 5 \nelseif x < 1400 then y = 4 \nelseif x < 1600 then y = 3 \nelseif x < 1800 then y = 2 \nelseif x < 2000 then y = 1 \nend\nprint(y)\n", "problem_context": "Score: 100 points\n\nProblem Statement\n\nM-kun is a competitor in AtCoder, whose highest rating is X.\n\nIn this site, a competitor is given a kyu (class) according to his/her highest rating. For ratings from 400 through 1999, the following kyus are given:\n\nFrom 400 through 599: 8-kyu\n\nFrom 600 through 799: 7-kyu\n\nFrom 800 through 999: 6-kyu\n\nFrom 1000 through 1199: 5-kyu\n\nFrom 1200 through 1399: 4-kyu\n\nFrom 1400 through 1599: 3-kyu\n\nFrom 1600 through 1799: 2-kyu\n\nFrom 1800 through 1999: 1-kyu\n\nWhat kyu does M-kun have?\n\nConstraints\n\n400 \\leq X \\leq 1999\n\nX is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX\n\nOutput\n\nPrint the kyu M-kun has, as an integer.\nFor example, if he has 8-kyu, print 8.\n\nSample Input 1\n\n725\n\nSample Output 1\n\n7\n\nM-kun's highest rating is 725, which corresponds to 7-kyu.\n\nThus, 7 is the correct output.\n\nSample Input 2\n\n1600\n\nSample Output 2\n\n2\n\nM-kun's highest rating is 1600, which corresponds to 2-kyu.\n\nThus, 2 is the correct output.", "sample_input": "725\n"}, "reference_outputs": ["7\n"], "source_document_id": "p02600", "source_text": "Score: 100 points\n\nProblem Statement\n\nM-kun is a competitor in AtCoder, whose highest rating is X.\n\nIn this site, a competitor is given a kyu (class) according to his/her highest rating. For ratings from 400 through 1999, the following kyus are given:\n\nFrom 400 through 599: 8-kyu\n\nFrom 600 through 799: 7-kyu\n\nFrom 800 through 999: 6-kyu\n\nFrom 1000 through 1199: 5-kyu\n\nFrom 1200 through 1399: 4-kyu\n\nFrom 1400 through 1599: 3-kyu\n\nFrom 1600 through 1799: 2-kyu\n\nFrom 1800 through 1999: 1-kyu\n\nWhat kyu does M-kun have?\n\nConstraints\n\n400 \\leq X \\leq 1999\n\nX is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX\n\nOutput\n\nPrint the kyu M-kun has, as an integer.\nFor example, if he has 8-kyu, print 8.\n\nSample Input 1\n\n725\n\nSample Output 1\n\n7\n\nM-kun's highest rating is 725, which corresponds to 7-kyu.\n\nThus, 7 is the correct output.\n\nSample Input 2\n\n1600\n\nSample Output 2\n\n2\n\nM-kun's highest rating is 1600, which corresponds to 2-kyu.\n\nThus, 2 is the correct output.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1139, "cpu_time_ms": 7, "memory_kb": 2748}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s045600008", "group_id": "codeNet:p02600", "input_text": "a = io.read(\"*n\")\nb = 0\nif a < 600 then\n b = 8\nelseif a < 800 then\n b = 7\nelseif a < 1000 then\n b = 6\nelseif a < 1200 then\n b = 5\nelseif a < 1400 then\n b = 4\nelseif a < 1600 then\n b = 3\nelseif a < 1800 then\n b = 2\nelse\n b = 1\nend\nprint(b)\n", "language": "Lua", "metadata": {"date": 1595725287, "filename_ext": "lua", "original_language": "Lua (Lua 5.3.5)", "problem_description_relpath": "problem_descriptions/p02600.html", "problem_id": "p02600", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02600/input.txt", "sample_output_relpath": "derived/input_output/data/p02600/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02600/Lua/s045600008.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s045600008", "user_id": "u120582723"}, "prompt_components": {"gold_output": "7\n", "input_to_evaluate": "a = io.read(\"*n\")\nb = 0\nif a < 600 then\n b = 8\nelseif a < 800 then\n b = 7\nelseif a < 1000 then\n b = 6\nelseif a < 1200 then\n b = 5\nelseif a < 1400 then\n b = 4\nelseif a < 1600 then\n b = 3\nelseif a < 1800 then\n b = 2\nelse\n b = 1\nend\nprint(b)\n", "problem_context": "Score: 100 points\n\nProblem Statement\n\nM-kun is a competitor in AtCoder, whose highest rating is X.\n\nIn this site, a competitor is given a kyu (class) according to his/her highest rating. For ratings from 400 through 1999, the following kyus are given:\n\nFrom 400 through 599: 8-kyu\n\nFrom 600 through 799: 7-kyu\n\nFrom 800 through 999: 6-kyu\n\nFrom 1000 through 1199: 5-kyu\n\nFrom 1200 through 1399: 4-kyu\n\nFrom 1400 through 1599: 3-kyu\n\nFrom 1600 through 1799: 2-kyu\n\nFrom 1800 through 1999: 1-kyu\n\nWhat kyu does M-kun have?\n\nConstraints\n\n400 \\leq X \\leq 1999\n\nX is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX\n\nOutput\n\nPrint the kyu M-kun has, as an integer.\nFor example, if he has 8-kyu, print 8.\n\nSample Input 1\n\n725\n\nSample Output 1\n\n7\n\nM-kun's highest rating is 725, which corresponds to 7-kyu.\n\nThus, 7 is the correct output.\n\nSample Input 2\n\n1600\n\nSample Output 2\n\n2\n\nM-kun's highest rating is 1600, which corresponds to 2-kyu.\n\nThus, 2 is the correct output.", "sample_input": "725\n"}, "reference_outputs": ["7\n"], "source_document_id": "p02600", "source_text": "Score: 100 points\n\nProblem Statement\n\nM-kun is a competitor in AtCoder, whose highest rating is X.\n\nIn this site, a competitor is given a kyu (class) according to his/her highest rating. For ratings from 400 through 1999, the following kyus are given:\n\nFrom 400 through 599: 8-kyu\n\nFrom 600 through 799: 7-kyu\n\nFrom 800 through 999: 6-kyu\n\nFrom 1000 through 1199: 5-kyu\n\nFrom 1200 through 1399: 4-kyu\n\nFrom 1400 through 1599: 3-kyu\n\nFrom 1600 through 1799: 2-kyu\n\nFrom 1800 through 1999: 1-kyu\n\nWhat kyu does M-kun have?\n\nConstraints\n\n400 \\leq X \\leq 1999\n\nX is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX\n\nOutput\n\nPrint the kyu M-kun has, as an integer.\nFor example, if he has 8-kyu, print 8.\n\nSample Input 1\n\n725\n\nSample Output 1\n\n7\n\nM-kun's highest rating is 725, which corresponds to 7-kyu.\n\nThus, 7 is the correct output.\n\nSample Input 2\n\n1600\n\nSample Output 2\n\n2\n\nM-kun's highest rating is 1600, which corresponds to 2-kyu.\n\nThus, 2 is the correct output.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 247, "cpu_time_ms": 8, "memory_kb": 2756}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s977530398", "group_id": "codeNet:p02601", "input_text": "local read = setmetatable({}, {__index = function(t, k) local a = {} for i=1,#k do table.insert(a, '*'..string.sub(k, i, i)) end local r = io.read local u = table.unpack or unpack return function() return r(u(a)) end end})\nread.N = function(N) local t={} for i=1,N do t[i]=read.n() end return t end\nstring.totable = function(s) local t={} local u=string.sub for i=1,#s do t[i] = u(s, i, i) end return t end\nstring.split = function(s) local t={} for w in string.gmatch(s, \"[^%s]+\") do table.insert(t, w) end return (table.unpack or unpack)(t) end\nlocal function array(dimensi0n, default_val) assert(type(default_val) ~= 'table') local n=dimensi0n local m={}if default_val~=nil then m[1]={__index=function()return default_val end}end for i=2,n do m[i]={__index=function(p, k)local c=setmetatable({},m[i-1])rawset(p,k,c)return c end}end return setmetatable({},m[n])end\n--\nlocal R, G, B = read.nnn()\nlocal K = read.n()\nwhile K > 0 do\n if G <= R then\n G = G * 2\n elseif B <= G then\n B = B * 2\n end\n K = K - 1\nend\nif G > R and B > G then\n print(\"Yes\")\nelse\n print(\"No\")\nend", "language": "Lua", "metadata": {"date": 1595725833, "filename_ext": "lua", "original_language": "Lua (Lua 5.3.5)", "problem_description_relpath": "problem_descriptions/p02601.html", "problem_id": "p02601", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02601/input.txt", "sample_output_relpath": "derived/input_output/data/p02601/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02601/Lua/s977530398.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s977530398", "user_id": "u162773977"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "local read = setmetatable({}, {__index = function(t, k) local a = {} for i=1,#k do table.insert(a, '*'..string.sub(k, i, i)) end local r = io.read local u = table.unpack or unpack return function() return r(u(a)) end end})\nread.N = function(N) local t={} for i=1,N do t[i]=read.n() end return t end\nstring.totable = function(s) local t={} local u=string.sub for i=1,#s do t[i] = u(s, i, i) end return t end\nstring.split = function(s) local t={} for w in string.gmatch(s, \"[^%s]+\") do table.insert(t, w) end return (table.unpack or unpack)(t) end\nlocal function array(dimensi0n, default_val) assert(type(default_val) ~= 'table') local n=dimensi0n local m={}if default_val~=nil then m[1]={__index=function()return default_val end}end for i=2,n do m[i]={__index=function(p, k)local c=setmetatable({},m[i-1])rawset(p,k,c)return c end}end return setmetatable({},m[n])end\n--\nlocal R, G, B = read.nnn()\nlocal K = read.n()\nwhile K > 0 do\n if G <= R then\n G = G * 2\n elseif B <= G then\n B = B * 2\n end\n K = K - 1\nend\nif G > R and B > G then\n print(\"Yes\")\nelse\n print(\"No\")\nend", "problem_context": "Score: 200 points\n\nProblem Statement\n\nM-kun has the following three cards:\n\nA red card with the integer A.\n\nA green card with the integer B.\n\nA blue card with the integer C.\n\nHe is a genius magician who can do the following operation at most K times:\n\nChoose one of the three cards and multiply the written integer by 2.\n\nHis magic is successful if both of the following conditions are satisfied after the operations:\n\nThe integer on the green card is strictly greater than the integer on the red card.\n\nThe integer on the blue card is strictly greater than the integer on the green card.\n\nDetermine whether the magic can be successful.\n\nConstraints\n\n1 \\leq A, B, C \\leq 7\n\n1 \\leq K \\leq 7\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C\nK\n\nOutput\n\nIf the magic can be successful, print Yes; otherwise, print No.\n\nSample Input 1\n\n7 2 5\n3\n\nSample Output 1\n\nYes\n\nThe magic will be successful if, for example, he does the following operations:\n\nFirst, choose the blue card. The integers on the red, green, and blue cards are now 7, 2, and 10, respectively.\n\nSecond, choose the green card. The integers on the red, green, and blue cards are now 7, 4, and 10, respectively.\n\nThird, choose the green card. The integers on the red, green, and blue cards are now 7, 8, and 10, respectively.\n\nSample Input 2\n\n7 4 2\n3\n\nSample Output 2\n\nNo\n\nHe has no way to succeed in the magic with at most three operations.", "sample_input": "7 2 5\n3\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p02601", "source_text": "Score: 200 points\n\nProblem Statement\n\nM-kun has the following three cards:\n\nA red card with the integer A.\n\nA green card with the integer B.\n\nA blue card with the integer C.\n\nHe is a genius magician who can do the following operation at most K times:\n\nChoose one of the three cards and multiply the written integer by 2.\n\nHis magic is successful if both of the following conditions are satisfied after the operations:\n\nThe integer on the green card is strictly greater than the integer on the red card.\n\nThe integer on the blue card is strictly greater than the integer on the green card.\n\nDetermine whether the magic can be successful.\n\nConstraints\n\n1 \\leq A, B, C \\leq 7\n\n1 \\leq K \\leq 7\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C\nK\n\nOutput\n\nIf the magic can be successful, print Yes; otherwise, print No.\n\nSample Input 1\n\n7 2 5\n3\n\nSample Output 1\n\nYes\n\nThe magic will be successful if, for example, he does the following operations:\n\nFirst, choose the blue card. The integers on the red, green, and blue cards are now 7, 2, and 10, respectively.\n\nSecond, choose the green card. The integers on the red, green, and blue cards are now 7, 4, and 10, respectively.\n\nThird, choose the green card. The integers on the red, green, and blue cards are now 7, 8, and 10, respectively.\n\nSample Input 2\n\n7 4 2\n3\n\nSample Output 2\n\nNo\n\nHe has no way to succeed in the magic with at most three operations.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1099, "cpu_time_ms": 9, "memory_kb": 2688}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s077694831", "group_id": "codeNet:p02601", "input_text": "a, b, c = io.read(\"*n\", \"*n\", \"*n\")\nk = io.read(\"*n\")\nd = 0\nwhile b <= a do\n b = b * 2\n d = d + 1\nend\nwhile c <= b do\n c = c * 2\n d = d + 1\nend\nprint(d <= k and \"Yes\" or \"No\")\n", "language": "Lua", "metadata": {"date": 1595725370, "filename_ext": "lua", "original_language": "Lua (Lua 5.3.5)", "problem_description_relpath": "problem_descriptions/p02601.html", "problem_id": "p02601", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02601/input.txt", "sample_output_relpath": "derived/input_output/data/p02601/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02601/Lua/s077694831.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s077694831", "user_id": "u120582723"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "a, b, c = io.read(\"*n\", \"*n\", \"*n\")\nk = io.read(\"*n\")\nd = 0\nwhile b <= a do\n b = b * 2\n d = d + 1\nend\nwhile c <= b do\n c = c * 2\n d = d + 1\nend\nprint(d <= k and \"Yes\" or \"No\")\n", "problem_context": "Score: 200 points\n\nProblem Statement\n\nM-kun has the following three cards:\n\nA red card with the integer A.\n\nA green card with the integer B.\n\nA blue card with the integer C.\n\nHe is a genius magician who can do the following operation at most K times:\n\nChoose one of the three cards and multiply the written integer by 2.\n\nHis magic is successful if both of the following conditions are satisfied after the operations:\n\nThe integer on the green card is strictly greater than the integer on the red card.\n\nThe integer on the blue card is strictly greater than the integer on the green card.\n\nDetermine whether the magic can be successful.\n\nConstraints\n\n1 \\leq A, B, C \\leq 7\n\n1 \\leq K \\leq 7\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C\nK\n\nOutput\n\nIf the magic can be successful, print Yes; otherwise, print No.\n\nSample Input 1\n\n7 2 5\n3\n\nSample Output 1\n\nYes\n\nThe magic will be successful if, for example, he does the following operations:\n\nFirst, choose the blue card. The integers on the red, green, and blue cards are now 7, 2, and 10, respectively.\n\nSecond, choose the green card. The integers on the red, green, and blue cards are now 7, 4, and 10, respectively.\n\nThird, choose the green card. The integers on the red, green, and blue cards are now 7, 8, and 10, respectively.\n\nSample Input 2\n\n7 4 2\n3\n\nSample Output 2\n\nNo\n\nHe has no way to succeed in the magic with at most three operations.", "sample_input": "7 2 5\n3\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p02601", "source_text": "Score: 200 points\n\nProblem Statement\n\nM-kun has the following three cards:\n\nA red card with the integer A.\n\nA green card with the integer B.\n\nA blue card with the integer C.\n\nHe is a genius magician who can do the following operation at most K times:\n\nChoose one of the three cards and multiply the written integer by 2.\n\nHis magic is successful if both of the following conditions are satisfied after the operations:\n\nThe integer on the green card is strictly greater than the integer on the red card.\n\nThe integer on the blue card is strictly greater than the integer on the green card.\n\nDetermine whether the magic can be successful.\n\nConstraints\n\n1 \\leq A, B, C \\leq 7\n\n1 \\leq K \\leq 7\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C\nK\n\nOutput\n\nIf the magic can be successful, print Yes; otherwise, print No.\n\nSample Input 1\n\n7 2 5\n3\n\nSample Output 1\n\nYes\n\nThe magic will be successful if, for example, he does the following operations:\n\nFirst, choose the blue card. The integers on the red, green, and blue cards are now 7, 2, and 10, respectively.\n\nSecond, choose the green card. The integers on the red, green, and blue cards are now 7, 4, and 10, respectively.\n\nThird, choose the green card. The integers on the red, green, and blue cards are now 7, 8, and 10, respectively.\n\nSample Input 2\n\n7 4 2\n3\n\nSample Output 2\n\nNo\n\nHe has no way to succeed in the magic with at most three operations.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 180, "cpu_time_ms": 7, "memory_kb": 2680}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s658614215", "group_id": "codeNet:p02603", "input_text": "local n = io.read(\"*n\")\nlocal a = {}\nfor i = 1, n do\n a[i] = io.read(\"*n\")\nend\na[n + 1] = 0\nlocal buycost = 1000000007\n\nlocal money = 1000\nlocal kabu = 0\n\nfor i = 1, n do\n local needbuy = false\n local needsell = false\n for j = i + 1, n do\n if a[i] < a[j] then\n needbuy = true\n end\n end\n for j = i + 1, n do\n if a[i] > a[j] then\n needsell = true\n for k = i + 1, j - 1 do\n if a[i] < a[k] then\n needsell = false\n break\n end\n end\n break\n end\n end\n if i == n then needsell = true end\n if needsell then\n money = money + kabu * a[i]\n kabu = 0\n elseif needbuy then\n kabu = kabu + money // a[i]\n money = money % a[i]\n end\n -- print(i, money, kabu)\nend\nprint(money)\n", "language": "Lua", "metadata": {"date": 1595726968, "filename_ext": "lua", "original_language": "Lua (Lua 5.3.5)", "problem_description_relpath": "problem_descriptions/p02603.html", "problem_id": "p02603", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02603/input.txt", "sample_output_relpath": "derived/input_output/data/p02603/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02603/Lua/s658614215.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s658614215", "user_id": "u120582723"}, "prompt_components": {"gold_output": "1685\n", "input_to_evaluate": "local n = io.read(\"*n\")\nlocal a = {}\nfor i = 1, n do\n a[i] = io.read(\"*n\")\nend\na[n + 1] = 0\nlocal buycost = 1000000007\n\nlocal money = 1000\nlocal kabu = 0\n\nfor i = 1, n do\n local needbuy = false\n local needsell = false\n for j = i + 1, n do\n if a[i] < a[j] then\n needbuy = true\n end\n end\n for j = i + 1, n do\n if a[i] > a[j] then\n needsell = true\n for k = i + 1, j - 1 do\n if a[i] < a[k] then\n needsell = false\n break\n end\n end\n break\n end\n end\n if i == n then needsell = true end\n if needsell then\n money = money + kabu * a[i]\n kabu = 0\n elseif needbuy then\n kabu = kabu + money // a[i]\n money = money % a[i]\n end\n -- print(i, money, kabu)\nend\nprint(money)\n", "problem_context": "Score: 400 points\n\nProblem Statement\n\nTo become a millionaire, M-kun has decided to make money by trading in the next N days. Currently, he has 1000 yen and no stocks - only one kind of stock is issued in the country where he lives.\n\nHe is famous across the country for his ability to foresee the future. He already knows that the price of one stock in the next N days will be as follows:\n\nA_1 yen on the 1-st day, A_2 yen on the 2-nd day, ..., A_N yen on the N-th day.\n\nIn the i-th day, M-kun can make the following trade any number of times (possibly zero), within the amount of money and stocks that he has at the time.\n\nBuy stock: Pay A_i yen and receive one stock.\n\nSell stock: Sell one stock for A_i yen.\n\nWhat is the maximum possible amount of money that M-kun can have in the end by trading optimally?\n\nConstraints\n\n2 \\leq N \\leq 80\n\n100 \\leq A_i \\leq 200\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 \\cdots A_N\n\nOutput\n\nPrint the maximum possible amount of money that M-kun can have in the end, as an integer.\n\nSample Input 1\n\n7\n100 130 130 130 115 115 150\n\nSample Output 1\n\n1685\n\nIn this sample input, M-kun has seven days of trading. One way to have 1685 yen in the end is as follows:\n\nInitially, he has 1000 yen and no stocks.\n\nDay 1: Buy 10 stocks for 1000 yen. Now he has 0 yen.\n\nDay 2: Sell 7 stocks for 910 yen. Now he has 910 yen.\n\nDay 3: Sell 3 stocks for 390 yen. Now he has 1300 yen.\n\nDay 4: Do nothing.\n\nDay 5: Buy 1 stock for 115 yen. Now he has 1185 yen.\n\nDay 6: Buy 10 stocks for 1150 yen. Now he has 35 yen.\n\nDay 7: Sell 11 stocks for 1650 yen. Now he has 1685 yen.\n\nThere is no way to have 1686 yen or more in the end, so the answer is 1685.\n\nSample Input 2\n\n6\n200 180 160 140 120 100\n\nSample Output 2\n\n1000\n\nIn this sample input, it is optimal to do nothing throughout the six days, after which we will have 1000 yen.\n\nSample Input 3\n\n2\n157 193\n\nSample Output 3\n\n1216\n\nIn this sample input, it is optimal to buy 6 stocks in Day 1 and sell them in Day 2, after which we will have 1216 yen.", "sample_input": "7\n100 130 130 130 115 115 150\n"}, "reference_outputs": ["1685\n"], "source_document_id": "p02603", "source_text": "Score: 400 points\n\nProblem Statement\n\nTo become a millionaire, M-kun has decided to make money by trading in the next N days. Currently, he has 1000 yen and no stocks - only one kind of stock is issued in the country where he lives.\n\nHe is famous across the country for his ability to foresee the future. He already knows that the price of one stock in the next N days will be as follows:\n\nA_1 yen on the 1-st day, A_2 yen on the 2-nd day, ..., A_N yen on the N-th day.\n\nIn the i-th day, M-kun can make the following trade any number of times (possibly zero), within the amount of money and stocks that he has at the time.\n\nBuy stock: Pay A_i yen and receive one stock.\n\nSell stock: Sell one stock for A_i yen.\n\nWhat is the maximum possible amount of money that M-kun can have in the end by trading optimally?\n\nConstraints\n\n2 \\leq N \\leq 80\n\n100 \\leq A_i \\leq 200\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 \\cdots A_N\n\nOutput\n\nPrint the maximum possible amount of money that M-kun can have in the end, as an integer.\n\nSample Input 1\n\n7\n100 130 130 130 115 115 150\n\nSample Output 1\n\n1685\n\nIn this sample input, M-kun has seven days of trading. One way to have 1685 yen in the end is as follows:\n\nInitially, he has 1000 yen and no stocks.\n\nDay 1: Buy 10 stocks for 1000 yen. Now he has 0 yen.\n\nDay 2: Sell 7 stocks for 910 yen. Now he has 910 yen.\n\nDay 3: Sell 3 stocks for 390 yen. Now he has 1300 yen.\n\nDay 4: Do nothing.\n\nDay 5: Buy 1 stock for 115 yen. Now he has 1185 yen.\n\nDay 6: Buy 10 stocks for 1150 yen. Now he has 35 yen.\n\nDay 7: Sell 11 stocks for 1650 yen. Now he has 1685 yen.\n\nThere is no way to have 1686 yen or more in the end, so the answer is 1685.\n\nSample Input 2\n\n6\n200 180 160 140 120 100\n\nSample Output 2\n\n1000\n\nIn this sample input, it is optimal to do nothing throughout the six days, after which we will have 1000 yen.\n\nSample Input 3\n\n2\n157 193\n\nSample Output 3\n\n1216\n\nIn this sample input, it is optimal to buy 6 stocks in Day 1 and sell them in Day 2, after which we will have 1216 yen.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 749, "cpu_time_ms": 6, "memory_kb": 2756}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s290428924", "group_id": "codeNet:p02604", "input_text": "local mmi, mma = math.min, math.max\nlocal mab = math.abs\nlocal mfl, mce = math.floor, math.ceil\nlocal bls, brs = bit.lshift, bit.rshift\nlocal bxor = bit.bxor\n\nlocal n = io.read(\"*n\")\nlocal x, y, p = {}, {}, {}\nlocal flag = {}\nfor i = 1, n do\n x[i], y[i], p[i] = io.read(\"*n\", \"*n\", \"*n\")\n flag[i] = false\nend\n\nlocal function grayCode(x)\n return bxor(x, brs(x, 1))\nend\n\nlocal function findright(idxes, ofst)\n for i = ofst, #idxes do\n if flag[idxes[i]] then\n return i\n end\n end\n return false\nend\n\nlocal function getmincosts(ik, pos, val, idx_pos, idx_val)\n local retary = {}\n for i = 1, ik + 1 do retary[i] = 0 end\n for i = 1, #pos do flag[i] = false end\n for linecnt = 0, ik do\n if #pos <= linecnt then\n break\n end\n if 0 < linecnt then\n flag[idx_val[linecnt]] = true\n end\n local retval = 0\n local leftpos = false\n local rightpos = findright(idx_pos, 1)\n for i = 1, #idx_pos do\n local idx_i = idx_pos[i]\n if flag[idx_i] then\n leftpos = rightpos\n if rightpos then\n rightpos = findright(idx_pos, rightpos + 1)\n end\n else\n local cand = mab(pos[idx_i])\n if leftpos then\n cand = mmi(cand, mab(pos[idx_i] - pos[idx_pos[leftpos]]))\n end\n if rightpos then\n cand = mmi(cand, mab(pos[idx_i] - pos[idx_pos[rightpos]]))\n end\n retval = retval + cand * val[idx_i]\n end\n end\n retary[linecnt + 1] = retval\n end\n return retary\nend\n\nlocal retik = {}\n\nlocal g_ik = 0\nlocal xs, ys = {}, {}\nlocal function add_func(idx)\n local xv = x[idx]\n local yv = y[idx]\n xs[xv] = xs[xv] - p[idx]\n if xs[xv] == 0 then xs[xv] = nil end\n if not ys[yv] then\n ys[yv] = p[idx]\n else\n ys[yv] = ys[yv] + p[idx]\n end\nend\nlocal function rm_func(idx)\n local xv = x[idx]\n local yv = y[idx]\n ys[yv] = ys[yv] - p[idx]\n if ys[yv] == 0 then ys[yv] = nil end\n if not xs[xv] then\n xs[xv] = p[idx]\n else\n xs[xv] = xs[xv] + p[idx]\n end\nend\nlocal function work_func()\n local cand = 0\n local xpos, xval, xidx_pos, xidx_val = {}, {}, {}, {}\n for k, v in pairs(xs) do\n table.insert(xpos, k)\n table.insert(xval, v)\n end\n for i = 1, #xpos do xidx_pos[i], xidx_val[i] = i, i end\n table.sort(xidx_pos, function(a, b) return xpos[a] < xpos[b] end)\n table.sort(xidx_val, function(a, b) return xval[a] > xval[b] end)\n\n local ypos, yval, yidx_pos, yidx_val = {}, {}, {}, {}\n for k, v in pairs(ys) do\n table.insert(ypos, k)\n table.insert(yval, v)\n end\n for i = 1, #ypos do yidx_pos[i], yidx_val[i] = i, i end\n table.sort(yidx_pos, function(a, b) return ypos[a] < ypos[b] end)\n table.sort(yidx_val, function(a, b) return yval[a] > yval[b] end)\n\n local xcosts = getmincosts(n - 1, xpos, xval, xidx_pos, xidx_val)\n local ycosts = getmincosts(n - 1, ypos, yval, yidx_pos, yidx_val)\n for ik = 0, n - 1 do\n cand = xcosts[0 + 1] + ycosts[ik + 1]\n for i = 1, ik do\n cand = mmi(cand, xcosts[i + 1] + ycosts[ik - i + 1])\n end\n if not retik[ik + 1] then\n retik[ik + 1] = cand\n elseif cand < retik[ik + 1] then\n retik[ik + 1] = cand\n end\n end\nend\n\nlocal function grayWalk(size, add_func, rm_func, work_func)\n local prv = 0\n local total = bls(1, size) - 1\n local bpos = {}\n for i = 1, size do\n bpos[bls(1, i - 1)] = i\n end\n work_func()\n for i = 1, total do\n local v = grayCode(i)\n if prv < v then\n prv, v = v, v - prv\n add_func(bpos[v])\n else\n prv, v = v, prv - v\n rm_func(bpos[v])\n end\n work_func()\n end\nend\n\nfor j = 1, n do\n local xj = x[j]\n if not xs[xj] then\n xs[xj] = p[j]\n else\n xs[xj] = xs[xj] + p[j]\n end\nend\nfor ik = 0, n do\n retik[ik + 1] = false\nend\n\ngrayWalk(n, add_func, rm_func, work_func)\nretik[n + 1] = 0\nprint(table.concat(retik, \"\\n\"))\n-- print(os.clock())\n", "language": "Lua", "metadata": {"date": 1595737134, "filename_ext": "lua", "original_language": "Lua (LuaJIT 2.1.0)", "problem_description_relpath": "problem_descriptions/p02604.html", "problem_id": "p02604", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02604/input.txt", "sample_output_relpath": "derived/input_output/data/p02604/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02604/Lua/s290428924.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s290428924", "user_id": "u120582723"}, "prompt_components": {"gold_output": "2900\n900\n0\n0\n", "input_to_evaluate": "local mmi, mma = math.min, math.max\nlocal mab = math.abs\nlocal mfl, mce = math.floor, math.ceil\nlocal bls, brs = bit.lshift, bit.rshift\nlocal bxor = bit.bxor\n\nlocal n = io.read(\"*n\")\nlocal x, y, p = {}, {}, {}\nlocal flag = {}\nfor i = 1, n do\n x[i], y[i], p[i] = io.read(\"*n\", \"*n\", \"*n\")\n flag[i] = false\nend\n\nlocal function grayCode(x)\n return bxor(x, brs(x, 1))\nend\n\nlocal function findright(idxes, ofst)\n for i = ofst, #idxes do\n if flag[idxes[i]] then\n return i\n end\n end\n return false\nend\n\nlocal function getmincosts(ik, pos, val, idx_pos, idx_val)\n local retary = {}\n for i = 1, ik + 1 do retary[i] = 0 end\n for i = 1, #pos do flag[i] = false end\n for linecnt = 0, ik do\n if #pos <= linecnt then\n break\n end\n if 0 < linecnt then\n flag[idx_val[linecnt]] = true\n end\n local retval = 0\n local leftpos = false\n local rightpos = findright(idx_pos, 1)\n for i = 1, #idx_pos do\n local idx_i = idx_pos[i]\n if flag[idx_i] then\n leftpos = rightpos\n if rightpos then\n rightpos = findright(idx_pos, rightpos + 1)\n end\n else\n local cand = mab(pos[idx_i])\n if leftpos then\n cand = mmi(cand, mab(pos[idx_i] - pos[idx_pos[leftpos]]))\n end\n if rightpos then\n cand = mmi(cand, mab(pos[idx_i] - pos[idx_pos[rightpos]]))\n end\n retval = retval + cand * val[idx_i]\n end\n end\n retary[linecnt + 1] = retval\n end\n return retary\nend\n\nlocal retik = {}\n\nlocal g_ik = 0\nlocal xs, ys = {}, {}\nlocal function add_func(idx)\n local xv = x[idx]\n local yv = y[idx]\n xs[xv] = xs[xv] - p[idx]\n if xs[xv] == 0 then xs[xv] = nil end\n if not ys[yv] then\n ys[yv] = p[idx]\n else\n ys[yv] = ys[yv] + p[idx]\n end\nend\nlocal function rm_func(idx)\n local xv = x[idx]\n local yv = y[idx]\n ys[yv] = ys[yv] - p[idx]\n if ys[yv] == 0 then ys[yv] = nil end\n if not xs[xv] then\n xs[xv] = p[idx]\n else\n xs[xv] = xs[xv] + p[idx]\n end\nend\nlocal function work_func()\n local cand = 0\n local xpos, xval, xidx_pos, xidx_val = {}, {}, {}, {}\n for k, v in pairs(xs) do\n table.insert(xpos, k)\n table.insert(xval, v)\n end\n for i = 1, #xpos do xidx_pos[i], xidx_val[i] = i, i end\n table.sort(xidx_pos, function(a, b) return xpos[a] < xpos[b] end)\n table.sort(xidx_val, function(a, b) return xval[a] > xval[b] end)\n\n local ypos, yval, yidx_pos, yidx_val = {}, {}, {}, {}\n for k, v in pairs(ys) do\n table.insert(ypos, k)\n table.insert(yval, v)\n end\n for i = 1, #ypos do yidx_pos[i], yidx_val[i] = i, i end\n table.sort(yidx_pos, function(a, b) return ypos[a] < ypos[b] end)\n table.sort(yidx_val, function(a, b) return yval[a] > yval[b] end)\n\n local xcosts = getmincosts(n - 1, xpos, xval, xidx_pos, xidx_val)\n local ycosts = getmincosts(n - 1, ypos, yval, yidx_pos, yidx_val)\n for ik = 0, n - 1 do\n cand = xcosts[0 + 1] + ycosts[ik + 1]\n for i = 1, ik do\n cand = mmi(cand, xcosts[i + 1] + ycosts[ik - i + 1])\n end\n if not retik[ik + 1] then\n retik[ik + 1] = cand\n elseif cand < retik[ik + 1] then\n retik[ik + 1] = cand\n end\n end\nend\n\nlocal function grayWalk(size, add_func, rm_func, work_func)\n local prv = 0\n local total = bls(1, size) - 1\n local bpos = {}\n for i = 1, size do\n bpos[bls(1, i - 1)] = i\n end\n work_func()\n for i = 1, total do\n local v = grayCode(i)\n if prv < v then\n prv, v = v, v - prv\n add_func(bpos[v])\n else\n prv, v = v, prv - v\n rm_func(bpos[v])\n end\n work_func()\n end\nend\n\nfor j = 1, n do\n local xj = x[j]\n if not xs[xj] then\n xs[xj] = p[j]\n else\n xs[xj] = xs[xj] + p[j]\n end\nend\nfor ik = 0, n do\n retik[ik + 1] = false\nend\n\ngrayWalk(n, add_func, rm_func, work_func)\nretik[n + 1] = 0\nprint(table.concat(retik, \"\\n\"))\n-- print(os.clock())\n", "problem_context": "Score: 500 points\n\nProblem Statement\n\nNew AtCoder City has an infinite grid of streets, as follows:\n\nAt the center of the city stands a clock tower. Let (0, 0) be the coordinates of this point.\n\nA straight street, which we will call East-West Main Street, runs east-west and passes the clock tower. It corresponds to the x-axis in the two-dimensional coordinate plane.\n\nThere are also other infinitely many streets parallel to East-West Main Street, with a distance of 1 between them. They correspond to the lines \\ldots, y = -2, y = -1, y = 1, y = 2, \\ldots in the two-dimensional coordinate plane.\n\nA straight street, which we will call North-South Main Street, runs north-south and passes the clock tower. It corresponds to the y-axis in the two-dimensional coordinate plane.\n\nThere are also other infinitely many streets parallel to North-South Main Street, with a distance of 1 between them. They correspond to the lines \\ldots, x = -2, x = -1, x = 1, x = 2, \\ldots in the two-dimensional coordinate plane.\n\nThere are N residential areas in New AtCoder City. The i-th area is located at the intersection with the coordinates (X_i, Y_i) and has a population of P_i. Each citizen in the city lives in one of these areas.\n\nThe city currently has only two railroads, stretching infinitely, one along East-West Main Street and the other along North-South Main Street.\n\nM-kun, the mayor, thinks that they are not enough for the commuters, so he decides to choose K streets and build a railroad stretching infinitely along each of those streets.\n\nLet the walking distance of each citizen be the distance from his/her residential area to the nearest railroad.\n\nM-kun wants to build railroads so that the sum of the walking distances of all citizens, S, is minimized.\n\nFor each K = 0, 1, 2, \\dots, N, what is the minimum possible value of S after building railroads?\n\nConstraints\n\n1 \\leq N \\leq 15\n\n-10 \\ 000 \\leq X_i \\leq 10 \\ 000\n\n-10 \\ 000 \\leq Y_i \\leq 10 \\ 000\n\n1 \\leq P_i \\leq 1 \\ 000 \\ 000\n\nThe locations of the N residential areas, (X_i, Y_i), are all distinct.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nX_1 Y_1 P_1\nX_2 Y_2 P_2\n: : :\nX_N Y_N P_N\n\nOutput\n\nPrint the answer in N+1 lines.\n\nThe i-th line (i = 1, \\ldots, N+1) should contain the minimum possible value of S after building railroads for the case K = i-1.\n\nSample Input 1\n\n3\n1 2 300\n3 3 600\n1 4 800\n\nSample Output 1\n\n2900\n900\n0\n0\n\nWhen K = 0, the residents of Area 1, 2, and 3 have to walk the distances of 1, 3, and 1, respectively, to reach a railroad.\n\nThus, the sum of the walking distances of all citizens, S, is 1 \\times 300 + 3 \\times 600 + 1 \\times 800 = 2900.\n\nWhen K = 1, if we build a railroad along the street corresponding to the line y = 4 in the coordinate plane, the walking distances of the citizens of Area 1, 2, and 3 become 1, 1, and 0, respectively.\n\nThen, S = 1 \\times 300 + 1 \\times 600 + 0 \\times 800 = 900.\n\nWe have many other options for where we build the railroad, but none of them makes S less than 900.\n\nWhen K = 2, if we build a railroad along the street corresponding to the lines x = 1 and x = 3 in the coordinate plane, all citizens can reach a railroad with the walking distance of 0, so S = 0. We can also have S = 0 when K = 3.\n\nThe figure below shows the optimal way to build railroads for the cases K = 0, 1, 2.\n\nThe street painted blue represents the roads along which we build railroads.\n\nSample Input 2\n\n5\n3 5 400\n5 3 700\n5 5 1000\n5 7 700\n7 5 400\n\nSample Output 2\n\n13800\n1600\n0\n0\n0\n0\n\nThe figure below shows the optimal way to build railroads for the cases K = 1, 2.\n\nSample Input 3\n\n6\n2 5 1000\n5 2 1100\n5 5 1700\n-2 -5 900\n-5 -2 600\n-5 -5 2200\n\nSample Output 3\n\n26700\n13900\n3200\n1200\n0\n0\n0\n\nThe figure below shows the optimal way to build railroads for the case K = 3.\n\nSample Input 4\n\n8\n2 2 286017\n3 1 262355\n2 -2 213815\n1 -3 224435\n-2 -2 136860\n-3 -1 239338\n-2 2 217647\n-1 3 141903\n\nSample Output 4\n\n2576709\n1569381\n868031\n605676\n366338\n141903\n0\n0\n0\n\nThe figure below shows the optimal way to build railroads for the case K = 4.", "sample_input": "3\n1 2 300\n3 3 600\n1 4 800\n"}, "reference_outputs": ["2900\n900\n0\n0\n"], "source_document_id": "p02604", "source_text": "Score: 500 points\n\nProblem Statement\n\nNew AtCoder City has an infinite grid of streets, as follows:\n\nAt the center of the city stands a clock tower. Let (0, 0) be the coordinates of this point.\n\nA straight street, which we will call East-West Main Street, runs east-west and passes the clock tower. It corresponds to the x-axis in the two-dimensional coordinate plane.\n\nThere are also other infinitely many streets parallel to East-West Main Street, with a distance of 1 between them. They correspond to the lines \\ldots, y = -2, y = -1, y = 1, y = 2, \\ldots in the two-dimensional coordinate plane.\n\nA straight street, which we will call North-South Main Street, runs north-south and passes the clock tower. It corresponds to the y-axis in the two-dimensional coordinate plane.\n\nThere are also other infinitely many streets parallel to North-South Main Street, with a distance of 1 between them. They correspond to the lines \\ldots, x = -2, x = -1, x = 1, x = 2, \\ldots in the two-dimensional coordinate plane.\n\nThere are N residential areas in New AtCoder City. The i-th area is located at the intersection with the coordinates (X_i, Y_i) and has a population of P_i. Each citizen in the city lives in one of these areas.\n\nThe city currently has only two railroads, stretching infinitely, one along East-West Main Street and the other along North-South Main Street.\n\nM-kun, the mayor, thinks that they are not enough for the commuters, so he decides to choose K streets and build a railroad stretching infinitely along each of those streets.\n\nLet the walking distance of each citizen be the distance from his/her residential area to the nearest railroad.\n\nM-kun wants to build railroads so that the sum of the walking distances of all citizens, S, is minimized.\n\nFor each K = 0, 1, 2, \\dots, N, what is the minimum possible value of S after building railroads?\n\nConstraints\n\n1 \\leq N \\leq 15\n\n-10 \\ 000 \\leq X_i \\leq 10 \\ 000\n\n-10 \\ 000 \\leq Y_i \\leq 10 \\ 000\n\n1 \\leq P_i \\leq 1 \\ 000 \\ 000\n\nThe locations of the N residential areas, (X_i, Y_i), are all distinct.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nX_1 Y_1 P_1\nX_2 Y_2 P_2\n: : :\nX_N Y_N P_N\n\nOutput\n\nPrint the answer in N+1 lines.\n\nThe i-th line (i = 1, \\ldots, N+1) should contain the minimum possible value of S after building railroads for the case K = i-1.\n\nSample Input 1\n\n3\n1 2 300\n3 3 600\n1 4 800\n\nSample Output 1\n\n2900\n900\n0\n0\n\nWhen K = 0, the residents of Area 1, 2, and 3 have to walk the distances of 1, 3, and 1, respectively, to reach a railroad.\n\nThus, the sum of the walking distances of all citizens, S, is 1 \\times 300 + 3 \\times 600 + 1 \\times 800 = 2900.\n\nWhen K = 1, if we build a railroad along the street corresponding to the line y = 4 in the coordinate plane, the walking distances of the citizens of Area 1, 2, and 3 become 1, 1, and 0, respectively.\n\nThen, S = 1 \\times 300 + 1 \\times 600 + 0 \\times 800 = 900.\n\nWe have many other options for where we build the railroad, but none of them makes S less than 900.\n\nWhen K = 2, if we build a railroad along the street corresponding to the lines x = 1 and x = 3 in the coordinate plane, all citizens can reach a railroad with the walking distance of 0, so S = 0. We can also have S = 0 when K = 3.\n\nThe figure below shows the optimal way to build railroads for the cases K = 0, 1, 2.\n\nThe street painted blue represents the roads along which we build railroads.\n\nSample Input 2\n\n5\n3 5 400\n5 3 700\n5 5 1000\n5 7 700\n7 5 400\n\nSample Output 2\n\n13800\n1600\n0\n0\n0\n0\n\nThe figure below shows the optimal way to build railroads for the cases K = 1, 2.\n\nSample Input 3\n\n6\n2 5 1000\n5 2 1100\n5 5 1700\n-2 -5 900\n-5 -2 600\n-5 -5 2200\n\nSample Output 3\n\n26700\n13900\n3200\n1200\n0\n0\n0\n\nThe figure below shows the optimal way to build railroads for the case K = 3.\n\nSample Input 4\n\n8\n2 2 286017\n3 1 262355\n2 -2 213815\n1 -3 224435\n-2 -2 136860\n-3 -1 239338\n-2 2 217647\n-1 3 141903\n\nSample Output 4\n\n2576709\n1569381\n868031\n605676\n366338\n141903\n0\n0\n0\n\nThe figure below shows the optimal way to build railroads for the case K = 4.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 3812, "cpu_time_ms": 484, "memory_kb": 2812}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s745908610", "group_id": "codeNet:p02605", "input_text": "local read = setmetatable({}, {__index = function(t, k) local a = {} for i=1,#k do table.insert(a, '*'..string.sub(k, i, i)) end local r = io.read local u = table.unpack or unpack return function() return r(u(a)) end end})\nread.N = function(N) local t={} for i=1,N do t[i]=read.n() end return t end\nstring.totable = function(s) local t={} local u=string.sub for i=1,#s do t[i] = u(s, i, i) end return t end\nstring.split = function(s) local t={} for w in string.gmatch(s, \"[^%s]+\") do table.insert(t, w) end return (table.unpack or unpack)(t) end\nlocal function array(dimensi0n, default_val) assert(type(default_val) ~= 'table') local n=dimensi0n local m={}if default_val~=nil then m[1]={__index=function()return default_val end}end for i=2,n do m[i]={__index=function(p, k)local c=setmetatable({},m[i-1])rawset(p,k,c)return c end}end return setmetatable({},m[n])end\nlocal function tostringxx(o, depth) depth = depth or 0 if depth > 10 then return \"\" end if o == _G then return \"<_G>\" end local indent0 = (\" \"):rep((depth) * 2) local indent1 = (\" \"):rep((depth+1) * 2) local indent2= (\" \"):rep((depth+2) * 2) if type(o) == 'table' then local keys = {} local types = {} for k in pairs(o) do types[type(k)] = true table.insert(keys, k) end local types_count = 0 local lasttype for k in pairs(types) do types_count = types_count + 1 lasttype = k end if types_count == 1 and (lasttype == 'string' or lasttype == 'number') then table.sort(keys) end local inside = {} for i=1,#keys do local k = keys[i] local v = o[k] if type(k) == 'string' then k = string.format('%q', k) end table.insert(inside, indent1 .. '['..tostring(k)..'] = ' .. tostringxx(v, depth + 1)) end return '{\\n' .. table.concat(inside, ',\\n') .. '\\n' .. indent0 .. '}' else if type(o) == 'string' then o = string.format('%q', o) end return tostring(o) end end\nlocal function richtraceback() local x = 2 while true do local info = debug.getinfo(x) if not info then break end local fname = '<' .. info.short_src .. \":\" .. info.linedefined .. \">\" if info.name then fname = info.name end print(info.short_src .. \":\" .. info.currentline .. \": in \" .. (\"%q\"):format(fname)) print(\" LOCALS:\") local p = 1 while true do local name, val = debug.getlocal(x,p) if not name then break end print(\" \" .. name .. \": \" .. tostringxx(val, 3)) p = p + 1 end print(\" UPVALUES:\") for p=1,info.nups do local name, val = debug.getupvalue(info.func,p) if not name then break end print(\" \" .. name .. \": \" .. tostringxx(val, 3)) end x = x + 1 end end\nlocal function myassert(b) if not b then richtraceback() error(\"assertion failed\") end end \n--\nlocal DBG = false\nlocal insert = table.insert\nlocal function getkeys(t)\n local keys = {}\n for k,v in pairs(t) do\n insert(keys, k)\n end\n table.sort(keys)\n return keys\nend\n\nlocal function dbgpr(...)\n if DBG then\n io.write(\"[dbg]\")\n print(...)\n end\nend\n--\nlocal N = read.nl()\nlocal X, Y, U = {},{},{}\nlocal yy = {}\nlocal xx = {}\nlocal rr = {} -- right down\nlocal ll = {} -- left down\nlocal function push(tt, p, e)\n if not tt[p] then\n tt[p] = {}\n end\n insert(tt[p], e)\nend\nfor i=1,N do\n X[i], Y[i], U[i] = read.nnl()\n U[i] = U[i]:sub(2,2)\n local e = i\n push(yy, Y[i], e)\n push(xx, X[i], e)\n local rrp = X[i] + Y[i]\n push(rr, rrp, e)\n local llp = X[i] - Y[i]\n push(ll, llp, e)\nend\n--richtraceback()\nlocal INF = 10^18\nlocal nearest_crash = INF\nlocal function f1(name, tt, inv, fw, bk, sp)\n local ttk = getkeys(tt)\n for _,w in ipairs(ttk) do\n local t = tt[w]\n dbgpr(\"on same \" .. name , w)\n local inttk = {}\n for _,i in ipairs(t) do\n if U[i] == fw or U[i] == bk then\n insert(inttk, {inv[i], i, U[i]})\n end\n end\n table.sort(inttk, function (a1, a2)\n return a1[1] < a2[1]\n end)\n local state = 0\n local recentfwinv = -200000\n for _,ee in ipairs(inttk) do\n local i = ee[2]\n if U[i] == fw or U[i] == bk then\n dbgpr(\"plane #\" .. i, \"inv=\"..inv[i], \"X=\"..X[i], \"Y=\"..Y[i], U[i])\n if state == 0 then\n if U[i] == fw then\n state = 1\n recentfwinv = inv[i]\n end\n elseif state == 1 then\n if U[i] == fw then\n recentfwinv = inv[i]\n elseif U[i] == bk then\n local d = inv[i] - recentfwinv\n nearest_crash = math.min(nearest_crash, d * sp)\n dbgpr(\"crash!\", i, nearest_crash)\n end\n end\n end\n end\n end\n \nend\nf1('Y', yy, X, 'R', 'L', 5)\nf1('X', xx, Y, 'U', 'D', 5)\nf1('rr', rr, X, 'R', 'U', 10)\nf1('rr', rr, X, 'D', 'L', 10)\nf1('ll', ll, X, 'U', 'L', 10)\nf1('ll', ll, X, 'R', 'D', 10)\n\nif nearest_crash == INF then\n print(\"SAFE\")\nelse\n print(nearest_crash)\nend", "language": "Lua", "metadata": {"date": 1595797616, "filename_ext": "lua", "original_language": "Lua (LuaJIT 2.1.0)", "problem_description_relpath": "problem_descriptions/p02605.html", "problem_id": "p02605", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02605/input.txt", "sample_output_relpath": "derived/input_output/data/p02605/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02605/Lua/s745908610.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s745908610", "user_id": "u162773977"}, "prompt_components": {"gold_output": "230\n", "input_to_evaluate": "local read = setmetatable({}, {__index = function(t, k) local a = {} for i=1,#k do table.insert(a, '*'..string.sub(k, i, i)) end local r = io.read local u = table.unpack or unpack return function() return r(u(a)) end end})\nread.N = function(N) local t={} for i=1,N do t[i]=read.n() end return t end\nstring.totable = function(s) local t={} local u=string.sub for i=1,#s do t[i] = u(s, i, i) end return t end\nstring.split = function(s) local t={} for w in string.gmatch(s, \"[^%s]+\") do table.insert(t, w) end return (table.unpack or unpack)(t) end\nlocal function array(dimensi0n, default_val) assert(type(default_val) ~= 'table') local n=dimensi0n local m={}if default_val~=nil then m[1]={__index=function()return default_val end}end for i=2,n do m[i]={__index=function(p, k)local c=setmetatable({},m[i-1])rawset(p,k,c)return c end}end return setmetatable({},m[n])end\nlocal function tostringxx(o, depth) depth = depth or 0 if depth > 10 then return \"\" end if o == _G then return \"<_G>\" end local indent0 = (\" \"):rep((depth) * 2) local indent1 = (\" \"):rep((depth+1) * 2) local indent2= (\" \"):rep((depth+2) * 2) if type(o) == 'table' then local keys = {} local types = {} for k in pairs(o) do types[type(k)] = true table.insert(keys, k) end local types_count = 0 local lasttype for k in pairs(types) do types_count = types_count + 1 lasttype = k end if types_count == 1 and (lasttype == 'string' or lasttype == 'number') then table.sort(keys) end local inside = {} for i=1,#keys do local k = keys[i] local v = o[k] if type(k) == 'string' then k = string.format('%q', k) end table.insert(inside, indent1 .. '['..tostring(k)..'] = ' .. tostringxx(v, depth + 1)) end return '{\\n' .. table.concat(inside, ',\\n') .. '\\n' .. indent0 .. '}' else if type(o) == 'string' then o = string.format('%q', o) end return tostring(o) end end\nlocal function richtraceback() local x = 2 while true do local info = debug.getinfo(x) if not info then break end local fname = '<' .. info.short_src .. \":\" .. info.linedefined .. \">\" if info.name then fname = info.name end print(info.short_src .. \":\" .. info.currentline .. \": in \" .. (\"%q\"):format(fname)) print(\" LOCALS:\") local p = 1 while true do local name, val = debug.getlocal(x,p) if not name then break end print(\" \" .. name .. \": \" .. tostringxx(val, 3)) p = p + 1 end print(\" UPVALUES:\") for p=1,info.nups do local name, val = debug.getupvalue(info.func,p) if not name then break end print(\" \" .. name .. \": \" .. tostringxx(val, 3)) end x = x + 1 end end\nlocal function myassert(b) if not b then richtraceback() error(\"assertion failed\") end end \n--\nlocal DBG = false\nlocal insert = table.insert\nlocal function getkeys(t)\n local keys = {}\n for k,v in pairs(t) do\n insert(keys, k)\n end\n table.sort(keys)\n return keys\nend\n\nlocal function dbgpr(...)\n if DBG then\n io.write(\"[dbg]\")\n print(...)\n end\nend\n--\nlocal N = read.nl()\nlocal X, Y, U = {},{},{}\nlocal yy = {}\nlocal xx = {}\nlocal rr = {} -- right down\nlocal ll = {} -- left down\nlocal function push(tt, p, e)\n if not tt[p] then\n tt[p] = {}\n end\n insert(tt[p], e)\nend\nfor i=1,N do\n X[i], Y[i], U[i] = read.nnl()\n U[i] = U[i]:sub(2,2)\n local e = i\n push(yy, Y[i], e)\n push(xx, X[i], e)\n local rrp = X[i] + Y[i]\n push(rr, rrp, e)\n local llp = X[i] - Y[i]\n push(ll, llp, e)\nend\n--richtraceback()\nlocal INF = 10^18\nlocal nearest_crash = INF\nlocal function f1(name, tt, inv, fw, bk, sp)\n local ttk = getkeys(tt)\n for _,w in ipairs(ttk) do\n local t = tt[w]\n dbgpr(\"on same \" .. name , w)\n local inttk = {}\n for _,i in ipairs(t) do\n if U[i] == fw or U[i] == bk then\n insert(inttk, {inv[i], i, U[i]})\n end\n end\n table.sort(inttk, function (a1, a2)\n return a1[1] < a2[1]\n end)\n local state = 0\n local recentfwinv = -200000\n for _,ee in ipairs(inttk) do\n local i = ee[2]\n if U[i] == fw or U[i] == bk then\n dbgpr(\"plane #\" .. i, \"inv=\"..inv[i], \"X=\"..X[i], \"Y=\"..Y[i], U[i])\n if state == 0 then\n if U[i] == fw then\n state = 1\n recentfwinv = inv[i]\n end\n elseif state == 1 then\n if U[i] == fw then\n recentfwinv = inv[i]\n elseif U[i] == bk then\n local d = inv[i] - recentfwinv\n nearest_crash = math.min(nearest_crash, d * sp)\n dbgpr(\"crash!\", i, nearest_crash)\n end\n end\n end\n end\n end\n \nend\nf1('Y', yy, X, 'R', 'L', 5)\nf1('X', xx, Y, 'U', 'D', 5)\nf1('rr', rr, X, 'R', 'U', 10)\nf1('rr', rr, X, 'D', 'L', 10)\nf1('ll', ll, X, 'U', 'L', 10)\nf1('ll', ll, X, 'R', 'D', 10)\n\nif nearest_crash == INF then\n print(\"SAFE\")\nelse\n print(nearest_crash)\nend", "problem_context": "Score: 600 points\n\nProblem Statement\n\nM-kun is a brilliant air traffic controller.\n\nOn the display of his radar, there are N airplanes numbered 1, 2, ..., N, all flying at the same altitude.\n\nEach of the airplanes flies at a constant speed of 0.1 per second in a constant direction. The current coordinates of the airplane numbered i are (X_i, Y_i), and the direction of the airplane is as follows:\n\nif U_i is U, it flies in the positive y direction;\n\nif U_i is R, it flies in the positive x direction;\n\nif U_i is D, it flies in the negative y direction;\n\nif U_i is L, it flies in the negative x direction.\n\nTo help M-kun in his work, determine whether there is a pair of airplanes that will collide with each other if they keep flying as they are now.\n\nIf there is such a pair, find the number of seconds after which the first collision will happen.\n\nWe assume that the airplanes are negligibly small so that two airplanes only collide when they reach the same coordinates simultaneously.\n\nConstraints\n\n1 \\leq N \\leq 200000\n\n0 \\leq X_i, Y_i \\leq 200000\n\nU_i is U, R, D, or L.\n\nThe current positions of the N airplanes, (X_i, Y_i), are all distinct.\n\nN, X_i, and Y_i are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nX_1 Y_1 U_1\nX_2 Y_2 U_2\nX_3 Y_3 U_3\n:\nX_N Y_N U_N\n\nOutput\n\nIf there is a pair of airplanes that will collide with each other if they keep flying as they are now, print an integer representing the number of seconds after which the first collision will happen.\n\nIf there is no such pair, print SAFE.\n\nSample Input 1\n\n2\n11 1 U\n11 47 D\n\nSample Output 1\n\n230\n\nIf the airplanes keep flying as they are now, two airplanes numbered 1 and 2 will reach the coordinates (11, 24) simultaneously and collide.\n\nSample Input 2\n\n4\n20 30 U\n30 20 R\n20 10 D\n10 20 L\n\nSample Output 2\n\nSAFE\n\nNo pair of airplanes will collide.\n\nSample Input 3\n\n8\n168 224 U\n130 175 R\n111 198 D\n121 188 L\n201 116 U\n112 121 R\n145 239 D\n185 107 L\n\nSample Output 3\n\n100", "sample_input": "2\n11 1 U\n11 47 D\n"}, "reference_outputs": ["230\n"], "source_document_id": "p02605", "source_text": "Score: 600 points\n\nProblem Statement\n\nM-kun is a brilliant air traffic controller.\n\nOn the display of his radar, there are N airplanes numbered 1, 2, ..., N, all flying at the same altitude.\n\nEach of the airplanes flies at a constant speed of 0.1 per second in a constant direction. The current coordinates of the airplane numbered i are (X_i, Y_i), and the direction of the airplane is as follows:\n\nif U_i is U, it flies in the positive y direction;\n\nif U_i is R, it flies in the positive x direction;\n\nif U_i is D, it flies in the negative y direction;\n\nif U_i is L, it flies in the negative x direction.\n\nTo help M-kun in his work, determine whether there is a pair of airplanes that will collide with each other if they keep flying as they are now.\n\nIf there is such a pair, find the number of seconds after which the first collision will happen.\n\nWe assume that the airplanes are negligibly small so that two airplanes only collide when they reach the same coordinates simultaneously.\n\nConstraints\n\n1 \\leq N \\leq 200000\n\n0 \\leq X_i, Y_i \\leq 200000\n\nU_i is U, R, D, or L.\n\nThe current positions of the N airplanes, (X_i, Y_i), are all distinct.\n\nN, X_i, and Y_i are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nX_1 Y_1 U_1\nX_2 Y_2 U_2\nX_3 Y_3 U_3\n:\nX_N Y_N U_N\n\nOutput\n\nIf there is a pair of airplanes that will collide with each other if they keep flying as they are now, print an integer representing the number of seconds after which the first collision will happen.\n\nIf there is no such pair, print SAFE.\n\nSample Input 1\n\n2\n11 1 U\n11 47 D\n\nSample Output 1\n\n230\n\nIf the airplanes keep flying as they are now, two airplanes numbered 1 and 2 will reach the coordinates (11, 24) simultaneously and collide.\n\nSample Input 2\n\n4\n20 30 U\n30 20 R\n20 10 D\n10 20 L\n\nSample Output 2\n\nSAFE\n\nNo pair of airplanes will collide.\n\nSample Input 3\n\n8\n168 224 U\n130 175 R\n111 198 D\n121 188 L\n201 116 U\n112 121 R\n145 239 D\n185 107 L\n\nSample Output 3\n\n100", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 4979, "cpu_time_ms": 3216, "memory_kb": 173080}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s370552386", "group_id": "codeNet:p02606", "input_text": "-- AIsing Programming Contest 2020\nl, r, d = io.read(\"*n\", \"*n\", \"*n\")\nk = l / d\nif (k * d) < l then k = k + 1 end\nprint(k)", "language": "Lua", "metadata": {"date": 1595607580, "filename_ext": "lua", "original_language": "Lua (Lua 5.3.5)", "problem_description_relpath": "problem_descriptions/p02606.html", "problem_id": "p02606", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02606/input.txt", "sample_output_relpath": "derived/input_output/data/p02606/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02606/Lua/s370552386.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s370552386", "user_id": "u803033472"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "-- AIsing Programming Contest 2020\nl, r, d = io.read(\"*n\", \"*n\", \"*n\")\nk = l / d\nif (k * d) < l then k = k + 1 end\nprint(k)", "problem_context": "Score : 100 points\n\nProblem Statement\n\nHow many multiples of d are there among the integers between L and R (inclusive)?\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq L \\leq R \\leq 100\n\n1 \\leq d \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nL R d\n\nOutput\n\nPrint the number of multiples of d among the integers between L and R (inclusive).\n\nSample Input 1\n\n5 10 2\n\nSample Output 1\n\n3\n\nAmong the integers between 5 and 10, there are three multiples of 2: 6, 8, and 10.\n\nSample Input 2\n\n6 20 7\n\nSample Output 2\n\n2\n\nAmong the integers between 6 and 20, there are two multiples of 7: 7 and 14.\n\nSample Input 3\n\n1 100 1\n\nSample Output 3\n\n100", "sample_input": "5 10 2\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02606", "source_text": "Score : 100 points\n\nProblem Statement\n\nHow many multiples of d are there among the integers between L and R (inclusive)?\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq L \\leq R \\leq 100\n\n1 \\leq d \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nL R d\n\nOutput\n\nPrint the number of multiples of d among the integers between L and R (inclusive).\n\nSample Input 1\n\n5 10 2\n\nSample Output 1\n\n3\n\nAmong the integers between 5 and 10, there are three multiples of 2: 6, 8, and 10.\n\nSample Input 2\n\n6 20 7\n\nSample Output 2\n\n2\n\nAmong the integers between 6 and 20, there are two multiples of 7: 7 and 14.\n\nSample Input 3\n\n1 100 1\n\nSample Output 3\n\n100", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 123, "cpu_time_ms": 8, "memory_kb": 2704}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s019716419", "group_id": "codeNet:p02607", "input_text": "n = io.read(\"*n\")\ncnt = 0\nfor i = 1, n do\n x = io.read(\"*n\")\n if (i % 2 == 1) and (x % 2 == 1) then\n cnt = cnt + 1\n end\nend\nprint(cnt)", "language": "Lua", "metadata": {"date": 1595616452, "filename_ext": "lua", "original_language": "Lua (Lua 5.3.5)", "problem_description_relpath": "problem_descriptions/p02607.html", "problem_id": "p02607", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02607/input.txt", "sample_output_relpath": "derived/input_output/data/p02607/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02607/Lua/s019716419.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s019716419", "user_id": "u803033472"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "n = io.read(\"*n\")\ncnt = 0\nfor i = 1, n do\n x = io.read(\"*n\")\n if (i % 2 == 1) and (x % 2 == 1) then\n cnt = cnt + 1\n end\nend\nprint(cnt)", "problem_context": "Score : 200 points\n\nProblem Statement\n\nWe have N squares assigned the numbers 1,2,3,\\ldots,N. Each square has an integer written on it, and the integer written on Square i is a_i.\n\nHow many squares i satisfy both of the following conditions?\n\nThe assigned number, i, is odd.\n\nThe written integer is odd.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N, a_i \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 \\cdots a_N\n\nOutput\n\nPrint the number of squares that satisfy both of the conditions.\n\nSample Input 1\n\n5\n1 3 4 5 7\n\nSample Output 1\n\n2\n\nTwo squares, Square 1 and 5, satisfy both of the conditions.\n\nFor Square 2 and 4, the assigned numbers are not odd.\n\nFor Square 3, the written integer is not odd.\n\nSample Input 2\n\n15\n13 76 46 15 50 98 93 77 31 43 84 90 6 24 14\n\nSample Output 2\n\n3", "sample_input": "5\n1 3 4 5 7\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02607", "source_text": "Score : 200 points\n\nProblem Statement\n\nWe have N squares assigned the numbers 1,2,3,\\ldots,N. Each square has an integer written on it, and the integer written on Square i is a_i.\n\nHow many squares i satisfy both of the following conditions?\n\nThe assigned number, i, is odd.\n\nThe written integer is odd.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N, a_i \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 \\cdots a_N\n\nOutput\n\nPrint the number of squares that satisfy both of the conditions.\n\nSample Input 1\n\n5\n1 3 4 5 7\n\nSample Output 1\n\n2\n\nTwo squares, Square 1 and 5, satisfy both of the conditions.\n\nFor Square 2 and 4, the assigned numbers are not odd.\n\nFor Square 3, the written integer is not odd.\n\nSample Input 2\n\n15\n13 76 46 15 50 98 93 77 31 43 84 90 6 24 14\n\nSample Output 2\n\n3", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 140, "cpu_time_ms": 8, "memory_kb": 2796}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s498428135", "group_id": "codeNet:p02608", "input_text": "n = io.read(\"*n\")\nfor k = 1, n do\n cnt = 0\n for x = 1, math.floor(math.sqrt(k)) do\n for y = 1, x do\n for z = 1, y do\n if (x * x + y * y + z * z + x * y + x * z + y * z) == k then\n if x == y and y == z then\n cnt = cnt + 1\n elseif (x == y and y ~= z) or (x == z and x ~=y) or(y == z and y ~= x) then\n cnt = cnt + 3\n elseif (x ~= y and x ~= z and y ~= z) then\n cnt = cnt + 6\n end\n end\n end\n end\n end\n print(cnt)\nend\n", "language": "Lua", "metadata": {"date": 1595620496, "filename_ext": "lua", "original_language": "Lua (Lua 5.3.5)", "problem_description_relpath": "problem_descriptions/p02608.html", "problem_id": "p02608", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02608/input.txt", "sample_output_relpath": "derived/input_output/data/p02608/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02608/Lua/s498428135.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s498428135", "user_id": "u803033472"}, "prompt_components": {"gold_output": "0\n0\n0\n0\n0\n1\n0\n0\n0\n0\n3\n0\n0\n0\n0\n0\n3\n3\n0\n0\n", "input_to_evaluate": "n = io.read(\"*n\")\nfor k = 1, n do\n cnt = 0\n for x = 1, math.floor(math.sqrt(k)) do\n for y = 1, x do\n for z = 1, y do\n if (x * x + y * y + z * z + x * y + x * z + y * z) == k then\n if x == y and y == z then\n cnt = cnt + 1\n elseif (x == y and y ~= z) or (x == z and x ~=y) or(y == z and y ~= x) then\n cnt = cnt + 3\n elseif (x ~= y and x ~= z and y ~= z) then\n cnt = cnt + 6\n end\n end\n end\n end\n end\n print(cnt)\nend\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nLet f(n) be the number of triples of integers (x,y,z) that satisfy both of the following conditions:\n\n1 \\leq x,y,z\n\nx^2 + y^2 + z^2 + xy + yz + zx = n\n\nGiven an integer N, find each of f(1),f(2),f(3),\\ldots,f(N).\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^4\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint N lines. The i-th line should contain the value f(i).\n\nSample Input 1\n\n20\n\nSample Output 1\n\n0\n0\n0\n0\n0\n1\n0\n0\n0\n0\n3\n0\n0\n0\n0\n0\n3\n3\n0\n0\n\nFor n=6, only (1,1,1) satisfies both of the conditions. Thus, f(6) = 1.\n\nFor n=11, three triples, (1,1,2), (1,2,1), and (2,1,1), satisfy both of the conditions. Thus, f(6) = 3.\n\nFor n=17, three triples, (1,2,2), (2,1,2), and (2,2,1), satisfy both of the conditions. Thus, f(17) = 3.\n\nFor n=18, three triples, (1,1,3), (1,3,1), and (3,1,1), satisfy both of the conditions. Thus, f(18) = 3.", "sample_input": "20\n"}, "reference_outputs": ["0\n0\n0\n0\n0\n1\n0\n0\n0\n0\n3\n0\n0\n0\n0\n0\n3\n3\n0\n0\n"], "source_document_id": "p02608", "source_text": "Score : 300 points\n\nProblem Statement\n\nLet f(n) be the number of triples of integers (x,y,z) that satisfy both of the following conditions:\n\n1 \\leq x,y,z\n\nx^2 + y^2 + z^2 + xy + yz + zx = n\n\nGiven an integer N, find each of f(1),f(2),f(3),\\ldots,f(N).\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^4\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint N lines. The i-th line should contain the value f(i).\n\nSample Input 1\n\n20\n\nSample Output 1\n\n0\n0\n0\n0\n0\n1\n0\n0\n0\n0\n3\n0\n0\n0\n0\n0\n3\n3\n0\n0\n\nFor n=6, only (1,1,1) satisfies both of the conditions. Thus, f(6) = 1.\n\nFor n=11, three triples, (1,1,2), (1,2,1), and (2,1,1), satisfy both of the conditions. Thus, f(6) = 3.\n\nFor n=17, three triples, (1,2,2), (2,1,2), and (2,2,1), satisfy both of the conditions. Thus, f(17) = 3.\n\nFor n=18, three triples, (1,1,3), (1,3,1), and (3,1,1), satisfy both of the conditions. Thus, f(18) = 3.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 516, "cpu_time_ms": 2205, "memory_kb": 2648}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s521403571", "group_id": "codeNet:p02608", "input_text": "-- 答え参照\nlocal function xyz(x, y, z)\n\treturn x*x + y*y + z*z + x*y + y*z + z*x\nend\n\nlocal N = io.read(\"*n\")\n\nlocal loop_num = math.ceil(math.sqrt(N)^3)\n\nlocal out_s = {}\nfor i = 1, N do\n\tout_s[i] = 0\nend\n\nfor x = 1, loop_num do\n\tfor y = 1, loop_num do\n\t\tfor z = 1, loop_num do\n\t\t\tlocal result = xyz(x, y, z)\n\t\t\tif result <= N then\n\t\t\t\tout_s[result] = out_s[result] + 1\n\t\t\tend\n\t\tend\n\tend\nend\n\nprint(table.concat(out_s, \"\\n\"))\n", "language": "Lua", "metadata": {"date": 1594665261, "filename_ext": "lua", "original_language": "Lua (LuaJIT 2.1.0)", "problem_description_relpath": "problem_descriptions/p02608.html", "problem_id": "p02608", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02608/input.txt", "sample_output_relpath": "derived/input_output/data/p02608/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02608/Lua/s521403571.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s521403571", "user_id": "u793881115"}, "prompt_components": {"gold_output": "0\n0\n0\n0\n0\n1\n0\n0\n0\n0\n3\n0\n0\n0\n0\n0\n3\n3\n0\n0\n", "input_to_evaluate": "-- 答え参照\nlocal function xyz(x, y, z)\n\treturn x*x + y*y + z*z + x*y + y*z + z*x\nend\n\nlocal N = io.read(\"*n\")\n\nlocal loop_num = math.ceil(math.sqrt(N)^3)\n\nlocal out_s = {}\nfor i = 1, N do\n\tout_s[i] = 0\nend\n\nfor x = 1, loop_num do\n\tfor y = 1, loop_num do\n\t\tfor z = 1, loop_num do\n\t\t\tlocal result = xyz(x, y, z)\n\t\t\tif result <= N then\n\t\t\t\tout_s[result] = out_s[result] + 1\n\t\t\tend\n\t\tend\n\tend\nend\n\nprint(table.concat(out_s, \"\\n\"))\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nLet f(n) be the number of triples of integers (x,y,z) that satisfy both of the following conditions:\n\n1 \\leq x,y,z\n\nx^2 + y^2 + z^2 + xy + yz + zx = n\n\nGiven an integer N, find each of f(1),f(2),f(3),\\ldots,f(N).\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^4\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint N lines. The i-th line should contain the value f(i).\n\nSample Input 1\n\n20\n\nSample Output 1\n\n0\n0\n0\n0\n0\n1\n0\n0\n0\n0\n3\n0\n0\n0\n0\n0\n3\n3\n0\n0\n\nFor n=6, only (1,1,1) satisfies both of the conditions. Thus, f(6) = 1.\n\nFor n=11, three triples, (1,1,2), (1,2,1), and (2,1,1), satisfy both of the conditions. Thus, f(6) = 3.\n\nFor n=17, three triples, (1,2,2), (2,1,2), and (2,2,1), satisfy both of the conditions. Thus, f(17) = 3.\n\nFor n=18, three triples, (1,1,3), (1,3,1), and (3,1,1), satisfy both of the conditions. Thus, f(18) = 3.", "sample_input": "20\n"}, "reference_outputs": ["0\n0\n0\n0\n0\n1\n0\n0\n0\n0\n3\n0\n0\n0\n0\n0\n3\n3\n0\n0\n"], "source_document_id": "p02608", "source_text": "Score : 300 points\n\nProblem Statement\n\nLet f(n) be the number of triples of integers (x,y,z) that satisfy both of the following conditions:\n\n1 \\leq x,y,z\n\nx^2 + y^2 + z^2 + xy + yz + zx = n\n\nGiven an integer N, find each of f(1),f(2),f(3),\\ldots,f(N).\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^4\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint N lines. The i-th line should contain the value f(i).\n\nSample Input 1\n\n20\n\nSample Output 1\n\n0\n0\n0\n0\n0\n1\n0\n0\n0\n0\n3\n0\n0\n0\n0\n0\n3\n3\n0\n0\n\nFor n=6, only (1,1,1) satisfies both of the conditions. Thus, f(6) = 1.\n\nFor n=11, three triples, (1,1,2), (1,2,1), and (2,1,1), satisfy both of the conditions. Thus, f(6) = 3.\n\nFor n=17, three triples, (1,2,2), (2,1,2), and (2,2,1), satisfy both of the conditions. Thus, f(17) = 3.\n\nFor n=18, three triples, (1,1,3), (1,3,1), and (3,1,1), satisfy both of the conditions. Thus, f(18) = 3.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 432, "cpu_time_ms": 2205, "memory_kb": 3132}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s296409406", "group_id": "codeNet:p02608", "input_text": "local read = setmetatable({}, {__index = function(t, k) local a = {} for i=1,#k do table.insert(a, '*'..string.sub(k, i, i)) end local r = io.read local u = table.unpack or unpack return function() return r(u(a)) end end})\n-----------------------\nlocal N = read.n()\nlocal L = 100\nfor i=1,N do\n local cnt = 0\n for x=1,L do\n local a = x*x\n if a > i then\n break\n end\n for y=1,L do\n local b = a + y*y+x*y\n if b > i then\n break\n end\n for z=1,L do\n local c = b + z*z + y*z + z*x\n if c > i then\n break\n end\n if c == i then\n cnt = cnt + 1\n end\n end\n end\n end\n print(cnt)\nend", "language": "Lua", "metadata": {"date": 1594525745, "filename_ext": "lua", "original_language": "Lua (LuaJIT 2.1.0)", "problem_description_relpath": "problem_descriptions/p02608.html", "problem_id": "p02608", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02608/input.txt", "sample_output_relpath": "derived/input_output/data/p02608/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02608/Lua/s296409406.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s296409406", "user_id": "u162773977"}, "prompt_components": {"gold_output": "0\n0\n0\n0\n0\n1\n0\n0\n0\n0\n3\n0\n0\n0\n0\n0\n3\n3\n0\n0\n", "input_to_evaluate": "local read = setmetatable({}, {__index = function(t, k) local a = {} for i=1,#k do table.insert(a, '*'..string.sub(k, i, i)) end local r = io.read local u = table.unpack or unpack return function() return r(u(a)) end end})\n-----------------------\nlocal N = read.n()\nlocal L = 100\nfor i=1,N do\n local cnt = 0\n for x=1,L do\n local a = x*x\n if a > i then\n break\n end\n for y=1,L do\n local b = a + y*y+x*y\n if b > i then\n break\n end\n for z=1,L do\n local c = b + z*z + y*z + z*x\n if c > i then\n break\n end\n if c == i then\n cnt = cnt + 1\n end\n end\n end\n end\n print(cnt)\nend", "problem_context": "Score : 300 points\n\nProblem Statement\n\nLet f(n) be the number of triples of integers (x,y,z) that satisfy both of the following conditions:\n\n1 \\leq x,y,z\n\nx^2 + y^2 + z^2 + xy + yz + zx = n\n\nGiven an integer N, find each of f(1),f(2),f(3),\\ldots,f(N).\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^4\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint N lines. The i-th line should contain the value f(i).\n\nSample Input 1\n\n20\n\nSample Output 1\n\n0\n0\n0\n0\n0\n1\n0\n0\n0\n0\n3\n0\n0\n0\n0\n0\n3\n3\n0\n0\n\nFor n=6, only (1,1,1) satisfies both of the conditions. Thus, f(6) = 1.\n\nFor n=11, three triples, (1,1,2), (1,2,1), and (2,1,1), satisfy both of the conditions. Thus, f(6) = 3.\n\nFor n=17, three triples, (1,2,2), (2,1,2), and (2,2,1), satisfy both of the conditions. Thus, f(17) = 3.\n\nFor n=18, three triples, (1,1,3), (1,3,1), and (3,1,1), satisfy both of the conditions. Thus, f(18) = 3.", "sample_input": "20\n"}, "reference_outputs": ["0\n0\n0\n0\n0\n1\n0\n0\n0\n0\n3\n0\n0\n0\n0\n0\n3\n3\n0\n0\n"], "source_document_id": "p02608", "source_text": "Score : 300 points\n\nProblem Statement\n\nLet f(n) be the number of triples of integers (x,y,z) that satisfy both of the following conditions:\n\n1 \\leq x,y,z\n\nx^2 + y^2 + z^2 + xy + yz + zx = n\n\nGiven an integer N, find each of f(1),f(2),f(3),\\ldots,f(N).\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^4\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint N lines. The i-th line should contain the value f(i).\n\nSample Input 1\n\n20\n\nSample Output 1\n\n0\n0\n0\n0\n0\n1\n0\n0\n0\n0\n3\n0\n0\n0\n0\n0\n3\n3\n0\n0\n\nFor n=6, only (1,1,1) satisfies both of the conditions. Thus, f(6) = 1.\n\nFor n=11, three triples, (1,1,2), (1,2,1), and (2,1,1), satisfy both of the conditions. Thus, f(6) = 3.\n\nFor n=17, three triples, (1,2,2), (2,1,2), and (2,2,1), satisfy both of the conditions. Thus, f(17) = 3.\n\nFor n=18, three triples, (1,1,3), (1,3,1), and (3,1,1), satisfy both of the conditions. Thus, f(18) = 3.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 807, "cpu_time_ms": 2205, "memory_kb": 2580}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s168266059", "group_id": "codeNet:p02609", "input_text": "local mfl, mce = math.floor, math.ceil\nlocal n = io.read(\"*n\", \"*l\")\nlocal t = {}\nlocal s = io.read()\nlocal cnt1 = 0\nfor i = 1, n do\n t[i] = s:byte(i) == 49\n if t[i] then cnt1 = cnt1 + 1 end\nend\n\nlocal function firstdevide(p, dv)\n local currem = 0\n for i = 1, n do\n currem = currem * 2\n if i == p then\n if not t[i] then\n currem = currem + 1\n end\n else\n if t[i] then\n currem = currem + 1\n end\n end\n currem = currem % dv\n end\n return currem\nend\n\nlocal function getpopcnt(x)\n local c = 0\n while 0 < x do\n if x % 2 == 1 then c = c + 1 end\n x = mfl(x / 2)\n end\n return c\nend\n\nfor iq = 1, n do\n local dv = t[iq] and cnt1 - 1 or cnt1 + 1\n if dv == 0 then\n print(0)\n else\n local rem = firstdevide(iq, dv)\n local cnt = 1\n while 0 < rem do\n dv = getpopcnt(rem)\n rem = rem % dv\n cnt = cnt + 1\n end\n print(cnt)\n end\nend\n", "language": "Lua", "metadata": {"date": 1594516842, "filename_ext": "lua", "original_language": "Lua (LuaJIT 2.1.0)", "problem_description_relpath": "problem_descriptions/p02609.html", "problem_id": "p02609", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02609/input.txt", "sample_output_relpath": "derived/input_output/data/p02609/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02609/Lua/s168266059.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s168266059", "user_id": "u120582723"}, "prompt_components": {"gold_output": "2\n1\n1\n", "input_to_evaluate": "local mfl, mce = math.floor, math.ceil\nlocal n = io.read(\"*n\", \"*l\")\nlocal t = {}\nlocal s = io.read()\nlocal cnt1 = 0\nfor i = 1, n do\n t[i] = s:byte(i) == 49\n if t[i] then cnt1 = cnt1 + 1 end\nend\n\nlocal function firstdevide(p, dv)\n local currem = 0\n for i = 1, n do\n currem = currem * 2\n if i == p then\n if not t[i] then\n currem = currem + 1\n end\n else\n if t[i] then\n currem = currem + 1\n end\n end\n currem = currem % dv\n end\n return currem\nend\n\nlocal function getpopcnt(x)\n local c = 0\n while 0 < x do\n if x % 2 == 1 then c = c + 1 end\n x = mfl(x / 2)\n end\n return c\nend\n\nfor iq = 1, n do\n local dv = t[iq] and cnt1 - 1 or cnt1 + 1\n if dv == 0 then\n print(0)\n else\n local rem = firstdevide(iq, dv)\n local cnt = 1\n while 0 < rem do\n dv = getpopcnt(rem)\n rem = rem % dv\n cnt = cnt + 1\n end\n print(cnt)\n end\nend\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nLet \\mathrm{popcount}(n) be the number of 1s in the binary representation of n.\nFor example, \\mathrm{popcount}(3) = 2, \\mathrm{popcount}(7) = 3, and \\mathrm{popcount}(0) = 0.\n\nLet f(n) be the number of times the following operation will be done when we repeat it until n becomes 0: \"replace n with the remainder when n is divided by \\mathrm{popcount}(n).\" (It can be proved that, under the constraints of this problem, n always becomes 0 after a finite number of operations.)\n\nFor example, when n=7, it becomes 0 after two operations, as follows:\n\n\\mathrm{popcount}(7)=3, so we divide 7 by 3 and replace it with the remainder, 1.\n\n\\mathrm{popcount}(1)=1, so we divide 1 by 1 and replace it with the remainder, 0.\n\nYou are given an integer X with N digits in binary.\nFor each integer i such that 1 \\leq i \\leq N, let X_i be what X becomes when the i-th bit from the top is inverted.\nFind f(X_1), f(X_2), \\ldots, f(X_N).\n\nConstraints\n\n1 \\leq N \\leq 2 \\times 10^5\n\nX is an integer with N digits in binary, possibly with leading zeros.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nX\n\nOutput\n\nPrint N lines. The i-th line should contain the value f(X_i).\n\nSample Input 1\n\n3\n011\n\nSample Output 1\n\n2\n1\n1\n\nX_1 = 7, which will change as follows: 7 \\rightarrow 1 \\rightarrow 0. Thus, f(7) = 2.\n\nX_2 = 1, which will change as follows: 1 \\rightarrow 0. Thus, f(1) = 1.\n\nX_3 = 2, which will change as follows: 2 \\rightarrow 0. Thus, f(2) = 1.\n\nSample Input 2\n\n23\n00110111001011011001110\n\nSample Output 2\n\n2\n1\n2\n2\n1\n2\n2\n2\n2\n2\n2\n2\n2\n2\n2\n2\n2\n2\n2\n2\n2\n1\n3", "sample_input": "3\n011\n"}, "reference_outputs": ["2\n1\n1\n"], "source_document_id": "p02609", "source_text": "Score : 400 points\n\nProblem Statement\n\nLet \\mathrm{popcount}(n) be the number of 1s in the binary representation of n.\nFor example, \\mathrm{popcount}(3) = 2, \\mathrm{popcount}(7) = 3, and \\mathrm{popcount}(0) = 0.\n\nLet f(n) be the number of times the following operation will be done when we repeat it until n becomes 0: \"replace n with the remainder when n is divided by \\mathrm{popcount}(n).\" (It can be proved that, under the constraints of this problem, n always becomes 0 after a finite number of operations.)\n\nFor example, when n=7, it becomes 0 after two operations, as follows:\n\n\\mathrm{popcount}(7)=3, so we divide 7 by 3 and replace it with the remainder, 1.\n\n\\mathrm{popcount}(1)=1, so we divide 1 by 1 and replace it with the remainder, 0.\n\nYou are given an integer X with N digits in binary.\nFor each integer i such that 1 \\leq i \\leq N, let X_i be what X becomes when the i-th bit from the top is inverted.\nFind f(X_1), f(X_2), \\ldots, f(X_N).\n\nConstraints\n\n1 \\leq N \\leq 2 \\times 10^5\n\nX is an integer with N digits in binary, possibly with leading zeros.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nX\n\nOutput\n\nPrint N lines. The i-th line should contain the value f(X_i).\n\nSample Input 1\n\n3\n011\n\nSample Output 1\n\n2\n1\n1\n\nX_1 = 7, which will change as follows: 7 \\rightarrow 1 \\rightarrow 0. Thus, f(7) = 2.\n\nX_2 = 1, which will change as follows: 1 \\rightarrow 0. Thus, f(1) = 1.\n\nX_3 = 2, which will change as follows: 2 \\rightarrow 0. Thus, f(2) = 1.\n\nSample Input 2\n\n23\n00110111001011011001110\n\nSample Output 2\n\n2\n1\n2\n2\n1\n2\n2\n2\n2\n2\n2\n2\n2\n2\n2\n2\n2\n2\n2\n2\n2\n1\n3", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 910, "cpu_time_ms": 2205, "memory_kb": 5136}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s985711036", "group_id": "codeNet:p02613", "input_text": "local length = io.read()\nlocal data = {AC = 0, WA = 0, TLE =0, RE = 0}\n\nfor i = 1, length do \n local key = io.read()\n if data[key] then\n data[key] = data[key] + 1\n end\nend\n\nprint(\"AC x\"..\" \"..data[\"AC\"])\nprint(\"WA x\"..\" \"..data[\"WA\"])\nprint(\"TLE x\"..\" \"..data[\"TLE\"])\nprint(\"RE x\"..\" \"..data[\"RE\"])\n", "language": "Lua", "metadata": {"date": 1594428331, "filename_ext": "lua", "original_language": "Lua (Lua 5.3.5)", "problem_description_relpath": "problem_descriptions/p02613.html", "problem_id": "p02613", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02613/input.txt", "sample_output_relpath": "derived/input_output/data/p02613/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02613/Lua/s985711036.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s985711036", "user_id": "u353919145"}, "prompt_components": {"gold_output": "AC x 3\nWA x 1\nTLE x 2\nRE x 0\n", "input_to_evaluate": "local length = io.read()\nlocal data = {AC = 0, WA = 0, TLE =0, RE = 0}\n\nfor i = 1, length do \n local key = io.read()\n if data[key] then\n data[key] = data[key] + 1\n end\nend\n\nprint(\"AC x\"..\" \"..data[\"AC\"])\nprint(\"WA x\"..\" \"..data[\"WA\"])\nprint(\"TLE x\"..\" \"..data[\"TLE\"])\nprint(\"RE x\"..\" \"..data[\"RE\"])\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nTakahashi is participating in a programming contest called AXC002, and he has just submitted his code to Problem A.\n\nThe problem has N test cases.\n\nFor each test case i (1\\leq i \\leq N), you are given a string S_i representing the verdict for that test case. Find the numbers of test cases for which the verdict is AC, WA, TLE, and RE, respectively.\n\nSee the Output section for the output format.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\nS_i is AC, WA, TLE, or RE.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS_1\n\\vdots\nS_N\n\nOutput\n\nLet C_0, C_1, C_2, and C_3 be the numbers of test cases for which the verdict is AC, WA, TLE, and RE, respectively. Print the following:\n\nAC x C_0\nWA x C_1\nTLE x C_2\nRE x C_3\n\nSample Input 1\n\n6\nAC\nTLE\nAC\nAC\nWA\nTLE\n\nSample Output 1\n\nAC x 3\nWA x 1\nTLE x 2\nRE x 0\n\nWe have 3, 1, 2, and 0 test case(s) for which the verdict is AC, WA, TLE, and RE, respectively.\n\nSample Input 2\n\n10\nAC\nAC\nAC\nAC\nAC\nAC\nAC\nAC\nAC\nAC\n\nSample Output 2\n\nAC x 10\nWA x 0\nTLE x 0\nRE x 0", "sample_input": "6\nAC\nTLE\nAC\nAC\nWA\nTLE\n"}, "reference_outputs": ["AC x 3\nWA x 1\nTLE x 2\nRE x 0\n"], "source_document_id": "p02613", "source_text": "Score : 200 points\n\nProblem Statement\n\nTakahashi is participating in a programming contest called AXC002, and he has just submitted his code to Problem A.\n\nThe problem has N test cases.\n\nFor each test case i (1\\leq i \\leq N), you are given a string S_i representing the verdict for that test case. Find the numbers of test cases for which the verdict is AC, WA, TLE, and RE, respectively.\n\nSee the Output section for the output format.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\nS_i is AC, WA, TLE, or RE.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS_1\n\\vdots\nS_N\n\nOutput\n\nLet C_0, C_1, C_2, and C_3 be the numbers of test cases for which the verdict is AC, WA, TLE, and RE, respectively. Print the following:\n\nAC x C_0\nWA x C_1\nTLE x C_2\nRE x C_3\n\nSample Input 1\n\n6\nAC\nTLE\nAC\nAC\nWA\nTLE\n\nSample Output 1\n\nAC x 3\nWA x 1\nTLE x 2\nRE x 0\n\nWe have 3, 1, 2, and 0 test case(s) for which the verdict is AC, WA, TLE, and RE, respectively.\n\nSample Input 2\n\n10\nAC\nAC\nAC\nAC\nAC\nAC\nAC\nAC\nAC\nAC\n\nSample Output 2\n\nAC x 10\nWA x 0\nTLE x 0\nRE x 0", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 315, "cpu_time_ms": 31, "memory_kb": 2720}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s620243796", "group_id": "codeNet:p02613", "input_text": "local n=io.read(\"n\",\"l\")\nlocal s={}\nfor i=1,n do\n local input=io.read()\n s[input]=(s[input] or 0)+1\nend\n\nprint(\"AC x \"..(s[\"AC\"] or 0))\nprint(\"WA x \"..(s[\"WA\"] or 0))\nprint(\"TLE x \"..(s[\"TLE\"] or 0))\nprint(\"RE x \"..(s[\"RE\"] or 0))", "language": "Lua", "metadata": {"date": 1594006799, "filename_ext": "lua", "original_language": "Lua (Lua 5.3.5)", "problem_description_relpath": "problem_descriptions/p02613.html", "problem_id": "p02613", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02613/input.txt", "sample_output_relpath": "derived/input_output/data/p02613/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02613/Lua/s620243796.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s620243796", "user_id": "u045238009"}, "prompt_components": {"gold_output": "AC x 3\nWA x 1\nTLE x 2\nRE x 0\n", "input_to_evaluate": "local n=io.read(\"n\",\"l\")\nlocal s={}\nfor i=1,n do\n local input=io.read()\n s[input]=(s[input] or 0)+1\nend\n\nprint(\"AC x \"..(s[\"AC\"] or 0))\nprint(\"WA x \"..(s[\"WA\"] or 0))\nprint(\"TLE x \"..(s[\"TLE\"] or 0))\nprint(\"RE x \"..(s[\"RE\"] or 0))", "problem_context": "Score : 200 points\n\nProblem Statement\n\nTakahashi is participating in a programming contest called AXC002, and he has just submitted his code to Problem A.\n\nThe problem has N test cases.\n\nFor each test case i (1\\leq i \\leq N), you are given a string S_i representing the verdict for that test case. Find the numbers of test cases for which the verdict is AC, WA, TLE, and RE, respectively.\n\nSee the Output section for the output format.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\nS_i is AC, WA, TLE, or RE.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS_1\n\\vdots\nS_N\n\nOutput\n\nLet C_0, C_1, C_2, and C_3 be the numbers of test cases for which the verdict is AC, WA, TLE, and RE, respectively. Print the following:\n\nAC x C_0\nWA x C_1\nTLE x C_2\nRE x C_3\n\nSample Input 1\n\n6\nAC\nTLE\nAC\nAC\nWA\nTLE\n\nSample Output 1\n\nAC x 3\nWA x 1\nTLE x 2\nRE x 0\n\nWe have 3, 1, 2, and 0 test case(s) for which the verdict is AC, WA, TLE, and RE, respectively.\n\nSample Input 2\n\n10\nAC\nAC\nAC\nAC\nAC\nAC\nAC\nAC\nAC\nAC\n\nSample Output 2\n\nAC x 10\nWA x 0\nTLE x 0\nRE x 0", "sample_input": "6\nAC\nTLE\nAC\nAC\nWA\nTLE\n"}, "reference_outputs": ["AC x 3\nWA x 1\nTLE x 2\nRE x 0\n"], "source_document_id": "p02613", "source_text": "Score : 200 points\n\nProblem Statement\n\nTakahashi is participating in a programming contest called AXC002, and he has just submitted his code to Problem A.\n\nThe problem has N test cases.\n\nFor each test case i (1\\leq i \\leq N), you are given a string S_i representing the verdict for that test case. Find the numbers of test cases for which the verdict is AC, WA, TLE, and RE, respectively.\n\nSee the Output section for the output format.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\nS_i is AC, WA, TLE, or RE.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS_1\n\\vdots\nS_N\n\nOutput\n\nLet C_0, C_1, C_2, and C_3 be the numbers of test cases for which the verdict is AC, WA, TLE, and RE, respectively. Print the following:\n\nAC x C_0\nWA x C_1\nTLE x C_2\nRE x C_3\n\nSample Input 1\n\n6\nAC\nTLE\nAC\nAC\nWA\nTLE\n\nSample Output 1\n\nAC x 3\nWA x 1\nTLE x 2\nRE x 0\n\nWe have 3, 1, 2, and 0 test case(s) for which the verdict is AC, WA, TLE, and RE, respectively.\n\nSample Input 2\n\n10\nAC\nAC\nAC\nAC\nAC\nAC\nAC\nAC\nAC\nAC\n\nSample Output 2\n\nAC x 10\nWA x 0\nTLE x 0\nRE x 0", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 236, "cpu_time_ms": 35, "memory_kb": 2792}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s095961720", "group_id": "codeNet:p02614", "input_text": "local a = io.read()\nlocal b = io.read()\nlocal c = io.read()\n\nlocal num = 0\nfor i=1,tonumber(a)*tonumber(b) do\n\ts = io.read()\n\tif s == \"#\" then\n\t\tnum = num + 1\n\tend\nend\nif num <= tonumber(c) then\n\tprint(0)\nend\nlocal n = 0\nfor i= c,num-1 do\n\tn = n+ i\nend\nprint(n)", "language": "Lua", "metadata": {"date": 1594430649, "filename_ext": "lua", "original_language": "Lua (Lua 5.3.5)", "problem_description_relpath": "problem_descriptions/p02614.html", "problem_id": "p02614", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02614/input.txt", "sample_output_relpath": "derived/input_output/data/p02614/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02614/Lua/s095961720.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s095961720", "user_id": "u863370423"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "local a = io.read()\nlocal b = io.read()\nlocal c = io.read()\n\nlocal num = 0\nfor i=1,tonumber(a)*tonumber(b) do\n\ts = io.read()\n\tif s == \"#\" then\n\t\tnum = num + 1\n\tend\nend\nif num <= tonumber(c) then\n\tprint(0)\nend\nlocal n = 0\nfor i= c,num-1 do\n\tn = n+ i\nend\nprint(n)", "problem_context": "Score : 300 points\n\nProblem Statement\n\nWe have a grid of H rows and W columns of squares. The color of the square at the i-th row from the top and the j-th column from the left (1 \\leq i \\leq H, 1 \\leq j \\leq W) is given to you as a character c_{i,j}: the square is white if c_{i,j} is ., and black if c_{i,j} is #.\n\nConsider doing the following operation:\n\nChoose some number of rows (possibly zero), and some number of columns (possibly zero). Then, paint red all squares in the chosen rows and all squares in the chosen columns.\n\nYou are given a positive integer K. How many choices of rows and columns result in exactly K black squares remaining after the operation? Here, we consider two choices different when there is a row or column chosen in only one of those choices.\n\nConstraints\n\n1 \\leq H, W \\leq 6\n\n1 \\leq K \\leq HW\n\nc_{i,j} is . or #.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W K\nc_{1,1}c_{1,2}...c_{1,W}\nc_{2,1}c_{2,2}...c_{2,W}\n:\nc_{H,1}c_{H,2}...c_{H,W}\n\nOutput\n\nPrint an integer representing the number of choices of rows and columns satisfying the condition.\n\nSample Input 1\n\n2 3 2\n..#\n###\n\nSample Output 1\n\n5\n\nFive choices below satisfy the condition.\n\nThe 1-st row and 1-st column\n\nThe 1-st row and 2-nd column\n\nThe 1-st row and 3-rd column\n\nThe 1-st and 2-nd column\n\nThe 3-rd column\n\nSample Input 2\n\n2 3 4\n..#\n###\n\nSample Output 2\n\n1\n\nOne choice, which is choosing nothing, satisfies the condition.\n\nSample Input 3\n\n2 2 3\n##\n##\n\nSample Output 3\n\n0\n\nSample Input 4\n\n6 6 8\n..##..\n.#..#.\n#....#\n######\n#....#\n#....#\n\nSample Output 4\n\n208", "sample_input": "2 3 2\n..#\n###\n"}, "reference_outputs": ["5\n"], "source_document_id": "p02614", "source_text": "Score : 300 points\n\nProblem Statement\n\nWe have a grid of H rows and W columns of squares. The color of the square at the i-th row from the top and the j-th column from the left (1 \\leq i \\leq H, 1 \\leq j \\leq W) is given to you as a character c_{i,j}: the square is white if c_{i,j} is ., and black if c_{i,j} is #.\n\nConsider doing the following operation:\n\nChoose some number of rows (possibly zero), and some number of columns (possibly zero). Then, paint red all squares in the chosen rows and all squares in the chosen columns.\n\nYou are given a positive integer K. How many choices of rows and columns result in exactly K black squares remaining after the operation? Here, we consider two choices different when there is a row or column chosen in only one of those choices.\n\nConstraints\n\n1 \\leq H, W \\leq 6\n\n1 \\leq K \\leq HW\n\nc_{i,j} is . or #.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W K\nc_{1,1}c_{1,2}...c_{1,W}\nc_{2,1}c_{2,2}...c_{2,W}\n:\nc_{H,1}c_{H,2}...c_{H,W}\n\nOutput\n\nPrint an integer representing the number of choices of rows and columns satisfying the condition.\n\nSample Input 1\n\n2 3 2\n..#\n###\n\nSample Output 1\n\n5\n\nFive choices below satisfy the condition.\n\nThe 1-st row and 1-st column\n\nThe 1-st row and 2-nd column\n\nThe 1-st row and 3-rd column\n\nThe 1-st and 2-nd column\n\nThe 3-rd column\n\nSample Input 2\n\n2 3 4\n..#\n###\n\nSample Output 2\n\n1\n\nOne choice, which is choosing nothing, satisfies the condition.\n\nSample Input 3\n\n2 2 3\n##\n##\n\nSample Output 3\n\n0\n\nSample Input 4\n\n6 6 8\n..##..\n.#..#.\n#....#\n######\n#....#\n#....#\n\nSample Output 4\n\n208", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 261, "cpu_time_ms": 7, "memory_kb": 2776}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s121681708", "group_id": "codeNet:p02614", "input_text": "function rl()\n local r = {}\n for word in io.read():gmatch(\"%S+\") do\n table.insert(r, tonumber(word))\n end\n return r\nend\n\nfunction ru()\n return unpack(rl())\nend\n\nfunction pu(x, ...)\n if x then\n io.write(x, ' ')\n return pu(...)\n else\n io.write('\\n')\n end\nend\n\nH, W, K = ru()\nc = {}\nfor i = 1, H do\n c[i] = {}\n for j = 1, W do\n c[i][j] = io.read(1)\n end\n io.read()\nend\n\nfunction line(i)\n if i > H then\n return col(1)\n else\n local save = {}\n for j = 1, W do\n\t save[j] = c[i][j]\n\t c[i][j] = 'x'\n end\n local r = line(i + 1)\n for j = 1, W do\n\t c[i][j] = save[j]\n end\n return r + line(i + 1)\n end\nend\n\nfunction col(j)\n if j > W then\n local count = 0\n for i = 1, H do\n\t for j = 1, W do\n\t if c[i][j] == '#' then\n\t count = count + 1\n\t end\n\t end\n end\n return count == K and 1 or 0\n else\n local save = {}\n for i = 1, H do\n\t save[i] = c[i][j]\n\t c[i][j] = 'x'\n end\n local r = col(j + 1)\n for i = 1, H do\n\t c[i][j] = save[i]\n end\n return r + col(j + 1)\n end\nend\n\npu(line(1))\n", "language": "Lua", "metadata": {"date": 1593998755, "filename_ext": "lua", "original_language": "Lua (LuaJIT 2.1.0)", "problem_description_relpath": "problem_descriptions/p02614.html", "problem_id": "p02614", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02614/input.txt", "sample_output_relpath": "derived/input_output/data/p02614/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02614/Lua/s121681708.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s121681708", "user_id": "u677997743"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "function rl()\n local r = {}\n for word in io.read():gmatch(\"%S+\") do\n table.insert(r, tonumber(word))\n end\n return r\nend\n\nfunction ru()\n return unpack(rl())\nend\n\nfunction pu(x, ...)\n if x then\n io.write(x, ' ')\n return pu(...)\n else\n io.write('\\n')\n end\nend\n\nH, W, K = ru()\nc = {}\nfor i = 1, H do\n c[i] = {}\n for j = 1, W do\n c[i][j] = io.read(1)\n end\n io.read()\nend\n\nfunction line(i)\n if i > H then\n return col(1)\n else\n local save = {}\n for j = 1, W do\n\t save[j] = c[i][j]\n\t c[i][j] = 'x'\n end\n local r = line(i + 1)\n for j = 1, W do\n\t c[i][j] = save[j]\n end\n return r + line(i + 1)\n end\nend\n\nfunction col(j)\n if j > W then\n local count = 0\n for i = 1, H do\n\t for j = 1, W do\n\t if c[i][j] == '#' then\n\t count = count + 1\n\t end\n\t end\n end\n return count == K and 1 or 0\n else\n local save = {}\n for i = 1, H do\n\t save[i] = c[i][j]\n\t c[i][j] = 'x'\n end\n local r = col(j + 1)\n for i = 1, H do\n\t c[i][j] = save[i]\n end\n return r + col(j + 1)\n end\nend\n\npu(line(1))\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nWe have a grid of H rows and W columns of squares. The color of the square at the i-th row from the top and the j-th column from the left (1 \\leq i \\leq H, 1 \\leq j \\leq W) is given to you as a character c_{i,j}: the square is white if c_{i,j} is ., and black if c_{i,j} is #.\n\nConsider doing the following operation:\n\nChoose some number of rows (possibly zero), and some number of columns (possibly zero). Then, paint red all squares in the chosen rows and all squares in the chosen columns.\n\nYou are given a positive integer K. How many choices of rows and columns result in exactly K black squares remaining after the operation? Here, we consider two choices different when there is a row or column chosen in only one of those choices.\n\nConstraints\n\n1 \\leq H, W \\leq 6\n\n1 \\leq K \\leq HW\n\nc_{i,j} is . or #.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W K\nc_{1,1}c_{1,2}...c_{1,W}\nc_{2,1}c_{2,2}...c_{2,W}\n:\nc_{H,1}c_{H,2}...c_{H,W}\n\nOutput\n\nPrint an integer representing the number of choices of rows and columns satisfying the condition.\n\nSample Input 1\n\n2 3 2\n..#\n###\n\nSample Output 1\n\n5\n\nFive choices below satisfy the condition.\n\nThe 1-st row and 1-st column\n\nThe 1-st row and 2-nd column\n\nThe 1-st row and 3-rd column\n\nThe 1-st and 2-nd column\n\nThe 3-rd column\n\nSample Input 2\n\n2 3 4\n..#\n###\n\nSample Output 2\n\n1\n\nOne choice, which is choosing nothing, satisfies the condition.\n\nSample Input 3\n\n2 2 3\n##\n##\n\nSample Output 3\n\n0\n\nSample Input 4\n\n6 6 8\n..##..\n.#..#.\n#....#\n######\n#....#\n#....#\n\nSample Output 4\n\n208", "sample_input": "2 3 2\n..#\n###\n"}, "reference_outputs": ["5\n"], "source_document_id": "p02614", "source_text": "Score : 300 points\n\nProblem Statement\n\nWe have a grid of H rows and W columns of squares. The color of the square at the i-th row from the top and the j-th column from the left (1 \\leq i \\leq H, 1 \\leq j \\leq W) is given to you as a character c_{i,j}: the square is white if c_{i,j} is ., and black if c_{i,j} is #.\n\nConsider doing the following operation:\n\nChoose some number of rows (possibly zero), and some number of columns (possibly zero). Then, paint red all squares in the chosen rows and all squares in the chosen columns.\n\nYou are given a positive integer K. How many choices of rows and columns result in exactly K black squares remaining after the operation? Here, we consider two choices different when there is a row or column chosen in only one of those choices.\n\nConstraints\n\n1 \\leq H, W \\leq 6\n\n1 \\leq K \\leq HW\n\nc_{i,j} is . or #.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W K\nc_{1,1}c_{1,2}...c_{1,W}\nc_{2,1}c_{2,2}...c_{2,W}\n:\nc_{H,1}c_{H,2}...c_{H,W}\n\nOutput\n\nPrint an integer representing the number of choices of rows and columns satisfying the condition.\n\nSample Input 1\n\n2 3 2\n..#\n###\n\nSample Output 1\n\n5\n\nFive choices below satisfy the condition.\n\nThe 1-st row and 1-st column\n\nThe 1-st row and 2-nd column\n\nThe 1-st row and 3-rd column\n\nThe 1-st and 2-nd column\n\nThe 3-rd column\n\nSample Input 2\n\n2 3 4\n..#\n###\n\nSample Output 2\n\n1\n\nOne choice, which is choosing nothing, satisfies the condition.\n\nSample Input 3\n\n2 2 3\n##\n##\n\nSample Output 3\n\n0\n\nSample Input 4\n\n6 6 8\n..##..\n.#..#.\n#....#\n######\n#....#\n#....#\n\nSample Output 4\n\n208", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1127, "cpu_time_ms": 15, "memory_kb": 2584}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s572526153", "group_id": "codeNet:p02615", "input_text": "local n=io.read(\"n\")\nlocal a={}\nfor i=1,n do\n a[i]=io.read(\"n\")\nend\ntable.sort(a)\nlocal total=0\nfor i=1,n-1 do\n total=total+a[n-i//2]\nend\nprint(total)", "language": "Lua", "metadata": {"date": 1594088465, "filename_ext": "lua", "original_language": "Lua (Lua 5.3.5)", "problem_description_relpath": "problem_descriptions/p02615.html", "problem_id": "p02615", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02615/input.txt", "sample_output_relpath": "derived/input_output/data/p02615/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02615/Lua/s572526153.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s572526153", "user_id": "u045238009"}, "prompt_components": {"gold_output": "7\n", "input_to_evaluate": "local n=io.read(\"n\")\nlocal a={}\nfor i=1,n do\n a[i]=io.read(\"n\")\nend\ntable.sort(a)\nlocal total=0\nfor i=1,n-1 do\n total=total+a[n-i//2]\nend\nprint(total)", "problem_context": "Score: 400 points\n\nProblem Statement\n\nQuickly after finishing the tutorial of the online game ATChat, you have decided to visit a particular place with N-1 players who happen to be there. These N players, including you, are numbered 1 through N, and the friendliness of Player i is A_i.\n\nThe N players will arrive at the place one by one in some order. To make sure nobody gets lost, you have set the following rule: players who have already arrived there should form a circle, and a player who has just arrived there should cut into the circle somewhere.\n\nWhen each player, except the first one to arrive, arrives at the place, the player gets comfort equal to the smaller of the friendliness of the clockwise adjacent player and that of the counter-clockwise adjacent player. The first player to arrive there gets the comfort of 0.\n\nWhat is the maximum total comfort the N players can get by optimally choosing the order of arrivals and the positions in the circle to cut into?\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 2 \\times 10^5\n\n1 \\leq A_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 \\dots A_N\n\nOutput\n\nPrint the maximum total comfort the N players can get.\n\nSample Input 1\n\n4\n2 2 1 3\n\nSample Output 1\n\n7\n\nBy arriving at the place in the order Player 4, 2, 1, 3, and cutting into the circle as shown in the figure, they can get the total comfort of 7.\n\nThey cannot get the total comfort greater than 7, so the answer is 7.\n\nSample Input 2\n\n7\n1 1 1 1 1 1 1\n\nSample Output 2\n\n6", "sample_input": "4\n2 2 1 3\n"}, "reference_outputs": ["7\n"], "source_document_id": "p02615", "source_text": "Score: 400 points\n\nProblem Statement\n\nQuickly after finishing the tutorial of the online game ATChat, you have decided to visit a particular place with N-1 players who happen to be there. These N players, including you, are numbered 1 through N, and the friendliness of Player i is A_i.\n\nThe N players will arrive at the place one by one in some order. To make sure nobody gets lost, you have set the following rule: players who have already arrived there should form a circle, and a player who has just arrived there should cut into the circle somewhere.\n\nWhen each player, except the first one to arrive, arrives at the place, the player gets comfort equal to the smaller of the friendliness of the clockwise adjacent player and that of the counter-clockwise adjacent player. The first player to arrive there gets the comfort of 0.\n\nWhat is the maximum total comfort the N players can get by optimally choosing the order of arrivals and the positions in the circle to cut into?\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 2 \\times 10^5\n\n1 \\leq A_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 \\dots A_N\n\nOutput\n\nPrint the maximum total comfort the N players can get.\n\nSample Input 1\n\n4\n2 2 1 3\n\nSample Output 1\n\n7\n\nBy arriving at the place in the order Player 4, 2, 1, 3, and cutting into the circle as shown in the figure, they can get the total comfort of 7.\n\nThey cannot get the total comfort greater than 7, so the answer is 7.\n\nSample Input 2\n\n7\n1 1 1 1 1 1 1\n\nSample Output 2\n\n6", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 156, "cpu_time_ms": 151, "memory_kb": 6348}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s528401603", "group_id": "codeNet:p02615", "input_text": "local n=io.read(\"n\")\nlocal a={}\nfor i=1,n do\n a[i]=io.read(\"n\")\nend\ntable.sort(a,function(a,b)\n return a>b\nend)\n\nlocal total=a[1]\nfor i=3,n do\n total=total+math.max(a[i],a[i-1])\nend\nprint(total)", "language": "Lua", "metadata": {"date": 1594009262, "filename_ext": "lua", "original_language": "Lua (Lua 5.3.5)", "problem_description_relpath": "problem_descriptions/p02615.html", "problem_id": "p02615", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02615/input.txt", "sample_output_relpath": "derived/input_output/data/p02615/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02615/Lua/s528401603.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s528401603", "user_id": "u045238009"}, "prompt_components": {"gold_output": "7\n", "input_to_evaluate": "local n=io.read(\"n\")\nlocal a={}\nfor i=1,n do\n a[i]=io.read(\"n\")\nend\ntable.sort(a,function(a,b)\n return a>b\nend)\n\nlocal total=a[1]\nfor i=3,n do\n total=total+math.max(a[i],a[i-1])\nend\nprint(total)", "problem_context": "Score: 400 points\n\nProblem Statement\n\nQuickly after finishing the tutorial of the online game ATChat, you have decided to visit a particular place with N-1 players who happen to be there. These N players, including you, are numbered 1 through N, and the friendliness of Player i is A_i.\n\nThe N players will arrive at the place one by one in some order. To make sure nobody gets lost, you have set the following rule: players who have already arrived there should form a circle, and a player who has just arrived there should cut into the circle somewhere.\n\nWhen each player, except the first one to arrive, arrives at the place, the player gets comfort equal to the smaller of the friendliness of the clockwise adjacent player and that of the counter-clockwise adjacent player. The first player to arrive there gets the comfort of 0.\n\nWhat is the maximum total comfort the N players can get by optimally choosing the order of arrivals and the positions in the circle to cut into?\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 2 \\times 10^5\n\n1 \\leq A_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 \\dots A_N\n\nOutput\n\nPrint the maximum total comfort the N players can get.\n\nSample Input 1\n\n4\n2 2 1 3\n\nSample Output 1\n\n7\n\nBy arriving at the place in the order Player 4, 2, 1, 3, and cutting into the circle as shown in the figure, they can get the total comfort of 7.\n\nThey cannot get the total comfort greater than 7, so the answer is 7.\n\nSample Input 2\n\n7\n1 1 1 1 1 1 1\n\nSample Output 2\n\n6", "sample_input": "4\n2 2 1 3\n"}, "reference_outputs": ["7\n"], "source_document_id": "p02615", "source_text": "Score: 400 points\n\nProblem Statement\n\nQuickly after finishing the tutorial of the online game ATChat, you have decided to visit a particular place with N-1 players who happen to be there. These N players, including you, are numbered 1 through N, and the friendliness of Player i is A_i.\n\nThe N players will arrive at the place one by one in some order. To make sure nobody gets lost, you have set the following rule: players who have already arrived there should form a circle, and a player who has just arrived there should cut into the circle somewhere.\n\nWhen each player, except the first one to arrive, arrives at the place, the player gets comfort equal to the smaller of the friendliness of the clockwise adjacent player and that of the counter-clockwise adjacent player. The first player to arrive there gets the comfort of 0.\n\nWhat is the maximum total comfort the N players can get by optimally choosing the order of arrivals and the positions in the circle to cut into?\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 2 \\times 10^5\n\n1 \\leq A_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 \\dots A_N\n\nOutput\n\nPrint the maximum total comfort the N players can get.\n\nSample Input 1\n\n4\n2 2 1 3\n\nSample Output 1\n\n7\n\nBy arriving at the place in the order Player 4, 2, 1, 3, and cutting into the circle as shown in the figure, they can get the total comfort of 7.\n\nThey cannot get the total comfort greater than 7, so the answer is 7.\n\nSample Input 2\n\n7\n1 1 1 1 1 1 1\n\nSample Output 2\n\n6", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 203, "cpu_time_ms": 349, "memory_kb": 6376}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s492276949", "group_id": "codeNet:p02619", "input_text": "local read = setmetatable({}, {__index = function(t, k) local a = {} for i=1,#k do table.insert(a, '*'..string.sub(k, i, i)) end local r = io.read local u = table.unpack or unpack return function() return r(u(a)) end end})\nread.N = function(N) local t={} for i=1,N do t[i]=read.n() end return t end\nstring.totable = function(s) local t={} local u=string.sub for i=1,#s do t[i] = u(s, i, i) end return t end\nstring.split = function(s) local t={} for w in string.gmatch(s, \"[^%s]+\") do table.insert(t, w) end return (table.unpack or unpack)(t) end\nlocal function array(dimension, default_val) assert(type(default_val) ~= 'table') local n=dimension local m={}if default_val~=nil then m[1]={__index=function()return default_val end}end for i=2,n do m[i]={__index=function(p, k)local c=setmetatable({},m[i-1])rawset(p,k,c)return c end}end return setmetatable({},m[n])end\nlocal function tostringxx(o, depth) depth = depth or 0 if depth > 10 then return \"\" end if o == _G then return \"<_G>\" end local indent0 = (\" \"):rep((depth) * 2) local indent1 = (\" \"):rep((depth+1) * 2) local indent2= (\" \"):rep((depth+2) * 2) if type(o) == 'table' then local keys = {} local types = {} for k in pairs(o) do types[type(k)] = true table.insert(keys, k) end local types_count = 0 local lasttype for k in pairs(types) do types_count = types_count + 1 lasttype = k end if types_count == 1 and (lasttype == 'string' or lasttype == 'number') then table.sort(keys) end local inside = {} for i=1,#keys do local k = keys[i] local v = o[k] if type(k) == 'string' then k = string.format('%q', k) end table.insert(inside, indent1 .. '['..tostring(k)..'] = ' .. tostringxx(v, depth + 1)) end return '{\\n' .. table.concat(inside, ',\\n') .. '\\n' .. indent0 .. '}' else if type(o) == 'string' then o = string.format('%q', o) end return tostring(o) end end\nlocal function richtraceback() local x = 2 while true do local info = debug.getinfo(x) if not info then break end local fname = '<' .. info.short_src .. \":\" .. info.linedefined .. \">\" if info.name then fname = info.name end print(info.short_src .. \":\" .. info.currentline .. \": in \" .. (\"%q\"):format(fname)) print(\" LOCALS:\") local p = 1 while true do local name, val = debug.getlocal(x,p) if not name then break end print(\" \" .. name .. \": \" .. tostringxx(val, 3)) p = p + 1 end print(\" UPVALUES:\") for p=1,info.nups do local name, val = debug.getupvalue(info.func,p) if not name then break end print(\" \" .. name .. \": \" .. tostringxx(val, 3)) end x = x + 1 end end\nlocal function myassert(b) if not b then richtraceback() error(\"assertion failed\") end end \n-----------------------\nlocal D = read.n()\nlocal C = read.N(26)\nlocal S = {}\nfor i=1,D do\n S[i] = read.N(26)\nend\n-----\n-----\nlocal last = array(1, 0)\nfor d=1,D do\n local amax = 0\n local maxi = -1\n for i=1,26 do\n local ans = S[d][i]\n for j=1,26 do\n if j ~= i then\n ans = ans - C[j] * (d - last[j])\n end\n end\n if ans > amax then\n amax = ans\n maxi = i\n end\n end\n last[maxi] = d\n print(maxi)\nend", "language": "Lua", "metadata": {"date": 1593393586, "filename_ext": "lua", "original_language": "Lua (Lua 5.3.5)", "problem_description_relpath": "problem_descriptions/p02619.html", "problem_id": "p02619", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02619/input.txt", "sample_output_relpath": "derived/input_output/data/p02619/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02619/Lua/s492276949.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s492276949", "user_id": "u162773977"}, "prompt_components": {"gold_output": "18398\n35037\n51140\n65837\n79325\n", "input_to_evaluate": "local read = setmetatable({}, {__index = function(t, k) local a = {} for i=1,#k do table.insert(a, '*'..string.sub(k, i, i)) end local r = io.read local u = table.unpack or unpack return function() return r(u(a)) end end})\nread.N = function(N) local t={} for i=1,N do t[i]=read.n() end return t end\nstring.totable = function(s) local t={} local u=string.sub for i=1,#s do t[i] = u(s, i, i) end return t end\nstring.split = function(s) local t={} for w in string.gmatch(s, \"[^%s]+\") do table.insert(t, w) end return (table.unpack or unpack)(t) end\nlocal function array(dimension, default_val) assert(type(default_val) ~= 'table') local n=dimension local m={}if default_val~=nil then m[1]={__index=function()return default_val end}end for i=2,n do m[i]={__index=function(p, k)local c=setmetatable({},m[i-1])rawset(p,k,c)return c end}end return setmetatable({},m[n])end\nlocal function tostringxx(o, depth) depth = depth or 0 if depth > 10 then return \"\" end if o == _G then return \"<_G>\" end local indent0 = (\" \"):rep((depth) * 2) local indent1 = (\" \"):rep((depth+1) * 2) local indent2= (\" \"):rep((depth+2) * 2) if type(o) == 'table' then local keys = {} local types = {} for k in pairs(o) do types[type(k)] = true table.insert(keys, k) end local types_count = 0 local lasttype for k in pairs(types) do types_count = types_count + 1 lasttype = k end if types_count == 1 and (lasttype == 'string' or lasttype == 'number') then table.sort(keys) end local inside = {} for i=1,#keys do local k = keys[i] local v = o[k] if type(k) == 'string' then k = string.format('%q', k) end table.insert(inside, indent1 .. '['..tostring(k)..'] = ' .. tostringxx(v, depth + 1)) end return '{\\n' .. table.concat(inside, ',\\n') .. '\\n' .. indent0 .. '}' else if type(o) == 'string' then o = string.format('%q', o) end return tostring(o) end end\nlocal function richtraceback() local x = 2 while true do local info = debug.getinfo(x) if not info then break end local fname = '<' .. info.short_src .. \":\" .. info.linedefined .. \">\" if info.name then fname = info.name end print(info.short_src .. \":\" .. info.currentline .. \": in \" .. (\"%q\"):format(fname)) print(\" LOCALS:\") local p = 1 while true do local name, val = debug.getlocal(x,p) if not name then break end print(\" \" .. name .. \": \" .. tostringxx(val, 3)) p = p + 1 end print(\" UPVALUES:\") for p=1,info.nups do local name, val = debug.getupvalue(info.func,p) if not name then break end print(\" \" .. name .. \": \" .. tostringxx(val, 3)) end x = x + 1 end end\nlocal function myassert(b) if not b then richtraceback() error(\"assertion failed\") end end \n-----------------------\nlocal D = read.n()\nlocal C = read.N(26)\nlocal S = {}\nfor i=1,D do\n S[i] = read.N(26)\nend\n-----\n-----\nlocal last = array(1, 0)\nfor d=1,D do\n local amax = 0\n local maxi = -1\n for i=1,26 do\n local ans = S[d][i]\n for j=1,26 do\n if j ~= i then\n ans = ans - C[j] * (d - last[j])\n end\n end\n if ans > amax then\n amax = ans\n maxi = i\n end\n end\n last[maxi] = d\n print(maxi)\nend", "problem_context": "(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\n\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\n\nYou will be given a contest schedule for D days.\nFor each d=1,2,\\ldots,D, calculate the satisfaction at the end of day d.\n\nInput\n\nInput is given from Standard Input in the form of the input of Problem A followed by the output of Problem A.\n\nD\nc_1 c_2 \\cdots c_{26}\ns_{1,1} s_{1,2} \\cdots s_{1,26}\n\\vdots\ns_{D,1} s_{D,2} \\cdots s_{D,26}\nt_1\nt_2\n\\vdots\nt_D\n\nThe constraints and generation methods for the input part are the same as those for Problem A.\n\nFor each d, t_d is an integer satisfying 1\\leq t_d \\leq 26, and your program is expected to work correctly for any value that meets the constraints.\n\nOutput\n\nLet v_d be the satisfaction at the end of day d.\nPrint D integers v_d to Standard Output in the following format:\n\nv_1\nv_2\n\\vdots\nv_D\n\nSample Input 1\n\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\n\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\n\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,\\ldots,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!\n\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.", "sample_input": "5\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"}, "reference_outputs": ["18398\n35037\n51140\n65837\n79325\n"], "source_document_id": "p02619", "source_text": "(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\n\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\n\nYou will be given a contest schedule for D days.\nFor each d=1,2,\\ldots,D, calculate the satisfaction at the end of day d.\n\nInput\n\nInput is given from Standard Input in the form of the input of Problem A followed by the output of Problem A.\n\nD\nc_1 c_2 \\cdots c_{26}\ns_{1,1} s_{1,2} \\cdots s_{1,26}\n\\vdots\ns_{D,1} s_{D,2} \\cdots s_{D,26}\nt_1\nt_2\n\\vdots\nt_D\n\nThe constraints and generation methods for the input part are the same as those for Problem A.\n\nFor each d, t_d is an integer satisfying 1\\leq t_d \\leq 26, and your program is expected to work correctly for any value that meets the constraints.\n\nOutput\n\nLet v_d be the satisfaction at the end of day d.\nPrint D integers v_d to Standard Output in the following format:\n\nv_1\nv_2\n\\vdots\nv_D\n\nSample Input 1\n\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\n\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\n\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,\\ldots,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!\n\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.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 3097, "cpu_time_ms": 49, "memory_kb": 3700}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s797739089", "group_id": "codeNet:p02620", "input_text": "local day = io.read(\"*n\")\nlocal c = {}\nfor i = 1, 26 do\n c[i] = io.read(\"*n\")\nend\nlocal s = {}\nfor id = 1, day do\n s[id] = {}\n for i = 1, 26 do\n s[id][i] = io.read(\"*n\")\n end\nend\n\nlocal scores = {}\nlocal penalties = {}\nfor i = 1, 26 do\n scores[i] = 0\n penalties[i] = 0\nend\nlocal function solveAll(t)\n local lastday = {}\n for i = 1, 26 do lastday[i] = 0 end\n for id = 1, day do\n local pid = t[id]\n scores[pid] = scores[pid] + s[id][pid]\n lastday[pid] = id\n for i = 1, 26 do\n penalties[i] = penalties[i] + c[i] * (id - lastday[i])\n end\n end\nend\nlocal function solveDiff(t, iday, pto)\n local pfrom = t[iday]\n scores[pfrom] = scores[pfrom] - s[iday][pfrom]\n scores[pto] = scores[pto] + s[iday][pto]\n t[iday] = pto\n penalties[pfrom] = 0\n penalties[pto] = 0\n local ld = {}\n for i = 1, 26 do ld[i] = 0 end\n for id = 1, day do\n local p = t[id]\n ld[p] = id\n for ip = pfrom, pto, (pto - pfrom) do\n penalties[ip] = penalties[ip] + c[ip] * (id - ld[ip])\n end\n end\nend\n\nlocal function solveSum()\n local z = 0\n for i = 1, 26 do z = z + scores[i] - penalties[i] end\n return z\nend\n\nlocal t = {}\nfor id = 1, day do\n t[id] = io.read(\"*n\")\n -- t[id] = 1 + (id % 26)\nend\nsolveAll(t)\nlocal score = solveSum()\nlocal m = io.read(\"*n\")\nfor i = 1, m do\n local d, q = io.read(\"*n\", \"*n\")\n solveDiff(t, d, q)\n print(solveSum())\nend\nos.exit()\n\nmath.randomseed(1)\nlocal iter = 1\nlocal random = math.random\nwhile os.clock() < 1.85 do\n iter = iter + 1\n local changeday = random(1, 365)\n local changeto = random(1, 25)\n local changefrom = t[changeday]\n if changefrom <= changeto then\n changeto = changeto + 1\n end\n solveDiff(t, changeday, changeto)\n local tmp = solveSum()\n if score < tmp then\n score = tmp\n else\n solveDiff(t, changeday, changefrom)\n end\nend\n-- print(iter)\nprint(table.concat(t, \"\\n\"))\n", "language": "Lua", "metadata": {"date": 1593396109, "filename_ext": "lua", "original_language": "Lua (LuaJIT 2.1.0)", "problem_description_relpath": "problem_descriptions/p02620.html", "problem_id": "p02620", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02620/input.txt", "sample_output_relpath": "derived/input_output/data/p02620/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02620/Lua/s797739089.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s797739089", "user_id": "u120582723"}, "prompt_components": {"gold_output": "72882\n56634\n38425\n27930\n42884\n", "input_to_evaluate": "local day = io.read(\"*n\")\nlocal c = {}\nfor i = 1, 26 do\n c[i] = io.read(\"*n\")\nend\nlocal s = {}\nfor id = 1, day do\n s[id] = {}\n for i = 1, 26 do\n s[id][i] = io.read(\"*n\")\n end\nend\n\nlocal scores = {}\nlocal penalties = {}\nfor i = 1, 26 do\n scores[i] = 0\n penalties[i] = 0\nend\nlocal function solveAll(t)\n local lastday = {}\n for i = 1, 26 do lastday[i] = 0 end\n for id = 1, day do\n local pid = t[id]\n scores[pid] = scores[pid] + s[id][pid]\n lastday[pid] = id\n for i = 1, 26 do\n penalties[i] = penalties[i] + c[i] * (id - lastday[i])\n end\n end\nend\nlocal function solveDiff(t, iday, pto)\n local pfrom = t[iday]\n scores[pfrom] = scores[pfrom] - s[iday][pfrom]\n scores[pto] = scores[pto] + s[iday][pto]\n t[iday] = pto\n penalties[pfrom] = 0\n penalties[pto] = 0\n local ld = {}\n for i = 1, 26 do ld[i] = 0 end\n for id = 1, day do\n local p = t[id]\n ld[p] = id\n for ip = pfrom, pto, (pto - pfrom) do\n penalties[ip] = penalties[ip] + c[ip] * (id - ld[ip])\n end\n end\nend\n\nlocal function solveSum()\n local z = 0\n for i = 1, 26 do z = z + scores[i] - penalties[i] end\n return z\nend\n\nlocal t = {}\nfor id = 1, day do\n t[id] = io.read(\"*n\")\n -- t[id] = 1 + (id % 26)\nend\nsolveAll(t)\nlocal score = solveSum()\nlocal m = io.read(\"*n\")\nfor i = 1, m do\n local d, q = io.read(\"*n\", \"*n\")\n solveDiff(t, d, q)\n print(solveSum())\nend\nos.exit()\n\nmath.randomseed(1)\nlocal iter = 1\nlocal random = math.random\nwhile os.clock() < 1.85 do\n iter = iter + 1\n local changeday = random(1, 365)\n local changeto = random(1, 25)\n local changefrom = t[changeday]\n if changefrom <= changeto then\n changeto = changeto + 1\n end\n solveDiff(t, changeday, changeto)\n local tmp = solveSum()\n if score < tmp then\n score = tmp\n else\n solveDiff(t, changeday, changefrom)\n end\nend\n-- print(iter)\nprint(table.concat(t, \"\\n\"))\n", "problem_context": "(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\n\n\"Local search\" is a powerful method for finding a high-quality solution.\nIn this method, instead of constructing a solution from scratch, we try to find a better solution by slightly modifying the already found solution.\nIf the solution gets better, update it, and if it gets worse, restore it.\nBy repeating this process, the quality of the solution is gradually improved over time.\nThe 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:\nslightly modify the solution (randomly)\nif the solution gets worse:\nrestore 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.\nThe 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:\npick d and q at random\nold = t[d] # Remember the original value so that we can restore it later\nt[d] = q\nif the solution gets worse:\nt[d] = old\n\nThe most important thing when using the local search method is the design of how to modify solutions.\n\nIf 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.\n\nIn 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.\nThe score after the modification can, of course, be obtained by calculating the score from scratch.\nHowever, 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.\nFrom another viewpoint, the impossibility of such a fast incremental calculation implies that a small modification to the solution affects a majority of the score calculation.\nIn such a case, we may need to redesign how to modify solutions, or there is a high possibility that the problem is not suitable for local search.\nLet's implement fast incremental score computation.\nIt's time to demonstrate the skills of algorithms and data structures you have developed in ABC and ARC!\n\nIn this kind of contest, where the objective is to find a better solution instead of the optimal one, a bug in a program does not result in a wrong answer, which may delay the discovery of the bug.\nFor early detection of bugs, it is a good idea to unit test functions you implemented complicated routines.\nFor example, if you implement fast incremental score calculation, it is a good idea to test that the scores computed by the fast implementation match the scores computed from scratch, as we will do in this problem C.\n\nProblem Statement\n\nYou will be given a contest schedule for D days and M queries of schedule modification.\nIn 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.\nNote 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\n\nInput 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\nD\nc_1 c_2 \\cdots c_{26}\ns_{1,1} s_{1,2} \\cdots s_{1,26}\n\\vdots\ns_{D,1} s_{D,2} \\cdots s_{D,26}\nt_1\nt_2\n\\vdots\nt_D\nM\nd_1 q_1\nd_2 q_2\n\\vdots\nd_M q_M\n\nThe constraints and generation methods for the input part are the same as those for Problem A.\n\nFor each d=1,\\ldots,D, t_d is an integer generated independently and uniformly at random from {1,2,\\ldots,26}.\n\nThe number of queries M is an integer satisfying 1\\leq M\\leq 10^5.\n\nFor each i=1,\\ldots,M, d_i is an integer generated independently and uniformly at random from {1,2,\\ldots,D}.\n\nFor each i=1,\\ldots,26, q_i is an integer satisfying 1\\leq q_i\\leq 26 generated uniformly at random from the 25 values that differ from the type of contest on day d_i.\n\nOutput\n\nLet v_i be the final satisfaction at the end of day D on the schedule after applying the i-th query.\nPrint M integers v_i to Standard Output in the following format:\n\nv_1\nv_2\n\\vdots\nv_M\n\nSample Input 1\n\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\n\n72882\n56634\n38425\n27930\n42884\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\n\nLet's go back to Problem A and implement the local search algorithm by utilizing the incremental score calculator you just implemented!\nFor 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.\nOne of the most powerful and widely used variant of the local search method is \"Simulated Annealing (SA)\", which makes it easier to reach a better solution by stochastically accepting worsening moves.\nFor more information about SA and other local search techniques, please refer to the editorial that will be published after the contest.", "sample_input": "5\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"}, "reference_outputs": ["72882\n56634\n38425\n27930\n42884\n"], "source_document_id": "p02620", "source_text": "(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\n\n\"Local search\" is a powerful method for finding a high-quality solution.\nIn this method, instead of constructing a solution from scratch, we try to find a better solution by slightly modifying the already found solution.\nIf the solution gets better, update it, and if it gets worse, restore it.\nBy repeating this process, the quality of the solution is gradually improved over time.\nThe 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:\nslightly modify the solution (randomly)\nif the solution gets worse:\nrestore 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.\nThe 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:\npick d and q at random\nold = t[d] # Remember the original value so that we can restore it later\nt[d] = q\nif the solution gets worse:\nt[d] = old\n\nThe most important thing when using the local search method is the design of how to modify solutions.\n\nIf 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.\n\nIn 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.\nThe score after the modification can, of course, be obtained by calculating the score from scratch.\nHowever, 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.\nFrom another viewpoint, the impossibility of such a fast incremental calculation implies that a small modification to the solution affects a majority of the score calculation.\nIn such a case, we may need to redesign how to modify solutions, or there is a high possibility that the problem is not suitable for local search.\nLet's implement fast incremental score computation.\nIt's time to demonstrate the skills of algorithms and data structures you have developed in ABC and ARC!\n\nIn this kind of contest, where the objective is to find a better solution instead of the optimal one, a bug in a program does not result in a wrong answer, which may delay the discovery of the bug.\nFor early detection of bugs, it is a good idea to unit test functions you implemented complicated routines.\nFor example, if you implement fast incremental score calculation, it is a good idea to test that the scores computed by the fast implementation match the scores computed from scratch, as we will do in this problem C.\n\nProblem Statement\n\nYou will be given a contest schedule for D days and M queries of schedule modification.\nIn 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.\nNote 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\n\nInput 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\nD\nc_1 c_2 \\cdots c_{26}\ns_{1,1} s_{1,2} \\cdots s_{1,26}\n\\vdots\ns_{D,1} s_{D,2} \\cdots s_{D,26}\nt_1\nt_2\n\\vdots\nt_D\nM\nd_1 q_1\nd_2 q_2\n\\vdots\nd_M q_M\n\nThe constraints and generation methods for the input part are the same as those for Problem A.\n\nFor each d=1,\\ldots,D, t_d is an integer generated independently and uniformly at random from {1,2,\\ldots,26}.\n\nThe number of queries M is an integer satisfying 1\\leq M\\leq 10^5.\n\nFor each i=1,\\ldots,M, d_i is an integer generated independently and uniformly at random from {1,2,\\ldots,D}.\n\nFor each i=1,\\ldots,26, q_i is an integer satisfying 1\\leq q_i\\leq 26 generated uniformly at random from the 25 values that differ from the type of contest on day d_i.\n\nOutput\n\nLet v_i be the final satisfaction at the end of day D on the schedule after applying the i-th query.\nPrint M integers v_i to Standard Output in the following format:\n\nv_1\nv_2\n\\vdots\nv_M\n\nSample Input 1\n\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\n\n72882\n56634\n38425\n27930\n42884\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\n\nLet's go back to Problem A and implement the local search algorithm by utilizing the incremental score calculator you just implemented!\nFor 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.\nOne of the most powerful and widely used variant of the local search method is \"Simulated Annealing (SA)\", which makes it easier to reach a better solution by stochastically accepting worsening moves.\nFor more information about SA and other local search techniques, please refer to the editorial that will be published after the contest.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1859, "cpu_time_ms": 470, "memory_kb": 3116}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s771301450", "group_id": "codeNet:p02620", "input_text": "local day = io.read(\"*n\")\nlocal c = {}\nfor i = 1, 26 do\n c[i] = io.read(\"*n\")\nend\nlocal s = {}\nfor id = 1, day do\n s[id] = {}\n for i = 1, 26 do\n s[id][i] = io.read(\"*n\")\n end\nend\n\nlocal scores = {}\nlocal penalties = {}\nfor i = 1, 26 do\n scores[i] = 0\n penalties[i] = 0\nend\nlocal function solveAll(t)\n local lastday = {}\n for i = 1, 26 do lastday[i] = 0 end\n for id = 1, day do\n local pid = t[id]\n scores[pid] = scores[pid] + s[id][pid]\n lastday[pid] = id\n for i = 1, 26 do\n penalties[i] = penalties[i] + c[i] * (id - lastday[i])\n end\n end\nend\nlocal function solveDiff(t, iday, pto)\n local pfrom = t[iday]\n scores[pfrom] = scores[pfrom] - s[iday][pfrom]\n scores[pto] = scores[pto] + s[iday][pto]\n t[iday] = pto\n penalties[pfrom] = 0\n penalties[pto] = 0\n local ld = {}\n for i = 1, 26 do ld[i] = 0 end\n for id = 1, day do\n local p = t[id]\n ld[p] = id\n for ip = pfrom, pto, (pto - pfrom) do\n penalties[ip] = penalties[ip] + c[ip] * (id - ld[ip])\n end\n end\nend\n\nlocal function solveSum()\n local z = 0\n for i = 1, 26 do z = z + scores[i] - penalties[i] end\n return z\nend\n\nlocal t = {}\nfor id = 1, day do\n t[id] = 1 + (id % 26)\nend\nsolveAll(t)\nlocal score = solveSum()\nmath.randomseed(1)\nlocal iter = 1\nlocal random = math.random\nwhile os.clock() < 1.85 do\n iter = iter + 1\n local changeday = random(1, 365)\n local changeto = random(1, 25)\n local changefrom = t[changeday]\n if changefrom <= changeto then\n changeto = changeto + 1\n end\n solveDiff(t, changeday, changeto)\n local tmp = solveSum()\n if score < tmp then\n score = tmp\n else\n solveDiff(t, changeday, changefrom)\n end\nend\n-- print(iter)\nprint(table.concat(t, \"\\n\"))\n", "language": "Lua", "metadata": {"date": 1593395744, "filename_ext": "lua", "original_language": "Lua (LuaJIT 2.1.0)", "problem_description_relpath": "problem_descriptions/p02620.html", "problem_id": "p02620", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02620/input.txt", "sample_output_relpath": "derived/input_output/data/p02620/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02620/Lua/s771301450.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s771301450", "user_id": "u120582723"}, "prompt_components": {"gold_output": "72882\n56634\n38425\n27930\n42884\n", "input_to_evaluate": "local day = io.read(\"*n\")\nlocal c = {}\nfor i = 1, 26 do\n c[i] = io.read(\"*n\")\nend\nlocal s = {}\nfor id = 1, day do\n s[id] = {}\n for i = 1, 26 do\n s[id][i] = io.read(\"*n\")\n end\nend\n\nlocal scores = {}\nlocal penalties = {}\nfor i = 1, 26 do\n scores[i] = 0\n penalties[i] = 0\nend\nlocal function solveAll(t)\n local lastday = {}\n for i = 1, 26 do lastday[i] = 0 end\n for id = 1, day do\n local pid = t[id]\n scores[pid] = scores[pid] + s[id][pid]\n lastday[pid] = id\n for i = 1, 26 do\n penalties[i] = penalties[i] + c[i] * (id - lastday[i])\n end\n end\nend\nlocal function solveDiff(t, iday, pto)\n local pfrom = t[iday]\n scores[pfrom] = scores[pfrom] - s[iday][pfrom]\n scores[pto] = scores[pto] + s[iday][pto]\n t[iday] = pto\n penalties[pfrom] = 0\n penalties[pto] = 0\n local ld = {}\n for i = 1, 26 do ld[i] = 0 end\n for id = 1, day do\n local p = t[id]\n ld[p] = id\n for ip = pfrom, pto, (pto - pfrom) do\n penalties[ip] = penalties[ip] + c[ip] * (id - ld[ip])\n end\n end\nend\n\nlocal function solveSum()\n local z = 0\n for i = 1, 26 do z = z + scores[i] - penalties[i] end\n return z\nend\n\nlocal t = {}\nfor id = 1, day do\n t[id] = 1 + (id % 26)\nend\nsolveAll(t)\nlocal score = solveSum()\nmath.randomseed(1)\nlocal iter = 1\nlocal random = math.random\nwhile os.clock() < 1.85 do\n iter = iter + 1\n local changeday = random(1, 365)\n local changeto = random(1, 25)\n local changefrom = t[changeday]\n if changefrom <= changeto then\n changeto = changeto + 1\n end\n solveDiff(t, changeday, changeto)\n local tmp = solveSum()\n if score < tmp then\n score = tmp\n else\n solveDiff(t, changeday, changefrom)\n end\nend\n-- print(iter)\nprint(table.concat(t, \"\\n\"))\n", "problem_context": "(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\n\n\"Local search\" is a powerful method for finding a high-quality solution.\nIn this method, instead of constructing a solution from scratch, we try to find a better solution by slightly modifying the already found solution.\nIf the solution gets better, update it, and if it gets worse, restore it.\nBy repeating this process, the quality of the solution is gradually improved over time.\nThe 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:\nslightly modify the solution (randomly)\nif the solution gets worse:\nrestore 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.\nThe 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:\npick d and q at random\nold = t[d] # Remember the original value so that we can restore it later\nt[d] = q\nif the solution gets worse:\nt[d] = old\n\nThe most important thing when using the local search method is the design of how to modify solutions.\n\nIf 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.\n\nIn 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.\nThe score after the modification can, of course, be obtained by calculating the score from scratch.\nHowever, 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.\nFrom another viewpoint, the impossibility of such a fast incremental calculation implies that a small modification to the solution affects a majority of the score calculation.\nIn such a case, we may need to redesign how to modify solutions, or there is a high possibility that the problem is not suitable for local search.\nLet's implement fast incremental score computation.\nIt's time to demonstrate the skills of algorithms and data structures you have developed in ABC and ARC!\n\nIn this kind of contest, where the objective is to find a better solution instead of the optimal one, a bug in a program does not result in a wrong answer, which may delay the discovery of the bug.\nFor early detection of bugs, it is a good idea to unit test functions you implemented complicated routines.\nFor example, if you implement fast incremental score calculation, it is a good idea to test that the scores computed by the fast implementation match the scores computed from scratch, as we will do in this problem C.\n\nProblem Statement\n\nYou will be given a contest schedule for D days and M queries of schedule modification.\nIn 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.\nNote 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\n\nInput 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\nD\nc_1 c_2 \\cdots c_{26}\ns_{1,1} s_{1,2} \\cdots s_{1,26}\n\\vdots\ns_{D,1} s_{D,2} \\cdots s_{D,26}\nt_1\nt_2\n\\vdots\nt_D\nM\nd_1 q_1\nd_2 q_2\n\\vdots\nd_M q_M\n\nThe constraints and generation methods for the input part are the same as those for Problem A.\n\nFor each d=1,\\ldots,D, t_d is an integer generated independently and uniformly at random from {1,2,\\ldots,26}.\n\nThe number of queries M is an integer satisfying 1\\leq M\\leq 10^5.\n\nFor each i=1,\\ldots,M, d_i is an integer generated independently and uniformly at random from {1,2,\\ldots,D}.\n\nFor each i=1,\\ldots,26, q_i is an integer satisfying 1\\leq q_i\\leq 26 generated uniformly at random from the 25 values that differ from the type of contest on day d_i.\n\nOutput\n\nLet v_i be the final satisfaction at the end of day D on the schedule after applying the i-th query.\nPrint M integers v_i to Standard Output in the following format:\n\nv_1\nv_2\n\\vdots\nv_M\n\nSample Input 1\n\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\n\n72882\n56634\n38425\n27930\n42884\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\n\nLet's go back to Problem A and implement the local search algorithm by utilizing the incremental score calculator you just implemented!\nFor 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.\nOne of the most powerful and widely used variant of the local search method is \"Simulated Annealing (SA)\", which makes it easier to reach a better solution by stochastically accepting worsening moves.\nFor more information about SA and other local search techniques, please refer to the editorial that will be published after the contest.", "sample_input": "5\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"}, "reference_outputs": ["72882\n56634\n38425\n27930\n42884\n"], "source_document_id": "p02620", "source_text": "(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\n\n\"Local search\" is a powerful method for finding a high-quality solution.\nIn this method, instead of constructing a solution from scratch, we try to find a better solution by slightly modifying the already found solution.\nIf the solution gets better, update it, and if it gets worse, restore it.\nBy repeating this process, the quality of the solution is gradually improved over time.\nThe 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:\nslightly modify the solution (randomly)\nif the solution gets worse:\nrestore 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.\nThe 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:\npick d and q at random\nold = t[d] # Remember the original value so that we can restore it later\nt[d] = q\nif the solution gets worse:\nt[d] = old\n\nThe most important thing when using the local search method is the design of how to modify solutions.\n\nIf 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.\n\nIn 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.\nThe score after the modification can, of course, be obtained by calculating the score from scratch.\nHowever, 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.\nFrom another viewpoint, the impossibility of such a fast incremental calculation implies that a small modification to the solution affects a majority of the score calculation.\nIn such a case, we may need to redesign how to modify solutions, or there is a high possibility that the problem is not suitable for local search.\nLet's implement fast incremental score computation.\nIt's time to demonstrate the skills of algorithms and data structures you have developed in ABC and ARC!\n\nIn this kind of contest, where the objective is to find a better solution instead of the optimal one, a bug in a program does not result in a wrong answer, which may delay the discovery of the bug.\nFor early detection of bugs, it is a good idea to unit test functions you implemented complicated routines.\nFor example, if you implement fast incremental score calculation, it is a good idea to test that the scores computed by the fast implementation match the scores computed from scratch, as we will do in this problem C.\n\nProblem Statement\n\nYou will be given a contest schedule for D days and M queries of schedule modification.\nIn 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.\nNote 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\n\nInput 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\nD\nc_1 c_2 \\cdots c_{26}\ns_{1,1} s_{1,2} \\cdots s_{1,26}\n\\vdots\ns_{D,1} s_{D,2} \\cdots s_{D,26}\nt_1\nt_2\n\\vdots\nt_D\nM\nd_1 q_1\nd_2 q_2\n\\vdots\nd_M q_M\n\nThe constraints and generation methods for the input part are the same as those for Problem A.\n\nFor each d=1,\\ldots,D, t_d is an integer generated independently and uniformly at random from {1,2,\\ldots,26}.\n\nThe number of queries M is an integer satisfying 1\\leq M\\leq 10^5.\n\nFor each i=1,\\ldots,M, d_i is an integer generated independently and uniformly at random from {1,2,\\ldots,D}.\n\nFor each i=1,\\ldots,26, q_i is an integer satisfying 1\\leq q_i\\leq 26 generated uniformly at random from the 25 values that differ from the type of contest on day d_i.\n\nOutput\n\nLet v_i be the final satisfaction at the end of day D on the schedule after applying the i-th query.\nPrint M integers v_i to Standard Output in the following format:\n\nv_1\nv_2\n\\vdots\nv_M\n\nSample Input 1\n\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\n\n72882\n56634\n38425\n27930\n42884\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\n\nLet's go back to Problem A and implement the local search algorithm by utilizing the incremental score calculator you just implemented!\nFor 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.\nOne of the most powerful and widely used variant of the local search method is \"Simulated Annealing (SA)\", which makes it easier to reach a better solution by stochastically accepting worsening moves.\nFor more information about SA and other local search techniques, please refer to the editorial that will be published after the contest.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1701, "cpu_time_ms": 1862, "memory_kb": 3088}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s156488964", "group_id": "codeNet:p02621", "input_text": "local s = io.read()\ns = tonumber(s)\n\nlocal function func(s)\n\treturn s + s * s + s * s * s\nend\n\n\nprint(func(s))", "language": "Lua", "metadata": {"date": 1594084353, "filename_ext": "lua", "original_language": "Lua (Lua 5.3.5)", "problem_description_relpath": "problem_descriptions/p02621.html", "problem_id": "p02621", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02621/input.txt", "sample_output_relpath": "derived/input_output/data/p02621/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02621/Lua/s156488964.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s156488964", "user_id": "u018679195"}, "prompt_components": {"gold_output": "14\n", "input_to_evaluate": "local s = io.read()\ns = tonumber(s)\n\nlocal function func(s)\n\treturn s + s * s + s * s * s\nend\n\n\nprint(func(s))", "problem_context": "Score : 100 points\n\nProblem Statement\n\nGiven an integer a as input, print the value a + a^2 + a^3.\n\nConstraints\n\n1 \\leq a \\leq 10\n\na is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\na\n\nOutput\n\nPrint the value a + a^2 + a^3 as an integer.\n\nSample Input 1\n\n2\n\nSample Output 1\n\n14\n\nWhen a = 2, we have a + a^2 + a^3 = 2 + 2^2 + 2^3 = 2 + 4 + 8 = 14.\n\nPrint the answer as an input. Outputs such as 14.0 will be judged as incorrect.\n\nSample Input 2\n\n10\n\nSample Output 2\n\n1110", "sample_input": "2\n"}, "reference_outputs": ["14\n"], "source_document_id": "p02621", "source_text": "Score : 100 points\n\nProblem Statement\n\nGiven an integer a as input, print the value a + a^2 + a^3.\n\nConstraints\n\n1 \\leq a \\leq 10\n\na is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\na\n\nOutput\n\nPrint the value a + a^2 + a^3 as an integer.\n\nSample Input 1\n\n2\n\nSample Output 1\n\n14\n\nWhen a = 2, we have a + a^2 + a^3 = 2 + 2^2 + 2^3 = 2 + 4 + 8 = 14.\n\nPrint the answer as an input. Outputs such as 14.0 will be judged as incorrect.\n\nSample Input 2\n\n10\n\nSample Output 2\n\n1110", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 110, "cpu_time_ms": 3, "memory_kb": 2648}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s514210334", "group_id": "codeNet:p02622", "input_text": "local s = io.read()\nlocal t = io.read()\n\nlocal ans = 0\n\nfor i = 1, string.len(s) do\n if string.sub(s, i, i) ~= string.sub(t, i, i) then\n ans = ans + 1\n end\nend\n\nprint(ans)\n", "language": "Lua", "metadata": {"date": 1594733130, "filename_ext": "lua", "original_language": "Lua (Lua 5.3.5)", "problem_description_relpath": "problem_descriptions/p02622.html", "problem_id": "p02622", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02622/input.txt", "sample_output_relpath": "derived/input_output/data/p02622/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02622/Lua/s514210334.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s514210334", "user_id": "u914562870"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "local s = io.read()\nlocal t = io.read()\n\nlocal ans = 0\n\nfor i = 1, string.len(s) do\n if string.sub(s, i, i) ~= string.sub(t, i, i) then\n ans = ans + 1\n end\nend\n\nprint(ans)\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nGiven are strings S and T. Consider changing S to T by repeating the operation below. Find the minimum number of operations required to do so.\n\nOperation: Choose one character of S and replace it with a different character.\n\nConstraints\n\nS and T have lengths between 1 and 2\\times 10^5 (inclusive).\n\nS and T consists of lowercase English letters.\n\nS and T have equal lengths.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\nT\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\ncupofcoffee\ncupofhottea\n\nSample Output 1\n\n4\n\nWe can achieve the objective in four operations, such as the following:\n\nFirst, replace the sixth character c with h.\n\nSecond, replace the eighth character f with t.\n\nThird, replace the ninth character f with t.\n\nFourth, replace the eleventh character e with a.\n\nSample Input 2\n\nabcde\nbcdea\n\nSample Output 2\n\n5\n\nSample Input 3\n\napple\napple\n\nSample Output 3\n\n0\n\nNo operations may be needed to achieve the objective.", "sample_input": "cupofcoffee\ncupofhottea\n"}, "reference_outputs": ["4\n"], "source_document_id": "p02622", "source_text": "Score : 200 points\n\nProblem Statement\n\nGiven are strings S and T. Consider changing S to T by repeating the operation below. Find the minimum number of operations required to do so.\n\nOperation: Choose one character of S and replace it with a different character.\n\nConstraints\n\nS and T have lengths between 1 and 2\\times 10^5 (inclusive).\n\nS and T consists of lowercase English letters.\n\nS and T have equal lengths.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\nT\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\ncupofcoffee\ncupofhottea\n\nSample Output 1\n\n4\n\nWe can achieve the objective in four operations, such as the following:\n\nFirst, replace the sixth character c with h.\n\nSecond, replace the eighth character f with t.\n\nThird, replace the ninth character f with t.\n\nFourth, replace the eleventh character e with a.\n\nSample Input 2\n\nabcde\nbcdea\n\nSample Output 2\n\n5\n\nSample Input 3\n\napple\napple\n\nSample Output 3\n\n0\n\nNo operations may be needed to achieve the objective.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 185, "cpu_time_ms": 53, "memory_kb": 2812}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s599309877", "group_id": "codeNet:p02622", "input_text": "local read = setmetatable({}, {__index = function(t, k) local a = {} for i=1,#k do table.insert(a, '*'..string.sub(k, i, i)) end local r = io.read local u = table.unpack or unpack return function() return r(u(a)) end end})\nread.N = function(N) local t={} for i=1,N do t[i]=read.n() end return t end\nstring.totable = function(s) local t={} local u=string.sub for i=1,#s do t[i] = u(s, i, i) end return t end\nstring.split = function(s) local t={} for w in string.gmatch(s, \"[^%s]+\") do table.insert(t, w) end return (table.unpack or unpack)(t) end\nlocal function array(dimension, default_val) assert(type(default_val) ~= 'table') local n=dimension local m={}if default_val~=nil then m[1]={__index=function()return default_val end}end for i=2,n do m[i]={__index=function(p, k)local c=setmetatable({},m[i-1])rawset(p,k,c)return c end}end return setmetatable({},m[n])end\n-----------------------\nlocal S = (read.l()):totable()\nlocal T = (read.l()):totable()\nlocal c = 0\nfor i=1, #S do\n if S[i] ~= T[i] then\n c = c + 1\n end\nend\nprint(c)", "language": "Lua", "metadata": {"date": 1593306114, "filename_ext": "lua", "original_language": "Lua (Lua 5.3.5)", "problem_description_relpath": "problem_descriptions/p02622.html", "problem_id": "p02622", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02622/input.txt", "sample_output_relpath": "derived/input_output/data/p02622/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02622/Lua/s599309877.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s599309877", "user_id": "u162773977"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "local read = setmetatable({}, {__index = function(t, k) local a = {} for i=1,#k do table.insert(a, '*'..string.sub(k, i, i)) end local r = io.read local u = table.unpack or unpack return function() return r(u(a)) end end})\nread.N = function(N) local t={} for i=1,N do t[i]=read.n() end return t end\nstring.totable = function(s) local t={} local u=string.sub for i=1,#s do t[i] = u(s, i, i) end return t end\nstring.split = function(s) local t={} for w in string.gmatch(s, \"[^%s]+\") do table.insert(t, w) end return (table.unpack or unpack)(t) end\nlocal function array(dimension, default_val) assert(type(default_val) ~= 'table') local n=dimension local m={}if default_val~=nil then m[1]={__index=function()return default_val end}end for i=2,n do m[i]={__index=function(p, k)local c=setmetatable({},m[i-1])rawset(p,k,c)return c end}end return setmetatable({},m[n])end\n-----------------------\nlocal S = (read.l()):totable()\nlocal T = (read.l()):totable()\nlocal c = 0\nfor i=1, #S do\n if S[i] ~= T[i] then\n c = c + 1\n end\nend\nprint(c)", "problem_context": "Score : 200 points\n\nProblem Statement\n\nGiven are strings S and T. Consider changing S to T by repeating the operation below. Find the minimum number of operations required to do so.\n\nOperation: Choose one character of S and replace it with a different character.\n\nConstraints\n\nS and T have lengths between 1 and 2\\times 10^5 (inclusive).\n\nS and T consists of lowercase English letters.\n\nS and T have equal lengths.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\nT\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\ncupofcoffee\ncupofhottea\n\nSample Output 1\n\n4\n\nWe can achieve the objective in four operations, such as the following:\n\nFirst, replace the sixth character c with h.\n\nSecond, replace the eighth character f with t.\n\nThird, replace the ninth character f with t.\n\nFourth, replace the eleventh character e with a.\n\nSample Input 2\n\nabcde\nbcdea\n\nSample Output 2\n\n5\n\nSample Input 3\n\napple\napple\n\nSample Output 3\n\n0\n\nNo operations may be needed to achieve the objective.", "sample_input": "cupofcoffee\ncupofhottea\n"}, "reference_outputs": ["4\n"], "source_document_id": "p02622", "source_text": "Score : 200 points\n\nProblem Statement\n\nGiven are strings S and T. Consider changing S to T by repeating the operation below. Find the minimum number of operations required to do so.\n\nOperation: Choose one character of S and replace it with a different character.\n\nConstraints\n\nS and T have lengths between 1 and 2\\times 10^5 (inclusive).\n\nS and T consists of lowercase English letters.\n\nS and T have equal lengths.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\nT\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\ncupofcoffee\ncupofhottea\n\nSample Output 1\n\n4\n\nWe can achieve the objective in four operations, such as the following:\n\nFirst, replace the sixth character c with h.\n\nSecond, replace the eighth character f with t.\n\nThird, replace the ninth character f with t.\n\nFourth, replace the eleventh character e with a.\n\nSample Input 2\n\nabcde\nbcdea\n\nSample Output 2\n\n5\n\nSample Input 3\n\napple\napple\n\nSample Output 3\n\n0\n\nNo operations may be needed to achieve the objective.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1042, "cpu_time_ms": 63, "memory_kb": 11060}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s520270095", "group_id": "codeNet:p02622", "input_text": "s = io.read()\nt = io.read()\nn = #s\nc = 0\nfor i = 1, n do\n if s:sub(i, i) ~= t:sub(i, i) then\n c = c + 1\n end\nend\nprint(c)\n", "language": "Lua", "metadata": {"date": 1593306073, "filename_ext": "lua", "original_language": "Lua (Lua 5.3.5)", "problem_description_relpath": "problem_descriptions/p02622.html", "problem_id": "p02622", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02622/input.txt", "sample_output_relpath": "derived/input_output/data/p02622/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02622/Lua/s520270095.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s520270095", "user_id": "u120582723"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "s = io.read()\nt = io.read()\nn = #s\nc = 0\nfor i = 1, n do\n if s:sub(i, i) ~= t:sub(i, i) then\n c = c + 1\n end\nend\nprint(c)\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nGiven are strings S and T. Consider changing S to T by repeating the operation below. Find the minimum number of operations required to do so.\n\nOperation: Choose one character of S and replace it with a different character.\n\nConstraints\n\nS and T have lengths between 1 and 2\\times 10^5 (inclusive).\n\nS and T consists of lowercase English letters.\n\nS and T have equal lengths.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\nT\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\ncupofcoffee\ncupofhottea\n\nSample Output 1\n\n4\n\nWe can achieve the objective in four operations, such as the following:\n\nFirst, replace the sixth character c with h.\n\nSecond, replace the eighth character f with t.\n\nThird, replace the ninth character f with t.\n\nFourth, replace the eleventh character e with a.\n\nSample Input 2\n\nabcde\nbcdea\n\nSample Output 2\n\n5\n\nSample Input 3\n\napple\napple\n\nSample Output 3\n\n0\n\nNo operations may be needed to achieve the objective.", "sample_input": "cupofcoffee\ncupofhottea\n"}, "reference_outputs": ["4\n"], "source_document_id": "p02622", "source_text": "Score : 200 points\n\nProblem Statement\n\nGiven are strings S and T. Consider changing S to T by repeating the operation below. Find the minimum number of operations required to do so.\n\nOperation: Choose one character of S and replace it with a different character.\n\nConstraints\n\nS and T have lengths between 1 and 2\\times 10^5 (inclusive).\n\nS and T consists of lowercase English letters.\n\nS and T have equal lengths.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\nT\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\ncupofcoffee\ncupofhottea\n\nSample Output 1\n\n4\n\nWe can achieve the objective in four operations, such as the following:\n\nFirst, replace the sixth character c with h.\n\nSecond, replace the eighth character f with t.\n\nThird, replace the ninth character f with t.\n\nFourth, replace the eleventh character e with a.\n\nSample Input 2\n\nabcde\nbcdea\n\nSample Output 2\n\n5\n\nSample Input 3\n\napple\napple\n\nSample Output 3\n\n0\n\nNo operations may be needed to achieve the objective.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 127, "cpu_time_ms": 60, "memory_kb": 2812}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s376459717", "group_id": "codeNet:p02625", "input_text": "local mod = 1000000007\nlocal mfl = math.floor\n\nlocal function bmul(x, y)\n local x1, y1 = mfl(x / 31623), mfl(y / 31623)\n local x0, y0 = x - x1 * 31623, y - y1 * 31623\n return (x1 * y1 * 14122 + (x1 * y0 + x0 * y1) * 31623 + x0 * y0) % mod\nend\n\nlocal function badd(x, y)\n return (x + y) % mod\nend\n\nlocal fact = {1}\nlocal invs = {1}\nlocal invfact = {1}\n\nfor i = 2, 500000 do\n fact[i] = bmul(fact[i - 1], i)\n invs[i] = bmul(mfl(mod / i), mod - invs[mod % i])\n invfact[i] = bmul(invfact[i - 1], invs[i])\nend\n\nlocal function getPerm(n, k)\n if n == 0 or k == 0 then return 1 end\n local ret = fact[n]\n if k < n then\n ret = bmul(ret, invfact[n - k])\n end\n return ret\nend\n\nlocal function getComb(n, k)\n if k == 0 or k == n then return 1 end\n return bmul(fact[n], bmul(invfact[k], invfact[n - k]))\nend\n\nlocal n, m = io.read(\"*n\", \"*n\")\nif m < n then\n print(0) os.exit()\nend\nlocal p_mn = getPerm(m, n)\nlocal matched = 0\nfor i = 1, n do\n local comb = getComb(n, i)\n local remPerm = getPerm(m - i, n - i)\n local z = bmul(comb, remPerm)\n if i % 2 == 1 then\n matched = badd(matched, z)\n else\n matched = badd(matched, mod - z)\n end\nend\nlocal not_matched = badd(p_mn, mod - matched)\nprint(bmul(p_mn, not_matched))\n", "language": "Lua", "metadata": {"date": 1593307858, "filename_ext": "lua", "original_language": "Lua (LuaJIT 2.1.0)", "problem_description_relpath": "problem_descriptions/p02625.html", "problem_id": "p02625", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02625/input.txt", "sample_output_relpath": "derived/input_output/data/p02625/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02625/Lua/s376459717.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s376459717", "user_id": "u120582723"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "local mod = 1000000007\nlocal mfl = math.floor\n\nlocal function bmul(x, y)\n local x1, y1 = mfl(x / 31623), mfl(y / 31623)\n local x0, y0 = x - x1 * 31623, y - y1 * 31623\n return (x1 * y1 * 14122 + (x1 * y0 + x0 * y1) * 31623 + x0 * y0) % mod\nend\n\nlocal function badd(x, y)\n return (x + y) % mod\nend\n\nlocal fact = {1}\nlocal invs = {1}\nlocal invfact = {1}\n\nfor i = 2, 500000 do\n fact[i] = bmul(fact[i - 1], i)\n invs[i] = bmul(mfl(mod / i), mod - invs[mod % i])\n invfact[i] = bmul(invfact[i - 1], invs[i])\nend\n\nlocal function getPerm(n, k)\n if n == 0 or k == 0 then return 1 end\n local ret = fact[n]\n if k < n then\n ret = bmul(ret, invfact[n - k])\n end\n return ret\nend\n\nlocal function getComb(n, k)\n if k == 0 or k == n then return 1 end\n return bmul(fact[n], bmul(invfact[k], invfact[n - k]))\nend\n\nlocal n, m = io.read(\"*n\", \"*n\")\nif m < n then\n print(0) os.exit()\nend\nlocal p_mn = getPerm(m, n)\nlocal matched = 0\nfor i = 1, n do\n local comb = getComb(n, i)\n local remPerm = getPerm(m - i, n - i)\n local z = bmul(comb, remPerm)\n if i % 2 == 1 then\n matched = badd(matched, z)\n else\n matched = badd(matched, mod - z)\n end\nend\nlocal not_matched = badd(p_mn, mod - matched)\nprint(bmul(p_mn, not_matched))\n", "problem_context": "Score : 500 points\n\nProblem Statement\n\nCount the pairs of length-N sequences consisting of integers between 1 and M (inclusive), A_1, A_2, \\cdots, A_{N} and B_1, B_2, \\cdots, B_{N}, that satisfy all of the following conditions:\n\nA_i \\neq B_i, for every i such that 1\\leq i\\leq N.\n\nA_i \\neq A_j and B_i \\neq B_j, for every (i, j) such that 1\\leq i < j\\leq N.\n\nSince the count can be enormous, print it modulo (10^9+7).\n\nConstraints\n\n1\\leq N \\leq M \\leq 5\\times10^5\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\n\nOutput\n\nPrint the count modulo (10^9+7).\n\nSample Input 1\n\n2 2\n\nSample Output 1\n\n2\n\nA_1=1,A_2=2,B_1=2,B_2=1 and A_1=2,A_2=1,B_1=1,B_2=2 satisfy the conditions.\n\nSample Input 2\n\n2 3\n\nSample Output 2\n\n18\n\nSample Input 3\n\n141421 356237\n\nSample Output 3\n\n881613484", "sample_input": "2 2\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02625", "source_text": "Score : 500 points\n\nProblem Statement\n\nCount the pairs of length-N sequences consisting of integers between 1 and M (inclusive), A_1, A_2, \\cdots, A_{N} and B_1, B_2, \\cdots, B_{N}, that satisfy all of the following conditions:\n\nA_i \\neq B_i, for every i such that 1\\leq i\\leq N.\n\nA_i \\neq A_j and B_i \\neq B_j, for every (i, j) such that 1\\leq i < j\\leq N.\n\nSince the count can be enormous, print it modulo (10^9+7).\n\nConstraints\n\n1\\leq N \\leq M \\leq 5\\times10^5\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\n\nOutput\n\nPrint the count modulo (10^9+7).\n\nSample Input 1\n\n2 2\n\nSample Output 1\n\n2\n\nA_1=1,A_2=2,B_1=2,B_2=1 and A_1=2,A_2=1,B_1=1,B_2=2 satisfy the conditions.\n\nSample Input 2\n\n2 3\n\nSample Output 2\n\n18\n\nSample Input 3\n\n141421 356237\n\nSample Output 3\n\n881613484", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1227, "cpu_time_ms": 102, "memory_kb": 15112}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s170276713", "group_id": "codeNet:p02626", "input_text": "local mfl, mce = math.floor, math.ceil\nlocal n = io.read(\"*n\")\nlocal a = {}\nfor i = 1, n do\n a[i] = io.read(\"*n\")\nend\nlocal xor = 0\nfor i = 3, n do\n xor = xor ~ a[i]\nend\nlocal sum = a[1] + a[2]\nif sum < xor then\n print(-1)\n os.exit()\nend\nlocal b_xor, b_sum = {}, {}\nwhile 0 < sum do\n table.insert(b_sum, sum % 2)\n table.insert(b_xor, xor % 2)\n sum = mfl(sum / 2)\n xor = mfl(xor / 2)\nend\nlocal dig = #b_sum\nlocal moveup = false\nlocal state = {}\nfor i = 1, dig do state[i] = 0 end\n-- state of bit of a[1] and a[2]\n-- 1: [0, 0], 2: [1, 1], 3: [0, 1] or [1, 0]\nfor idig = dig, 1, -1 do\n if b_sum[idig] == 1 then\n if b_xor[idig] == 1 then\n if moveup then\n print(-1)\n os.exit()\n else\n state[idig] = 3\n end\n else\n if moveup then\n state[idig] = 2\n else\n state[idig] = 1\n end\n moveup = true\n end\n else-- sum = 0\n if b_xor[idig] == 1 then\n if moveup then\n state[idig] = 3\n else\n print(-1)\n os.exit()\n end\n else\n if moveup then\n state[idig] = 2\n else\n state[idig] = 1\n end\n moveup = false\n end\n end\nend\nif moveup then print(-1) os.exit() end\nlocal alim = {}\ndo\n local tmp = a[1]\n for i = 1, dig do\n alim[i] = tmp % 2\n tmp = mfl(tmp / 2)\n end\nend\nlocal tbl = {}\nfor i = 1, dig do tbl[i] = 0 end\n\nlocal function dfs(idig, limit)\n if idig == 0 then return true end\n if limit then\n if alim[idig] == 0 then\n if state[idig] == 2 then\n return false\n else\n tbl[idig] = 0\n return dfs(idig - 1, true)\n end\n else\n if state[idig] == 2 then\n tbl[idig] = 1\n return dfs(idig - 1, true)\n elseif state[idig] == 1 then\n tbl[idig] = 0\n return dfs(idig - 1, false)\n else\n tbl[idig] = 1\n local ret = dfs(idig - 1, true)\n if ret then\n return true\n else\n tbl[idig] = 0\n return dfs(idig - 1, false)\n end\n end\n end\n else\n if state[idig] == 1 then\n tbl[idig] = 0\n return dfs(idig - 1, false)\n else\n tbl[idig] = 1\n return dfs(idig - 1, false)\n end\n end\nend\n\nlocal ret = dfs(dig, true)\nif not ret then\n print(-1)\n os.exit()\nend\nlocal ans = 0\nlocal mul = 1\nfor i = 1, dig do\n ans = ans + mul * tbl[i]\n mul = mul * 2\nend\nif ans == 0 then\n print(-1)\nelse\n print(a[1] - ans)\nend\n", "language": "Lua", "metadata": {"date": 1593310502, "filename_ext": "lua", "original_language": "Lua (Lua 5.3.5)", "problem_description_relpath": "problem_descriptions/p02626.html", "problem_id": "p02626", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02626/input.txt", "sample_output_relpath": "derived/input_output/data/p02626/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02626/Lua/s170276713.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s170276713", "user_id": "u120582723"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "local mfl, mce = math.floor, math.ceil\nlocal n = io.read(\"*n\")\nlocal a = {}\nfor i = 1, n do\n a[i] = io.read(\"*n\")\nend\nlocal xor = 0\nfor i = 3, n do\n xor = xor ~ a[i]\nend\nlocal sum = a[1] + a[2]\nif sum < xor then\n print(-1)\n os.exit()\nend\nlocal b_xor, b_sum = {}, {}\nwhile 0 < sum do\n table.insert(b_sum, sum % 2)\n table.insert(b_xor, xor % 2)\n sum = mfl(sum / 2)\n xor = mfl(xor / 2)\nend\nlocal dig = #b_sum\nlocal moveup = false\nlocal state = {}\nfor i = 1, dig do state[i] = 0 end\n-- state of bit of a[1] and a[2]\n-- 1: [0, 0], 2: [1, 1], 3: [0, 1] or [1, 0]\nfor idig = dig, 1, -1 do\n if b_sum[idig] == 1 then\n if b_xor[idig] == 1 then\n if moveup then\n print(-1)\n os.exit()\n else\n state[idig] = 3\n end\n else\n if moveup then\n state[idig] = 2\n else\n state[idig] = 1\n end\n moveup = true\n end\n else-- sum = 0\n if b_xor[idig] == 1 then\n if moveup then\n state[idig] = 3\n else\n print(-1)\n os.exit()\n end\n else\n if moveup then\n state[idig] = 2\n else\n state[idig] = 1\n end\n moveup = false\n end\n end\nend\nif moveup then print(-1) os.exit() end\nlocal alim = {}\ndo\n local tmp = a[1]\n for i = 1, dig do\n alim[i] = tmp % 2\n tmp = mfl(tmp / 2)\n end\nend\nlocal tbl = {}\nfor i = 1, dig do tbl[i] = 0 end\n\nlocal function dfs(idig, limit)\n if idig == 0 then return true end\n if limit then\n if alim[idig] == 0 then\n if state[idig] == 2 then\n return false\n else\n tbl[idig] = 0\n return dfs(idig - 1, true)\n end\n else\n if state[idig] == 2 then\n tbl[idig] = 1\n return dfs(idig - 1, true)\n elseif state[idig] == 1 then\n tbl[idig] = 0\n return dfs(idig - 1, false)\n else\n tbl[idig] = 1\n local ret = dfs(idig - 1, true)\n if ret then\n return true\n else\n tbl[idig] = 0\n return dfs(idig - 1, false)\n end\n end\n end\n else\n if state[idig] == 1 then\n tbl[idig] = 0\n return dfs(idig - 1, false)\n else\n tbl[idig] = 1\n return dfs(idig - 1, false)\n end\n end\nend\n\nlocal ret = dfs(dig, true)\nif not ret then\n print(-1)\n os.exit()\nend\nlocal ans = 0\nlocal mul = 1\nfor i = 1, dig do\n ans = ans + mul * tbl[i]\n mul = mul * 2\nend\nif ans == 0 then\n print(-1)\nelse\n print(a[1] - ans)\nend\n", "problem_context": "Score : 600 points\n\nProblem Statement\n\nThere are N piles of stones. The i-th pile has A_i stones.\n\nAoki and Takahashi are about to use them to play the following game:\n\nStarting with Aoki, the two players alternately do the following operation:\n\nOperation: Choose one pile of stones, and remove one or more stones from it.\n\nWhen a player is unable to do the operation, he loses, and the other player wins.\n\nWhen the two players play optimally, there are two possibilities in this game: the player who moves first always wins, or the player who moves second always wins, only depending on the initial number of stones in each pile.\n\nIn such a situation, Takahashi, the second player to act, is trying to guarantee his win by moving at least zero and at most (A_1 - 1) stones from the 1-st pile to the 2-nd pile before the game begins.\n\nIf this is possible, print the minimum number of stones to move to guarantee his victory; otherwise, print -1 instead.\n\nConstraints\n\n2 \\leq N \\leq 300\n\n1 \\leq A_i \\leq 10^{12}\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 \\ldots A_N\n\nOutput\n\nPrint the minimum number of stones to move to guarantee Takahashi's win; otherwise, print -1 instead.\n\nSample Input 1\n\n2\n5 3\n\nSample Output 1\n\n1\n\nWithout moving stones, if Aoki first removes 2 stones from the 1-st pile, Takahashi cannot win in any way.\n\nIf Takahashi moves 1 stone from the 1-st pile to the 2-nd before the game begins so that both piles have 4 stones, Takahashi can always win by properly choosing his actions.\n\nSample Input 2\n\n2\n3 5\n\nSample Output 2\n\n-1\n\nIt is not allowed to move stones from the 2-nd pile to the 1-st.\n\nSample Input 3\n\n3\n1 1 2\n\nSample Output 3\n\n-1\n\nIt is not allowed to move all stones from the 1-st pile.\n\nSample Input 4\n\n8\n10 9 8 7 6 5 4 3\n\nSample Output 4\n\n3\n\nSample Input 5\n\n3\n4294967297 8589934593 12884901890\n\nSample Output 5\n\n1\n\nWatch out for overflows.", "sample_input": "2\n5 3\n"}, "reference_outputs": ["1\n"], "source_document_id": "p02626", "source_text": "Score : 600 points\n\nProblem Statement\n\nThere are N piles of stones. The i-th pile has A_i stones.\n\nAoki and Takahashi are about to use them to play the following game:\n\nStarting with Aoki, the two players alternately do the following operation:\n\nOperation: Choose one pile of stones, and remove one or more stones from it.\n\nWhen a player is unable to do the operation, he loses, and the other player wins.\n\nWhen the two players play optimally, there are two possibilities in this game: the player who moves first always wins, or the player who moves second always wins, only depending on the initial number of stones in each pile.\n\nIn such a situation, Takahashi, the second player to act, is trying to guarantee his win by moving at least zero and at most (A_1 - 1) stones from the 1-st pile to the 2-nd pile before the game begins.\n\nIf this is possible, print the minimum number of stones to move to guarantee his victory; otherwise, print -1 instead.\n\nConstraints\n\n2 \\leq N \\leq 300\n\n1 \\leq A_i \\leq 10^{12}\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 \\ldots A_N\n\nOutput\n\nPrint the minimum number of stones to move to guarantee Takahashi's win; otherwise, print -1 instead.\n\nSample Input 1\n\n2\n5 3\n\nSample Output 1\n\n1\n\nWithout moving stones, if Aoki first removes 2 stones from the 1-st pile, Takahashi cannot win in any way.\n\nIf Takahashi moves 1 stone from the 1-st pile to the 2-nd before the game begins so that both piles have 4 stones, Takahashi can always win by properly choosing his actions.\n\nSample Input 2\n\n2\n3 5\n\nSample Output 2\n\n-1\n\nIt is not allowed to move stones from the 2-nd pile to the 1-st.\n\nSample Input 3\n\n3\n1 1 2\n\nSample Output 3\n\n-1\n\nIt is not allowed to move all stones from the 1-st pile.\n\nSample Input 4\n\n8\n10 9 8 7 6 5 4 3\n\nSample Output 4\n\n3\n\nSample Input 5\n\n3\n4294967297 8589934593 12884901890\n\nSample Output 5\n\n1\n\nWatch out for overflows.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2408, "cpu_time_ms": 7, "memory_kb": 2748}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s999881246", "group_id": "codeNet:p02627", "input_text": "local s=io.read():byte(1)\nif 97<=s then\n print(\"a\")\nelse\n print(\"A\")\nend", "language": "Lua", "metadata": {"date": 1592884053, "filename_ext": "lua", "original_language": "Lua (Lua 5.3.5)", "problem_description_relpath": "problem_descriptions/p02627.html", "problem_id": "p02627", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02627/input.txt", "sample_output_relpath": "derived/input_output/data/p02627/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02627/Lua/s999881246.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s999881246", "user_id": "u045238009"}, "prompt_components": {"gold_output": "A\n", "input_to_evaluate": "local s=io.read():byte(1)\nif 97<=s then\n print(\"a\")\nelse\n print(\"A\")\nend", "problem_context": "Score : 100 points\n\nProblem Statement\n\nAn uppercase or lowercase English letter \\alpha will be given as input.\nIf \\alpha is uppercase, print A; if it is lowercase, print a.\n\nConstraints\n\n\\alpha is an uppercase (A - Z) or lowercase (a - z) English letter.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nα\n\nOutput\n\nIf \\alpha is uppercase, print A; if it is lowercase, print a.\n\nSample Input 1\n\nB\n\nSample Output 1\n\nA\n\nB is uppercase, so we should print A.\n\nSample Input 2\n\na\n\nSample Output 2\n\na\n\na is lowercase, so we should print a.", "sample_input": "B\n"}, "reference_outputs": ["A\n"], "source_document_id": "p02627", "source_text": "Score : 100 points\n\nProblem Statement\n\nAn uppercase or lowercase English letter \\alpha will be given as input.\nIf \\alpha is uppercase, print A; if it is lowercase, print a.\n\nConstraints\n\n\\alpha is an uppercase (A - Z) or lowercase (a - z) English letter.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nα\n\nOutput\n\nIf \\alpha is uppercase, print A; if it is lowercase, print a.\n\nSample Input 1\n\nB\n\nSample Output 1\n\nA\n\nB is uppercase, so we should print A.\n\nSample Input 2\n\na\n\nSample Output 2\n\na\n\na is lowercase, so we should print a.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 78, "cpu_time_ms": 4, "memory_kb": 2552}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s598101006", "group_id": "codeNet:p02627", "input_text": "s=io.read()\nprint(s==s:lower()and\"a\"or\"A\")", "language": "Lua", "metadata": {"date": 1592787650, "filename_ext": "lua", "original_language": "Lua (LuaJIT 2.1.0)", "problem_description_relpath": "problem_descriptions/p02627.html", "problem_id": "p02627", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02627/input.txt", "sample_output_relpath": "derived/input_output/data/p02627/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02627/Lua/s598101006.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s598101006", "user_id": "u726173718"}, "prompt_components": {"gold_output": "A\n", "input_to_evaluate": "s=io.read()\nprint(s==s:lower()and\"a\"or\"A\")", "problem_context": "Score : 100 points\n\nProblem Statement\n\nAn uppercase or lowercase English letter \\alpha will be given as input.\nIf \\alpha is uppercase, print A; if it is lowercase, print a.\n\nConstraints\n\n\\alpha is an uppercase (A - Z) or lowercase (a - z) English letter.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nα\n\nOutput\n\nIf \\alpha is uppercase, print A; if it is lowercase, print a.\n\nSample Input 1\n\nB\n\nSample Output 1\n\nA\n\nB is uppercase, so we should print A.\n\nSample Input 2\n\na\n\nSample Output 2\n\na\n\na is lowercase, so we should print a.", "sample_input": "B\n"}, "reference_outputs": ["A\n"], "source_document_id": "p02627", "source_text": "Score : 100 points\n\nProblem Statement\n\nAn uppercase or lowercase English letter \\alpha will be given as input.\nIf \\alpha is uppercase, print A; if it is lowercase, print a.\n\nConstraints\n\n\\alpha is an uppercase (A - Z) or lowercase (a - z) English letter.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nα\n\nOutput\n\nIf \\alpha is uppercase, print A; if it is lowercase, print a.\n\nSample Input 1\n\nB\n\nSample Output 1\n\nA\n\nB is uppercase, so we should print A.\n\nSample Input 2\n\na\n\nSample Output 2\n\na\n\na is lowercase, so we should print a.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 42, "cpu_time_ms": 2, "memory_kb": 2568}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s237516433", "group_id": "codeNet:p02629", "input_text": "n = io.read(\"*n\")\nlocal rep = 1\nwhile true do\n local mul = 1\n for i = 1, rep do\n mul = mul * 26\n end\n if n <= mul then\n local z = n - 1\n local s = {}\n for i = 1, rep do\n s[i] = string.char(z % 26 + 97)\n z = z // 26\n end\n print(table.concat(s):reverse())\n break\n else\n n = n - mul\n rep = rep + 1\n end\nend\n", "language": "Lua", "metadata": {"date": 1593351645, "filename_ext": "lua", "original_language": "Lua (Lua 5.3.5)", "problem_description_relpath": "problem_descriptions/p02629.html", "problem_id": "p02629", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02629/input.txt", "sample_output_relpath": "derived/input_output/data/p02629/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02629/Lua/s237516433.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s237516433", "user_id": "u120582723"}, "prompt_components": {"gold_output": "b\n", "input_to_evaluate": "n = io.read(\"*n\")\nlocal rep = 1\nwhile true do\n local mul = 1\n for i = 1, rep do\n mul = mul * 26\n end\n if n <= mul then\n local z = n - 1\n local s = {}\n for i = 1, rep do\n s[i] = string.char(z % 26 + 97)\n z = z // 26\n end\n print(table.concat(s):reverse())\n break\n else\n n = n - mul\n rep = rep + 1\n end\nend\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\n1000000000000001 dogs suddenly appeared under the roof of Roger's house, all of which he decided to keep. The dogs had been numbered 1 through 1000000000000001, but he gave them new names, as follows:\n\nthe dogs numbered 1,2,\\cdots,26 were respectively given the names a, b, ..., z;\n\nthe dogs numbered 27,28,29,\\cdots,701,702 were respectively given the names aa, ab, ac, ..., zy, zz;\n\nthe dogs numbered 703,704,705,\\cdots,18277,18278 were respectively given the names aaa, aab, aac, ..., zzy, zzz;\n\nthe dogs numbered 18279,18280,18281,\\cdots,475253,475254 were respectively given the names aaaa, aaab, aaac, ..., zzzy, zzzz;\n\nthe dogs numbered 475255,475256,\\cdots were respectively given the names aaaaa, aaaab, ...;\n\nand so on.\n\nTo sum it up, the dogs numbered 1, 2, \\cdots were respectively given the following names:\n\na, b, ..., z, aa, ab, ..., az, ba, bb, ..., bz, ..., za, zb, ..., zz, aaa, aab, ..., aaz, aba, abb, ..., abz, ..., zzz, aaaa, ...\n\nNow, Roger asks you:\n\n\"What is the name for the dog numbered N?\"\n\nConstraints\n\nN is an integer.\n\n1 \\leq N \\leq 1000000000000001\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the answer to Roger's question as a string consisting of lowercase English letters.\n\nSample Input 1\n\n2\n\nSample Output 1\n\nb\n\nSample Input 2\n\n27\n\nSample Output 2\n\naa\n\nSample Input 3\n\n123456789\n\nSample Output 3\n\njjddja", "sample_input": "2\n"}, "reference_outputs": ["b\n"], "source_document_id": "p02629", "source_text": "Score : 300 points\n\nProblem Statement\n\n1000000000000001 dogs suddenly appeared under the roof of Roger's house, all of which he decided to keep. The dogs had been numbered 1 through 1000000000000001, but he gave them new names, as follows:\n\nthe dogs numbered 1,2,\\cdots,26 were respectively given the names a, b, ..., z;\n\nthe dogs numbered 27,28,29,\\cdots,701,702 were respectively given the names aa, ab, ac, ..., zy, zz;\n\nthe dogs numbered 703,704,705,\\cdots,18277,18278 were respectively given the names aaa, aab, aac, ..., zzy, zzz;\n\nthe dogs numbered 18279,18280,18281,\\cdots,475253,475254 were respectively given the names aaaa, aaab, aaac, ..., zzzy, zzzz;\n\nthe dogs numbered 475255,475256,\\cdots were respectively given the names aaaaa, aaaab, ...;\n\nand so on.\n\nTo sum it up, the dogs numbered 1, 2, \\cdots were respectively given the following names:\n\na, b, ..., z, aa, ab, ..., az, ba, bb, ..., bz, ..., za, zb, ..., zz, aaa, aab, ..., aaz, aba, abb, ..., abz, ..., zzz, aaaa, ...\n\nNow, Roger asks you:\n\n\"What is the name for the dog numbered N?\"\n\nConstraints\n\nN is an integer.\n\n1 \\leq N \\leq 1000000000000001\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the answer to Roger's question as a string consisting of lowercase English letters.\n\nSample Input 1\n\n2\n\nSample Output 1\n\nb\n\nSample Input 2\n\n27\n\nSample Output 2\n\naa\n\nSample Input 3\n\n123456789\n\nSample Output 3\n\njjddja", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 347, "cpu_time_ms": 7, "memory_kb": 2636}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s901480008", "group_id": "codeNet:p02629", "input_text": "local N = io.read(\"*n\")\nlocal abc = \"abcdefghijklmnopqrstuvwxyz\"\n\nlocal N_to_0_num = N\nlocal str = \"\"\nwhile N_to_0_num > 0 do\n\tlocal index = N_to_0_num%26\n\tstr = str..abc:sub(index, index)\n\tN_to_0_num = N_to_0_num // 26\nend\n\nprint(str:reverse())\n", "language": "Lua", "metadata": {"date": 1592790739, "filename_ext": "lua", "original_language": "Lua (Lua 5.3.5)", "problem_description_relpath": "problem_descriptions/p02629.html", "problem_id": "p02629", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02629/input.txt", "sample_output_relpath": "derived/input_output/data/p02629/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02629/Lua/s901480008.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s901480008", "user_id": "u793881115"}, "prompt_components": {"gold_output": "b\n", "input_to_evaluate": "local N = io.read(\"*n\")\nlocal abc = \"abcdefghijklmnopqrstuvwxyz\"\n\nlocal N_to_0_num = N\nlocal str = \"\"\nwhile N_to_0_num > 0 do\n\tlocal index = N_to_0_num%26\n\tstr = str..abc:sub(index, index)\n\tN_to_0_num = N_to_0_num // 26\nend\n\nprint(str:reverse())\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\n1000000000000001 dogs suddenly appeared under the roof of Roger's house, all of which he decided to keep. The dogs had been numbered 1 through 1000000000000001, but he gave them new names, as follows:\n\nthe dogs numbered 1,2,\\cdots,26 were respectively given the names a, b, ..., z;\n\nthe dogs numbered 27,28,29,\\cdots,701,702 were respectively given the names aa, ab, ac, ..., zy, zz;\n\nthe dogs numbered 703,704,705,\\cdots,18277,18278 were respectively given the names aaa, aab, aac, ..., zzy, zzz;\n\nthe dogs numbered 18279,18280,18281,\\cdots,475253,475254 were respectively given the names aaaa, aaab, aaac, ..., zzzy, zzzz;\n\nthe dogs numbered 475255,475256,\\cdots were respectively given the names aaaaa, aaaab, ...;\n\nand so on.\n\nTo sum it up, the dogs numbered 1, 2, \\cdots were respectively given the following names:\n\na, b, ..., z, aa, ab, ..., az, ba, bb, ..., bz, ..., za, zb, ..., zz, aaa, aab, ..., aaz, aba, abb, ..., abz, ..., zzz, aaaa, ...\n\nNow, Roger asks you:\n\n\"What is the name for the dog numbered N?\"\n\nConstraints\n\nN is an integer.\n\n1 \\leq N \\leq 1000000000000001\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the answer to Roger's question as a string consisting of lowercase English letters.\n\nSample Input 1\n\n2\n\nSample Output 1\n\nb\n\nSample Input 2\n\n27\n\nSample Output 2\n\naa\n\nSample Input 3\n\n123456789\n\nSample Output 3\n\njjddja", "sample_input": "2\n"}, "reference_outputs": ["b\n"], "source_document_id": "p02629", "source_text": "Score : 300 points\n\nProblem Statement\n\n1000000000000001 dogs suddenly appeared under the roof of Roger's house, all of which he decided to keep. The dogs had been numbered 1 through 1000000000000001, but he gave them new names, as follows:\n\nthe dogs numbered 1,2,\\cdots,26 were respectively given the names a, b, ..., z;\n\nthe dogs numbered 27,28,29,\\cdots,701,702 were respectively given the names aa, ab, ac, ..., zy, zz;\n\nthe dogs numbered 703,704,705,\\cdots,18277,18278 were respectively given the names aaa, aab, aac, ..., zzy, zzz;\n\nthe dogs numbered 18279,18280,18281,\\cdots,475253,475254 were respectively given the names aaaa, aaab, aaac, ..., zzzy, zzzz;\n\nthe dogs numbered 475255,475256,\\cdots were respectively given the names aaaaa, aaaab, ...;\n\nand so on.\n\nTo sum it up, the dogs numbered 1, 2, \\cdots were respectively given the following names:\n\na, b, ..., z, aa, ab, ..., az, ba, bb, ..., bz, ..., za, zb, ..., zz, aaa, aab, ..., aaz, aba, abb, ..., abz, ..., zzz, aaaa, ...\n\nNow, Roger asks you:\n\n\"What is the name for the dog numbered N?\"\n\nConstraints\n\nN is an integer.\n\n1 \\leq N \\leq 1000000000000001\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the answer to Roger's question as a string consisting of lowercase English letters.\n\nSample Input 1\n\n2\n\nSample Output 1\n\nb\n\nSample Input 2\n\n27\n\nSample Output 2\n\naa\n\nSample Input 3\n\n123456789\n\nSample Output 3\n\njjddja", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 246, "cpu_time_ms": 6, "memory_kb": 2640}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s580997650", "group_id": "codeNet:p02630", "input_text": "N=io.read\"*n\"\nt={}\nfor i=1,N do\n\tn=io.read\"*n\"\n\tt[n]=(t[n]or 0)+1\nend\nQ=io.read\"*n\"\n \nfor i=1,Q do\n\tB=io.read\"*n\"\n\tC=io.read\"*n\"\n\t\n\tt[C]=(t[C]or 0)+(t[B]or 0)\n\tt[B]=nil\n\t\n\ts=0\n\tfor k,v in pairs(t)do\n\t\ts=s+k*v\n\tend\n\tprint(s)\n \nend", "language": "Lua", "metadata": {"date": 1592788662, "filename_ext": "lua", "original_language": "Lua (LuaJIT 2.1.0)", "problem_description_relpath": "problem_descriptions/p02630.html", "problem_id": "p02630", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02630/input.txt", "sample_output_relpath": "derived/input_output/data/p02630/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02630/Lua/s580997650.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s580997650", "user_id": "u726173718"}, "prompt_components": {"gold_output": "11\n12\n16\n", "input_to_evaluate": "N=io.read\"*n\"\nt={}\nfor i=1,N do\n\tn=io.read\"*n\"\n\tt[n]=(t[n]or 0)+1\nend\nQ=io.read\"*n\"\n \nfor i=1,Q do\n\tB=io.read\"*n\"\n\tC=io.read\"*n\"\n\t\n\tt[C]=(t[C]or 0)+(t[B]or 0)\n\tt[B]=nil\n\t\n\ts=0\n\tfor k,v in pairs(t)do\n\t\ts=s+k*v\n\tend\n\tprint(s)\n \nend", "problem_context": "Score : 400 points\n\nProblem Statement\n\nYou have a sequence A composed of N positive integers: A_{1}, A_{2}, \\cdots, A_{N}.\n\nYou will now successively do the following Q operations:\n\nIn the i-th operation, you replace every element whose value is B_{i} with C_{i}.\n\nFor each i (1 \\leq i \\leq Q), find S_{i}: the sum of all elements in A just after the i-th operation.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N, Q, A_{i}, B_{i}, C_{i} \\leq 10^{5}\n\nB_{i} \\neq C_{i}\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_{1} A_{2} \\cdots A_{N}\nQ\nB_{1} C_{1}\nB_{2} C_{2}\n\\vdots\nB_{Q} C_{Q}\n\nOutput\n\nPrint Q integers S_{i} to Standard Output in the following format:\n\nS_{1}\nS_{2}\n\\vdots\nS_{Q}\n\nNote that S_{i} may not fit into a 32-bit integer.\n\nSample Input 1\n\n4\n1 2 3 4\n3\n1 2\n3 4\n2 4\n\nSample Output 1\n\n11\n12\n16\n\nInitially, the sequence A is 1,2,3,4.\n\nAfter each operation, it becomes the following:\n\n2, 2, 3, 4\n\n2, 2, 4, 4\n\n4, 4, 4, 4\n\nSample Input 2\n\n4\n1 1 1 1\n3\n1 2\n2 1\n3 5\n\nSample Output 2\n\n8\n4\n4\n\nNote that the sequence A may not contain an element whose value is B_{i}.\n\nSample Input 3\n\n2\n1 2\n3\n1 100\n2 100\n100 1000\n\nSample Output 3\n\n102\n200\n2000", "sample_input": "4\n1 2 3 4\n3\n1 2\n3 4\n2 4\n"}, "reference_outputs": ["11\n12\n16\n"], "source_document_id": "p02630", "source_text": "Score : 400 points\n\nProblem Statement\n\nYou have a sequence A composed of N positive integers: A_{1}, A_{2}, \\cdots, A_{N}.\n\nYou will now successively do the following Q operations:\n\nIn the i-th operation, you replace every element whose value is B_{i} with C_{i}.\n\nFor each i (1 \\leq i \\leq Q), find S_{i}: the sum of all elements in A just after the i-th operation.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N, Q, A_{i}, B_{i}, C_{i} \\leq 10^{5}\n\nB_{i} \\neq C_{i}\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_{1} A_{2} \\cdots A_{N}\nQ\nB_{1} C_{1}\nB_{2} C_{2}\n\\vdots\nB_{Q} C_{Q}\n\nOutput\n\nPrint Q integers S_{i} to Standard Output in the following format:\n\nS_{1}\nS_{2}\n\\vdots\nS_{Q}\n\nNote that S_{i} may not fit into a 32-bit integer.\n\nSample Input 1\n\n4\n1 2 3 4\n3\n1 2\n3 4\n2 4\n\nSample Output 1\n\n11\n12\n16\n\nInitially, the sequence A is 1,2,3,4.\n\nAfter each operation, it becomes the following:\n\n2, 2, 3, 4\n\n2, 2, 4, 4\n\n4, 4, 4, 4\n\nSample Input 2\n\n4\n1 1 1 1\n3\n1 2\n2 1\n3 5\n\nSample Output 2\n\n8\n4\n4\n\nNote that the sequence A may not contain an element whose value is B_{i}.\n\nSample Input 3\n\n2\n1 2\n3\n1 100\n2 100\n100 1000\n\nSample Output 3\n\n102\n200\n2000", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 229, "cpu_time_ms": 2205, "memory_kb": 4388}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s096387786", "group_id": "codeNet:p02630", "input_text": "N=io.read\"*n\"\nt={}\nfor i=1,N do\n\tn=io.read\"*n\"\n\tt[n]=(t[n]or 0)+1\nend\nQ=io.read\"*n\"\n\nfor i=1,Q do\n\tB=io.read\"*n\"\n\tC=io.read\"*n\"\n\t\n\tt[C]=(t[C]or 0)+(t[B]or 0)\n\t\t\n\tt[B]=0\n\t\n\ts=0\n\tfor k,v in pairs(t)do\n\t\ts=s+k*v\n\tend\n\tprint(s)\n\nend", "language": "Lua", "metadata": {"date": 1592788499, "filename_ext": "lua", "original_language": "Lua (Lua 5.3.5)", "problem_description_relpath": "problem_descriptions/p02630.html", "problem_id": "p02630", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02630/input.txt", "sample_output_relpath": "derived/input_output/data/p02630/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02630/Lua/s096387786.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s096387786", "user_id": "u726173718"}, "prompt_components": {"gold_output": "11\n12\n16\n", "input_to_evaluate": "N=io.read\"*n\"\nt={}\nfor i=1,N do\n\tn=io.read\"*n\"\n\tt[n]=(t[n]or 0)+1\nend\nQ=io.read\"*n\"\n\nfor i=1,Q do\n\tB=io.read\"*n\"\n\tC=io.read\"*n\"\n\t\n\tt[C]=(t[C]or 0)+(t[B]or 0)\n\t\t\n\tt[B]=0\n\t\n\ts=0\n\tfor k,v in pairs(t)do\n\t\ts=s+k*v\n\tend\n\tprint(s)\n\nend", "problem_context": "Score : 400 points\n\nProblem Statement\n\nYou have a sequence A composed of N positive integers: A_{1}, A_{2}, \\cdots, A_{N}.\n\nYou will now successively do the following Q operations:\n\nIn the i-th operation, you replace every element whose value is B_{i} with C_{i}.\n\nFor each i (1 \\leq i \\leq Q), find S_{i}: the sum of all elements in A just after the i-th operation.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N, Q, A_{i}, B_{i}, C_{i} \\leq 10^{5}\n\nB_{i} \\neq C_{i}\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_{1} A_{2} \\cdots A_{N}\nQ\nB_{1} C_{1}\nB_{2} C_{2}\n\\vdots\nB_{Q} C_{Q}\n\nOutput\n\nPrint Q integers S_{i} to Standard Output in the following format:\n\nS_{1}\nS_{2}\n\\vdots\nS_{Q}\n\nNote that S_{i} may not fit into a 32-bit integer.\n\nSample Input 1\n\n4\n1 2 3 4\n3\n1 2\n3 4\n2 4\n\nSample Output 1\n\n11\n12\n16\n\nInitially, the sequence A is 1,2,3,4.\n\nAfter each operation, it becomes the following:\n\n2, 2, 3, 4\n\n2, 2, 4, 4\n\n4, 4, 4, 4\n\nSample Input 2\n\n4\n1 1 1 1\n3\n1 2\n2 1\n3 5\n\nSample Output 2\n\n8\n4\n4\n\nNote that the sequence A may not contain an element whose value is B_{i}.\n\nSample Input 3\n\n2\n1 2\n3\n1 100\n2 100\n100 1000\n\nSample Output 3\n\n102\n200\n2000", "sample_input": "4\n1 2 3 4\n3\n1 2\n3 4\n2 4\n"}, "reference_outputs": ["11\n12\n16\n"], "source_document_id": "p02630", "source_text": "Score : 400 points\n\nProblem Statement\n\nYou have a sequence A composed of N positive integers: A_{1}, A_{2}, \\cdots, A_{N}.\n\nYou will now successively do the following Q operations:\n\nIn the i-th operation, you replace every element whose value is B_{i} with C_{i}.\n\nFor each i (1 \\leq i \\leq Q), find S_{i}: the sum of all elements in A just after the i-th operation.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N, Q, A_{i}, B_{i}, C_{i} \\leq 10^{5}\n\nB_{i} \\neq C_{i}\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_{1} A_{2} \\cdots A_{N}\nQ\nB_{1} C_{1}\nB_{2} C_{2}\n\\vdots\nB_{Q} C_{Q}\n\nOutput\n\nPrint Q integers S_{i} to Standard Output in the following format:\n\nS_{1}\nS_{2}\n\\vdots\nS_{Q}\n\nNote that S_{i} may not fit into a 32-bit integer.\n\nSample Input 1\n\n4\n1 2 3 4\n3\n1 2\n3 4\n2 4\n\nSample Output 1\n\n11\n12\n16\n\nInitially, the sequence A is 1,2,3,4.\n\nAfter each operation, it becomes the following:\n\n2, 2, 3, 4\n\n2, 2, 4, 4\n\n4, 4, 4, 4\n\nSample Input 2\n\n4\n1 1 1 1\n3\n1 2\n2 1\n3 5\n\nSample Output 2\n\n8\n4\n4\n\nNote that the sequence A may not contain an element whose value is B_{i}.\n\nSample Input 3\n\n2\n1 2\n3\n1 100\n2 100\n100 1000\n\nSample Output 3\n\n102\n200\n2000", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 228, "cpu_time_ms": 2205, "memory_kb": 5264}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s434873453", "group_id": "codeNet:p02631", "input_text": "local n = io.read(\"*n\")\nlocal t = {}\nlocal z = 0\nfor i = 1, n do\n t[i] = io.read(\"*n\")\n z = z ~ t[i]\nend\nlocal r = {}\nfor i = 1, n do\n r[i] = z ~ t[i]\nend\nprint(table.concat(r, \" \"))\n", "language": "Lua", "metadata": {"date": 1592794673, "filename_ext": "lua", "original_language": "Lua (Lua 5.3.5)", "problem_description_relpath": "problem_descriptions/p02631.html", "problem_id": "p02631", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02631/input.txt", "sample_output_relpath": "derived/input_output/data/p02631/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02631/Lua/s434873453.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s434873453", "user_id": "u120582723"}, "prompt_components": {"gold_output": "26 5 7 22\n", "input_to_evaluate": "local n = io.read(\"*n\")\nlocal t = {}\nlocal z = 0\nfor i = 1, n do\n t[i] = io.read(\"*n\")\n z = z ~ t[i]\nend\nlocal r = {}\nfor i = 1, n do\n r[i] = z ~ t[i]\nend\nprint(table.concat(r, \" \"))\n", "problem_context": "Score : 500 points\n\nProblem Statement\n\nThere are N Snuke Cats numbered 1, 2, \\ldots, N, where N is even.\n\nEach Snuke Cat wears a red scarf, on which his favorite non-negative integer is written.\n\nRecently, they learned the operation called xor (exclusive OR).\n\nWhat is xor?\n\nFor n non-negative integers x_1, x_2, \\ldots, x_n, their xor, x_1~\\textrm{xor}~x_2~\\textrm{xor}~\\ldots~\\textrm{xor}~x_n is defined as follows:\n\nWhen x_1~\\textrm{xor}~x_2~\\textrm{xor}~\\ldots~\\textrm{xor}~x_n is written in base two, the digit in the 2^k's place (k \\geq 0) is 1 if the number of integers among x_1, x_2, \\ldots, x_n whose binary representations have 1 in the 2^k's place is odd, and 0 if that count is even.\n\nFor example, 3~\\textrm{xor}~5 = 6.\n\nThey wanted to use this operation quickly, so each of them calculated the xor of the integers written on their scarfs except his scarf.\n\nWe know that the xor calculated by Snuke Cat i, that is, the xor of the integers written on the scarfs except the scarf of Snuke Cat i is a_i.\nUsing this information, restore the integer written on the scarf of each Snuke Cat.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 200000\n\nN is even.\n\n0 \\leq a_i \\leq 10^9\n\nThere exists a combination of integers on the scarfs that is consistent with the given information.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 \\ldots a_N\n\nOutput\n\nPrint a line containing N integers separated with space.\n\nThe i-th of the integers from the left should represent the integer written on the scarf of Snuke Cat i.\n\nIf there are multiple possible solutions, you may print any of them.\n\nSample Input 1\n\n4\n20 11 9 24\n\nSample Output 1\n\n26 5 7 22\n\n5~\\textrm{xor}~7~\\textrm{xor}~22 = 20\n\n26~\\textrm{xor}~7~\\textrm{xor}~22 = 11\n\n26~\\textrm{xor}~5~\\textrm{xor}~22 = 9\n\n26~\\textrm{xor}~5~\\textrm{xor}~7 = 24\n\nThus, this output is consistent with the given information.", "sample_input": "4\n20 11 9 24\n"}, "reference_outputs": ["26 5 7 22\n"], "source_document_id": "p02631", "source_text": "Score : 500 points\n\nProblem Statement\n\nThere are N Snuke Cats numbered 1, 2, \\ldots, N, where N is even.\n\nEach Snuke Cat wears a red scarf, on which his favorite non-negative integer is written.\n\nRecently, they learned the operation called xor (exclusive OR).\n\nWhat is xor?\n\nFor n non-negative integers x_1, x_2, \\ldots, x_n, their xor, x_1~\\textrm{xor}~x_2~\\textrm{xor}~\\ldots~\\textrm{xor}~x_n is defined as follows:\n\nWhen x_1~\\textrm{xor}~x_2~\\textrm{xor}~\\ldots~\\textrm{xor}~x_n is written in base two, the digit in the 2^k's place (k \\geq 0) is 1 if the number of integers among x_1, x_2, \\ldots, x_n whose binary representations have 1 in the 2^k's place is odd, and 0 if that count is even.\n\nFor example, 3~\\textrm{xor}~5 = 6.\n\nThey wanted to use this operation quickly, so each of them calculated the xor of the integers written on their scarfs except his scarf.\n\nWe know that the xor calculated by Snuke Cat i, that is, the xor of the integers written on the scarfs except the scarf of Snuke Cat i is a_i.\nUsing this information, restore the integer written on the scarf of each Snuke Cat.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 200000\n\nN is even.\n\n0 \\leq a_i \\leq 10^9\n\nThere exists a combination of integers on the scarfs that is consistent with the given information.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 \\ldots a_N\n\nOutput\n\nPrint a line containing N integers separated with space.\n\nThe i-th of the integers from the left should represent the integer written on the scarf of Snuke Cat i.\n\nIf there are multiple possible solutions, you may print any of them.\n\nSample Input 1\n\n4\n20 11 9 24\n\nSample Output 1\n\n26 5 7 22\n\n5~\\textrm{xor}~7~\\textrm{xor}~22 = 20\n\n26~\\textrm{xor}~7~\\textrm{xor}~22 = 11\n\n26~\\textrm{xor}~5~\\textrm{xor}~22 = 9\n\n26~\\textrm{xor}~5~\\textrm{xor}~7 = 24\n\nThus, this output is consistent with the given information.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 186, "cpu_time_ms": 125, "memory_kb": 25476}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s254924875", "group_id": "codeNet:p02631", "input_text": "local xor = bit.bxor\nlocal n = io.read(\"*n\")\nlocal t = {}\nlocal z = 0\nfor i = 1, n do\n t[i] = io.read(\"*n\")\n z = xor(z, t[i])\nend\nlocal r = {}\nfor i = 1, n do\n r[i] = xor(z, t[i])\nend\nprint(table.concat(r, \" \"))\n", "language": "Lua", "metadata": {"date": 1592794633, "filename_ext": "lua", "original_language": "Lua (LuaJIT 2.1.0)", "problem_description_relpath": "problem_descriptions/p02631.html", "problem_id": "p02631", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02631/input.txt", "sample_output_relpath": "derived/input_output/data/p02631/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02631/Lua/s254924875.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s254924875", "user_id": "u120582723"}, "prompt_components": {"gold_output": "26 5 7 22\n", "input_to_evaluate": "local xor = bit.bxor\nlocal n = io.read(\"*n\")\nlocal t = {}\nlocal z = 0\nfor i = 1, n do\n t[i] = io.read(\"*n\")\n z = xor(z, t[i])\nend\nlocal r = {}\nfor i = 1, n do\n r[i] = xor(z, t[i])\nend\nprint(table.concat(r, \" \"))\n", "problem_context": "Score : 500 points\n\nProblem Statement\n\nThere are N Snuke Cats numbered 1, 2, \\ldots, N, where N is even.\n\nEach Snuke Cat wears a red scarf, on which his favorite non-negative integer is written.\n\nRecently, they learned the operation called xor (exclusive OR).\n\nWhat is xor?\n\nFor n non-negative integers x_1, x_2, \\ldots, x_n, their xor, x_1~\\textrm{xor}~x_2~\\textrm{xor}~\\ldots~\\textrm{xor}~x_n is defined as follows:\n\nWhen x_1~\\textrm{xor}~x_2~\\textrm{xor}~\\ldots~\\textrm{xor}~x_n is written in base two, the digit in the 2^k's place (k \\geq 0) is 1 if the number of integers among x_1, x_2, \\ldots, x_n whose binary representations have 1 in the 2^k's place is odd, and 0 if that count is even.\n\nFor example, 3~\\textrm{xor}~5 = 6.\n\nThey wanted to use this operation quickly, so each of them calculated the xor of the integers written on their scarfs except his scarf.\n\nWe know that the xor calculated by Snuke Cat i, that is, the xor of the integers written on the scarfs except the scarf of Snuke Cat i is a_i.\nUsing this information, restore the integer written on the scarf of each Snuke Cat.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 200000\n\nN is even.\n\n0 \\leq a_i \\leq 10^9\n\nThere exists a combination of integers on the scarfs that is consistent with the given information.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 \\ldots a_N\n\nOutput\n\nPrint a line containing N integers separated with space.\n\nThe i-th of the integers from the left should represent the integer written on the scarf of Snuke Cat i.\n\nIf there are multiple possible solutions, you may print any of them.\n\nSample Input 1\n\n4\n20 11 9 24\n\nSample Output 1\n\n26 5 7 22\n\n5~\\textrm{xor}~7~\\textrm{xor}~22 = 20\n\n26~\\textrm{xor}~7~\\textrm{xor}~22 = 11\n\n26~\\textrm{xor}~5~\\textrm{xor}~22 = 9\n\n26~\\textrm{xor}~5~\\textrm{xor}~7 = 24\n\nThus, this output is consistent with the given information.", "sample_input": "4\n20 11 9 24\n"}, "reference_outputs": ["26 5 7 22\n"], "source_document_id": "p02631", "source_text": "Score : 500 points\n\nProblem Statement\n\nThere are N Snuke Cats numbered 1, 2, \\ldots, N, where N is even.\n\nEach Snuke Cat wears a red scarf, on which his favorite non-negative integer is written.\n\nRecently, they learned the operation called xor (exclusive OR).\n\nWhat is xor?\n\nFor n non-negative integers x_1, x_2, \\ldots, x_n, their xor, x_1~\\textrm{xor}~x_2~\\textrm{xor}~\\ldots~\\textrm{xor}~x_n is defined as follows:\n\nWhen x_1~\\textrm{xor}~x_2~\\textrm{xor}~\\ldots~\\textrm{xor}~x_n is written in base two, the digit in the 2^k's place (k \\geq 0) is 1 if the number of integers among x_1, x_2, \\ldots, x_n whose binary representations have 1 in the 2^k's place is odd, and 0 if that count is even.\n\nFor example, 3~\\textrm{xor}~5 = 6.\n\nThey wanted to use this operation quickly, so each of them calculated the xor of the integers written on their scarfs except his scarf.\n\nWe know that the xor calculated by Snuke Cat i, that is, the xor of the integers written on the scarfs except the scarf of Snuke Cat i is a_i.\nUsing this information, restore the integer written on the scarf of each Snuke Cat.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 200000\n\nN is even.\n\n0 \\leq a_i \\leq 10^9\n\nThere exists a combination of integers on the scarfs that is consistent with the given information.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 \\ldots a_N\n\nOutput\n\nPrint a line containing N integers separated with space.\n\nThe i-th of the integers from the left should represent the integer written on the scarf of Snuke Cat i.\n\nIf there are multiple possible solutions, you may print any of them.\n\nSample Input 1\n\n4\n20 11 9 24\n\nSample Output 1\n\n26 5 7 22\n\n5~\\textrm{xor}~7~\\textrm{xor}~22 = 20\n\n26~\\textrm{xor}~7~\\textrm{xor}~22 = 11\n\n26~\\textrm{xor}~5~\\textrm{xor}~22 = 9\n\n26~\\textrm{xor}~5~\\textrm{xor}~7 = 24\n\nThus, this output is consistent with the given information.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 215, "cpu_time_ms": 65, "memory_kb": 11156}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s231222903", "group_id": "codeNet:p02631", "input_text": "local bit=require\"bit\"\nlocal function reada(n,m)m=m or 1 r={}for i=1,m do r[i]={}end for i=1,n do for j=1,m do r[j][i]=io.read\"*n\"end end return unpack(r)end \nN=io.read\"*n\"\na=reada(N)\ns=0\nfor i=1,N do\n\ts=bit.bxor(a[i],s)\nend\nfor i=1,N do\n\tprint(bit.bxor(a[i],s))\nend", "language": "Lua", "metadata": {"date": 1592789147, "filename_ext": "lua", "original_language": "Lua (LuaJIT 2.1.0)", "problem_description_relpath": "problem_descriptions/p02631.html", "problem_id": "p02631", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02631/input.txt", "sample_output_relpath": "derived/input_output/data/p02631/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02631/Lua/s231222903.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s231222903", "user_id": "u726173718"}, "prompt_components": {"gold_output": "26 5 7 22\n", "input_to_evaluate": "local bit=require\"bit\"\nlocal function reada(n,m)m=m or 1 r={}for i=1,m do r[i]={}end for i=1,n do for j=1,m do r[j][i]=io.read\"*n\"end end return unpack(r)end \nN=io.read\"*n\"\na=reada(N)\ns=0\nfor i=1,N do\n\ts=bit.bxor(a[i],s)\nend\nfor i=1,N do\n\tprint(bit.bxor(a[i],s))\nend", "problem_context": "Score : 500 points\n\nProblem Statement\n\nThere are N Snuke Cats numbered 1, 2, \\ldots, N, where N is even.\n\nEach Snuke Cat wears a red scarf, on which his favorite non-negative integer is written.\n\nRecently, they learned the operation called xor (exclusive OR).\n\nWhat is xor?\n\nFor n non-negative integers x_1, x_2, \\ldots, x_n, their xor, x_1~\\textrm{xor}~x_2~\\textrm{xor}~\\ldots~\\textrm{xor}~x_n is defined as follows:\n\nWhen x_1~\\textrm{xor}~x_2~\\textrm{xor}~\\ldots~\\textrm{xor}~x_n is written in base two, the digit in the 2^k's place (k \\geq 0) is 1 if the number of integers among x_1, x_2, \\ldots, x_n whose binary representations have 1 in the 2^k's place is odd, and 0 if that count is even.\n\nFor example, 3~\\textrm{xor}~5 = 6.\n\nThey wanted to use this operation quickly, so each of them calculated the xor of the integers written on their scarfs except his scarf.\n\nWe know that the xor calculated by Snuke Cat i, that is, the xor of the integers written on the scarfs except the scarf of Snuke Cat i is a_i.\nUsing this information, restore the integer written on the scarf of each Snuke Cat.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 200000\n\nN is even.\n\n0 \\leq a_i \\leq 10^9\n\nThere exists a combination of integers on the scarfs that is consistent with the given information.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 \\ldots a_N\n\nOutput\n\nPrint a line containing N integers separated with space.\n\nThe i-th of the integers from the left should represent the integer written on the scarf of Snuke Cat i.\n\nIf there are multiple possible solutions, you may print any of them.\n\nSample Input 1\n\n4\n20 11 9 24\n\nSample Output 1\n\n26 5 7 22\n\n5~\\textrm{xor}~7~\\textrm{xor}~22 = 20\n\n26~\\textrm{xor}~7~\\textrm{xor}~22 = 11\n\n26~\\textrm{xor}~5~\\textrm{xor}~22 = 9\n\n26~\\textrm{xor}~5~\\textrm{xor}~7 = 24\n\nThus, this output is consistent with the given information.", "sample_input": "4\n20 11 9 24\n"}, "reference_outputs": ["26 5 7 22\n"], "source_document_id": "p02631", "source_text": "Score : 500 points\n\nProblem Statement\n\nThere are N Snuke Cats numbered 1, 2, \\ldots, N, where N is even.\n\nEach Snuke Cat wears a red scarf, on which his favorite non-negative integer is written.\n\nRecently, they learned the operation called xor (exclusive OR).\n\nWhat is xor?\n\nFor n non-negative integers x_1, x_2, \\ldots, x_n, their xor, x_1~\\textrm{xor}~x_2~\\textrm{xor}~\\ldots~\\textrm{xor}~x_n is defined as follows:\n\nWhen x_1~\\textrm{xor}~x_2~\\textrm{xor}~\\ldots~\\textrm{xor}~x_n is written in base two, the digit in the 2^k's place (k \\geq 0) is 1 if the number of integers among x_1, x_2, \\ldots, x_n whose binary representations have 1 in the 2^k's place is odd, and 0 if that count is even.\n\nFor example, 3~\\textrm{xor}~5 = 6.\n\nThey wanted to use this operation quickly, so each of them calculated the xor of the integers written on their scarfs except his scarf.\n\nWe know that the xor calculated by Snuke Cat i, that is, the xor of the integers written on the scarfs except the scarf of Snuke Cat i is a_i.\nUsing this information, restore the integer written on the scarf of each Snuke Cat.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 200000\n\nN is even.\n\n0 \\leq a_i \\leq 10^9\n\nThere exists a combination of integers on the scarfs that is consistent with the given information.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 \\ldots a_N\n\nOutput\n\nPrint a line containing N integers separated with space.\n\nThe i-th of the integers from the left should represent the integer written on the scarf of Snuke Cat i.\n\nIf there are multiple possible solutions, you may print any of them.\n\nSample Input 1\n\n4\n20 11 9 24\n\nSample Output 1\n\n26 5 7 22\n\n5~\\textrm{xor}~7~\\textrm{xor}~22 = 20\n\n26~\\textrm{xor}~7~\\textrm{xor}~22 = 11\n\n26~\\textrm{xor}~5~\\textrm{xor}~22 = 9\n\n26~\\textrm{xor}~5~\\textrm{xor}~7 = 24\n\nThus, this output is consistent with the given information.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 266, "cpu_time_ms": 78, "memory_kb": 4744}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s153427012", "group_id": "codeNet:p02632", "input_text": "local mod = 1000000007\nlocal mfl = math.floor\n\nlocal function bmul(x, y)\n return (x * y) % mod\nend\n\nlocal function badd(x, y)\n return (x + y) % mod\nend\n\nlocal fact = {1}\nlocal invs = {1}\nlocal invfact = {1}\nfor i = 2, 2000000 do\n fact[i] = bmul(fact[i - 1], i)\n invs[i] = bmul(mfl(mod / i), mod - invs[mod % i])\n invfact[i] = bmul(invfact[i - 1], invs[i])\nend\n\nlocal function getCombQ(n, k)\n if k == 0 or k == n then return 1 end\n return bmul(fact[n], bmul(invfact[k], invfact[n - k]))\nend\n\nlocal pow25 = {1}\nlocal pow26 = {1}\nfor i = 2, 1000010 do\n pow25[i] = bmul(pow25[i - 1], 25)\n pow26[i] = bmul(pow26[i - 1], 26)\nend\n\nlocal k = io.read(\"*n\", \"*l\")\nlocal s = io.read()\nlocal n = #s\nlocal ret = 0\nfor j = 0, k do\n local z = getCombQ(n + j - 1, n - 1)\n z = bmul(z, pow25[j + 1])\n local rem = k - j\n z = bmul(z, pow26[rem + 1])\n ret = badd(ret, z)\nend\nprint(ret)\n", "language": "Lua", "metadata": {"date": 1592798435, "filename_ext": "lua", "original_language": "Lua (LuaJIT 2.1.0)", "problem_description_relpath": "problem_descriptions/p02632.html", "problem_id": "p02632", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02632/input.txt", "sample_output_relpath": "derived/input_output/data/p02632/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02632/Lua/s153427012.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s153427012", "user_id": "u120582723"}, "prompt_components": {"gold_output": "575111451\n", "input_to_evaluate": "local mod = 1000000007\nlocal mfl = math.floor\n\nlocal function bmul(x, y)\n return (x * y) % mod\nend\n\nlocal function badd(x, y)\n return (x + y) % mod\nend\n\nlocal fact = {1}\nlocal invs = {1}\nlocal invfact = {1}\nfor i = 2, 2000000 do\n fact[i] = bmul(fact[i - 1], i)\n invs[i] = bmul(mfl(mod / i), mod - invs[mod % i])\n invfact[i] = bmul(invfact[i - 1], invs[i])\nend\n\nlocal function getCombQ(n, k)\n if k == 0 or k == n then return 1 end\n return bmul(fact[n], bmul(invfact[k], invfact[n - k]))\nend\n\nlocal pow25 = {1}\nlocal pow26 = {1}\nfor i = 2, 1000010 do\n pow25[i] = bmul(pow25[i - 1], 25)\n pow26[i] = bmul(pow26[i - 1], 26)\nend\n\nlocal k = io.read(\"*n\", \"*l\")\nlocal s = io.read()\nlocal n = #s\nlocal ret = 0\nfor j = 0, k do\n local z = getCombQ(n + j - 1, n - 1)\n z = bmul(z, pow25[j + 1])\n local rem = k - j\n z = bmul(z, pow26[rem + 1])\n ret = badd(ret, z)\nend\nprint(ret)\n", "problem_context": "Score: 600 points\n\nProblem Statement\n\nHow many strings can be obtained by applying the following operation on a string S exactly K times: \"choose one lowercase English letter and insert it somewhere\"?\n\nThe answer can be enormous, so print it modulo (10^9+7).\n\nConstraints\n\nK is an integer between 1 and 10^6 (inclusive).\n\nS is a string of length between 1 and 10^6 (inclusive) consisting of lowercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nK\nS\n\nOutput\n\nPrint the number of strings satisfying the condition, modulo (10^9+7).\n\nSample Input 1\n\n5\noof\n\nSample Output 1\n\n575111451\n\nFor example, we can obtain proofend, moonwolf, and onionpuf, while we cannot obtain oofsix, oofelevennn, voxafolt, or fooooooo.\n\nSample Input 2\n\n37564\nwhydidyoudesertme\n\nSample Output 2\n\n318008117", "sample_input": "5\noof\n"}, "reference_outputs": ["575111451\n"], "source_document_id": "p02632", "source_text": "Score: 600 points\n\nProblem Statement\n\nHow many strings can be obtained by applying the following operation on a string S exactly K times: \"choose one lowercase English letter and insert it somewhere\"?\n\nThe answer can be enormous, so print it modulo (10^9+7).\n\nConstraints\n\nK is an integer between 1 and 10^6 (inclusive).\n\nS is a string of length between 1 and 10^6 (inclusive) consisting of lowercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nK\nS\n\nOutput\n\nPrint the number of strings satisfying the condition, modulo (10^9+7).\n\nSample Input 1\n\n5\noof\n\nSample Output 1\n\n575111451\n\nFor example, we can obtain proofend, moonwolf, and onionpuf, while we cannot obtain oofsix, oofelevennn, voxafolt, or fooooooo.\n\nSample Input 2\n\n37564\nwhydidyoudesertme\n\nSample Output 2\n\n318008117", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 879, "cpu_time_ms": 175, "memory_kb": 70364}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s218771628", "group_id": "codeNet:p02639", "input_text": "local x = {io.read(\"*n\", \"*n\", \"*n\", \"*n\", \"*n\")}\n\nfor i = 1, 5 do\n\tif x[i] == 0 then\n\t\tprint(i)\n\tend\nend\n", "language": "Lua", "metadata": {"date": 1592183053, "filename_ext": "lua", "original_language": "Lua (LuaJIT 2.1.0)", "problem_description_relpath": "problem_descriptions/p02639.html", "problem_id": "p02639", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02639/input.txt", "sample_output_relpath": "derived/input_output/data/p02639/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02639/Lua/s218771628.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s218771628", "user_id": "u793881115"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "local x = {io.read(\"*n\", \"*n\", \"*n\", \"*n\", \"*n\")}\n\nfor i = 1, 5 do\n\tif x[i] == 0 then\n\t\tprint(i)\n\tend\nend\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nWe have five variables x_1, x_2, x_3, x_4, and x_5.\n\nThe variable x_i was initially assigned a value of i.\n\nSnuke chose one of these variables and assigned it 0.\n\nYou are given the values of the five variables after this assignment.\n\nFind out which variable Snuke assigned 0.\n\nConstraints\n\nThe values of x_1, x_2, x_3, x_4, and x_5 given as input are a possible outcome of the assignment by Snuke.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nx_1 x_2 x_3 x_4 x_5\n\nOutput\n\nIf the variable Snuke assigned 0 was x_i, print the integer i.\n\nSample Input 1\n\n0 2 3 4 5\n\nSample Output 1\n\n1\n\nIn this case, Snuke assigned 0 to x_1, so we should print 1.\n\nSample Input 2\n\n1 2 0 4 5\n\nSample Output 2\n\n3", "sample_input": "0 2 3 4 5\n"}, "reference_outputs": ["1\n"], "source_document_id": "p02639", "source_text": "Score : 100 points\n\nProblem Statement\n\nWe have five variables x_1, x_2, x_3, x_4, and x_5.\n\nThe variable x_i was initially assigned a value of i.\n\nSnuke chose one of these variables and assigned it 0.\n\nYou are given the values of the five variables after this assignment.\n\nFind out which variable Snuke assigned 0.\n\nConstraints\n\nThe values of x_1, x_2, x_3, x_4, and x_5 given as input are a possible outcome of the assignment by Snuke.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nx_1 x_2 x_3 x_4 x_5\n\nOutput\n\nIf the variable Snuke assigned 0 was x_i, print the integer i.\n\nSample Input 1\n\n0 2 3 4 5\n\nSample Output 1\n\n1\n\nIn this case, Snuke assigned 0 to x_1, so we should print 1.\n\nSample Input 2\n\n1 2 0 4 5\n\nSample Output 2\n\n3", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 106, "cpu_time_ms": 2, "memory_kb": 2712}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s472956856", "group_id": "codeNet:p02640", "input_text": "X=io.read\"*n\"\nY=io.read\"*n\"\nif(Y%2==1)then print\"No\"return end\nprint(X*2<=Y and Y<=X*4 and \"Yes\" or \"No\")", "language": "Lua", "metadata": {"date": 1592183365, "filename_ext": "lua", "original_language": "Lua (LuaJIT 2.1.0)", "problem_description_relpath": "problem_descriptions/p02640.html", "problem_id": "p02640", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02640/input.txt", "sample_output_relpath": "derived/input_output/data/p02640/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02640/Lua/s472956856.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s472956856", "user_id": "u726173718"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "X=io.read\"*n\"\nY=io.read\"*n\"\nif(Y%2==1)then print\"No\"return end\nprint(X*2<=Y and Y<=X*4 and \"Yes\" or \"No\")", "problem_context": "Score : 200 points\n\nProblem Statement\n\nThere are some animals in a garden. Each of them is a crane with two legs or a turtle with four legs.\n\nTakahashi says: \"there are X animals in total in the garden, and they have Y legs in total.\" Determine whether there is a combination of numbers of cranes and turtles in which this statement is correct.\n\nConstraints\n\n1 \\leq X \\leq 100\n\n1 \\leq Y \\leq 100\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX Y\n\nOutput\n\nIf there is a combination of numbers of cranes and turtles in which the statement is correct, print Yes; otherwise, print No.\n\nSample Input 1\n\n3 8\n\nSample Output 1\n\nYes\n\nThe statement \"there are 3 animals in total in the garden, and they have 8 legs in total\" is correct if there are two cranes and one turtle. Thus, there is a combination of numbers of cranes and turtles in which the statement is correct.\n\nSample Input 2\n\n2 100\n\nSample Output 2\n\nNo\n\nThere is no combination of numbers of cranes and turtles in which this statement is correct.\n\nSample Input 3\n\n1 2\n\nSample Output 3\n\nYes\n\nWe also consider the case in which there are only cranes or only turtles.", "sample_input": "3 8\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p02640", "source_text": "Score : 200 points\n\nProblem Statement\n\nThere are some animals in a garden. Each of them is a crane with two legs or a turtle with four legs.\n\nTakahashi says: \"there are X animals in total in the garden, and they have Y legs in total.\" Determine whether there is a combination of numbers of cranes and turtles in which this statement is correct.\n\nConstraints\n\n1 \\leq X \\leq 100\n\n1 \\leq Y \\leq 100\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX Y\n\nOutput\n\nIf there is a combination of numbers of cranes and turtles in which the statement is correct, print Yes; otherwise, print No.\n\nSample Input 1\n\n3 8\n\nSample Output 1\n\nYes\n\nThe statement \"there are 3 animals in total in the garden, and they have 8 legs in total\" is correct if there are two cranes and one turtle. Thus, there is a combination of numbers of cranes and turtles in which the statement is correct.\n\nSample Input 2\n\n2 100\n\nSample Output 2\n\nNo\n\nThere is no combination of numbers of cranes and turtles in which this statement is correct.\n\nSample Input 3\n\n1 2\n\nSample Output 3\n\nYes\n\nWe also consider the case in which there are only cranes or only turtles.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 105, "cpu_time_ms": 2, "memory_kb": 2720}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s554206360", "group_id": "codeNet:p02641", "input_text": "local read = io.read\nlocal insert = table.insert\nlocal abs = math.abs\n\nlocal X, N = read(\"*n\", \"*n\")\nlocal p = {}\nfor i = 1, N do\n\tp[i] = read(\"*n\")\nend\n\nlocal not_p = {}\nfor i = 0, 101 do\n\tlocal can_ins = true\n\tfor j = 1, N do\n\t\tif p[j] == i then\n\t\t\tcan_ins = false\n\t\t\tbreak\n\t\tend\n\tend\n\tif can_ins then\n\t\tinsert(not_p, i)\n\tend\nend\n\nlocal out = math.huge\nfor i = 1, #not_p do\n\tif abs(not_p[i] - X) < abs(out - X) then\n\t\tout = not_p[i]\n\tend\nend\n\nprint(out)\n", "language": "Lua", "metadata": {"date": 1592185057, "filename_ext": "lua", "original_language": "Lua (LuaJIT 2.1.0)", "problem_description_relpath": "problem_descriptions/p02641.html", "problem_id": "p02641", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02641/input.txt", "sample_output_relpath": "derived/input_output/data/p02641/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02641/Lua/s554206360.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s554206360", "user_id": "u793881115"}, "prompt_components": {"gold_output": "8\n", "input_to_evaluate": "local read = io.read\nlocal insert = table.insert\nlocal abs = math.abs\n\nlocal X, N = read(\"*n\", \"*n\")\nlocal p = {}\nfor i = 1, N do\n\tp[i] = read(\"*n\")\nend\n\nlocal not_p = {}\nfor i = 0, 101 do\n\tlocal can_ins = true\n\tfor j = 1, N do\n\t\tif p[j] == i then\n\t\t\tcan_ins = false\n\t\t\tbreak\n\t\tend\n\tend\n\tif can_ins then\n\t\tinsert(not_p, i)\n\tend\nend\n\nlocal out = math.huge\nfor i = 1, #not_p do\n\tif abs(not_p[i] - X) < abs(out - X) then\n\t\tout = not_p[i]\n\tend\nend\n\nprint(out)\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nGiven are an integer X and an integer sequence of length N: p_1, \\ldots, p_N.\n\nAmong the integers not contained in the sequence p_1, \\ldots, p_N (not necessarily positive), find the integer nearest to X, that is, find the integer whose absolute difference with X is the minimum. If there are multiple such integers, report the smallest such integer.\n\nConstraints\n\n1 \\leq X \\leq 100\n\n0 \\leq N \\leq 100\n\n1 \\leq p_i \\leq 100\n\np_1, \\ldots, p_N are all distinct.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX N\np_1 ... p_N\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n6 5\n4 7 10 6 5\n\nSample Output 1\n\n8\n\nAmong the integers not contained in the sequence 4, 7, 10, 6, 5, the one nearest to 6 is 8.\n\nSample Input 2\n\n10 5\n4 7 10 6 5\n\nSample Output 2\n\n9\n\nAmong the integers not contained in the sequence 4, 7, 10, 6, 5, the ones nearest to 10 are 9 and 11. We should print the smaller one, 9.\n\nSample Input 3\n\n100 0\n\nSample Output 3\n\n100\n\nWhen N = 0, the second line in the input will be empty. Also, as seen here, X itself can be the answer.", "sample_input": "6 5\n4 7 10 6 5\n"}, "reference_outputs": ["8\n"], "source_document_id": "p02641", "source_text": "Score : 300 points\n\nProblem Statement\n\nGiven are an integer X and an integer sequence of length N: p_1, \\ldots, p_N.\n\nAmong the integers not contained in the sequence p_1, \\ldots, p_N (not necessarily positive), find the integer nearest to X, that is, find the integer whose absolute difference with X is the minimum. If there are multiple such integers, report the smallest such integer.\n\nConstraints\n\n1 \\leq X \\leq 100\n\n0 \\leq N \\leq 100\n\n1 \\leq p_i \\leq 100\n\np_1, \\ldots, p_N are all distinct.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX N\np_1 ... p_N\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n6 5\n4 7 10 6 5\n\nSample Output 1\n\n8\n\nAmong the integers not contained in the sequence 4, 7, 10, 6, 5, the one nearest to 6 is 8.\n\nSample Input 2\n\n10 5\n4 7 10 6 5\n\nSample Output 2\n\n9\n\nAmong the integers not contained in the sequence 4, 7, 10, 6, 5, the ones nearest to 10 are 9 and 11. We should print the smaller one, 9.\n\nSample Input 3\n\n100 0\n\nSample Output 3\n\n100\n\nWhen N = 0, the second line in the input will be empty. Also, as seen here, X itself can be the answer.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 456, "cpu_time_ms": 3, "memory_kb": 2744}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s467659006", "group_id": "codeNet:p02644", "input_text": "local mfl, mce = math.floor, math.ceil\nlocal mmi, mma = math.min, math.max\nlocal pow2 = {1}\nfor i = 2, 28 do pow2[i] = pow2[i - 1] * 2 end\nlocal SegTree = {}\nSegTree.updateAll = function(self)\n for i = self.stagenum - 1, 1, -1 do\n local cnt = pow2[i]\n for j = 0, cnt - 1 do\n self.stage[cnt + j] = self.func(self.stage[(cnt + j) * 2], self.stage[(cnt + j) * 2 + 1])\n end\n end\nend\nSegTree.create = function(self, n, func, emptyvalue)\n self.func, self.emptyvalue = func, emptyvalue\n local stagenum, mul = 1, 1\n self.stage = {}\n while mul < n do\n mul, stagenum = mul * 2, stagenum + 1\n end\n self.stagenum = stagenum\n for i = 1, mul * 2 - 1 do self.stage[i] = emptyvalue end\n for i = 1, n do self.stage[mul + i - 1] = i end\n self:updateAll()\nend\nSegTree.update = function(self, idx)\n idx = idx + pow2[self.stagenum] - 1\n for i = self.stagenum - 1, 1, -1 do\n local dst = mfl(idx / 2)\n local rem = dst * 4 + 1 - idx\n self.stage[dst] = self.func(self.stage[idx], self.stage[rem])\n idx = dst\n end\nend\nSegTree.new = function(n, func, emptyvalue)\n local obj = {}\n setmetatable(obj, {__index = SegTree})\n obj:create(n, func, emptyvalue)\n return obj\nend\n\nlocal h, w, k = io.read(\"*n\", \"*n\", \"*n\")\nlocal inf = h * w * k + 1\nlocal x1, y1 = io.read(\"*n\", \"*n\")\nlocal sidx = (x1 - 1) * w + y1\nlocal x2, y2 = io.read(\"*n\", \"*n\", \"*l\")\nlocal tidx = (x2 - 1) * w + y2\nlocal len = {}\nlocal asked = {}\nfor i = 1, h do\n local s = io.read()\n for j = 1, w do\n local idx = (i - 1) * w + j\n local f = s:sub(j, j) ~= \".\"\n for k = -1, 0 do\n len[idx * 2 + k] = inf\n asked[idx * 2 + k] = f\n end\n end\nend\nlen[sidx * 2 - 1] = 0\nlen[sidx * 2] = 0\n\nlocal n = h * w * 2\nasked[n + 1] = true\n\nlocal function mergefunc(x, y)\n if asked[x] then return y\n elseif asked[y] then return x\n else\n return len[x] < len[y] and x or y\n end\nend\n\nlocal st = SegTree.new(n, mergefunc, n + 1)\n\nlocal function walk(src, dst, cost)\n if not asked[dst] and len[src] + cost < len[dst] then\n len[dst] = len[src] + cost\n st:update(dst)\n end\nend\n\nfor i = 1, n do\n local src = st.stage[1]\n if asked[src] then break end\n asked[src] = true\n st:update(src)\n local idx = mce(src / 2)\n\n local l = len[src]\n local z = mce(l / k) * k - l\n if src % 2 == 1 then\n -- to left-right\n if 1 < w then\n if idx % w ~= 1 then walk(src, src - 2, 1) end\n if idx % w ~= 0 then walk(src, src + 2, 1) end\n end\n walk(src, src + 1, z)\n else\n -- to up-down\n if w < idx then\n walk(src, src - 2 * w, 1)\n end\n if idx <= (h - 1) * w then\n walk(src, src + 2 * w, 1)\n end\n walk(src, src - 1, z)\n end\nend\n\nlocal ret = mmi(len[tidx * 2 - 1], len[tidx * 2])\nif inf <= ret then\n print(-1)\nelse\n local l = mce(ret / k)\n print(l)\nend\n-- print(os.clock())\n", "language": "Lua", "metadata": {"date": 1592697416, "filename_ext": "lua", "original_language": "Lua (LuaJIT 2.1.0)", "problem_description_relpath": "problem_descriptions/p02644.html", "problem_id": "p02644", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02644/input.txt", "sample_output_relpath": "derived/input_output/data/p02644/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02644/Lua/s467659006.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s467659006", "user_id": "u120582723"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "local mfl, mce = math.floor, math.ceil\nlocal mmi, mma = math.min, math.max\nlocal pow2 = {1}\nfor i = 2, 28 do pow2[i] = pow2[i - 1] * 2 end\nlocal SegTree = {}\nSegTree.updateAll = function(self)\n for i = self.stagenum - 1, 1, -1 do\n local cnt = pow2[i]\n for j = 0, cnt - 1 do\n self.stage[cnt + j] = self.func(self.stage[(cnt + j) * 2], self.stage[(cnt + j) * 2 + 1])\n end\n end\nend\nSegTree.create = function(self, n, func, emptyvalue)\n self.func, self.emptyvalue = func, emptyvalue\n local stagenum, mul = 1, 1\n self.stage = {}\n while mul < n do\n mul, stagenum = mul * 2, stagenum + 1\n end\n self.stagenum = stagenum\n for i = 1, mul * 2 - 1 do self.stage[i] = emptyvalue end\n for i = 1, n do self.stage[mul + i - 1] = i end\n self:updateAll()\nend\nSegTree.update = function(self, idx)\n idx = idx + pow2[self.stagenum] - 1\n for i = self.stagenum - 1, 1, -1 do\n local dst = mfl(idx / 2)\n local rem = dst * 4 + 1 - idx\n self.stage[dst] = self.func(self.stage[idx], self.stage[rem])\n idx = dst\n end\nend\nSegTree.new = function(n, func, emptyvalue)\n local obj = {}\n setmetatable(obj, {__index = SegTree})\n obj:create(n, func, emptyvalue)\n return obj\nend\n\nlocal h, w, k = io.read(\"*n\", \"*n\", \"*n\")\nlocal inf = h * w * k + 1\nlocal x1, y1 = io.read(\"*n\", \"*n\")\nlocal sidx = (x1 - 1) * w + y1\nlocal x2, y2 = io.read(\"*n\", \"*n\", \"*l\")\nlocal tidx = (x2 - 1) * w + y2\nlocal len = {}\nlocal asked = {}\nfor i = 1, h do\n local s = io.read()\n for j = 1, w do\n local idx = (i - 1) * w + j\n local f = s:sub(j, j) ~= \".\"\n for k = -1, 0 do\n len[idx * 2 + k] = inf\n asked[idx * 2 + k] = f\n end\n end\nend\nlen[sidx * 2 - 1] = 0\nlen[sidx * 2] = 0\n\nlocal n = h * w * 2\nasked[n + 1] = true\n\nlocal function mergefunc(x, y)\n if asked[x] then return y\n elseif asked[y] then return x\n else\n return len[x] < len[y] and x or y\n end\nend\n\nlocal st = SegTree.new(n, mergefunc, n + 1)\n\nlocal function walk(src, dst, cost)\n if not asked[dst] and len[src] + cost < len[dst] then\n len[dst] = len[src] + cost\n st:update(dst)\n end\nend\n\nfor i = 1, n do\n local src = st.stage[1]\n if asked[src] then break end\n asked[src] = true\n st:update(src)\n local idx = mce(src / 2)\n\n local l = len[src]\n local z = mce(l / k) * k - l\n if src % 2 == 1 then\n -- to left-right\n if 1 < w then\n if idx % w ~= 1 then walk(src, src - 2, 1) end\n if idx % w ~= 0 then walk(src, src + 2, 1) end\n end\n walk(src, src + 1, z)\n else\n -- to up-down\n if w < idx then\n walk(src, src - 2 * w, 1)\n end\n if idx <= (h - 1) * w then\n walk(src, src + 2 * w, 1)\n end\n walk(src, src - 1, z)\n end\nend\n\nlocal ret = mmi(len[tidx * 2 - 1], len[tidx * 2])\nif inf <= ret then\n print(-1)\nelse\n local l = mce(ret / k)\n print(l)\nend\n-- print(os.clock())\n", "problem_context": "Score : 600 points\n\nProblem Statement\n\nSnuke, a water strider, lives in a rectangular pond that can be seen as a grid with H east-west rows and W north-south columns. Let (i,j) be the square at the i-th row from the north and j-th column from the west.\n\nSome of the squares have a lotus leaf on it and cannot be entered.\nThe square (i,j) has a lotus leaf on it if c_{ij} is @, and it does not if c_{ij} is ..\n\nIn one stroke, Snuke can move between 1 and K squares (inclusive) toward one of the four directions: north, east, south, and west.\nThe move may not pass through a square with a lotus leaf. Moving to such a square or out of the pond is also forbidden.\n\nFind the minimum number of strokes Snuke takes to travel from the square (x_1,y_1) to (x_2,y_2).\nIf the travel from (x_1,y_1) to (x_2,y_2) is impossible, point out that fact.\n\nConstraints\n\n1 \\leq H,W,K \\leq 10^6\n\nH \\times W \\leq 10^6\n\n1 \\leq x_1,x_2 \\leq H\n\n1 \\leq y_1,y_2 \\leq W\n\nx_1 \\neq x_2 or y_1 \\neq y_2.\n\nc_{i,j} is . or @.\n\nc_{x_1,y_1} = .\n\nc_{x_2,y_2} = .\n\nAll numbers in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W K\nx_1 y_1 x_2 y_2\nc_{1,1}c_{1,2} .. c_{1,W}\nc_{2,1}c_{2,2} .. c_{2,W}\n:\nc_{H,1}c_{H,2} .. c_{H,W}\n\nOutput\n\nPrint the minimum number of strokes Snuke takes to travel from the square (x_1,y_1) to (x_2,y_2), or print -1 if the travel is impossible.\n\nSample Input 1\n\n3 5 2\n3 2 3 4\n.....\n.@..@\n..@..\n\nSample Output 1\n\n5\n\nInitially, Snuke is at the square (3,2).\nHe can reach the square (3, 4) by making five strokes as follows:\n\nFrom (3, 2), go west one square to (3, 1).\n\nFrom (3, 1), go north two squares to (1, 1).\n\nFrom (1, 1), go east two squares to (1, 3).\n\nFrom (1, 3), go east one square to (1, 4).\n\nFrom (1, 4), go south two squares to (3, 4).\n\nSample Input 2\n\n1 6 4\n1 1 1 6\n......\n\nSample Output 2\n\n2\n\nSample Input 3\n\n3 3 1\n2 1 2 3\n.@.\n.@.\n.@.\n\nSample Output 3\n\n-1", "sample_input": "3 5 2\n3 2 3 4\n.....\n.@..@\n..@..\n"}, "reference_outputs": ["5\n"], "source_document_id": "p02644", "source_text": "Score : 600 points\n\nProblem Statement\n\nSnuke, a water strider, lives in a rectangular pond that can be seen as a grid with H east-west rows and W north-south columns. Let (i,j) be the square at the i-th row from the north and j-th column from the west.\n\nSome of the squares have a lotus leaf on it and cannot be entered.\nThe square (i,j) has a lotus leaf on it if c_{ij} is @, and it does not if c_{ij} is ..\n\nIn one stroke, Snuke can move between 1 and K squares (inclusive) toward one of the four directions: north, east, south, and west.\nThe move may not pass through a square with a lotus leaf. Moving to such a square or out of the pond is also forbidden.\n\nFind the minimum number of strokes Snuke takes to travel from the square (x_1,y_1) to (x_2,y_2).\nIf the travel from (x_1,y_1) to (x_2,y_2) is impossible, point out that fact.\n\nConstraints\n\n1 \\leq H,W,K \\leq 10^6\n\nH \\times W \\leq 10^6\n\n1 \\leq x_1,x_2 \\leq H\n\n1 \\leq y_1,y_2 \\leq W\n\nx_1 \\neq x_2 or y_1 \\neq y_2.\n\nc_{i,j} is . or @.\n\nc_{x_1,y_1} = .\n\nc_{x_2,y_2} = .\n\nAll numbers in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W K\nx_1 y_1 x_2 y_2\nc_{1,1}c_{1,2} .. c_{1,W}\nc_{2,1}c_{2,2} .. c_{2,W}\n:\nc_{H,1}c_{H,2} .. c_{H,W}\n\nOutput\n\nPrint the minimum number of strokes Snuke takes to travel from the square (x_1,y_1) to (x_2,y_2), or print -1 if the travel is impossible.\n\nSample Input 1\n\n3 5 2\n3 2 3 4\n.....\n.@..@\n..@..\n\nSample Output 1\n\n5\n\nInitially, Snuke is at the square (3,2).\nHe can reach the square (3, 4) by making five strokes as follows:\n\nFrom (3, 2), go west one square to (3, 1).\n\nFrom (3, 1), go north two squares to (1, 1).\n\nFrom (1, 1), go east two squares to (1, 3).\n\nFrom (1, 3), go east one square to (1, 4).\n\nFrom (1, 4), go south two squares to (3, 4).\n\nSample Input 2\n\n1 6 4\n1 1 1 6\n......\n\nSample Output 2\n\n2\n\nSample Input 3\n\n3 3 1\n2 1 2 3\n.@.\n.@.\n.@.\n\nSample Output 3\n\n-1", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2804, "cpu_time_ms": 2041, "memory_kb": 69860}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s160422319", "group_id": "codeNet:p02645", "input_text": "print(io.read():sub(1,3))", "language": "Lua", "metadata": {"date": 1592104536, "filename_ext": "lua", "original_language": "Lua (Lua 5.3.5)", "problem_description_relpath": "problem_descriptions/p02645.html", "problem_id": "p02645", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02645/input.txt", "sample_output_relpath": "derived/input_output/data/p02645/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02645/Lua/s160422319.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s160422319", "user_id": "u045238009"}, "prompt_components": {"gold_output": "tak\n", "input_to_evaluate": "print(io.read():sub(1,3))", "problem_context": "Score : 100 points\n\nProblem Statement\n\nWhen you asked some guy in your class his name, he called himself S, where S is a string of length between 3 and 20 (inclusive) consisting of lowercase English letters.\nYou have decided to choose some three consecutive characters from S and make it his nickname. Print a string that is a valid nickname for him.\n\nConstraints\n\n3 \\leq |S| \\leq 20\n\nS consists of lowercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint your answer.\n\nSample Input 1\n\ntakahashi\n\nSample Output 1\n\ntak\n\nSample Input 2\n\nnaohiro\n\nSample Output 2\n\nnao", "sample_input": "takahashi\n"}, "reference_outputs": ["tak\n"], "source_document_id": "p02645", "source_text": "Score : 100 points\n\nProblem Statement\n\nWhen you asked some guy in your class his name, he called himself S, where S is a string of length between 3 and 20 (inclusive) consisting of lowercase English letters.\nYou have decided to choose some three consecutive characters from S and make it his nickname. Print a string that is a valid nickname for him.\n\nConstraints\n\n3 \\leq |S| \\leq 20\n\nS consists of lowercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint your answer.\n\nSample Input 1\n\ntakahashi\n\nSample Output 1\n\ntak\n\nSample Input 2\n\nnaohiro\n\nSample Output 2\n\nnao", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 25, "cpu_time_ms": 5, "memory_kb": 2604}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s760233817", "group_id": "codeNet:p02646", "input_text": "A=io.read\"*n\"\nV=io.read\"*n\"\nB=io.read\"*n\"\nW=io.read\"*n\"\nT=io.read\"*n\"\nt=math.abs(A-B)/(V-W)\nprint((V~=W and 0<=t and t<=T)and\"YES\"or\"NO\")", "language": "Lua", "metadata": {"date": 1592105491, "filename_ext": "lua", "original_language": "Lua (LuaJIT 2.1.0)", "problem_description_relpath": "problem_descriptions/p02646.html", "problem_id": "p02646", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02646/input.txt", "sample_output_relpath": "derived/input_output/data/p02646/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02646/Lua/s760233817.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s760233817", "user_id": "u726173718"}, "prompt_components": {"gold_output": "YES\n", "input_to_evaluate": "A=io.read\"*n\"\nV=io.read\"*n\"\nB=io.read\"*n\"\nW=io.read\"*n\"\nT=io.read\"*n\"\nt=math.abs(A-B)/(V-W)\nprint((V~=W and 0<=t and t<=T)and\"YES\"or\"NO\")", "problem_context": "Score : 200 points\n\nProblem Statement\n\nTwo children are playing tag on a number line. (In the game of tag, the child called \"it\" tries to catch the other child.) The child who is \"it\" is now at coordinate A, and he can travel the distance of V per second.\nThe other child is now at coordinate B, and she can travel the distance of W per second.\n\nHe can catch her when his coordinate is the same as hers.\nDetermine whether he can catch her within T seconds (including exactly T seconds later).\nWe assume that both children move optimally.\n\nConstraints\n\n-10^9 \\leq A,B \\leq 10^9\n\n1 \\leq V,W \\leq 10^9\n\n1 \\leq T \\leq 10^9\n\nA \\neq B\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA V\nB W\nT\n\nOutput\n\nIf \"it\" can catch the other child, print YES; otherwise, print NO.\n\nSample Input 1\n\n1 2\n3 1\n3\n\nSample Output 1\n\nYES\n\nSample Input 2\n\n1 2\n3 2\n3\n\nSample Output 2\n\nNO\n\nSample Input 3\n\n1 2\n3 3\n3\n\nSample Output 3\n\nNO", "sample_input": "1 2\n3 1\n3\n"}, "reference_outputs": ["YES\n"], "source_document_id": "p02646", "source_text": "Score : 200 points\n\nProblem Statement\n\nTwo children are playing tag on a number line. (In the game of tag, the child called \"it\" tries to catch the other child.) The child who is \"it\" is now at coordinate A, and he can travel the distance of V per second.\nThe other child is now at coordinate B, and she can travel the distance of W per second.\n\nHe can catch her when his coordinate is the same as hers.\nDetermine whether he can catch her within T seconds (including exactly T seconds later).\nWe assume that both children move optimally.\n\nConstraints\n\n-10^9 \\leq A,B \\leq 10^9\n\n1 \\leq V,W \\leq 10^9\n\n1 \\leq T \\leq 10^9\n\nA \\neq B\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA V\nB W\nT\n\nOutput\n\nIf \"it\" can catch the other child, print YES; otherwise, print NO.\n\nSample Input 1\n\n1 2\n3 1\n3\n\nSample Output 1\n\nYES\n\nSample Input 2\n\n1 2\n3 2\n3\n\nSample Output 2\n\nNO\n\nSample Input 3\n\n1 2\n3 3\n3\n\nSample Output 3\n\nNO", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 137, "cpu_time_ms": 2, "memory_kb": 2724}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s073603668", "group_id": "codeNet:p02646", "input_text": "A=io.read\"*n\"\nV=io.read\"*n\"\nB=io.read\"*n\"\nW=io.read\"*n\"\nT=io.read\"*n\"\nt=math.abs(A-B)/(V-W)\nprint((V~=W and 0<=t and t<=T)and\"Yes\"or\"No\")", "language": "Lua", "metadata": {"date": 1592105473, "filename_ext": "lua", "original_language": "Lua (LuaJIT 2.1.0)", "problem_description_relpath": "problem_descriptions/p02646.html", "problem_id": "p02646", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02646/input.txt", "sample_output_relpath": "derived/input_output/data/p02646/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02646/Lua/s073603668.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s073603668", "user_id": "u726173718"}, "prompt_components": {"gold_output": "YES\n", "input_to_evaluate": "A=io.read\"*n\"\nV=io.read\"*n\"\nB=io.read\"*n\"\nW=io.read\"*n\"\nT=io.read\"*n\"\nt=math.abs(A-B)/(V-W)\nprint((V~=W and 0<=t and t<=T)and\"Yes\"or\"No\")", "problem_context": "Score : 200 points\n\nProblem Statement\n\nTwo children are playing tag on a number line. (In the game of tag, the child called \"it\" tries to catch the other child.) The child who is \"it\" is now at coordinate A, and he can travel the distance of V per second.\nThe other child is now at coordinate B, and she can travel the distance of W per second.\n\nHe can catch her when his coordinate is the same as hers.\nDetermine whether he can catch her within T seconds (including exactly T seconds later).\nWe assume that both children move optimally.\n\nConstraints\n\n-10^9 \\leq A,B \\leq 10^9\n\n1 \\leq V,W \\leq 10^9\n\n1 \\leq T \\leq 10^9\n\nA \\neq B\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA V\nB W\nT\n\nOutput\n\nIf \"it\" can catch the other child, print YES; otherwise, print NO.\n\nSample Input 1\n\n1 2\n3 1\n3\n\nSample Output 1\n\nYES\n\nSample Input 2\n\n1 2\n3 2\n3\n\nSample Output 2\n\nNO\n\nSample Input 3\n\n1 2\n3 3\n3\n\nSample Output 3\n\nNO", "sample_input": "1 2\n3 1\n3\n"}, "reference_outputs": ["YES\n"], "source_document_id": "p02646", "source_text": "Score : 200 points\n\nProblem Statement\n\nTwo children are playing tag on a number line. (In the game of tag, the child called \"it\" tries to catch the other child.) The child who is \"it\" is now at coordinate A, and he can travel the distance of V per second.\nThe other child is now at coordinate B, and she can travel the distance of W per second.\n\nHe can catch her when his coordinate is the same as hers.\nDetermine whether he can catch her within T seconds (including exactly T seconds later).\nWe assume that both children move optimally.\n\nConstraints\n\n-10^9 \\leq A,B \\leq 10^9\n\n1 \\leq V,W \\leq 10^9\n\n1 \\leq T \\leq 10^9\n\nA \\neq B\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA V\nB W\nT\n\nOutput\n\nIf \"it\" can catch the other child, print YES; otherwise, print NO.\n\nSample Input 1\n\n1 2\n3 1\n3\n\nSample Output 1\n\nYES\n\nSample Input 2\n\n1 2\n3 2\n3\n\nSample Output 2\n\nNO\n\nSample Input 3\n\n1 2\n3 3\n3\n\nSample Output 3\n\nNO", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 137, "cpu_time_ms": 3, "memory_kb": 2704}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s631483380", "group_id": "codeNet:p02646", "input_text": "local a,v=io.read(\"n\",\"n\")\nlocal b,w=io.read(\"n\",\"n\")\nlocal t=io.read(\"n\")\n\nif a=b+w*t then\n print(\"YES\")\n else\n print(\"NO\")\n end\nelse\n if a+v*t<=b+w*t then\n print(\"YES\")\n else\n print(\"NO\")\n end\nend", "language": "Lua", "metadata": {"date": 1592104967, "filename_ext": "lua", "original_language": "Lua (Lua 5.3.5)", "problem_description_relpath": "problem_descriptions/p02646.html", "problem_id": "p02646", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02646/input.txt", "sample_output_relpath": "derived/input_output/data/p02646/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02646/Lua/s631483380.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s631483380", "user_id": "u045238009"}, "prompt_components": {"gold_output": "YES\n", "input_to_evaluate": "local a,v=io.read(\"n\",\"n\")\nlocal b,w=io.read(\"n\",\"n\")\nlocal t=io.read(\"n\")\n\nif a=b+w*t then\n print(\"YES\")\n else\n print(\"NO\")\n end\nelse\n if a+v*t<=b+w*t then\n print(\"YES\")\n else\n print(\"NO\")\n end\nend", "problem_context": "Score : 200 points\n\nProblem Statement\n\nTwo children are playing tag on a number line. (In the game of tag, the child called \"it\" tries to catch the other child.) The child who is \"it\" is now at coordinate A, and he can travel the distance of V per second.\nThe other child is now at coordinate B, and she can travel the distance of W per second.\n\nHe can catch her when his coordinate is the same as hers.\nDetermine whether he can catch her within T seconds (including exactly T seconds later).\nWe assume that both children move optimally.\n\nConstraints\n\n-10^9 \\leq A,B \\leq 10^9\n\n1 \\leq V,W \\leq 10^9\n\n1 \\leq T \\leq 10^9\n\nA \\neq B\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA V\nB W\nT\n\nOutput\n\nIf \"it\" can catch the other child, print YES; otherwise, print NO.\n\nSample Input 1\n\n1 2\n3 1\n3\n\nSample Output 1\n\nYES\n\nSample Input 2\n\n1 2\n3 2\n3\n\nSample Output 2\n\nNO\n\nSample Input 3\n\n1 2\n3 3\n3\n\nSample Output 3\n\nNO", "sample_input": "1 2\n3 1\n3\n"}, "reference_outputs": ["YES\n"], "source_document_id": "p02646", "source_text": "Score : 200 points\n\nProblem Statement\n\nTwo children are playing tag on a number line. (In the game of tag, the child called \"it\" tries to catch the other child.) The child who is \"it\" is now at coordinate A, and he can travel the distance of V per second.\nThe other child is now at coordinate B, and she can travel the distance of W per second.\n\nHe can catch her when his coordinate is the same as hers.\nDetermine whether he can catch her within T seconds (including exactly T seconds later).\nWe assume that both children move optimally.\n\nConstraints\n\n-10^9 \\leq A,B \\leq 10^9\n\n1 \\leq V,W \\leq 10^9\n\n1 \\leq T \\leq 10^9\n\nA \\neq B\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA V\nB W\nT\n\nOutput\n\nIf \"it\" can catch the other child, print YES; otherwise, print NO.\n\nSample Input 1\n\n1 2\n3 1\n3\n\nSample Output 1\n\nYES\n\nSample Input 2\n\n1 2\n3 2\n3\n\nSample Output 2\n\nNO\n\nSample Input 3\n\n1 2\n3 3\n3\n\nSample Output 3\n\nNO", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 262, "cpu_time_ms": 5, "memory_kb": 2668}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s134383908", "group_id": "codeNet:p02648", "input_text": "local bls, brs = bit.lshift, bit.rshift\nlocal mmi, mma = math.min, math.max\nlocal n = io.read(\"*n\")\nlocal v, w = {}, {}\nfor i = 1, n do\n v[i], w[i] = io.read(\"*n\", \"*n\")\nend\nlocal head_tbl = {}\nlocal box = {}\nlocal ten5 = 100000\nfor i = 256, mmi(n, 1023) do\n head_tbl[i - 255] = {}\n local tbl = head_tbl[i - 255]\n for j = 1, ten5 do\n tbl[j] = 0\n end\n local jlim = i < 512 and 511 or 1023\n local klim = i < 512 and 9 or 10\n for j = 1, jlim do\n local tmpi, tmpj = i, j\n local weight, val = 0, 0\n for k = 1, klim do\n if tmpj % 2 == 1 then\n val = val + v[tmpi]\n weight = weight + w[tmpi]\n end\n tmpi = brs(tmpi, 1)\n tmpj = brs(tmpj, 1)\n end\n if weight <= ten5 then\n tbl[weight] = mma(tbl[weight], val)\n end\n end\n for i = 2, ten5 do\n tbl[i] = mma(tbl[i], tbl[i - 1])\n end\nend\nlocal function debug(...)\n -- print(...)\nend\nlocal function output(z)\n print(z)\nend\n\ndebug(os.clock(), collectgarbage(\"count\"))\nlocal q = io.read(\"*n\")\nfor iq = 1, q do\n if iq % 1000 == 0 then\n debug(iq, os.clock())\n end\n local pos, wlim = io.read(\"*n\", \"*n\")\n local deg = 0\n do\n local tmp = pos\n while 0 < tmp do\n deg, tmp = deg + 1, brs(tmp, 1)\n end\n end\n if pos < 256 then\n local ans = 0\n local tot = bls(1, deg)\n for j = 0, tot - 1 do\n local tmpi, tmpj = pos, j\n local val, weight = 0, 0\n for k = 1, deg do\n if tmpj % 2 == 1 then\n val, weight = val + v[tmpi], weight + w[tmpi]\n end\n tmpi, tmpj = brs(tmpi, 1), brs(tmpj, 1)\n end\n if weight <= wlim then\n ans = mma(ans, val)\n end\n end\n output(ans)\n elseif pos < 1024 then\n output(head_tbl[pos - 255][wlim])\n else\n deg = deg - 10\n local basepos = pos\n for i = 1, deg do\n basepos = brs(basepos, 1)\n end\n local tbl = head_tbl[basepos - 255]\n local ans = tbl[wlim]\n local tot = bls(1, deg)\n local deglim, mul = 1, 2\n for j = 1, tot - 1 do\n local tmpi, tmpj = pos, j\n local val, weight = 0, 0\n if j == mul then\n deglim, mul = deglim + 1, mul * 2\n end\n for k = 1, deglim do\n if tmpj % 2 == 1 then\n val, weight = val + v[tmpi], weight + w[tmpi]\n end\n tmpi, tmpj = brs(tmpi, 1), brs(tmpj, 1)\n end\n if weight == wlim then\n ans = mma(ans, val)\n elseif weight < wlim then\n ans = mma(ans, val + tbl[wlim - weight])\n end\n end\n output(ans)\n end\nend\ndebug(os.clock())\n", "language": "Lua", "metadata": {"date": 1593745602, "filename_ext": "lua", "original_language": "Lua (LuaJIT 2.1.0)", "problem_description_relpath": "problem_descriptions/p02648.html", "problem_id": "p02648", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02648/input.txt", "sample_output_relpath": "derived/input_output/data/p02648/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02648/Lua/s134383908.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s134383908", "user_id": "u120582723"}, "prompt_components": {"gold_output": "0\n3\n3\n", "input_to_evaluate": "local bls, brs = bit.lshift, bit.rshift\nlocal mmi, mma = math.min, math.max\nlocal n = io.read(\"*n\")\nlocal v, w = {}, {}\nfor i = 1, n do\n v[i], w[i] = io.read(\"*n\", \"*n\")\nend\nlocal head_tbl = {}\nlocal box = {}\nlocal ten5 = 100000\nfor i = 256, mmi(n, 1023) do\n head_tbl[i - 255] = {}\n local tbl = head_tbl[i - 255]\n for j = 1, ten5 do\n tbl[j] = 0\n end\n local jlim = i < 512 and 511 or 1023\n local klim = i < 512 and 9 or 10\n for j = 1, jlim do\n local tmpi, tmpj = i, j\n local weight, val = 0, 0\n for k = 1, klim do\n if tmpj % 2 == 1 then\n val = val + v[tmpi]\n weight = weight + w[tmpi]\n end\n tmpi = brs(tmpi, 1)\n tmpj = brs(tmpj, 1)\n end\n if weight <= ten5 then\n tbl[weight] = mma(tbl[weight], val)\n end\n end\n for i = 2, ten5 do\n tbl[i] = mma(tbl[i], tbl[i - 1])\n end\nend\nlocal function debug(...)\n -- print(...)\nend\nlocal function output(z)\n print(z)\nend\n\ndebug(os.clock(), collectgarbage(\"count\"))\nlocal q = io.read(\"*n\")\nfor iq = 1, q do\n if iq % 1000 == 0 then\n debug(iq, os.clock())\n end\n local pos, wlim = io.read(\"*n\", \"*n\")\n local deg = 0\n do\n local tmp = pos\n while 0 < tmp do\n deg, tmp = deg + 1, brs(tmp, 1)\n end\n end\n if pos < 256 then\n local ans = 0\n local tot = bls(1, deg)\n for j = 0, tot - 1 do\n local tmpi, tmpj = pos, j\n local val, weight = 0, 0\n for k = 1, deg do\n if tmpj % 2 == 1 then\n val, weight = val + v[tmpi], weight + w[tmpi]\n end\n tmpi, tmpj = brs(tmpi, 1), brs(tmpj, 1)\n end\n if weight <= wlim then\n ans = mma(ans, val)\n end\n end\n output(ans)\n elseif pos < 1024 then\n output(head_tbl[pos - 255][wlim])\n else\n deg = deg - 10\n local basepos = pos\n for i = 1, deg do\n basepos = brs(basepos, 1)\n end\n local tbl = head_tbl[basepos - 255]\n local ans = tbl[wlim]\n local tot = bls(1, deg)\n local deglim, mul = 1, 2\n for j = 1, tot - 1 do\n local tmpi, tmpj = pos, j\n local val, weight = 0, 0\n if j == mul then\n deglim, mul = deglim + 1, mul * 2\n end\n for k = 1, deglim do\n if tmpj % 2 == 1 then\n val, weight = val + v[tmpi], weight + w[tmpi]\n end\n tmpi, tmpj = brs(tmpi, 1), brs(tmpj, 1)\n end\n if weight == wlim then\n ans = mma(ans, val)\n elseif weight < wlim then\n ans = mma(ans, val + tbl[wlim - weight])\n end\n end\n output(ans)\n end\nend\ndebug(os.clock())\n", "problem_context": "Score : 700 points\n\nProblem Statement\n\nWe have a rooted binary tree with N vertices, where the vertices are numbered 1 to N.\nVertex 1 is the root, and the parent of Vertex i (i \\geq 2) is Vertex \\left[ \\frac{i}{2} \\right].\n\nEach vertex has one item in it. The item in Vertex i has a value of V_i and a weight of W_i.\nNow, process the following query Q times:\n\nGiven are a vertex v of the tree and a positive integer L.\nLet us choose some (possibly none) of the items in v and the ancestors of v so that their total weight is at most L.\nFind the maximum possible total value of the chosen items.\n\nHere, Vertex u is said to be an ancestor of Vertex v when u is an indirect parent of v, that is, there exists a sequence of vertices w_1,w_2,\\ldots,w_k (k\\geq 2) where w_1=v, w_k=u, and w_{i+1} is the parent of w_i for each i.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N < 2^{18}\n\n1 \\leq Q \\leq 10^5\n\n1 \\leq V_i \\leq 10^5\n\n1 \\leq W_i \\leq 10^5\n\nFor the values v and L given in each query, 1 \\leq v \\leq N and 1 \\leq L \\leq 10^5.\n\nInput\n\nLet v_i and L_i be the values v and L given in the i-th query.\nThen, Input is given from Standard Input in the following format:\n\nN\nV_1 W_1\n:\nV_N W_N\nQ\nv_1 L_1\n:\nv_Q L_Q\n\nOutput\n\nFor each integer i from 1 through Q,\nthe i-th line should contain the response to the i-th query.\n\nSample Input 1\n\n3\n1 2\n2 3\n3 4\n3\n1 1\n2 5\n3 5\n\nSample Output 1\n\n0\n3\n3\n\nIn the first query, we are given only one choice: the item with (V, W)=(1,2). Since L = 1, we cannot actually choose it, so our response should be 0.\n\nIn the second query, we are given two choices: the items with (V, W)=(1,2) and (V, W)=(2,3). Since L = 5, we can choose both of them, so our response should be 3.\n\nSample Input 2\n\n15\n123 119\n129 120\n132 112\n126 109\n118 103\n115 109\n102 100\n130 120\n105 105\n132 115\n104 102\n107 107\n127 116\n121 104\n121 115\n8\n8 234\n9 244\n10 226\n11 227\n12 240\n13 237\n14 206\n15 227\n\nSample Output 2\n\n256\n255\n250\n247\n255\n259\n223\n253", "sample_input": "3\n1 2\n2 3\n3 4\n3\n1 1\n2 5\n3 5\n"}, "reference_outputs": ["0\n3\n3\n"], "source_document_id": "p02648", "source_text": "Score : 700 points\n\nProblem Statement\n\nWe have a rooted binary tree with N vertices, where the vertices are numbered 1 to N.\nVertex 1 is the root, and the parent of Vertex i (i \\geq 2) is Vertex \\left[ \\frac{i}{2} \\right].\n\nEach vertex has one item in it. The item in Vertex i has a value of V_i and a weight of W_i.\nNow, process the following query Q times:\n\nGiven are a vertex v of the tree and a positive integer L.\nLet us choose some (possibly none) of the items in v and the ancestors of v so that their total weight is at most L.\nFind the maximum possible total value of the chosen items.\n\nHere, Vertex u is said to be an ancestor of Vertex v when u is an indirect parent of v, that is, there exists a sequence of vertices w_1,w_2,\\ldots,w_k (k\\geq 2) where w_1=v, w_k=u, and w_{i+1} is the parent of w_i for each i.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N < 2^{18}\n\n1 \\leq Q \\leq 10^5\n\n1 \\leq V_i \\leq 10^5\n\n1 \\leq W_i \\leq 10^5\n\nFor the values v and L given in each query, 1 \\leq v \\leq N and 1 \\leq L \\leq 10^5.\n\nInput\n\nLet v_i and L_i be the values v and L given in the i-th query.\nThen, Input is given from Standard Input in the following format:\n\nN\nV_1 W_1\n:\nV_N W_N\nQ\nv_1 L_1\n:\nv_Q L_Q\n\nOutput\n\nFor each integer i from 1 through Q,\nthe i-th line should contain the response to the i-th query.\n\nSample Input 1\n\n3\n1 2\n2 3\n3 4\n3\n1 1\n2 5\n3 5\n\nSample Output 1\n\n0\n3\n3\n\nIn the first query, we are given only one choice: the item with (V, W)=(1,2). Since L = 1, we cannot actually choose it, so our response should be 0.\n\nIn the second query, we are given two choices: the items with (V, W)=(1,2) and (V, W)=(2,3). Since L = 5, we can choose both of them, so our response should be 3.\n\nSample Input 2\n\n15\n123 119\n129 120\n132 112\n126 109\n118 103\n115 109\n102 100\n130 120\n105 105\n132 115\n104 102\n107 107\n127 116\n121 104\n121 115\n8\n8 234\n9 244\n10 226\n11 227\n12 240\n13 237\n14 206\n15 227\n\nSample Output 2\n\n256\n255\n250\n247\n255\n259\n223\n253", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2497, "cpu_time_ms": 3340, "memory_kb": 796480}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s096929704", "group_id": "codeNet:p02651", "input_text": "local function check(x, vec)\n local w = {}\n for i = 1, #vec do\n w[i] = vec[i]\n end\n local isok = true\n for i = 1, 62 do\n local rmpos = 0\n for j = #w, 1, -1 do\n if w[j] % 2 == 1 then\n rmpos = j\n break\n end\n end\n if rmpos == 0 then\n if x % 2 == 1 then\n isok = false\n break\n end\n else\n local v = w[rmpos]\n table.remove(w, rmpos)\n if x % 2 == 1 then\n x = v ~ x\n end\n for j = 1, #w do\n if w[j] % 2 == 1 then\n w[j] = v ~ w[j]\n end\n end\n end\n x = x // 2\n for j = 1, #w do\n w[j] = w[j] // 2\n end\n end\n return isok\nend\nlocal q = io.read(\"*n\")\nfor iq = 1, q do\n local n = io.read(\"*n\", \"*l\")\n local as = io.read()\n local a = {}\n for ac in as:gmatch(\"%d+\") do\n table.insert(a, tonumber(ac))\n end\n local s = io.read()\n local t = {}\n local valid = true\n for i = n, 1, -1 do\n if s:sub(i, i) == \"0\" then\n table.insert(t, a[i])\n else\n if not check(a[i], t) then\n valid = false break\n end\n end\n end\n print(valid and 0 or 1)\nend", "language": "Lua", "metadata": {"date": 1591666294, "filename_ext": "lua", "original_language": "Lua (Lua 5.3.5)", "problem_description_relpath": "problem_descriptions/p02651.html", "problem_id": "p02651", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02651/input.txt", "sample_output_relpath": "derived/input_output/data/p02651/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02651/Lua/s096929704.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s096929704", "user_id": "u120582723"}, "prompt_components": {"gold_output": "1\n0\n0\n", "input_to_evaluate": "local function check(x, vec)\n local w = {}\n for i = 1, #vec do\n w[i] = vec[i]\n end\n local isok = true\n for i = 1, 62 do\n local rmpos = 0\n for j = #w, 1, -1 do\n if w[j] % 2 == 1 then\n rmpos = j\n break\n end\n end\n if rmpos == 0 then\n if x % 2 == 1 then\n isok = false\n break\n end\n else\n local v = w[rmpos]\n table.remove(w, rmpos)\n if x % 2 == 1 then\n x = v ~ x\n end\n for j = 1, #w do\n if w[j] % 2 == 1 then\n w[j] = v ~ w[j]\n end\n end\n end\n x = x // 2\n for j = 1, #w do\n w[j] = w[j] // 2\n end\n end\n return isok\nend\nlocal q = io.read(\"*n\")\nfor iq = 1, q do\n local n = io.read(\"*n\", \"*l\")\n local as = io.read()\n local a = {}\n for ac in as:gmatch(\"%d+\") do\n table.insert(a, tonumber(ac))\n end\n local s = io.read()\n local t = {}\n local valid = true\n for i = n, 1, -1 do\n if s:sub(i, i) == \"0\" then\n table.insert(t, a[i])\n else\n if not check(a[i], t) then\n valid = false break\n end\n end\n end\n print(valid and 0 or 1)\nend", "problem_context": "Score : 400 points\n\nProblem Statement\n\nThere are two persons, numbered 0 and 1, and a variable x whose initial value is 0.\nThe two persons now play a game.\nThe game is played in N rounds. The following should be done in the i-th round (1 \\leq i \\leq N):\n\nPerson S_i does one of the following:\n\nReplace x with x \\oplus A_i, where \\oplus represents bitwise XOR.\n\nDo nothing.\n\nPerson 0 aims to have x=0 at the end of the game, while Person 1 aims to have x \\neq 0 at the end of the game.\n\nDetermine whether x becomes 0 at the end of the game when the two persons play optimally.\n\nSolve T test cases for each input file.\n\nConstraints\n\n1 \\leq T \\leq 100\n\n1 \\leq N \\leq 200\n\n1 \\leq A_i \\leq 10^{18}\n\nS is a string of length N consisting of 0 and 1.\n\nAll numbers in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format.\nThe first line is as follows:\n\nT\n\nThen, T test cases follow.\nEach test case is given in the following format:\n\nN\nA_1 A_2 \\cdots A_N\nS\n\nOutput\n\nFor each test case, print a line containing 0 if x becomes 0 at the end of the game, and 1 otherwise.\n\nSample Input 1\n\n3\n2\n1 2\n10\n2\n1 1\n10\n6\n2 3 4 5 6 7\n111000\n\nSample Output 1\n\n1\n0\n0\n\nIn the first test case, if Person 1 replaces x with 0 \\oplus 1=1, we surely have x \\neq 0 at the end of the game, regardless of the choice of Person 0.\n\nIn the second test case, regardless of the choice of Person 1, Person 0 can make x=0 with a suitable choice.", "sample_input": "3\n2\n1 2\n10\n2\n1 1\n10\n6\n2 3 4 5 6 7\n111000\n"}, "reference_outputs": ["1\n0\n0\n"], "source_document_id": "p02651", "source_text": "Score : 400 points\n\nProblem Statement\n\nThere are two persons, numbered 0 and 1, and a variable x whose initial value is 0.\nThe two persons now play a game.\nThe game is played in N rounds. The following should be done in the i-th round (1 \\leq i \\leq N):\n\nPerson S_i does one of the following:\n\nReplace x with x \\oplus A_i, where \\oplus represents bitwise XOR.\n\nDo nothing.\n\nPerson 0 aims to have x=0 at the end of the game, while Person 1 aims to have x \\neq 0 at the end of the game.\n\nDetermine whether x becomes 0 at the end of the game when the two persons play optimally.\n\nSolve T test cases for each input file.\n\nConstraints\n\n1 \\leq T \\leq 100\n\n1 \\leq N \\leq 200\n\n1 \\leq A_i \\leq 10^{18}\n\nS is a string of length N consisting of 0 and 1.\n\nAll numbers in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format.\nThe first line is as follows:\n\nT\n\nThen, T test cases follow.\nEach test case is given in the following format:\n\nN\nA_1 A_2 \\cdots A_N\nS\n\nOutput\n\nFor each test case, print a line containing 0 if x becomes 0 at the end of the game, and 1 otherwise.\n\nSample Input 1\n\n3\n2\n1 2\n10\n2\n1 1\n10\n6\n2 3 4 5 6 7\n111000\n\nSample Output 1\n\n1\n0\n0\n\nIn the first test case, if Person 1 replaces x with 0 \\oplus 1=1, we surely have x \\neq 0 at the end of the game, regardless of the choice of Person 0.\n\nIn the second test case, regardless of the choice of Person 1, Person 0 can make x=0 with a suitable choice.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1105, "cpu_time_ms": 974, "memory_kb": 2972}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s929589530", "group_id": "codeNet:p02657", "input_text": "print(io.read\"*n\"*io.read\"*n\")", "language": "Lua", "metadata": {"date": 1592089212, "filename_ext": "lua", "original_language": "Lua (LuaJIT 2.1.0)", "problem_description_relpath": "problem_descriptions/p02657.html", "problem_id": "p02657", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02657/input.txt", "sample_output_relpath": "derived/input_output/data/p02657/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02657/Lua/s929589530.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s929589530", "user_id": "u726173718"}, "prompt_components": {"gold_output": "10\n", "input_to_evaluate": "print(io.read\"*n\"*io.read\"*n\")", "problem_context": "Score : 100 points\n\nProblem Statement\n\nCompute A \\times B.\n\nConstraints\n\n1 \\leq A \\leq 100\n\n1 \\leq B \\leq 100\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nPrint the value A \\times B as an integer.\n\nSample Input 1\n\n2 5\n\nSample Output 1\n\n10\n\nWe have 2 \\times 5 = 10.\n\nSample Input 2\n\n100 100\n\nSample Output 2\n\n10000", "sample_input": "2 5\n"}, "reference_outputs": ["10\n"], "source_document_id": "p02657", "source_text": "Score : 100 points\n\nProblem Statement\n\nCompute A \\times B.\n\nConstraints\n\n1 \\leq A \\leq 100\n\n1 \\leq B \\leq 100\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nPrint the value A \\times B as an integer.\n\nSample Input 1\n\n2 5\n\nSample Output 1\n\n10\n\nWe have 2 \\times 5 = 10.\n\nSample Input 2\n\n100 100\n\nSample Output 2\n\n10000", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 30, "cpu_time_ms": 2, "memory_kb": 2752}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s857160864", "group_id": "codeNet:p02660", "input_text": "local read = setmetatable({}, {__index = function(t, k) local a = {} for i=1,#k do table.insert(a, '*'..string.sub(k, i, i)) end local r = io.read local u = table.unpack or unpack return function() return r(u(a)) end end})\nread.N = function(N) local t={} for i=1,N do t[i]=read.n() end return t end\nstring.totable = function(s) local t={} local u=string.sub for i=1,#s do t[i] = u(s, i, i) end return t end\nstring.split = function(s) local t={} for w in string.gmatch(s, \"[^%s]+\") do table.insert(t, w) end return (table.unpack or unpack)(t) end\nlocal function array(dimension, default_val) assert(type(default_val) ~= 'table') local n=dimension local m={}if default_val~=nil then m[1]={__index=function()return default_val end}end for i=2,n do m[i]={__index=function(p, k)local c=setmetatable({},m[i-1])rawset(p,k,c)return c end}end return setmetatable({},m[n])end\nlocal function tostringxx(o, depth) depth = depth or 0 if depth > 10 then return \"\" end if o == _G then return \"<_G>\" end local indent0 = (\" \"):rep((depth) * 2) local indent1 = (\" \"):rep((depth+1) * 2) local indent2= (\" \"):rep((depth+2) * 2) if type(o) == 'table' then local keys = {} local types = {} for k in pairs(o) do types[type(k)] = true table.insert(keys, k) end local types_count = 0 local lasttype for k in pairs(types) do types_count = types_count + 1 lasttype = k end if types_count == 1 and (lasttype == 'string' or lasttype == 'number') then table.sort(keys) end local inside = {} for i=1,#keys do local k = keys[i] local v = o[k] if type(k) == 'string' then k = string.format('%q', k) end table.insert(inside, indent1 .. '['..tostring(k)..'] = ' .. tostringxx(v, depth + 1)) end return '{\\n' .. table.concat(inside, ',\\n') .. '\\n' .. indent0 .. '}' else if type(o) == 'string' then o = string.format('%q', o) end return tostring(o) end end\nlocal function richtraceback() local x = 2 while true do local info = debug.getinfo(x) if not info then break end local fname = '<' .. info.short_src .. \":\" .. info.linedefined .. \">\" if info.name then fname = info.name end print(info.short_src .. \":\" .. info.currentline .. \": in \" .. (\"%q\"):format(fname)) print(\" LOCALS:\") local p = 1 while true do local name, val = debug.getlocal(x,p) if not name then break end print(\" \" .. name .. \": \" .. tostringxx(val, 3)) p = p + 1 end print(\" UPVALUES:\") for p=1,info.nups do local name, val = debug.getupvalue(info.func,p) if not name then break end print(\" \" .. name .. \": \" .. tostringxx(val, 3)) end x = x + 1 end end\nlocal function myassert(b) if not b then richtraceback() error(\"assertion failed\") end end \n----\nlocal function factorize(n)\n local nn = n\n local lst = {}\n for i=2, math.floor(1 + n^0.5) do\n local k = 0\n while nn % i == 0 do\n k = k + 1\n nn = nn // i\n end\n if k > 0 then\n table.insert(lst, {i, k})\n end\n end\n if nn ~= 1 then\n table.insert(lst, {nn, 1})\n end\n return lst\nend\n----\nlocal N = read.n()\nlocal lst = factorize(N)\nlocal ans = 0\nfor k,v in ipairs(lst) do\n local p, n = v[1], v[2]\n local cur = n\n for i=1,n do\n if i <= cur then\n ans = ans + 1\n cur = cur - i\n else\n break\n end\n end\nend\nprint(ans)", "language": "Lua", "metadata": {"date": 1590975276, "filename_ext": "lua", "original_language": "Lua (Lua 5.3.5)", "problem_description_relpath": "problem_descriptions/p02660.html", "problem_id": "p02660", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02660/input.txt", "sample_output_relpath": "derived/input_output/data/p02660/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02660/Lua/s857160864.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s857160864", "user_id": "u162773977"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "local read = setmetatable({}, {__index = function(t, k) local a = {} for i=1,#k do table.insert(a, '*'..string.sub(k, i, i)) end local r = io.read local u = table.unpack or unpack return function() return r(u(a)) end end})\nread.N = function(N) local t={} for i=1,N do t[i]=read.n() end return t end\nstring.totable = function(s) local t={} local u=string.sub for i=1,#s do t[i] = u(s, i, i) end return t end\nstring.split = function(s) local t={} for w in string.gmatch(s, \"[^%s]+\") do table.insert(t, w) end return (table.unpack or unpack)(t) end\nlocal function array(dimension, default_val) assert(type(default_val) ~= 'table') local n=dimension local m={}if default_val~=nil then m[1]={__index=function()return default_val end}end for i=2,n do m[i]={__index=function(p, k)local c=setmetatable({},m[i-1])rawset(p,k,c)return c end}end return setmetatable({},m[n])end\nlocal function tostringxx(o, depth) depth = depth or 0 if depth > 10 then return \"\" end if o == _G then return \"<_G>\" end local indent0 = (\" \"):rep((depth) * 2) local indent1 = (\" \"):rep((depth+1) * 2) local indent2= (\" \"):rep((depth+2) * 2) if type(o) == 'table' then local keys = {} local types = {} for k in pairs(o) do types[type(k)] = true table.insert(keys, k) end local types_count = 0 local lasttype for k in pairs(types) do types_count = types_count + 1 lasttype = k end if types_count == 1 and (lasttype == 'string' or lasttype == 'number') then table.sort(keys) end local inside = {} for i=1,#keys do local k = keys[i] local v = o[k] if type(k) == 'string' then k = string.format('%q', k) end table.insert(inside, indent1 .. '['..tostring(k)..'] = ' .. tostringxx(v, depth + 1)) end return '{\\n' .. table.concat(inside, ',\\n') .. '\\n' .. indent0 .. '}' else if type(o) == 'string' then o = string.format('%q', o) end return tostring(o) end end\nlocal function richtraceback() local x = 2 while true do local info = debug.getinfo(x) if not info then break end local fname = '<' .. info.short_src .. \":\" .. info.linedefined .. \">\" if info.name then fname = info.name end print(info.short_src .. \":\" .. info.currentline .. \": in \" .. (\"%q\"):format(fname)) print(\" LOCALS:\") local p = 1 while true do local name, val = debug.getlocal(x,p) if not name then break end print(\" \" .. name .. \": \" .. tostringxx(val, 3)) p = p + 1 end print(\" UPVALUES:\") for p=1,info.nups do local name, val = debug.getupvalue(info.func,p) if not name then break end print(\" \" .. name .. \": \" .. tostringxx(val, 3)) end x = x + 1 end end\nlocal function myassert(b) if not b then richtraceback() error(\"assertion failed\") end end \n----\nlocal function factorize(n)\n local nn = n\n local lst = {}\n for i=2, math.floor(1 + n^0.5) do\n local k = 0\n while nn % i == 0 do\n k = k + 1\n nn = nn // i\n end\n if k > 0 then\n table.insert(lst, {i, k})\n end\n end\n if nn ~= 1 then\n table.insert(lst, {nn, 1})\n end\n return lst\nend\n----\nlocal N = read.n()\nlocal lst = factorize(N)\nlocal ans = 0\nfor k,v in ipairs(lst) do\n local p, n = v[1], v[2]\n local cur = n\n for i=1,n do\n if i <= cur then\n ans = ans + 1\n cur = cur - i\n else\n break\n end\n end\nend\nprint(ans)", "problem_context": "Score : 400 points\n\nProblem Statement\n\nGiven is a positive integer N. Consider repeatedly applying the operation below on N:\n\nFirst, choose a positive integer z satisfying all of the conditions below:\n\nz can be represented as z=p^e, where p is a prime number and e is a positive integer;\n\nz divides N;\n\nz is different from all integers chosen in previous operations.\n\nThen, replace N with N/z.\n\nFind the maximum number of times the operation can be applied.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^{12}\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the maximum number of times the operation can be applied.\n\nSample Input 1\n\n24\n\nSample Output 1\n\n3\n\nWe can apply the operation three times by, for example, making the following choices:\n\nChoose z=2 (=2^1). (Now we have N=12.)\n\nChoose z=3 (=3^1). (Now we have N=4.)\n\nChoose z=4 (=2^2). (Now we have N=1.)\n\nSample Input 2\n\n1\n\nSample Output 2\n\n0\n\nWe cannot apply the operation at all.\n\nSample Input 3\n\n64\n\nSample Output 3\n\n3\n\nWe can apply the operation three times by, for example, making the following choices:\n\nChoose z=2 (=2^1). (Now we have N=32.)\n\nChoose z=4 (=2^2). (Now we have N=8.)\n\nChoose z=8 (=2^3). (Now we have N=1.)\n\nSample Input 4\n\n1000000007\n\nSample Output 4\n\n1\n\nWe can apply the operation once by, for example, making the following choice:\n\nz=1000000007 (=1000000007^1). (Now we have N=1.)\n\nSample Input 5\n\n997764507000\n\nSample Output 5\n\n7", "sample_input": "24\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02660", "source_text": "Score : 400 points\n\nProblem Statement\n\nGiven is a positive integer N. Consider repeatedly applying the operation below on N:\n\nFirst, choose a positive integer z satisfying all of the conditions below:\n\nz can be represented as z=p^e, where p is a prime number and e is a positive integer;\n\nz divides N;\n\nz is different from all integers chosen in previous operations.\n\nThen, replace N with N/z.\n\nFind the maximum number of times the operation can be applied.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^{12}\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the maximum number of times the operation can be applied.\n\nSample Input 1\n\n24\n\nSample Output 1\n\n3\n\nWe can apply the operation three times by, for example, making the following choices:\n\nChoose z=2 (=2^1). (Now we have N=12.)\n\nChoose z=3 (=3^1). (Now we have N=4.)\n\nChoose z=4 (=2^2). (Now we have N=1.)\n\nSample Input 2\n\n1\n\nSample Output 2\n\n0\n\nWe cannot apply the operation at all.\n\nSample Input 3\n\n64\n\nSample Output 3\n\n3\n\nWe can apply the operation three times by, for example, making the following choices:\n\nChoose z=2 (=2^1). (Now we have N=32.)\n\nChoose z=4 (=2^2). (Now we have N=8.)\n\nChoose z=8 (=2^3). (Now we have N=1.)\n\nSample Input 4\n\n1000000007\n\nSample Output 4\n\n1\n\nWe can apply the operation once by, for example, making the following choice:\n\nz=1000000007 (=1000000007^1). (Now we have N=1.)\n\nSample Input 5\n\n997764507000\n\nSample Output 5\n\n7", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 3262, "cpu_time_ms": 44, "memory_kb": 3168}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s081601921", "group_id": "codeNet:p02661", "input_text": "local mfl, mce = math.floor, math.ceil\nlocal n = io.read(\"*n\")\nlocal a, b = {}, {}\nfor i = 1, n do\n a[i], b[i] = io.read(\"*n\", \"*n\")\nend\n\nlocal function solvelow(x)\n local c = 0\n for i = 1, n do\n if a[i] <= x then\n c = c + 1\n end\n end\n return n + 1 <= c * 2\nend\n\nlocal function solvehigh(x)\n local c = 0\n for i = 1, n do\n if x <= b[i] then\n c = c + 1\n end\n end\n return n + 1 <= c * 2\nend\n\nlocal function solvelow_even(x)\n local c = 0\n local lowmax, highmin = -1, 2000000007\n for i = 1, n do\n if a[i] <= x then\n c = c + 1\n if lowmax < a[i] then\n lowmax = a[i]\n end\n else\n if a[i] < highmin then\n highmin = a[i]\n end\n end\n end\n if n < c * 2 then return true\n elseif n == c * 2 then\n local diff = x - lowmax\n return highmin - x <= diff\n else\n return false\n end\nend\n\nlocal function solvehigh_even(x)\n local c = 0\n local lowmax, highmin = -1, 2000000007\n for i = 1, n do\n if x <= b[i] then\n c = c + 1\n if b[i] < highmin then\n highmin = b[i]\n end\n else\n if lowmax < b[i] then\n lowmax = b[i]\n end\n end\n end\n if n < c * 2 then return true\n elseif n == c * 2 then\n local diff = highmin - x\n return x - lowmax <= diff\n else\n return false\n end\nend\n\nif n % 2 == 1 then\n local min, max = 0, 1000000000\n while 1 < max - min do\n local mid = mfl((min + max) / 2)\n if solvelow(mid) then\n max = mid\n else\n min = mid\n end\n end\n local lowlim = max\n min, max = 1, 1000000001\n while 1 < max - min do\n local mid = mfl((min + max) / 2)\n if solvehigh(mid) then\n min = mid\n else\n max = mid\n end\n end\n local highlim = min\n print(highlim - lowlim + 1)\nelse\n for i = 1, n do\n a[i], b[i] = a[i] * 2, b[i] * 2\n end\n local min, max = 0, 2000000100\n while 1 < max - min do\n local mid = mfl((min + max) / 2)\n if solvelow_even(mid) then\n max = mid\n else\n min = mid\n end\n end\n local lowlim = max\n min, max = 1, 2000000101\n while 1 < max - min do\n local mid = mfl((min + max) / 2)\n if solvehigh_even(mid) then\n min = mid\n else\n max = mid\n end\n end\n local highlim = min\n print(highlim - lowlim + 1)\nend\n", "language": "Lua", "metadata": {"date": 1590975886, "filename_ext": "lua", "original_language": "Lua (LuaJIT 2.1.0)", "problem_description_relpath": "problem_descriptions/p02661.html", "problem_id": "p02661", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02661/input.txt", "sample_output_relpath": "derived/input_output/data/p02661/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02661/Lua/s081601921.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s081601921", "user_id": "u120582723"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "local mfl, mce = math.floor, math.ceil\nlocal n = io.read(\"*n\")\nlocal a, b = {}, {}\nfor i = 1, n do\n a[i], b[i] = io.read(\"*n\", \"*n\")\nend\n\nlocal function solvelow(x)\n local c = 0\n for i = 1, n do\n if a[i] <= x then\n c = c + 1\n end\n end\n return n + 1 <= c * 2\nend\n\nlocal function solvehigh(x)\n local c = 0\n for i = 1, n do\n if x <= b[i] then\n c = c + 1\n end\n end\n return n + 1 <= c * 2\nend\n\nlocal function solvelow_even(x)\n local c = 0\n local lowmax, highmin = -1, 2000000007\n for i = 1, n do\n if a[i] <= x then\n c = c + 1\n if lowmax < a[i] then\n lowmax = a[i]\n end\n else\n if a[i] < highmin then\n highmin = a[i]\n end\n end\n end\n if n < c * 2 then return true\n elseif n == c * 2 then\n local diff = x - lowmax\n return highmin - x <= diff\n else\n return false\n end\nend\n\nlocal function solvehigh_even(x)\n local c = 0\n local lowmax, highmin = -1, 2000000007\n for i = 1, n do\n if x <= b[i] then\n c = c + 1\n if b[i] < highmin then\n highmin = b[i]\n end\n else\n if lowmax < b[i] then\n lowmax = b[i]\n end\n end\n end\n if n < c * 2 then return true\n elseif n == c * 2 then\n local diff = highmin - x\n return x - lowmax <= diff\n else\n return false\n end\nend\n\nif n % 2 == 1 then\n local min, max = 0, 1000000000\n while 1 < max - min do\n local mid = mfl((min + max) / 2)\n if solvelow(mid) then\n max = mid\n else\n min = mid\n end\n end\n local lowlim = max\n min, max = 1, 1000000001\n while 1 < max - min do\n local mid = mfl((min + max) / 2)\n if solvehigh(mid) then\n min = mid\n else\n max = mid\n end\n end\n local highlim = min\n print(highlim - lowlim + 1)\nelse\n for i = 1, n do\n a[i], b[i] = a[i] * 2, b[i] * 2\n end\n local min, max = 0, 2000000100\n while 1 < max - min do\n local mid = mfl((min + max) / 2)\n if solvelow_even(mid) then\n max = mid\n else\n min = mid\n end\n end\n local lowlim = max\n min, max = 1, 2000000101\n while 1 < max - min do\n local mid = mfl((min + max) / 2)\n if solvehigh_even(mid) then\n min = mid\n else\n max = mid\n end\n end\n local highlim = min\n print(highlim - lowlim + 1)\nend\n", "problem_context": "Score : 500 points\n\nProblem Statement\n\nThere are N integers X_1, X_2, \\cdots, X_N, and we know that A_i \\leq X_i \\leq B_i.\nFind the number of different values that the median of X_1, X_2, \\cdots, X_N can take.\n\nNotes\n\nThe median of X_1, X_2, \\cdots, X_N is defined as follows. Let x_1, x_2, \\cdots, x_N be the result of sorting X_1, X_2, \\cdots, X_N in ascending order.\n\nIf N is odd, the median is x_{(N+1)/2};\n\nif N is even, the median is (x_{N/2} + x_{N/2+1}) / 2.\n\nConstraints\n\n2 \\leq N \\leq 2 \\times 10^5\n\n1 \\leq A_i \\leq B_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 B_1\nA_2 B_2\n:\nA_N B_N\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n2\n1 2\n2 3\n\nSample Output 1\n\n3\n\nIf X_1 = 1 and X_2 = 2, the median is \\frac{3}{2};\n\nif X_1 = 1 and X_2 = 3, the median is 2;\n\nif X_1 = 2 and X_2 = 2, the median is 2;\n\nif X_1 = 2 and X_2 = 3, the median is \\frac{5}{2}.\n\nThus, the median can take three values: \\frac{3}{2}, 2, and \\frac{5}{2}.\n\nSample Input 2\n\n3\n100 100\n10 10000\n1 1000000000\n\nSample Output 2\n\n9991", "sample_input": "2\n1 2\n2 3\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02661", "source_text": "Score : 500 points\n\nProblem Statement\n\nThere are N integers X_1, X_2, \\cdots, X_N, and we know that A_i \\leq X_i \\leq B_i.\nFind the number of different values that the median of X_1, X_2, \\cdots, X_N can take.\n\nNotes\n\nThe median of X_1, X_2, \\cdots, X_N is defined as follows. Let x_1, x_2, \\cdots, x_N be the result of sorting X_1, X_2, \\cdots, X_N in ascending order.\n\nIf N is odd, the median is x_{(N+1)/2};\n\nif N is even, the median is (x_{N/2} + x_{N/2+1}) / 2.\n\nConstraints\n\n2 \\leq N \\leq 2 \\times 10^5\n\n1 \\leq A_i \\leq B_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 B_1\nA_2 B_2\n:\nA_N B_N\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n2\n1 2\n2 3\n\nSample Output 1\n\n3\n\nIf X_1 = 1 and X_2 = 2, the median is \\frac{3}{2};\n\nif X_1 = 1 and X_2 = 3, the median is 2;\n\nif X_1 = 2 and X_2 = 2, the median is 2;\n\nif X_1 = 2 and X_2 = 3, the median is \\frac{5}{2}.\n\nThus, the median can take three values: \\frac{3}{2}, 2, and \\frac{5}{2}.\n\nSample Input 2\n\n3\n100 100\n10 10000\n1 1000000000\n\nSample Output 2\n\n9991", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2237, "cpu_time_ms": 193, "memory_kb": 6944}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s486842039", "group_id": "codeNet:p02662", "input_text": "local mmi, mma = math.min, math.max\nlocal mod = 998244353\nlocal mfl = math.floor\nlocal function bmul(x, y)\n local x0, y0 = x % 31596, y % 31596\n local x1, y1 = mfl(x / 31596), mfl(y / 31596)\n return (x1 * y1 * 62863 + (x1 * y0 + x0 * y1) * 31596 + x0 * y0) % mod\nend\nlocal function badd(x, y)\n return (x + y) % mod\nend\n\nlocal n, s = io.read(\"*n\", \"*n\")\nlocal a = {}\nfor i = 1, n do\n a[i] = io.read(\"*n\")\nend\nlocal dp = {}\nfor i = 1, s + 1 do\n dp[i] = 0\nend\ndp[1] = 1\nfor i = 1, n do\n local v = a[i]\n for j = s + 1, mma(1, s + 2 - v), -1 do\n dp[j] = bmul(dp[j], 2)\n end\n for j = s + 1 - v, 1, -1 do\n dp[j + v] = badd(dp[j + v], dp[j])\n dp[j] = bmul(dp[j], 2)\n end\nend\nprint(dp[s + 1])\n", "language": "Lua", "metadata": {"date": 1590976754, "filename_ext": "lua", "original_language": "Lua (LuaJIT 2.1.0)", "problem_description_relpath": "problem_descriptions/p02662.html", "problem_id": "p02662", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02662/input.txt", "sample_output_relpath": "derived/input_output/data/p02662/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02662/Lua/s486842039.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s486842039", "user_id": "u120582723"}, "prompt_components": {"gold_output": "6\n", "input_to_evaluate": "local mmi, mma = math.min, math.max\nlocal mod = 998244353\nlocal mfl = math.floor\nlocal function bmul(x, y)\n local x0, y0 = x % 31596, y % 31596\n local x1, y1 = mfl(x / 31596), mfl(y / 31596)\n return (x1 * y1 * 62863 + (x1 * y0 + x0 * y1) * 31596 + x0 * y0) % mod\nend\nlocal function badd(x, y)\n return (x + y) % mod\nend\n\nlocal n, s = io.read(\"*n\", \"*n\")\nlocal a = {}\nfor i = 1, n do\n a[i] = io.read(\"*n\")\nend\nlocal dp = {}\nfor i = 1, s + 1 do\n dp[i] = 0\nend\ndp[1] = 1\nfor i = 1, n do\n local v = a[i]\n for j = s + 1, mma(1, s + 2 - v), -1 do\n dp[j] = bmul(dp[j], 2)\n end\n for j = s + 1 - v, 1, -1 do\n dp[j + v] = badd(dp[j + v], dp[j])\n dp[j] = bmul(dp[j], 2)\n end\nend\nprint(dp[s + 1])\n", "problem_context": "Score : 600 points\n\nProblem Statement\n\nGiven are a sequence of N positive integers A_1, A_2, \\ldots, A_N and another positive integer S.\n\nFor a non-empty subset T of the set \\{1, 2, \\ldots , N \\}, let us define f(T) as follows:\n\nf(T) is the number of different non-empty subsets \\{x_1, x_2, \\ldots , x_k \\} of T such that A_{x_1}+A_{x_2}+\\cdots +A_{x_k} = S.\n\nFind the sum of f(T) over all 2^N-1 subsets T of \\{1, 2, \\ldots , N \\}. Since the sum can be enormous, print it modulo 998244353.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 3000\n\n1 \\leq S \\leq 3000\n\n1 \\leq A_i \\leq 3000\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN S\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the sum of f(T) modulo 998244353.\n\nSample Input 1\n\n3 4\n2 2 4\n\nSample Output 1\n\n6\n\nFor each T, the value of f(T) is shown below. The sum of these values is 6.\n\nf(\\{1\\}) = 0\n\nf(\\{2\\}) = 0\n\nf(\\{3\\}) = 1 (One subset \\{3\\} satisfies the condition.)\n\nf(\\{1, 2\\}) = 1 (\\{1, 2\\})\n\nf(\\{2, 3\\}) = 1 (\\{3\\})\n\nf(\\{1, 3\\}) = 1 (\\{3\\})\n\nf(\\{1, 2, 3\\}) = 2 (\\{1, 2\\}, \\{3\\})\n\nSample Input 2\n\n5 8\n9 9 9 9 9\n\nSample Output 2\n\n0\n\nSample Input 3\n\n10 10\n3 1 4 1 5 9 2 6 5 3\n\nSample Output 3\n\n3296", "sample_input": "3 4\n2 2 4\n"}, "reference_outputs": ["6\n"], "source_document_id": "p02662", "source_text": "Score : 600 points\n\nProblem Statement\n\nGiven are a sequence of N positive integers A_1, A_2, \\ldots, A_N and another positive integer S.\n\nFor a non-empty subset T of the set \\{1, 2, \\ldots , N \\}, let us define f(T) as follows:\n\nf(T) is the number of different non-empty subsets \\{x_1, x_2, \\ldots , x_k \\} of T such that A_{x_1}+A_{x_2}+\\cdots +A_{x_k} = S.\n\nFind the sum of f(T) over all 2^N-1 subsets T of \\{1, 2, \\ldots , N \\}. Since the sum can be enormous, print it modulo 998244353.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 3000\n\n1 \\leq S \\leq 3000\n\n1 \\leq A_i \\leq 3000\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN S\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the sum of f(T) modulo 998244353.\n\nSample Input 1\n\n3 4\n2 2 4\n\nSample Output 1\n\n6\n\nFor each T, the value of f(T) is shown below. The sum of these values is 6.\n\nf(\\{1\\}) = 0\n\nf(\\{2\\}) = 0\n\nf(\\{3\\}) = 1 (One subset \\{3\\} satisfies the condition.)\n\nf(\\{1, 2\\}) = 1 (\\{1, 2\\})\n\nf(\\{2, 3\\}) = 1 (\\{3\\})\n\nf(\\{1, 3\\}) = 1 (\\{3\\})\n\nf(\\{1, 2, 3\\}) = 2 (\\{1, 2\\}, \\{3\\})\n\nSample Input 2\n\n5 8\n9 9 9 9 9\n\nSample Output 2\n\n0\n\nSample Input 3\n\n10 10\n3 1 4 1 5 9 2 6 5 3\n\nSample Output 3\n\n3296", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 704, "cpu_time_ms": 72, "memory_kb": 2728}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s697960702", "group_id": "codeNet:p02669", "input_text": "local mma = math.max\nlocal mfl, mce, mmi = math.floor, math.ceil, math.min\n\nlocal AvlTree = {}\nAvlTree.makenode = function(self, val, parent)\n local i = self.box[#self.box]\n if not i then i = #self.v + 1\n else table.remove(self.box)\n end\n self.v[i], self.p[i] = val, parent\n self.lc[i], self.rc[i], self.l[i], self.r[i] = 0, 0, 1, 1\n return i\nend\nAvlTree.create = function(self, lessthan, n)\n self.lessthan = lessthan\n self.root = 1\n self.box = {}\n for i = n + 1, 2, -1 do table.insert(self.box, i) end\n -- value, leftCount, rightCount, left, right, parent\n self.v, self.lc, self.rc, self.l, self.r, self.p = {}, {}, {}, {}, {}, {}\n for i = 1, n + 1 do\n self.v[i], self.p[i] = 0, 1\n self.lc[i], self.rc[i], self.l[i], self.r[i] = 0, 0, 1, 1\n end\nend\nAvlTree.clear = function(self)\n local n = #self.box\n self.root = 1\n self.box = {}\n for i = n + 1, 2, -1 do self.box[n + 2 - i] = i end\n self.v, self.lc, self.rc, self.l, self.r, self.p = {}, {}, {}, {}, {}, {}\n for i = 1, n + 1 do\n self.v[i], self.p[i] = 0, 1\n self.lc[i], self.rc[i], self.l[i], self.r[i] = 0, 0, 1, 1\n end\nend\n\nAvlTree.recalc = function(self, i)\n local kl, kr = self.l[i], self.r[i]\n if 1 < kl then self.lc[i] = 1 + mma(self.lc[kl], self.rc[kl])\n else self.lc[i] = 0\n end\n if 1 < kr then self.rc[i] = 1 + mma(self.lc[kr], self.rc[kr])\n else self.rc[i] = 0\n end\nend\nAvlTree.recalcAll = function(self, i)\n while 1 < i do\n self:recalc(i)\n i = self.p[i]\n end\nend\n\nAvlTree.rotR = function(self, parent)\n local granp, child = self.p[parent], self.l[parent]\n self.r[child], self.l[parent] = parent, self.r[child]\n self.p[child], self.p[parent] = granp, child\n self.p[self.l[parent]] = parent\n if 1 < granp then\n if self.l[granp] == parent then\n self.l[granp] = child\n else\n self.r[granp] = child\n end\n else\n self.root = child\n end\nend\n\nAvlTree.rotL = function(self, parent)\n local granp, child = self.p[parent], self.r[parent]\n self.l[child], self.r[parent] = parent, self.l[child]\n self.p[child], self.p[parent] = granp, child\n self.p[self.r[parent]] = parent\n if 1 < granp then\n if self.r[granp] == parent then\n self.r[granp] = child\n else\n self.l[granp] = child\n end\n else\n self.root = child\n end\nend\n\nAvlTree.rotLR = function(self, lparent, rparent)\n local sp, sl, sr = self.p, self.l, self.r\n local granp, d = sp[rparent], sr[lparent]\n sp[lparent], sr[lparent] = d, sl[d]\n sp[rparent], sl[rparent] = d, sr[d]\n sp[sl[d]], sp[sr[d]] = lparent, rparent\n sp[d], sl[d], sr[d] = granp, lparent, rparent\n if 1 < granp then\n if sr[granp] == rparent then sr[granp] = d\n else sl[granp] = d\n end\n else self.root = d\n end\nend\n\nAvlTree.rotRL = function(self, rparent, lparent)\n local sp, sl, sr = self.p, self.l, self.r\n local granp, d = sp[lparent], sl[rparent]\n sp[rparent], sl[rparent] = d, sr[d]\n sp[lparent], sr[lparent] = d, sl[d]\n sp[sr[d]], sp[sl[d]] = rparent, lparent\n sp[d], sr[d], sl[d] = granp, rparent, lparent\n if 1 < granp then\n if sl[granp] == lparent then sl[granp] = d\n else sr[granp] = d\n end\n else self.root = d\n end\nend\n\nAvlTree.empty = function(self)\n return self.root <= 1\nend\n\nAvlTree.push = function(self, val)\n if self.root <= 1 then self.root = self:makenode(val, 1) return end\n local pos = self.root\n while true do\n if self.lessthan(val, self.v[pos]) then\n if 1 < self.l[pos] then\n pos = self.l[pos]\n else\n self.l[pos] = self:makenode(val, pos)\n pos = self.l[pos]\n break\n end\n else\n if 1 < self.r[pos] then\n pos = self.r[pos]\n else\n self.r[pos] = self:makenode(val, pos)\n pos = self.r[pos]\n break\n end\n end\n end\n while 1 < pos do\n local child, parent = pos, self.p[pos]\n if parent <= 1 then\n break\n end\n self:recalc(parent)\n local lcp_m_rcp = self.lc[parent] - self.rc[parent]\n if lcp_m_rcp % 2 ~= 0 then -- 1 or -1\n pos = parent\n elseif lcp_m_rcp == 2 then\n if self.lc[child] - 1 == self.rc[child] then\n self:rotR(parent)\n self:recalcAll(parent)\n else\n self:rotLR(child, parent)\n self:recalc(child)\n self:recalcAll(parent)\n end\n break\n elseif lcp_m_rcp == -2 then\n if self.rc[child] - 1 == self.lc[child] then\n self:rotL(parent)\n self:recalcAll(parent)\n else\n self:rotRL(child, parent)\n self:recalc(child)\n self:recalcAll(parent)\n end\n break\n else\n break\n end\n end\nend\n\nAvlTree.rmsub = function(self, node)\n while 1 < node do\n self:recalc(node)\n if self.lc[node] == self.rc[node] then\n node = self.p[node]\n elseif self.lc[node] + 1 == self.rc[node] then\n self:recalcAll(self.p[node])\n break\n else\n if self.lc[self.r[node]] == self.rc[self.r[node]] then\n self:rotL(node)\n self:recalcAll(node)\n break\n elseif self.lc[self.r[node]] + 1 == self.rc[self.r[node]] then\n local nr = self.r[node]\n self:rotL(node)\n self:recalc(node)\n node = nr\n else\n local nr = self.r[node]\n local nrl = self.l[nr]\n self:rotRL(nr, node)\n self:recalc(nr)\n self:recalc(node)\n node = nrl\n end\n end\n end\nend\n\nAvlTree.pop = function(self)\n local node = self.root\n while 1 < self.l[node] do\n node = self.l[node]\n end\n local v = self.v[node]\n local kp = self.p[node]\n self.p[self.r[node]] = kp\n if 1 < kp then\n self.l[kp] = self.r[node]\n self:rmsub(kp)\n else\n self.root = self.r[node]\n end\n table.insert(self.box, node)\n return v\nend\n\nAvlTree.new = function(lessthan, n)\n local obj = {}\n setmetatable(obj, {__index = AvlTree})\n obj:create(lessthan, n)\n return obj\nend\n\nlocal q = io.read(\"*n\")\nlocal len = {}\nlocal function lt(x, y)\n return len[x] < len[y]\nend\nlocal avl = AvlTree.new(lt, 1)\n\nlocal function pushfunc(dst, dstcost)\n if not len[dst] or dstcost < len[dst] then\n len[dst] = dstcost\n avl:push(dst)\n end\nend\n\nfor iq = 1, q do\n local n, a, b, c, d = io.read(\"*n\", \"*n\", \"*n\", \"*n\", \"*n\")\n local t = {}\n len = {}\n len[n] = 0\n avl:clear()\n avl:push(n)\n local inf = 1000000007 * 1000000007\n local cand = inf\n while not avl:empty() do\n local src = avl:pop()\n local cost = len[src]\n local zf = d * src\n if zf < 1000000000 * 2 * 128 then\n local z = cost + d * src\n if 1 <= z then\n cand = mmi(cand, z)\n end\n end\n if 1 < src then\n -- print(src, cost)\n local dst = src // 2\n local dstcost = cost + d * (src % 2) + a\n pushfunc(dst, dstcost)\n if dst % 2 ~= 0 then\n dst = dst + 1\n dstcost = cost + d * (2 - (src % 2)) + a\n pushfunc(dst, dstcost)\n end\n dst = src // 3\n dstcost = cost + d * (src % 3) + b\n pushfunc(dst, dstcost)\n if dst % 3 ~= 0 then\n dst = dst + 1\n dstcost = cost + d * (3 - (src % 3)) + b\n pushfunc(dst, dstcost)\n end\n dst = src // 5\n dstcost = cost + d * (src % 5) + c\n pushfunc(dst, dstcost)\n if dst % 5 ~= 0 then\n dst = dst + 1\n dstcost = cost + d * (5 - (src % 5)) + c\n pushfunc(dst, dstcost)\n end\n end\n end\n print(cand)\nend\n", "language": "Lua", "metadata": {"date": 1590284910, "filename_ext": "lua", "original_language": "Lua (Lua 5.3.5)", "problem_description_relpath": "problem_descriptions/p02669.html", "problem_id": "p02669", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02669/input.txt", "sample_output_relpath": "derived/input_output/data/p02669/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02669/Lua/s697960702.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s697960702", "user_id": "u120582723"}, "prompt_components": {"gold_output": "20\n19\n26\n3821859835\n23441258666\n", "input_to_evaluate": "local mma = math.max\nlocal mfl, mce, mmi = math.floor, math.ceil, math.min\n\nlocal AvlTree = {}\nAvlTree.makenode = function(self, val, parent)\n local i = self.box[#self.box]\n if not i then i = #self.v + 1\n else table.remove(self.box)\n end\n self.v[i], self.p[i] = val, parent\n self.lc[i], self.rc[i], self.l[i], self.r[i] = 0, 0, 1, 1\n return i\nend\nAvlTree.create = function(self, lessthan, n)\n self.lessthan = lessthan\n self.root = 1\n self.box = {}\n for i = n + 1, 2, -1 do table.insert(self.box, i) end\n -- value, leftCount, rightCount, left, right, parent\n self.v, self.lc, self.rc, self.l, self.r, self.p = {}, {}, {}, {}, {}, {}\n for i = 1, n + 1 do\n self.v[i], self.p[i] = 0, 1\n self.lc[i], self.rc[i], self.l[i], self.r[i] = 0, 0, 1, 1\n end\nend\nAvlTree.clear = function(self)\n local n = #self.box\n self.root = 1\n self.box = {}\n for i = n + 1, 2, -1 do self.box[n + 2 - i] = i end\n self.v, self.lc, self.rc, self.l, self.r, self.p = {}, {}, {}, {}, {}, {}\n for i = 1, n + 1 do\n self.v[i], self.p[i] = 0, 1\n self.lc[i], self.rc[i], self.l[i], self.r[i] = 0, 0, 1, 1\n end\nend\n\nAvlTree.recalc = function(self, i)\n local kl, kr = self.l[i], self.r[i]\n if 1 < kl then self.lc[i] = 1 + mma(self.lc[kl], self.rc[kl])\n else self.lc[i] = 0\n end\n if 1 < kr then self.rc[i] = 1 + mma(self.lc[kr], self.rc[kr])\n else self.rc[i] = 0\n end\nend\nAvlTree.recalcAll = function(self, i)\n while 1 < i do\n self:recalc(i)\n i = self.p[i]\n end\nend\n\nAvlTree.rotR = function(self, parent)\n local granp, child = self.p[parent], self.l[parent]\n self.r[child], self.l[parent] = parent, self.r[child]\n self.p[child], self.p[parent] = granp, child\n self.p[self.l[parent]] = parent\n if 1 < granp then\n if self.l[granp] == parent then\n self.l[granp] = child\n else\n self.r[granp] = child\n end\n else\n self.root = child\n end\nend\n\nAvlTree.rotL = function(self, parent)\n local granp, child = self.p[parent], self.r[parent]\n self.l[child], self.r[parent] = parent, self.l[child]\n self.p[child], self.p[parent] = granp, child\n self.p[self.r[parent]] = parent\n if 1 < granp then\n if self.r[granp] == parent then\n self.r[granp] = child\n else\n self.l[granp] = child\n end\n else\n self.root = child\n end\nend\n\nAvlTree.rotLR = function(self, lparent, rparent)\n local sp, sl, sr = self.p, self.l, self.r\n local granp, d = sp[rparent], sr[lparent]\n sp[lparent], sr[lparent] = d, sl[d]\n sp[rparent], sl[rparent] = d, sr[d]\n sp[sl[d]], sp[sr[d]] = lparent, rparent\n sp[d], sl[d], sr[d] = granp, lparent, rparent\n if 1 < granp then\n if sr[granp] == rparent then sr[granp] = d\n else sl[granp] = d\n end\n else self.root = d\n end\nend\n\nAvlTree.rotRL = function(self, rparent, lparent)\n local sp, sl, sr = self.p, self.l, self.r\n local granp, d = sp[lparent], sl[rparent]\n sp[rparent], sl[rparent] = d, sr[d]\n sp[lparent], sr[lparent] = d, sl[d]\n sp[sr[d]], sp[sl[d]] = rparent, lparent\n sp[d], sr[d], sl[d] = granp, rparent, lparent\n if 1 < granp then\n if sl[granp] == lparent then sl[granp] = d\n else sr[granp] = d\n end\n else self.root = d\n end\nend\n\nAvlTree.empty = function(self)\n return self.root <= 1\nend\n\nAvlTree.push = function(self, val)\n if self.root <= 1 then self.root = self:makenode(val, 1) return end\n local pos = self.root\n while true do\n if self.lessthan(val, self.v[pos]) then\n if 1 < self.l[pos] then\n pos = self.l[pos]\n else\n self.l[pos] = self:makenode(val, pos)\n pos = self.l[pos]\n break\n end\n else\n if 1 < self.r[pos] then\n pos = self.r[pos]\n else\n self.r[pos] = self:makenode(val, pos)\n pos = self.r[pos]\n break\n end\n end\n end\n while 1 < pos do\n local child, parent = pos, self.p[pos]\n if parent <= 1 then\n break\n end\n self:recalc(parent)\n local lcp_m_rcp = self.lc[parent] - self.rc[parent]\n if lcp_m_rcp % 2 ~= 0 then -- 1 or -1\n pos = parent\n elseif lcp_m_rcp == 2 then\n if self.lc[child] - 1 == self.rc[child] then\n self:rotR(parent)\n self:recalcAll(parent)\n else\n self:rotLR(child, parent)\n self:recalc(child)\n self:recalcAll(parent)\n end\n break\n elseif lcp_m_rcp == -2 then\n if self.rc[child] - 1 == self.lc[child] then\n self:rotL(parent)\n self:recalcAll(parent)\n else\n self:rotRL(child, parent)\n self:recalc(child)\n self:recalcAll(parent)\n end\n break\n else\n break\n end\n end\nend\n\nAvlTree.rmsub = function(self, node)\n while 1 < node do\n self:recalc(node)\n if self.lc[node] == self.rc[node] then\n node = self.p[node]\n elseif self.lc[node] + 1 == self.rc[node] then\n self:recalcAll(self.p[node])\n break\n else\n if self.lc[self.r[node]] == self.rc[self.r[node]] then\n self:rotL(node)\n self:recalcAll(node)\n break\n elseif self.lc[self.r[node]] + 1 == self.rc[self.r[node]] then\n local nr = self.r[node]\n self:rotL(node)\n self:recalc(node)\n node = nr\n else\n local nr = self.r[node]\n local nrl = self.l[nr]\n self:rotRL(nr, node)\n self:recalc(nr)\n self:recalc(node)\n node = nrl\n end\n end\n end\nend\n\nAvlTree.pop = function(self)\n local node = self.root\n while 1 < self.l[node] do\n node = self.l[node]\n end\n local v = self.v[node]\n local kp = self.p[node]\n self.p[self.r[node]] = kp\n if 1 < kp then\n self.l[kp] = self.r[node]\n self:rmsub(kp)\n else\n self.root = self.r[node]\n end\n table.insert(self.box, node)\n return v\nend\n\nAvlTree.new = function(lessthan, n)\n local obj = {}\n setmetatable(obj, {__index = AvlTree})\n obj:create(lessthan, n)\n return obj\nend\n\nlocal q = io.read(\"*n\")\nlocal len = {}\nlocal function lt(x, y)\n return len[x] < len[y]\nend\nlocal avl = AvlTree.new(lt, 1)\n\nlocal function pushfunc(dst, dstcost)\n if not len[dst] or dstcost < len[dst] then\n len[dst] = dstcost\n avl:push(dst)\n end\nend\n\nfor iq = 1, q do\n local n, a, b, c, d = io.read(\"*n\", \"*n\", \"*n\", \"*n\", \"*n\")\n local t = {}\n len = {}\n len[n] = 0\n avl:clear()\n avl:push(n)\n local inf = 1000000007 * 1000000007\n local cand = inf\n while not avl:empty() do\n local src = avl:pop()\n local cost = len[src]\n local zf = d * src\n if zf < 1000000000 * 2 * 128 then\n local z = cost + d * src\n if 1 <= z then\n cand = mmi(cand, z)\n end\n end\n if 1 < src then\n -- print(src, cost)\n local dst = src // 2\n local dstcost = cost + d * (src % 2) + a\n pushfunc(dst, dstcost)\n if dst % 2 ~= 0 then\n dst = dst + 1\n dstcost = cost + d * (2 - (src % 2)) + a\n pushfunc(dst, dstcost)\n end\n dst = src // 3\n dstcost = cost + d * (src % 3) + b\n pushfunc(dst, dstcost)\n if dst % 3 ~= 0 then\n dst = dst + 1\n dstcost = cost + d * (3 - (src % 3)) + b\n pushfunc(dst, dstcost)\n end\n dst = src // 5\n dstcost = cost + d * (src % 5) + c\n pushfunc(dst, dstcost)\n if dst % 5 ~= 0 then\n dst = dst + 1\n dstcost = cost + d * (5 - (src % 5)) + c\n pushfunc(dst, dstcost)\n end\n end\n end\n print(cand)\nend\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nYou start with the number 0 and you want to reach the number N.\n\nYou can change the number, paying a certain amount of coins, with the following operations:\n\nMultiply the number by 2, paying A coins.\n\nMultiply the number by 3, paying B coins.\n\nMultiply the number by 5, paying C coins.\n\nIncrease or decrease the number by 1, paying D coins.\n\nYou can perform these operations in arbitrary order and an arbitrary number of times.\n\nWhat is the minimum number of coins you need to reach N?\n\nYou have to solve T testcases.\n\nConstraints\n\n1 \\le T \\le 10\n\n1 \\le N \\le 10^{18}\n\n1 \\le A, B, C, D \\le 10^9\n\nAll numbers N, A, B, C, D are integers.\n\nInput\n\nThe input is given from Standard Input. The first line of the input is\n\nT\n\nThen, T lines follow describing the T testcases.\nEach of the T lines has the format\n\nN A B C D\n\nOutput\n\nFor each testcase, print the answer on Standard Output followed by a newline.\n\nSample Input 1\n\n5\n11 1 2 4 8\n11 1 2 2 8\n32 10 8 5 4\n29384293847243 454353412 332423423 934923490 1\n900000000000000000 332423423 454353412 934923490 987654321\n\nSample Output 1\n\n20\n19\n26\n3821859835\n23441258666\n\nFor the first testcase, a sequence of moves that achieves the minimum cost of 20 is:\n\nInitially x = 0.\n\nPay 8 to increase by 1 (x = 1).\n\nPay 1 to multiply by 2 (x = 2).\n\nPay 1 to multiply by 2 (x = 4).\n\nPay 2 to multiply by 3 (x = 12).\n\nPay 8 to decrease by 1 (x = 11).\n\nFor the second testcase, a sequence of moves that achieves the minimum cost of 19 is:\n\nInitially x = 0.\n\nPay 8 to increase by 1 (x = 1).\n\nPay 1 to multiply by 2 (x = 2).\n\nPay 2 to multiply by 5 (x = 10).\n\nPay 8 to increase by 1 (x = 11).", "sample_input": "5\n11 1 2 4 8\n11 1 2 2 8\n32 10 8 5 4\n29384293847243 454353412 332423423 934923490 1\n900000000000000000 332423423 454353412 934923490 987654321\n"}, "reference_outputs": ["20\n19\n26\n3821859835\n23441258666\n"], "source_document_id": "p02669", "source_text": "Score : 400 points\n\nProblem Statement\n\nYou start with the number 0 and you want to reach the number N.\n\nYou can change the number, paying a certain amount of coins, with the following operations:\n\nMultiply the number by 2, paying A coins.\n\nMultiply the number by 3, paying B coins.\n\nMultiply the number by 5, paying C coins.\n\nIncrease or decrease the number by 1, paying D coins.\n\nYou can perform these operations in arbitrary order and an arbitrary number of times.\n\nWhat is the minimum number of coins you need to reach N?\n\nYou have to solve T testcases.\n\nConstraints\n\n1 \\le T \\le 10\n\n1 \\le N \\le 10^{18}\n\n1 \\le A, B, C, D \\le 10^9\n\nAll numbers N, A, B, C, D are integers.\n\nInput\n\nThe input is given from Standard Input. The first line of the input is\n\nT\n\nThen, T lines follow describing the T testcases.\nEach of the T lines has the format\n\nN A B C D\n\nOutput\n\nFor each testcase, print the answer on Standard Output followed by a newline.\n\nSample Input 1\n\n5\n11 1 2 4 8\n11 1 2 2 8\n32 10 8 5 4\n29384293847243 454353412 332423423 934923490 1\n900000000000000000 332423423 454353412 934923490 987654321\n\nSample Output 1\n\n20\n19\n26\n3821859835\n23441258666\n\nFor the first testcase, a sequence of moves that achieves the minimum cost of 20 is:\n\nInitially x = 0.\n\nPay 8 to increase by 1 (x = 1).\n\nPay 1 to multiply by 2 (x = 2).\n\nPay 1 to multiply by 2 (x = 4).\n\nPay 2 to multiply by 3 (x = 12).\n\nPay 8 to decrease by 1 (x = 11).\n\nFor the second testcase, a sequence of moves that achieves the minimum cost of 19 is:\n\nInitially x = 0.\n\nPay 8 to increase by 1 (x = 1).\n\nPay 1 to multiply by 2 (x = 2).\n\nPay 2 to multiply by 5 (x = 10).\n\nPay 8 to increase by 1 (x = 11).", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 7270, "cpu_time_ms": 1751, "memory_kb": 9796}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s372962749", "group_id": "codeNet:p02670", "input_text": "local mmi, mma = math.min, math.max\nlocal n = io.read(\"*n\")\n\nlocal used = {}\nlocal len = {}\nlocal cost = {}\nfor i = 1, n do\n for j = 1, n do\n local idx = (i - 1) * n + j\n local z = mmi(i - 1, j - 1, n - i, n - j)\n len[idx] = z\n cost[idx] = 1\n end\nend\n\nlocal ret = 0\n-- local t = {}\nlocal tasks = {}\n\nfor i = 1, n * n do\n -- t[i] = io.read(\"*n\")\n local pos = io.read(\"*n\")\n ret = ret + len[pos]\n cost[pos] = 0\n\n local done = 0\n local taskpos = 1\n tasks[1] = pos\n\n local function walk(src, dst)\n if len[src] + cost[src] < len[dst] then\n len[dst] = len[src] + cost[src]\n taskpos = taskpos + 1\n tasks[taskpos] = dst\n end\n end\n\n while done < taskpos do\n done = done + 1\n local idx = tasks[done]\n if n < idx then walk(idx, idx - n) end\n if idx <= (n - 1) * n then walk(idx, idx + n) end\n if idx % n ~= 0 then walk(idx, idx + 1) end\n if idx % n ~= 1 then walk(idx, idx - 1) end\n end\nend\nprint(ret)\n", "language": "Lua", "metadata": {"date": 1590286037, "filename_ext": "lua", "original_language": "Lua (LuaJIT 2.1.0)", "problem_description_relpath": "problem_descriptions/p02670.html", "problem_id": "p02670", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02670/input.txt", "sample_output_relpath": "derived/input_output/data/p02670/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02670/Lua/s372962749.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s372962749", "user_id": "u120582723"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "local mmi, mma = math.min, math.max\nlocal n = io.read(\"*n\")\n\nlocal used = {}\nlocal len = {}\nlocal cost = {}\nfor i = 1, n do\n for j = 1, n do\n local idx = (i - 1) * n + j\n local z = mmi(i - 1, j - 1, n - i, n - j)\n len[idx] = z\n cost[idx] = 1\n end\nend\n\nlocal ret = 0\n-- local t = {}\nlocal tasks = {}\n\nfor i = 1, n * n do\n -- t[i] = io.read(\"*n\")\n local pos = io.read(\"*n\")\n ret = ret + len[pos]\n cost[pos] = 0\n\n local done = 0\n local taskpos = 1\n tasks[1] = pos\n\n local function walk(src, dst)\n if len[src] + cost[src] < len[dst] then\n len[dst] = len[src] + cost[src]\n taskpos = taskpos + 1\n tasks[taskpos] = dst\n end\n end\n\n while done < taskpos do\n done = done + 1\n local idx = tasks[done]\n if n < idx then walk(idx, idx - n) end\n if idx <= (n - 1) * n then walk(idx, idx + n) end\n if idx % n ~= 0 then walk(idx, idx + 1) end\n if idx % n ~= 1 then walk(idx, idx - 1) end\n end\nend\nprint(ret)\n", "problem_context": "Score : 700 points\n\nProblem Statement\n\nTonight, in your favourite cinema they are giving the movie Joker and all seats are occupied. In the cinema there are N rows with N seats each, forming an N\\times N square. We denote with 1, 2,\\dots, N the viewers in the first row (from left to right); with N+1, \\dots, 2N the viewers in the second row (from left to right); and so on until the last row, whose viewers are denoted by N^2-N+1,\\dots, N^2.\n\nAt the end of the movie, the viewers go out of the cinema in a certain order: the i-th viewer leaving her seat is the one denoted by the number P_i. The viewer P_{i+1} waits until viewer P_i has left the cinema before leaving her seat.\nTo exit from the cinema, a viewer must move from seat to seat until she exits the square of seats (any side of the square is a valid exit). A viewer can move from a seat to one of its 4 adjacent seats (same row or same column).\nWhile leaving the cinema, it might be that a certain viewer x goes through a seat currently occupied by viewer y; in that case viewer y will hate viewer x forever. Each viewer chooses the way that minimizes the number of viewers that will hate her forever.\n\nCompute the number of pairs of viewers (x, y) such that y will hate x forever.\n\nConstraints\n\n2 \\le N \\le 500\n\nThe sequence P_1, P_2, \\dots, P_{N^2} is a permutation of \\{1, 2, \\dots, N^2\\}.\n\nInput\n\nThe input is given from Standard Input in the format\n\nN\nP_1 P_2 \\cdots P_{N^2}\n\nOutput\n\nIf ans is the number of pairs of viewers described in the statement, you should print on Standard Output\n\nans\n\nSample Input 1\n\n3\n1 3 7 9 5 4 8 6 2\n\nSample Output 1\n\n1\n\nBefore the end of the movie, the viewers are arranged in the cinema as follows:\n\n1 2 3\n4 5 6\n7 8 9\n\nThe first four viewers leaving the cinema (1, 3, 7, 9) can leave the cinema without going through any seat, so they will not be hated by anybody.\n\nThen, viewer 5 must go through one of the seats where viewers 2, 4, 6, 8 are currently seated while leaving the cinema; hence he will be hated by at least one of those viewers.\n\nFinally the remaining viewers can leave the cinema (in the order 4, 8, 6, 2) without going through any occupied seat (actually, they can leave the cinema without going through any seat at all).\n\nSample Input 2\n\n4\n6 7 1 4 13 16 10 9 5 11 12 14 15 2 3 8\n\nSample Output 2\n\n3\n\nSample Input 3\n\n6\n11 21 35 22 7 36 27 34 8 20 15 13 16 1 24 3 2 17 26 9 18 32 31 23 19 14 4 25 10 29 28 33 12 6 5 30\n\nSample Output 3\n\n11", "sample_input": "3\n1 3 7 9 5 4 8 6 2\n"}, "reference_outputs": ["1\n"], "source_document_id": "p02670", "source_text": "Score : 700 points\n\nProblem Statement\n\nTonight, in your favourite cinema they are giving the movie Joker and all seats are occupied. In the cinema there are N rows with N seats each, forming an N\\times N square. We denote with 1, 2,\\dots, N the viewers in the first row (from left to right); with N+1, \\dots, 2N the viewers in the second row (from left to right); and so on until the last row, whose viewers are denoted by N^2-N+1,\\dots, N^2.\n\nAt the end of the movie, the viewers go out of the cinema in a certain order: the i-th viewer leaving her seat is the one denoted by the number P_i. The viewer P_{i+1} waits until viewer P_i has left the cinema before leaving her seat.\nTo exit from the cinema, a viewer must move from seat to seat until she exits the square of seats (any side of the square is a valid exit). A viewer can move from a seat to one of its 4 adjacent seats (same row or same column).\nWhile leaving the cinema, it might be that a certain viewer x goes through a seat currently occupied by viewer y; in that case viewer y will hate viewer x forever. Each viewer chooses the way that minimizes the number of viewers that will hate her forever.\n\nCompute the number of pairs of viewers (x, y) such that y will hate x forever.\n\nConstraints\n\n2 \\le N \\le 500\n\nThe sequence P_1, P_2, \\dots, P_{N^2} is a permutation of \\{1, 2, \\dots, N^2\\}.\n\nInput\n\nThe input is given from Standard Input in the format\n\nN\nP_1 P_2 \\cdots P_{N^2}\n\nOutput\n\nIf ans is the number of pairs of viewers described in the statement, you should print on Standard Output\n\nans\n\nSample Input 1\n\n3\n1 3 7 9 5 4 8 6 2\n\nSample Output 1\n\n1\n\nBefore the end of the movie, the viewers are arranged in the cinema as follows:\n\n1 2 3\n4 5 6\n7 8 9\n\nThe first four viewers leaving the cinema (1, 3, 7, 9) can leave the cinema without going through any seat, so they will not be hated by anybody.\n\nThen, viewer 5 must go through one of the seats where viewers 2, 4, 6, 8 are currently seated while leaving the cinema; hence he will be hated by at least one of those viewers.\n\nFinally the remaining viewers can leave the cinema (in the order 4, 8, 6, 2) without going through any occupied seat (actually, they can leave the cinema without going through any seat at all).\n\nSample Input 2\n\n4\n6 7 1 4 13 16 10 9 5 11 12 14 15 2 3 8\n\nSample Output 2\n\n3\n\nSample Input 3\n\n6\n11 21 35 22 7 36 27 34 8 20 15 13 16 1 24 3 2 17 26 9 18 32 31 23 19 14 4 25 10 29 28 33 12 6 5 30\n\nSample Output 3\n\n11", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 955, "cpu_time_ms": 902, "memory_kb": 16996}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s848739979", "group_id": "codeNet:p02675", "input_text": "n = io.read(\"*n\")\nn = n % 10\nif n % 10 == 3 then\n print(\"bon\")\nelseif n == 0 or n == 1 or n == 6 or n == 8 then\n print(\"pon\")\nelse\n print(\"hon\")\nend\n", "language": "Lua", "metadata": {"date": 1589763667, "filename_ext": "lua", "original_language": "Lua (LuaJIT 2.1.0)", "problem_description_relpath": "problem_descriptions/p02675.html", "problem_id": "p02675", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02675/input.txt", "sample_output_relpath": "derived/input_output/data/p02675/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02675/Lua/s848739979.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s848739979", "user_id": "u120582723"}, "prompt_components": {"gold_output": "pon\n", "input_to_evaluate": "n = io.read(\"*n\")\nn = n % 10\nif n % 10 == 3 then\n print(\"bon\")\nelseif n == 0 or n == 1 or n == 6 or n == 8 then\n print(\"pon\")\nelse\n print(\"hon\")\nend\n", "problem_context": "Score: 100 points\n\nProblem Statement\n\nThe cat Snuke wants to play a popular Japanese game called ÅtCoder, so Iroha has decided to teach him Japanese.\n\nWhen counting pencils in Japanese, the counter word \"本\" follows the number. The pronunciation of this word varies depending on the number. Specifically, the pronunciation of \"本\" in the phrase \"N 本\" for a positive integer N not exceeding 999 is as follows:\n\nhon when the digit in the one's place of N is 2, 4, 5, 7, or 9;\n\npon when the digit in the one's place of N is 0, 1, 6 or 8;\n\nbon when the digit in the one's place of N is 3.\n\nGiven N, print the pronunciation of \"本\" in the phrase \"N 本\".\n\nConstraints\n\nN is a positive integer not exceeding 999.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n16\n\nSample Output 1\n\npon\n\nThe digit in the one's place of 16 is 6, so the \"本\" in \"16 本\" is pronounced pon.\n\nSample Input 2\n\n2\n\nSample Output 2\n\nhon\n\nSample Input 3\n\n183\n\nSample Output 3\n\nbon", "sample_input": "16\n"}, "reference_outputs": ["pon\n"], "source_document_id": "p02675", "source_text": "Score: 100 points\n\nProblem Statement\n\nThe cat Snuke wants to play a popular Japanese game called ÅtCoder, so Iroha has decided to teach him Japanese.\n\nWhen counting pencils in Japanese, the counter word \"本\" follows the number. The pronunciation of this word varies depending on the number. Specifically, the pronunciation of \"本\" in the phrase \"N 本\" for a positive integer N not exceeding 999 is as follows:\n\nhon when the digit in the one's place of N is 2, 4, 5, 7, or 9;\n\npon when the digit in the one's place of N is 0, 1, 6 or 8;\n\nbon when the digit in the one's place of N is 3.\n\nGiven N, print the pronunciation of \"本\" in the phrase \"N 本\".\n\nConstraints\n\nN is a positive integer not exceeding 999.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n16\n\nSample Output 1\n\npon\n\nThe digit in the one's place of 16 is 6, so the \"本\" in \"16 本\" is pronounced pon.\n\nSample Input 2\n\n2\n\nSample Output 2\n\nhon\n\nSample Input 3\n\n183\n\nSample Output 3\n\nbon", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 152, "cpu_time_ms": 2, "memory_kb": 2720}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s234015607", "group_id": "codeNet:p02676", "input_text": "K=io.read\"*n\"\nio.read()\nS=io.read()\nif(#S<=K)then print(S)\nelse print(S:sub(1,K)..\"...\")end", "language": "Lua", "metadata": {"date": 1590271018, "filename_ext": "lua", "original_language": "Lua (LuaJIT 2.1.0)", "problem_description_relpath": "problem_descriptions/p02676.html", "problem_id": "p02676", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02676/input.txt", "sample_output_relpath": "derived/input_output/data/p02676/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02676/Lua/s234015607.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s234015607", "user_id": "u726173718"}, "prompt_components": {"gold_output": "nikoand...\n", "input_to_evaluate": "K=io.read\"*n\"\nio.read()\nS=io.read()\nif(#S<=K)then print(S)\nelse print(S:sub(1,K)..\"...\")end", "problem_context": "Score: 200 points\n\nProblem Statement\n\nWe have a string S consisting of lowercase English letters.\n\nIf the length of S is at most K, print S without change.\n\nIf the length of S exceeds K, extract the first K characters in S, append ... to the end of them, and print the result.\n\nConstraints\n\nK is an integer between 1 and 100 (inclusive).\n\nS is a string consisting of lowercase English letters.\n\nThe length of S is between 1 and 100 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nK\nS\n\nOutput\n\nPrint a string as stated in Problem Statement.\n\nSample Input 1\n\n7\nnikoandsolstice\n\nSample Output 1\n\nnikoand...\n\nnikoandsolstice has a length of 15, which exceeds K=7.\n\nWe should extract the first 7 characters in this string, append ... to the end of them, and print the result nikoand....\n\nSample Input 2\n\n40\nferelibenterhominesidquodvoluntcredunt\n\nSample Output 2\n\nferelibenterhominesidquodvoluntcredunt\n\nThe famous quote from Gaius Julius Caesar.", "sample_input": "7\nnikoandsolstice\n"}, "reference_outputs": ["nikoand...\n"], "source_document_id": "p02676", "source_text": "Score: 200 points\n\nProblem Statement\n\nWe have a string S consisting of lowercase English letters.\n\nIf the length of S is at most K, print S without change.\n\nIf the length of S exceeds K, extract the first K characters in S, append ... to the end of them, and print the result.\n\nConstraints\n\nK is an integer between 1 and 100 (inclusive).\n\nS is a string consisting of lowercase English letters.\n\nThe length of S is between 1 and 100 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nK\nS\n\nOutput\n\nPrint a string as stated in Problem Statement.\n\nSample Input 1\n\n7\nnikoandsolstice\n\nSample Output 1\n\nnikoand...\n\nnikoandsolstice has a length of 15, which exceeds K=7.\n\nWe should extract the first 7 characters in this string, append ... to the end of them, and print the result nikoand....\n\nSample Input 2\n\n40\nferelibenterhominesidquodvoluntcredunt\n\nSample Output 2\n\nferelibenterhominesidquodvoluntcredunt\n\nThe famous quote from Gaius Julius Caesar.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 91, "cpu_time_ms": 2, "memory_kb": 2724}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s188627291", "group_id": "codeNet:p02677", "input_text": "local a,b,h,m=io.read(\"n\",\"n\",\"n\",\"n\")\nlocal angle=h*(2*math.pi/12)+m*(math.pi/360)-m*(2*math.pi/60)\nlocal dist=math.sqrt(a^2+b^2-2*a*b*math.cos(angle))\nprint(string.format(\"%.20f\",dist))", "language": "Lua", "metadata": {"date": 1592958779, "filename_ext": "lua", "original_language": "Lua (Lua 5.3.5)", "problem_description_relpath": "problem_descriptions/p02677.html", "problem_id": "p02677", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02677/input.txt", "sample_output_relpath": "derived/input_output/data/p02677/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02677/Lua/s188627291.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s188627291", "user_id": "u045238009"}, "prompt_components": {"gold_output": "5.00000000000000000000\n", "input_to_evaluate": "local a,b,h,m=io.read(\"n\",\"n\",\"n\",\"n\")\nlocal angle=h*(2*math.pi/12)+m*(math.pi/360)-m*(2*math.pi/60)\nlocal dist=math.sqrt(a^2+b^2-2*a*b*math.cos(angle))\nprint(string.format(\"%.20f\",dist))", "problem_context": "Score: 300 points\n\nProblem Statement\n\nConsider an analog clock whose hour and minute hands are A and B centimeters long, respectively.\n\nAn endpoint of the hour hand and an endpoint of the minute hand are fixed at the same point, around which each hand rotates clockwise at constant angular velocity. It takes the hour and minute hands 12 hours and 1 hour to make one full rotation, respectively.\n\nAt 0 o'clock, the two hands overlap each other. H hours and M minutes later, what is the distance in centimeters between the unfixed endpoints of the hands?\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq A, B \\leq 1000\n\n0 \\leq H \\leq 11\n\n0 \\leq M \\leq 59\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B H M\n\nOutput\n\nPrint the answer without units. Your output will be accepted when its absolute or relative error from the correct value is at most 10^{-9}.\n\nSample Input 1\n\n3 4 9 0\n\nSample Output 1\n\n5.00000000000000000000\n\nThe two hands will be in the positions shown in the figure below, so the answer is 5 centimeters.\n\nSample Input 2\n\n3 4 10 40\n\nSample Output 2\n\n4.56425719433005567605\n\nThe two hands will be in the positions shown in the figure below. Note that each hand always rotates at constant angular velocity.", "sample_input": "3 4 9 0\n"}, "reference_outputs": ["5.00000000000000000000\n"], "source_document_id": "p02677", "source_text": "Score: 300 points\n\nProblem Statement\n\nConsider an analog clock whose hour and minute hands are A and B centimeters long, respectively.\n\nAn endpoint of the hour hand and an endpoint of the minute hand are fixed at the same point, around which each hand rotates clockwise at constant angular velocity. It takes the hour and minute hands 12 hours and 1 hour to make one full rotation, respectively.\n\nAt 0 o'clock, the two hands overlap each other. H hours and M minutes later, what is the distance in centimeters between the unfixed endpoints of the hands?\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq A, B \\leq 1000\n\n0 \\leq H \\leq 11\n\n0 \\leq M \\leq 59\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B H M\n\nOutput\n\nPrint the answer without units. Your output will be accepted when its absolute or relative error from the correct value is at most 10^{-9}.\n\nSample Input 1\n\n3 4 9 0\n\nSample Output 1\n\n5.00000000000000000000\n\nThe two hands will be in the positions shown in the figure below, so the answer is 5 centimeters.\n\nSample Input 2\n\n3 4 10 40\n\nSample Output 2\n\n4.56425719433005567605\n\nThe two hands will be in the positions shown in the figure below. Note that each hand always rotates at constant angular velocity.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 187, "cpu_time_ms": 8, "memory_kb": 3112}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s923480633", "group_id": "codeNet:p02678", "input_text": "local n, m = io.read(\"*n\", \"*n\")\nlocal edge = {}\nfor i = 1, n do\n edge[i] = {}\nend\nfor i = 1, m do\n local a, b = io.read(\"*n\", \"*n\")\n edge[a][b], edge[b][a] = true, true\nend\n\nlocal len = {}\nlocal ret = {}\nlocal inf = 1000000007\nfor i = 1, n do\n len[i] = inf\n ret[i] = 0\nend\nlen[1] = 0\n\nlocal tasks = {1}\nfor i = 1, n do\n local src = tasks[i]\n -- print(src)\n -- print(len[src])\n for dst, _u in pairs(edge[src]) do\n -- print(src .. \" to \" .. dst)\n if len[dst] + 1 == len[src] then\n ret[src] = dst\n elseif len[dst] == inf then\n len[dst] = len[src] + 1\n -- print(\"INS\", dst)\n table.insert(tasks, dst)\n end\n end\nend\nprint(\"Yes\")\nfor i = 2, n do\n print(ret[i])\nend\n", "language": "Lua", "metadata": {"date": 1589764444, "filename_ext": "lua", "original_language": "Lua (LuaJIT 2.1.0)", "problem_description_relpath": "problem_descriptions/p02678.html", "problem_id": "p02678", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02678/input.txt", "sample_output_relpath": "derived/input_output/data/p02678/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02678/Lua/s923480633.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s923480633", "user_id": "u120582723"}, "prompt_components": {"gold_output": "Yes\n1\n2\n2\n", "input_to_evaluate": "local n, m = io.read(\"*n\", \"*n\")\nlocal edge = {}\nfor i = 1, n do\n edge[i] = {}\nend\nfor i = 1, m do\n local a, b = io.read(\"*n\", \"*n\")\n edge[a][b], edge[b][a] = true, true\nend\n\nlocal len = {}\nlocal ret = {}\nlocal inf = 1000000007\nfor i = 1, n do\n len[i] = inf\n ret[i] = 0\nend\nlen[1] = 0\n\nlocal tasks = {1}\nfor i = 1, n do\n local src = tasks[i]\n -- print(src)\n -- print(len[src])\n for dst, _u in pairs(edge[src]) do\n -- print(src .. \" to \" .. dst)\n if len[dst] + 1 == len[src] then\n ret[src] = dst\n elseif len[dst] == inf then\n len[dst] = len[src] + 1\n -- print(\"INS\", dst)\n table.insert(tasks, dst)\n end\n end\nend\nprint(\"Yes\")\nfor i = 2, n do\n print(ret[i])\nend\n", "problem_context": "Score: 400 points\n\nProblem Statement\n\nThere is a cave.\n\nThe cave has N rooms and M passages. The rooms are numbered 1 to N, and the passages are numbered 1 to M. Passage i connects Room A_i and Room B_i bidirectionally. One can travel between any two rooms by traversing passages. Room 1 is a special room with an entrance from the outside.\n\nIt is dark in the cave, so we have decided to place a signpost in each room except Room 1. The signpost in each room will point to one of the rooms directly connected to that room with a passage.\n\nSince it is dangerous in the cave, our objective is to satisfy the condition below for each room except Room 1.\n\nIf you start in that room and repeatedly move to the room indicated by the signpost in the room you are in, you will reach Room 1 after traversing the minimum number of passages possible.\n\nDetermine whether there is a way to place signposts satisfying our objective, and print one such way if it exists.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 2 \\times 10^5\n\n1 \\leq A_i, B_i \\leq N\\ (1 \\leq i \\leq M)\n\nA_i \\neq B_i\\ (1 \\leq i \\leq M)\n\nOne can travel between any two rooms by traversing passages.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nA_1 B_1\n:\nA_M B_M\n\nOutput\n\nIf there is no way to place signposts satisfying the objective, print No.\n\nOtherwise, print N lines. The first line should contain Yes, and the i-th line (2 \\leq i \\leq N) should contain the integer representing the room indicated by the signpost in Room i.\n\nSample Input 1\n\n4 4\n1 2\n2 3\n3 4\n4 2\n\nSample Output 1\n\nYes\n1\n2\n2\n\nIf we place the signposts as described in the sample output, the following happens:\n\nStarting in Room 2, you will reach Room 1 after traversing one passage: (2) \\to 1. This is the minimum number of passages possible.\n\nStarting in Room 3, you will reach Room 1 after traversing two passages: (3) \\to 2 \\to 1. This is the minimum number of passages possible.\n\nStarting in Room 4, you will reach Room 1 after traversing two passages: (4) \\to 2 \\to 1. This is the minimum number of passages possible.\n\nThus, the objective is satisfied.\n\nSample Input 2\n\n6 9\n3 4\n6 1\n2 4\n5 3\n4 6\n1 5\n6 2\n4 5\n5 6\n\nSample Output 2\n\nYes\n6\n5\n5\n1\n1\n\nIf there are multiple solutions, any of them will be accepted.", "sample_input": "4 4\n1 2\n2 3\n3 4\n4 2\n"}, "reference_outputs": ["Yes\n1\n2\n2\n"], "source_document_id": "p02678", "source_text": "Score: 400 points\n\nProblem Statement\n\nThere is a cave.\n\nThe cave has N rooms and M passages. The rooms are numbered 1 to N, and the passages are numbered 1 to M. Passage i connects Room A_i and Room B_i bidirectionally. One can travel between any two rooms by traversing passages. Room 1 is a special room with an entrance from the outside.\n\nIt is dark in the cave, so we have decided to place a signpost in each room except Room 1. The signpost in each room will point to one of the rooms directly connected to that room with a passage.\n\nSince it is dangerous in the cave, our objective is to satisfy the condition below for each room except Room 1.\n\nIf you start in that room and repeatedly move to the room indicated by the signpost in the room you are in, you will reach Room 1 after traversing the minimum number of passages possible.\n\nDetermine whether there is a way to place signposts satisfying our objective, and print one such way if it exists.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 2 \\times 10^5\n\n1 \\leq A_i, B_i \\leq N\\ (1 \\leq i \\leq M)\n\nA_i \\neq B_i\\ (1 \\leq i \\leq M)\n\nOne can travel between any two rooms by traversing passages.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nA_1 B_1\n:\nA_M B_M\n\nOutput\n\nIf there is no way to place signposts satisfying the objective, print No.\n\nOtherwise, print N lines. The first line should contain Yes, and the i-th line (2 \\leq i \\leq N) should contain the integer representing the room indicated by the signpost in Room i.\n\nSample Input 1\n\n4 4\n1 2\n2 3\n3 4\n4 2\n\nSample Output 1\n\nYes\n1\n2\n2\n\nIf we place the signposts as described in the sample output, the following happens:\n\nStarting in Room 2, you will reach Room 1 after traversing one passage: (2) \\to 1. This is the minimum number of passages possible.\n\nStarting in Room 3, you will reach Room 1 after traversing two passages: (3) \\to 2 \\to 1. This is the minimum number of passages possible.\n\nStarting in Room 4, you will reach Room 1 after traversing two passages: (4) \\to 2 \\to 1. This is the minimum number of passages possible.\n\nThus, the objective is satisfied.\n\nSample Input 2\n\n6 9\n3 4\n6 1\n2 4\n5 3\n4 6\n1 5\n6 2\n4 5\n5 6\n\nSample Output 2\n\nYes\n6\n5\n5\n1\n1\n\nIf there are multiple solutions, any of them will be accepted.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 702, "cpu_time_ms": 219, "memory_kb": 24956}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s414438509", "group_id": "codeNet:p02679", "input_text": "local n=io.read(\"n\")\nlocal iwashi={}\nfor i=1,n do\n local a,b=io.read(\"n\",\"n\")\n iwashi[a/b]=(iwashi[a/b] or 0)+1\n iwashi[-b/a]=(iwashi[-b/a] or 0)+1\nend\n\nlocal counter=1\nfor i=1,n do\n counter=counter*2%1000000007\nend\ncounter=counter-1\n\nfor k,v in pairs(iwashi) do\n if iwashi[k] and iwashi[-k] then\n counter=counter-(iwashi[k]*iwashi[-k]%1000000007)\n end\nend\nprint(counter)", "language": "Lua", "metadata": {"date": 1592960961, "filename_ext": "lua", "original_language": "Lua (Lua 5.3.5)", "problem_description_relpath": "problem_descriptions/p02679.html", "problem_id": "p02679", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02679/input.txt", "sample_output_relpath": "derived/input_output/data/p02679/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02679/Lua/s414438509.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s414438509", "user_id": "u045238009"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "local n=io.read(\"n\")\nlocal iwashi={}\nfor i=1,n do\n local a,b=io.read(\"n\",\"n\")\n iwashi[a/b]=(iwashi[a/b] or 0)+1\n iwashi[-b/a]=(iwashi[-b/a] or 0)+1\nend\n\nlocal counter=1\nfor i=1,n do\n counter=counter*2%1000000007\nend\ncounter=counter-1\n\nfor k,v in pairs(iwashi) do\n if iwashi[k] and iwashi[-k] then\n counter=counter-(iwashi[k]*iwashi[-k]%1000000007)\n end\nend\nprint(counter)", "problem_context": "Score: 500 points\n\nProblem Statement\n\nWe have caught N sardines. The deliciousness and fragrantness of the i-th sardine is A_i and B_i, respectively.\n\nWe will choose one or more of these sardines and put them into a cooler. However, two sardines on bad terms cannot be chosen at the same time.\n\nThe i-th and j-th sardines (i \\neq j) are on bad terms if and only if A_i \\cdot A_j + B_i \\cdot B_j = 0.\n\nIn how many ways can we choose the set of sardines to put into the cooler? Since the count can be enormous, print it modulo 1000000007.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 2 \\times 10^5\n\n-10^{18} \\leq A_i, B_i \\leq 10^{18}\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 B_1\n:\nA_N B_N\n\nOutput\n\nPrint the count modulo 1000000007.\n\nSample Input 1\n\n3\n1 2\n-1 1\n2 -1\n\nSample Output 1\n\n5\n\nThere are five ways to choose the set of sardines, as follows:\n\nThe 1-st\n\nThe 1-st and 2-nd\n\nThe 2-nd\n\nThe 2-nd and 3-rd\n\nThe 3-rd\n\nSample Input 2\n\n10\n3 2\n3 2\n-1 1\n2 -1\n-3 -9\n-8 12\n7 7\n8 1\n8 2\n8 4\n\nSample Output 2\n\n479", "sample_input": "3\n1 2\n-1 1\n2 -1\n"}, "reference_outputs": ["5\n"], "source_document_id": "p02679", "source_text": "Score: 500 points\n\nProblem Statement\n\nWe have caught N sardines. The deliciousness and fragrantness of the i-th sardine is A_i and B_i, respectively.\n\nWe will choose one or more of these sardines and put them into a cooler. However, two sardines on bad terms cannot be chosen at the same time.\n\nThe i-th and j-th sardines (i \\neq j) are on bad terms if and only if A_i \\cdot A_j + B_i \\cdot B_j = 0.\n\nIn how many ways can we choose the set of sardines to put into the cooler? Since the count can be enormous, print it modulo 1000000007.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 2 \\times 10^5\n\n-10^{18} \\leq A_i, B_i \\leq 10^{18}\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 B_1\n:\nA_N B_N\n\nOutput\n\nPrint the count modulo 1000000007.\n\nSample Input 1\n\n3\n1 2\n-1 1\n2 -1\n\nSample Output 1\n\n5\n\nThere are five ways to choose the set of sardines, as follows:\n\nThe 1-st\n\nThe 1-st and 2-nd\n\nThe 2-nd\n\nThe 2-nd and 3-rd\n\nThe 3-rd\n\nSample Input 2\n\n10\n3 2\n3 2\n-1 1\n2 -1\n-3 -9\n-8 12\n7 7\n8 1\n8 2\n8 4\n\nSample Output 2\n\n479", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 396, "cpu_time_ms": 500, "memory_kb": 26984}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s689967338", "group_id": "codeNet:p02679", "input_text": "local mod = 1000000007\n\nlocal function bmul(x, y)\n return (x * y) % mod\nend\n\nlocal function badd(x, y)\n return (x + y) % mod\nend\n\nlocal function bsub(x, y)\n return x < y and x - y + mod or x - y\nend\n\nlocal function getgcd(x, y)\n while 0 < x do\n x, y = y % x, x\n end\n return y\nend\n\nlocal x1, y1 = {}, {}\nlocal x2, y2 = {}, {}\nlocal xzero = 0\nlocal yzero = 0\nlocal zero = 0\n\nlocal n = io.read(\"*n\", \"*l\")\nfor i = 1, n do\n local a, b = io.read(\"*n\", \"*n\")\n if a == 0 and b == 0 then\n zero = zero + 1\n elseif a == 0 then\n xzero = xzero + 1\n elseif b == 0 then\n yzero = yzero + 1\n else\n if b < 0 then\n a, b = -a, -b\n end\n if 0 < a then\n local gcd = getgcd(a, b)\n table.insert(x1, a // gcd)\n table.insert(y1, b // gcd)\n else\n local gcd = getgcd(-a, b)\n table.insert(x2, -a // gcd)\n table.insert(y2, b // gcd)\n end\n end\nend\n\nlocal pow2 = {1}\nfor i = 1, 200010 do\n pow2[i + 1] = (pow2[i] * 2) % mod\nend\n\nlocal ret = badd(pow2[xzero + 1], pow2[yzero + 1])\nret = bsub(ret, 1)\n\nlocal m1 = {}\nfor i1 = 1, #x1 do\n local xs, ys = x1[i1], y1[i1]\n if not m1[xs] then m1[xs] = {} end\n if not m1[xs][ys] then\n m1[xs][ys] = 1\n else\n m1[xs][ys] = m1[xs][ys] + 1\n end\nend\n\nlocal m2 = {}\nfor i2 = 1, #x2 do\n local xs, ys = x2[i2], y2[i2]\n if not m2[ys] then m2[ys] = {} end\n if not m2[ys][xs] then\n m2[ys][xs] = 1\n else\n m2[ys][xs] = m2[ys][xs] + 1\n end\nend\nfor k1, v in pairs(m1) do\n if m2[k1] then\n local m2k1 = m2[k1]\n for k2, c1 in pairs(v) do\n local c2 = m2k1[k2]\n if c2 then\n ret = bmul(ret, bsub(badd(pow2[c1 + 1], pow2[c2 + 1]), 1))\n m2k1[k2] = nil\n else\n ret = bmul(ret, pow2[c1 + 1])\n end\n end\n else\n for k2, c1 in pairs(v) do\n ret = bmul(ret, pow2[c1 + 1])\n end\n end\nend\nfor k1, v in pairs(m2) do\n for k2, c in pairs(v) do\n ret = bmul(ret, pow2[c + 1])\n end\nend\nret = bsub(ret, 1)\nret = badd(ret, zero)\nprint(ret)\n", "language": "Lua", "metadata": {"date": 1589770572, "filename_ext": "lua", "original_language": "Lua (Lua 5.3.5)", "problem_description_relpath": "problem_descriptions/p02679.html", "problem_id": "p02679", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02679/input.txt", "sample_output_relpath": "derived/input_output/data/p02679/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02679/Lua/s689967338.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s689967338", "user_id": "u120582723"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "local mod = 1000000007\n\nlocal function bmul(x, y)\n return (x * y) % mod\nend\n\nlocal function badd(x, y)\n return (x + y) % mod\nend\n\nlocal function bsub(x, y)\n return x < y and x - y + mod or x - y\nend\n\nlocal function getgcd(x, y)\n while 0 < x do\n x, y = y % x, x\n end\n return y\nend\n\nlocal x1, y1 = {}, {}\nlocal x2, y2 = {}, {}\nlocal xzero = 0\nlocal yzero = 0\nlocal zero = 0\n\nlocal n = io.read(\"*n\", \"*l\")\nfor i = 1, n do\n local a, b = io.read(\"*n\", \"*n\")\n if a == 0 and b == 0 then\n zero = zero + 1\n elseif a == 0 then\n xzero = xzero + 1\n elseif b == 0 then\n yzero = yzero + 1\n else\n if b < 0 then\n a, b = -a, -b\n end\n if 0 < a then\n local gcd = getgcd(a, b)\n table.insert(x1, a // gcd)\n table.insert(y1, b // gcd)\n else\n local gcd = getgcd(-a, b)\n table.insert(x2, -a // gcd)\n table.insert(y2, b // gcd)\n end\n end\nend\n\nlocal pow2 = {1}\nfor i = 1, 200010 do\n pow2[i + 1] = (pow2[i] * 2) % mod\nend\n\nlocal ret = badd(pow2[xzero + 1], pow2[yzero + 1])\nret = bsub(ret, 1)\n\nlocal m1 = {}\nfor i1 = 1, #x1 do\n local xs, ys = x1[i1], y1[i1]\n if not m1[xs] then m1[xs] = {} end\n if not m1[xs][ys] then\n m1[xs][ys] = 1\n else\n m1[xs][ys] = m1[xs][ys] + 1\n end\nend\n\nlocal m2 = {}\nfor i2 = 1, #x2 do\n local xs, ys = x2[i2], y2[i2]\n if not m2[ys] then m2[ys] = {} end\n if not m2[ys][xs] then\n m2[ys][xs] = 1\n else\n m2[ys][xs] = m2[ys][xs] + 1\n end\nend\nfor k1, v in pairs(m1) do\n if m2[k1] then\n local m2k1 = m2[k1]\n for k2, c1 in pairs(v) do\n local c2 = m2k1[k2]\n if c2 then\n ret = bmul(ret, bsub(badd(pow2[c1 + 1], pow2[c2 + 1]), 1))\n m2k1[k2] = nil\n else\n ret = bmul(ret, pow2[c1 + 1])\n end\n end\n else\n for k2, c1 in pairs(v) do\n ret = bmul(ret, pow2[c1 + 1])\n end\n end\nend\nfor k1, v in pairs(m2) do\n for k2, c in pairs(v) do\n ret = bmul(ret, pow2[c + 1])\n end\nend\nret = bsub(ret, 1)\nret = badd(ret, zero)\nprint(ret)\n", "problem_context": "Score: 500 points\n\nProblem Statement\n\nWe have caught N sardines. The deliciousness and fragrantness of the i-th sardine is A_i and B_i, respectively.\n\nWe will choose one or more of these sardines and put them into a cooler. However, two sardines on bad terms cannot be chosen at the same time.\n\nThe i-th and j-th sardines (i \\neq j) are on bad terms if and only if A_i \\cdot A_j + B_i \\cdot B_j = 0.\n\nIn how many ways can we choose the set of sardines to put into the cooler? Since the count can be enormous, print it modulo 1000000007.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 2 \\times 10^5\n\n-10^{18} \\leq A_i, B_i \\leq 10^{18}\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 B_1\n:\nA_N B_N\n\nOutput\n\nPrint the count modulo 1000000007.\n\nSample Input 1\n\n3\n1 2\n-1 1\n2 -1\n\nSample Output 1\n\n5\n\nThere are five ways to choose the set of sardines, as follows:\n\nThe 1-st\n\nThe 1-st and 2-nd\n\nThe 2-nd\n\nThe 2-nd and 3-rd\n\nThe 3-rd\n\nSample Input 2\n\n10\n3 2\n3 2\n-1 1\n2 -1\n-3 -9\n-8 12\n7 7\n8 1\n8 2\n8 4\n\nSample Output 2\n\n479", "sample_input": "3\n1 2\n-1 1\n2 -1\n"}, "reference_outputs": ["5\n"], "source_document_id": "p02679", "source_text": "Score: 500 points\n\nProblem Statement\n\nWe have caught N sardines. The deliciousness and fragrantness of the i-th sardine is A_i and B_i, respectively.\n\nWe will choose one or more of these sardines and put them into a cooler. However, two sardines on bad terms cannot be chosen at the same time.\n\nThe i-th and j-th sardines (i \\neq j) are on bad terms if and only if A_i \\cdot A_j + B_i \\cdot B_j = 0.\n\nIn how many ways can we choose the set of sardines to put into the cooler? Since the count can be enormous, print it modulo 1000000007.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 2 \\times 10^5\n\n-10^{18} \\leq A_i, B_i \\leq 10^{18}\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 B_1\n:\nA_N B_N\n\nOutput\n\nPrint the count modulo 1000000007.\n\nSample Input 1\n\n3\n1 2\n-1 1\n2 -1\n\nSample Output 1\n\n5\n\nThere are five ways to choose the set of sardines, as follows:\n\nThe 1-st\n\nThe 1-st and 2-nd\n\nThe 2-nd\n\nThe 2-nd and 3-rd\n\nThe 3-rd\n\nSample Input 2\n\n10\n3 2\n3 2\n-1 1\n2 -1\n-3 -9\n-8 12\n7 7\n8 1\n8 2\n8 4\n\nSample Output 2\n\n479", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1969, "cpu_time_ms": 539, "memory_kb": 44728}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s059450145", "group_id": "codeNet:p02679", "input_text": "local mod = 1000000007\nlocal mfl = math.floor\n\nlocal function bmul(x, y)\n local x1, y1 = mfl(x / 31623), mfl(y / 31623)\n local x0, y0 = x - x1 * 31623, y - y1 * 31623\n return (x1 * y1 * 14122 + (x1 * y0 + x0 * y1) * 31623 + x0 * y0) % mod\nend\n\nlocal function badd(x, y)\n return (x + y) % mod\nend\n\nlocal function bsub(x, y)\n return x < y and x - y + mod or x - y\nend\n\nlocal function modpow(src, pow)\n local res = 1\n while 0 < pow do\n if pow % 2 == 1 then\n res = bmul(res, src)\n pow = pow - 1\n end\n src = bmul(src, src)\n pow = mfl(pow / 2)\n end\n return res\nend\n\nlocal function modinv(src)\n return modpow(src, mod - 2)\nend\n\nlocal function getgcd(x, y)\n while 0LL < x do\n x, y = y % x, x\n end\n return y\nend\n\nlocal ffi = require(\"ffi\")\nlocal C = ffi.C\nffi.cdef[[\nlong long atoll(const char*);\n]]\n\nlocal function lltonumber(str)\n return C.atoll(str)\nend\n\nlocal x1, y1 = {}, {}\nlocal x2, y2 = {}, {}\nlocal xzero = 0\nlocal yzero = 0\nlocal haszero = false\n\nlocal n = io.read(\"*n\", \"*l\")\nlocal a, b = {}, {}\nfor i = 1, n do\n local s = io.read()\n local ai, bi = s:match(\"(%-?%d+) (%-?%d+)\")\n a[i] = lltonumber(ai)\n b[i] = lltonumber(bi)\n if a[i] == 0LL and b[i] == 0LL then\n haszero = true\n elseif a[i] == 0LL then\n xzero = xzero + 1\n elseif b[i] == 0LL then\n yzero = yzero + 1\n else\n if b[i] < 0LL then\n a[i], b[i] = -a[i], -b[i]\n end\n if 0LL < a[i] then\n local xi = a[i]\n local yi = b[i]\n local gcd = getgcd(xi, yi)\n table.insert(x1, xi / gcd)\n table.insert(y1, yi / gcd)\n else\n local xi = -a[i]\n local yi = b[i]\n local gcd = getgcd(xi, yi)\n table.insert(x2, xi / gcd)\n table.insert(y2, yi / gcd)\n end\n end\nend\n-- print(os.clock())\n-- local idx1 = {}\n-- for i = 1, #x1 do\n-- idx1[i] = i\n-- end\n-- local idx2 = {}\n-- for i = 1, #x2 do\n-- idx2[i] = i\n-- end\n-- table.sort(idx1, function(aa, bb)\n-- if x1[aa] ~= x1[bb] then\n-- return x1[aa] < x1[bb]\n-- else\n-- return y1[aa] < y1[bb]\n-- end\n-- end)\n--\n-- table.sort(idx2, function(aa, bb)\n-- if y2[aa] ~= y2[bb] then\n-- return y2[aa] < y2[bb]\n-- else\n-- return x2[aa] < x2[bb]\n-- end\n-- end)\n\nlocal pow2 = {1}\nfor i = 1, 200010 do\n pow2[i + 1] = (pow2[i] * 2) % mod\nend\n\nlocal ret = badd(pow2[xzero + 1], pow2[yzero + 1])\nret = bsub(ret, 1)\n\nlocal m1 = {}\nfor i1 = 1, #x1 do\n local xs, ys = tostring(x1[i1]), tostring(y1[i1])\n if not m1[xs] then m1[xs] = {} end\n if not m1[xs][ys] then\n m1[xs][ys] = 1\n else\n m1[xs][ys] = m1[xs][ys] + 1\n end\nend\n\nlocal m2 = {}\nfor i2 = 1, #x2 do\n local xs, ys = tostring(x2[i2]), tostring(y2[i2])\n if not m2[ys] then m2[ys] = {} end\n if not m2[ys][xs] then\n m2[ys][xs] = 1\n else\n m2[ys][xs] = m2[ys][xs] + 1\n end\nend\nfor k1, v in pairs(m1) do\n if m2[k1] then\n local m2k1 = m2[k1]\n for k2, c1 in pairs(v) do\n local c2 = m2k1[k2]\n if c2 then\n ret = bmul(ret, bsub(badd(pow2[c1 + 1], pow2[c2 + 1]), 1))\n m2k1[k2] = nil\n else\n ret = bmul(ret, pow2[c1 + 1])\n end\n end\n else\n for k2, c1 in pairs(v) do\n ret = bmul(ret, pow2[c1 + 1])\n end\n end\nend\nfor k1, v in pairs(m2) do\n for k2, c in pairs(v) do\n ret = bmul(ret, pow2[c + 1])\n end\nend\nif not haszero then\n ret = bsub(ret, 1)\nend\nprint(ret)\n", "language": "Lua", "metadata": {"date": 1589770028, "filename_ext": "lua", "original_language": "Lua (LuaJIT 2.1.0)", "problem_description_relpath": "problem_descriptions/p02679.html", "problem_id": "p02679", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02679/input.txt", "sample_output_relpath": "derived/input_output/data/p02679/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02679/Lua/s059450145.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s059450145", "user_id": "u120582723"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "local mod = 1000000007\nlocal mfl = math.floor\n\nlocal function bmul(x, y)\n local x1, y1 = mfl(x / 31623), mfl(y / 31623)\n local x0, y0 = x - x1 * 31623, y - y1 * 31623\n return (x1 * y1 * 14122 + (x1 * y0 + x0 * y1) * 31623 + x0 * y0) % mod\nend\n\nlocal function badd(x, y)\n return (x + y) % mod\nend\n\nlocal function bsub(x, y)\n return x < y and x - y + mod or x - y\nend\n\nlocal function modpow(src, pow)\n local res = 1\n while 0 < pow do\n if pow % 2 == 1 then\n res = bmul(res, src)\n pow = pow - 1\n end\n src = bmul(src, src)\n pow = mfl(pow / 2)\n end\n return res\nend\n\nlocal function modinv(src)\n return modpow(src, mod - 2)\nend\n\nlocal function getgcd(x, y)\n while 0LL < x do\n x, y = y % x, x\n end\n return y\nend\n\nlocal ffi = require(\"ffi\")\nlocal C = ffi.C\nffi.cdef[[\nlong long atoll(const char*);\n]]\n\nlocal function lltonumber(str)\n return C.atoll(str)\nend\n\nlocal x1, y1 = {}, {}\nlocal x2, y2 = {}, {}\nlocal xzero = 0\nlocal yzero = 0\nlocal haszero = false\n\nlocal n = io.read(\"*n\", \"*l\")\nlocal a, b = {}, {}\nfor i = 1, n do\n local s = io.read()\n local ai, bi = s:match(\"(%-?%d+) (%-?%d+)\")\n a[i] = lltonumber(ai)\n b[i] = lltonumber(bi)\n if a[i] == 0LL and b[i] == 0LL then\n haszero = true\n elseif a[i] == 0LL then\n xzero = xzero + 1\n elseif b[i] == 0LL then\n yzero = yzero + 1\n else\n if b[i] < 0LL then\n a[i], b[i] = -a[i], -b[i]\n end\n if 0LL < a[i] then\n local xi = a[i]\n local yi = b[i]\n local gcd = getgcd(xi, yi)\n table.insert(x1, xi / gcd)\n table.insert(y1, yi / gcd)\n else\n local xi = -a[i]\n local yi = b[i]\n local gcd = getgcd(xi, yi)\n table.insert(x2, xi / gcd)\n table.insert(y2, yi / gcd)\n end\n end\nend\n-- print(os.clock())\n-- local idx1 = {}\n-- for i = 1, #x1 do\n-- idx1[i] = i\n-- end\n-- local idx2 = {}\n-- for i = 1, #x2 do\n-- idx2[i] = i\n-- end\n-- table.sort(idx1, function(aa, bb)\n-- if x1[aa] ~= x1[bb] then\n-- return x1[aa] < x1[bb]\n-- else\n-- return y1[aa] < y1[bb]\n-- end\n-- end)\n--\n-- table.sort(idx2, function(aa, bb)\n-- if y2[aa] ~= y2[bb] then\n-- return y2[aa] < y2[bb]\n-- else\n-- return x2[aa] < x2[bb]\n-- end\n-- end)\n\nlocal pow2 = {1}\nfor i = 1, 200010 do\n pow2[i + 1] = (pow2[i] * 2) % mod\nend\n\nlocal ret = badd(pow2[xzero + 1], pow2[yzero + 1])\nret = bsub(ret, 1)\n\nlocal m1 = {}\nfor i1 = 1, #x1 do\n local xs, ys = tostring(x1[i1]), tostring(y1[i1])\n if not m1[xs] then m1[xs] = {} end\n if not m1[xs][ys] then\n m1[xs][ys] = 1\n else\n m1[xs][ys] = m1[xs][ys] + 1\n end\nend\n\nlocal m2 = {}\nfor i2 = 1, #x2 do\n local xs, ys = tostring(x2[i2]), tostring(y2[i2])\n if not m2[ys] then m2[ys] = {} end\n if not m2[ys][xs] then\n m2[ys][xs] = 1\n else\n m2[ys][xs] = m2[ys][xs] + 1\n end\nend\nfor k1, v in pairs(m1) do\n if m2[k1] then\n local m2k1 = m2[k1]\n for k2, c1 in pairs(v) do\n local c2 = m2k1[k2]\n if c2 then\n ret = bmul(ret, bsub(badd(pow2[c1 + 1], pow2[c2 + 1]), 1))\n m2k1[k2] = nil\n else\n ret = bmul(ret, pow2[c1 + 1])\n end\n end\n else\n for k2, c1 in pairs(v) do\n ret = bmul(ret, pow2[c1 + 1])\n end\n end\nend\nfor k1, v in pairs(m2) do\n for k2, c in pairs(v) do\n ret = bmul(ret, pow2[c + 1])\n end\nend\nif not haszero then\n ret = bsub(ret, 1)\nend\nprint(ret)\n", "problem_context": "Score: 500 points\n\nProblem Statement\n\nWe have caught N sardines. The deliciousness and fragrantness of the i-th sardine is A_i and B_i, respectively.\n\nWe will choose one or more of these sardines and put them into a cooler. However, two sardines on bad terms cannot be chosen at the same time.\n\nThe i-th and j-th sardines (i \\neq j) are on bad terms if and only if A_i \\cdot A_j + B_i \\cdot B_j = 0.\n\nIn how many ways can we choose the set of sardines to put into the cooler? Since the count can be enormous, print it modulo 1000000007.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 2 \\times 10^5\n\n-10^{18} \\leq A_i, B_i \\leq 10^{18}\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 B_1\n:\nA_N B_N\n\nOutput\n\nPrint the count modulo 1000000007.\n\nSample Input 1\n\n3\n1 2\n-1 1\n2 -1\n\nSample Output 1\n\n5\n\nThere are five ways to choose the set of sardines, as follows:\n\nThe 1-st\n\nThe 1-st and 2-nd\n\nThe 2-nd\n\nThe 2-nd and 3-rd\n\nThe 3-rd\n\nSample Input 2\n\n10\n3 2\n3 2\n-1 1\n2 -1\n-3 -9\n-8 12\n7 7\n8 1\n8 2\n8 4\n\nSample Output 2\n\n479", "sample_input": "3\n1 2\n-1 1\n2 -1\n"}, "reference_outputs": ["5\n"], "source_document_id": "p02679", "source_text": "Score: 500 points\n\nProblem Statement\n\nWe have caught N sardines. The deliciousness and fragrantness of the i-th sardine is A_i and B_i, respectively.\n\nWe will choose one or more of these sardines and put them into a cooler. However, two sardines on bad terms cannot be chosen at the same time.\n\nThe i-th and j-th sardines (i \\neq j) are on bad terms if and only if A_i \\cdot A_j + B_i \\cdot B_j = 0.\n\nIn how many ways can we choose the set of sardines to put into the cooler? Since the count can be enormous, print it modulo 1000000007.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 2 \\times 10^5\n\n-10^{18} \\leq A_i, B_i \\leq 10^{18}\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 B_1\n:\nA_N B_N\n\nOutput\n\nPrint the count modulo 1000000007.\n\nSample Input 1\n\n3\n1 2\n-1 1\n2 -1\n\nSample Output 1\n\n5\n\nThere are five ways to choose the set of sardines, as follows:\n\nThe 1-st\n\nThe 1-st and 2-nd\n\nThe 2-nd\n\nThe 2-nd and 3-rd\n\nThe 3-rd\n\nSample Input 2\n\n10\n3 2\n3 2\n-1 1\n2 -1\n-3 -9\n-8 12\n7 7\n8 1\n8 2\n8 4\n\nSample Output 2\n\n479", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 3311, "cpu_time_ms": 2207, "memory_kb": 87924}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s575247473", "group_id": "codeNet:p02681", "input_text": "S=io.read()\nT=io.read()\nprint((\n\tS==T:sub(1,-2)\n)and\"Yes\"or\"No\")", "language": "Lua", "metadata": {"date": 1589181905, "filename_ext": "lua", "original_language": "Lua (LuaJIT 2.1.0)", "problem_description_relpath": "problem_descriptions/p02681.html", "problem_id": "p02681", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02681/input.txt", "sample_output_relpath": "derived/input_output/data/p02681/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02681/Lua/s575247473.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s575247473", "user_id": "u726173718"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "S=io.read()\nT=io.read()\nprint((\n\tS==T:sub(1,-2)\n)and\"Yes\"or\"No\")", "problem_context": "Score : 100 points\n\nProblem Statement\n\nTakahashi wants to be a member of some web service.\n\nHe tried to register himself with the ID S, which turned out to be already used by another user.\n\nThus, he decides to register using a string obtained by appending one character at the end of S as his ID.\n\nHe is now trying to register with the ID T. Determine whether this string satisfies the property above.\n\nConstraints\n\nS and T are strings consisting of lowercase English letters.\n\n1 \\leq |S| \\leq 10\n\n|T| = |S| + 1\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\nT\n\nOutput\n\nIf T satisfies the property in Problem Statement, print Yes; otherwise, print No.\n\nSample Input 1\n\nchokudai\nchokudaiz\n\nSample Output 1\n\nYes\n\nchokudaiz can be obtained by appending z at the end of chokudai.\n\nSample Input 2\n\nsnuke\nsnekee\n\nSample Output 2\n\nNo\n\nsnekee cannot be obtained by appending one character at the end of snuke.\n\nSample Input 3\n\na\naa\n\nSample Output 3\n\nYes", "sample_input": "chokudai\nchokudaiz\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p02681", "source_text": "Score : 100 points\n\nProblem Statement\n\nTakahashi wants to be a member of some web service.\n\nHe tried to register himself with the ID S, which turned out to be already used by another user.\n\nThus, he decides to register using a string obtained by appending one character at the end of S as his ID.\n\nHe is now trying to register with the ID T. Determine whether this string satisfies the property above.\n\nConstraints\n\nS and T are strings consisting of lowercase English letters.\n\n1 \\leq |S| \\leq 10\n\n|T| = |S| + 1\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\nT\n\nOutput\n\nIf T satisfies the property in Problem Statement, print Yes; otherwise, print No.\n\nSample Input 1\n\nchokudai\nchokudaiz\n\nSample Output 1\n\nYes\n\nchokudaiz can be obtained by appending z at the end of chokudai.\n\nSample Input 2\n\nsnuke\nsnekee\n\nSample Output 2\n\nNo\n\nsnekee cannot be obtained by appending one character at the end of snuke.\n\nSample Input 3\n\na\naa\n\nSample Output 3\n\nYes", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 64, "cpu_time_ms": 4, "memory_kb": 2544}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s632132792", "group_id": "codeNet:p02682", "input_text": "a,b,c,k=io.read(\"*n\",\"*n\",\"*n\",\"*n\")\nif a+b>=k then\n print(math.min(a,k))\nelseif a+bk then\n print(a+b-(k-a-b))\n end\nend", "language": "Lua", "metadata": {"date": 1589298591, "filename_ext": "lua", "original_language": "Lua (Lua 5.3.5)", "problem_description_relpath": "problem_descriptions/p02682.html", "problem_id": "p02682", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02682/input.txt", "sample_output_relpath": "derived/input_output/data/p02682/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02682/Lua/s632132792.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s632132792", "user_id": "u045238009"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "a,b,c,k=io.read(\"*n\",\"*n\",\"*n\",\"*n\")\nif a+b>=k then\n print(math.min(a,k))\nelseif a+bk then\n print(a+b-(k-a-b))\n end\nend", "problem_context": "Score : 200 points\n\nProblem Statement\n\nWe have A cards, each of which has an integer 1 written on it. Similarly, we also have B cards with 0s and C cards with -1s.\n\nWe will pick up K among these cards. What is the maximum possible sum of the numbers written on the cards chosen?\n\nConstraints\n\nAll values in input are integers.\n\n0 \\leq A, B, C\n\n1 \\leq K \\leq A + B + C \\leq 2 \\times 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C K\n\nOutput\n\nPrint the maximum possible sum of the numbers written on the cards chosen.\n\nSample Input 1\n\n2 1 1 3\n\nSample Output 1\n\n2\n\nConsider picking up two cards with 1s and one card with a 0.\nIn this case, the sum of the numbers written on the cards is 2, which is the maximum possible value.\n\nSample Input 2\n\n1 2 3 4\n\nSample Output 2\n\n0\n\nSample Input 3\n\n2000000000 0 0 2000000000\n\nSample Output 3\n\n2000000000", "sample_input": "2 1 1 3\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02682", "source_text": "Score : 200 points\n\nProblem Statement\n\nWe have A cards, each of which has an integer 1 written on it. Similarly, we also have B cards with 0s and C cards with -1s.\n\nWe will pick up K among these cards. What is the maximum possible sum of the numbers written on the cards chosen?\n\nConstraints\n\nAll values in input are integers.\n\n0 \\leq A, B, C\n\n1 \\leq K \\leq A + B + C \\leq 2 \\times 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C K\n\nOutput\n\nPrint the maximum possible sum of the numbers written on the cards chosen.\n\nSample Input 1\n\n2 1 1 3\n\nSample Output 1\n\n2\n\nConsider picking up two cards with 1s and one card with a 0.\nIn this case, the sum of the numbers written on the cards is 2, which is the maximum possible value.\n\nSample Input 2\n\n1 2 3 4\n\nSample Output 2\n\n0\n\nSample Input 3\n\n2000000000 0 0 2000000000\n\nSample Output 3\n\n2000000000", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 199, "cpu_time_ms": 2, "memory_kb": 2792}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s204616943", "group_id": "codeNet:p02682", "input_text": "a, b = io.read(\"*n\", \"*n\")\nc, k = io.read(\"*n\", \"*n\")\nlocal mmi, mma = math.min, math.max\nr = 0\nv = mmi(a, k)\nr = r + v\nk = k - v\n\nv = mmi(b, k)\nk = k - v\nv = mmi(c, k)\nr = r - v\nprint(r)\n", "language": "Lua", "metadata": {"date": 1589158973, "filename_ext": "lua", "original_language": "Lua (LuaJIT 2.1.0)", "problem_description_relpath": "problem_descriptions/p02682.html", "problem_id": "p02682", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02682/input.txt", "sample_output_relpath": "derived/input_output/data/p02682/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02682/Lua/s204616943.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s204616943", "user_id": "u120582723"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "a, b = io.read(\"*n\", \"*n\")\nc, k = io.read(\"*n\", \"*n\")\nlocal mmi, mma = math.min, math.max\nr = 0\nv = mmi(a, k)\nr = r + v\nk = k - v\n\nv = mmi(b, k)\nk = k - v\nv = mmi(c, k)\nr = r - v\nprint(r)\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nWe have A cards, each of which has an integer 1 written on it. Similarly, we also have B cards with 0s and C cards with -1s.\n\nWe will pick up K among these cards. What is the maximum possible sum of the numbers written on the cards chosen?\n\nConstraints\n\nAll values in input are integers.\n\n0 \\leq A, B, C\n\n1 \\leq K \\leq A + B + C \\leq 2 \\times 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C K\n\nOutput\n\nPrint the maximum possible sum of the numbers written on the cards chosen.\n\nSample Input 1\n\n2 1 1 3\n\nSample Output 1\n\n2\n\nConsider picking up two cards with 1s and one card with a 0.\nIn this case, the sum of the numbers written on the cards is 2, which is the maximum possible value.\n\nSample Input 2\n\n1 2 3 4\n\nSample Output 2\n\n0\n\nSample Input 3\n\n2000000000 0 0 2000000000\n\nSample Output 3\n\n2000000000", "sample_input": "2 1 1 3\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02682", "source_text": "Score : 200 points\n\nProblem Statement\n\nWe have A cards, each of which has an integer 1 written on it. Similarly, we also have B cards with 0s and C cards with -1s.\n\nWe will pick up K among these cards. What is the maximum possible sum of the numbers written on the cards chosen?\n\nConstraints\n\nAll values in input are integers.\n\n0 \\leq A, B, C\n\n1 \\leq K \\leq A + B + C \\leq 2 \\times 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C K\n\nOutput\n\nPrint the maximum possible sum of the numbers written on the cards chosen.\n\nSample Input 1\n\n2 1 1 3\n\nSample Output 1\n\n2\n\nConsider picking up two cards with 1s and one card with a 0.\nIn this case, the sum of the numbers written on the cards is 2, which is the maximum possible value.\n\nSample Input 2\n\n1 2 3 4\n\nSample Output 2\n\n0\n\nSample Input 3\n\n2000000000 0 0 2000000000\n\nSample Output 3\n\n2000000000", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 188, "cpu_time_ms": 1, "memory_kb": 2728}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s838803730", "group_id": "codeNet:p02683", "input_text": "bit=require(\"bit\")\nn,m,x=io.read(\"*n\",\"*n\",\"*n\",\"*l\")\nc={}\na={}\nfor i=1,n do\n c[i]=io.read(\"*n\")\n a[i]={}\n for j=1,m do\n a[i][j]=io.read(\"*n\")\n end\nend\n\ntotal=-1\nfor i=0,bit.lshift(1,n)-1 do\n icopy=i\n price=0\n xable={}\n for j=1,m do\n xable[j]=0\n end\n for j=1,n do\n if icopy%2==1 then\n for k=1,m do\n xable[k]=xable[k]+a[j][k]\n end\n price=price+c[j]\n end\n icopy=bit.rshift(icopy,1)\n end\n xbove=true\n for j=1,m do\n if xable[j] b[1]\nend\ntable.sort(up, sort1)\ntable.sort(down, sort2)\nlocal cur = 0\nlocal valid = true\nfor i = 1, n do\n local dec, tot = 0, 0\n if i <= #up then\n dec, tot = up[i][1], up[i][2]\n else\n local p = i - #up\n dec, tot = down[p][1], down[p][2]\n end\n if cur - dec < 0 then\n valid = false\n break\n end\n cur = cur + tot\nend\nvalid = valid and cur == 0\nprint(valid and \"Yes\" or \"No\")\n", "language": "Lua", "metadata": {"date": 1589163061, "filename_ext": "lua", "original_language": "Lua (LuaJIT 2.1.0)", "problem_description_relpath": "problem_descriptions/p02686.html", "problem_id": "p02686", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02686/input.txt", "sample_output_relpath": "derived/input_output/data/p02686/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02686/Lua/s411333420.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s411333420", "user_id": "u120582723"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "local mmi, mma = math.min, math.max\nlocal n = io.read(\"*n\", \"*l\")\nlocal s = {}\nlocal up, down = {}, {}\nfor i = 1, n do\n s[i] = io.read()\n local cur = 0\n local min = 0\n for j = 1, #s[i] do\n if s[i]:sub(j, j) == \"(\" then\n cur = cur + 1\n else\n cur = cur - 1\n end\n min = mmi(min, cur)\n end\n local dec = -min\n if 0 < cur then\n table.insert(up, {dec, cur})\n else\n table.insert(down, {dec, cur})\n end\nend\n\nlocal function sort1(a, b)\n return a[1] < b[1]\nend\nlocal function sort2(a, b)\n return a[1] > b[1]\nend\ntable.sort(up, sort1)\ntable.sort(down, sort2)\nlocal cur = 0\nlocal valid = true\nfor i = 1, n do\n local dec, tot = 0, 0\n if i <= #up then\n dec, tot = up[i][1], up[i][2]\n else\n local p = i - #up\n dec, tot = down[p][1], down[p][2]\n end\n if cur - dec < 0 then\n valid = false\n break\n end\n cur = cur + tot\nend\nvalid = valid and cur == 0\nprint(valid and \"Yes\" or \"No\")\n", "problem_context": "Score : 600 points\n\nProblem Statement\n\nA bracket sequence is a string that is one of the following:\n\nAn empty string;\n\nThe concatenation of (, A, and ) in this order, for some bracket sequence A ;\n\nThe concatenation of A and B in this order, for some non-empty bracket sequences A and B /\n\nGiven are N strings S_i. Can a bracket sequence be formed by concatenating all the N strings in some order?\n\nConstraints\n\n1 \\leq N \\leq 10^6\n\nThe total length of the strings S_i is at most 10^6.\n\nS_i is a non-empty string consisting of ( and ).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS_1\n:\nS_N\n\nOutput\n\nIf a bracket sequence can be formed by concatenating all the N strings in some order, print Yes; otherwise, print No.\n\nSample Input 1\n\n2\n)\n(()\n\nSample Output 1\n\nYes\n\nConcatenating (() and ) in this order forms a bracket sequence.\n\nSample Input 2\n\n2\n)(\n()\n\nSample Output 2\n\nNo\n\nSample Input 3\n\n4\n((()))\n((((((\n))))))\n()()()\n\nSample Output 3\n\nYes\n\nSample Input 4\n\n3\n(((\n)\n)\n\nSample Output 4\n\nNo", "sample_input": "2\n)\n(()\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p02686", "source_text": "Score : 600 points\n\nProblem Statement\n\nA bracket sequence is a string that is one of the following:\n\nAn empty string;\n\nThe concatenation of (, A, and ) in this order, for some bracket sequence A ;\n\nThe concatenation of A and B in this order, for some non-empty bracket sequences A and B /\n\nGiven are N strings S_i. Can a bracket sequence be formed by concatenating all the N strings in some order?\n\nConstraints\n\n1 \\leq N \\leq 10^6\n\nThe total length of the strings S_i is at most 10^6.\n\nS_i is a non-empty string consisting of ( and ).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS_1\n:\nS_N\n\nOutput\n\nIf a bracket sequence can be formed by concatenating all the N strings in some order, print Yes; otherwise, print No.\n\nSample Input 1\n\n2\n)\n(()\n\nSample Output 1\n\nYes\n\nConcatenating (() and ) in this order forms a bracket sequence.\n\nSample Input 2\n\n2\n)(\n()\n\nSample Output 2\n\nNo\n\nSample Input 3\n\n4\n((()))\n((((((\n))))))\n()()()\n\nSample Output 3\n\nYes\n\nSample Input 4\n\n3\n(((\n)\n)\n\nSample Output 4\n\nNo", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 923, "cpu_time_ms": 1231, "memory_kb": 81384}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s721172007", "group_id": "codeNet:p02687", "input_text": "s=io.read()\nif s==\"ABC\" then\n print(\"ARC\")\nelse\n print(\"ABC\")\nend", "language": "Lua", "metadata": {"date": 1588636329, "filename_ext": "lua", "original_language": "Lua (Lua 5.3.5)", "problem_description_relpath": "problem_descriptions/p02687.html", "problem_id": "p02687", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02687/input.txt", "sample_output_relpath": "derived/input_output/data/p02687/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02687/Lua/s721172007.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s721172007", "user_id": "u045238009"}, "prompt_components": {"gold_output": "ARC\n", "input_to_evaluate": "s=io.read()\nif s==\"ABC\" then\n print(\"ARC\")\nelse\n print(\"ABC\")\nend", "problem_context": "Score : 100 points\n\nProblem Statement\n\nAtCoder Inc. holds a contest every Saturday.\n\nThere are two types of contests called ABC and ARC, and just one of them is held at a time.\n\nThe company holds these two types of contests alternately: an ARC follows an ABC and vice versa.\n\nGiven a string S representing the type of the contest held last week, print the string representing the type of the contest held this week.\n\nConstraints\n\nS is ABC or ARC.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the string representing the type of the contest held this week.\n\nSample Input 1\n\nABC\n\nSample Output 1\n\nARC\n\nThey held an ABC last week, so they will hold an ARC this week.", "sample_input": "ABC\n"}, "reference_outputs": ["ARC\n"], "source_document_id": "p02687", "source_text": "Score : 100 points\n\nProblem Statement\n\nAtCoder Inc. holds a contest every Saturday.\n\nThere are two types of contests called ABC and ARC, and just one of them is held at a time.\n\nThe company holds these two types of contests alternately: an ARC follows an ABC and vice versa.\n\nGiven a string S representing the type of the contest held last week, print the string representing the type of the contest held this week.\n\nConstraints\n\nS is ABC or ARC.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the string representing the type of the contest held this week.\n\nSample Input 1\n\nABC\n\nSample Output 1\n\nARC\n\nThey held an ABC last week, so they will hold an ARC this week.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 71, "cpu_time_ms": 6, "memory_kb": 2576}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s192305859", "group_id": "codeNet:p02687", "input_text": "s=io.read()\nif s==\"ABC\" then\n print(\"ARC\")\nelse\n print(\"ARC\")\nend", "language": "Lua", "metadata": {"date": 1588636267, "filename_ext": "lua", "original_language": "Lua (Lua 5.3.5)", "problem_description_relpath": "problem_descriptions/p02687.html", "problem_id": "p02687", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02687/input.txt", "sample_output_relpath": "derived/input_output/data/p02687/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02687/Lua/s192305859.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s192305859", "user_id": "u045238009"}, "prompt_components": {"gold_output": "ARC\n", "input_to_evaluate": "s=io.read()\nif s==\"ABC\" then\n print(\"ARC\")\nelse\n print(\"ARC\")\nend", "problem_context": "Score : 100 points\n\nProblem Statement\n\nAtCoder Inc. holds a contest every Saturday.\n\nThere are two types of contests called ABC and ARC, and just one of them is held at a time.\n\nThe company holds these two types of contests alternately: an ARC follows an ABC and vice versa.\n\nGiven a string S representing the type of the contest held last week, print the string representing the type of the contest held this week.\n\nConstraints\n\nS is ABC or ARC.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the string representing the type of the contest held this week.\n\nSample Input 1\n\nABC\n\nSample Output 1\n\nARC\n\nThey held an ABC last week, so they will hold an ARC this week.", "sample_input": "ABC\n"}, "reference_outputs": ["ARC\n"], "source_document_id": "p02687", "source_text": "Score : 100 points\n\nProblem Statement\n\nAtCoder Inc. holds a contest every Saturday.\n\nThere are two types of contests called ABC and ARC, and just one of them is held at a time.\n\nThe company holds these two types of contests alternately: an ARC follows an ABC and vice versa.\n\nGiven a string S representing the type of the contest held last week, print the string representing the type of the contest held this week.\n\nConstraints\n\nS is ABC or ARC.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the string representing the type of the contest held this week.\n\nSample Input 1\n\nABC\n\nSample Output 1\n\nARC\n\nThey held an ABC last week, so they will hold an ARC this week.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 71, "cpu_time_ms": 6, "memory_kb": 2548}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s356583648", "group_id": "codeNet:p02687", "input_text": "s = io.read()\nprint(s == \"ABC\" and \"ARC\" or \"ABC\")", "language": "Lua", "metadata": {"date": 1588554027, "filename_ext": "lua", "original_language": "Lua (LuaJIT 2.1.0)", "problem_description_relpath": "problem_descriptions/p02687.html", "problem_id": "p02687", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02687/input.txt", "sample_output_relpath": "derived/input_output/data/p02687/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02687/Lua/s356583648.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s356583648", "user_id": "u120582723"}, "prompt_components": {"gold_output": "ARC\n", "input_to_evaluate": "s = io.read()\nprint(s == \"ABC\" and \"ARC\" or \"ABC\")", "problem_context": "Score : 100 points\n\nProblem Statement\n\nAtCoder Inc. holds a contest every Saturday.\n\nThere are two types of contests called ABC and ARC, and just one of them is held at a time.\n\nThe company holds these two types of contests alternately: an ARC follows an ABC and vice versa.\n\nGiven a string S representing the type of the contest held last week, print the string representing the type of the contest held this week.\n\nConstraints\n\nS is ABC or ARC.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the string representing the type of the contest held this week.\n\nSample Input 1\n\nABC\n\nSample Output 1\n\nARC\n\nThey held an ABC last week, so they will hold an ARC this week.", "sample_input": "ABC\n"}, "reference_outputs": ["ARC\n"], "source_document_id": "p02687", "source_text": "Score : 100 points\n\nProblem Statement\n\nAtCoder Inc. holds a contest every Saturday.\n\nThere are two types of contests called ABC and ARC, and just one of them is held at a time.\n\nThe company holds these two types of contests alternately: an ARC follows an ABC and vice versa.\n\nGiven a string S representing the type of the contest held last week, print the string representing the type of the contest held this week.\n\nConstraints\n\nS is ABC or ARC.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the string representing the type of the contest held this week.\n\nSample Input 1\n\nABC\n\nSample Output 1\n\nARC\n\nThey held an ABC last week, so they will hold an ARC this week.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 50, "cpu_time_ms": 3, "memory_kb": 2520}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s383242549", "group_id": "codeNet:p02688", "input_text": "n,k=io.read(\"*n\",\"*n\",\"*l\")\nsnuke={}\nfor i=1,n do\n snuke[i]=1\nend\na={} \nfor i=1,k do\n a[i]={}\n d=io.read(\"*n\",\"*l\")\n for j=1,d do\n a[i][j]=io.read(\"*n\")\n if snuke[a[i][j]]==1 then\n snuke[a[i][j]]=0\n end\n end\nend\n\ncounter=0\nfor i=1,n do\n counter=counter+snuke[i]\nend\nprint(counter)", "language": "Lua", "metadata": {"date": 1588636970, "filename_ext": "lua", "original_language": "Lua (Lua 5.3.5)", "problem_description_relpath": "problem_descriptions/p02688.html", "problem_id": "p02688", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02688/input.txt", "sample_output_relpath": "derived/input_output/data/p02688/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02688/Lua/s383242549.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s383242549", "user_id": "u045238009"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "n,k=io.read(\"*n\",\"*n\",\"*l\")\nsnuke={}\nfor i=1,n do\n snuke[i]=1\nend\na={} \nfor i=1,k do\n a[i]={}\n d=io.read(\"*n\",\"*l\")\n for j=1,d do\n a[i][j]=io.read(\"*n\")\n if snuke[a[i][j]]==1 then\n snuke[a[i][j]]=0\n end\n end\nend\n\ncounter=0\nfor i=1,n do\n counter=counter+snuke[i]\nend\nprint(counter)", "problem_context": "Score : 200 points\n\nProblem Statement\n\nN Snukes called Snuke 1, Snuke 2, ..., Snuke N live in a town.\n\nThere are K kinds of snacks sold in this town, called Snack 1, Snack 2, ..., Snack K. The following d_i Snukes have Snack i: Snuke A_{i, 1}, A_{i, 2}, \\cdots, A_{i, {d_i}}.\n\nTakahashi will walk around this town and make mischief on the Snukes who have no snacks. How many Snukes will fall victim to Takahashi's mischief?\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 100\n\n1 \\leq K \\leq 100\n\n1 \\leq d_i \\leq N\n\n1 \\leq A_{i, 1} < \\cdots < A_{i, d_i} \\leq N\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nd_1\nA_{1, 1} \\cdots A_{1, d_1}\n\\vdots\nd_K\nA_{K, 1} \\cdots A_{K, d_K}\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n3 2\n2\n1 3\n1\n3\n\nSample Output 1\n\n1\n\nSnuke 1 has Snack 1.\n\nSnuke 2 has no snacks.\n\nSnuke 3 has Snack 1 and 2.\n\nThus, there will be one victim: Snuke 2.\n\nSample Input 2\n\n3 3\n1\n3\n1\n3\n1\n3\n\nSample Output 2\n\n2", "sample_input": "3 2\n2\n1 3\n1\n3\n"}, "reference_outputs": ["1\n"], "source_document_id": "p02688", "source_text": "Score : 200 points\n\nProblem Statement\n\nN Snukes called Snuke 1, Snuke 2, ..., Snuke N live in a town.\n\nThere are K kinds of snacks sold in this town, called Snack 1, Snack 2, ..., Snack K. The following d_i Snukes have Snack i: Snuke A_{i, 1}, A_{i, 2}, \\cdots, A_{i, {d_i}}.\n\nTakahashi will walk around this town and make mischief on the Snukes who have no snacks. How many Snukes will fall victim to Takahashi's mischief?\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 100\n\n1 \\leq K \\leq 100\n\n1 \\leq d_i \\leq N\n\n1 \\leq A_{i, 1} < \\cdots < A_{i, d_i} \\leq N\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nd_1\nA_{1, 1} \\cdots A_{1, d_1}\n\\vdots\nd_K\nA_{K, 1} \\cdots A_{K, d_K}\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n3 2\n2\n1 3\n1\n3\n\nSample Output 1\n\n1\n\nSnuke 1 has Snack 1.\n\nSnuke 2 has no snacks.\n\nSnuke 3 has Snack 1 and 2.\n\nThus, there will be one victim: Snuke 2.\n\nSample Input 2\n\n3 3\n1\n3\n1\n3\n1\n3\n\nSample Output 2\n\n2", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 333, "cpu_time_ms": 7, "memory_kb": 2852}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s529213565", "group_id": "codeNet:p02688", "input_text": "local n, k = io.read(\"*n\", \"*n\")\nlocal t = {}\nfor i = 1, n do t[i] = false end\nfor i = 1, k do\n local d = io.read(\"*n\")\n for j = 1, d do\n x = io.read(\"*n\")\n t[x] = true\n end\nend\nc = 0\nfor i = 1, n do\n if not t[i] then c = c + 1 end\nend\nprint(c)\n", "language": "Lua", "metadata": {"date": 1588554114, "filename_ext": "lua", "original_language": "Lua (LuaJIT 2.1.0)", "problem_description_relpath": "problem_descriptions/p02688.html", "problem_id": "p02688", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02688/input.txt", "sample_output_relpath": "derived/input_output/data/p02688/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02688/Lua/s529213565.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s529213565", "user_id": "u120582723"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "local n, k = io.read(\"*n\", \"*n\")\nlocal t = {}\nfor i = 1, n do t[i] = false end\nfor i = 1, k do\n local d = io.read(\"*n\")\n for j = 1, d do\n x = io.read(\"*n\")\n t[x] = true\n end\nend\nc = 0\nfor i = 1, n do\n if not t[i] then c = c + 1 end\nend\nprint(c)\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nN Snukes called Snuke 1, Snuke 2, ..., Snuke N live in a town.\n\nThere are K kinds of snacks sold in this town, called Snack 1, Snack 2, ..., Snack K. The following d_i Snukes have Snack i: Snuke A_{i, 1}, A_{i, 2}, \\cdots, A_{i, {d_i}}.\n\nTakahashi will walk around this town and make mischief on the Snukes who have no snacks. How many Snukes will fall victim to Takahashi's mischief?\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 100\n\n1 \\leq K \\leq 100\n\n1 \\leq d_i \\leq N\n\n1 \\leq A_{i, 1} < \\cdots < A_{i, d_i} \\leq N\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nd_1\nA_{1, 1} \\cdots A_{1, d_1}\n\\vdots\nd_K\nA_{K, 1} \\cdots A_{K, d_K}\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n3 2\n2\n1 3\n1\n3\n\nSample Output 1\n\n1\n\nSnuke 1 has Snack 1.\n\nSnuke 2 has no snacks.\n\nSnuke 3 has Snack 1 and 2.\n\nThus, there will be one victim: Snuke 2.\n\nSample Input 2\n\n3 3\n1\n3\n1\n3\n1\n3\n\nSample Output 2\n\n2", "sample_input": "3 2\n2\n1 3\n1\n3\n"}, "reference_outputs": ["1\n"], "source_document_id": "p02688", "source_text": "Score : 200 points\n\nProblem Statement\n\nN Snukes called Snuke 1, Snuke 2, ..., Snuke N live in a town.\n\nThere are K kinds of snacks sold in this town, called Snack 1, Snack 2, ..., Snack K. The following d_i Snukes have Snack i: Snuke A_{i, 1}, A_{i, 2}, \\cdots, A_{i, {d_i}}.\n\nTakahashi will walk around this town and make mischief on the Snukes who have no snacks. How many Snukes will fall victim to Takahashi's mischief?\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 100\n\n1 \\leq K \\leq 100\n\n1 \\leq d_i \\leq N\n\n1 \\leq A_{i, 1} < \\cdots < A_{i, d_i} \\leq N\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nd_1\nA_{1, 1} \\cdots A_{1, d_1}\n\\vdots\nd_K\nA_{K, 1} \\cdots A_{K, d_K}\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n3 2\n2\n1 3\n1\n3\n\nSample Output 1\n\n1\n\nSnuke 1 has Snack 1.\n\nSnuke 2 has no snacks.\n\nSnuke 3 has Snack 1 and 2.\n\nThus, there will be one victim: Snuke 2.\n\nSample Input 2\n\n3 3\n1\n3\n1\n3\n1\n3\n\nSample Output 2\n\n2", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 255, "cpu_time_ms": 4, "memory_kb": 2732}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s454351776", "group_id": "codeNet:p02689", "input_text": "local function reada(n,m)m=m or 1 r={}for i=1,m do r[i]={}end for i=1,n do for j=1,m do r[j][i]=io.read\"*n\"end end return unpack(r)end\nN=io.read\"*n\"\nM=io.read\"*n\"\nH=reada(N)\n\nt={}\nfor i=1,N do t[i]={}end\n\nfor i=1,M do\n\ta=io.read\"*n\"\n\tb=io.read\"*n\"\n\ttable.insert(t[a],b)\n\ttable.insert(t[b],a)\nend\ns=0\nfor i=1,N do\n\tb=true\n\tfor j=1,#t[i]do\n\t\tif(H[t[i][j]]>=H[i])then b=false break end\n\tend\n\tif(b)then s=s+1 end\nend\nprint(s)", "language": "Lua", "metadata": {"date": 1588554675, "filename_ext": "lua", "original_language": "Lua (LuaJIT 2.1.0)", "problem_description_relpath": "problem_descriptions/p02689.html", "problem_id": "p02689", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02689/input.txt", "sample_output_relpath": "derived/input_output/data/p02689/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02689/Lua/s454351776.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s454351776", "user_id": "u726173718"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "local function reada(n,m)m=m or 1 r={}for i=1,m do r[i]={}end for i=1,n do for j=1,m do r[j][i]=io.read\"*n\"end end return unpack(r)end\nN=io.read\"*n\"\nM=io.read\"*n\"\nH=reada(N)\n\nt={}\nfor i=1,N do t[i]={}end\n\nfor i=1,M do\n\ta=io.read\"*n\"\n\tb=io.read\"*n\"\n\ttable.insert(t[a],b)\n\ttable.insert(t[b],a)\nend\ns=0\nfor i=1,N do\n\tb=true\n\tfor j=1,#t[i]do\n\t\tif(H[t[i][j]]>=H[i])then b=false break end\n\tend\n\tif(b)then s=s+1 end\nend\nprint(s)", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere are N observatories in AtCoder Hill, called Obs. 1, Obs. 2, ..., Obs. N. The elevation of Obs. i is H_i.\nThere are also M roads, each connecting two different observatories. Road j connects Obs. A_j and Obs. B_j.\n\nObs. i is said to be good when its elevation is higher than those of all observatories that can be reached from Obs. i using just one road.\nNote that Obs. i is also good when no observatory can be reached from Obs. i using just one road.\n\nHow many good observatories are there?\n\nConstraints\n\n2 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^5\n\n1 \\leq H_i \\leq 10^9\n\n1 \\leq A_i,B_i \\leq N\n\nA_i \\neq B_i\n\nMultiple roads may connect the same pair of observatories.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nH_1 H_2 ... H_N\nA_1 B_1\nA_2 B_2\n:\nA_M B_M\n\nOutput\n\nPrint the number of good observatories.\n\nSample Input 1\n\n4 3\n1 2 3 4\n1 3\n2 3\n2 4\n\nSample Output 1\n\n2\n\nFrom Obs. 1, you can reach Obs. 3 using just one road. The elevation of Obs. 1 is not higher than that of Obs. 3, so Obs. 1 is not good.\n\nFrom Obs. 2, you can reach Obs. 3 and 4 using just one road. The elevation of Obs. 2 is not higher than that of Obs. 3, so Obs. 2 is not good.\n\nFrom Obs. 3, you can reach Obs. 1 and 2 using just one road. The elevation of Obs. 3 is higher than those of Obs. 1 and 2, so Obs. 3 is good.\n\nFrom Obs. 4, you can reach Obs. 2 using just one road. The elevation of Obs. 4 is higher than that of Obs. 2, so Obs. 4 is good.\n\nThus, the good observatories are Obs. 3 and 4, so there are two good observatories.\n\nSample Input 2\n\n6 5\n8 6 9 1 2 1\n1 3\n4 2\n4 3\n4 6\n4 6\n\nSample Output 2\n\n3", "sample_input": "4 3\n1 2 3 4\n1 3\n2 3\n2 4\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02689", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere are N observatories in AtCoder Hill, called Obs. 1, Obs. 2, ..., Obs. N. The elevation of Obs. i is H_i.\nThere are also M roads, each connecting two different observatories. Road j connects Obs. A_j and Obs. B_j.\n\nObs. i is said to be good when its elevation is higher than those of all observatories that can be reached from Obs. i using just one road.\nNote that Obs. i is also good when no observatory can be reached from Obs. i using just one road.\n\nHow many good observatories are there?\n\nConstraints\n\n2 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^5\n\n1 \\leq H_i \\leq 10^9\n\n1 \\leq A_i,B_i \\leq N\n\nA_i \\neq B_i\n\nMultiple roads may connect the same pair of observatories.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nH_1 H_2 ... H_N\nA_1 B_1\nA_2 B_2\n:\nA_M B_M\n\nOutput\n\nPrint the number of good observatories.\n\nSample Input 1\n\n4 3\n1 2 3 4\n1 3\n2 3\n2 4\n\nSample Output 1\n\n2\n\nFrom Obs. 1, you can reach Obs. 3 using just one road. The elevation of Obs. 1 is not higher than that of Obs. 3, so Obs. 1 is not good.\n\nFrom Obs. 2, you can reach Obs. 3 and 4 using just one road. The elevation of Obs. 2 is not higher than that of Obs. 3, so Obs. 2 is not good.\n\nFrom Obs. 3, you can reach Obs. 1 and 2 using just one road. The elevation of Obs. 3 is higher than those of Obs. 1 and 2, so Obs. 3 is good.\n\nFrom Obs. 4, you can reach Obs. 2 using just one road. The elevation of Obs. 4 is higher than that of Obs. 2, so Obs. 4 is good.\n\nThus, the good observatories are Obs. 3 and 4, so there are two good observatories.\n\nSample Input 2\n\n6 5\n8 6 9 1 2 1\n1 3\n4 2\n4 3\n4 6\n4 6\n\nSample Output 2\n\n3", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 421, "cpu_time_ms": 113, "memory_kb": 12112}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s970056803", "group_id": "codeNet:p02690", "input_text": "x=io.read(\"*n\")\nlocal range\nfor i=0,1000000000 do\n if i*i*i*i*i-(i-1)*(i-1)*(i-1)*(i-1)*(i-1)>=1000000000 then\n range=i\n break\n end\nend\n\nfor i=-range,range do\n for j=-range,range do\n if i*i*i*i*i-j*j*j*j*j==x then\n print(i..\" \"..j)\n return\n end\n end\nend", "language": "Lua", "metadata": {"date": 1588643025, "filename_ext": "lua", "original_language": "Lua (Lua 5.3.5)", "problem_description_relpath": "problem_descriptions/p02690.html", "problem_id": "p02690", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02690/input.txt", "sample_output_relpath": "derived/input_output/data/p02690/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02690/Lua/s970056803.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s970056803", "user_id": "u045238009"}, "prompt_components": {"gold_output": "2 -1\n", "input_to_evaluate": "x=io.read(\"*n\")\nlocal range\nfor i=0,1000000000 do\n if i*i*i*i*i-(i-1)*(i-1)*(i-1)*(i-1)*(i-1)>=1000000000 then\n range=i\n break\n end\nend\n\nfor i=-range,range do\n for j=-range,range do\n if i*i*i*i*i-j*j*j*j*j==x then\n print(i..\" \"..j)\n return\n end\n end\nend", "problem_context": "Score : 400 points\n\nProblem Statement\n\nGive a pair of integers (A, B) such that A^5-B^5 = X.\nIt is guaranteed that there exists such a pair for the given integer X.\n\nConstraints\n\n1 \\leq X \\leq 10^9\n\nX is an integer.\n\nThere exists a pair of integers (A, B) satisfying the condition in Problem Statement.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX\n\nOutput\n\nPrint A and B, with space in between.\nIf there are multiple pairs of integers (A, B) satisfying the condition, you may print any of them.\n\nA B\n\nSample Input 1\n\n33\n\nSample Output 1\n\n2 -1\n\nFor A=2 and B=-1, A^5-B^5 = 33.\n\nSample Input 2\n\n1\n\nSample Output 2\n\n0 -1", "sample_input": "33\n"}, "reference_outputs": ["2 -1\n"], "source_document_id": "p02690", "source_text": "Score : 400 points\n\nProblem Statement\n\nGive a pair of integers (A, B) such that A^5-B^5 = X.\nIt is guaranteed that there exists such a pair for the given integer X.\n\nConstraints\n\n1 \\leq X \\leq 10^9\n\nX is an integer.\n\nThere exists a pair of integers (A, B) satisfying the condition in Problem Statement.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX\n\nOutput\n\nPrint A and B, with space in between.\nIf there are multiple pairs of integers (A, B) satisfying the condition, you may print any of them.\n\nA B\n\nSample Input 1\n\n33\n\nSample Output 1\n\n2 -1\n\nFor A=2 and B=-1, A^5-B^5 = 33.\n\nSample Input 2\n\n1\n\nSample Output 2\n\n0 -1", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 315, "cpu_time_ms": 11, "memory_kb": 2788}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s773283407", "group_id": "codeNet:p02691", "input_text": "local function reada(n,m)m=m or 1 r={}for i=1,m do r[i]={}end for i=1,n do for j=1,m do r[j][i]=io.read\"*n\"end end return unpack(r)end\nN=io.read\"*n\"\nA=reada(N)\n\ns=0\nfor i=1,N do\nfor j=i+A[i]+1,N do\n\tif(A[i]+A[j]==j-i)then s=s+1 end\nend\nend\nprint(s)", "language": "Lua", "metadata": {"date": 1588557977, "filename_ext": "lua", "original_language": "Lua (LuaJIT 2.1.0)", "problem_description_relpath": "problem_descriptions/p02691.html", "problem_id": "p02691", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02691/input.txt", "sample_output_relpath": "derived/input_output/data/p02691/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02691/Lua/s773283407.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s773283407", "user_id": "u726173718"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "local function reada(n,m)m=m or 1 r={}for i=1,m do r[i]={}end for i=1,n do for j=1,m do r[j][i]=io.read\"*n\"end end return unpack(r)end\nN=io.read\"*n\"\nA=reada(N)\n\ns=0\nfor i=1,N do\nfor j=i+A[i]+1,N do\n\tif(A[i]+A[j]==j-i)then s=s+1 end\nend\nend\nprint(s)", "problem_context": "Score: 500 points\n\nProblem Statement\n\nYou are the top spy of AtCoder Kingdom. To prevent the stolen secret from being handed to AlDebaran Kingdom, you have sneaked into the party where the transaction happens.\n\nThere are N attendees in the party, and they are given attendee numbers from 1 through N. The height of Attendee i is A_i.\n\nAccording to an examination beforehand, you know that a pair of attendees satisfying the condition below will make the transaction.\n\nThe absolute difference of their attendee numbers is equal to the sum of their heights.\n\nThere are \\frac{N(N-1)}{2} ways to choose two from the N attendees and make a pair. Among them, how many satisfy the condition above?\n\nP.S.: We cannot let you know the secret.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 2 \\times 10^5\n\n1 \\leq A_i \\leq 10^9\\ (1 \\leq i \\leq N)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 \\dots A_N\n\nOutput\n\nPrint the number of pairs satisfying the condition.\n\nSample Input 1\n\n6\n2 3 3 1 3 1\n\nSample Output 1\n\n3\n\nA_1 + A_4 = 3, so the pair of Attendee 1 and 4 satisfy the condition.\n\nA_2 + A_6 = 4, so the pair of Attendee 2 and 6 satisfy the condition.\n\nA_4 + A_6 = 2, so the pair of Attendee 4 and 6 satisfy the condition.\n\nNo other pair satisfies the condition, so you should print 3.\n\nSample Input 2\n\n6\n5 2 4 2 8 8\n\nSample Output 2\n\n0\n\nNo pair satisfies the condition, so you should print 0.\n\nSample Input 3\n\n32\n3 1 4 1 5 9 2 6 5 3 5 8 9 7 9 3 2 3 8 4 6 2 6 4 3 3 8 3 2 7 9 5\n\nSample Output 3\n\n22", "sample_input": "6\n2 3 3 1 3 1\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02691", "source_text": "Score: 500 points\n\nProblem Statement\n\nYou are the top spy of AtCoder Kingdom. To prevent the stolen secret from being handed to AlDebaran Kingdom, you have sneaked into the party where the transaction happens.\n\nThere are N attendees in the party, and they are given attendee numbers from 1 through N. The height of Attendee i is A_i.\n\nAccording to an examination beforehand, you know that a pair of attendees satisfying the condition below will make the transaction.\n\nThe absolute difference of their attendee numbers is equal to the sum of their heights.\n\nThere are \\frac{N(N-1)}{2} ways to choose two from the N attendees and make a pair. Among them, how many satisfy the condition above?\n\nP.S.: We cannot let you know the secret.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 2 \\times 10^5\n\n1 \\leq A_i \\leq 10^9\\ (1 \\leq i \\leq N)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 \\dots A_N\n\nOutput\n\nPrint the number of pairs satisfying the condition.\n\nSample Input 1\n\n6\n2 3 3 1 3 1\n\nSample Output 1\n\n3\n\nA_1 + A_4 = 3, so the pair of Attendee 1 and 4 satisfy the condition.\n\nA_2 + A_6 = 4, so the pair of Attendee 2 and 6 satisfy the condition.\n\nA_4 + A_6 = 2, so the pair of Attendee 4 and 6 satisfy the condition.\n\nNo other pair satisfies the condition, so you should print 3.\n\nSample Input 2\n\n6\n5 2 4 2 8 8\n\nSample Output 2\n\n0\n\nNo pair satisfies the condition, so you should print 0.\n\nSample Input 3\n\n32\n3 1 4 1 5 9 2 6 5 3 5 8 9 7 9 3 2 3 8 4 6 2 6 4 3 3 8 3 2 7 9 5\n\nSample Output 3\n\n22", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 248, "cpu_time_ms": 2205, "memory_kb": 4768}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s488269007", "group_id": "codeNet:p02692", "input_text": "local q, a, b, c = io.read(\"*n\", \"*n\", \"*n\", \"*n\", \"*l\")\nlocal op = {}\nfor i = 1, q do\n op[i] = io.read()\nend\nif a + b + c == 0 then\n print(\"No\")\n os.exit()\nelseif a + b + c == 1 then\n local ret = {}\n local valid = true\n for iq = 1, q do\n if op[iq] == \"AB\" then\n if a == 1 then\n ret[iq] = \"B\"\n a, b = 0, 1\n elseif b == 1 then\n ret[iq] = \"A\"\n a, b = 1, 0\n else\n valid = false break\n end\n elseif op[iq] == \"BC\" then\n if b == 1 then\n ret[iq] = \"C\"\n b, c = 0, 1\n elseif c == 1 then\n ret[iq] = \"B\"\n b, c = 1, 0\n else\n valid = false break\n end\n else\n if a == 1 then\n ret[iq] = \"C\"\n a, c = 0, 1\n elseif c == 1 then\n ret[iq] = \"A\"\n a, c = 1, 0\n else\n valid = false break\n end\n end\n end\n if valid then\n print(\"Yes\")\n print(table.concat(ret, \"\\n\"))\n else\n print(\"No\")\n end\n os.exit()\nelseif 3 <= a + b + c then\n if a + b == 0 and op[1] == \"AB\" then\n print(\"No\") os.exit()\n elseif b + c == 0 and op[1] == \"BC\" then\n print(\"No\") os.exit()\n elseif a + c == 0 and op[1] == \"AC\" then\n print(\"No\") os.exit()\n end\n local ret = {}\n for iq = 1, q do\n if op[iq] == \"AB\" then\n if a < b then\n ret[iq] = \"A\"\n a, b = a + 1, b - 1\n else\n ret[iq] = \"B\"\n a, b = a - 1, b + 1\n end\n elseif op[iq] == \"BC\" then\n if b < c then\n ret[iq] = \"B\"\n b, c = b + 1, c - 1\n else\n ret[iq] = \"C\"\n b, c = b - 1, c + 1\n end\n else\n if a < c then\n ret[iq] = \"A\"\n a, c = a + 1, c - 1\n else\n ret[iq] = \"C\"\n a, c = a - 1, c + 1\n end\n end\n end\n print(\"Yes\")\n print(table.concat(ret, \"\\n\"))\n os.exit()\nend\n-- a + b + c == 2\nlocal dp = {}\nfor j = 1, q + 1 do\n dp[j] = {}\n -- 110, 101, 011, 200, 020, 002\n for i = 1, 6 do\n dp[j][i] = false\n end\nend\nif a == 1 and b == 1 then\n dp[1][1] = true\nelseif a == 1 and c == 1 then\n dp[1][2] = true\nelseif b == 1 and c == 1 then\n dp[1][3] = true\nelseif a == 2 then\n dp[1][4] = true\nelseif b == 2 then\n dp[1][5] = true\nelse\n dp[1][6] = true\nend\nfor i = 1, q do\n if op[i] == \"AB\" then\n if dp[i][1] then\n dp[i + 1][4] = true\n dp[i + 1][5] = true\n end\n if dp[i][2] then\n dp[i + 1][3] = true\n end\n if dp[i][3] then\n dp[i + 1][2] = true\n end\n if dp[i][4] or dp[i][5] then\n dp[i + 1][1] = true\n end\n elseif op[i] == \"BC\" then\n if dp[i][3] then\n dp[i + 1][5] = true\n dp[i + 1][6] = true\n end\n if dp[i][2] then\n dp[i + 1][1] = true\n end\n if dp[i][1] then\n dp[i + 1][2] = true\n end\n if dp[i][5] or dp[i][6] then\n dp[i + 1][3] = true\n end\n else\n if dp[i][2] then\n dp[i + 1][4] = true\n dp[i + 1][6] = true\n end\n if dp[i][1] then\n dp[i + 1][3] = true\n end\n if dp[i][3] then\n dp[i + 1][1] = true\n end\n if dp[i][4] or dp[i][6] then\n dp[i + 1][2] = true\n end\n end\nend\nlocal cur = false\nfor i = 1, 6 do\n if dp[q + 1][i] then\n cur = i\n break\n end\nend\nif not cur then\n print(\"No\")\n os.exit()\nend\nlocal ret = {}\nfor i = 1, q do ret[i] = 0 end\nfor i = q, 1, -1 do\n local iq = i\n -- print(cur)\n if op[iq] == \"AB\" then\n if cur == 1 then\n if dp[i][4] then\n ret[i] = \"B\"\n cur = 4\n else--5\n ret[i] = \"A\"\n cur = 5\n end\n elseif cur == 2 then\n ret[i] = \"A\"\n cur = 3\n elseif cur == 3 then\n ret[i] = \"B\"\n cur = 2\n elseif cur == 4 then\n ret[i] = \"A\"\n cur = 1\n else-- 5\n ret[i] = \"B\"\n cur = 1\n end\n elseif op[iq] == \"BC\" then\n if cur == 3 then\n if dp[i][5] then\n ret[i] = \"C\"\n cur = 5\n else--6\n ret[i] = \"B\"\n cur = 6\n end\n elseif cur == 1 then\n ret[i] = \"B\"\n cur = 2\n elseif cur == 2 then\n ret[i] = \"C\"\n cur = 1\n elseif cur == 5 then\n ret[i] = \"B\"\n cur = 3\n else-- 6\n ret[i] = \"C\"\n cur = 3\n end\n else\n if cur == 2 then\n if dp[i][4] then\n ret[i] = \"C\"\n cur = 4\n else--6\n ret[i] = \"A\"\n cur = 6\n end\n elseif cur == 1 then\n ret[i] = \"A\"\n cur = 3\n elseif cur == 3 then\n ret[i] = \"C\"\n cur = 1\n elseif cur == 4 then\n ret[i] = \"A\"\n cur = 2\n else-- 6\n ret[i] = \"C\"\n cur = 2\n end\n end\nend\nprint(\"Yes\")\nprint(table.concat(ret, \"\\n\"))\n", "language": "Lua", "metadata": {"date": 1588536709, "filename_ext": "lua", "original_language": "Lua (LuaJIT 2.1.0)", "problem_description_relpath": "problem_descriptions/p02692.html", "problem_id": "p02692", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02692/input.txt", "sample_output_relpath": "derived/input_output/data/p02692/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02692/Lua/s488269007.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s488269007", "user_id": "u120582723"}, "prompt_components": {"gold_output": "Yes\nA\nC\n", "input_to_evaluate": "local q, a, b, c = io.read(\"*n\", \"*n\", \"*n\", \"*n\", \"*l\")\nlocal op = {}\nfor i = 1, q do\n op[i] = io.read()\nend\nif a + b + c == 0 then\n print(\"No\")\n os.exit()\nelseif a + b + c == 1 then\n local ret = {}\n local valid = true\n for iq = 1, q do\n if op[iq] == \"AB\" then\n if a == 1 then\n ret[iq] = \"B\"\n a, b = 0, 1\n elseif b == 1 then\n ret[iq] = \"A\"\n a, b = 1, 0\n else\n valid = false break\n end\n elseif op[iq] == \"BC\" then\n if b == 1 then\n ret[iq] = \"C\"\n b, c = 0, 1\n elseif c == 1 then\n ret[iq] = \"B\"\n b, c = 1, 0\n else\n valid = false break\n end\n else\n if a == 1 then\n ret[iq] = \"C\"\n a, c = 0, 1\n elseif c == 1 then\n ret[iq] = \"A\"\n a, c = 1, 0\n else\n valid = false break\n end\n end\n end\n if valid then\n print(\"Yes\")\n print(table.concat(ret, \"\\n\"))\n else\n print(\"No\")\n end\n os.exit()\nelseif 3 <= a + b + c then\n if a + b == 0 and op[1] == \"AB\" then\n print(\"No\") os.exit()\n elseif b + c == 0 and op[1] == \"BC\" then\n print(\"No\") os.exit()\n elseif a + c == 0 and op[1] == \"AC\" then\n print(\"No\") os.exit()\n end\n local ret = {}\n for iq = 1, q do\n if op[iq] == \"AB\" then\n if a < b then\n ret[iq] = \"A\"\n a, b = a + 1, b - 1\n else\n ret[iq] = \"B\"\n a, b = a - 1, b + 1\n end\n elseif op[iq] == \"BC\" then\n if b < c then\n ret[iq] = \"B\"\n b, c = b + 1, c - 1\n else\n ret[iq] = \"C\"\n b, c = b - 1, c + 1\n end\n else\n if a < c then\n ret[iq] = \"A\"\n a, c = a + 1, c - 1\n else\n ret[iq] = \"C\"\n a, c = a - 1, c + 1\n end\n end\n end\n print(\"Yes\")\n print(table.concat(ret, \"\\n\"))\n os.exit()\nend\n-- a + b + c == 2\nlocal dp = {}\nfor j = 1, q + 1 do\n dp[j] = {}\n -- 110, 101, 011, 200, 020, 002\n for i = 1, 6 do\n dp[j][i] = false\n end\nend\nif a == 1 and b == 1 then\n dp[1][1] = true\nelseif a == 1 and c == 1 then\n dp[1][2] = true\nelseif b == 1 and c == 1 then\n dp[1][3] = true\nelseif a == 2 then\n dp[1][4] = true\nelseif b == 2 then\n dp[1][5] = true\nelse\n dp[1][6] = true\nend\nfor i = 1, q do\n if op[i] == \"AB\" then\n if dp[i][1] then\n dp[i + 1][4] = true\n dp[i + 1][5] = true\n end\n if dp[i][2] then\n dp[i + 1][3] = true\n end\n if dp[i][3] then\n dp[i + 1][2] = true\n end\n if dp[i][4] or dp[i][5] then\n dp[i + 1][1] = true\n end\n elseif op[i] == \"BC\" then\n if dp[i][3] then\n dp[i + 1][5] = true\n dp[i + 1][6] = true\n end\n if dp[i][2] then\n dp[i + 1][1] = true\n end\n if dp[i][1] then\n dp[i + 1][2] = true\n end\n if dp[i][5] or dp[i][6] then\n dp[i + 1][3] = true\n end\n else\n if dp[i][2] then\n dp[i + 1][4] = true\n dp[i + 1][6] = true\n end\n if dp[i][1] then\n dp[i + 1][3] = true\n end\n if dp[i][3] then\n dp[i + 1][1] = true\n end\n if dp[i][4] or dp[i][6] then\n dp[i + 1][2] = true\n end\n end\nend\nlocal cur = false\nfor i = 1, 6 do\n if dp[q + 1][i] then\n cur = i\n break\n end\nend\nif not cur then\n print(\"No\")\n os.exit()\nend\nlocal ret = {}\nfor i = 1, q do ret[i] = 0 end\nfor i = q, 1, -1 do\n local iq = i\n -- print(cur)\n if op[iq] == \"AB\" then\n if cur == 1 then\n if dp[i][4] then\n ret[i] = \"B\"\n cur = 4\n else--5\n ret[i] = \"A\"\n cur = 5\n end\n elseif cur == 2 then\n ret[i] = \"A\"\n cur = 3\n elseif cur == 3 then\n ret[i] = \"B\"\n cur = 2\n elseif cur == 4 then\n ret[i] = \"A\"\n cur = 1\n else-- 5\n ret[i] = \"B\"\n cur = 1\n end\n elseif op[iq] == \"BC\" then\n if cur == 3 then\n if dp[i][5] then\n ret[i] = \"C\"\n cur = 5\n else--6\n ret[i] = \"B\"\n cur = 6\n end\n elseif cur == 1 then\n ret[i] = \"B\"\n cur = 2\n elseif cur == 2 then\n ret[i] = \"C\"\n cur = 1\n elseif cur == 5 then\n ret[i] = \"B\"\n cur = 3\n else-- 6\n ret[i] = \"C\"\n cur = 3\n end\n else\n if cur == 2 then\n if dp[i][4] then\n ret[i] = \"C\"\n cur = 4\n else--6\n ret[i] = \"A\"\n cur = 6\n end\n elseif cur == 1 then\n ret[i] = \"A\"\n cur = 3\n elseif cur == 3 then\n ret[i] = \"C\"\n cur = 1\n elseif cur == 4 then\n ret[i] = \"A\"\n cur = 2\n else-- 6\n ret[i] = \"C\"\n cur = 2\n end\n end\nend\nprint(\"Yes\")\nprint(table.concat(ret, \"\\n\"))\n", "problem_context": "Score : 600 points\n\nProblem Statement\n\nThere is a game that involves three variables, denoted A, B, and C.\n\nAs the game progresses, there will be N events where you are asked to make a choice.\nEach of these choices is represented by a string s_i. If s_i is AB, you must add 1 to A or B then subtract 1 from the other; if s_i is AC, you must add 1 to A or C then subtract 1 from the other; if s_i is BC, you must add 1 to B or C then subtract 1 from the other.\n\nAfter each choice, none of A, B, and C should be negative.\n\nDetermine whether it is possible to make N choices under this condition. If it is possible, also give one such way to make the choices.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n0 \\leq A,B,C \\leq 10^9\n\nN, A, B, C are integers.\n\ns_i is AB, AC, or BC.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN A B C\ns_1\ns_2\n:\ns_N\n\nOutput\n\nIf it is possible to make N choices under the condition, print Yes; otherwise, print No.\n\nAlso, in the former case, show one such way to make the choices in the subsequent N lines. The (i+1)-th line should contain the name of the variable (A, B, or C) to which you add 1 in the i-th choice.\n\nSample Input 1\n\n2 1 3 0\nAB\nAC\n\nSample Output 1\n\nYes\nA\nC\n\nYou can successfully make two choices, as follows:\n\nIn the first choice, add 1 to A and subtract 1 from B. A becomes 2, and B becomes 2.\n\nIn the second choice, add 1 to C and subtract 1 from A. C becomes 1, and A becomes 1.\n\nSample Input 2\n\n3 1 0 0\nAB\nBC\nAB\n\nSample Output 2\n\nNo\n\nSample Input 3\n\n1 0 9 0\nAC\n\nSample Output 3\n\nNo\n\nSample Input 4\n\n8 6 9 1\nAC\nBC\nAB\nBC\nAC\nBC\nAB\nAB\n\nSample Output 4\n\nYes\nC\nB\nB\nC\nC\nB\nA\nA", "sample_input": "2 1 3 0\nAB\nAC\n"}, "reference_outputs": ["Yes\nA\nC\n"], "source_document_id": "p02692", "source_text": "Score : 600 points\n\nProblem Statement\n\nThere is a game that involves three variables, denoted A, B, and C.\n\nAs the game progresses, there will be N events where you are asked to make a choice.\nEach of these choices is represented by a string s_i. If s_i is AB, you must add 1 to A or B then subtract 1 from the other; if s_i is AC, you must add 1 to A or C then subtract 1 from the other; if s_i is BC, you must add 1 to B or C then subtract 1 from the other.\n\nAfter each choice, none of A, B, and C should be negative.\n\nDetermine whether it is possible to make N choices under this condition. If it is possible, also give one such way to make the choices.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n0 \\leq A,B,C \\leq 10^9\n\nN, A, B, C are integers.\n\ns_i is AB, AC, or BC.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN A B C\ns_1\ns_2\n:\ns_N\n\nOutput\n\nIf it is possible to make N choices under the condition, print Yes; otherwise, print No.\n\nAlso, in the former case, show one such way to make the choices in the subsequent N lines. The (i+1)-th line should contain the name of the variable (A, B, or C) to which you add 1 in the i-th choice.\n\nSample Input 1\n\n2 1 3 0\nAB\nAC\n\nSample Output 1\n\nYes\nA\nC\n\nYou can successfully make two choices, as follows:\n\nIn the first choice, add 1 to A and subtract 1 from B. A becomes 2, and B becomes 2.\n\nIn the second choice, add 1 to C and subtract 1 from A. C becomes 1, and A becomes 1.\n\nSample Input 2\n\n3 1 0 0\nAB\nBC\nAB\n\nSample Output 2\n\nNo\n\nSample Input 3\n\n1 0 9 0\nAC\n\nSample Output 3\n\nNo\n\nSample Input 4\n\n8 6 9 1\nAC\nBC\nAB\nBC\nAC\nBC\nAB\nAB\n\nSample Output 4\n\nYes\nC\nB\nB\nC\nC\nB\nA\nA", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 4516, "cpu_time_ms": 81, "memory_kb": 20244}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s123079916", "group_id": "codeNet:p02693", "input_text": "K=io.read\"*n\"\nA=io.read\"*n\"\nB=io.read\"*n\"\nprint((function()\n\tfor i=A,B do\n\t\tif(i%K==0)then return true end\n\tend\nreturn false end)()and\"OK\"or\"NG\")", "language": "Lua", "metadata": {"date": 1588820556, "filename_ext": "lua", "original_language": "Lua (LuaJIT 2.1.0)", "problem_description_relpath": "problem_descriptions/p02693.html", "problem_id": "p02693", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02693/input.txt", "sample_output_relpath": "derived/input_output/data/p02693/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02693/Lua/s123079916.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s123079916", "user_id": "u726173718"}, "prompt_components": {"gold_output": "OK\n", "input_to_evaluate": "K=io.read\"*n\"\nA=io.read\"*n\"\nB=io.read\"*n\"\nprint((function()\n\tfor i=A,B do\n\t\tif(i%K==0)then return true end\n\tend\nreturn false end)()and\"OK\"or\"NG\")", "problem_context": "Score: 100 points\n\nProblem Statement\n\nTakahashi the Jumbo will practice golf.\n\nHis objective is to get a carry distance that is a multiple of K, while he can only make a carry distance of between A and B (inclusive).\n\nIf he can achieve the objective, print OK; if he cannot, print NG.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq A \\leq B \\leq 1000\n\n1 \\leq K \\leq 1000\n\nInput\n\nInput is given from Standard Input in the following format:\n\nK\nA B\n\nOutput\n\nIf he can achieve the objective, print OK; if he cannot, print NG.\n\nSample Input 1\n\n7\n500 600\n\nSample Output 1\n\nOK\n\nAmong the multiples of 7, for example, 567 lies between 500 and 600.\n\nSample Input 2\n\n4\n5 7\n\nSample Output 2\n\nNG\n\nNo multiple of 4 lies between 5 and 7.\n\nSample Input 3\n\n1\n11 11\n\nSample Output 3\n\nOK", "sample_input": "7\n500 600\n"}, "reference_outputs": ["OK\n"], "source_document_id": "p02693", "source_text": "Score: 100 points\n\nProblem Statement\n\nTakahashi the Jumbo will practice golf.\n\nHis objective is to get a carry distance that is a multiple of K, while he can only make a carry distance of between A and B (inclusive).\n\nIf he can achieve the objective, print OK; if he cannot, print NG.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq A \\leq B \\leq 1000\n\n1 \\leq K \\leq 1000\n\nInput\n\nInput is given from Standard Input in the following format:\n\nK\nA B\n\nOutput\n\nIf he can achieve the objective, print OK; if he cannot, print NG.\n\nSample Input 1\n\n7\n500 600\n\nSample Output 1\n\nOK\n\nAmong the multiples of 7, for example, 567 lies between 500 and 600.\n\nSample Input 2\n\n4\n5 7\n\nSample Output 2\n\nNG\n\nNo multiple of 4 lies between 5 and 7.\n\nSample Input 3\n\n1\n11 11\n\nSample Output 3\n\nOK", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 145, "cpu_time_ms": 2, "memory_kb": 2696}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s726307442", "group_id": "codeNet:p02694", "input_text": "local x=io.read(\"n\")\nlocal yokin=100\nlocal counter=0\nwhile yokinb and b or n),1,-1 do\n local x=math.floor(a*i/b)-a*math.floor(i/b)\n if answerb and b or n),1,-1 do\n local x=math.floor(a*i/b)-a*math.floor(i/b)\n if answer= S then\n print(\"unsafe\")\nelse\n print(\"safe\")\nend", "language": "Lua", "metadata": {"date": 1587949256, "filename_ext": "lua", "original_language": "Lua (Lua 5.3.5)", "problem_description_relpath": "problem_descriptions/p02699.html", "problem_id": "p02699", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02699/input.txt", "sample_output_relpath": "derived/input_output/data/p02699/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02699/Lua/s922970055.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s922970055", "user_id": "u162773977"}, "prompt_components": {"gold_output": "unsafe\n", "input_to_evaluate": "local read = setmetatable({}, {__index = function(t, k) local a = {} for i=1,#k do table.insert(a, '*'..string.sub(k, i, i)) end local r = io.read local u = table.unpack or unpack return function() return r(u(a)) end end})\nread.N = function(N) local t={} for i=1,N do t[i]=read.n() end return t end\nstring.totable = function(s) local t={} local u=string.sub for i=1,#s do t[i] = u(s, i, i) end return t end\nstring.split = function(s) local t={} for w in string.gmatch(s, \"[^%s]+\") do table.insert(t, w) end return (table.unpack or unpack)(t) end\nlocal function array(dimension, default_val) assert(type(default_val) ~= 'table') local n=dimension local m={}if default_val~=nil then m[1]={__index=function()return default_val end}end for i=2,n do m[i]={__index=function(p, k)local c=setmetatable({},m[i-1])rawset(p,k,c)return c end}end return setmetatable({},m[n])end\n----\nlocal S, W = read.nn()\nif W >= S then\n print(\"unsafe\")\nelse\n print(\"safe\")\nend", "problem_context": "Score : 100 points\n\nProblem Statement\n\nThere are S sheep and W wolves.\n\nIf the number of wolves is greater than or equal to that of sheep, the wolves will attack the sheep.\n\nIf the wolves will attack the sheep, print unsafe; otherwise, print safe.\n\nConstraints\n\n1 \\leq S \\leq 100\n\n1 \\leq W \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS W\n\nOutput\n\nIf the wolves will attack the sheep, print unsafe; otherwise, print safe.\n\nSample Input 1\n\n4 5\n\nSample Output 1\n\nunsafe\n\nThere are four sheep and five wolves. The number of wolves is not less than that of sheep, so they will attack them.\n\nSample Input 2\n\n100 2\n\nSample Output 2\n\nsafe\n\nMany a sheep drive away two wolves.\n\nSample Input 3\n\n10 10\n\nSample Output 3\n\nunsafe", "sample_input": "4 5\n"}, "reference_outputs": ["unsafe\n"], "source_document_id": "p02699", "source_text": "Score : 100 points\n\nProblem Statement\n\nThere are S sheep and W wolves.\n\nIf the number of wolves is greater than or equal to that of sheep, the wolves will attack the sheep.\n\nIf the wolves will attack the sheep, print unsafe; otherwise, print safe.\n\nConstraints\n\n1 \\leq S \\leq 100\n\n1 \\leq W \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS W\n\nOutput\n\nIf the wolves will attack the sheep, print unsafe; otherwise, print safe.\n\nSample Input 1\n\n4 5\n\nSample Output 1\n\nunsafe\n\nThere are four sheep and five wolves. The number of wolves is not less than that of sheep, so they will attack them.\n\nSample Input 2\n\n100 2\n\nSample Output 2\n\nsafe\n\nMany a sheep drive away two wolves.\n\nSample Input 3\n\n10 10\n\nSample Output 3\n\nunsafe", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 955, "cpu_time_ms": 3, "memory_kb": 2632}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s961276205", "group_id": "codeNet:p02701", "input_text": "n = io.read()\nn = tonumber(n)\nt = {}\nfor i = 1, n do\n s = io.read()\n t[s] = true\nend\nc = 0\nfor k, _u in pairs(t) do\n c = c + 1\nend\nprint(c)\n", "language": "Lua", "metadata": {"date": 1589041732, "filename_ext": "lua", "original_language": "Lua (Lua 5.3.5)", "problem_description_relpath": "problem_descriptions/p02701.html", "problem_id": "p02701", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02701/input.txt", "sample_output_relpath": "derived/input_output/data/p02701/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02701/Lua/s961276205.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s961276205", "user_id": "u120582723"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "n = io.read()\nn = tonumber(n)\nt = {}\nfor i = 1, n do\n s = io.read()\n t[s] = true\nend\nc = 0\nfor k, _u in pairs(t) do\n c = c + 1\nend\nprint(c)\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nYou drew lottery N times. In the i-th draw, you got an item of the kind represented by a string S_i.\n\nHow many kinds of items did you get?\n\nConstraints\n\n1 \\leq N \\leq 2\\times 10^5\n\nS_i consists of lowercase English letters and has a length between 1 and 10 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS_1\n:\nS_N\n\nOutput\n\nPrint the number of kinds of items you got.\n\nSample Input 1\n\n3\napple\norange\napple\n\nSample Output 1\n\n2\n\nYou got two kinds of items: apple and orange.\n\nSample Input 2\n\n5\ngrape\ngrape\ngrape\ngrape\ngrape\n\nSample Output 2\n\n1\n\nSample Input 3\n\n4\naaaa\na\naaa\naa\n\nSample Output 3\n\n4", "sample_input": "3\napple\norange\napple\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02701", "source_text": "Score : 300 points\n\nProblem Statement\n\nYou drew lottery N times. In the i-th draw, you got an item of the kind represented by a string S_i.\n\nHow many kinds of items did you get?\n\nConstraints\n\n1 \\leq N \\leq 2\\times 10^5\n\nS_i consists of lowercase English letters and has a length between 1 and 10 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS_1\n:\nS_N\n\nOutput\n\nPrint the number of kinds of items you got.\n\nSample Input 1\n\n3\napple\norange\napple\n\nSample Output 1\n\n2\n\nYou got two kinds of items: apple and orange.\n\nSample Input 2\n\n5\ngrape\ngrape\ngrape\ngrape\ngrape\n\nSample Output 2\n\n1\n\nSample Input 3\n\n4\naaaa\na\naaa\naa\n\nSample Output 3\n\n4", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 143, "cpu_time_ms": 148, "memory_kb": 23640}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s874135135", "group_id": "codeNet:p02706", "input_text": "n,m=io.read(\"*n\",\"*n\",\"*l\")\nsum=0\nfor i=1,m do\n sum=sum+io.read(\"*n\")\nend\n\nif sum>n then\n print(-1)\n return\nelse\n print(n-sum)\nend", "language": "Lua", "metadata": {"date": 1588897881, "filename_ext": "lua", "original_language": "Lua (Lua 5.3.5)", "problem_description_relpath": "problem_descriptions/p02706.html", "problem_id": "p02706", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02706/input.txt", "sample_output_relpath": "derived/input_output/data/p02706/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02706/Lua/s874135135.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s874135135", "user_id": "u045238009"}, "prompt_components": {"gold_output": "30\n", "input_to_evaluate": "n,m=io.read(\"*n\",\"*n\",\"*l\")\nsum=0\nfor i=1,m do\n sum=sum+io.read(\"*n\")\nend\n\nif sum>n then\n print(-1)\n return\nelse\n print(n-sum)\nend", "problem_context": "Score : 200 points\n\nProblem Statement\n\nTakahashi has N days of summer vacation.\n\nHis teacher gave him M summer assignments. It will take A_i days for him to do the i-th assignment.\n\nHe cannot do multiple assignments on the same day, or hang out on a day he does an assignment.\n\nWhat is the maximum number of days Takahashi can hang out during the vacation if he finishes all the assignments during this vacation?\n\nIf Takahashi cannot finish all the assignments during the vacation, print -1 instead.\n\nConstraints\n\n1 \\leq N \\leq 10^6\n\n1 \\leq M \\leq 10^4\n\n1 \\leq A_i \\leq 10^4\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nA_1 ... A_M\n\nOutput\n\nPrint the maximum number of days Takahashi can hang out during the vacation, or -1.\n\nSample Input 1\n\n41 2\n5 6\n\nSample Output 1\n\n30\n\nFor example, he can do the first assignment on the first 5 days, hang out on the next 30 days, and do the second assignment on the last 6 days of the vacation. In this way, he can safely spend 30 days hanging out.\n\nSample Input 2\n\n10 2\n5 6\n\nSample Output 2\n\n-1\n\nHe cannot finish his assignments.\n\nSample Input 3\n\n11 2\n5 6\n\nSample Output 3\n\n0\n\nHe can finish his assignments, but he will have no time to hang out.\n\nSample Input 4\n\n314 15\n9 26 5 35 8 9 79 3 23 8 46 2 6 43 3\n\nSample Output 4\n\n9", "sample_input": "41 2\n5 6\n"}, "reference_outputs": ["30\n"], "source_document_id": "p02706", "source_text": "Score : 200 points\n\nProblem Statement\n\nTakahashi has N days of summer vacation.\n\nHis teacher gave him M summer assignments. It will take A_i days for him to do the i-th assignment.\n\nHe cannot do multiple assignments on the same day, or hang out on a day he does an assignment.\n\nWhat is the maximum number of days Takahashi can hang out during the vacation if he finishes all the assignments during this vacation?\n\nIf Takahashi cannot finish all the assignments during the vacation, print -1 instead.\n\nConstraints\n\n1 \\leq N \\leq 10^6\n\n1 \\leq M \\leq 10^4\n\n1 \\leq A_i \\leq 10^4\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nA_1 ... A_M\n\nOutput\n\nPrint the maximum number of days Takahashi can hang out during the vacation, or -1.\n\nSample Input 1\n\n41 2\n5 6\n\nSample Output 1\n\n30\n\nFor example, he can do the first assignment on the first 5 days, hang out on the next 30 days, and do the second assignment on the last 6 days of the vacation. In this way, he can safely spend 30 days hanging out.\n\nSample Input 2\n\n10 2\n5 6\n\nSample Output 2\n\n-1\n\nHe cannot finish his assignments.\n\nSample Input 3\n\n11 2\n5 6\n\nSample Output 3\n\n0\n\nHe can finish his assignments, but he will have no time to hang out.\n\nSample Input 4\n\n314 15\n9 26 5 35 8 9 79 3 23 8 46 2 6 43 3\n\nSample Output 4\n\n9", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 142, "cpu_time_ms": 6, "memory_kb": 2712}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s909170785", "group_id": "codeNet:p02708", "input_text": "local ffi=require\"ffi\"\nlocal modint\ndo\nlocal MOD=1000000007\nlocal mt={}\nmodint=setmetatable({new=function(x)return setmetatable({v=x},mt)end},{__call=function(o,x)return setmetatable({v=x%MOD},mt)end})\nlocal function add(a,b)return (a+b)%MOD end\nfunction mt.__add(a,b) return modint.new(add(a.v,b.v))end\nlocal function sub(a,b)return (a-b)%MOD end\nfunction mt.__sub(a,b) return modint.new(sub(a.v,b.v))end\nlocal function mul(a,b)\n\tlocal ret=0\n\twhile(b>0)do\n\t\tif(b%2==1)then ret=(ret+a)%MOD end\n\t\ta=(a+a)%MOD\n\t\tb=math.floor(b*.5)\n\tend\n\treturn ret\nend\nfunction mt.__mul(a,b)\n\ta=a.v b=b.v\n\treturn modint(a0)do\n\t\tif(b%2==1)then ret=mul(ret,a)end\n\t\ta=mul(a,a)\n\t\tb=math.floor(b*.5)\n\tend\n\treturn ret\nend\nfunction mt.__pow(a,b)return modint(pow(a.v,b.v))end\nlocal function inv(x)\nlocal a=x\nlocal b,u,v=MOD,1,0\nrepeat\nlocal t=math.floor(a/b)\na,b=b,a-t*b\nu,v=v,u-t*v\nuntil(b==0)\nreturn u\nend\nlocal function div(a,b)return mul(a,inv(b))end\nfunction mt.__div(a,b)return modint.new(div(a.v,b.v))end\nfunction mt.__tostring(x)return tostring(x.v)end\nlocal method={}\nmt.__index=method\nfunction method.inv(x)return modint.new(inv(x.v))end\ndo\nlocal MAX=510000\nlocal ct=ffi.typeof(\"int[$]\",MAX)\nlocal fac=ffi.new(ct,{1,1})\nlocal inv=ffi.new(ct,{1,1})\nlocal finv=ffi.new(ct,{1,1})\nfor i=2,MAX-1 do\nfac[i]=mul(fac[i-1],i)\ninv[i]=MOD-mul(inv[MOD%i],math.floor(MOD/i))\nfinv[i]=mul(finv[i-1],inv[i])\nend\nfunction method.C(n,k)\nn=n.v k=k.v\nif(n0)do\n\t\tif(b%2==1)then ret=(ret+a)%MOD end\n\t\ta=(a+a)%MOD\n\t\tb=math.floor(b*.5)\n\tend\n\treturn ret\nend\nfunction mt.__mul(a,b)\n\ta=a.v b=b.v\n\treturn modint(a0)do\n\t\tif(b%2==1)then ret=mul(ret,a)end\n\t\ta=mul(a,a)\n\t\tb=math.floor(b*.5)\n\tend\n\treturn ret\nend\nfunction mt.__pow(a,b)return modint(pow(a.v,b.v))end\nlocal function inv(x)\nlocal a=x\nlocal b,u,v=MOD,1,0\nrepeat\nlocal t=math.floor(a/b)\na,b=b,a-t*b\nu,v=v,u-t*v\nuntil(b==0)\nreturn u\nend\nlocal function div(a,b)return mul(a,inv(b))end\nfunction mt.__div(a,b)return modint.new(div(a.v,b.v))end\nfunction mt.__tostring(x)return tostring(x.v)end\nlocal method={}\nmt.__index=method\nfunction method.inv(x)return modint.new(inv(x.v))end\ndo\nlocal MAX=510000\nlocal ct=ffi.typeof(\"int[$]\",MAX)\nlocal fac=ffi.new(ct,{1,1})\nlocal inv=ffi.new(ct,{1,1})\nlocal finv=ffi.new(ct,{1,1})\nfor i=2,MAX-1 do\nfac[i]=mul(fac[i-1],i)\ninv[i]=MOD-mul(inv[MOD%i],math.floor(MOD/i))\nfinv[i]=mul(finv[i-1],inv[i])\nend\nfunction method.C(n,k)\nn=n.v k=k.v\nif(n 0 then\n return self.buff[self.top_index]\n end\nend\n--\nfunction Queue:isEmpty()\n return #self.buff == 0\nend\n--]]\n---- from http://www.nct9.ne.jp/m_hiroi/light/lua.html ----\n\n\n--[[\nルンルン数の特徴:十以上の位がそれまでに出て来たルンルン数を流用している。\nそれゆえ、流用される側の数字の一の位に-1, 0, 1を加えた数と\n流用される側の数字を10倍した数を足し、ルンルン数を生成する。\nただし、流用される側の数字の一の位の数字が0,9のときは生成しない場合を作っておく。\n]]\nlocal k = io.read(\"*n\")\nlocal lunluns = Queue.new()\nfor i = 1, 9 do\n lunluns:enqueue(i)\n if i == k then\n print(tostring(i)); os.exit()\n end\nend\n\nfor i = 1, k do\n local x = 0LL + lunluns:dequeue()\n if x % 10 ~= 0 then\n lunluns:enqueue(10 * x + (x % 10) - 1)\n if #lunluns.buff == k then\n print(tostring(10 * x + (x % 10) - 1):sub(1, -3)); break\n end\n end\n lunluns:enqueue(10 * x + (x % 10))\n if #lunluns.buff == k then\n print(tostring(10 * x + (x % 10)):sub(1, -3)); break\n end\n if x % 10 ~= 9 then\n lunluns:enqueue(10 * x + (x % 10) + 1)\n if #lunluns.buff == k then\n print(tostring(10 * x + (x % 10) + 1):sub(1, -3)); break\n end\n end\nend", "language": "Lua", "metadata": {"date": 1586186784, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p02720.html", "problem_id": "p02720", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02720/input.txt", "sample_output_relpath": "derived/input_output/data/p02720/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02720/Lua/s744782019.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s744782019", "user_id": "u793881115"}, "prompt_components": {"gold_output": "23\n", "input_to_evaluate": "---- Quote(Alteration) ----\nQueue = {}\n\nfunction Queue.new()\n local obj = { buff = {}, top_index = 0}\n return setmetatable(obj,{__index = Queue})\nend\n\nfunction Queue:enqueue(x)\n table.insert(self.buff, x)\nend\n\nfunction Queue:dequeue()\n self.top_index = self.top_index + 1\n local value = self.buff[self.top_index]\n self.buff[self.top_index] = nil\n return value\nend\n--[[\nfunction Queue:top()\n if #self.buff > 0 then\n return self.buff[self.top_index]\n end\nend\n--\nfunction Queue:isEmpty()\n return #self.buff == 0\nend\n--]]\n---- from http://www.nct9.ne.jp/m_hiroi/light/lua.html ----\n\n\n--[[\nルンルン数の特徴:十以上の位がそれまでに出て来たルンルン数を流用している。\nそれゆえ、流用される側の数字の一の位に-1, 0, 1を加えた数と\n流用される側の数字を10倍した数を足し、ルンルン数を生成する。\nただし、流用される側の数字の一の位の数字が0,9のときは生成しない場合を作っておく。\n]]\nlocal k = io.read(\"*n\")\nlocal lunluns = Queue.new()\nfor i = 1, 9 do\n lunluns:enqueue(i)\n if i == k then\n print(tostring(i)); os.exit()\n end\nend\n\nfor i = 1, k do\n local x = 0LL + lunluns:dequeue()\n if x % 10 ~= 0 then\n lunluns:enqueue(10 * x + (x % 10) - 1)\n if #lunluns.buff == k then\n print(tostring(10 * x + (x % 10) - 1):sub(1, -3)); break\n end\n end\n lunluns:enqueue(10 * x + (x % 10))\n if #lunluns.buff == k then\n print(tostring(10 * x + (x % 10)):sub(1, -3)); break\n end\n if x % 10 ~= 9 then\n lunluns:enqueue(10 * x + (x % 10) + 1)\n if #lunluns.buff == k then\n print(tostring(10 * x + (x % 10) + 1):sub(1, -3)); break\n end\n end\nend", "problem_context": "Score : 400 points\n\nProblem Statement\n\nA positive integer X is said to be a lunlun number if and only if the following condition is satisfied:\n\nIn the base ten representation of X (without leading zeros), for every pair of two adjacent digits, the absolute difference of those digits is at most 1.\n\nFor example, 1234, 1, and 334 are lunlun numbers, while none of 31415, 119, or 13579 is.\n\nYou are given a positive integer K. Find the K-th smallest lunlun number.\n\nConstraints\n\n1 \\leq K \\leq 10^5\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nK\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n15\n\nSample Output 1\n\n23\n\nWe will list the 15 smallest lunlun numbers in ascending order:\n\n1,\n2,\n3,\n4,\n5,\n6,\n7,\n8,\n9,\n10,\n11,\n12,\n21,\n22,\n23.\n\nThus, the answer is 23.\n\nSample Input 2\n\n1\n\nSample Output 2\n\n1\n\nSample Input 3\n\n13\n\nSample Output 3\n\n21\n\nSample Input 4\n\n100000\n\nSample Output 4\n\n3234566667\n\nNote that the answer may not fit into the 32-bit signed integer type.", "sample_input": "15\n"}, "reference_outputs": ["23\n"], "source_document_id": "p02720", "source_text": "Score : 400 points\n\nProblem Statement\n\nA positive integer X is said to be a lunlun number if and only if the following condition is satisfied:\n\nIn the base ten representation of X (without leading zeros), for every pair of two adjacent digits, the absolute difference of those digits is at most 1.\n\nFor example, 1234, 1, and 334 are lunlun numbers, while none of 31415, 119, or 13579 is.\n\nYou are given a positive integer K. Find the K-th smallest lunlun number.\n\nConstraints\n\n1 \\leq K \\leq 10^5\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nK\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n15\n\nSample Output 1\n\n23\n\nWe will list the 15 smallest lunlun numbers in ascending order:\n\n1,\n2,\n3,\n4,\n5,\n6,\n7,\n8,\n9,\n10,\n11,\n12,\n21,\n22,\n23.\n\nThus, the answer is 23.\n\nSample Input 2\n\n1\n\nSample Output 2\n\n1\n\nSample Input 3\n\n13\n\nSample Output 3\n\n21\n\nSample Input 4\n\n100000\n\nSample Output 4\n\n3234566667\n\nNote that the answer may not fit into the 32-bit signed integer type.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1777, "cpu_time_ms": 19, "memory_kb": 3840}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s847964077", "group_id": "codeNet:p02722", "input_text": "local mce, mfl, msq, mmi, mma, mab = math.ceil, math.floor, math.sqrt, math.min, math.max, math.abs\n\nlocal function getprimes(x)\n local primes = {}\n local allnums = {}\n for i = 1, x do allnums[i] = true end\n for i = 2, x do\n if allnums[i] then\n table.insert(primes, i)\n local lim = mfl(x / i)\n for j = 2, lim do\n allnums[j * i] = false\n end\n end\n end\n return primes\nend\n\nlocal function getdivisorparts(x, primes)\n local prime_num = #primes\n local tmp = {}\n local lim = mce(msq(x))\n local primepos = 1\n local dv = primes[primepos]\n while primepos <= prime_num and dv <= lim do\n if x % dv == 0 then\n local t = {}\n t.p = dv\n t.cnt = 1\n x = x / dv\n while x % dv == 0 do\n x = x / dv\n t.cnt = t.cnt + 1\n end\n table.insert(tmp, t)\n lim = mce(msq(x))\n end\n if primepos == prime_num then break end\n primepos = primepos + 1\n dv = primes[primepos]\n end\n if x ~= 1 then\n local t = {}\n t.p, t.cnt = x, 1\n table.insert(tmp, t)\n end\n return tmp\nend\n\nlocal function getdivisorCore(divisorparts)\n local t = {}\n local pat = 1\n local len = #divisorparts\n local allpat = 1\n for i = 1, len do\n allpat = allpat * (1 + divisorparts[i].cnt)\n end\n for t_i_pat = 0, allpat - 1 do\n local div = allpat\n local i_pat = t_i_pat\n local ret = 1\n for i = 1, len do\n div = mfl(div / (divisorparts[i].cnt + 1))\n local mul = mfl(i_pat / div)\n i_pat = i_pat % div\n for j = 1, mul do\n ret = ret * divisorparts[i].p\n end\n end\n table.insert(t, ret)\n end\n -- table.sort(t)\n return t\nend\n\nlocal function getdivisor(x, primes)\n local dvp = getdivisorparts(x, primes)\n return getdivisorCore(dvp)\nend\n\nlocal n = io.read(\"*n\")\n-- n = k^a * (bk + 1)\n-- n = 1000 * 1000 * 1000 * 1000\n-- 2 <= a\nlocal a = 1\nlocal ret = 0\nwhile true do\n a = a + 1\n if n < (2^a) then break end\n local k = 1\n while true do\n k = k + 1\n local ka = 1\n for i = 1, a do\n ka = ka * k\n end\n if n < ka then\n --print(a, k, ka)\n break\n end\n if n % ka == 0 then\n local rem = mfl(n / ka)\n if rem % k == 1 then ret = ret + 1 end\n end\n end\nend\n-- a == 1\n-- a == 1 and 0 < b\nfor k = 2, 1000000 do\n if k * k <= n then\n if n % (k * k) == k then ret = ret + 1 end\n -- local rem = mfl(n / (k * k))\n -- if rem % k == 1 then ret = ret + 1 end\n end\nend\n-- a == 1 and b == 0\nif 2 < n then ret = ret + 1 end\n-- a == 0\nif 2 < n then\n local primes = getprimes(1000000)\n local divisor = getdivisor(n - 1, primes)\n -- print(table.concat(divisor, \" \"))\n ret = ret + #divisor - 1\nend\nprint(ret)\n", "language": "Lua", "metadata": {"date": 1586051726, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p02722.html", "problem_id": "p02722", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02722/input.txt", "sample_output_relpath": "derived/input_output/data/p02722/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02722/Lua/s847964077.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s847964077", "user_id": "u120582723"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "local mce, mfl, msq, mmi, mma, mab = math.ceil, math.floor, math.sqrt, math.min, math.max, math.abs\n\nlocal function getprimes(x)\n local primes = {}\n local allnums = {}\n for i = 1, x do allnums[i] = true end\n for i = 2, x do\n if allnums[i] then\n table.insert(primes, i)\n local lim = mfl(x / i)\n for j = 2, lim do\n allnums[j * i] = false\n end\n end\n end\n return primes\nend\n\nlocal function getdivisorparts(x, primes)\n local prime_num = #primes\n local tmp = {}\n local lim = mce(msq(x))\n local primepos = 1\n local dv = primes[primepos]\n while primepos <= prime_num and dv <= lim do\n if x % dv == 0 then\n local t = {}\n t.p = dv\n t.cnt = 1\n x = x / dv\n while x % dv == 0 do\n x = x / dv\n t.cnt = t.cnt + 1\n end\n table.insert(tmp, t)\n lim = mce(msq(x))\n end\n if primepos == prime_num then break end\n primepos = primepos + 1\n dv = primes[primepos]\n end\n if x ~= 1 then\n local t = {}\n t.p, t.cnt = x, 1\n table.insert(tmp, t)\n end\n return tmp\nend\n\nlocal function getdivisorCore(divisorparts)\n local t = {}\n local pat = 1\n local len = #divisorparts\n local allpat = 1\n for i = 1, len do\n allpat = allpat * (1 + divisorparts[i].cnt)\n end\n for t_i_pat = 0, allpat - 1 do\n local div = allpat\n local i_pat = t_i_pat\n local ret = 1\n for i = 1, len do\n div = mfl(div / (divisorparts[i].cnt + 1))\n local mul = mfl(i_pat / div)\n i_pat = i_pat % div\n for j = 1, mul do\n ret = ret * divisorparts[i].p\n end\n end\n table.insert(t, ret)\n end\n -- table.sort(t)\n return t\nend\n\nlocal function getdivisor(x, primes)\n local dvp = getdivisorparts(x, primes)\n return getdivisorCore(dvp)\nend\n\nlocal n = io.read(\"*n\")\n-- n = k^a * (bk + 1)\n-- n = 1000 * 1000 * 1000 * 1000\n-- 2 <= a\nlocal a = 1\nlocal ret = 0\nwhile true do\n a = a + 1\n if n < (2^a) then break end\n local k = 1\n while true do\n k = k + 1\n local ka = 1\n for i = 1, a do\n ka = ka * k\n end\n if n < ka then\n --print(a, k, ka)\n break\n end\n if n % ka == 0 then\n local rem = mfl(n / ka)\n if rem % k == 1 then ret = ret + 1 end\n end\n end\nend\n-- a == 1\n-- a == 1 and 0 < b\nfor k = 2, 1000000 do\n if k * k <= n then\n if n % (k * k) == k then ret = ret + 1 end\n -- local rem = mfl(n / (k * k))\n -- if rem % k == 1 then ret = ret + 1 end\n end\nend\n-- a == 1 and b == 0\nif 2 < n then ret = ret + 1 end\n-- a == 0\nif 2 < n then\n local primes = getprimes(1000000)\n local divisor = getdivisor(n - 1, primes)\n -- print(table.concat(divisor, \" \"))\n ret = ret + #divisor - 1\nend\nprint(ret)\n", "problem_context": "Score : 600 points\n\nProblem Statement\n\nGiven is a positive integer N.\n\nWe will choose an integer K between 2 and N (inclusive), then we will repeat the operation below until N becomes less than K.\n\nOperation: if K divides N, replace N with N/K; otherwise, replace N with N-K.\n\nIn how many choices of K will N become 1 in the end?\n\nConstraints\n\n2 \\leq N \\leq 10^{12}\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the number of choices of K in which N becomes 1 in the end.\n\nSample Input 1\n\n6\n\nSample Output 1\n\n3\n\nThere are three choices of K in which N becomes 1 in the end: 2, 5, and 6.\n\nIn each of these choices, N will change as follows:\n\nWhen K=2: 6 \\to 3 \\to 1\n\nWhen K=5: 6 \\to 1\n\nWhen K=6: 6 \\to 1\n\nSample Input 2\n\n3141\n\nSample Output 2\n\n13\n\nSample Input 3\n\n314159265358\n\nSample Output 3\n\n9", "sample_input": "6\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02722", "source_text": "Score : 600 points\n\nProblem Statement\n\nGiven is a positive integer N.\n\nWe will choose an integer K between 2 and N (inclusive), then we will repeat the operation below until N becomes less than K.\n\nOperation: if K divides N, replace N with N/K; otherwise, replace N with N-K.\n\nIn how many choices of K will N become 1 in the end?\n\nConstraints\n\n2 \\leq N \\leq 10^{12}\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the number of choices of K in which N becomes 1 in the end.\n\nSample Input 1\n\n6\n\nSample Output 1\n\n3\n\nThere are three choices of K in which N becomes 1 in the end: 2, 5, and 6.\n\nIn each of these choices, N will change as follows:\n\nWhen K=2: 6 \\to 3 \\to 1\n\nWhen K=5: 6 \\to 1\n\nWhen K=6: 6 \\to 1\n\nSample Input 2\n\n3141\n\nSample Output 2\n\n13\n\nSample Input 3\n\n314159265358\n\nSample Output 3\n\n9", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2656, "cpu_time_ms": 36, "memory_kb": 10112}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s553122598", "group_id": "codeNet:p02725", "input_text": "K,N=io.read(\"*n\",\"*n\")\nA={}\nfor i=1,N do\nA[i]={i,io.read\"*n\"}\nend\ntable.sort(A,function(a,b)return a[2]max[2])then max=B[i] end\nend\nprint(K-max[2])", "language": "Lua", "metadata": {"date": 1586153147, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p02725.html", "problem_id": "p02725", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02725/input.txt", "sample_output_relpath": "derived/input_output/data/p02725/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02725/Lua/s553122598.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s553122598", "user_id": "u726173718"}, "prompt_components": {"gold_output": "10\n", "input_to_evaluate": "K,N=io.read(\"*n\",\"*n\")\nA={}\nfor i=1,N do\nA[i]={i,io.read\"*n\"}\nend\ntable.sort(A,function(a,b)return a[2]max[2])then max=B[i] end\nend\nprint(K-max[2])", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere is a circular pond with a perimeter of K meters, and N houses around them.\n\nThe i-th house is built at a distance of A_i meters from the northmost point of the pond, measured clockwise around the pond.\n\nWhen traveling between these houses, you can only go around the pond.\n\nFind the minimum distance that needs to be traveled when you start at one of the houses and visit all the N houses.\n\nConstraints\n\n2 \\leq K \\leq 10^6\n\n2 \\leq N \\leq 2 \\times 10^5\n\n0 \\leq A_1 < ... < A_N < K\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nK N\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the minimum distance that needs to be traveled when you start at one of the houses and visit all the N houses.\n\nSample Input 1\n\n20 3\n5 10 15\n\nSample Output 1\n\n10\n\nIf you start at the 1-st house and go to the 2-nd and 3-rd houses in this order, the total distance traveled will be 10.\n\nSample Input 2\n\n20 3\n0 5 15\n\nSample Output 2\n\n10\n\nIf you start at the 2-nd house and go to the 1-st and 3-rd houses in this order, the total distance traveled will be 10.", "sample_input": "20 3\n5 10 15\n"}, "reference_outputs": ["10\n"], "source_document_id": "p02725", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere is a circular pond with a perimeter of K meters, and N houses around them.\n\nThe i-th house is built at a distance of A_i meters from the northmost point of the pond, measured clockwise around the pond.\n\nWhen traveling between these houses, you can only go around the pond.\n\nFind the minimum distance that needs to be traveled when you start at one of the houses and visit all the N houses.\n\nConstraints\n\n2 \\leq K \\leq 10^6\n\n2 \\leq N \\leq 2 \\times 10^5\n\n0 \\leq A_1 < ... < A_N < K\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nK N\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the minimum distance that needs to be traveled when you start at one of the houses and visit all the N houses.\n\nSample Input 1\n\n20 3\n5 10 15\n\nSample Output 1\n\n10\n\nIf you start at the 1-st house and go to the 2-nd and 3-rd houses in this order, the total distance traveled will be 10.\n\nSample Input 2\n\n20 3\n0 5 15\n\nSample Output 2\n\n10\n\nIf you start at the 2-nd house and go to the 1-st and 3-rd houses in this order, the total distance traveled will be 10.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 275, "cpu_time_ms": 253, "memory_kb": 29424}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s956806194", "group_id": "codeNet:p02729", "input_text": "n,m=io.read(\"*n\",\"*n\")\nprint(string.format(\"%d\", (n*(n-1)+m*(m-1))/2))", "language": "Lua", "metadata": {"date": 1587167145, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p02729.html", "problem_id": "p02729", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02729/input.txt", "sample_output_relpath": "derived/input_output/data/p02729/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02729/Lua/s956806194.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s956806194", "user_id": "u045238009"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "n,m=io.read(\"*n\",\"*n\")\nprint(string.format(\"%d\", (n*(n-1)+m*(m-1))/2))", "problem_context": "Score : 100 points\n\nProblem Statement\n\nWe have N+M balls, each of which has an integer written on it.\n\nIt is known that:\n\nThe numbers written on N of the balls are even.\n\nThe numbers written on M of the balls are odd.\n\nFind the number of ways to choose two of the N+M balls (disregarding order) so that the sum of the numbers written on them is even.\n\nIt can be shown that this count does not depend on the actual values written on the balls.\n\nConstraints\n\n0 \\leq N,M \\leq 100\n\n2 \\leq N+M\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n2 1\n\nSample Output 1\n\n1\n\nFor example, let us assume that the numbers written on the three balls are 1,2,4.\n\nIf we choose the two balls with 1 and 2, the sum is odd;\n\nIf we choose the two balls with 1 and 4, the sum is odd;\n\nIf we choose the two balls with 2 and 4, the sum is even.\n\nThus, the answer is 1.\n\nSample Input 2\n\n4 3\n\nSample Output 2\n\n9\n\nSample Input 3\n\n1 1\n\nSample Output 3\n\n0\n\nSample Input 4\n\n13 3\n\nSample Output 4\n\n81\n\nSample Input 5\n\n0 3\n\nSample Output 5\n\n3", "sample_input": "2 1\n"}, "reference_outputs": ["1\n"], "source_document_id": "p02729", "source_text": "Score : 100 points\n\nProblem Statement\n\nWe have N+M balls, each of which has an integer written on it.\n\nIt is known that:\n\nThe numbers written on N of the balls are even.\n\nThe numbers written on M of the balls are odd.\n\nFind the number of ways to choose two of the N+M balls (disregarding order) so that the sum of the numbers written on them is even.\n\nIt can be shown that this count does not depend on the actual values written on the balls.\n\nConstraints\n\n0 \\leq N,M \\leq 100\n\n2 \\leq N+M\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n2 1\n\nSample Output 1\n\n1\n\nFor example, let us assume that the numbers written on the three balls are 1,2,4.\n\nIf we choose the two balls with 1 and 2, the sum is odd;\n\nIf we choose the two balls with 1 and 4, the sum is odd;\n\nIf we choose the two balls with 2 and 4, the sum is even.\n\nThus, the answer is 1.\n\nSample Input 2\n\n4 3\n\nSample Output 2\n\n9\n\nSample Input 3\n\n1 1\n\nSample Output 3\n\n0\n\nSample Input 4\n\n13 3\n\nSample Output 4\n\n81\n\nSample Input 5\n\n0 3\n\nSample Output 5\n\n3", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 70, "cpu_time_ms": 8, "memory_kb": 760}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s260394144", "group_id": "codeNet:p02729", "input_text": "n,m=io.read(\"*n\",\"*n\")\nprint((n*(n-1)+m*(m-1))/2)", "language": "Lua", "metadata": {"date": 1587167028, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p02729.html", "problem_id": "p02729", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02729/input.txt", "sample_output_relpath": "derived/input_output/data/p02729/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02729/Lua/s260394144.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s260394144", "user_id": "u045238009"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "n,m=io.read(\"*n\",\"*n\")\nprint((n*(n-1)+m*(m-1))/2)", "problem_context": "Score : 100 points\n\nProblem Statement\n\nWe have N+M balls, each of which has an integer written on it.\n\nIt is known that:\n\nThe numbers written on N of the balls are even.\n\nThe numbers written on M of the balls are odd.\n\nFind the number of ways to choose two of the N+M balls (disregarding order) so that the sum of the numbers written on them is even.\n\nIt can be shown that this count does not depend on the actual values written on the balls.\n\nConstraints\n\n0 \\leq N,M \\leq 100\n\n2 \\leq N+M\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n2 1\n\nSample Output 1\n\n1\n\nFor example, let us assume that the numbers written on the three balls are 1,2,4.\n\nIf we choose the two balls with 1 and 2, the sum is odd;\n\nIf we choose the two balls with 1 and 4, the sum is odd;\n\nIf we choose the two balls with 2 and 4, the sum is even.\n\nThus, the answer is 1.\n\nSample Input 2\n\n4 3\n\nSample Output 2\n\n9\n\nSample Input 3\n\n1 1\n\nSample Output 3\n\n0\n\nSample Input 4\n\n13 3\n\nSample Output 4\n\n81\n\nSample Input 5\n\n0 3\n\nSample Output 5\n\n3", "sample_input": "2 1\n"}, "reference_outputs": ["1\n"], "source_document_id": "p02729", "source_text": "Score : 100 points\n\nProblem Statement\n\nWe have N+M balls, each of which has an integer written on it.\n\nIt is known that:\n\nThe numbers written on N of the balls are even.\n\nThe numbers written on M of the balls are odd.\n\nFind the number of ways to choose two of the N+M balls (disregarding order) so that the sum of the numbers written on them is even.\n\nIt can be shown that this count does not depend on the actual values written on the balls.\n\nConstraints\n\n0 \\leq N,M \\leq 100\n\n2 \\leq N+M\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n2 1\n\nSample Output 1\n\n1\n\nFor example, let us assume that the numbers written on the three balls are 1,2,4.\n\nIf we choose the two balls with 1 and 2, the sum is odd;\n\nIf we choose the two balls with 1 and 4, the sum is odd;\n\nIf we choose the two balls with 2 and 4, the sum is even.\n\nThus, the answer is 1.\n\nSample Input 2\n\n4 3\n\nSample Output 2\n\n9\n\nSample Input 3\n\n1 1\n\nSample Output 3\n\n0\n\nSample Input 4\n\n13 3\n\nSample Output 4\n\n81\n\nSample Input 5\n\n0 3\n\nSample Output 5\n\n3", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 49, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s800313017", "group_id": "codeNet:p02731", "input_text": "local l = io.read(\"*n\")\n\nprint((l / 3) ^ 3)", "language": "Lua", "metadata": {"date": 1586291439, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p02731.html", "problem_id": "p02731", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02731/input.txt", "sample_output_relpath": "derived/input_output/data/p02731/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02731/Lua/s800313017.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s800313017", "user_id": "u793881115"}, "prompt_components": {"gold_output": "1.000000000000\n", "input_to_evaluate": "local l = io.read(\"*n\")\n\nprint((l / 3) ^ 3)", "problem_context": "Score : 300 points\n\nProblem Statement\n\nGiven is a positive integer L.\nFind the maximum possible volume of a rectangular cuboid whose sum of the dimensions (not necessarily integers) is L.\n\nConstraints\n\n1 ≤ L ≤ 1000\n\nL is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nL\n\nOutput\n\nPrint the maximum possible volume of a rectangular cuboid whose sum of the dimensions (not necessarily integers) is L.\nYour output is considered correct if its absolute or relative error from our answer is at most 10^{-6}.\n\nSample Input 1\n\n3\n\nSample Output 1\n\n1.000000000000\n\nFor example, a rectangular cuboid whose dimensions are 0.8, 1, and 1.2 has a volume of 0.96.\n\nOn the other hand, if the dimensions are 1, 1, and 1, the volume of the rectangular cuboid is 1, which is greater.\n\nSample Input 2\n\n999\n\nSample Output 2\n\n36926037.000000000000", "sample_input": "3\n"}, "reference_outputs": ["1.000000000000\n"], "source_document_id": "p02731", "source_text": "Score : 300 points\n\nProblem Statement\n\nGiven is a positive integer L.\nFind the maximum possible volume of a rectangular cuboid whose sum of the dimensions (not necessarily integers) is L.\n\nConstraints\n\n1 ≤ L ≤ 1000\n\nL is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nL\n\nOutput\n\nPrint the maximum possible volume of a rectangular cuboid whose sum of the dimensions (not necessarily integers) is L.\nYour output is considered correct if its absolute or relative error from our answer is at most 10^{-6}.\n\nSample Input 1\n\n3\n\nSample Output 1\n\n1.000000000000\n\nFor example, a rectangular cuboid whose dimensions are 0.8, 1, and 1.2 has a volume of 0.96.\n\nOn the other hand, if the dimensions are 1, 1, and 1, the volume of the rectangular cuboid is 1, which is greater.\n\nSample Input 2\n\n999\n\nSample Output 2\n\n36926037.000000000000", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 43, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s604622317", "group_id": "codeNet:p02731", "input_text": "local a = io.read(\"*n\")\na = a / 3\nprint(a * a * a)\n", "language": "Lua", "metadata": {"date": 1584925632, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p02731.html", "problem_id": "p02731", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02731/input.txt", "sample_output_relpath": "derived/input_output/data/p02731/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02731/Lua/s604622317.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s604622317", "user_id": "u120582723"}, "prompt_components": {"gold_output": "1.000000000000\n", "input_to_evaluate": "local a = io.read(\"*n\")\na = a / 3\nprint(a * a * a)\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nGiven is a positive integer L.\nFind the maximum possible volume of a rectangular cuboid whose sum of the dimensions (not necessarily integers) is L.\n\nConstraints\n\n1 ≤ L ≤ 1000\n\nL is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nL\n\nOutput\n\nPrint the maximum possible volume of a rectangular cuboid whose sum of the dimensions (not necessarily integers) is L.\nYour output is considered correct if its absolute or relative error from our answer is at most 10^{-6}.\n\nSample Input 1\n\n3\n\nSample Output 1\n\n1.000000000000\n\nFor example, a rectangular cuboid whose dimensions are 0.8, 1, and 1.2 has a volume of 0.96.\n\nOn the other hand, if the dimensions are 1, 1, and 1, the volume of the rectangular cuboid is 1, which is greater.\n\nSample Input 2\n\n999\n\nSample Output 2\n\n36926037.000000000000", "sample_input": "3\n"}, "reference_outputs": ["1.000000000000\n"], "source_document_id": "p02731", "source_text": "Score : 300 points\n\nProblem Statement\n\nGiven is a positive integer L.\nFind the maximum possible volume of a rectangular cuboid whose sum of the dimensions (not necessarily integers) is L.\n\nConstraints\n\n1 ≤ L ≤ 1000\n\nL is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nL\n\nOutput\n\nPrint the maximum possible volume of a rectangular cuboid whose sum of the dimensions (not necessarily integers) is L.\nYour output is considered correct if its absolute or relative error from our answer is at most 10^{-6}.\n\nSample Input 1\n\n3\n\nSample Output 1\n\n1.000000000000\n\nFor example, a rectangular cuboid whose dimensions are 0.8, 1, and 1.2 has a volume of 0.96.\n\nOn the other hand, if the dimensions are 1, 1, and 1, the volume of the rectangular cuboid is 1, which is greater.\n\nSample Input 2\n\n999\n\nSample Output 2\n\n36926037.000000000000", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 51, "cpu_time_ms": 44, "memory_kb": 1012}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s082857358", "group_id": "codeNet:p02732", "input_text": "n=io.read(\"*n\")\na={}\nfor i=1, n do\n a[i]=io.read(\"*n\")\nend\n\nb={}\nfor i=1, n do\n if b[a[i]]==nil then\n b[a[i]]=1\n else\n b[a[i]]=b[a[i]]+1\n end\nend\n\ntotal=0\nfor key,value in pairs(b) do\n total=total+value*(value-1)//2\nend\n\nfor i=1, n do\n answer = total\n answer = answer - (b[a[i]]*(b[a[i]]-1)//2)\n answer = answer + ((b[a[i]]-1)*(b[a[i]]-2)//2)\n print(answer)\nend", "language": "Lua", "metadata": {"date": 1587172986, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p02732.html", "problem_id": "p02732", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02732/input.txt", "sample_output_relpath": "derived/input_output/data/p02732/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02732/Lua/s082857358.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s082857358", "user_id": "u045238009"}, "prompt_components": {"gold_output": "2\n2\n3\n2\n3\n", "input_to_evaluate": "n=io.read(\"*n\")\na={}\nfor i=1, n do\n a[i]=io.read(\"*n\")\nend\n\nb={}\nfor i=1, n do\n if b[a[i]]==nil then\n b[a[i]]=1\n else\n b[a[i]]=b[a[i]]+1\n end\nend\n\ntotal=0\nfor key,value in pairs(b) do\n total=total+value*(value-1)//2\nend\n\nfor i=1, n do\n answer = total\n answer = answer - (b[a[i]]*(b[a[i]]-1)//2)\n answer = answer + ((b[a[i]]-1)*(b[a[i]]-2)//2)\n print(answer)\nend", "problem_context": "Score : 400 points\n\nProblem Statement\n\nWe have N balls. The i-th ball has an integer A_i written on it.\n\nFor each k=1, 2, ..., N, solve the following problem and print the answer.\n\nFind the number of ways to choose two distinct balls (disregarding order) from the N-1 balls other than the k-th ball so that the integers written on them are equal.\n\nConstraints\n\n3 \\leq N \\leq 2 \\times 10^5\n\n1 \\leq A_i \\leq N\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nFor each k=1,2,...,N, print a line containing the answer.\n\nSample Input 1\n\n5\n1 1 2 1 2\n\nSample Output 1\n\n2\n2\n3\n2\n3\n\nConsider the case k=1 for example. The numbers written on the remaining balls are 1,2,1,2.\n\nFrom these balls, there are two ways to choose two distinct balls so that the integers written on them are equal.\n\nThus, the answer for k=1 is 2.\n\nSample Input 2\n\n4\n1 2 3 4\n\nSample Output 2\n\n0\n0\n0\n0\n\nNo two balls have equal numbers written on them.\n\nSample Input 3\n\n5\n3 3 3 3 3\n\nSample Output 3\n\n6\n6\n6\n6\n6\n\nAny two balls have equal numbers written on them.\n\nSample Input 4\n\n8\n1 2 1 4 2 1 4 1\n\nSample Output 4\n\n5\n7\n5\n7\n7\n5\n7\n5", "sample_input": "5\n1 1 2 1 2\n"}, "reference_outputs": ["2\n2\n3\n2\n3\n"], "source_document_id": "p02732", "source_text": "Score : 400 points\n\nProblem Statement\n\nWe have N balls. The i-th ball has an integer A_i written on it.\n\nFor each k=1, 2, ..., N, solve the following problem and print the answer.\n\nFind the number of ways to choose two distinct balls (disregarding order) from the N-1 balls other than the k-th ball so that the integers written on them are equal.\n\nConstraints\n\n3 \\leq N \\leq 2 \\times 10^5\n\n1 \\leq A_i \\leq N\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nFor each k=1,2,...,N, print a line containing the answer.\n\nSample Input 1\n\n5\n1 1 2 1 2\n\nSample Output 1\n\n2\n2\n3\n2\n3\n\nConsider the case k=1 for example. The numbers written on the remaining balls are 1,2,1,2.\n\nFrom these balls, there are two ways to choose two distinct balls so that the integers written on them are equal.\n\nThus, the answer for k=1 is 2.\n\nSample Input 2\n\n4\n1 2 3 4\n\nSample Output 2\n\n0\n0\n0\n0\n\nNo two balls have equal numbers written on them.\n\nSample Input 3\n\n5\n3 3 3 3 3\n\nSample Output 3\n\n6\n6\n6\n6\n6\n\nAny two balls have equal numbers written on them.\n\nSample Input 4\n\n8\n1 2 1 4 2 1 4 1\n\nSample Output 4\n\n5\n7\n5\n7\n7\n5\n7\n5", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 402, "cpu_time_ms": 702, "memory_kb": 10604}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s478964301", "group_id": "codeNet:p02734", "input_text": "local mod = 998244353\nlocal mfl = math.floor\nlocal function bmul(x, y)\n local x0, y0 = x % 31596, y % 31596\n local x1, y1 = mfl(x / 31596), mfl(y / 31596)\n return (x1 * y1 * 62863 + (x1 * y0 + x0 * y1) * 31596 + x0 * y0) % mod\nend\n\nlocal function badd(x, y)\n return (x + y) % mod\nend\n\nlocal n, s = io.read(\"*n\", \"*n\")\nlocal a = {}\nfor i = 1, n do\n a[i] = io.read(\"*n\")\nend\nlocal dp = {}\nfor i = 1, s + 1 do\n dp[i] = 0\nend\ndp[1] = 1\nif a[n] <= s then\n dp[a[n] + 1] = 1\nend\nlocal ret = dp[s + 1]\nfor i = n - 1, 1, -1 do\n local av = a[i]\n dp[1] = badd(dp[1], 1)\n for j = s + 1 - av, 1, -1 do\n dp[j + av] = badd(dp[j + av], dp[j])\n end\n ret = badd(ret, dp[s + 1])\nend\nprint(ret)\n", "language": "Lua", "metadata": {"date": 1584928602, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p02734.html", "problem_id": "p02734", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02734/input.txt", "sample_output_relpath": "derived/input_output/data/p02734/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02734/Lua/s478964301.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s478964301", "user_id": "u120582723"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "local mod = 998244353\nlocal mfl = math.floor\nlocal function bmul(x, y)\n local x0, y0 = x % 31596, y % 31596\n local x1, y1 = mfl(x / 31596), mfl(y / 31596)\n return (x1 * y1 * 62863 + (x1 * y0 + x0 * y1) * 31596 + x0 * y0) % mod\nend\n\nlocal function badd(x, y)\n return (x + y) % mod\nend\n\nlocal n, s = io.read(\"*n\", \"*n\")\nlocal a = {}\nfor i = 1, n do\n a[i] = io.read(\"*n\")\nend\nlocal dp = {}\nfor i = 1, s + 1 do\n dp[i] = 0\nend\ndp[1] = 1\nif a[n] <= s then\n dp[a[n] + 1] = 1\nend\nlocal ret = dp[s + 1]\nfor i = n - 1, 1, -1 do\n local av = a[i]\n dp[1] = badd(dp[1], 1)\n for j = s + 1 - av, 1, -1 do\n dp[j + av] = badd(dp[j + av], dp[j])\n end\n ret = badd(ret, dp[s + 1])\nend\nprint(ret)\n", "problem_context": "Score : 600 points\n\nProblem Statement\n\nGiven are a sequence of N integers A_1, A_2, \\ldots, A_N and a positive integer S.\n\nFor a pair of integers (L, R) such that 1\\leq L \\leq R \\leq N, let us define f(L, R) as follows:\n\nf(L, R) is the number of sequences of integers (x_1, x_2, \\ldots , x_k) such that L \\leq x_1 < x_2 < \\cdots < x_k \\leq R and A_{x_1}+A_{x_2}+\\cdots +A_{x_k} = S.\n\nFind the sum of f(L, R) over all pairs of integers (L, R) such that 1\\leq L \\leq R\\leq N. Since this sum can be enormous, print it modulo 998244353.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 3000\n\n1 \\leq S \\leq 3000\n\n1 \\leq A_i \\leq 3000\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN S\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the sum of f(L, R), modulo 998244353.\n\nSample Input 1\n\n3 4\n2 2 4\n\nSample Output 1\n\n5\n\nThe value of f(L, R) for each pair is as follows, for a total of 5.\n\nf(1,1) = 0\n\nf(1,2) = 1 (for the sequence (1, 2))\n\nf(1,3) = 2 (for (1, 2) and (3))\n\nf(2,2) = 0\n\nf(2,3) = 1 (for (3))\n\nf(3,3) = 1 (for (3))\n\nSample Input 2\n\n5 8\n9 9 9 9 9\n\nSample Output 2\n\n0\n\nSample Input 3\n\n10 10\n3 1 4 1 5 9 2 6 5 3\n\nSample Output 3\n\n152", "sample_input": "3 4\n2 2 4\n"}, "reference_outputs": ["5\n"], "source_document_id": "p02734", "source_text": "Score : 600 points\n\nProblem Statement\n\nGiven are a sequence of N integers A_1, A_2, \\ldots, A_N and a positive integer S.\n\nFor a pair of integers (L, R) such that 1\\leq L \\leq R \\leq N, let us define f(L, R) as follows:\n\nf(L, R) is the number of sequences of integers (x_1, x_2, \\ldots , x_k) such that L \\leq x_1 < x_2 < \\cdots < x_k \\leq R and A_{x_1}+A_{x_2}+\\cdots +A_{x_k} = S.\n\nFind the sum of f(L, R) over all pairs of integers (L, R) such that 1\\leq L \\leq R\\leq N. Since this sum can be enormous, print it modulo 998244353.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 3000\n\n1 \\leq S \\leq 3000\n\n1 \\leq A_i \\leq 3000\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN S\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the sum of f(L, R), modulo 998244353.\n\nSample Input 1\n\n3 4\n2 2 4\n\nSample Output 1\n\n5\n\nThe value of f(L, R) for each pair is as follows, for a total of 5.\n\nf(1,1) = 0\n\nf(1,2) = 1 (for the sequence (1, 2))\n\nf(1,3) = 2 (for (1, 2) and (3))\n\nf(2,2) = 0\n\nf(2,3) = 1 (for (3))\n\nf(3,3) = 1 (for (3))\n\nSample Input 2\n\n5 8\n9 9 9 9 9\n\nSample Output 2\n\n0\n\nSample Input 3\n\n10 10\n3 1 4 1 5 9 2 6 5 3\n\nSample Output 3\n\n152", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 690, "cpu_time_ms": 36, "memory_kb": 256}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s100785488", "group_id": "codeNet:p02735", "input_text": "local h,w=io.read(\"n\",\"n\",\"l\")\nlocal s={}\nlocal dp={}\nfor i=1,h do\n local t=io.read()\n s[i]={}\n dp[i]={}\n for j=1,w do\n s[i][j]=t:sub(j,j)\n dp[i][j]=10000000000000000\n end\nend\n\nlocal dx={1,0}\nlocal dy={0,1}\n\nlocal function solve()\n if s[1][1]==\"#\" then\n dp[1][1]=1\n else\n dp[1][1]=0\n end\n\n for i=1,h do\n for j=1,w do\n for k=1,2 do\n local ni=i+dx[k]\n local nj=j+dy[k]\n if h>=ni and w>=nj then\n local add=0\n if s[ni][nj]==\"#\" and s[i][j]==\".\" then\n add=1\n end\n if dp[ni][nj]>dp[i][j]+add then\n dp[ni][nj]=dp[i][j]+add\n end\n end\n end\n end\n end\n return dp[h][w]\nend\n\nprint(solve())", "language": "Lua", "metadata": {"date": 1591108037, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p02735.html", "problem_id": "p02735", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02735/input.txt", "sample_output_relpath": "derived/input_output/data/p02735/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02735/Lua/s100785488.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s100785488", "user_id": "u045238009"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "local h,w=io.read(\"n\",\"n\",\"l\")\nlocal s={}\nlocal dp={}\nfor i=1,h do\n local t=io.read()\n s[i]={}\n dp[i]={}\n for j=1,w do\n s[i][j]=t:sub(j,j)\n dp[i][j]=10000000000000000\n end\nend\n\nlocal dx={1,0}\nlocal dy={0,1}\n\nlocal function solve()\n if s[1][1]==\"#\" then\n dp[1][1]=1\n else\n dp[1][1]=0\n end\n\n for i=1,h do\n for j=1,w do\n for k=1,2 do\n local ni=i+dx[k]\n local nj=j+dy[k]\n if h>=ni and w>=nj then\n local add=0\n if s[ni][nj]==\"#\" and s[i][j]==\".\" then\n add=1\n end\n if dp[ni][nj]>dp[i][j]+add then\n dp[ni][nj]=dp[i][j]+add\n end\n end\n end\n end\n end\n return dp[h][w]\nend\n\nprint(solve())", "problem_context": "Score : 400 points\n\nProblem Statement\n\nConsider a grid with H rows and W columns of squares. Let (r, c) denote the square at the r-th row from the top and the c-th column from the left.\nEach square is painted black or white.\n\nThe grid is said to be good if and only if the following condition is satisfied:\n\nFrom (1, 1), we can reach (H, W) by moving one square right or down repeatedly, while always being on a white square.\n\nNote that (1, 1) and (H, W) must be white if the grid is good.\n\nYour task is to make the grid good by repeating the operation below. Find the minimum number of operations needed to complete the task. It can be proved that you can always complete the task in a finite number of operations.\n\nChoose four integers r_0, c_0, r_1, c_1(1 \\leq r_0 \\leq r_1 \\leq H, 1 \\leq c_0 \\leq c_1 \\leq W). For each pair r, c (r_0 \\leq r \\leq r_1, c_0 \\leq c \\leq c_1), invert the color of (r, c) - that is, from white to black and vice versa.\n\nConstraints\n\n2 \\leq H, W \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\ns_{11} s_{12} \\cdots s_{1W}\ns_{21} s_{22} \\cdots s_{2W}\n\\vdots\ns_{H1} s_{H2} \\cdots s_{HW}\n\nHere s_{rc} represents the color of (r, c) - # stands for black, and . stands for white.\n\nOutput\n\nPrint the minimum number of operations needed.\n\nSample Input 1\n\n3 3\n.##\n.#.\n##.\n\nSample Output 1\n\n1\n\nDo the operation with (r_0, c_0, r_1, c_1) = (2, 2, 2, 2) to change just the color of (2, 2), and we are done.\n\nSample Input 2\n\n2 2\n#.\n.#\n\nSample Output 2\n\n2\n\nSample Input 3\n\n4 4\n..##\n#...\n###.\n###.\n\nSample Output 3\n\n0\n\nNo operation may be needed.\n\nSample Input 4\n\n5 5\n.#.#.\n#.#.#\n.#.#.\n#.#.#\n.#.#.\n\nSample Output 4\n\n4", "sample_input": "3 3\n.##\n.#.\n##.\n"}, "reference_outputs": ["1\n"], "source_document_id": "p02735", "source_text": "Score : 400 points\n\nProblem Statement\n\nConsider a grid with H rows and W columns of squares. Let (r, c) denote the square at the r-th row from the top and the c-th column from the left.\nEach square is painted black or white.\n\nThe grid is said to be good if and only if the following condition is satisfied:\n\nFrom (1, 1), we can reach (H, W) by moving one square right or down repeatedly, while always being on a white square.\n\nNote that (1, 1) and (H, W) must be white if the grid is good.\n\nYour task is to make the grid good by repeating the operation below. Find the minimum number of operations needed to complete the task. It can be proved that you can always complete the task in a finite number of operations.\n\nChoose four integers r_0, c_0, r_1, c_1(1 \\leq r_0 \\leq r_1 \\leq H, 1 \\leq c_0 \\leq c_1 \\leq W). For each pair r, c (r_0 \\leq r \\leq r_1, c_0 \\leq c \\leq c_1), invert the color of (r, c) - that is, from white to black and vice versa.\n\nConstraints\n\n2 \\leq H, W \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\ns_{11} s_{12} \\cdots s_{1W}\ns_{21} s_{22} \\cdots s_{2W}\n\\vdots\ns_{H1} s_{H2} \\cdots s_{HW}\n\nHere s_{rc} represents the color of (r, c) - # stands for black, and . stands for white.\n\nOutput\n\nPrint the minimum number of operations needed.\n\nSample Input 1\n\n3 3\n.##\n.#.\n##.\n\nSample Output 1\n\n1\n\nDo the operation with (r_0, c_0, r_1, c_1) = (2, 2, 2, 2) to change just the color of (2, 2), and we are done.\n\nSample Input 2\n\n2 2\n#.\n.#\n\nSample Output 2\n\n2\n\nSample Input 3\n\n4 4\n..##\n#...\n###.\n###.\n\nSample Output 3\n\n0\n\nNo operation may be needed.\n\nSample Input 4\n\n5 5\n.#.#.\n#.#.#\n.#.#.\n#.#.#\n.#.#.\n\nSample Output 4\n\n4", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 875, "cpu_time_ms": 11, "memory_kb": 760}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s714306485", "group_id": "codeNet:p02741", "input_text": "local read = setmetatable({}, {__index = function(t, k) local a = {} for i=1,#k do table.insert(a, '*'..string.sub(k, i, i)) end local r = io.read local u = table.unpack or unpack return function() return r(u(a)) end end})\nread.N = function(N) local t={} for i=1,N do t[i]=read.n() end return t end\nstring.totable = function(s) local t={} local u=string.sub for i=1,#s do t[i] = u(s, i, i) end return t end\nstring.split = function(s) local t={} for w in string.gmatch(s, \"[^%s]+\") do table.insert(t, w) end return (table.unpack or unpack)(t) end\nlocal function array(dimension, default_val) assert(type(default_val) ~= 'table') local n=dimension local m={}if default_val~=nil then m[1]={__index=function()return default_val end}end for i=2,n do m[i]={__index=function(p, k)local c=setmetatable({},m[i-1])rawset(p,k,c)return c end}end return setmetatable({},m[n])end\n----\nlocal a = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51}\nlocal K = read.n()\nprint(a[K])", "language": "Lua", "metadata": {"date": 1584234067, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p02741.html", "problem_id": "p02741", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02741/input.txt", "sample_output_relpath": "derived/input_output/data/p02741/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02741/Lua/s714306485.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s714306485", "user_id": "u162773977"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "local read = setmetatable({}, {__index = function(t, k) local a = {} for i=1,#k do table.insert(a, '*'..string.sub(k, i, i)) end local r = io.read local u = table.unpack or unpack return function() return r(u(a)) end end})\nread.N = function(N) local t={} for i=1,N do t[i]=read.n() end return t end\nstring.totable = function(s) local t={} local u=string.sub for i=1,#s do t[i] = u(s, i, i) end return t end\nstring.split = function(s) local t={} for w in string.gmatch(s, \"[^%s]+\") do table.insert(t, w) end return (table.unpack or unpack)(t) end\nlocal function array(dimension, default_val) assert(type(default_val) ~= 'table') local n=dimension local m={}if default_val~=nil then m[1]={__index=function()return default_val end}end for i=2,n do m[i]={__index=function(p, k)local c=setmetatable({},m[i-1])rawset(p,k,c)return c end}end return setmetatable({},m[n])end\n----\nlocal a = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51}\nlocal K = read.n()\nprint(a[K])", "problem_context": "Score : 100 points\n\nProblem Statement\n\nPrint the K-th element of the following sequence of length 32:\n\n1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51\n\nConstraints\n\n1 \\leq K \\leq 32\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nK\n\nOutput\n\nPrint the K-th element.\n\nSample Input 1\n\n6\n\nSample Output 1\n\n2\n\nThe 6-th element is 2.\n\nSample Input 2\n\n27\n\nSample Output 2\n\n5\n\nThe 27-th element is 5.", "sample_input": "6\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02741", "source_text": "Score : 100 points\n\nProblem Statement\n\nPrint the K-th element of the following sequence of length 32:\n\n1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51\n\nConstraints\n\n1 \\leq K \\leq 32\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nK\n\nOutput\n\nPrint the K-th element.\n\nSample Input 1\n\n6\n\nSample Output 1\n\n2\n\nThe 6-th element is 2.\n\nSample Input 2\n\n27\n\nSample Output 2\n\n5\n\nThe 27-th element is 5.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1011, "cpu_time_ms": 9, "memory_kb": 1008}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s324864990", "group_id": "codeNet:p02742", "input_text": "local h, w = io.read(\"*n\", \"*n\")\nif h % 2 == 0 or w % 2 == 0 then\n print(h * w // 2)\nelse\n local a = w // 2\n local b = h // 2\n print(a * b + (a + 1) * (b + 1))\n\nend\n", "language": "Lua", "metadata": {"date": 1584234623, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p02742.html", "problem_id": "p02742", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02742/input.txt", "sample_output_relpath": "derived/input_output/data/p02742/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02742/Lua/s324864990.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s324864990", "user_id": "u120582723"}, "prompt_components": {"gold_output": "10\n", "input_to_evaluate": "local h, w = io.read(\"*n\", \"*n\")\nif h % 2 == 0 or w % 2 == 0 then\n print(h * w // 2)\nelse\n local a = w // 2\n local b = h // 2\n print(a * b + (a + 1) * (b + 1))\n\nend\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nWe have a board with H horizontal rows and W vertical columns of squares.\nThere is a bishop at the top-left square on this board.\nHow many squares can this bishop reach by zero or more movements?\n\nHere the bishop can only move diagonally.\nMore formally, the bishop can move from the square at the r_1-th row (from the top) and the c_1-th column (from the left) to the square at the r_2-th row and the c_2-th column if and only if exactly one of the following holds:\n\nr_1 + c_1 = r_2 + c_2\n\nr_1 - c_1 = r_2 - c_2\n\nFor example, in the following figure, the bishop can move to any of the red squares in one move:\n\nConstraints\n\n1 \\leq H, W \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH \\ W\n\nOutput\n\nPrint the number of squares the bishop can reach.\n\nSample Input 1\n\n4 5\n\nSample Output 1\n\n10\n\nThe bishop can reach the cyan squares in the following figure:\n\nSample Input 2\n\n7 3\n\nSample Output 2\n\n11\n\nThe bishop can reach the cyan squares in the following figure:\n\nSample Input 3\n\n1000000000 1000000000\n\nSample Output 3\n\n500000000000000000", "sample_input": "4 5\n"}, "reference_outputs": ["10\n"], "source_document_id": "p02742", "source_text": "Score : 200 points\n\nProblem Statement\n\nWe have a board with H horizontal rows and W vertical columns of squares.\nThere is a bishop at the top-left square on this board.\nHow many squares can this bishop reach by zero or more movements?\n\nHere the bishop can only move diagonally.\nMore formally, the bishop can move from the square at the r_1-th row (from the top) and the c_1-th column (from the left) to the square at the r_2-th row and the c_2-th column if and only if exactly one of the following holds:\n\nr_1 + c_1 = r_2 + c_2\n\nr_1 - c_1 = r_2 - c_2\n\nFor example, in the following figure, the bishop can move to any of the red squares in one move:\n\nConstraints\n\n1 \\leq H, W \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH \\ W\n\nOutput\n\nPrint the number of squares the bishop can reach.\n\nSample Input 1\n\n4 5\n\nSample Output 1\n\n10\n\nThe bishop can reach the cyan squares in the following figure:\n\nSample Input 2\n\n7 3\n\nSample Output 2\n\n11\n\nThe bishop can reach the cyan squares in the following figure:\n\nSample Input 3\n\n1000000000 1000000000\n\nSample Output 3\n\n500000000000000000", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 169, "cpu_time_ms": 8, "memory_kb": 760}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s235788831", "group_id": "codeNet:p02744", "input_text": "local n=io.read(\"n\")\nlocal s=\"\"\nlocal function dfs(s,max)\n if #s==n then\n print(s)\n else\n for c=97,max do\n dfs(s..string.char(c),(c==max and max+1 or max))\n end\n end\nend\ndfs(s,97)", "language": "Lua", "metadata": {"date": 1593976667, "filename_ext": "lua", "original_language": "Lua (LuaJIT 2.1.0)", "problem_description_relpath": "problem_descriptions/p02744.html", "problem_id": "p02744", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02744/input.txt", "sample_output_relpath": "derived/input_output/data/p02744/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02744/Lua/s235788831.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s235788831", "user_id": "u045238009"}, "prompt_components": {"gold_output": "a\n", "input_to_evaluate": "local n=io.read(\"n\")\nlocal s=\"\"\nlocal function dfs(s,max)\n if #s==n then\n print(s)\n else\n for c=97,max do\n dfs(s..string.char(c),(c==max and max+1 or max))\n end\n end\nend\ndfs(s,97)", "problem_context": "Score : 400 points\n\nProblem Statement\n\nIn this problem, we only consider strings consisting of lowercase English letters.\n\nStrings s and t are said to be isomorphic when the following conditions are satisfied:\n\n|s| = |t| holds.\n\nFor every pair i, j, one of the following holds:\n\ns_i = s_j and t_i = t_j.\n\ns_i \\neq s_j and t_i \\neq t_j.\n\nFor example, abcac and zyxzx are isomorphic, while abcac and ppppp are not.\n\nA string s is said to be in normal form when the following condition is satisfied:\n\nFor every string t that is isomorphic to s, s \\leq t holds. Here \\leq denotes lexicographic comparison.\n\nFor example, abcac is in normal form, but zyxzx is not since it is isomorphic to abcac, which is lexicographically smaller than zyxzx.\n\nYou are given an integer N.\nPrint all strings of length N that are in normal form, in lexicographically ascending order.\n\nConstraints\n\n1 \\leq N \\leq 10\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nAssume that there are K strings of length N that are in normal form: w_1, \\ldots, w_K in lexicographical order.\nOutput should be in the following format:\n\nw_1\n:\nw_K\n\nSample Input 1\n\n1\n\nSample Output 1\n\na\n\nSample Input 2\n\n2\n\nSample Output 2\n\naa\nab", "sample_input": "1\n"}, "reference_outputs": ["a\n"], "source_document_id": "p02744", "source_text": "Score : 400 points\n\nProblem Statement\n\nIn this problem, we only consider strings consisting of lowercase English letters.\n\nStrings s and t are said to be isomorphic when the following conditions are satisfied:\n\n|s| = |t| holds.\n\nFor every pair i, j, one of the following holds:\n\ns_i = s_j and t_i = t_j.\n\ns_i \\neq s_j and t_i \\neq t_j.\n\nFor example, abcac and zyxzx are isomorphic, while abcac and ppppp are not.\n\nA string s is said to be in normal form when the following condition is satisfied:\n\nFor every string t that is isomorphic to s, s \\leq t holds. Here \\leq denotes lexicographic comparison.\n\nFor example, abcac is in normal form, but zyxzx is not since it is isomorphic to abcac, which is lexicographically smaller than zyxzx.\n\nYou are given an integer N.\nPrint all strings of length N that are in normal form, in lexicographically ascending order.\n\nConstraints\n\n1 \\leq N \\leq 10\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nAssume that there are K strings of length N that are in normal form: w_1, \\ldots, w_K in lexicographical order.\nOutput should be in the following format:\n\nw_1\n:\nw_K\n\nSample Input 1\n\n1\n\nSample Output 1\n\na\n\nSample Input 2\n\n2\n\nSample Output 2\n\naa\nab", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 220, "cpu_time_ms": 27, "memory_kb": 2684}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s652437375", "group_id": "codeNet:p02744", "input_text": "local read = setmetatable({}, {__index = function(t, k) local a = {} for i=1,#k do table.insert(a, '*'..string.sub(k, i, i)) end local r = io.read local u = table.unpack or unpack return function() return r(u(a)) end end})\nread.N = function(N) local t={} for i=1,N do t[i]=read.n() end return t end\nstring.totable = function(s) local t={} local u=string.sub for i=1,#s do t[i] = u(s, i, i) end return t end\nstring.split = function(s) local t={} for w in string.gmatch(s, \"[^%s]+\") do table.insert(t, w) end return (table.unpack or unpack)(t) end\nlocal function array(dimension, default_val) assert(type(default_val) ~= 'table') local n=dimension local m={}if default_val~=nil then m[1]={__index=function()return default_val end}end for i=2,n do m[i]={__index=function(p, k)local c=setmetatable({},m[i-1])rawset(p,k,c)return c end}end return setmetatable({},m[n])end\n----\nlocal A = {}\nfor i=1,26 do\n A[i] = string.char(0x60 + i)\nend\nlocal N = read.n()\n\nlocal ans = {}\nlocal build = {}\nlocal function dfs_cps(i, mx, cont)\n if i == N then\n table.insert(ans, table.concat(build))\n return cont()\n else\n local function make_cont(j, lim)\n return function()\n if j <= lim then\n build[i+1] = A[j]\n return dfs_cps(i+1, math.max(j,mx), make_cont(j+1,lim))\n else\n return cont()\n end\n end\n end\n return make_cont(1, mx+1)()\n end\nend\ndfs_cps(0, 0, function()\n for i=1,#ans do\n print(ans[i])\n end\n --print(#ans)\nend)", "language": "Lua", "metadata": {"date": 1584283032, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p02744.html", "problem_id": "p02744", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02744/input.txt", "sample_output_relpath": "derived/input_output/data/p02744/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02744/Lua/s652437375.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s652437375", "user_id": "u162773977"}, "prompt_components": {"gold_output": "a\n", "input_to_evaluate": "local read = setmetatable({}, {__index = function(t, k) local a = {} for i=1,#k do table.insert(a, '*'..string.sub(k, i, i)) end local r = io.read local u = table.unpack or unpack return function() return r(u(a)) end end})\nread.N = function(N) local t={} for i=1,N do t[i]=read.n() end return t end\nstring.totable = function(s) local t={} local u=string.sub for i=1,#s do t[i] = u(s, i, i) end return t end\nstring.split = function(s) local t={} for w in string.gmatch(s, \"[^%s]+\") do table.insert(t, w) end return (table.unpack or unpack)(t) end\nlocal function array(dimension, default_val) assert(type(default_val) ~= 'table') local n=dimension local m={}if default_val~=nil then m[1]={__index=function()return default_val end}end for i=2,n do m[i]={__index=function(p, k)local c=setmetatable({},m[i-1])rawset(p,k,c)return c end}end return setmetatable({},m[n])end\n----\nlocal A = {}\nfor i=1,26 do\n A[i] = string.char(0x60 + i)\nend\nlocal N = read.n()\n\nlocal ans = {}\nlocal build = {}\nlocal function dfs_cps(i, mx, cont)\n if i == N then\n table.insert(ans, table.concat(build))\n return cont()\n else\n local function make_cont(j, lim)\n return function()\n if j <= lim then\n build[i+1] = A[j]\n return dfs_cps(i+1, math.max(j,mx), make_cont(j+1,lim))\n else\n return cont()\n end\n end\n end\n return make_cont(1, mx+1)()\n end\nend\ndfs_cps(0, 0, function()\n for i=1,#ans do\n print(ans[i])\n end\n --print(#ans)\nend)", "problem_context": "Score : 400 points\n\nProblem Statement\n\nIn this problem, we only consider strings consisting of lowercase English letters.\n\nStrings s and t are said to be isomorphic when the following conditions are satisfied:\n\n|s| = |t| holds.\n\nFor every pair i, j, one of the following holds:\n\ns_i = s_j and t_i = t_j.\n\ns_i \\neq s_j and t_i \\neq t_j.\n\nFor example, abcac and zyxzx are isomorphic, while abcac and ppppp are not.\n\nA string s is said to be in normal form when the following condition is satisfied:\n\nFor every string t that is isomorphic to s, s \\leq t holds. Here \\leq denotes lexicographic comparison.\n\nFor example, abcac is in normal form, but zyxzx is not since it is isomorphic to abcac, which is lexicographically smaller than zyxzx.\n\nYou are given an integer N.\nPrint all strings of length N that are in normal form, in lexicographically ascending order.\n\nConstraints\n\n1 \\leq N \\leq 10\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nAssume that there are K strings of length N that are in normal form: w_1, \\ldots, w_K in lexicographical order.\nOutput should be in the following format:\n\nw_1\n:\nw_K\n\nSample Input 1\n\n1\n\nSample Output 1\n\na\n\nSample Input 2\n\n2\n\nSample Output 2\n\naa\nab", "sample_input": "1\n"}, "reference_outputs": ["a\n"], "source_document_id": "p02744", "source_text": "Score : 400 points\n\nProblem Statement\n\nIn this problem, we only consider strings consisting of lowercase English letters.\n\nStrings s and t are said to be isomorphic when the following conditions are satisfied:\n\n|s| = |t| holds.\n\nFor every pair i, j, one of the following holds:\n\ns_i = s_j and t_i = t_j.\n\ns_i \\neq s_j and t_i \\neq t_j.\n\nFor example, abcac and zyxzx are isomorphic, while abcac and ppppp are not.\n\nA string s is said to be in normal form when the following condition is satisfied:\n\nFor every string t that is isomorphic to s, s \\leq t holds. Here \\leq denotes lexicographic comparison.\n\nFor example, abcac is in normal form, but zyxzx is not since it is isomorphic to abcac, which is lexicographically smaller than zyxzx.\n\nYou are given an integer N.\nPrint all strings of length N that are in normal form, in lexicographically ascending order.\n\nConstraints\n\n1 \\leq N \\leq 10\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nAssume that there are K strings of length N that are in normal form: w_1, \\ldots, w_K in lexicographical order.\nOutput should be in the following format:\n\nw_1\n:\nw_K\n\nSample Input 1\n\n1\n\nSample Output 1\n\na\n\nSample Input 2\n\n2\n\nSample Output 2\n\naa\nab", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1586, "cpu_time_ms": 464, "memory_kb": 21880}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s459083898", "group_id": "codeNet:p02755", "input_text": "local read = setmetatable({}, {__index = function(t, k) local a = {} for i=1,#k do table.insert(a, '*'..string.sub(k, i, i)) end local r = io.read local u = table.unpack or unpack return function() return r(u(a)) end end})\nread.N = function(N) local t={} for i=1,N do t[i]=read.n() end return t end\nstring.totable = function(s) local t={} local u=string.sub for i=1,#s do t[i] = u(s, i, i) end return t end\nstring.split = function(s) local t={} for w in string.gmatch(s, \"[^%s]+\") do table.insert(t, w) end return (table.unpack or unpack)(t) end\nlocal function array(dimension, default_val) local n=dimension local m={}if default_val~=nil then m[1]={__index=function()return default_val end}end for i=2,n do m[i]={__index=function(p, k)local c=setmetatable({},m[i-1])rawset(p,k,c)return c end}end return setmetatable({},m[n])end\n----\nlocal A, B = read.nn()\nlocal price_base = B * 10\nfor i=0,9 do\n local p = price_base + i\n if p * 8 // 100 == A then\n print(p)\n return\n end\nend\nprint(-1)\n", "language": "Lua", "metadata": {"date": 1583639468, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p02755.html", "problem_id": "p02755", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02755/input.txt", "sample_output_relpath": "derived/input_output/data/p02755/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02755/Lua/s459083898.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s459083898", "user_id": "u162773977"}, "prompt_components": {"gold_output": "25\n", "input_to_evaluate": "local read = setmetatable({}, {__index = function(t, k) local a = {} for i=1,#k do table.insert(a, '*'..string.sub(k, i, i)) end local r = io.read local u = table.unpack or unpack return function() return r(u(a)) end end})\nread.N = function(N) local t={} for i=1,N do t[i]=read.n() end return t end\nstring.totable = function(s) local t={} local u=string.sub for i=1,#s do t[i] = u(s, i, i) end return t end\nstring.split = function(s) local t={} for w in string.gmatch(s, \"[^%s]+\") do table.insert(t, w) end return (table.unpack or unpack)(t) end\nlocal function array(dimension, default_val) local n=dimension local m={}if default_val~=nil then m[1]={__index=function()return default_val end}end for i=2,n do m[i]={__index=function(p, k)local c=setmetatable({},m[i-1])rawset(p,k,c)return c end}end return setmetatable({},m[n])end\n----\nlocal A, B = read.nn()\nlocal price_base = B * 10\nfor i=0,9 do\n local p = price_base + i\n if p * 8 // 100 == A then\n print(p)\n return\n end\nend\nprint(-1)\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nFind the price of a product before tax such that, when the consumption tax rate is 8 percent and 10 percent, the amount of consumption tax levied on it is A yen and B yen, respectively. (Yen is the currency of Japan.)\n\nHere, the price before tax must be a positive integer, and the amount of consumption tax is rounded down to the nearest integer.\n\nIf multiple prices satisfy the condition, print the lowest such price; if no price satisfies the condition, print -1.\n\nConstraints\n\n1 \\leq A \\leq B \\leq 100\n\nA and B are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nIf there is a price that satisfies the condition, print an integer representing the lowest such price; otherwise, print -1.\n\nSample Input 1\n\n2 2\n\nSample Output 1\n\n25\n\nIf the price of a product before tax is 25 yen, the amount of consumption tax levied on it is:\n\nWhen the consumption tax rate is 8 percent: \\lfloor 25 \\times 0.08 \\rfloor = \\lfloor 2 \\rfloor = 2 yen.\n\nWhen the consumption tax rate is 10 percent: \\lfloor 25 \\times 0.1 \\rfloor = \\lfloor 2.5 \\rfloor = 2 yen.\n\nThus, the price of 25 yen satisfies the condition. There are other possible prices, such as 26 yen, but print the minimum such price, 25.\n\nSample Input 2\n\n8 10\n\nSample Output 2\n\n100\n\nIf the price of a product before tax is 100 yen, the amount of consumption tax levied on it is:\n\nWhen the consumption tax rate is 8 percent: \\lfloor 100 \\times 0.08 \\rfloor = 8 yen.\n\nWhen the consumption tax rate is 10 percent: \\lfloor 100 \\times 0.1 \\rfloor = 10 yen.\n\nSample Input 3\n\n19 99\n\nSample Output 3\n\n-1\n\nThere is no price before tax satisfying this condition, so print -1.", "sample_input": "2 2\n"}, "reference_outputs": ["25\n"], "source_document_id": "p02755", "source_text": "Score : 300 points\n\nProblem Statement\n\nFind the price of a product before tax such that, when the consumption tax rate is 8 percent and 10 percent, the amount of consumption tax levied on it is A yen and B yen, respectively. (Yen is the currency of Japan.)\n\nHere, the price before tax must be a positive integer, and the amount of consumption tax is rounded down to the nearest integer.\n\nIf multiple prices satisfy the condition, print the lowest such price; if no price satisfies the condition, print -1.\n\nConstraints\n\n1 \\leq A \\leq B \\leq 100\n\nA and B are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nIf there is a price that satisfies the condition, print an integer representing the lowest such price; otherwise, print -1.\n\nSample Input 1\n\n2 2\n\nSample Output 1\n\n25\n\nIf the price of a product before tax is 25 yen, the amount of consumption tax levied on it is:\n\nWhen the consumption tax rate is 8 percent: \\lfloor 25 \\times 0.08 \\rfloor = \\lfloor 2 \\rfloor = 2 yen.\n\nWhen the consumption tax rate is 10 percent: \\lfloor 25 \\times 0.1 \\rfloor = \\lfloor 2.5 \\rfloor = 2 yen.\n\nThus, the price of 25 yen satisfies the condition. There are other possible prices, such as 26 yen, but print the minimum such price, 25.\n\nSample Input 2\n\n8 10\n\nSample Output 2\n\n100\n\nIf the price of a product before tax is 100 yen, the amount of consumption tax levied on it is:\n\nWhen the consumption tax rate is 8 percent: \\lfloor 100 \\times 0.08 \\rfloor = 8 yen.\n\nWhen the consumption tax rate is 10 percent: \\lfloor 100 \\times 0.1 \\rfloor = 10 yen.\n\nSample Input 3\n\n19 99\n\nSample Output 3\n\n-1\n\nThere is no price before tax satisfying this condition, so print -1.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1009, "cpu_time_ms": 7, "memory_kb": 508}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s749901362", "group_id": "codeNet:p02756", "input_text": "local s = io.read()\nlocal q = io.read(\"*n\", \"*l\")\nlocal w = true\nlocal left, right = {}, {}\nfor i = 1, q do\n local sq = io.read()\n if sq == \"1\" then\n w = not w\n else\n local f, c = sq:sub(3, 3), sq:sub(5, 5)\n if f == \"1\" then\n if w then\n table.insert(left, c)\n else\n table.insert(right, c)\n end\n else\n if w then\n table.insert(right, c)\n else\n table.insert(left, c)\n end\n end\n end\nend\nif w then\n for i = #left, 1, -1 do\n io.write(left[i])\n end\n io.write(s)\n for i = 1, #right do\n io.write(right[i])\n end\n io.write(\"\\n\")\nelse\n for i = #right, 1, -1 do\n io.write(right[i])\n end\n io.write(s:reverse())\n for i = 1, #left do\n io.write(left[i])\n end\n io.write(\"\\n\")\nend\n", "language": "Lua", "metadata": {"date": 1583644002, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p02756.html", "problem_id": "p02756", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02756/input.txt", "sample_output_relpath": "derived/input_output/data/p02756/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02756/Lua/s749901362.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s749901362", "user_id": "u120582723"}, "prompt_components": {"gold_output": "cpa\n", "input_to_evaluate": "local s = io.read()\nlocal q = io.read(\"*n\", \"*l\")\nlocal w = true\nlocal left, right = {}, {}\nfor i = 1, q do\n local sq = io.read()\n if sq == \"1\" then\n w = not w\n else\n local f, c = sq:sub(3, 3), sq:sub(5, 5)\n if f == \"1\" then\n if w then\n table.insert(left, c)\n else\n table.insert(right, c)\n end\n else\n if w then\n table.insert(right, c)\n else\n table.insert(left, c)\n end\n end\n end\nend\nif w then\n for i = #left, 1, -1 do\n io.write(left[i])\n end\n io.write(s)\n for i = 1, #right do\n io.write(right[i])\n end\n io.write(\"\\n\")\nelse\n for i = #right, 1, -1 do\n io.write(right[i])\n end\n io.write(s:reverse())\n for i = 1, #left do\n io.write(left[i])\n end\n io.write(\"\\n\")\nend\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nTakahashi has a string S consisting of lowercase English letters.\n\nStarting with this string, he will produce a new one in the procedure given as follows.\n\nThe procedure consists of Q operations. In Operation i (1 \\leq i \\leq Q), an integer T_i is provided, which means the following:\n\nIf T_i = 1: reverse the string S.\n\nIf T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided.\n\nIf F_i = 1 : Add C_i to the beginning of the string S.\n\nIf F_i = 2 : Add C_i to the end of the string S.\n\nHelp Takahashi by finding the final string that results from the procedure.\n\nConstraints\n\n1 \\leq |S| \\leq 10^5\n\nS consists of lowercase English letters.\n\n1 \\leq Q \\leq 2 \\times 10^5\n\nT_i = 1 or 2.\n\nF_i = 1 or 2, if provided.\n\nC_i is a lowercase English letter, if provided.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\nQ\nQuery_1\n:\nQuery_Q\n\nIn the 3-rd through the (Q+2)-th lines, Query_i is one of the following:\n\n1\n\nwhich means T_i = 1, and:\n\n2 F_i C_i\n\nwhich means T_i = 2.\n\nOutput\n\nPrint the resulting string.\n\nSample Input 1\n\na\n4\n2 1 p\n1\n2 2 c\n1\n\nSample Output 1\n\ncpa\n\nThere will be Q = 4 operations. Initially, S is a.\n\nOperation 1: Add p at the beginning of S. S becomes pa.\n\nOperation 2: Reverse S. S becomes ap.\n\nOperation 3: Add c at the end of S. S becomes apc.\n\nOperation 4: Reverse S. S becomes cpa.\n\nThus, the resulting string is cpa.\n\nSample Input 2\n\na\n6\n2 2 a\n2 1 b\n1\n2 2 c\n1\n1\n\nSample Output 2\n\naabc\n\nThere will be Q = 6 operations. Initially, S is a.\n\nOperation 1: S becomes aa.\n\nOperation 2: S becomes baa.\n\nOperation 3: S becomes aab.\n\nOperation 4: S becomes aabc.\n\nOperation 5: S becomes cbaa.\n\nOperation 6: S becomes aabc.\n\nThus, the resulting string is aabc.\n\nSample Input 3\n\ny\n1\n2 1 x\n\nSample Output 3\n\nxy", "sample_input": "a\n4\n2 1 p\n1\n2 2 c\n1\n"}, "reference_outputs": ["cpa\n"], "source_document_id": "p02756", "source_text": "Score : 400 points\n\nProblem Statement\n\nTakahashi has a string S consisting of lowercase English letters.\n\nStarting with this string, he will produce a new one in the procedure given as follows.\n\nThe procedure consists of Q operations. In Operation i (1 \\leq i \\leq Q), an integer T_i is provided, which means the following:\n\nIf T_i = 1: reverse the string S.\n\nIf T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided.\n\nIf F_i = 1 : Add C_i to the beginning of the string S.\n\nIf F_i = 2 : Add C_i to the end of the string S.\n\nHelp Takahashi by finding the final string that results from the procedure.\n\nConstraints\n\n1 \\leq |S| \\leq 10^5\n\nS consists of lowercase English letters.\n\n1 \\leq Q \\leq 2 \\times 10^5\n\nT_i = 1 or 2.\n\nF_i = 1 or 2, if provided.\n\nC_i is a lowercase English letter, if provided.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\nQ\nQuery_1\n:\nQuery_Q\n\nIn the 3-rd through the (Q+2)-th lines, Query_i is one of the following:\n\n1\n\nwhich means T_i = 1, and:\n\n2 F_i C_i\n\nwhich means T_i = 2.\n\nOutput\n\nPrint the resulting string.\n\nSample Input 1\n\na\n4\n2 1 p\n1\n2 2 c\n1\n\nSample Output 1\n\ncpa\n\nThere will be Q = 4 operations. Initially, S is a.\n\nOperation 1: Add p at the beginning of S. S becomes pa.\n\nOperation 2: Reverse S. S becomes ap.\n\nOperation 3: Add c at the end of S. S becomes apc.\n\nOperation 4: Reverse S. S becomes cpa.\n\nThus, the resulting string is cpa.\n\nSample Input 2\n\na\n6\n2 2 a\n2 1 b\n1\n2 2 c\n1\n1\n\nSample Output 2\n\naabc\n\nThere will be Q = 6 operations. Initially, S is a.\n\nOperation 1: S becomes aa.\n\nOperation 2: S becomes baa.\n\nOperation 3: S becomes aab.\n\nOperation 4: S becomes aabc.\n\nOperation 5: S becomes cbaa.\n\nOperation 6: S becomes aabc.\n\nThus, the resulting string is aabc.\n\nSample Input 3\n\ny\n1\n2 1 x\n\nSample Output 3\n\nxy", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 763, "cpu_time_ms": 148, "memory_kb": 5928}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s997695724", "group_id": "codeNet:p02758", "input_text": "local mfl, mce = math.floor, math.ceil\nlocal mmi, mma = math.min, math.max\nlocal bls, brs = bit.lshift, bit.rshift\nlocal SegTree = {}\nSegTree.updateAll = function(self)\n for i = self.stagenum - 1, 1, -1 do\n local cnt = bls(1, i - 1)\n for j = 1, cnt do\n self.stage[i][j] = self.func(self.stage[i + 1][j * 2 - 1], self.stage[i + 1][j * 2])\n end\n end\nend\nSegTree.create = function(self, n, func, emptyvalue)\n self.func, self.emptyvalue = func, emptyvalue\n local stagenum, mul = 1, 1\n self.stage = {{}}\n while mul < n do\n mul, stagenum = mul * 2, stagenum + 1\n self.stage[stagenum] = {}\n end\n self.stagenum = stagenum\n for i = 1, mul do self.stage[stagenum][i] = emptyvalue end\n self:updateAll()\nend\nSegTree.getRange = function(self, left, right)\n if left == right then return self.stage[self.stagenum][left] end\n local stagenum = self.stagenum\n local ret = self.emptyvalue\n while left <= right do\n local stage, sz = 1, bls(1, stagenum - 1)\n local len = right - left + 1\n while (left - 1) % sz ~= 0 or len < sz do\n stage, sz = stage + 1, brs(sz, 1)\n end\n ret = self.func(ret, self.stage[stage][1 + brs(left - 1, stagenum - stage)])\n left = left + sz\n end\n return ret\nend\nSegTree.setValue = function(self, idx, value, silent)\n self.stage[self.stagenum][idx] = value\n if not silent then\n for i = self.stagenum - 1, 1, -1 do\n local dst = brs(idx + 1, 1)\n local rem = dst * 4 - 1 - idx\n self.stage[i][dst] = self.func(self.stage[i + 1][idx], self.stage[i + 1][rem])\n idx = dst\n end\n end\nend\nSegTree.new = function(n, func, emptyvalue)\n local obj = {}\n setmetatable(obj, {__index = SegTree})\n obj:create(n, func, emptyvalue)\n return obj\nend\n\nlocal function comp(a, b)\n return a[1] < b\nend\n\nlocal function lower_bound(ary, x)\n local num = #ary\n if num == 0 then return 1 end\n if not comp(ary[1], x) then return 1 end\n if comp(ary[num], x) then return num + 1 end\n local min, max = 1, num\n while 1 < max - min do\n local mid = mfl((min + max) / 2)\n if comp(ary[mid], x) then\n min = mid\n else\n max = mid\n end\n end\n return max\nend\n\nlocal mod = 998244353\nlocal function badd(x, y) return (x + y) % mod end\n\nlocal n = io.read(\"*n\")\nlocal t = {}\nfor i = 1, n do\n t[i] = {}\n t[i][1], t[i][2] = io.read(\"*n\", \"*n\")\nend\ntable.sort(t, function(a, b) return a[1] < b[1] end)\nt[n + 1] = {3 * 1000000007, 0}\n\nlocal stReach = SegTree.new(n + 1, mma, 0)\nfor i = 1, n + 1 do\n stReach:setValue(i, i)\nend\n\nlocal dp = {}\nfor i = 1, n + 1 do\n dp[i] = 0\nend\ndp[n + 1] = 1\nfor i = n, 1, -1 do\n local dstLen = lower_bound(t, t[i][1] + t[i][2])\n local dstPos = stReach:getRange(i, dstLen - 1)\n stReach:setValue(i, dstPos)\n dp[i] = badd(dp[dstPos + 1], dp[i + 1])\nend\nprint(dp[1])\n", "language": "Lua", "metadata": {"date": 1583762078, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p02758.html", "problem_id": "p02758", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02758/input.txt", "sample_output_relpath": "derived/input_output/data/p02758/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02758/Lua/s997695724.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s997695724", "user_id": "u120582723"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "local mfl, mce = math.floor, math.ceil\nlocal mmi, mma = math.min, math.max\nlocal bls, brs = bit.lshift, bit.rshift\nlocal SegTree = {}\nSegTree.updateAll = function(self)\n for i = self.stagenum - 1, 1, -1 do\n local cnt = bls(1, i - 1)\n for j = 1, cnt do\n self.stage[i][j] = self.func(self.stage[i + 1][j * 2 - 1], self.stage[i + 1][j * 2])\n end\n end\nend\nSegTree.create = function(self, n, func, emptyvalue)\n self.func, self.emptyvalue = func, emptyvalue\n local stagenum, mul = 1, 1\n self.stage = {{}}\n while mul < n do\n mul, stagenum = mul * 2, stagenum + 1\n self.stage[stagenum] = {}\n end\n self.stagenum = stagenum\n for i = 1, mul do self.stage[stagenum][i] = emptyvalue end\n self:updateAll()\nend\nSegTree.getRange = function(self, left, right)\n if left == right then return self.stage[self.stagenum][left] end\n local stagenum = self.stagenum\n local ret = self.emptyvalue\n while left <= right do\n local stage, sz = 1, bls(1, stagenum - 1)\n local len = right - left + 1\n while (left - 1) % sz ~= 0 or len < sz do\n stage, sz = stage + 1, brs(sz, 1)\n end\n ret = self.func(ret, self.stage[stage][1 + brs(left - 1, stagenum - stage)])\n left = left + sz\n end\n return ret\nend\nSegTree.setValue = function(self, idx, value, silent)\n self.stage[self.stagenum][idx] = value\n if not silent then\n for i = self.stagenum - 1, 1, -1 do\n local dst = brs(idx + 1, 1)\n local rem = dst * 4 - 1 - idx\n self.stage[i][dst] = self.func(self.stage[i + 1][idx], self.stage[i + 1][rem])\n idx = dst\n end\n end\nend\nSegTree.new = function(n, func, emptyvalue)\n local obj = {}\n setmetatable(obj, {__index = SegTree})\n obj:create(n, func, emptyvalue)\n return obj\nend\n\nlocal function comp(a, b)\n return a[1] < b\nend\n\nlocal function lower_bound(ary, x)\n local num = #ary\n if num == 0 then return 1 end\n if not comp(ary[1], x) then return 1 end\n if comp(ary[num], x) then return num + 1 end\n local min, max = 1, num\n while 1 < max - min do\n local mid = mfl((min + max) / 2)\n if comp(ary[mid], x) then\n min = mid\n else\n max = mid\n end\n end\n return max\nend\n\nlocal mod = 998244353\nlocal function badd(x, y) return (x + y) % mod end\n\nlocal n = io.read(\"*n\")\nlocal t = {}\nfor i = 1, n do\n t[i] = {}\n t[i][1], t[i][2] = io.read(\"*n\", \"*n\")\nend\ntable.sort(t, function(a, b) return a[1] < b[1] end)\nt[n + 1] = {3 * 1000000007, 0}\n\nlocal stReach = SegTree.new(n + 1, mma, 0)\nfor i = 1, n + 1 do\n stReach:setValue(i, i)\nend\n\nlocal dp = {}\nfor i = 1, n + 1 do\n dp[i] = 0\nend\ndp[n + 1] = 1\nfor i = n, 1, -1 do\n local dstLen = lower_bound(t, t[i][1] + t[i][2])\n local dstPos = stReach:getRange(i, dstLen - 1)\n stReach:setValue(i, dstPos)\n dp[i] = badd(dp[dstPos + 1], dp[i + 1])\nend\nprint(dp[1])\n", "problem_context": "Score : 600 points\n\nProblem Statement\n\nThere are N robots numbered 1 to N placed on a number line. Robot i is placed at coordinate X_i. When activated, it will travel the distance of D_i in the positive direction, and then it will be removed from the number line. All the robots move at the same speed, and their sizes are ignorable.\n\nTakahashi, who is a mischievous boy, can do the following operation any number of times (possibly zero) as long as there is a robot remaining on the number line.\n\nChoose a robot and activate it. This operation cannot be done when there is a robot moving.\n\nWhile Robot i is moving, if it touches another robot j that is remaining in the range [X_i, X_i + D_i) on the number line, Robot j also gets activated and starts moving. This process is repeated recursively.\n\nHow many possible sets of robots remaining on the number line are there after Takahashi does the operation some number of times? Compute this count modulo 998244353, since it can be enormous.\n\nConstraints\n\n1 \\leq N \\leq 2 \\times 10^5\n\n-10^9 \\leq X_i \\leq 10^9\n\n1 \\leq D_i \\leq 10^9\n\nX_i \\neq X_j (i \\neq j)\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nX_1 D_1\n:\nX_N D_N\n\nOutput\n\nPrint the number of possible sets of robots remaining on the number line, modulo 998244353.\n\nSample Input 1\n\n2\n1 5\n3 3\n\nSample Output 1\n\n3\n\nThere are three possible sets of robots remaining on the number line: \\{1, 2\\}, \\{1\\}, and \\{\\}.\n\nThese can be achieved as follows:\n\nIf Takahashi activates nothing, the robots \\{1, 2\\} will remain.\n\nIf Takahashi activates Robot 1, it will activate Robot 2 while moving, after which there will be no robots on the number line. This state can also be reached by activating Robot 2 and then Robot 1.\n\nIf Takahashi activates Robot 2 and finishes doing the operation, the robot \\{1\\} will remain.\n\nSample Input 2\n\n3\n6 5\n-1 10\n3 3\n\nSample Output 2\n\n5\n\nThere are five possible sets of robots remaining on the number line: \\{1, 2, 3\\}, \\{1, 2\\}, \\{2\\}, \\{2, 3\\}, and \\{\\}.\n\nSample Input 3\n\n4\n7 10\n-10 3\n4 3\n-4 3\n\nSample Output 3\n\n16\n\nNone of the robots influences others.\n\nSample Input 4\n\n20\n-8 1\n26 4\n0 5\n9 1\n19 4\n22 20\n28 27\n11 8\n-3 20\n-25 17\n10 4\n-18 27\n24 28\n-11 19\n2 27\n-2 18\n-1 12\n-24 29\n31 29\n29 7\n\nSample Output 4\n\n110\n\nRemember to print the count modulo 998244353.", "sample_input": "2\n1 5\n3 3\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02758", "source_text": "Score : 600 points\n\nProblem Statement\n\nThere are N robots numbered 1 to N placed on a number line. Robot i is placed at coordinate X_i. When activated, it will travel the distance of D_i in the positive direction, and then it will be removed from the number line. All the robots move at the same speed, and their sizes are ignorable.\n\nTakahashi, who is a mischievous boy, can do the following operation any number of times (possibly zero) as long as there is a robot remaining on the number line.\n\nChoose a robot and activate it. This operation cannot be done when there is a robot moving.\n\nWhile Robot i is moving, if it touches another robot j that is remaining in the range [X_i, X_i + D_i) on the number line, Robot j also gets activated and starts moving. This process is repeated recursively.\n\nHow many possible sets of robots remaining on the number line are there after Takahashi does the operation some number of times? Compute this count modulo 998244353, since it can be enormous.\n\nConstraints\n\n1 \\leq N \\leq 2 \\times 10^5\n\n-10^9 \\leq X_i \\leq 10^9\n\n1 \\leq D_i \\leq 10^9\n\nX_i \\neq X_j (i \\neq j)\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nX_1 D_1\n:\nX_N D_N\n\nOutput\n\nPrint the number of possible sets of robots remaining on the number line, modulo 998244353.\n\nSample Input 1\n\n2\n1 5\n3 3\n\nSample Output 1\n\n3\n\nThere are three possible sets of robots remaining on the number line: \\{1, 2\\}, \\{1\\}, and \\{\\}.\n\nThese can be achieved as follows:\n\nIf Takahashi activates nothing, the robots \\{1, 2\\} will remain.\n\nIf Takahashi activates Robot 1, it will activate Robot 2 while moving, after which there will be no robots on the number line. This state can also be reached by activating Robot 2 and then Robot 1.\n\nIf Takahashi activates Robot 2 and finishes doing the operation, the robot \\{1\\} will remain.\n\nSample Input 2\n\n3\n6 5\n-1 10\n3 3\n\nSample Output 2\n\n5\n\nThere are five possible sets of robots remaining on the number line: \\{1, 2, 3\\}, \\{1, 2\\}, \\{2\\}, \\{2, 3\\}, and \\{\\}.\n\nSample Input 3\n\n4\n7 10\n-10 3\n4 3\n-4 3\n\nSample Output 3\n\n16\n\nNone of the robots influences others.\n\nSample Input 4\n\n20\n-8 1\n26 4\n0 5\n9 1\n19 4\n22 20\n28 27\n11 8\n-3 20\n-25 17\n10 4\n-18 27\n24 28\n-11 19\n2 27\n-2 18\n-1 12\n-24 29\n31 29\n29 7\n\nSample Output 4\n\n110\n\nRemember to print the count modulo 998244353.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2776, "cpu_time_ms": 720, "memory_kb": 22632}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s411930023", "group_id": "codeNet:p02759", "input_text": "a = io.read(\"*n\")\nprint(math.ceil(a / 2))", "language": "Lua", "metadata": {"date": 1589908352, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p02759.html", "problem_id": "p02759", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02759/input.txt", "sample_output_relpath": "derived/input_output/data/p02759/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02759/Lua/s411930023.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s411930023", "user_id": "u120582723"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "a = io.read(\"*n\")\nprint(math.ceil(a / 2))", "problem_context": "Score : 100 points\n\nProblem Statement\n\nTakahashi wants to print a document with N pages double-sided, where two pages of data can be printed on one sheet of paper.\n\nAt least how many sheets of paper does he need?\n\nConstraints\n\nN is an integer.\n\n1 \\leq N \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n5\n\nSample Output 1\n\n3\n\nBy printing the 1-st, 2-nd pages on the 1-st sheet, 3-rd and 4-th pages on the 2-nd sheet, and 5-th page on the 3-rd sheet, we can print all the data on 3 sheets of paper.\n\nSample Input 2\n\n2\n\nSample Output 2\n\n1\n\nSample Input 3\n\n100\n\nSample Output 3\n\n50", "sample_input": "5\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02759", "source_text": "Score : 100 points\n\nProblem Statement\n\nTakahashi wants to print a document with N pages double-sided, where two pages of data can be printed on one sheet of paper.\n\nAt least how many sheets of paper does he need?\n\nConstraints\n\nN is an integer.\n\n1 \\leq N \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n5\n\nSample Output 1\n\n3\n\nBy printing the 1-st, 2-nd pages on the 1-st sheet, 3-rd and 4-th pages on the 2-nd sheet, and 5-th page on the 3-rd sheet, we can print all the data on 3 sheets of paper.\n\nSample Input 2\n\n2\n\nSample Output 2\n\n1\n\nSample Input 3\n\n100\n\nSample Output 3\n\n50", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 41, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s466037253", "group_id": "codeNet:p02760", "input_text": "A={}\nR={}\nfor i=1,9 do\n A[io.read\"*n\"]=i\nend\nN=io.read\"*n\"\nfunction bingo(t)\n for i=1,3 do\n if(t[i]and t[i+3]and t[i+6])then return true end\n end\n for i=1,3 do\n if(t[i*3-2]and t[i*3-1]and t[i*3])then return true end\n end\n return (t[1]and t[5]and t[9]or t[3]and t[5]and t[7])and true or false\nend\nfor i=1,N do\n local k=A[io.read\"*n\"]\n if(k)then R[k]=0 end\nend\nprint(bingo(R)and\"Yes\"or\"No\")", "language": "Lua", "metadata": {"date": 1587244008, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p02760.html", "problem_id": "p02760", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02760/input.txt", "sample_output_relpath": "derived/input_output/data/p02760/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02760/Lua/s466037253.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s466037253", "user_id": "u726173718"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "A={}\nR={}\nfor i=1,9 do\n A[io.read\"*n\"]=i\nend\nN=io.read\"*n\"\nfunction bingo(t)\n for i=1,3 do\n if(t[i]and t[i+3]and t[i+6])then return true end\n end\n for i=1,3 do\n if(t[i*3-2]and t[i*3-1]and t[i*3])then return true end\n end\n return (t[1]and t[5]and t[9]or t[3]and t[5]and t[7])and true or false\nend\nfor i=1,N do\n local k=A[io.read\"*n\"]\n if(k)then R[k]=0 end\nend\nprint(bingo(R)and\"Yes\"or\"No\")", "problem_context": "Score : 200 points\n\nProblem Statement\n\nWe have a bingo card with a 3\\times3 grid. The square at the i-th row from the top and the j-th column from the left contains the number A_{i, j}.\n\nThe MC will choose N numbers, b_1, b_2, \\cdots, b_N. If our bingo sheet contains some of those numbers, we will mark them on our sheet.\n\nDetermine whether we will have a bingo when the N numbers are chosen, that is, the sheet will contain three marked numbers in a row, column, or diagonal.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq A_{i, j} \\leq 100\n\nA_{i_1, j_1} \\neq A_{i_2, j_2} ((i_1, j_1) \\neq (i_2, j_2))\n\n1 \\leq N \\leq 10\n\n1 \\leq b_i \\leq 100\n\nb_i \\neq b_j (i \\neq j)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA_{1, 1} A_{1, 2} A_{1, 3}\nA_{2, 1} A_{2, 2} A_{2, 3}\nA_{3, 1} A_{3, 2} A_{3, 3}\nN\nb_1\n\\vdots\nb_N\n\nOutput\n\nIf we will have a bingo, print Yes; otherwise, print No.\n\nSample Input 1\n\n84 97 66\n79 89 11\n61 59 7\n7\n89\n7\n87\n79\n24\n84\n30\n\nSample Output 1\n\nYes\n\nWe will mark A_{1, 1}, A_{2, 1}, A_{2, 2}, A_{3, 3}, and complete the diagonal from the top-left to the bottom-right.\n\nSample Input 2\n\n41 7 46\n26 89 2\n78 92 8\n5\n6\n45\n16\n57\n17\n\nSample Output 2\n\nNo\n\nWe will mark nothing.\n\nSample Input 3\n\n60 88 34\n92 41 43\n65 73 48\n10\n60\n43\n88\n11\n48\n73\n65\n41\n92\n34\n\nSample Output 3\n\nYes\n\nWe will mark all the squares.", "sample_input": "84 97 66\n79 89 11\n61 59 7\n7\n89\n7\n87\n79\n24\n84\n30\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p02760", "source_text": "Score : 200 points\n\nProblem Statement\n\nWe have a bingo card with a 3\\times3 grid. The square at the i-th row from the top and the j-th column from the left contains the number A_{i, j}.\n\nThe MC will choose N numbers, b_1, b_2, \\cdots, b_N. If our bingo sheet contains some of those numbers, we will mark them on our sheet.\n\nDetermine whether we will have a bingo when the N numbers are chosen, that is, the sheet will contain three marked numbers in a row, column, or diagonal.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq A_{i, j} \\leq 100\n\nA_{i_1, j_1} \\neq A_{i_2, j_2} ((i_1, j_1) \\neq (i_2, j_2))\n\n1 \\leq N \\leq 10\n\n1 \\leq b_i \\leq 100\n\nb_i \\neq b_j (i \\neq j)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA_{1, 1} A_{1, 2} A_{1, 3}\nA_{2, 1} A_{2, 2} A_{2, 3}\nA_{3, 1} A_{3, 2} A_{3, 3}\nN\nb_1\n\\vdots\nb_N\n\nOutput\n\nIf we will have a bingo, print Yes; otherwise, print No.\n\nSample Input 1\n\n84 97 66\n79 89 11\n61 59 7\n7\n89\n7\n87\n79\n24\n84\n30\n\nSample Output 1\n\nYes\n\nWe will mark A_{1, 1}, A_{2, 1}, A_{2, 2}, A_{3, 3}, and complete the diagonal from the top-left to the bottom-right.\n\nSample Input 2\n\n41 7 46\n26 89 2\n78 92 8\n5\n6\n45\n16\n57\n17\n\nSample Output 2\n\nNo\n\nWe will mark nothing.\n\nSample Input 3\n\n60 88 34\n92 41 43\n65 73 48\n10\n60\n43\n88\n11\n48\n73\n65\n41\n92\n34\n\nSample Output 3\n\nYes\n\nWe will mark all the squares.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 402, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s177637428", "group_id": "codeNet:p02760", "input_text": "local a = {}\nlocal c = {}\nfor i = 1, 9 do\n a[i] = io.read(\"*n\")\n c[i] = false\nend\nlocal n = io.read(\"*n\")\nfor i = 1, n do\n local b = io.read(\"*n\")\n for j = 1, 9 do\n if a[j] == b then\n c[j] = true\n end\n end\nend\nlocal f = false\nif c[1] and c[4] and c[7] then f = true end\nif c[2] and c[5] and c[8] then f = true end\nif c[3] and c[6] and c[9] then f = true end\nif c[1] and c[2] and c[3] then f = true end\nif c[4] and c[5] and c[6] then f = true end\nif c[7] and c[8] and c[9] then f = true end\nif c[1] and c[5] and c[9] then f = true end\nif c[3] and c[5] and c[7] then f = true end\nprint(f and \"Yes\" or \"No\")\n", "language": "Lua", "metadata": {"date": 1583114583, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p02760.html", "problem_id": "p02760", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02760/input.txt", "sample_output_relpath": "derived/input_output/data/p02760/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02760/Lua/s177637428.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s177637428", "user_id": "u120582723"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "local a = {}\nlocal c = {}\nfor i = 1, 9 do\n a[i] = io.read(\"*n\")\n c[i] = false\nend\nlocal n = io.read(\"*n\")\nfor i = 1, n do\n local b = io.read(\"*n\")\n for j = 1, 9 do\n if a[j] == b then\n c[j] = true\n end\n end\nend\nlocal f = false\nif c[1] and c[4] and c[7] then f = true end\nif c[2] and c[5] and c[8] then f = true end\nif c[3] and c[6] and c[9] then f = true end\nif c[1] and c[2] and c[3] then f = true end\nif c[4] and c[5] and c[6] then f = true end\nif c[7] and c[8] and c[9] then f = true end\nif c[1] and c[5] and c[9] then f = true end\nif c[3] and c[5] and c[7] then f = true end\nprint(f and \"Yes\" or \"No\")\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nWe have a bingo card with a 3\\times3 grid. The square at the i-th row from the top and the j-th column from the left contains the number A_{i, j}.\n\nThe MC will choose N numbers, b_1, b_2, \\cdots, b_N. If our bingo sheet contains some of those numbers, we will mark them on our sheet.\n\nDetermine whether we will have a bingo when the N numbers are chosen, that is, the sheet will contain three marked numbers in a row, column, or diagonal.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq A_{i, j} \\leq 100\n\nA_{i_1, j_1} \\neq A_{i_2, j_2} ((i_1, j_1) \\neq (i_2, j_2))\n\n1 \\leq N \\leq 10\n\n1 \\leq b_i \\leq 100\n\nb_i \\neq b_j (i \\neq j)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA_{1, 1} A_{1, 2} A_{1, 3}\nA_{2, 1} A_{2, 2} A_{2, 3}\nA_{3, 1} A_{3, 2} A_{3, 3}\nN\nb_1\n\\vdots\nb_N\n\nOutput\n\nIf we will have a bingo, print Yes; otherwise, print No.\n\nSample Input 1\n\n84 97 66\n79 89 11\n61 59 7\n7\n89\n7\n87\n79\n24\n84\n30\n\nSample Output 1\n\nYes\n\nWe will mark A_{1, 1}, A_{2, 1}, A_{2, 2}, A_{3, 3}, and complete the diagonal from the top-left to the bottom-right.\n\nSample Input 2\n\n41 7 46\n26 89 2\n78 92 8\n5\n6\n45\n16\n57\n17\n\nSample Output 2\n\nNo\n\nWe will mark nothing.\n\nSample Input 3\n\n60 88 34\n92 41 43\n65 73 48\n10\n60\n43\n88\n11\n48\n73\n65\n41\n92\n34\n\nSample Output 3\n\nYes\n\nWe will mark all the squares.", "sample_input": "84 97 66\n79 89 11\n61 59 7\n7\n89\n7\n87\n79\n24\n84\n30\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p02760", "source_text": "Score : 200 points\n\nProblem Statement\n\nWe have a bingo card with a 3\\times3 grid. The square at the i-th row from the top and the j-th column from the left contains the number A_{i, j}.\n\nThe MC will choose N numbers, b_1, b_2, \\cdots, b_N. If our bingo sheet contains some of those numbers, we will mark them on our sheet.\n\nDetermine whether we will have a bingo when the N numbers are chosen, that is, the sheet will contain three marked numbers in a row, column, or diagonal.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq A_{i, j} \\leq 100\n\nA_{i_1, j_1} \\neq A_{i_2, j_2} ((i_1, j_1) \\neq (i_2, j_2))\n\n1 \\leq N \\leq 10\n\n1 \\leq b_i \\leq 100\n\nb_i \\neq b_j (i \\neq j)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA_{1, 1} A_{1, 2} A_{1, 3}\nA_{2, 1} A_{2, 2} A_{2, 3}\nA_{3, 1} A_{3, 2} A_{3, 3}\nN\nb_1\n\\vdots\nb_N\n\nOutput\n\nIf we will have a bingo, print Yes; otherwise, print No.\n\nSample Input 1\n\n84 97 66\n79 89 11\n61 59 7\n7\n89\n7\n87\n79\n24\n84\n30\n\nSample Output 1\n\nYes\n\nWe will mark A_{1, 1}, A_{2, 1}, A_{2, 2}, A_{3, 3}, and complete the diagonal from the top-left to the bottom-right.\n\nSample Input 2\n\n41 7 46\n26 89 2\n78 92 8\n5\n6\n45\n16\n57\n17\n\nSample Output 2\n\nNo\n\nWe will mark nothing.\n\nSample Input 3\n\n60 88 34\n92 41 43\n65 73 48\n10\n60\n43\n88\n11\n48\n73\n65\n41\n92\n34\n\nSample Output 3\n\nYes\n\nWe will mark all the squares.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 621, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s967827404", "group_id": "codeNet:p02762", "input_text": "local par={}\nlocal rank={}\n\nlocal function init(n)\n for i=1,n do\n par[i]=i\n rank[i]=1\n end\nend\n\nlocal function root(x)\n return par[x]==x and x or root(par[x])\nend\n\nlocal function same(x,y)\n return root(x)==root(y)\nend\n\nlocal function unite(x,y)\n x=root(x)\n y=root(y)\n if x==y then\n return\n end\n if rank[x]>rank[y] then\n x,y=y,x\n end\n par[x]=y\n rank[y]=rank[y]+rank[x]\nend\n\nlocal function size(x)\n return rank[root(x)]\nend\n\nlocal n,m,k=io.read(\"n\",\"n\",\"n\")\n\ninit(n)\n\nlocal graph={}\nfor i=1,n do\n graph[i]={}\nend\nfor i=1,m do\n local a,b=io.read(\"n\",\"n\")\n table.insert(graph[a],b)\n table.insert(graph[b],a)\n unite(a,b)\nend\nfor i=1,k do\n local c,d=io.read(\"n\",\"n\")\n if same(c,d) then\n table.insert(graph[c],d)\n table.insert(graph[d],c)\n end\nend\n\nfor i=1,n do\n local kouho=size(i)-#graph[i]-1\n io.write(kouho..\" \")\nend\nprint()", "language": "Lua", "metadata": {"date": 1598077784, "filename_ext": "lua", "original_language": "Lua (LuaJIT 2.1.0)", "problem_description_relpath": "problem_descriptions/p02762.html", "problem_id": "p02762", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02762/input.txt", "sample_output_relpath": "derived/input_output/data/p02762/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02762/Lua/s967827404.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s967827404", "user_id": "u045238009"}, "prompt_components": {"gold_output": "0 1 0 1\n", "input_to_evaluate": "local par={}\nlocal rank={}\n\nlocal function init(n)\n for i=1,n do\n par[i]=i\n rank[i]=1\n end\nend\n\nlocal function root(x)\n return par[x]==x and x or root(par[x])\nend\n\nlocal function same(x,y)\n return root(x)==root(y)\nend\n\nlocal function unite(x,y)\n x=root(x)\n y=root(y)\n if x==y then\n return\n end\n if rank[x]>rank[y] then\n x,y=y,x\n end\n par[x]=y\n rank[y]=rank[y]+rank[x]\nend\n\nlocal function size(x)\n return rank[root(x)]\nend\n\nlocal n,m,k=io.read(\"n\",\"n\",\"n\")\n\ninit(n)\n\nlocal graph={}\nfor i=1,n do\n graph[i]={}\nend\nfor i=1,m do\n local a,b=io.read(\"n\",\"n\")\n table.insert(graph[a],b)\n table.insert(graph[b],a)\n unite(a,b)\nend\nfor i=1,k do\n local c,d=io.read(\"n\",\"n\")\n if same(c,d) then\n table.insert(graph[c],d)\n table.insert(graph[d],c)\n end\nend\n\nfor i=1,n do\n local kouho=size(i)-#graph[i]-1\n io.write(kouho..\" \")\nend\nprint()", "problem_context": "Score : 400 points\n\nProblem Statement\n\nAn SNS has N users - User 1, User 2, \\cdots, User N.\n\nBetween these N users, there are some relationships - M friendships and K blockships.\n\nFor each i = 1, 2, \\cdots, M, there is a bidirectional friendship between User A_i and User B_i.\n\nFor each i = 1, 2, \\cdots, K, there is a bidirectional blockship between User C_i and User D_i.\n\nWe define User a to be a friend candidate for User b when all of the following four conditions are satisfied:\n\na \\neq b.\n\nThere is not a friendship between User a and User b.\n\nThere is not a blockship between User a and User b.\n\nThere exists a sequence c_0, c_1, c_2, \\cdots, c_L consisting of integers between 1 and N (inclusive) such that c_0 = a, c_L = b, and there is a friendship between User c_i and c_{i+1} for each i = 0, 1, \\cdots, L - 1.\n\nFor each user i = 1, 2, ... N, how many friend candidates does it have?\n\nConstraints\n\nAll values in input are integers.\n\n2 ≤ N ≤ 10^5\n\n0 \\leq M \\leq 10^5\n\n0 \\leq K \\leq 10^5\n\n1 \\leq A_i, B_i \\leq N\n\nA_i \\neq B_i\n\n1 \\leq C_i, D_i \\leq N\n\nC_i \\neq D_i\n\n(A_i, B_i) \\neq (A_j, B_j) (i \\neq j)\n\n(A_i, B_i) \\neq (B_j, A_j)\n\n(C_i, D_i) \\neq (C_j, D_j) (i \\neq j)\n\n(C_i, D_i) \\neq (D_j, C_j)\n\n(A_i, B_i) \\neq (C_j, D_j)\n\n(A_i, B_i) \\neq (D_j, C_j)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M K\nA_1 B_1\n\\vdots\nA_M B_M\nC_1 D_1\n\\vdots\nC_K D_K\n\nOutput\n\nPrint the answers in order, with space in between.\n\nSample Input 1\n\n4 4 1\n2 1\n1 3\n3 2\n3 4\n4 1\n\nSample Output 1\n\n0 1 0 1\n\nThere is a friendship between User 2 and 3, and between 3 and 4. Also, there is no friendship or blockship between User 2 and 4. Thus, User 4 is a friend candidate for User 2.\n\nHowever, neither User 1 or 3 is a friend candidate for User 2, so User 2 has one friend candidate.\n\nSample Input 2\n\n5 10 0\n1 2\n1 3\n1 4\n1 5\n3 2\n2 4\n2 5\n4 3\n5 3\n4 5\n\nSample Output 2\n\n0 0 0 0 0\n\nEveryone is a friend of everyone else and has no friend candidate.\n\nSample Input 3\n\n10 9 3\n10 1\n6 7\n8 2\n2 5\n8 4\n7 3\n10 9\n6 4\n5 8\n2 6\n7 5\n3 1\n\nSample Output 3\n\n1 3 5 4 3 3 3 3 1 0", "sample_input": "4 4 1\n2 1\n1 3\n3 2\n3 4\n4 1\n"}, "reference_outputs": ["0 1 0 1\n"], "source_document_id": "p02762", "source_text": "Score : 400 points\n\nProblem Statement\n\nAn SNS has N users - User 1, User 2, \\cdots, User N.\n\nBetween these N users, there are some relationships - M friendships and K blockships.\n\nFor each i = 1, 2, \\cdots, M, there is a bidirectional friendship between User A_i and User B_i.\n\nFor each i = 1, 2, \\cdots, K, there is a bidirectional blockship between User C_i and User D_i.\n\nWe define User a to be a friend candidate for User b when all of the following four conditions are satisfied:\n\na \\neq b.\n\nThere is not a friendship between User a and User b.\n\nThere is not a blockship between User a and User b.\n\nThere exists a sequence c_0, c_1, c_2, \\cdots, c_L consisting of integers between 1 and N (inclusive) such that c_0 = a, c_L = b, and there is a friendship between User c_i and c_{i+1} for each i = 0, 1, \\cdots, L - 1.\n\nFor each user i = 1, 2, ... N, how many friend candidates does it have?\n\nConstraints\n\nAll values in input are integers.\n\n2 ≤ N ≤ 10^5\n\n0 \\leq M \\leq 10^5\n\n0 \\leq K \\leq 10^5\n\n1 \\leq A_i, B_i \\leq N\n\nA_i \\neq B_i\n\n1 \\leq C_i, D_i \\leq N\n\nC_i \\neq D_i\n\n(A_i, B_i) \\neq (A_j, B_j) (i \\neq j)\n\n(A_i, B_i) \\neq (B_j, A_j)\n\n(C_i, D_i) \\neq (C_j, D_j) (i \\neq j)\n\n(C_i, D_i) \\neq (D_j, C_j)\n\n(A_i, B_i) \\neq (C_j, D_j)\n\n(A_i, B_i) \\neq (D_j, C_j)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M K\nA_1 B_1\n\\vdots\nA_M B_M\nC_1 D_1\n\\vdots\nC_K D_K\n\nOutput\n\nPrint the answers in order, with space in between.\n\nSample Input 1\n\n4 4 1\n2 1\n1 3\n3 2\n3 4\n4 1\n\nSample Output 1\n\n0 1 0 1\n\nThere is a friendship between User 2 and 3, and between 3 and 4. Also, there is no friendship or blockship between User 2 and 4. Thus, User 4 is a friend candidate for User 2.\n\nHowever, neither User 1 or 3 is a friend candidate for User 2, so User 2 has one friend candidate.\n\nSample Input 2\n\n5 10 0\n1 2\n1 3\n1 4\n1 5\n3 2\n2 4\n2 5\n4 3\n5 3\n4 5\n\nSample Output 2\n\n0 0 0 0 0\n\nEveryone is a friend of everyone else and has no friend candidate.\n\nSample Input 3\n\n10 9 3\n10 1\n6 7\n8 2\n2 5\n8 4\n7 3\n10 9\n6 4\n5 8\n2 6\n7 5\n3 1\n\nSample Output 3\n\n1 3 5 4 3 3 3 3 1 0", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 932, "cpu_time_ms": 180, "memory_kb": 15976}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s164097008", "group_id": "codeNet:p02763", "input_text": "local mfl, mce, mmi = math.floor, math.ceil, math.min\nlocal bls, brs = bit.lshift, bit.rshift\nlocal SegTree = {}\nSegTree.updateAll = function(self)\n for i = self.stagenum - 1, 1, -1 do\n for j = 1, self.cnt[i] do\n self.stage[i][j] = false\n end\n end\nend\nSegTree.create = function(self, n)\n local stagenum, mul = 1, 1\n self.cnt, self.stage = {1}, {{}}\n while mul < n do\n mul, stagenum = mul * 2, stagenum + 1\n self.cnt[stagenum], self.stage[stagenum] = mul, {}\n end\n self.stagenum = stagenum\n for i = 1, mul do self.stage[stagenum][i] = false end\n self:updateAll()\nend\nSegTree.getRange = function(self, left, right)\n if left == right then return self.stage[self.stagenum][left] end\n local start_stage = 1\n local stagenum = self.stagenum\n while right - left + 1 < bls(1, stagenum - start_stage) do\n start_stage = start_stage + 1\n end\n local ret = false\n local t1, t2, t3 = {start_stage}, {left}, {right}\n while 0 < #t1 do\n local stage, l, r = t1[#t1], t2[#t1], t3[#t1]\n table.remove(t1) table.remove(t2) table.remove(t3)\n local sz = bls(1, stagenum - stage)\n if (l - 1) % sz ~= 0 then\n local newr = mmi(r, mce((l - 1) / sz) * sz)\n table.insert(t1, stage + 1) table.insert(t2, l) table.insert(t3, newr)\n l = newr + 1\n end\n if sz <= r + 1 - l then\n ret = ret or self.stage[stage][mce(l / sz)]\n l = l + sz\n end\n if l <= r then\n table.insert(t1, stage + 1) table.insert(t2, l) table.insert(t3, r)\n end\n if ret then break end\n end\n return ret\nend\nSegTree.setValue = function(self, idx, value)\n self.stage[self.stagenum][idx] = value\n for i = self.stagenum - 1, 1, -1 do\n local dst = brs(idx + 1, 1)\n local rem = dst * 4 - 1 - idx\n self.stage[i][dst] = self.stage[i + 1][idx] or self.stage[i + 1][rem]\n idx = dst\n end\nend\nSegTree.new = function(n, func, emptyvalue)\n local obj = {}\n setmetatable(obj, {__index = SegTree})\n obj:create(n, func, emptyvalue)\n return obj\nend\n\nlocal n = io.read(\"*n\", \"*l\")\nlocal s = io.read()\nlocal q = io.read(\"*n\", \"*l\")\nlocal sts = {}\nlocal t = {}\nfor i = 1, 26 do\n sts[i] = SegTree.new(n, function(a, b) return a or b end, false)\nend\nfor i = 1, n do\n t[i] = s:sub(i, i):byte() - 96\n sts[t[i]]:setValue(i, true)\nend\n\nfor iq = 1, q do\n local iqstr = io.read()\n local ic = iqstr:sub(1, 1)\n if ic == \"1\" then\n local i, cs = iqstr:match(\"%d (%d+) (%w)\")\n i = tonumber(i)\n local c = cs:byte() - 96\n if t[i] ~= c then\n sts[t[i]]:setValue(i, false)\n t[i] = c\n sts[c]:setValue(i, true)\n end\n else\n local l, r = iqstr:match(\"%d (%d+) (%d+)\")\n l, r = tonumber(l), tonumber(r)\n local cnt = 0\n for i = 1, 26 do\n if sts[i]:getRange(l, r) then cnt = cnt + 1 end\n end\n print(cnt)\n end\nend\n", "language": "Lua", "metadata": {"date": 1583210206, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p02763.html", "problem_id": "p02763", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02763/input.txt", "sample_output_relpath": "derived/input_output/data/p02763/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02763/Lua/s164097008.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s164097008", "user_id": "u120582723"}, "prompt_components": {"gold_output": "3\n1\n5\n", "input_to_evaluate": "local mfl, mce, mmi = math.floor, math.ceil, math.min\nlocal bls, brs = bit.lshift, bit.rshift\nlocal SegTree = {}\nSegTree.updateAll = function(self)\n for i = self.stagenum - 1, 1, -1 do\n for j = 1, self.cnt[i] do\n self.stage[i][j] = false\n end\n end\nend\nSegTree.create = function(self, n)\n local stagenum, mul = 1, 1\n self.cnt, self.stage = {1}, {{}}\n while mul < n do\n mul, stagenum = mul * 2, stagenum + 1\n self.cnt[stagenum], self.stage[stagenum] = mul, {}\n end\n self.stagenum = stagenum\n for i = 1, mul do self.stage[stagenum][i] = false end\n self:updateAll()\nend\nSegTree.getRange = function(self, left, right)\n if left == right then return self.stage[self.stagenum][left] end\n local start_stage = 1\n local stagenum = self.stagenum\n while right - left + 1 < bls(1, stagenum - start_stage) do\n start_stage = start_stage + 1\n end\n local ret = false\n local t1, t2, t3 = {start_stage}, {left}, {right}\n while 0 < #t1 do\n local stage, l, r = t1[#t1], t2[#t1], t3[#t1]\n table.remove(t1) table.remove(t2) table.remove(t3)\n local sz = bls(1, stagenum - stage)\n if (l - 1) % sz ~= 0 then\n local newr = mmi(r, mce((l - 1) / sz) * sz)\n table.insert(t1, stage + 1) table.insert(t2, l) table.insert(t3, newr)\n l = newr + 1\n end\n if sz <= r + 1 - l then\n ret = ret or self.stage[stage][mce(l / sz)]\n l = l + sz\n end\n if l <= r then\n table.insert(t1, stage + 1) table.insert(t2, l) table.insert(t3, r)\n end\n if ret then break end\n end\n return ret\nend\nSegTree.setValue = function(self, idx, value)\n self.stage[self.stagenum][idx] = value\n for i = self.stagenum - 1, 1, -1 do\n local dst = brs(idx + 1, 1)\n local rem = dst * 4 - 1 - idx\n self.stage[i][dst] = self.stage[i + 1][idx] or self.stage[i + 1][rem]\n idx = dst\n end\nend\nSegTree.new = function(n, func, emptyvalue)\n local obj = {}\n setmetatable(obj, {__index = SegTree})\n obj:create(n, func, emptyvalue)\n return obj\nend\n\nlocal n = io.read(\"*n\", \"*l\")\nlocal s = io.read()\nlocal q = io.read(\"*n\", \"*l\")\nlocal sts = {}\nlocal t = {}\nfor i = 1, 26 do\n sts[i] = SegTree.new(n, function(a, b) return a or b end, false)\nend\nfor i = 1, n do\n t[i] = s:sub(i, i):byte() - 96\n sts[t[i]]:setValue(i, true)\nend\n\nfor iq = 1, q do\n local iqstr = io.read()\n local ic = iqstr:sub(1, 1)\n if ic == \"1\" then\n local i, cs = iqstr:match(\"%d (%d+) (%w)\")\n i = tonumber(i)\n local c = cs:byte() - 96\n if t[i] ~= c then\n sts[t[i]]:setValue(i, false)\n t[i] = c\n sts[c]:setValue(i, true)\n end\n else\n local l, r = iqstr:match(\"%d (%d+) (%d+)\")\n l, r = tonumber(l), tonumber(r)\n local cnt = 0\n for i = 1, 26 do\n if sts[i]:getRange(l, r) then cnt = cnt + 1 end\n end\n print(cnt)\n end\nend\n", "problem_context": "Score : 500 points\n\nProblem Statement\n\nYou are given a string S of length N consisting of lowercase English letters.\n\nProcess Q queries of the following two types:\n\nType 1: change the i_q-th character of S to c_q. (Do nothing if the i_q-th character is already c_q.)\n\nType 2: answer the number of different characters occurring in the substring of S between the l_q-th and r_q-th characters (inclusive).\n\nConstraints\n\nN, Q, i_q, l_q, and r_q are integers.\n\nS is a string consisting of lowercase English letters.\n\nc_q is a lowercase English letter.\n\n1 \\leq N \\leq 500000\n\n1 \\leq Q \\leq 20000\n\n|S| = N\n\n1 \\leq i_q \\leq N\n\n1 \\leq l_q \\leq r_q \\leq N\n\nThere is at least one query of type 2 in each testcase.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS\nQ\nQuery_1\n\\vdots\nQuery_Q\n\nHere, Query_i in the 4-th through (Q+3)-th lines is one of the following:\n\n1 i_q c_q\n\n2 l_q r_q\n\nOutput\n\nFor each query of type 2, print a line containing the answer.\n\nSample Input 1\n\n7\nabcdbbd\n6\n2 3 6\n1 5 z\n2 1 1\n1 4 a\n1 7 d\n2 1 7\n\nSample Output 1\n\n3\n1\n5\n\nIn the first query, cdbb contains three kinds of letters: b , c , and d, so we print 3.\n\nIn the second query, S is modified to abcdzbd.\n\nIn the third query, a contains one kind of letter: a, so we print 1.\n\nIn the fourth query, S is modified to abcazbd.\n\nIn the fifth query, S does not change and is still abcazbd.\n\nIn the sixth query, abcazbd contains five kinds of letters: a, b, c, d, and z, so we print 5.", "sample_input": "7\nabcdbbd\n6\n2 3 6\n1 5 z\n2 1 1\n1 4 a\n1 7 d\n2 1 7\n"}, "reference_outputs": ["3\n1\n5\n"], "source_document_id": "p02763", "source_text": "Score : 500 points\n\nProblem Statement\n\nYou are given a string S of length N consisting of lowercase English letters.\n\nProcess Q queries of the following two types:\n\nType 1: change the i_q-th character of S to c_q. (Do nothing if the i_q-th character is already c_q.)\n\nType 2: answer the number of different characters occurring in the substring of S between the l_q-th and r_q-th characters (inclusive).\n\nConstraints\n\nN, Q, i_q, l_q, and r_q are integers.\n\nS is a string consisting of lowercase English letters.\n\nc_q is a lowercase English letter.\n\n1 \\leq N \\leq 500000\n\n1 \\leq Q \\leq 20000\n\n|S| = N\n\n1 \\leq i_q \\leq N\n\n1 \\leq l_q \\leq r_q \\leq N\n\nThere is at least one query of type 2 in each testcase.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS\nQ\nQuery_1\n\\vdots\nQuery_Q\n\nHere, Query_i in the 4-th through (Q+3)-th lines is one of the following:\n\n1 i_q c_q\n\n2 l_q r_q\n\nOutput\n\nFor each query of type 2, print a line containing the answer.\n\nSample Input 1\n\n7\nabcdbbd\n6\n2 3 6\n1 5 z\n2 1 1\n1 4 a\n1 7 d\n2 1 7\n\nSample Output 1\n\n3\n1\n5\n\nIn the first query, cdbb contains three kinds of letters: b , c , and d, so we print 3.\n\nIn the second query, S is modified to abcdzbd.\n\nIn the third query, a contains one kind of letter: a, so we print 1.\n\nIn the fourth query, S is modified to abcazbd.\n\nIn the fifth query, S does not change and is still abcazbd.\n\nIn the sixth query, abcazbd contains five kinds of letters: a, b, c, d, and z, so we print 5.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2775, "cpu_time_ms": 994, "memory_kb": 317488}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s013308627", "group_id": "codeNet:p02763", "input_text": "local mfl, mce, mmi = math.floor, math.ceil, math.min\nlocal SegTree = {}\nSegTree.updateAll = function(self)\n for i = self.stagenum - 1, 1, -1 do\n for j = 1, self.cnt[i] do\n self.stage[i][j] = false\n end\n end\nend\nSegTree.create = function(self, n)\n local stagenum, mul = 1, 1\n self.cnt, self.stage, self.size = {1}, {{}}, {}\n while mul < n do\n mul, stagenum = mul * 2, stagenum + 1\n self.cnt[stagenum], self.stage[stagenum] = mul, {}\n end\n for i = 1, stagenum do self.size[i] = self.cnt[stagenum + 1 - i] end\n self.stagenum = stagenum\n for i = 1, mul do self.stage[stagenum][i] = false end\n self:updateAll()\nend\nSegTree.getRange = function(self, left, right)\n if left == right then return self.stage[self.stagenum][left] end\n local start_stage = 1\n while right - left + 1 < self.size[start_stage] do\n start_stage = start_stage + 1\n end\n local ret = false\n local t1, t2, t3 = {start_stage}, {left}, {right}\n while 0 < #t1 do\n local stage, l, r = t1[#t1], t2[#t1], t3[#t1]\n table.remove(t1) table.remove(t2) table.remove(t3)\n local sz = self.size[stage]\n if (l - 1) % sz ~= 0 then\n local newr = mmi(r, mce((l - 1) / sz) * sz)\n table.insert(t1, stage + 1) table.insert(t2, l) table.insert(t3, newr)\n l = newr + 1\n end\n if sz <= r + 1 - l then\n ret = ret or self.stage[stage][mce(l / sz)]\n l = l + sz\n end\n if l <= r then\n table.insert(t1, stage + 1) table.insert(t2, l) table.insert(t3, r)\n end\n if ret then break end\n end\n return ret\nend\nSegTree.setValue = function(self, idx, value)\n self.stage[self.stagenum][idx] = value\n for i = self.stagenum - 1, 1, -1 do\n local dst = mce(idx / 2)\n local rem = dst * 4 - 1 - idx\n self.stage[i][dst] = self.stage[i + 1][idx] or self.stage[i + 1][rem]\n idx = dst\n end\nend\nSegTree.new = function(n, func, emptyvalue)\n local obj = {}\n setmetatable(obj, {__index = SegTree})\n obj:create(n, func, emptyvalue)\n return obj\nend\n\nlocal n = io.read(\"*n\", \"*l\")\nlocal s = io.read()\nlocal q = io.read(\"*n\", \"*l\")\nlocal sts = {}\nlocal t = {}\nfor i = 1, 26 do\n sts[i] = SegTree.new(n, function(a, b) return a or b end, false)\nend\nfor i = 1, n do\n t[i] = s:sub(i, i):byte() - 96\n sts[t[i]]:setValue(i, true)\nend\n\nfor iq = 1, q do\n local iqstr = io.read()\n local ic = iqstr:sub(1, 1)\n if ic == \"1\" then\n local i, cs = iqstr:match(\"%d (%d+) (%w)\")\n i = tonumber(i)\n local c = cs:byte() - 96\n if t[i] ~= c then\n sts[t[i]]:setValue(i, false)\n t[i] = c\n sts[c]:setValue(i, true)\n end\n else\n local l, r = iqstr:match(\"%d (%d+) (%d+)\")\n l, r = tonumber(l), tonumber(r)\n local cnt = 0\n for i = 1, 26 do\n if sts[i]:getRange(l, r) then cnt = cnt + 1 end\n end\n print(cnt)\n end\nend\n", "language": "Lua", "metadata": {"date": 1583207999, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p02763.html", "problem_id": "p02763", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02763/input.txt", "sample_output_relpath": "derived/input_output/data/p02763/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02763/Lua/s013308627.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s013308627", "user_id": "u120582723"}, "prompt_components": {"gold_output": "3\n1\n5\n", "input_to_evaluate": "local mfl, mce, mmi = math.floor, math.ceil, math.min\nlocal SegTree = {}\nSegTree.updateAll = function(self)\n for i = self.stagenum - 1, 1, -1 do\n for j = 1, self.cnt[i] do\n self.stage[i][j] = false\n end\n end\nend\nSegTree.create = function(self, n)\n local stagenum, mul = 1, 1\n self.cnt, self.stage, self.size = {1}, {{}}, {}\n while mul < n do\n mul, stagenum = mul * 2, stagenum + 1\n self.cnt[stagenum], self.stage[stagenum] = mul, {}\n end\n for i = 1, stagenum do self.size[i] = self.cnt[stagenum + 1 - i] end\n self.stagenum = stagenum\n for i = 1, mul do self.stage[stagenum][i] = false end\n self:updateAll()\nend\nSegTree.getRange = function(self, left, right)\n if left == right then return self.stage[self.stagenum][left] end\n local start_stage = 1\n while right - left + 1 < self.size[start_stage] do\n start_stage = start_stage + 1\n end\n local ret = false\n local t1, t2, t3 = {start_stage}, {left}, {right}\n while 0 < #t1 do\n local stage, l, r = t1[#t1], t2[#t1], t3[#t1]\n table.remove(t1) table.remove(t2) table.remove(t3)\n local sz = self.size[stage]\n if (l - 1) % sz ~= 0 then\n local newr = mmi(r, mce((l - 1) / sz) * sz)\n table.insert(t1, stage + 1) table.insert(t2, l) table.insert(t3, newr)\n l = newr + 1\n end\n if sz <= r + 1 - l then\n ret = ret or self.stage[stage][mce(l / sz)]\n l = l + sz\n end\n if l <= r then\n table.insert(t1, stage + 1) table.insert(t2, l) table.insert(t3, r)\n end\n if ret then break end\n end\n return ret\nend\nSegTree.setValue = function(self, idx, value)\n self.stage[self.stagenum][idx] = value\n for i = self.stagenum - 1, 1, -1 do\n local dst = mce(idx / 2)\n local rem = dst * 4 - 1 - idx\n self.stage[i][dst] = self.stage[i + 1][idx] or self.stage[i + 1][rem]\n idx = dst\n end\nend\nSegTree.new = function(n, func, emptyvalue)\n local obj = {}\n setmetatable(obj, {__index = SegTree})\n obj:create(n, func, emptyvalue)\n return obj\nend\n\nlocal n = io.read(\"*n\", \"*l\")\nlocal s = io.read()\nlocal q = io.read(\"*n\", \"*l\")\nlocal sts = {}\nlocal t = {}\nfor i = 1, 26 do\n sts[i] = SegTree.new(n, function(a, b) return a or b end, false)\nend\nfor i = 1, n do\n t[i] = s:sub(i, i):byte() - 96\n sts[t[i]]:setValue(i, true)\nend\n\nfor iq = 1, q do\n local iqstr = io.read()\n local ic = iqstr:sub(1, 1)\n if ic == \"1\" then\n local i, cs = iqstr:match(\"%d (%d+) (%w)\")\n i = tonumber(i)\n local c = cs:byte() - 96\n if t[i] ~= c then\n sts[t[i]]:setValue(i, false)\n t[i] = c\n sts[c]:setValue(i, true)\n end\n else\n local l, r = iqstr:match(\"%d (%d+) (%d+)\")\n l, r = tonumber(l), tonumber(r)\n local cnt = 0\n for i = 1, 26 do\n if sts[i]:getRange(l, r) then cnt = cnt + 1 end\n end\n print(cnt)\n end\nend\n", "problem_context": "Score : 500 points\n\nProblem Statement\n\nYou are given a string S of length N consisting of lowercase English letters.\n\nProcess Q queries of the following two types:\n\nType 1: change the i_q-th character of S to c_q. (Do nothing if the i_q-th character is already c_q.)\n\nType 2: answer the number of different characters occurring in the substring of S between the l_q-th and r_q-th characters (inclusive).\n\nConstraints\n\nN, Q, i_q, l_q, and r_q are integers.\n\nS is a string consisting of lowercase English letters.\n\nc_q is a lowercase English letter.\n\n1 \\leq N \\leq 500000\n\n1 \\leq Q \\leq 20000\n\n|S| = N\n\n1 \\leq i_q \\leq N\n\n1 \\leq l_q \\leq r_q \\leq N\n\nThere is at least one query of type 2 in each testcase.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS\nQ\nQuery_1\n\\vdots\nQuery_Q\n\nHere, Query_i in the 4-th through (Q+3)-th lines is one of the following:\n\n1 i_q c_q\n\n2 l_q r_q\n\nOutput\n\nFor each query of type 2, print a line containing the answer.\n\nSample Input 1\n\n7\nabcdbbd\n6\n2 3 6\n1 5 z\n2 1 1\n1 4 a\n1 7 d\n2 1 7\n\nSample Output 1\n\n3\n1\n5\n\nIn the first query, cdbb contains three kinds of letters: b , c , and d, so we print 3.\n\nIn the second query, S is modified to abcdzbd.\n\nIn the third query, a contains one kind of letter: a, so we print 1.\n\nIn the fourth query, S is modified to abcazbd.\n\nIn the fifth query, S does not change and is still abcazbd.\n\nIn the sixth query, abcazbd contains five kinds of letters: a, b, c, d, and z, so we print 5.", "sample_input": "7\nabcdbbd\n6\n2 3 6\n1 5 z\n2 1 1\n1 4 a\n1 7 d\n2 1 7\n"}, "reference_outputs": ["3\n1\n5\n"], "source_document_id": "p02763", "source_text": "Score : 500 points\n\nProblem Statement\n\nYou are given a string S of length N consisting of lowercase English letters.\n\nProcess Q queries of the following two types:\n\nType 1: change the i_q-th character of S to c_q. (Do nothing if the i_q-th character is already c_q.)\n\nType 2: answer the number of different characters occurring in the substring of S between the l_q-th and r_q-th characters (inclusive).\n\nConstraints\n\nN, Q, i_q, l_q, and r_q are integers.\n\nS is a string consisting of lowercase English letters.\n\nc_q is a lowercase English letter.\n\n1 \\leq N \\leq 500000\n\n1 \\leq Q \\leq 20000\n\n|S| = N\n\n1 \\leq i_q \\leq N\n\n1 \\leq l_q \\leq r_q \\leq N\n\nThere is at least one query of type 2 in each testcase.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS\nQ\nQuery_1\n\\vdots\nQuery_Q\n\nHere, Query_i in the 4-th through (Q+3)-th lines is one of the following:\n\n1 i_q c_q\n\n2 l_q r_q\n\nOutput\n\nFor each query of type 2, print a line containing the answer.\n\nSample Input 1\n\n7\nabcdbbd\n6\n2 3 6\n1 5 z\n2 1 1\n1 4 a\n1 7 d\n2 1 7\n\nSample Output 1\n\n3\n1\n5\n\nIn the first query, cdbb contains three kinds of letters: b , c , and d, so we print 3.\n\nIn the second query, S is modified to abcdzbd.\n\nIn the third query, a contains one kind of letter: a, so we print 1.\n\nIn the fourth query, S is modified to abcazbd.\n\nIn the fifth query, S does not change and is still abcazbd.\n\nIn the sixth query, abcazbd contains five kinds of letters: a, b, c, d, and z, so we print 5.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2769, "cpu_time_ms": 1023, "memory_kb": 317420}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s186974478", "group_id": "codeNet:p02764", "input_text": "local mma, mmi = math.max, math.min\nlocal msq = math.sqrt\nlocal n, k = io.read(\"*n\", \"*n\")\nlocal t = {}\nfor i = 1, n do\n t[i] = {io.read(\"*n\", \"*n\", \"*n\")}\nend\n\nlocal function func(x, y)\n local q = {}\n for i = 1, n do\n q[i] = t[i][3] * t[i][3] * ((t[i][1] - x) * (t[i][1] - x) + (t[i][2] - y) * (t[i][2] - y))\n end\n table.sort(q)\n return msq(q[k])\nend\n\nlocal function solve(tbl)\n local xmin, xmax, ymin, ymax = tbl[1], tbl[2], tbl[3], tbl[4]\n local dv = 64\n local dxrange = (xmax - xmin) / (dv * 2)\n local dyrange = (ymax - ymin) / (dv * 2)\n local xp = {}\n for i = 1, dv do\n xp[i] = xmin + dxrange * (i * 2 - 1)\n end\n local yp = {}\n for i = 1, dv do\n yp[i] = ymin + dyrange * (i * 2 - 1)\n end\n local mp, minval = false, 0\n for i = 1, dv do\n for j = 1, dv do\n local v = func(xp[i], yp[j])\n if not mp or v < minval then\n minval = v\n mp = {i, j}\n end\n end\n end\n tbl[1] = xmin + mma(0, dxrange * (mp[1] * 2 - 1 - dv / 4))\n tbl[2] = mmi(xmax, xmin + dxrange * (mp[1] * 2 - 1 + dv / 4))\n tbl[3] = ymin + mma(0, dyrange * (mp[2] * 2 - 1 - dv / 4))\n tbl[4] = mmi(ymax, ymin + dyrange * (mp[2] * 2 - 1 + dv / 4))\nend\n\nlocal tbl = {-1000, 1000, -1000, 1000}\nlocal rep = 10000000\nwhile true do\n solve(tbl)\n if 1.85 < os.clock() then break end\nend\nlocal xm, ym = (tbl[1] + tbl[2]) / 2, (tbl[3] + tbl[4]) / 2\nlocal ret = func(xm, ym)\nprint(string.format(\"%.10f\", ret))\n", "language": "Lua", "metadata": {"date": 1583119433, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p02764.html", "problem_id": "p02764", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02764/input.txt", "sample_output_relpath": "derived/input_output/data/p02764/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02764/Lua/s186974478.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s186974478", "user_id": "u120582723"}, "prompt_components": {"gold_output": "2.4\n", "input_to_evaluate": "local mma, mmi = math.max, math.min\nlocal msq = math.sqrt\nlocal n, k = io.read(\"*n\", \"*n\")\nlocal t = {}\nfor i = 1, n do\n t[i] = {io.read(\"*n\", \"*n\", \"*n\")}\nend\n\nlocal function func(x, y)\n local q = {}\n for i = 1, n do\n q[i] = t[i][3] * t[i][3] * ((t[i][1] - x) * (t[i][1] - x) + (t[i][2] - y) * (t[i][2] - y))\n end\n table.sort(q)\n return msq(q[k])\nend\n\nlocal function solve(tbl)\n local xmin, xmax, ymin, ymax = tbl[1], tbl[2], tbl[3], tbl[4]\n local dv = 64\n local dxrange = (xmax - xmin) / (dv * 2)\n local dyrange = (ymax - ymin) / (dv * 2)\n local xp = {}\n for i = 1, dv do\n xp[i] = xmin + dxrange * (i * 2 - 1)\n end\n local yp = {}\n for i = 1, dv do\n yp[i] = ymin + dyrange * (i * 2 - 1)\n end\n local mp, minval = false, 0\n for i = 1, dv do\n for j = 1, dv do\n local v = func(xp[i], yp[j])\n if not mp or v < minval then\n minval = v\n mp = {i, j}\n end\n end\n end\n tbl[1] = xmin + mma(0, dxrange * (mp[1] * 2 - 1 - dv / 4))\n tbl[2] = mmi(xmax, xmin + dxrange * (mp[1] * 2 - 1 + dv / 4))\n tbl[3] = ymin + mma(0, dyrange * (mp[2] * 2 - 1 - dv / 4))\n tbl[4] = mmi(ymax, ymin + dyrange * (mp[2] * 2 - 1 + dv / 4))\nend\n\nlocal tbl = {-1000, 1000, -1000, 1000}\nlocal rep = 10000000\nwhile true do\n solve(tbl)\n if 1.85 < os.clock() then break end\nend\nlocal xm, ym = (tbl[1] + tbl[2]) / 2, (tbl[3] + tbl[4]) / 2\nlocal ret = func(xm, ym)\nprint(string.format(\"%.10f\", ret))\n", "problem_context": "Score : 600 points\n\nProblem Statement\n\nTakahashi wants to grill N pieces of meat on a grilling net, which can be seen as a two-dimensional plane. The coordinates of the i-th piece of meat are \\left(x_i, y_i\\right), and its hardness is c_i.\n\nTakahashi can use one heat source to grill the meat. If he puts the heat source at coordinates \\left(X, Y\\right), where X and Y are real numbers, the i-th piece of meat will be ready to eat in c_i \\times \\sqrt{\\left(X - x_i\\right)^2 + \\left(Y-y_i\\right)^2} seconds.\n\nTakahashi wants to eat K pieces of meat. Find the time required to have K or more pieces of meat ready if he put the heat source to minimize this time.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 60\n\n1 \\leq K \\leq N\n\n-1000 \\leq x_i , y_i \\leq 1000\n\n\\left(x_i, y_i\\right) \\neq \\left(x_j, y_j\\right) \\left(i \\neq j \\right)\n\n1 \\leq c_i \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nx_1 y_1 c_1\n\\vdots\nx_N y_N c_N\n\nOutput\n\nPrint the answer.\n\nIt will be considered correct if its absolute or relative error from our answer is at most 10^{-6}.\n\nSample Input 1\n\n4 3\n-1 0 3\n0 0 3\n1 0 2\n1 1 40\n\nSample Output 1\n\n2.4\n\nIf we put the heat source at \\left(-0.2, 0\\right), the 1-st, 2-nd, and 3-rd pieces of meat will be ready to eat within 2.4 seconds. This is the optimal place to put the heat source.\n\nSample Input 2\n\n10 5\n-879 981 26\n890 -406 81\n512 859 97\n362 -955 25\n128 553 17\n-885 763 2\n449 310 57\n-656 -204 11\n-270 76 40\n184 170 16\n\nSample Output 2\n\n7411.2252", "sample_input": "4 3\n-1 0 3\n0 0 3\n1 0 2\n1 1 40\n"}, "reference_outputs": ["2.4\n"], "source_document_id": "p02764", "source_text": "Score : 600 points\n\nProblem Statement\n\nTakahashi wants to grill N pieces of meat on a grilling net, which can be seen as a two-dimensional plane. The coordinates of the i-th piece of meat are \\left(x_i, y_i\\right), and its hardness is c_i.\n\nTakahashi can use one heat source to grill the meat. If he puts the heat source at coordinates \\left(X, Y\\right), where X and Y are real numbers, the i-th piece of meat will be ready to eat in c_i \\times \\sqrt{\\left(X - x_i\\right)^2 + \\left(Y-y_i\\right)^2} seconds.\n\nTakahashi wants to eat K pieces of meat. Find the time required to have K or more pieces of meat ready if he put the heat source to minimize this time.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 60\n\n1 \\leq K \\leq N\n\n-1000 \\leq x_i , y_i \\leq 1000\n\n\\left(x_i, y_i\\right) \\neq \\left(x_j, y_j\\right) \\left(i \\neq j \\right)\n\n1 \\leq c_i \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nx_1 y_1 c_1\n\\vdots\nx_N y_N c_N\n\nOutput\n\nPrint the answer.\n\nIt will be considered correct if its absolute or relative error from our answer is at most 10^{-6}.\n\nSample Input 1\n\n4 3\n-1 0 3\n0 0 3\n1 0 2\n1 1 40\n\nSample Output 1\n\n2.4\n\nIf we put the heat source at \\left(-0.2, 0\\right), the 1-st, 2-nd, and 3-rd pieces of meat will be ready to eat within 2.4 seconds. This is the optimal place to put the heat source.\n\nSample Input 2\n\n10 5\n-879 981 26\n890 -406 81\n512 859 97\n362 -955 25\n128 553 17\n-885 763 2\n449 310 57\n-656 -204 11\n-270 76 40\n184 170 16\n\nSample Output 2\n\n7411.2252", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1425, "cpu_time_ms": 1896, "memory_kb": 512}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s067188513", "group_id": "codeNet:p02765", "input_text": "local a, b = io.read(\"*n\", \"*n\")\nif a < 10 then\n print(b + 100 * (10 - a))\nelse\n print(b)\nend\n", "language": "Lua", "metadata": {"date": 1582423317, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p02765.html", "problem_id": "p02765", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02765/input.txt", "sample_output_relpath": "derived/input_output/data/p02765/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02765/Lua/s067188513.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s067188513", "user_id": "u120582723"}, "prompt_components": {"gold_output": "3719\n", "input_to_evaluate": "local a, b = io.read(\"*n\", \"*n\")\nif a < 10 then\n print(b + 100 * (10 - a))\nelse\n print(b)\nend\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nTakahashi is a member of a programming competition site, ButCoder.\n\nEach member of ButCoder is assigned two values: Inner Rating and Displayed Rating.\n\nThe Displayed Rating of a member is equal to their Inner Rating if the member has participated in 10 or more contests. Otherwise, the Displayed Rating will be their Inner Rating minus 100 \\times (10 - K) when the member has participated in K contests.\n\nTakahashi has participated in N contests, and his Displayed Rating is R. Find his Inner Rating.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 100\n\n0 \\leq R \\leq 4111\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN R\n\nOutput\n\nPrint his Inner Rating.\n\nSample Input 1\n\n2 2919\n\nSample Output 1\n\n3719\n\nTakahashi has participated in 2 contests, which is less than 10, so his Displayed Rating is his Inner Rating minus 100 \\times (10 - 2) = 800.\n\nThus, Takahashi's Inner Rating is 2919 + 800 = 3719.\n\nSample Input 2\n\n22 3051\n\nSample Output 2\n\n3051", "sample_input": "2 2919\n"}, "reference_outputs": ["3719\n"], "source_document_id": "p02765", "source_text": "Score : 100 points\n\nProblem Statement\n\nTakahashi is a member of a programming competition site, ButCoder.\n\nEach member of ButCoder is assigned two values: Inner Rating and Displayed Rating.\n\nThe Displayed Rating of a member is equal to their Inner Rating if the member has participated in 10 or more contests. Otherwise, the Displayed Rating will be their Inner Rating minus 100 \\times (10 - K) when the member has participated in K contests.\n\nTakahashi has participated in N contests, and his Displayed Rating is R. Find his Inner Rating.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 100\n\n0 \\leq R \\leq 4111\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN R\n\nOutput\n\nPrint his Inner Rating.\n\nSample Input 1\n\n2 2919\n\nSample Output 1\n\n3719\n\nTakahashi has participated in 2 contests, which is less than 10, so his Displayed Rating is his Inner Rating minus 100 \\times (10 - 2) = 800.\n\nThus, Takahashi's Inner Rating is 2919 + 800 = 3719.\n\nSample Input 2\n\n22 3051\n\nSample Output 2\n\n3051", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 96, "cpu_time_ms": 72, "memory_kb": 760}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s466703055", "group_id": "codeNet:p02766", "input_text": "local read = setmetatable({}, {__index = function(t, k) local a = {} for i=1,#k do table.insert(a, '*'..string.sub(k, i, i)) end local r = io.read local u = table.unpack or unpack return function() return r(u(a)) end end})\nread.N = function(N) local t={} for i=1,N do t[i]=read.n() end return t end\nstring.totable = function(s) local t={} local u=string.sub for i=1,#s do t[i] = u(s, i, i) end return t end\nstring.split = function(s) local t={} for w in string.gmatch(s, \"[^%s]+\") do table.insert(t, w) end return (table.unpack or unpack)(t) end\nlocal function array(dimension, default_val) local n=dimension local m={}if default_val~=nil then m[1]={__index=function()return default_val end}end for i=2,n do m[i]={__index=function(p, k)local c=setmetatable({},m[i-1])rawset(p,k,c)return c end}end return setmetatable({},m[n])end\n----\nlocal N, K = read.nn()\nif N == 0 then\n print(1)\n return\nend\nlocal n = N\nlocal ans = 0\nwhile n > 0 do\n ans = ans + 1\n n = n // K\n --print(n)\nend\nprint(ans)", "language": "Lua", "metadata": {"date": 1582423451, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p02766.html", "problem_id": "p02766", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02766/input.txt", "sample_output_relpath": "derived/input_output/data/p02766/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02766/Lua/s466703055.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s466703055", "user_id": "u162773977"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "local read = setmetatable({}, {__index = function(t, k) local a = {} for i=1,#k do table.insert(a, '*'..string.sub(k, i, i)) end local r = io.read local u = table.unpack or unpack return function() return r(u(a)) end end})\nread.N = function(N) local t={} for i=1,N do t[i]=read.n() end return t end\nstring.totable = function(s) local t={} local u=string.sub for i=1,#s do t[i] = u(s, i, i) end return t end\nstring.split = function(s) local t={} for w in string.gmatch(s, \"[^%s]+\") do table.insert(t, w) end return (table.unpack or unpack)(t) end\nlocal function array(dimension, default_val) local n=dimension local m={}if default_val~=nil then m[1]={__index=function()return default_val end}end for i=2,n do m[i]={__index=function(p, k)local c=setmetatable({},m[i-1])rawset(p,k,c)return c end}end return setmetatable({},m[n])end\n----\nlocal N, K = read.nn()\nif N == 0 then\n print(1)\n return\nend\nlocal n = N\nlocal ans = 0\nwhile n > 0 do\n ans = ans + 1\n n = n // K\n --print(n)\nend\nprint(ans)", "problem_context": "Score : 200 points\n\nProblem Statement\n\nGiven is an integer N. Find the number of digits that N has in base K.\n\nNotes\n\nFor information on base-K representation, see Positional notation - Wikipedia.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^9\n\n2 \\leq K \\leq 10\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\n\nOutput\n\nPrint the number of digits that N has in base K.\n\nSample Input 1\n\n11 2\n\nSample Output 1\n\n4\n\nIn binary, 11 is represented as 1011.\n\nSample Input 2\n\n1010101 10\n\nSample Output 2\n\n7\n\nSample Input 3\n\n314159265 3\n\nSample Output 3\n\n18", "sample_input": "11 2\n"}, "reference_outputs": ["4\n"], "source_document_id": "p02766", "source_text": "Score : 200 points\n\nProblem Statement\n\nGiven is an integer N. Find the number of digits that N has in base K.\n\nNotes\n\nFor information on base-K representation, see Positional notation - Wikipedia.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^9\n\n2 \\leq K \\leq 10\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\n\nOutput\n\nPrint the number of digits that N has in base K.\n\nSample Input 1\n\n11 2\n\nSample Output 1\n\n4\n\nIn binary, 11 is represented as 1011.\n\nSample Input 2\n\n1010101 10\n\nSample Output 2\n\n7\n\nSample Input 3\n\n314159265 3\n\nSample Output 3\n\n18", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1003, "cpu_time_ms": 39, "memory_kb": 1008}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s711211226", "group_id": "codeNet:p02766", "input_text": "local n, k = io.read(\"*n\", \"*n\")\nlocal d = 1\nlocal x = k\nwhile true do\n if n < x then\n print(d)\n break\n else\n x = x * k\n d = d + 1\n end\nend\n", "language": "Lua", "metadata": {"date": 1582423401, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p02766.html", "problem_id": "p02766", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02766/input.txt", "sample_output_relpath": "derived/input_output/data/p02766/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02766/Lua/s711211226.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s711211226", "user_id": "u120582723"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "local n, k = io.read(\"*n\", \"*n\")\nlocal d = 1\nlocal x = k\nwhile true do\n if n < x then\n print(d)\n break\n else\n x = x * k\n d = d + 1\n end\nend\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nGiven is an integer N. Find the number of digits that N has in base K.\n\nNotes\n\nFor information on base-K representation, see Positional notation - Wikipedia.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^9\n\n2 \\leq K \\leq 10\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\n\nOutput\n\nPrint the number of digits that N has in base K.\n\nSample Input 1\n\n11 2\n\nSample Output 1\n\n4\n\nIn binary, 11 is represented as 1011.\n\nSample Input 2\n\n1010101 10\n\nSample Output 2\n\n7\n\nSample Input 3\n\n314159265 3\n\nSample Output 3\n\n18", "sample_input": "11 2\n"}, "reference_outputs": ["4\n"], "source_document_id": "p02766", "source_text": "Score : 200 points\n\nProblem Statement\n\nGiven is an integer N. Find the number of digits that N has in base K.\n\nNotes\n\nFor information on base-K representation, see Positional notation - Wikipedia.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^9\n\n2 \\leq K \\leq 10\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\n\nOutput\n\nPrint the number of digits that N has in base K.\n\nSample Input 1\n\n11 2\n\nSample Output 1\n\n4\n\nIn binary, 11 is represented as 1011.\n\nSample Input 2\n\n1010101 10\n\nSample Output 2\n\n7\n\nSample Input 3\n\n314159265 3\n\nSample Output 3\n\n18", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 155, "cpu_time_ms": 68, "memory_kb": 888}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s267899363", "group_id": "codeNet:p02767", "input_text": "local n = io.read(\"*n\")\nlocal t = {}\nfor i = 1, n do\n t[i] = io.read(\"*n\")\nend\nlocal ret = 1\nfor x = 1, 100 do\n local r = 0\n for i = 1, n do\n r = r + (t[i] - x) * (t[i] - x)\n end\n if x == 1 then ret = r\n else ret = math.min(ret, r)\n end\nend\nprint(ret)\n", "language": "Lua", "metadata": {"date": 1582423555, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p02767.html", "problem_id": "p02767", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02767/input.txt", "sample_output_relpath": "derived/input_output/data/p02767/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02767/Lua/s267899363.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s267899363", "user_id": "u120582723"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "local n = io.read(\"*n\")\nlocal t = {}\nfor i = 1, n do\n t[i] = io.read(\"*n\")\nend\nlocal ret = 1\nfor x = 1, 100 do\n local r = 0\n for i = 1, n do\n r = r + (t[i] - x) * (t[i] - x)\n end\n if x == 1 then ret = r\n else ret = math.min(ret, r)\n end\nend\nprint(ret)\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere are N people living on a number line.\n\nThe i-th person lives at coordinate X_i.\n\nYou are going to hold a meeting that all N people have to attend.\n\nThe meeting can be held at any integer coordinate. If you choose to hold the meeting at coordinate P, the i-th person will spend (X_i - P)^2 points of stamina to attend the meeting.\n\nFind the minimum total points of stamina the N people have to spend.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 100\n\n1 \\leq X_i \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nX_1 X_2 ... X_N\n\nOutput\n\nPrint the minimum total stamina the N people have to spend.\n\nSample Input 1\n\n2\n1 4\n\nSample Output 1\n\n5\n\nAssume the meeting is held at coordinate 2. In this case, the first person will spend (1 - 2)^2 points of stamina, and the second person will spend (4 - 2)^2 = 4 points of stamina, for a total of 5 points of stamina. This is the minimum total stamina that the 2 people have to spend.\n\nNote that you can hold the meeting only at an integer coordinate.\n\nSample Input 2\n\n7\n14 14 2 13 56 2 37\n\nSample Output 2\n\n2354", "sample_input": "2\n1 4\n"}, "reference_outputs": ["5\n"], "source_document_id": "p02767", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere are N people living on a number line.\n\nThe i-th person lives at coordinate X_i.\n\nYou are going to hold a meeting that all N people have to attend.\n\nThe meeting can be held at any integer coordinate. If you choose to hold the meeting at coordinate P, the i-th person will spend (X_i - P)^2 points of stamina to attend the meeting.\n\nFind the minimum total points of stamina the N people have to spend.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 100\n\n1 \\leq X_i \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nX_1 X_2 ... X_N\n\nOutput\n\nPrint the minimum total stamina the N people have to spend.\n\nSample Input 1\n\n2\n1 4\n\nSample Output 1\n\n5\n\nAssume the meeting is held at coordinate 2. In this case, the first person will spend (1 - 2)^2 points of stamina, and the second person will spend (4 - 2)^2 = 4 points of stamina, for a total of 5 points of stamina. This is the minimum total stamina that the 2 people have to spend.\n\nNote that you can hold the meeting only at an integer coordinate.\n\nSample Input 2\n\n7\n14 14 2 13 56 2 37\n\nSample Output 2\n\n2354", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 262, "cpu_time_ms": 8, "memory_kb": 1008}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s230539602", "group_id": "codeNet:p02768", "input_text": "local bit=require\"bit\"\nlocal ffi=require\"ffi\"\nlocal function int(x)return ffi.new(\"int64_t\",x)end\nlocal function printn(x)print(tonumber(x))end\nlocal function for64(a,b,c)c=c or 1 local x=a return c<0 and function()local ret=x x=x+c return ret>=b and ret or nil end or function() local ret=x x=x+c return ret<=b and ret or nil end end\nlocal MOD=int(1000000007)\nlocal function add(a,b)return (a+b)%MOD end\nlocal function sub(a,b)a=(a-b)%MOD return a<0 and a+MOD or a end\nlocal function mul(a,b)return a*b%MOD end\nlocal function pow(a,b)\n\tlocal ret=int(1)\n\twhile(b>0)do\n\t\tif(b%2==1)then ret=mul(ret,a)end\n\t\ta=mul(a,a)\n\t\tb=b/2\n\tend\n\treturn ret\nend\nlocal function inv(x)\n\tlocal a=x\n\tlocal b,u,v=int(MOD),int(1),int(0)\n\trepeat\n\t\tlocal t=a/b\n\t\ta,b=b,a-t*b\n\t\tu,v=v,u-t*v\n\tuntil(b==0)\n\tu=u%MOD\n\treturn u<0 and u+MOD or u\nend\nlocal function div(a,b)return mul(a,inv(b))end\nlocal function C(n,k)\n\tif(n=b and ret or nil end or function() local ret=x x=x+c return ret<=b and ret or nil end end\nlocal MOD=int(1000000007)\nlocal function add(a,b)return (a+b)%MOD end\nlocal function sub(a,b)a=(a-b)%MOD return a<0 and a+MOD or a end\nlocal function mul(a,b)return a*b%MOD end\nlocal function pow(a,b)\n\tlocal ret=int(1)\n\twhile(b>0)do\n\t\tif(b%2==1)then ret=mul(ret,a)end\n\t\ta=mul(a,a)\n\t\tb=b/2\n\tend\n\treturn ret\nend\nlocal function inv(x)\n\tlocal a=x\n\tlocal b,u,v=int(MOD),int(1),int(0)\n\trepeat\n\t\tlocal t=a/b\n\t\ta,b=b,a-t*b\n\t\tu,v=v,u-t*v\n\tuntil(b==0)\n\tu=u%MOD\n\treturn u<0 and u+MOD or u\nend\nlocal function div(a,b)return mul(a,inv(b))end\nlocal function C(n,k)\n\tif(n0)do\n\t\tif(b%2==1)then ret=(ret+a)%MOD end\n\t\ta=(a+a)%MOD\n\t\tb=math.floor(b*.5)\n\tend\n\treturn ret\nend\nlocal function mul(a,b)\n\treturn a0)do\n\t\tif(b%2==1)then ret=mul(ret,a)end\n\t\ta=mul(a,a)\n\t\tb=math.floor(b*.5)\n\tend\n\treturn ret\nend\nlocal function inv(x)\n\tlocal a=x\n\tlocal b,u,v=MOD,1,0\n\trepeat\n\t\tlocal t=math.floor(a/b)\n\t\ta,b=b,a-t*b\n\t\tu,v=v,u-t*v\n\tuntil(b==0)\n\treturn u%MOD\nend\nlocal function div(a,b)return mul(a,inv(b))end\nlocal function C(n,k)\n\tif(n0)do\n\t\tif(b%2==1)then ret=(ret+a)%MOD end\n\t\ta=(a+a)%MOD\n\t\tb=math.floor(b*.5)\n\tend\n\treturn ret\nend\nlocal function mul(a,b)\n\treturn a0)do\n\t\tif(b%2==1)then ret=mul(ret,a)end\n\t\ta=mul(a,a)\n\t\tb=math.floor(b*.5)\n\tend\n\treturn ret\nend\nlocal function inv(x)\n\tlocal a=x\n\tlocal b,u,v=MOD,1,0\n\trepeat\n\t\tlocal t=math.floor(a/b)\n\t\ta,b=b,a-t*b\n\t\tu,v=v,u-t*v\n\tuntil(b==0)\n\treturn u%MOD\nend\nlocal function div(a,b)return mul(a,inv(b))end\nlocal function C(n,k)\n\tif(n\n local invmfac = {}\n invmfac[nmax] = modpow(mfac[nmax], m - 2, m)\n for i=nmax,1,-1 do\n -- ((a-1)!)^(-1) ≡ a * (a!)^(-1) \n invmfac[i-1] = i * invmfac[i] % m\n end\n -- returns nCr % m\n local function mod_nCr(n, r)\n -- nCr ≡ n! * (r!)^(-1) * ((n-r)!)^(-1) \n local a = mfac[n] * invmfac[r] % m\n a = a * invmfac[n-r] % m\n return a\n end\n return mod_nCr\nend\n\n-- larger n and small r\nlocal function make_mod_nCr_2(rmax, m)\n -- Create n! table\n local mfac = {}\n mfac[0] = 1\n for i=1,rmax do\n mfac[i] = mfac[i-1] * i % m\n end\n -- Create (n!)^(-1) table\n -- (n!)^(-1) ≡ (n!)^(m - 2) \n local invmfac = {}\n invmfac[rmax] = modpow(mfac[rmax], m - 2, m)\n for i=rmax,1,-1 do\n -- ((a-1)!)^(-1) ≡ a * (a!)^(-1) \n invmfac[i-1] = i * invmfac[i] % m\n end\n -- partial factory ()\n local pmfac\n -- returns nCr % m\n local function mod_nCr(n, r)\n if r > n then\n return 0\n end\n if r > n/2 then\n r = n - r\n end\n -- nCr ≡ (n * (n - 1) * ... * (n-r+1)) * (r!)^(-1) \n local a = 1\n for i=n, n-r+1, -1 do\n a = (a * i) % m\n end\n a = a * invmfac[r] % m\n return a\n end\n return mod_nCr\nend\n\n\n----\nlocal n, k = read.nn()\n\nlocal nCr = make_mod_nCr(n, MOD)\n\nlocal ans = 0\nfor i=0,math.min(n-1,k) do\n local empty_room_pattern = nCr(n, i)\n local nonempty_room_pattern = nCr(n-1, i)\n ans = (ans + (empty_room_pattern * nonempty_room_pattern % MOD)) % MOD\nend\n\nprint(ans)", "language": "Lua", "metadata": {"date": 1582480875, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p02769.html", "problem_id": "p02769", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02769/input.txt", "sample_output_relpath": "derived/input_output/data/p02769/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02769/Lua/s658326949.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s658326949", "user_id": "u162773977"}, "prompt_components": {"gold_output": "10\n", "input_to_evaluate": "local read = setmetatable({}, {__index = function(t, k) local a = {} for i=1,#k do table.insert(a, '*'..string.sub(k, i, i)) end local r = io.read local u = table.unpack or unpack return function() return r(u(a)) end end})\nread.N = function(N) local t={} for i=1,N do t[i]=read.n() end return t end\nstring.totable = function(s) local t={} local u=string.sub for i=1,#s do t[i] = u(s, i, i) end return t end\nstring.split = function(s) local t={} for w in string.gmatch(s, \"[^%s]+\") do table.insert(t, w) end return (table.unpack or unpack)(t) end\nlocal function array(dimension, default_val) local n=dimension local m={}if default_val~=nil then m[1]={__index=function()return default_val end}end for i=2,n do m[i]={__index=function(p, k)local c=setmetatable({},m[i-1])rawset(p,k,c)return c end}end return setmetatable({},m[n])end\n----\nlocal floor = math.floor\nlocal MOD = floor(10^9)+7\n\n\n-- returns (b^n) % m\nlocal function modpow(b, n, m)\n if n == 0 then\n return 1\n elseif n % 2 == 0 then\n -- be careful about overflow of b*b\n return modpow(b * b % m, n//2, m)\n else\n return b * modpow(b, n - 1, m) % m\n end\nend\n\n-- returns n! % m\nlocal function modfactorial(n, m)\n local a = 1\n for i=1, n do\n a = a * i % m\n end\n return a\nend\n\nlocal function make_mod_nCr(nmax, m)\n -- Create n! table\n local mfac = {}\n mfac[0] = 1\n for i=1,nmax do\n mfac[i] = mfac[i-1] * i % m\n end\n -- Create (n!)^(-1) table\n -- (n!)^(-1) ≡ (n!)^(m - 2) \n local invmfac = {}\n invmfac[nmax] = modpow(mfac[nmax], m - 2, m)\n for i=nmax,1,-1 do\n -- ((a-1)!)^(-1) ≡ a * (a!)^(-1) \n invmfac[i-1] = i * invmfac[i] % m\n end\n -- returns nCr % m\n local function mod_nCr(n, r)\n -- nCr ≡ n! * (r!)^(-1) * ((n-r)!)^(-1) \n local a = mfac[n] * invmfac[r] % m\n a = a * invmfac[n-r] % m\n return a\n end\n return mod_nCr\nend\n\n-- larger n and small r\nlocal function make_mod_nCr_2(rmax, m)\n -- Create n! table\n local mfac = {}\n mfac[0] = 1\n for i=1,rmax do\n mfac[i] = mfac[i-1] * i % m\n end\n -- Create (n!)^(-1) table\n -- (n!)^(-1) ≡ (n!)^(m - 2) \n local invmfac = {}\n invmfac[rmax] = modpow(mfac[rmax], m - 2, m)\n for i=rmax,1,-1 do\n -- ((a-1)!)^(-1) ≡ a * (a!)^(-1) \n invmfac[i-1] = i * invmfac[i] % m\n end\n -- partial factory ()\n local pmfac\n -- returns nCr % m\n local function mod_nCr(n, r)\n if r > n then\n return 0\n end\n if r > n/2 then\n r = n - r\n end\n -- nCr ≡ (n * (n - 1) * ... * (n-r+1)) * (r!)^(-1) \n local a = 1\n for i=n, n-r+1, -1 do\n a = (a * i) % m\n end\n a = a * invmfac[r] % m\n return a\n end\n return mod_nCr\nend\n\n\n----\nlocal n, k = read.nn()\n\nlocal nCr = make_mod_nCr(n, MOD)\n\nlocal ans = 0\nfor i=0,math.min(n-1,k) do\n local empty_room_pattern = nCr(n, i)\n local nonempty_room_pattern = nCr(n-1, i)\n ans = (ans + (empty_room_pattern * nonempty_room_pattern % MOD)) % MOD\nend\n\nprint(ans)", "problem_context": "Score : 500 points\n\nProblem Statement\n\nThere is a building with n rooms, numbered 1 to n.\n\nWe can move from any room to any other room in the building.\n\nLet us call the following event a move: a person in some room i goes to another room j~ (i \\neq j).\n\nInitially, there was one person in each room in the building.\n\nAfter that, we know that there were exactly k moves happened up to now.\n\nWe are interested in the number of people in each of the n rooms now. How many combinations of numbers of people in the n rooms are possible?\n\nFind the count modulo (10^9 + 7).\n\nConstraints\n\nAll values in input are integers.\n\n3 \\leq n \\leq 2 \\times 10^5\n\n2 \\leq k \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nn k\n\nOutput\n\nPrint the number of possible combinations of numbers of people in the n rooms now, modulo (10^9 + 7).\n\nSample Input 1\n\n3 2\n\nSample Output 1\n\n10\n\nLet c_1, c_2, and c_3 be the number of people in Room 1, 2, and 3 now, respectively. There are 10 possible combination of (c_1, c_2, c_3):\n\n(0, 0, 3)\n\n(0, 1, 2)\n\n(0, 2, 1)\n\n(0, 3, 0)\n\n(1, 0, 2)\n\n(1, 1, 1)\n\n(1, 2, 0)\n\n(2, 0, 1)\n\n(2, 1, 0)\n\n(3, 0, 0)\n\nFor example, (c_1, c_2, c_3) will be (0, 1, 2) if the person in Room 1 goes to Room 2 and then one of the persons in Room 2 goes to Room 3.\n\nSample Input 2\n\n200000 1000000000\n\nSample Output 2\n\n607923868\n\nPrint the count modulo (10^9 + 7).\n\nSample Input 3\n\n15 6\n\nSample Output 3\n\n22583772", "sample_input": "3 2\n"}, "reference_outputs": ["10\n"], "source_document_id": "p02769", "source_text": "Score : 500 points\n\nProblem Statement\n\nThere is a building with n rooms, numbered 1 to n.\n\nWe can move from any room to any other room in the building.\n\nLet us call the following event a move: a person in some room i goes to another room j~ (i \\neq j).\n\nInitially, there was one person in each room in the building.\n\nAfter that, we know that there were exactly k moves happened up to now.\n\nWe are interested in the number of people in each of the n rooms now. How many combinations of numbers of people in the n rooms are possible?\n\nFind the count modulo (10^9 + 7).\n\nConstraints\n\nAll values in input are integers.\n\n3 \\leq n \\leq 2 \\times 10^5\n\n2 \\leq k \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nn k\n\nOutput\n\nPrint the number of possible combinations of numbers of people in the n rooms now, modulo (10^9 + 7).\n\nSample Input 1\n\n3 2\n\nSample Output 1\n\n10\n\nLet c_1, c_2, and c_3 be the number of people in Room 1, 2, and 3 now, respectively. There are 10 possible combination of (c_1, c_2, c_3):\n\n(0, 0, 3)\n\n(0, 1, 2)\n\n(0, 2, 1)\n\n(0, 3, 0)\n\n(1, 0, 2)\n\n(1, 1, 1)\n\n(1, 2, 0)\n\n(2, 0, 1)\n\n(2, 1, 0)\n\n(3, 0, 0)\n\nFor example, (c_1, c_2, c_3) will be (0, 1, 2) if the person in Room 1 goes to Room 2 and then one of the persons in Room 2 goes to Room 3.\n\nSample Input 2\n\n200000 1000000000\n\nSample Output 2\n\n607923868\n\nPrint the count modulo (10^9 + 7).\n\nSample Input 3\n\n15 6\n\nSample Output 3\n\n22583772", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 3146, "cpu_time_ms": 126, "memory_kb": 12648}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s936562501", "group_id": "codeNet:p02771", "input_text": "a, b, c = io.read(\"*n\", \"*n\", \"*n\")\nif a == b and a ~= c then\n print(\"Yes\")\nelseif a == c and a ~= b then\n print(\"Yes\")\nelseif b == c and a ~= b then\n print(\"Yes\")\nelse\n print(\"No\")\nend\n", "language": "Lua", "metadata": {"date": 1589887063, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p02771.html", "problem_id": "p02771", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02771/input.txt", "sample_output_relpath": "derived/input_output/data/p02771/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02771/Lua/s936562501.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s936562501", "user_id": "u120582723"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "a, b, c = io.read(\"*n\", \"*n\", \"*n\")\nif a == b and a ~= c then\n print(\"Yes\")\nelseif a == c and a ~= b then\n print(\"Yes\")\nelseif b == c and a ~= b then\n print(\"Yes\")\nelse\n print(\"No\")\nend\n", "problem_context": "Score: 100 points\n\nProblem Statement\n\nA triple of numbers is said to be poor when two of those numbers are equal but the other number is different from those two numbers.\n\nYou will be given three integers A, B, and C. If this triple is poor, print Yes; otherwise, print No.\n\nConstraints\n\nA, B, and C are all integers between 1 and 9 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C\n\nOutput\n\nIf the given triple is poor, print Yes; otherwise, print No.\n\nSample Input 1\n\n5 7 5\n\nSample Output 1\n\nYes\n\nA and C are equal, but B is different from those two numbers, so this triple is poor.\n\nSample Input 2\n\n4 4 4\n\nSample Output 2\n\nNo\n\nA, B, and C are all equal, so this triple is not poor.\n\nSample Input 3\n\n4 9 6\n\nSample Output 3\n\nNo\n\nSample Input 4\n\n3 3 4\n\nSample Output 4\n\nYes", "sample_input": "5 7 5\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p02771", "source_text": "Score: 100 points\n\nProblem Statement\n\nA triple of numbers is said to be poor when two of those numbers are equal but the other number is different from those two numbers.\n\nYou will be given three integers A, B, and C. If this triple is poor, print Yes; otherwise, print No.\n\nConstraints\n\nA, B, and C are all integers between 1 and 9 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C\n\nOutput\n\nIf the given triple is poor, print Yes; otherwise, print No.\n\nSample Input 1\n\n5 7 5\n\nSample Output 1\n\nYes\n\nA and C are equal, but B is different from those two numbers, so this triple is poor.\n\nSample Input 2\n\n4 4 4\n\nSample Output 2\n\nNo\n\nA, B, and C are all equal, so this triple is not poor.\n\nSample Input 3\n\n4 9 6\n\nSample Output 3\n\nNo\n\nSample Input 4\n\n3 3 4\n\nSample Output 4\n\nYes", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 190, "cpu_time_ms": 6, "memory_kb": 760}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s069678418", "group_id": "codeNet:p02772", "input_text": "n = io.read(\"*n\")\na = {}\nfor i = 1, n do\n a[i] = io.read(\"*n\")\nend\nv = true\nfor i = 1, n do\n if a[i] % 2 == 0 then\n if a[i] % 3 ~= 0 and a[i] % 5 ~= 0 then\n v = false break\n end\n end\nend\nprint(v and \"APPROVED\" or \"DENIED\")\n", "language": "Lua", "metadata": {"date": 1589887184, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p02772.html", "problem_id": "p02772", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02772/input.txt", "sample_output_relpath": "derived/input_output/data/p02772/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02772/Lua/s069678418.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s069678418", "user_id": "u120582723"}, "prompt_components": {"gold_output": "APPROVED\n", "input_to_evaluate": "n = io.read(\"*n\")\na = {}\nfor i = 1, n do\n a[i] = io.read(\"*n\")\nend\nv = true\nfor i = 1, n do\n if a[i] % 2 == 0 then\n if a[i] % 3 ~= 0 and a[i] % 5 ~= 0 then\n v = false break\n end\n end\nend\nprint(v and \"APPROVED\" or \"DENIED\")\n", "problem_context": "Score: 200 points\n\nProblem Statement\n\nYou are an immigration officer in the Kingdom of AtCoder. The document carried by an immigrant has some number of integers written on it, and you need to check whether they meet certain criteria.\n\nAccording to the regulation, the immigrant should be allowed entry to the kingdom if and only if the following condition is satisfied:\n\nAll even numbers written on the document are divisible by 3 or 5.\n\nIf the immigrant should be allowed entry according to the regulation, output APPROVED; otherwise, print DENIED.\n\nNotes\n\nThe condition in the statement can be rephrased as \"If x is an even number written on the document, x is divisible by 3 or 5\".\nHere \"if\" and \"or\" are logical terms.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 100\n\n1 \\leq A_i \\leq 1000\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 \\dots A_N\n\nOutput\n\nIf the immigrant should be allowed entry according to the regulation, print APPROVED; otherwise, print DENIED.\n\nSample Input 1\n\n5\n6 7 9 10 31\n\nSample Output 1\n\nAPPROVED\n\nThe even numbers written on the document are 6 and 10.\n\nAll of them are divisible by 3 or 5, so the immigrant should be allowed entry.\n\nSample Input 2\n\n3\n28 27 24\n\nSample Output 2\n\nDENIED\n\n28 violates the condition, so the immigrant should not be allowed entry.", "sample_input": "5\n6 7 9 10 31\n"}, "reference_outputs": ["APPROVED\n"], "source_document_id": "p02772", "source_text": "Score: 200 points\n\nProblem Statement\n\nYou are an immigration officer in the Kingdom of AtCoder. The document carried by an immigrant has some number of integers written on it, and you need to check whether they meet certain criteria.\n\nAccording to the regulation, the immigrant should be allowed entry to the kingdom if and only if the following condition is satisfied:\n\nAll even numbers written on the document are divisible by 3 or 5.\n\nIf the immigrant should be allowed entry according to the regulation, output APPROVED; otherwise, print DENIED.\n\nNotes\n\nThe condition in the statement can be rephrased as \"If x is an even number written on the document, x is divisible by 3 or 5\".\nHere \"if\" and \"or\" are logical terms.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 100\n\n1 \\leq A_i \\leq 1000\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 \\dots A_N\n\nOutput\n\nIf the immigrant should be allowed entry according to the regulation, print APPROVED; otherwise, print DENIED.\n\nSample Input 1\n\n5\n6 7 9 10 31\n\nSample Output 1\n\nAPPROVED\n\nThe even numbers written on the document are 6 and 10.\n\nAll of them are divisible by 3 or 5, so the immigrant should be allowed entry.\n\nSample Input 2\n\n3\n28 27 24\n\nSample Output 2\n\nDENIED\n\n28 violates the condition, so the immigrant should not be allowed entry.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 237, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s238702648", "group_id": "codeNet:p02773", "input_text": "n=io.read(\"*n\",\"*l\")\nt={}\nfrequency=0\nfor i=1,n do\n s=io.read()\n if not t[s] then\n t[s]=1\n else\n t[s]=t[s]+1\n end\n frequency=math.max(frequency,t[s])\nend\ntable.sort(t)\nfor k,v in pairs(t) do\n if t[k]==frequency then\n print(k)\n end\nend", "language": "Lua", "metadata": {"date": 1587319117, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p02773.html", "problem_id": "p02773", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02773/input.txt", "sample_output_relpath": "derived/input_output/data/p02773/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02773/Lua/s238702648.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s238702648", "user_id": "u045238009"}, "prompt_components": {"gold_output": "beet\nvet\n", "input_to_evaluate": "n=io.read(\"*n\",\"*l\")\nt={}\nfrequency=0\nfor i=1,n do\n s=io.read()\n if not t[s] then\n t[s]=1\n else\n t[s]=t[s]+1\n end\n frequency=math.max(frequency,t[s])\nend\ntable.sort(t)\nfor k,v in pairs(t) do\n if t[k]==frequency then\n print(k)\n end\nend", "problem_context": "Score: 300 points\n\nProblem Statement\n\nWe have N voting papers. The i-th vote (1 \\leq i \\leq N) has the string S_i written on it.\n\nPrint all strings that are written on the most number of votes, in lexicographical order.\n\nConstraints\n\n1 \\leq N \\leq 2 \\times 10^5\n\nS_i (1 \\leq i \\leq N) are strings consisting of lowercase English letters.\n\nThe length of S_i (1 \\leq i \\leq N) is between 1 and 10 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS_1\n:\nS_N\n\nOutput\n\nPrint all strings in question in lexicographical order.\n\nSample Input 1\n\n7\nbeat\nvet\nbeet\nbed\nvet\nbet\nbeet\n\nSample Output 1\n\nbeet\nvet\n\nbeet and vet are written on two sheets each, while beat, bed, and bet are written on one vote each. Thus, we should print the strings beet and vet.\n\nSample Input 2\n\n8\nbuffalo\nbuffalo\nbuffalo\nbuffalo\nbuffalo\nbuffalo\nbuffalo\nbuffalo\n\nSample Output 2\n\nbuffalo\n\nSample Input 3\n\n7\nbass\nbass\nkick\nkick\nbass\nkick\nkick\n\nSample Output 3\n\nkick\n\nSample Input 4\n\n4\nushi\ntapu\nnichia\nkun\n\nSample Output 4\n\nkun\nnichia\ntapu\nushi", "sample_input": "7\nbeat\nvet\nbeet\nbed\nvet\nbet\nbeet\n"}, "reference_outputs": ["beet\nvet\n"], "source_document_id": "p02773", "source_text": "Score: 300 points\n\nProblem Statement\n\nWe have N voting papers. The i-th vote (1 \\leq i \\leq N) has the string S_i written on it.\n\nPrint all strings that are written on the most number of votes, in lexicographical order.\n\nConstraints\n\n1 \\leq N \\leq 2 \\times 10^5\n\nS_i (1 \\leq i \\leq N) are strings consisting of lowercase English letters.\n\nThe length of S_i (1 \\leq i \\leq N) is between 1 and 10 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS_1\n:\nS_N\n\nOutput\n\nPrint all strings in question in lexicographical order.\n\nSample Input 1\n\n7\nbeat\nvet\nbeet\nbed\nvet\nbet\nbeet\n\nSample Output 1\n\nbeet\nvet\n\nbeet and vet are written on two sheets each, while beat, bed, and bet are written on one vote each. Thus, we should print the strings beet and vet.\n\nSample Input 2\n\n8\nbuffalo\nbuffalo\nbuffalo\nbuffalo\nbuffalo\nbuffalo\nbuffalo\nbuffalo\n\nSample Output 2\n\nbuffalo\n\nSample Input 3\n\n7\nbass\nbass\nkick\nkick\nbass\nkick\nkick\n\nSample Output 3\n\nkick\n\nSample Input 4\n\n4\nushi\ntapu\nnichia\nkun\n\nSample Output 4\n\nkun\nnichia\ntapu\nushi", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 276, "cpu_time_ms": 584, "memory_kb": 21860}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s961847112", "group_id": "codeNet:p02775", "input_text": "local mmi = math.min\nlocal sn = io.read()\nlocal n = #sn\nlocal t = {}\nfor i = 1, n do\n t[i] = tonumber(sn:sub(i, i))\nend\nlocal p1, p2 = 1, 0\nfor i = 1, n do\n local np1 = 1000000007\n if i ~= n and 0 < t[i + 1] then\n np1 = mmi(p1 + 9 - t[i], p2 + t[i] + 1)\n end\n local np2 = mmi(p1 + 10 - t[i], p2 + t[i])\n p1, p2 = np1, np2\nend\nprint(mmi(p1, p2))\n", "language": "Lua", "metadata": {"date": 1581928044, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p02775.html", "problem_id": "p02775", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02775/input.txt", "sample_output_relpath": "derived/input_output/data/p02775/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02775/Lua/s961847112.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s961847112", "user_id": "u120582723"}, "prompt_components": {"gold_output": "8\n", "input_to_evaluate": "local mmi = math.min\nlocal sn = io.read()\nlocal n = #sn\nlocal t = {}\nfor i = 1, n do\n t[i] = tonumber(sn:sub(i, i))\nend\nlocal p1, p2 = 1, 0\nfor i = 1, n do\n local np1 = 1000000007\n if i ~= n and 0 < t[i + 1] then\n np1 = mmi(p1 + 9 - t[i], p2 + t[i] + 1)\n end\n local np2 = mmi(p1 + 10 - t[i], p2 + t[i])\n p1, p2 = np1, np2\nend\nprint(mmi(p1, p2))\n", "problem_context": "Score: 500 points\n\nProblem Statement\n\nIn the Kingdom of AtCoder, only banknotes are used as currency. There are 10^{100}+1 kinds of banknotes, with the values of 1, 10, 10^2, 10^3, \\dots, 10^{(10^{100})}. You have come shopping at a mall and are now buying a takoyaki machine with a value of N. (Takoyaki is the name of a Japanese snack.)\n\nTo make the payment, you will choose some amount of money which is at least N and give it to the clerk. Then, the clerk gives you back the change, which is the amount of money you give minus N.\n\nWhat will be the minimum possible number of total banknotes used by you and the clerk, when both choose the combination of banknotes to minimize this count?\n\nAssume that you have sufficient numbers of banknotes, and so does the clerk.\n\nConstraints\n\nN is an integer between 1 and 10^{1,000,000} (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the minimum possible number of total banknotes used by you and the clerk.\n\nSample Input 1\n\n36\n\nSample Output 1\n\n8\n\nIf you give four banknotes of value 10 each, and the clerk gives you back four banknotes of value 1 each, a total of eight banknotes are used.\n\nThe payment cannot be made with less than eight banknotes in total, so the answer is 8.\n\nSample Input 2\n\n91\n\nSample Output 2\n\n3\n\nIf you give two banknotes of value 100, 1, and the clerk gives you back one banknote of value 10, a total of three banknotes are used.\n\nSample Input 3\n\n314159265358979323846264338327950288419716939937551058209749445923078164062862089986280348253421170\n\nSample Output 3\n\n243", "sample_input": "36\n"}, "reference_outputs": ["8\n"], "source_document_id": "p02775", "source_text": "Score: 500 points\n\nProblem Statement\n\nIn the Kingdom of AtCoder, only banknotes are used as currency. There are 10^{100}+1 kinds of banknotes, with the values of 1, 10, 10^2, 10^3, \\dots, 10^{(10^{100})}. You have come shopping at a mall and are now buying a takoyaki machine with a value of N. (Takoyaki is the name of a Japanese snack.)\n\nTo make the payment, you will choose some amount of money which is at least N and give it to the clerk. Then, the clerk gives you back the change, which is the amount of money you give minus N.\n\nWhat will be the minimum possible number of total banknotes used by you and the clerk, when both choose the combination of banknotes to minimize this count?\n\nAssume that you have sufficient numbers of banknotes, and so does the clerk.\n\nConstraints\n\nN is an integer between 1 and 10^{1,000,000} (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the minimum possible number of total banknotes used by you and the clerk.\n\nSample Input 1\n\n36\n\nSample Output 1\n\n8\n\nIf you give four banknotes of value 10 each, and the clerk gives you back four banknotes of value 1 each, a total of eight banknotes are used.\n\nThe payment cannot be made with less than eight banknotes in total, so the answer is 8.\n\nSample Input 2\n\n91\n\nSample Output 2\n\n3\n\nIf you give two banknotes of value 100, 1, and the clerk gives you back one banknote of value 10, a total of three banknotes are used.\n\nSample Input 3\n\n314159265358979323846264338327950288419716939937551058209749445923078164062862089986280348253421170\n\nSample Output 3\n\n243", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 354, "cpu_time_ms": 467, "memory_kb": 18724}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s440701767", "group_id": "codeNet:p02777", "input_text": "S=io.read()\nS,T=S:match(\"(%a+)%s+(%a+)\")\nA,B=io.read(\"*n\",\"*n\")\nio.read()\nU=io.read()\nA={[S]=A,[T]=B}\nA[U]=A[U]-1\nprint(A[S],A[T])", "language": "Lua", "metadata": {"date": 1587306833, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p02777.html", "problem_id": "p02777", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02777/input.txt", "sample_output_relpath": "derived/input_output/data/p02777/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02777/Lua/s440701767.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s440701767", "user_id": "u726173718"}, "prompt_components": {"gold_output": "2 4\n", "input_to_evaluate": "S=io.read()\nS,T=S:match(\"(%a+)%s+(%a+)\")\nA,B=io.read(\"*n\",\"*n\")\nio.read()\nU=io.read()\nA={[S]=A,[T]=B}\nA[U]=A[U]-1\nprint(A[S],A[T])", "problem_context": "Score : 100 points\n\nProblem Statement\n\nWe have A balls with the string S written on each of them and B balls with the string T written on each of them.\n\nFrom these balls, Takahashi chooses one with the string U written on it and throws it away.\n\nFind the number of balls with the string S and balls with the string T that we have now.\n\nConstraints\n\nS, T, and U are strings consisting of lowercase English letters.\n\nThe lengths of S and T are each between 1 and 10 (inclusive).\n\nS \\not= T\n\nS=U or T=U.\n\n1 \\leq A,B \\leq 10\n\nA and B are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS T\nA B\nU\n\nOutput\n\nPrint the answer, with space in between.\n\nSample Input 1\n\nred blue\n3 4\nred\n\nSample Output 1\n\n2 4\n\nTakahashi chose a ball with red written on it and threw it away.\nNow we have two balls with the string S and four balls with the string T.\n\nSample Input 2\n\nred blue\n5 5\nblue\n\nSample Output 2\n\n5 4\n\nTakahashi chose a ball with blue written on it and threw it away.\nNow we have five balls with the string S and four balls with the string T.", "sample_input": "red blue\n3 4\nred\n"}, "reference_outputs": ["2 4\n"], "source_document_id": "p02777", "source_text": "Score : 100 points\n\nProblem Statement\n\nWe have A balls with the string S written on each of them and B balls with the string T written on each of them.\n\nFrom these balls, Takahashi chooses one with the string U written on it and throws it away.\n\nFind the number of balls with the string S and balls with the string T that we have now.\n\nConstraints\n\nS, T, and U are strings consisting of lowercase English letters.\n\nThe lengths of S and T are each between 1 and 10 (inclusive).\n\nS \\not= T\n\nS=U or T=U.\n\n1 \\leq A,B \\leq 10\n\nA and B are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS T\nA B\nU\n\nOutput\n\nPrint the answer, with space in between.\n\nSample Input 1\n\nred blue\n3 4\nred\n\nSample Output 1\n\n2 4\n\nTakahashi chose a ball with red written on it and threw it away.\nNow we have two balls with the string S and four balls with the string T.\n\nSample Input 2\n\nred blue\n5 5\nblue\n\nSample Output 2\n\n5 4\n\nTakahashi chose a ball with blue written on it and threw it away.\nNow we have five balls with the string S and four balls with the string T.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 130, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s019163354", "group_id": "codeNet:p02778", "input_text": "print((\"x\"):rep(#io.read()))", "language": "Lua", "metadata": {"date": 1587306940, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p02778.html", "problem_id": "p02778", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02778/input.txt", "sample_output_relpath": "derived/input_output/data/p02778/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02778/Lua/s019163354.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s019163354", "user_id": "u726173718"}, "prompt_components": {"gold_output": "xxxxxxx\n", "input_to_evaluate": "print((\"x\"):rep(#io.read()))", "problem_context": "Score : 200 points\n\nProblem Statement\n\nGiven is a string S. Replace every character in S with x and print the result.\n\nConstraints\n\nS is a string consisting of lowercase English letters.\n\nThe length of S is between 1 and 100 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nReplace every character in S with x and print the result.\n\nSample Input 1\n\nsardine\n\nSample Output 1\n\nxxxxxxx\n\nReplacing every character in S with x results in xxxxxxx.\n\nSample Input 2\n\nxxxx\n\nSample Output 2\n\nxxxx\n\nSample Input 3\n\ngone\n\nSample Output 3\n\nxxxx", "sample_input": "sardine\n"}, "reference_outputs": ["xxxxxxx\n"], "source_document_id": "p02778", "source_text": "Score : 200 points\n\nProblem Statement\n\nGiven is a string S. Replace every character in S with x and print the result.\n\nConstraints\n\nS is a string consisting of lowercase English letters.\n\nThe length of S is between 1 and 100 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nReplace every character in S with x and print the result.\n\nSample Input 1\n\nsardine\n\nSample Output 1\n\nxxxxxxx\n\nReplacing every character in S with x results in xxxxxxx.\n\nSample Input 2\n\nxxxx\n\nSample Output 2\n\nxxxx\n\nSample Input 3\n\ngone\n\nSample Output 3\n\nxxxx", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 28, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s047562453", "group_id": "codeNet:p02779", "input_text": "local read = setmetatable({}, {__index = function(t, k) local a = {} for i=1,#k do table.insert(a, '*'..string.sub(k, i, i)) end local r = io.read local u = table.unpack or unpack return function() return r(u(a)) end end})\nread.N = function(N) local t={} for i=1,N do t[i]=read.n() end return t end\nstring.totable = function(s) local t={} local u=string.sub for i=1,#s do t[i] = u(s, i, i) end return t end\nstring.split = function(s) local t={} for w in string.gmatch(s, \"[^%s]+\") do table.insert(t, w) end return (table.unpack or unpack)(t) end\n----\n-- C\nlocal N = read.n()\nlocal T = {}\nlocal ans = \"YES\"\nfor i=1,N do\n local A = read.n()\n T[A] = (T[A] or 0) + 1\n if T[A] == 2 then\n ans = \"NO\"\n end\nend\nprint(ans)", "language": "Lua", "metadata": {"date": 1581278764, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p02779.html", "problem_id": "p02779", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02779/input.txt", "sample_output_relpath": "derived/input_output/data/p02779/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02779/Lua/s047562453.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s047562453", "user_id": "u162773977"}, "prompt_components": {"gold_output": "YES\n", "input_to_evaluate": "local read = setmetatable({}, {__index = function(t, k) local a = {} for i=1,#k do table.insert(a, '*'..string.sub(k, i, i)) end local r = io.read local u = table.unpack or unpack return function() return r(u(a)) end end})\nread.N = function(N) local t={} for i=1,N do t[i]=read.n() end return t end\nstring.totable = function(s) local t={} local u=string.sub for i=1,#s do t[i] = u(s, i, i) end return t end\nstring.split = function(s) local t={} for w in string.gmatch(s, \"[^%s]+\") do table.insert(t, w) end return (table.unpack or unpack)(t) end\n----\n-- C\nlocal N = read.n()\nlocal T = {}\nlocal ans = \"YES\"\nfor i=1,N do\n local A = read.n()\n T[A] = (T[A] or 0) + 1\n if T[A] == 2 then\n ans = \"NO\"\n end\nend\nprint(ans)", "problem_context": "Score : 300 points\n\nProblem Statement\n\nGiven is a sequence of integers A_1, A_2, ..., A_N.\nIf its elements are pairwise distinct, print YES; otherwise, print NO.\n\nConstraints\n\n2 ≤ N ≤ 200000\n\n1 ≤ A_i ≤ 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 ... A_N\n\nOutput\n\nIf the elements of the sequence are pairwise distinct, print YES; otherwise, print NO.\n\nSample Input 1\n\n5\n2 6 1 4 5\n\nSample Output 1\n\nYES\n\nThe elements are pairwise distinct.\n\nSample Input 2\n\n6\n4 1 3 1 6 2\n\nSample Output 2\n\nNO\n\nThe second and fourth elements are identical.\n\nSample Input 3\n\n2\n10000000 10000000\n\nSample Output 3\n\nNO", "sample_input": "5\n2 6 1 4 5\n"}, "reference_outputs": ["YES\n"], "source_document_id": "p02779", "source_text": "Score : 300 points\n\nProblem Statement\n\nGiven is a sequence of integers A_1, A_2, ..., A_N.\nIf its elements are pairwise distinct, print YES; otherwise, print NO.\n\nConstraints\n\n2 ≤ N ≤ 200000\n\n1 ≤ A_i ≤ 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 ... A_N\n\nOutput\n\nIf the elements of the sequence are pairwise distinct, print YES; otherwise, print NO.\n\nSample Input 1\n\n5\n2 6 1 4 5\n\nSample Output 1\n\nYES\n\nThe elements are pairwise distinct.\n\nSample Input 2\n\n6\n4 1 3 1 6 2\n\nSample Output 2\n\nNO\n\nThe second and fourth elements are identical.\n\nSample Input 3\n\n2\n10000000 10000000\n\nSample Output 3\n\nNO", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 732, "cpu_time_ms": 358, "memory_kb": 29408}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s457455894", "group_id": "codeNet:p02780", "input_text": "local n, k = io.read(\"*n\", \"*n\")\nlocal t = {}\nfor i = 1, n do\n t[i] = io.read(\"*n\")\nend\nlocal sum = 0\nfor i = 1, k do\n sum = sum + t[i]\nend\nlocal ret = sum\nfor i = k + 1, n do\n sum = sum + t[i] - t[i - k]\n ret = math.max(ret, sum)\nend\nprint((ret + k) / 2)\n", "language": "Lua", "metadata": {"date": 1581321643, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p02780.html", "problem_id": "p02780", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02780/input.txt", "sample_output_relpath": "derived/input_output/data/p02780/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02780/Lua/s457455894.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s457455894", "user_id": "u120582723"}, "prompt_components": {"gold_output": "7.000000000000\n", "input_to_evaluate": "local n, k = io.read(\"*n\", \"*n\")\nlocal t = {}\nfor i = 1, n do\n t[i] = io.read(\"*n\")\nend\nlocal sum = 0\nfor i = 1, k do\n sum = sum + t[i]\nend\nlocal ret = sum\nfor i = k + 1, n do\n sum = sum + t[i] - t[i - k]\n ret = math.max(ret, sum)\nend\nprint((ret + k) / 2)\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nWe have N dice arranged in a line from left to right. The i-th die from the left shows p_i numbers from 1 to p_i with equal probability when thrown.\n\nWe will choose K adjacent dice, throw each of them independently, and compute the sum of the numbers shown. Find the maximum possible value of the expected value of this sum.\n\nConstraints\n\n1 ≤ K ≤ N ≤ 200000\n\n1 ≤ p_i ≤ 1000\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\np_1 ... p_N\n\nOutput\n\nPrint the maximum possible value of the expected value of the sum of the numbers shown.\n\nYour output will be considered correct when its absolute or relative error from our answer is at most 10^{-6}.\n\nSample Input 1\n\n5 3\n1 2 2 4 5\n\nSample Output 1\n\n7.000000000000\n\nWhen we throw the third, fourth, and fifth dice from the left, the expected value of the sum of the numbers shown is 7. This is the maximum value we can achieve.\n\nSample Input 2\n\n4 1\n6 6 6 6\n\nSample Output 2\n\n3.500000000000\n\nRegardless of which die we choose, the expected value of the number shown is 3.5.\n\nSample Input 3\n\n10 4\n17 13 13 12 15 20 10 13 17 11\n\nSample Output 3\n\n32.000000000000", "sample_input": "5 3\n1 2 2 4 5\n"}, "reference_outputs": ["7.000000000000\n"], "source_document_id": "p02780", "source_text": "Score : 400 points\n\nProblem Statement\n\nWe have N dice arranged in a line from left to right. The i-th die from the left shows p_i numbers from 1 to p_i with equal probability when thrown.\n\nWe will choose K adjacent dice, throw each of them independently, and compute the sum of the numbers shown. Find the maximum possible value of the expected value of this sum.\n\nConstraints\n\n1 ≤ K ≤ N ≤ 200000\n\n1 ≤ p_i ≤ 1000\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\np_1 ... p_N\n\nOutput\n\nPrint the maximum possible value of the expected value of the sum of the numbers shown.\n\nYour output will be considered correct when its absolute or relative error from our answer is at most 10^{-6}.\n\nSample Input 1\n\n5 3\n1 2 2 4 5\n\nSample Output 1\n\n7.000000000000\n\nWhen we throw the third, fourth, and fifth dice from the left, the expected value of the sum of the numbers shown is 7. This is the maximum value we can achieve.\n\nSample Input 2\n\n4 1\n6 6 6 6\n\nSample Output 2\n\n3.500000000000\n\nRegardless of which die we choose, the expected value of the number shown is 3.5.\n\nSample Input 3\n\n10 4\n17 13 13 12 15 20 10 13 17 11\n\nSample Output 3\n\n32.000000000000", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 260, "cpu_time_ms": 73, "memory_kb": 4472}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s065097879", "group_id": "codeNet:p02781", "input_text": "local mfl = math.floor\nlocal ns = io.read()\nlocal k = io.read(\"*n\")\nif k == 1 then\n local a = tonumber(ns:sub(1, 1))\n print(a + 9 * (#ns - 1))\nelseif k == 2 then\n if #ns == 1 or ns == \"10\" then print(0)\n else\n local a = tonumber(ns:sub(1, 1))\n local b, bpos = 0, #ns + 1\n for i = 2, #ns do\n if ns:sub(i, i) ~= \"0\" then\n b, bpos = tonumber(ns:sub(i, i)), i\n break\n end\n end\n -- use 1st but not max\n local ret = (#ns - 1) * 9 * (a - 1)\n -- don't use 1st\n ret = ret + 81 * mfl((#ns - 1) * (#ns - 2) / 2)\n -- use 1st by max\n if bpos <= #ns then\n ret = ret + b + 9 * (#ns - bpos)\n end\n print(ret)\n end\nelse\n if #ns < 3 then print(0)\n else\n local a = tonumber(ns:sub(1, 1))\n local b, bpos = 0, #ns + 1\n for i = 2, #ns do\n if ns:sub(i, i) ~= \"0\" then\n b, bpos = tonumber(ns:sub(i, i)), i\n break\n end\n end\n local c, cpos = 0, #ns + 1\n for i = bpos + 1, #ns do\n if ns:sub(i, i) ~= \"0\" then\n c, cpos = tonumber(ns:sub(i, i)), i\n break\n end\n end\n -- don't use 1st\n ret = 729 * mfl((#ns - 1) * (#ns - 2) * (#ns - 3) / 6)\n -- use 1st but not max\n ret = ret + (a - 1) * 81 * mfl((#ns - 1) * (#ns - 2) / 2)\n -- use 1st by max\n if bpos <= #ns - 1 then\n -- don't use second\n ret = ret + 81 * mfl((#ns - bpos) * (#ns - bpos - 1) / 2)\n -- use 2nd but not max\n ret = ret + (b - 1) * 9 * (#ns - bpos)\n -- use 2nd by max\n if cpos <= #ns then\n ret = ret + c + 9 * (#ns - cpos)\n end\n end\n print(ret)\n end\nend\n", "language": "Lua", "metadata": {"date": 1581854767, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p02781.html", "problem_id": "p02781", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02781/input.txt", "sample_output_relpath": "derived/input_output/data/p02781/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02781/Lua/s065097879.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s065097879", "user_id": "u120582723"}, "prompt_components": {"gold_output": "19\n", "input_to_evaluate": "local mfl = math.floor\nlocal ns = io.read()\nlocal k = io.read(\"*n\")\nif k == 1 then\n local a = tonumber(ns:sub(1, 1))\n print(a + 9 * (#ns - 1))\nelseif k == 2 then\n if #ns == 1 or ns == \"10\" then print(0)\n else\n local a = tonumber(ns:sub(1, 1))\n local b, bpos = 0, #ns + 1\n for i = 2, #ns do\n if ns:sub(i, i) ~= \"0\" then\n b, bpos = tonumber(ns:sub(i, i)), i\n break\n end\n end\n -- use 1st but not max\n local ret = (#ns - 1) * 9 * (a - 1)\n -- don't use 1st\n ret = ret + 81 * mfl((#ns - 1) * (#ns - 2) / 2)\n -- use 1st by max\n if bpos <= #ns then\n ret = ret + b + 9 * (#ns - bpos)\n end\n print(ret)\n end\nelse\n if #ns < 3 then print(0)\n else\n local a = tonumber(ns:sub(1, 1))\n local b, bpos = 0, #ns + 1\n for i = 2, #ns do\n if ns:sub(i, i) ~= \"0\" then\n b, bpos = tonumber(ns:sub(i, i)), i\n break\n end\n end\n local c, cpos = 0, #ns + 1\n for i = bpos + 1, #ns do\n if ns:sub(i, i) ~= \"0\" then\n c, cpos = tonumber(ns:sub(i, i)), i\n break\n end\n end\n -- don't use 1st\n ret = 729 * mfl((#ns - 1) * (#ns - 2) * (#ns - 3) / 6)\n -- use 1st but not max\n ret = ret + (a - 1) * 81 * mfl((#ns - 1) * (#ns - 2) / 2)\n -- use 1st by max\n if bpos <= #ns - 1 then\n -- don't use second\n ret = ret + 81 * mfl((#ns - bpos) * (#ns - bpos - 1) / 2)\n -- use 2nd but not max\n ret = ret + (b - 1) * 9 * (#ns - bpos)\n -- use 2nd by max\n if cpos <= #ns then\n ret = ret + c + 9 * (#ns - cpos)\n end\n end\n print(ret)\n end\nend\n", "problem_context": "Score : 500 points\n\nProblem Statement\n\nFind the number of integers between 1 and N (inclusive) that contains exactly K non-zero digits when written in base ten.\n\nConstraints\n\n1 \\leq N < 10^{100}\n\n1 \\leq K \\leq 3\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nK\n\nOutput\n\nPrint the count.\n\nSample Input 1\n\n100\n1\n\nSample Output 1\n\n19\n\nThe following 19 integers satisfy the condition:\n\n1,2,3,4,5,6,7,8,9,10,20,30,40,50,60,70,80,90,100\n\nSample Input 2\n\n25\n2\n\nSample Output 2\n\n14\n\nThe following 14 integers satisfy the condition:\n\n11,12,13,14,15,16,17,18,19,21,22,23,24,25\n\nSample Input 3\n\n314159\n2\n\nSample Output 3\n\n937\n\nSample Input 4\n\n9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999\n3\n\nSample Output 4\n\n117879300", "sample_input": "100\n1\n"}, "reference_outputs": ["19\n"], "source_document_id": "p02781", "source_text": "Score : 500 points\n\nProblem Statement\n\nFind the number of integers between 1 and N (inclusive) that contains exactly K non-zero digits when written in base ten.\n\nConstraints\n\n1 \\leq N < 10^{100}\n\n1 \\leq K \\leq 3\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nK\n\nOutput\n\nPrint the count.\n\nSample Input 1\n\n100\n1\n\nSample Output 1\n\n19\n\nThe following 19 integers satisfy the condition:\n\n1,2,3,4,5,6,7,8,9,10,20,30,40,50,60,70,80,90,100\n\nSample Input 2\n\n25\n2\n\nSample Output 2\n\n14\n\nThe following 14 integers satisfy the condition:\n\n11,12,13,14,15,16,17,18,19,21,22,23,24,25\n\nSample Input 3\n\n314159\n2\n\nSample Output 3\n\n937\n\nSample Input 4\n\n9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999\n3\n\nSample Output 4\n\n117879300", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1593, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s111650797", "group_id": "codeNet:p02781", "input_text": "local read = setmetatable({}, {__index = function(t, k) local a = {} for i=1,#k do table.insert(a, '*'..string.sub(k, i, i)) end local r = io.read local u = table.unpack or unpack return function() return r(u(a)) end end})\nread.T = function(T) local t={} for i=1,T do t[i]=read.n() end return t end\nstring.totable = function(s) local t={} local u=string.sub for i=1,#s do t[i] = u(s, i, i) end return t end\nstring.split = function(s) local t={} for w in string.gmatch(s, \"[^%s]+\") do table.insert(t, w) end return (table.unpack or unpack)(t) end\n----\nlocal function factorial(n)\n local a = 1\n for i=1, n do\n a = a * i\n end\n return a\nend\n\nlocal function nCr(n, r)\n if r > n then\n return 0\n end\n if r > n/2 then\n r = n - r\n end\n local a = 1\n for i=n, n-r+1, -1 do\n a = a * i\n end\n return a // factorial(r)\nend\n\nlocal function normal(d, k)\n return nCr(d, k) * math.floor(9^k)\nend\n-- E\nlocal S = read.l():totable()\nlocal T = {}\nfor i=1,#S do\n T[i] = tonumber(S[i])\nend\nlocal D = #T\nlocal K = read.n()\n\nlocal function rec(x, remain)\n if remain == 0 then\n return 1\n end\n for i=x, D do\n if T[i] ~= 0 then\n local ans1 = normal(D-i, remain)\n local ans2 = (T[i] - 1) * normal(D-i, remain-1)\n local ans3 = 1 * rec(i+1, remain-1)\n return ans1+ans2+ans3\n end\n end\n return 0\nend\n\nlocal ans = rec(1, K)\nprint(ans)", "language": "Lua", "metadata": {"date": 1581369774, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p02781.html", "problem_id": "p02781", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02781/input.txt", "sample_output_relpath": "derived/input_output/data/p02781/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02781/Lua/s111650797.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s111650797", "user_id": "u162773977"}, "prompt_components": {"gold_output": "19\n", "input_to_evaluate": "local read = setmetatable({}, {__index = function(t, k) local a = {} for i=1,#k do table.insert(a, '*'..string.sub(k, i, i)) end local r = io.read local u = table.unpack or unpack return function() return r(u(a)) end end})\nread.T = function(T) local t={} for i=1,T do t[i]=read.n() end return t end\nstring.totable = function(s) local t={} local u=string.sub for i=1,#s do t[i] = u(s, i, i) end return t end\nstring.split = function(s) local t={} for w in string.gmatch(s, \"[^%s]+\") do table.insert(t, w) end return (table.unpack or unpack)(t) end\n----\nlocal function factorial(n)\n local a = 1\n for i=1, n do\n a = a * i\n end\n return a\nend\n\nlocal function nCr(n, r)\n if r > n then\n return 0\n end\n if r > n/2 then\n r = n - r\n end\n local a = 1\n for i=n, n-r+1, -1 do\n a = a * i\n end\n return a // factorial(r)\nend\n\nlocal function normal(d, k)\n return nCr(d, k) * math.floor(9^k)\nend\n-- E\nlocal S = read.l():totable()\nlocal T = {}\nfor i=1,#S do\n T[i] = tonumber(S[i])\nend\nlocal D = #T\nlocal K = read.n()\n\nlocal function rec(x, remain)\n if remain == 0 then\n return 1\n end\n for i=x, D do\n if T[i] ~= 0 then\n local ans1 = normal(D-i, remain)\n local ans2 = (T[i] - 1) * normal(D-i, remain-1)\n local ans3 = 1 * rec(i+1, remain-1)\n return ans1+ans2+ans3\n end\n end\n return 0\nend\n\nlocal ans = rec(1, K)\nprint(ans)", "problem_context": "Score : 500 points\n\nProblem Statement\n\nFind the number of integers between 1 and N (inclusive) that contains exactly K non-zero digits when written in base ten.\n\nConstraints\n\n1 \\leq N < 10^{100}\n\n1 \\leq K \\leq 3\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nK\n\nOutput\n\nPrint the count.\n\nSample Input 1\n\n100\n1\n\nSample Output 1\n\n19\n\nThe following 19 integers satisfy the condition:\n\n1,2,3,4,5,6,7,8,9,10,20,30,40,50,60,70,80,90,100\n\nSample Input 2\n\n25\n2\n\nSample Output 2\n\n14\n\nThe following 14 integers satisfy the condition:\n\n11,12,13,14,15,16,17,18,19,21,22,23,24,25\n\nSample Input 3\n\n314159\n2\n\nSample Output 3\n\n937\n\nSample Input 4\n\n9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999\n3\n\nSample Output 4\n\n117879300", "sample_input": "100\n1\n"}, "reference_outputs": ["19\n"], "source_document_id": "p02781", "source_text": "Score : 500 points\n\nProblem Statement\n\nFind the number of integers between 1 and N (inclusive) that contains exactly K non-zero digits when written in base ten.\n\nConstraints\n\n1 \\leq N < 10^{100}\n\n1 \\leq K \\leq 3\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nK\n\nOutput\n\nPrint the count.\n\nSample Input 1\n\n100\n1\n\nSample Output 1\n\n19\n\nThe following 19 integers satisfy the condition:\n\n1,2,3,4,5,6,7,8,9,10,20,30,40,50,60,70,80,90,100\n\nSample Input 2\n\n25\n2\n\nSample Output 2\n\n14\n\nThe following 14 integers satisfy the condition:\n\n11,12,13,14,15,16,17,18,19,21,22,23,24,25\n\nSample Input 3\n\n314159\n2\n\nSample Output 3\n\n937\n\nSample Input 4\n\n9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999\n3\n\nSample Output 4\n\n117879300", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1448, "cpu_time_ms": 8, "memory_kb": 760}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s468498989", "group_id": "codeNet:p02782", "input_text": "local mod = 1000000007\nlocal mfl = math.floor\n\nlocal function bmul(x, y)\n local x0, y0 = x % 31623, y % 31623\n local x1, y1 = mfl(x / 31623), mfl(y / 31623)\n return (x1 * y1 * 14122 + (x1 * y0 + x0 * y1) * 31623 + x0 * y0) % mod\nend\n\nlocal function badd(x, y)\n return (x + y) % mod\nend\n\nlocal function bsub(x, y)\n return x < y and x - y + mod or x - y\nend\nlocal function modpow(src, pow)\n local res = 1\n while 0 < pow do\n if pow % 2 == 1 then\n res = bmul(res, src)\n pow = pow - 1\n end\n src = bmul(src, src)\n pow = mfl(pow / 2)\n end\n return res\nend\n\nlocal function modinv(src)\n return modpow(src, mod - 2)\nend\n\nlocal r1, c1 = io.read(\"*n\", \"*n\")\nlocal r2, c2 = io.read(\"*n\", \"*n\")\n\nlocal function getSum(r, c)\n local sum = 0\n local cur = 1\n for ir = 0, r do\n cur = bmul(cur, ir + c + 1)\n cur = bmul(cur, modinv(ir + 1))\n sum = badd(sum, cur)\n end\n return sum\nend\nlocal z = getSum(r2, c2)\nz = bsub(z, getSum(r2, c1 - 1))\nz = bsub(z, getSum(r1 - 1, c2))\nz = badd(z, getSum(r1 - 1, c1 - 1))\nprint(z)\n", "language": "Lua", "metadata": {"date": 1581809291, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p02782.html", "problem_id": "p02782", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02782/input.txt", "sample_output_relpath": "derived/input_output/data/p02782/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02782/Lua/s468498989.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s468498989", "user_id": "u120582723"}, "prompt_components": {"gold_output": "14\n", "input_to_evaluate": "local mod = 1000000007\nlocal mfl = math.floor\n\nlocal function bmul(x, y)\n local x0, y0 = x % 31623, y % 31623\n local x1, y1 = mfl(x / 31623), mfl(y / 31623)\n return (x1 * y1 * 14122 + (x1 * y0 + x0 * y1) * 31623 + x0 * y0) % mod\nend\n\nlocal function badd(x, y)\n return (x + y) % mod\nend\n\nlocal function bsub(x, y)\n return x < y and x - y + mod or x - y\nend\nlocal function modpow(src, pow)\n local res = 1\n while 0 < pow do\n if pow % 2 == 1 then\n res = bmul(res, src)\n pow = pow - 1\n end\n src = bmul(src, src)\n pow = mfl(pow / 2)\n end\n return res\nend\n\nlocal function modinv(src)\n return modpow(src, mod - 2)\nend\n\nlocal r1, c1 = io.read(\"*n\", \"*n\")\nlocal r2, c2 = io.read(\"*n\", \"*n\")\n\nlocal function getSum(r, c)\n local sum = 0\n local cur = 1\n for ir = 0, r do\n cur = bmul(cur, ir + c + 1)\n cur = bmul(cur, modinv(ir + 1))\n sum = badd(sum, cur)\n end\n return sum\nend\nlocal z = getSum(r2, c2)\nz = bsub(z, getSum(r2, c1 - 1))\nz = bsub(z, getSum(r1 - 1, c2))\nz = badd(z, getSum(r1 - 1, c1 - 1))\nprint(z)\n", "problem_context": "Score : 600 points\n\nProblem Statement\n\nSnuke is standing on a two-dimensional plane. In one operation, he can move by 1 in the positive x-direction, or move by 1 in the positive y-direction.\n\nLet us define a function f(r, c) as follows:\n\nf(r,c) := (The number of paths from the point (0, 0) to the point (r, c) that Snuke can trace by repeating the operation above)\n\nGiven are integers r_1, r_2, c_1, and c_2.\nFind the sum of f(i, j) over all pair of integers (i, j) such that r_1 ≤ i ≤ r_2 and c_1 ≤ j ≤ c_2, and compute this value modulo (10^9+7).\n\nConstraints\n\n1 ≤ r_1 ≤ r_2 ≤ 10^6\n\n1 ≤ c_1 ≤ c_2 ≤ 10^6\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nr_1 c_1 r_2 c_2\n\nOutput\n\nPrint the sum of f(i, j) modulo (10^9+7).\n\nSample Input 1\n\n1 1 2 2\n\nSample Output 1\n\n14\n\nFor example, there are two paths from the point (0, 0) to the point (1, 1): (0,0) → (0,1) → (1,1) and (0,0) → (1,0) → (1,1), so f(1,1)=2.\n\nSimilarly, f(1,2)=3, f(2,1)=3, and f(2,2)=6. Thus, the sum is 14.\n\nSample Input 2\n\n314 159 2653 589\n\nSample Output 2\n\n602215194", "sample_input": "1 1 2 2\n"}, "reference_outputs": ["14\n"], "source_document_id": "p02782", "source_text": "Score : 600 points\n\nProblem Statement\n\nSnuke is standing on a two-dimensional plane. In one operation, he can move by 1 in the positive x-direction, or move by 1 in the positive y-direction.\n\nLet us define a function f(r, c) as follows:\n\nf(r,c) := (The number of paths from the point (0, 0) to the point (r, c) that Snuke can trace by repeating the operation above)\n\nGiven are integers r_1, r_2, c_1, and c_2.\nFind the sum of f(i, j) over all pair of integers (i, j) such that r_1 ≤ i ≤ r_2 and c_1 ≤ j ≤ c_2, and compute this value modulo (10^9+7).\n\nConstraints\n\n1 ≤ r_1 ≤ r_2 ≤ 10^6\n\n1 ≤ c_1 ≤ c_2 ≤ 10^6\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nr_1 c_1 r_2 c_2\n\nOutput\n\nPrint the sum of f(i, j) modulo (10^9+7).\n\nSample Input 1\n\n1 1 2 2\n\nSample Output 1\n\n14\n\nFor example, there are two paths from the point (0, 0) to the point (1, 1): (0,0) → (0,1) → (1,1) and (0,0) → (1,0) → (1,1), so f(1,1)=2.\n\nSimilarly, f(1,2)=3, f(2,1)=3, and f(2,2)=6. Thus, the sum is 14.\n\nSample Input 2\n\n314 159 2653 589\n\nSample Output 2\n\n602215194", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1042, "cpu_time_ms": 2103, "memory_kb": 256}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s270789556", "group_id": "codeNet:p02783", "input_text": "n = io.read(\"n\")\na = io.read(\"n\")\nprint((n+a-1) // a )", "language": "Lua", "metadata": {"date": 1581019895, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p02783.html", "problem_id": "p02783", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02783/input.txt", "sample_output_relpath": "derived/input_output/data/p02783/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02783/Lua/s270789556.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s270789556", "user_id": "u330661451"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "n = io.read(\"n\")\na = io.read(\"n\")\nprint((n+a-1) // a )", "problem_context": "Score : 100 points\n\nProblem Statement\n\nServal is fighting with a monster.\n\nThe health of the monster is H.\n\nIn one attack, Serval can decrease the monster's health by A.\nThere is no other way to decrease the monster's health.\n\nServal wins when the monster's health becomes 0 or below.\n\nFind the number of attacks Serval needs to make before winning.\n\nConstraints\n\n1 \\leq H \\leq 10^4\n\n1 \\leq A \\leq 10^4\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH A\n\nOutput\n\nPrint the number of attacks Serval needs to make before winning.\n\nSample Input 1\n\n10 4\n\nSample Output 1\n\n3\n\nAfter one attack, the monster's health will be 6.\n\nAfter two attacks, the monster's health will be 2.\n\nAfter three attacks, the monster's health will be -2.\n\nThus, Serval needs to make three attacks to win.\n\nSample Input 2\n\n1 10000\n\nSample Output 2\n\n1\n\nSample Input 3\n\n10000 1\n\nSample Output 3\n\n10000", "sample_input": "10 4\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02783", "source_text": "Score : 100 points\n\nProblem Statement\n\nServal is fighting with a monster.\n\nThe health of the monster is H.\n\nIn one attack, Serval can decrease the monster's health by A.\nThere is no other way to decrease the monster's health.\n\nServal wins when the monster's health becomes 0 or below.\n\nFind the number of attacks Serval needs to make before winning.\n\nConstraints\n\n1 \\leq H \\leq 10^4\n\n1 \\leq A \\leq 10^4\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH A\n\nOutput\n\nPrint the number of attacks Serval needs to make before winning.\n\nSample Input 1\n\n10 4\n\nSample Output 1\n\n3\n\nAfter one attack, the monster's health will be 6.\n\nAfter two attacks, the monster's health will be 2.\n\nAfter three attacks, the monster's health will be -2.\n\nThus, Serval needs to make three attacks to win.\n\nSample Input 2\n\n1 10000\n\nSample Output 2\n\n1\n\nSample Input 3\n\n10000 1\n\nSample Output 3\n\n10000", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 54, "cpu_time_ms": 7, "memory_kb": 760}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s824789537", "group_id": "codeNet:p02784", "input_text": "H=io.read\"*n\"\nN=io.read\"*n\"\nAS=0\nfor i=1,N do\n\tAS=AS+io.read\"*n\"\nend\nprint((\nH<=AS\n)and\"Yes\"or\"No\")", "language": "Lua", "metadata": {"date": 1587307491, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p02784.html", "problem_id": "p02784", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02784/input.txt", "sample_output_relpath": "derived/input_output/data/p02784/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02784/Lua/s824789537.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s824789537", "user_id": "u726173718"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "H=io.read\"*n\"\nN=io.read\"*n\"\nAS=0\nfor i=1,N do\n\tAS=AS+io.read\"*n\"\nend\nprint((\nH<=AS\n)and\"Yes\"or\"No\")", "problem_context": "Score : 200 points\n\nProblem Statement\n\nRaccoon is fighting with a monster.\n\nThe health of the monster is H.\n\nRaccoon can use N kinds of special moves. Using the i-th move decreases the monster's health by A_i.\nThere is no other way to decrease the monster's health.\n\nRaccoon wins when the monster's health becomes 0 or below.\n\nIf Raccoon can win without using the same move twice or more, print Yes; otherwise, print No.\n\nConstraints\n\n1 \\leq H \\leq 10^9\n\n1 \\leq N \\leq 10^5\n\n1 \\leq A_i \\leq 10^4\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH N\nA_1 A_2 ... A_N\n\nOutput\n\nIf Raccoon can win without using the same move twice or more, print Yes; otherwise, print No.\n\nSample Input 1\n\n10 3\n4 5 6\n\nSample Output 1\n\nYes\n\nThe monster's health will become 0 or below after, for example, using the second and third moves.\n\nSample Input 2\n\n20 3\n4 5 6\n\nSample Output 2\n\nNo\n\nSample Input 3\n\n210 5\n31 41 59 26 53\n\nSample Output 3\n\nYes\n\nSample Input 4\n\n211 5\n31 41 59 26 53\n\nSample Output 4\n\nNo", "sample_input": "10 3\n4 5 6\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p02784", "source_text": "Score : 200 points\n\nProblem Statement\n\nRaccoon is fighting with a monster.\n\nThe health of the monster is H.\n\nRaccoon can use N kinds of special moves. Using the i-th move decreases the monster's health by A_i.\nThere is no other way to decrease the monster's health.\n\nRaccoon wins when the monster's health becomes 0 or below.\n\nIf Raccoon can win without using the same move twice or more, print Yes; otherwise, print No.\n\nConstraints\n\n1 \\leq H \\leq 10^9\n\n1 \\leq N \\leq 10^5\n\n1 \\leq A_i \\leq 10^4\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH N\nA_1 A_2 ... A_N\n\nOutput\n\nIf Raccoon can win without using the same move twice or more, print Yes; otherwise, print No.\n\nSample Input 1\n\n10 3\n4 5 6\n\nSample Output 1\n\nYes\n\nThe monster's health will become 0 or below after, for example, using the second and third moves.\n\nSample Input 2\n\n20 3\n4 5 6\n\nSample Output 2\n\nNo\n\nSample Input 3\n\n210 5\n31 41 59 26 53\n\nSample Output 3\n\nYes\n\nSample Input 4\n\n211 5\n31 41 59 26 53\n\nSample Output 4\n\nNo", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 99, "cpu_time_ms": 21, "memory_kb": 256}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s817805351", "group_id": "codeNet:p02785", "input_text": "n, k = io.read(\"*n\", \"*n\")\nt = {}\nfor i = 1, n do t[i] = io.read(\"*n\") end\ntable.sort(t)\ns = 0\nfor i = 1, n - k do s = s + t[i] end\nprint(s)\n", "language": "Lua", "metadata": {"date": 1580112482, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p02785.html", "problem_id": "p02785", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02785/input.txt", "sample_output_relpath": "derived/input_output/data/p02785/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02785/Lua/s817805351.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s817805351", "user_id": "u120582723"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "n, k = io.read(\"*n\", \"*n\")\nt = {}\nfor i = 1, n do t[i] = io.read(\"*n\") end\ntable.sort(t)\ns = 0\nfor i = 1, n - k do s = s + t[i] end\nprint(s)\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nFennec is fighting with N monsters.\n\nThe health of the i-th monster is H_i.\n\nFennec can do the following two actions:\n\nAttack: Fennec chooses one monster. That monster's health will decrease by 1.\n\nSpecial Move: Fennec chooses one monster. That monster's health will become 0.\n\nThere is no way other than Attack and Special Move to decrease the monsters' health.\n\nFennec wins when all the monsters' healths become 0 or below.\n\nFind the minimum number of times Fennec needs to do Attack (not counting Special Move) before winning when she can use Special Move at most K times.\n\nConstraints\n\n1 \\leq N \\leq 2 \\times 10^5\n\n0 \\leq K \\leq 2 \\times 10^5\n\n1 \\leq H_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nH_1 ... H_N\n\nOutput\n\nPrint the minimum number of times Fennec needs to do Attack (not counting Special Move) before winning.\n\nSample Input 1\n\n3 1\n4 1 5\n\nSample Output 1\n\n5\n\nBy using Special Move on the third monster, and doing Attack four times on the first monster and once on the second monster, Fennec can win with five Attacks.\n\nSample Input 2\n\n8 9\n7 9 3 2 3 8 4 6\n\nSample Output 2\n\n0\n\nShe can use Special Move on all the monsters.\n\nSample Input 3\n\n3 0\n1000000000 1000000000 1000000000\n\nSample Output 3\n\n3000000000\n\nWatch out for overflow.", "sample_input": "3 1\n4 1 5\n"}, "reference_outputs": ["5\n"], "source_document_id": "p02785", "source_text": "Score : 300 points\n\nProblem Statement\n\nFennec is fighting with N monsters.\n\nThe health of the i-th monster is H_i.\n\nFennec can do the following two actions:\n\nAttack: Fennec chooses one monster. That monster's health will decrease by 1.\n\nSpecial Move: Fennec chooses one monster. That monster's health will become 0.\n\nThere is no way other than Attack and Special Move to decrease the monsters' health.\n\nFennec wins when all the monsters' healths become 0 or below.\n\nFind the minimum number of times Fennec needs to do Attack (not counting Special Move) before winning when she can use Special Move at most K times.\n\nConstraints\n\n1 \\leq N \\leq 2 \\times 10^5\n\n0 \\leq K \\leq 2 \\times 10^5\n\n1 \\leq H_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nH_1 ... H_N\n\nOutput\n\nPrint the minimum number of times Fennec needs to do Attack (not counting Special Move) before winning.\n\nSample Input 1\n\n3 1\n4 1 5\n\nSample Output 1\n\n5\n\nBy using Special Move on the third monster, and doing Attack four times on the first monster and once on the second monster, Fennec can win with five Attacks.\n\nSample Input 2\n\n8 9\n7 9 3 2 3 8 4 6\n\nSample Output 2\n\n0\n\nShe can use Special Move on all the monsters.\n\nSample Input 3\n\n3 0\n1000000000 1000000000 1000000000\n\nSample Output 3\n\n3000000000\n\nWatch out for overflow.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 141, "cpu_time_ms": 200, "memory_kb": 4976}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s768712740", "group_id": "codeNet:p02787", "input_text": "local h,n=io.read(\"n\",\"n\")\nlocal a,b={},{}\nfor i=1,n do\n a[i],b[i]=io.read(\"n\",\"n\")\nend\n\nlocal dp={0}\nfor i=2,h+1 do\n dp[i]=10^9\nend\n\nfor i=1,n do\n for j=1,h+1 do\n local k=math.min(j+a[i],h+1)\n dp[k]=math.min(dp[k],dp[j]+b[i])\n end\nend\nprint(dp[h+1])", "language": "Lua", "metadata": {"date": 1593295131, "filename_ext": "lua", "original_language": "Lua (LuaJIT 2.1.0)", "problem_description_relpath": "problem_descriptions/p02787.html", "problem_id": "p02787", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02787/input.txt", "sample_output_relpath": "derived/input_output/data/p02787/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02787/Lua/s768712740.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s768712740", "user_id": "u045238009"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "local h,n=io.read(\"n\",\"n\")\nlocal a,b={},{}\nfor i=1,n do\n a[i],b[i]=io.read(\"n\",\"n\")\nend\n\nlocal dp={0}\nfor i=2,h+1 do\n dp[i]=10^9\nend\n\nfor i=1,n do\n for j=1,h+1 do\n local k=math.min(j+a[i],h+1)\n dp[k]=math.min(dp[k],dp[j]+b[i])\n end\nend\nprint(dp[h+1])", "problem_context": "Score : 500 points\n\nProblem Statement\n\nIbis is fighting with a monster.\n\nThe health of the monster is H.\n\nIbis can cast N kinds of spells. Casting the i-th spell decreases the monster's health by A_i, at the cost of B_i Magic Points.\n\nThe same spell can be cast multiple times. There is no way other than spells to decrease the monster's health.\n\nIbis wins when the health of the monster becomes 0 or below.\n\nFind the minimum total Magic Points that have to be consumed before winning.\n\nConstraints\n\n1 \\leq H \\leq 10^4\n\n1 \\leq N \\leq 10^3\n\n1 \\leq A_i \\leq 10^4\n\n1 \\leq B_i \\leq 10^4\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH N\nA_1 B_1\n:\nA_N B_N\n\nOutput\n\nPrint the minimum total Magic Points that have to be consumed before winning.\n\nSample Input 1\n\n9 3\n8 3\n4 2\n2 1\n\nSample Output 1\n\n4\n\nFirst, let us cast the first spell to decrease the monster's health by 8, at the cost of 3 Magic Points. The monster's health is now 1.\n\nThen, cast the third spell to decrease the monster's health by 2, at the cost of 1 Magic Point. The monster's health is now -1.\n\nIn this way, we can win at the total cost of 4 Magic Points.\n\nSample Input 2\n\n100 6\n1 1\n2 3\n3 9\n4 27\n5 81\n6 243\n\nSample Output 2\n\n100\n\nIt is optimal to cast the first spell 100 times.\n\nSample Input 3\n\n9999 10\n540 7550\n691 9680\n700 9790\n510 7150\n415 5818\n551 7712\n587 8227\n619 8671\n588 8228\n176 2461\n\nSample Output 3\n\n139815", "sample_input": "9 3\n8 3\n4 2\n2 1\n"}, "reference_outputs": ["4\n"], "source_document_id": "p02787", "source_text": "Score : 500 points\n\nProblem Statement\n\nIbis is fighting with a monster.\n\nThe health of the monster is H.\n\nIbis can cast N kinds of spells. Casting the i-th spell decreases the monster's health by A_i, at the cost of B_i Magic Points.\n\nThe same spell can be cast multiple times. There is no way other than spells to decrease the monster's health.\n\nIbis wins when the health of the monster becomes 0 or below.\n\nFind the minimum total Magic Points that have to be consumed before winning.\n\nConstraints\n\n1 \\leq H \\leq 10^4\n\n1 \\leq N \\leq 10^3\n\n1 \\leq A_i \\leq 10^4\n\n1 \\leq B_i \\leq 10^4\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH N\nA_1 B_1\n:\nA_N B_N\n\nOutput\n\nPrint the minimum total Magic Points that have to be consumed before winning.\n\nSample Input 1\n\n9 3\n8 3\n4 2\n2 1\n\nSample Output 1\n\n4\n\nFirst, let us cast the first spell to decrease the monster's health by 8, at the cost of 3 Magic Points. The monster's health is now 1.\n\nThen, cast the third spell to decrease the monster's health by 2, at the cost of 1 Magic Point. The monster's health is now -1.\n\nIn this way, we can win at the total cost of 4 Magic Points.\n\nSample Input 2\n\n100 6\n1 1\n2 3\n3 9\n4 27\n5 81\n6 243\n\nSample Output 2\n\n100\n\nIt is optimal to cast the first spell 100 times.\n\nSample Input 3\n\n9999 10\n540 7550\n691 9680\n700 9790\n510 7150\n415 5818\n551 7712\n587 8227\n619 8671\n588 8228\n176 2461\n\nSample Output 3\n\n139815", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 276, "cpu_time_ms": 53, "memory_kb": 2704}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s618678648", "group_id": "codeNet:p02788", "input_text": "local function meld(a,b)\n if not a then\n return b\n elseif not b then\n return a\n elseif a[1] P_j holds for j = 1.\n\nSimilarly, i=5 does not satisfy the condition, either. Thus, there are three integers that satisfy the condition.\n\nSample Input 2\n\n4\n4 3 2 1\n\nSample Output 2\n\n4\n\nAll integers i (1 \\leq i \\leq N) satisfy the condition.\n\nSample Input 3\n\n6\n1 2 3 4 5 6\n\nSample Output 3\n\n1\n\nOnly i=1 satisfies the condition.\n\nSample Input 4\n\n8\n5 7 4 2 6 8 1 3\n\nSample Output 4\n\n4\n\nSample Input 5\n\n1\n1\n\nSample Output 5\n\n1", "sample_input": "5\n4 2 5 1 3\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02791", "source_text": "Score : 300 points\n\nProblem Statement\n\nGiven is a permutation P_1, \\ldots, P_N of 1, \\ldots, N.\nFind the number of integers i (1 \\leq i \\leq N) that satisfy the following condition:\n\nFor any integer j (1 \\leq j \\leq i), P_i \\leq P_j.\n\nConstraints\n\n1 \\leq N \\leq 2 \\times 10^5\n\nP_1, \\ldots, P_N is a permutation of 1, \\ldots, N.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nP_1 ... P_N\n\nOutput\n\nPrint the number of integers i that satisfy the condition.\n\nSample Input 1\n\n5\n4 2 5 1 3\n\nSample Output 1\n\n3\n\ni=1, 2, and 4 satisfy the condition, but i=3 does not - for example, P_i > P_j holds for j = 1.\n\nSimilarly, i=5 does not satisfy the condition, either. Thus, there are three integers that satisfy the condition.\n\nSample Input 2\n\n4\n4 3 2 1\n\nSample Output 2\n\n4\n\nAll integers i (1 \\leq i \\leq N) satisfy the condition.\n\nSample Input 3\n\n6\n1 2 3 4 5 6\n\nSample Output 3\n\n1\n\nOnly i=1 satisfies the condition.\n\nSample Input 4\n\n8\n5 7 4 2 6 8 1 3\n\nSample Output 4\n\n4\n\nSample Input 5\n\n1\n1\n\nSample Output 5\n\n1", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 180, "cpu_time_ms": 77, "memory_kb": 760}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s779246036", "group_id": "codeNet:p02791", "input_text": "local n = io.read(\"*n\")\nlocal r = 0\nlocal m = n + 1\nfor i = 1, n do\n local p = io.read(\"*n\")\n if p < m then\n r, m = r + 1, p\n end\nend\nprint(r)\n", "language": "Lua", "metadata": {"date": 1579689443, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p02791.html", "problem_id": "p02791", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02791/input.txt", "sample_output_relpath": "derived/input_output/data/p02791/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02791/Lua/s779246036.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s779246036", "user_id": "u120582723"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "local n = io.read(\"*n\")\nlocal r = 0\nlocal m = n + 1\nfor i = 1, n do\n local p = io.read(\"*n\")\n if p < m then\n r, m = r + 1, p\n end\nend\nprint(r)\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nGiven is a permutation P_1, \\ldots, P_N of 1, \\ldots, N.\nFind the number of integers i (1 \\leq i \\leq N) that satisfy the following condition:\n\nFor any integer j (1 \\leq j \\leq i), P_i \\leq P_j.\n\nConstraints\n\n1 \\leq N \\leq 2 \\times 10^5\n\nP_1, \\ldots, P_N is a permutation of 1, \\ldots, N.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nP_1 ... P_N\n\nOutput\n\nPrint the number of integers i that satisfy the condition.\n\nSample Input 1\n\n5\n4 2 5 1 3\n\nSample Output 1\n\n3\n\ni=1, 2, and 4 satisfy the condition, but i=3 does not - for example, P_i > P_j holds for j = 1.\n\nSimilarly, i=5 does not satisfy the condition, either. Thus, there are three integers that satisfy the condition.\n\nSample Input 2\n\n4\n4 3 2 1\n\nSample Output 2\n\n4\n\nAll integers i (1 \\leq i \\leq N) satisfy the condition.\n\nSample Input 3\n\n6\n1 2 3 4 5 6\n\nSample Output 3\n\n1\n\nOnly i=1 satisfies the condition.\n\nSample Input 4\n\n8\n5 7 4 2 6 8 1 3\n\nSample Output 4\n\n4\n\nSample Input 5\n\n1\n1\n\nSample Output 5\n\n1", "sample_input": "5\n4 2 5 1 3\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02791", "source_text": "Score : 300 points\n\nProblem Statement\n\nGiven is a permutation P_1, \\ldots, P_N of 1, \\ldots, N.\nFind the number of integers i (1 \\leq i \\leq N) that satisfy the following condition:\n\nFor any integer j (1 \\leq j \\leq i), P_i \\leq P_j.\n\nConstraints\n\n1 \\leq N \\leq 2 \\times 10^5\n\nP_1, \\ldots, P_N is a permutation of 1, \\ldots, N.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nP_1 ... P_N\n\nOutput\n\nPrint the number of integers i that satisfy the condition.\n\nSample Input 1\n\n5\n4 2 5 1 3\n\nSample Output 1\n\n3\n\ni=1, 2, and 4 satisfy the condition, but i=3 does not - for example, P_i > P_j holds for j = 1.\n\nSimilarly, i=5 does not satisfy the condition, either. Thus, there are three integers that satisfy the condition.\n\nSample Input 2\n\n4\n4 3 2 1\n\nSample Output 2\n\n4\n\nAll integers i (1 \\leq i \\leq N) satisfy the condition.\n\nSample Input 3\n\n6\n1 2 3 4 5 6\n\nSample Output 3\n\n1\n\nOnly i=1 satisfies the condition.\n\nSample Input 4\n\n8\n5 7 4 2 6 8 1 3\n\nSample Output 4\n\n4\n\nSample Input 5\n\n1\n1\n\nSample Output 5\n\n1", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 149, "cpu_time_ms": 52, "memory_kb": 632}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s487268239", "group_id": "codeNet:p02792", "input_text": "local read = setmetatable({}, {__index = function(t, k) local a = {} for i=1,#k do table.insert(a, '*'..string.sub(k, i, i)) end local r = io.read local u = table.unpack or unpack return function() return r(u(a)) end end})\nread.N = function(N) local t={} for i=1,N do t[i]=read.n() end return t end\nstring.totable = function(s) local t={} local u=string.sub for i=1,#s do t[i] = u(s, i, i) end return t end\nstring.split = function(s) local t={} for w in string.gmatch(s, \"[^%s]+\") do table.insert(t, w) end return (table.unpack or unpack)(t) end\nlocal function array(dimensi0n, default_val) assert(type(default_val) ~= 'table') local n=dimensi0n local m={}if default_val~=nil then m[1]={__index=function()return default_val end}end for i=2,n do m[i]={__index=function(p, k)local c=setmetatable({},m[i-1])rawset(p,k,c)return c end}end return setmetatable({},m[n])end\n----\n\nlocal N = read.n()\n\nlocal function first_last(x)\n local s = tostring(x)\n local first = tonumber(s:sub(1,1))\n return first, x%10\nend\n\nlocal t = array(1, 0)\nfor i=1,N do\n local f, e = first_last(i)\n t[f*10+e] = t[f*10+e] + 1\nend\n\n\nlocal cnt = 0\nfor x=1,9 do\n for y=1,9 do\n local cnt_a = t[x*10+y]\n local cnt_b = t[y*10+x]\n cnt = cnt + cnt_a * cnt_b\n end\nend\nprint(cnt)", "language": "Lua", "metadata": {"date": 1594846006, "filename_ext": "lua", "original_language": "Lua (Lua 5.3.5)", "problem_description_relpath": "problem_descriptions/p02792.html", "problem_id": "p02792", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02792/input.txt", "sample_output_relpath": "derived/input_output/data/p02792/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02792/Lua/s487268239.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s487268239", "user_id": "u162773977"}, "prompt_components": {"gold_output": "17\n", "input_to_evaluate": "local read = setmetatable({}, {__index = function(t, k) local a = {} for i=1,#k do table.insert(a, '*'..string.sub(k, i, i)) end local r = io.read local u = table.unpack or unpack return function() return r(u(a)) end end})\nread.N = function(N) local t={} for i=1,N do t[i]=read.n() end return t end\nstring.totable = function(s) local t={} local u=string.sub for i=1,#s do t[i] = u(s, i, i) end return t end\nstring.split = function(s) local t={} for w in string.gmatch(s, \"[^%s]+\") do table.insert(t, w) end return (table.unpack or unpack)(t) end\nlocal function array(dimensi0n, default_val) assert(type(default_val) ~= 'table') local n=dimensi0n local m={}if default_val~=nil then m[1]={__index=function()return default_val end}end for i=2,n do m[i]={__index=function(p, k)local c=setmetatable({},m[i-1])rawset(p,k,c)return c end}end return setmetatable({},m[n])end\n----\n\nlocal N = read.n()\n\nlocal function first_last(x)\n local s = tostring(x)\n local first = tonumber(s:sub(1,1))\n return first, x%10\nend\n\nlocal t = array(1, 0)\nfor i=1,N do\n local f, e = first_last(i)\n t[f*10+e] = t[f*10+e] + 1\nend\n\n\nlocal cnt = 0\nfor x=1,9 do\n for y=1,9 do\n local cnt_a = t[x*10+y]\n local cnt_b = t[y*10+x]\n cnt = cnt + cnt_a * cnt_b\n end\nend\nprint(cnt)", "problem_context": "Score : 400 points\n\nProblem Statement\n\nGiven is a positive integer N.\n\nFind the number of pairs (A, B) of positive integers not greater than N that satisfy the following condition:\n\nWhen A and B are written in base ten without leading zeros, the last digit of A is equal to the first digit of B, and the first digit of A is equal to the last digit of B.\n\nConstraints\n\n1 \\leq N \\leq 2 \\times 10^5\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n25\n\nSample Output 1\n\n17\n\nThe following 17 pairs satisfy the condition: (1,1), (1,11), (2,2), (2,22), (3,3), (4,4), (5,5), (6,6), (7,7), (8,8), (9,9), (11,1), (11,11), (12,21), (21,12), (22,2), and (22,22).\n\nSample Input 2\n\n1\n\nSample Output 2\n\n1\n\nSample Input 3\n\n100\n\nSample Output 3\n\n108\n\nSample Input 4\n\n2020\n\nSample Output 4\n\n40812\n\nSample Input 5\n\n200000\n\nSample Output 5\n\n400000008", "sample_input": "25\n"}, "reference_outputs": ["17\n"], "source_document_id": "p02792", "source_text": "Score : 400 points\n\nProblem Statement\n\nGiven is a positive integer N.\n\nFind the number of pairs (A, B) of positive integers not greater than N that satisfy the following condition:\n\nWhen A and B are written in base ten without leading zeros, the last digit of A is equal to the first digit of B, and the first digit of A is equal to the last digit of B.\n\nConstraints\n\n1 \\leq N \\leq 2 \\times 10^5\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n25\n\nSample Output 1\n\n17\n\nThe following 17 pairs satisfy the condition: (1,1), (1,11), (2,2), (2,22), (3,3), (4,4), (5,5), (6,6), (7,7), (8,8), (9,9), (11,1), (11,11), (12,21), (21,12), (22,2), and (22,22).\n\nSample Input 2\n\n1\n\nSample Output 2\n\n1\n\nSample Input 3\n\n100\n\nSample Output 3\n\n108\n\nSample Input 4\n\n2020\n\nSample Output 4\n\n40812\n\nSample Input 5\n\n200000\n\nSample Output 5\n\n400000008", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1280, "cpu_time_ms": 116, "memory_kb": 2908}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s323646003", "group_id": "codeNet:p02792", "input_text": "local read = setmetatable({}, {__index = function(t, k) local a = {} for i=1,#k do table.insert(a, '*'..string.sub(k, i, i)) end local r = io.read local u = table.unpack or unpack return function() return r(u(a)) end end})\nread.N = function(N) local t={} for i=1,N do t[i]=read.n() end return t end\nstring.totable = function(s) local t={} local u=string.sub for i=1,#s do t[i] = u(s, i, i) end return t end\nstring.split = function(s) local t={} for w in string.gmatch(s, \"[^%s]+\") do table.insert(t, w) end return (table.unpack or unpack)(t) end\nlocal function array(dimensi0n, default_val) assert(type(default_val) ~= 'table') local n=dimensi0n local m={}if default_val~=nil then m[1]={__index=function()return default_val end}end for i=2,n do m[i]={__index=function(p, k)local c=setmetatable({},m[i-1])rawset(p,k,c)return c end}end return setmetatable({},m[n])end\nlocal function tostringxx(o, depth) depth = depth or 0 if depth > 10 then return \"\" end if o == _G then return \"<_G>\" end local indent0 = (\" \"):rep((depth) * 2) local indent1 = (\" \"):rep((depth+1) * 2) local indent2= (\" \"):rep((depth+2) * 2) if type(o) == 'table' then local keys = {} local types = {} for k in pairs(o) do types[type(k)] = true table.insert(keys, k) end local types_count = 0 local lasttype for k in pairs(types) do types_count = types_count + 1 lasttype = k end if types_count == 1 and (lasttype == 'string' or lasttype == 'number') then table.sort(keys) end local inside = {} for i=1,#keys do local k = keys[i] local v = o[k] if type(k) == 'string' then k = string.format('%q', k) end table.insert(inside, indent1 .. '['..tostring(k)..'] = ' .. tostringxx(v, depth + 1)) end return '{\\n' .. table.concat(inside, ',\\n') .. '\\n' .. indent0 .. '}' else if type(o) == 'string' then o = string.format('%q', o) end return tostring(o) end end\nlocal function richtraceback() local x = 2 while true do local info = debug.getinfo(x) if not info then break end local fname = '<' .. info.short_src .. \":\" .. info.linedefined .. \">\" if info.name then fname = info.name end print(info.short_src .. \":\" .. info.currentline .. \": in \" .. (\"%q\"):format(fname)) print(\" LOCALS:\") local p = 1 while true do local name, val = debug.getlocal(x,p) if not name then break end print(\" \" .. name .. \": \" .. tostringxx(val, 3)) p = p + 1 end print(\" UPVALUES:\") for p=1,info.nups do local name, val = debug.getupvalue(info.func,p) if not name then break end print(\" \" .. name .. \": \" .. tostringxx(val, 3)) end x = x + 1 end end\nlocal function myassert(b) if not b then richtraceback() error(\"assertion failed\") end end \n----\n\nlocal N = read.n()\n\nlocal function get(b, e)\n -- number of integer x where:\n -- - begin with b,\n -- - end with e, and\n -- - x <= N\n local c = 0\n -- [1..9]\n if b==e and b <= N then\n c = c + 1\n end\n -- [11..99]\n if b*10+e <= N then\n c = c + 1\n end\n -- [101..999]\n for i=0,9 do\n if b*100+i*10+e <= N then\n c = c + 1\n end\n end\n -- [1001..9999]\n for i=0,9 do\n for j=0,9 do\n if b*1000+i*100+j*10+e <= N then\n c = c + 1\n end\n end\n end\n -- [10001..99999]\n for i=0,9 do\n for j=0,9 do\n for k=0,9 do\n if b*10000+i*1000+j*100+k*10+e <= N then\n c = c + 1\n end\n end\n end\n end\n -- [100001..199999]\n for i=0,9 do\n for j=0,9 do\n for k=0,9 do\n for l=0,9 do\n if b*100000+i*10000+j*1000+k*100+l*10+e <= N then\n c = c + 1\n end\n end\n end\n end\n end\n return c\nend\n\nlocal cnt = 0\n-- A\n-- x....y\n-- B\n-- y....x\nfor x=1,9 do\n for y=1,9 do\n local cnt_a = get(x, y)\n local cnt_b = get(y, x)\n cnt = cnt + cnt_a * cnt_b\n end\nend\nprint(cnt)", "language": "Lua", "metadata": {"date": 1594845019, "filename_ext": "lua", "original_language": "Lua (Lua 5.3.5)", "problem_description_relpath": "problem_descriptions/p02792.html", "problem_id": "p02792", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02792/input.txt", "sample_output_relpath": "derived/input_output/data/p02792/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02792/Lua/s323646003.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s323646003", "user_id": "u162773977"}, "prompt_components": {"gold_output": "17\n", "input_to_evaluate": "local read = setmetatable({}, {__index = function(t, k) local a = {} for i=1,#k do table.insert(a, '*'..string.sub(k, i, i)) end local r = io.read local u = table.unpack or unpack return function() return r(u(a)) end end})\nread.N = function(N) local t={} for i=1,N do t[i]=read.n() end return t end\nstring.totable = function(s) local t={} local u=string.sub for i=1,#s do t[i] = u(s, i, i) end return t end\nstring.split = function(s) local t={} for w in string.gmatch(s, \"[^%s]+\") do table.insert(t, w) end return (table.unpack or unpack)(t) end\nlocal function array(dimensi0n, default_val) assert(type(default_val) ~= 'table') local n=dimensi0n local m={}if default_val~=nil then m[1]={__index=function()return default_val end}end for i=2,n do m[i]={__index=function(p, k)local c=setmetatable({},m[i-1])rawset(p,k,c)return c end}end return setmetatable({},m[n])end\nlocal function tostringxx(o, depth) depth = depth or 0 if depth > 10 then return \"\" end if o == _G then return \"<_G>\" end local indent0 = (\" \"):rep((depth) * 2) local indent1 = (\" \"):rep((depth+1) * 2) local indent2= (\" \"):rep((depth+2) * 2) if type(o) == 'table' then local keys = {} local types = {} for k in pairs(o) do types[type(k)] = true table.insert(keys, k) end local types_count = 0 local lasttype for k in pairs(types) do types_count = types_count + 1 lasttype = k end if types_count == 1 and (lasttype == 'string' or lasttype == 'number') then table.sort(keys) end local inside = {} for i=1,#keys do local k = keys[i] local v = o[k] if type(k) == 'string' then k = string.format('%q', k) end table.insert(inside, indent1 .. '['..tostring(k)..'] = ' .. tostringxx(v, depth + 1)) end return '{\\n' .. table.concat(inside, ',\\n') .. '\\n' .. indent0 .. '}' else if type(o) == 'string' then o = string.format('%q', o) end return tostring(o) end end\nlocal function richtraceback() local x = 2 while true do local info = debug.getinfo(x) if not info then break end local fname = '<' .. info.short_src .. \":\" .. info.linedefined .. \">\" if info.name then fname = info.name end print(info.short_src .. \":\" .. info.currentline .. \": in \" .. (\"%q\"):format(fname)) print(\" LOCALS:\") local p = 1 while true do local name, val = debug.getlocal(x,p) if not name then break end print(\" \" .. name .. \": \" .. tostringxx(val, 3)) p = p + 1 end print(\" UPVALUES:\") for p=1,info.nups do local name, val = debug.getupvalue(info.func,p) if not name then break end print(\" \" .. name .. \": \" .. tostringxx(val, 3)) end x = x + 1 end end\nlocal function myassert(b) if not b then richtraceback() error(\"assertion failed\") end end \n----\n\nlocal N = read.n()\n\nlocal function get(b, e)\n -- number of integer x where:\n -- - begin with b,\n -- - end with e, and\n -- - x <= N\n local c = 0\n -- [1..9]\n if b==e and b <= N then\n c = c + 1\n end\n -- [11..99]\n if b*10+e <= N then\n c = c + 1\n end\n -- [101..999]\n for i=0,9 do\n if b*100+i*10+e <= N then\n c = c + 1\n end\n end\n -- [1001..9999]\n for i=0,9 do\n for j=0,9 do\n if b*1000+i*100+j*10+e <= N then\n c = c + 1\n end\n end\n end\n -- [10001..99999]\n for i=0,9 do\n for j=0,9 do\n for k=0,9 do\n if b*10000+i*1000+j*100+k*10+e <= N then\n c = c + 1\n end\n end\n end\n end\n -- [100001..199999]\n for i=0,9 do\n for j=0,9 do\n for k=0,9 do\n for l=0,9 do\n if b*100000+i*10000+j*1000+k*100+l*10+e <= N then\n c = c + 1\n end\n end\n end\n end\n end\n return c\nend\n\nlocal cnt = 0\n-- A\n-- x....y\n-- B\n-- y....x\nfor x=1,9 do\n for y=1,9 do\n local cnt_a = get(x, y)\n local cnt_b = get(y, x)\n cnt = cnt + cnt_a * cnt_b\n end\nend\nprint(cnt)", "problem_context": "Score : 400 points\n\nProblem Statement\n\nGiven is a positive integer N.\n\nFind the number of pairs (A, B) of positive integers not greater than N that satisfy the following condition:\n\nWhen A and B are written in base ten without leading zeros, the last digit of A is equal to the first digit of B, and the first digit of A is equal to the last digit of B.\n\nConstraints\n\n1 \\leq N \\leq 2 \\times 10^5\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n25\n\nSample Output 1\n\n17\n\nThe following 17 pairs satisfy the condition: (1,1), (1,11), (2,2), (2,22), (3,3), (4,4), (5,5), (6,6), (7,7), (8,8), (9,9), (11,1), (11,11), (12,21), (21,12), (22,2), and (22,22).\n\nSample Input 2\n\n1\n\nSample Output 2\n\n1\n\nSample Input 3\n\n100\n\nSample Output 3\n\n108\n\nSample Input 4\n\n2020\n\nSample Output 4\n\n40812\n\nSample Input 5\n\n200000\n\nSample Output 5\n\n400000008", "sample_input": "25\n"}, "reference_outputs": ["17\n"], "source_document_id": "p02792", "source_text": "Score : 400 points\n\nProblem Statement\n\nGiven is a positive integer N.\n\nFind the number of pairs (A, B) of positive integers not greater than N that satisfy the following condition:\n\nWhen A and B are written in base ten without leading zeros, the last digit of A is equal to the first digit of B, and the first digit of A is equal to the last digit of B.\n\nConstraints\n\n1 \\leq N \\leq 2 \\times 10^5\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n25\n\nSample Output 1\n\n17\n\nThe following 17 pairs satisfy the condition: (1,1), (1,11), (2,2), (2,22), (3,3), (4,4), (5,5), (6,6), (7,7), (8,8), (9,9), (11,1), (11,11), (12,21), (21,12), (22,2), and (22,22).\n\nSample Input 2\n\n1\n\nSample Output 2\n\n1\n\nSample Input 3\n\n100\n\nSample Output 3\n\n108\n\nSample Input 4\n\n2020\n\nSample Output 4\n\n40812\n\nSample Input 5\n\n200000\n\nSample Output 5\n\n400000008", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 3909, "cpu_time_ms": 144, "memory_kb": 2776}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s276768669", "group_id": "codeNet:p02792", "input_text": "local mfl = math.floor\nlocal n = io.read(\"*n\")\nlocal t = {}\nfor i = 1, 81 do\n t[i] = 0\nend\nfor i = 1, n do\n local ri = i\n local btm = i % 10\n if btm ~= 0 then\n local top = btm\n if i < 10 then\n end\n while 10 <= i do\n i = mfl(i / 10)\n end\n local top = i\n local idx = (top - 1) * 9 + btm\n t[idx] = t[idx] + 1\n end\nend\nlocal ret = 0\nfor i = 1, 9 do\n local idx = (i - 1) * 9 + i\n -- ret = ret + t[idx] * t[idx]\n for j = 1, 9 do\n local idx1, idx2 = (i - 1) * 9 + j, (j - 1) * 9 + i\n ret = ret + t[idx1] * t[idx2]\n end\nend\nprint(ret)\n", "language": "Lua", "metadata": {"date": 1579464994, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p02792.html", "problem_id": "p02792", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02792/input.txt", "sample_output_relpath": "derived/input_output/data/p02792/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02792/Lua/s276768669.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s276768669", "user_id": "u120582723"}, "prompt_components": {"gold_output": "17\n", "input_to_evaluate": "local mfl = math.floor\nlocal n = io.read(\"*n\")\nlocal t = {}\nfor i = 1, 81 do\n t[i] = 0\nend\nfor i = 1, n do\n local ri = i\n local btm = i % 10\n if btm ~= 0 then\n local top = btm\n if i < 10 then\n end\n while 10 <= i do\n i = mfl(i / 10)\n end\n local top = i\n local idx = (top - 1) * 9 + btm\n t[idx] = t[idx] + 1\n end\nend\nlocal ret = 0\nfor i = 1, 9 do\n local idx = (i - 1) * 9 + i\n -- ret = ret + t[idx] * t[idx]\n for j = 1, 9 do\n local idx1, idx2 = (i - 1) * 9 + j, (j - 1) * 9 + i\n ret = ret + t[idx1] * t[idx2]\n end\nend\nprint(ret)\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nGiven is a positive integer N.\n\nFind the number of pairs (A, B) of positive integers not greater than N that satisfy the following condition:\n\nWhen A and B are written in base ten without leading zeros, the last digit of A is equal to the first digit of B, and the first digit of A is equal to the last digit of B.\n\nConstraints\n\n1 \\leq N \\leq 2 \\times 10^5\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n25\n\nSample Output 1\n\n17\n\nThe following 17 pairs satisfy the condition: (1,1), (1,11), (2,2), (2,22), (3,3), (4,4), (5,5), (6,6), (7,7), (8,8), (9,9), (11,1), (11,11), (12,21), (21,12), (22,2), and (22,22).\n\nSample Input 2\n\n1\n\nSample Output 2\n\n1\n\nSample Input 3\n\n100\n\nSample Output 3\n\n108\n\nSample Input 4\n\n2020\n\nSample Output 4\n\n40812\n\nSample Input 5\n\n200000\n\nSample Output 5\n\n400000008", "sample_input": "25\n"}, "reference_outputs": ["17\n"], "source_document_id": "p02792", "source_text": "Score : 400 points\n\nProblem Statement\n\nGiven is a positive integer N.\n\nFind the number of pairs (A, B) of positive integers not greater than N that satisfy the following condition:\n\nWhen A and B are written in base ten without leading zeros, the last digit of A is equal to the first digit of B, and the first digit of A is equal to the last digit of B.\n\nConstraints\n\n1 \\leq N \\leq 2 \\times 10^5\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n25\n\nSample Output 1\n\n17\n\nThe following 17 pairs satisfy the condition: (1,1), (1,11), (2,2), (2,22), (3,3), (4,4), (5,5), (6,6), (7,7), (8,8), (9,9), (11,1), (11,11), (12,21), (21,12), (22,2), and (22,22).\n\nSample Input 2\n\n1\n\nSample Output 2\n\n1\n\nSample Input 3\n\n100\n\nSample Output 3\n\n108\n\nSample Input 4\n\n2020\n\nSample Output 4\n\n40812\n\nSample Input 5\n\n200000\n\nSample Output 5\n\n400000008", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 571, "cpu_time_ms": 7, "memory_kb": 256}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s074840930", "group_id": "codeNet:p02793", "input_text": "local mce, mfl, msq, mmi, mma, mab = math.ceil, math.floor, math.sqrt, math.min, math.max, math.abs\nlocal mod = 1000000007\n\nlocal function bmul(x, y)\n local x0, y0 = x % 31623, y % 31623\n local x1, y1 = mfl(x / 31623), mfl(y / 31623)\n return (x1 * y1 * 14122 + (x1 * y0 + x0 * y1) * 31623 + x0 * y0) % mod\nend\nlocal function badd(x, y)\n return (x + y) % mod\nend\n\nlocal function bsub(x, y)\n return x < y and x - y + mod or x - y\nend\n\nlocal function modpow(src, pow)\n local res = 1\n while 0 < pow do\n if pow % 2 == 1 then\n res = bmul(res, src)\n pow = pow - 1\n end\n src = bmul(src, src)\n pow = mfl(pow / 2)\n end\n return res\nend\n\nlocal function modinv(src)\n return modpow(src, mod - 2)\nend\n\nlocal function getprimes(x)\n local primes = {}\n local allnums = {}\n for i = 1, x do allnums[i] = true end\n for i = 2, x do\n if allnums[i] then\n table.insert(primes, i)\n local lim = mfl(x / i)\n for j = 2, lim do\n allnums[j * i] = false\n end\n end\n end\n return primes\nend\n\nlocal function getdivisorparts(x, primes)\n local prime_num = #primes\n local tmp = {}\n local lim = mce(msq(x))\n local primepos = 1\n local dv = primes[primepos]\n while(primepos <= prime_num and dv <= lim) do\n if(x % dv == 0) then\n local asdf = {}\n asdf.p = dv\n asdf.cnt = 1\n x = x / dv\n while(x % dv == 0) do\n x = x / dv\n asdf.cnt = asdf.cnt + 1\n end\n table.insert(tmp, asdf)\n lim = mce(msq(x))\n end\n if(primepos == prime_num) then break end\n primepos = primepos + 1\n dv = primes[primepos]\n end\n if(x ~= 1) then\n local asdf = {}\n asdf.p, asdf.cnt = x, 1\n table.insert(tmp, asdf)\n end\n return tmp\nend\n\n\nlocal n = io.read(\"*n\")\nlocal a = {}\nfor i = 1, n do\n a[i] = io.read(\"*n\")\nend\nlocal primes = getprimes(1000)\nlocal alldvs = {}\nlocal dvs = {}\nfor i = 1, n do\n dvs[i] = getdivisorparts(a[i], primes)\n for j = 1, #dvs[i] do\n local p, c = dvs[i][j].p, dvs[i][j].cnt\n if not alldvs[p] then\n alldvs[p] = c\n else\n alldvs[p] = mma(alldvs[p], c)\n end\n end\nend\nlocal ret = 0\nlocal mul = 1\nfor p, c in pairs(alldvs) do\n mul = bmul(mul, modpow(p, c))\nend\nfor i = 1, n do\n local z = 1\n for j = 1, #dvs[i] do\n local p, c = dvs[i][j].p, dvs[i][j].cnt\n z = bmul(z, modpow(p, c))\n end\n ret = badd(ret, bmul(mul, modinv(z)))\nend\nprint(ret)\n", "language": "Lua", "metadata": {"date": 1579464118, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p02793.html", "problem_id": "p02793", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02793/input.txt", "sample_output_relpath": "derived/input_output/data/p02793/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02793/Lua/s074840930.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s074840930", "user_id": "u120582723"}, "prompt_components": {"gold_output": "13\n", "input_to_evaluate": "local mce, mfl, msq, mmi, mma, mab = math.ceil, math.floor, math.sqrt, math.min, math.max, math.abs\nlocal mod = 1000000007\n\nlocal function bmul(x, y)\n local x0, y0 = x % 31623, y % 31623\n local x1, y1 = mfl(x / 31623), mfl(y / 31623)\n return (x1 * y1 * 14122 + (x1 * y0 + x0 * y1) * 31623 + x0 * y0) % mod\nend\nlocal function badd(x, y)\n return (x + y) % mod\nend\n\nlocal function bsub(x, y)\n return x < y and x - y + mod or x - y\nend\n\nlocal function modpow(src, pow)\n local res = 1\n while 0 < pow do\n if pow % 2 == 1 then\n res = bmul(res, src)\n pow = pow - 1\n end\n src = bmul(src, src)\n pow = mfl(pow / 2)\n end\n return res\nend\n\nlocal function modinv(src)\n return modpow(src, mod - 2)\nend\n\nlocal function getprimes(x)\n local primes = {}\n local allnums = {}\n for i = 1, x do allnums[i] = true end\n for i = 2, x do\n if allnums[i] then\n table.insert(primes, i)\n local lim = mfl(x / i)\n for j = 2, lim do\n allnums[j * i] = false\n end\n end\n end\n return primes\nend\n\nlocal function getdivisorparts(x, primes)\n local prime_num = #primes\n local tmp = {}\n local lim = mce(msq(x))\n local primepos = 1\n local dv = primes[primepos]\n while(primepos <= prime_num and dv <= lim) do\n if(x % dv == 0) then\n local asdf = {}\n asdf.p = dv\n asdf.cnt = 1\n x = x / dv\n while(x % dv == 0) do\n x = x / dv\n asdf.cnt = asdf.cnt + 1\n end\n table.insert(tmp, asdf)\n lim = mce(msq(x))\n end\n if(primepos == prime_num) then break end\n primepos = primepos + 1\n dv = primes[primepos]\n end\n if(x ~= 1) then\n local asdf = {}\n asdf.p, asdf.cnt = x, 1\n table.insert(tmp, asdf)\n end\n return tmp\nend\n\n\nlocal n = io.read(\"*n\")\nlocal a = {}\nfor i = 1, n do\n a[i] = io.read(\"*n\")\nend\nlocal primes = getprimes(1000)\nlocal alldvs = {}\nlocal dvs = {}\nfor i = 1, n do\n dvs[i] = getdivisorparts(a[i], primes)\n for j = 1, #dvs[i] do\n local p, c = dvs[i][j].p, dvs[i][j].cnt\n if not alldvs[p] then\n alldvs[p] = c\n else\n alldvs[p] = mma(alldvs[p], c)\n end\n end\nend\nlocal ret = 0\nlocal mul = 1\nfor p, c in pairs(alldvs) do\n mul = bmul(mul, modpow(p, c))\nend\nfor i = 1, n do\n local z = 1\n for j = 1, #dvs[i] do\n local p, c = dvs[i][j].p, dvs[i][j].cnt\n z = bmul(z, modpow(p, c))\n end\n ret = badd(ret, bmul(mul, modinv(z)))\nend\nprint(ret)\n", "problem_context": "Score : 500 points\n\nProblem Statement\n\nGiven are N positive integers A_1,...,A_N.\n\nConsider positive integers B_1, ..., B_N that satisfy the following condition.\n\nCondition: For any i, j such that 1 \\leq i < j \\leq N, A_i B_i = A_j B_j holds.\n\nFind the minimum possible value of B_1 + ... + B_N for such B_1,...,B_N.\n\nSince the answer can be enormous, print the sum modulo (10^9 +7).\n\nConstraints\n\n1 \\leq N \\leq 10^4\n\n1 \\leq A_i \\leq 10^6\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 ... A_N\n\nOutput\n\nPrint the minimum possible value of B_1 + ... + B_N for B_1,...,B_N that satisfy the condition, modulo (10^9 +7).\n\nSample Input 1\n\n3\n2 3 4\n\nSample Output 1\n\n13\n\nLet B_1=6, B_2=4, and B_3=3, and the condition will be satisfied.\n\nSample Input 2\n\n5\n12 12 12 12 12\n\nSample Output 2\n\n5\n\nWe can let all B_i be 1.\n\nSample Input 3\n\n3\n1000000 999999 999998\n\nSample Output 3\n\n996989508\n\nPrint the sum modulo (10^9+7).", "sample_input": "3\n2 3 4\n"}, "reference_outputs": ["13\n"], "source_document_id": "p02793", "source_text": "Score : 500 points\n\nProblem Statement\n\nGiven are N positive integers A_1,...,A_N.\n\nConsider positive integers B_1, ..., B_N that satisfy the following condition.\n\nCondition: For any i, j such that 1 \\leq i < j \\leq N, A_i B_i = A_j B_j holds.\n\nFind the minimum possible value of B_1 + ... + B_N for such B_1,...,B_N.\n\nSince the answer can be enormous, print the sum modulo (10^9 +7).\n\nConstraints\n\n1 \\leq N \\leq 10^4\n\n1 \\leq A_i \\leq 10^6\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 ... A_N\n\nOutput\n\nPrint the minimum possible value of B_1 + ... + B_N for B_1,...,B_N that satisfy the condition, modulo (10^9 +7).\n\nSample Input 1\n\n3\n2 3 4\n\nSample Output 1\n\n13\n\nLet B_1=6, B_2=4, and B_3=3, and the condition will be satisfied.\n\nSample Input 2\n\n5\n12 12 12 12 12\n\nSample Output 2\n\n5\n\nWe can let all B_i be 1.\n\nSample Input 3\n\n3\n1000000 999999 999998\n\nSample Output 3\n\n996989508\n\nPrint the sum modulo (10^9+7).", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2376, "cpu_time_ms": 33, "memory_kb": 6528}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s242538306", "group_id": "codeNet:p02794", "input_text": "local mfl, mce, mmi = math.floor, math.ceil, math.min\n\nlocal function getor(x, y)\n local ret = 0\n local mul = 1\n while 0 < x + y do\n ret = ret + mul * (1 - (1 - x % 2) * (1 - y % 2))\n x, y, mul = mfl(x / 2), mfl(y / 2), mul * 2\n end\n return ret\nend\n\nlocal SegTree = {}\nSegTree.updateAll = function(self)\n for i = self.stagenum - 1, 1, -1 do\n for j = 1, self.cnt[i] do\n self.stage[i][j] = self.func(self.stage[i + 1][j * 2 - 1], self.stage[i + 1][j * 2])\n end\n end\nend\nSegTree.create = function(self, n, func, emptyvalue)\n self.func, self.emptyvalue = func, emptyvalue\n local stagenum, mul = 1, 1\n self.cnt, self.stage, self.size = {1}, {{}}, {}\n while mul < n do\n mul, stagenum = mul * 2, stagenum + 1\n self.cnt[stagenum], self.stage[stagenum] = mul, {}\n end\n for i = 1, stagenum do self.size[i] = self.cnt[stagenum + 1 - i] end\n self.stagenum = stagenum\n for i = 1, mul do self.stage[stagenum][i] = emptyvalue end\n self:updateAll()\nend\nSegTree.getRange = function(self, left, right)\n if left == right then return self.stage[self.stagenum][left] end\n local start_stage = 1\n while right - left + 1 < self.size[start_stage] do\n start_stage = start_stage + 1\n end\n local ret = self.emptyvalue\n local t1, t2, t3 = {start_stage}, {left}, {right}\n while 0 < #t1 do\n local stage, l, r = t1[#t1], t2[#t1], t3[#t1]\n table.remove(t1) table.remove(t2) table.remove(t3)\n local sz = self.size[stage]\n if (l - 1) % sz ~= 0 then\n local newr = mmi(r, mce((l - 1) / sz) * sz)\n table.insert(t1, stage + 1) table.insert(t2, l) table.insert(t3, newr)\n l = newr + 1\n end\n if sz <= r + 1 - l then\n ret = self.func(ret, self.stage[stage][mce(l / sz)])\n l = l + sz\n end\n if l <= r then\n table.insert(t1, stage + 1) table.insert(t2, l) table.insert(t3, r)\n end\n end\n return ret\nend\nSegTree.setValue = function(self, idx, value, silent)\n self.stage[self.stagenum][idx] = value\n if not silent then\n for i = self.stagenum - 1, 1, -1 do\n local dst = mce(idx / 2)\n local rem = dst * 4 - 1 - idx\n self.stage[i][dst] = self.func(self.stage[i + 1][idx], self.stage[i + 1][rem])\n idx = dst\n end\n end\nend\nSegTree.new = function(n, func, emptyvalue)\n local obj = {}\n setmetatable(obj, {__index = SegTree})\n obj:create(n, func, emptyvalue)\n return obj\nend\n\nlocal n = io.read(\"*n\")\nlocal edge = {}\nlocal asked = {}\nlocal cpos = {}\nlocal len = {}\nfor i = 1, n do\n edge[i] = {}\n asked[i] = false\n cpos[i] = 0\n len[i] = 0\nend\nlen[n + 1] = 100\nlocal line = {}\nfor i = 1, n - 1 do\n local x, y = io.read(\"*n\", \"*n\")\n table.insert(edge[x], y)\n table.insert(edge[y], x)\n line[i] = {x, y}\nend\n\nlocal tasks = {1}\nlocal posinv = {}\nfor i = 1, n do\n posinv[i] = 0\nend\nlocal eulers = {}\nwhile 0 < #tasks do\n local src = tasks[#tasks]\n table.remove(tasks)\n asked[src] = true\n table.insert(eulers, src)\n if posinv[src] == 0 then\n posinv[src] = #eulers\n end\n while cpos[src] < #edge[src] do\n cpos[src] = cpos[src] + 1\n local dst = edge[src][cpos[src]]\n if not asked[dst] then\n len[dst] = len[src] + 1\n table.insert(tasks, src)\n table.insert(tasks, dst)\n break\n end\n end\nend\nlocal lca = {}\nfor i = 1, #eulers do\n lca[i] = {}\n local prv = eulers[i]\n lca[i][1] = prv\n for j = i + 1, #eulers do\n lca[i][j - i + 1] = len[prv] < len[eulers[j]] and prv or eulers[j]\n prv = lca[i][j - i + 1]\n end\nend\nlocal stLine = SegTree.new(2 * n - 2, function(a, b) return a + b end, 0)\n\nlocal m = io.read(\"*n\")\nlocal mtot = 2^m\nlocal mbox = {}\nfor i = 1, mtot do\n mbox[i] = 0LL\nend\nmbox[1] = 1LL\nlocal posu, posv, posp = {}, {}, {}\nfor i = 1, m do\n local u, v = io.read(\"*n\", \"*n\")\n local pu, pv = posinv[u], posinv[v]\n if pv < pu then pu, pv = pv, pu end\n local p = lca[pu][pv - pu + 1]\n posu[i], posv[i], posp[i] = pu, pv, posinv[p]\nend\nlocal linepos = {}\nfor il = 1, n - 1 do\n linepos[il] = {}\n local lx, ly = line[il][1], line[il][2]\n for j = 1, #eulers - 1 do\n if lx == eulers[j] and ly == eulers[j + 1] then\n table.insert(linepos[il], j)\n elseif ly == eulers[j] and lx == eulers[j + 1] then\n table.insert(linepos[il], j)\n end\n end\nend\n\nfor il = 1, n - 1 do\n local lx, ly = line[il][1], line[il][2]\n local p1, p2 = linepos[il][1], linepos[il][2]\n stLine:setValue(p1, 1)\n stLine:setValue(p2, -1)\n local mul = 1\n local actsum = 0\n for im = 1, m do\n local pu, pv, pp = posu[im], posv[im], posp[im]\n if pv < pp then\n activate = 0 ~= stLine:getRange(pv, pp - 1)\n elseif pp < pv then\n activate = 0 ~= stLine:getRange(pp, pv - 1)\n end\n if not activate then\n if pu < pp then\n activate = 0 ~= stLine:getRange(pu, pp - 1)\n elseif pp < pu then\n activate = 0 ~= stLine:getRange(pp, pu - 1)\n end\n end\n if activate then\n actsum = actsum + mul\n end\n mul = mul * 2\n end\n for im = mtot, 1, -1 do\n local dst = getor(im - 1, actsum)\n mbox[dst + 1] = mbox[dst + 1] + mbox[im]\n end\n stLine:setValue(p1, 0)\n stLine:setValue(p2, 0)\nend\nlocal str = tostring(mbox[mtot]):gsub(\"LL\", \"\")\nprint(str)\n", "language": "Lua", "metadata": {"date": 1579648538, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p02794.html", "problem_id": "p02794", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02794/input.txt", "sample_output_relpath": "derived/input_output/data/p02794/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02794/Lua/s242538306.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s242538306", "user_id": "u120582723"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "local mfl, mce, mmi = math.floor, math.ceil, math.min\n\nlocal function getor(x, y)\n local ret = 0\n local mul = 1\n while 0 < x + y do\n ret = ret + mul * (1 - (1 - x % 2) * (1 - y % 2))\n x, y, mul = mfl(x / 2), mfl(y / 2), mul * 2\n end\n return ret\nend\n\nlocal SegTree = {}\nSegTree.updateAll = function(self)\n for i = self.stagenum - 1, 1, -1 do\n for j = 1, self.cnt[i] do\n self.stage[i][j] = self.func(self.stage[i + 1][j * 2 - 1], self.stage[i + 1][j * 2])\n end\n end\nend\nSegTree.create = function(self, n, func, emptyvalue)\n self.func, self.emptyvalue = func, emptyvalue\n local stagenum, mul = 1, 1\n self.cnt, self.stage, self.size = {1}, {{}}, {}\n while mul < n do\n mul, stagenum = mul * 2, stagenum + 1\n self.cnt[stagenum], self.stage[stagenum] = mul, {}\n end\n for i = 1, stagenum do self.size[i] = self.cnt[stagenum + 1 - i] end\n self.stagenum = stagenum\n for i = 1, mul do self.stage[stagenum][i] = emptyvalue end\n self:updateAll()\nend\nSegTree.getRange = function(self, left, right)\n if left == right then return self.stage[self.stagenum][left] end\n local start_stage = 1\n while right - left + 1 < self.size[start_stage] do\n start_stage = start_stage + 1\n end\n local ret = self.emptyvalue\n local t1, t2, t3 = {start_stage}, {left}, {right}\n while 0 < #t1 do\n local stage, l, r = t1[#t1], t2[#t1], t3[#t1]\n table.remove(t1) table.remove(t2) table.remove(t3)\n local sz = self.size[stage]\n if (l - 1) % sz ~= 0 then\n local newr = mmi(r, mce((l - 1) / sz) * sz)\n table.insert(t1, stage + 1) table.insert(t2, l) table.insert(t3, newr)\n l = newr + 1\n end\n if sz <= r + 1 - l then\n ret = self.func(ret, self.stage[stage][mce(l / sz)])\n l = l + sz\n end\n if l <= r then\n table.insert(t1, stage + 1) table.insert(t2, l) table.insert(t3, r)\n end\n end\n return ret\nend\nSegTree.setValue = function(self, idx, value, silent)\n self.stage[self.stagenum][idx] = value\n if not silent then\n for i = self.stagenum - 1, 1, -1 do\n local dst = mce(idx / 2)\n local rem = dst * 4 - 1 - idx\n self.stage[i][dst] = self.func(self.stage[i + 1][idx], self.stage[i + 1][rem])\n idx = dst\n end\n end\nend\nSegTree.new = function(n, func, emptyvalue)\n local obj = {}\n setmetatable(obj, {__index = SegTree})\n obj:create(n, func, emptyvalue)\n return obj\nend\n\nlocal n = io.read(\"*n\")\nlocal edge = {}\nlocal asked = {}\nlocal cpos = {}\nlocal len = {}\nfor i = 1, n do\n edge[i] = {}\n asked[i] = false\n cpos[i] = 0\n len[i] = 0\nend\nlen[n + 1] = 100\nlocal line = {}\nfor i = 1, n - 1 do\n local x, y = io.read(\"*n\", \"*n\")\n table.insert(edge[x], y)\n table.insert(edge[y], x)\n line[i] = {x, y}\nend\n\nlocal tasks = {1}\nlocal posinv = {}\nfor i = 1, n do\n posinv[i] = 0\nend\nlocal eulers = {}\nwhile 0 < #tasks do\n local src = tasks[#tasks]\n table.remove(tasks)\n asked[src] = true\n table.insert(eulers, src)\n if posinv[src] == 0 then\n posinv[src] = #eulers\n end\n while cpos[src] < #edge[src] do\n cpos[src] = cpos[src] + 1\n local dst = edge[src][cpos[src]]\n if not asked[dst] then\n len[dst] = len[src] + 1\n table.insert(tasks, src)\n table.insert(tasks, dst)\n break\n end\n end\nend\nlocal lca = {}\nfor i = 1, #eulers do\n lca[i] = {}\n local prv = eulers[i]\n lca[i][1] = prv\n for j = i + 1, #eulers do\n lca[i][j - i + 1] = len[prv] < len[eulers[j]] and prv or eulers[j]\n prv = lca[i][j - i + 1]\n end\nend\nlocal stLine = SegTree.new(2 * n - 2, function(a, b) return a + b end, 0)\n\nlocal m = io.read(\"*n\")\nlocal mtot = 2^m\nlocal mbox = {}\nfor i = 1, mtot do\n mbox[i] = 0LL\nend\nmbox[1] = 1LL\nlocal posu, posv, posp = {}, {}, {}\nfor i = 1, m do\n local u, v = io.read(\"*n\", \"*n\")\n local pu, pv = posinv[u], posinv[v]\n if pv < pu then pu, pv = pv, pu end\n local p = lca[pu][pv - pu + 1]\n posu[i], posv[i], posp[i] = pu, pv, posinv[p]\nend\nlocal linepos = {}\nfor il = 1, n - 1 do\n linepos[il] = {}\n local lx, ly = line[il][1], line[il][2]\n for j = 1, #eulers - 1 do\n if lx == eulers[j] and ly == eulers[j + 1] then\n table.insert(linepos[il], j)\n elseif ly == eulers[j] and lx == eulers[j + 1] then\n table.insert(linepos[il], j)\n end\n end\nend\n\nfor il = 1, n - 1 do\n local lx, ly = line[il][1], line[il][2]\n local p1, p2 = linepos[il][1], linepos[il][2]\n stLine:setValue(p1, 1)\n stLine:setValue(p2, -1)\n local mul = 1\n local actsum = 0\n for im = 1, m do\n local pu, pv, pp = posu[im], posv[im], posp[im]\n if pv < pp then\n activate = 0 ~= stLine:getRange(pv, pp - 1)\n elseif pp < pv then\n activate = 0 ~= stLine:getRange(pp, pv - 1)\n end\n if not activate then\n if pu < pp then\n activate = 0 ~= stLine:getRange(pu, pp - 1)\n elseif pp < pu then\n activate = 0 ~= stLine:getRange(pp, pu - 1)\n end\n end\n if activate then\n actsum = actsum + mul\n end\n mul = mul * 2\n end\n for im = mtot, 1, -1 do\n local dst = getor(im - 1, actsum)\n mbox[dst + 1] = mbox[dst + 1] + mbox[im]\n end\n stLine:setValue(p1, 0)\n stLine:setValue(p2, 0)\nend\nlocal str = tostring(mbox[mtot]):gsub(\"LL\", \"\")\nprint(str)\n", "problem_context": "Score : 600 points\n\nProblem Statement\n\nWe have a tree with N vertices numbered 1 to N.\nThe i-th edge in this tree connects Vertex a_i and Vertex b_i.\n\nConsider painting each of these edges white or black. There are 2^{N-1} such ways to paint the edges. Among them, how many satisfy all of the following M restrictions?\n\nThe i-th (1 \\leq i \\leq M) restriction is represented by two integers u_i and v_i, which mean that the path connecting Vertex u_i and Vertex v_i must contain at least one edge painted black.\n\nConstraints\n\n2 \\leq N \\leq 50\n\n1 \\leq a_i,b_i \\leq N\n\nThe graph given in input is a tree.\n\n1 \\leq M \\leq \\min(20,\\frac{N(N-1)}{2})\n\n1 \\leq u_i < v_i \\leq N\n\nIf i \\not= j, either u_i \\not=u_j or v_i\\not=v_j\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 b_1\n:\na_{N-1} b_{N-1}\nM\nu_1 v_1\n:\nu_M v_M\n\nOutput\n\nPrint the number of ways to paint the edges that satisfy all of the M conditions.\n\nSample Input 1\n\n3\n1 2\n2 3\n1\n1 3\n\nSample Output 1\n\n3\n\nThe tree in this input is shown below:\n\nAll of the M restrictions will be satisfied if Edge 1 and 2 are respectively painted (white, black), (black, white), or (black, black), so the answer is 3.\n\nSample Input 2\n\n2\n1 2\n1\n1 2\n\nSample Output 2\n\n1\n\nThe tree in this input is shown below:\n\nAll of the M restrictions will be satisfied only if Edge 1 is painted black, so the answer is 1.\n\nSample Input 3\n\n5\n1 2\n3 2\n3 4\n5 3\n3\n1 3\n2 4\n2 5\n\nSample Output 3\n\n9\n\nThe tree in this input is shown below:\n\nSample Input 4\n\n8\n1 2\n2 3\n4 3\n2 5\n6 3\n6 7\n8 6\n5\n2 7\n3 5\n1 6\n2 8\n7 8\n\nSample Output 4\n\n62\n\nThe tree in this input is shown below:", "sample_input": "3\n1 2\n2 3\n1\n1 3\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02794", "source_text": "Score : 600 points\n\nProblem Statement\n\nWe have a tree with N vertices numbered 1 to N.\nThe i-th edge in this tree connects Vertex a_i and Vertex b_i.\n\nConsider painting each of these edges white or black. There are 2^{N-1} such ways to paint the edges. Among them, how many satisfy all of the following M restrictions?\n\nThe i-th (1 \\leq i \\leq M) restriction is represented by two integers u_i and v_i, which mean that the path connecting Vertex u_i and Vertex v_i must contain at least one edge painted black.\n\nConstraints\n\n2 \\leq N \\leq 50\n\n1 \\leq a_i,b_i \\leq N\n\nThe graph given in input is a tree.\n\n1 \\leq M \\leq \\min(20,\\frac{N(N-1)}{2})\n\n1 \\leq u_i < v_i \\leq N\n\nIf i \\not= j, either u_i \\not=u_j or v_i\\not=v_j\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 b_1\n:\na_{N-1} b_{N-1}\nM\nu_1 v_1\n:\nu_M v_M\n\nOutput\n\nPrint the number of ways to paint the edges that satisfy all of the M conditions.\n\nSample Input 1\n\n3\n1 2\n2 3\n1\n1 3\n\nSample Output 1\n\n3\n\nThe tree in this input is shown below:\n\nAll of the M restrictions will be satisfied if Edge 1 and 2 are respectively painted (white, black), (black, white), or (black, black), so the answer is 3.\n\nSample Input 2\n\n2\n1 2\n1\n1 2\n\nSample Output 2\n\n1\n\nThe tree in this input is shown below:\n\nAll of the M restrictions will be satisfied only if Edge 1 is painted black, so the answer is 1.\n\nSample Input 3\n\n5\n1 2\n3 2\n3 4\n5 3\n3\n1 3\n2 4\n2 5\n\nSample Output 3\n\n9\n\nThe tree in this input is shown below:\n\nSample Input 4\n\n8\n1 2\n2 3\n4 3\n2 5\n6 3\n6 7\n8 6\n5\n2 7\n3 5\n1 6\n2 8\n7 8\n\nSample Output 4\n\n62\n\nThe tree in this input is shown below:", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 5126, "cpu_time_ms": 4210, "memory_kb": 103552}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s357172454", "group_id": "codeNet:p02794", "input_text": "local mfl, mce, mmi = math.floor, math.ceil, math.min\n\nlocal function getor(x, y)\n if x == 0 then return y end\n if y == 0 then return x end\n local ret = 0\n local mul = 1\n while 0 < x or 0 < y do\n if 1 <= (x % 2) + (y % 2) then\n ret = ret + mul\n end\n x, y, mul = mfl(x / 2), mfl(y / 2), mul * 2\n end\n return ret\nend\n-- print(getor(1, 7)) os.exit()\n\nlocal SegTree = {}\nSegTree.updateAll = function(self)\n for i = self.stagenum - 1, 1, -1 do\n for j = 1, self.cnt[i] do\n self.stage[i][j] = self.func(self.stage[i + 1][j * 2 - 1], self.stage[i + 1][j * 2])\n end\n end\nend\nSegTree.create = function(self, n, func, emptyvalue)\n self.func, self.emptyvalue = func, emptyvalue\n local stagenum, mul = 1, 1\n self.cnt, self.stage, self.size = {1}, {{}}, {}\n while mul < n do\n mul, stagenum = mul * 2, stagenum + 1\n self.cnt[stagenum], self.stage[stagenum] = mul, {}\n end\n for i = 1, stagenum do self.size[i] = self.cnt[stagenum + 1 - i] end\n self.stagenum = stagenum\n for i = 1, mul do self.stage[stagenum][i] = emptyvalue end\n self:updateAll()\nend\nSegTree.getRange = function(self, left, right)\n if left == right then return self.stage[self.stagenum][left] end\n local start_stage = 1\n while right - left + 1 < self.size[start_stage] do\n start_stage = start_stage + 1\n end\n local ret = self.emptyvalue\n local t1, t2, t3 = {start_stage}, {left}, {right}\n while 0 < #t1 do\n local stage, l, r = t1[#t1], t2[#t1], t3[#t1]\n table.remove(t1) table.remove(t2) table.remove(t3)\n local sz = self.size[stage]\n if (l - 1) % sz ~= 0 then\n local newr = mmi(r, mce((l - 1) / sz) * sz)\n table.insert(t1, stage + 1) table.insert(t2, l) table.insert(t3, newr)\n l = newr + 1\n end\n if sz <= r + 1 - l then\n ret = self.func(ret, self.stage[stage][mce(l / sz)])\n l = l + sz\n end\n if l <= r then\n table.insert(t1, stage + 1) table.insert(t2, l) table.insert(t3, r)\n end\n end\n return ret\nend\nSegTree.setValue = function(self, idx, value, silent)\n self.stage[self.stagenum][idx] = value\n if not silent then\n for i = self.stagenum - 1, 1, -1 do\n local dst = mce(idx / 2)\n local rem = dst * 4 - 1 - idx\n self.stage[i][dst] = self.func(self.stage[i + 1][idx], self.stage[i + 1][rem])\n idx = dst\n end\n end\nend\nSegTree.new = function(n, func, emptyvalue)\n local obj = {}\n setmetatable(obj, {__index = SegTree})\n obj:create(n, func, emptyvalue)\n return obj\nend\n\nlocal n = io.read(\"*n\")\nlocal edge = {}\nlocal asked = {}\nlocal cpos = {}\nlocal len = {}\nfor i = 1, n do\n edge[i] = {}\n asked[i] = false\n cpos[i] = 0\n len[i] = 0\nend\nlen[n + 1] = 100\nlocal line = {}\nfor i = 1, n - 1 do\n local x, y = io.read(\"*n\", \"*n\")\n table.insert(edge[x], y)\n table.insert(edge[y], x)\n line[i] = {x, y}\nend\n\nlocal st = SegTree.new(2 * n - 1, function(a, b)\n return len[a] < len[b] and a or b end,\n n + 1\n)\n\nlocal tasks = {1}\nlocal posinv = {}\nfor i = 1, n do\n posinv[i] = 0\nend\nlocal eulers = {}\nwhile 0 < #tasks do\n local src = tasks[#tasks]\n table.remove(tasks)\n asked[src] = true\n table.insert(eulers, src)\n st:setValue(#eulers, src)\n if posinv[src] == 0 then\n posinv[src] = #eulers\n end\n while cpos[src] < #edge[src] do\n cpos[src] = cpos[src] + 1\n local dst = edge[src][cpos[src]]\n if not asked[dst] then\n len[dst] = len[src] + 1\n table.insert(tasks, src)\n table.insert(tasks, dst)\n break\n end\n end\nend\nlocal stLine = SegTree.new(2 * n - 2, function(a, b) return a + b end, 0)\n\nlocal m = io.read(\"*n\")\nlocal mtot = 2^m\nlocal mbox = {}\nfor i = 1, mtot do\n mbox[i] = 0\nend\nmbox[1] = 1\nlocal mu, mv = {}, {}\nfor i = 1, m do\n mu[i], mv[i] = io.read(\"*n\", \"*n\")\nend\nlocal linepos = {}\nfor il = 1, n - 1 do\n linepos[il] = {}\n local lx, ly = line[il][1], line[il][2]\n for j = 1, #eulers - 1 do\n if lx == eulers[j] and ly == eulers[j + 1] then\n table.insert(linepos[il], j)\n elseif ly == eulers[j] and lx == eulers[j + 1] then\n table.insert(linepos[il], j)\n end\n end\nend\n\nfor il = 1, n - 1 do\n local lx, ly = line[il][1], line[il][2]\n local p1, p2 = linepos[il][1], linepos[il][2]\n stLine:setValue(p1, 1)\n stLine:setValue(p2, -1)\n local mul = 1\n local actsum = 0\n for im = 1, m do\n local u, v = mu[im], mv[im]\n local pu, pv = posinv[u], posinv[v]\n if pv < pu then pu, pv = pv, pu end\n local parent = st:getRange(pu, pv)\n local activate = false\n local pp = posinv[parent]\n if pv < pp then\n activate = 1 == stLine:getRange(pv, pp - 1)\n elseif pp < pv then\n activate = 1 == stLine:getRange(pp, pv - 1)\n end\n if not activate then\n if pu < pp then\n activate = 1 == stLine:getRange(pu, pp - 1)\n elseif pp < pu then\n activate = 1 == stLine:getRange(pp, pu - 1)\n end\n end\n if activate then\n actsum = actsum + mul\n end\n mul = mul * 2\n end\n if 0 < actsum then\n end\n -- print(\"IL\", il, actsum)\n for im = mtot, 1, -1 do\n local src = im - 1\n local dst = getor(src, actsum)\n -- print(\"a \" .. src .. \" \" .. dst)\n mbox[dst + 1] = mbox[dst + 1] + mbox[src + 1]\n end\n stLine:setValue(p1, 0)\n stLine:setValue(p2, 0)\n -- print(table.concat(mbox, \" \"))\nend\n-- print(table.concat(mbox, \" \"))\nprint(mbox[mtot])\n", "language": "Lua", "metadata": {"date": 1579469113, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p02794.html", "problem_id": "p02794", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02794/input.txt", "sample_output_relpath": "derived/input_output/data/p02794/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02794/Lua/s357172454.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s357172454", "user_id": "u120582723"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "local mfl, mce, mmi = math.floor, math.ceil, math.min\n\nlocal function getor(x, y)\n if x == 0 then return y end\n if y == 0 then return x end\n local ret = 0\n local mul = 1\n while 0 < x or 0 < y do\n if 1 <= (x % 2) + (y % 2) then\n ret = ret + mul\n end\n x, y, mul = mfl(x / 2), mfl(y / 2), mul * 2\n end\n return ret\nend\n-- print(getor(1, 7)) os.exit()\n\nlocal SegTree = {}\nSegTree.updateAll = function(self)\n for i = self.stagenum - 1, 1, -1 do\n for j = 1, self.cnt[i] do\n self.stage[i][j] = self.func(self.stage[i + 1][j * 2 - 1], self.stage[i + 1][j * 2])\n end\n end\nend\nSegTree.create = function(self, n, func, emptyvalue)\n self.func, self.emptyvalue = func, emptyvalue\n local stagenum, mul = 1, 1\n self.cnt, self.stage, self.size = {1}, {{}}, {}\n while mul < n do\n mul, stagenum = mul * 2, stagenum + 1\n self.cnt[stagenum], self.stage[stagenum] = mul, {}\n end\n for i = 1, stagenum do self.size[i] = self.cnt[stagenum + 1 - i] end\n self.stagenum = stagenum\n for i = 1, mul do self.stage[stagenum][i] = emptyvalue end\n self:updateAll()\nend\nSegTree.getRange = function(self, left, right)\n if left == right then return self.stage[self.stagenum][left] end\n local start_stage = 1\n while right - left + 1 < self.size[start_stage] do\n start_stage = start_stage + 1\n end\n local ret = self.emptyvalue\n local t1, t2, t3 = {start_stage}, {left}, {right}\n while 0 < #t1 do\n local stage, l, r = t1[#t1], t2[#t1], t3[#t1]\n table.remove(t1) table.remove(t2) table.remove(t3)\n local sz = self.size[stage]\n if (l - 1) % sz ~= 0 then\n local newr = mmi(r, mce((l - 1) / sz) * sz)\n table.insert(t1, stage + 1) table.insert(t2, l) table.insert(t3, newr)\n l = newr + 1\n end\n if sz <= r + 1 - l then\n ret = self.func(ret, self.stage[stage][mce(l / sz)])\n l = l + sz\n end\n if l <= r then\n table.insert(t1, stage + 1) table.insert(t2, l) table.insert(t3, r)\n end\n end\n return ret\nend\nSegTree.setValue = function(self, idx, value, silent)\n self.stage[self.stagenum][idx] = value\n if not silent then\n for i = self.stagenum - 1, 1, -1 do\n local dst = mce(idx / 2)\n local rem = dst * 4 - 1 - idx\n self.stage[i][dst] = self.func(self.stage[i + 1][idx], self.stage[i + 1][rem])\n idx = dst\n end\n end\nend\nSegTree.new = function(n, func, emptyvalue)\n local obj = {}\n setmetatable(obj, {__index = SegTree})\n obj:create(n, func, emptyvalue)\n return obj\nend\n\nlocal n = io.read(\"*n\")\nlocal edge = {}\nlocal asked = {}\nlocal cpos = {}\nlocal len = {}\nfor i = 1, n do\n edge[i] = {}\n asked[i] = false\n cpos[i] = 0\n len[i] = 0\nend\nlen[n + 1] = 100\nlocal line = {}\nfor i = 1, n - 1 do\n local x, y = io.read(\"*n\", \"*n\")\n table.insert(edge[x], y)\n table.insert(edge[y], x)\n line[i] = {x, y}\nend\n\nlocal st = SegTree.new(2 * n - 1, function(a, b)\n return len[a] < len[b] and a or b end,\n n + 1\n)\n\nlocal tasks = {1}\nlocal posinv = {}\nfor i = 1, n do\n posinv[i] = 0\nend\nlocal eulers = {}\nwhile 0 < #tasks do\n local src = tasks[#tasks]\n table.remove(tasks)\n asked[src] = true\n table.insert(eulers, src)\n st:setValue(#eulers, src)\n if posinv[src] == 0 then\n posinv[src] = #eulers\n end\n while cpos[src] < #edge[src] do\n cpos[src] = cpos[src] + 1\n local dst = edge[src][cpos[src]]\n if not asked[dst] then\n len[dst] = len[src] + 1\n table.insert(tasks, src)\n table.insert(tasks, dst)\n break\n end\n end\nend\nlocal stLine = SegTree.new(2 * n - 2, function(a, b) return a + b end, 0)\n\nlocal m = io.read(\"*n\")\nlocal mtot = 2^m\nlocal mbox = {}\nfor i = 1, mtot do\n mbox[i] = 0\nend\nmbox[1] = 1\nlocal mu, mv = {}, {}\nfor i = 1, m do\n mu[i], mv[i] = io.read(\"*n\", \"*n\")\nend\nlocal linepos = {}\nfor il = 1, n - 1 do\n linepos[il] = {}\n local lx, ly = line[il][1], line[il][2]\n for j = 1, #eulers - 1 do\n if lx == eulers[j] and ly == eulers[j + 1] then\n table.insert(linepos[il], j)\n elseif ly == eulers[j] and lx == eulers[j + 1] then\n table.insert(linepos[il], j)\n end\n end\nend\n\nfor il = 1, n - 1 do\n local lx, ly = line[il][1], line[il][2]\n local p1, p2 = linepos[il][1], linepos[il][2]\n stLine:setValue(p1, 1)\n stLine:setValue(p2, -1)\n local mul = 1\n local actsum = 0\n for im = 1, m do\n local u, v = mu[im], mv[im]\n local pu, pv = posinv[u], posinv[v]\n if pv < pu then pu, pv = pv, pu end\n local parent = st:getRange(pu, pv)\n local activate = false\n local pp = posinv[parent]\n if pv < pp then\n activate = 1 == stLine:getRange(pv, pp - 1)\n elseif pp < pv then\n activate = 1 == stLine:getRange(pp, pv - 1)\n end\n if not activate then\n if pu < pp then\n activate = 1 == stLine:getRange(pu, pp - 1)\n elseif pp < pu then\n activate = 1 == stLine:getRange(pp, pu - 1)\n end\n end\n if activate then\n actsum = actsum + mul\n end\n mul = mul * 2\n end\n if 0 < actsum then\n end\n -- print(\"IL\", il, actsum)\n for im = mtot, 1, -1 do\n local src = im - 1\n local dst = getor(src, actsum)\n -- print(\"a \" .. src .. \" \" .. dst)\n mbox[dst + 1] = mbox[dst + 1] + mbox[src + 1]\n end\n stLine:setValue(p1, 0)\n stLine:setValue(p2, 0)\n -- print(table.concat(mbox, \" \"))\nend\n-- print(table.concat(mbox, \" \"))\nprint(mbox[mtot])\n", "problem_context": "Score : 600 points\n\nProblem Statement\n\nWe have a tree with N vertices numbered 1 to N.\nThe i-th edge in this tree connects Vertex a_i and Vertex b_i.\n\nConsider painting each of these edges white or black. There are 2^{N-1} such ways to paint the edges. Among them, how many satisfy all of the following M restrictions?\n\nThe i-th (1 \\leq i \\leq M) restriction is represented by two integers u_i and v_i, which mean that the path connecting Vertex u_i and Vertex v_i must contain at least one edge painted black.\n\nConstraints\n\n2 \\leq N \\leq 50\n\n1 \\leq a_i,b_i \\leq N\n\nThe graph given in input is a tree.\n\n1 \\leq M \\leq \\min(20,\\frac{N(N-1)}{2})\n\n1 \\leq u_i < v_i \\leq N\n\nIf i \\not= j, either u_i \\not=u_j or v_i\\not=v_j\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 b_1\n:\na_{N-1} b_{N-1}\nM\nu_1 v_1\n:\nu_M v_M\n\nOutput\n\nPrint the number of ways to paint the edges that satisfy all of the M conditions.\n\nSample Input 1\n\n3\n1 2\n2 3\n1\n1 3\n\nSample Output 1\n\n3\n\nThe tree in this input is shown below:\n\nAll of the M restrictions will be satisfied if Edge 1 and 2 are respectively painted (white, black), (black, white), or (black, black), so the answer is 3.\n\nSample Input 2\n\n2\n1 2\n1\n1 2\n\nSample Output 2\n\n1\n\nThe tree in this input is shown below:\n\nAll of the M restrictions will be satisfied only if Edge 1 is painted black, so the answer is 1.\n\nSample Input 3\n\n5\n1 2\n3 2\n3 4\n5 3\n3\n1 3\n2 4\n2 5\n\nSample Output 3\n\n9\n\nThe tree in this input is shown below:\n\nSample Input 4\n\n8\n1 2\n2 3\n4 3\n2 5\n6 3\n6 7\n8 6\n5\n2 7\n3 5\n1 6\n2 8\n7 8\n\nSample Output 4\n\n62\n\nThe tree in this input is shown below:", "sample_input": "3\n1 2\n2 3\n1\n1 3\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02794", "source_text": "Score : 600 points\n\nProblem Statement\n\nWe have a tree with N vertices numbered 1 to N.\nThe i-th edge in this tree connects Vertex a_i and Vertex b_i.\n\nConsider painting each of these edges white or black. There are 2^{N-1} such ways to paint the edges. Among them, how many satisfy all of the following M restrictions?\n\nThe i-th (1 \\leq i \\leq M) restriction is represented by two integers u_i and v_i, which mean that the path connecting Vertex u_i and Vertex v_i must contain at least one edge painted black.\n\nConstraints\n\n2 \\leq N \\leq 50\n\n1 \\leq a_i,b_i \\leq N\n\nThe graph given in input is a tree.\n\n1 \\leq M \\leq \\min(20,\\frac{N(N-1)}{2})\n\n1 \\leq u_i < v_i \\leq N\n\nIf i \\not= j, either u_i \\not=u_j or v_i\\not=v_j\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 b_1\n:\na_{N-1} b_{N-1}\nM\nu_1 v_1\n:\nu_M v_M\n\nOutput\n\nPrint the number of ways to paint the edges that satisfy all of the M conditions.\n\nSample Input 1\n\n3\n1 2\n2 3\n1\n1 3\n\nSample Output 1\n\n3\n\nThe tree in this input is shown below:\n\nAll of the M restrictions will be satisfied if Edge 1 and 2 are respectively painted (white, black), (black, white), or (black, black), so the answer is 3.\n\nSample Input 2\n\n2\n1 2\n1\n1 2\n\nSample Output 2\n\n1\n\nThe tree in this input is shown below:\n\nAll of the M restrictions will be satisfied only if Edge 1 is painted black, so the answer is 1.\n\nSample Input 3\n\n5\n1 2\n3 2\n3 4\n5 3\n3\n1 3\n2 4\n2 5\n\nSample Output 3\n\n9\n\nThe tree in this input is shown below:\n\nSample Input 4\n\n8\n1 2\n2 3\n4 3\n2 5\n6 3\n6 7\n8 6\n5\n2 7\n3 5\n1 6\n2 8\n7 8\n\nSample Output 4\n\n62\n\nThe tree in this input is shown below:", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 5266, "cpu_time_ms": 4207, "memory_kb": 10880}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s644595775", "group_id": "codeNet:p02795", "input_text": "local h, w, n = io.read(\"*n\", \"*n\", \"*n\")\nprint(math.min(math.ceil(n / w), math.ceil(n / h)))\n", "language": "Lua", "metadata": {"date": 1579379526, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p02795.html", "problem_id": "p02795", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02795/input.txt", "sample_output_relpath": "derived/input_output/data/p02795/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02795/Lua/s644595775.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s644595775", "user_id": "u120582723"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "local h, w, n = io.read(\"*n\", \"*n\", \"*n\")\nprint(math.min(math.ceil(n / w), math.ceil(n / h)))\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nWe have a grid with H rows and W columns, where all the squares are initially white.\n\nYou will perform some number of painting operations on the grid.\nIn one operation, you can do one of the following two actions:\n\nChoose one row, then paint all the squares in that row black.\n\nChoose one column, then paint all the squares in that column black.\n\nAt least how many operations do you need in order to have N or more black squares in the grid?\nIt is guaranteed that, under the conditions in Constraints, having N or more black squares is always possible by performing some number of operations.\n\nConstraints\n\n1 \\leq H \\leq 100\n\n1 \\leq W \\leq 100\n\n1 \\leq N \\leq H \\times W\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH\nW\nN\n\nOutput\n\nPrint the minimum number of operations needed.\n\nSample Input 1\n\n3\n7\n10\n\nSample Output 1\n\n2\n\nYou can have 14 black squares in the grid by performing the \"row\" operation twice, on different rows.\n\nSample Input 2\n\n14\n12\n112\n\nSample Output 2\n\n8\n\nSample Input 3\n\n2\n100\n200\n\nSample Output 3\n\n2", "sample_input": "3\n7\n10\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02795", "source_text": "Score : 100 points\n\nProblem Statement\n\nWe have a grid with H rows and W columns, where all the squares are initially white.\n\nYou will perform some number of painting operations on the grid.\nIn one operation, you can do one of the following two actions:\n\nChoose one row, then paint all the squares in that row black.\n\nChoose one column, then paint all the squares in that column black.\n\nAt least how many operations do you need in order to have N or more black squares in the grid?\nIt is guaranteed that, under the conditions in Constraints, having N or more black squares is always possible by performing some number of operations.\n\nConstraints\n\n1 \\leq H \\leq 100\n\n1 \\leq W \\leq 100\n\n1 \\leq N \\leq H \\times W\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH\nW\nN\n\nOutput\n\nPrint the minimum number of operations needed.\n\nSample Input 1\n\n3\n7\n10\n\nSample Output 1\n\n2\n\nYou can have 14 black squares in the grid by performing the \"row\" operation twice, on different rows.\n\nSample Input 2\n\n14\n12\n112\n\nSample Output 2\n\n8\n\nSample Input 3\n\n2\n100\n200\n\nSample Output 3\n\n2", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 94, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s873547735", "group_id": "codeNet:p02796", "input_text": "local mma = math.max\nlocal mfl, mce, mmi = math.floor, math.ceil, math.min\nlocal SegTree = {}\nSegTree.updateAll = function(self)\n for i = self.stagenum - 1, 1, -1 do\n for j = 1, self.cnt[i] do\n self.stage[i][j] = self.func(self.stage[i + 1][j * 2 - 1], self.stage[i + 1][j * 2])\n end\n end\nend\nSegTree.create = function(self, n, func, emptyvalue)\n self.func, self.emptyvalue = func, emptyvalue\n local stagenum, mul = 1, 1\n self.cnt, self.stage, self.size = {1}, {{}}, {}\n while mul < n do\n mul, stagenum = mul * 2, stagenum + 1\n self.cnt[stagenum], self.stage[stagenum] = mul, {}\n end\n for i = 1, stagenum do self.size[i] = self.cnt[stagenum + 1 - i] end\n self.stagenum = stagenum\n for i = 1, mul do self.stage[stagenum][i] = emptyvalue end\n self:updateAll()\nend\nSegTree.getRange = function(self, left, right)\n if left == right then return self.stage[self.stagenum][left] end\n local start_stage = 1\n while right - left + 1 < self.size[start_stage] do\n start_stage = start_stage + 1\n end\n local ret = self.emptyvalue\n local t1, t2, t3 = {start_stage}, {left}, {right}\n while 0 < #t1 do\n local stage, l, r = t1[#t1], t2[#t1], t3[#t1]\n table.remove(t1) table.remove(t2) table.remove(t3)\n local sz = self.size[stage]\n if (l - 1) % sz ~= 0 then\n local newr = mmi(r, mce((l - 1) / sz) * sz)\n table.insert(t1, stage + 1) table.insert(t2, l) table.insert(t3, newr)\n l = newr + 1\n end\n if sz <= r + 1 - l then\n ret = self.func(ret, self.stage[stage][mce(l / sz)])\n l = l + sz\n end\n if l <= r then\n table.insert(t1, stage + 1) table.insert(t2, l) table.insert(t3, r)\n end\n end\n return ret\nend\nSegTree.setValue = function(self, idx, value, silent)\n self.stage[self.stagenum][idx] = value\n if not silent then\n for i = self.stagenum - 1, 1, -1 do\n local dst = mce(idx / 2)\n local rem = dst * 4 - 1 - idx\n self.stage[i][dst] = self.func(self.stage[i + 1][idx], self.stage[i + 1][rem])\n idx = dst\n end\n end\nend\nSegTree.new = function(n, func, emptyvalue)\n local obj = {}\n setmetatable(obj, {__index = SegTree})\n obj:create(n, func, emptyvalue)\n return obj\nend\n\nlocal n = io.read(\"*n\")\nlocal robo = {}\nlocal z = {}\nlocal zmap = {}\nfor i = 1, n do\n local a, b = io.read(\"*n\", \"*n\")\n if not zmap[a - b] then\n table.insert(z, a - b)\n zmap[a - b] = true\n end\n if not zmap[a + b] then\n table.insert(z, a + b)\n zmap[a + b] = true\n end\n robo[i] = {a - b, a + b}\nend\ntable.sort(z)\nlocal zinv = {}\nlocal st = SegTree.new(#z, mma, 0)\nfor i = 1, #z do\n zinv[z[i]] = i\nend\ntable.sort(robo, function(a, b) return a[1] < b[1] end)\nfor i = 1, n do\n local left, right = robo[i][1], robo[i][2]\n local lp, rp = zinv[left], zinv[right]\n local cur = st:getRange(1, lp)\n local nxt = mma(st:getRange(rp, rp), cur + 1)\n st:setValue(rp, nxt)\nend\nlocal tot = st:getRange(1, #z)\nprint(tot)\n", "language": "Lua", "metadata": {"date": 1579380122, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p02796.html", "problem_id": "p02796", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02796/input.txt", "sample_output_relpath": "derived/input_output/data/p02796/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02796/Lua/s873547735.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s873547735", "user_id": "u120582723"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "local mma = math.max\nlocal mfl, mce, mmi = math.floor, math.ceil, math.min\nlocal SegTree = {}\nSegTree.updateAll = function(self)\n for i = self.stagenum - 1, 1, -1 do\n for j = 1, self.cnt[i] do\n self.stage[i][j] = self.func(self.stage[i + 1][j * 2 - 1], self.stage[i + 1][j * 2])\n end\n end\nend\nSegTree.create = function(self, n, func, emptyvalue)\n self.func, self.emptyvalue = func, emptyvalue\n local stagenum, mul = 1, 1\n self.cnt, self.stage, self.size = {1}, {{}}, {}\n while mul < n do\n mul, stagenum = mul * 2, stagenum + 1\n self.cnt[stagenum], self.stage[stagenum] = mul, {}\n end\n for i = 1, stagenum do self.size[i] = self.cnt[stagenum + 1 - i] end\n self.stagenum = stagenum\n for i = 1, mul do self.stage[stagenum][i] = emptyvalue end\n self:updateAll()\nend\nSegTree.getRange = function(self, left, right)\n if left == right then return self.stage[self.stagenum][left] end\n local start_stage = 1\n while right - left + 1 < self.size[start_stage] do\n start_stage = start_stage + 1\n end\n local ret = self.emptyvalue\n local t1, t2, t3 = {start_stage}, {left}, {right}\n while 0 < #t1 do\n local stage, l, r = t1[#t1], t2[#t1], t3[#t1]\n table.remove(t1) table.remove(t2) table.remove(t3)\n local sz = self.size[stage]\n if (l - 1) % sz ~= 0 then\n local newr = mmi(r, mce((l - 1) / sz) * sz)\n table.insert(t1, stage + 1) table.insert(t2, l) table.insert(t3, newr)\n l = newr + 1\n end\n if sz <= r + 1 - l then\n ret = self.func(ret, self.stage[stage][mce(l / sz)])\n l = l + sz\n end\n if l <= r then\n table.insert(t1, stage + 1) table.insert(t2, l) table.insert(t3, r)\n end\n end\n return ret\nend\nSegTree.setValue = function(self, idx, value, silent)\n self.stage[self.stagenum][idx] = value\n if not silent then\n for i = self.stagenum - 1, 1, -1 do\n local dst = mce(idx / 2)\n local rem = dst * 4 - 1 - idx\n self.stage[i][dst] = self.func(self.stage[i + 1][idx], self.stage[i + 1][rem])\n idx = dst\n end\n end\nend\nSegTree.new = function(n, func, emptyvalue)\n local obj = {}\n setmetatable(obj, {__index = SegTree})\n obj:create(n, func, emptyvalue)\n return obj\nend\n\nlocal n = io.read(\"*n\")\nlocal robo = {}\nlocal z = {}\nlocal zmap = {}\nfor i = 1, n do\n local a, b = io.read(\"*n\", \"*n\")\n if not zmap[a - b] then\n table.insert(z, a - b)\n zmap[a - b] = true\n end\n if not zmap[a + b] then\n table.insert(z, a + b)\n zmap[a + b] = true\n end\n robo[i] = {a - b, a + b}\nend\ntable.sort(z)\nlocal zinv = {}\nlocal st = SegTree.new(#z, mma, 0)\nfor i = 1, #z do\n zinv[z[i]] = i\nend\ntable.sort(robo, function(a, b) return a[1] < b[1] end)\nfor i = 1, n do\n local left, right = robo[i][1], robo[i][2]\n local lp, rp = zinv[left], zinv[right]\n local cur = st:getRange(1, lp)\n local nxt = mma(st:getRange(rp, rp), cur + 1)\n st:setValue(rp, nxt)\nend\nlocal tot = st:getRange(1, #z)\nprint(tot)\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nIn a factory, there are N robots placed on a number line.\nRobot i is placed at coordinate X_i and can extend its arms of length L_i in both directions, positive and negative.\n\nWe want to remove zero or more robots so that the movable ranges of arms of no two remaining robots intersect.\nHere, for each i (1 \\leq i \\leq N), the movable range of arms of Robot i is the part of the number line between the coordinates X_i - L_i and X_i + L_i, excluding the endpoints.\n\nFind the maximum number of robots that we can keep.\n\nConstraints\n\n1 \\leq N \\leq 100,000\n\n0 \\leq X_i \\leq 10^9 (1 \\leq i \\leq N)\n\n1 \\leq L_i \\leq 10^9 (1 \\leq i \\leq N)\n\nIf i \\neq j, X_i \\neq X_j.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nX_1 L_1\nX_2 L_2\n\\vdots\nX_N L_N\n\nOutput\n\nPrint the maximum number of robots that we can keep.\n\nSample Input 1\n\n4\n2 4\n4 3\n9 3\n100 5\n\nSample Output 1\n\n3\n\nBy removing Robot 2, we can keep the other three robots.\n\nSample Input 2\n\n2\n8 20\n1 10\n\nSample Output 2\n\n1\n\nSample Input 3\n\n5\n10 1\n2 1\n4 1\n6 1\n8 1\n\nSample Output 3\n\n5", "sample_input": "4\n2 4\n4 3\n9 3\n100 5\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02796", "source_text": "Score : 200 points\n\nProblem Statement\n\nIn a factory, there are N robots placed on a number line.\nRobot i is placed at coordinate X_i and can extend its arms of length L_i in both directions, positive and negative.\n\nWe want to remove zero or more robots so that the movable ranges of arms of no two remaining robots intersect.\nHere, for each i (1 \\leq i \\leq N), the movable range of arms of Robot i is the part of the number line between the coordinates X_i - L_i and X_i + L_i, excluding the endpoints.\n\nFind the maximum number of robots that we can keep.\n\nConstraints\n\n1 \\leq N \\leq 100,000\n\n0 \\leq X_i \\leq 10^9 (1 \\leq i \\leq N)\n\n1 \\leq L_i \\leq 10^9 (1 \\leq i \\leq N)\n\nIf i \\neq j, X_i \\neq X_j.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nX_1 L_1\nX_2 L_2\n\\vdots\nX_N L_N\n\nOutput\n\nPrint the maximum number of robots that we can keep.\n\nSample Input 1\n\n4\n2 4\n4 3\n9 3\n100 5\n\nSample Output 1\n\n3\n\nBy removing Robot 2, we can keep the other three robots.\n\nSample Input 2\n\n2\n8 20\n1 10\n\nSample Output 2\n\n1\n\nSample Input 3\n\n5\n10 1\n2 1\n4 1\n6 1\n8 1\n\nSample Output 3\n\n5", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2901, "cpu_time_ms": 511, "memory_kb": 44856}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s111370085", "group_id": "codeNet:p02799", "input_text": "local n, m = io.read(\"*n\", \"*n\")\nlocal d = {}\nlocal d_short_idx = {}\nlocal edge = {}\nlocal color = {}\nlocal inf = 1000000007 - 7\nfor i = 1, n do\n d[i] = io.read(\"*n\")\n edge[i] = {}\n color[i] = 0\n d_short_idx[i] = i\nend\ntable.sort(d_short_idx, function(a, b) return d[a] < d[b] end)\nlocal edgeinfo = {}\nfor i = 1, m do\n local a, b = io.read(\"*n\", \"*n\")\n edgeinfo[i] = {a, b, 0}\n table.insert(edge[a], i)\n table.insert(edge[b], i)\nend\n\nfor id = 1, n do\n local src = d_short_idx[id]\n local asked_edge_color = false\n local samelevel_edge_found = false\n for i = 1, #edge[src] do\n local edge_idx = edge[src][i]\n local e1, e2 = edgeinfo[edge_idx][1], edgeinfo[edge_idx][2]\n local dst = src == e1 and e2 or e1\n if 0 < color[dst] then\n asked_edge_color = color[dst]\n end\n if d[dst] == d[src] then\n samelevel_edge_found = true\n end\n end\n if asked_edge_color then\n color[src] = 3 - asked_edge_color\n for i = 1, #edge[src] do\n local edge_idx = edge[src][i]\n local e1, e2 = edgeinfo[edge_idx][1], edgeinfo[edge_idx][2]\n local dst = src == e1 and e2 or e1\n if color[dst] == color[src] then\n edgeinfo[edge_idx][3] = inf\n else\n edgeinfo[edge_idx][3] = d[src]\n end\n end\n elseif samelevel_edge_found then\n color[src] = 1\n else\n print(-1) os.exit()\n end\nend\nfor i = 1, n do\n io.write(color[i] == 1 and \"W\" or \"B\")\nend\nio.write(\"\\n\")\nfor i = 1, m do\n print(edgeinfo[i][3])\nend\n", "language": "Lua", "metadata": {"date": 1600776724, "filename_ext": "lua", "original_language": "Lua (LuaJIT 2.1.0)", "problem_description_relpath": "problem_descriptions/p02799.html", "problem_id": "p02799", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02799/input.txt", "sample_output_relpath": "derived/input_output/data/p02799/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02799/Lua/s111370085.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s111370085", "user_id": "u120582723"}, "prompt_components": {"gold_output": "BWWBB\n4\n3\n1\n5\n2\n", "input_to_evaluate": "local n, m = io.read(\"*n\", \"*n\")\nlocal d = {}\nlocal d_short_idx = {}\nlocal edge = {}\nlocal color = {}\nlocal inf = 1000000007 - 7\nfor i = 1, n do\n d[i] = io.read(\"*n\")\n edge[i] = {}\n color[i] = 0\n d_short_idx[i] = i\nend\ntable.sort(d_short_idx, function(a, b) return d[a] < d[b] end)\nlocal edgeinfo = {}\nfor i = 1, m do\n local a, b = io.read(\"*n\", \"*n\")\n edgeinfo[i] = {a, b, 0}\n table.insert(edge[a], i)\n table.insert(edge[b], i)\nend\n\nfor id = 1, n do\n local src = d_short_idx[id]\n local asked_edge_color = false\n local samelevel_edge_found = false\n for i = 1, #edge[src] do\n local edge_idx = edge[src][i]\n local e1, e2 = edgeinfo[edge_idx][1], edgeinfo[edge_idx][2]\n local dst = src == e1 and e2 or e1\n if 0 < color[dst] then\n asked_edge_color = color[dst]\n end\n if d[dst] == d[src] then\n samelevel_edge_found = true\n end\n end\n if asked_edge_color then\n color[src] = 3 - asked_edge_color\n for i = 1, #edge[src] do\n local edge_idx = edge[src][i]\n local e1, e2 = edgeinfo[edge_idx][1], edgeinfo[edge_idx][2]\n local dst = src == e1 and e2 or e1\n if color[dst] == color[src] then\n edgeinfo[edge_idx][3] = inf\n else\n edgeinfo[edge_idx][3] = d[src]\n end\n end\n elseif samelevel_edge_found then\n color[src] = 1\n else\n print(-1) os.exit()\n end\nend\nfor i = 1, n do\n io.write(color[i] == 1 and \"W\" or \"B\")\nend\nio.write(\"\\n\")\nfor i = 1, m do\n print(edgeinfo[i][3])\nend\n", "problem_context": "Score : 900 points\n\nProblem Statement\n\nWe have a connected undirected graph with N vertices and M edges.\nEdge i in this graph (1 \\leq i \\leq M) connects Vertex U_i and Vertex V_i bidirectionally.\nWe are additionally given N integers D_1, D_2, ..., D_N.\n\nDetermine whether the conditions below can be satisfied by assigning a color - white or black - to each vertex and an integer weight between 1 and 10^9 (inclusive) to each edge in this graph.\nIf the answer is yes, find one such assignment of colors and integers, too.\n\nThere is at least one vertex assigned white and at least one vertex assigned black.\n\nFor each vertex v (1 \\leq v \\leq N), the following holds.\n\nThe minimum cost to travel from Vertex v to a vertex whose color assigned is different from that of Vertex v by traversing the edges is equal to D_v.\n\nHere, the cost of traversing the edges is the sum of the weights of the edges traversed.\n\nConstraints\n\n2 \\leq N \\leq 100,000\n\n1 \\leq M \\leq 200,000\n\n1 \\leq D_i \\leq 10^9\n\n1 \\leq U_i, V_i \\leq N\n\nThe given graph is connected and has no self-loops or multiple edges.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nD_1 D_2 ... D_N\nU_1 V_1\nU_2 V_2\n\\vdots\nU_M V_M\n\nOutput\n\nIf there is no assignment satisfying the conditions, print a single line containing -1.\n\nIf such an assignment exists, print one such assignment in the following format:\n\nS\nC_1\nC_2\n\\vdots\nC_M\n\nHere,\n\nthe first line should contain the string S of length N. Its i-th character (1 \\leq i \\leq N) should be W if Vertex i is assigned white and B if it is assigned black.\n\nThe (i + 1)-th line (1 \\leq i \\leq M) should contain the integer weight C_i assigned to Edge i.\n\nSample Input 1\n\n5 5\n3 4 3 5 7\n1 2\n1 3\n3 2\n4 2\n4 5\n\nSample Output 1\n\nBWWBB\n4\n3\n1\n5\n2\n\nAssume that we assign the colors and integers as the sample output, and let us consider Vertex 5, for example. To travel from Vertex 5, which is assigned black, to a vertex that is assigned white with the minimum cost, we should make these moves: Vertex 5 \\to Vertex 4 \\to Vertex 2. The total cost of these moves is 7, which satisfies the condition. We can also verify that the condition is satisfied for other vertices.\n\nSample Input 2\n\n5 7\n1 2 3 4 5\n1 2\n1 3\n1 4\n2 3\n2 5\n3 5\n4 5\n\nSample Output 2\n\n-1\n\nSample Input 3\n\n4 6\n1 1 1 1\n1 2\n1 3\n1 4\n2 3\n2 4\n3 4\n\nSample Output 3\n\nBBBW\n1\n1\n1\n2\n1\n1", "sample_input": "5 5\n3 4 3 5 7\n1 2\n1 3\n3 2\n4 2\n4 5\n"}, "reference_outputs": ["BWWBB\n4\n3\n1\n5\n2\n"], "source_document_id": "p02799", "source_text": "Score : 900 points\n\nProblem Statement\n\nWe have a connected undirected graph with N vertices and M edges.\nEdge i in this graph (1 \\leq i \\leq M) connects Vertex U_i and Vertex V_i bidirectionally.\nWe are additionally given N integers D_1, D_2, ..., D_N.\n\nDetermine whether the conditions below can be satisfied by assigning a color - white or black - to each vertex and an integer weight between 1 and 10^9 (inclusive) to each edge in this graph.\nIf the answer is yes, find one such assignment of colors and integers, too.\n\nThere is at least one vertex assigned white and at least one vertex assigned black.\n\nFor each vertex v (1 \\leq v \\leq N), the following holds.\n\nThe minimum cost to travel from Vertex v to a vertex whose color assigned is different from that of Vertex v by traversing the edges is equal to D_v.\n\nHere, the cost of traversing the edges is the sum of the weights of the edges traversed.\n\nConstraints\n\n2 \\leq N \\leq 100,000\n\n1 \\leq M \\leq 200,000\n\n1 \\leq D_i \\leq 10^9\n\n1 \\leq U_i, V_i \\leq N\n\nThe given graph is connected and has no self-loops or multiple edges.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nD_1 D_2 ... D_N\nU_1 V_1\nU_2 V_2\n\\vdots\nU_M V_M\n\nOutput\n\nIf there is no assignment satisfying the conditions, print a single line containing -1.\n\nIf such an assignment exists, print one such assignment in the following format:\n\nS\nC_1\nC_2\n\\vdots\nC_M\n\nHere,\n\nthe first line should contain the string S of length N. Its i-th character (1 \\leq i \\leq N) should be W if Vertex i is assigned white and B if it is assigned black.\n\nThe (i + 1)-th line (1 \\leq i \\leq M) should contain the integer weight C_i assigned to Edge i.\n\nSample Input 1\n\n5 5\n3 4 3 5 7\n1 2\n1 3\n3 2\n4 2\n4 5\n\nSample Output 1\n\nBWWBB\n4\n3\n1\n5\n2\n\nAssume that we assign the colors and integers as the sample output, and let us consider Vertex 5, for example. To travel from Vertex 5, which is assigned black, to a vertex that is assigned white with the minimum cost, we should make these moves: Vertex 5 \\to Vertex 4 \\to Vertex 2. The total cost of these moves is 7, which satisfies the condition. We can also verify that the condition is satisfied for other vertices.\n\nSample Input 2\n\n5 7\n1 2 3 4 5\n1 2\n1 3\n1 4\n2 3\n2 5\n3 5\n4 5\n\nSample Output 2\n\n-1\n\nSample Input 3\n\n4 6\n1 1 1 1\n1 2\n1 3\n1 4\n2 3\n2 4\n3 4\n\nSample Output 3\n\nBBBW\n1\n1\n1\n2\n1\n1", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1466, "cpu_time_ms": 361, "memory_kb": 32568}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s052034486", "group_id": "codeNet:p02801", "input_text": "a = io.read()\na = string.char(a:byte(1) + 1)\nprint(a)\n", "language": "Lua", "metadata": {"date": 1597517086, "filename_ext": "lua", "original_language": "Lua (Lua 5.3.5)", "problem_description_relpath": "problem_descriptions/p02801.html", "problem_id": "p02801", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02801/input.txt", "sample_output_relpath": "derived/input_output/data/p02801/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02801/Lua/s052034486.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s052034486", "user_id": "u120582723"}, "prompt_components": {"gold_output": "b\n", "input_to_evaluate": "a = io.read()\na = string.char(a:byte(1) + 1)\nprint(a)\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nGiven is a lowercase English letter C that is not z. Print the letter that follows C in alphabetical order.\n\nConstraints\n\nC is a lowercase English letter that is not z.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nC\n\nOutput\n\nPrint the letter that follows C in alphabetical order.\n\nSample Input 1\n\na\n\nSample Output 1\n\nb\n\na is followed by b.\n\nSample Input 2\n\ny\n\nSample Output 2\n\nz\n\ny is followed by z.", "sample_input": "a\n"}, "reference_outputs": ["b\n"], "source_document_id": "p02801", "source_text": "Score : 100 points\n\nProblem Statement\n\nGiven is a lowercase English letter C that is not z. Print the letter that follows C in alphabetical order.\n\nConstraints\n\nC is a lowercase English letter that is not z.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nC\n\nOutput\n\nPrint the letter that follows C in alphabetical order.\n\nSample Input 1\n\na\n\nSample Output 1\n\nb\n\na is followed by b.\n\nSample Input 2\n\ny\n\nSample Output 2\n\nz\n\ny is followed by z.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 54, "cpu_time_ms": 5, "memory_kb": 2472}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s217086126", "group_id": "codeNet:p02801", "input_text": "print(string.char(io.read():byte()+1))", "language": "Lua", "metadata": {"date": 1587567457, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p02801.html", "problem_id": "p02801", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02801/input.txt", "sample_output_relpath": "derived/input_output/data/p02801/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02801/Lua/s217086126.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s217086126", "user_id": "u726173718"}, "prompt_components": {"gold_output": "b\n", "input_to_evaluate": "print(string.char(io.read():byte()+1))", "problem_context": "Score : 100 points\n\nProblem Statement\n\nGiven is a lowercase English letter C that is not z. Print the letter that follows C in alphabetical order.\n\nConstraints\n\nC is a lowercase English letter that is not z.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nC\n\nOutput\n\nPrint the letter that follows C in alphabetical order.\n\nSample Input 1\n\na\n\nSample Output 1\n\nb\n\na is followed by b.\n\nSample Input 2\n\ny\n\nSample Output 2\n\nz\n\ny is followed by z.", "sample_input": "a\n"}, "reference_outputs": ["b\n"], "source_document_id": "p02801", "source_text": "Score : 100 points\n\nProblem Statement\n\nGiven is a lowercase English letter C that is not z. Print the letter that follows C in alphabetical order.\n\nConstraints\n\nC is a lowercase English letter that is not z.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nC\n\nOutput\n\nPrint the letter that follows C in alphabetical order.\n\nSample Input 1\n\na\n\nSample Output 1\n\nb\n\na is followed by b.\n\nSample Input 2\n\ny\n\nSample Output 2\n\nz\n\ny is followed by z.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 38, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s908191288", "group_id": "codeNet:p02802", "input_text": "n,m=io.read(\"*n\",\"*n\",\"*l\")\nt={}\nfor i=1,m do\n x=io.read()\n p,s=x:match(\"(%d+) (%u+)\")\n if not t[p] then\n t[p]={}\n table.insert(t[p],s)\n else\n table.insert(t[p],s)\n end\nend\n\nac_counter=0\nwa_counter=0\nfor k,_ in pairs(t) do\n for i=1,#t[k] do\n if t[k][i]==\"AC\" then\n ac_counter=ac_counter+1\n do\n break\n end\n elseif t[k][i]==\"WA\" then\n wa_counter=wa_counter+1\n end\n end\nend\n\nprint(ac_counter..\" \"..wa_counter)", "language": "Lua", "metadata": {"date": 1587863881, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p02802.html", "problem_id": "p02802", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02802/input.txt", "sample_output_relpath": "derived/input_output/data/p02802/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02802/Lua/s908191288.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s908191288", "user_id": "u045238009"}, "prompt_components": {"gold_output": "2 2\n", "input_to_evaluate": "n,m=io.read(\"*n\",\"*n\",\"*l\")\nt={}\nfor i=1,m do\n x=io.read()\n p,s=x:match(\"(%d+) (%u+)\")\n if not t[p] then\n t[p]={}\n table.insert(t[p],s)\n else\n table.insert(t[p],s)\n end\nend\n\nac_counter=0\nwa_counter=0\nfor k,_ in pairs(t) do\n for i=1,#t[k] do\n if t[k][i]==\"AC\" then\n ac_counter=ac_counter+1\n do\n break\n end\n elseif t[k][i]==\"WA\" then\n wa_counter=wa_counter+1\n end\n end\nend\n\nprint(ac_counter..\" \"..wa_counter)", "problem_context": "Score : 300 points\n\nProblem Statement\n\nTakahashi participated in a contest on AtCoder.\n\nThe contest had N problems.\n\nTakahashi made M submissions during the contest.\n\nThe i-th submission was made for the p_i-th problem and received the verdict S_i (AC or WA).\n\nThe number of Takahashi's correct answers is the number of problems on which he received an AC once or more.\n\nThe number of Takahashi's penalties is the sum of the following count for the problems on which he received an AC once or more: the number of WAs received before receiving an AC for the first time on that problem.\n\nFind the numbers of Takahashi's correct answers and penalties.\n\nConstraints\n\nN, M, and p_i are integers.\n\n1 \\leq N \\leq 10^5\n\n0 \\leq M \\leq 10^5\n\n1 \\leq p_i \\leq N\n\nS_i is AC or WA.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\np_1 S_1\n:\np_M S_M\n\nOutput\n\nPrint the number of Takahashi's correct answers and the number of Takahashi's penalties.\n\nSample Input 1\n\n2 5\n1 WA\n1 AC\n2 WA\n2 AC\n2 WA\n\nSample Output 1\n\n2 2\n\nIn his second submission, he received an AC on the first problem for the first time. Before this, he received one WA on this problem.\n\nIn his fourth submission, he received an AC on the second problem for the first time. Before this, he received one WA on this problem.\n\nThus, he has two correct answers and two penalties.\n\nSample Input 2\n\n100000 3\n7777 AC\n7777 AC\n7777 AC\n\nSample Output 2\n\n1 0\n\nNote that it is pointless to get an AC more than once on the same problem.\n\nSample Input 3\n\n6 0\n\nSample Output 3\n\n0 0", "sample_input": "2 5\n1 WA\n1 AC\n2 WA\n2 AC\n2 WA\n"}, "reference_outputs": ["2 2\n"], "source_document_id": "p02802", "source_text": "Score : 300 points\n\nProblem Statement\n\nTakahashi participated in a contest on AtCoder.\n\nThe contest had N problems.\n\nTakahashi made M submissions during the contest.\n\nThe i-th submission was made for the p_i-th problem and received the verdict S_i (AC or WA).\n\nThe number of Takahashi's correct answers is the number of problems on which he received an AC once or more.\n\nThe number of Takahashi's penalties is the sum of the following count for the problems on which he received an AC once or more: the number of WAs received before receiving an AC for the first time on that problem.\n\nFind the numbers of Takahashi's correct answers and penalties.\n\nConstraints\n\nN, M, and p_i are integers.\n\n1 \\leq N \\leq 10^5\n\n0 \\leq M \\leq 10^5\n\n1 \\leq p_i \\leq N\n\nS_i is AC or WA.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\np_1 S_1\n:\np_M S_M\n\nOutput\n\nPrint the number of Takahashi's correct answers and the number of Takahashi's penalties.\n\nSample Input 1\n\n2 5\n1 WA\n1 AC\n2 WA\n2 AC\n2 WA\n\nSample Output 1\n\n2 2\n\nIn his second submission, he received an AC on the first problem for the first time. Before this, he received one WA on this problem.\n\nIn his fourth submission, he received an AC on the second problem for the first time. Before this, he received one WA on this problem.\n\nThus, he has two correct answers and two penalties.\n\nSample Input 2\n\n100000 3\n7777 AC\n7777 AC\n7777 AC\n\nSample Output 2\n\n1 0\n\nNote that it is pointless to get an AC more than once on the same problem.\n\nSample Input 3\n\n6 0\n\nSample Output 3\n\n0 0", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 528, "cpu_time_ms": 209, "memory_kb": 23268}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s244212978", "group_id": "codeNet:p02802", "input_text": "local read = setmetatable({}, {__index = function(t, k) local a = {} for i=1,#k do table.insert(a, '*'..string.sub(k, i, i)) end local r = io.read local u = table.unpack or unpack return function() return r(u(a)) end end})\nread.N = function(N) local t={} for i=1,N do t[i]=read.n() end return t end\nstring.totable = function(s) local t={} local u=string.sub for i=1,#s do t[i] = u(s, i, i) end return t end\nstring.split = function(s) local t={} for w in string.gmatch(s, \"[^%s]+\") do table.insert(t, w) end return (table.unpack or unpack)(t) end\n----\nlocal N, M = read.nnl()\nlocal task_completed = {}\nlocal ac_count = 0\nlocal wa_count = {}\nfor i=1,M do\n local p, s = read.l():split()\n if not task_completed[p] then\n if s == 'AC' then\n ac_count = ac_count + 1\n task_completed[p] = true\n else\n wa_count[p] = (wa_count[p] or 0) + 1\n end\n end\nend\nlocal wa_total = 0\nfor p in pairs(task_completed) do\n wa_total = wa_total + (wa_count[p] or 0)\nend\nprint(ac_count .. \" \" .. wa_total)", "language": "Lua", "metadata": {"date": 1578881580, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p02802.html", "problem_id": "p02802", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02802/input.txt", "sample_output_relpath": "derived/input_output/data/p02802/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02802/Lua/s244212978.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s244212978", "user_id": "u162773977"}, "prompt_components": {"gold_output": "2 2\n", "input_to_evaluate": "local read = setmetatable({}, {__index = function(t, k) local a = {} for i=1,#k do table.insert(a, '*'..string.sub(k, i, i)) end local r = io.read local u = table.unpack or unpack return function() return r(u(a)) end end})\nread.N = function(N) local t={} for i=1,N do t[i]=read.n() end return t end\nstring.totable = function(s) local t={} local u=string.sub for i=1,#s do t[i] = u(s, i, i) end return t end\nstring.split = function(s) local t={} for w in string.gmatch(s, \"[^%s]+\") do table.insert(t, w) end return (table.unpack or unpack)(t) end\n----\nlocal N, M = read.nnl()\nlocal task_completed = {}\nlocal ac_count = 0\nlocal wa_count = {}\nfor i=1,M do\n local p, s = read.l():split()\n if not task_completed[p] then\n if s == 'AC' then\n ac_count = ac_count + 1\n task_completed[p] = true\n else\n wa_count[p] = (wa_count[p] or 0) + 1\n end\n end\nend\nlocal wa_total = 0\nfor p in pairs(task_completed) do\n wa_total = wa_total + (wa_count[p] or 0)\nend\nprint(ac_count .. \" \" .. wa_total)", "problem_context": "Score : 300 points\n\nProblem Statement\n\nTakahashi participated in a contest on AtCoder.\n\nThe contest had N problems.\n\nTakahashi made M submissions during the contest.\n\nThe i-th submission was made for the p_i-th problem and received the verdict S_i (AC or WA).\n\nThe number of Takahashi's correct answers is the number of problems on which he received an AC once or more.\n\nThe number of Takahashi's penalties is the sum of the following count for the problems on which he received an AC once or more: the number of WAs received before receiving an AC for the first time on that problem.\n\nFind the numbers of Takahashi's correct answers and penalties.\n\nConstraints\n\nN, M, and p_i are integers.\n\n1 \\leq N \\leq 10^5\n\n0 \\leq M \\leq 10^5\n\n1 \\leq p_i \\leq N\n\nS_i is AC or WA.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\np_1 S_1\n:\np_M S_M\n\nOutput\n\nPrint the number of Takahashi's correct answers and the number of Takahashi's penalties.\n\nSample Input 1\n\n2 5\n1 WA\n1 AC\n2 WA\n2 AC\n2 WA\n\nSample Output 1\n\n2 2\n\nIn his second submission, he received an AC on the first problem for the first time. Before this, he received one WA on this problem.\n\nIn his fourth submission, he received an AC on the second problem for the first time. Before this, he received one WA on this problem.\n\nThus, he has two correct answers and two penalties.\n\nSample Input 2\n\n100000 3\n7777 AC\n7777 AC\n7777 AC\n\nSample Output 2\n\n1 0\n\nNote that it is pointless to get an AC more than once on the same problem.\n\nSample Input 3\n\n6 0\n\nSample Output 3\n\n0 0", "sample_input": "2 5\n1 WA\n1 AC\n2 WA\n2 AC\n2 WA\n"}, "reference_outputs": ["2 2\n"], "source_document_id": "p02802", "source_text": "Score : 300 points\n\nProblem Statement\n\nTakahashi participated in a contest on AtCoder.\n\nThe contest had N problems.\n\nTakahashi made M submissions during the contest.\n\nThe i-th submission was made for the p_i-th problem and received the verdict S_i (AC or WA).\n\nThe number of Takahashi's correct answers is the number of problems on which he received an AC once or more.\n\nThe number of Takahashi's penalties is the sum of the following count for the problems on which he received an AC once or more: the number of WAs received before receiving an AC for the first time on that problem.\n\nFind the numbers of Takahashi's correct answers and penalties.\n\nConstraints\n\nN, M, and p_i are integers.\n\n1 \\leq N \\leq 10^5\n\n0 \\leq M \\leq 10^5\n\n1 \\leq p_i \\leq N\n\nS_i is AC or WA.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\np_1 S_1\n:\np_M S_M\n\nOutput\n\nPrint the number of Takahashi's correct answers and the number of Takahashi's penalties.\n\nSample Input 1\n\n2 5\n1 WA\n1 AC\n2 WA\n2 AC\n2 WA\n\nSample Output 1\n\n2 2\n\nIn his second submission, he received an AC on the first problem for the first time. Before this, he received one WA on this problem.\n\nIn his fourth submission, he received an AC on the second problem for the first time. Before this, he received one WA on this problem.\n\nThus, he has two correct answers and two penalties.\n\nSample Input 2\n\n100000 3\n7777 AC\n7777 AC\n7777 AC\n\nSample Output 2\n\n1 0\n\nNote that it is pointless to get an AC more than once on the same problem.\n\nSample Input 3\n\n6 0\n\nSample Output 3\n\n0 0", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1042, "cpu_time_ms": 469, "memory_kb": 28516}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s006774214", "group_id": "codeNet:p02803", "input_text": "local mma = math.max\nlocal h, w = io.read(\"*n\", \"*n\", \"*l\")\nlocal map = {}\nfor i = 1, h do\n local s = io.read()\n for j = 1, w do\n map[(i - 1) * w + j] = s:sub(j, j) == \".\"\n end\nend\n\n\nlocal function getlength(start_idx, dst_idx)\n local taskstate = {}\n for i = 1, h * w do taskstate[i] = false end\n local tasks = {}\n local tasknum = 0\n local done = 0\n\n local len = {}\n local inf = -1\n for i = 1, h * w do len[i] = inf end\n len[start_idx] = 0\n\n local function addtask(idx)\n if not taskstate[idx] then\n taskstate[idx] = true\n tasknum = tasknum + 1\n tasks[tasknum] = idx\n end\n end\n addtask(start_idx)\n\n local function walk(src, dst)\n if map[dst] then\n if len[dst] == inf or len[src] + 1 < len[dst] then\n len[dst] = len[src] + 1\n addtask(dst)\n end\n end\n end\n\n while done < tasknum do\n done = done + 1\n local idx = tasks[done]\n taskstate[idx] = false\n local tmp = {}\n\n if w < idx then walk(idx, idx - w) end\n if idx <= (h - 1) * w then walk(idx, idx + w) end\n if 1 < w then\n if idx % w ~= 0 then walk(idx, idx + 1) end\n if idx % w ~= 1 then walk(idx, idx - 1) end\n end\n end\n local ret = 0\n for i = 1, h * w do\n if 0 < len[i] then\n ret = mma(ret, len[i])\n end\n end\n return ret\nend\nlocal totret = 0\nfor i = 1, h * w do\n totret = mma(totret, getlength(i))\nend\nprint(totret)\n", "language": "Lua", "metadata": {"date": 1578882274, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p02803.html", "problem_id": "p02803", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02803/input.txt", "sample_output_relpath": "derived/input_output/data/p02803/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02803/Lua/s006774214.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s006774214", "user_id": "u120582723"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "local mma = math.max\nlocal h, w = io.read(\"*n\", \"*n\", \"*l\")\nlocal map = {}\nfor i = 1, h do\n local s = io.read()\n for j = 1, w do\n map[(i - 1) * w + j] = s:sub(j, j) == \".\"\n end\nend\n\n\nlocal function getlength(start_idx, dst_idx)\n local taskstate = {}\n for i = 1, h * w do taskstate[i] = false end\n local tasks = {}\n local tasknum = 0\n local done = 0\n\n local len = {}\n local inf = -1\n for i = 1, h * w do len[i] = inf end\n len[start_idx] = 0\n\n local function addtask(idx)\n if not taskstate[idx] then\n taskstate[idx] = true\n tasknum = tasknum + 1\n tasks[tasknum] = idx\n end\n end\n addtask(start_idx)\n\n local function walk(src, dst)\n if map[dst] then\n if len[dst] == inf or len[src] + 1 < len[dst] then\n len[dst] = len[src] + 1\n addtask(dst)\n end\n end\n end\n\n while done < tasknum do\n done = done + 1\n local idx = tasks[done]\n taskstate[idx] = false\n local tmp = {}\n\n if w < idx then walk(idx, idx - w) end\n if idx <= (h - 1) * w then walk(idx, idx + w) end\n if 1 < w then\n if idx % w ~= 0 then walk(idx, idx + 1) end\n if idx % w ~= 1 then walk(idx, idx - 1) end\n end\n end\n local ret = 0\n for i = 1, h * w do\n if 0 < len[i] then\n ret = mma(ret, len[i])\n end\n end\n return ret\nend\nlocal totret = 0\nfor i = 1, h * w do\n totret = mma(totret, getlength(i))\nend\nprint(totret)\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nTakahashi has a maze, which is a grid of H \\times W squares with H horizontal rows and W vertical columns.\n\nThe square at the i-th row from the top and the j-th column is a \"wall\" square if S_{ij} is #, and a \"road\" square if S_{ij} is ..\n\nFrom a road square, you can move to a horizontally or vertically adjacent road square.\n\nYou cannot move out of the maze, move to a wall square, or move diagonally.\n\nTakahashi will choose a starting square and a goal square, which can be any road squares, and give the maze to Aoki.\n\nAoki will then travel from the starting square to the goal square, in the minimum number of moves required.\n\nIn this situation, find the maximum possible number of moves Aoki has to make.\n\nConstraints\n\n1 \\leq H,W \\leq 20\n\nS_{ij} is . or #.\n\nS contains at least two occurrences of ..\n\nAny road square can be reached from any road square in zero or more moves.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\nS_{11}...S_{1W}\n:\nS_{H1}...S_{HW}\n\nOutput\n\nPrint the maximum possible number of moves Aoki has to make.\n\nSample Input 1\n\n3 3\n...\n...\n...\n\nSample Output 1\n\n4\n\nIf Takahashi chooses the top-left square as the starting square and the bottom-right square as the goal square, Aoki has to make four moves.\n\nSample Input 2\n\n3 5\n...#.\n.#.#.\n.#...\n\nSample Output 2\n\n10\n\nIf Takahashi chooses the bottom-left square as the starting square and the top-right square as the goal square, Aoki has to make ten moves.", "sample_input": "3 3\n...\n...\n...\n"}, "reference_outputs": ["4\n"], "source_document_id": "p02803", "source_text": "Score : 400 points\n\nProblem Statement\n\nTakahashi has a maze, which is a grid of H \\times W squares with H horizontal rows and W vertical columns.\n\nThe square at the i-th row from the top and the j-th column is a \"wall\" square if S_{ij} is #, and a \"road\" square if S_{ij} is ..\n\nFrom a road square, you can move to a horizontally or vertically adjacent road square.\n\nYou cannot move out of the maze, move to a wall square, or move diagonally.\n\nTakahashi will choose a starting square and a goal square, which can be any road squares, and give the maze to Aoki.\n\nAoki will then travel from the starting square to the goal square, in the minimum number of moves required.\n\nIn this situation, find the maximum possible number of moves Aoki has to make.\n\nConstraints\n\n1 \\leq H,W \\leq 20\n\nS_{ij} is . or #.\n\nS contains at least two occurrences of ..\n\nAny road square can be reached from any road square in zero or more moves.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\nS_{11}...S_{1W}\n:\nS_{H1}...S_{HW}\n\nOutput\n\nPrint the maximum possible number of moves Aoki has to make.\n\nSample Input 1\n\n3 3\n...\n...\n...\n\nSample Output 1\n\n4\n\nIf Takahashi chooses the top-left square as the starting square and the bottom-right square as the goal square, Aoki has to make four moves.\n\nSample Input 2\n\n3 5\n...#.\n.#.#.\n.#...\n\nSample Output 2\n\n10\n\nIf Takahashi chooses the bottom-left square as the starting square and the top-right square as the goal square, Aoki has to make ten moves.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1387, "cpu_time_ms": 19, "memory_kb": 768}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s816495835", "group_id": "codeNet:p02805", "input_text": "local mma = math.max\nlocal msq = math.sqrt\nlocal n = io.read(\"*n\")\nlocal x, y = {}, {}\nfor i = 1, n do\n x[i], y[i] = io.read(\"*n\", \"*n\")\nend\nlocal rep = 1000\n\nlocal tx, ty = 0, 0\nlocal function solvex(px)\n tx = px\n local sq = 0\n for i = 1, n do\n local tmp = (tx - x[i]) * (tx - x[i]) + (ty - y[i]) * (ty - y[i])\n sq = mma(sq, tmp)\n end\n return sq\nend\n\nlocal function triplediv(xmin, xmax, rep, func)\n local left_v, right_v = func(xmin), func(xmax)\n for i = 1, rep do\n local xmid1, xmid2 = (xmin * 2 + xmax) / 3, (xmin + xmax * 2) / 3\n local mid_v1, mid_v2 = func(xmid1), func(xmid2)\n if left_v > mid_v1 then\n if mid_v2 > right_v then\n xmin = xmid2\n left_v = mid_v2\n elseif mid_v1 > mid_v2 then\n xmin = xmid1\n left_v = mid_v1\n else\n xmax = xmid2\n right_v = mid_v2\n end\n else\n if mid_v2 < right_v then\n xmax = xmid1\n right_v = mid_v1\n elseif mid_v1 < mid_v2 then\n xmin = xmid1\n left_v = mid_v1\n else\n xmax = xmid2\n right_v = mid_v2\n end\n end\n end\n return (left_v + right_v) / 2\nend\n\nlocal function solvey(py)\n ty = py\n return triplediv(0, 1000, rep, solvex)\nend\n\nlocal ret = triplediv(0, 1000, rep, solvey)\nprint(string.format(\"%.10f\", msq(ret)))\n", "language": "Lua", "metadata": {"date": 1578886905, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p02805.html", "problem_id": "p02805", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02805/input.txt", "sample_output_relpath": "derived/input_output/data/p02805/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02805/Lua/s816495835.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s816495835", "user_id": "u120582723"}, "prompt_components": {"gold_output": "0.500000000000000000\n", "input_to_evaluate": "local mma = math.max\nlocal msq = math.sqrt\nlocal n = io.read(\"*n\")\nlocal x, y = {}, {}\nfor i = 1, n do\n x[i], y[i] = io.read(\"*n\", \"*n\")\nend\nlocal rep = 1000\n\nlocal tx, ty = 0, 0\nlocal function solvex(px)\n tx = px\n local sq = 0\n for i = 1, n do\n local tmp = (tx - x[i]) * (tx - x[i]) + (ty - y[i]) * (ty - y[i])\n sq = mma(sq, tmp)\n end\n return sq\nend\n\nlocal function triplediv(xmin, xmax, rep, func)\n local left_v, right_v = func(xmin), func(xmax)\n for i = 1, rep do\n local xmid1, xmid2 = (xmin * 2 + xmax) / 3, (xmin + xmax * 2) / 3\n local mid_v1, mid_v2 = func(xmid1), func(xmid2)\n if left_v > mid_v1 then\n if mid_v2 > right_v then\n xmin = xmid2\n left_v = mid_v2\n elseif mid_v1 > mid_v2 then\n xmin = xmid1\n left_v = mid_v1\n else\n xmax = xmid2\n right_v = mid_v2\n end\n else\n if mid_v2 < right_v then\n xmax = xmid1\n right_v = mid_v1\n elseif mid_v1 < mid_v2 then\n xmin = xmid1\n left_v = mid_v1\n else\n xmax = xmid2\n right_v = mid_v2\n end\n end\n end\n return (left_v + right_v) / 2\nend\n\nlocal function solvey(py)\n ty = py\n return triplediv(0, 1000, rep, solvex)\nend\n\nlocal ret = triplediv(0, 1000, rep, solvey)\nprint(string.format(\"%.10f\", msq(ret)))\n", "problem_context": "Score : 600 points\n\nProblem Statement\n\nGiven are N points (x_i, y_i) in a two-dimensional plane.\n\nFind the minimum radius of a circle such that all the points are inside or on it.\n\nConstraints\n\n2 \\leq N \\leq 50\n\n0 \\leq x_i \\leq 1000\n\n0 \\leq y_i \\leq 1000\n\nThe given N points are all different.\n\nThe values in input are all integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nx_1 y_1\n:\nx_N y_N\n\nOutput\n\nPrint the minimum radius of a circle such that all the N points are inside or on it.\n\nYour output will be considered correct if the absolute or relative error from our answer is at most 10^{-6}.\n\nSample Input 1\n\n2\n0 0\n1 0\n\nSample Output 1\n\n0.500000000000000000\n\nBoth points are contained in the circle centered at (0.5,0) with a radius of 0.5.\n\nSample Input 2\n\n3\n0 0\n0 1\n1 0\n\nSample Output 2\n\n0.707106781186497524\n\nSample Input 3\n\n10\n10 9\n5 9\n2 0\n0 0\n2 7\n3 3\n2 5\n10 0\n3 7\n1 9\n\nSample Output 3\n\n6.726812023536805158\n\nIf the absolute or relative error from our answer is at most 10^{-6}, the output will be considered correct.", "sample_input": "2\n0 0\n1 0\n"}, "reference_outputs": ["0.500000000000000000\n"], "source_document_id": "p02805", "source_text": "Score : 600 points\n\nProblem Statement\n\nGiven are N points (x_i, y_i) in a two-dimensional plane.\n\nFind the minimum radius of a circle such that all the points are inside or on it.\n\nConstraints\n\n2 \\leq N \\leq 50\n\n0 \\leq x_i \\leq 1000\n\n0 \\leq y_i \\leq 1000\n\nThe given N points are all different.\n\nThe values in input are all integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nx_1 y_1\n:\nx_N y_N\n\nOutput\n\nPrint the minimum radius of a circle such that all the N points are inside or on it.\n\nYour output will be considered correct if the absolute or relative error from our answer is at most 10^{-6}.\n\nSample Input 1\n\n2\n0 0\n1 0\n\nSample Output 1\n\n0.500000000000000000\n\nBoth points are contained in the circle centered at (0.5,0) with a radius of 0.5.\n\nSample Input 2\n\n3\n0 0\n0 1\n1 0\n\nSample Output 2\n\n0.707106781186497524\n\nSample Input 3\n\n10\n10 9\n5 9\n2 0\n0 0\n2 7\n3 3\n2 5\n10 0\n3 7\n1 9\n\nSample Output 3\n\n6.726812023536805158\n\nIf the absolute or relative error from our answer is at most 10^{-6}, the output will be considered correct.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1302, "cpu_time_ms": 1355, "memory_kb": 256}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s799199857", "group_id": "codeNet:p02809", "input_text": "local mfl, mce, mmi = math.floor, math.ceil, math.min\nlocal mma = math.max\nlocal SegTree = {}\nSegTree.updateAll = function(self)\n for i = self.stagenum - 1, 1, -1 do\n for j = 1, self.cnt[i] do\n self.stage[i][j] = self.func(self.stage[i + 1][j * 2 - 1], self.stage[i + 1][j * 2])\n end\n end\nend\nSegTree.create = function(self, n, func, emptyvalue)\n self.func, self.emptyvalue = func, emptyvalue\n local stagenum, mul = 1, 1\n self.cnt, self.stage, self.size = {1}, {{}}, {}\n while mul < n do\n mul, stagenum = mul * 2, stagenum + 1\n self.cnt[stagenum], self.stage[stagenum] = mul, {}\n end\n for i = 1, stagenum do self.size[i] = self.cnt[stagenum + 1 - i] end\n self.stagenum = stagenum\n for i = 1, mul do self.stage[stagenum][i] = emptyvalue end\n self:updateAll()\nend\nSegTree.getRange = function(self, left, right)\n if left == right then return self.stage[self.stagenum][left] end\n local start_stage = 1\n while right - left + 1 < self.size[start_stage] do\n start_stage = start_stage + 1\n end\n local ret = self.emptyvalue\n local t1, t2, t3 = {start_stage}, {left}, {right}\n while 0 < #t1 do\n local stage, l, r = t1[#t1], t2[#t1], t3[#t1]\n table.remove(t1) table.remove(t2) table.remove(t3)\n local sz = self.size[stage]\n if (l - 1) % sz ~= 0 then\n local newr = mmi(r, mce((l - 1) / sz) * sz)\n table.insert(t1, stage + 1) table.insert(t2, l) table.insert(t3, newr)\n l = newr + 1\n end\n if sz <= r + 1 - l then\n ret = self.func(ret, self.stage[stage][mce(l / sz)])\n l = l + sz\n end\n if l <= r then\n table.insert(t1, stage + 1) table.insert(t2, l) table.insert(t3, r)\n end\n end\n return ret\nend\nSegTree.setValue = function(self, idx, value, silent)\n self.stage[self.stagenum][idx] = value\n if not silent then\n for i = self.stagenum - 1, 1, -1 do\n local dst = mce(idx / 2)\n local rem = dst * 4 - 1 - idx\n self.stage[i][dst] = self.func(self.stage[i + 1][idx], self.stage[i + 1][rem])\n idx = dst\n end\n end\nend\nSegTree.new = function(n, func, emptyvalue)\n local obj = {}\n setmetatable(obj, {__index = SegTree})\n obj:create(n, func, emptyvalue)\n return obj\nend\n\nlocal n = io.read(\"*n\")\nlocal t = {}\nlocal ng = {}\nfor i = 1, n + 1 do ng[i] = {} end\nfor i = 1, n do\n t[i] = io.read(\"*n\")\n ng[t[i]][i] = true\nend\nt[n + 1] = n + 1\n\nif n == 2 and t[1] == 2 then\n print(-1)\n os.exit()\nend\n\nlocal use = {}\nfor i = 1, n do use[i] = false end\nuse[n + 1] = true\nlocal function merge(a, b)\n if use[a] then return b end\n if use[b] then return a end\n return mmi(a, b)\nend\nlocal st = SegTree.new(n, merge, n + 1)\nfor i = 1, n do\n st:setValue(i, i, true)\nend\nst:updateAll()\nlocal ret = {}\nlocal prv = n + 1\nfor i = 1, n - 3 do\n local left = 1\n while true do\n local v = st:getRange(left, n)\n if t[prv] == v then\n left = v + 1\n else\n table.insert(ret, v)\n use[v] = true\n st:setValue(v, v)\n prv = v\n break\n end\n end\nend\nlocal rem = {}\nfor i = 1, n do\n if not use[i] then table.insert(rem, i) end\nend\n-- #rem should be 3\ndo\n local a, b, c = rem[1], rem[2], rem[3]\n local z = {}\n z[1] = {a, b, c}\n z[2] = {a, c, b}\n z[3] = {b, a, c}\n z[4] = {b, c, a}\n z[5] = {c, a, b}\n z[6] = {c, b, a}\n for iz = 1, 6 do\n if t[prv] ~= z[iz][1]\n and t[z[iz][1]] ~= z[iz][2]\n and t[z[iz][2]] ~= z[iz][3] then\n table.insert(ret, z[iz][1])\n table.insert(ret, z[iz][2])\n table.insert(ret, z[iz][3])\n break\n end\n end\nend\n\nprint(table.concat(ret, \" \"))\n", "language": "Lua", "metadata": {"date": 1578797701, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p02809.html", "problem_id": "p02809", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02809/input.txt", "sample_output_relpath": "derived/input_output/data/p02809/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02809/Lua/s799199857.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s799199857", "user_id": "u120582723"}, "prompt_components": {"gold_output": "1 3 2 4\n", "input_to_evaluate": "local mfl, mce, mmi = math.floor, math.ceil, math.min\nlocal mma = math.max\nlocal SegTree = {}\nSegTree.updateAll = function(self)\n for i = self.stagenum - 1, 1, -1 do\n for j = 1, self.cnt[i] do\n self.stage[i][j] = self.func(self.stage[i + 1][j * 2 - 1], self.stage[i + 1][j * 2])\n end\n end\nend\nSegTree.create = function(self, n, func, emptyvalue)\n self.func, self.emptyvalue = func, emptyvalue\n local stagenum, mul = 1, 1\n self.cnt, self.stage, self.size = {1}, {{}}, {}\n while mul < n do\n mul, stagenum = mul * 2, stagenum + 1\n self.cnt[stagenum], self.stage[stagenum] = mul, {}\n end\n for i = 1, stagenum do self.size[i] = self.cnt[stagenum + 1 - i] end\n self.stagenum = stagenum\n for i = 1, mul do self.stage[stagenum][i] = emptyvalue end\n self:updateAll()\nend\nSegTree.getRange = function(self, left, right)\n if left == right then return self.stage[self.stagenum][left] end\n local start_stage = 1\n while right - left + 1 < self.size[start_stage] do\n start_stage = start_stage + 1\n end\n local ret = self.emptyvalue\n local t1, t2, t3 = {start_stage}, {left}, {right}\n while 0 < #t1 do\n local stage, l, r = t1[#t1], t2[#t1], t3[#t1]\n table.remove(t1) table.remove(t2) table.remove(t3)\n local sz = self.size[stage]\n if (l - 1) % sz ~= 0 then\n local newr = mmi(r, mce((l - 1) / sz) * sz)\n table.insert(t1, stage + 1) table.insert(t2, l) table.insert(t3, newr)\n l = newr + 1\n end\n if sz <= r + 1 - l then\n ret = self.func(ret, self.stage[stage][mce(l / sz)])\n l = l + sz\n end\n if l <= r then\n table.insert(t1, stage + 1) table.insert(t2, l) table.insert(t3, r)\n end\n end\n return ret\nend\nSegTree.setValue = function(self, idx, value, silent)\n self.stage[self.stagenum][idx] = value\n if not silent then\n for i = self.stagenum - 1, 1, -1 do\n local dst = mce(idx / 2)\n local rem = dst * 4 - 1 - idx\n self.stage[i][dst] = self.func(self.stage[i + 1][idx], self.stage[i + 1][rem])\n idx = dst\n end\n end\nend\nSegTree.new = function(n, func, emptyvalue)\n local obj = {}\n setmetatable(obj, {__index = SegTree})\n obj:create(n, func, emptyvalue)\n return obj\nend\n\nlocal n = io.read(\"*n\")\nlocal t = {}\nlocal ng = {}\nfor i = 1, n + 1 do ng[i] = {} end\nfor i = 1, n do\n t[i] = io.read(\"*n\")\n ng[t[i]][i] = true\nend\nt[n + 1] = n + 1\n\nif n == 2 and t[1] == 2 then\n print(-1)\n os.exit()\nend\n\nlocal use = {}\nfor i = 1, n do use[i] = false end\nuse[n + 1] = true\nlocal function merge(a, b)\n if use[a] then return b end\n if use[b] then return a end\n return mmi(a, b)\nend\nlocal st = SegTree.new(n, merge, n + 1)\nfor i = 1, n do\n st:setValue(i, i, true)\nend\nst:updateAll()\nlocal ret = {}\nlocal prv = n + 1\nfor i = 1, n - 3 do\n local left = 1\n while true do\n local v = st:getRange(left, n)\n if t[prv] == v then\n left = v + 1\n else\n table.insert(ret, v)\n use[v] = true\n st:setValue(v, v)\n prv = v\n break\n end\n end\nend\nlocal rem = {}\nfor i = 1, n do\n if not use[i] then table.insert(rem, i) end\nend\n-- #rem should be 3\ndo\n local a, b, c = rem[1], rem[2], rem[3]\n local z = {}\n z[1] = {a, b, c}\n z[2] = {a, c, b}\n z[3] = {b, a, c}\n z[4] = {b, c, a}\n z[5] = {c, a, b}\n z[6] = {c, b, a}\n for iz = 1, 6 do\n if t[prv] ~= z[iz][1]\n and t[z[iz][1]] ~= z[iz][2]\n and t[z[iz][2]] ~= z[iz][3] then\n table.insert(ret, z[iz][1])\n table.insert(ret, z[iz][2])\n table.insert(ret, z[iz][3])\n break\n end\n end\nend\n\nprint(table.concat(ret, \" \"))\n", "problem_context": "Score : 800 points\n\nProblem Statement\n\nNiwango has N cards, numbered 1,2,\\ldots,N.\nHe will now arrange these cards in a row.\n\nNiwango wants to know if there is a way to arrange the cards while satisfying all the N conditions below.\nTo help him, determine whether such a way exists. If the answer is yes, also find the lexicographically smallest such arrangement.\n\nTo the immediate right of Card 1 (if any) is NOT Card a_1.\n\nTo the immediate right of Card 2 (if any) is NOT Card a_2.\n\n\\vdots\n\nTo the immediate right of Card N (if any) is NOT Card a_N.\n\nConstraints\n\n2 \\leq N \\leq 10^{5}\n\n1 \\leq a_i \\leq N\n\na_i \\neq i\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 \\ldots a_N\n\nOutput\n\nIf no arrangements satisfy the conditions, print -1. If such arrangements exist, print the lexicographically smallest such arrangement, in the following format:\n\nb_1 b_2 \\ldots b_N\n\nHere, b_i represents the i-th card from the left.\n\nSample Input 1\n\n4\n2 3 4 1\n\nSample Output 1\n\n1 3 2 4\n\nThe arrangement (1,2,3,4) is lexicographically smaller than (1,3,2,4), but is invalid, since it violates the condition \"to the immediate right of Card 1 is not Card 2.\"\n\nSample Input 2\n\n2\n2 1\n\nSample Output 2\n\n-1\n\nIf no arrangements satisfy the conditions, print -1.\n\nSample Input 3\n\n13\n2 3 4 5 6 7 8 9 10 11 12 13 12\n\nSample Output 3\n\n1 3 2 4 6 5 7 9 8 10 12 11 13", "sample_input": "4\n2 3 4 1\n"}, "reference_outputs": ["1 3 2 4\n"], "source_document_id": "p02809", "source_text": "Score : 800 points\n\nProblem Statement\n\nNiwango has N cards, numbered 1,2,\\ldots,N.\nHe will now arrange these cards in a row.\n\nNiwango wants to know if there is a way to arrange the cards while satisfying all the N conditions below.\nTo help him, determine whether such a way exists. If the answer is yes, also find the lexicographically smallest such arrangement.\n\nTo the immediate right of Card 1 (if any) is NOT Card a_1.\n\nTo the immediate right of Card 2 (if any) is NOT Card a_2.\n\n\\vdots\n\nTo the immediate right of Card N (if any) is NOT Card a_N.\n\nConstraints\n\n2 \\leq N \\leq 10^{5}\n\n1 \\leq a_i \\leq N\n\na_i \\neq i\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 \\ldots a_N\n\nOutput\n\nIf no arrangements satisfy the conditions, print -1. If such arrangements exist, print the lexicographically smallest such arrangement, in the following format:\n\nb_1 b_2 \\ldots b_N\n\nHere, b_i represents the i-th card from the left.\n\nSample Input 1\n\n4\n2 3 4 1\n\nSample Output 1\n\n1 3 2 4\n\nThe arrangement (1,2,3,4) is lexicographically smaller than (1,3,2,4), but is invalid, since it violates the condition \"to the immediate right of Card 1 is not Card 2.\"\n\nSample Input 2\n\n2\n2 1\n\nSample Output 2\n\n-1\n\nIf no arrangements satisfy the conditions, print -1.\n\nSample Input 3\n\n13\n2 3 4 5 6 7 8 9 10 11 12 13 12\n\nSample Output 3\n\n1 3 2 4 6 5 7 9 8 10 12 11 13", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 3519, "cpu_time_ms": 422, "memory_kb": 34140}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s308690915", "group_id": "codeNet:p02809", "input_text": "local mfl, mce, mmi = math.floor, math.ceil, math.min\nlocal mma = math.max\nlocal SegTree = {}\nSegTree.updateAll = function(self)\n for i = self.stagenum - 1, 1, -1 do\n for j = 1, self.cnt[i] do\n self.stage[i][j] = self.func(self.stage[i + 1][j * 2 - 1], self.stage[i + 1][j * 2])\n end\n end\nend\nSegTree.create = function(self, n, func, emptyvalue)\n self.func, self.emptyvalue = func, emptyvalue\n local stagenum, mul = 1, 1\n self.cnt, self.stage, self.size = {1}, {{}}, {}\n while mul < n do\n mul, stagenum = mul * 2, stagenum + 1\n self.cnt[stagenum], self.stage[stagenum] = mul, {}\n end\n for i = 1, stagenum do self.size[i] = self.cnt[stagenum + 1 - i] end\n self.stagenum = stagenum\n for i = 1, mul do self.stage[stagenum][i] = emptyvalue end\n self:updateAll()\nend\nSegTree.getRange = function(self, left, right)\n if left == right then return self.stage[self.stagenum][left] end\n local start_stage = 1\n while right - left + 1 < self.size[start_stage] do\n start_stage = start_stage + 1\n end\n local ret = self.emptyvalue\n local t1, t2, t3 = {start_stage}, {left}, {right}\n while 0 < #t1 do\n local stage, l, r = t1[#t1], t2[#t1], t3[#t1]\n table.remove(t1) table.remove(t2) table.remove(t3)\n local sz = self.size[stage]\n if (l - 1) % sz ~= 0 then\n local newr = mmi(r, mce((l - 1) / sz) * sz)\n table.insert(t1, stage + 1) table.insert(t2, l) table.insert(t3, newr)\n l = newr + 1\n end\n if sz <= r + 1 - l then\n ret = self.func(ret, self.stage[stage][mce(l / sz)])\n l = l + sz\n end\n if l <= r then\n table.insert(t1, stage + 1) table.insert(t2, l) table.insert(t3, r)\n end\n end\n return ret\nend\nSegTree.setValue = function(self, idx, value, silent)\n self.stage[self.stagenum][idx] = value\n if not silent then\n for i = self.stagenum - 1, 1, -1 do\n local dst = mce(idx / 2)\n local rem = dst * 4 - 1 - idx\n self.stage[i][dst] = self.func(self.stage[i + 1][idx], self.stage[i + 1][rem])\n idx = dst\n end\n end\nend\nSegTree.new = function(n, func, emptyvalue)\n local obj = {}\n setmetatable(obj, {__index = SegTree})\n obj:create(n, func, emptyvalue)\n return obj\nend\n\nlocal n = io.read(\"*n\")\nlocal t = {}\nlocal ng = {}\nfor i = 1, n + 1 do ng[i] = {} end\nfor i = 1, n do\n t[i] = io.read(\"*n\")\n ng[t[i]][i] = true\nend\nt[n + 1] = n + 1\n\nif n == 2 and t[1] == 2 then\n print(-1)\n os.exit()\nend\n\nlocal use = {}\nfor i = 1, n do use[i] = false end\nuse[n + 1] = true\nlocal function merge(a, b)\n if use[a] then return b end\n if use[b] then return a end\n return mmi(a, b)\nend\nlocal st = SegTree.new(n, merge, n + 1)\nfor i = 1, n do\n st:setValue(i, i, true)\nend\nst:updateAll()\nlocal ret = {}\nlocal prv = n + 1\nfor i = 1, n - 3 do\n local left = 1\n while true do\n local v = st:getRange(left, n)\n if t[prv] == v then\n left = v + 1\n else\n table.insert(ret, v)\n use[v] = true\n st:setValue(v, v)\n prv = v\n break\n end\n end\nend\nlocal rem = {}\nfor i = 1, n do\n if not use[i] then table.insert(rem, i) end\nend\n-- #rem should be 3\ndo\n local a, b, c = rem[1], rem[2], rem[3]\n local af, bf, cf = true, true, true\n if t[prv] == a then af = false end\n if t[prv] == b then bf = false end\n if t[b] == c and t[c] == b then af = false end\n if t[a] == c and t[c] == a then bf = false end\n if af then\n table.insert(ret, a)\n if t[b] == c then\n table.insert(ret, c)\n table.insert(ret, b)\n else\n table.insert(ret, b)\n table.insert(ret, c)\n end\n elseif bf then\n table.insert(ret, b)\n if t[a] == c then\n table.insert(ret, c)\n table.insert(ret, a)\n else\n table.insert(ret, a)\n table.insert(ret, c)\n end\n else\n table.insert(ret, c)\n if t[a] == b then\n table.insert(ret, b)\n table.insert(ret, a)\n else\n table.insert(ret, a)\n table.insert(ret, b)\n end\n end\nend\n\nprint(table.concat(ret, \" \"))\n", "language": "Lua", "metadata": {"date": 1578796631, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p02809.html", "problem_id": "p02809", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02809/input.txt", "sample_output_relpath": "derived/input_output/data/p02809/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02809/Lua/s308690915.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s308690915", "user_id": "u120582723"}, "prompt_components": {"gold_output": "1 3 2 4\n", "input_to_evaluate": "local mfl, mce, mmi = math.floor, math.ceil, math.min\nlocal mma = math.max\nlocal SegTree = {}\nSegTree.updateAll = function(self)\n for i = self.stagenum - 1, 1, -1 do\n for j = 1, self.cnt[i] do\n self.stage[i][j] = self.func(self.stage[i + 1][j * 2 - 1], self.stage[i + 1][j * 2])\n end\n end\nend\nSegTree.create = function(self, n, func, emptyvalue)\n self.func, self.emptyvalue = func, emptyvalue\n local stagenum, mul = 1, 1\n self.cnt, self.stage, self.size = {1}, {{}}, {}\n while mul < n do\n mul, stagenum = mul * 2, stagenum + 1\n self.cnt[stagenum], self.stage[stagenum] = mul, {}\n end\n for i = 1, stagenum do self.size[i] = self.cnt[stagenum + 1 - i] end\n self.stagenum = stagenum\n for i = 1, mul do self.stage[stagenum][i] = emptyvalue end\n self:updateAll()\nend\nSegTree.getRange = function(self, left, right)\n if left == right then return self.stage[self.stagenum][left] end\n local start_stage = 1\n while right - left + 1 < self.size[start_stage] do\n start_stage = start_stage + 1\n end\n local ret = self.emptyvalue\n local t1, t2, t3 = {start_stage}, {left}, {right}\n while 0 < #t1 do\n local stage, l, r = t1[#t1], t2[#t1], t3[#t1]\n table.remove(t1) table.remove(t2) table.remove(t3)\n local sz = self.size[stage]\n if (l - 1) % sz ~= 0 then\n local newr = mmi(r, mce((l - 1) / sz) * sz)\n table.insert(t1, stage + 1) table.insert(t2, l) table.insert(t3, newr)\n l = newr + 1\n end\n if sz <= r + 1 - l then\n ret = self.func(ret, self.stage[stage][mce(l / sz)])\n l = l + sz\n end\n if l <= r then\n table.insert(t1, stage + 1) table.insert(t2, l) table.insert(t3, r)\n end\n end\n return ret\nend\nSegTree.setValue = function(self, idx, value, silent)\n self.stage[self.stagenum][idx] = value\n if not silent then\n for i = self.stagenum - 1, 1, -1 do\n local dst = mce(idx / 2)\n local rem = dst * 4 - 1 - idx\n self.stage[i][dst] = self.func(self.stage[i + 1][idx], self.stage[i + 1][rem])\n idx = dst\n end\n end\nend\nSegTree.new = function(n, func, emptyvalue)\n local obj = {}\n setmetatable(obj, {__index = SegTree})\n obj:create(n, func, emptyvalue)\n return obj\nend\n\nlocal n = io.read(\"*n\")\nlocal t = {}\nlocal ng = {}\nfor i = 1, n + 1 do ng[i] = {} end\nfor i = 1, n do\n t[i] = io.read(\"*n\")\n ng[t[i]][i] = true\nend\nt[n + 1] = n + 1\n\nif n == 2 and t[1] == 2 then\n print(-1)\n os.exit()\nend\n\nlocal use = {}\nfor i = 1, n do use[i] = false end\nuse[n + 1] = true\nlocal function merge(a, b)\n if use[a] then return b end\n if use[b] then return a end\n return mmi(a, b)\nend\nlocal st = SegTree.new(n, merge, n + 1)\nfor i = 1, n do\n st:setValue(i, i, true)\nend\nst:updateAll()\nlocal ret = {}\nlocal prv = n + 1\nfor i = 1, n - 3 do\n local left = 1\n while true do\n local v = st:getRange(left, n)\n if t[prv] == v then\n left = v + 1\n else\n table.insert(ret, v)\n use[v] = true\n st:setValue(v, v)\n prv = v\n break\n end\n end\nend\nlocal rem = {}\nfor i = 1, n do\n if not use[i] then table.insert(rem, i) end\nend\n-- #rem should be 3\ndo\n local a, b, c = rem[1], rem[2], rem[3]\n local af, bf, cf = true, true, true\n if t[prv] == a then af = false end\n if t[prv] == b then bf = false end\n if t[b] == c and t[c] == b then af = false end\n if t[a] == c and t[c] == a then bf = false end\n if af then\n table.insert(ret, a)\n if t[b] == c then\n table.insert(ret, c)\n table.insert(ret, b)\n else\n table.insert(ret, b)\n table.insert(ret, c)\n end\n elseif bf then\n table.insert(ret, b)\n if t[a] == c then\n table.insert(ret, c)\n table.insert(ret, a)\n else\n table.insert(ret, a)\n table.insert(ret, c)\n end\n else\n table.insert(ret, c)\n if t[a] == b then\n table.insert(ret, b)\n table.insert(ret, a)\n else\n table.insert(ret, a)\n table.insert(ret, b)\n end\n end\nend\n\nprint(table.concat(ret, \" \"))\n", "problem_context": "Score : 800 points\n\nProblem Statement\n\nNiwango has N cards, numbered 1,2,\\ldots,N.\nHe will now arrange these cards in a row.\n\nNiwango wants to know if there is a way to arrange the cards while satisfying all the N conditions below.\nTo help him, determine whether such a way exists. If the answer is yes, also find the lexicographically smallest such arrangement.\n\nTo the immediate right of Card 1 (if any) is NOT Card a_1.\n\nTo the immediate right of Card 2 (if any) is NOT Card a_2.\n\n\\vdots\n\nTo the immediate right of Card N (if any) is NOT Card a_N.\n\nConstraints\n\n2 \\leq N \\leq 10^{5}\n\n1 \\leq a_i \\leq N\n\na_i \\neq i\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 \\ldots a_N\n\nOutput\n\nIf no arrangements satisfy the conditions, print -1. If such arrangements exist, print the lexicographically smallest such arrangement, in the following format:\n\nb_1 b_2 \\ldots b_N\n\nHere, b_i represents the i-th card from the left.\n\nSample Input 1\n\n4\n2 3 4 1\n\nSample Output 1\n\n1 3 2 4\n\nThe arrangement (1,2,3,4) is lexicographically smaller than (1,3,2,4), but is invalid, since it violates the condition \"to the immediate right of Card 1 is not Card 2.\"\n\nSample Input 2\n\n2\n2 1\n\nSample Output 2\n\n-1\n\nIf no arrangements satisfy the conditions, print -1.\n\nSample Input 3\n\n13\n2 3 4 5 6 7 8 9 10 11 12 13 12\n\nSample Output 3\n\n1 3 2 4 6 5 7 9 8 10 12 11 13", "sample_input": "4\n2 3 4 1\n"}, "reference_outputs": ["1 3 2 4\n"], "source_document_id": "p02809", "source_text": "Score : 800 points\n\nProblem Statement\n\nNiwango has N cards, numbered 1,2,\\ldots,N.\nHe will now arrange these cards in a row.\n\nNiwango wants to know if there is a way to arrange the cards while satisfying all the N conditions below.\nTo help him, determine whether such a way exists. If the answer is yes, also find the lexicographically smallest such arrangement.\n\nTo the immediate right of Card 1 (if any) is NOT Card a_1.\n\nTo the immediate right of Card 2 (if any) is NOT Card a_2.\n\n\\vdots\n\nTo the immediate right of Card N (if any) is NOT Card a_N.\n\nConstraints\n\n2 \\leq N \\leq 10^{5}\n\n1 \\leq a_i \\leq N\n\na_i \\neq i\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 \\ldots a_N\n\nOutput\n\nIf no arrangements satisfy the conditions, print -1. If such arrangements exist, print the lexicographically smallest such arrangement, in the following format:\n\nb_1 b_2 \\ldots b_N\n\nHere, b_i represents the i-th card from the left.\n\nSample Input 1\n\n4\n2 3 4 1\n\nSample Output 1\n\n1 3 2 4\n\nThe arrangement (1,2,3,4) is lexicographically smaller than (1,3,2,4), but is invalid, since it violates the condition \"to the immediate right of Card 1 is not Card 2.\"\n\nSample Input 2\n\n2\n2 1\n\nSample Output 2\n\n-1\n\nIf no arrangements satisfy the conditions, print -1.\n\nSample Input 3\n\n13\n2 3 4 5 6 7 8 9 10 11 12 13 12\n\nSample Output 3\n\n1 3 2 4 6 5 7 9 8 10 12 11 13", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 3917, "cpu_time_ms": 415, "memory_kb": 34140}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s869003106", "group_id": "codeNet:p02813", "input_text": "local n = io.read(\"*n\")\nlocal fact = {1}\nfor i = 2, n do\n fact[i] = i * fact[i - 1]\nend\nlocal function getrank(a)\n local box = {}\n for i = 1, n do box[i] = false end\n local r = 0\n for i = 1, n do\n for j = 1, a[i] - 1 do\n if not box[j] then\n r = r + fact[n - i]\n end\n end\n box[a[i]] = true\n end\n return r\nend\nlocal t = {}\nfor i = 1, n do\n t[i] = io.read(\"*n\")\nend\nlocal ar = getrank(t)\nfor i = 1, n do\n t[i] = io.read(\"*n\")\nend\nlocal br = getrank(t)\nprint(math.abs(ar - br))\n", "language": "Lua", "metadata": {"date": 1578718093, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p02813.html", "problem_id": "p02813", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02813/input.txt", "sample_output_relpath": "derived/input_output/data/p02813/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02813/Lua/s869003106.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s869003106", "user_id": "u120582723"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "local n = io.read(\"*n\")\nlocal fact = {1}\nfor i = 2, n do\n fact[i] = i * fact[i - 1]\nend\nlocal function getrank(a)\n local box = {}\n for i = 1, n do box[i] = false end\n local r = 0\n for i = 1, n do\n for j = 1, a[i] - 1 do\n if not box[j] then\n r = r + fact[n - i]\n end\n end\n box[a[i]] = true\n end\n return r\nend\nlocal t = {}\nfor i = 1, n do\n t[i] = io.read(\"*n\")\nend\nlocal ar = getrank(t)\nfor i = 1, n do\n t[i] = io.read(\"*n\")\nend\nlocal br = getrank(t)\nprint(math.abs(ar - br))\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nWe have two permutations P and Q of size N (that is, P and Q are both rearrangements of (1,~2,~...,~N)).\n\nThere are N! possible permutations of size N. Among them, let P and Q be the a-th and b-th lexicographically smallest permutations, respectively. Find |a - b|.\n\nNotes\n\nFor two sequences X and Y, X is said to be lexicographically smaller than Y if and only if there exists an integer k such that X_i = Y_i~(1 \\leq i < k) and X_k < Y_k.\n\nConstraints\n\n2 \\leq N \\leq 8\n\nP and Q are permutations of size N.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nP_1 P_2 ... P_N\nQ_1 Q_2 ... Q_N\n\nOutput\n\nPrint |a - b|.\n\nSample Input 1\n\n3\n1 3 2\n3 1 2\n\nSample Output 1\n\n3\n\nThere are 6 permutations of size 3: (1,~2,~3), (1,~3,~2), (2,~1,~3), (2,~3,~1), (3,~1,~2), and (3,~2,~1). Among them, (1,~3,~2) and (3,~1,~2) come 2-nd and 5-th in lexicographical order, so the answer is |2 - 5| = 3.\n\nSample Input 2\n\n8\n7 3 5 4 2 1 6 8\n3 8 2 5 4 6 7 1\n\nSample Output 2\n\n17517\n\nSample Input 3\n\n3\n1 2 3\n1 2 3\n\nSample Output 3\n\n0", "sample_input": "3\n1 3 2\n3 1 2\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02813", "source_text": "Score : 300 points\n\nProblem Statement\n\nWe have two permutations P and Q of size N (that is, P and Q are both rearrangements of (1,~2,~...,~N)).\n\nThere are N! possible permutations of size N. Among them, let P and Q be the a-th and b-th lexicographically smallest permutations, respectively. Find |a - b|.\n\nNotes\n\nFor two sequences X and Y, X is said to be lexicographically smaller than Y if and only if there exists an integer k such that X_i = Y_i~(1 \\leq i < k) and X_k < Y_k.\n\nConstraints\n\n2 \\leq N \\leq 8\n\nP and Q are permutations of size N.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nP_1 P_2 ... P_N\nQ_1 Q_2 ... Q_N\n\nOutput\n\nPrint |a - b|.\n\nSample Input 1\n\n3\n1 3 2\n3 1 2\n\nSample Output 1\n\n3\n\nThere are 6 permutations of size 3: (1,~2,~3), (1,~3,~2), (2,~1,~3), (2,~3,~1), (3,~1,~2), and (3,~2,~1). Among them, (1,~3,~2) and (3,~1,~2) come 2-nd and 5-th in lexicographical order, so the answer is |2 - 5| = 3.\n\nSample Input 2\n\n8\n7 3 5 4 2 1 6 8\n3 8 2 5 4 6 7 1\n\nSample Output 2\n\n17517\n\nSample Input 3\n\n3\n1 2 3\n1 2 3\n\nSample Output 3\n\n0", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 509, "cpu_time_ms": 4, "memory_kb": 508}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s651212281", "group_id": "codeNet:p02814", "input_text": "local function getgcd(x, y)\n while 0 < x do\n x, y = y % x, x\n end\n return y\nend\n\nlocal function getlcm(x, y)\n local gcd = getgcd(x, y)\n return (x // gcd) * y\nend\n\nlocal n, m = io.read(\"*n\", \"*n\")\nlocal a = {}\nfor i = 1, n do\n a[i] = io.read(\"*n\") // 2\nend\nlocal valid = true\nlocal cur = a[1]\nfor i = 2, n do\n local gcd = getgcd(cur, a[i])\n if (cur // gcd) % 2 == 0 or (a[i] // gcd) % 2 == 0 then\n valid = false\n break\n end\n cur = (cur // gcd) * a[i]\n if m < cur then\n valid = false\n break\n end\nend\nif valid then\n local c = m // cur\n print(math.ceil(c / 2))\nelse\n print(0)\nend\n", "language": "Lua", "metadata": {"date": 1578973722, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p02814.html", "problem_id": "p02814", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02814/input.txt", "sample_output_relpath": "derived/input_output/data/p02814/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02814/Lua/s651212281.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s651212281", "user_id": "u120582723"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "local function getgcd(x, y)\n while 0 < x do\n x, y = y % x, x\n end\n return y\nend\n\nlocal function getlcm(x, y)\n local gcd = getgcd(x, y)\n return (x // gcd) * y\nend\n\nlocal n, m = io.read(\"*n\", \"*n\")\nlocal a = {}\nfor i = 1, n do\n a[i] = io.read(\"*n\") // 2\nend\nlocal valid = true\nlocal cur = a[1]\nfor i = 2, n do\n local gcd = getgcd(cur, a[i])\n if (cur // gcd) % 2 == 0 or (a[i] // gcd) % 2 == 0 then\n valid = false\n break\n end\n cur = (cur // gcd) * a[i]\n if m < cur then\n valid = false\n break\n end\nend\nif valid then\n local c = m // cur\n print(math.ceil(c / 2))\nelse\n print(0)\nend\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nGiven are a sequence A= {a_1,a_2,......a_N} of N positive even numbers, and an integer M.\n\nLet a semi-common multiple of A be a positive integer X that satisfies the following condition for every k (1 \\leq k \\leq N):\n\nThere exists a non-negative integer p such that X= a_k \\times (p+0.5).\n\nFind the number of semi-common multiples of A among the integers between 1 and M (inclusive).\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^9\n\n2 \\leq a_i \\leq 10^9\n\na_i is an even number.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\na_1 a_2 ... a_N\n\nOutput\n\nPrint the number of semi-common multiples of A among the integers between 1 and M (inclusive).\n\nSample Input 1\n\n2 50\n6 10\n\nSample Output 1\n\n2\n\n15 = 6 \\times 2.5\n\n15 = 10 \\times 1.5\n\n45 = 6 \\times 7.5\n\n45 = 10 \\times 4.5\n\nThus, 15 and 45 are semi-common multiples of A. There are no other semi-common multiples of A between 1 and 50, so the answer is 2.\n\nSample Input 2\n\n3 100\n14 22 40\n\nSample Output 2\n\n0\n\nThe answer can be 0.\n\nSample Input 3\n\n5 1000000000\n6 6 2 6 2\n\nSample Output 3\n\n166666667", "sample_input": "2 50\n6 10\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02814", "source_text": "Score : 400 points\n\nProblem Statement\n\nGiven are a sequence A= {a_1,a_2,......a_N} of N positive even numbers, and an integer M.\n\nLet a semi-common multiple of A be a positive integer X that satisfies the following condition for every k (1 \\leq k \\leq N):\n\nThere exists a non-negative integer p such that X= a_k \\times (p+0.5).\n\nFind the number of semi-common multiples of A among the integers between 1 and M (inclusive).\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^9\n\n2 \\leq a_i \\leq 10^9\n\na_i is an even number.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\na_1 a_2 ... a_N\n\nOutput\n\nPrint the number of semi-common multiples of A among the integers between 1 and M (inclusive).\n\nSample Input 1\n\n2 50\n6 10\n\nSample Output 1\n\n2\n\n15 = 6 \\times 2.5\n\n15 = 10 \\times 1.5\n\n45 = 6 \\times 7.5\n\n45 = 10 \\times 4.5\n\nThus, 15 and 45 are semi-common multiples of A. There are no other semi-common multiples of A between 1 and 50, so the answer is 2.\n\nSample Input 2\n\n3 100\n14 22 40\n\nSample Output 2\n\n0\n\nThe answer can be 0.\n\nSample Input 3\n\n5 1000000000\n6 6 2 6 2\n\nSample Output 3\n\n166666667", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 606, "cpu_time_ms": 60, "memory_kb": 2424}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s963273806", "group_id": "codeNet:p02814", "input_text": "local read = setmetatable({}, {__index = function(t, k) local a = {} for i=1,#k do table.insert(a, '*'..string.sub(k, i, i)) end local r = io.read local u = table.unpack or unpack return function() return r(u(a)) end end})\nread.N = function(N) local t={} for i=1,N do t[i]=read.n() end return t end\nstring.totable = function(s) local t={} local u=string.sub for i=1,#s do t[i] = u(s, i, i) end return t end\nstring.split = function(s) local t={} for w in string.gmatch(s, \"[^%s]+\") do table.insert(t, w) end return (table.unpack or unpack)(t) end\n----\nlocal function gcd(a,b)\n if b == 0 then\n return a\n else\n return gcd(b, a % b)\n end\nend\n\nlocal function gcdmany(tbl)\n local ans = tbl[1]\n for i=2,#tbl do\n ans = gcd(ans, tbl[i])\n end\n return ans\nend\n\nlocal function lcm(a, b)\n return math.floor(a / gcd(a, b)) * b\nend\n\nlocal function lcmmany(tbl)\n local ans = tbl[1]\n for i=2, #tbl do\n ans = lcm(ans, tbl[i])\n end\n return ans\nend\n---\nlocal N, M = read.nn()\nlocal A = read.N(N)\ntable.sort(A)\nlocal L = lcmmany(A)\nlocal highest = A[#A]\nlocal low_limit = math.floor(A[1] / 2)\nlocal high_limit = M % L\n\nlocal function check(x, ak)\n local x_shifted = x - math.floor(ak / 2)\n return x_shifted % ak == 0\nend\n\nlocal count_first_bad = 0\nlocal count = 0\nlocal count_last_bad = 0\nlocal x = math.floor(highest / 2)\nlocal function check2(x, ak)\n return x >= math.floor(ak / 2)\nend\nlocal function check3(x, ak)\n return x <= high_limit\nend\n\nwhile x <= L do\n local result = true\n local result_first = true\n local result_last = true\n for k, ak in ipairs(A) do\n result = result and check(x, ak)\n result_first = result_first and check2(x, ak)\n result_last = result_last and check3(x, ak)\n end\n if result then\n count = count + 1\n if not result_first then\n count_first_bad = count_first_bad + 1\n end\n if not result_last then\n count_last_bad = count_last_bad + 1\n end\n end\n x = x + highest\nend\nlocal roundup = L * math.ceil(M / L)\nlocal cycles = math.floor(roundup / L)\nif M % L == 0 then\n roundup = roundup + L\n cycles = cycles + 1\nend\n--print(L, roundup, cycles, count, count_first_bad, count_last_bad)\nlocal ans = cycles * count - count_first_bad - count_last_bad\nprint(ans)", "language": "Lua", "metadata": {"date": 1578712534, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p02814.html", "problem_id": "p02814", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02814/input.txt", "sample_output_relpath": "derived/input_output/data/p02814/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02814/Lua/s963273806.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s963273806", "user_id": "u162773977"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "local read = setmetatable({}, {__index = function(t, k) local a = {} for i=1,#k do table.insert(a, '*'..string.sub(k, i, i)) end local r = io.read local u = table.unpack or unpack return function() return r(u(a)) end end})\nread.N = function(N) local t={} for i=1,N do t[i]=read.n() end return t end\nstring.totable = function(s) local t={} local u=string.sub for i=1,#s do t[i] = u(s, i, i) end return t end\nstring.split = function(s) local t={} for w in string.gmatch(s, \"[^%s]+\") do table.insert(t, w) end return (table.unpack or unpack)(t) end\n----\nlocal function gcd(a,b)\n if b == 0 then\n return a\n else\n return gcd(b, a % b)\n end\nend\n\nlocal function gcdmany(tbl)\n local ans = tbl[1]\n for i=2,#tbl do\n ans = gcd(ans, tbl[i])\n end\n return ans\nend\n\nlocal function lcm(a, b)\n return math.floor(a / gcd(a, b)) * b\nend\n\nlocal function lcmmany(tbl)\n local ans = tbl[1]\n for i=2, #tbl do\n ans = lcm(ans, tbl[i])\n end\n return ans\nend\n---\nlocal N, M = read.nn()\nlocal A = read.N(N)\ntable.sort(A)\nlocal L = lcmmany(A)\nlocal highest = A[#A]\nlocal low_limit = math.floor(A[1] / 2)\nlocal high_limit = M % L\n\nlocal function check(x, ak)\n local x_shifted = x - math.floor(ak / 2)\n return x_shifted % ak == 0\nend\n\nlocal count_first_bad = 0\nlocal count = 0\nlocal count_last_bad = 0\nlocal x = math.floor(highest / 2)\nlocal function check2(x, ak)\n return x >= math.floor(ak / 2)\nend\nlocal function check3(x, ak)\n return x <= high_limit\nend\n\nwhile x <= L do\n local result = true\n local result_first = true\n local result_last = true\n for k, ak in ipairs(A) do\n result = result and check(x, ak)\n result_first = result_first and check2(x, ak)\n result_last = result_last and check3(x, ak)\n end\n if result then\n count = count + 1\n if not result_first then\n count_first_bad = count_first_bad + 1\n end\n if not result_last then\n count_last_bad = count_last_bad + 1\n end\n end\n x = x + highest\nend\nlocal roundup = L * math.ceil(M / L)\nlocal cycles = math.floor(roundup / L)\nif M % L == 0 then\n roundup = roundup + L\n cycles = cycles + 1\nend\n--print(L, roundup, cycles, count, count_first_bad, count_last_bad)\nlocal ans = cycles * count - count_first_bad - count_last_bad\nprint(ans)", "problem_context": "Score : 400 points\n\nProblem Statement\n\nGiven are a sequence A= {a_1,a_2,......a_N} of N positive even numbers, and an integer M.\n\nLet a semi-common multiple of A be a positive integer X that satisfies the following condition for every k (1 \\leq k \\leq N):\n\nThere exists a non-negative integer p such that X= a_k \\times (p+0.5).\n\nFind the number of semi-common multiples of A among the integers between 1 and M (inclusive).\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^9\n\n2 \\leq a_i \\leq 10^9\n\na_i is an even number.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\na_1 a_2 ... a_N\n\nOutput\n\nPrint the number of semi-common multiples of A among the integers between 1 and M (inclusive).\n\nSample Input 1\n\n2 50\n6 10\n\nSample Output 1\n\n2\n\n15 = 6 \\times 2.5\n\n15 = 10 \\times 1.5\n\n45 = 6 \\times 7.5\n\n45 = 10 \\times 4.5\n\nThus, 15 and 45 are semi-common multiples of A. There are no other semi-common multiples of A between 1 and 50, so the answer is 2.\n\nSample Input 2\n\n3 100\n14 22 40\n\nSample Output 2\n\n0\n\nThe answer can be 0.\n\nSample Input 3\n\n5 1000000000\n6 6 2 6 2\n\nSample Output 3\n\n166666667", "sample_input": "2 50\n6 10\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02814", "source_text": "Score : 400 points\n\nProblem Statement\n\nGiven are a sequence A= {a_1,a_2,......a_N} of N positive even numbers, and an integer M.\n\nLet a semi-common multiple of A be a positive integer X that satisfies the following condition for every k (1 \\leq k \\leq N):\n\nThere exists a non-negative integer p such that X= a_k \\times (p+0.5).\n\nFind the number of semi-common multiples of A among the integers between 1 and M (inclusive).\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^9\n\n2 \\leq a_i \\leq 10^9\n\na_i is an even number.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\na_1 a_2 ... a_N\n\nOutput\n\nPrint the number of semi-common multiples of A among the integers between 1 and M (inclusive).\n\nSample Input 1\n\n2 50\n6 10\n\nSample Output 1\n\n2\n\n15 = 6 \\times 2.5\n\n15 = 10 \\times 1.5\n\n45 = 6 \\times 7.5\n\n45 = 10 \\times 4.5\n\nThus, 15 and 45 are semi-common multiples of A. There are no other semi-common multiples of A between 1 and 50, so the answer is 2.\n\nSample Input 2\n\n3 100\n14 22 40\n\nSample Output 2\n\n0\n\nThe answer can be 0.\n\nSample Input 3\n\n5 1000000000\n6 6 2 6 2\n\nSample Output 3\n\n166666667", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2338, "cpu_time_ms": 2103, "memory_kb": 2688}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s617086546", "group_id": "codeNet:p02815", "input_text": "local mod = 1000000007\nlocal function badd(x, y) return (x + y) % mod end\nlocal function bmul(x, y) return (x * y) % mod end\nlocal n = io.read(\"*n\")\nlocal t = {}\nfor i = 1, n do\n t[i] = io.read(\"*n\")\nend\ntable.sort(t)\nlocal mul = {1}\nfor i = 2, n + 1 do\n mul[i] = bmul(mul[i - 1], 2)\nend\nlocal ret = 0\nlocal csum = 0\nfor i = 1, n do\n local c = t[i]\n ret = badd(ret, bmul(c, mul[n]))\n if 1 < i then\n ret = badd(ret, bmul(csum, mul[n - 1]))\n end\n csum = badd(csum, c)\nend\nret = bmul(ret, mul[n + 1])\nprint(ret)\n", "language": "Lua", "metadata": {"date": 1588217762, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p02815.html", "problem_id": "p02815", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02815/input.txt", "sample_output_relpath": "derived/input_output/data/p02815/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02815/Lua/s617086546.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s617086546", "user_id": "u120582723"}, "prompt_components": {"gold_output": "999999993\n", "input_to_evaluate": "local mod = 1000000007\nlocal function badd(x, y) return (x + y) % mod end\nlocal function bmul(x, y) return (x * y) % mod end\nlocal n = io.read(\"*n\")\nlocal t = {}\nfor i = 1, n do\n t[i] = io.read(\"*n\")\nend\ntable.sort(t)\nlocal mul = {1}\nfor i = 2, n + 1 do\n mul[i] = bmul(mul[i - 1], 2)\nend\nlocal ret = 0\nlocal csum = 0\nfor i = 1, n do\n local c = t[i]\n ret = badd(ret, bmul(c, mul[n]))\n if 1 < i then\n ret = badd(ret, bmul(csum, mul[n - 1]))\n end\n csum = badd(csum, c)\nend\nret = bmul(ret, mul[n + 1])\nprint(ret)\n", "problem_context": "Score : 500 points\n\nProblem Statement\n\nFor two sequences S and T of length N consisting of 0 and 1, let us define f(S, T) as follows:\n\nConsider repeating the following operation on S so that S will be equal to T. f(S, T) is the minimum possible total cost of those operations.\n\nChange S_i (from 0 to 1 or vice versa). The cost of this operation is D \\times C_i, where D is the number of integers j such that S_j \\neq T_j (1 \\leq j \\leq N) just before this change.\n\nThere are 2^N \\times (2^N - 1) pairs (S, T) of different sequences of length N consisting of 0 and 1. Compute the sum of f(S, T) over all of those pairs, modulo (10^9+7).\n\nConstraints\n\n1 \\leq N \\leq 2 \\times 10^5\n\n1 \\leq C_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nC_1 C_2 \\cdots C_N\n\nOutput\n\nPrint the sum of f(S, T), modulo (10^9+7).\n\nSample Input 1\n\n1\n1000000000\n\nSample Output 1\n\n999999993\n\nThere are two pairs (S, T) of different sequences of length 2 consisting of 0 and 1, as follows:\n\nS = (0), T = (1): by changing S_1 to 1, we can have S = T at the cost of 1000000000, so f(S, T) = 1000000000.\n\nS = (1), T = (0): by changing S_1 to 0, we can have S = T at the cost of 1000000000, so f(S, T) = 1000000000.\n\nThe sum of these is 2000000000, and we should print it modulo (10^9+7), that is, 999999993.\n\nSample Input 2\n\n2\n5 8\n\nSample Output 2\n\n124\n\nThere are 12 pairs (S, T) of different sequences of length 3 consisting of 0 and 1, which include:\n\nS = (0, 1), T = (1, 0)\n\nIn this case, if we first change S_1 to 1 then change S_2 to 0, the total cost is 5 \\times 2 + 8 = 18. We cannot have S = T at a smaller cost, so f(S, T) = 18.\n\nSample Input 3\n\n5\n52 67 72 25 79\n\nSample Output 3\n\n269312", "sample_input": "1\n1000000000\n"}, "reference_outputs": ["999999993\n"], "source_document_id": "p02815", "source_text": "Score : 500 points\n\nProblem Statement\n\nFor two sequences S and T of length N consisting of 0 and 1, let us define f(S, T) as follows:\n\nConsider repeating the following operation on S so that S will be equal to T. f(S, T) is the minimum possible total cost of those operations.\n\nChange S_i (from 0 to 1 or vice versa). The cost of this operation is D \\times C_i, where D is the number of integers j such that S_j \\neq T_j (1 \\leq j \\leq N) just before this change.\n\nThere are 2^N \\times (2^N - 1) pairs (S, T) of different sequences of length N consisting of 0 and 1. Compute the sum of f(S, T) over all of those pairs, modulo (10^9+7).\n\nConstraints\n\n1 \\leq N \\leq 2 \\times 10^5\n\n1 \\leq C_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nC_1 C_2 \\cdots C_N\n\nOutput\n\nPrint the sum of f(S, T), modulo (10^9+7).\n\nSample Input 1\n\n1\n1000000000\n\nSample Output 1\n\n999999993\n\nThere are two pairs (S, T) of different sequences of length 2 consisting of 0 and 1, as follows:\n\nS = (0), T = (1): by changing S_1 to 1, we can have S = T at the cost of 1000000000, so f(S, T) = 1000000000.\n\nS = (1), T = (0): by changing S_1 to 0, we can have S = T at the cost of 1000000000, so f(S, T) = 1000000000.\n\nThe sum of these is 2000000000, and we should print it modulo (10^9+7), that is, 999999993.\n\nSample Input 2\n\n2\n5 8\n\nSample Output 2\n\n124\n\nThere are 12 pairs (S, T) of different sequences of length 3 consisting of 0 and 1, which include:\n\nS = (0, 1), T = (1, 0)\n\nIn this case, if we first change S_1 to 1 then change S_2 to 0, the total cost is 5 \\times 2 + 8 = 18. We cannot have S = T at a smaller cost, so f(S, T) = 18.\n\nSample Input 3\n\n5\n52 67 72 25 79\n\nSample Output 3\n\n269312", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 519, "cpu_time_ms": 301, "memory_kb": 8568}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s726988597", "group_id": "codeNet:p02816", "input_text": "local mmi, mma = math.min, math.max\nlocal mfl = math.floor\nlocal xor = bit.bxor\n-- local function xor(x, y) return x end\n\nlocal n = io.read(\"*n\")\nlocal ar, br = {}, {}\nfor i = 1, n do\n ar[i] = io.read(\"*n\")\nend\nfor i = 1, n do\n br[i] = io.read(\"*n\")\nend\nlocal as, bs = {}, {}\nfor i = 1, n - 1 do\n as[i], bs[i] = xor(ar[i], ar[i + 1]), xor(br[i], br[i + 1])\nend\nas[n], bs[n] = xor(ar[n], ar[1]), xor(br[n], br[1])\nlocal idx = {}\nlocal v = {}\nfor i = 1, n do\n idx[i] = i\n v[i] = as[i]\nend\n-- stage 1\ntable.sort(idx, function(a, b) return v[a] < v[b] end)\ndo\n local cur = 1\n local v_nxt = {}\n for i = 1, n do v_nxt[i] = 0 end\n v_nxt[idx[1]] = 1\n for i = 2, n do\n if v[idx[i]] ~= v[idx[i - 1]] then\n cur = cur + 1\n end\n v_nxt[idx[i]] = cur\n end\n for i = 1, n do v[i] = v_nxt[i] end\nend\nlocal step = 1\nwhile step < n do\n local vd = {}\n local left, major = 1, v[idx[1]]\n local minor_min = v[idx[1 + step]]\n local minor_max = minor_min\n for i = 1, n do\n local isend = i == n or major ~= v[idx[i + 1]]\n if isend then\n if minor_min ~= minor_max then\n local right = i\n local t = {}\n for j = left, right do\n t[j - left + 1] = idx[j]\n end\n table.sort(t, function(x, y)\n local xi, yi = x + step, y + step\n if n < xi then xi = xi - n end\n if n < yi then yi = yi - n end\n return v[xi] < v[yi] end)\n for j = left, right do\n idx[j] = t[j - left + 1]\n end\n end\n else\n local j = i + step\n if n < j then j = j - n end\n local minor = v[idx[j]]\n minor_min, minor_max = mmi(minor_min, minor), mma(minor_max, minor)\n end\n end\n vd[idx[1]] = 1\n local cur = 1\n for i = 2, n do\n local idx_prv, idx_nxt = idx[i - 1], idx[i]\n local idx_prv_i, idx_nxt_i = idx_prv + step, idx_nxt + step\n if n < idx_prv_i then idx_prv_i = idx_prv_i - n end\n if n < idx_nxt_i then idx_nxt_i = idx_nxt_i - n end\n if v[idx_prv] ~= v[idx_nxt] or v[idx_prv_i] ~= v[idx_nxt_i] then\n cur = cur + 1\n end\n vd[idx_nxt] = cur\n end\n for i = 1, n do v[i] = vd[i] end\n step = step * 2\nend\n\nlocal function comp_l(offset)\n for i = 1, n do\n local ai = offset - 1 + i\n if n < ai then ai = ai - n end\n if as[ai] < bs[i] then return true\n elseif bs[i] < as[ai] then return false\n end\n end\n return false\nend\n\nlocal function comp_u(offset)\n for i = 1, n do\n local ai = offset - 1 + i\n if n < ai then ai = ai - n end\n if bs[i] < as[ai] then return true\n elseif as[ai] < bs[i] then return false\n end\n end\n return false\nend\n\nlocal function lower_bound(ary)\n local num = #ary\n if num == 0 then return 1 end\n if not comp_l(ary[1]) then return 1 end\n if comp_l(ary[num]) then return num + 1 end\n local min, max = 1, num\n while 1 < max - min do\n local mid = mfl((min + max) / 2)\n if comp_l(ary[mid]) then\n min = mid\n else\n max = mid\n end\n end\n return max\nend\n\nlocal function upper_bound(ary)\n local num = #ary\n if num == 0 then return 1 end\n if comp_u(ary[1]) then return 1 end\n if not comp_u(ary[num]) then return num + 1 end\n local min, max = 1, num\n while 1 < max - min do\n local mid = mfl((min + max) / 2)\n if not comp_u(ary[mid]) then\n min = mid\n else\n max = mid\n end\n end\n return max\nend\nlocal lb = lower_bound(idx)\nlocal ub = upper_bound(idx)\nlocal t = {}\nfor i = lb, ub - 1 do\n table.insert(t, idx[i])\nend\ntable.sort(t)\nfor i = 1, #t do\n local k = t[i] - 1\n local v = xor(ar[t[i]], br[1])\n print(k .. \" \" .. v)\nend\n-- print(os.clock())\n", "language": "Lua", "metadata": {"date": 1580852991, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p02816.html", "problem_id": "p02816", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02816/input.txt", "sample_output_relpath": "derived/input_output/data/p02816/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02816/Lua/s726988597.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s726988597", "user_id": "u120582723"}, "prompt_components": {"gold_output": "1 3\n", "input_to_evaluate": "local mmi, mma = math.min, math.max\nlocal mfl = math.floor\nlocal xor = bit.bxor\n-- local function xor(x, y) return x end\n\nlocal n = io.read(\"*n\")\nlocal ar, br = {}, {}\nfor i = 1, n do\n ar[i] = io.read(\"*n\")\nend\nfor i = 1, n do\n br[i] = io.read(\"*n\")\nend\nlocal as, bs = {}, {}\nfor i = 1, n - 1 do\n as[i], bs[i] = xor(ar[i], ar[i + 1]), xor(br[i], br[i + 1])\nend\nas[n], bs[n] = xor(ar[n], ar[1]), xor(br[n], br[1])\nlocal idx = {}\nlocal v = {}\nfor i = 1, n do\n idx[i] = i\n v[i] = as[i]\nend\n-- stage 1\ntable.sort(idx, function(a, b) return v[a] < v[b] end)\ndo\n local cur = 1\n local v_nxt = {}\n for i = 1, n do v_nxt[i] = 0 end\n v_nxt[idx[1]] = 1\n for i = 2, n do\n if v[idx[i]] ~= v[idx[i - 1]] then\n cur = cur + 1\n end\n v_nxt[idx[i]] = cur\n end\n for i = 1, n do v[i] = v_nxt[i] end\nend\nlocal step = 1\nwhile step < n do\n local vd = {}\n local left, major = 1, v[idx[1]]\n local minor_min = v[idx[1 + step]]\n local minor_max = minor_min\n for i = 1, n do\n local isend = i == n or major ~= v[idx[i + 1]]\n if isend then\n if minor_min ~= minor_max then\n local right = i\n local t = {}\n for j = left, right do\n t[j - left + 1] = idx[j]\n end\n table.sort(t, function(x, y)\n local xi, yi = x + step, y + step\n if n < xi then xi = xi - n end\n if n < yi then yi = yi - n end\n return v[xi] < v[yi] end)\n for j = left, right do\n idx[j] = t[j - left + 1]\n end\n end\n else\n local j = i + step\n if n < j then j = j - n end\n local minor = v[idx[j]]\n minor_min, minor_max = mmi(minor_min, minor), mma(minor_max, minor)\n end\n end\n vd[idx[1]] = 1\n local cur = 1\n for i = 2, n do\n local idx_prv, idx_nxt = idx[i - 1], idx[i]\n local idx_prv_i, idx_nxt_i = idx_prv + step, idx_nxt + step\n if n < idx_prv_i then idx_prv_i = idx_prv_i - n end\n if n < idx_nxt_i then idx_nxt_i = idx_nxt_i - n end\n if v[idx_prv] ~= v[idx_nxt] or v[idx_prv_i] ~= v[idx_nxt_i] then\n cur = cur + 1\n end\n vd[idx_nxt] = cur\n end\n for i = 1, n do v[i] = vd[i] end\n step = step * 2\nend\n\nlocal function comp_l(offset)\n for i = 1, n do\n local ai = offset - 1 + i\n if n < ai then ai = ai - n end\n if as[ai] < bs[i] then return true\n elseif bs[i] < as[ai] then return false\n end\n end\n return false\nend\n\nlocal function comp_u(offset)\n for i = 1, n do\n local ai = offset - 1 + i\n if n < ai then ai = ai - n end\n if bs[i] < as[ai] then return true\n elseif as[ai] < bs[i] then return false\n end\n end\n return false\nend\n\nlocal function lower_bound(ary)\n local num = #ary\n if num == 0 then return 1 end\n if not comp_l(ary[1]) then return 1 end\n if comp_l(ary[num]) then return num + 1 end\n local min, max = 1, num\n while 1 < max - min do\n local mid = mfl((min + max) / 2)\n if comp_l(ary[mid]) then\n min = mid\n else\n max = mid\n end\n end\n return max\nend\n\nlocal function upper_bound(ary)\n local num = #ary\n if num == 0 then return 1 end\n if comp_u(ary[1]) then return 1 end\n if not comp_u(ary[num]) then return num + 1 end\n local min, max = 1, num\n while 1 < max - min do\n local mid = mfl((min + max) / 2)\n if not comp_u(ary[mid]) then\n min = mid\n else\n max = mid\n end\n end\n return max\nend\nlocal lb = lower_bound(idx)\nlocal ub = upper_bound(idx)\nlocal t = {}\nfor i = lb, ub - 1 do\n table.insert(t, idx[i])\nend\ntable.sort(t)\nfor i = 1, #t do\n local k = t[i] - 1\n local v = xor(ar[t[i]], br[1])\n print(k .. \" \" .. v)\nend\n-- print(os.clock())\n", "problem_context": "Score : 600 points\n\nProblem Statement\n\nGiven are two sequences a=\\{a_0,\\ldots,a_{N-1}\\} and b=\\{b_0,\\ldots,b_{N-1}\\} of N non-negative integers each.\n\nSnuke will choose an integer k such that 0 \\leq k < N and an integer x not less than 0, to make a new sequence of length N, a'=\\{a_0',\\ldots,a_{N-1}'\\}, as follows:\n\na_i'= a_{i+k \\mod N}\\ XOR \\ x\n\nFind all pairs (k,x) such that a' will be equal to b.\n\nWhat is \\mbox{ XOR }?\n\nThe XOR of integers A and B, A \\mbox{ XOR } B, is defined as follows:\n\nWhen A \\mbox{ XOR } B is written in base two, the digit in the 2^k's place (k \\geq 0) is 1 if either A or B, but not both, has 1 in the 2^k's place, and 0 otherwise.\n\nFor example, 3 \\mbox{ XOR } 5 = 6. (In base two: 011 \\mbox{ XOR } 101 = 110.)\n\nConstraints\n\n1 \\leq N \\leq 2 \\times 10^5\n\n0 \\leq a_i,b_i < 2^{30}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_0 a_1 ... a_{N-1}\nb_0 b_1 ... b_{N-1}\n\nOutput\n\nPrint 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).\n\nIf there are no such pairs, the output should be empty.\n\nSample Input 1\n\n3\n0 2 1\n1 2 3\n\nSample Output 1\n\n1 3\n\nIf (k,x)=(1,3),\n\na_0'=(a_1\\ XOR \\ 3)=1\n\na_1'=(a_2\\ XOR \\ 3)=2\n\na_2'=(a_0\\ XOR \\ 3)=3\n\nand we have a' = b.\n\nSample Input 2\n\n5\n0 0 0 0 0\n2 2 2 2 2\n\nSample Output 2\n\n0 2\n1 2\n2 2\n3 2\n4 2\n\nSample Input 3\n\n6\n0 1 3 7 6 4\n1 5 4 6 2 3\n\nSample Output 3\n\n2 2\n5 5\n\nSample Input 4\n\n2\n1 2\n0 0\n\nSample Output 4\n\nNo pairs may satisfy the condition.", "sample_input": "3\n0 2 1\n1 2 3\n"}, "reference_outputs": ["1 3\n"], "source_document_id": "p02816", "source_text": "Score : 600 points\n\nProblem Statement\n\nGiven are two sequences a=\\{a_0,\\ldots,a_{N-1}\\} and b=\\{b_0,\\ldots,b_{N-1}\\} of N non-negative integers each.\n\nSnuke will choose an integer k such that 0 \\leq k < N and an integer x not less than 0, to make a new sequence of length N, a'=\\{a_0',\\ldots,a_{N-1}'\\}, as follows:\n\na_i'= a_{i+k \\mod N}\\ XOR \\ x\n\nFind all pairs (k,x) such that a' will be equal to b.\n\nWhat is \\mbox{ XOR }?\n\nThe XOR of integers A and B, A \\mbox{ XOR } B, is defined as follows:\n\nWhen A \\mbox{ XOR } B is written in base two, the digit in the 2^k's place (k \\geq 0) is 1 if either A or B, but not both, has 1 in the 2^k's place, and 0 otherwise.\n\nFor example, 3 \\mbox{ XOR } 5 = 6. (In base two: 011 \\mbox{ XOR } 101 = 110.)\n\nConstraints\n\n1 \\leq N \\leq 2 \\times 10^5\n\n0 \\leq a_i,b_i < 2^{30}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_0 a_1 ... a_{N-1}\nb_0 b_1 ... b_{N-1}\n\nOutput\n\nPrint 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).\n\nIf there are no such pairs, the output should be empty.\n\nSample Input 1\n\n3\n0 2 1\n1 2 3\n\nSample Output 1\n\n1 3\n\nIf (k,x)=(1,3),\n\na_0'=(a_1\\ XOR \\ 3)=1\n\na_1'=(a_2\\ XOR \\ 3)=2\n\na_2'=(a_0\\ XOR \\ 3)=3\n\nand we have a' = b.\n\nSample Input 2\n\n5\n0 0 0 0 0\n2 2 2 2 2\n\nSample Output 2\n\n0 2\n1 2\n2 2\n3 2\n4 2\n\nSample Input 3\n\n6\n0 1 3 7 6 4\n1 5 4 6 2 3\n\nSample Output 3\n\n2 2\n5 5\n\nSample Input 4\n\n2\n1 2\n0 0\n\nSample Output 4\n\nNo pairs may satisfy the condition.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 3576, "cpu_time_ms": 2105, "memory_kb": 45220}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s941378377", "group_id": "codeNet:p02817", "input_text": "s,t=io.read():match(\"(%w+) (%w+)\")\nprint(t..s)", "language": "Lua", "metadata": {"date": 1579311451, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p02817.html", "problem_id": "p02817", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02817/input.txt", "sample_output_relpath": "derived/input_output/data/p02817/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02817/Lua/s941378377.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s941378377", "user_id": "u720483676"}, "prompt_components": {"gold_output": "atcoder\n", "input_to_evaluate": "s,t=io.read():match(\"(%w+) (%w+)\")\nprint(t..s)", "problem_context": "Score : 100 points\n\nProblem Statement\n\nGiven are two strings S and T consisting of lowercase English letters. Concatenate T and S in this order, without space in between, and print the resulting string.\n\nConstraints\n\nS and T are strings consisting of lowercase English letters.\n\nThe lengths of S and T are between 1 and 100 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS T\n\nOutput\n\nPrint the resulting string.\n\nSample Input 1\n\noder atc\n\nSample Output 1\n\natcoder\n\nWhen S = oder and T = atc, concatenating T and S in this order results in atcoder.\n\nSample Input 2\n\nhumu humu\n\nSample Output 2\n\nhumuhumu", "sample_input": "oder atc\n"}, "reference_outputs": ["atcoder\n"], "source_document_id": "p02817", "source_text": "Score : 100 points\n\nProblem Statement\n\nGiven are two strings S and T consisting of lowercase English letters. Concatenate T and S in this order, without space in between, and print the resulting string.\n\nConstraints\n\nS and T are strings consisting of lowercase English letters.\n\nThe lengths of S and T are between 1 and 100 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS T\n\nOutput\n\nPrint the resulting string.\n\nSample Input 1\n\noder atc\n\nSample Output 1\n\natcoder\n\nWhen S = oder and T = atc, concatenating T and S in this order results in atcoder.\n\nSample Input 2\n\nhumu humu\n\nSample Output 2\n\nhumuhumu", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 46, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s466514397", "group_id": "codeNet:p02817", "input_text": "a=(io.read()):gsub('(%w+) (%w+)','%2%1')print(a)", "language": "Lua", "metadata": {"date": 1577710000, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p02817.html", "problem_id": "p02817", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02817/input.txt", "sample_output_relpath": "derived/input_output/data/p02817/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02817/Lua/s466514397.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s466514397", "user_id": "u162773977"}, "prompt_components": {"gold_output": "atcoder\n", "input_to_evaluate": "a=(io.read()):gsub('(%w+) (%w+)','%2%1')print(a)", "problem_context": "Score : 100 points\n\nProblem Statement\n\nGiven are two strings S and T consisting of lowercase English letters. Concatenate T and S in this order, without space in between, and print the resulting string.\n\nConstraints\n\nS and T are strings consisting of lowercase English letters.\n\nThe lengths of S and T are between 1 and 100 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS T\n\nOutput\n\nPrint the resulting string.\n\nSample Input 1\n\noder atc\n\nSample Output 1\n\natcoder\n\nWhen S = oder and T = atc, concatenating T and S in this order results in atcoder.\n\nSample Input 2\n\nhumu humu\n\nSample Output 2\n\nhumuhumu", "sample_input": "oder atc\n"}, "reference_outputs": ["atcoder\n"], "source_document_id": "p02817", "source_text": "Score : 100 points\n\nProblem Statement\n\nGiven are two strings S and T consisting of lowercase English letters. Concatenate T and S in this order, without space in between, and print the resulting string.\n\nConstraints\n\nS and T are strings consisting of lowercase English letters.\n\nThe lengths of S and T are between 1 and 100 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS T\n\nOutput\n\nPrint the resulting string.\n\nSample Input 1\n\noder atc\n\nSample Output 1\n\natcoder\n\nWhen S = oder and T = atc, concatenating T and S in this order results in atcoder.\n\nSample Input 2\n\nhumu humu\n\nSample Output 2\n\nhumuhumu", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 48, "cpu_time_ms": 7, "memory_kb": 760}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s746333620", "group_id": "codeNet:p02817", "input_text": "a = read()\nb = read()\nprint(b .. a)", "language": "Lua", "metadata": {"date": 1577667660, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p02817.html", "problem_id": "p02817", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02817/input.txt", "sample_output_relpath": "derived/input_output/data/p02817/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02817/Lua/s746333620.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s746333620", "user_id": "u290898260"}, "prompt_components": {"gold_output": "atcoder\n", "input_to_evaluate": "a = read()\nb = read()\nprint(b .. a)", "problem_context": "Score : 100 points\n\nProblem Statement\n\nGiven are two strings S and T consisting of lowercase English letters. Concatenate T and S in this order, without space in between, and print the resulting string.\n\nConstraints\n\nS and T are strings consisting of lowercase English letters.\n\nThe lengths of S and T are between 1 and 100 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS T\n\nOutput\n\nPrint the resulting string.\n\nSample Input 1\n\noder atc\n\nSample Output 1\n\natcoder\n\nWhen S = oder and T = atc, concatenating T and S in this order results in atcoder.\n\nSample Input 2\n\nhumu humu\n\nSample Output 2\n\nhumuhumu", "sample_input": "oder atc\n"}, "reference_outputs": ["atcoder\n"], "source_document_id": "p02817", "source_text": "Score : 100 points\n\nProblem Statement\n\nGiven are two strings S and T consisting of lowercase English letters. Concatenate T and S in this order, without space in between, and print the resulting string.\n\nConstraints\n\nS and T are strings consisting of lowercase English letters.\n\nThe lengths of S and T are between 1 and 100 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS T\n\nOutput\n\nPrint the resulting string.\n\nSample Input 1\n\noder atc\n\nSample Output 1\n\natcoder\n\nWhen S = oder and T = atc, concatenating T and S in this order results in atcoder.\n\nSample Input 2\n\nhumu humu\n\nSample Output 2\n\nhumuhumu", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 35, "cpu_time_ms": 8, "memory_kb": 760}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s967328918", "group_id": "codeNet:p02818", "input_text": "A=io.read\"*n\"\nB=io.read\"*n\"\nK=io.read\"*n\"\n\nif(A-K>=0)then print(A-K,B)return end\nK=K-A\nB=B-K\nprint(0,math.max(0,B))", "language": "Lua", "metadata": {"date": 1587698314, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p02818.html", "problem_id": "p02818", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02818/input.txt", "sample_output_relpath": "derived/input_output/data/p02818/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02818/Lua/s967328918.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s967328918", "user_id": "u726173718"}, "prompt_components": {"gold_output": "0 2\n", "input_to_evaluate": "A=io.read\"*n\"\nB=io.read\"*n\"\nK=io.read\"*n\"\n\nif(A-K>=0)then print(A-K,B)return end\nK=K-A\nB=B-K\nprint(0,math.max(0,B))", "problem_context": "Score : 200 points\n\nProblem Statement\n\nTakahashi has A cookies, and Aoki has B cookies.\nTakahashi will do the following action K times:\n\nIf Takahashi has one or more cookies, eat one of his cookies.\n\nOtherwise, if Aoki has one or more cookies, eat one of Aoki's cookies.\n\nIf they both have no cookies, do nothing.\n\nIn the end, how many cookies will Takahashi and Aoki have, respectively?\n\nConstraints\n\n0 \\leq A \\leq 10^{12}\n\n0 \\leq B \\leq 10^{12}\n\n0 \\leq K \\leq 10^{12}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B K\n\nOutput\n\nPrint the numbers of Takahashi's and Aoki's cookies after K actions.\n\nSample Input 1\n\n2 3 3\n\nSample Output 1\n\n0 2\n\nTakahashi will do the following:\n\nHe has two cookies, so he eats one of them.\n\nNow he has one cookie left, and he eats it.\n\nNow he has no cookies left, but Aoki has three, so Takahashi eats one of them.\n\nThus, in the end, Takahashi will have 0 cookies, and Aoki will have 2.\n\nSample Input 2\n\n500000000000 500000000000 1000000000000\n\nSample Output 2\n\n0 0\n\nWatch out for overflows.", "sample_input": "2 3 3\n"}, "reference_outputs": ["0 2\n"], "source_document_id": "p02818", "source_text": "Score : 200 points\n\nProblem Statement\n\nTakahashi has A cookies, and Aoki has B cookies.\nTakahashi will do the following action K times:\n\nIf Takahashi has one or more cookies, eat one of his cookies.\n\nOtherwise, if Aoki has one or more cookies, eat one of Aoki's cookies.\n\nIf they both have no cookies, do nothing.\n\nIn the end, how many cookies will Takahashi and Aoki have, respectively?\n\nConstraints\n\n0 \\leq A \\leq 10^{12}\n\n0 \\leq B \\leq 10^{12}\n\n0 \\leq K \\leq 10^{12}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B K\n\nOutput\n\nPrint the numbers of Takahashi's and Aoki's cookies after K actions.\n\nSample Input 1\n\n2 3 3\n\nSample Output 1\n\n0 2\n\nTakahashi will do the following:\n\nHe has two cookies, so he eats one of them.\n\nNow he has one cookie left, and he eats it.\n\nNow he has no cookies left, but Aoki has three, so Takahashi eats one of them.\n\nThus, in the end, Takahashi will have 0 cookies, and Aoki will have 2.\n\nSample Input 2\n\n500000000000 500000000000 1000000000000\n\nSample Output 2\n\n0 0\n\nWatch out for overflows.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 115, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s719466368", "group_id": "codeNet:p02818", "input_text": "a = tonumber(io.read())\nb = tonumber(io.read())\nk = tonumber(io.read())\nz = math.min(a, k)\na = a - z\nk = k - z\nz = math.min(b, k)\nb = b - z\nio.write(a, \" \", b, \"\\n\")", "language": "Lua", "metadata": {"date": 1577667791, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p02818.html", "problem_id": "p02818", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02818/input.txt", "sample_output_relpath": "derived/input_output/data/p02818/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02818/Lua/s719466368.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s719466368", "user_id": "u290898260"}, "prompt_components": {"gold_output": "0 2\n", "input_to_evaluate": "a = tonumber(io.read())\nb = tonumber(io.read())\nk = tonumber(io.read())\nz = math.min(a, k)\na = a - z\nk = k - z\nz = math.min(b, k)\nb = b - z\nio.write(a, \" \", b, \"\\n\")", "problem_context": "Score : 200 points\n\nProblem Statement\n\nTakahashi has A cookies, and Aoki has B cookies.\nTakahashi will do the following action K times:\n\nIf Takahashi has one or more cookies, eat one of his cookies.\n\nOtherwise, if Aoki has one or more cookies, eat one of Aoki's cookies.\n\nIf they both have no cookies, do nothing.\n\nIn the end, how many cookies will Takahashi and Aoki have, respectively?\n\nConstraints\n\n0 \\leq A \\leq 10^{12}\n\n0 \\leq B \\leq 10^{12}\n\n0 \\leq K \\leq 10^{12}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B K\n\nOutput\n\nPrint the numbers of Takahashi's and Aoki's cookies after K actions.\n\nSample Input 1\n\n2 3 3\n\nSample Output 1\n\n0 2\n\nTakahashi will do the following:\n\nHe has two cookies, so he eats one of them.\n\nNow he has one cookie left, and he eats it.\n\nNow he has no cookies left, but Aoki has three, so Takahashi eats one of them.\n\nThus, in the end, Takahashi will have 0 cookies, and Aoki will have 2.\n\nSample Input 2\n\n500000000000 500000000000 1000000000000\n\nSample Output 2\n\n0 0\n\nWatch out for overflows.", "sample_input": "2 3 3\n"}, "reference_outputs": ["0 2\n"], "source_document_id": "p02818", "source_text": "Score : 200 points\n\nProblem Statement\n\nTakahashi has A cookies, and Aoki has B cookies.\nTakahashi will do the following action K times:\n\nIf Takahashi has one or more cookies, eat one of his cookies.\n\nOtherwise, if Aoki has one or more cookies, eat one of Aoki's cookies.\n\nIf they both have no cookies, do nothing.\n\nIn the end, how many cookies will Takahashi and Aoki have, respectively?\n\nConstraints\n\n0 \\leq A \\leq 10^{12}\n\n0 \\leq B \\leq 10^{12}\n\n0 \\leq K \\leq 10^{12}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B K\n\nOutput\n\nPrint the numbers of Takahashi's and Aoki's cookies after K actions.\n\nSample Input 1\n\n2 3 3\n\nSample Output 1\n\n0 2\n\nTakahashi will do the following:\n\nHe has two cookies, so he eats one of them.\n\nNow he has one cookie left, and he eats it.\n\nNow he has no cookies left, but Aoki has three, so Takahashi eats one of them.\n\nThus, in the end, Takahashi will have 0 cookies, and Aoki will have 2.\n\nSample Input 2\n\n500000000000 500000000000 1000000000000\n\nSample Output 2\n\n0 0\n\nWatch out for overflows.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 165, "cpu_time_ms": 6, "memory_kb": 888}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s020277110", "group_id": "codeNet:p02819", "input_text": "function judge(n)\n\tfor i = 2, math.sqrt(n) do\n \tif n % i == 0 then\n \t\treturn false\n \tend\n end\n return true\nend\n\nn = tonumber(io.read())\n\nfor i = n, n + 10000 do\n \tif judge(i) then\n \tprint(i)\n \tbreak\n end\nend", "language": "Lua", "metadata": {"date": 1577667904, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p02819.html", "problem_id": "p02819", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02819/input.txt", "sample_output_relpath": "derived/input_output/data/p02819/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02819/Lua/s020277110.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s020277110", "user_id": "u290898260"}, "prompt_components": {"gold_output": "23\n", "input_to_evaluate": "function judge(n)\n\tfor i = 2, math.sqrt(n) do\n \tif n % i == 0 then\n \t\treturn false\n \tend\n end\n return true\nend\n\nn = tonumber(io.read())\n\nfor i = n, n + 10000 do\n \tif judge(i) then\n \tprint(i)\n \tbreak\n end\nend", "problem_context": "Score: 300 points\n\nProblem Statement\n\nFind the minimum prime number greater than or equal to X.\n\nNotes\n\nA prime number is an integer greater than 1 that cannot be evenly divided by any positive integer except 1 and itself.\n\nFor example, 2, 3, and 5 are prime numbers, while 4 and 6 are not.\n\nConstraints\n\n2 \\le X \\le 10^5\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX\n\nOutput\n\nPrint the minimum prime number greater than or equal to X.\n\nSample Input 1\n\n20\n\nSample Output 1\n\n23\n\nThe minimum prime number greater than or equal to 20 is 23.\n\nSample Input 2\n\n2\n\nSample Output 2\n\n2\n\nX itself can be a prime number.\n\nSample Input 3\n\n99992\n\nSample Output 3\n\n100003", "sample_input": "20\n"}, "reference_outputs": ["23\n"], "source_document_id": "p02819", "source_text": "Score: 300 points\n\nProblem Statement\n\nFind the minimum prime number greater than or equal to X.\n\nNotes\n\nA prime number is an integer greater than 1 that cannot be evenly divided by any positive integer except 1 and itself.\n\nFor example, 2, 3, and 5 are prime numbers, while 4 and 6 are not.\n\nConstraints\n\n2 \\le X \\le 10^5\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX\n\nOutput\n\nPrint the minimum prime number greater than or equal to X.\n\nSample Input 1\n\n20\n\nSample Output 1\n\n23\n\nThe minimum prime number greater than or equal to 20 is 23.\n\nSample Input 2\n\n2\n\nSample Output 2\n\n2\n\nX itself can be a prime number.\n\nSample Input 3\n\n99992\n\nSample Output 3\n\n100003", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 234, "cpu_time_ms": 10, "memory_kb": 1008}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s099611203", "group_id": "codeNet:p02820", "input_text": "local n,k=io.read(\"n\",\"n\")\nlocal R,S,P=io.read(\"n\",\"n\",\"n\",\"l\")\nlocal t=io.read()\nlocal a={}\nlocal point=0\n\nfor i=1,n do\n if t:sub(i,i)==\"r\" then\n a[i]=\"p\"\n point=point+P\n end\n if t:sub(i,i)==\"s\" then\n a[i]=\"r\"\n point=point+R\n end\n if t:sub(i,i)==\"p\" then\n a[i]=\"s\"\n point=point+S\n end\nend\n\nfor i=1,n-k do\n if a[i]==a[i+k] then\n if a[i]==\"p\" then\n point=point-P\n a[i+k]=\"\"\n end\n if a[i]==\"r\" then\n point=point-R\n a[i+k]=\"\"\n end\n if a[i]==\"s\" then\n point=point-S\n a[i+k]=\"\"\n end\n end\nend\n\nprint(point)", "language": "Lua", "metadata": {"date": 1590464815, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p02820.html", "problem_id": "p02820", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02820/input.txt", "sample_output_relpath": "derived/input_output/data/p02820/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02820/Lua/s099611203.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s099611203", "user_id": "u045238009"}, "prompt_components": {"gold_output": "27\n", "input_to_evaluate": "local n,k=io.read(\"n\",\"n\")\nlocal R,S,P=io.read(\"n\",\"n\",\"n\",\"l\")\nlocal t=io.read()\nlocal a={}\nlocal point=0\n\nfor i=1,n do\n if t:sub(i,i)==\"r\" then\n a[i]=\"p\"\n point=point+P\n end\n if t:sub(i,i)==\"s\" then\n a[i]=\"r\"\n point=point+R\n end\n if t:sub(i,i)==\"p\" then\n a[i]=\"s\"\n point=point+S\n end\nend\n\nfor i=1,n-k do\n if a[i]==a[i+k] then\n if a[i]==\"p\" then\n point=point-P\n a[i+k]=\"\"\n end\n if a[i]==\"r\" then\n point=point-R\n a[i+k]=\"\"\n end\n if a[i]==\"s\" then\n point=point-S\n a[i+k]=\"\"\n end\n end\nend\n\nprint(point)", "problem_context": "Score : 400 points\n\nProblem Statement\n\nAt an arcade, Takahashi is playing a game called RPS Battle, which is played as follows:\n\nThe player plays N rounds of Rock Paper Scissors against the machine. (See Notes for the description of Rock Paper Scissors. A draw also counts as a round.)\n\nEach time the player wins a round, depending on which hand he/she uses, he/she earns the following score (no points for a draw or a loss):\n\nR points for winning with Rock;\n\nS points for winning with Scissors;\n\nP points for winning with Paper.\n\nHowever, in the i-th round, the player cannot use the hand he/she used in the (i-K)-th round. (In the first K rounds, the player can use any hand.)\n\nBefore the start of the game, the machine decides the hand it will play in each round. With supernatural power, Takahashi managed to read all of those hands.\n\nThe information Takahashi obtained is given as a string T. If the i-th character of T (1 \\leq i \\leq N) is r, the machine will play Rock in the i-th round. Similarly, p and s stand for Paper and Scissors, respectively.\n\nWhat is the maximum total score earned in the game by adequately choosing the hand to play in each round?\n\nNotes\n\nIn this problem, Rock Paper Scissors can be thought of as a two-player game, in which each player simultaneously forms Rock, Paper, or Scissors with a hand.\n\nIf a player chooses Rock and the other chooses Scissors, the player choosing Rock wins;\n\nif a player chooses Scissors and the other chooses Paper, the player choosing Scissors wins;\n\nif a player chooses Paper and the other chooses Rock, the player choosing Paper wins;\n\nif both players play the same hand, it is a draw.\n\nConstraints\n\n2 \\leq N \\leq 10^5\n\n1 \\leq K \\leq N-1\n\n1 \\leq R,S,P \\leq 10^4\n\nN,K,R,S, and P are all integers.\n\n|T| = N\n\nT consists of r, p, and s.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nR S P\nT\n\nOutput\n\nPrint the maximum total score earned in the game.\n\nSample Input 1\n\n5 2\n8 7 6\nrsrpr\n\nSample Output 1\n\n27\n\nThe machine will play {Rock, Scissors, Rock, Paper, Rock}.\n\nWe can, for example, play {Paper, Rock, Rock, Scissors, Paper} against it to earn 27 points.\nWe cannot earn more points, so the answer is 27.\n\nSample Input 2\n\n7 1\n100 10 1\nssssppr\n\nSample Output 2\n\n211\n\nSample Input 3\n\n30 5\n325 234 123\nrspsspspsrpspsppprpsprpssprpsr\n\nSample Output 3\n\n4996", "sample_input": "5 2\n8 7 6\nrsrpr\n"}, "reference_outputs": ["27\n"], "source_document_id": "p02820", "source_text": "Score : 400 points\n\nProblem Statement\n\nAt an arcade, Takahashi is playing a game called RPS Battle, which is played as follows:\n\nThe player plays N rounds of Rock Paper Scissors against the machine. (See Notes for the description of Rock Paper Scissors. A draw also counts as a round.)\n\nEach time the player wins a round, depending on which hand he/she uses, he/she earns the following score (no points for a draw or a loss):\n\nR points for winning with Rock;\n\nS points for winning with Scissors;\n\nP points for winning with Paper.\n\nHowever, in the i-th round, the player cannot use the hand he/she used in the (i-K)-th round. (In the first K rounds, the player can use any hand.)\n\nBefore the start of the game, the machine decides the hand it will play in each round. With supernatural power, Takahashi managed to read all of those hands.\n\nThe information Takahashi obtained is given as a string T. If the i-th character of T (1 \\leq i \\leq N) is r, the machine will play Rock in the i-th round. Similarly, p and s stand for Paper and Scissors, respectively.\n\nWhat is the maximum total score earned in the game by adequately choosing the hand to play in each round?\n\nNotes\n\nIn this problem, Rock Paper Scissors can be thought of as a two-player game, in which each player simultaneously forms Rock, Paper, or Scissors with a hand.\n\nIf a player chooses Rock and the other chooses Scissors, the player choosing Rock wins;\n\nif a player chooses Scissors and the other chooses Paper, the player choosing Scissors wins;\n\nif a player chooses Paper and the other chooses Rock, the player choosing Paper wins;\n\nif both players play the same hand, it is a draw.\n\nConstraints\n\n2 \\leq N \\leq 10^5\n\n1 \\leq K \\leq N-1\n\n1 \\leq R,S,P \\leq 10^4\n\nN,K,R,S, and P are all integers.\n\n|T| = N\n\nT consists of r, p, and s.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nR S P\nT\n\nOutput\n\nPrint the maximum total score earned in the game.\n\nSample Input 1\n\n5 2\n8 7 6\nrsrpr\n\nSample Output 1\n\n27\n\nThe machine will play {Rock, Scissors, Rock, Paper, Rock}.\n\nWe can, for example, play {Paper, Rock, Rock, Scissors, Paper} against it to earn 27 points.\nWe cannot earn more points, so the answer is 27.\n\nSample Input 2\n\n7 1\n100 10 1\nssssppr\n\nSample Output 2\n\n211\n\nSample Input 3\n\n30 5\n325 234 123\nrspsspspsrpspsppprpsprpssprpsr\n\nSample Output 3\n\n4996", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 674, "cpu_time_ms": 47, "memory_kb": 2708}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s859647247", "group_id": "codeNet:p02820", "input_text": "local mma = math.max\nlocal n, k = io.read(\"*n\", \"*n\")\nlocal score_gu, score_cho, score_pa = io.read(\"*n\", \"*n\", \"*n\", \"*l\")\nlocal s = io.read()\n-- 1, 2, 3 gu chi pa\nlocal t = {}\nfor i = 1, #s do\n local tmp = s:sub(i, i)\n if tmp == \"r\" then\n t[i] = 1\n elseif tmp == \"s\" then\n t[i] = 2\n else\n t[i] = 3\n end\nend\nlocal retscore = 0\nfor ikrem = 0, k - 1 do\n local prv_g, prv_c, prv_p = 0, 0, 0\n local cur = 1 + ikrem\n while cur <= n do\n local nxt_g, nxt_c, nxt_p = 0, 0, 0\n if t[cur] == 1 then\n nxt_g = mma(prv_c, prv_p)\n nxt_c = mma(prv_g, prv_p)\n nxt_p = score_pa + mma(prv_g, prv_c)\n elseif t[cur] == 2 then\n nxt_g = score_gu + mma(prv_c, prv_p)\n nxt_c = mma(prv_g, prv_p)\n nxt_p = mma(prv_g, prv_c)\n else\n nxt_g = mma(prv_c, prv_p)\n nxt_c = score_cho + mma(prv_g, prv_p)\n nxt_p = mma(prv_g, prv_c)\n end\n prv_g, prv_c, prv_p = nxt_g, nxt_c, nxt_p\n cur = cur + k\n end\n retscore = retscore + mma(prv_g, mma(prv_c, prv_p))\nend\nprint(retscore)\n", "language": "Lua", "metadata": {"date": 1577669360, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p02820.html", "problem_id": "p02820", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02820/input.txt", "sample_output_relpath": "derived/input_output/data/p02820/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02820/Lua/s859647247.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s859647247", "user_id": "u120582723"}, "prompt_components": {"gold_output": "27\n", "input_to_evaluate": "local mma = math.max\nlocal n, k = io.read(\"*n\", \"*n\")\nlocal score_gu, score_cho, score_pa = io.read(\"*n\", \"*n\", \"*n\", \"*l\")\nlocal s = io.read()\n-- 1, 2, 3 gu chi pa\nlocal t = {}\nfor i = 1, #s do\n local tmp = s:sub(i, i)\n if tmp == \"r\" then\n t[i] = 1\n elseif tmp == \"s\" then\n t[i] = 2\n else\n t[i] = 3\n end\nend\nlocal retscore = 0\nfor ikrem = 0, k - 1 do\n local prv_g, prv_c, prv_p = 0, 0, 0\n local cur = 1 + ikrem\n while cur <= n do\n local nxt_g, nxt_c, nxt_p = 0, 0, 0\n if t[cur] == 1 then\n nxt_g = mma(prv_c, prv_p)\n nxt_c = mma(prv_g, prv_p)\n nxt_p = score_pa + mma(prv_g, prv_c)\n elseif t[cur] == 2 then\n nxt_g = score_gu + mma(prv_c, prv_p)\n nxt_c = mma(prv_g, prv_p)\n nxt_p = mma(prv_g, prv_c)\n else\n nxt_g = mma(prv_c, prv_p)\n nxt_c = score_cho + mma(prv_g, prv_p)\n nxt_p = mma(prv_g, prv_c)\n end\n prv_g, prv_c, prv_p = nxt_g, nxt_c, nxt_p\n cur = cur + k\n end\n retscore = retscore + mma(prv_g, mma(prv_c, prv_p))\nend\nprint(retscore)\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nAt an arcade, Takahashi is playing a game called RPS Battle, which is played as follows:\n\nThe player plays N rounds of Rock Paper Scissors against the machine. (See Notes for the description of Rock Paper Scissors. A draw also counts as a round.)\n\nEach time the player wins a round, depending on which hand he/she uses, he/she earns the following score (no points for a draw or a loss):\n\nR points for winning with Rock;\n\nS points for winning with Scissors;\n\nP points for winning with Paper.\n\nHowever, in the i-th round, the player cannot use the hand he/she used in the (i-K)-th round. (In the first K rounds, the player can use any hand.)\n\nBefore the start of the game, the machine decides the hand it will play in each round. With supernatural power, Takahashi managed to read all of those hands.\n\nThe information Takahashi obtained is given as a string T. If the i-th character of T (1 \\leq i \\leq N) is r, the machine will play Rock in the i-th round. Similarly, p and s stand for Paper and Scissors, respectively.\n\nWhat is the maximum total score earned in the game by adequately choosing the hand to play in each round?\n\nNotes\n\nIn this problem, Rock Paper Scissors can be thought of as a two-player game, in which each player simultaneously forms Rock, Paper, or Scissors with a hand.\n\nIf a player chooses Rock and the other chooses Scissors, the player choosing Rock wins;\n\nif a player chooses Scissors and the other chooses Paper, the player choosing Scissors wins;\n\nif a player chooses Paper and the other chooses Rock, the player choosing Paper wins;\n\nif both players play the same hand, it is a draw.\n\nConstraints\n\n2 \\leq N \\leq 10^5\n\n1 \\leq K \\leq N-1\n\n1 \\leq R,S,P \\leq 10^4\n\nN,K,R,S, and P are all integers.\n\n|T| = N\n\nT consists of r, p, and s.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nR S P\nT\n\nOutput\n\nPrint the maximum total score earned in the game.\n\nSample Input 1\n\n5 2\n8 7 6\nrsrpr\n\nSample Output 1\n\n27\n\nThe machine will play {Rock, Scissors, Rock, Paper, Rock}.\n\nWe can, for example, play {Paper, Rock, Rock, Scissors, Paper} against it to earn 27 points.\nWe cannot earn more points, so the answer is 27.\n\nSample Input 2\n\n7 1\n100 10 1\nssssppr\n\nSample Output 2\n\n211\n\nSample Input 3\n\n30 5\n325 234 123\nrspsspspsrpspsppprpsprpssprpsr\n\nSample Output 3\n\n4996", "sample_input": "5 2\n8 7 6\nrsrpr\n"}, "reference_outputs": ["27\n"], "source_document_id": "p02820", "source_text": "Score : 400 points\n\nProblem Statement\n\nAt an arcade, Takahashi is playing a game called RPS Battle, which is played as follows:\n\nThe player plays N rounds of Rock Paper Scissors against the machine. (See Notes for the description of Rock Paper Scissors. A draw also counts as a round.)\n\nEach time the player wins a round, depending on which hand he/she uses, he/she earns the following score (no points for a draw or a loss):\n\nR points for winning with Rock;\n\nS points for winning with Scissors;\n\nP points for winning with Paper.\n\nHowever, in the i-th round, the player cannot use the hand he/she used in the (i-K)-th round. (In the first K rounds, the player can use any hand.)\n\nBefore the start of the game, the machine decides the hand it will play in each round. With supernatural power, Takahashi managed to read all of those hands.\n\nThe information Takahashi obtained is given as a string T. If the i-th character of T (1 \\leq i \\leq N) is r, the machine will play Rock in the i-th round. Similarly, p and s stand for Paper and Scissors, respectively.\n\nWhat is the maximum total score earned in the game by adequately choosing the hand to play in each round?\n\nNotes\n\nIn this problem, Rock Paper Scissors can be thought of as a two-player game, in which each player simultaneously forms Rock, Paper, or Scissors with a hand.\n\nIf a player chooses Rock and the other chooses Scissors, the player choosing Rock wins;\n\nif a player chooses Scissors and the other chooses Paper, the player choosing Scissors wins;\n\nif a player chooses Paper and the other chooses Rock, the player choosing Paper wins;\n\nif both players play the same hand, it is a draw.\n\nConstraints\n\n2 \\leq N \\leq 10^5\n\n1 \\leq K \\leq N-1\n\n1 \\leq R,S,P \\leq 10^4\n\nN,K,R,S, and P are all integers.\n\n|T| = N\n\nT consists of r, p, and s.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nR S P\nT\n\nOutput\n\nPrint the maximum total score earned in the game.\n\nSample Input 1\n\n5 2\n8 7 6\nrsrpr\n\nSample Output 1\n\n27\n\nThe machine will play {Rock, Scissors, Rock, Paper, Rock}.\n\nWe can, for example, play {Paper, Rock, Rock, Scissors, Paper} against it to earn 27 points.\nWe cannot earn more points, so the answer is 27.\n\nSample Input 2\n\n7 1\n100 10 1\nssssppr\n\nSample Output 2\n\n211\n\nSample Input 3\n\n30 5\n325 234 123\nrspsspspsrpspsppprpsprpssprpsr\n\nSample Output 3\n\n4996", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1029, "cpu_time_ms": 6, "memory_kb": 1632}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s025686727", "group_id": "codeNet:p02821", "input_text": "local mfl = math.floor\n\nlocal function comp(a, b)\n return a < b\nend\n\nlocal function lower_bound(ary, x)\n local num = #ary\n if num == 0 then return 1 end\n if not comp(ary[1], x) then return 1 end\n if comp(ary[num], x) then return num + 1 end\n local min, max = 1, num\n while 1 < max - min do\n local mid = mfl((min + max) / 2)\n if comp(ary[mid], x) then\n min = mid\n else\n max = mid\n end\n end\n return max\nend\n\nlocal n, m = io.read(\"*n\", \"*n\")\nlocal a = {}\nfor i = 1, n do\n a[i] = io.read(\"*n\")\nend\ntable.sort(a)\nlocal asum = {a[1]}\nfor i = 2, n do\n asum[i] = asum[i - 1] + a[i]\nend\n\nlocal function solve(x)\n local cnt = 0\n for i = 1, n do\n local dst = x - a[i]\n local pos = lower_bound(a, dst)\n cnt = cnt + n + 1 - pos\n end\n return m <= cnt\nend\n\nlocal min, max = 0, 200001\nwhile 1 < max - min do\n local mid = mfl((max + min) / 2)\n if solve(mid) then\n min = mid\n else\n max = mid\n end\nend\nlocal ret = 0LL\nlocal mcnt = 0\nfor i = 1, n do\n local dst = min - a[i]\n local pos = lower_bound(a, dst)\n if pos == 1 then\n ret = ret + asum[n] + n * a[i]\n else\n ret = ret + asum[n] - asum[pos - 1] + (n + 1 - pos) * a[i]\n end\n mcnt = mcnt + n + 1 - pos\nend\nif m < mcnt then\n ret = ret - (mcnt - m) * min\nend\nlocal str = tostring(ret):gsub(\"LL\", \"\")\nprint(str)\n", "language": "Lua", "metadata": {"date": 1577669369, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p02821.html", "problem_id": "p02821", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02821/input.txt", "sample_output_relpath": "derived/input_output/data/p02821/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02821/Lua/s025686727.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s025686727", "user_id": "u120582723"}, "prompt_components": {"gold_output": "202\n", "input_to_evaluate": "local mfl = math.floor\n\nlocal function comp(a, b)\n return a < b\nend\n\nlocal function lower_bound(ary, x)\n local num = #ary\n if num == 0 then return 1 end\n if not comp(ary[1], x) then return 1 end\n if comp(ary[num], x) then return num + 1 end\n local min, max = 1, num\n while 1 < max - min do\n local mid = mfl((min + max) / 2)\n if comp(ary[mid], x) then\n min = mid\n else\n max = mid\n end\n end\n return max\nend\n\nlocal n, m = io.read(\"*n\", \"*n\")\nlocal a = {}\nfor i = 1, n do\n a[i] = io.read(\"*n\")\nend\ntable.sort(a)\nlocal asum = {a[1]}\nfor i = 2, n do\n asum[i] = asum[i - 1] + a[i]\nend\n\nlocal function solve(x)\n local cnt = 0\n for i = 1, n do\n local dst = x - a[i]\n local pos = lower_bound(a, dst)\n cnt = cnt + n + 1 - pos\n end\n return m <= cnt\nend\n\nlocal min, max = 0, 200001\nwhile 1 < max - min do\n local mid = mfl((max + min) / 2)\n if solve(mid) then\n min = mid\n else\n max = mid\n end\nend\nlocal ret = 0LL\nlocal mcnt = 0\nfor i = 1, n do\n local dst = min - a[i]\n local pos = lower_bound(a, dst)\n if pos == 1 then\n ret = ret + asum[n] + n * a[i]\n else\n ret = ret + asum[n] - asum[pos - 1] + (n + 1 - pos) * a[i]\n end\n mcnt = mcnt + n + 1 - pos\nend\nif m < mcnt then\n ret = ret - (mcnt - m) * min\nend\nlocal str = tostring(ret):gsub(\"LL\", \"\")\nprint(str)\n", "problem_context": "Score : 500 points\n\nProblem Statement\n\nTakahashi has come to a party as a special guest.\nThere are N ordinary guests at the party. The i-th ordinary guest has a power of A_i.\n\nTakahashi has decided to perform M handshakes to increase the happiness of the party (let the current happiness be 0).\nA handshake will be performed as follows:\n\nTakahashi chooses one (ordinary) guest x for his left hand and another guest y for his right hand (x and y can be the same).\n\nThen, he shakes the left hand of Guest x and the right hand of Guest y simultaneously to increase the happiness by A_x+A_y.\n\nHowever, Takahashi should not perform the same handshake more than once. Formally, the following condition must hold:\n\nAssume that, in the k-th handshake, Takahashi shakes the left hand of Guest x_k and the right hand of Guest y_k. Then, there is no pair p, q (1 \\leq p < q \\leq M) such that (x_p,y_p)=(x_q,y_q).\n\nWhat is the maximum possible happiness after M handshakes?\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n1 \\leq M \\leq N^2\n\n1 \\leq A_i \\leq 10^5\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the maximum possible happiness after M handshakes.\n\nSample Input 1\n\n5 3\n10 14 19 34 33\n\nSample Output 1\n\n202\n\nLet us say that Takahashi performs the following handshakes:\n\nIn the first handshake, Takahashi shakes the left hand of Guest 4 and the right hand of Guest 4.\n\nIn the second handshake, Takahashi shakes the left hand of Guest 4 and the right hand of Guest 5.\n\nIn the third handshake, Takahashi shakes the left hand of Guest 5 and the right hand of Guest 4.\n\nThen, we will have the happiness of (34+34)+(34+33)+(33+34)=202.\n\nWe cannot achieve the happiness of 203 or greater, so the answer is 202.\n\nSample Input 2\n\n9 14\n1 3 5 110 24 21 34 5 3\n\nSample Output 2\n\n1837\n\nSample Input 3\n\n9 73\n67597 52981 5828 66249 75177 64141 40773 79105 16076\n\nSample Output 3\n\n8128170", "sample_input": "5 3\n10 14 19 34 33\n"}, "reference_outputs": ["202\n"], "source_document_id": "p02821", "source_text": "Score : 500 points\n\nProblem Statement\n\nTakahashi has come to a party as a special guest.\nThere are N ordinary guests at the party. The i-th ordinary guest has a power of A_i.\n\nTakahashi has decided to perform M handshakes to increase the happiness of the party (let the current happiness be 0).\nA handshake will be performed as follows:\n\nTakahashi chooses one (ordinary) guest x for his left hand and another guest y for his right hand (x and y can be the same).\n\nThen, he shakes the left hand of Guest x and the right hand of Guest y simultaneously to increase the happiness by A_x+A_y.\n\nHowever, Takahashi should not perform the same handshake more than once. Formally, the following condition must hold:\n\nAssume that, in the k-th handshake, Takahashi shakes the left hand of Guest x_k and the right hand of Guest y_k. Then, there is no pair p, q (1 \\leq p < q \\leq M) such that (x_p,y_p)=(x_q,y_q).\n\nWhat is the maximum possible happiness after M handshakes?\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n1 \\leq M \\leq N^2\n\n1 \\leq A_i \\leq 10^5\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the maximum possible happiness after M handshakes.\n\nSample Input 1\n\n5 3\n10 14 19 34 33\n\nSample Output 1\n\n202\n\nLet us say that Takahashi performs the following handshakes:\n\nIn the first handshake, Takahashi shakes the left hand of Guest 4 and the right hand of Guest 4.\n\nIn the second handshake, Takahashi shakes the left hand of Guest 4 and the right hand of Guest 5.\n\nIn the third handshake, Takahashi shakes the left hand of Guest 5 and the right hand of Guest 4.\n\nThen, we will have the happiness of (34+34)+(34+33)+(33+34)=202.\n\nWe cannot achieve the happiness of 203 or greater, so the answer is 202.\n\nSample Input 2\n\n9 14\n1 3 5 110 24 21 34 5 3\n\nSample Output 2\n\n1837\n\nSample Input 3\n\n9 73\n67597 52981 5828 66249 75177 64141 40773 79105 16076\n\nSample Output 3\n\n8128170", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1311, "cpu_time_ms": 511, "memory_kb": 5504}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s576547242", "group_id": "codeNet:p02823", "input_text": "n,a,b=io.read(\"*n\",\"*n\",\"*n\")\nif a%2==b%2 then\n print((b-a)//2)\nelse\n print(math.min(n-b,a-1)+1+(b-a-1)//2)\nend", "language": "Lua", "metadata": {"date": 1588034368, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p02823.html", "problem_id": "p02823", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02823/input.txt", "sample_output_relpath": "derived/input_output/data/p02823/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02823/Lua/s576547242.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s576547242", "user_id": "u045238009"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "n,a,b=io.read(\"*n\",\"*n\",\"*n\")\nif a%2==b%2 then\n print((b-a)//2)\nelse\n print(math.min(n-b,a-1)+1+(b-a-1)//2)\nend", "problem_context": "Score : 300 points\n\nProblem Statement\n\n2N players are running a competitive table tennis training on N tables numbered from 1 to N.\n\nThe training consists of rounds.\nIn each round, the players form N pairs, one pair per table.\nIn each pair, competitors play a match against each other.\nAs a result, one of them wins and the other one loses.\n\nThe winner of the match on table X plays on table X-1 in the next round,\nexcept for the winner of the match on table 1 who stays at table 1.\n\nSimilarly, the loser of the match on table X plays on table X+1 in the next round,\nexcept for the loser of the match on table N who stays at table N.\n\nTwo friends are playing their first round matches on distinct tables A and B.\nLet's assume that the friends are strong enough to win or lose any match at will.\nWhat is the smallest number of rounds after which the friends can get to play a match against each other?\n\nConstraints\n\n2 \\leq N \\leq 10^{18}\n\n1 \\leq A < B \\leq N\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN A B\n\nOutput\n\nPrint the smallest number of rounds after which the friends can get to play a match against each other.\n\nSample Input 1\n\n5 2 4\n\nSample Output 1\n\n1\n\nIf the first friend loses their match and the second friend wins their match, they will both move to table 3 and play each other in the next round.\n\nSample Input 2\n\n5 2 3\n\nSample Output 2\n\n2\n\nIf both friends win two matches in a row, they will both move to table 1.", "sample_input": "5 2 4\n"}, "reference_outputs": ["1\n"], "source_document_id": "p02823", "source_text": "Score : 300 points\n\nProblem Statement\n\n2N players are running a competitive table tennis training on N tables numbered from 1 to N.\n\nThe training consists of rounds.\nIn each round, the players form N pairs, one pair per table.\nIn each pair, competitors play a match against each other.\nAs a result, one of them wins and the other one loses.\n\nThe winner of the match on table X plays on table X-1 in the next round,\nexcept for the winner of the match on table 1 who stays at table 1.\n\nSimilarly, the loser of the match on table X plays on table X+1 in the next round,\nexcept for the loser of the match on table N who stays at table N.\n\nTwo friends are playing their first round matches on distinct tables A and B.\nLet's assume that the friends are strong enough to win or lose any match at will.\nWhat is the smallest number of rounds after which the friends can get to play a match against each other?\n\nConstraints\n\n2 \\leq N \\leq 10^{18}\n\n1 \\leq A < B \\leq N\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN A B\n\nOutput\n\nPrint the smallest number of rounds after which the friends can get to play a match against each other.\n\nSample Input 1\n\n5 2 4\n\nSample Output 1\n\n1\n\nIf the first friend loses their match and the second friend wins their match, they will both move to table 3 and play each other in the next round.\n\nSample Input 2\n\n5 2 3\n\nSample Output 2\n\n2\n\nIf both friends win two matches in a row, they will both move to table 1.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 117, "cpu_time_ms": 8, "memory_kb": 760}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s022097604", "group_id": "codeNet:p02824", "input_text": "local mfl = math.floor\nlocal n, m = io.read(\"*n\", \"*n\")\nlocal v, p = io.read(\"*n\", \"*n\")\nlocal a = {}\nfor i = 1, n do\n a[i] = io.read(\"*n\")\nend\ntable.sort(a)\n\nlocal function solve(x)\n local currank = n + 1 - x\n local rem = m * (n - v)\n if m < a[n + 1 - p] - a[x] then\n return false\n end\n local need = 0\n local base = a[x]\n for i = x + 1, n + 1 - p do\n need = need + a[i] - base\n end\n -- print(x, need)\n return need <= rem\nend\n\nlocal min, max = 1, n\nwhile 1 < max - min do\n local mid = mfl((min + max) / 2)\n if solve(mid) then\n max = mid\n else\n min = mid\n end\nend\nprint(n + 1 - max)\n", "language": "Lua", "metadata": {"date": 1577585881, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p02824.html", "problem_id": "p02824", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02824/input.txt", "sample_output_relpath": "derived/input_output/data/p02824/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02824/Lua/s022097604.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s022097604", "user_id": "u120582723"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "local mfl = math.floor\nlocal n, m = io.read(\"*n\", \"*n\")\nlocal v, p = io.read(\"*n\", \"*n\")\nlocal a = {}\nfor i = 1, n do\n a[i] = io.read(\"*n\")\nend\ntable.sort(a)\n\nlocal function solve(x)\n local currank = n + 1 - x\n local rem = m * (n - v)\n if m < a[n + 1 - p] - a[x] then\n return false\n end\n local need = 0\n local base = a[x]\n for i = x + 1, n + 1 - p do\n need = need + a[i] - base\n end\n -- print(x, need)\n return need <= rem\nend\n\nlocal min, max = 1, n\nwhile 1 < max - min do\n local mid = mfl((min + max) / 2)\n if solve(mid) then\n max = mid\n else\n min = mid\n end\nend\nprint(n + 1 - max)\n", "problem_context": "Score : 700 points\n\nProblem Statement\n\nN problems are proposed for an upcoming contest. Problem i has an initial integer score of A_i points.\n\nM judges are about to vote for problems they like. Each judge will choose exactly V problems, independently from the other judges,\nand increase the score of each chosen problem by 1.\n\nAfter all M judges cast their vote, the problems will be sorted in non-increasing order of score, and the first P problems will be chosen for the problemset.\nProblems with the same score can be ordered arbitrarily, this order is decided by the chief judge.\n\nHow many problems out of the given N have a chance to be chosen for the problemset?\n\nConstraints\n\n2 \\le N \\le 10^5\n\n1 \\le M \\le 10^9\n\n1 \\le V \\le N - 1\n\n1 \\le P \\le N - 1\n\n0 \\le A_i \\le 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M V P\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the number of problems that have a chance to be chosen for the problemset.\n\nSample Input 1\n\n6 1 2 2\n2 1 1 3 0 2\n\nSample Output 1\n\n5\n\nIf the only judge votes for problems 2 and 5, the scores will be 2 2 1 3 1 2.\nThe problemset will consist of problem 4 and one of problems 1, 2, or 6.\n\nIf the only judge votes for problems 3 and 4, the scores will be 2 1 2 4 0 2.\nThe problemset will consist of problem 4 and one of problems 1, 3, or 6.\n\nThus, problems 1, 2, 3, 4, and 6 have a chance to be chosen for the problemset. On the contrary, there is no way for problem 5 to be chosen.\n\nSample Input 2\n\n6 1 5 2\n2 1 1 3 0 2\n\nSample Output 2\n\n3\n\nOnly problems 1, 4, and 6 have a chance to be chosen.\n\nSample Input 3\n\n10 4 8 5\n7 2 3 6 1 6 5 4 6 5\n\nSample Output 3\n\n8", "sample_input": "6 1 2 2\n2 1 1 3 0 2\n"}, "reference_outputs": ["5\n"], "source_document_id": "p02824", "source_text": "Score : 700 points\n\nProblem Statement\n\nN problems are proposed for an upcoming contest. Problem i has an initial integer score of A_i points.\n\nM judges are about to vote for problems they like. Each judge will choose exactly V problems, independently from the other judges,\nand increase the score of each chosen problem by 1.\n\nAfter all M judges cast their vote, the problems will be sorted in non-increasing order of score, and the first P problems will be chosen for the problemset.\nProblems with the same score can be ordered arbitrarily, this order is decided by the chief judge.\n\nHow many problems out of the given N have a chance to be chosen for the problemset?\n\nConstraints\n\n2 \\le N \\le 10^5\n\n1 \\le M \\le 10^9\n\n1 \\le V \\le N - 1\n\n1 \\le P \\le N - 1\n\n0 \\le A_i \\le 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M V P\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the number of problems that have a chance to be chosen for the problemset.\n\nSample Input 1\n\n6 1 2 2\n2 1 1 3 0 2\n\nSample Output 1\n\n5\n\nIf the only judge votes for problems 2 and 5, the scores will be 2 2 1 3 1 2.\nThe problemset will consist of problem 4 and one of problems 1, 2, or 6.\n\nIf the only judge votes for problems 3 and 4, the scores will be 2 1 2 4 0 2.\nThe problemset will consist of problem 4 and one of problems 1, 3, or 6.\n\nThus, problems 1, 2, 3, 4, and 6 have a chance to be chosen for the problemset. On the contrary, there is no way for problem 5 to be chosen.\n\nSample Input 2\n\n6 1 5 2\n2 1 1 3 0 2\n\nSample Output 2\n\n3\n\nOnly problems 1, 4, and 6 have a chance to be chosen.\n\nSample Input 3\n\n10 4 8 5\n7 2 3 6 1 6 5 4 6 5\n\nSample Output 3\n\n8", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 609, "cpu_time_ms": 86, "memory_kb": 1280}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s468939975", "group_id": "codeNet:p02825", "input_text": "local mfl = math.floor\nlocal n = io.read(\"*n\")\n\nlocal function make_singlemap(k)\n local map = {}\n if k == 4 then\n map = {1, 1, 2, 3, 4, 4, 2, 3, 5, 6, 7, 7, 5, 6, 8, 8}\n elseif k == 3 then\n map = {1, 0, 0, 1, 0, 0, 0, 1, 1}\n elseif k == 5 then\n map = {1, 1, 2, 2, 3,\n 8, 9, 0, 0, 3,\n 8, 9, 0, 0, 4,\n 7, 0, 9, 9, 4,\n 7, 6, 6, 5, 5}\n else\n for i = 1, k * k do map[i] = 0 end\n local corner = mfl((k - 3) / 2)\n -- row = 1\n do\n local edge = mfl((k - 5) / 2)\n for col = 1, k do\n if col <= edge then map[col] = 0\n elseif k - edge < col then map[col] = 0\n elseif col == edge + 1 then map[col] = 1\n else\n map[col] = (col - edge - 2) % 4 < 2 and 2 or 1\n end\n end\n end\n -- 2 <= row <= corner\n for row = 2, corner do\n for col = 1, k do\n local idx = (row - 1) * k + col\n if col <= corner then\n if row + col == 1 + corner or row + col == 2 + corner then\n if (corner - col) % 2 == 0 then\n map[idx] = 1\n else\n map[idx] = 2\n end\n end\n elseif k - corner < col then\n if col - row == k - corner or col - row == k - corner - 1 then\n map[idx] = row % 2 == 0 and 2 or 1\n if row == corner then\n map[idx] = map[idx] + 2\n end\n end\n end\n end\n end\n -- corner + 1 <= row <= k - corner\n do\n local leftcol = map[1 + k * (corner - 1)]\n map[k * corner + 1] = leftcol\n for row = corner + 2, k - corner, 2 do\n leftcol = 3 - leftcol\n map[k * (row - 1) + 1] = leftcol\n map[k * (row) + 1] = leftcol\n end\n local rightcol = map[k * corner]\n for row = corner + 1, k - corner, 2 do\n rightcol = rightcol == 3 and 4 or 3\n map[k * (row)] = rightcol\n map[k * (row + 1)] = rightcol\n end\n local ofst = k * corner + corner\n map[ofst + 1] = 5\n map[ofst + 1 + k] = 5\n map[ofst + 2 + k * 2] = 5\n map[ofst + 3 + k * 2] = 5\n end\n --k - corner < row < k\n do\n local leftcol = map[(k - corner - 1) * k + 1]\n for row = k - corner + 1, k - 1 do\n leftcol = 3 - leftcol\n for col = 1, k do\n local idx = (row - 1) * k + col\n if col <= corner then\n if row - col == k - corner or row - col == k - corner - 1 then\n map[idx] = leftcol\n end\n elseif k - corner < col then\n if row + col == 2 * k - corner + 1 or row + col == 2 * k - corner then\n if (col - (k - corner)) % 2 == 0 then\n map[idx] = 2\n else\n map[idx] = 1\n end\n if col == k then map[idx] = map[idx] + 2 end\n if col == k - corner + 1 then map[idx] = map[idx] + 2 end\n end\n end\n end\n end\n end\n --k == row\n do\n map[(k - 1) * k + corner] = 3\n map[(k - 1) * k + corner + 1] = 3\n map[(k - 1) * k + corner + 2] = 4\n map[(k - 1) * k + corner + 3] = 4\n map[(k - 1) * k + corner + 4] = 3\n end\n end\n return map\nend\n\nlocal function solve(n)\n if n == 2 then\n print(-1)\n return\n end\n local mul = 1\n local k = n\n while k ~= 4 and k % 2 == 0 do\n mul = mul * 2\n k = mfl(k / 2)\n end\n local map = make_singlemap(k)\n for i = 1, n do\n for j = 1, n do\n local map_i = i % k\n if map_i == 0 then map_i = k end\n local map_j = j % k\n if map_j == 0 then map_j = k end\n local mappos = (map_i - 1) * k + map_j\n if map[mappos] == 0 then\n io.write(\".\")\n else\n io.write(string.char(96 + map[mappos]))\n end\n end\n io.write(\"\\n\")\n end\nend\n\nsolve(n)\n", "language": "Lua", "metadata": {"date": 1577593250, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p02825.html", "problem_id": "p02825", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02825/input.txt", "sample_output_relpath": "derived/input_output/data/p02825/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02825/Lua/s468939975.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s468939975", "user_id": "u120582723"}, "prompt_components": {"gold_output": "aabb..\nb..zz.\nba....\n.a..aa\n..a..b\n..a..b\n", "input_to_evaluate": "local mfl = math.floor\nlocal n = io.read(\"*n\")\n\nlocal function make_singlemap(k)\n local map = {}\n if k == 4 then\n map = {1, 1, 2, 3, 4, 4, 2, 3, 5, 6, 7, 7, 5, 6, 8, 8}\n elseif k == 3 then\n map = {1, 0, 0, 1, 0, 0, 0, 1, 1}\n elseif k == 5 then\n map = {1, 1, 2, 2, 3,\n 8, 9, 0, 0, 3,\n 8, 9, 0, 0, 4,\n 7, 0, 9, 9, 4,\n 7, 6, 6, 5, 5}\n else\n for i = 1, k * k do map[i] = 0 end\n local corner = mfl((k - 3) / 2)\n -- row = 1\n do\n local edge = mfl((k - 5) / 2)\n for col = 1, k do\n if col <= edge then map[col] = 0\n elseif k - edge < col then map[col] = 0\n elseif col == edge + 1 then map[col] = 1\n else\n map[col] = (col - edge - 2) % 4 < 2 and 2 or 1\n end\n end\n end\n -- 2 <= row <= corner\n for row = 2, corner do\n for col = 1, k do\n local idx = (row - 1) * k + col\n if col <= corner then\n if row + col == 1 + corner or row + col == 2 + corner then\n if (corner - col) % 2 == 0 then\n map[idx] = 1\n else\n map[idx] = 2\n end\n end\n elseif k - corner < col then\n if col - row == k - corner or col - row == k - corner - 1 then\n map[idx] = row % 2 == 0 and 2 or 1\n if row == corner then\n map[idx] = map[idx] + 2\n end\n end\n end\n end\n end\n -- corner + 1 <= row <= k - corner\n do\n local leftcol = map[1 + k * (corner - 1)]\n map[k * corner + 1] = leftcol\n for row = corner + 2, k - corner, 2 do\n leftcol = 3 - leftcol\n map[k * (row - 1) + 1] = leftcol\n map[k * (row) + 1] = leftcol\n end\n local rightcol = map[k * corner]\n for row = corner + 1, k - corner, 2 do\n rightcol = rightcol == 3 and 4 or 3\n map[k * (row)] = rightcol\n map[k * (row + 1)] = rightcol\n end\n local ofst = k * corner + corner\n map[ofst + 1] = 5\n map[ofst + 1 + k] = 5\n map[ofst + 2 + k * 2] = 5\n map[ofst + 3 + k * 2] = 5\n end\n --k - corner < row < k\n do\n local leftcol = map[(k - corner - 1) * k + 1]\n for row = k - corner + 1, k - 1 do\n leftcol = 3 - leftcol\n for col = 1, k do\n local idx = (row - 1) * k + col\n if col <= corner then\n if row - col == k - corner or row - col == k - corner - 1 then\n map[idx] = leftcol\n end\n elseif k - corner < col then\n if row + col == 2 * k - corner + 1 or row + col == 2 * k - corner then\n if (col - (k - corner)) % 2 == 0 then\n map[idx] = 2\n else\n map[idx] = 1\n end\n if col == k then map[idx] = map[idx] + 2 end\n if col == k - corner + 1 then map[idx] = map[idx] + 2 end\n end\n end\n end\n end\n end\n --k == row\n do\n map[(k - 1) * k + corner] = 3\n map[(k - 1) * k + corner + 1] = 3\n map[(k - 1) * k + corner + 2] = 4\n map[(k - 1) * k + corner + 3] = 4\n map[(k - 1) * k + corner + 4] = 3\n end\n end\n return map\nend\n\nlocal function solve(n)\n if n == 2 then\n print(-1)\n return\n end\n local mul = 1\n local k = n\n while k ~= 4 and k % 2 == 0 do\n mul = mul * 2\n k = mfl(k / 2)\n end\n local map = make_singlemap(k)\n for i = 1, n do\n for j = 1, n do\n local map_i = i % k\n if map_i == 0 then map_i = k end\n local map_j = j % k\n if map_j == 0 then map_j = k end\n local mappos = (map_i - 1) * k + map_j\n if map[mappos] == 0 then\n io.write(\".\")\n else\n io.write(string.char(96 + map[mappos]))\n end\n end\n io.write(\"\\n\")\n end\nend\n\nsolve(n)\n", "problem_context": "Score : 900 points\n\nProblem Statement\n\nLet us consider a grid of squares with N rows and N columns. You want to put some domino pieces on this grid.\nEach domino piece covers two squares that have a common side. Each square can be covered by at most one piece.\n\nFor each row of the grid, let's define its quality as the number of domino pieces that cover at least one square in this row.\nWe define the quality of each column similarly.\n\nFind a way to put at least one domino piece on the grid so that the quality of every row is equal to the quality of every column,\nor determine that such a placement doesn't exist.\n\nConstraints\n\n2 \\le N \\le 1000\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nIf the required domino placement doesn't exist, print a single integer -1.\n\nOtherwise, output your placement as N strings of N characters each.\nIf a square is not covered, the corresponding character must be . (a dot).\nOtherwise, it must contain a lowercase English letter.\nSquares covered by the same domino piece must contain the same letter.\nIf two squares have a common side but belong to different pieces, they must contain different letters.\n\nSample Input 1\n\n6\n\nSample Output 1\n\naabb..\nb..zz.\nba....\n.a..aa\n..a..b\n..a..b\n\nThe quality of every row and every column is 2.\n\nSample Input 2\n\n2\n\nSample Output 2\n\n-1", "sample_input": "6\n"}, "reference_outputs": ["aabb..\nb..zz.\nba....\n.a..aa\n..a..b\n..a..b\n"], "source_document_id": "p02825", "source_text": "Score : 900 points\n\nProblem Statement\n\nLet us consider a grid of squares with N rows and N columns. You want to put some domino pieces on this grid.\nEach domino piece covers two squares that have a common side. Each square can be covered by at most one piece.\n\nFor each row of the grid, let's define its quality as the number of domino pieces that cover at least one square in this row.\nWe define the quality of each column similarly.\n\nFind a way to put at least one domino piece on the grid so that the quality of every row is equal to the quality of every column,\nor determine that such a placement doesn't exist.\n\nConstraints\n\n2 \\le N \\le 1000\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nIf the required domino placement doesn't exist, print a single integer -1.\n\nOtherwise, output your placement as N strings of N characters each.\nIf a square is not covered, the corresponding character must be . (a dot).\nOtherwise, it must contain a lowercase English letter.\nSquares covered by the same domino piece must contain the same letter.\nIf two squares have a common side but belong to different pieces, they must contain different letters.\n\nSample Input 1\n\n6\n\nSample Output 1\n\naabb..\nb..zz.\nba....\n.a..aa\n..a..b\n..a..b\n\nThe quality of every row and every column is 2.\n\nSample Input 2\n\n2\n\nSample Output 2\n\n-1", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 3785, "cpu_time_ms": 29, "memory_kb": 10496}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s732971643", "group_id": "codeNet:p02829", "input_text": "A=io.read\"*n\"\nB=io.read\"*n\"\nprint(6-A-B)", "language": "Lua", "metadata": {"date": 1587698663, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p02829.html", "problem_id": "p02829", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02829/input.txt", "sample_output_relpath": "derived/input_output/data/p02829/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02829/Lua/s732971643.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s732971643", "user_id": "u726173718"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "A=io.read\"*n\"\nB=io.read\"*n\"\nprint(6-A-B)", "problem_context": "Score: 100 points\n\nProblem Statement\n\nTakahashi is solving quizzes. He has easily solved all but the last one.\n\nThe last quiz has three choices: 1, 2, and 3.\n\nWith his supernatural power, Takahashi has found out that the choices A and B are both wrong.\n\nPrint the correct choice for this problem.\n\nConstraints\n\nEach of the numbers A and B is 1, 2, or 3.\n\nA and B are different.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA\nB\n\nOutput\n\nPrint the correct choice.\n\nSample Input 1\n\n3\n1\n\nSample Output 1\n\n2\n\nWhen we know 3 and 1 are both wrong, the correct choice is 2.\n\nSample Input 2\n\n1\n2\n\nSample Output 2\n\n3", "sample_input": "3\n1\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02829", "source_text": "Score: 100 points\n\nProblem Statement\n\nTakahashi is solving quizzes. He has easily solved all but the last one.\n\nThe last quiz has three choices: 1, 2, and 3.\n\nWith his supernatural power, Takahashi has found out that the choices A and B are both wrong.\n\nPrint the correct choice for this problem.\n\nConstraints\n\nEach of the numbers A and B is 1, 2, or 3.\n\nA and B are different.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA\nB\n\nOutput\n\nPrint the correct choice.\n\nSample Input 1\n\n3\n1\n\nSample Output 1\n\n2\n\nWhen we know 3 and 1 are both wrong, the correct choice is 2.\n\nSample Input 2\n\n1\n2\n\nSample Output 2\n\n3", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 40, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s827342187", "group_id": "codeNet:p02830", "input_text": "N=io.read\"*n\"\nio.read()\nS,T=io.read():match(\"(%S+)%s+(%S+)\")\n\nfor i=1,N do\nio.write(S:sub(i,i),T:sub(i,i))\nend\nio.write\"\\n\"", "language": "Lua", "metadata": {"date": 1587699289, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p02830.html", "problem_id": "p02830", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02830/input.txt", "sample_output_relpath": "derived/input_output/data/p02830/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02830/Lua/s827342187.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s827342187", "user_id": "u726173718"}, "prompt_components": {"gold_output": "icpc\n", "input_to_evaluate": "N=io.read\"*n\"\nio.read()\nS,T=io.read():match(\"(%S+)%s+(%S+)\")\n\nfor i=1,N do\nio.write(S:sub(i,i),T:sub(i,i))\nend\nio.write\"\\n\"", "problem_context": "Score : 200 points\n\nProblem Statement\n\nGiven are strings s and t of length N each, both consisting of lowercase English letters.\n\nLet us form a new string by alternating the characters of S and the characters of T, as follows: the first character of S, the first character of T, the second character of S, the second character of T, ..., the N-th character of S, the N-th character of T. Print this new string.\n\nConstraints\n\n1 \\leq N \\leq 100\n\n|S| = |T| = N\n\nS and T are strings consisting of lowercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS T\n\nOutput\n\nPrint the string formed.\n\nSample Input 1\n\n2\nip cc\n\nSample Output 1\n\nicpc\n\nSample Input 2\n\n8\nhmhmnknk uuuuuuuu\n\nSample Output 2\n\nhumuhumunukunuku\n\nSample Input 3\n\n5\naaaaa aaaaa\n\nSample Output 3\n\naaaaaaaaaa", "sample_input": "2\nip cc\n"}, "reference_outputs": ["icpc\n"], "source_document_id": "p02830", "source_text": "Score : 200 points\n\nProblem Statement\n\nGiven are strings s and t of length N each, both consisting of lowercase English letters.\n\nLet us form a new string by alternating the characters of S and the characters of T, as follows: the first character of S, the first character of T, the second character of S, the second character of T, ..., the N-th character of S, the N-th character of T. Print this new string.\n\nConstraints\n\n1 \\leq N \\leq 100\n\n|S| = |T| = N\n\nS and T are strings consisting of lowercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS T\n\nOutput\n\nPrint the string formed.\n\nSample Input 1\n\n2\nip cc\n\nSample Output 1\n\nicpc\n\nSample Input 2\n\n8\nhmhmnknk uuuuuuuu\n\nSample Output 2\n\nhumuhumunukunuku\n\nSample Input 3\n\n5\naaaaa aaaaa\n\nSample Output 3\n\naaaaaaaaaa", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 123, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s981087935", "group_id": "codeNet:p02832", "input_text": "local function reada(n,m)m=m or 1 r={}for i=1,m do r[i]={}end for i=1,n do for j=1,m do r[j][i]=io.read\"*n\"end end return unpack(r)end\n\nN=io.read\"*n\"\na=reada(N)\n\nt=0\ns=0\nfor i=1,N do\n\tif(a[i]~=t+1)then s=s+1\n\telse t=t+1 end\nend\n\nprint(s~=N and s or -1)", "language": "Lua", "metadata": {"date": 1587700127, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p02832.html", "problem_id": "p02832", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02832/input.txt", "sample_output_relpath": "derived/input_output/data/p02832/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02832/Lua/s981087935.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s981087935", "user_id": "u726173718"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "local function reada(n,m)m=m or 1 r={}for i=1,m do r[i]={}end for i=1,n do for j=1,m do r[j][i]=io.read\"*n\"end end return unpack(r)end\n\nN=io.read\"*n\"\na=reada(N)\n\nt=0\ns=0\nfor i=1,N do\n\tif(a[i]~=t+1)then s=s+1\n\telse t=t+1 end\nend\n\nprint(s~=N and s or -1)", "problem_context": "Score : 400 points\n\nProblem Statement\n\nWe have N bricks arranged in a row from left to right.\n\nThe i-th brick from the left (1 \\leq i \\leq N) has an integer a_i written on it.\n\nAmong them, you can break at most N-1 bricks of your choice.\n\nLet us say there are K bricks remaining. Snuke will be satisfied if, for each integer i (1 \\leq i \\leq K), the i-th of those brick from the left has the integer i written on it.\n\nFind the minimum number of bricks you need to break to satisfy Snuke's desire. If his desire is unsatisfiable, print -1 instead.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 200000\n\n1 \\leq a_i \\leq N\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 ... a_N\n\nOutput\n\nPrint the minimum number of bricks that need to be broken to satisfy Snuke's desire, or print -1 if his desire is unsatisfiable.\n\nSample Input 1\n\n3\n2 1 2\n\nSample Output 1\n\n1\n\nIf we break the leftmost brick, the remaining bricks have integers 1 and 2 written on them from left to right, in which case Snuke will be satisfied.\n\nSample Input 2\n\n3\n2 2 2\n\nSample Output 2\n\n-1\n\nIn this case, there is no way to break some of the bricks to satisfy Snuke's desire.\n\nSample Input 3\n\n10\n3 1 4 1 5 9 2 6 5 3\n\nSample Output 3\n\n7\n\nSample Input 4\n\n1\n1\n\nSample Output 4\n\n0\n\nThere may be no need to break the bricks at all.", "sample_input": "3\n2 1 2\n"}, "reference_outputs": ["1\n"], "source_document_id": "p02832", "source_text": "Score : 400 points\n\nProblem Statement\n\nWe have N bricks arranged in a row from left to right.\n\nThe i-th brick from the left (1 \\leq i \\leq N) has an integer a_i written on it.\n\nAmong them, you can break at most N-1 bricks of your choice.\n\nLet us say there are K bricks remaining. Snuke will be satisfied if, for each integer i (1 \\leq i \\leq K), the i-th of those brick from the left has the integer i written on it.\n\nFind the minimum number of bricks you need to break to satisfy Snuke's desire. If his desire is unsatisfiable, print -1 instead.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 200000\n\n1 \\leq a_i \\leq N\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 ... a_N\n\nOutput\n\nPrint the minimum number of bricks that need to be broken to satisfy Snuke's desire, or print -1 if his desire is unsatisfiable.\n\nSample Input 1\n\n3\n2 1 2\n\nSample Output 1\n\n1\n\nIf we break the leftmost brick, the remaining bricks have integers 1 and 2 written on them from left to right, in which case Snuke will be satisfied.\n\nSample Input 2\n\n3\n2 2 2\n\nSample Output 2\n\n-1\n\nIn this case, there is no way to break some of the bricks to satisfy Snuke's desire.\n\nSample Input 3\n\n10\n3 1 4 1 5 9 2 6 5 3\n\nSample Output 3\n\n7\n\nSample Input 4\n\n1\n1\n\nSample Output 4\n\n0\n\nThere may be no need to break the bricks at all.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 252, "cpu_time_ms": 48, "memory_kb": 2304}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s917018226", "group_id": "codeNet:p02833", "input_text": "local n=io.read(\"n\")\nlocal x=10\nlocal counter=0\nwhile x<=n do\n counter=counter+n//x\n x=x*5\nend\nprint(counter)", "language": "Lua", "metadata": {"date": 1591404786, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p02833.html", "problem_id": "p02833", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02833/input.txt", "sample_output_relpath": "derived/input_output/data/p02833/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02833/Lua/s917018226.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s917018226", "user_id": "u045238009"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "local n=io.read(\"n\")\nlocal x=10\nlocal counter=0\nwhile x<=n do\n counter=counter+n//x\n x=x*5\nend\nprint(counter)", "problem_context": "Score : 500 points\n\nProblem Statement\n\nFor an integer n not less than 0, let us define f(n) as follows:\n\nf(n) = 1 (if n < 2)\n\nf(n) = n f(n-2) (if n \\geq 2)\n\nGiven is an integer N. Find the number of trailing zeros in the decimal notation of f(N).\n\nConstraints\n\n0 \\leq N \\leq 10^{18}\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the number of trailing zeros in the decimal notation of f(N).\n\nSample Input 1\n\n12\n\nSample Output 1\n\n1\n\nf(12) = 12 × 10 × 8 × 6 × 4 × 2 = 46080, which has one trailing zero.\n\nSample Input 2\n\n5\n\nSample Output 2\n\n0\n\nf(5) = 5 × 3 × 1 = 15, which has no trailing zeros.\n\nSample Input 3\n\n1000000000000000000\n\nSample Output 3\n\n124999999999999995", "sample_input": "12\n"}, "reference_outputs": ["1\n"], "source_document_id": "p02833", "source_text": "Score : 500 points\n\nProblem Statement\n\nFor an integer n not less than 0, let us define f(n) as follows:\n\nf(n) = 1 (if n < 2)\n\nf(n) = n f(n-2) (if n \\geq 2)\n\nGiven is an integer N. Find the number of trailing zeros in the decimal notation of f(N).\n\nConstraints\n\n0 \\leq N \\leq 10^{18}\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the number of trailing zeros in the decimal notation of f(N).\n\nSample Input 1\n\n12\n\nSample Output 1\n\n1\n\nf(12) = 12 × 10 × 8 × 6 × 4 × 2 = 46080, which has one trailing zero.\n\nSample Input 2\n\n5\n\nSample Output 2\n\n0\n\nf(5) = 5 × 3 × 1 = 15, which has no trailing zeros.\n\nSample Input 3\n\n1000000000000000000\n\nSample Output 3\n\n124999999999999995", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 115, "cpu_time_ms": 8, "memory_kb": 760}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s291433015", "group_id": "codeNet:p02835", "input_text": "local a,b,c=io.read(\"*n\",\"*n\",\"*n\")\nif a+b+c>21 then \n return print \"bust\"\nelse\n return print \"win\"\nend", "language": "Lua", "metadata": {"date": 1576449603, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p02835.html", "problem_id": "p02835", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02835/input.txt", "sample_output_relpath": "derived/input_output/data/p02835/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02835/Lua/s291433015.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s291433015", "user_id": "u373958718"}, "prompt_components": {"gold_output": "win\n", "input_to_evaluate": "local a,b,c=io.read(\"*n\",\"*n\",\"*n\")\nif a+b+c>21 then \n return print \"bust\"\nelse\n return print \"win\"\nend", "problem_context": "Score : 100 points\n\nProblem Statement\n\nGiven are three integers A_1, A_2, and A_3.\n\nIf A_1+A_2+A_3 is greater than or equal to 22, print bust; otherwise, print win.\n\nConstraints\n\n1 \\leq A_i \\leq 13 \\ \\ (i=1,2,3)\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA_1 A_2 A_3\n\nOutput\n\nIf A_1+A_2+A_3 is greater than or equal to 22, print bust; otherwise, print win.\n\nSample Input 1\n\n5 7 9\n\nSample Output 1\n\nwin\n\n5+7+9=21, so print win.\n\nSample Input 2\n\n13 7 2\n\nSample Output 2\n\nbust\n\n13+7+2=22, so print bust.", "sample_input": "5 7 9\n"}, "reference_outputs": ["win\n"], "source_document_id": "p02835", "source_text": "Score : 100 points\n\nProblem Statement\n\nGiven are three integers A_1, A_2, and A_3.\n\nIf A_1+A_2+A_3 is greater than or equal to 22, print bust; otherwise, print win.\n\nConstraints\n\n1 \\leq A_i \\leq 13 \\ \\ (i=1,2,3)\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA_1 A_2 A_3\n\nOutput\n\nIf A_1+A_2+A_3 is greater than or equal to 22, print bust; otherwise, print win.\n\nSample Input 1\n\n5 7 9\n\nSample Output 1\n\nwin\n\n5+7+9=21, so print win.\n\nSample Input 2\n\n13 7 2\n\nSample Output 2\n\nbust\n\n13+7+2=22, so print bust.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 105, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s470219115", "group_id": "codeNet:p02836", "input_text": "local A = tostring(io.read())\n\nlocal counter = 0\nfor i=1 , #A do\n if string.sub(A, i, i) ~= string.sub(string.reverse(A), i, i) then\n counter = counter + 1\n end\nend\nprint(string.format(\"%d\", counter/2))", "language": "Lua", "metadata": {"date": 1581735883, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p02836.html", "problem_id": "p02836", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02836/input.txt", "sample_output_relpath": "derived/input_output/data/p02836/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02836/Lua/s470219115.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s470219115", "user_id": "u045238009"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "local A = tostring(io.read())\n\nlocal counter = 0\nfor i=1 , #A do\n if string.sub(A, i, i) ~= string.sub(string.reverse(A), i, i) then\n counter = counter + 1\n end\nend\nprint(string.format(\"%d\", counter/2))", "problem_context": "Score : 200 points\n\nProblem Statement\n\nTakahashi loves palindromes. Non-palindromic strings are unacceptable to him. Each time he hugs a string, he can change one of its characters to any character of his choice.\n\nGiven is a string S. Find the minimum number of hugs needed to make S palindromic.\n\nConstraints\n\nS is a string consisting of lowercase English letters.\n\nThe length of S is between 1 and 100 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the minimum number of hugs needed to make S palindromic.\n\nSample Input 1\n\nredcoder\n\nSample Output 1\n\n1\n\nFor example, we can change the fourth character to o and get a palindrome redooder.\n\nSample Input 2\n\nvvvvvv\n\nSample Output 2\n\n0\n\nWe might need no hugs at all.\n\nSample Input 3\n\nabcdabc\n\nSample Output 3\n\n2", "sample_input": "redcoder\n"}, "reference_outputs": ["1\n"], "source_document_id": "p02836", "source_text": "Score : 200 points\n\nProblem Statement\n\nTakahashi loves palindromes. Non-palindromic strings are unacceptable to him. Each time he hugs a string, he can change one of its characters to any character of his choice.\n\nGiven is a string S. Find the minimum number of hugs needed to make S palindromic.\n\nConstraints\n\nS is a string consisting of lowercase English letters.\n\nThe length of S is between 1 and 100 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the minimum number of hugs needed to make S palindromic.\n\nSample Input 1\n\nredcoder\n\nSample Output 1\n\n1\n\nFor example, we can change the fourth character to o and get a palindrome redooder.\n\nSample Input 2\n\nvvvvvv\n\nSample Output 2\n\n0\n\nWe might need no hugs at all.\n\nSample Input 3\n\nabcdabc\n\nSample Output 3\n\n2", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 215, "cpu_time_ms": 7, "memory_kb": 760}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s141575008", "group_id": "codeNet:p02837", "input_text": "local mmi, mma = math.min, math.max\nlocal bls, brs = bit.lshift, bit.rshift\nlocal bxor = bit.bxor\n\nlocal function grayCode(x)\n return bxor(x, brs(x, 1))\nend\n\n-- add_func(idx), rm_func(idx), work_func()\nlocal function grayWalk(size, add_func, rm_func, work_func)\n local prv = 0\n local total = bls(1, size) - 1\n local bpos = {}\n for i = 1, size do\n bpos[bls(1, i - 1)] = i\n end\n work_func()\n for i = 1, total do\n local v = grayCode(i)\n if prv < v then\n prv, v = v, v - prv\n add_func(bpos[v])\n else\n prv, v = v, prv - v\n rm_func(bpos[v])\n end\n work_func()\n end\nend\n\nlocal n = io.read(\"*n\")\nlocal t = {}\nlocal maps = {}\nfor i = 1, n do\n t[i] = 0\n local a = io.read(\"*n\")\n maps[i] = {}\n for j = 1, a do\n local p, q = io.read(\"*n\", \"*n\")\n maps[i][p] = q\n end\nend\n\nlocal function add_func(idx)\n t[idx] = 1\nend\nlocal function rm_func(idx)\n t[idx] = 0\nend\nlocal ret = 0\nlocal function work_func()\n local valid = true\n local c = 0\n for i = 1, n do\n if t[i] == 1 then\n c = c + 1\n for k, v in pairs(maps[i]) do\n if t[k] ~= v then\n valid = false break\n end\n end\n else\n for k, v in pairs(maps[i]) do\n if t[k] == v then\n valid = false break\n end\n end\n end\n if not valid then break end\n end\n if valid then\n ret = mma(ret, c)\n end\nend\n\ngrayWalk(n, add_func, rm_func, work_func)\nprint(ret)\n", "language": "Lua", "metadata": {"date": 1597980156, "filename_ext": "lua", "original_language": "Lua (LuaJIT 2.1.0)", "problem_description_relpath": "problem_descriptions/p02837.html", "problem_id": "p02837", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02837/input.txt", "sample_output_relpath": "derived/input_output/data/p02837/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02837/Lua/s141575008.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s141575008", "user_id": "u120582723"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "local mmi, mma = math.min, math.max\nlocal bls, brs = bit.lshift, bit.rshift\nlocal bxor = bit.bxor\n\nlocal function grayCode(x)\n return bxor(x, brs(x, 1))\nend\n\n-- add_func(idx), rm_func(idx), work_func()\nlocal function grayWalk(size, add_func, rm_func, work_func)\n local prv = 0\n local total = bls(1, size) - 1\n local bpos = {}\n for i = 1, size do\n bpos[bls(1, i - 1)] = i\n end\n work_func()\n for i = 1, total do\n local v = grayCode(i)\n if prv < v then\n prv, v = v, v - prv\n add_func(bpos[v])\n else\n prv, v = v, prv - v\n rm_func(bpos[v])\n end\n work_func()\n end\nend\n\nlocal n = io.read(\"*n\")\nlocal t = {}\nlocal maps = {}\nfor i = 1, n do\n t[i] = 0\n local a = io.read(\"*n\")\n maps[i] = {}\n for j = 1, a do\n local p, q = io.read(\"*n\", \"*n\")\n maps[i][p] = q\n end\nend\n\nlocal function add_func(idx)\n t[idx] = 1\nend\nlocal function rm_func(idx)\n t[idx] = 0\nend\nlocal ret = 0\nlocal function work_func()\n local valid = true\n local c = 0\n for i = 1, n do\n if t[i] == 1 then\n c = c + 1\n for k, v in pairs(maps[i]) do\n if t[k] ~= v then\n valid = false break\n end\n end\n else\n for k, v in pairs(maps[i]) do\n if t[k] == v then\n valid = false break\n end\n end\n end\n if not valid then break end\n end\n if valid then\n ret = mma(ret, c)\n end\nend\n\ngrayWalk(n, add_func, rm_func, work_func)\nprint(ret)\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere are N people numbered 1 to N. Each of them is either an honest person whose testimonies are always correct or an unkind person whose testimonies may be correct or not.\n\nPerson i gives A_i testimonies. The j-th testimony by Person i is represented by two integers x_{ij} and y_{ij}. If y_{ij} = 1, the testimony says Person x_{ij} is honest; if y_{ij} = 0, it says Person x_{ij} is unkind.\n\nHow many honest persons can be among those N people at most?\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 15\n\n0 \\leq A_i \\leq N - 1\n\n1 \\leq x_{ij} \\leq N\n\nx_{ij} \\neq i\n\nx_{ij_1} \\neq x_{ij_2} (j_1 \\neq j_2)\n\ny_{ij} = 0, 1\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1\nx_{11} y_{11}\nx_{12} y_{12}\n:\nx_{1A_1} y_{1A_1}\nA_2\nx_{21} y_{21}\nx_{22} y_{22}\n:\nx_{2A_2} y_{2A_2}\n:\nA_N\nx_{N1} y_{N1}\nx_{N2} y_{N2}\n:\nx_{NA_N} y_{NA_N}\n\nOutput\n\nPrint the maximum possible number of honest persons among the N people.\n\nSample Input 1\n\n3\n1\n2 1\n1\n1 1\n1\n2 0\n\nSample Output 1\n\n2\n\nIf Person 1 and Person 2 are honest and Person 3 is unkind, we have two honest persons without inconsistencies, which is the maximum possible number of honest persons.\n\nSample Input 2\n\n3\n2\n2 1\n3 0\n2\n3 1\n1 0\n2\n1 1\n2 0\n\nSample Output 2\n\n0\n\nAssuming that one or more of them are honest immediately leads to a contradiction.\n\nSample Input 3\n\n2\n1\n2 0\n1\n1 0\n\nSample Output 3\n\n1", "sample_input": "3\n1\n2 1\n1\n1 1\n1\n2 0\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02837", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere are N people numbered 1 to N. Each of them is either an honest person whose testimonies are always correct or an unkind person whose testimonies may be correct or not.\n\nPerson i gives A_i testimonies. The j-th testimony by Person i is represented by two integers x_{ij} and y_{ij}. If y_{ij} = 1, the testimony says Person x_{ij} is honest; if y_{ij} = 0, it says Person x_{ij} is unkind.\n\nHow many honest persons can be among those N people at most?\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 15\n\n0 \\leq A_i \\leq N - 1\n\n1 \\leq x_{ij} \\leq N\n\nx_{ij} \\neq i\n\nx_{ij_1} \\neq x_{ij_2} (j_1 \\neq j_2)\n\ny_{ij} = 0, 1\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1\nx_{11} y_{11}\nx_{12} y_{12}\n:\nx_{1A_1} y_{1A_1}\nA_2\nx_{21} y_{21}\nx_{22} y_{22}\n:\nx_{2A_2} y_{2A_2}\n:\nA_N\nx_{N1} y_{N1}\nx_{N2} y_{N2}\n:\nx_{NA_N} y_{NA_N}\n\nOutput\n\nPrint the maximum possible number of honest persons among the N people.\n\nSample Input 1\n\n3\n1\n2 1\n1\n1 1\n1\n2 0\n\nSample Output 1\n\n2\n\nIf Person 1 and Person 2 are honest and Person 3 is unkind, we have two honest persons without inconsistencies, which is the maximum possible number of honest persons.\n\nSample Input 2\n\n3\n2\n2 1\n3 0\n2\n3 1\n1 0\n2\n1 1\n2 0\n\nSample Output 2\n\n0\n\nAssuming that one or more of them are honest immediately leads to a contradiction.\n\nSample Input 3\n\n2\n1\n2 0\n1\n1 0\n\nSample Output 3\n\n1", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1424, "cpu_time_ms": 29, "memory_kb": 2728}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s256631563", "group_id": "codeNet:p02837", "input_text": "local n=io.read(\"n\")\nlocal testimony={}\nfor i=1,n do\n testimony[i]={}\n local a=io.read(\"n\")\n for j=1,a do\n local x,y=io.read(\"n\",\"n\")\n table.insert(testimony[i],{x,y})\n end\nend\n\nlocal function check(bit)\n local checker=true\n for i=1,n do\n if (bit & 1<0 then\n for k,v in pairs(testimony[i]) do\n local x=v[1]\n local y=v[2]\n if y==1 and (bit & 1<0 then\n checker=false\n end\n end\n end\n end\n return checker\nend\n\nlocal max=0\nfor bit=1,1<0 then\n counter=counter+1\n end\n end\n max=math.max(counter,max)\n end\nend\nprint(max)", "language": "Lua", "metadata": {"date": 1593285220, "filename_ext": "lua", "original_language": "Lua (Lua 5.3.5)", "problem_description_relpath": "problem_descriptions/p02837.html", "problem_id": "p02837", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02837/input.txt", "sample_output_relpath": "derived/input_output/data/p02837/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02837/Lua/s256631563.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s256631563", "user_id": "u045238009"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "local n=io.read(\"n\")\nlocal testimony={}\nfor i=1,n do\n testimony[i]={}\n local a=io.read(\"n\")\n for j=1,a do\n local x,y=io.read(\"n\",\"n\")\n table.insert(testimony[i],{x,y})\n end\nend\n\nlocal function check(bit)\n local checker=true\n for i=1,n do\n if (bit & 1<0 then\n for k,v in pairs(testimony[i]) do\n local x=v[1]\n local y=v[2]\n if y==1 and (bit & 1<0 then\n checker=false\n end\n end\n end\n end\n return checker\nend\n\nlocal max=0\nfor bit=1,1<0 then\n counter=counter+1\n end\n end\n max=math.max(counter,max)\n end\nend\nprint(max)", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere are N people numbered 1 to N. Each of them is either an honest person whose testimonies are always correct or an unkind person whose testimonies may be correct or not.\n\nPerson i gives A_i testimonies. The j-th testimony by Person i is represented by two integers x_{ij} and y_{ij}. If y_{ij} = 1, the testimony says Person x_{ij} is honest; if y_{ij} = 0, it says Person x_{ij} is unkind.\n\nHow many honest persons can be among those N people at most?\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 15\n\n0 \\leq A_i \\leq N - 1\n\n1 \\leq x_{ij} \\leq N\n\nx_{ij} \\neq i\n\nx_{ij_1} \\neq x_{ij_2} (j_1 \\neq j_2)\n\ny_{ij} = 0, 1\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1\nx_{11} y_{11}\nx_{12} y_{12}\n:\nx_{1A_1} y_{1A_1}\nA_2\nx_{21} y_{21}\nx_{22} y_{22}\n:\nx_{2A_2} y_{2A_2}\n:\nA_N\nx_{N1} y_{N1}\nx_{N2} y_{N2}\n:\nx_{NA_N} y_{NA_N}\n\nOutput\n\nPrint the maximum possible number of honest persons among the N people.\n\nSample Input 1\n\n3\n1\n2 1\n1\n1 1\n1\n2 0\n\nSample Output 1\n\n2\n\nIf Person 1 and Person 2 are honest and Person 3 is unkind, we have two honest persons without inconsistencies, which is the maximum possible number of honest persons.\n\nSample Input 2\n\n3\n2\n2 1\n3 0\n2\n3 1\n1 0\n2\n1 1\n2 0\n\nSample Output 2\n\n0\n\nAssuming that one or more of them are honest immediately leads to a contradiction.\n\nSample Input 3\n\n2\n1\n2 0\n1\n1 0\n\nSample Output 3\n\n1", "sample_input": "3\n1\n2 1\n1\n1 1\n1\n2 0\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02837", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere are N people numbered 1 to N. Each of them is either an honest person whose testimonies are always correct or an unkind person whose testimonies may be correct or not.\n\nPerson i gives A_i testimonies. The j-th testimony by Person i is represented by two integers x_{ij} and y_{ij}. If y_{ij} = 1, the testimony says Person x_{ij} is honest; if y_{ij} = 0, it says Person x_{ij} is unkind.\n\nHow many honest persons can be among those N people at most?\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 15\n\n0 \\leq A_i \\leq N - 1\n\n1 \\leq x_{ij} \\leq N\n\nx_{ij} \\neq i\n\nx_{ij_1} \\neq x_{ij_2} (j_1 \\neq j_2)\n\ny_{ij} = 0, 1\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1\nx_{11} y_{11}\nx_{12} y_{12}\n:\nx_{1A_1} y_{1A_1}\nA_2\nx_{21} y_{21}\nx_{22} y_{22}\n:\nx_{2A_2} y_{2A_2}\n:\nA_N\nx_{N1} y_{N1}\nx_{N2} y_{N2}\n:\nx_{NA_N} y_{NA_N}\n\nOutput\n\nPrint the maximum possible number of honest persons among the N people.\n\nSample Input 1\n\n3\n1\n2 1\n1\n1 1\n1\n2 0\n\nSample Output 1\n\n2\n\nIf Person 1 and Person 2 are honest and Person 3 is unkind, we have two honest persons without inconsistencies, which is the maximum possible number of honest persons.\n\nSample Input 2\n\n3\n2\n2 1\n3 0\n2\n3 1\n1 0\n2\n1 1\n2 0\n\nSample Output 2\n\n0\n\nAssuming that one or more of them are honest immediately leads to a contradiction.\n\nSample Input 3\n\n2\n1\n2 0\n1\n1 0\n\nSample Output 3\n\n1", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 923, "cpu_time_ms": 297, "memory_kb": 2748}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s264642057", "group_id": "codeNet:p02838", "input_text": "local mod = 1000000007\nlocal mfl = math.floor\nlocal function bmul(x, y)\n local x0, y0 = x % 31623, y % 31623\n local x1, y1 = mfl(x / 31623), mfl(y / 31623)\n return (x1 * y1 * 14122 + (x1 * y0 + x0 * y1) * 31623 + x0 * y0) % mod\nend\nlocal function badd(x, y) return (x + y) % mod end\nlocal function lltonumber(str)\n local ret = 0LL\n for i = 1, #str do\n ret = ret * 10LL\n ret = ret + tonumber(str:sub(i, i))\n end\n return ret\nend\n\nlocal n = io.read(\"*n\", \"*l\")\nlocal box = {0}\nlocal mul = {1}\nfor i = 2, 61 do\n box[i] = 0\n mul[i] = bmul(mul[i - 1], 2)\nend\nlocal ret = 0\nlocal s = io.read()\nlocal str = {}\nfor z in s:gmatch(\"%d+\") do\n table.insert(str, z)\nend\nlocal mulbox = {}\nfor i = 1, 61 do\n mulbox[i] = {}\nend\nlocal function getmul(j, a)\n if a <= 0 then return 0 end\n if not mulbox[j][a] then mulbox[j][a] = bmul(mul[j], a) end\n return mulbox[j][a]\nend\nfor i = 1, n do\n local a = lltonumber(str[i])\n for j = 1, 61 do\n local p = a % 2\n if p == 1LL then\n ret = badd(ret, getmul(j, i - 1 - box[j]))\n box[j] = box[j] + 1\n else\n ret = badd(ret, getmul(j, box[j]))\n end\n a = a / 2\n end\nend\nprint(ret)\n", "language": "Lua", "metadata": {"date": 1575902494, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p02838.html", "problem_id": "p02838", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02838/input.txt", "sample_output_relpath": "derived/input_output/data/p02838/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02838/Lua/s264642057.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s264642057", "user_id": "u120582723"}, "prompt_components": {"gold_output": "6\n", "input_to_evaluate": "local mod = 1000000007\nlocal mfl = math.floor\nlocal function bmul(x, y)\n local x0, y0 = x % 31623, y % 31623\n local x1, y1 = mfl(x / 31623), mfl(y / 31623)\n return (x1 * y1 * 14122 + (x1 * y0 + x0 * y1) * 31623 + x0 * y0) % mod\nend\nlocal function badd(x, y) return (x + y) % mod end\nlocal function lltonumber(str)\n local ret = 0LL\n for i = 1, #str do\n ret = ret * 10LL\n ret = ret + tonumber(str:sub(i, i))\n end\n return ret\nend\n\nlocal n = io.read(\"*n\", \"*l\")\nlocal box = {0}\nlocal mul = {1}\nfor i = 2, 61 do\n box[i] = 0\n mul[i] = bmul(mul[i - 1], 2)\nend\nlocal ret = 0\nlocal s = io.read()\nlocal str = {}\nfor z in s:gmatch(\"%d+\") do\n table.insert(str, z)\nend\nlocal mulbox = {}\nfor i = 1, 61 do\n mulbox[i] = {}\nend\nlocal function getmul(j, a)\n if a <= 0 then return 0 end\n if not mulbox[j][a] then mulbox[j][a] = bmul(mul[j], a) end\n return mulbox[j][a]\nend\nfor i = 1, n do\n local a = lltonumber(str[i])\n for j = 1, 61 do\n local p = a % 2\n if p == 1LL then\n ret = badd(ret, getmul(j, i - 1 - box[j]))\n box[j] = box[j] + 1\n else\n ret = badd(ret, getmul(j, box[j]))\n end\n a = a / 2\n end\nend\nprint(ret)\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nWe have N integers. The i-th integer is A_i.\n\nFind \\sum_{i=1}^{N-1}\\sum_{j=i+1}^{N} (A_i \\mbox{ XOR } A_j), modulo (10^9+7).\n\nWhat is \\mbox{ XOR }?\n\nThe XOR of integers A and B, A \\mbox{ XOR } B, is defined as follows:\n\nWhen A \\mbox{ XOR } B is written in base two, the digit in the 2^k's place (k \\geq 0) is 1 if either A or B, but not both, has 1 in the 2^k's place, and 0 otherwise.\n\nFor example, 3 \\mbox{ XOR } 5 = 6. (In base two: 011 \\mbox{ XOR } 101 = 110.)\n\nConstraints\n\n2 \\leq N \\leq 3 \\times 10^5\n\n0 \\leq A_i < 2^{60}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the value \\sum_{i=1}^{N-1}\\sum_{j=i+1}^{N} (A_i \\mbox{ XOR } A_j), modulo (10^9+7).\n\nSample Input 1\n\n3\n1 2 3\n\nSample Output 1\n\n6\n\nWe have (1\\mbox{ XOR } 2)+(1\\mbox{ XOR } 3)+(2\\mbox{ XOR } 3)=3+2+1=6.\n\nSample Input 2\n\n10\n3 1 4 1 5 9 2 6 5 3\n\nSample Output 2\n\n237\n\nSample Input 3\n\n10\n3 14 159 2653 58979 323846 2643383 27950288 419716939 9375105820\n\nSample Output 3\n\n103715602\n\nPrint the sum modulo (10^9+7).", "sample_input": "3\n1 2 3\n"}, "reference_outputs": ["6\n"], "source_document_id": "p02838", "source_text": "Score : 400 points\n\nProblem Statement\n\nWe have N integers. The i-th integer is A_i.\n\nFind \\sum_{i=1}^{N-1}\\sum_{j=i+1}^{N} (A_i \\mbox{ XOR } A_j), modulo (10^9+7).\n\nWhat is \\mbox{ XOR }?\n\nThe XOR of integers A and B, A \\mbox{ XOR } B, is defined as follows:\n\nWhen A \\mbox{ XOR } B is written in base two, the digit in the 2^k's place (k \\geq 0) is 1 if either A or B, but not both, has 1 in the 2^k's place, and 0 otherwise.\n\nFor example, 3 \\mbox{ XOR } 5 = 6. (In base two: 011 \\mbox{ XOR } 101 = 110.)\n\nConstraints\n\n2 \\leq N \\leq 3 \\times 10^5\n\n0 \\leq A_i < 2^{60}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the value \\sum_{i=1}^{N-1}\\sum_{j=i+1}^{N} (A_i \\mbox{ XOR } A_j), modulo (10^9+7).\n\nSample Input 1\n\n3\n1 2 3\n\nSample Output 1\n\n6\n\nWe have (1\\mbox{ XOR } 2)+(1\\mbox{ XOR } 3)+(2\\mbox{ XOR } 3)=3+2+1=6.\n\nSample Input 2\n\n10\n3 1 4 1 5 9 2 6 5 3\n\nSample Output 2\n\n237\n\nSample Input 3\n\n10\n3 14 159 2653 58979 323846 2643383 27950288 419716939 9375105820\n\nSample Output 3\n\n103715602\n\nPrint the sum modulo (10^9+7).", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1149, "cpu_time_ms": 2119, "memory_kb": 262108}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s068329999", "group_id": "codeNet:p02839", "input_text": "local mmi = math.min\nlocal h, w = io.read(\"*n\", \"*n\")\nlocal a = {}\nfor i = 1, h do\n for j = 1, w do\n a[(i - 1) * w + j] = io.read(\"*n\")\n end\nend\nfor i = 1, h do\n for j = 1, w do\n local idx = (i - 1) * w + j\n a[idx] = a[idx] - io.read(\"*n\")\n end\nend\n\n-- top\nlocal map = {}\nfor i = 1, h * w do map[i] = {} end\nfor i = 1, 161 do map[1][i] = false end\nmap[1][81 + a[1]] = true\nmap[1][81 - a[1]] = true\nfor j = 2, w do\n local av = a[j]\n local lim = 80 * j\n for p = -lim, lim do\n local dst = p + lim + 1\n map[j][dst] = false\n local src = dst - 80\n if av < src and map[j - 1][src - av] then\n map[j][dst] = true\n end\n if src + av <= lim * 2 - 159 and map[j - 1][src + av] then\n map[j][dst] = true\n end\n end\nend\n-- left\nfor i = 2, h do\n local idx = (i - 1) * w + 1\n local av = a[idx]\n local lim = 80 * i\n for p = -lim, lim do\n local dst = p + lim + 1\n local src = dst - 80\n map[idx][dst] = false\n if av < src and map[idx - w][src - av] then\n map[idx][dst] = true\n end\n if src + av <= lim * 2 - 159 and map[idx - w][src + av] then\n map[idx][dst] = true\n end\n end\nend\nlocal mmi = math.min\n-- rem\nfor i = 2, h do\n for j = 2, w do\n local idx = (i - 1) * w + j\n local av = a[idx]\n local lim = mmi(6400, (i + j - 1) * 80) * 2 + 1\n -- if 6400 < lim then lim = 6400 end\n for dst = 1, lim do\n -- for p = -lim, lim do\n -- local dst = p + lim + 1\n local src = dst - 80\n local f = false\n if av < src then\n if map[idx - w][src - av] or map[idx - 1][src - av] then\n f = true\n end\n end\n if not f and src + av <= lim - 160 then\n -- if src + av <= lim * 2 - 159 then\n if map[idx - w][src + av] or map[idx - 1][src + av] then\n f = true\n end\n end\n map[idx][dst] = f\n end\n end\nend\nlocal ret = 1000000007\nlocal mab = math.abs\ndo\n local lim = (h + w - 1) * 80\n for p = -lim, lim do\n if map[h * w][p + lim + 1] then\n if mab(p) < ret then\n ret = mab(p)\n end\n end\n end\nend\nprint(ret)\n", "language": "Lua", "metadata": {"date": 1575954771, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p02839.html", "problem_id": "p02839", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02839/input.txt", "sample_output_relpath": "derived/input_output/data/p02839/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02839/Lua/s068329999.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s068329999", "user_id": "u120582723"}, "prompt_components": {"gold_output": "0\n", "input_to_evaluate": "local mmi = math.min\nlocal h, w = io.read(\"*n\", \"*n\")\nlocal a = {}\nfor i = 1, h do\n for j = 1, w do\n a[(i - 1) * w + j] = io.read(\"*n\")\n end\nend\nfor i = 1, h do\n for j = 1, w do\n local idx = (i - 1) * w + j\n a[idx] = a[idx] - io.read(\"*n\")\n end\nend\n\n-- top\nlocal map = {}\nfor i = 1, h * w do map[i] = {} end\nfor i = 1, 161 do map[1][i] = false end\nmap[1][81 + a[1]] = true\nmap[1][81 - a[1]] = true\nfor j = 2, w do\n local av = a[j]\n local lim = 80 * j\n for p = -lim, lim do\n local dst = p + lim + 1\n map[j][dst] = false\n local src = dst - 80\n if av < src and map[j - 1][src - av] then\n map[j][dst] = true\n end\n if src + av <= lim * 2 - 159 and map[j - 1][src + av] then\n map[j][dst] = true\n end\n end\nend\n-- left\nfor i = 2, h do\n local idx = (i - 1) * w + 1\n local av = a[idx]\n local lim = 80 * i\n for p = -lim, lim do\n local dst = p + lim + 1\n local src = dst - 80\n map[idx][dst] = false\n if av < src and map[idx - w][src - av] then\n map[idx][dst] = true\n end\n if src + av <= lim * 2 - 159 and map[idx - w][src + av] then\n map[idx][dst] = true\n end\n end\nend\nlocal mmi = math.min\n-- rem\nfor i = 2, h do\n for j = 2, w do\n local idx = (i - 1) * w + j\n local av = a[idx]\n local lim = mmi(6400, (i + j - 1) * 80) * 2 + 1\n -- if 6400 < lim then lim = 6400 end\n for dst = 1, lim do\n -- for p = -lim, lim do\n -- local dst = p + lim + 1\n local src = dst - 80\n local f = false\n if av < src then\n if map[idx - w][src - av] or map[idx - 1][src - av] then\n f = true\n end\n end\n if not f and src + av <= lim - 160 then\n -- if src + av <= lim * 2 - 159 then\n if map[idx - w][src + av] or map[idx - 1][src + av] then\n f = true\n end\n end\n map[idx][dst] = f\n end\n end\nend\nlocal ret = 1000000007\nlocal mab = math.abs\ndo\n local lim = (h + w - 1) * 80\n for p = -lim, lim do\n if map[h * w][p + lim + 1] then\n if mab(p) < ret then\n ret = mab(p)\n end\n end\n end\nend\nprint(ret)\n", "problem_context": "Score : 500 points\n\nProblem Statement\n\nWe have a grid with H horizontal rows and W vertical columns. Let (i,j) denote the square at the i-th row from the top and the j-th column from the left.\n\nThe square (i, j) has two numbers A_{ij} and B_{ij} written on it.\n\nFirst, for each square, Takahashi paints one of the written numbers red and the other blue.\n\nThen, he travels from the square (1, 1) to the square (H, W). In one move, he can move from a square (i, j) to the square (i+1, j) or the square (i, j+1). He must not leave the grid.\n\nLet the unbalancedness be the absolute difference of the sum of red numbers and the sum of blue numbers written on the squares along Takahashi's path, including the squares (1, 1) and (H, W).\n\nTakahashi wants to make the unbalancedness as small as possible by appropriately painting the grid and traveling on it.\n\nFind the minimum unbalancedness possible.\n\nConstraints\n\n2 \\leq H \\leq 80\n\n2 \\leq W \\leq 80\n\n0 \\leq A_{ij} \\leq 80\n\n0 \\leq B_{ij} \\leq 80\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\nA_{11} A_{12} \\ldots A_{1W}\n:\nA_{H1} A_{H2} \\ldots A_{HW}\nB_{11} B_{12} \\ldots B_{1W}\n:\nB_{H1} B_{H2} \\ldots B_{HW}\n\nOutput\n\nPrint the minimum unbalancedness possible.\n\nSample Input 1\n\n2 2\n1 2\n3 4\n3 4\n2 1\n\nSample Output 1\n\n0\n\nBy painting the grid and traveling on it as shown in the figure below, the sum of red numbers and the sum of blue numbers are 3+3+1=7 and 1+2+4=7, respectively, for the unbalancedness of 0.\n\nSample Input 2\n\n2 3\n1 10 80\n80 10 1\n1 2 3\n4 5 6\n\nSample Output 2\n\n2", "sample_input": "2 2\n1 2\n3 4\n3 4\n2 1\n"}, "reference_outputs": ["0\n"], "source_document_id": "p02839", "source_text": "Score : 500 points\n\nProblem Statement\n\nWe have a grid with H horizontal rows and W vertical columns. Let (i,j) denote the square at the i-th row from the top and the j-th column from the left.\n\nThe square (i, j) has two numbers A_{ij} and B_{ij} written on it.\n\nFirst, for each square, Takahashi paints one of the written numbers red and the other blue.\n\nThen, he travels from the square (1, 1) to the square (H, W). In one move, he can move from a square (i, j) to the square (i+1, j) or the square (i, j+1). He must not leave the grid.\n\nLet the unbalancedness be the absolute difference of the sum of red numbers and the sum of blue numbers written on the squares along Takahashi's path, including the squares (1, 1) and (H, W).\n\nTakahashi wants to make the unbalancedness as small as possible by appropriately painting the grid and traveling on it.\n\nFind the minimum unbalancedness possible.\n\nConstraints\n\n2 \\leq H \\leq 80\n\n2 \\leq W \\leq 80\n\n0 \\leq A_{ij} \\leq 80\n\n0 \\leq B_{ij} \\leq 80\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\nA_{11} A_{12} \\ldots A_{1W}\n:\nA_{H1} A_{H2} \\ldots A_{HW}\nB_{11} B_{12} \\ldots B_{1W}\n:\nB_{H1} B_{H2} \\ldots B_{HW}\n\nOutput\n\nPrint the minimum unbalancedness possible.\n\nSample Input 1\n\n2 2\n1 2\n3 4\n3 4\n2 1\n\nSample Output 1\n\n0\n\nBy painting the grid and traveling on it as shown in the figure below, the sum of red numbers and the sum of blue numbers are 3+3+1=7 and 1+2+4=7, respectively, for the unbalancedness of 0.\n\nSample Input 2\n\n2 3\n1 10 80\n80 10 1\n1 2 3\n4 5 6\n\nSample Output 2\n\n2", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2074, "cpu_time_ms": 2148, "memory_kb": 740736}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s403760711", "group_id": "codeNet:p02840", "input_text": "local mfl, mce = math.floor, math.ceil\nlocal mmi, mma = math.min, math.max\nlocal n, x, d = io.read(\"*n\", \"*n\", \"*n\")\nif d == 0 then\n if x == 0 then print(1)\n else print(n + 1)\n end\n os.exit()\nelseif d < 0 then\n x, d = -x, -d\nend\nlocal ret = 0\nlocal min, max = 0, 0\nlocal t = {}\nt[0] = {}\ntable.insert(t[0], {0, 0})\nfor i = 1, n do\n min = min + i - 1\n max = max + n - i\n local v = x * i\n local quot = mfl(v / d)\n local rem = v - quot * d\n if rem < 0 then\n rem = rem + d\n quot = quot - 1\n end\n if not t[rem] then t[rem] = {} end\n table.insert(t[rem], {quot + min, quot + max})\nend\nfor k, tbl in pairs(t) do\n table.sort(tbl, function(a, b) return a[1] < b[1] end)\n local curleft, curright = tbl[1][1], tbl[1][2]\n for i = 2, #tbl do\n local l, r = tbl[i][1], tbl[i][2]\n if l <= curright + 1 then\n curright = mma(curright, r)\n else\n ret = ret + (curright - curleft + 1)\n curleft, curright = l, r\n end\n end\n ret = ret + (curright - curleft + 1)\nend\nprint(ret)\n", "language": "Lua", "metadata": {"date": 1598117539, "filename_ext": "lua", "original_language": "Lua (Lua 5.3.5)", "problem_description_relpath": "problem_descriptions/p02840.html", "problem_id": "p02840", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02840/input.txt", "sample_output_relpath": "derived/input_output/data/p02840/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02840/Lua/s403760711.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s403760711", "user_id": "u120582723"}, "prompt_components": {"gold_output": "8\n", "input_to_evaluate": "local mfl, mce = math.floor, math.ceil\nlocal mmi, mma = math.min, math.max\nlocal n, x, d = io.read(\"*n\", \"*n\", \"*n\")\nif d == 0 then\n if x == 0 then print(1)\n else print(n + 1)\n end\n os.exit()\nelseif d < 0 then\n x, d = -x, -d\nend\nlocal ret = 0\nlocal min, max = 0, 0\nlocal t = {}\nt[0] = {}\ntable.insert(t[0], {0, 0})\nfor i = 1, n do\n min = min + i - 1\n max = max + n - i\n local v = x * i\n local quot = mfl(v / d)\n local rem = v - quot * d\n if rem < 0 then\n rem = rem + d\n quot = quot - 1\n end\n if not t[rem] then t[rem] = {} end\n table.insert(t[rem], {quot + min, quot + max})\nend\nfor k, tbl in pairs(t) do\n table.sort(tbl, function(a, b) return a[1] < b[1] end)\n local curleft, curright = tbl[1][1], tbl[1][2]\n for i = 2, #tbl do\n local l, r = tbl[i][1], tbl[i][2]\n if l <= curright + 1 then\n curright = mma(curright, r)\n else\n ret = ret + (curright - curleft + 1)\n curleft, curright = l, r\n end\n end\n ret = ret + (curright - curleft + 1)\nend\nprint(ret)\n", "problem_context": "Score : 600 points\n\nProblem Statement\n\nWe have an integer sequence A of length N, where A_1 = X, A_{i+1} = A_i + D (1 \\leq i < N ) holds.\n\nTakahashi will take some (possibly all or none) of the elements in this sequence, and Aoki will take all of the others.\n\nLet S and T be the sum of the numbers taken by Takahashi and Aoki, respectively. How many possible values of S - T are there?\n\nConstraints\n\n-10^8 \\leq X, D \\leq 10^8\n\n1 \\leq N \\leq 2 \\times 10^5\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN X D\n\nOutput\n\nPrint the number of possible values of S - T.\n\nSample Input 1\n\n3 4 2\n\nSample Output 1\n\n8\n\nA is (4, 6, 8).\n\nThere are eight ways for (Takahashi, Aoki) to take the elements: ((), (4, 6, 8)), ((4), (6, 8)), ((6), (4, 8)), ((8), (4, 6))), ((4, 6), (8))), ((4, 8), (6))), ((6, 8), (4))), and ((4, 6, 8), ()).\n\nThe values of S - T in these ways are -18, -10, -6, -2, 2, 6, 10, and 18, respectively, so there are eight possible values of S - T.\n\nSample Input 2\n\n2 3 -3\n\nSample Output 2\n\n2\n\nA is (3, 0). There are two possible values of S - T: -3 and 3.\n\nSample Input 3\n\n100 14 20\n\nSample Output 3\n\n49805", "sample_input": "3 4 2\n"}, "reference_outputs": ["8\n"], "source_document_id": "p02840", "source_text": "Score : 600 points\n\nProblem Statement\n\nWe have an integer sequence A of length N, where A_1 = X, A_{i+1} = A_i + D (1 \\leq i < N ) holds.\n\nTakahashi will take some (possibly all or none) of the elements in this sequence, and Aoki will take all of the others.\n\nLet S and T be the sum of the numbers taken by Takahashi and Aoki, respectively. How many possible values of S - T are there?\n\nConstraints\n\n-10^8 \\leq X, D \\leq 10^8\n\n1 \\leq N \\leq 2 \\times 10^5\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN X D\n\nOutput\n\nPrint the number of possible values of S - T.\n\nSample Input 1\n\n3 4 2\n\nSample Output 1\n\n8\n\nA is (4, 6, 8).\n\nThere are eight ways for (Takahashi, Aoki) to take the elements: ((), (4, 6, 8)), ((4), (6, 8)), ((6), (4, 8)), ((8), (4, 6))), ((4, 6), (8))), ((4, 8), (6))), ((6, 8), (4))), and ((4, 6, 8), ()).\n\nThe values of S - T in these ways are -18, -10, -6, -2, 2, 6, 10, and 18, respectively, so there are eight possible values of S - T.\n\nSample Input 2\n\n2 3 -3\n\nSample Output 2\n\n2\n\nA is (3, 0). There are two possible values of S - T: -3 and 3.\n\nSample Input 3\n\n100 14 20\n\nSample Output 3\n\n49805", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1005, "cpu_time_ms": 481, "memory_kb": 51264}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s421822709", "group_id": "codeNet:p02840", "input_text": "local mfl, mce = math.floor, math.ceil\nlocal mmi, mma = math.min, math.max\nlocal n, x, d = io.read(\"*n\", \"*n\", \"*n\")\nif d == 0 then\n print(n + 1)\n os.exit()\nelseif d < 0 then\n x, d = -x, -d\nend\nlocal ret = 0\nlocal min, max = 0, 0\nlocal t = {}\nt[0] = {}\ntable.insert(t[0], {0, 0})\nfor i = 1, n do\n min = min + i - 1\n max = max + n - i\n local v = x * i\n local quot = mfl(v / d)\n local rem = v - quot * d\n if rem < 0 then\n rem = rem + d\n quot = quot - 1\n end\n if not t[rem] then t[rem] = {} end\n table.insert(t[rem], {quot + min, quot + max})\nend\nfor k, tbl in pairs(t) do\n table.sort(tbl, function(a, b) return a[1] < b[1] end)\n local curleft, curright = tbl[1][1], tbl[1][2]\n for i = 2, #tbl do\n local l, r = tbl[i][1], tbl[i][2]\n if l <= curright + 1 then\n curright = mma(curright, r)\n else\n ret = ret + (curright - curleft + 1)\n curleft, curright = l, r\n end\n end\n ret = ret + (curright - curleft + 1)\nend\nprint(ret)\n", "language": "Lua", "metadata": {"date": 1598116644, "filename_ext": "lua", "original_language": "Lua (LuaJIT 2.1.0)", "problem_description_relpath": "problem_descriptions/p02840.html", "problem_id": "p02840", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02840/input.txt", "sample_output_relpath": "derived/input_output/data/p02840/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02840/Lua/s421822709.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s421822709", "user_id": "u120582723"}, "prompt_components": {"gold_output": "8\n", "input_to_evaluate": "local mfl, mce = math.floor, math.ceil\nlocal mmi, mma = math.min, math.max\nlocal n, x, d = io.read(\"*n\", \"*n\", \"*n\")\nif d == 0 then\n print(n + 1)\n os.exit()\nelseif d < 0 then\n x, d = -x, -d\nend\nlocal ret = 0\nlocal min, max = 0, 0\nlocal t = {}\nt[0] = {}\ntable.insert(t[0], {0, 0})\nfor i = 1, n do\n min = min + i - 1\n max = max + n - i\n local v = x * i\n local quot = mfl(v / d)\n local rem = v - quot * d\n if rem < 0 then\n rem = rem + d\n quot = quot - 1\n end\n if not t[rem] then t[rem] = {} end\n table.insert(t[rem], {quot + min, quot + max})\nend\nfor k, tbl in pairs(t) do\n table.sort(tbl, function(a, b) return a[1] < b[1] end)\n local curleft, curright = tbl[1][1], tbl[1][2]\n for i = 2, #tbl do\n local l, r = tbl[i][1], tbl[i][2]\n if l <= curright + 1 then\n curright = mma(curright, r)\n else\n ret = ret + (curright - curleft + 1)\n curleft, curright = l, r\n end\n end\n ret = ret + (curright - curleft + 1)\nend\nprint(ret)\n", "problem_context": "Score : 600 points\n\nProblem Statement\n\nWe have an integer sequence A of length N, where A_1 = X, A_{i+1} = A_i + D (1 \\leq i < N ) holds.\n\nTakahashi will take some (possibly all or none) of the elements in this sequence, and Aoki will take all of the others.\n\nLet S and T be the sum of the numbers taken by Takahashi and Aoki, respectively. How many possible values of S - T are there?\n\nConstraints\n\n-10^8 \\leq X, D \\leq 10^8\n\n1 \\leq N \\leq 2 \\times 10^5\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN X D\n\nOutput\n\nPrint the number of possible values of S - T.\n\nSample Input 1\n\n3 4 2\n\nSample Output 1\n\n8\n\nA is (4, 6, 8).\n\nThere are eight ways for (Takahashi, Aoki) to take the elements: ((), (4, 6, 8)), ((4), (6, 8)), ((6), (4, 8)), ((8), (4, 6))), ((4, 6), (8))), ((4, 8), (6))), ((6, 8), (4))), and ((4, 6, 8), ()).\n\nThe values of S - T in these ways are -18, -10, -6, -2, 2, 6, 10, and 18, respectively, so there are eight possible values of S - T.\n\nSample Input 2\n\n2 3 -3\n\nSample Output 2\n\n2\n\nA is (3, 0). There are two possible values of S - T: -3 and 3.\n\nSample Input 3\n\n100 14 20\n\nSample Output 3\n\n49805", "sample_input": "3 4 2\n"}, "reference_outputs": ["8\n"], "source_document_id": "p02840", "source_text": "Score : 600 points\n\nProblem Statement\n\nWe have an integer sequence A of length N, where A_1 = X, A_{i+1} = A_i + D (1 \\leq i < N ) holds.\n\nTakahashi will take some (possibly all or none) of the elements in this sequence, and Aoki will take all of the others.\n\nLet S and T be the sum of the numbers taken by Takahashi and Aoki, respectively. How many possible values of S - T are there?\n\nConstraints\n\n-10^8 \\leq X, D \\leq 10^8\n\n1 \\leq N \\leq 2 \\times 10^5\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN X D\n\nOutput\n\nPrint the number of possible values of S - T.\n\nSample Input 1\n\n3 4 2\n\nSample Output 1\n\n8\n\nA is (4, 6, 8).\n\nThere are eight ways for (Takahashi, Aoki) to take the elements: ((), (4, 6, 8)), ((4), (6, 8)), ((6), (4, 8)), ((8), (4, 6))), ((4, 6), (8))), ((4, 8), (6))), ((6, 8), (4))), and ((4, 6, 8), ()).\n\nThe values of S - T in these ways are -18, -10, -6, -2, 2, 6, 10, and 18, respectively, so there are eight possible values of S - T.\n\nSample Input 2\n\n2 3 -3\n\nSample Output 2\n\n2\n\nA is (3, 0). There are two possible values of S - T: -3 and 3.\n\nSample Input 3\n\n100 14 20\n\nSample Output 3\n\n49805", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 968, "cpu_time_ms": 244, "memory_kb": 41428}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s709475807", "group_id": "codeNet:p02842", "input_text": "local n = io.read(\"*n\")\nn = n * 100\nf = false\nfor i = 1, 50000 do\n local cand = i * 108\n cand = cand - (cand % 100)\n if cand == n then\n print(i)\n f = true\n break\n end\nend\nif not f then\n print(\":(\")\nend\n", "language": "Lua", "metadata": {"date": 1575253377, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p02842.html", "problem_id": "p02842", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02842/input.txt", "sample_output_relpath": "derived/input_output/data/p02842/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02842/Lua/s709475807.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s709475807", "user_id": "u120582723"}, "prompt_components": {"gold_output": "400\n", "input_to_evaluate": "local n = io.read(\"*n\")\nn = n * 100\nf = false\nfor i = 1, 50000 do\n local cand = i * 108\n cand = cand - (cand % 100)\n if cand == n then\n print(i)\n f = true\n break\n end\nend\nif not f then\n print(\":(\")\nend\n", "problem_context": "Score: 200 points\n\nProblem Statement\n\nTakahashi bought a piece of apple pie at ABC Confiserie. According to his memory, he paid N yen (the currency of Japan) for it.\n\nThe consumption tax rate for foods in this shop is 8 percent. That is, to buy an apple pie priced at X yen before tax, you have to pay X \\times 1.08 yen (rounded down to the nearest integer).\n\nTakahashi forgot the price of his apple pie before tax, X, and wants to know it again. Write a program that takes N as input and finds X. We assume X is an integer.\n\nIf there are multiple possible values for X, find any one of them. Also, Takahashi's memory of N, the amount he paid, may be incorrect. If no value could be X, report that fact.\n\nConstraints\n\n1 \\leq N \\leq 50000\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nIf there are values that could be X, the price of the apple pie before tax, print any one of them.\n\nIf there are multiple such values, printing any one of them will be accepted.\n\nIf no value could be X, print :(.\n\nSample Input 1\n\n432\n\nSample Output 1\n\n400\n\nIf the apple pie is priced at 400 yen before tax, you have to pay 400 \\times 1.08 = 432 yen to buy one.\n\nOtherwise, the amount you have to pay will not be 432 yen.\n\nSample Input 2\n\n1079\n\nSample Output 2\n\n:(\n\nThere is no possible price before tax for which you have to pay 1079 yen with tax.\n\nSample Input 3\n\n1001\n\nSample Output 3\n\n927\n\nIf the apple pie is priced 927 yen before tax, by rounding down 927 \\times 1.08 = 1001.16, you have to pay 1001 yen.", "sample_input": "432\n"}, "reference_outputs": ["400\n"], "source_document_id": "p02842", "source_text": "Score: 200 points\n\nProblem Statement\n\nTakahashi bought a piece of apple pie at ABC Confiserie. According to his memory, he paid N yen (the currency of Japan) for it.\n\nThe consumption tax rate for foods in this shop is 8 percent. That is, to buy an apple pie priced at X yen before tax, you have to pay X \\times 1.08 yen (rounded down to the nearest integer).\n\nTakahashi forgot the price of his apple pie before tax, X, and wants to know it again. Write a program that takes N as input and finds X. We assume X is an integer.\n\nIf there are multiple possible values for X, find any one of them. Also, Takahashi's memory of N, the amount he paid, may be incorrect. If no value could be X, report that fact.\n\nConstraints\n\n1 \\leq N \\leq 50000\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nIf there are values that could be X, the price of the apple pie before tax, print any one of them.\n\nIf there are multiple such values, printing any one of them will be accepted.\n\nIf no value could be X, print :(.\n\nSample Input 1\n\n432\n\nSample Output 1\n\n400\n\nIf the apple pie is priced at 400 yen before tax, you have to pay 400 \\times 1.08 = 432 yen to buy one.\n\nOtherwise, the amount you have to pay will not be 432 yen.\n\nSample Input 2\n\n1079\n\nSample Output 2\n\n:(\n\nThere is no possible price before tax for which you have to pay 1079 yen with tax.\n\nSample Input 3\n\n1001\n\nSample Output 3\n\n927\n\nIf the apple pie is priced 927 yen before tax, by rounding down 927 \\times 1.08 = 1001.16, you have to pay 1001 yen.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 216, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s574634762", "group_id": "codeNet:p02843", "input_text": "x = io.read(\"*n\")\nfor i = 1, 1000 do\n min = i * 100\n max = i * 105\n if min <= x and x <= max then\n print(1)\n os.exit()\n end\nend\nprint(0)\n", "language": "Lua", "metadata": {"date": 1589856711, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p02843.html", "problem_id": "p02843", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02843/input.txt", "sample_output_relpath": "derived/input_output/data/p02843/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02843/Lua/s574634762.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s574634762", "user_id": "u120582723"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "x = io.read(\"*n\")\nfor i = 1, 1000 do\n min = i * 100\n max = i * 105\n if min <= x and x <= max then\n print(1)\n os.exit()\n end\nend\nprint(0)\n", "problem_context": "Score: 300 points\n\nProblem Statement\n\nAtCoder Mart sells 1000000 of each of the six items below:\n\nRiceballs, priced at 100 yen (the currency of Japan) each\n\nSandwiches, priced at 101 yen each\n\nCookies, priced at 102 yen each\n\nCakes, priced at 103 yen each\n\nCandies, priced at 104 yen each\n\nComputers, priced at 105 yen each\n\nTakahashi wants to buy some of them that cost exactly X yen in total.\nDetermine whether this is possible.\n\n(Ignore consumption tax.)\n\nConstraints\n\n1 \\leq X \\leq 100000\n\nX is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX\n\nOutput\n\nIf it is possible to buy some set of items that cost exactly X yen in total, print 1; otherwise, print 0.\n\nSample Input 1\n\n615\n\nSample Output 1\n\n1\n\nFor example, we can buy one of each kind of item, which will cost 100+101+102+103+104+105=615 yen in total.\n\nSample Input 2\n\n217\n\nSample Output 2\n\n0\n\nNo set of items costs 217 yen in total.", "sample_input": "615\n"}, "reference_outputs": ["1\n"], "source_document_id": "p02843", "source_text": "Score: 300 points\n\nProblem Statement\n\nAtCoder Mart sells 1000000 of each of the six items below:\n\nRiceballs, priced at 100 yen (the currency of Japan) each\n\nSandwiches, priced at 101 yen each\n\nCookies, priced at 102 yen each\n\nCakes, priced at 103 yen each\n\nCandies, priced at 104 yen each\n\nComputers, priced at 105 yen each\n\nTakahashi wants to buy some of them that cost exactly X yen in total.\nDetermine whether this is possible.\n\n(Ignore consumption tax.)\n\nConstraints\n\n1 \\leq X \\leq 100000\n\nX is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX\n\nOutput\n\nIf it is possible to buy some set of items that cost exactly X yen in total, print 1; otherwise, print 0.\n\nSample Input 1\n\n615\n\nSample Output 1\n\n1\n\nFor example, we can buy one of each kind of item, which will cost 100+101+102+103+104+105=615 yen in total.\n\nSample Input 2\n\n217\n\nSample Output 2\n\n0\n\nNo set of items costs 217 yen in total.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 147, "cpu_time_ms": 7, "memory_kb": 888}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s095214932", "group_id": "codeNet:p02844", "input_text": "local n=io.read(\"*n\",\"*l\")\nlocal s=tostring(io.read())\n\nlocal counter=0\nfor i=0,999 do\n k=string.format(\"%03d\",i)\n local a,b=0,0\n for j=1,n do\n if s:sub(j,j)==k:sub(1,1) then\n a=j\n break\n end\n end\n if a>0 then\n for j=a+1,n do\n if s:sub(j,j)==k:sub(2,2) then\n b=j\n break\n end\n end\n if b>a then\n for j=b+1,n do\n if s:sub(j,j)==k:sub(3,3) then\n counter=counter+1\n break\n end\n end\n end\n end\nend\nprint(counter)", "language": "Lua", "metadata": {"date": 1588695127, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p02844.html", "problem_id": "p02844", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02844/input.txt", "sample_output_relpath": "derived/input_output/data/p02844/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02844/Lua/s095214932.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s095214932", "user_id": "u045238009"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "local n=io.read(\"*n\",\"*l\")\nlocal s=tostring(io.read())\n\nlocal counter=0\nfor i=0,999 do\n k=string.format(\"%03d\",i)\n local a,b=0,0\n for j=1,n do\n if s:sub(j,j)==k:sub(1,1) then\n a=j\n break\n end\n end\n if a>0 then\n for j=a+1,n do\n if s:sub(j,j)==k:sub(2,2) then\n b=j\n break\n end\n end\n if b>a then\n for j=b+1,n do\n if s:sub(j,j)==k:sub(3,3) then\n counter=counter+1\n break\n end\n end\n end\n end\nend\nprint(counter)", "problem_context": "Score: 400 points\n\nProblem Statement\n\nAtCoder Inc. has decided to lock the door of its office with a 3-digit PIN code.\n\nThe company has an N-digit lucky number, S. Takahashi, the president, will erase N-3 digits from S and concatenate the remaining 3 digits without changing the order to set the PIN code.\n\nHow many different PIN codes can he set this way?\n\nBoth the lucky number and the PIN code may begin with a 0.\n\nConstraints\n\n4 \\leq N \\leq 30000\n\nS is a string of length N consisting of digits.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS\n\nOutput\n\nPrint the number of different PIN codes Takahashi can set.\n\nSample Input 1\n\n4\n0224\n\nSample Output 1\n\n3\n\nTakahashi has the following options:\n\nErase the first digit of S and set 224.\n\nErase the second digit of S and set 024.\n\nErase the third digit of S and set 024.\n\nErase the fourth digit of S and set 022.\n\nThus, he can set three different PIN codes: 022, 024, and 224.\n\nSample Input 2\n\n6\n123123\n\nSample Output 2\n\n17\n\nSample Input 3\n\n19\n3141592653589793238\n\nSample Output 3\n\n329", "sample_input": "4\n0224\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02844", "source_text": "Score: 400 points\n\nProblem Statement\n\nAtCoder Inc. has decided to lock the door of its office with a 3-digit PIN code.\n\nThe company has an N-digit lucky number, S. Takahashi, the president, will erase N-3 digits from S and concatenate the remaining 3 digits without changing the order to set the PIN code.\n\nHow many different PIN codes can he set this way?\n\nBoth the lucky number and the PIN code may begin with a 0.\n\nConstraints\n\n4 \\leq N \\leq 30000\n\nS is a string of length N consisting of digits.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS\n\nOutput\n\nPrint the number of different PIN codes Takahashi can set.\n\nSample Input 1\n\n4\n0224\n\nSample Output 1\n\n3\n\nTakahashi has the following options:\n\nErase the first digit of S and set 224.\n\nErase the second digit of S and set 024.\n\nErase the third digit of S and set 024.\n\nErase the fourth digit of S and set 022.\n\nThus, he can set three different PIN codes: 022, 024, and 224.\n\nSample Input 2\n\n6\n123123\n\nSample Output 2\n\n17\n\nSample Input 3\n\n19\n3141592653589793238\n\nSample Output 3\n\n329", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 629, "cpu_time_ms": 2107, "memory_kb": 1008}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s665013088", "group_id": "codeNet:p02844", "input_text": "local n=io.read(\"*n\",\"*l\")\nlocal s=tostring(io.read())\n\nlocal t={}\nfor i=0,9 do\n for j=0,9 do\n for k=0,9 do\n pin=tostring(i..j..k)\n table.insert(t,pin)\n end\n end\nend\n\nlocal counter=0\nfor i=1,1000 do\n k=t[i]\n a,b=0,0\n for j=1,n do\n if s:sub(j,j)==k:sub(1,1) then\n a=j\n break\n end\n end\n if a>0 then\n for j=a+1,n do\n if s:sub(j,j)==k:sub(2,2) then\n b=j\n break\n end\n end\n if b>a then\n for j=b+1,n do\n if s:sub(j,j)==k:sub(3,3) then\n counter=counter+1\n break\n end\n end\n end\n end\nend\nprint(counter)", "language": "Lua", "metadata": {"date": 1588694606, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p02844.html", "problem_id": "p02844", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02844/input.txt", "sample_output_relpath": "derived/input_output/data/p02844/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02844/Lua/s665013088.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s665013088", "user_id": "u045238009"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "local n=io.read(\"*n\",\"*l\")\nlocal s=tostring(io.read())\n\nlocal t={}\nfor i=0,9 do\n for j=0,9 do\n for k=0,9 do\n pin=tostring(i..j..k)\n table.insert(t,pin)\n end\n end\nend\n\nlocal counter=0\nfor i=1,1000 do\n k=t[i]\n a,b=0,0\n for j=1,n do\n if s:sub(j,j)==k:sub(1,1) then\n a=j\n break\n end\n end\n if a>0 then\n for j=a+1,n do\n if s:sub(j,j)==k:sub(2,2) then\n b=j\n break\n end\n end\n if b>a then\n for j=b+1,n do\n if s:sub(j,j)==k:sub(3,3) then\n counter=counter+1\n break\n end\n end\n end\n end\nend\nprint(counter)", "problem_context": "Score: 400 points\n\nProblem Statement\n\nAtCoder Inc. has decided to lock the door of its office with a 3-digit PIN code.\n\nThe company has an N-digit lucky number, S. Takahashi, the president, will erase N-3 digits from S and concatenate the remaining 3 digits without changing the order to set the PIN code.\n\nHow many different PIN codes can he set this way?\n\nBoth the lucky number and the PIN code may begin with a 0.\n\nConstraints\n\n4 \\leq N \\leq 30000\n\nS is a string of length N consisting of digits.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS\n\nOutput\n\nPrint the number of different PIN codes Takahashi can set.\n\nSample Input 1\n\n4\n0224\n\nSample Output 1\n\n3\n\nTakahashi has the following options:\n\nErase the first digit of S and set 224.\n\nErase the second digit of S and set 024.\n\nErase the third digit of S and set 024.\n\nErase the fourth digit of S and set 022.\n\nThus, he can set three different PIN codes: 022, 024, and 224.\n\nSample Input 2\n\n6\n123123\n\nSample Output 2\n\n17\n\nSample Input 3\n\n19\n3141592653589793238\n\nSample Output 3\n\n329", "sample_input": "4\n0224\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02844", "source_text": "Score: 400 points\n\nProblem Statement\n\nAtCoder Inc. has decided to lock the door of its office with a 3-digit PIN code.\n\nThe company has an N-digit lucky number, S. Takahashi, the president, will erase N-3 digits from S and concatenate the remaining 3 digits without changing the order to set the PIN code.\n\nHow many different PIN codes can he set this way?\n\nBoth the lucky number and the PIN code may begin with a 0.\n\nConstraints\n\n4 \\leq N \\leq 30000\n\nS is a string of length N consisting of digits.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS\n\nOutput\n\nPrint the number of different PIN codes Takahashi can set.\n\nSample Input 1\n\n4\n0224\n\nSample Output 1\n\n3\n\nTakahashi has the following options:\n\nErase the first digit of S and set 224.\n\nErase the second digit of S and set 024.\n\nErase the third digit of S and set 024.\n\nErase the fourth digit of S and set 022.\n\nThus, he can set three different PIN codes: 022, 024, and 224.\n\nSample Input 2\n\n6\n123123\n\nSample Output 2\n\n17\n\nSample Input 3\n\n19\n3141592653589793238\n\nSample Output 3\n\n329", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 758, "cpu_time_ms": 2107, "memory_kb": 1008}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s929734943", "group_id": "codeNet:p02847", "input_text": "local s=io.read()\nlocal weekday={\"SUN\",\"MON\",\"TUE\",\"WED\",\"THU\",\"FRI\",\"SAT\"}\nfor i=1,7 do\n if weekday[i]==s then\n print(7-i+1)\n return\n end\nend", "language": "Lua", "metadata": {"date": 1592090582, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p02847.html", "problem_id": "p02847", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02847/input.txt", "sample_output_relpath": "derived/input_output/data/p02847/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02847/Lua/s929734943.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s929734943", "user_id": "u045238009"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "local s=io.read()\nlocal weekday={\"SUN\",\"MON\",\"TUE\",\"WED\",\"THU\",\"FRI\",\"SAT\"}\nfor i=1,7 do\n if weekday[i]==s then\n print(7-i+1)\n return\n end\nend", "problem_context": "Score : 100 points\n\nProblem Statement\n\nGiven is a string S representing the day of the week today.\n\nS is SUN, MON, TUE, WED, THU, FRI, or SAT, for Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, and Saturday, respectively.\n\nAfter how many days is the next Sunday (tomorrow or later)?\n\nConstraints\n\nS is SUN, MON, TUE, WED, THU, FRI, or SAT.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the number of days before the next Sunday.\n\nSample Input 1\n\nSAT\n\nSample Output 1\n\n1\n\nIt is Saturday today, and tomorrow will be Sunday.\n\nSample Input 2\n\nSUN\n\nSample Output 2\n\n7\n\nIt is Sunday today, and seven days later, it will be Sunday again.", "sample_input": "SAT\n"}, "reference_outputs": ["1\n"], "source_document_id": "p02847", "source_text": "Score : 100 points\n\nProblem Statement\n\nGiven is a string S representing the day of the week today.\n\nS is SUN, MON, TUE, WED, THU, FRI, or SAT, for Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, and Saturday, respectively.\n\nAfter how many days is the next Sunday (tomorrow or later)?\n\nConstraints\n\nS is SUN, MON, TUE, WED, THU, FRI, or SAT.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the number of days before the next Sunday.\n\nSample Input 1\n\nSAT\n\nSample Output 1\n\n1\n\nIt is Saturday today, and tomorrow will be Sunday.\n\nSample Input 2\n\nSUN\n\nSample Output 2\n\n7\n\nIt is Sunday today, and seven days later, it will be Sunday again.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 162, "cpu_time_ms": 10, "memory_kb": 884}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s955177718", "group_id": "codeNet:p02847", "input_text": "s=io.read()\nd={SAT=1,FRI=2,THU=3,WED=4,TUE=5,MON=6,SUN=7}\nprint(d[s])", "language": "Lua", "metadata": {"date": 1579277798, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p02847.html", "problem_id": "p02847", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02847/input.txt", "sample_output_relpath": "derived/input_output/data/p02847/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02847/Lua/s955177718.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s955177718", "user_id": "u720483676"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "s=io.read()\nd={SAT=1,FRI=2,THU=3,WED=4,TUE=5,MON=6,SUN=7}\nprint(d[s])", "problem_context": "Score : 100 points\n\nProblem Statement\n\nGiven is a string S representing the day of the week today.\n\nS is SUN, MON, TUE, WED, THU, FRI, or SAT, for Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, and Saturday, respectively.\n\nAfter how many days is the next Sunday (tomorrow or later)?\n\nConstraints\n\nS is SUN, MON, TUE, WED, THU, FRI, or SAT.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the number of days before the next Sunday.\n\nSample Input 1\n\nSAT\n\nSample Output 1\n\n1\n\nIt is Saturday today, and tomorrow will be Sunday.\n\nSample Input 2\n\nSUN\n\nSample Output 2\n\n7\n\nIt is Sunday today, and seven days later, it will be Sunday again.", "sample_input": "SAT\n"}, "reference_outputs": ["1\n"], "source_document_id": "p02847", "source_text": "Score : 100 points\n\nProblem Statement\n\nGiven is a string S representing the day of the week today.\n\nS is SUN, MON, TUE, WED, THU, FRI, or SAT, for Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, and Saturday, respectively.\n\nAfter how many days is the next Sunday (tomorrow or later)?\n\nConstraints\n\nS is SUN, MON, TUE, WED, THU, FRI, or SAT.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the number of days before the next Sunday.\n\nSample Input 1\n\nSAT\n\nSample Output 1\n\n1\n\nIt is Saturday today, and tomorrow will be Sunday.\n\nSample Input 2\n\nSUN\n\nSample Output 2\n\n7\n\nIt is Sunday today, and seven days later, it will be Sunday again.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 69, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s850716681", "group_id": "codeNet:p02848", "input_text": "a=(\"A\"):byte()\nz=(\"Z\"):byte()\nN=io.read\"*n\"\nio.read()\nS=io.read()\nfor i=1,#S do\nio.write(string.char(\n(S:sub(i,i):byte()-a+N)%(z-a+1)+a)\n)\nend\nio.write\"\\n\"", "language": "Lua", "metadata": {"date": 1587768317, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p02848.html", "problem_id": "p02848", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02848/input.txt", "sample_output_relpath": "derived/input_output/data/p02848/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02848/Lua/s850716681.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s850716681", "user_id": "u726173718"}, "prompt_components": {"gold_output": "CDEZAB\n", "input_to_evaluate": "a=(\"A\"):byte()\nz=(\"Z\"):byte()\nN=io.read\"*n\"\nio.read()\nS=io.read()\nfor i=1,#S do\nio.write(string.char(\n(S:sub(i,i):byte()-a+N)%(z-a+1)+a)\n)\nend\nio.write\"\\n\"", "problem_context": "Score : 200 points\n\nProblem Statement\n\nWe have a string S consisting of uppercase English letters. Additionally, an integer N will be given.\n\nShift each character of S by N in alphabetical order (see below), and print the resulting string.\n\nWe assume that A follows Z. For example, shifting A by 2 results in C (A \\to B \\to C), and shifting Y by 3 results in B (Y \\to Z \\to A \\to B).\n\nConstraints\n\n0 \\leq N \\leq 26\n\n1 \\leq |S| \\leq 10^4\n\nS consists of uppercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS\n\nOutput\n\nPrint the string resulting from shifting each character of S by N in alphabetical order.\n\nSample Input 1\n\n2\nABCXYZ\n\nSample Output 1\n\nCDEZAB\n\nNote that A follows Z.\n\nSample Input 2\n\n0\nABCXYZ\n\nSample Output 2\n\nABCXYZ\n\nSample Input 3\n\n13\nABCDEFGHIJKLMNOPQRSTUVWXYZ\n\nSample Output 3\n\nNOPQRSTUVWXYZABCDEFGHIJKLM", "sample_input": "2\nABCXYZ\n"}, "reference_outputs": ["CDEZAB\n"], "source_document_id": "p02848", "source_text": "Score : 200 points\n\nProblem Statement\n\nWe have a string S consisting of uppercase English letters. Additionally, an integer N will be given.\n\nShift each character of S by N in alphabetical order (see below), and print the resulting string.\n\nWe assume that A follows Z. For example, shifting A by 2 results in C (A \\to B \\to C), and shifting Y by 3 results in B (Y \\to Z \\to A \\to B).\n\nConstraints\n\n0 \\leq N \\leq 26\n\n1 \\leq |S| \\leq 10^4\n\nS consists of uppercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS\n\nOutput\n\nPrint the string resulting from shifting each character of S by N in alphabetical order.\n\nSample Input 1\n\n2\nABCXYZ\n\nSample Output 1\n\nCDEZAB\n\nNote that A follows Z.\n\nSample Input 2\n\n0\nABCXYZ\n\nSample Output 2\n\nABCXYZ\n\nSample Input 3\n\n13\nABCDEFGHIJKLMNOPQRSTUVWXYZ\n\nSample Output 3\n\nNOPQRSTUVWXYZABCDEFGHIJKLM", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 155, "cpu_time_ms": 3, "memory_kb": 256}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s176305265", "group_id": "codeNet:p02848", "input_text": "num = io.read(\"*l\")\nstr = io.read(\"*l\")\nans = \"\"\nfor i=1,#str do\n c = string.byte(str,i)\n ans = ans..string.char((c+num-65)%26+65)\nend\nprint(ans)", "language": "Lua", "metadata": {"date": 1574970475, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p02848.html", "problem_id": "p02848", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02848/input.txt", "sample_output_relpath": "derived/input_output/data/p02848/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02848/Lua/s176305265.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s176305265", "user_id": "u483156389"}, "prompt_components": {"gold_output": "CDEZAB\n", "input_to_evaluate": "num = io.read(\"*l\")\nstr = io.read(\"*l\")\nans = \"\"\nfor i=1,#str do\n c = string.byte(str,i)\n ans = ans..string.char((c+num-65)%26+65)\nend\nprint(ans)", "problem_context": "Score : 200 points\n\nProblem Statement\n\nWe have a string S consisting of uppercase English letters. Additionally, an integer N will be given.\n\nShift each character of S by N in alphabetical order (see below), and print the resulting string.\n\nWe assume that A follows Z. For example, shifting A by 2 results in C (A \\to B \\to C), and shifting Y by 3 results in B (Y \\to Z \\to A \\to B).\n\nConstraints\n\n0 \\leq N \\leq 26\n\n1 \\leq |S| \\leq 10^4\n\nS consists of uppercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS\n\nOutput\n\nPrint the string resulting from shifting each character of S by N in alphabetical order.\n\nSample Input 1\n\n2\nABCXYZ\n\nSample Output 1\n\nCDEZAB\n\nNote that A follows Z.\n\nSample Input 2\n\n0\nABCXYZ\n\nSample Output 2\n\nABCXYZ\n\nSample Input 3\n\n13\nABCDEFGHIJKLMNOPQRSTUVWXYZ\n\nSample Output 3\n\nNOPQRSTUVWXYZABCDEFGHIJKLM", "sample_input": "2\nABCXYZ\n"}, "reference_outputs": ["CDEZAB\n"], "source_document_id": "p02848", "source_text": "Score : 200 points\n\nProblem Statement\n\nWe have a string S consisting of uppercase English letters. Additionally, an integer N will be given.\n\nShift each character of S by N in alphabetical order (see below), and print the resulting string.\n\nWe assume that A follows Z. For example, shifting A by 2 results in C (A \\to B \\to C), and shifting Y by 3 results in B (Y \\to Z \\to A \\to B).\n\nConstraints\n\n0 \\leq N \\leq 26\n\n1 \\leq |S| \\leq 10^4\n\nS consists of uppercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS\n\nOutput\n\nPrint the string resulting from shifting each character of S by N in alphabetical order.\n\nSample Input 1\n\n2\nABCXYZ\n\nSample Output 1\n\nCDEZAB\n\nNote that A follows Z.\n\nSample Input 2\n\n0\nABCXYZ\n\nSample Output 2\n\nABCXYZ\n\nSample Input 3\n\n13\nABCDEFGHIJKLMNOPQRSTUVWXYZ\n\nSample Output 3\n\nNOPQRSTUVWXYZABCDEFGHIJKLM", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 147, "cpu_time_ms": 11, "memory_kb": 504}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s127215883", "group_id": "codeNet:p02850", "input_text": "local List = {}\nfunction List.new ()\n return {first = 0, last = -1}\nend\n\nfunction List.pushleft (list, value)\n local first = list.first - 1\n list.first = first\n list[first] = value\nend\n\nfunction List.pushright (list, value)\n local last = list.last + 1\n list.last = last\n list[last] = value\nend\n\nfunction List.popleft (list)\n local first = list.first\n local value = list[first]\n list[first] = nil\n list.first = first + 1\n return value\nend\n\nfunction List.popright (list)\n local last = list.last\n local value = list[last]\n list[last] = nil\n list.last = last - 1\n return value\nend\n\nfunction List.empty (list)\n return list.first > list.last\nend\n\n----------\n\nlocal n=io.read(\"n\")\nlocal graph={}\nfor i=1,n do\n graph[i]={}\nend\nfor i=1,n-1 do\n local a,b=io.read(\"n\",\"n\")\n graph[a][b]=i\n graph[b][a]=i\nend\n\nlocal que=List.new()\nList.pushright(que,1)\nlocal out={}\nlocal k=0\nwhile not List.empty(que) do\n local a=List.popleft(que)\n local used=0\n for b,i in pairs(graph[a]) do\n if out[-i] then\n used=used+out[-i]\n break\n end\n end\n local deg=0\n local color=1\n for b,i in pairs(graph[a]) do\n if color==used then\n color=color+1\n end\n out[i]=color\n if graph[a][b]>0 then\n graph[a][b]=-graph[a][b]\n graph[b][a]=-graph[b][a]\n List.pushright(que,b)\n color=color+1\n end\n deg=deg+1\n end\n k=math.max(deg,k)\nend\n\nprint(k)\nfor i=1,n-1 do\n print(out[i])\nend", "language": "Lua", "metadata": {"date": 1598152047, "filename_ext": "lua", "original_language": "Lua (Lua 5.3.5)", "problem_description_relpath": "problem_descriptions/p02850.html", "problem_id": "p02850", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02850/input.txt", "sample_output_relpath": "derived/input_output/data/p02850/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02850/Lua/s127215883.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s127215883", "user_id": "u045238009"}, "prompt_components": {"gold_output": "2\n1\n2\n", "input_to_evaluate": "local List = {}\nfunction List.new ()\n return {first = 0, last = -1}\nend\n\nfunction List.pushleft (list, value)\n local first = list.first - 1\n list.first = first\n list[first] = value\nend\n\nfunction List.pushright (list, value)\n local last = list.last + 1\n list.last = last\n list[last] = value\nend\n\nfunction List.popleft (list)\n local first = list.first\n local value = list[first]\n list[first] = nil\n list.first = first + 1\n return value\nend\n\nfunction List.popright (list)\n local last = list.last\n local value = list[last]\n list[last] = nil\n list.last = last - 1\n return value\nend\n\nfunction List.empty (list)\n return list.first > list.last\nend\n\n----------\n\nlocal n=io.read(\"n\")\nlocal graph={}\nfor i=1,n do\n graph[i]={}\nend\nfor i=1,n-1 do\n local a,b=io.read(\"n\",\"n\")\n graph[a][b]=i\n graph[b][a]=i\nend\n\nlocal que=List.new()\nList.pushright(que,1)\nlocal out={}\nlocal k=0\nwhile not List.empty(que) do\n local a=List.popleft(que)\n local used=0\n for b,i in pairs(graph[a]) do\n if out[-i] then\n used=used+out[-i]\n break\n end\n end\n local deg=0\n local color=1\n for b,i in pairs(graph[a]) do\n if color==used then\n color=color+1\n end\n out[i]=color\n if graph[a][b]>0 then\n graph[a][b]=-graph[a][b]\n graph[b][a]=-graph[b][a]\n List.pushright(que,b)\n color=color+1\n end\n deg=deg+1\n end\n k=math.max(deg,k)\nend\n\nprint(k)\nfor i=1,n-1 do\n print(out[i])\nend", "problem_context": "Score : 400 points\n\nProblem Statement\n\nGiven is a tree G with N vertices.\nThe vertices are numbered 1 through N, and the i-th edge connects Vertex a_i and Vertex b_i.\n\nConsider painting the edges in G with some number of colors.\nWe want to paint them so that, for each vertex, the colors of the edges incident to that vertex are all different.\n\nAmong the colorings satisfying the condition above, construct one that uses the minimum number of colors.\n\nConstraints\n\n2 \\le N \\le 10^5\n\n1 \\le a_i \\lt b_i \\le N\n\nAll values in input are integers.\n\nThe given graph is a tree.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 b_1\na_2 b_2\n\\vdots\na_{N-1} b_{N-1}\n\nOutput\n\nPrint N lines.\n\nThe first line should contain K, the number of colors used.\n\nThe (i+1)-th line (1 \\le i \\le N-1) should contain c_i, the integer representing the color of the i-th edge, where 1 \\le c_i \\le K must hold.\n\nIf there are multiple colorings with the minimum number of colors that satisfy the condition, printing any of them will be accepted.\n\nSample Input 1\n\n3\n1 2\n2 3\n\nSample Output 1\n\n2\n1\n2\n\nSample Input 2\n\n8\n1 2\n2 3\n2 4\n2 5\n4 7\n5 6\n6 8\n\nSample Output 2\n\n4\n1\n2\n3\n4\n1\n1\n2\n\nSample Input 3\n\n6\n1 2\n1 3\n1 4\n1 5\n1 6\n\nSample Output 3\n\n5\n1\n2\n3\n4\n5", "sample_input": "3\n1 2\n2 3\n"}, "reference_outputs": ["2\n1\n2\n"], "source_document_id": "p02850", "source_text": "Score : 400 points\n\nProblem Statement\n\nGiven is a tree G with N vertices.\nThe vertices are numbered 1 through N, and the i-th edge connects Vertex a_i and Vertex b_i.\n\nConsider painting the edges in G with some number of colors.\nWe want to paint them so that, for each vertex, the colors of the edges incident to that vertex are all different.\n\nAmong the colorings satisfying the condition above, construct one that uses the minimum number of colors.\n\nConstraints\n\n2 \\le N \\le 10^5\n\n1 \\le a_i \\lt b_i \\le N\n\nAll values in input are integers.\n\nThe given graph is a tree.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 b_1\na_2 b_2\n\\vdots\na_{N-1} b_{N-1}\n\nOutput\n\nPrint N lines.\n\nThe first line should contain K, the number of colors used.\n\nThe (i+1)-th line (1 \\le i \\le N-1) should contain c_i, the integer representing the color of the i-th edge, where 1 \\le c_i \\le K must hold.\n\nIf there are multiple colorings with the minimum number of colors that satisfy the condition, printing any of them will be accepted.\n\nSample Input 1\n\n3\n1 2\n2 3\n\nSample Output 1\n\n2\n1\n2\n\nSample Input 2\n\n8\n1 2\n2 3\n2 4\n2 5\n4 7\n5 6\n6 8\n\nSample Output 2\n\n4\n1\n2\n3\n4\n1\n1\n2\n\nSample Input 3\n\n6\n1 2\n1 3\n1 4\n1 5\n1 6\n\nSample Output 3\n\n5\n1\n2\n3\n4\n5", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1560, "cpu_time_ms": 466, "memory_kb": 28392}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s033964526", "group_id": "codeNet:p02852", "input_text": "local mfl, mce, mmi = math.floor, math.ceil, math.min\nlocal SegTree = {}\nSegTree.updateAll = function(self)\n for i = self.stagenum - 1, 1, -1 do\n for j = 1, self.cnt[i] do\n self.stage[i][j] = self.func(self.stage[i + 1][j * 2 - 1], self.stage[i + 1][j * 2])\n end\n end\nend\nSegTree.create = function(self, n, func, emptyvalue)\n self.func, self.emptyvalue = func, emptyvalue\n local stagenum, mul = 1, 1\n self.cnt, self.stage, self.size = {1}, {{}}, {}\n while mul < n do\n mul, stagenum = mul * 2, stagenum + 1\n self.cnt[stagenum], self.stage[stagenum] = mul, {}\n end\n for i = 1, stagenum do self.size[i] = self.cnt[stagenum + 1 - i] end\n self.stagenum = stagenum\n for i = 1, n do self.stage[stagenum][i] = i end\n for i = n + 1, mul do self.stage[stagenum][i] = emptyvalue end\n self:updateAll()\nend\nSegTree.getRange = function(self, left, right)\n if left == right then return self.stage[self.stagenum][left] end\n local start_stage = 1\n while right - left + 1 < self.size[start_stage] do\n start_stage = start_stage + 1\n end\n local ret = self.emptyvalue\n local t1, t2, t3 = {start_stage}, {left}, {right}\n while 0 < #t1 do\n local stage, l, r = t1[#t1], t2[#t1], t3[#t1]\n table.remove(t1) table.remove(t2) table.remove(t3)\n local sz = self.size[stage]\n if (l - 1) % sz ~= 0 then\n local newr = mmi(r, mce((l - 1) / sz) * sz)\n table.insert(t1, stage + 1) table.insert(t2, l) table.insert(t3, newr)\n l = newr + 1\n end\n if sz <= r + 1 - l then\n ret = self.func(ret, self.stage[stage][mce(l / sz)])\n l = l + sz\n end\n if l <= r then\n table.insert(t1, stage + 1) table.insert(t2, l) table.insert(t3, r)\n end\n end\n return ret\nend\nSegTree.update = function(self, idx, value)\n for i = self.stagenum - 1, 1, -1 do\n local dst = mce(idx / 2)\n local rem = dst * 4 - 1 - idx\n self.stage[i][dst] = self.func(self.stage[i + 1][idx], self.stage[i + 1][rem])\n idx = dst\n end\nend\nSegTree.new = function(n, func, emptyvalue)\n local obj = {}\n setmetatable(obj, {__index = SegTree})\n obj:create(n, func, emptyvalue)\n return obj\nend\n\nlocal n, m = io.read(\"*n\", \"*n\", \"*l\")\nlocal s = io.read()\nlocal map = {}\nfor i = 1, n + 1 do\n map[i] = s:sub(i, i) == \"0\"\nend\nlocal len = {}\nlocal inf = n + 2\nfor i = 1, n do\n len[i] = inf\nend\nlen[n + 1] = 0\nlen[n + 2] = inf\nlocal st = SegTree.new(n + 2, function(a, b) return len[a] < len[b] and a or b end, n + 2)\nst:updateAll()\nfor i = n, 1, -1 do\n if map[i] then\n local right = mmi(n + 1, i + m)\n local minpos = st:getRange(i + 1, right)\n len[i] = len[minpos] + 1\n st:update(i)\n end\nend\nif inf <= len[1] then\n print(-1)\nelse\n local cur, curpos = len[1], 1\n local ret = {}\n for i = 2, n + 1 do\n if cur == len[i] + 1 then\n table.insert(ret, i - curpos)\n cur, curpos = cur - 1, i\n end\n end\n print(table.concat(ret, \" \"))\nend\n", "language": "Lua", "metadata": {"date": 1574692408, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p02852.html", "problem_id": "p02852", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02852/input.txt", "sample_output_relpath": "derived/input_output/data/p02852/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02852/Lua/s033964526.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s033964526", "user_id": "u120582723"}, "prompt_components": {"gold_output": "1 3 2 3\n", "input_to_evaluate": "local mfl, mce, mmi = math.floor, math.ceil, math.min\nlocal SegTree = {}\nSegTree.updateAll = function(self)\n for i = self.stagenum - 1, 1, -1 do\n for j = 1, self.cnt[i] do\n self.stage[i][j] = self.func(self.stage[i + 1][j * 2 - 1], self.stage[i + 1][j * 2])\n end\n end\nend\nSegTree.create = function(self, n, func, emptyvalue)\n self.func, self.emptyvalue = func, emptyvalue\n local stagenum, mul = 1, 1\n self.cnt, self.stage, self.size = {1}, {{}}, {}\n while mul < n do\n mul, stagenum = mul * 2, stagenum + 1\n self.cnt[stagenum], self.stage[stagenum] = mul, {}\n end\n for i = 1, stagenum do self.size[i] = self.cnt[stagenum + 1 - i] end\n self.stagenum = stagenum\n for i = 1, n do self.stage[stagenum][i] = i end\n for i = n + 1, mul do self.stage[stagenum][i] = emptyvalue end\n self:updateAll()\nend\nSegTree.getRange = function(self, left, right)\n if left == right then return self.stage[self.stagenum][left] end\n local start_stage = 1\n while right - left + 1 < self.size[start_stage] do\n start_stage = start_stage + 1\n end\n local ret = self.emptyvalue\n local t1, t2, t3 = {start_stage}, {left}, {right}\n while 0 < #t1 do\n local stage, l, r = t1[#t1], t2[#t1], t3[#t1]\n table.remove(t1) table.remove(t2) table.remove(t3)\n local sz = self.size[stage]\n if (l - 1) % sz ~= 0 then\n local newr = mmi(r, mce((l - 1) / sz) * sz)\n table.insert(t1, stage + 1) table.insert(t2, l) table.insert(t3, newr)\n l = newr + 1\n end\n if sz <= r + 1 - l then\n ret = self.func(ret, self.stage[stage][mce(l / sz)])\n l = l + sz\n end\n if l <= r then\n table.insert(t1, stage + 1) table.insert(t2, l) table.insert(t3, r)\n end\n end\n return ret\nend\nSegTree.update = function(self, idx, value)\n for i = self.stagenum - 1, 1, -1 do\n local dst = mce(idx / 2)\n local rem = dst * 4 - 1 - idx\n self.stage[i][dst] = self.func(self.stage[i + 1][idx], self.stage[i + 1][rem])\n idx = dst\n end\nend\nSegTree.new = function(n, func, emptyvalue)\n local obj = {}\n setmetatable(obj, {__index = SegTree})\n obj:create(n, func, emptyvalue)\n return obj\nend\n\nlocal n, m = io.read(\"*n\", \"*n\", \"*l\")\nlocal s = io.read()\nlocal map = {}\nfor i = 1, n + 1 do\n map[i] = s:sub(i, i) == \"0\"\nend\nlocal len = {}\nlocal inf = n + 2\nfor i = 1, n do\n len[i] = inf\nend\nlen[n + 1] = 0\nlen[n + 2] = inf\nlocal st = SegTree.new(n + 2, function(a, b) return len[a] < len[b] and a or b end, n + 2)\nst:updateAll()\nfor i = n, 1, -1 do\n if map[i] then\n local right = mmi(n + 1, i + m)\n local minpos = st:getRange(i + 1, right)\n len[i] = len[minpos] + 1\n st:update(i)\n end\nend\nif inf <= len[1] then\n print(-1)\nelse\n local cur, curpos = len[1], 1\n local ret = {}\n for i = 2, n + 1 do\n if cur == len[i] + 1 then\n table.insert(ret, i - curpos)\n cur, curpos = cur - 1, i\n end\n end\n print(table.concat(ret, \" \"))\nend\n", "problem_context": "Score : 600 points\n\nProblem Statement\n\nTakahashi is playing a board game called Sugoroku.\n\nOn the board, there are N + 1 squares numbered 0 to N. Takahashi starts at Square 0, and he has to stop exactly at Square N to win the game.\n\nThe game uses a roulette with the M numbers from 1 to M. In each turn, Takahashi spins the roulette. If the number x comes up when he is at Square s, he moves to Square s+x. If this makes him go beyond Square N, he loses the game.\n\nAdditionally, some of the squares are Game Over Squares. He also loses the game if he stops at one of those squares. You are given a string S of length N + 1, representing which squares are Game Over Squares. For each i (0 \\leq i \\leq N), Square i is a Game Over Square if S[i] = 1 and not if S[i] = 0.\n\nFind the sequence of numbers coming up in the roulette in which Takahashi can win the game in the fewest number of turns possible. If there are multiple such sequences, find the lexicographically smallest such sequence. If Takahashi cannot win the game, print -1.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^5\n\n|S| = N + 1\n\nS consists of 0 and 1.\n\nS[0] = 0\n\nS[N] = 0\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nS\n\nOutput\n\nIf Takahashi can win the game, print the lexicographically smallest sequence among the shortest sequences of numbers coming up in the roulette in which Takahashi can win the game, with spaces in between.\n\nIf Takahashi cannot win the game, print -1.\n\nSample Input 1\n\n9 3\n0001000100\n\nSample Output 1\n\n1 3 2 3\n\nIf the numbers 1, 3, 2, 3 come up in this order, Takahashi can reach Square 9 via Square 1, 4, and 6. He cannot reach Square 9 in three or fewer turns, and this is the lexicographically smallest sequence in which he reaches Square 9 in four turns.\n\nSample Input 2\n\n5 4\n011110\n\nSample Output 2\n\n-1\n\nTakahashi cannot reach Square 5.\n\nSample Input 3\n\n6 6\n0101010\n\nSample Output 3\n\n6", "sample_input": "9 3\n0001000100\n"}, "reference_outputs": ["1 3 2 3\n"], "source_document_id": "p02852", "source_text": "Score : 600 points\n\nProblem Statement\n\nTakahashi is playing a board game called Sugoroku.\n\nOn the board, there are N + 1 squares numbered 0 to N. Takahashi starts at Square 0, and he has to stop exactly at Square N to win the game.\n\nThe game uses a roulette with the M numbers from 1 to M. In each turn, Takahashi spins the roulette. If the number x comes up when he is at Square s, he moves to Square s+x. If this makes him go beyond Square N, he loses the game.\n\nAdditionally, some of the squares are Game Over Squares. He also loses the game if he stops at one of those squares. You are given a string S of length N + 1, representing which squares are Game Over Squares. For each i (0 \\leq i \\leq N), Square i is a Game Over Square if S[i] = 1 and not if S[i] = 0.\n\nFind the sequence of numbers coming up in the roulette in which Takahashi can win the game in the fewest number of turns possible. If there are multiple such sequences, find the lexicographically smallest such sequence. If Takahashi cannot win the game, print -1.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^5\n\n|S| = N + 1\n\nS consists of 0 and 1.\n\nS[0] = 0\n\nS[N] = 0\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nS\n\nOutput\n\nIf Takahashi can win the game, print the lexicographically smallest sequence among the shortest sequences of numbers coming up in the roulette in which Takahashi can win the game, with spaces in between.\n\nIf Takahashi cannot win the game, print -1.\n\nSample Input 1\n\n9 3\n0001000100\n\nSample Output 1\n\n1 3 2 3\n\nIf the numbers 1, 3, 2, 3 come up in this order, Takahashi can reach Square 9 via Square 1, 4, and 6. He cannot reach Square 9 in three or fewer turns, and this is the lexicographically smallest sequence in which he reaches Square 9 in four turns.\n\nSample Input 2\n\n5 4\n011110\n\nSample Output 2\n\n-1\n\nTakahashi cannot reach Square 5.\n\nSample Input 3\n\n6 6\n0101010\n\nSample Output 3\n\n6", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2883, "cpu_time_ms": 196, "memory_kb": 9952}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s240450114", "group_id": "codeNet:p02854", "input_text": "n=io.read(\"*n\",\"*l\")\na={0}\nfor i=1,n do\n a[i]=io.read(\"*n\")\nend\n\nb={a[1]}\nfor i=2,n do\n b[i]=b[i-1]+a[i]\nend\nc={b[n]}\nfor i=2,n do\n c[i]=c[i-1]-a[i-1]\nend\n\nminyen=2020202020\nfor i=1,n-1 do\n minyen=math.min(minyen,math.abs(b[i]-c[i+1]))\nend\nprint(minyen)", "language": "Lua", "metadata": {"date": 1588388039, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p02854.html", "problem_id": "p02854", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02854/input.txt", "sample_output_relpath": "derived/input_output/data/p02854/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02854/Lua/s240450114.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s240450114", "user_id": "u045238009"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "n=io.read(\"*n\",\"*l\")\na={0}\nfor i=1,n do\n a[i]=io.read(\"*n\")\nend\n\nb={a[1]}\nfor i=2,n do\n b[i]=b[i-1]+a[i]\nend\nc={b[n]}\nfor i=2,n do\n c[i]=c[i-1]-a[i-1]\nend\n\nminyen=2020202020\nfor i=1,n-1 do\n minyen=math.min(minyen,math.abs(b[i]-c[i+1]))\nend\nprint(minyen)", "problem_context": "Score: 200 points\n\nProblem Statement\n\nTakahashi, who works at DISCO, is standing before an iron bar.\nThe bar has N-1 notches, which divide the bar into N sections. The i-th section from the left has a length of A_i millimeters.\n\nTakahashi wanted to choose a notch and cut the bar at that point into two parts with the same length.\nHowever, this may not be possible as is, so he will do the following operations some number of times before he does the cut:\n\nChoose one section and expand it, increasing its length by 1 millimeter. Doing this operation once costs 1 yen (the currency of Japan).\n\nChoose one section of length at least 2 millimeters and shrink it, decreasing its length by 1 millimeter. Doing this operation once costs 1 yen.\n\nFind the minimum amount of money needed before cutting the bar into two parts with the same length.\n\nConstraints\n\n2 \\leq N \\leq 200000\n\n1 \\leq A_i \\leq 2020202020\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 A_3 ... A_N\n\nOutput\n\nPrint an integer representing the minimum amount of money needed before cutting the bar into two parts with the same length.\n\nSample Input 1\n\n3\n2 4 3\n\nSample Output 1\n\n3\n\nThe initial lengths of the sections are [2, 4, 3] (in millimeters). Takahashi can cut the bar equally after doing the following operations for 3 yen:\n\nShrink the second section from the left. The lengths of the sections are now [2, 3, 3].\n\nShrink the first section from the left. The lengths of the sections are now [1, 3, 3].\n\nShrink the second section from the left. The lengths of the sections are now [1, 2, 3], and we can cut the bar at the second notch from the left into two parts of length 3 each.\n\nSample Input 2\n\n12\n100 104 102 105 103 103 101 105 104 102 104 101\n\nSample Output 2\n\n0", "sample_input": "3\n2 4 3\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02854", "source_text": "Score: 200 points\n\nProblem Statement\n\nTakahashi, who works at DISCO, is standing before an iron bar.\nThe bar has N-1 notches, which divide the bar into N sections. The i-th section from the left has a length of A_i millimeters.\n\nTakahashi wanted to choose a notch and cut the bar at that point into two parts with the same length.\nHowever, this may not be possible as is, so he will do the following operations some number of times before he does the cut:\n\nChoose one section and expand it, increasing its length by 1 millimeter. Doing this operation once costs 1 yen (the currency of Japan).\n\nChoose one section of length at least 2 millimeters and shrink it, decreasing its length by 1 millimeter. Doing this operation once costs 1 yen.\n\nFind the minimum amount of money needed before cutting the bar into two parts with the same length.\n\nConstraints\n\n2 \\leq N \\leq 200000\n\n1 \\leq A_i \\leq 2020202020\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 A_3 ... A_N\n\nOutput\n\nPrint an integer representing the minimum amount of money needed before cutting the bar into two parts with the same length.\n\nSample Input 1\n\n3\n2 4 3\n\nSample Output 1\n\n3\n\nThe initial lengths of the sections are [2, 4, 3] (in millimeters). Takahashi can cut the bar equally after doing the following operations for 3 yen:\n\nShrink the second section from the left. The lengths of the sections are now [2, 3, 3].\n\nShrink the first section from the left. The lengths of the sections are now [1, 3, 3].\n\nShrink the second section from the left. The lengths of the sections are now [1, 2, 3], and we can cut the bar at the second notch from the left into two parts of length 3 each.\n\nSample Input 2\n\n12\n100 104 102 105 103 103 101 105 104 102 104 101\n\nSample Output 2\n\n0", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 265, "cpu_time_ms": 177, "memory_kb": 12664}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s153313750", "group_id": "codeNet:p02854", "input_text": "local n = io.read(\"*n\")\nlocal sum = {}\nsum[1] = io.read(\"*n\")\nfor i = 2, n do\n local a = io.read(\"*n\")\n sum[i] = a + sum[i - 1]\nend\nlocal mab, mmi = math.abs, math.min\nlocal ret = mab(sum[n] - sum[1] - sum[1])\nfor i = 2, n - 1 do\n ret = mmi(ret, mab(sum[n] - sum[i] - sum[i]))\nend\nprint(ret)\n", "language": "Lua", "metadata": {"date": 1575297743, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p02854.html", "problem_id": "p02854", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02854/input.txt", "sample_output_relpath": "derived/input_output/data/p02854/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02854/Lua/s153313750.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s153313750", "user_id": "u120582723"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "local n = io.read(\"*n\")\nlocal sum = {}\nsum[1] = io.read(\"*n\")\nfor i = 2, n do\n local a = io.read(\"*n\")\n sum[i] = a + sum[i - 1]\nend\nlocal mab, mmi = math.abs, math.min\nlocal ret = mab(sum[n] - sum[1] - sum[1])\nfor i = 2, n - 1 do\n ret = mmi(ret, mab(sum[n] - sum[i] - sum[i]))\nend\nprint(ret)\n", "problem_context": "Score: 200 points\n\nProblem Statement\n\nTakahashi, who works at DISCO, is standing before an iron bar.\nThe bar has N-1 notches, which divide the bar into N sections. The i-th section from the left has a length of A_i millimeters.\n\nTakahashi wanted to choose a notch and cut the bar at that point into two parts with the same length.\nHowever, this may not be possible as is, so he will do the following operations some number of times before he does the cut:\n\nChoose one section and expand it, increasing its length by 1 millimeter. Doing this operation once costs 1 yen (the currency of Japan).\n\nChoose one section of length at least 2 millimeters and shrink it, decreasing its length by 1 millimeter. Doing this operation once costs 1 yen.\n\nFind the minimum amount of money needed before cutting the bar into two parts with the same length.\n\nConstraints\n\n2 \\leq N \\leq 200000\n\n1 \\leq A_i \\leq 2020202020\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 A_3 ... A_N\n\nOutput\n\nPrint an integer representing the minimum amount of money needed before cutting the bar into two parts with the same length.\n\nSample Input 1\n\n3\n2 4 3\n\nSample Output 1\n\n3\n\nThe initial lengths of the sections are [2, 4, 3] (in millimeters). Takahashi can cut the bar equally after doing the following operations for 3 yen:\n\nShrink the second section from the left. The lengths of the sections are now [2, 3, 3].\n\nShrink the first section from the left. The lengths of the sections are now [1, 3, 3].\n\nShrink the second section from the left. The lengths of the sections are now [1, 2, 3], and we can cut the bar at the second notch from the left into two parts of length 3 each.\n\nSample Input 2\n\n12\n100 104 102 105 103 103 101 105 104 102 104 101\n\nSample Output 2\n\n0", "sample_input": "3\n2 4 3\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02854", "source_text": "Score: 200 points\n\nProblem Statement\n\nTakahashi, who works at DISCO, is standing before an iron bar.\nThe bar has N-1 notches, which divide the bar into N sections. The i-th section from the left has a length of A_i millimeters.\n\nTakahashi wanted to choose a notch and cut the bar at that point into two parts with the same length.\nHowever, this may not be possible as is, so he will do the following operations some number of times before he does the cut:\n\nChoose one section and expand it, increasing its length by 1 millimeter. Doing this operation once costs 1 yen (the currency of Japan).\n\nChoose one section of length at least 2 millimeters and shrink it, decreasing its length by 1 millimeter. Doing this operation once costs 1 yen.\n\nFind the minimum amount of money needed before cutting the bar into two parts with the same length.\n\nConstraints\n\n2 \\leq N \\leq 200000\n\n1 \\leq A_i \\leq 2020202020\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 A_3 ... A_N\n\nOutput\n\nPrint an integer representing the minimum amount of money needed before cutting the bar into two parts with the same length.\n\nSample Input 1\n\n3\n2 4 3\n\nSample Output 1\n\n3\n\nThe initial lengths of the sections are [2, 4, 3] (in millimeters). Takahashi can cut the bar equally after doing the following operations for 3 yen:\n\nShrink the second section from the left. The lengths of the sections are now [2, 3, 3].\n\nShrink the first section from the left. The lengths of the sections are now [1, 3, 3].\n\nShrink the second section from the left. The lengths of the sections are now [1, 2, 3], and we can cut the bar at the second notch from the left into two parts of length 3 each.\n\nSample Input 2\n\n12\n100 104 102 105 103 103 101 105 104 102 104 101\n\nSample Output 2\n\n0", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 295, "cpu_time_ms": 99, "memory_kb": 4472}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s080600146", "group_id": "codeNet:p02855", "input_text": "local h,w,k=io.read(\"n\",\"n\",\"n\",\"l\")\nlocal cake={}\nlocal counter=1\nfor i=1,h do\n local s=io.read()\n local strawberry=0\n for _,_ in s:gmatch(\"#\") do\n strawberry=strawberry+1\n end\n cake[i]={}\n for j=1,w do\n if s:sub(j,j)~=\"#\" then\n cake[i][j]=counter\n else\n cake[i][j]=counter\n strawberry=strawberry-1\n if strawberry>0 then\n counter=counter+1\n end\n end\n end\n counter=counter+1\nend\n\nfor i=1,h do\n print(table.concat(cake[i],\" \"))\nend", "language": "Lua", "metadata": {"date": 1592224494, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p02855.html", "problem_id": "p02855", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02855/input.txt", "sample_output_relpath": "derived/input_output/data/p02855/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02855/Lua/s080600146.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s080600146", "user_id": "u045238009"}, "prompt_components": {"gold_output": "1 2 2\n1 3 4\n5 5 4\n", "input_to_evaluate": "local h,w,k=io.read(\"n\",\"n\",\"n\",\"l\")\nlocal cake={}\nlocal counter=1\nfor i=1,h do\n local s=io.read()\n local strawberry=0\n for _,_ in s:gmatch(\"#\") do\n strawberry=strawberry+1\n end\n cake[i]={}\n for j=1,w do\n if s:sub(j,j)~=\"#\" then\n cake[i][j]=counter\n else\n cake[i][j]=counter\n strawberry=strawberry-1\n if strawberry>0 then\n counter=counter+1\n end\n end\n end\n counter=counter+1\nend\n\nfor i=1,h do\n print(table.concat(cake[i],\" \"))\nend", "problem_context": "Score: 400 points\n\nProblem Statement\n\nChokudai made a rectangular cake for contestants in DDCC 2020 Finals.\n\nThe cake has H - 1 horizontal notches and W - 1 vertical notches, which divide the cake into H \\times W equal sections. K of these sections has a strawberry on top of each of them.\n\nThe positions of the strawberries are given to you as H \\times W characters s_{i, j} (1 \\leq i \\leq H, 1 \\leq j \\leq W). If s_{i, j} is #, the section at the i-th row from the top and the j-th column from the left contains a strawberry; if s_{i, j} is ., the section does not contain one. There are exactly K occurrences of #s.\n\nTakahashi wants to cut this cake into K pieces and serve them to the contestants. Each of these pieces must satisfy the following conditions:\n\nHas a rectangular shape.\n\nContains exactly one strawberry.\n\nOne possible way to cut the cake is shown below:\n\nFind one way to cut the cake and satisfy the condition. We can show that this is always possible, regardless of the number and positions of the strawberries.\n\nConstraints\n\n1 \\leq H \\leq 300\n\n1 \\leq W \\leq 300\n\n1 \\leq K \\leq H \\times W\n\ns_{i, j} is # or ..\n\nThere are exactly K occurrences of # in s.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W K\ns_{1, 1} s_{1, 2} \\cdots s_{1, W}\ns_{2, 1} s_{2, 2} \\cdots s_{2, W}\n:\ns_{H, 1} s_{H, 2} \\cdots s_{H, W}\n\nOutput\n\nAssign the numbers 1, 2, 3, \\dots, K to the K pieces obtained after the cut, in any order. Then, let a_{i, j} be the number representing the piece containing the section at the i-th row from the top and the j-th column from the left of the cake. Output should be in the following format:\n\na_{1, 1} \\ a_{1, 2} \\ \\cdots \\ a_{1, W}\na_{2, 1} \\ a_{2, 2} \\ \\cdots \\ a_{2, W}\n:\na_{H, 1} \\ a_{H, 2} \\ \\cdots \\ a_{H, W}\n\nIf multiple solutions exist, any of them will be accepted.\n\nSample Input 1\n\n3 3 5\n#.#\n.#.\n#.#\n\nSample Output 1\n\n1 2 2\n1 3 4\n5 5 4\n\nOne way to cut this cake is shown below:\n\nSample Input 2\n\n3 7 7\n#...#.#\n..#...#\n.#..#..\n\nSample Output 2\n\n1 1 2 2 3 4 4\n6 6 2 2 3 5 5\n6 6 7 7 7 7 7\n\nOne way to cut this cake is shown below:\n\nSample Input 3\n\n13 21 106\n.....................\n.####.####.####.####.\n..#.#..#.#.#....#....\n..#.#..#.#.#....#....\n..#.#..#.#.#....#....\n.####.####.####.####.\n.....................\n.####.####.####.####.\n....#.#..#....#.#..#.\n.####.#..#.####.#..#.\n.#....#..#.#....#..#.\n.####.####.####.####.\n.....................\n\nSample Output 3\n\n12 12 23 34 45 45 60 71 82 93 93 2 13 24 35 35 17 28 39 50 50\n12 12 23 34 45 45 60 71 82 93 93 2 13 24 35 35 17 28 39 50 50\n12 12 56 89 89 89 60 104 82 31 31 46 13 24 35 35 61 61 39 50 50\n12 12 67 67 100 100 60 9 9 42 42 57 13 24 6 72 72 72 72 72 72\n12 12 78 5 5 5 20 20 20 53 68 68 90 24 6 83 83 83 83 83 83\n16 16 27 38 49 49 64 75 86 97 79 79 90 101 6 94 94 105 10 21 21\n16 16 27 38 49 49 64 75 86 97 79 79 90 101 6 94 94 105 10 21 21\n32 32 43 54 65 65 80 11 106 95 22 22 33 44 55 55 70 1 96 85 85\n32 32 43 54 76 76 91 11 106 84 84 4 99 66 66 66 81 1 96 74 74\n14 14 3 98 87 87 102 11 73 73 73 4 99 88 77 77 92 92 63 63 63\n25 25 3 98 87 87 7 29 62 62 62 15 99 88 77 77 103 19 30 52 52\n36 36 47 58 69 69 18 29 40 51 51 26 37 48 59 59 8 19 30 41 41\n36 36 47 58 69 69 18 29 40 51 51 26 37 48 59 59 8 19 30 41 41", "sample_input": "3 3 5\n#.#\n.#.\n#.#\n"}, "reference_outputs": ["1 2 2\n1 3 4\n5 5 4\n"], "source_document_id": "p02855", "source_text": "Score: 400 points\n\nProblem Statement\n\nChokudai made a rectangular cake for contestants in DDCC 2020 Finals.\n\nThe cake has H - 1 horizontal notches and W - 1 vertical notches, which divide the cake into H \\times W equal sections. K of these sections has a strawberry on top of each of them.\n\nThe positions of the strawberries are given to you as H \\times W characters s_{i, j} (1 \\leq i \\leq H, 1 \\leq j \\leq W). If s_{i, j} is #, the section at the i-th row from the top and the j-th column from the left contains a strawberry; if s_{i, j} is ., the section does not contain one. There are exactly K occurrences of #s.\n\nTakahashi wants to cut this cake into K pieces and serve them to the contestants. Each of these pieces must satisfy the following conditions:\n\nHas a rectangular shape.\n\nContains exactly one strawberry.\n\nOne possible way to cut the cake is shown below:\n\nFind one way to cut the cake and satisfy the condition. We can show that this is always possible, regardless of the number and positions of the strawberries.\n\nConstraints\n\n1 \\leq H \\leq 300\n\n1 \\leq W \\leq 300\n\n1 \\leq K \\leq H \\times W\n\ns_{i, j} is # or ..\n\nThere are exactly K occurrences of # in s.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W K\ns_{1, 1} s_{1, 2} \\cdots s_{1, W}\ns_{2, 1} s_{2, 2} \\cdots s_{2, W}\n:\ns_{H, 1} s_{H, 2} \\cdots s_{H, W}\n\nOutput\n\nAssign the numbers 1, 2, 3, \\dots, K to the K pieces obtained after the cut, in any order. Then, let a_{i, j} be the number representing the piece containing the section at the i-th row from the top and the j-th column from the left of the cake. Output should be in the following format:\n\na_{1, 1} \\ a_{1, 2} \\ \\cdots \\ a_{1, W}\na_{2, 1} \\ a_{2, 2} \\ \\cdots \\ a_{2, W}\n:\na_{H, 1} \\ a_{H, 2} \\ \\cdots \\ a_{H, W}\n\nIf multiple solutions exist, any of them will be accepted.\n\nSample Input 1\n\n3 3 5\n#.#\n.#.\n#.#\n\nSample Output 1\n\n1 2 2\n1 3 4\n5 5 4\n\nOne way to cut this cake is shown below:\n\nSample Input 2\n\n3 7 7\n#...#.#\n..#...#\n.#..#..\n\nSample Output 2\n\n1 1 2 2 3 4 4\n6 6 2 2 3 5 5\n6 6 7 7 7 7 7\n\nOne way to cut this cake is shown below:\n\nSample Input 3\n\n13 21 106\n.....................\n.####.####.####.####.\n..#.#..#.#.#....#....\n..#.#..#.#.#....#....\n..#.#..#.#.#....#....\n.####.####.####.####.\n.....................\n.####.####.####.####.\n....#.#..#....#.#..#.\n.####.#..#.####.#..#.\n.#....#..#.#....#..#.\n.####.####.####.####.\n.....................\n\nSample Output 3\n\n12 12 23 34 45 45 60 71 82 93 93 2 13 24 35 35 17 28 39 50 50\n12 12 23 34 45 45 60 71 82 93 93 2 13 24 35 35 17 28 39 50 50\n12 12 56 89 89 89 60 104 82 31 31 46 13 24 35 35 61 61 39 50 50\n12 12 67 67 100 100 60 9 9 42 42 57 13 24 6 72 72 72 72 72 72\n12 12 78 5 5 5 20 20 20 53 68 68 90 24 6 83 83 83 83 83 83\n16 16 27 38 49 49 64 75 86 97 79 79 90 101 6 94 94 105 10 21 21\n16 16 27 38 49 49 64 75 86 97 79 79 90 101 6 94 94 105 10 21 21\n32 32 43 54 65 65 80 11 106 95 22 22 33 44 55 55 70 1 96 85 85\n32 32 43 54 76 76 91 11 106 84 84 4 99 66 66 66 81 1 96 74 74\n14 14 3 98 87 87 102 11 73 73 73 4 99 88 77 77 92 92 63 63 63\n25 25 3 98 87 87 7 29 62 62 62 15 99 88 77 77 103 19 30 52 52\n36 36 47 58 69 69 18 29 40 51 51 26 37 48 59 59 8 19 30 41 41\n36 36 47 58 69 69 18 29 40 51 51 26 37 48 59 59 8 19 30 41 41", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 555, "cpu_time_ms": 52, "memory_kb": 6904}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s118728864", "group_id": "codeNet:p02856", "input_text": "local m = io.read(\"*n\")\nlocal digsum = 0\nlocal quot = 0\nlocal rem = 0\nfor i = 1, m do\n local d, c = io.read(\"*n\", \"*n\")\n digsum = digsum + c\n rem = rem + d * c\n if 9 < rem then\n if rem % 9 == 0 then\n quot = rem // 9 + quot - 1\n rem = 9\n else\n quot = rem // 9 + quot\n rem = rem % 9\n end\n end\nend\nprint(digsum - 1 + quot)\n", "language": "Lua", "metadata": {"date": 1574917543, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p02856.html", "problem_id": "p02856", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02856/input.txt", "sample_output_relpath": "derived/input_output/data/p02856/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02856/Lua/s118728864.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s118728864", "user_id": "u120582723"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "local m = io.read(\"*n\")\nlocal digsum = 0\nlocal quot = 0\nlocal rem = 0\nfor i = 1, m do\n local d, c = io.read(\"*n\", \"*n\")\n digsum = digsum + c\n rem = rem + d * c\n if 9 < rem then\n if rem % 9 == 0 then\n quot = rem // 9 + quot - 1\n rem = 9\n else\n quot = rem // 9 + quot\n rem = rem % 9\n end\n end\nend\nprint(digsum - 1 + quot)\n", "problem_context": "Score: 500 points\n\nProblem Statement\n\nN programmers are going to participate in the preliminary stage of DDCC 20XX. Due to the size of the venue, however, at most 9 contestants can participate in the finals.\n\nThe preliminary stage consists of several rounds, which will take place as follows:\n\nAll the N contestants will participate in the first round.\n\nWhen X contestants participate in some round, the number of contestants advancing to the next round will be decided as follows:\n\nThe organizer will choose two consecutive digits in the decimal notation of X, and replace them with the sum of these digits. The number resulted will be the number of contestants advancing to the next round.\n\nFor example, when X = 2378, the number of contestants advancing to the next round will be 578 (if 2 and 3 are chosen), 2108 (if 3 and 7 are chosen), or 2315 (if 7 and 8 are chosen).\n\nWhen X = 100, the number of contestants advancing to the next round will be 10, no matter which two digits are chosen.\n\nThe preliminary stage ends when 9 or fewer contestants remain.\n\nRingo, the chief organizer, wants to hold as many rounds as possible.\nFind the maximum possible number of rounds in the preliminary stage.\n\nSince the number of contestants, N, can be enormous, it is given to you as two integer sequences d_1, \\ldots, d_M and c_1, \\ldots, c_M, which means the following: the decimal notation of N consists of c_1 + c_2 + \\ldots + c_M digits, whose first c_1 digits are all d_1, the following c_2 digits are all d_2, \\ldots, and the last c_M digits are all d_M.\n\nConstraints\n\n1 \\leq M \\leq 200000\n\n0 \\leq d_i \\leq 9\n\nd_1 \\neq 0\n\nd_i \\neq d_{i+1}\n\nc_i \\geq 1\n\n2 \\leq c_1 + \\ldots + c_M \\leq 10^{15}\n\nInput\n\nInput is given from Standard Input in the following format:\n\nM\nd_1 c_1\nd_2 c_2\n:\nd_M c_M\n\nOutput\n\nPrint the maximum possible number of rounds in the preliminary stage.\n\nSample Input 1\n\n2\n2 2\n9 1\n\nSample Output 1\n\n3\n\nIn this case, N = 229 contestants will participate in the first round. One possible progression of the preliminary stage is as follows:\n\n229 contestants participate in Round 1, 49 contestants participate in Round 2, 13 contestants participate in Round 3, and 4 contestants advance to the finals.\n\nHere, three rounds take place in the preliminary stage, which is the maximum possible number.\n\nSample Input 2\n\n3\n1 1\n0 8\n7 1\n\nSample Output 2\n\n9\n\nIn this case, 1000000007 will participate in the first round.", "sample_input": "2\n2 2\n9 1\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02856", "source_text": "Score: 500 points\n\nProblem Statement\n\nN programmers are going to participate in the preliminary stage of DDCC 20XX. Due to the size of the venue, however, at most 9 contestants can participate in the finals.\n\nThe preliminary stage consists of several rounds, which will take place as follows:\n\nAll the N contestants will participate in the first round.\n\nWhen X contestants participate in some round, the number of contestants advancing to the next round will be decided as follows:\n\nThe organizer will choose two consecutive digits in the decimal notation of X, and replace them with the sum of these digits. The number resulted will be the number of contestants advancing to the next round.\n\nFor example, when X = 2378, the number of contestants advancing to the next round will be 578 (if 2 and 3 are chosen), 2108 (if 3 and 7 are chosen), or 2315 (if 7 and 8 are chosen).\n\nWhen X = 100, the number of contestants advancing to the next round will be 10, no matter which two digits are chosen.\n\nThe preliminary stage ends when 9 or fewer contestants remain.\n\nRingo, the chief organizer, wants to hold as many rounds as possible.\nFind the maximum possible number of rounds in the preliminary stage.\n\nSince the number of contestants, N, can be enormous, it is given to you as two integer sequences d_1, \\ldots, d_M and c_1, \\ldots, c_M, which means the following: the decimal notation of N consists of c_1 + c_2 + \\ldots + c_M digits, whose first c_1 digits are all d_1, the following c_2 digits are all d_2, \\ldots, and the last c_M digits are all d_M.\n\nConstraints\n\n1 \\leq M \\leq 200000\n\n0 \\leq d_i \\leq 9\n\nd_1 \\neq 0\n\nd_i \\neq d_{i+1}\n\nc_i \\geq 1\n\n2 \\leq c_1 + \\ldots + c_M \\leq 10^{15}\n\nInput\n\nInput is given from Standard Input in the following format:\n\nM\nd_1 c_1\nd_2 c_2\n:\nd_M c_M\n\nOutput\n\nPrint the maximum possible number of rounds in the preliminary stage.\n\nSample Input 1\n\n2\n2 2\n9 1\n\nSample Output 1\n\n3\n\nIn this case, N = 229 contestants will participate in the first round. One possible progression of the preliminary stage is as follows:\n\n229 contestants participate in Round 1, 49 contestants participate in Round 2, 13 contestants participate in Round 3, and 4 contestants advance to the finals.\n\nHere, three rounds take place in the preliminary stage, which is the maximum possible number.\n\nSample Input 2\n\n3\n1 1\n0 8\n7 1\n\nSample Output 2\n\n9\n\nIn this case, 1000000007 will participate in the first round.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 354, "cpu_time_ms": 97, "memory_kb": 888}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s395656601", "group_id": "codeNet:p02859", "input_text": "print(math.pi*r^2/math.pi)", "language": "Lua", "metadata": {"date": 1588568996, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p02859.html", "problem_id": "p02859", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02859/input.txt", "sample_output_relpath": "derived/input_output/data/p02859/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02859/Lua/s395656601.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s395656601", "user_id": "u540534068"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "print(math.pi*r^2/math.pi)", "problem_context": "Score : 100 points\n\nProblem Statement\n\nGiven is an integer r.\n\nHow many times is the area of a circle of radius r larger than the area of a circle of radius 1?\n\nIt can be proved that the answer is always an integer under the constraints given.\n\nConstraints\n\n1 \\leq r \\leq 100\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nr\n\nOutput\n\nPrint the area of a circle of radius r, divided by the area of a circle of radius 1, as an integer.\n\nSample Input 1\n\n2\n\nSample Output 1\n\n4\n\nThe area of a circle of radius 2 is 4 times larger than the area of a circle of radius 1.\n\nNote that output must be an integer - for example, 4.0 will not be accepted.\n\nSample Input 2\n\n100\n\nSample Output 2\n\n10000", "sample_input": "2\n"}, "reference_outputs": ["4\n"], "source_document_id": "p02859", "source_text": "Score : 100 points\n\nProblem Statement\n\nGiven is an integer r.\n\nHow many times is the area of a circle of radius r larger than the area of a circle of radius 1?\n\nIt can be proved that the answer is always an integer under the constraints given.\n\nConstraints\n\n1 \\leq r \\leq 100\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nr\n\nOutput\n\nPrint the area of a circle of radius r, divided by the area of a circle of radius 1, as an integer.\n\nSample Input 1\n\n2\n\nSample Output 1\n\n4\n\nThe area of a circle of radius 2 is 4 times larger than the area of a circle of radius 1.\n\nNote that output must be an integer - for example, 4.0 will not be accepted.\n\nSample Input 2\n\n100\n\nSample Output 2\n\n10000", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 26, "cpu_time_ms": 7, "memory_kb": 760}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s720098881", "group_id": "codeNet:p02859", "input_text": "x = io.read\"*n\"\nprint(x*x)", "language": "Lua", "metadata": {"date": 1587783261, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p02859.html", "problem_id": "p02859", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02859/input.txt", "sample_output_relpath": "derived/input_output/data/p02859/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02859/Lua/s720098881.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s720098881", "user_id": "u373047809"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "x = io.read\"*n\"\nprint(x*x)", "problem_context": "Score : 100 points\n\nProblem Statement\n\nGiven is an integer r.\n\nHow many times is the area of a circle of radius r larger than the area of a circle of radius 1?\n\nIt can be proved that the answer is always an integer under the constraints given.\n\nConstraints\n\n1 \\leq r \\leq 100\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nr\n\nOutput\n\nPrint the area of a circle of radius r, divided by the area of a circle of radius 1, as an integer.\n\nSample Input 1\n\n2\n\nSample Output 1\n\n4\n\nThe area of a circle of radius 2 is 4 times larger than the area of a circle of radius 1.\n\nNote that output must be an integer - for example, 4.0 will not be accepted.\n\nSample Input 2\n\n100\n\nSample Output 2\n\n10000", "sample_input": "2\n"}, "reference_outputs": ["4\n"], "source_document_id": "p02859", "source_text": "Score : 100 points\n\nProblem Statement\n\nGiven is an integer r.\n\nHow many times is the area of a circle of radius r larger than the area of a circle of radius 1?\n\nIt can be proved that the answer is always an integer under the constraints given.\n\nConstraints\n\n1 \\leq r \\leq 100\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nr\n\nOutput\n\nPrint the area of a circle of radius r, divided by the area of a circle of radius 1, as an integer.\n\nSample Input 1\n\n2\n\nSample Output 1\n\n4\n\nThe area of a circle of radius 2 is 4 times larger than the area of a circle of radius 1.\n\nNote that output must be an integer - for example, 4.0 will not be accepted.\n\nSample Input 2\n\n100\n\nSample Output 2\n\n10000", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 26, "cpu_time_ms": 2, "memory_kb": 256}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s811234650", "group_id": "codeNet:p02859", "input_text": "n = io.read()\nio.write(n * n)", "language": "Lua", "metadata": {"date": 1580867630, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p02859.html", "problem_id": "p02859", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02859/input.txt", "sample_output_relpath": "derived/input_output/data/p02859/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02859/Lua/s811234650.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s811234650", "user_id": "u126737379"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "n = io.read()\nio.write(n * n)", "problem_context": "Score : 100 points\n\nProblem Statement\n\nGiven is an integer r.\n\nHow many times is the area of a circle of radius r larger than the area of a circle of radius 1?\n\nIt can be proved that the answer is always an integer under the constraints given.\n\nConstraints\n\n1 \\leq r \\leq 100\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nr\n\nOutput\n\nPrint the area of a circle of radius r, divided by the area of a circle of radius 1, as an integer.\n\nSample Input 1\n\n2\n\nSample Output 1\n\n4\n\nThe area of a circle of radius 2 is 4 times larger than the area of a circle of radius 1.\n\nNote that output must be an integer - for example, 4.0 will not be accepted.\n\nSample Input 2\n\n100\n\nSample Output 2\n\n10000", "sample_input": "2\n"}, "reference_outputs": ["4\n"], "source_document_id": "p02859", "source_text": "Score : 100 points\n\nProblem Statement\n\nGiven is an integer r.\n\nHow many times is the area of a circle of radius r larger than the area of a circle of radius 1?\n\nIt can be proved that the answer is always an integer under the constraints given.\n\nConstraints\n\n1 \\leq r \\leq 100\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nr\n\nOutput\n\nPrint the area of a circle of radius r, divided by the area of a circle of radius 1, as an integer.\n\nSample Input 1\n\n2\n\nSample Output 1\n\n4\n\nThe area of a circle of radius 2 is 4 times larger than the area of a circle of radius 1.\n\nNote that output must be an integer - for example, 4.0 will not be accepted.\n\nSample Input 2\n\n100\n\nSample Output 2\n\n10000", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 29, "cpu_time_ms": 7, "memory_kb": 888}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s828154541", "group_id": "codeNet:p02859", "input_text": "print(math.floor(tonumber(io.read())^2))", "language": "Lua", "metadata": {"date": 1579278809, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p02859.html", "problem_id": "p02859", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02859/input.txt", "sample_output_relpath": "derived/input_output/data/p02859/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02859/Lua/s828154541.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s828154541", "user_id": "u720483676"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "print(math.floor(tonumber(io.read())^2))", "problem_context": "Score : 100 points\n\nProblem Statement\n\nGiven is an integer r.\n\nHow many times is the area of a circle of radius r larger than the area of a circle of radius 1?\n\nIt can be proved that the answer is always an integer under the constraints given.\n\nConstraints\n\n1 \\leq r \\leq 100\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nr\n\nOutput\n\nPrint the area of a circle of radius r, divided by the area of a circle of radius 1, as an integer.\n\nSample Input 1\n\n2\n\nSample Output 1\n\n4\n\nThe area of a circle of radius 2 is 4 times larger than the area of a circle of radius 1.\n\nNote that output must be an integer - for example, 4.0 will not be accepted.\n\nSample Input 2\n\n100\n\nSample Output 2\n\n10000", "sample_input": "2\n"}, "reference_outputs": ["4\n"], "source_document_id": "p02859", "source_text": "Score : 100 points\n\nProblem Statement\n\nGiven is an integer r.\n\nHow many times is the area of a circle of radius r larger than the area of a circle of radius 1?\n\nIt can be proved that the answer is always an integer under the constraints given.\n\nConstraints\n\n1 \\leq r \\leq 100\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nr\n\nOutput\n\nPrint the area of a circle of radius r, divided by the area of a circle of radius 1, as an integer.\n\nSample Input 1\n\n2\n\nSample Output 1\n\n4\n\nThe area of a circle of radius 2 is 4 times larger than the area of a circle of radius 1.\n\nNote that output must be an integer - for example, 4.0 will not be accepted.\n\nSample Input 2\n\n100\n\nSample Output 2\n\n10000", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 40, "cpu_time_ms": 2, "memory_kb": 376}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s124258233", "group_id": "codeNet:p02860", "input_text": "N=io.read\"*n\"\nio.read()\nS=io.read()\nprint((\n\tS:sub(1,N/2)==S:sub(-N/2,-1)\n)and\"Yes\"or\"No\")", "language": "Lua", "metadata": {"date": 1587768445, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p02860.html", "problem_id": "p02860", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02860/input.txt", "sample_output_relpath": "derived/input_output/data/p02860/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02860/Lua/s124258233.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s124258233", "user_id": "u726173718"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "N=io.read\"*n\"\nio.read()\nS=io.read()\nprint((\n\tS:sub(1,N/2)==S:sub(-N/2,-1)\n)and\"Yes\"or\"No\")", "problem_context": "Score : 200 points\n\nProblem Statement\n\nGiven are a positive integer N and a string S of length N consisting of lowercase English letters.\n\nDetermine whether the string is a concatenation of two copies of some string.\nThat is, determine whether there is a string T such that S = T + T.\n\nConstraints\n\n1 \\leq N \\leq 100\n\nS consists of lowercase English letters.\n\n|S| = N\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS\n\nOutput\n\nIf S is a concatenation of two copies of some string, print Yes; otherwise, print No.\n\nSample Input 1\n\n6\nabcabc\n\nSample Output 1\n\nYes\n\nLet T = abc, and S = T + T.\n\nSample Input 2\n\n6\nabcadc\n\nSample Output 2\n\nNo\n\nSample Input 3\n\n1\nz\n\nSample Output 3\n\nNo", "sample_input": "6\nabcabc\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p02860", "source_text": "Score : 200 points\n\nProblem Statement\n\nGiven are a positive integer N and a string S of length N consisting of lowercase English letters.\n\nDetermine whether the string is a concatenation of two copies of some string.\nThat is, determine whether there is a string T such that S = T + T.\n\nConstraints\n\n1 \\leq N \\leq 100\n\nS consists of lowercase English letters.\n\n|S| = N\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS\n\nOutput\n\nIf S is a concatenation of two copies of some string, print Yes; otherwise, print No.\n\nSample Input 1\n\n6\nabcabc\n\nSample Output 1\n\nYes\n\nLet T = abc, and S = T + T.\n\nSample Input 2\n\n6\nabcadc\n\nSample Output 2\n\nNo\n\nSample Input 3\n\n1\nz\n\nSample Output 3\n\nNo", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 90, "cpu_time_ms": 2, "memory_kb": 256}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s011116725", "group_id": "codeNet:p02861", "input_text": "local read = setmetatable({}, {__index = function(t, k) local a = {} for i=1,#k do table.insert(a, '*'..string.sub(k, i, i)) end local r = io.read local u = table.unpack or unpack return function() return r(u(a)) end end})\nread.N = function(N) local t={} for i=1,N do t[i]=read.n() end return t end\nstring.totable = function(s) local t={} local u=string.sub for i=1,#s do t[i] = u(s, i, i) end return t end\nstring.split = function(s) local t={} for w in string.gmatch(s, \"[^%s]+\") do table.insert(t, w) end return (table.unpack or unpack)(t) end\n----\n\nlocal function factorial(n)\n local a = 1\n for i=1, n do\n a = a * i\n end\n return a\nend\n\nlocal function perm(seq)\n local up = table.unpack or unpack\n local t = {up(seq)}\n return coroutine.wrap(function()\n local function rec(i)\n if i > #t then\n --coroutine.yield({up(t)})\n coroutine.yield(t)\n return\n end\n rec(i+1)\n for j=i+1,#t do\n t[i], t[j] = t[j], t[i]\n rec(i+1)\n t[i], t[j] = t[j], t[i]\n end\n end\n rec(1)\n end)\nend\n\n-- C\nlocal N = read.n()\nlocal X, Y = {}, {}\nfor i=1,N do\n X[i], Y[i] = read.nn()\nend\n\nlocal route_num = factorial(N)\n\nlocal sum = 0\nlocal set = {}\nfor i=1,N do set[i] = i end\nfor route in perm(set) do\n for n=1,N-1 do\n local i, j = route[n], route[n+1]\n local d = math.sqrt((X[i]-X[j])^2 + (Y[i]-Y[j])^2)\n sum = sum + d\n end\nend\n\nprint(sum / route_num)\n", "language": "Lua", "metadata": {"date": 1574014689, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p02861.html", "problem_id": "p02861", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02861/input.txt", "sample_output_relpath": "derived/input_output/data/p02861/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02861/Lua/s011116725.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s011116725", "user_id": "u162773977"}, "prompt_components": {"gold_output": "2.2761423749\n", "input_to_evaluate": "local read = setmetatable({}, {__index = function(t, k) local a = {} for i=1,#k do table.insert(a, '*'..string.sub(k, i, i)) end local r = io.read local u = table.unpack or unpack return function() return r(u(a)) end end})\nread.N = function(N) local t={} for i=1,N do t[i]=read.n() end return t end\nstring.totable = function(s) local t={} local u=string.sub for i=1,#s do t[i] = u(s, i, i) end return t end\nstring.split = function(s) local t={} for w in string.gmatch(s, \"[^%s]+\") do table.insert(t, w) end return (table.unpack or unpack)(t) end\n----\n\nlocal function factorial(n)\n local a = 1\n for i=1, n do\n a = a * i\n end\n return a\nend\n\nlocal function perm(seq)\n local up = table.unpack or unpack\n local t = {up(seq)}\n return coroutine.wrap(function()\n local function rec(i)\n if i > #t then\n --coroutine.yield({up(t)})\n coroutine.yield(t)\n return\n end\n rec(i+1)\n for j=i+1,#t do\n t[i], t[j] = t[j], t[i]\n rec(i+1)\n t[i], t[j] = t[j], t[i]\n end\n end\n rec(1)\n end)\nend\n\n-- C\nlocal N = read.n()\nlocal X, Y = {}, {}\nfor i=1,N do\n X[i], Y[i] = read.nn()\nend\n\nlocal route_num = factorial(N)\n\nlocal sum = 0\nlocal set = {}\nfor i=1,N do set[i] = i end\nfor route in perm(set) do\n for n=1,N-1 do\n local i, j = route[n], route[n+1]\n local d = math.sqrt((X[i]-X[j])^2 + (Y[i]-Y[j])^2)\n sum = sum + d\n end\nend\n\nprint(sum / route_num)\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere are N towns in a coordinate plane. Town i is located at coordinates (x_i, y_i). The distance between Town i and Town j is \\sqrt{\\left(x_i-x_j\\right)^2+\\left(y_i-y_j\\right)^2}.\n\nThere are N! possible paths to visit all of these towns once. Let the length of a path be the distance covered when we start at the first town in the path, visit the second, third, \\dots, towns, and arrive at the last town (assume that we travel in a straight line from a town to another). Compute the average length of these N! paths.\n\nConstraints\n\n2 \\leq N \\leq 8\n\n-1000 \\leq x_i \\leq 1000\n\n-1000 \\leq y_i \\leq 1000\n\n\\left(x_i, y_i\\right) \\neq \\left(x_j, y_j\\right) (if i \\neq j)\n\n(Added 21:12 JST) All values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nx_1 y_1\n:\nx_N y_N\n\nOutput\n\nPrint the average length of the paths.\nYour output will be judges as correct when the absolute difference from the judge's output is at most 10^{-6}.\n\nSample Input 1\n\n3\n0 0\n1 0\n0 1\n\nSample Output 1\n\n2.2761423749\n\nThere are six paths to visit the towns: 1 → 2 → 3, 1 → 3 → 2, 2 → 1 → 3, 2 → 3 → 1, 3 → 1 → 2, and 3 → 2 → 1.\n\nThe length of the path 1 → 2 → 3 is \\sqrt{\\left(0-1\\right)^2+\\left(0-0\\right)^2} + \\sqrt{\\left(1-0\\right)^2+\\left(0-1\\right)^2} = 1+\\sqrt{2}.\n\nBy calculating the lengths of the other paths in this way, we see that the average length of all routes is:\n\n\\frac{\\left(1+\\sqrt{2}\\right)+\\left(1+\\sqrt{2}\\right)+\\left(2\\right)+\\left(1+\\sqrt{2}\\right)+\\left(2\\right)+\\left(1+\\sqrt{2}\\right)}{6} = 2.276142...\n\nSample Input 2\n\n2\n-879 981\n-866 890\n\nSample Output 2\n\n91.9238815543\n\nThere are two paths to visit the towns: 1 → 2 and 2 → 1. These paths have the same length.\n\nSample Input 3\n\n8\n-406 10\n512 859\n494 362\n-955 -475\n128 553\n-986 -885\n763 77\n449 310\n\nSample Output 3\n\n7641.9817824387", "sample_input": "3\n0 0\n1 0\n0 1\n"}, "reference_outputs": ["2.2761423749\n"], "source_document_id": "p02861", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere are N towns in a coordinate plane. Town i is located at coordinates (x_i, y_i). The distance between Town i and Town j is \\sqrt{\\left(x_i-x_j\\right)^2+\\left(y_i-y_j\\right)^2}.\n\nThere are N! possible paths to visit all of these towns once. Let the length of a path be the distance covered when we start at the first town in the path, visit the second, third, \\dots, towns, and arrive at the last town (assume that we travel in a straight line from a town to another). Compute the average length of these N! paths.\n\nConstraints\n\n2 \\leq N \\leq 8\n\n-1000 \\leq x_i \\leq 1000\n\n-1000 \\leq y_i \\leq 1000\n\n\\left(x_i, y_i\\right) \\neq \\left(x_j, y_j\\right) (if i \\neq j)\n\n(Added 21:12 JST) All values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nx_1 y_1\n:\nx_N y_N\n\nOutput\n\nPrint the average length of the paths.\nYour output will be judges as correct when the absolute difference from the judge's output is at most 10^{-6}.\n\nSample Input 1\n\n3\n0 0\n1 0\n0 1\n\nSample Output 1\n\n2.2761423749\n\nThere are six paths to visit the towns: 1 → 2 → 3, 1 → 3 → 2, 2 → 1 → 3, 2 → 3 → 1, 3 → 1 → 2, and 3 → 2 → 1.\n\nThe length of the path 1 → 2 → 3 is \\sqrt{\\left(0-1\\right)^2+\\left(0-0\\right)^2} + \\sqrt{\\left(1-0\\right)^2+\\left(0-1\\right)^2} = 1+\\sqrt{2}.\n\nBy calculating the lengths of the other paths in this way, we see that the average length of all routes is:\n\n\\frac{\\left(1+\\sqrt{2}\\right)+\\left(1+\\sqrt{2}\\right)+\\left(2\\right)+\\left(1+\\sqrt{2}\\right)+\\left(2\\right)+\\left(1+\\sqrt{2}\\right)}{6} = 2.276142...\n\nSample Input 2\n\n2\n-879 981\n-866 890\n\nSample Output 2\n\n91.9238815543\n\nThere are two paths to visit the towns: 1 → 2 and 2 → 1. These paths have the same length.\n\nSample Input 3\n\n8\n-406 10\n512 859\n494 362\n-955 -475\n128 553\n-986 -885\n763 77\n449 310\n\nSample Output 3\n\n7641.9817824387", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1549, "cpu_time_ms": 114, "memory_kb": 256}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s466141425", "group_id": "codeNet:p02862", "input_text": "local mod = 1000000007\n\nlocal function bmul(x, y)\n return (x * y) % mod\nend\n\nlocal function badd(x, y)\n return (x + y) % mod\nend\n\nlocal function bsub(x, y)\n return x < y and x - y + mod or x - y\nend\n\nlocal function modpow(src, pow)\n local res = 1\n while 0 < pow do\n if pow % 2 == 1 then\n res = bmul(res, src)\n pow = pow - 1\n end\n src = bmul(src, src)\n pow = pow // 2\n end\n return res\nend\n\nlocal function modinv(src)\n return modpow(src, mod - 2)\nend\n\nlocal function getComb(n, k)\n local ret = 1\n local inv = 1\n for i = 1, k do\n ret = bmul(ret, n + 1 - i)\n inv = bmul(inv, i)\n end\n return bmul(ret, modinv(inv))\nend\n\nlocal x, y = io.read(\"*n\", \"*n\")\nif (x + y) % 3 ~= 0 then\n print(0) os.exit()\nend\nlocal z = (x + y) // 3\nx, y = x - z, y - z\nif x < 0 or y < 0 then\n print(0) os.exit()\nend\nprint(getComb(x + y, x))", "language": "Lua", "metadata": {"date": 1601247388, "filename_ext": "lua", "original_language": "Lua (Lua 5.3.5)", "problem_description_relpath": "problem_descriptions/p02862.html", "problem_id": "p02862", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02862/input.txt", "sample_output_relpath": "derived/input_output/data/p02862/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02862/Lua/s466141425.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s466141425", "user_id": "u120582723"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "local mod = 1000000007\n\nlocal function bmul(x, y)\n return (x * y) % mod\nend\n\nlocal function badd(x, y)\n return (x + y) % mod\nend\n\nlocal function bsub(x, y)\n return x < y and x - y + mod or x - y\nend\n\nlocal function modpow(src, pow)\n local res = 1\n while 0 < pow do\n if pow % 2 == 1 then\n res = bmul(res, src)\n pow = pow - 1\n end\n src = bmul(src, src)\n pow = pow // 2\n end\n return res\nend\n\nlocal function modinv(src)\n return modpow(src, mod - 2)\nend\n\nlocal function getComb(n, k)\n local ret = 1\n local inv = 1\n for i = 1, k do\n ret = bmul(ret, n + 1 - i)\n inv = bmul(inv, i)\n end\n return bmul(ret, modinv(inv))\nend\n\nlocal x, y = io.read(\"*n\", \"*n\")\nif (x + y) % 3 ~= 0 then\n print(0) os.exit()\nend\nlocal z = (x + y) // 3\nx, y = x - z, y - z\nif x < 0 or y < 0 then\n print(0) os.exit()\nend\nprint(getComb(x + y, x))", "problem_context": "Score : 400 points\n\nProblem Statement\n\nThere is a knight - the chess piece - at the origin (0, 0) of a two-dimensional grid.\n\nWhen the knight is at the square (i, j), it can be moved to either (i+1,j+2) or (i+2, j+1).\n\nIn how many ways can the knight reach the square (X, Y)?\n\nFind the number of ways modulo 10^9 + 7.\n\nConstraints\n\n1 \\leq X \\leq 10^6\n\n1 \\leq Y \\leq 10^6\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX Y\n\nOutput\n\nPrint the number of ways for the knight to reach (X, Y) from (0, 0), modulo 10^9 + 7.\n\nSample Input 1\n\n3 3\n\nSample Output 1\n\n2\n\nThere are two ways: (0,0) \\to (1,2) \\to (3,3) and (0,0) \\to (2,1) \\to (3,3).\n\nSample Input 2\n\n2 2\n\nSample Output 2\n\n0\n\nThe knight cannot reach (2,2).\n\nSample Input 3\n\n999999 999999\n\nSample Output 3\n\n151840682\n\nPrint the number of ways modulo 10^9 + 7.", "sample_input": "3 3\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02862", "source_text": "Score : 400 points\n\nProblem Statement\n\nThere is a knight - the chess piece - at the origin (0, 0) of a two-dimensional grid.\n\nWhen the knight is at the square (i, j), it can be moved to either (i+1,j+2) or (i+2, j+1).\n\nIn how many ways can the knight reach the square (X, Y)?\n\nFind the number of ways modulo 10^9 + 7.\n\nConstraints\n\n1 \\leq X \\leq 10^6\n\n1 \\leq Y \\leq 10^6\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX Y\n\nOutput\n\nPrint the number of ways for the knight to reach (X, Y) from (0, 0), modulo 10^9 + 7.\n\nSample Input 1\n\n3 3\n\nSample Output 1\n\n2\n\nThere are two ways: (0,0) \\to (1,2) \\to (3,3) and (0,0) \\to (2,1) \\to (3,3).\n\nSample Input 2\n\n2 2\n\nSample Output 2\n\n0\n\nThe knight cannot reach (2,2).\n\nSample Input 3\n\n999999 999999\n\nSample Output 3\n\n151840682\n\nPrint the number of ways modulo 10^9 + 7.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 854, "cpu_time_ms": 57, "memory_kb": 2796}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s092775141", "group_id": "codeNet:p02863", "input_text": "local mma = math.max\nlocal n, t = io.read(\"*n\", \"*n\")\nlocal a, b = {}, {}\nfor i = 1, n do\n a[i], b[i] = io.read(\"*n\", \"*n\")\nend\n\nlocal function solve()\n if t == 1 then\n local t1ret = b[1]\n for i = 2, n do\n t1ret = mma(t1ret, b[i])\n end\n return t1ret\n end\n local totret = 0\n local tail = {}\n for i = 1, n do\n tail[i] = {}\n for j = 1, t - 1 do\n tail[i][j] = 0\n end\n end\n local curmax = 0\n for i = n, 1, -1 do\n for j = 1, curmax do\n tail[i][j] = mma(tail[i][j], tail[i + 1][j])\n if j + a[i] < t then\n tail[i][j + a[i]] = mma(tail[i][j + a[i]], tail[i + 1][j] + b[i])\n curmax = mma(curmax, j + a[i])\n end\n end\n if a[i] < t then\n tail[i][a[i]] = mma(tail[i][a[i]], b[i])\n curmax = mma(curmax, a[i])\n end\n end\n local head = {}\n for i = 1, t - 1 do\n head[i] = 0\n end\n curmax = 0\n for i = 1, n - 1 do\n local headmax = {}\n headmax[1] = head[1]\n for j = 2, t - 1 do\n headmax[j] = mma(head[j], headmax[j - 1])\n end\n local tailmax = {}\n tailmax[1] = tail[i + 1][1]\n for j = 2, t - 1 do\n tailmax[j] = mma(tail[i + 1][j], tailmax[j - 1])\n end\n local iret = 0\n if 1 < t then iret = mma(headmax[t - 1], tailmax[t - 1]) end\n for j = 1, t - 2 do\n iret = mma(iret, headmax[j] + tailmax[t - 1 - j])\n end\n iret = iret + b[i]\n totret = mma(totret, iret)\n for j = t - 1 - a[i], 1, -1 do\n head[j + a[i]] = mma(head[j + a[i]], head[j] + b[i])\n end\n if a[i] < t then\n head[a[i]] = mma(head[a[i]], b[i])\n end\n end\n do -- i == n\n local headmax = {}\n headmax[1] = head[1]\n for j = 2, t - 1 do\n headmax[j] = mma(head[j], headmax[j - 1])\n end\n local iret = 1 < t and headmax[t - 1] or 0\n iret = iret + b[n]\n totret = mma(totret, iret)\n end\n return totret\nend\nprint(solve())\n", "language": "Lua", "metadata": {"date": 1573960680, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p02863.html", "problem_id": "p02863", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02863/input.txt", "sample_output_relpath": "derived/input_output/data/p02863/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02863/Lua/s092775141.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s092775141", "user_id": "u120582723"}, "prompt_components": {"gold_output": "110\n", "input_to_evaluate": "local mma = math.max\nlocal n, t = io.read(\"*n\", \"*n\")\nlocal a, b = {}, {}\nfor i = 1, n do\n a[i], b[i] = io.read(\"*n\", \"*n\")\nend\n\nlocal function solve()\n if t == 1 then\n local t1ret = b[1]\n for i = 2, n do\n t1ret = mma(t1ret, b[i])\n end\n return t1ret\n end\n local totret = 0\n local tail = {}\n for i = 1, n do\n tail[i] = {}\n for j = 1, t - 1 do\n tail[i][j] = 0\n end\n end\n local curmax = 0\n for i = n, 1, -1 do\n for j = 1, curmax do\n tail[i][j] = mma(tail[i][j], tail[i + 1][j])\n if j + a[i] < t then\n tail[i][j + a[i]] = mma(tail[i][j + a[i]], tail[i + 1][j] + b[i])\n curmax = mma(curmax, j + a[i])\n end\n end\n if a[i] < t then\n tail[i][a[i]] = mma(tail[i][a[i]], b[i])\n curmax = mma(curmax, a[i])\n end\n end\n local head = {}\n for i = 1, t - 1 do\n head[i] = 0\n end\n curmax = 0\n for i = 1, n - 1 do\n local headmax = {}\n headmax[1] = head[1]\n for j = 2, t - 1 do\n headmax[j] = mma(head[j], headmax[j - 1])\n end\n local tailmax = {}\n tailmax[1] = tail[i + 1][1]\n for j = 2, t - 1 do\n tailmax[j] = mma(tail[i + 1][j], tailmax[j - 1])\n end\n local iret = 0\n if 1 < t then iret = mma(headmax[t - 1], tailmax[t - 1]) end\n for j = 1, t - 2 do\n iret = mma(iret, headmax[j] + tailmax[t - 1 - j])\n end\n iret = iret + b[i]\n totret = mma(totret, iret)\n for j = t - 1 - a[i], 1, -1 do\n head[j + a[i]] = mma(head[j + a[i]], head[j] + b[i])\n end\n if a[i] < t then\n head[a[i]] = mma(head[a[i]], b[i])\n end\n end\n do -- i == n\n local headmax = {}\n headmax[1] = head[1]\n for j = 2, t - 1 do\n headmax[j] = mma(head[j], headmax[j - 1])\n end\n local iret = 1 < t and headmax[t - 1] or 0\n iret = iret + b[n]\n totret = mma(totret, iret)\n end\n return totret\nend\nprint(solve())\n", "problem_context": "Score : 500 points\n\nProblem Statement\n\nTakahashi is at an all-you-can-eat restaurant.\n\nThe restaurant offers N kinds of dishes. It takes A_i minutes to eat the i-th dish, whose deliciousness is B_i.\n\nThe restaurant has the following rules:\n\nYou can only order one dish at a time. The dish ordered will be immediately served and ready to eat.\n\nYou cannot order the same kind of dish more than once.\n\nUntil you finish eating the dish already served, you cannot order a new dish.\n\nAfter T-0.5 minutes from the first order, you can no longer place a new order, but you can continue eating the dish already served.\n\nLet Takahashi's happiness be the sum of the deliciousness of the dishes he eats in this restaurant.\n\nWhat is the maximum possible happiness achieved by making optimal choices?\n\nConstraints\n\n2 \\leq N \\leq 3000\n\n1 \\leq T \\leq 3000\n\n1 \\leq A_i \\leq 3000\n\n1 \\leq B_i \\leq 3000\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN T\nA_1 B_1\n:\nA_N B_N\n\nOutput\n\nPrint the maximum possible happiness Takahashi can achieve.\n\nSample Input 1\n\n2 60\n10 10\n100 100\n\nSample Output 1\n\n110\n\nBy ordering the first and second dishes in this order, Takahashi's happiness will be 110.\n\nNote that, if we manage to order a dish in time, we can spend any amount of time to eat it.\n\nSample Input 2\n\n3 60\n10 10\n10 20\n10 30\n\nSample Output 2\n\n60\n\nTakahashi can eat all the dishes within 60 minutes.\n\nSample Input 3\n\n3 60\n30 10\n30 20\n30 30\n\nSample Output 3\n\n50\n\nBy ordering the second and third dishes in this order, Takahashi's happiness will be 50.\n\nWe cannot order three dishes, in whatever order we place them.\n\nSample Input 4\n\n10 100\n15 23\n20 18\n13 17\n24 12\n18 29\n19 27\n23 21\n18 20\n27 15\n22 25\n\nSample Output 4\n\n145", "sample_input": "2 60\n10 10\n100 100\n"}, "reference_outputs": ["110\n"], "source_document_id": "p02863", "source_text": "Score : 500 points\n\nProblem Statement\n\nTakahashi is at an all-you-can-eat restaurant.\n\nThe restaurant offers N kinds of dishes. It takes A_i minutes to eat the i-th dish, whose deliciousness is B_i.\n\nThe restaurant has the following rules:\n\nYou can only order one dish at a time. The dish ordered will be immediately served and ready to eat.\n\nYou cannot order the same kind of dish more than once.\n\nUntil you finish eating the dish already served, you cannot order a new dish.\n\nAfter T-0.5 minutes from the first order, you can no longer place a new order, but you can continue eating the dish already served.\n\nLet Takahashi's happiness be the sum of the deliciousness of the dishes he eats in this restaurant.\n\nWhat is the maximum possible happiness achieved by making optimal choices?\n\nConstraints\n\n2 \\leq N \\leq 3000\n\n1 \\leq T \\leq 3000\n\n1 \\leq A_i \\leq 3000\n\n1 \\leq B_i \\leq 3000\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN T\nA_1 B_1\n:\nA_N B_N\n\nOutput\n\nPrint the maximum possible happiness Takahashi can achieve.\n\nSample Input 1\n\n2 60\n10 10\n100 100\n\nSample Output 1\n\n110\n\nBy ordering the first and second dishes in this order, Takahashi's happiness will be 110.\n\nNote that, if we manage to order a dish in time, we can spend any amount of time to eat it.\n\nSample Input 2\n\n3 60\n10 10\n10 20\n10 30\n\nSample Output 2\n\n60\n\nTakahashi can eat all the dishes within 60 minutes.\n\nSample Input 3\n\n3 60\n30 10\n30 20\n30 30\n\nSample Output 3\n\n50\n\nBy ordering the second and third dishes in this order, Takahashi's happiness will be 50.\n\nWe cannot order three dishes, in whatever order we place them.\n\nSample Input 4\n\n10 100\n15 23\n20 18\n13 17\n24 12\n18 29\n19 27\n23 21\n18 20\n27 15\n22 25\n\nSample Output 4\n\n145", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1852, "cpu_time_ms": 344, "memory_kb": 230784}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s053117837", "group_id": "codeNet:p02863", "input_text": "local mma = math.max\nlocal n, t = io.read(\"*n\", \"*n\")\nlocal a, b = {}, {}\nfor i = 1, n do\n a[i], b[i] = io.read(\"*n\", \"*n\")\nend\n\nlocal function solve()\n if t == 1 then\n local t1ret = b[1]\n for i = 2, n do\n t1ret = mma(t1ret, b[i])\n end\n return t1ret\n end\n local totret = 0\n local tail = {}\n for i = 1, n do\n tail[i] = {}\n for j = 1, t - 1 do\n tail[i][j] = 0\n end\n end\n local curmax = 0\n for i = n, 1, -1 do\n for j = 1, curmax do\n tail[i][j] = mma(tail[i][j], tail[i + 1][j])\n if j + a[i] < t and 0 < tail[i + 1][j] then\n tail[i][j + a[i]] = mma(tail[i][j + a[i]], tail[i + 1][j] + b[i])\n curmax = mma(curmax, j + a[i])\n end\n end\n if a[i] < t then\n tail[i][a[i]] = mma(tail[i][a[i]], b[i])\n curmax = mma(curmax, a[i])\n end\n end\n local head = {}\n for i = 1, t - 1 do\n head[i] = 0\n end\n curmax = 0\n for i = 1, n - 1 do\n local headmax = {}\n headmax[1] = head[1]\n for j = 2, t - 1 do\n headmax[j] = mma(head[j], headmax[j - 1])\n end\n local tailmax = {}\n tailmax[1] = tail[i + 1][1]\n for j = 2, t - 1 do\n tailmax[j] = mma(tail[i + 1][j], tailmax[j - 1])\n end\n local iret = mma(headmax[t - 1], tailmax[t - 1])\n for j = 1, t - 2 do\n iret = mma(iret, headmax[j] + tailmax[t - 1 - j])\n end\n iret = iret + b[i]\n totret = mma(totret, iret)\n for j = t - 1 - a[i], 1, -1 do\n if 0 < head[j] then\n head[j + a[i]] = mma(head[j + a[i]], head[j] + b[i])\n end\n end\n end\n do -- i == n\n local headmax = {}\n headmax[1] = head[1]\n for j = 2, t - 1 do\n headmax[j] = mma(head[j], headmax[j - 1])\n end\n local iret = headmax[t - 1]\n iret = iret + b[n]\n totret = mma(totret, iret)\n end\n return totret\nend\nprint(solve())\n", "language": "Lua", "metadata": {"date": 1573960049, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p02863.html", "problem_id": "p02863", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02863/input.txt", "sample_output_relpath": "derived/input_output/data/p02863/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02863/Lua/s053117837.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s053117837", "user_id": "u120582723"}, "prompt_components": {"gold_output": "110\n", "input_to_evaluate": "local mma = math.max\nlocal n, t = io.read(\"*n\", \"*n\")\nlocal a, b = {}, {}\nfor i = 1, n do\n a[i], b[i] = io.read(\"*n\", \"*n\")\nend\n\nlocal function solve()\n if t == 1 then\n local t1ret = b[1]\n for i = 2, n do\n t1ret = mma(t1ret, b[i])\n end\n return t1ret\n end\n local totret = 0\n local tail = {}\n for i = 1, n do\n tail[i] = {}\n for j = 1, t - 1 do\n tail[i][j] = 0\n end\n end\n local curmax = 0\n for i = n, 1, -1 do\n for j = 1, curmax do\n tail[i][j] = mma(tail[i][j], tail[i + 1][j])\n if j + a[i] < t and 0 < tail[i + 1][j] then\n tail[i][j + a[i]] = mma(tail[i][j + a[i]], tail[i + 1][j] + b[i])\n curmax = mma(curmax, j + a[i])\n end\n end\n if a[i] < t then\n tail[i][a[i]] = mma(tail[i][a[i]], b[i])\n curmax = mma(curmax, a[i])\n end\n end\n local head = {}\n for i = 1, t - 1 do\n head[i] = 0\n end\n curmax = 0\n for i = 1, n - 1 do\n local headmax = {}\n headmax[1] = head[1]\n for j = 2, t - 1 do\n headmax[j] = mma(head[j], headmax[j - 1])\n end\n local tailmax = {}\n tailmax[1] = tail[i + 1][1]\n for j = 2, t - 1 do\n tailmax[j] = mma(tail[i + 1][j], tailmax[j - 1])\n end\n local iret = mma(headmax[t - 1], tailmax[t - 1])\n for j = 1, t - 2 do\n iret = mma(iret, headmax[j] + tailmax[t - 1 - j])\n end\n iret = iret + b[i]\n totret = mma(totret, iret)\n for j = t - 1 - a[i], 1, -1 do\n if 0 < head[j] then\n head[j + a[i]] = mma(head[j + a[i]], head[j] + b[i])\n end\n end\n end\n do -- i == n\n local headmax = {}\n headmax[1] = head[1]\n for j = 2, t - 1 do\n headmax[j] = mma(head[j], headmax[j - 1])\n end\n local iret = headmax[t - 1]\n iret = iret + b[n]\n totret = mma(totret, iret)\n end\n return totret\nend\nprint(solve())\n", "problem_context": "Score : 500 points\n\nProblem Statement\n\nTakahashi is at an all-you-can-eat restaurant.\n\nThe restaurant offers N kinds of dishes. It takes A_i minutes to eat the i-th dish, whose deliciousness is B_i.\n\nThe restaurant has the following rules:\n\nYou can only order one dish at a time. The dish ordered will be immediately served and ready to eat.\n\nYou cannot order the same kind of dish more than once.\n\nUntil you finish eating the dish already served, you cannot order a new dish.\n\nAfter T-0.5 minutes from the first order, you can no longer place a new order, but you can continue eating the dish already served.\n\nLet Takahashi's happiness be the sum of the deliciousness of the dishes he eats in this restaurant.\n\nWhat is the maximum possible happiness achieved by making optimal choices?\n\nConstraints\n\n2 \\leq N \\leq 3000\n\n1 \\leq T \\leq 3000\n\n1 \\leq A_i \\leq 3000\n\n1 \\leq B_i \\leq 3000\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN T\nA_1 B_1\n:\nA_N B_N\n\nOutput\n\nPrint the maximum possible happiness Takahashi can achieve.\n\nSample Input 1\n\n2 60\n10 10\n100 100\n\nSample Output 1\n\n110\n\nBy ordering the first and second dishes in this order, Takahashi's happiness will be 110.\n\nNote that, if we manage to order a dish in time, we can spend any amount of time to eat it.\n\nSample Input 2\n\n3 60\n10 10\n10 20\n10 30\n\nSample Output 2\n\n60\n\nTakahashi can eat all the dishes within 60 minutes.\n\nSample Input 3\n\n3 60\n30 10\n30 20\n30 30\n\nSample Output 3\n\n50\n\nBy ordering the second and third dishes in this order, Takahashi's happiness will be 50.\n\nWe cannot order three dishes, in whatever order we place them.\n\nSample Input 4\n\n10 100\n15 23\n20 18\n13 17\n24 12\n18 29\n19 27\n23 21\n18 20\n27 15\n22 25\n\nSample Output 4\n\n145", "sample_input": "2 60\n10 10\n100 100\n"}, "reference_outputs": ["110\n"], "source_document_id": "p02863", "source_text": "Score : 500 points\n\nProblem Statement\n\nTakahashi is at an all-you-can-eat restaurant.\n\nThe restaurant offers N kinds of dishes. It takes A_i minutes to eat the i-th dish, whose deliciousness is B_i.\n\nThe restaurant has the following rules:\n\nYou can only order one dish at a time. The dish ordered will be immediately served and ready to eat.\n\nYou cannot order the same kind of dish more than once.\n\nUntil you finish eating the dish already served, you cannot order a new dish.\n\nAfter T-0.5 minutes from the first order, you can no longer place a new order, but you can continue eating the dish already served.\n\nLet Takahashi's happiness be the sum of the deliciousness of the dishes he eats in this restaurant.\n\nWhat is the maximum possible happiness achieved by making optimal choices?\n\nConstraints\n\n2 \\leq N \\leq 3000\n\n1 \\leq T \\leq 3000\n\n1 \\leq A_i \\leq 3000\n\n1 \\leq B_i \\leq 3000\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN T\nA_1 B_1\n:\nA_N B_N\n\nOutput\n\nPrint the maximum possible happiness Takahashi can achieve.\n\nSample Input 1\n\n2 60\n10 10\n100 100\n\nSample Output 1\n\n110\n\nBy ordering the first and second dishes in this order, Takahashi's happiness will be 110.\n\nNote that, if we manage to order a dish in time, we can spend any amount of time to eat it.\n\nSample Input 2\n\n3 60\n10 10\n10 20\n10 30\n\nSample Output 2\n\n60\n\nTakahashi can eat all the dishes within 60 minutes.\n\nSample Input 3\n\n3 60\n30 10\n30 20\n30 30\n\nSample Output 3\n\n50\n\nBy ordering the second and third dishes in this order, Takahashi's happiness will be 50.\n\nWe cannot order three dishes, in whatever order we place them.\n\nSample Input 4\n\n10 100\n15 23\n20 18\n13 17\n24 12\n18 29\n19 27\n23 21\n18 20\n27 15\n22 25\n\nSample Output 4\n\n145", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1797, "cpu_time_ms": 409, "memory_kb": 248320}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s099680838", "group_id": "codeNet:p02864", "input_text": "local mmi, mma = math.min, math.max\nlocal n, k = io.read(\"*n\", \"*n\")\nlocal h = {0}\nfor i = 1, n do\n h[i + 1] = io.read(\"*n\")\nend\nh[n + 2] = 0\nlocal hsum = {h[1]}\nfor i = 2, n + 2 do\n hsum[i] = hsum[i - 1] + h[i]\nend\nlocal t = {}\nt[1] = {}\nfor i = 1, k + 1 do\n t[1][i] = 0\nend\nfor i = 2, n + 1 do\n t[i] = {}\n for j = 1, k + 1 do\n t[i][j] = t[i - 1][j]\n end\n if h[i - 1] < h[i] and h[i + 1] < h[i] then\n local right = h[i + 1]\n local left = h[i]\n for j = i - 1, 1, -1 do\n if left <= h[j] then\n break\n end\n local len = i - j\n local score = hsum[i] - hsum[j]\n if h[j] <= right then\n score = score - len * right\n for z = len + 1, k + 1 do\n t[i][z] = mma(t[i][z], t[j][z - len] + score)\n end\n break\n else\n score = score - len * h[j]\n for z = len + 1, k + 1 do\n t[i][z] = mma(t[i][z], t[j][z - len] + score)\n end\n end\n left = h[j]\n end\n end\n for j = 2, k + 1 do\n t[i][j] = mma(t[i][j], t[i][j - 1])\n end\nend\nlocal ret = -t[n + 1][k + 1]\nfor i = 2, n + 1 do\n ret = ret + mma(0, h[i] - h[i - 1])\nend\nprint(ret)\n", "language": "Lua", "metadata": {"date": 1589029054, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p02864.html", "problem_id": "p02864", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02864/input.txt", "sample_output_relpath": "derived/input_output/data/p02864/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02864/Lua/s099680838.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s099680838", "user_id": "u120582723"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "local mmi, mma = math.min, math.max\nlocal n, k = io.read(\"*n\", \"*n\")\nlocal h = {0}\nfor i = 1, n do\n h[i + 1] = io.read(\"*n\")\nend\nh[n + 2] = 0\nlocal hsum = {h[1]}\nfor i = 2, n + 2 do\n hsum[i] = hsum[i - 1] + h[i]\nend\nlocal t = {}\nt[1] = {}\nfor i = 1, k + 1 do\n t[1][i] = 0\nend\nfor i = 2, n + 1 do\n t[i] = {}\n for j = 1, k + 1 do\n t[i][j] = t[i - 1][j]\n end\n if h[i - 1] < h[i] and h[i + 1] < h[i] then\n local right = h[i + 1]\n local left = h[i]\n for j = i - 1, 1, -1 do\n if left <= h[j] then\n break\n end\n local len = i - j\n local score = hsum[i] - hsum[j]\n if h[j] <= right then\n score = score - len * right\n for z = len + 1, k + 1 do\n t[i][z] = mma(t[i][z], t[j][z - len] + score)\n end\n break\n else\n score = score - len * h[j]\n for z = len + 1, k + 1 do\n t[i][z] = mma(t[i][z], t[j][z - len] + score)\n end\n end\n left = h[j]\n end\n end\n for j = 2, k + 1 do\n t[i][j] = mma(t[i][j], t[i][j - 1])\n end\nend\nlocal ret = -t[n + 1][k + 1]\nfor i = 2, n + 1 do\n ret = ret + mma(0, h[i] - h[i - 1])\nend\nprint(ret)\n", "problem_context": "Score : 600 points\n\nProblem Statement\n\nWe will create an artwork by painting black some squares in a white square grid with 10^9 rows and N columns.\n\nThe current plan is as follows: for the i-th column from the left, we will paint the H_i bottommost squares and will not paint the other squares in that column.\n\nBefore starting to work, you can choose at most K columns (possibly zero) and change the values of H_i for these columns to any integers of your choice between 0 and 10^9 (inclusive).\n\nDifferent values can be chosen for different columns.\n\nThen, you will create the modified artwork by repeating the following operation:\n\nChoose one or more consecutive squares in one row and paint them black. (Squares already painted black can be painted again, but squares not to be painted according to the modified plan should not be painted.)\n\nFind the minimum number of times you need to perform this operation.\n\nConstraints\n\n1 \\leq N \\leq 300\n\n0 \\leq K \\leq N\n\n0 \\leq H_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nH_1 H_2 ... H_N\n\nOutput\n\nPrint the minimum number of operations required.\n\nSample Input 1\n\n4 1\n2 3 4 1\n\nSample Output 1\n\n3\n\nFor example, by changing the value of H_3 to 2, you can create the modified artwork by the following three operations:\n\nPaint black the 1-st through 4-th squares from the left in the 1-st row from the bottom.\n\nPaint black the 1-st through 3-rd squares from the left in the 2-nd row from the bottom.\n\nPaint black the 2-nd square from the left in the 3-rd row from the bottom.\n\nSample Input 2\n\n6 2\n8 6 9 1 2 1\n\nSample Output 2\n\n7\n\nSample Input 3\n\n10 0\n1 1000000000 1 1000000000 1 1000000000 1 1000000000 1 1000000000\n\nSample Output 3\n\n4999999996", "sample_input": "4 1\n2 3 4 1\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02864", "source_text": "Score : 600 points\n\nProblem Statement\n\nWe will create an artwork by painting black some squares in a white square grid with 10^9 rows and N columns.\n\nThe current plan is as follows: for the i-th column from the left, we will paint the H_i bottommost squares and will not paint the other squares in that column.\n\nBefore starting to work, you can choose at most K columns (possibly zero) and change the values of H_i for these columns to any integers of your choice between 0 and 10^9 (inclusive).\n\nDifferent values can be chosen for different columns.\n\nThen, you will create the modified artwork by repeating the following operation:\n\nChoose one or more consecutive squares in one row and paint them black. (Squares already painted black can be painted again, but squares not to be painted according to the modified plan should not be painted.)\n\nFind the minimum number of times you need to perform this operation.\n\nConstraints\n\n1 \\leq N \\leq 300\n\n0 \\leq K \\leq N\n\n0 \\leq H_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nH_1 H_2 ... H_N\n\nOutput\n\nPrint the minimum number of operations required.\n\nSample Input 1\n\n4 1\n2 3 4 1\n\nSample Output 1\n\n3\n\nFor example, by changing the value of H_3 to 2, you can create the modified artwork by the following three operations:\n\nPaint black the 1-st through 4-th squares from the left in the 1-st row from the bottom.\n\nPaint black the 1-st through 3-rd squares from the left in the 2-nd row from the bottom.\n\nPaint black the 2-nd square from the left in the 3-rd row from the bottom.\n\nSample Input 2\n\n6 2\n8 6 9 1 2 1\n\nSample Output 2\n\n7\n\nSample Input 3\n\n10 0\n1 1000000000 1 1000000000 1 1000000000 1 1000000000 1 1000000000\n\nSample Output 3\n\n4999999996", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1145, "cpu_time_ms": 4, "memory_kb": 1536}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s947188395", "group_id": "codeNet:p02868", "input_text": "local mfl, mce, mmi = math.floor, math.ceil, math.min\nlocal SegTree = {}\nSegTree.updateAll = function(self)\n for i = self.stagenum - 1, 1, -1 do\n for j = 1, self.cnt[i] do\n self.stage[i][j] = self.func(self.stage[i + 1][j * 2 - 1], self.stage[i + 1][j * 2])\n self.lazy[i][j] = false\n end\n end\nend\nSegTree.create = function(self, n, func, emptyvalue)\n self.func, self.emptyvalue = func, emptyvalue\n local stagenum, mul = 1, 1\n self.cnt, self.stage, self.size = {1}, {{}}, {}\n self.lazy = {{}}\n while mul < n do\n mul, stagenum = mul * 2, stagenum + 1\n self.cnt[stagenum], self.stage[stagenum] = mul, {}\n self.lazy[stagenum] = {}\n end\n for i = 1, stagenum do self.size[i] = self.cnt[stagenum + 1 - i] end\n self.stagenum = stagenum\n for i = 1, mul do self.stage[stagenum][i] = emptyvalue end\n for i = 1, mul do self.lazy[stagenum][i] = false end\n self:updateAll()\nend\nSegTree.getValue = function(self, idx)\n return self.stage[self.stagenum][idx]\nend\nSegTree.setRange = function(self, left, right, value)\n if left == right then self.stage[self.stagenum][left] = value return end\n local start_stage = 1\n while right - left + 1 < self.size[start_stage] do\n start_stage = start_stage + 1\n end\n local t1, t2, t3 = {start_stage}, {left}, {right}\n while 0 < #t1 do\n local stage, l, r = t1[#t1], t2[#t1], t3[#t1]\n table.remove(t1) table.remove(t2) table.remove(t3)\n local sz = self.size[stage]\n if (l - 1) % sz ~= 0 then\n local newr = mmi(r, mce((l - 1) / sz) * sz)\n table.insert(t1, stage + 1) table.insert(t2, l) table.insert(t3, newr)\n l = newr + 1\n end\n if sz <= r + 1 - l then\n if value < self.stage[stage][mce(l / sz)] then\n self.stage[stage][mce(l / sz)] = value\n self.lazy[stage][mce(l / sz)] = true\n end\n l = l + sz\n end\n if l <= r then\n table.insert(t1, stage + 1) table.insert(t2, l) table.insert(t3, r)\n end\n end\nend\nSegTree.resolve = function(self, idx)\n for stage = 1, self.stagenum - 1 do\n local pos = mce(idx / (self.size[stage]))\n if self.lazy[stage][pos] then\n self.lazy[stage][pos] = false\n local v = self.stage[stage][pos]\n if v < self.stage[stage + 1][pos * 2 - 1] then\n self.stage[stage + 1][pos * 2 - 1] = v\n self.lazy[stage + 1][pos * 2 - 1] = true\n end\n if v < self.stage[stage + 1][pos * 2] then\n self.stage[stage + 1][pos * 2] = v\n self.lazy[stage + 1][pos * 2] = true\n end\n end\n end\nend\nSegTree.new = function(n, func, emptyvalue)\n local obj = {}\n setmetatable(obj, {__index = SegTree})\n obj:create(n, func, emptyvalue)\n return obj\nend\n\nlocal n, m = io.read(\"*n\", \"*n\")\nlocal t = {}\nfor i = 1, m do\n local a, b, c = io.read(\"*n\", \"*n\", \"*n\")\n t[i] = {a, b, c}\nend\n\ntable.sort(t, function(x, y) return x[1] < y[1] end)\nlocal st = SegTree.new(n, mmi, 99999999999999)\nst:setRange(1, 1, 0)\nfor i = 1, m do\n st:resolve(t[i][1])\n local lval = st:getValue(t[i][1])\n st:setRange(t[i][1] + 1, t[i][2], lval + t[i][3])\nend\nst:resolve(n)\nprint(99999999999999 <= st:getValue(n) and -1 or st:getValue(n))\n", "language": "Lua", "metadata": {"date": 1573355289, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p02868.html", "problem_id": "p02868", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02868/input.txt", "sample_output_relpath": "derived/input_output/data/p02868/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02868/Lua/s947188395.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s947188395", "user_id": "u120582723"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "local mfl, mce, mmi = math.floor, math.ceil, math.min\nlocal SegTree = {}\nSegTree.updateAll = function(self)\n for i = self.stagenum - 1, 1, -1 do\n for j = 1, self.cnt[i] do\n self.stage[i][j] = self.func(self.stage[i + 1][j * 2 - 1], self.stage[i + 1][j * 2])\n self.lazy[i][j] = false\n end\n end\nend\nSegTree.create = function(self, n, func, emptyvalue)\n self.func, self.emptyvalue = func, emptyvalue\n local stagenum, mul = 1, 1\n self.cnt, self.stage, self.size = {1}, {{}}, {}\n self.lazy = {{}}\n while mul < n do\n mul, stagenum = mul * 2, stagenum + 1\n self.cnt[stagenum], self.stage[stagenum] = mul, {}\n self.lazy[stagenum] = {}\n end\n for i = 1, stagenum do self.size[i] = self.cnt[stagenum + 1 - i] end\n self.stagenum = stagenum\n for i = 1, mul do self.stage[stagenum][i] = emptyvalue end\n for i = 1, mul do self.lazy[stagenum][i] = false end\n self:updateAll()\nend\nSegTree.getValue = function(self, idx)\n return self.stage[self.stagenum][idx]\nend\nSegTree.setRange = function(self, left, right, value)\n if left == right then self.stage[self.stagenum][left] = value return end\n local start_stage = 1\n while right - left + 1 < self.size[start_stage] do\n start_stage = start_stage + 1\n end\n local t1, t2, t3 = {start_stage}, {left}, {right}\n while 0 < #t1 do\n local stage, l, r = t1[#t1], t2[#t1], t3[#t1]\n table.remove(t1) table.remove(t2) table.remove(t3)\n local sz = self.size[stage]\n if (l - 1) % sz ~= 0 then\n local newr = mmi(r, mce((l - 1) / sz) * sz)\n table.insert(t1, stage + 1) table.insert(t2, l) table.insert(t3, newr)\n l = newr + 1\n end\n if sz <= r + 1 - l then\n if value < self.stage[stage][mce(l / sz)] then\n self.stage[stage][mce(l / sz)] = value\n self.lazy[stage][mce(l / sz)] = true\n end\n l = l + sz\n end\n if l <= r then\n table.insert(t1, stage + 1) table.insert(t2, l) table.insert(t3, r)\n end\n end\nend\nSegTree.resolve = function(self, idx)\n for stage = 1, self.stagenum - 1 do\n local pos = mce(idx / (self.size[stage]))\n if self.lazy[stage][pos] then\n self.lazy[stage][pos] = false\n local v = self.stage[stage][pos]\n if v < self.stage[stage + 1][pos * 2 - 1] then\n self.stage[stage + 1][pos * 2 - 1] = v\n self.lazy[stage + 1][pos * 2 - 1] = true\n end\n if v < self.stage[stage + 1][pos * 2] then\n self.stage[stage + 1][pos * 2] = v\n self.lazy[stage + 1][pos * 2] = true\n end\n end\n end\nend\nSegTree.new = function(n, func, emptyvalue)\n local obj = {}\n setmetatable(obj, {__index = SegTree})\n obj:create(n, func, emptyvalue)\n return obj\nend\n\nlocal n, m = io.read(\"*n\", \"*n\")\nlocal t = {}\nfor i = 1, m do\n local a, b, c = io.read(\"*n\", \"*n\", \"*n\")\n t[i] = {a, b, c}\nend\n\ntable.sort(t, function(x, y) return x[1] < y[1] end)\nlocal st = SegTree.new(n, mmi, 99999999999999)\nst:setRange(1, 1, 0)\nfor i = 1, m do\n st:resolve(t[i][1])\n local lval = st:getValue(t[i][1])\n st:setRange(t[i][1] + 1, t[i][2], lval + t[i][3])\nend\nst:resolve(n)\nprint(99999999999999 <= st:getValue(n) and -1 or st:getValue(n))\n", "problem_context": "Score : 600 points\n\nProblem Statement\n\nWe have N points numbered 1 to N arranged in a line in this order.\n\nTakahashi decides to make an undirected graph, using these points as the vertices.\nIn the beginning, the graph has no edge. Takahashi will do M operations to add edges in this graph.\nThe i-th operation is as follows:\n\nThe operation uses integers L_i and R_i between 1 and N (inclusive), and a positive integer C_i. For every pair of integers (s, t) such that L_i \\leq s < t \\leq R_i, add an edge of length C_i between Vertex s and Vertex t.\n\nThe integers L_1, ..., L_M, R_1, ..., R_M, C_1, ..., C_M are all given as input.\n\nTakahashi wants to solve the shortest path problem in the final graph obtained. Find the length of the shortest path from Vertex 1 to Vertex N in the final graph.\n\nConstraints\n\n2 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^5\n\n1 \\leq L_i < R_i \\leq N\n\n1 \\leq C_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nL_1 R_1 C_1\n:\nL_M R_M C_M\n\nOutput\n\nPrint the length of the shortest path from Vertex 1 to Vertex N in the final graph.\nIf there is no shortest path, print -1 instead.\n\nSample Input 1\n\n4 3\n1 3 2\n2 4 3\n1 4 6\n\nSample Output 1\n\n5\n\nWe have an edge of length 2 between Vertex 1 and Vertex 2, and an edge of length 3 between Vertex 2 and Vertex 4, so there is a path of length 5 between Vertex 1 and Vertex 4.\n\nSample Input 2\n\n4 2\n1 2 1\n3 4 2\n\nSample Output 2\n\n-1\n\nSample Input 3\n\n10 7\n1 5 18\n3 4 8\n1 3 5\n4 7 10\n5 9 8\n6 10 5\n8 10 3\n\nSample Output 3\n\n28", "sample_input": "4 3\n1 3 2\n2 4 3\n1 4 6\n"}, "reference_outputs": ["5\n"], "source_document_id": "p02868", "source_text": "Score : 600 points\n\nProblem Statement\n\nWe have N points numbered 1 to N arranged in a line in this order.\n\nTakahashi decides to make an undirected graph, using these points as the vertices.\nIn the beginning, the graph has no edge. Takahashi will do M operations to add edges in this graph.\nThe i-th operation is as follows:\n\nThe operation uses integers L_i and R_i between 1 and N (inclusive), and a positive integer C_i. For every pair of integers (s, t) such that L_i \\leq s < t \\leq R_i, add an edge of length C_i between Vertex s and Vertex t.\n\nThe integers L_1, ..., L_M, R_1, ..., R_M, C_1, ..., C_M are all given as input.\n\nTakahashi wants to solve the shortest path problem in the final graph obtained. Find the length of the shortest path from Vertex 1 to Vertex N in the final graph.\n\nConstraints\n\n2 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^5\n\n1 \\leq L_i < R_i \\leq N\n\n1 \\leq C_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nL_1 R_1 C_1\n:\nL_M R_M C_M\n\nOutput\n\nPrint the length of the shortest path from Vertex 1 to Vertex N in the final graph.\nIf there is no shortest path, print -1 instead.\n\nSample Input 1\n\n4 3\n1 3 2\n2 4 3\n1 4 6\n\nSample Output 1\n\n5\n\nWe have an edge of length 2 between Vertex 1 and Vertex 2, and an edge of length 3 between Vertex 2 and Vertex 4, so there is a path of length 5 between Vertex 1 and Vertex 4.\n\nSample Input 2\n\n4 2\n1 2 1\n3 4 2\n\nSample Output 2\n\n-1\n\nSample Input 3\n\n10 7\n1 5 18\n3 4 8\n1 3 5\n4 7 10\n5 9 8\n6 10 5\n8 10 3\n\nSample Output 3\n\n28", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 3111, "cpu_time_ms": 430, "memory_kb": 29924}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s882229721", "group_id": "codeNet:p02873", "input_text": "local S = io.read()\nlocal a = {}\na[#S+1] = 0\nfor i=#S,1,-1 do\n local c = S:sub(i,i)\n if c == '>' then\n a[i] = a[i+1] + 1\n else\n a[i] = 0\n end\nend\nfor i=1,#S do\n local c = S:sub(i,i)\n if c == '<' and a[i+1] <= a[i] then\n a[i+1] = a[i] + 1\n end\nend\nlocal s = 0\nfor i=1,#a do\n s = s + a[i]\nend\nprint(s)\n", "language": "Lua", "metadata": {"date": 1572894048, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p02873.html", "problem_id": "p02873", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02873/input.txt", "sample_output_relpath": "derived/input_output/data/p02873/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02873/Lua/s882229721.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s882229721", "user_id": "u162773977"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "local S = io.read()\nlocal a = {}\na[#S+1] = 0\nfor i=#S,1,-1 do\n local c = S:sub(i,i)\n if c == '>' then\n a[i] = a[i+1] + 1\n else\n a[i] = 0\n end\nend\nfor i=1,#S do\n local c = S:sub(i,i)\n if c == '<' and a[i+1] <= a[i] then\n a[i+1] = a[i] + 1\n end\nend\nlocal s = 0\nfor i=1,#a do\n s = s + a[i]\nend\nprint(s)\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nGiven is a string S of length N-1.\nEach character in S is < or >.\n\nA sequence of N non-negative integers, a_1,a_2,\\cdots,a_N, is said to be good when the following condition is satisfied for all i (1 \\leq i \\leq N-1):\n\nIf S_i= <: a_i: a_i>a_{i+1}\n\nFind the minimum possible sum of the elements of a good sequence of N non-negative integers.\n\nConstraints\n\n2 \\leq N \\leq 5 \\times 10^5\n\nS is a string of length N-1 consisting of < and >.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nFind the minimum possible sum of the elements of a good sequence of N non-negative integers.\n\nSample Input 1\n\n<>>\n\nSample Output 1\n\n3\n\na=(0,2,1,0) is a good sequence whose sum is 3.\nThere is no good sequence whose sum is less than 3.\n\nSample Input 2\n\n<>>><<><<<<<>>><\n\nSample Output 2\n\n28", "sample_input": "<>>\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02873", "source_text": "Score : 300 points\n\nProblem Statement\n\nGiven is a string S of length N-1.\nEach character in S is < or >.\n\nA sequence of N non-negative integers, a_1,a_2,\\cdots,a_N, is said to be good when the following condition is satisfied for all i (1 \\leq i \\leq N-1):\n\nIf S_i= <: a_i: a_i>a_{i+1}\n\nFind the minimum possible sum of the elements of a good sequence of N non-negative integers.\n\nConstraints\n\n2 \\leq N \\leq 5 \\times 10^5\n\nS is a string of length N-1 consisting of < and >.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nFind the minimum possible sum of the elements of a good sequence of N non-negative integers.\n\nSample Input 1\n\n<>>\n\nSample Output 1\n\n3\n\na=(0,2,1,0) is a good sequence whose sum is 3.\nThere is no good sequence whose sum is less than 3.\n\nSample Input 2\n\n<>>><<><<<<<>>><\n\nSample Output 2\n\n28", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 317, "cpu_time_ms": 196, "memory_kb": 17304}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s604878853", "group_id": "codeNet:p02874", "input_text": "local mma, mmi = math.max, math.min\nlocal n = io.read(\"*n\")\nlocal t = {}\nfor i = 1, n do\n t[i] = {io.read(\"*n\", \"*n\")}\n t[i][3] = i\nend\nlocal lmaxp, rminp = 1, 1\nfor i = 2, n do\n if t[lmaxp][1] < t[i][1] then\n lmaxp = i\n end\n if t[i][2] < t[rminp][2] then\n rminp = i\n end\nend\nlocal cand = mma(0, t[rminp][2] - t[lmaxp][1] + 1)\ndo\n local maxlen = 0\n for i = 1, n do\n if i ~= lmaxp and i ~= rminp then\n maxlen = mma(maxlen, t[i][2] - t[i][1] + 1)\n end\n end\n cand = cand + maxlen\nend\nif lmaxp ~= rminp then\n local l_r, r_l = t[rminp][2], t[lmaxp][1]\n\n local l_l, r_r = false, t[lmaxp][2]\n table.sort(t, function(a, b) return a[1] > b[1] end)\n for i = 1, n do\n if t[i][3] ~= lmaxp then\n l_l = t[i][1]\n cand = mma(cand, mma(0, l_r - l_l + 1) + mma(0, r_r - r_l + 1))\n end\n if t[i][3] ~= rminp then\n r_r = mmi(r_r, t[i][2])\n end\n end\n cand = mma(cand, mma(0, l_r - l_l + 1) + mma(0, r_r - r_l + 1))\nend\nprint(cand)\n", "language": "Lua", "metadata": {"date": 1582988628, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p02874.html", "problem_id": "p02874", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02874/input.txt", "sample_output_relpath": "derived/input_output/data/p02874/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02874/Lua/s604878853.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s604878853", "user_id": "u120582723"}, "prompt_components": {"gold_output": "6\n", "input_to_evaluate": "local mma, mmi = math.max, math.min\nlocal n = io.read(\"*n\")\nlocal t = {}\nfor i = 1, n do\n t[i] = {io.read(\"*n\", \"*n\")}\n t[i][3] = i\nend\nlocal lmaxp, rminp = 1, 1\nfor i = 2, n do\n if t[lmaxp][1] < t[i][1] then\n lmaxp = i\n end\n if t[i][2] < t[rminp][2] then\n rminp = i\n end\nend\nlocal cand = mma(0, t[rminp][2] - t[lmaxp][1] + 1)\ndo\n local maxlen = 0\n for i = 1, n do\n if i ~= lmaxp and i ~= rminp then\n maxlen = mma(maxlen, t[i][2] - t[i][1] + 1)\n end\n end\n cand = cand + maxlen\nend\nif lmaxp ~= rminp then\n local l_r, r_l = t[rminp][2], t[lmaxp][1]\n\n local l_l, r_r = false, t[lmaxp][2]\n table.sort(t, function(a, b) return a[1] > b[1] end)\n for i = 1, n do\n if t[i][3] ~= lmaxp then\n l_l = t[i][1]\n cand = mma(cand, mma(0, l_r - l_l + 1) + mma(0, r_r - r_l + 1))\n end\n if t[i][3] ~= rminp then\n r_r = mmi(r_r, t[i][2])\n end\n end\n cand = mma(cand, mma(0, l_r - l_l + 1) + mma(0, r_r - r_l + 1))\nend\nprint(cand)\n", "problem_context": "Score : 600 points\n\nProblem Statement\n\n10^9 contestants, numbered 1 to 10^9, will compete in a competition.\nThere will be two contests in this competition.\n\nThe organizer prepared N problems, numbered 1 to N, to use in these contests.\nWhen Problem i is presented in a contest, it will be solved by all contestants from Contestant L_i to Contestant R_i (inclusive), and will not be solved by any other contestants.\n\nThe organizer will use these N problems in the two contests.\nEach problem must be used in exactly one of the contests, and each contest must have at least one problem.\n\nThe joyfulness of each contest is the number of contestants who will solve all the problems in the contest.\nFind the maximum possible total joyfulness of the two contests.\n\nConstraints\n\n2 \\leq N \\leq 10^5\n\n1 \\leq L_i \\leq R_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nL_1 R_1\nL_2 R_2\n\\vdots\nL_N R_N\n\nOutput\n\nPrint the maximum possible total joyfulness of the two contests.\n\nSample Input 1\n\n4\n4 7\n1 4\n5 8\n2 5\n\nSample Output 1\n\n6\n\nThe optimal choice is:\n\nUse Problem 1 and 3 in the first contest. Contestant 5, 6, and 7 will solve both of them, so the joyfulness of this contest is 3.\n\nUse Problem 2 and 4 in the second contest. Contestant 2, 3, and 4 will solve both of them, so the joyfulness of this contest is 3.\n\nThe total joyfulness of these two contests is 6. We cannot make the total joyfulness greater than 6.\n\nSample Input 2\n\n4\n1 20\n2 19\n3 18\n4 17\n\nSample Output 2\n\n34\n\nSample Input 3\n\n10\n457835016 996058008\n456475528 529149798\n455108441 512701454\n455817105 523506955\n457368248 814532746\n455073228 459494089\n456651538 774276744\n457667152 974637457\n457293701 800549465\n456580262 636471526\n\nSample Output 3\n\n540049931", "sample_input": "4\n4 7\n1 4\n5 8\n2 5\n"}, "reference_outputs": ["6\n"], "source_document_id": "p02874", "source_text": "Score : 600 points\n\nProblem Statement\n\n10^9 contestants, numbered 1 to 10^9, will compete in a competition.\nThere will be two contests in this competition.\n\nThe organizer prepared N problems, numbered 1 to N, to use in these contests.\nWhen Problem i is presented in a contest, it will be solved by all contestants from Contestant L_i to Contestant R_i (inclusive), and will not be solved by any other contestants.\n\nThe organizer will use these N problems in the two contests.\nEach problem must be used in exactly one of the contests, and each contest must have at least one problem.\n\nThe joyfulness of each contest is the number of contestants who will solve all the problems in the contest.\nFind the maximum possible total joyfulness of the two contests.\n\nConstraints\n\n2 \\leq N \\leq 10^5\n\n1 \\leq L_i \\leq R_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nL_1 R_1\nL_2 R_2\n\\vdots\nL_N R_N\n\nOutput\n\nPrint the maximum possible total joyfulness of the two contests.\n\nSample Input 1\n\n4\n4 7\n1 4\n5 8\n2 5\n\nSample Output 1\n\n6\n\nThe optimal choice is:\n\nUse Problem 1 and 3 in the first contest. Contestant 5, 6, and 7 will solve both of them, so the joyfulness of this contest is 3.\n\nUse Problem 2 and 4 in the second contest. Contestant 2, 3, and 4 will solve both of them, so the joyfulness of this contest is 3.\n\nThe total joyfulness of these two contests is 6. We cannot make the total joyfulness greater than 6.\n\nSample Input 2\n\n4\n1 20\n2 19\n3 18\n4 17\n\nSample Output 2\n\n34\n\nSample Input 3\n\n10\n457835016 996058008\n456475528 529149798\n455108441 512701454\n455817105 523506955\n457368248 814532746\n455073228 459494089\n456651538 774276744\n457667152 974637457\n457293701 800549465\n456580262 636471526\n\nSample Output 3\n\n540049931", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 969, "cpu_time_ms": 423, "memory_kb": 16376}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s847694531", "group_id": "codeNet:p02880", "input_text": "N=io.read\"*n\"\nprint((function()\n\tfor i=1,9 do\n\t\tlocal a=N/i\n\t\tif(a==math.floor(a)and 1<=a and a<=9)then return true end\n\tend\nreturn false end)()and\"Yes\"or\"No\")", "language": "Lua", "metadata": {"date": 1587859849, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p02880.html", "problem_id": "p02880", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02880/input.txt", "sample_output_relpath": "derived/input_output/data/p02880/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02880/Lua/s847694531.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s847694531", "user_id": "u726173718"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "N=io.read\"*n\"\nprint((function()\n\tfor i=1,9 do\n\t\tlocal a=N/i\n\t\tif(a==math.floor(a)and 1<=a and a<=9)then return true end\n\tend\nreturn false end)()and\"Yes\"or\"No\")", "problem_context": "Score : 200 points\n\nProblem Statement\n\nHaving learned the multiplication table, Takahashi can multiply two integers between 1 and 9 (inclusive) together.\n\nGiven an integer N, determine whether N can be represented as the product of two integers between 1 and 9. If it can, print Yes; if it cannot, print No.\n\nConstraints\n\n1 \\leq N \\leq 100\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nIf N can be represented as the product of two integers between 1 and 9 (inclusive), print Yes; if it cannot, print No.\n\nSample Input 1\n\n10\n\nSample Output 1\n\nYes\n\n10 can be represented as, for example, 2 \\times 5.\n\nSample Input 2\n\n50\n\nSample Output 2\n\nNo\n\n50 cannot be represented as the product of two integers between 1 and 9.\n\nSample Input 3\n\n81\n\nSample Output 3\n\nYes", "sample_input": "10\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p02880", "source_text": "Score : 200 points\n\nProblem Statement\n\nHaving learned the multiplication table, Takahashi can multiply two integers between 1 and 9 (inclusive) together.\n\nGiven an integer N, determine whether N can be represented as the product of two integers between 1 and 9. If it can, print Yes; if it cannot, print No.\n\nConstraints\n\n1 \\leq N \\leq 100\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nIf N can be represented as the product of two integers between 1 and 9 (inclusive), print Yes; if it cannot, print No.\n\nSample Input 1\n\n10\n\nSample Output 1\n\nYes\n\n10 can be represented as, for example, 2 \\times 5.\n\nSample Input 2\n\n50\n\nSample Output 2\n\nNo\n\n50 cannot be represented as the product of two integers between 1 and 9.\n\nSample Input 3\n\n81\n\nSample Output 3\n\nYes", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 159, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s856823476", "group_id": "codeNet:p02880", "input_text": "local n=io.read(\"*n\")\nfor i=1,9 do\n for j=1,9 do\n if i*j==n then\n return print(\"Yes\")\n end\n end\nend\nprint(\"No\")", "language": "Lua", "metadata": {"date": 1576557097, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p02880.html", "problem_id": "p02880", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02880/input.txt", "sample_output_relpath": "derived/input_output/data/p02880/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02880/Lua/s856823476.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s856823476", "user_id": "u373958718"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "local n=io.read(\"*n\")\nfor i=1,9 do\n for j=1,9 do\n if i*j==n then\n return print(\"Yes\")\n end\n end\nend\nprint(\"No\")", "problem_context": "Score : 200 points\n\nProblem Statement\n\nHaving learned the multiplication table, Takahashi can multiply two integers between 1 and 9 (inclusive) together.\n\nGiven an integer N, determine whether N can be represented as the product of two integers between 1 and 9. If it can, print Yes; if it cannot, print No.\n\nConstraints\n\n1 \\leq N \\leq 100\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nIf N can be represented as the product of two integers between 1 and 9 (inclusive), print Yes; if it cannot, print No.\n\nSample Input 1\n\n10\n\nSample Output 1\n\nYes\n\n10 can be represented as, for example, 2 \\times 5.\n\nSample Input 2\n\n50\n\nSample Output 2\n\nNo\n\n50 cannot be represented as the product of two integers between 1 and 9.\n\nSample Input 3\n\n81\n\nSample Output 3\n\nYes", "sample_input": "10\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p02880", "source_text": "Score : 200 points\n\nProblem Statement\n\nHaving learned the multiplication table, Takahashi can multiply two integers between 1 and 9 (inclusive) together.\n\nGiven an integer N, determine whether N can be represented as the product of two integers between 1 and 9. If it can, print Yes; if it cannot, print No.\n\nConstraints\n\n1 \\leq N \\leq 100\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nIf N can be represented as the product of two integers between 1 and 9 (inclusive), print Yes; if it cannot, print No.\n\nSample Input 1\n\n10\n\nSample Output 1\n\nYes\n\n10 can be represented as, for example, 2 \\times 5.\n\nSample Input 2\n\n50\n\nSample Output 2\n\nNo\n\n50 cannot be represented as the product of two integers between 1 and 9.\n\nSample Input 3\n\n81\n\nSample Output 3\n\nYes", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 124, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s915394939", "group_id": "codeNet:p02880", "input_text": " n=io.read(\"*n\")\n \tcnt=0\n for i=1, 9 do\n if n%i==0 and n/i<10 then\n print(\"Yes\")\n \tcnt=1\n end\n end\n if not(cnt==1) then\n print(\"No\")\n end", "language": "Lua", "metadata": {"date": 1572225539, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p02880.html", "problem_id": "p02880", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02880/input.txt", "sample_output_relpath": "derived/input_output/data/p02880/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02880/Lua/s915394939.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s915394939", "user_id": "u535423069"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": " n=io.read(\"*n\")\n \tcnt=0\n for i=1, 9 do\n if n%i==0 and n/i<10 then\n print(\"Yes\")\n \tcnt=1\n end\n end\n if not(cnt==1) then\n print(\"No\")\n end", "problem_context": "Score : 200 points\n\nProblem Statement\n\nHaving learned the multiplication table, Takahashi can multiply two integers between 1 and 9 (inclusive) together.\n\nGiven an integer N, determine whether N can be represented as the product of two integers between 1 and 9. If it can, print Yes; if it cannot, print No.\n\nConstraints\n\n1 \\leq N \\leq 100\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nIf N can be represented as the product of two integers between 1 and 9 (inclusive), print Yes; if it cannot, print No.\n\nSample Input 1\n\n10\n\nSample Output 1\n\nYes\n\n10 can be represented as, for example, 2 \\times 5.\n\nSample Input 2\n\n50\n\nSample Output 2\n\nNo\n\n50 cannot be represented as the product of two integers between 1 and 9.\n\nSample Input 3\n\n81\n\nSample Output 3\n\nYes", "sample_input": "10\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p02880", "source_text": "Score : 200 points\n\nProblem Statement\n\nHaving learned the multiplication table, Takahashi can multiply two integers between 1 and 9 (inclusive) together.\n\nGiven an integer N, determine whether N can be represented as the product of two integers between 1 and 9. If it can, print Yes; if it cannot, print No.\n\nConstraints\n\n1 \\leq N \\leq 100\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nIf N can be represented as the product of two integers between 1 and 9 (inclusive), print Yes; if it cannot, print No.\n\nSample Input 1\n\n10\n\nSample Output 1\n\nYes\n\n10 can be represented as, for example, 2 \\times 5.\n\nSample Input 2\n\n50\n\nSample Output 2\n\nNo\n\n50 cannot be represented as the product of two integers between 1 and 9.\n\nSample Input 3\n\n81\n\nSample Output 3\n\nYes", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 208, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s718829292", "group_id": "codeNet:p02881", "input_text": "local n=io.read(\"*n\")\nfor i=math.ceil(math.sqrt(n)),1,-1 do\n if n%i==0 then\n return print(math.floor(i+n/i-2))\n end\nend", "language": "Lua", "metadata": {"date": 1576558605, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p02881.html", "problem_id": "p02881", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02881/input.txt", "sample_output_relpath": "derived/input_output/data/p02881/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02881/Lua/s718829292.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s718829292", "user_id": "u373958718"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "local n=io.read(\"*n\")\nfor i=math.ceil(math.sqrt(n)),1,-1 do\n if n%i==0 then\n return print(math.floor(i+n/i-2))\n end\nend", "problem_context": "Score : 300 points\n\nProblem Statement\n\nTakahashi is standing on a multiplication table with infinitely many rows and columns.\n\nThe square (i,j) contains the integer i \\times j. Initially, Takahashi is standing at (1,1).\n\nIn one move, he can move from (i,j) to either (i+1,j) or (i,j+1).\n\nGiven an integer N, find the minimum number of moves needed to reach a square that contains N.\n\nConstraints\n\n2 \\leq N \\leq 10^{12}\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the minimum number of moves needed to reach a square that contains the integer N.\n\nSample Input 1\n\n10\n\nSample Output 1\n\n5\n\n(2,5) can be reached in five moves. We cannot reach a square that contains 10 in less than five moves.\n\nSample Input 2\n\n50\n\nSample Output 2\n\n13\n\n(5, 10) can be reached in 13 moves.\n\nSample Input 3\n\n10000000019\n\nSample Output 3\n\n10000000018\n\nBoth input and output may be enormous.", "sample_input": "10\n"}, "reference_outputs": ["5\n"], "source_document_id": "p02881", "source_text": "Score : 300 points\n\nProblem Statement\n\nTakahashi is standing on a multiplication table with infinitely many rows and columns.\n\nThe square (i,j) contains the integer i \\times j. Initially, Takahashi is standing at (1,1).\n\nIn one move, he can move from (i,j) to either (i+1,j) or (i,j+1).\n\nGiven an integer N, find the minimum number of moves needed to reach a square that contains N.\n\nConstraints\n\n2 \\leq N \\leq 10^{12}\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the minimum number of moves needed to reach a square that contains the integer N.\n\nSample Input 1\n\n10\n\nSample Output 1\n\n5\n\n(2,5) can be reached in five moves. We cannot reach a square that contains 10 in less than five moves.\n\nSample Input 2\n\n50\n\nSample Output 2\n\n13\n\n(5, 10) can be reached in 13 moves.\n\nSample Input 3\n\n10000000019\n\nSample Output 3\n\n10000000018\n\nBoth input and output may be enormous.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 124, "cpu_time_ms": 34, "memory_kb": 256}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s730827092", "group_id": "codeNet:p02881", "input_text": "local n=io.read(\"*n\")\nfor i=math.ceil(math.sqrt(n)),1,-1 do\n if n%i==0 then\n return print(math.floor(i+n/i-2))\n end\nend", "language": "Lua", "metadata": {"date": 1576558591, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p02881.html", "problem_id": "p02881", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02881/input.txt", "sample_output_relpath": "derived/input_output/data/p02881/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02881/Lua/s730827092.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s730827092", "user_id": "u373958718"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "local n=io.read(\"*n\")\nfor i=math.ceil(math.sqrt(n)),1,-1 do\n if n%i==0 then\n return print(math.floor(i+n/i-2))\n end\nend", "problem_context": "Score : 300 points\n\nProblem Statement\n\nTakahashi is standing on a multiplication table with infinitely many rows and columns.\n\nThe square (i,j) contains the integer i \\times j. Initially, Takahashi is standing at (1,1).\n\nIn one move, he can move from (i,j) to either (i+1,j) or (i,j+1).\n\nGiven an integer N, find the minimum number of moves needed to reach a square that contains N.\n\nConstraints\n\n2 \\leq N \\leq 10^{12}\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the minimum number of moves needed to reach a square that contains the integer N.\n\nSample Input 1\n\n10\n\nSample Output 1\n\n5\n\n(2,5) can be reached in five moves. We cannot reach a square that contains 10 in less than five moves.\n\nSample Input 2\n\n50\n\nSample Output 2\n\n13\n\n(5, 10) can be reached in 13 moves.\n\nSample Input 3\n\n10000000019\n\nSample Output 3\n\n10000000018\n\nBoth input and output may be enormous.", "sample_input": "10\n"}, "reference_outputs": ["5\n"], "source_document_id": "p02881", "source_text": "Score : 300 points\n\nProblem Statement\n\nTakahashi is standing on a multiplication table with infinitely many rows and columns.\n\nThe square (i,j) contains the integer i \\times j. Initially, Takahashi is standing at (1,1).\n\nIn one move, he can move from (i,j) to either (i+1,j) or (i,j+1).\n\nGiven an integer N, find the minimum number of moves needed to reach a square that contains N.\n\nConstraints\n\n2 \\leq N \\leq 10^{12}\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the minimum number of moves needed to reach a square that contains the integer N.\n\nSample Input 1\n\n10\n\nSample Output 1\n\n5\n\n(2,5) can be reached in five moves. We cannot reach a square that contains 10 in less than five moves.\n\nSample Input 2\n\n50\n\nSample Output 2\n\n13\n\n(5, 10) can be reached in 13 moves.\n\nSample Input 3\n\n10000000019\n\nSample Output 3\n\n10000000018\n\nBoth input and output may be enormous.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 124, "cpu_time_ms": 6, "memory_kb": 256}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s403937659", "group_id": "codeNet:p02881", "input_text": "local n = io.read(\"*n\")\nfor i = math.ceil(math.sqrt(n)), 1, -1 do\n if n % i == 0 then\n print(i + (n // i) - 2)\n break\n end\nend\n", "language": "Lua", "metadata": {"date": 1572317111, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p02881.html", "problem_id": "p02881", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02881/input.txt", "sample_output_relpath": "derived/input_output/data/p02881/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02881/Lua/s403937659.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s403937659", "user_id": "u120582723"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "local n = io.read(\"*n\")\nfor i = math.ceil(math.sqrt(n)), 1, -1 do\n if n % i == 0 then\n print(i + (n // i) - 2)\n break\n end\nend\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nTakahashi is standing on a multiplication table with infinitely many rows and columns.\n\nThe square (i,j) contains the integer i \\times j. Initially, Takahashi is standing at (1,1).\n\nIn one move, he can move from (i,j) to either (i+1,j) or (i,j+1).\n\nGiven an integer N, find the minimum number of moves needed to reach a square that contains N.\n\nConstraints\n\n2 \\leq N \\leq 10^{12}\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the minimum number of moves needed to reach a square that contains the integer N.\n\nSample Input 1\n\n10\n\nSample Output 1\n\n5\n\n(2,5) can be reached in five moves. We cannot reach a square that contains 10 in less than five moves.\n\nSample Input 2\n\n50\n\nSample Output 2\n\n13\n\n(5, 10) can be reached in 13 moves.\n\nSample Input 3\n\n10000000019\n\nSample Output 3\n\n10000000018\n\nBoth input and output may be enormous.", "sample_input": "10\n"}, "reference_outputs": ["5\n"], "source_document_id": "p02881", "source_text": "Score : 300 points\n\nProblem Statement\n\nTakahashi is standing on a multiplication table with infinitely many rows and columns.\n\nThe square (i,j) contains the integer i \\times j. Initially, Takahashi is standing at (1,1).\n\nIn one move, he can move from (i,j) to either (i+1,j) or (i,j+1).\n\nGiven an integer N, find the minimum number of moves needed to reach a square that contains N.\n\nConstraints\n\n2 \\leq N \\leq 10^{12}\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the minimum number of moves needed to reach a square that contains the integer N.\n\nSample Input 1\n\n10\n\nSample Output 1\n\n5\n\n(2,5) can be reached in five moves. We cannot reach a square that contains 10 in less than five moves.\n\nSample Input 2\n\n50\n\nSample Output 2\n\n13\n\n(5, 10) can be reached in 13 moves.\n\nSample Input 3\n\n10000000019\n\nSample Output 3\n\n10000000018\n\nBoth input and output may be enormous.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 135, "cpu_time_ms": 34, "memory_kb": 760}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s554145155", "group_id": "codeNet:p02882", "input_text": "local a,b,x=io.read(\"n\",\"n\",\"n\")\nprint(x>a^2*b/2 and math.atan(2*(a^2*b-x)/a^3)*180/math.pi or math.atan((a*b^2)/(2*x))*180/math.pi)", "language": "Lua", "metadata": {"date": 1590978689, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p02882.html", "problem_id": "p02882", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02882/input.txt", "sample_output_relpath": "derived/input_output/data/p02882/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02882/Lua/s554145155.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s554145155", "user_id": "u045238009"}, "prompt_components": {"gold_output": "45.0000000000\n", "input_to_evaluate": "local a,b,x=io.read(\"n\",\"n\",\"n\")\nprint(x>a^2*b/2 and math.atan(2*(a^2*b-x)/a^3)*180/math.pi or math.atan((a*b^2)/(2*x))*180/math.pi)", "problem_context": "Score : 400 points\n\nProblem Statement\n\nTakahashi has a water bottle with the shape of a rectangular prism whose base is a square of side a~\\mathrm{cm} and whose height is b~\\mathrm{cm}. (The thickness of the bottle can be ignored.)\n\nWe will pour x~\\mathrm{cm}^3 of water into the bottle, and gradually tilt the bottle around one of the sides of the base.\n\nWhen will the water be spilled? More formally, find the maximum angle in which we can tilt the bottle without spilling any water.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq a \\leq 100\n\n1 \\leq b \\leq 100\n\n1 \\leq x \\leq a^2b\n\nInput\n\nInput is given from Standard Input in the following format:\n\na b x\n\nOutput\n\nPrint the maximum angle in which we can tilt the bottle without spilling any water, in degrees.\nYour output will be judged as correct when the absolute or relative error from the judge's output is at most 10^{-6}.\n\nSample Input 1\n\n2 2 4\n\nSample Output 1\n\n45.0000000000\n\nThis bottle has a cubic shape, and it is half-full. The water gets spilled when we tilt the bottle more than 45 degrees.\n\nSample Input 2\n\n12 21 10\n\nSample Output 2\n\n89.7834636934\n\nThis bottle is almost empty. When the water gets spilled, the bottle is nearly horizontal.\n\nSample Input 3\n\n3 1 8\n\nSample Output 3\n\n4.2363947991\n\nThis bottle is almost full. When the water gets spilled, the bottle is still nearly vertical.", "sample_input": "2 2 4\n"}, "reference_outputs": ["45.0000000000\n"], "source_document_id": "p02882", "source_text": "Score : 400 points\n\nProblem Statement\n\nTakahashi has a water bottle with the shape of a rectangular prism whose base is a square of side a~\\mathrm{cm} and whose height is b~\\mathrm{cm}. (The thickness of the bottle can be ignored.)\n\nWe will pour x~\\mathrm{cm}^3 of water into the bottle, and gradually tilt the bottle around one of the sides of the base.\n\nWhen will the water be spilled? More formally, find the maximum angle in which we can tilt the bottle without spilling any water.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq a \\leq 100\n\n1 \\leq b \\leq 100\n\n1 \\leq x \\leq a^2b\n\nInput\n\nInput is given from Standard Input in the following format:\n\na b x\n\nOutput\n\nPrint the maximum angle in which we can tilt the bottle without spilling any water, in degrees.\nYour output will be judged as correct when the absolute or relative error from the judge's output is at most 10^{-6}.\n\nSample Input 1\n\n2 2 4\n\nSample Output 1\n\n45.0000000000\n\nThis bottle has a cubic shape, and it is half-full. The water gets spilled when we tilt the bottle more than 45 degrees.\n\nSample Input 2\n\n12 21 10\n\nSample Output 2\n\n89.7834636934\n\nThis bottle is almost empty. When the water gets spilled, the bottle is nearly horizontal.\n\nSample Input 3\n\n3 1 8\n\nSample Output 3\n\n4.2363947991\n\nThis bottle is almost full. When the water gets spilled, the bottle is still nearly vertical.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 132, "cpu_time_ms": 7, "memory_kb": 760}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s680710088", "group_id": "codeNet:p02883", "input_text": "local read = setmetatable({}, {__index = function(t, k) local a = {} for i=1,#k do table.insert(a, '*'..string.sub(k, i, i)) end local r = io.read local u = table.unpack or unpack return function() return r(u(a)) end end})\nread.N = function(N) local t={} for i=1,N do t[i]=read.n() end return t end\nstring.totable = function(s) local t={} local u=string.sub for i=1,#s do t[i] = u(s, i, i) end return t end\nstring.split = function(s) local t={} for w in string.gmatch(s, \"[^%s]+\") do table.insert(t, w) end return (table.unpack or unpack)(t) end\n--\nlocal function find_min_true(n, f)\n -- Define f(-1) == false, f(n) == true\n -- Invariant: f(left) == false and f(right) == true\n local left = -1\n local right = n\n while right - left > 1 do\n local m = left + (right - left) // 2\n if f(m) then\n right = m -- keep f(right) == true\n else\n left = m -- keep f(left) == false\n end\n end\n return right\nend\n---\nlocal N, K = read.nn()\nlocal A = read.N(N)\nlocal F = read.N(N)\ntable.sort(A)\ntable.sort(F, function(x,y)return x>y end)\nlocal upper_lim = A[N] * F[1]\n\nlocal function possible(max_time)\n local kk = K\n for i=1, N do\n local time = A[i] * F[i]\n if time > max_time then\n local train_cost = math.ceil((A[i] * F[i] - max_time) / F[i])\n kk = kk - train_cost\n if kk < 0 then\n return false\n end\n end\n end\n return true\nend\nprint(find_min_true(upper_lim, possible))\n", "language": "Lua", "metadata": {"date": 1572408672, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p02883.html", "problem_id": "p02883", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02883/input.txt", "sample_output_relpath": "derived/input_output/data/p02883/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02883/Lua/s680710088.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s680710088", "user_id": "u162773977"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "local read = setmetatable({}, {__index = function(t, k) local a = {} for i=1,#k do table.insert(a, '*'..string.sub(k, i, i)) end local r = io.read local u = table.unpack or unpack return function() return r(u(a)) end end})\nread.N = function(N) local t={} for i=1,N do t[i]=read.n() end return t end\nstring.totable = function(s) local t={} local u=string.sub for i=1,#s do t[i] = u(s, i, i) end return t end\nstring.split = function(s) local t={} for w in string.gmatch(s, \"[^%s]+\") do table.insert(t, w) end return (table.unpack or unpack)(t) end\n--\nlocal function find_min_true(n, f)\n -- Define f(-1) == false, f(n) == true\n -- Invariant: f(left) == false and f(right) == true\n local left = -1\n local right = n\n while right - left > 1 do\n local m = left + (right - left) // 2\n if f(m) then\n right = m -- keep f(right) == true\n else\n left = m -- keep f(left) == false\n end\n end\n return right\nend\n---\nlocal N, K = read.nn()\nlocal A = read.N(N)\nlocal F = read.N(N)\ntable.sort(A)\ntable.sort(F, function(x,y)return x>y end)\nlocal upper_lim = A[N] * F[1]\n\nlocal function possible(max_time)\n local kk = K\n for i=1, N do\n local time = A[i] * F[i]\n if time > max_time then\n local train_cost = math.ceil((A[i] * F[i] - max_time) / F[i])\n kk = kk - train_cost\n if kk < 0 then\n return false\n end\n end\n end\n return true\nend\nprint(find_min_true(upper_lim, possible))\n", "problem_context": "Score: 500 points\n\nProblem Statement\n\nTakahashi will take part in an eating contest. Teams of N members will compete in this contest, and Takahashi's team consists of N players numbered 1 through N from youngest to oldest. The consumption coefficient of Member i is A_i.\n\nIn the contest, N foods numbered 1 through N will be presented, and the difficulty of Food i is F_i. The details of the contest are as follows:\n\nA team should assign one member to each food, and should not assign the same member to multiple foods.\n\nIt will take x \\times y seconds for a member to finish the food, where x is the consumption coefficient of the member and y is the difficulty of the dish.\n\nThe score of a team is the longest time it takes for an individual member to finish the food.\n\nBefore the contest, Takahashi's team decided to do some training. In one set of training, a member can reduce his/her consumption coefficient by 1, as long as it does not go below 0. However, for financial reasons, the N members can do at most K sets of training in total.\n\nWhat is the minimum possible score of the team, achieved by choosing the amounts of members' training and allocating the dishes optimally?\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 2 \\times 10^5\n\n0 \\leq K \\leq 10^{18}\n\n1 \\leq A_i \\leq 10^6\\ (1 \\leq i \\leq N)\n\n1 \\leq F_i \\leq 10^6\\ (1 \\leq i \\leq N)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nA_1 A_2 ... A_N\nF_1 F_2 ... F_N\n\nOutput\n\nPrint the minimum possible score of the team.\n\nSample Input 1\n\n3 5\n4 2 1\n2 3 1\n\nSample Output 1\n\n2\n\nThey can achieve the score of 2, as follows:\n\nMember 1 does 4 sets of training and eats Food 2 in (4-4) \\times 3 = 0 seconds.\n\nMember 2 does 1 set of training and eats Food 3 in (2-1) \\times 1 = 1 second.\n\nMember 3 does 0 sets of training and eats Food 1 in (1-0) \\times 2 = 2 seconds.\n\nThey cannot achieve a score of less than 2, so the answer is 2.\n\nSample Input 2\n\n3 8\n4 2 1\n2 3 1\n\nSample Output 2\n\n0\n\nThey can choose not to do exactly K sets of training.\n\nSample Input 3\n\n11 14\n3 1 4 1 5 9 2 6 5 3 5\n8 9 7 9 3 2 3 8 4 6 2\n\nSample Output 3\n\n12", "sample_input": "3 5\n4 2 1\n2 3 1\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02883", "source_text": "Score: 500 points\n\nProblem Statement\n\nTakahashi will take part in an eating contest. Teams of N members will compete in this contest, and Takahashi's team consists of N players numbered 1 through N from youngest to oldest. The consumption coefficient of Member i is A_i.\n\nIn the contest, N foods numbered 1 through N will be presented, and the difficulty of Food i is F_i. The details of the contest are as follows:\n\nA team should assign one member to each food, and should not assign the same member to multiple foods.\n\nIt will take x \\times y seconds for a member to finish the food, where x is the consumption coefficient of the member and y is the difficulty of the dish.\n\nThe score of a team is the longest time it takes for an individual member to finish the food.\n\nBefore the contest, Takahashi's team decided to do some training. In one set of training, a member can reduce his/her consumption coefficient by 1, as long as it does not go below 0. However, for financial reasons, the N members can do at most K sets of training in total.\n\nWhat is the minimum possible score of the team, achieved by choosing the amounts of members' training and allocating the dishes optimally?\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 2 \\times 10^5\n\n0 \\leq K \\leq 10^{18}\n\n1 \\leq A_i \\leq 10^6\\ (1 \\leq i \\leq N)\n\n1 \\leq F_i \\leq 10^6\\ (1 \\leq i \\leq N)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nA_1 A_2 ... A_N\nF_1 F_2 ... F_N\n\nOutput\n\nPrint the minimum possible score of the team.\n\nSample Input 1\n\n3 5\n4 2 1\n2 3 1\n\nSample Output 1\n\n2\n\nThey can achieve the score of 2, as follows:\n\nMember 1 does 4 sets of training and eats Food 2 in (4-4) \\times 3 = 0 seconds.\n\nMember 2 does 1 set of training and eats Food 3 in (2-1) \\times 1 = 1 second.\n\nMember 3 does 0 sets of training and eats Food 1 in (1-0) \\times 2 = 2 seconds.\n\nThey cannot achieve a score of less than 2, so the answer is 2.\n\nSample Input 2\n\n3 8\n4 2 1\n2 3 1\n\nSample Output 2\n\n0\n\nThey can choose not to do exactly K sets of training.\n\nSample Input 3\n\n11 14\n3 1 4 1 5 9 2 6 5 3 5\n8 9 7 9 3 2 3 8 4 6 2\n\nSample Output 3\n\n12", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1516, "cpu_time_ms": 2106, "memory_kb": 33528}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s485781095", "group_id": "codeNet:p02883", "input_text": " n=io.read(\"*n\")\n k=io.read(\"*k\")\n \n a={}\n f={}\n \n for i=1, n do\n table.insert(a, io.read(\"*n\"))\n end\n for i=1, n do\n table.insert(f, io.read(\"*n\"))\n end\n \n table.sort(a)\n for i=1, n do\n if a[i]=k then\n a[i]=a[i]-k\n k=0\n break\n end\n end\n \n function maxpos(t, len)\n local p=1\n for i=1,len do\n if t[i]>t[p] then\n p=i\n end\n end\n \n \t\t\t return p \n end\n function minpos(t, len)\n local q=1\n for i=1,len do\n if t[i]=k then\n a[i]=a[i]-k\n k=0\n break\n end\n end\n \n function maxpos(t, len)\n local p=1\n for i=1,len do\n if t[i]>t[p] then\n p=i\n end\n end\n \n \t\t\t return p \n end\n function minpos(t, len)\n local q=1\n for i=1,len do\n if t[i]=ary[n] then\n return n+1\n end\n local min,max=1,n\n while 1=ary[mid] then\n min=mid\n else\n max=mid\n end\n end\n return max\nend\n\nn=io.read(\"*n\",\"*l\")\nl={}\nfor i=1,n do\n l[i]=io.read(\"*n\")\nend\ntable.sort(l)\ncounter=0\nfor i=n,3,-1 do\n large=l[i]\n for j=i-1,2,-1 do\n middle=l[j]\n if middle*2<=large then\n break\n end\n local smallmin=upper_bound(large-middle,l)\n if smallmin=ary[n] then\n return n+1\n end\n local min,max=1,n\n while 1=ary[mid] then\n min=mid\n else\n max=mid\n end\n end\n return max\nend\n\nn=io.read(\"*n\",\"*l\")\nl={}\nfor i=1,n do\n l[i]=io.read(\"*n\")\nend\ntable.sort(l)\ncounter=0\nfor i=n,3,-1 do\n large=l[i]\n for j=i-1,2,-1 do\n middle=l[j]\n if middle*2<=large then\n break\n end\n local smallmin=upper_bound(large-middle,l)\n if smallmin=k then\n counter=counter+1\n end\nend\nprint(counter)", "language": "Lua", "metadata": {"date": 1592142060, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p02898.html", "problem_id": "p02898", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02898/input.txt", "sample_output_relpath": "derived/input_output/data/p02898/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02898/Lua/s593786344.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s593786344", "user_id": "u045238009"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "local n,k=io.read(\"n\",\"n\")\nlocal counter=0\nfor i=1,n do\n local h=io.read(\"n\")\n if h>=k then\n counter=counter+1\n end\nend\nprint(counter)", "problem_context": "Score : 200 points\n\nProblem Statement\n\nN friends of Takahashi has come to a theme park.\n\nTo ride the most popular roller coaster in the park, you must be at least K centimeters tall.\n\nThe i-th friend is h_i centimeters tall.\n\nHow many of the Takahashi's friends can ride the roller coaster?\n\nConstraints\n\n1 \\le N \\le 10^5\n\n1 \\le K \\le 500\n\n1 \\le h_i \\le 500\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nh_1 h_2 \\ldots h_N\n\nOutput\n\nPrint the number of people among the Takahashi's friends who can ride the roller coaster.\n\nSample Input 1\n\n4 150\n150 140 100 200\n\nSample Output 1\n\n2\n\nTwo of them can ride the roller coaster: the first and fourth friends.\n\nSample Input 2\n\n1 500\n499\n\nSample Output 2\n\n0\n\nSample Input 3\n\n5 1\n100 200 300 400 500\n\nSample Output 3\n\n5", "sample_input": "4 150\n150 140 100 200\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02898", "source_text": "Score : 200 points\n\nProblem Statement\n\nN friends of Takahashi has come to a theme park.\n\nTo ride the most popular roller coaster in the park, you must be at least K centimeters tall.\n\nThe i-th friend is h_i centimeters tall.\n\nHow many of the Takahashi's friends can ride the roller coaster?\n\nConstraints\n\n1 \\le N \\le 10^5\n\n1 \\le K \\le 500\n\n1 \\le h_i \\le 500\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nh_1 h_2 \\ldots h_N\n\nOutput\n\nPrint the number of people among the Takahashi's friends who can ride the roller coaster.\n\nSample Input 1\n\n4 150\n150 140 100 200\n\nSample Output 1\n\n2\n\nTwo of them can ride the roller coaster: the first and fourth friends.\n\nSample Input 2\n\n1 500\n499\n\nSample Output 2\n\n0\n\nSample Input 3\n\n5 1\n100 200 300 400 500\n\nSample Output 3\n\n5", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 150, "cpu_time_ms": 23, "memory_kb": 256}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s885298301", "group_id": "codeNet:p02899", "input_text": "local read = setmetatable({}, {__index = function(t, k) local a = {} for i=1,#k do table.insert(a, string.sub(k, i, i)) end local r = io.read local u = table.unpack return function() return r(u(a)) end end})\nlocal N = read.n()\nlocal t = {}\nfor i=1,N do\n local a = io.read(\"n\")\n t[i] = {i, a}\nend\ntable.sort(t, function(x,y) return x[2] < y[2] end)\nlocal ans = {}\nfor i=1,N do\n ans[i] = t[i][1]\nend\nprint(table.concat(ans, \" \"))\n", "language": "Lua", "metadata": {"date": 1569719266, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p02899.html", "problem_id": "p02899", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02899/input.txt", "sample_output_relpath": "derived/input_output/data/p02899/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02899/Lua/s885298301.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s885298301", "user_id": "u162773977"}, "prompt_components": {"gold_output": "3 1 2\n", "input_to_evaluate": "local read = setmetatable({}, {__index = function(t, k) local a = {} for i=1,#k do table.insert(a, string.sub(k, i, i)) end local r = io.read local u = table.unpack return function() return r(u(a)) end end})\nlocal N = read.n()\nlocal t = {}\nfor i=1,N do\n local a = io.read(\"n\")\n t[i] = {i, a}\nend\ntable.sort(t, function(x,y) return x[2] < y[2] end)\nlocal ans = {}\nfor i=1,N do\n ans[i] = t[i][1]\nend\nprint(table.concat(ans, \" \"))\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nTakahashi is a teacher responsible for a class of N students.\n\nThe students are given distinct student numbers from 1 to N.\n\nToday, all the students entered the classroom at different times.\n\nAccording to Takahashi's record, there were A_i students in the classroom when student number i entered the classroom (including student number i).\n\nFrom these records, reconstruct the order in which the students entered the classroom.\n\nConstraints\n\n1 \\le N \\le 10^5\n\n1 \\le A_i \\le N\n\nA_i \\neq A_j (i \\neq j)\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 \\ldots A_N\n\nOutput\n\nPrint the student numbers of the students in the order the students entered the classroom.\n\nSample Input 1\n\n3\n2 3 1\n\nSample Output 1\n\n3 1 2\n\nFirst, student number 3 entered the classroom.\n\nThen, student number 1 entered the classroom.\n\nFinally, student number 2 entered the classroom.\n\nSample Input 2\n\n5\n1 2 3 4 5\n\nSample Output 2\n\n1 2 3 4 5\n\nSample Input 3\n\n8\n8 2 7 3 4 5 6 1\n\nSample Output 3\n\n8 2 4 5 6 7 3 1", "sample_input": "3\n2 3 1\n"}, "reference_outputs": ["3 1 2\n"], "source_document_id": "p02899", "source_text": "Score : 300 points\n\nProblem Statement\n\nTakahashi is a teacher responsible for a class of N students.\n\nThe students are given distinct student numbers from 1 to N.\n\nToday, all the students entered the classroom at different times.\n\nAccording to Takahashi's record, there were A_i students in the classroom when student number i entered the classroom (including student number i).\n\nFrom these records, reconstruct the order in which the students entered the classroom.\n\nConstraints\n\n1 \\le N \\le 10^5\n\n1 \\le A_i \\le N\n\nA_i \\neq A_j (i \\neq j)\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 \\ldots A_N\n\nOutput\n\nPrint the student numbers of the students in the order the students entered the classroom.\n\nSample Input 1\n\n3\n2 3 1\n\nSample Output 1\n\n3 1 2\n\nFirst, student number 3 entered the classroom.\n\nThen, student number 1 entered the classroom.\n\nFinally, student number 2 entered the classroom.\n\nSample Input 2\n\n5\n1 2 3 4 5\n\nSample Output 2\n\n1 2 3 4 5\n\nSample Input 3\n\n8\n8 2 7 3 4 5 6 1\n\nSample Output 3\n\n8 2 4 5 6 7 3 1", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 437, "cpu_time_ms": 326, "memory_kb": 22200}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s953382198", "group_id": "codeNet:p02899", "input_text": "local n = io.read(\"*n\")\nlocal t = {}\nfor i = 1, n do\n t[i] = {i, io.read(\"*n\")}\nend\ntable.sort(t, function(x, y) return x[2] < y[2] end)\nlocal s = {}\nfor i = 1, n do s[i] = t[i][1] end\nprint(table.concat(s, \" \"))\n", "language": "Lua", "metadata": {"date": 1569719016, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p02899.html", "problem_id": "p02899", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02899/input.txt", "sample_output_relpath": "derived/input_output/data/p02899/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02899/Lua/s953382198.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s953382198", "user_id": "u120582723"}, "prompt_components": {"gold_output": "3 1 2\n", "input_to_evaluate": "local n = io.read(\"*n\")\nlocal t = {}\nfor i = 1, n do\n t[i] = {i, io.read(\"*n\")}\nend\ntable.sort(t, function(x, y) return x[2] < y[2] end)\nlocal s = {}\nfor i = 1, n do s[i] = t[i][1] end\nprint(table.concat(s, \" \"))\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nTakahashi is a teacher responsible for a class of N students.\n\nThe students are given distinct student numbers from 1 to N.\n\nToday, all the students entered the classroom at different times.\n\nAccording to Takahashi's record, there were A_i students in the classroom when student number i entered the classroom (including student number i).\n\nFrom these records, reconstruct the order in which the students entered the classroom.\n\nConstraints\n\n1 \\le N \\le 10^5\n\n1 \\le A_i \\le N\n\nA_i \\neq A_j (i \\neq j)\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 \\ldots A_N\n\nOutput\n\nPrint the student numbers of the students in the order the students entered the classroom.\n\nSample Input 1\n\n3\n2 3 1\n\nSample Output 1\n\n3 1 2\n\nFirst, student number 3 entered the classroom.\n\nThen, student number 1 entered the classroom.\n\nFinally, student number 2 entered the classroom.\n\nSample Input 2\n\n5\n1 2 3 4 5\n\nSample Output 2\n\n1 2 3 4 5\n\nSample Input 3\n\n8\n8 2 7 3 4 5 6 1\n\nSample Output 3\n\n8 2 4 5 6 7 3 1", "sample_input": "3\n2 3 1\n"}, "reference_outputs": ["3 1 2\n"], "source_document_id": "p02899", "source_text": "Score : 300 points\n\nProblem Statement\n\nTakahashi is a teacher responsible for a class of N students.\n\nThe students are given distinct student numbers from 1 to N.\n\nToday, all the students entered the classroom at different times.\n\nAccording to Takahashi's record, there were A_i students in the classroom when student number i entered the classroom (including student number i).\n\nFrom these records, reconstruct the order in which the students entered the classroom.\n\nConstraints\n\n1 \\le N \\le 10^5\n\n1 \\le A_i \\le N\n\nA_i \\neq A_j (i \\neq j)\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 \\ldots A_N\n\nOutput\n\nPrint the student numbers of the students in the order the students entered the classroom.\n\nSample Input 1\n\n3\n2 3 1\n\nSample Output 1\n\n3 1 2\n\nFirst, student number 3 entered the classroom.\n\nThen, student number 1 entered the classroom.\n\nFinally, student number 2 entered the classroom.\n\nSample Input 2\n\n5\n1 2 3 4 5\n\nSample Output 2\n\n1 2 3 4 5\n\nSample Input 3\n\n8\n8 2 7 3 4 5 6 1\n\nSample Output 3\n\n8 2 4 5 6 7 3 1", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 214, "cpu_time_ms": 326, "memory_kb": 22200}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s990161907", "group_id": "codeNet:p02900", "input_text": "local function gcd(a,b)\n if b>0 then\n return gcd(b,a%b)\n else\n return a\n end\nend\n\nlocal x=gcd(io.read(\"n\",\"n\"))\n\nlocal counter=1\nfor i=2,math.sqrt(x) do\n if x%i==0 then\n while x%i==0 do\n x=x//i\n end\n counter=counter+1\n end\nend\nprint(x~=1 and counter+1 or counter)", "language": "Lua", "metadata": {"date": 1591512733, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p02900.html", "problem_id": "p02900", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02900/input.txt", "sample_output_relpath": "derived/input_output/data/p02900/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02900/Lua/s990161907.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s990161907", "user_id": "u045238009"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "local function gcd(a,b)\n if b>0 then\n return gcd(b,a%b)\n else\n return a\n end\nend\n\nlocal x=gcd(io.read(\"n\",\"n\"))\n\nlocal counter=1\nfor i=2,math.sqrt(x) do\n if x%i==0 then\n while x%i==0 do\n x=x//i\n end\n counter=counter+1\n end\nend\nprint(x~=1 and counter+1 or counter)", "problem_context": "Score : 400 points\n\nProblem Statement\n\nGiven are positive integers A and B.\n\nLet us choose some number of positive common divisors of A and B.\n\nHere, any two of the chosen divisors must be coprime.\n\nAt most, how many divisors can we choose?\n\nDefinition of common divisor\n\nAn integer d is said to be a common divisor of integers x and y when d divides both x and y.\n\nDefinition of being coprime\n\nIntegers x and y are said to be coprime when x and y have no positive common divisors other than 1.\n\nDefinition of dividing\n\nAn integer x is said to divide another integer y when there exists an integer \\alpha such that y = \\alpha x.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq A, B \\leq 10^{12}\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nPrint the maximum number of divisors that can be chosen to satisfy the condition.\n\nSample Input 1\n\n12 18\n\nSample Output 1\n\n3\n\n12 and 18 have the following positive common divisors: 1, 2, 3, and 6.\n\n1 and 2 are coprime, 2 and 3 are coprime, and 3 and 1 are coprime, so we can choose 1, 2, and 3, which achieve the maximum result.\n\nSample Input 2\n\n420 660\n\nSample Output 2\n\n4\n\nSample Input 3\n\n1 2019\n\nSample Output 3\n\n1\n\n1 and 2019 have no positive common divisors other than 1.", "sample_input": "12 18\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02900", "source_text": "Score : 400 points\n\nProblem Statement\n\nGiven are positive integers A and B.\n\nLet us choose some number of positive common divisors of A and B.\n\nHere, any two of the chosen divisors must be coprime.\n\nAt most, how many divisors can we choose?\n\nDefinition of common divisor\n\nAn integer d is said to be a common divisor of integers x and y when d divides both x and y.\n\nDefinition of being coprime\n\nIntegers x and y are said to be coprime when x and y have no positive common divisors other than 1.\n\nDefinition of dividing\n\nAn integer x is said to divide another integer y when there exists an integer \\alpha such that y = \\alpha x.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq A, B \\leq 10^{12}\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nPrint the maximum number of divisors that can be chosen to satisfy the condition.\n\nSample Input 1\n\n12 18\n\nSample Output 1\n\n3\n\n12 and 18 have the following positive common divisors: 1, 2, 3, and 6.\n\n1 and 2 are coprime, 2 and 3 are coprime, and 3 and 1 are coprime, so we can choose 1, 2, and 3, which achieve the maximum result.\n\nSample Input 2\n\n420 660\n\nSample Output 2\n\n4\n\nSample Input 3\n\n1 2019\n\nSample Output 3\n\n1\n\n1 and 2019 have no positive common divisors other than 1.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 324, "cpu_time_ms": 35, "memory_kb": 888}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s040025474", "group_id": "codeNet:p02900", "input_text": "local x,y = io.read(\"*l\"):match(\"(%d+).(%d+)\")\nlocal numX,numY = tonumber(x),tonumber(y)\nlocal result = 1\n\nlocal function FindFactors(numZ)\n local arr = {}\n for i = 2, numZ do\n local check = false\n while numZ % i == 0 do\n numZ = numZ // i\n check = true\n end\n if check then\n table.insert(arr,1,i)\n end\n end\n return arr\nend\n\nlocal arrX = FindFactors(numX)\nlocal arrY = FindFactors(numY)\n\nfor i=1,#arrX do\n for j=1,#arrY do\n if arrX[i] == arrY[j] then\n result = result + 1\n end\n end\nend\nprint(result)", "language": "Lua", "metadata": {"date": 1569724270, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p02900.html", "problem_id": "p02900", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02900/input.txt", "sample_output_relpath": "derived/input_output/data/p02900/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02900/Lua/s040025474.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s040025474", "user_id": "u959346025"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "local x,y = io.read(\"*l\"):match(\"(%d+).(%d+)\")\nlocal numX,numY = tonumber(x),tonumber(y)\nlocal result = 1\n\nlocal function FindFactors(numZ)\n local arr = {}\n for i = 2, numZ do\n local check = false\n while numZ % i == 0 do\n numZ = numZ // i\n check = true\n end\n if check then\n table.insert(arr,1,i)\n end\n end\n return arr\nend\n\nlocal arrX = FindFactors(numX)\nlocal arrY = FindFactors(numY)\n\nfor i=1,#arrX do\n for j=1,#arrY do\n if arrX[i] == arrY[j] then\n result = result + 1\n end\n end\nend\nprint(result)", "problem_context": "Score : 400 points\n\nProblem Statement\n\nGiven are positive integers A and B.\n\nLet us choose some number of positive common divisors of A and B.\n\nHere, any two of the chosen divisors must be coprime.\n\nAt most, how many divisors can we choose?\n\nDefinition of common divisor\n\nAn integer d is said to be a common divisor of integers x and y when d divides both x and y.\n\nDefinition of being coprime\n\nIntegers x and y are said to be coprime when x and y have no positive common divisors other than 1.\n\nDefinition of dividing\n\nAn integer x is said to divide another integer y when there exists an integer \\alpha such that y = \\alpha x.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq A, B \\leq 10^{12}\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nPrint the maximum number of divisors that can be chosen to satisfy the condition.\n\nSample Input 1\n\n12 18\n\nSample Output 1\n\n3\n\n12 and 18 have the following positive common divisors: 1, 2, 3, and 6.\n\n1 and 2 are coprime, 2 and 3 are coprime, and 3 and 1 are coprime, so we can choose 1, 2, and 3, which achieve the maximum result.\n\nSample Input 2\n\n420 660\n\nSample Output 2\n\n4\n\nSample Input 3\n\n1 2019\n\nSample Output 3\n\n1\n\n1 and 2019 have no positive common divisors other than 1.", "sample_input": "12 18\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02900", "source_text": "Score : 400 points\n\nProblem Statement\n\nGiven are positive integers A and B.\n\nLet us choose some number of positive common divisors of A and B.\n\nHere, any two of the chosen divisors must be coprime.\n\nAt most, how many divisors can we choose?\n\nDefinition of common divisor\n\nAn integer d is said to be a common divisor of integers x and y when d divides both x and y.\n\nDefinition of being coprime\n\nIntegers x and y are said to be coprime when x and y have no positive common divisors other than 1.\n\nDefinition of dividing\n\nAn integer x is said to divide another integer y when there exists an integer \\alpha such that y = \\alpha x.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq A, B \\leq 10^{12}\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nPrint the maximum number of divisors that can be chosen to satisfy the condition.\n\nSample Input 1\n\n12 18\n\nSample Output 1\n\n3\n\n12 and 18 have the following positive common divisors: 1, 2, 3, and 6.\n\n1 and 2 are coprime, 2 and 3 are coprime, and 3 and 1 are coprime, so we can choose 1, 2, and 3, which achieve the maximum result.\n\nSample Input 2\n\n420 660\n\nSample Output 2\n\n4\n\nSample Input 3\n\n1 2019\n\nSample Output 3\n\n1\n\n1 and 2019 have no positive common divisors other than 1.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 544, "cpu_time_ms": 2103, "memory_kb": 888}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s106308739", "group_id": "codeNet:p02901", "input_text": "local read = setmetatable({}, {__index = function(t, k) local a = {} for i=1,#k do table.insert(a, '*'..string.sub(k, i, i)) end local r = io.read local u = table.unpack or unpack return function() return r(u(a)) end end})\nread.N = function(N) local t={} for i=1,N do t[i]=read.n() end return t end\nstring.totable = function(s) local t={} local u=string.sub for i=1,#s do t[i] = u(s, i, i) end return t end\nstring.split = function(s) local t={} for w in string.gmatch(s, \"[^%s]+\") do table.insert(t, w) end return (table.unpack or unpack)(t) end\nlocal function array(dimension, default_val) local n=dimension local m={}if default_val~=nil then m[1]={__index=function()return default_val end}end for i=2,n do m[i]={__index=function(p, k)local c=setmetatable({},m[i-1])rawset(p,k,c)return c end}end return setmetatable({},m[n])end\n----\nlocal N, M = read.nn()\nlocal KCost = {}\nlocal KAbl = {}\nfor i=1,M do\n local a, b = read.nn()\n KCost[i] = a\n KAbl[i] = 0\n for j=1,b do\n local c = read.n()\n local bit = 1 << (c-1)\n KAbl[i] = KAbl[i] | bit\n end\nend\n\n\nlocal curset = 0\nlocal STATMAX = math.floor(2^N) - 1\n\nlocal INF = 10^9\nlocal cost = array(1, INF)\ncost[0] = 0\nlocal min = math.min\nlocal function chmin(s, val)\n cost[s] = min(cost[s], val)\nend\n\nfor stat=0,STATMAX do\n if cost[stat] ~= INF then\n for curkey=1,M do\n local newstat = stat | KAbl[curkey]\n chmin(newstat, cost[stat] + KCost[curkey])\n end\n end\nend\n\nif cost[STATMAX] == INF then\n print(\"-1\")\n return\nend\n\nprint(cost[STATMAX])\n", "language": "Lua", "metadata": {"date": 1582587389, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p02901.html", "problem_id": "p02901", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02901/input.txt", "sample_output_relpath": "derived/input_output/data/p02901/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02901/Lua/s106308739.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s106308739", "user_id": "u162773977"}, "prompt_components": {"gold_output": "25\n", "input_to_evaluate": "local read = setmetatable({}, {__index = function(t, k) local a = {} for i=1,#k do table.insert(a, '*'..string.sub(k, i, i)) end local r = io.read local u = table.unpack or unpack return function() return r(u(a)) end end})\nread.N = function(N) local t={} for i=1,N do t[i]=read.n() end return t end\nstring.totable = function(s) local t={} local u=string.sub for i=1,#s do t[i] = u(s, i, i) end return t end\nstring.split = function(s) local t={} for w in string.gmatch(s, \"[^%s]+\") do table.insert(t, w) end return (table.unpack or unpack)(t) end\nlocal function array(dimension, default_val) local n=dimension local m={}if default_val~=nil then m[1]={__index=function()return default_val end}end for i=2,n do m[i]={__index=function(p, k)local c=setmetatable({},m[i-1])rawset(p,k,c)return c end}end return setmetatable({},m[n])end\n----\nlocal N, M = read.nn()\nlocal KCost = {}\nlocal KAbl = {}\nfor i=1,M do\n local a, b = read.nn()\n KCost[i] = a\n KAbl[i] = 0\n for j=1,b do\n local c = read.n()\n local bit = 1 << (c-1)\n KAbl[i] = KAbl[i] | bit\n end\nend\n\n\nlocal curset = 0\nlocal STATMAX = math.floor(2^N) - 1\n\nlocal INF = 10^9\nlocal cost = array(1, INF)\ncost[0] = 0\nlocal min = math.min\nlocal function chmin(s, val)\n cost[s] = min(cost[s], val)\nend\n\nfor stat=0,STATMAX do\n if cost[stat] ~= INF then\n for curkey=1,M do\n local newstat = stat | KAbl[curkey]\n chmin(newstat, cost[stat] + KCost[curkey])\n end\n end\nend\n\nif cost[STATMAX] == INF then\n print(\"-1\")\n return\nend\n\nprint(cost[STATMAX])\n", "problem_context": "Score : 500 points\n\nProblem Statement\n\nWe have N locked treasure boxes, numbered 1 to N.\n\nA shop sells M keys. The i-th key is sold for a_i yen (the currency of Japan), and it can unlock b_i of the boxes: Box c_{i1}, c_{i2}, ..., c_{i{b_i}}. Each key purchased can be used any number of times.\n\nFind the minimum cost required to unlock all the treasure boxes. If it is impossible to unlock all of them, print -1.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 12\n\n1 \\leq M \\leq 10^3\n\n1 \\leq a_i \\leq 10^5\n\n1 \\leq b_i \\leq N\n\n1 \\leq c_{i1} < c_{i2} < ... < c_{i{b_i}} \\leq N\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\na_1 b_1\nc_{11} c_{12} ... c_{1{b_1}}\n:\na_M b_M\nc_{M1} c_{M2} ... c_{M{b_M}}\n\nOutput\n\nPrint the minimum cost required to unlock all the treasure boxes.\nIf it is impossible to unlock all of them, print -1.\n\nSample Input 1\n\n2 3\n10 1\n1\n15 1\n2\n30 2\n1 2\n\nSample Output 1\n\n25\n\nWe can unlock all the boxes by purchasing the first and second keys, at the cost of 25 yen, which is the minimum cost required.\n\nSample Input 2\n\n12 1\n100000 1\n2\n\nSample Output 2\n\n-1\n\nWe cannot unlock all the boxes.\n\nSample Input 3\n\n4 6\n67786 3\n1 3 4\n3497 1\n2\n44908 3\n2 3 4\n2156 3\n2 3 4\n26230 1\n2\n86918 1\n3\n\nSample Output 3\n\n69942", "sample_input": "2 3\n10 1\n1\n15 1\n2\n30 2\n1 2\n"}, "reference_outputs": ["25\n"], "source_document_id": "p02901", "source_text": "Score : 500 points\n\nProblem Statement\n\nWe have N locked treasure boxes, numbered 1 to N.\n\nA shop sells M keys. The i-th key is sold for a_i yen (the currency of Japan), and it can unlock b_i of the boxes: Box c_{i1}, c_{i2}, ..., c_{i{b_i}}. Each key purchased can be used any number of times.\n\nFind the minimum cost required to unlock all the treasure boxes. If it is impossible to unlock all of them, print -1.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 12\n\n1 \\leq M \\leq 10^3\n\n1 \\leq a_i \\leq 10^5\n\n1 \\leq b_i \\leq N\n\n1 \\leq c_{i1} < c_{i2} < ... < c_{i{b_i}} \\leq N\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\na_1 b_1\nc_{11} c_{12} ... c_{1{b_1}}\n:\na_M b_M\nc_{M1} c_{M2} ... c_{M{b_M}}\n\nOutput\n\nPrint the minimum cost required to unlock all the treasure boxes.\nIf it is impossible to unlock all of them, print -1.\n\nSample Input 1\n\n2 3\n10 1\n1\n15 1\n2\n30 2\n1 2\n\nSample Output 1\n\n25\n\nWe can unlock all the boxes by purchasing the first and second keys, at the cost of 25 yen, which is the minimum cost required.\n\nSample Input 2\n\n12 1\n100000 1\n2\n\nSample Output 2\n\n-1\n\nWe cannot unlock all the boxes.\n\nSample Input 3\n\n4 6\n67786 3\n1 3 4\n3497 1\n2\n44908 3\n2 3 4\n2156 3\n2 3 4\n26230 1\n2\n86918 1\n3\n\nSample Output 3\n\n69942", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1569, "cpu_time_ms": 508, "memory_kb": 760}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s750436892", "group_id": "codeNet:p02902", "input_text": "local mfl, mce = math.floor, math.ceil\nlocal mmi, mma = math.min, math.max\nlocal bls, brs = bit.lshift, bit.rshift\nlocal SegTree = {}\nSegTree.updateAll = function(self)\n for i = self.stagenum - 1, 1, -1 do\n local cnt = bls(1, i - 1)\n for j = 1, cnt do\n self.stage[i][j] = self.func(self.stage[i + 1][j * 2 - 1], self.stage[i + 1][j * 2])\n end\n end\nend\nSegTree.create = function(self, n, func, emptyvalue)\n self.func, self.emptyvalue = func, emptyvalue\n local stagenum, mul = 1, 1\n self.stage = {{}}\n while mul < n do\n mul, stagenum = mul * 2, stagenum + 1\n self.stage[stagenum] = {}\n end\n self.stagenum = stagenum\n for i = 1, n do self.stage[stagenum][i] = i end\n for i = n + 1, mul do self.stage[stagenum][i] = emptyvalue end\n self:updateAll()\nend\nSegTree.getRange = function(self, left, right)\n if left == right then return self.stage[self.stagenum][left] end\n local stagenum = self.stagenum\n local ret = self.emptyvalue\n while left <= right do\n local stage, sz = 1, bls(1, stagenum - 1)\n local len = right - left + 1\n while (left - 1) % sz ~= 0 or len < sz do\n stage, sz = stage + 1, brs(sz, 1)\n end\n ret = self.func(ret, self.stage[stage][1 + brs(left - 1, stagenum - stage)])\n left = left + sz\n end\n return ret\nend\nSegTree.update = function(self, idx)\n for i = self.stagenum - 1, 1, -1 do\n local dst = brs(idx + 1, 1)\n local rem = dst * 4 - 1 - idx\n self.stage[i][dst] = self.func(self.stage[i + 1][idx], self.stage[i + 1][rem])\n idx = dst\n end\nend\nSegTree.top = function(self) return self.stage[1][1] end\nSegTree.new = function(n, func, emptyvalue)\n local obj = {}\n setmetatable(obj, {__index = SegTree})\n obj:create(n, func, emptyvalue)\n return obj\nend\n\nlocal n, m = io.read(\"*n\", \"*n\")\nlocal longest_len = {}\nlocal edge = {}\nlocal invedge = {}\nlocal updated = {}\nlocal startcand = {}\nfor i = 1, n + 1 do\n longest_len[i] = -1\n edge[i] = {}\n invedge[i] = {}\n updated[i] = false\n startcand[i] = true\nend\nfor i = 1, m do\n local a, b = io.read(\"*n\", \"*n\")\n edge[a][b] = true\n invedge[b][a] = true\n startcand[b] = false\nend\nlocal function getmax(a, b)\n if updated[a] and updated[b] then\n return longest_len[a] < longest_len[b] and b or a\n elseif updated[a] then return a\n elseif updated[b] then return b\n else return n + 1\n end\nend\n-- find loop candidate\nlocal st = SegTree.new(n, getmax, n + 1)\nfor i = 1, n do\n longest_len[i] = 0\n updated[i] = true\nend\nst:updateAll()\nwhile true do\n local src = st:top()\n if src == n + 1 then break end\n for dst, _u in pairs(edge[src]) do\n if longest_len[dst] < 0 or longest_len[dst] < longest_len[src] + 1 then\n if longest_len[dst] < n then\n longest_len[dst] = longest_len[src] + 1\n updated[dst] = true\n st:update(dst)\n end\n end\n end\n updated[src] = false\n st:update(src)\nend\n\nlocal loopCandidates = {}\nfor i = 1, n do\n if n <= longest_len[i] then\n loopCandidates[i] = true\n end\nend\n-- remove no-loop points from loop candidate points\nwhile true do\n local removed = false\n for src, _u in pairs(loopCandidates) do\n local f = false\n for dst, _u2 in pairs(edge[src]) do\n if loopCandidates[dst] then\n f = true\n break\n end\n end\n if not f then loopCandidates[src], removed = nil, true break end\n end\n if not removed then break end\nend\n\n-- remove all no-loop edges\nfor src, _u in pairs(loopCandidates) do\n for dst, _u2 in pairs(edge[src]) do\n if not loopCandidates[dst] then edge[src][dst] = nil end\n end\n for dst, _u2 in pairs(invedge[src]) do\n if not loopCandidates[dst] then invedge[src][dst] = nil end\n end\nend\nfor i = 1, n do\n if not loopCandidates[i] then\n edge[i] = {}\n invedge[i] = {}\n end\nend\n\n-- find first length and second length from certain point\nlocal loop_len = {}\nlocal loop_started = {}\nfor src, _u in pairs(loopCandidates) do\n loop_len[src] = {-1, -1}\n loop_started[src] = false\nend\nif next(loopCandidates) then\n local src = next(loopCandidates)\n loop_len[src][1] = 0\n updated[src] = true\nend\n\nlocal function getlooptask(a, b)\n if updated[a] and updated[b] then\n if loop_len[a][2] < 0 and loop_len[b][2] < 0 then\n return loop_len[a][1] < loop_len[b][1] and a or b\n elseif loop_len[a][2] < 0 then return a\n elseif loop_len[b][2] < 0 then return b\n else\n return loop_len[a][2] < loop_len[b][2] and a or b\n end\n elseif updated[a] then return a\n elseif updated[b] then return b\n else return n + 1\n end\nend\n\nst.func = getlooptask\nst:updateAll()\n\nwhile true do\n local src = st:top()\n if src == n + 1 then break end\n for dst, _u in pairs(edge[src]) do\n if loop_started[dst] then\n if loop_started[src] then\n if loop_len[dst][2] < 0 or loop_len[src][2] + 1 < loop_len[dst][2] then\n loop_len[dst][2] = loop_len[src][2] + 1\n updated[dst] = true\n st:update(dst)\n end\n else\n if loop_len[dst][2] < 0 or loop_len[src][1] + 1 < loop_len[dst][2] then\n loop_len[dst][2] = loop_len[src][1] + 1\n updated[dst] = true\n st:update(dst)\n end\n end\n else\n if loop_len[dst][1] < 0 or loop_len[src][1] + 1 < loop_len[dst][1] then\n loop_len[dst][1] = loop_len[src][1] + 1\n updated[dst] = true\n st:update(dst)\n end\n end\n end\n loop_started[src] = true\n updated[src] = false\n st:update(src)\nend\n\n-- get start of shortest loop\nlocal short_loop_start = false\nlocal short_loop_len = false\nlocal short_loop_v1 = false\nlocal short_loop_v2 = false\nfor src, v in pairs(loop_len) do\n local len = v[2] - v[1]\n if 0 < len then\n local f = false\n if not short_loop_len or len < short_loop_len then\n f = true\n elseif short_loop_len == len then\n if v[1] < short_loop_v1 then\n f = true\n end\n end\n if f then\n short_loop_start, short_loop_len = src, len\n short_loop_v1, short_loop_v2 = v[1], v[2]\n end\n end\nend\n\n-- recalculate length\nlocal shortest_len = {}\nfor i = 1, n do\n shortest_len[i] = -1\n updated[i] = false\nend\nlocal function getmin(a, b)\n if updated[a] and updated[b] then\n return shortest_len[a] < shortest_len[b] and a or b\n elseif updated[a] then return a\n elseif updated[b] then return b\n else return n + 1\n end\nend\n\nif short_loop_start then\n shortest_len[short_loop_start] = 0\n updated[short_loop_start] = true\n st.func = getmin\n st:updateAll()\n while true do\n local src = st:top()\n if src == n + 1 then break end\n for dst, _u in pairs(edge[src]) do\n if shortest_len[dst] < 0 or shortest_len[src] + 1 < shortest_len[dst] then\n shortest_len[dst] = shortest_len[src] + 1\n updated[dst] = true\n st:update(dst)\n end\n end\n updated[src] = false\n st:update(src)\n end\n -- restore path\n local ans = {short_loop_start}\n for i = short_loop_len - 1, 1, -1 do\n local dst = ans[#ans]\n for src, _u in pairs(invedge[dst]) do\n if shortest_len[src] == i then\n table.insert(ans, src)\n break\n end\n end\n end\n print(short_loop_len)\n print(table.concat(ans, \"\\n\"))\nelse\n print(-1)\nend\n", "language": "Lua", "metadata": {"date": 1583332042, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p02902.html", "problem_id": "p02902", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02902/input.txt", "sample_output_relpath": "derived/input_output/data/p02902/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02902/Lua/s750436892.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s750436892", "user_id": "u120582723"}, "prompt_components": {"gold_output": "3\n1\n2\n4\n", "input_to_evaluate": "local mfl, mce = math.floor, math.ceil\nlocal mmi, mma = math.min, math.max\nlocal bls, brs = bit.lshift, bit.rshift\nlocal SegTree = {}\nSegTree.updateAll = function(self)\n for i = self.stagenum - 1, 1, -1 do\n local cnt = bls(1, i - 1)\n for j = 1, cnt do\n self.stage[i][j] = self.func(self.stage[i + 1][j * 2 - 1], self.stage[i + 1][j * 2])\n end\n end\nend\nSegTree.create = function(self, n, func, emptyvalue)\n self.func, self.emptyvalue = func, emptyvalue\n local stagenum, mul = 1, 1\n self.stage = {{}}\n while mul < n do\n mul, stagenum = mul * 2, stagenum + 1\n self.stage[stagenum] = {}\n end\n self.stagenum = stagenum\n for i = 1, n do self.stage[stagenum][i] = i end\n for i = n + 1, mul do self.stage[stagenum][i] = emptyvalue end\n self:updateAll()\nend\nSegTree.getRange = function(self, left, right)\n if left == right then return self.stage[self.stagenum][left] end\n local stagenum = self.stagenum\n local ret = self.emptyvalue\n while left <= right do\n local stage, sz = 1, bls(1, stagenum - 1)\n local len = right - left + 1\n while (left - 1) % sz ~= 0 or len < sz do\n stage, sz = stage + 1, brs(sz, 1)\n end\n ret = self.func(ret, self.stage[stage][1 + brs(left - 1, stagenum - stage)])\n left = left + sz\n end\n return ret\nend\nSegTree.update = function(self, idx)\n for i = self.stagenum - 1, 1, -1 do\n local dst = brs(idx + 1, 1)\n local rem = dst * 4 - 1 - idx\n self.stage[i][dst] = self.func(self.stage[i + 1][idx], self.stage[i + 1][rem])\n idx = dst\n end\nend\nSegTree.top = function(self) return self.stage[1][1] end\nSegTree.new = function(n, func, emptyvalue)\n local obj = {}\n setmetatable(obj, {__index = SegTree})\n obj:create(n, func, emptyvalue)\n return obj\nend\n\nlocal n, m = io.read(\"*n\", \"*n\")\nlocal longest_len = {}\nlocal edge = {}\nlocal invedge = {}\nlocal updated = {}\nlocal startcand = {}\nfor i = 1, n + 1 do\n longest_len[i] = -1\n edge[i] = {}\n invedge[i] = {}\n updated[i] = false\n startcand[i] = true\nend\nfor i = 1, m do\n local a, b = io.read(\"*n\", \"*n\")\n edge[a][b] = true\n invedge[b][a] = true\n startcand[b] = false\nend\nlocal function getmax(a, b)\n if updated[a] and updated[b] then\n return longest_len[a] < longest_len[b] and b or a\n elseif updated[a] then return a\n elseif updated[b] then return b\n else return n + 1\n end\nend\n-- find loop candidate\nlocal st = SegTree.new(n, getmax, n + 1)\nfor i = 1, n do\n longest_len[i] = 0\n updated[i] = true\nend\nst:updateAll()\nwhile true do\n local src = st:top()\n if src == n + 1 then break end\n for dst, _u in pairs(edge[src]) do\n if longest_len[dst] < 0 or longest_len[dst] < longest_len[src] + 1 then\n if longest_len[dst] < n then\n longest_len[dst] = longest_len[src] + 1\n updated[dst] = true\n st:update(dst)\n end\n end\n end\n updated[src] = false\n st:update(src)\nend\n\nlocal loopCandidates = {}\nfor i = 1, n do\n if n <= longest_len[i] then\n loopCandidates[i] = true\n end\nend\n-- remove no-loop points from loop candidate points\nwhile true do\n local removed = false\n for src, _u in pairs(loopCandidates) do\n local f = false\n for dst, _u2 in pairs(edge[src]) do\n if loopCandidates[dst] then\n f = true\n break\n end\n end\n if not f then loopCandidates[src], removed = nil, true break end\n end\n if not removed then break end\nend\n\n-- remove all no-loop edges\nfor src, _u in pairs(loopCandidates) do\n for dst, _u2 in pairs(edge[src]) do\n if not loopCandidates[dst] then edge[src][dst] = nil end\n end\n for dst, _u2 in pairs(invedge[src]) do\n if not loopCandidates[dst] then invedge[src][dst] = nil end\n end\nend\nfor i = 1, n do\n if not loopCandidates[i] then\n edge[i] = {}\n invedge[i] = {}\n end\nend\n\n-- find first length and second length from certain point\nlocal loop_len = {}\nlocal loop_started = {}\nfor src, _u in pairs(loopCandidates) do\n loop_len[src] = {-1, -1}\n loop_started[src] = false\nend\nif next(loopCandidates) then\n local src = next(loopCandidates)\n loop_len[src][1] = 0\n updated[src] = true\nend\n\nlocal function getlooptask(a, b)\n if updated[a] and updated[b] then\n if loop_len[a][2] < 0 and loop_len[b][2] < 0 then\n return loop_len[a][1] < loop_len[b][1] and a or b\n elseif loop_len[a][2] < 0 then return a\n elseif loop_len[b][2] < 0 then return b\n else\n return loop_len[a][2] < loop_len[b][2] and a or b\n end\n elseif updated[a] then return a\n elseif updated[b] then return b\n else return n + 1\n end\nend\n\nst.func = getlooptask\nst:updateAll()\n\nwhile true do\n local src = st:top()\n if src == n + 1 then break end\n for dst, _u in pairs(edge[src]) do\n if loop_started[dst] then\n if loop_started[src] then\n if loop_len[dst][2] < 0 or loop_len[src][2] + 1 < loop_len[dst][2] then\n loop_len[dst][2] = loop_len[src][2] + 1\n updated[dst] = true\n st:update(dst)\n end\n else\n if loop_len[dst][2] < 0 or loop_len[src][1] + 1 < loop_len[dst][2] then\n loop_len[dst][2] = loop_len[src][1] + 1\n updated[dst] = true\n st:update(dst)\n end\n end\n else\n if loop_len[dst][1] < 0 or loop_len[src][1] + 1 < loop_len[dst][1] then\n loop_len[dst][1] = loop_len[src][1] + 1\n updated[dst] = true\n st:update(dst)\n end\n end\n end\n loop_started[src] = true\n updated[src] = false\n st:update(src)\nend\n\n-- get start of shortest loop\nlocal short_loop_start = false\nlocal short_loop_len = false\nlocal short_loop_v1 = false\nlocal short_loop_v2 = false\nfor src, v in pairs(loop_len) do\n local len = v[2] - v[1]\n if 0 < len then\n local f = false\n if not short_loop_len or len < short_loop_len then\n f = true\n elseif short_loop_len == len then\n if v[1] < short_loop_v1 then\n f = true\n end\n end\n if f then\n short_loop_start, short_loop_len = src, len\n short_loop_v1, short_loop_v2 = v[1], v[2]\n end\n end\nend\n\n-- recalculate length\nlocal shortest_len = {}\nfor i = 1, n do\n shortest_len[i] = -1\n updated[i] = false\nend\nlocal function getmin(a, b)\n if updated[a] and updated[b] then\n return shortest_len[a] < shortest_len[b] and a or b\n elseif updated[a] then return a\n elseif updated[b] then return b\n else return n + 1\n end\nend\n\nif short_loop_start then\n shortest_len[short_loop_start] = 0\n updated[short_loop_start] = true\n st.func = getmin\n st:updateAll()\n while true do\n local src = st:top()\n if src == n + 1 then break end\n for dst, _u in pairs(edge[src]) do\n if shortest_len[dst] < 0 or shortest_len[src] + 1 < shortest_len[dst] then\n shortest_len[dst] = shortest_len[src] + 1\n updated[dst] = true\n st:update(dst)\n end\n end\n updated[src] = false\n st:update(src)\n end\n -- restore path\n local ans = {short_loop_start}\n for i = short_loop_len - 1, 1, -1 do\n local dst = ans[#ans]\n for src, _u in pairs(invedge[dst]) do\n if shortest_len[src] == i then\n table.insert(ans, src)\n break\n end\n end\n end\n print(short_loop_len)\n print(table.concat(ans, \"\\n\"))\nelse\n print(-1)\nend\n", "problem_context": "Score : 600 points\n\nProblem Statement\n\nGiven is a directed graph G with N vertices and M edges.\n\nThe vertices are numbered 1 to N, and the i-th edge is directed from Vertex A_i to Vertex B_i.\n\nIt is guaranteed that the graph contains no self-loops or multiple edges.\n\nDetermine whether there exists an induced subgraph (see Notes) of G such that the in-degree and out-degree of every vertex are both 1. If the answer is yes, show one such subgraph.\n\nHere the null graph is not considered as a subgraph.\n\nNotes\n\nFor a directed graph G = (V, E), we call a directed graph G' = (V', E') satisfying the following conditions an induced subgraph of G:\n\nV' is a (non-empty) subset of V.\n\nE' is the set of all the edges in E that have both endpoints in V'.\n\nConstraints\n\n1 \\leq N \\leq 1000\n\n0 \\leq M \\leq 2000\n\n1 \\leq A_i,B_i \\leq N\n\nA_i \\neq B_i\n\nAll pairs (A_i, B_i) are distinct.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nA_1 B_1\nA_2 B_2\n:\nA_M B_M\n\nOutput\n\nIf there is no induced subgraph of G that satisfies the condition, print -1.\nOtherwise, print an induced subgraph of G that satisfies the condition, in the following format:\n\nK\nv_1\nv_2\n:\nv_K\n\nThis represents the induced subgraph of G with K vertices whose vertex set is \\{v_1, v_2, \\ldots, v_K\\}. (The order of v_1, v_2, \\ldots, v_K does not matter.)\nIf there are multiple subgraphs of G that satisfy the condition, printing any of them is accepted.\n\nSample Input 1\n\n4 5\n1 2\n2 3\n2 4\n4 1\n4 3\n\nSample Output 1\n\n3\n1\n2\n4\n\nThe induced subgraph of G whose vertex set is \\{1, 2, 4\\} has the edge set \\{(1, 2), (2, 4), (4, 1)\\}. The in-degree and out-degree of every vertex in this graph are both 1.\n\nSample Input 2\n\n4 5\n1 2\n2 3\n2 4\n1 4\n4 3\n\nSample Output 2\n\n-1\n\nThere is no induced subgraph of G that satisfies the condition.\n\nSample Input 3\n\n6 9\n1 2\n2 3\n3 4\n4 5\n5 6\n5 1\n5 2\n6 1\n6 2\n\nSample Output 3\n\n4\n2\n3\n4\n5", "sample_input": "4 5\n1 2\n2 3\n2 4\n4 1\n4 3\n"}, "reference_outputs": ["3\n1\n2\n4\n"], "source_document_id": "p02902", "source_text": "Score : 600 points\n\nProblem Statement\n\nGiven is a directed graph G with N vertices and M edges.\n\nThe vertices are numbered 1 to N, and the i-th edge is directed from Vertex A_i to Vertex B_i.\n\nIt is guaranteed that the graph contains no self-loops or multiple edges.\n\nDetermine whether there exists an induced subgraph (see Notes) of G such that the in-degree and out-degree of every vertex are both 1. If the answer is yes, show one such subgraph.\n\nHere the null graph is not considered as a subgraph.\n\nNotes\n\nFor a directed graph G = (V, E), we call a directed graph G' = (V', E') satisfying the following conditions an induced subgraph of G:\n\nV' is a (non-empty) subset of V.\n\nE' is the set of all the edges in E that have both endpoints in V'.\n\nConstraints\n\n1 \\leq N \\leq 1000\n\n0 \\leq M \\leq 2000\n\n1 \\leq A_i,B_i \\leq N\n\nA_i \\neq B_i\n\nAll pairs (A_i, B_i) are distinct.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nA_1 B_1\nA_2 B_2\n:\nA_M B_M\n\nOutput\n\nIf there is no induced subgraph of G that satisfies the condition, print -1.\nOtherwise, print an induced subgraph of G that satisfies the condition, in the following format:\n\nK\nv_1\nv_2\n:\nv_K\n\nThis represents the induced subgraph of G with K vertices whose vertex set is \\{v_1, v_2, \\ldots, v_K\\}. (The order of v_1, v_2, \\ldots, v_K does not matter.)\nIf there are multiple subgraphs of G that satisfy the condition, printing any of them is accepted.\n\nSample Input 1\n\n4 5\n1 2\n2 3\n2 4\n4 1\n4 3\n\nSample Output 1\n\n3\n1\n2\n4\n\nThe induced subgraph of G whose vertex set is \\{1, 2, 4\\} has the edge set \\{(1, 2), (2, 4), (4, 1)\\}. The in-degree and out-degree of every vertex in this graph are both 1.\n\nSample Input 2\n\n4 5\n1 2\n2 3\n2 4\n1 4\n4 3\n\nSample Output 2\n\n-1\n\nThere is no induced subgraph of G that satisfies the condition.\n\nSample Input 3\n\n6 9\n1 2\n2 3\n3 4\n4 5\n5 6\n5 1\n5 2\n6 1\n6 2\n\nSample Output 3\n\n4\n2\n3\n4\n5", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 7116, "cpu_time_ms": 15, "memory_kb": 768}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s193075823", "group_id": "codeNet:p02902", "input_text": "local mfl, mce = math.floor, math.ceil\nlocal mmi, mma = math.min, math.max\nlocal bls, brs = bit.lshift, bit.rshift\nlocal SegTree = {}\nSegTree.updateAll = function(self)\n for i = self.stagenum - 1, 1, -1 do\n local cnt = bls(1, i - 1)\n for j = 1, cnt do\n self.stage[i][j] = self.func(self.stage[i + 1][j * 2 - 1], self.stage[i + 1][j * 2])\n end\n end\nend\nSegTree.create = function(self, n, func, emptyvalue)\n self.func, self.emptyvalue = func, emptyvalue\n local stagenum, mul = 1, 1\n self.stage = {{}}\n while mul < n do\n mul, stagenum = mul * 2, stagenum + 1\n self.stage[stagenum] = {}\n end\n self.stagenum = stagenum\n for i = 1, n do self.stage[stagenum][i] = i end\n for i = n + 1, mul do self.stage[stagenum][i] = emptyvalue end\n self:updateAll()\nend\nSegTree.getRange = function(self, left, right)\n if left == right then return self.stage[self.stagenum][left] end\n local stagenum = self.stagenum\n local ret = self.emptyvalue\n while left <= right do\n local stage, sz = 1, bls(1, stagenum - 1)\n local len = right - left + 1\n while (left - 1) % sz ~= 0 or len < sz do\n stage, sz = stage + 1, brs(sz, 1)\n end\n ret = self.func(ret, self.stage[stage][1 + brs(left - 1, stagenum - stage)])\n left = left + sz\n end\n return ret\nend\nSegTree.update = function(self, idx)\n for i = self.stagenum - 1, 1, -1 do\n local dst = brs(idx + 1, 1)\n local rem = dst * 4 - 1 - idx\n self.stage[i][dst] = self.func(self.stage[i + 1][idx], self.stage[i + 1][rem])\n idx = dst\n end\nend\nSegTree.top = function(self) return self.stage[1][1] end\nSegTree.new = function(n, func, emptyvalue)\n local obj = {}\n setmetatable(obj, {__index = SegTree})\n obj:create(n, func, emptyvalue)\n return obj\nend\n\nlocal n, m = io.read(\"*n\", \"*n\")\nlocal longest_len = {}\nlocal edge = {}\nlocal invedge = {}\nlocal updated = {}\nlocal startcand = {}\nfor i = 1, n + 1 do\n longest_len[i] = -1\n edge[i] = {}\n invedge[i] = {}\n updated[i] = false\n startcand[i] = true\nend\nfor i = 1, m do\n local a, b = io.read(\"*n\", \"*n\")\n edge[a][b] = true\n invedge[b][a] = true\n startcand[b] = false\nend\nlocal function getmax(a, b)\n if updated[a] and updated[b] then\n return longest_len[a] < longest_len[b] and b or a\n elseif updated[a] then return a\n elseif updated[b] then return b\n else return n + 1\n end\nend\n-- find loop candidate\nlocal st = SegTree.new(n, getmax, n + 1)\nfor i = 1, n do\n longest_len[i] = 0\n updated[i] = true\nend\nst:updateAll()\nwhile true do\n local src = st:top()\n if src == n + 1 then break end\n for dst, _u in pairs(edge[src]) do\n if longest_len[dst] < 0 or longest_len[dst] < longest_len[src] + 1 then\n if longest_len[dst] < n then\n longest_len[dst] = longest_len[src] + 1\n updated[dst] = true\n st:update(dst)\n end\n end\n end\n updated[src] = false\n st:update(src)\nend\n\nlocal loopCandidates = {}\nfor i = 1, n do\n if n <= longest_len[i] then\n loopCandidates[i] = true\n end\nend\n-- remove no-loop points from loop candidate points\nwhile true do\n local removed = false\n for src, _u in pairs(loopCandidates) do\n local f = false\n for dst, _u2 in pairs(edge[src]) do\n if loopCandidates[dst] then\n f = true\n break\n end\n end\n if not f then loopCandidates[src], removed = nil, true break end\n end\n if not removed then break end\nend\n\n-- remove all no-loop edges\nfor src, _u in pairs(loopCandidates) do\n for dst, _u2 in pairs(edge[src]) do\n if not loopCandidates[dst] then edge[src][dst] = nil end\n end\n for dst, _u2 in pairs(invedge[src]) do\n if not loopCandidates[dst] then invedge[src][dst] = nil end\n end\nend\nfor i = 1, n do\n if not loopCandidates[i] then\n edge[i] = {}\n invedge[i] = {}\n end\nend\n\n-- find first length and second length from certain point\nlocal loop_len = {}\nlocal loop_started = {}\nfor src, _u in pairs(loopCandidates) do\n loop_len[src] = {-1, -1}\n loop_started[src] = false\nend\nif next(loopCandidates) then\n local src = next(loopCandidates)\n loop_len[src][1] = 0\n updated[src] = true\nend\n\nlocal function getlooptask(a, b)\n if updated[a] and updated[b] then\n if loop_len[a][2] < 0 and loop_len[b][2] < 0 then\n return loop_len[a][1] < loop_len[b][1] and a or b\n elseif loop_len[a][2] < 0 then return a\n elseif loop_len[b][2] < 0 then return b\n else\n return loop_len[a][2] < loop_len[b][2] and a or b\n end\n elseif updated[a] then return a\n elseif updated[b] then return b\n else return n + 1\n end\nend\n\nst.func = getlooptask\nst:updateAll()\n\nwhile true do\n local src = st:top()\n if src == n + 1 then break end\n for dst, _u in pairs(edge[src]) do\n if loop_started[dst] then\n if loop_started[src] then\n if loop_len[dst][2] < 0 or loop_len[src][2] + 1 < loop_len[dst][2] then\n loop_len[dst][2] = loop_len[src][2] + 1\n updated[dst] = true\n st:update(dst)\n end\n else\n if loop_len[dst][2] < 0 or loop_len[src][1] + 1 < loop_len[dst][2] then\n loop_len[dst][2] = loop_len[src][1] + 1\n updated[dst] = true\n st:update(dst)\n end\n end\n else\n if loop_len[dst][1] < 0 or loop_len[src][1] + 1 < loop_len[dst][1] then\n loop_len[dst][1] = loop_len[src][1] + 1\n updated[dst] = true\n st:update(dst)\n end\n end\n end\n loop_started[src] = true\n updated[src] = false\n st:update(src)\nend\n\n-- get start of shortest loop\nlocal short_loop_start = false\nlocal short_loop_len = false\nlocal short_loop_v1 = false\nlocal short_loop_v2 = false\nfor src, v in pairs(loop_len) do\n local len = v[2] - v[1]\n if 0 < len then\n local f = false\n if not short_loop_len or len < short_loop_len then\n f = true\n elseif short_loop_len == len then\n if v[1] < short_loop_v1 then\n f = true\n end\n end\n if f then\n short_loop_start, short_loop_len = src, len\n short_loop_v1, short_loop_v2 = v[1], v[2]\n end\n end\nend\n\n-- recalculate length\nlocal shortest_len = {}\nfor i = 1, n do\n shortest_len[i] = -1\n updated[i] = false\nend\nlocal function getmin(a, b)\n if updated[a] and updated[b] then\n return shortest_len[a] < shortest_len[b] and a or b\n elseif updated[a] then return a\n elseif updated[b] then return b\n else return n + 1\n end\nend\n\nif short_loop_start then\n shortest_len[short_loop_start] = 0\n updated[short_loop_start] = true\n st.func = getmin\n st:updateAll()\n while true do\n local src = st:top()\n if src == n + 1 then break end\n for dst, _u in pairs(edge[src]) do\n if shortest_len[dst] < 0 or shortest_len[src] + 1 < shortest_len[dst] then\n shortest_len[dst] = shortest_len[src] + 1\n updated[dst] = true\n st:update(dst)\n end\n end\n updated[src] = false\n st:update(src)\n end\n -- restore path\n local ans = {short_loop_start}\n for i = short_loop_len - 1, 1, -1 do\n local dst = ans[#ans]\n for src, _u in pairs(invedge[dst]) do\n if (shortest_len[src] + 1) % short_loop_len == shortest_len[dst] then\n table.insert(ans, src)\n break\n end\n end\n end\n print(short_loop_len)\n print(table.concat(ans, \"\\n\"))\nelse\n print(-1)\nend\n", "language": "Lua", "metadata": {"date": 1583331750, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p02902.html", "problem_id": "p02902", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02902/input.txt", "sample_output_relpath": "derived/input_output/data/p02902/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02902/Lua/s193075823.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s193075823", "user_id": "u120582723"}, "prompt_components": {"gold_output": "3\n1\n2\n4\n", "input_to_evaluate": "local mfl, mce = math.floor, math.ceil\nlocal mmi, mma = math.min, math.max\nlocal bls, brs = bit.lshift, bit.rshift\nlocal SegTree = {}\nSegTree.updateAll = function(self)\n for i = self.stagenum - 1, 1, -1 do\n local cnt = bls(1, i - 1)\n for j = 1, cnt do\n self.stage[i][j] = self.func(self.stage[i + 1][j * 2 - 1], self.stage[i + 1][j * 2])\n end\n end\nend\nSegTree.create = function(self, n, func, emptyvalue)\n self.func, self.emptyvalue = func, emptyvalue\n local stagenum, mul = 1, 1\n self.stage = {{}}\n while mul < n do\n mul, stagenum = mul * 2, stagenum + 1\n self.stage[stagenum] = {}\n end\n self.stagenum = stagenum\n for i = 1, n do self.stage[stagenum][i] = i end\n for i = n + 1, mul do self.stage[stagenum][i] = emptyvalue end\n self:updateAll()\nend\nSegTree.getRange = function(self, left, right)\n if left == right then return self.stage[self.stagenum][left] end\n local stagenum = self.stagenum\n local ret = self.emptyvalue\n while left <= right do\n local stage, sz = 1, bls(1, stagenum - 1)\n local len = right - left + 1\n while (left - 1) % sz ~= 0 or len < sz do\n stage, sz = stage + 1, brs(sz, 1)\n end\n ret = self.func(ret, self.stage[stage][1 + brs(left - 1, stagenum - stage)])\n left = left + sz\n end\n return ret\nend\nSegTree.update = function(self, idx)\n for i = self.stagenum - 1, 1, -1 do\n local dst = brs(idx + 1, 1)\n local rem = dst * 4 - 1 - idx\n self.stage[i][dst] = self.func(self.stage[i + 1][idx], self.stage[i + 1][rem])\n idx = dst\n end\nend\nSegTree.top = function(self) return self.stage[1][1] end\nSegTree.new = function(n, func, emptyvalue)\n local obj = {}\n setmetatable(obj, {__index = SegTree})\n obj:create(n, func, emptyvalue)\n return obj\nend\n\nlocal n, m = io.read(\"*n\", \"*n\")\nlocal longest_len = {}\nlocal edge = {}\nlocal invedge = {}\nlocal updated = {}\nlocal startcand = {}\nfor i = 1, n + 1 do\n longest_len[i] = -1\n edge[i] = {}\n invedge[i] = {}\n updated[i] = false\n startcand[i] = true\nend\nfor i = 1, m do\n local a, b = io.read(\"*n\", \"*n\")\n edge[a][b] = true\n invedge[b][a] = true\n startcand[b] = false\nend\nlocal function getmax(a, b)\n if updated[a] and updated[b] then\n return longest_len[a] < longest_len[b] and b or a\n elseif updated[a] then return a\n elseif updated[b] then return b\n else return n + 1\n end\nend\n-- find loop candidate\nlocal st = SegTree.new(n, getmax, n + 1)\nfor i = 1, n do\n longest_len[i] = 0\n updated[i] = true\nend\nst:updateAll()\nwhile true do\n local src = st:top()\n if src == n + 1 then break end\n for dst, _u in pairs(edge[src]) do\n if longest_len[dst] < 0 or longest_len[dst] < longest_len[src] + 1 then\n if longest_len[dst] < n then\n longest_len[dst] = longest_len[src] + 1\n updated[dst] = true\n st:update(dst)\n end\n end\n end\n updated[src] = false\n st:update(src)\nend\n\nlocal loopCandidates = {}\nfor i = 1, n do\n if n <= longest_len[i] then\n loopCandidates[i] = true\n end\nend\n-- remove no-loop points from loop candidate points\nwhile true do\n local removed = false\n for src, _u in pairs(loopCandidates) do\n local f = false\n for dst, _u2 in pairs(edge[src]) do\n if loopCandidates[dst] then\n f = true\n break\n end\n end\n if not f then loopCandidates[src], removed = nil, true break end\n end\n if not removed then break end\nend\n\n-- remove all no-loop edges\nfor src, _u in pairs(loopCandidates) do\n for dst, _u2 in pairs(edge[src]) do\n if not loopCandidates[dst] then edge[src][dst] = nil end\n end\n for dst, _u2 in pairs(invedge[src]) do\n if not loopCandidates[dst] then invedge[src][dst] = nil end\n end\nend\nfor i = 1, n do\n if not loopCandidates[i] then\n edge[i] = {}\n invedge[i] = {}\n end\nend\n\n-- find first length and second length from certain point\nlocal loop_len = {}\nlocal loop_started = {}\nfor src, _u in pairs(loopCandidates) do\n loop_len[src] = {-1, -1}\n loop_started[src] = false\nend\nif next(loopCandidates) then\n local src = next(loopCandidates)\n loop_len[src][1] = 0\n updated[src] = true\nend\n\nlocal function getlooptask(a, b)\n if updated[a] and updated[b] then\n if loop_len[a][2] < 0 and loop_len[b][2] < 0 then\n return loop_len[a][1] < loop_len[b][1] and a or b\n elseif loop_len[a][2] < 0 then return a\n elseif loop_len[b][2] < 0 then return b\n else\n return loop_len[a][2] < loop_len[b][2] and a or b\n end\n elseif updated[a] then return a\n elseif updated[b] then return b\n else return n + 1\n end\nend\n\nst.func = getlooptask\nst:updateAll()\n\nwhile true do\n local src = st:top()\n if src == n + 1 then break end\n for dst, _u in pairs(edge[src]) do\n if loop_started[dst] then\n if loop_started[src] then\n if loop_len[dst][2] < 0 or loop_len[src][2] + 1 < loop_len[dst][2] then\n loop_len[dst][2] = loop_len[src][2] + 1\n updated[dst] = true\n st:update(dst)\n end\n else\n if loop_len[dst][2] < 0 or loop_len[src][1] + 1 < loop_len[dst][2] then\n loop_len[dst][2] = loop_len[src][1] + 1\n updated[dst] = true\n st:update(dst)\n end\n end\n else\n if loop_len[dst][1] < 0 or loop_len[src][1] + 1 < loop_len[dst][1] then\n loop_len[dst][1] = loop_len[src][1] + 1\n updated[dst] = true\n st:update(dst)\n end\n end\n end\n loop_started[src] = true\n updated[src] = false\n st:update(src)\nend\n\n-- get start of shortest loop\nlocal short_loop_start = false\nlocal short_loop_len = false\nlocal short_loop_v1 = false\nlocal short_loop_v2 = false\nfor src, v in pairs(loop_len) do\n local len = v[2] - v[1]\n if 0 < len then\n local f = false\n if not short_loop_len or len < short_loop_len then\n f = true\n elseif short_loop_len == len then\n if v[1] < short_loop_v1 then\n f = true\n end\n end\n if f then\n short_loop_start, short_loop_len = src, len\n short_loop_v1, short_loop_v2 = v[1], v[2]\n end\n end\nend\n\n-- recalculate length\nlocal shortest_len = {}\nfor i = 1, n do\n shortest_len[i] = -1\n updated[i] = false\nend\nlocal function getmin(a, b)\n if updated[a] and updated[b] then\n return shortest_len[a] < shortest_len[b] and a or b\n elseif updated[a] then return a\n elseif updated[b] then return b\n else return n + 1\n end\nend\n\nif short_loop_start then\n shortest_len[short_loop_start] = 0\n updated[short_loop_start] = true\n st.func = getmin\n st:updateAll()\n while true do\n local src = st:top()\n if src == n + 1 then break end\n for dst, _u in pairs(edge[src]) do\n if shortest_len[dst] < 0 or shortest_len[src] + 1 < shortest_len[dst] then\n shortest_len[dst] = shortest_len[src] + 1\n updated[dst] = true\n st:update(dst)\n end\n end\n updated[src] = false\n st:update(src)\n end\n -- restore path\n local ans = {short_loop_start}\n for i = short_loop_len - 1, 1, -1 do\n local dst = ans[#ans]\n for src, _u in pairs(invedge[dst]) do\n if (shortest_len[src] + 1) % short_loop_len == shortest_len[dst] then\n table.insert(ans, src)\n break\n end\n end\n end\n print(short_loop_len)\n print(table.concat(ans, \"\\n\"))\nelse\n print(-1)\nend\n", "problem_context": "Score : 600 points\n\nProblem Statement\n\nGiven is a directed graph G with N vertices and M edges.\n\nThe vertices are numbered 1 to N, and the i-th edge is directed from Vertex A_i to Vertex B_i.\n\nIt is guaranteed that the graph contains no self-loops or multiple edges.\n\nDetermine whether there exists an induced subgraph (see Notes) of G such that the in-degree and out-degree of every vertex are both 1. If the answer is yes, show one such subgraph.\n\nHere the null graph is not considered as a subgraph.\n\nNotes\n\nFor a directed graph G = (V, E), we call a directed graph G' = (V', E') satisfying the following conditions an induced subgraph of G:\n\nV' is a (non-empty) subset of V.\n\nE' is the set of all the edges in E that have both endpoints in V'.\n\nConstraints\n\n1 \\leq N \\leq 1000\n\n0 \\leq M \\leq 2000\n\n1 \\leq A_i,B_i \\leq N\n\nA_i \\neq B_i\n\nAll pairs (A_i, B_i) are distinct.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nA_1 B_1\nA_2 B_2\n:\nA_M B_M\n\nOutput\n\nIf there is no induced subgraph of G that satisfies the condition, print -1.\nOtherwise, print an induced subgraph of G that satisfies the condition, in the following format:\n\nK\nv_1\nv_2\n:\nv_K\n\nThis represents the induced subgraph of G with K vertices whose vertex set is \\{v_1, v_2, \\ldots, v_K\\}. (The order of v_1, v_2, \\ldots, v_K does not matter.)\nIf there are multiple subgraphs of G that satisfy the condition, printing any of them is accepted.\n\nSample Input 1\n\n4 5\n1 2\n2 3\n2 4\n4 1\n4 3\n\nSample Output 1\n\n3\n1\n2\n4\n\nThe induced subgraph of G whose vertex set is \\{1, 2, 4\\} has the edge set \\{(1, 2), (2, 4), (4, 1)\\}. The in-degree and out-degree of every vertex in this graph are both 1.\n\nSample Input 2\n\n4 5\n1 2\n2 3\n2 4\n1 4\n4 3\n\nSample Output 2\n\n-1\n\nThere is no induced subgraph of G that satisfies the condition.\n\nSample Input 3\n\n6 9\n1 2\n2 3\n3 4\n4 5\n5 6\n5 1\n5 2\n6 1\n6 2\n\nSample Output 3\n\n4\n2\n3\n4\n5", "sample_input": "4 5\n1 2\n2 3\n2 4\n4 1\n4 3\n"}, "reference_outputs": ["3\n1\n2\n4\n"], "source_document_id": "p02902", "source_text": "Score : 600 points\n\nProblem Statement\n\nGiven is a directed graph G with N vertices and M edges.\n\nThe vertices are numbered 1 to N, and the i-th edge is directed from Vertex A_i to Vertex B_i.\n\nIt is guaranteed that the graph contains no self-loops or multiple edges.\n\nDetermine whether there exists an induced subgraph (see Notes) of G such that the in-degree and out-degree of every vertex are both 1. If the answer is yes, show one such subgraph.\n\nHere the null graph is not considered as a subgraph.\n\nNotes\n\nFor a directed graph G = (V, E), we call a directed graph G' = (V', E') satisfying the following conditions an induced subgraph of G:\n\nV' is a (non-empty) subset of V.\n\nE' is the set of all the edges in E that have both endpoints in V'.\n\nConstraints\n\n1 \\leq N \\leq 1000\n\n0 \\leq M \\leq 2000\n\n1 \\leq A_i,B_i \\leq N\n\nA_i \\neq B_i\n\nAll pairs (A_i, B_i) are distinct.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nA_1 B_1\nA_2 B_2\n:\nA_M B_M\n\nOutput\n\nIf there is no induced subgraph of G that satisfies the condition, print -1.\nOtherwise, print an induced subgraph of G that satisfies the condition, in the following format:\n\nK\nv_1\nv_2\n:\nv_K\n\nThis represents the induced subgraph of G with K vertices whose vertex set is \\{v_1, v_2, \\ldots, v_K\\}. (The order of v_1, v_2, \\ldots, v_K does not matter.)\nIf there are multiple subgraphs of G that satisfy the condition, printing any of them is accepted.\n\nSample Input 1\n\n4 5\n1 2\n2 3\n2 4\n4 1\n4 3\n\nSample Output 1\n\n3\n1\n2\n4\n\nThe induced subgraph of G whose vertex set is \\{1, 2, 4\\} has the edge set \\{(1, 2), (2, 4), (4, 1)\\}. The in-degree and out-degree of every vertex in this graph are both 1.\n\nSample Input 2\n\n4 5\n1 2\n2 3\n2 4\n1 4\n4 3\n\nSample Output 2\n\n-1\n\nThere is no induced subgraph of G that satisfies the condition.\n\nSample Input 3\n\n6 9\n1 2\n2 3\n3 4\n4 5\n5 6\n5 1\n5 2\n6 1\n6 2\n\nSample Output 3\n\n4\n2\n3\n4\n5", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 7155, "cpu_time_ms": 15, "memory_kb": 768}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s316334707", "group_id": "codeNet:p02909", "input_text": "local s=io.read()\nif s==\"Sunny\"then\n print(\"Cloudy\")\nelseif s==\"Cloudy\"then\n print(\"Rainy\")\nelse\n print(\"Sunny\")\nend", "language": "Lua", "metadata": {"date": 1576556328, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p02909.html", "problem_id": "p02909", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02909/input.txt", "sample_output_relpath": "derived/input_output/data/p02909/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02909/Lua/s316334707.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s316334707", "user_id": "u373958718"}, "prompt_components": {"gold_output": "Cloudy\n", "input_to_evaluate": "local s=io.read()\nif s==\"Sunny\"then\n print(\"Cloudy\")\nelseif s==\"Cloudy\"then\n print(\"Rainy\")\nelse\n print(\"Sunny\")\nend", "problem_context": "Score: 100 points\n\nProblem Statement\n\nThe weather in Takahashi's town changes day by day, in the following cycle: Sunny, Cloudy, Rainy, Sunny, Cloudy, Rainy, ...\n\nGiven is a string S representing the weather in the town today. Predict the weather tomorrow.\n\nConstraints\n\nS is Sunny, Cloudy, or Rainy.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint a string representing the expected weather tomorrow, in the same format in which input is given.\n\nSample Input 1\n\nSunny\n\nSample Output 1\n\nCloudy\n\nIn Takahashi's town, a sunny day is followed by a cloudy day.\n\nSample Input 2\n\nRainy\n\nSample Output 2\n\nSunny", "sample_input": "Sunny\n"}, "reference_outputs": ["Cloudy\n"], "source_document_id": "p02909", "source_text": "Score: 100 points\n\nProblem Statement\n\nThe weather in Takahashi's town changes day by day, in the following cycle: Sunny, Cloudy, Rainy, Sunny, Cloudy, Rainy, ...\n\nGiven is a string S representing the weather in the town today. Predict the weather tomorrow.\n\nConstraints\n\nS is Sunny, Cloudy, or Rainy.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint a string representing the expected weather tomorrow, in the same format in which input is given.\n\nSample Input 1\n\nSunny\n\nSample Output 1\n\nCloudy\n\nIn Takahashi's town, a sunny day is followed by a cloudy day.\n\nSample Input 2\n\nRainy\n\nSample Output 2\n\nSunny", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 119, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s561020783", "group_id": "codeNet:p02910", "input_text": "s=io.read()\nlen=s:len()\n\nfor i=1,len do\n if i%2==0 then\n l=s:sub(i, i)\n if not (l==\"L\" or l==\"U\" or l==\"D\") then\n print(\"No\")\n os.exit()\n end\n else\n r=s:sub(i, i)\n if not (r==\"R\" or r==\"U\" or r==\"D\") then\n print(\"No\")\n os.exit()\n end\n end\nend\n\nprint(\"Yes\")", "language": "Lua", "metadata": {"date": 1572642989, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p02910.html", "problem_id": "p02910", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02910/input.txt", "sample_output_relpath": "derived/input_output/data/p02910/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02910/Lua/s561020783.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s561020783", "user_id": "u535423069"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "s=io.read()\nlen=s:len()\n\nfor i=1,len do\n if i%2==0 then\n l=s:sub(i, i)\n if not (l==\"L\" or l==\"U\" or l==\"D\") then\n print(\"No\")\n os.exit()\n end\n else\n r=s:sub(i, i)\n if not (r==\"R\" or r==\"U\" or r==\"D\") then\n print(\"No\")\n os.exit()\n end\n end\nend\n\nprint(\"Yes\")", "problem_context": "Score: 200 points\n\nProblem Statement\n\nTakahashi will do a tap dance. The dance is described by a string S where each character is L, R, U, or D. These characters indicate the positions on which Takahashi should step. He will follow these instructions one by one in order, starting with the first character.\n\nS is said to be easily playable if and only if it satisfies both of the following conditions:\n\nEvery character in an odd position (1-st, 3-rd, 5-th, \\ldots) is R, U, or D.\n\nEvery character in an even position (2-nd, 4-th, 6-th, \\ldots) is L, U, or D.\n\nYour task is to print Yes if S is easily playable, and No otherwise.\n\nConstraints\n\nS is a string of length between 1 and 100 (inclusive).\n\nEach character of S is L, R, U, or D.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint Yes if S is easily playable, and No otherwise.\n\nSample Input 1\n\nRUDLUDR\n\nSample Output 1\n\nYes\n\nEvery character in an odd position (1-st, 3-rd, 5-th, 7-th) is R, U, or D.\n\nEvery character in an even position (2-nd, 4-th, 6-th) is L, U, or D.\n\nThus, S is easily playable.\n\nSample Input 2\n\nDULL\n\nSample Output 2\n\nNo\n\nThe 3-rd character is not R, U, nor D, so S is not easily playable.\n\nSample Input 3\n\nUUUUUUUUUUUUUUU\n\nSample Output 3\n\nYes\n\nSample Input 4\n\nULURU\n\nSample Output 4\n\nNo\n\nSample Input 5\n\nRDULULDURURLRDULRLR\n\nSample Output 5\n\nYes", "sample_input": "RUDLUDR\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p02910", "source_text": "Score: 200 points\n\nProblem Statement\n\nTakahashi will do a tap dance. The dance is described by a string S where each character is L, R, U, or D. These characters indicate the positions on which Takahashi should step. He will follow these instructions one by one in order, starting with the first character.\n\nS is said to be easily playable if and only if it satisfies both of the following conditions:\n\nEvery character in an odd position (1-st, 3-rd, 5-th, \\ldots) is R, U, or D.\n\nEvery character in an even position (2-nd, 4-th, 6-th, \\ldots) is L, U, or D.\n\nYour task is to print Yes if S is easily playable, and No otherwise.\n\nConstraints\n\nS is a string of length between 1 and 100 (inclusive).\n\nEach character of S is L, R, U, or D.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint Yes if S is easily playable, and No otherwise.\n\nSample Input 1\n\nRUDLUDR\n\nSample Output 1\n\nYes\n\nEvery character in an odd position (1-st, 3-rd, 5-th, 7-th) is R, U, or D.\n\nEvery character in an even position (2-nd, 4-th, 6-th) is L, U, or D.\n\nThus, S is easily playable.\n\nSample Input 2\n\nDULL\n\nSample Output 2\n\nNo\n\nThe 3-rd character is not R, U, nor D, so S is not easily playable.\n\nSample Input 3\n\nUUUUUUUUUUUUUUU\n\nSample Output 3\n\nYes\n\nSample Input 4\n\nULURU\n\nSample Output 4\n\nNo\n\nSample Input 5\n\nRDULULDURURLRDULRLR\n\nSample Output 5\n\nYes", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 297, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s366026591", "group_id": "codeNet:p02911", "input_text": "n=io.read(\"*n\")\nk=io.read(\"*n\")\nq=io.read(\"*n\")\n\na={}\nfor i=1,q do\n table.insert(a,io.read(\"*n\"))\nend\n\nans={}\nfor i=1,n do\n table.insert(ans,k)\nend\n\nfor i=1,q do\n ans[a[i]]=ans[a[i]]+1\nend\n\nsum=0\nfor i=1,n do\n p=ans[i]-k\n if p>0 then\n sum=sum+p\n end\nend\n\nfor i=1,n do\n ans[i]=ans[i]-sum\n if ans[i]<=0 then\n print(\"No\")\n else\n print(\"Yes\")\n end\nend", "language": "Lua", "metadata": {"date": 1572646368, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p02911.html", "problem_id": "p02911", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02911/input.txt", "sample_output_relpath": "derived/input_output/data/p02911/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02911/Lua/s366026591.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s366026591", "user_id": "u535423069"}, "prompt_components": {"gold_output": "No\nNo\nYes\nNo\nNo\nNo\n", "input_to_evaluate": "n=io.read(\"*n\")\nk=io.read(\"*n\")\nq=io.read(\"*n\")\n\na={}\nfor i=1,q do\n table.insert(a,io.read(\"*n\"))\nend\n\nans={}\nfor i=1,n do\n table.insert(ans,k)\nend\n\nfor i=1,q do\n ans[a[i]]=ans[a[i]]+1\nend\n\nsum=0\nfor i=1,n do\n p=ans[i]-k\n if p>0 then\n sum=sum+p\n end\nend\n\nfor i=1,n do\n ans[i]=ans[i]-sum\n if ans[i]<=0 then\n print(\"No\")\n else\n print(\"Yes\")\n end\nend", "problem_context": "Score: 300 points\n\nProblem Statement\n\nTakahashi has decided to hold fastest-finger-fast quiz games. Kizahashi, who is in charge of making the scoreboard, is struggling to write the program that manages the players' scores in a game, which proceeds as follows.\n\nA game is played by N players, numbered 1 to N. At the beginning of a game, each player has K points.\n\nWhen a player correctly answers a question, each of the other N-1 players receives minus one (-1) point. There is no other factor that affects the players' scores.\n\nAt the end of a game, the players with 0 points or lower are eliminated, and the remaining players survive.\n\nIn the last game, the players gave a total of Q correct answers, the i-th of which was given by Player A_i.\nFor Kizahashi, write a program that determines whether each of the N players survived this game.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 10^5\n\n1 \\leq K \\leq 10^9\n\n1 \\leq Q \\leq 10^5\n\n1 \\leq A_i \\leq N\\ (1 \\leq i \\leq Q)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K Q\nA_1\nA_2\n.\n.\n.\nA_Q\n\nOutput\n\nPrint N lines. The i-th line should contain Yes if Player i survived the game, and No otherwise.\n\nSample Input 1\n\n6 3 4\n3\n1\n3\n2\n\nSample Output 1\n\nNo\nNo\nYes\nNo\nNo\nNo\n\nIn the beginning, the players' scores are (3, 3, 3, 3, 3, 3).\n\nPlayer 3 correctly answers a question. The players' scores are now (2, 2, 3, 2, 2, 2).\n\nPlayer 1 correctly answers a question. The players' scores are now (2, 1, 2, 1, 1, 1).\n\nPlayer 3 correctly answers a question. The players' scores are now (1, 0, 2, 0, 0, 0).\n\nPlayer 2 correctly answers a question. The players' scores are now (0, 0, 1, -1, -1, -1).\n\nPlayers 1, 2, 4, 5 and 6, who have 0 points or lower, are eliminated, and Player 3 survives this game.\n\nSample Input 2\n\n6 5 4\n3\n1\n3\n2\n\nSample Output 2\n\nYes\nYes\nYes\nYes\nYes\nYes\n\nSample Input 3\n\n10 13 15\n3\n1\n4\n1\n5\n9\n2\n6\n5\n3\n5\n8\n9\n7\n9\n\nSample Output 3\n\nNo\nNo\nNo\nNo\nYes\nNo\nNo\nNo\nYes\nNo", "sample_input": "6 3 4\n3\n1\n3\n2\n"}, "reference_outputs": ["No\nNo\nYes\nNo\nNo\nNo\n"], "source_document_id": "p02911", "source_text": "Score: 300 points\n\nProblem Statement\n\nTakahashi has decided to hold fastest-finger-fast quiz games. Kizahashi, who is in charge of making the scoreboard, is struggling to write the program that manages the players' scores in a game, which proceeds as follows.\n\nA game is played by N players, numbered 1 to N. At the beginning of a game, each player has K points.\n\nWhen a player correctly answers a question, each of the other N-1 players receives minus one (-1) point. There is no other factor that affects the players' scores.\n\nAt the end of a game, the players with 0 points or lower are eliminated, and the remaining players survive.\n\nIn the last game, the players gave a total of Q correct answers, the i-th of which was given by Player A_i.\nFor Kizahashi, write a program that determines whether each of the N players survived this game.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 10^5\n\n1 \\leq K \\leq 10^9\n\n1 \\leq Q \\leq 10^5\n\n1 \\leq A_i \\leq N\\ (1 \\leq i \\leq Q)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K Q\nA_1\nA_2\n.\n.\n.\nA_Q\n\nOutput\n\nPrint N lines. The i-th line should contain Yes if Player i survived the game, and No otherwise.\n\nSample Input 1\n\n6 3 4\n3\n1\n3\n2\n\nSample Output 1\n\nNo\nNo\nYes\nNo\nNo\nNo\n\nIn the beginning, the players' scores are (3, 3, 3, 3, 3, 3).\n\nPlayer 3 correctly answers a question. The players' scores are now (2, 2, 3, 2, 2, 2).\n\nPlayer 1 correctly answers a question. The players' scores are now (2, 1, 2, 1, 1, 1).\n\nPlayer 3 correctly answers a question. The players' scores are now (1, 0, 2, 0, 0, 0).\n\nPlayer 2 correctly answers a question. The players' scores are now (0, 0, 1, -1, -1, -1).\n\nPlayers 1, 2, 4, 5 and 6, who have 0 points or lower, are eliminated, and Player 3 survives this game.\n\nSample Input 2\n\n6 5 4\n3\n1\n3\n2\n\nSample Output 2\n\nYes\nYes\nYes\nYes\nYes\nYes\n\nSample Input 3\n\n10 13 15\n3\n1\n4\n1\n5\n9\n2\n6\n5\n3\n5\n8\n9\n7\n9\n\nSample Output 3\n\nNo\nNo\nNo\nNo\nYes\nNo\nNo\nNo\nYes\nNo", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 366, "cpu_time_ms": 53, "memory_kb": 2812}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s931644853", "group_id": "codeNet:p02915", "input_text": "a = io.read(\"*n\")\nprint(a*a*a)", "language": "Lua", "metadata": {"date": 1577969289, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p02915.html", "problem_id": "p02915", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02915/input.txt", "sample_output_relpath": "derived/input_output/data/p02915/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02915/Lua/s931644853.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s931644853", "user_id": "u120582723"}, "prompt_components": {"gold_output": "8\n", "input_to_evaluate": "a = io.read(\"*n\")\nprint(a*a*a)", "problem_context": "Score : 100 points\n\nProblem Statement\n\nTakahashi is going to set a 3-character password.\n\nHow many possible passwords are there if each of its characters must be a digit between 1 and N (inclusive)?\n\nConstraints\n\n1 \\leq N \\leq 9\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the number of possible passwords.\n\nSample Input 1\n\n2\n\nSample Output 1\n\n8\n\nThere are eight possible passwords: 111, 112, 121, 122, 211, 212, 221, and 222.\n\nSample Input 2\n\n1\n\nSample Output 2\n\n1\n\nThere is only one possible password if you can only use one kind of character.", "sample_input": "2\n"}, "reference_outputs": ["8\n"], "source_document_id": "p02915", "source_text": "Score : 100 points\n\nProblem Statement\n\nTakahashi is going to set a 3-character password.\n\nHow many possible passwords are there if each of its characters must be a digit between 1 and N (inclusive)?\n\nConstraints\n\n1 \\leq N \\leq 9\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the number of possible passwords.\n\nSample Input 1\n\n2\n\nSample Output 1\n\n8\n\nThere are eight possible passwords: 111, 112, 121, 122, 211, 212, 221, and 222.\n\nSample Input 2\n\n1\n\nSample Output 2\n\n1\n\nThere is only one possible password if you can only use one kind of character.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 30, "cpu_time_ms": 14, "memory_kb": 760}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s150543565", "group_id": "codeNet:p02916", "input_text": "local n=io.read(\"n\")\nlocal a,b,c={},{},{}\nfor i=1,n do\n a[i]=io.read(\"n\")\nend\nfor i=1,n do\n b[i]=io.read(\"n\")\nend\nfor i=1,n-1 do\n c[i]=io.read(\"n\")\nend\n\nlocal total=0\nfor i=1,n do\n if i>=2 then\n total=total+b[a[i]]+(a[i-1]+1==a[i] and c[a[i-1]] or 0)\n else\n total=total+b[a[i]]\n end\nend\nprint(total)", "language": "Lua", "metadata": {"date": 1596857004, "filename_ext": "lua", "original_language": "Lua (Lua 5.3.5)", "problem_description_relpath": "problem_descriptions/p02916.html", "problem_id": "p02916", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02916/input.txt", "sample_output_relpath": "derived/input_output/data/p02916/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02916/Lua/s150543565.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s150543565", "user_id": "u045238009"}, "prompt_components": {"gold_output": "14\n", "input_to_evaluate": "local n=io.read(\"n\")\nlocal a,b,c={},{},{}\nfor i=1,n do\n a[i]=io.read(\"n\")\nend\nfor i=1,n do\n b[i]=io.read(\"n\")\nend\nfor i=1,n-1 do\n c[i]=io.read(\"n\")\nend\n\nlocal total=0\nfor i=1,n do\n if i>=2 then\n total=total+b[a[i]]+(a[i-1]+1==a[i] and c[a[i-1]] or 0)\n else\n total=total+b[a[i]]\n end\nend\nprint(total)", "problem_context": "Score : 200 points\n\nProblem Statement\n\nTakahashi went to an all-you-can-eat buffet with N kinds of dishes and ate all of them (Dish 1, Dish 2, \\ldots, Dish N) once.\n\nThe i-th dish (1 \\leq i \\leq N) he ate was Dish A_i.\n\nWhen he eats Dish i (1 \\leq i \\leq N), he gains B_i satisfaction points.\n\nAdditionally, when he eats Dish i+1 just after eating Dish i (1 \\leq i \\leq N - 1), he gains C_i more satisfaction points.\n\nFind the sum of the satisfaction points he gained.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 20\n\n1 \\leq A_i \\leq N\n\nA_1, A_2, ..., A_N are all different.\n\n1 \\leq B_i \\leq 50\n\n1 \\leq C_i \\leq 50\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\nB_1 B_2 ... B_N\nC_1 C_2 ... C_{N-1}\n\nOutput\n\nPrint the sum of the satisfaction points Takahashi gained, as an integer.\n\nSample Input 1\n\n3\n3 1 2\n2 5 4\n3 6\n\nSample Output 1\n\n14\n\nTakahashi gained 14 satisfaction points in total, as follows:\n\nFirst, he ate Dish 3 and gained 4 satisfaction points.\n\nNext, he ate Dish 1 and gained 2 satisfaction points.\n\nLastly, he ate Dish 2 and gained 5 + 3 = 8 satisfaction points.\n\nSample Input 2\n\n4\n2 3 4 1\n13 5 8 24\n45 9 15\n\nSample Output 2\n\n74\n\nSample Input 3\n\n2\n1 2\n50 50\n50\n\nSample Output 3\n\n150", "sample_input": "3\n3 1 2\n2 5 4\n3 6\n"}, "reference_outputs": ["14\n"], "source_document_id": "p02916", "source_text": "Score : 200 points\n\nProblem Statement\n\nTakahashi went to an all-you-can-eat buffet with N kinds of dishes and ate all of them (Dish 1, Dish 2, \\ldots, Dish N) once.\n\nThe i-th dish (1 \\leq i \\leq N) he ate was Dish A_i.\n\nWhen he eats Dish i (1 \\leq i \\leq N), he gains B_i satisfaction points.\n\nAdditionally, when he eats Dish i+1 just after eating Dish i (1 \\leq i \\leq N - 1), he gains C_i more satisfaction points.\n\nFind the sum of the satisfaction points he gained.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 20\n\n1 \\leq A_i \\leq N\n\nA_1, A_2, ..., A_N are all different.\n\n1 \\leq B_i \\leq 50\n\n1 \\leq C_i \\leq 50\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\nB_1 B_2 ... B_N\nC_1 C_2 ... C_{N-1}\n\nOutput\n\nPrint the sum of the satisfaction points Takahashi gained, as an integer.\n\nSample Input 1\n\n3\n3 1 2\n2 5 4\n3 6\n\nSample Output 1\n\n14\n\nTakahashi gained 14 satisfaction points in total, as follows:\n\nFirst, he ate Dish 3 and gained 4 satisfaction points.\n\nNext, he ate Dish 1 and gained 2 satisfaction points.\n\nLastly, he ate Dish 2 and gained 5 + 3 = 8 satisfaction points.\n\nSample Input 2\n\n4\n2 3 4 1\n13 5 8 24\n45 9 15\n\nSample Output 2\n\n74\n\nSample Input 3\n\n2\n1 2\n50 50\n50\n\nSample Output 3\n\n150", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 331, "cpu_time_ms": 7, "memory_kb": 2780}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s812924560", "group_id": "codeNet:p02916", "input_text": "function split(s, c)\n if string.find(s, c) == nil then\n return { s }\n end\n\n local cs = {}\n \n local lastPos = 0\n for part, p in string.gmatch(s, \"(.-)\" .. c .. \"()\") do\n table.insert(cs, part)\n lastPos = p\n end\n\n table.insert(cs, string.sub(s, lastPos))\n\n return cs\nend\n\nn=io.read(\"*n\")\nans=0\na={}\n\nprint(\"\")\n\nfor i=0, n-1 do\n table.insert(a, i, io.read(\"*n\")-1)\nend\n\nfor i=0, n-1 do\n ans = ans + io.read(\"*n\")\nend\n\nc={}\nfor i=0, n-2 do\n table.insert(c, i, io.read(\"*n\"))\nend\n\nfor i=0, n-2 do\n if a[i]+1 == a[i+1] then\n ans = ans + c[a[i]]\n end\nend\n\nprint(ans)", "language": "Lua", "metadata": {"date": 1567918051, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p02916.html", "problem_id": "p02916", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02916/input.txt", "sample_output_relpath": "derived/input_output/data/p02916/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02916/Lua/s812924560.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s812924560", "user_id": "u535423069"}, "prompt_components": {"gold_output": "14\n", "input_to_evaluate": "function split(s, c)\n if string.find(s, c) == nil then\n return { s }\n end\n\n local cs = {}\n \n local lastPos = 0\n for part, p in string.gmatch(s, \"(.-)\" .. c .. \"()\") do\n table.insert(cs, part)\n lastPos = p\n end\n\n table.insert(cs, string.sub(s, lastPos))\n\n return cs\nend\n\nn=io.read(\"*n\")\nans=0\na={}\n\nprint(\"\")\n\nfor i=0, n-1 do\n table.insert(a, i, io.read(\"*n\")-1)\nend\n\nfor i=0, n-1 do\n ans = ans + io.read(\"*n\")\nend\n\nc={}\nfor i=0, n-2 do\n table.insert(c, i, io.read(\"*n\"))\nend\n\nfor i=0, n-2 do\n if a[i]+1 == a[i+1] then\n ans = ans + c[a[i]]\n end\nend\n\nprint(ans)", "problem_context": "Score : 200 points\n\nProblem Statement\n\nTakahashi went to an all-you-can-eat buffet with N kinds of dishes and ate all of them (Dish 1, Dish 2, \\ldots, Dish N) once.\n\nThe i-th dish (1 \\leq i \\leq N) he ate was Dish A_i.\n\nWhen he eats Dish i (1 \\leq i \\leq N), he gains B_i satisfaction points.\n\nAdditionally, when he eats Dish i+1 just after eating Dish i (1 \\leq i \\leq N - 1), he gains C_i more satisfaction points.\n\nFind the sum of the satisfaction points he gained.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 20\n\n1 \\leq A_i \\leq N\n\nA_1, A_2, ..., A_N are all different.\n\n1 \\leq B_i \\leq 50\n\n1 \\leq C_i \\leq 50\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\nB_1 B_2 ... B_N\nC_1 C_2 ... C_{N-1}\n\nOutput\n\nPrint the sum of the satisfaction points Takahashi gained, as an integer.\n\nSample Input 1\n\n3\n3 1 2\n2 5 4\n3 6\n\nSample Output 1\n\n14\n\nTakahashi gained 14 satisfaction points in total, as follows:\n\nFirst, he ate Dish 3 and gained 4 satisfaction points.\n\nNext, he ate Dish 1 and gained 2 satisfaction points.\n\nLastly, he ate Dish 2 and gained 5 + 3 = 8 satisfaction points.\n\nSample Input 2\n\n4\n2 3 4 1\n13 5 8 24\n45 9 15\n\nSample Output 2\n\n74\n\nSample Input 3\n\n2\n1 2\n50 50\n50\n\nSample Output 3\n\n150", "sample_input": "3\n3 1 2\n2 5 4\n3 6\n"}, "reference_outputs": ["14\n"], "source_document_id": "p02916", "source_text": "Score : 200 points\n\nProblem Statement\n\nTakahashi went to an all-you-can-eat buffet with N kinds of dishes and ate all of them (Dish 1, Dish 2, \\ldots, Dish N) once.\n\nThe i-th dish (1 \\leq i \\leq N) he ate was Dish A_i.\n\nWhen he eats Dish i (1 \\leq i \\leq N), he gains B_i satisfaction points.\n\nAdditionally, when he eats Dish i+1 just after eating Dish i (1 \\leq i \\leq N - 1), he gains C_i more satisfaction points.\n\nFind the sum of the satisfaction points he gained.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 20\n\n1 \\leq A_i \\leq N\n\nA_1, A_2, ..., A_N are all different.\n\n1 \\leq B_i \\leq 50\n\n1 \\leq C_i \\leq 50\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\nB_1 B_2 ... B_N\nC_1 C_2 ... C_{N-1}\n\nOutput\n\nPrint the sum of the satisfaction points Takahashi gained, as an integer.\n\nSample Input 1\n\n3\n3 1 2\n2 5 4\n3 6\n\nSample Output 1\n\n14\n\nTakahashi gained 14 satisfaction points in total, as follows:\n\nFirst, he ate Dish 3 and gained 4 satisfaction points.\n\nNext, he ate Dish 1 and gained 2 satisfaction points.\n\nLastly, he ate Dish 2 and gained 5 + 3 = 8 satisfaction points.\n\nSample Input 2\n\n4\n2 3 4 1\n13 5 8 24\n45 9 15\n\nSample Output 2\n\n74\n\nSample Input 3\n\n2\n1 2\n50 50\n50\n\nSample Output 3\n\n150", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 585, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s050653270", "group_id": "codeNet:p02917", "input_text": "local read = setmetatable({}, {__index = function(t, k) local a = {} for i=1,#k do table.insert(a, string.sub(k, i, i)) end local r = io.read local u = table.unpack return function() return r(u(a)) end end})\nlocal N = read.n()\nlocal B = {}\nfor i=1,N-1 do B[i] = read.n() end\n\nlocal AN = B[N-1]\nlocal ans = AN\nlocal next = AN\nfor i=N-1,2,-1 do\n local Ai = math.min(B[i-1], next)\n ans = ans + Ai\n next = Ai\nend\nlocal A1 = B[1]\nans = ans + A1\nprint(ans)", "language": "Lua", "metadata": {"date": 1567905450, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p02917.html", "problem_id": "p02917", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02917/input.txt", "sample_output_relpath": "derived/input_output/data/p02917/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02917/Lua/s050653270.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s050653270", "user_id": "u162773977"}, "prompt_components": {"gold_output": "9\n", "input_to_evaluate": "local read = setmetatable({}, {__index = function(t, k) local a = {} for i=1,#k do table.insert(a, string.sub(k, i, i)) end local r = io.read local u = table.unpack return function() return r(u(a)) end end})\nlocal N = read.n()\nlocal B = {}\nfor i=1,N-1 do B[i] = read.n() end\n\nlocal AN = B[N-1]\nlocal ans = AN\nlocal next = AN\nfor i=N-1,2,-1 do\n local Ai = math.min(B[i-1], next)\n ans = ans + Ai\n next = Ai\nend\nlocal A1 = B[1]\nans = ans + A1\nprint(ans)", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere is an integer sequence A of length N whose values are unknown.\n\nGiven is an integer sequence B of length N-1 which is known to satisfy the following:\n\nB_i \\geq \\max(A_i, A_{i+1})\n\nFind the maximum possible sum of the elements of A.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 100\n\n0 \\leq B_i \\leq 10^5\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nB_1 B_2 ... B_{N-1}\n\nOutput\n\nPrint the maximum possible sum of the elements of A.\n\nSample Input 1\n\n3\n2 5\n\nSample Output 1\n\n9\n\nA can be, for example, ( 2 , 1 , 5 ), ( -1 , -2 , -3 ), or ( 2 , 2 , 5 ). Among those candidates, A = ( 2 , 2 , 5 ) has the maximum possible sum.\n\nSample Input 2\n\n2\n3\n\nSample Output 2\n\n6\n\nSample Input 3\n\n6\n0 153 10 10 23\n\nSample Output 3\n\n53", "sample_input": "3\n2 5\n"}, "reference_outputs": ["9\n"], "source_document_id": "p02917", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere is an integer sequence A of length N whose values are unknown.\n\nGiven is an integer sequence B of length N-1 which is known to satisfy the following:\n\nB_i \\geq \\max(A_i, A_{i+1})\n\nFind the maximum possible sum of the elements of A.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 100\n\n0 \\leq B_i \\leq 10^5\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nB_1 B_2 ... B_{N-1}\n\nOutput\n\nPrint the maximum possible sum of the elements of A.\n\nSample Input 1\n\n3\n2 5\n\nSample Output 1\n\n9\n\nA can be, for example, ( 2 , 1 , 5 ), ( -1 , -2 , -3 ), or ( 2 , 2 , 5 ). Among those candidates, A = ( 2 , 2 , 5 ) has the maximum possible sum.\n\nSample Input 2\n\n2\n3\n\nSample Output 2\n\n6\n\nSample Input 3\n\n6\n0 153 10 10 23\n\nSample Output 3\n\n53", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 459, "cpu_time_ms": 8, "memory_kb": 760}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s297596399", "group_id": "codeNet:p02918", "input_text": "local n, k = io.read(\"*n\", \"*n\", \"*l\")\nlocal s = io.read()\nlocal prv = s:sub(1, 1)\nlocal nxt = \"\"\nlocal changed = 0\nlocal score = 0\nfor i = 2, n do\n nxt = s:sub(i, i)\n if prv == nxt then\n score = score + 1\n else\n changed = changed + 1\n end\n prv = nxt\nend\nwhile 0 < changed and 0 < k do\n if 2 <= changed then\n changed = changed - 2\n k = k - 1\n score = score + 2\n else\n changed = changed - 1\n k = k - 1\n score = score + 1\n end\nend\nprint(score)\n", "language": "Lua", "metadata": {"date": 1567911465, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p02918.html", "problem_id": "p02918", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02918/input.txt", "sample_output_relpath": "derived/input_output/data/p02918/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02918/Lua/s297596399.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s297596399", "user_id": "u120582723"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "local n, k = io.read(\"*n\", \"*n\", \"*l\")\nlocal s = io.read()\nlocal prv = s:sub(1, 1)\nlocal nxt = \"\"\nlocal changed = 0\nlocal score = 0\nfor i = 2, n do\n nxt = s:sub(i, i)\n if prv == nxt then\n score = score + 1\n else\n changed = changed + 1\n end\n prv = nxt\nend\nwhile 0 < changed and 0 < k do\n if 2 <= changed then\n changed = changed - 2\n k = k - 1\n score = score + 2\n else\n changed = changed - 1\n k = k - 1\n score = score + 1\n end\nend\nprint(score)\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nThere are N people standing in a queue from west to east.\n\nGiven is a string S of length N representing the directions of the people.\nThe i-th person from the west is facing west if the i-th character of S is L, and east if that character of S is R.\n\nA person is happy if the person in front of him/her is facing the same direction.\nIf no person is standing in front of a person, however, he/she is not happy.\n\nYou can perform the following operation any number of times between 0 and K (inclusive):\n\nOperation: Choose integers l and r such that 1 \\leq l \\leq r \\leq N, and rotate by 180 degrees the part of the queue: the l-th, (l+1)-th, ..., r-th persons. That is, for each i = 0, 1, ..., r-l, the (l + i)-th person from the west will stand the (r - i)-th from the west after the operation, facing east if he/she is facing west now, and vice versa.\n\nWhat is the maximum possible number of happy people you can have?\n\nConstraints\n\nN is an integer satisfying 1 \\leq N \\leq 10^5.\n\nK is an integer satisfying 1 \\leq K \\leq 10^5.\n\n|S| = N\n\nEach character of S is L or R.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nS\n\nOutput\n\nPrint the maximum possible number of happy people after at most K operations.\n\nSample Input 1\n\n6 1\nLRLRRL\n\nSample Output 1\n\n3\n\nIf we choose (l, r) = (2, 5), we have LLLRLL, where the 2-nd, 3-rd, and 6-th persons from the west are happy.\n\nSample Input 2\n\n13 3\nLRRLRLRRLRLLR\n\nSample Output 2\n\n9\n\nSample Input 3\n\n10 1\nLLLLLRRRRR\n\nSample Output 3\n\n9\n\nSample Input 4\n\n9 2\nRRRLRLRLL\n\nSample Output 4\n\n7", "sample_input": "6 1\nLRLRRL\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02918", "source_text": "Score : 400 points\n\nProblem Statement\n\nThere are N people standing in a queue from west to east.\n\nGiven is a string S of length N representing the directions of the people.\nThe i-th person from the west is facing west if the i-th character of S is L, and east if that character of S is R.\n\nA person is happy if the person in front of him/her is facing the same direction.\nIf no person is standing in front of a person, however, he/she is not happy.\n\nYou can perform the following operation any number of times between 0 and K (inclusive):\n\nOperation: Choose integers l and r such that 1 \\leq l \\leq r \\leq N, and rotate by 180 degrees the part of the queue: the l-th, (l+1)-th, ..., r-th persons. That is, for each i = 0, 1, ..., r-l, the (l + i)-th person from the west will stand the (r - i)-th from the west after the operation, facing east if he/she is facing west now, and vice versa.\n\nWhat is the maximum possible number of happy people you can have?\n\nConstraints\n\nN is an integer satisfying 1 \\leq N \\leq 10^5.\n\nK is an integer satisfying 1 \\leq K \\leq 10^5.\n\n|S| = N\n\nEach character of S is L or R.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nS\n\nOutput\n\nPrint the maximum possible number of happy people after at most K operations.\n\nSample Input 1\n\n6 1\nLRLRRL\n\nSample Output 1\n\n3\n\nIf we choose (l, r) = (2, 5), we have LLLRLL, where the 2-nd, 3-rd, and 6-th persons from the west are happy.\n\nSample Input 2\n\n13 3\nLRRLRLRRLRLLR\n\nSample Output 2\n\n9\n\nSample Input 3\n\n10 1\nLLLLLRRRRR\n\nSample Output 3\n\n9\n\nSample Input 4\n\n9 2\nRRRLRLRLL\n\nSample Output 4\n\n7", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 474, "cpu_time_ms": 18, "memory_kb": 888}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s329001645", "group_id": "codeNet:p02919", "input_text": "function comp_rev(a, b)\n if a > b then\n return true\n end\n\n return false\nend\n\n\nn=io.read(\"*n\")\np={}\n\nfor i=1, n do\n table.insert(p, i, io.read(\"*n\"))\nend\n\nans=0\n\nfor i=1, n-1 do\n for j=i+1, n do\n m={}\n for l=i, j do\n table.insert(m, p[l])\n end\n table.sort(m, comp_rev)\n ans = ans + m[2]\n end\nend\n\nprint(ans)", "language": "Lua", "metadata": {"date": 1568417386, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p02919.html", "problem_id": "p02919", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02919/input.txt", "sample_output_relpath": "derived/input_output/data/p02919/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02919/Lua/s329001645.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s329001645", "user_id": "u535423069"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "function comp_rev(a, b)\n if a > b then\n return true\n end\n\n return false\nend\n\n\nn=io.read(\"*n\")\np={}\n\nfor i=1, n do\n table.insert(p, i, io.read(\"*n\"))\nend\n\nans=0\n\nfor i=1, n-1 do\n for j=i+1, n do\n m={}\n for l=i, j do\n table.insert(m, p[l])\n end\n table.sort(m, comp_rev)\n ans = ans + m[2]\n end\nend\n\nprint(ans)", "problem_context": "Score: 500 points\n\nProblem Statement\n\nGiven is a permutation P of \\{1, 2, \\ldots, N\\}.\n\nFor a pair (L, R) (1 \\le L \\lt R \\le N), let X_{L, R} be the second largest value among P_L, P_{L+1}, \\ldots, P_R.\n\nFind \\displaystyle \\sum_{L=1}^{N-1} \\sum_{R=L+1}^{N} X_{L,R}.\n\nConstraints\n\n2 \\le N \\le 10^5\n\n1 \\le P_i \\le N\n\nP_i \\neq P_j (i \\neq j)\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nP_1 P_2 \\ldots P_N\n\nOutput\n\nPrint \\displaystyle \\sum_{L=1}^{N-1} \\sum_{R=L+1}^{N} X_{L,R}.\n\nSample Input 1\n\n3\n2 3 1\n\nSample Output 1\n\n5\n\nX_{1, 2} = 2, X_{1, 3} = 2, and X_{2, 3} = 1, so the sum is 2 + 2 + 1 = 5.\n\nSample Input 2\n\n5\n1 2 3 4 5\n\nSample Output 2\n\n30\n\nSample Input 3\n\n8\n8 2 7 3 4 5 6 1\n\nSample Output 3\n\n136", "sample_input": "3\n2 3 1\n"}, "reference_outputs": ["5\n"], "source_document_id": "p02919", "source_text": "Score: 500 points\n\nProblem Statement\n\nGiven is a permutation P of \\{1, 2, \\ldots, N\\}.\n\nFor a pair (L, R) (1 \\le L \\lt R \\le N), let X_{L, R} be the second largest value among P_L, P_{L+1}, \\ldots, P_R.\n\nFind \\displaystyle \\sum_{L=1}^{N-1} \\sum_{R=L+1}^{N} X_{L,R}.\n\nConstraints\n\n2 \\le N \\le 10^5\n\n1 \\le P_i \\le N\n\nP_i \\neq P_j (i \\neq j)\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nP_1 P_2 \\ldots P_N\n\nOutput\n\nPrint \\displaystyle \\sum_{L=1}^{N-1} \\sum_{R=L+1}^{N} X_{L,R}.\n\nSample Input 1\n\n3\n2 3 1\n\nSample Output 1\n\n5\n\nX_{1, 2} = 2, X_{1, 3} = 2, and X_{2, 3} = 1, so the sum is 2 + 2 + 1 = 5.\n\nSample Input 2\n\n5\n1 2 3 4 5\n\nSample Output 2\n\n30\n\nSample Input 3\n\n8\n8 2 7 3 4 5 6 1\n\nSample Output 3\n\n136", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 335, "cpu_time_ms": 2103, "memory_kb": 3200}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s753568118", "group_id": "codeNet:p02920", "input_text": "local bls = bit.lshift\nlocal mma = math.max\nlocal mfl, mce, mmi = math.floor, math.ceil, math.min\n\nlocal AvlTree = {}\nAvlTree.makenode = function(self, val, parent)\n local i = self.box[#self.box]\n if not i then i = #self.v + 1\n else table.remove(self.box)\n end\n self.v[i], self.p[i] = val, parent\n self.lc[i], self.rc[i], self.l[i], self.r[i] = 0, 0, 1, 1\n return i\nend\nAvlTree.create = function(self, lessthan, n)\n self.lessthan = lessthan\n self.root = 1\n self.box = {}\n for i = n + 1, 2, -1 do table.insert(self.box, i) end\n -- value, leftCount, rightCount, left, right, parent\n self.v, self.lc, self.rc, self.l, self.r, self.p = {}, {}, {}, {}, {}, {}\n for i = 1, n + 1 do\n self.v[i], self.p[i] = 0, 1\n self.lc[i], self.rc[i], self.l[i], self.r[i] = 0, 0, 1, 1\n end\nend\n\nAvlTree.recalc = function(self, i)\n local kl, kr = self.l[i], self.r[i]\n if 1 < kl then self.lc[i] = 1 + mma(self.lc[kl], self.rc[kl])\n else self.lc[i] = 0\n end\n if 1 < kr then self.rc[i] = 1 + mma(self.lc[kr], self.rc[kr])\n else self.rc[i] = 0\n end\nend\nAvlTree.recalcAll = function(self, i)\n while 1 < i do\n self:recalc(i)\n i = self.p[i]\n end\nend\n\nAvlTree.rotR = function(self, parent)\n local granp, child = self.p[parent], self.l[parent]\n self.r[child], self.l[parent] = parent, self.r[child]\n self.p[child], self.p[parent] = granp, child\n self.p[self.l[parent]] = parent\n if 1 < granp then\n if self.l[granp] == parent then\n self.l[granp] = child\n else\n self.r[granp] = child\n end\n else\n self.root = child\n end\nend\n\nAvlTree.rotL = function(self, parent)\n local granp, child = self.p[parent], self.r[parent]\n self.l[child], self.r[parent] = parent, self.l[child]\n self.p[child], self.p[parent] = granp, child\n self.p[self.r[parent]] = parent\n if 1 < granp then\n if self.r[granp] == parent then\n self.r[granp] = child\n else\n self.l[granp] = child\n end\n else\n self.root = child\n end\nend\n\nAvlTree.rotLR = function(self, lparent, rparent)\n local sp, sl, sr = self.p, self.l, self.r\n local granp, d = sp[rparent], sr[lparent]\n sp[lparent], sr[lparent] = d, sl[d]\n sp[rparent], sl[rparent] = d, sr[d]\n sp[sl[d]], sp[sr[d]] = lparent, rparent\n sp[d], sl[d], sr[d] = granp, lparent, rparent\n if 1 < granp then\n if sr[granp] == rparent then sr[granp] = d\n else sl[granp] = d\n end\n else self.root = d\n end\nend\n\nAvlTree.rotRL = function(self, rparent, lparent)\n local sp, sl, sr = self.p, self.l, self.r\n local granp, d = sp[lparent], sl[rparent]\n sp[rparent], sl[rparent] = d, sr[d]\n sp[lparent], sr[lparent] = d, sl[d]\n sp[sr[d]], sp[sl[d]] = rparent, lparent\n sp[d], sr[d], sl[d] = granp, rparent, lparent\n if 1 < granp then\n if sl[granp] == lparent then sl[granp] = d\n else sr[granp] = d\n end\n else self.root = d\n end\nend\nAvlTree.empty = function(self) return self.root <= 1 end\nAvlTree.push = function(self, val)\n if self.root <= 1 then self.root = self:makenode(val, 1) return end\n local pos = self.root\n while true do\n if self.lessthan(val, self.v[pos]) then\n if 1 < self.l[pos] then\n pos = self.l[pos]\n else\n self.l[pos] = self:makenode(val, pos)\n pos = self.l[pos]\n break\n end\n else\n if 1 < self.r[pos] then\n pos = self.r[pos]\n else\n self.r[pos] = self:makenode(val, pos)\n pos = self.r[pos]\n break\n end\n end\n end\n while 1 < pos do\n local child, parent = pos, self.p[pos]\n if parent <= 1 then\n break\n end\n self:recalc(parent)\n local lcp_m_rcp = self.lc[parent] - self.rc[parent]\n if lcp_m_rcp % 2 ~= 0 then -- 1 or -1\n pos = parent\n elseif lcp_m_rcp == 2 then\n if self.lc[child] - 1 == self.rc[child] then\n self:rotR(parent)\n self:recalcAll(parent)\n else\n self:rotLR(child, parent)\n self:recalc(child)\n self:recalcAll(parent)\n end\n break\n elseif lcp_m_rcp == -2 then\n if self.rc[child] - 1 == self.lc[child] then\n self:rotL(parent)\n self:recalcAll(parent)\n else\n self:rotRL(child, parent)\n self:recalc(child)\n self:recalcAll(parent)\n end\n break\n else\n break\n end\n end\nend\n\nAvlTree.rmsub = function(self, node)\n while 1 < node do\n self:recalc(node)\n if self.lc[node] == self.rc[node] then\n node = self.p[node]\n elseif self.lc[node] + 1 == self.rc[node] then\n self:recalcAll(self.p[node])\n break\n else\n if self.lc[self.r[node]] == self.rc[self.r[node]] then\n self:rotL(node)\n self:recalcAll(node)\n break\n elseif self.lc[self.r[node]] + 1 == self.rc[self.r[node]] then\n local nr = self.r[node]\n self:rotL(node)\n self:recalc(node)\n node = nr\n else\n local nr = self.r[node]\n local nrl = self.l[nr]\n self:rotRL(nr, node)\n self:recalc(nr)\n self:recalc(node)\n node = nrl\n end\n end\n end\nend\n\nAvlTree.pop = function(self)\n local node = self.root\n while 1 < self.l[node] do\n node = self.l[node]\n end\n local v = self.v[node]\n local kp = self.p[node]\n self.p[self.r[node]] = kp\n if 1 < kp then\n self.l[kp] = self.r[node]\n self:rmsub(kp)\n else\n self.root = self.r[node]\n end\n table.insert(self.box, node)\n return v\nend\n\nAvlTree.new = function(lessthan, n)\n local obj = {}\n setmetatable(obj, {__index = AvlTree})\n obj:create(lessthan, n)\n return obj\nend\n\nlocal nd = io.read(\"*n\")\nlocal n = bls(1, nd)\nlocal t = {}\nfor i = 1, n do\n t[i] = io.read(\"*n\")\nend\ntable.sort(t, function(a, b) return a > b end)\nt[n + 1] = -1\n\nlocal lv0 = 0\nlocal avl = AvlTree.new(function(a, b) return a > b end, 1)\navl:push(nd)\nlocal rem = 1\n\nlocal left = 1\nlocal z = {}\nwhile true do\n local right = left\n while t[left] == t[right + 1] do\n right = right + 1\n end\n local taskcnt = right - left + 1\n for i = 1, taskcnt do\n if avl:empty() then\n local rem = taskcnt + 1 - i\n if rem <= lv0 then\n lv0 = lv0 - rem\n taskcnt = i - 1\n break\n else\n print(\"No\")\n os.exit()\n end\n end\n z[i] = avl:pop()\n end\n lv0 = lv0 + taskcnt\n for i = 1, taskcnt do\n local v = z[i]\n for j = 1, v - 1 do\n avl:push(j)\n end\n end\n left = right + 1\n if n < left then break end\nend\nprint(\"Yes\")\n", "language": "Lua", "metadata": {"date": 1597939264, "filename_ext": "lua", "original_language": "Lua (LuaJIT 2.1.0)", "problem_description_relpath": "problem_descriptions/p02920.html", "problem_id": "p02920", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02920/input.txt", "sample_output_relpath": "derived/input_output/data/p02920/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02920/Lua/s753568118.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s753568118", "user_id": "u120582723"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "local bls = bit.lshift\nlocal mma = math.max\nlocal mfl, mce, mmi = math.floor, math.ceil, math.min\n\nlocal AvlTree = {}\nAvlTree.makenode = function(self, val, parent)\n local i = self.box[#self.box]\n if not i then i = #self.v + 1\n else table.remove(self.box)\n end\n self.v[i], self.p[i] = val, parent\n self.lc[i], self.rc[i], self.l[i], self.r[i] = 0, 0, 1, 1\n return i\nend\nAvlTree.create = function(self, lessthan, n)\n self.lessthan = lessthan\n self.root = 1\n self.box = {}\n for i = n + 1, 2, -1 do table.insert(self.box, i) end\n -- value, leftCount, rightCount, left, right, parent\n self.v, self.lc, self.rc, self.l, self.r, self.p = {}, {}, {}, {}, {}, {}\n for i = 1, n + 1 do\n self.v[i], self.p[i] = 0, 1\n self.lc[i], self.rc[i], self.l[i], self.r[i] = 0, 0, 1, 1\n end\nend\n\nAvlTree.recalc = function(self, i)\n local kl, kr = self.l[i], self.r[i]\n if 1 < kl then self.lc[i] = 1 + mma(self.lc[kl], self.rc[kl])\n else self.lc[i] = 0\n end\n if 1 < kr then self.rc[i] = 1 + mma(self.lc[kr], self.rc[kr])\n else self.rc[i] = 0\n end\nend\nAvlTree.recalcAll = function(self, i)\n while 1 < i do\n self:recalc(i)\n i = self.p[i]\n end\nend\n\nAvlTree.rotR = function(self, parent)\n local granp, child = self.p[parent], self.l[parent]\n self.r[child], self.l[parent] = parent, self.r[child]\n self.p[child], self.p[parent] = granp, child\n self.p[self.l[parent]] = parent\n if 1 < granp then\n if self.l[granp] == parent then\n self.l[granp] = child\n else\n self.r[granp] = child\n end\n else\n self.root = child\n end\nend\n\nAvlTree.rotL = function(self, parent)\n local granp, child = self.p[parent], self.r[parent]\n self.l[child], self.r[parent] = parent, self.l[child]\n self.p[child], self.p[parent] = granp, child\n self.p[self.r[parent]] = parent\n if 1 < granp then\n if self.r[granp] == parent then\n self.r[granp] = child\n else\n self.l[granp] = child\n end\n else\n self.root = child\n end\nend\n\nAvlTree.rotLR = function(self, lparent, rparent)\n local sp, sl, sr = self.p, self.l, self.r\n local granp, d = sp[rparent], sr[lparent]\n sp[lparent], sr[lparent] = d, sl[d]\n sp[rparent], sl[rparent] = d, sr[d]\n sp[sl[d]], sp[sr[d]] = lparent, rparent\n sp[d], sl[d], sr[d] = granp, lparent, rparent\n if 1 < granp then\n if sr[granp] == rparent then sr[granp] = d\n else sl[granp] = d\n end\n else self.root = d\n end\nend\n\nAvlTree.rotRL = function(self, rparent, lparent)\n local sp, sl, sr = self.p, self.l, self.r\n local granp, d = sp[lparent], sl[rparent]\n sp[rparent], sl[rparent] = d, sr[d]\n sp[lparent], sr[lparent] = d, sl[d]\n sp[sr[d]], sp[sl[d]] = rparent, lparent\n sp[d], sr[d], sl[d] = granp, rparent, lparent\n if 1 < granp then\n if sl[granp] == lparent then sl[granp] = d\n else sr[granp] = d\n end\n else self.root = d\n end\nend\nAvlTree.empty = function(self) return self.root <= 1 end\nAvlTree.push = function(self, val)\n if self.root <= 1 then self.root = self:makenode(val, 1) return end\n local pos = self.root\n while true do\n if self.lessthan(val, self.v[pos]) then\n if 1 < self.l[pos] then\n pos = self.l[pos]\n else\n self.l[pos] = self:makenode(val, pos)\n pos = self.l[pos]\n break\n end\n else\n if 1 < self.r[pos] then\n pos = self.r[pos]\n else\n self.r[pos] = self:makenode(val, pos)\n pos = self.r[pos]\n break\n end\n end\n end\n while 1 < pos do\n local child, parent = pos, self.p[pos]\n if parent <= 1 then\n break\n end\n self:recalc(parent)\n local lcp_m_rcp = self.lc[parent] - self.rc[parent]\n if lcp_m_rcp % 2 ~= 0 then -- 1 or -1\n pos = parent\n elseif lcp_m_rcp == 2 then\n if self.lc[child] - 1 == self.rc[child] then\n self:rotR(parent)\n self:recalcAll(parent)\n else\n self:rotLR(child, parent)\n self:recalc(child)\n self:recalcAll(parent)\n end\n break\n elseif lcp_m_rcp == -2 then\n if self.rc[child] - 1 == self.lc[child] then\n self:rotL(parent)\n self:recalcAll(parent)\n else\n self:rotRL(child, parent)\n self:recalc(child)\n self:recalcAll(parent)\n end\n break\n else\n break\n end\n end\nend\n\nAvlTree.rmsub = function(self, node)\n while 1 < node do\n self:recalc(node)\n if self.lc[node] == self.rc[node] then\n node = self.p[node]\n elseif self.lc[node] + 1 == self.rc[node] then\n self:recalcAll(self.p[node])\n break\n else\n if self.lc[self.r[node]] == self.rc[self.r[node]] then\n self:rotL(node)\n self:recalcAll(node)\n break\n elseif self.lc[self.r[node]] + 1 == self.rc[self.r[node]] then\n local nr = self.r[node]\n self:rotL(node)\n self:recalc(node)\n node = nr\n else\n local nr = self.r[node]\n local nrl = self.l[nr]\n self:rotRL(nr, node)\n self:recalc(nr)\n self:recalc(node)\n node = nrl\n end\n end\n end\nend\n\nAvlTree.pop = function(self)\n local node = self.root\n while 1 < self.l[node] do\n node = self.l[node]\n end\n local v = self.v[node]\n local kp = self.p[node]\n self.p[self.r[node]] = kp\n if 1 < kp then\n self.l[kp] = self.r[node]\n self:rmsub(kp)\n else\n self.root = self.r[node]\n end\n table.insert(self.box, node)\n return v\nend\n\nAvlTree.new = function(lessthan, n)\n local obj = {}\n setmetatable(obj, {__index = AvlTree})\n obj:create(lessthan, n)\n return obj\nend\n\nlocal nd = io.read(\"*n\")\nlocal n = bls(1, nd)\nlocal t = {}\nfor i = 1, n do\n t[i] = io.read(\"*n\")\nend\ntable.sort(t, function(a, b) return a > b end)\nt[n + 1] = -1\n\nlocal lv0 = 0\nlocal avl = AvlTree.new(function(a, b) return a > b end, 1)\navl:push(nd)\nlocal rem = 1\n\nlocal left = 1\nlocal z = {}\nwhile true do\n local right = left\n while t[left] == t[right + 1] do\n right = right + 1\n end\n local taskcnt = right - left + 1\n for i = 1, taskcnt do\n if avl:empty() then\n local rem = taskcnt + 1 - i\n if rem <= lv0 then\n lv0 = lv0 - rem\n taskcnt = i - 1\n break\n else\n print(\"No\")\n os.exit()\n end\n end\n z[i] = avl:pop()\n end\n lv0 = lv0 + taskcnt\n for i = 1, taskcnt do\n local v = z[i]\n for j = 1, v - 1 do\n avl:push(j)\n end\n end\n left = right + 1\n if n < left then break end\nend\nprint(\"Yes\")\n", "problem_context": "Score : 600 points\n\nProblem Statement\n\nWe have one slime.\n\nYou can set the health of this slime to any integer value of your choice.\n\nA slime reproduces every second by spawning another slime that has strictly less health. You can freely choose the health of each new slime. The first reproduction of our slime will happen in one second.\n\nDetermine if it is possible to set the healths of our first slime and the subsequent slimes spawn so that the multiset of the healths of the 2^N slimes that will exist in N seconds equals a multiset S.\n\nHere S is a multiset containing 2^N (possibly duplicated) integers: S_1,~S_2,~...,~S_{2^N}.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 18\n\n1 \\leq S_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS_1 S_2 ... S_{2^N}\n\nOutput\n\nIf it is possible to set the healths of the first slime and the subsequent slimes spawn so that the multiset of the healths of the 2^N slimes that will exist in N seconds equals S, print Yes; otherwise, print No.\n\nSample Input 1\n\n2\n4 2 3 1\n\nSample Output 1\n\nYes\n\nWe will show one way to make the multiset of the healths of the slimes that will exist in 2 seconds equal to S.\n\nFirst, set the health of the first slime to 4.\n\nBy letting the first slime spawn a slime whose health is 3, the healths of the slimes that exist in 1 second can be 4,~3.\n\nThen, by letting the first slime spawn a slime whose health is 2, and letting the second slime spawn a slime whose health is 1, the healths of the slimes that exist in 2 seconds can be 4,~3,~2,~1, which is equal to S as multisets.\n\nSample Input 2\n\n2\n1 2 3 1\n\nSample Output 2\n\nYes\n\nS may contain multiple instances of the same integer.\n\nSample Input 3\n\n1\n1 1\n\nSample Output 3\n\nNo\n\nSample Input 4\n\n5\n4 3 5 3 1 2 7 8 7 4 6 3 7 2 3 6 2 7 3 2 6 7 3 4 6 7 3 4 2 5 2 3\n\nSample Output 4\n\nNo", "sample_input": "2\n4 2 3 1\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p02920", "source_text": "Score : 600 points\n\nProblem Statement\n\nWe have one slime.\n\nYou can set the health of this slime to any integer value of your choice.\n\nA slime reproduces every second by spawning another slime that has strictly less health. You can freely choose the health of each new slime. The first reproduction of our slime will happen in one second.\n\nDetermine if it is possible to set the healths of our first slime and the subsequent slimes spawn so that the multiset of the healths of the 2^N slimes that will exist in N seconds equals a multiset S.\n\nHere S is a multiset containing 2^N (possibly duplicated) integers: S_1,~S_2,~...,~S_{2^N}.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 18\n\n1 \\leq S_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS_1 S_2 ... S_{2^N}\n\nOutput\n\nIf it is possible to set the healths of the first slime and the subsequent slimes spawn so that the multiset of the healths of the 2^N slimes that will exist in N seconds equals S, print Yes; otherwise, print No.\n\nSample Input 1\n\n2\n4 2 3 1\n\nSample Output 1\n\nYes\n\nWe will show one way to make the multiset of the healths of the slimes that will exist in 2 seconds equal to S.\n\nFirst, set the health of the first slime to 4.\n\nBy letting the first slime spawn a slime whose health is 3, the healths of the slimes that exist in 1 second can be 4,~3.\n\nThen, by letting the first slime spawn a slime whose health is 2, and letting the second slime spawn a slime whose health is 1, the healths of the slimes that exist in 2 seconds can be 4,~3,~2,~1, which is equal to S as multisets.\n\nSample Input 2\n\n2\n1 2 3 1\n\nSample Output 2\n\nYes\n\nS may contain multiple instances of the same integer.\n\nSample Input 3\n\n1\n1 1\n\nSample Output 3\n\nNo\n\nSample Input 4\n\n5\n4 3 5 3 1 2 7 8 7 4 6 3 7 2 3 6 2 7 3 2 6 7 3 4 6 7 3 4 2 5 2 3\n\nSample Output 4\n\nNo", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 6344, "cpu_time_ms": 379, "memory_kb": 14200}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s469504102", "group_id": "codeNet:p02921", "input_text": "s=io.read():match(\"%w+\")\nt=io.read():match(\"%w+\")\ncnt=0\nfor i=0,2,1 do\n if s:sub(i,i)==t:sub(i,i)then\n cnt=cnt+1\n end\nend\nprint(cnt)", "language": "Lua", "metadata": {"date": 1579291961, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p02921.html", "problem_id": "p02921", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02921/input.txt", "sample_output_relpath": "derived/input_output/data/p02921/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02921/Lua/s469504102.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s469504102", "user_id": "u720483676"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "s=io.read():match(\"%w+\")\nt=io.read():match(\"%w+\")\ncnt=0\nfor i=0,2,1 do\n if s:sub(i,i)==t:sub(i,i)then\n cnt=cnt+1\n end\nend\nprint(cnt)", "problem_context": "Score : 100 points\n\nProblem Statement\n\nYou will be given a string S of length 3 representing the weather forecast for three days in the past.\n\nThe i-th character (1 \\leq i \\leq 3) of S represents the forecast for the i-th day. S, C, and R stand for sunny, cloudy, and rainy, respectively.\n\nYou will also be given a string T of length 3 representing the actual weather on those three days.\n\nThe i-th character (1 \\leq i \\leq 3) of S represents the actual weather on the i-th day. S, C, and R stand for sunny, cloudy, and rainy, respectively.\n\nPrint the number of days for which the forecast was correct.\n\nConstraints\n\nS and T are strings of length 3 each.\n\nS and T consist of S, C, and R.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\nT\n\nOutput\n\nPrint the number of days for which the forecast was correct.\n\nSample Input 1\n\nCSS\nCSR\n\nSample Output 1\n\n2\n\nFor the first day, it was forecast to be cloudy, and it was indeed cloudy.\n\nFor the second day, it was forecast to be sunny, and it was indeed sunny.\n\nFor the third day, it was forecast to be sunny, but it was rainy.\n\nThus, the forecast was correct for two days in this case.\n\nSample Input 2\n\nSSR\nSSR\n\nSample Output 2\n\n3\n\nSample Input 3\n\nRRR\nSSS\n\nSample Output 3\n\n0", "sample_input": "CSS\nCSR\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02921", "source_text": "Score : 100 points\n\nProblem Statement\n\nYou will be given a string S of length 3 representing the weather forecast for three days in the past.\n\nThe i-th character (1 \\leq i \\leq 3) of S represents the forecast for the i-th day. S, C, and R stand for sunny, cloudy, and rainy, respectively.\n\nYou will also be given a string T of length 3 representing the actual weather on those three days.\n\nThe i-th character (1 \\leq i \\leq 3) of S represents the actual weather on the i-th day. S, C, and R stand for sunny, cloudy, and rainy, respectively.\n\nPrint the number of days for which the forecast was correct.\n\nConstraints\n\nS and T are strings of length 3 each.\n\nS and T consist of S, C, and R.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\nT\n\nOutput\n\nPrint the number of days for which the forecast was correct.\n\nSample Input 1\n\nCSS\nCSR\n\nSample Output 1\n\n2\n\nFor the first day, it was forecast to be cloudy, and it was indeed cloudy.\n\nFor the second day, it was forecast to be sunny, and it was indeed sunny.\n\nFor the third day, it was forecast to be sunny, but it was rainy.\n\nThus, the forecast was correct for two days in this case.\n\nSample Input 2\n\nSSR\nSSR\n\nSample Output 2\n\n3\n\nSample Input 3\n\nRRR\nSSS\n\nSample Output 3\n\n0", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 137, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s997871680", "group_id": "codeNet:p02922", "input_text": "a=io.read(\"*n\")\nb=io.read(\"*n\")\n\ns=1\nans=0\nwhile s < b do\n ans=ans+1\n s=s+a-1\nend\n\nprint(ans)", "language": "Lua", "metadata": {"date": 1568422679, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p02922.html", "problem_id": "p02922", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02922/input.txt", "sample_output_relpath": "derived/input_output/data/p02922/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02922/Lua/s997871680.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s997871680", "user_id": "u535423069"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "a=io.read(\"*n\")\nb=io.read(\"*n\")\n\ns=1\nans=0\nwhile s < b do\n ans=ans+1\n s=s+a-1\nend\n\nprint(ans)", "problem_context": "Score : 200 points\n\nProblem Statement\n\nTakahashi's house has only one socket.\n\nTakahashi wants to extend it with some number of power strips, each with A sockets, into B or more empty sockets.\n\nOne power strip with A sockets can extend one empty socket into A empty sockets.\n\nFind the minimum number of power strips required.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq A \\leq 20\n\n1 \\leq B \\leq 20\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nPrint the minimum number of power strips required.\n\nSample Input 1\n\n4 10\n\nSample Output 1\n\n3\n\n3 power strips, each with 4 sockets, extend the socket into 10 empty sockets.\n\nSample Input 2\n\n8 9\n\nSample Output 2\n\n2\n\n2 power strips, each with 8 sockets, extend the socket into 15 empty sockets.\n\nSample Input 3\n\n8 8\n\nSample Output 3\n\n1", "sample_input": "4 10\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02922", "source_text": "Score : 200 points\n\nProblem Statement\n\nTakahashi's house has only one socket.\n\nTakahashi wants to extend it with some number of power strips, each with A sockets, into B or more empty sockets.\n\nOne power strip with A sockets can extend one empty socket into A empty sockets.\n\nFind the minimum number of power strips required.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq A \\leq 20\n\n1 \\leq B \\leq 20\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nPrint the minimum number of power strips required.\n\nSample Input 1\n\n4 10\n\nSample Output 1\n\n3\n\n3 power strips, each with 4 sockets, extend the socket into 10 empty sockets.\n\nSample Input 2\n\n8 9\n\nSample Output 2\n\n2\n\n2 power strips, each with 8 sockets, extend the socket into 15 empty sockets.\n\nSample Input 3\n\n8 8\n\nSample Output 3\n\n1", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 95, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s104183473", "group_id": "codeNet:p02924", "input_text": "local n=io.read()\nprint(n*(n-1)/2)", "language": "Lua", "metadata": {"date": 1589660400, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p02924.html", "problem_id": "p02924", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02924/input.txt", "sample_output_relpath": "derived/input_output/data/p02924/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02924/Lua/s104183473.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s104183473", "user_id": "u045238009"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "local n=io.read()\nprint(n*(n-1)/2)", "problem_context": "Score : 400 points\n\nProblem Statement\n\nFor an integer N, we will choose a permutation \\{P_1, P_2, ..., P_N\\} of \\{1, 2, ..., N\\}.\n\nThen, for each i=1,2,...,N, let M_i be the remainder when i is divided by P_i.\n\nFind the maximum possible value of M_1 + M_2 + \\cdots + M_N.\n\nConstraints\n\nN is an integer satisfying 1 \\leq N \\leq 10^9.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the maximum possible value of M_1 + M_2 + \\cdots + M_N.\n\nSample Input 1\n\n2\n\nSample Output 1\n\n1\n\nWhen the permutation \\{P_1, P_2\\} = \\{2, 1\\} is chosen, M_1 + M_2 = 1 + 0 = 1.\n\nSample Input 2\n\n13\n\nSample Output 2\n\n78\n\nSample Input 3\n\n1\n\nSample Output 3\n\n0", "sample_input": "2\n"}, "reference_outputs": ["1\n"], "source_document_id": "p02924", "source_text": "Score : 400 points\n\nProblem Statement\n\nFor an integer N, we will choose a permutation \\{P_1, P_2, ..., P_N\\} of \\{1, 2, ..., N\\}.\n\nThen, for each i=1,2,...,N, let M_i be the remainder when i is divided by P_i.\n\nFind the maximum possible value of M_1 + M_2 + \\cdots + M_N.\n\nConstraints\n\nN is an integer satisfying 1 \\leq N \\leq 10^9.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the maximum possible value of M_1 + M_2 + \\cdots + M_N.\n\nSample Input 1\n\n2\n\nSample Output 1\n\n1\n\nWhen the permutation \\{P_1, P_2\\} = \\{2, 1\\} is chosen, M_1 + M_2 = 1 + 0 = 1.\n\nSample Input 2\n\n13\n\nSample Output 2\n\n78\n\nSample Input 3\n\n1\n\nSample Output 3\n\n0", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 34, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s554208762", "group_id": "codeNet:p02924", "input_text": "local n = io.read(\"*n\")\nprint(math.floor(n * (n - 1) / 2))\n", "language": "Lua", "metadata": {"date": 1581882318, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p02924.html", "problem_id": "p02924", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02924/input.txt", "sample_output_relpath": "derived/input_output/data/p02924/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02924/Lua/s554208762.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s554208762", "user_id": "u120582723"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "local n = io.read(\"*n\")\nprint(math.floor(n * (n - 1) / 2))\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nFor an integer N, we will choose a permutation \\{P_1, P_2, ..., P_N\\} of \\{1, 2, ..., N\\}.\n\nThen, for each i=1,2,...,N, let M_i be the remainder when i is divided by P_i.\n\nFind the maximum possible value of M_1 + M_2 + \\cdots + M_N.\n\nConstraints\n\nN is an integer satisfying 1 \\leq N \\leq 10^9.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the maximum possible value of M_1 + M_2 + \\cdots + M_N.\n\nSample Input 1\n\n2\n\nSample Output 1\n\n1\n\nWhen the permutation \\{P_1, P_2\\} = \\{2, 1\\} is chosen, M_1 + M_2 = 1 + 0 = 1.\n\nSample Input 2\n\n13\n\nSample Output 2\n\n78\n\nSample Input 3\n\n1\n\nSample Output 3\n\n0", "sample_input": "2\n"}, "reference_outputs": ["1\n"], "source_document_id": "p02924", "source_text": "Score : 400 points\n\nProblem Statement\n\nFor an integer N, we will choose a permutation \\{P_1, P_2, ..., P_N\\} of \\{1, 2, ..., N\\}.\n\nThen, for each i=1,2,...,N, let M_i be the remainder when i is divided by P_i.\n\nFind the maximum possible value of M_1 + M_2 + \\cdots + M_N.\n\nConstraints\n\nN is an integer satisfying 1 \\leq N \\leq 10^9.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the maximum possible value of M_1 + M_2 + \\cdots + M_N.\n\nSample Input 1\n\n2\n\nSample Output 1\n\n1\n\nWhen the permutation \\{P_1, P_2\\} = \\{2, 1\\} is chosen, M_1 + M_2 = 1 + 0 = 1.\n\nSample Input 2\n\n13\n\nSample Output 2\n\n78\n\nSample Input 3\n\n1\n\nSample Output 3\n\n0", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 59, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s314478669", "group_id": "codeNet:p02924", "input_text": "local l = io.read(\"*l\")\nl = tonumber(l)\nlocal result = 0\nif l == 1 then \n result = 0\nelseif l % 2 == 0 then\n result = (l - 1) * (l / 2)\nelse\n result = (l - 2) * (l / 2) + (l / 2)\nend\nprint(~~(result))", "language": "Lua", "metadata": {"date": 1567367789, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p02924.html", "problem_id": "p02924", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02924/input.txt", "sample_output_relpath": "derived/input_output/data/p02924/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02924/Lua/s314478669.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s314478669", "user_id": "u959346025"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "local l = io.read(\"*l\")\nl = tonumber(l)\nlocal result = 0\nif l == 1 then \n result = 0\nelseif l % 2 == 0 then\n result = (l - 1) * (l / 2)\nelse\n result = (l - 2) * (l / 2) + (l / 2)\nend\nprint(~~(result))", "problem_context": "Score : 400 points\n\nProblem Statement\n\nFor an integer N, we will choose a permutation \\{P_1, P_2, ..., P_N\\} of \\{1, 2, ..., N\\}.\n\nThen, for each i=1,2,...,N, let M_i be the remainder when i is divided by P_i.\n\nFind the maximum possible value of M_1 + M_2 + \\cdots + M_N.\n\nConstraints\n\nN is an integer satisfying 1 \\leq N \\leq 10^9.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the maximum possible value of M_1 + M_2 + \\cdots + M_N.\n\nSample Input 1\n\n2\n\nSample Output 1\n\n1\n\nWhen the permutation \\{P_1, P_2\\} = \\{2, 1\\} is chosen, M_1 + M_2 = 1 + 0 = 1.\n\nSample Input 2\n\n13\n\nSample Output 2\n\n78\n\nSample Input 3\n\n1\n\nSample Output 3\n\n0", "sample_input": "2\n"}, "reference_outputs": ["1\n"], "source_document_id": "p02924", "source_text": "Score : 400 points\n\nProblem Statement\n\nFor an integer N, we will choose a permutation \\{P_1, P_2, ..., P_N\\} of \\{1, 2, ..., N\\}.\n\nThen, for each i=1,2,...,N, let M_i be the remainder when i is divided by P_i.\n\nFind the maximum possible value of M_1 + M_2 + \\cdots + M_N.\n\nConstraints\n\nN is an integer satisfying 1 \\leq N \\leq 10^9.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the maximum possible value of M_1 + M_2 + \\cdots + M_N.\n\nSample Input 1\n\n2\n\nSample Output 1\n\n1\n\nWhen the permutation \\{P_1, P_2\\} = \\{2, 1\\} is chosen, M_1 + M_2 = 1 + 0 = 1.\n\nSample Input 2\n\n13\n\nSample Output 2\n\n78\n\nSample Input 3\n\n1\n\nSample Output 3\n\n0", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 203, "cpu_time_ms": 7, "memory_kb": 760}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s445609749", "group_id": "codeNet:p02925", "input_text": "local n = io.read(\"*n\")\nlocal edge = {}\nlocal srccnt = {}\nfor i = 1, n * n do\n edge[i] = {}\n srccnt[i] = 0\nend\nlocal function getindex(a, b)\n if a < b then\n return (a - 1) * n + b\n else\n return (b - 1) * n + a\n end\nend\nfor i = 1, n do\n local prvidx = getindex(i, io.read(\"*n\"))\n for j = 2, n - 1 do\n local nxtidx = getindex(i, io.read(\"*n\"))\n table.insert(edge[prvidx], nxtidx)\n srccnt[nxtidx] = srccnt[nxtidx] + 1\n prvidx = nxtidx\n end\nend\nlocal tasks = {}\nfor i = 1, n * n do\n if 0 < #edge[i] and srccnt[i] == 0 then\n table.insert(tasks, i)\n end\nend\nlocal day = 0\nlocal matched = 0\nwhile 0 < #tasks do\n day = day + 1\n local ng = false\n local newtasks = {}\n for i = 1, #tasks do\n local src = tasks[i]\n matched = matched + #edge[src]\n for j = 1, #edge[src] do\n local dst = edge[src][j]\n srccnt[dst] = srccnt[dst] - 1\n if srccnt[dst] == 0 then\n table.insert(newtasks, dst)\n end\n end\n if ng then break end\n end\n if ng then break end\n tasks = newtasks\nend\nif matched * 2 < n * (n - 1) then\n day = -1\nend\nprint(day)\n", "language": "Lua", "metadata": {"date": 1567461069, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p02925.html", "problem_id": "p02925", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02925/input.txt", "sample_output_relpath": "derived/input_output/data/p02925/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02925/Lua/s445609749.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s445609749", "user_id": "u120582723"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "local n = io.read(\"*n\")\nlocal edge = {}\nlocal srccnt = {}\nfor i = 1, n * n do\n edge[i] = {}\n srccnt[i] = 0\nend\nlocal function getindex(a, b)\n if a < b then\n return (a - 1) * n + b\n else\n return (b - 1) * n + a\n end\nend\nfor i = 1, n do\n local prvidx = getindex(i, io.read(\"*n\"))\n for j = 2, n - 1 do\n local nxtidx = getindex(i, io.read(\"*n\"))\n table.insert(edge[prvidx], nxtidx)\n srccnt[nxtidx] = srccnt[nxtidx] + 1\n prvidx = nxtidx\n end\nend\nlocal tasks = {}\nfor i = 1, n * n do\n if 0 < #edge[i] and srccnt[i] == 0 then\n table.insert(tasks, i)\n end\nend\nlocal day = 0\nlocal matched = 0\nwhile 0 < #tasks do\n day = day + 1\n local ng = false\n local newtasks = {}\n for i = 1, #tasks do\n local src = tasks[i]\n matched = matched + #edge[src]\n for j = 1, #edge[src] do\n local dst = edge[src][j]\n srccnt[dst] = srccnt[dst] - 1\n if srccnt[dst] == 0 then\n table.insert(newtasks, dst)\n end\n end\n if ng then break end\n end\n if ng then break end\n tasks = newtasks\nend\nif matched * 2 < n * (n - 1) then\n day = -1\nend\nprint(day)\n", "problem_context": "Score : 500 points\n\nProblem Statement\n\nN players will participate in a tennis tournament. We will call them Player 1, Player 2, \\ldots, Player N.\n\nThe tournament is round-robin format, and there will be N(N-1)/2 matches in total.\nIs it possible to schedule these matches so that all of the following conditions are satisfied? If the answer is yes, also find the minimum number of days required.\n\nEach player plays at most one matches in a day.\n\nEach player i (1 \\leq i \\leq N) plays one match against Player A_{i, 1}, A_{i, 2}, \\ldots, A_{i, N-1} in this order.\n\nConstraints\n\n3 \\leq N \\leq 1000\n\n1 \\leq A_{i, j} \\leq N\n\nA_{i, j} \\neq i\n\nA_{i, 1}, A_{i, 2}, \\ldots, A_{i, N-1} are all different.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_{1, 1} A_{1, 2} \\ldots A_{1, N-1}\nA_{2, 1} A_{2, 2} \\ldots A_{2, N-1}\n:\nA_{N, 1} A_{N, 2} \\ldots A_{N, N-1}\n\nOutput\n\nIf it is possible to schedule all the matches so that all of the conditions are satisfied, print the minimum number of days required; if it is impossible, print -1.\n\nSample Input 1\n\n3\n2 3\n1 3\n1 2\n\nSample Output 1\n\n3\n\nAll the conditions can be satisfied if the matches are scheduled for three days as follows:\n\nDay 1: Player 1 vs Player 2\n\nDay 2: Player 1 vs Player 3\n\nDay 3: Player 2 vs Player 3\n\nThis is the minimum number of days required.\n\nSample Input 2\n\n4\n2 3 4\n1 3 4\n4 1 2\n3 1 2\n\nSample Output 2\n\n4\n\nAll the conditions can be satisfied if the matches are scheduled for four days as follows:\n\nDay 1: Player 1 vs Player 2, Player 3 vs Player 4\n\nDay 2: Player 1 vs Player 3\n\nDay 3: Player 1 vs Player 4, Player 2 vs Player 3\n\nDay 4: Player 2 vs Player 4\n\nThis is the minimum number of days required.\n\nSample Input 3\n\n3\n2 3\n3 1\n1 2\n\nSample Output 3\n\n-1\n\nAny scheduling of the matches violates some condition.", "sample_input": "3\n2 3\n1 3\n1 2\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02925", "source_text": "Score : 500 points\n\nProblem Statement\n\nN players will participate in a tennis tournament. We will call them Player 1, Player 2, \\ldots, Player N.\n\nThe tournament is round-robin format, and there will be N(N-1)/2 matches in total.\nIs it possible to schedule these matches so that all of the following conditions are satisfied? If the answer is yes, also find the minimum number of days required.\n\nEach player plays at most one matches in a day.\n\nEach player i (1 \\leq i \\leq N) plays one match against Player A_{i, 1}, A_{i, 2}, \\ldots, A_{i, N-1} in this order.\n\nConstraints\n\n3 \\leq N \\leq 1000\n\n1 \\leq A_{i, j} \\leq N\n\nA_{i, j} \\neq i\n\nA_{i, 1}, A_{i, 2}, \\ldots, A_{i, N-1} are all different.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_{1, 1} A_{1, 2} \\ldots A_{1, N-1}\nA_{2, 1} A_{2, 2} \\ldots A_{2, N-1}\n:\nA_{N, 1} A_{N, 2} \\ldots A_{N, N-1}\n\nOutput\n\nIf it is possible to schedule all the matches so that all of the conditions are satisfied, print the minimum number of days required; if it is impossible, print -1.\n\nSample Input 1\n\n3\n2 3\n1 3\n1 2\n\nSample Output 1\n\n3\n\nAll the conditions can be satisfied if the matches are scheduled for three days as follows:\n\nDay 1: Player 1 vs Player 2\n\nDay 2: Player 1 vs Player 3\n\nDay 3: Player 2 vs Player 3\n\nThis is the minimum number of days required.\n\nSample Input 2\n\n4\n2 3 4\n1 3 4\n4 1 2\n3 1 2\n\nSample Output 2\n\n4\n\nAll the conditions can be satisfied if the matches are scheduled for four days as follows:\n\nDay 1: Player 1 vs Player 2, Player 3 vs Player 4\n\nDay 2: Player 1 vs Player 3\n\nDay 3: Player 1 vs Player 4, Player 2 vs Player 3\n\nDay 4: Player 2 vs Player 4\n\nThis is the minimum number of days required.\n\nSample Input 3\n\n3\n2 3\n3 1\n1 2\n\nSample Output 3\n\n-1\n\nAny scheduling of the matches violates some condition.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1093, "cpu_time_ms": 770, "memory_kb": 103004}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s941017465", "group_id": "codeNet:p02928", "input_text": "local mod = 1000000007\nlocal mfl = math.floor\nlocal function bmul(x, y)\n local x0, y0 = x % 31623, y % 31623\n local x1, y1 = mfl(x / 31623), mfl(y / 31623)\n return (x1 * y1 * 14122 + (x1 * y0 + x0 * y1) * 31623 + x0 * y0) % mod\nend\nlocal n, k = io.read(\"*n\", \"*n\")\nlocal a = {}\nfor i = 1, n do a[i] = io.read(\"*n\") end\nlocal sum = 0\nlocal fact1 = bmul(500000004, bmul(k, k - 1))\nlocal fact2 = bmul(500000004, bmul(k, k + 1))\nfor i = 1, n - 1 do\n for j = i + 1, n do\n if a[i] < a[j] then\n sum = (sum + fact1) % mod\n elseif a[j] < a[i] then\n sum = (sum + fact2) % mod\n end\n end\nend\nprint(sum)\n", "language": "Lua", "metadata": {"date": 1566706610, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p02928.html", "problem_id": "p02928", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02928/input.txt", "sample_output_relpath": "derived/input_output/data/p02928/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02928/Lua/s941017465.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s941017465", "user_id": "u120582723"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "local mod = 1000000007\nlocal mfl = math.floor\nlocal function bmul(x, y)\n local x0, y0 = x % 31623, y % 31623\n local x1, y1 = mfl(x / 31623), mfl(y / 31623)\n return (x1 * y1 * 14122 + (x1 * y0 + x0 * y1) * 31623 + x0 * y0) % mod\nend\nlocal n, k = io.read(\"*n\", \"*n\")\nlocal a = {}\nfor i = 1, n do a[i] = io.read(\"*n\") end\nlocal sum = 0\nlocal fact1 = bmul(500000004, bmul(k, k - 1))\nlocal fact2 = bmul(500000004, bmul(k, k + 1))\nfor i = 1, n - 1 do\n for j = i + 1, n do\n if a[i] < a[j] then\n sum = (sum + fact1) % mod\n elseif a[j] < a[i] then\n sum = (sum + fact2) % mod\n end\n end\nend\nprint(sum)\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nWe have a sequence of N integers A~=~A_0,~A_1,~...,~A_{N - 1}.\n\nLet B be a sequence of K \\times N integers obtained by concatenating K copies of A. For example, if A~=~1,~3,~2 and K~=~2, B~=~1,~3,~2,~1,~3,~2.\n\nFind the inversion number of B, modulo 10^9 + 7.\n\nHere the inversion number of B is defined as the number of ordered pairs of integers (i,~j)~(0 \\leq i < j \\leq K \\times N - 1) such that B_i > B_j.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 2000\n\n1 \\leq K \\leq 10^9\n\n1 \\leq A_i \\leq 2000\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nA_0 A_1 ... A_{N - 1}\n\nOutput\n\nPrint the inversion number of B, modulo 10^9 + 7.\n\nSample Input 1\n\n2 2\n2 1\n\nSample Output 1\n\n3\n\nIn this case, B~=~2,~1,~2,~1. We have:\n\nB_0 > B_1\n\nB_0 > B_3\n\nB_2 > B_3\n\nThus, the inversion number of B is 3.\n\nSample Input 2\n\n3 5\n1 1 1\n\nSample Output 2\n\n0\n\nA may contain multiple occurrences of the same number.\n\nSample Input 3\n\n10 998244353\n10 9 8 7 5 6 3 4 2 1\n\nSample Output 3\n\n185297239\n\nBe sure to print the output modulo 10^9 + 7.", "sample_input": "2 2\n2 1\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02928", "source_text": "Score : 300 points\n\nProblem Statement\n\nWe have a sequence of N integers A~=~A_0,~A_1,~...,~A_{N - 1}.\n\nLet B be a sequence of K \\times N integers obtained by concatenating K copies of A. For example, if A~=~1,~3,~2 and K~=~2, B~=~1,~3,~2,~1,~3,~2.\n\nFind the inversion number of B, modulo 10^9 + 7.\n\nHere the inversion number of B is defined as the number of ordered pairs of integers (i,~j)~(0 \\leq i < j \\leq K \\times N - 1) such that B_i > B_j.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 2000\n\n1 \\leq K \\leq 10^9\n\n1 \\leq A_i \\leq 2000\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nA_0 A_1 ... A_{N - 1}\n\nOutput\n\nPrint the inversion number of B, modulo 10^9 + 7.\n\nSample Input 1\n\n2 2\n2 1\n\nSample Output 1\n\n3\n\nIn this case, B~=~2,~1,~2,~1. We have:\n\nB_0 > B_1\n\nB_0 > B_3\n\nB_2 > B_3\n\nThus, the inversion number of B is 3.\n\nSample Input 2\n\n3 5\n1 1 1\n\nSample Output 2\n\n0\n\nA may contain multiple occurrences of the same number.\n\nSample Input 3\n\n10 998244353\n10 9 8 7 5 6 3 4 2 1\n\nSample Output 3\n\n185297239\n\nBe sure to print the output modulo 10^9 + 7.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 615, "cpu_time_ms": 27, "memory_kb": 256}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s427051141", "group_id": "codeNet:p02929", "input_text": "local read = setmetatable({}, {__index = function(t, k) local a = {} for i=1,#k do table.insert(a, '*'..string.sub(k, i, i)) end local r = io.read local u = table.unpack or unpack return function() return r(u(a)) end end})\nread.N = function(N) local t={} for i=1,N do t[i]=read.n() end return t end\nstring.totable = function(s) local t={} local u=string.sub for i=1,#s do t[i] = u(s, i, i) end return t end\nstring.split = function(s) local t={} for w in string.gmatch(s, \"[^%s]+\") do table.insert(t, w) end return (table.unpack or unpack)(t) end\n----\n-- returns n! % m\nlocal function modfactorial(n, m)\n local a = 1\n for i=1, n do\n a = a * i % m\n end\n return a\nend\n----\nlocal MOD = math.floor(10^9) + 7\nlocal N = read.nl()\nlocal S = read.l():totable()\n\nlocal lcount = 0\nlocal ans = 1\n\nfor i=1,2*N do\n local ev = i % 2 == 0 and 1 or 0\n local c = S[i] == 'W' and 0 or 1\n --[[ \n ev c example flip L R use\n 0 0 i=3,W Do not flip not flip R\n 0 1 i=3,B Do flip not flip L\n 1 0 i=2,W Do not not flip flip L\n 1 1 i=2,B Do not flip flip R\n ]]\n if ev ~ c == 0 then\n -- R\n if lcount <= 0 then\n print(0)\n return\n end\n ans = ans * lcount % MOD\n lcount = lcount - 1\n else\n -- L\n lcount = lcount + 1\n end\nend\nif lcount > 0 then\n print(0)\n return\nend\n\nans = ans * modfactorial(N, MOD) % MOD\nprint(ans)", "language": "Lua", "metadata": {"date": 1574304848, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p02929.html", "problem_id": "p02929", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02929/input.txt", "sample_output_relpath": "derived/input_output/data/p02929/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02929/Lua/s427051141.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s427051141", "user_id": "u162773977"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "local read = setmetatable({}, {__index = function(t, k) local a = {} for i=1,#k do table.insert(a, '*'..string.sub(k, i, i)) end local r = io.read local u = table.unpack or unpack return function() return r(u(a)) end end})\nread.N = function(N) local t={} for i=1,N do t[i]=read.n() end return t end\nstring.totable = function(s) local t={} local u=string.sub for i=1,#s do t[i] = u(s, i, i) end return t end\nstring.split = function(s) local t={} for w in string.gmatch(s, \"[^%s]+\") do table.insert(t, w) end return (table.unpack or unpack)(t) end\n----\n-- returns n! % m\nlocal function modfactorial(n, m)\n local a = 1\n for i=1, n do\n a = a * i % m\n end\n return a\nend\n----\nlocal MOD = math.floor(10^9) + 7\nlocal N = read.nl()\nlocal S = read.l():totable()\n\nlocal lcount = 0\nlocal ans = 1\n\nfor i=1,2*N do\n local ev = i % 2 == 0 and 1 or 0\n local c = S[i] == 'W' and 0 or 1\n --[[ \n ev c example flip L R use\n 0 0 i=3,W Do not flip not flip R\n 0 1 i=3,B Do flip not flip L\n 1 0 i=2,W Do not not flip flip L\n 1 1 i=2,B Do not flip flip R\n ]]\n if ev ~ c == 0 then\n -- R\n if lcount <= 0 then\n print(0)\n return\n end\n ans = ans * lcount % MOD\n lcount = lcount - 1\n else\n -- L\n lcount = lcount + 1\n end\nend\nif lcount > 0 then\n print(0)\n return\nend\n\nans = ans * modfactorial(N, MOD) % MOD\nprint(ans)", "problem_context": "Score : 500 points\n\nProblem Statement\n\nThere are 2N squares arranged from left to right. You are given a string of length 2N representing the color of each of the squares.\n\nThe color of the i-th square from the left is black if the i-th character of S is B, and white if that character is W.\n\nYou will perform the following operation exactly N times: choose two distinct squares, then invert the colors of these squares and the squares between them. Here, to invert the color of a square is to make it white if it is black, and vice versa.\n\nThroughout this process, you cannot choose the same square twice or more. That is, each square has to be chosen exactly once.\n\nFind the number of ways to make all the squares white at the end of the process, modulo 10^9+7.\n\nTwo ways to make the squares white are considered different if and only if there exists i (1 \\leq i \\leq N) such that the pair of the squares chosen in the i-th operation is different.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n|S| = 2N\n\nEach character of S is B or W.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS\n\nOutput\n\nPrint the number of ways to make all the squares white at the end of the process, modulo 10^9+7. If there are no such ways, print 0.\n\nSample Input 1\n\n2\nBWWB\n\nSample Output 1\n\n4\n\nThere are four ways to make all the squares white, as follows:\n\nChoose Squares 1, 3 in the first operation, and choose Squares 2, 4 in the second operation.\n\nChoose Squares 2, 4 in the first operation, and choose Squares 1, 3 in the second operation.\n\nChoose Squares 1, 4 in the first operation, and choose Squares 2, 3 in the second operation.\n\nChoose Squares 2, 3 in the first operation, and choose Squares 1, 4 in the second operation.\n\nSample Input 2\n\n4\nBWBBWWWB\n\nSample Output 2\n\n288\n\nSample Input 3\n\n5\nWWWWWWWWWW\n\nSample Output 3\n\n0", "sample_input": "2\nBWWB\n"}, "reference_outputs": ["4\n"], "source_document_id": "p02929", "source_text": "Score : 500 points\n\nProblem Statement\n\nThere are 2N squares arranged from left to right. You are given a string of length 2N representing the color of each of the squares.\n\nThe color of the i-th square from the left is black if the i-th character of S is B, and white if that character is W.\n\nYou will perform the following operation exactly N times: choose two distinct squares, then invert the colors of these squares and the squares between them. Here, to invert the color of a square is to make it white if it is black, and vice versa.\n\nThroughout this process, you cannot choose the same square twice or more. That is, each square has to be chosen exactly once.\n\nFind the number of ways to make all the squares white at the end of the process, modulo 10^9+7.\n\nTwo ways to make the squares white are considered different if and only if there exists i (1 \\leq i \\leq N) such that the pair of the squares chosen in the i-th operation is different.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n|S| = 2N\n\nEach character of S is B or W.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS\n\nOutput\n\nPrint the number of ways to make all the squares white at the end of the process, modulo 10^9+7. If there are no such ways, print 0.\n\nSample Input 1\n\n2\nBWWB\n\nSample Output 1\n\n4\n\nThere are four ways to make all the squares white, as follows:\n\nChoose Squares 1, 3 in the first operation, and choose Squares 2, 4 in the second operation.\n\nChoose Squares 2, 4 in the first operation, and choose Squares 1, 3 in the second operation.\n\nChoose Squares 1, 4 in the first operation, and choose Squares 2, 3 in the second operation.\n\nChoose Squares 2, 3 in the first operation, and choose Squares 1, 4 in the second operation.\n\nSample Input 2\n\n4\nBWBBWWWB\n\nSample Output 2\n\n288\n\nSample Input 3\n\n5\nWWWWWWWWWW\n\nSample Output 3\n\n0", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1574, "cpu_time_ms": 51, "memory_kb": 4836}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s429680431", "group_id": "codeNet:p02934", "input_text": "-- B\nlocal read = setmetatable({}, {__index = function(t, k) local a = {} for i=1,#k do table.insert(a, string.sub(k, i, i)) end local r = io.read local u = table.unpack return function() return r(u(a)) end end})\nlocal N = read.n()\nlocal tmp_sum = 0\nfor i=1,N do\n local a = read.n()\n tmp_sum = tmp_sum + 1.0 / a\nend\nlocal ans = 1 / tmp_sum\nprint(ans)", "language": "Lua", "metadata": {"date": 1566176610, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p02934.html", "problem_id": "p02934", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02934/input.txt", "sample_output_relpath": "derived/input_output/data/p02934/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02934/Lua/s429680431.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s429680431", "user_id": "u162773977"}, "prompt_components": {"gold_output": "7.5\n", "input_to_evaluate": "-- B\nlocal read = setmetatable({}, {__index = function(t, k) local a = {} for i=1,#k do table.insert(a, string.sub(k, i, i)) end local r = io.read local u = table.unpack return function() return r(u(a)) end end})\nlocal N = read.n()\nlocal tmp_sum = 0\nfor i=1,N do\n local a = read.n()\n tmp_sum = tmp_sum + 1.0 / a\nend\nlocal ans = 1 / tmp_sum\nprint(ans)", "problem_context": "Score : 200 points\n\nProblem Statement\n\nGiven is a sequence of N integers A_1, \\ldots, A_N.\n\nFind the (multiplicative) inverse of the sum of the inverses of these numbers, \\frac{1}{\\frac{1}{A_1} + \\ldots + \\frac{1}{A_N}}.\n\nConstraints\n\n1 \\leq N \\leq 100\n\n1 \\leq A_i \\leq 1000\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 \\ldots A_N\n\nOutput\n\nPrint a decimal number (or an integer) representing the value of \\frac{1}{\\frac{1}{A_1} + \\ldots + \\frac{1}{A_N}}.\n\nYour output will be judged correct when its absolute or relative error from the judge's output is at most 10^{-5}.\n\nSample Input 1\n\n2\n10 30\n\nSample Output 1\n\n7.5\n\n\\frac{1}{\\frac{1}{10} + \\frac{1}{30}} = \\frac{1}{\\frac{4}{30}} = \\frac{30}{4} = 7.5.\n\nPrinting 7.50001, 7.49999, and so on will also be accepted.\n\nSample Input 2\n\n3\n200 200 200\n\nSample Output 2\n\n66.66666666666667\n\n\\frac{1}{\\frac{1}{200} + \\frac{1}{200} + \\frac{1}{200}} = \\frac{1}{\\frac{3}{200}} = \\frac{200}{3} = 66.6666....\n\nPrinting 6.66666e+1 and so on will also be accepted.\n\nSample Input 3\n\n1\n1000\n\nSample Output 3\n\n1000\n\n\\frac{1}{\\frac{1}{1000}} = 1000.\n\nPrinting +1000.0 and so on will also be accepted.", "sample_input": "2\n10 30\n"}, "reference_outputs": ["7.5\n"], "source_document_id": "p02934", "source_text": "Score : 200 points\n\nProblem Statement\n\nGiven is a sequence of N integers A_1, \\ldots, A_N.\n\nFind the (multiplicative) inverse of the sum of the inverses of these numbers, \\frac{1}{\\frac{1}{A_1} + \\ldots + \\frac{1}{A_N}}.\n\nConstraints\n\n1 \\leq N \\leq 100\n\n1 \\leq A_i \\leq 1000\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 \\ldots A_N\n\nOutput\n\nPrint a decimal number (or an integer) representing the value of \\frac{1}{\\frac{1}{A_1} + \\ldots + \\frac{1}{A_N}}.\n\nYour output will be judged correct when its absolute or relative error from the judge's output is at most 10^{-5}.\n\nSample Input 1\n\n2\n10 30\n\nSample Output 1\n\n7.5\n\n\\frac{1}{\\frac{1}{10} + \\frac{1}{30}} = \\frac{1}{\\frac{4}{30}} = \\frac{30}{4} = 7.5.\n\nPrinting 7.50001, 7.49999, and so on will also be accepted.\n\nSample Input 2\n\n3\n200 200 200\n\nSample Output 2\n\n66.66666666666667\n\n\\frac{1}{\\frac{1}{200} + \\frac{1}{200} + \\frac{1}{200}} = \\frac{1}{\\frac{3}{200}} = \\frac{200}{3} = 66.6666....\n\nPrinting 6.66666e+1 and so on will also be accepted.\n\nSample Input 3\n\n1\n1000\n\nSample Output 3\n\n1000\n\n\\frac{1}{\\frac{1}{1000}} = 1000.\n\nPrinting +1000.0 and so on will also be accepted.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 356, "cpu_time_ms": 7, "memory_kb": 760}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s345565462", "group_id": "codeNet:p02937", "input_text": "local mfl = math.floor\n\nlocal function comp(a, b)\n return a < b\nend\n\nlocal function lower_bound(ary, x)\n local num = #ary\n if num == 0 then return 1 end\n if not comp(ary[1], x) then return 1 end\n if comp(ary[num], x) then return num + 1 end\n local min, max = 1, num\n while 1 < max - min do\n local mid = mfl((min + max) / 2)\n if comp(ary[mid], x) then\n min = mid\n else\n max = mid\n end\n end\n return max\nend\n\nlocal function upper_bound(ary, x)\n local num = #ary\n if num == 0 then return 1 end\n if comp(x, ary[1]) then return 1 end\n if not comp(x, ary[num]) then return num + 1 end\n local min, max = 1, num\n while 1 < max - min do\n local mid = mfl((min + max) / 2)\n if not comp(x, ary[mid]) then\n min = mid\n else\n max = mid\n end\n end\n return max\nend\n\nlocal s = io.read()\nlocal t = io.read()\nlocal w = {}\nfor i = 1, 26 do\n w[i] = {}\nend\nfor i = 1, #s do\n local b = s:byte(i) - 96\n table.insert(w[b], i)\nend\nfor i = 1, #t do\n local b = t:byte(i) - 96\n if #w[b] == 0 then print(-1) os.exit() end\nend\nlocal loop = 0\nlocal pos = 0\nfor i = 1, #t do\n local b = t:byte(i) - 96\n local ub = upper_bound(w[b], pos)\n if #w[b] < ub then\n loop = loop + 1\n pos = w[b][1]\n else\n pos = w[b][ub]\n end\nend\nprint(loop * #s + pos)\n", "language": "Lua", "metadata": {"date": 1600867648, "filename_ext": "lua", "original_language": "Lua (LuaJIT 2.1.0)", "problem_description_relpath": "problem_descriptions/p02937.html", "problem_id": "p02937", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02937/input.txt", "sample_output_relpath": "derived/input_output/data/p02937/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02937/Lua/s345565462.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s345565462", "user_id": "u120582723"}, "prompt_components": {"gold_output": "10\n", "input_to_evaluate": "local mfl = math.floor\n\nlocal function comp(a, b)\n return a < b\nend\n\nlocal function lower_bound(ary, x)\n local num = #ary\n if num == 0 then return 1 end\n if not comp(ary[1], x) then return 1 end\n if comp(ary[num], x) then return num + 1 end\n local min, max = 1, num\n while 1 < max - min do\n local mid = mfl((min + max) / 2)\n if comp(ary[mid], x) then\n min = mid\n else\n max = mid\n end\n end\n return max\nend\n\nlocal function upper_bound(ary, x)\n local num = #ary\n if num == 0 then return 1 end\n if comp(x, ary[1]) then return 1 end\n if not comp(x, ary[num]) then return num + 1 end\n local min, max = 1, num\n while 1 < max - min do\n local mid = mfl((min + max) / 2)\n if not comp(x, ary[mid]) then\n min = mid\n else\n max = mid\n end\n end\n return max\nend\n\nlocal s = io.read()\nlocal t = io.read()\nlocal w = {}\nfor i = 1, 26 do\n w[i] = {}\nend\nfor i = 1, #s do\n local b = s:byte(i) - 96\n table.insert(w[b], i)\nend\nfor i = 1, #t do\n local b = t:byte(i) - 96\n if #w[b] == 0 then print(-1) os.exit() end\nend\nlocal loop = 0\nlocal pos = 0\nfor i = 1, #t do\n local b = t:byte(i) - 96\n local ub = upper_bound(w[b], pos)\n if #w[b] < ub then\n loop = loop + 1\n pos = w[b][1]\n else\n pos = w[b][ub]\n end\nend\nprint(loop * #s + pos)\n", "problem_context": "Score : 500 points\n\nProblem Statement\n\nGiven are two strings s and t consisting of lowercase English letters. Determine if there exists an integer i satisfying the following condition, and find the minimum such i if it exists.\n\nLet s' be the concatenation of 10^{100} copies of s. t is a subsequence of the string {s'}_1{s'}_2\\ldots{s'}_i (the first i characters in s').\n\nNotes\n\nA subsequence of a string a is a string obtained by deleting zero or more characters from a and concatenating the remaining characters without changing the relative order. For example, the subsequences of contest include net, c, and contest.\n\nConstraints\n\n1 \\leq |s| \\leq 10^5\n\n1 \\leq |t| \\leq 10^5\n\ns and t consists of lowercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\ns\nt\n\nOutput\n\nIf there exists an integer i satisfying the following condition, print the minimum such i; otherwise, print -1.\n\nSample Input 1\n\ncontest\nson\n\nSample Output 1\n\n10\n\nt = son is a subsequence of the string contestcon (the first 10 characters in s' = contestcontestcontest...), so i = 10 satisfies the condition.\n\nOn the other hand, t is not a subsequence of the string contestco (the first 9 characters in s'), so i = 9 does not satisfy the condition.\n\nSimilarly, any integer less than 9 does not satisfy the condition, either. Thus, the minimum integer i satisfying the condition is 10.\n\nSample Input 2\n\ncontest\nprogramming\n\nSample Output 2\n\n-1\n\nt = programming is not a substring of s' = contestcontestcontest.... Thus, there is no integer i satisfying the condition.\n\nSample Input 3\n\ncontest\nsentence\n\nSample Output 3\n\n33\n\nNote that the answer may not fit into a 32-bit integer type, though we cannot put such a case here.", "sample_input": "contest\nson\n"}, "reference_outputs": ["10\n"], "source_document_id": "p02937", "source_text": "Score : 500 points\n\nProblem Statement\n\nGiven are two strings s and t consisting of lowercase English letters. Determine if there exists an integer i satisfying the following condition, and find the minimum such i if it exists.\n\nLet s' be the concatenation of 10^{100} copies of s. t is a subsequence of the string {s'}_1{s'}_2\\ldots{s'}_i (the first i characters in s').\n\nNotes\n\nA subsequence of a string a is a string obtained by deleting zero or more characters from a and concatenating the remaining characters without changing the relative order. For example, the subsequences of contest include net, c, and contest.\n\nConstraints\n\n1 \\leq |s| \\leq 10^5\n\n1 \\leq |t| \\leq 10^5\n\ns and t consists of lowercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\ns\nt\n\nOutput\n\nIf there exists an integer i satisfying the following condition, print the minimum such i; otherwise, print -1.\n\nSample Input 1\n\ncontest\nson\n\nSample Output 1\n\n10\n\nt = son is a subsequence of the string contestcon (the first 10 characters in s' = contestcontestcontest...), so i = 10 satisfies the condition.\n\nOn the other hand, t is not a subsequence of the string contestco (the first 9 characters in s'), so i = 9 does not satisfy the condition.\n\nSimilarly, any integer less than 9 does not satisfy the condition, either. Thus, the minimum integer i satisfying the condition is 10.\n\nSample Input 2\n\ncontest\nprogramming\n\nSample Output 2\n\n-1\n\nt = programming is not a substring of s' = contestcontestcontest.... Thus, there is no integer i satisfying the condition.\n\nSample Input 3\n\ncontest\nsentence\n\nSample Output 3\n\n33\n\nNote that the answer may not fit into a 32-bit integer type, though we cannot put such a case here.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1286, "cpu_time_ms": 61, "memory_kb": 4008}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s622641188", "group_id": "codeNet:p02937", "input_text": "local S = io.read(\"*l\")\nlocal SS = S .. S\nlocal T = io.read(\"*l\")\n\nlocal cur = 0\nlocal ans = 0\nlocal find = string.find\nlocal sub = string.sub\nfor i=1,#T do\n local c = sub(T, i, i)\n local pos = find(SS, c, cur+1)\n if pos then\n local step = pos - cur\n ans = ans + step\n cur = cur + step\n if cur > #S then\n cur = cur - #S\n end\n else\n print(\"-1\")\n return\n end\nend\nprint(ans)", "language": "Lua", "metadata": {"date": 1566255430, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p02937.html", "problem_id": "p02937", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02937/input.txt", "sample_output_relpath": "derived/input_output/data/p02937/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02937/Lua/s622641188.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s622641188", "user_id": "u162773977"}, "prompt_components": {"gold_output": "10\n", "input_to_evaluate": "local S = io.read(\"*l\")\nlocal SS = S .. S\nlocal T = io.read(\"*l\")\n\nlocal cur = 0\nlocal ans = 0\nlocal find = string.find\nlocal sub = string.sub\nfor i=1,#T do\n local c = sub(T, i, i)\n local pos = find(SS, c, cur+1)\n if pos then\n local step = pos - cur\n ans = ans + step\n cur = cur + step\n if cur > #S then\n cur = cur - #S\n end\n else\n print(\"-1\")\n return\n end\nend\nprint(ans)", "problem_context": "Score : 500 points\n\nProblem Statement\n\nGiven are two strings s and t consisting of lowercase English letters. Determine if there exists an integer i satisfying the following condition, and find the minimum such i if it exists.\n\nLet s' be the concatenation of 10^{100} copies of s. t is a subsequence of the string {s'}_1{s'}_2\\ldots{s'}_i (the first i characters in s').\n\nNotes\n\nA subsequence of a string a is a string obtained by deleting zero or more characters from a and concatenating the remaining characters without changing the relative order. For example, the subsequences of contest include net, c, and contest.\n\nConstraints\n\n1 \\leq |s| \\leq 10^5\n\n1 \\leq |t| \\leq 10^5\n\ns and t consists of lowercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\ns\nt\n\nOutput\n\nIf there exists an integer i satisfying the following condition, print the minimum such i; otherwise, print -1.\n\nSample Input 1\n\ncontest\nson\n\nSample Output 1\n\n10\n\nt = son is a subsequence of the string contestcon (the first 10 characters in s' = contestcontestcontest...), so i = 10 satisfies the condition.\n\nOn the other hand, t is not a subsequence of the string contestco (the first 9 characters in s'), so i = 9 does not satisfy the condition.\n\nSimilarly, any integer less than 9 does not satisfy the condition, either. Thus, the minimum integer i satisfying the condition is 10.\n\nSample Input 2\n\ncontest\nprogramming\n\nSample Output 2\n\n-1\n\nt = programming is not a substring of s' = contestcontestcontest.... Thus, there is no integer i satisfying the condition.\n\nSample Input 3\n\ncontest\nsentence\n\nSample Output 3\n\n33\n\nNote that the answer may not fit into a 32-bit integer type, though we cannot put such a case here.", "sample_input": "contest\nson\n"}, "reference_outputs": ["10\n"], "source_document_id": "p02937", "source_text": "Score : 500 points\n\nProblem Statement\n\nGiven are two strings s and t consisting of lowercase English letters. Determine if there exists an integer i satisfying the following condition, and find the minimum such i if it exists.\n\nLet s' be the concatenation of 10^{100} copies of s. t is a subsequence of the string {s'}_1{s'}_2\\ldots{s'}_i (the first i characters in s').\n\nNotes\n\nA subsequence of a string a is a string obtained by deleting zero or more characters from a and concatenating the remaining characters without changing the relative order. For example, the subsequences of contest include net, c, and contest.\n\nConstraints\n\n1 \\leq |s| \\leq 10^5\n\n1 \\leq |t| \\leq 10^5\n\ns and t consists of lowercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\ns\nt\n\nOutput\n\nIf there exists an integer i satisfying the following condition, print the minimum such i; otherwise, print -1.\n\nSample Input 1\n\ncontest\nson\n\nSample Output 1\n\n10\n\nt = son is a subsequence of the string contestcon (the first 10 characters in s' = contestcontestcontest...), so i = 10 satisfies the condition.\n\nOn the other hand, t is not a subsequence of the string contestco (the first 9 characters in s'), so i = 9 does not satisfy the condition.\n\nSimilarly, any integer less than 9 does not satisfy the condition, either. Thus, the minimum integer i satisfying the condition is 10.\n\nSample Input 2\n\ncontest\nprogramming\n\nSample Output 2\n\n-1\n\nt = programming is not a substring of s' = contestcontestcontest.... Thus, there is no integer i satisfying the condition.\n\nSample Input 3\n\ncontest\nsentence\n\nSample Output 3\n\n33\n\nNote that the answer may not fit into a 32-bit integer type, though we cannot put such a case here.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 446, "cpu_time_ms": 322, "memory_kb": 788}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s473358543", "group_id": "codeNet:p02937", "input_text": "local DBG = false\nif not DBG then\n assert = function()end\nend\nlocal function dbgpr(...)\n if DBG then\n io.write(\"[dbg]\")\n print(...)\n end\nend\n\nlocal function dbgpr_t(tbl, use_pairs)\n if DBG then\n local enum = ipairs\n if use_pairs then\n enum = pairs\n end\n dbgpr(tbl)\n io.write(\"[dbg]\")\n for i,v in enum(tbl) do\n io.write(i)\n io.write(\":\")\n io.write(tostring(v))\n io.write(\" \")\n end\n print(\"\")\n end\nend\n\nlocal function dbgpr_tp(tbl)\n dbgpr_t(tbl, true)\nend\n\nlocal function str2tbl(s)\n -- limit of #s is approximately 999959\n --local t = {string.byte(s, 1, #s)}\n local t = {}\n local a = string.byte('a')\n local char = string.char\n local sub = string.sub\n local byte = string.byte\n for i=1, #s do\n t[i] = byte(sub(s, i, i), 1, 1) - a + 1\n end\n return t\nend\n\n-- E\nlocal S = str2tbl(io.read(\"*l\"))\nlocal T = str2tbl(io.read(\"*l\"))\n--dbgpr_t(S)\n--dbgpr_t(T)\nlocal function search_s(n, c)\n for i=n,#S do\n if S[i] == c then\n --return i\n return i - n + 1\n end\n end\n return false\nend\nlocal lookup = {}\nlookup[0] = {}\nfor c=1,26 do\n lookup[0][c] = search_s(1, c)\nend\nfor i=1,#S do\n lookup[i] = {}\n for c=1,26 do\n if c == S[i] then\n lookup[i][c] = search_s(i+1, c)\n else\n local prev = lookup[i-1][c]\n lookup[i][c] = prev and prev - 1 or false\n end\n end\nend\n\nif DBG then\n for i=0,#S do\n local tbl = lookup[i]\n dbgpr(tbl)\n dbgpr(i)\n io.write(\"[dbg]\")\n for j,v in ipairs(tbl) do\n io.write(string.char(j+96))\n io.write(\":\")\n io.write(v and v or '*')\n io.write(\" \")\n end\n print(\"\")\n end\nend\nlocal cur = 0\nlocal ans = 0\nlocal i = 1\nwhile i <= #T do\n local c = T[i]\n dbgpr(\"!\", \"i=\", i, ans, \"c=\", c, \"cur=\", cur, \"#lookup\", #lookup)\n local step = lookup[cur][c]\n dbgpr(i, ans, c, cur, step)\n if step then\n dbgpr(cur, step)\n ans = ans + step\n cur = cur + step\n assert(cur <= #S)\n i = i + 1\n elseif cur ~= 0 then\n ans = ans + (#S - cur)\n cur = 0\n else\n -- cur == 0\n print(\"-1\")\n return\n end\nend\nprint(ans)", "language": "Lua", "metadata": {"date": 1566182006, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p02937.html", "problem_id": "p02937", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02937/input.txt", "sample_output_relpath": "derived/input_output/data/p02937/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02937/Lua/s473358543.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s473358543", "user_id": "u162773977"}, "prompt_components": {"gold_output": "10\n", "input_to_evaluate": "local DBG = false\nif not DBG then\n assert = function()end\nend\nlocal function dbgpr(...)\n if DBG then\n io.write(\"[dbg]\")\n print(...)\n end\nend\n\nlocal function dbgpr_t(tbl, use_pairs)\n if DBG then\n local enum = ipairs\n if use_pairs then\n enum = pairs\n end\n dbgpr(tbl)\n io.write(\"[dbg]\")\n for i,v in enum(tbl) do\n io.write(i)\n io.write(\":\")\n io.write(tostring(v))\n io.write(\" \")\n end\n print(\"\")\n end\nend\n\nlocal function dbgpr_tp(tbl)\n dbgpr_t(tbl, true)\nend\n\nlocal function str2tbl(s)\n -- limit of #s is approximately 999959\n --local t = {string.byte(s, 1, #s)}\n local t = {}\n local a = string.byte('a')\n local char = string.char\n local sub = string.sub\n local byte = string.byte\n for i=1, #s do\n t[i] = byte(sub(s, i, i), 1, 1) - a + 1\n end\n return t\nend\n\n-- E\nlocal S = str2tbl(io.read(\"*l\"))\nlocal T = str2tbl(io.read(\"*l\"))\n--dbgpr_t(S)\n--dbgpr_t(T)\nlocal function search_s(n, c)\n for i=n,#S do\n if S[i] == c then\n --return i\n return i - n + 1\n end\n end\n return false\nend\nlocal lookup = {}\nlookup[0] = {}\nfor c=1,26 do\n lookup[0][c] = search_s(1, c)\nend\nfor i=1,#S do\n lookup[i] = {}\n for c=1,26 do\n if c == S[i] then\n lookup[i][c] = search_s(i+1, c)\n else\n local prev = lookup[i-1][c]\n lookup[i][c] = prev and prev - 1 or false\n end\n end\nend\n\nif DBG then\n for i=0,#S do\n local tbl = lookup[i]\n dbgpr(tbl)\n dbgpr(i)\n io.write(\"[dbg]\")\n for j,v in ipairs(tbl) do\n io.write(string.char(j+96))\n io.write(\":\")\n io.write(v and v or '*')\n io.write(\" \")\n end\n print(\"\")\n end\nend\nlocal cur = 0\nlocal ans = 0\nlocal i = 1\nwhile i <= #T do\n local c = T[i]\n dbgpr(\"!\", \"i=\", i, ans, \"c=\", c, \"cur=\", cur, \"#lookup\", #lookup)\n local step = lookup[cur][c]\n dbgpr(i, ans, c, cur, step)\n if step then\n dbgpr(cur, step)\n ans = ans + step\n cur = cur + step\n assert(cur <= #S)\n i = i + 1\n elseif cur ~= 0 then\n ans = ans + (#S - cur)\n cur = 0\n else\n -- cur == 0\n print(\"-1\")\n return\n end\nend\nprint(ans)", "problem_context": "Score : 500 points\n\nProblem Statement\n\nGiven are two strings s and t consisting of lowercase English letters. Determine if there exists an integer i satisfying the following condition, and find the minimum such i if it exists.\n\nLet s' be the concatenation of 10^{100} copies of s. t is a subsequence of the string {s'}_1{s'}_2\\ldots{s'}_i (the first i characters in s').\n\nNotes\n\nA subsequence of a string a is a string obtained by deleting zero or more characters from a and concatenating the remaining characters without changing the relative order. For example, the subsequences of contest include net, c, and contest.\n\nConstraints\n\n1 \\leq |s| \\leq 10^5\n\n1 \\leq |t| \\leq 10^5\n\ns and t consists of lowercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\ns\nt\n\nOutput\n\nIf there exists an integer i satisfying the following condition, print the minimum such i; otherwise, print -1.\n\nSample Input 1\n\ncontest\nson\n\nSample Output 1\n\n10\n\nt = son is a subsequence of the string contestcon (the first 10 characters in s' = contestcontestcontest...), so i = 10 satisfies the condition.\n\nOn the other hand, t is not a subsequence of the string contestco (the first 9 characters in s'), so i = 9 does not satisfy the condition.\n\nSimilarly, any integer less than 9 does not satisfy the condition, either. Thus, the minimum integer i satisfying the condition is 10.\n\nSample Input 2\n\ncontest\nprogramming\n\nSample Output 2\n\n-1\n\nt = programming is not a substring of s' = contestcontestcontest.... Thus, there is no integer i satisfying the condition.\n\nSample Input 3\n\ncontest\nsentence\n\nSample Output 3\n\n33\n\nNote that the answer may not fit into a 32-bit integer type, though we cannot put such a case here.", "sample_input": "contest\nson\n"}, "reference_outputs": ["10\n"], "source_document_id": "p02937", "source_text": "Score : 500 points\n\nProblem Statement\n\nGiven are two strings s and t consisting of lowercase English letters. Determine if there exists an integer i satisfying the following condition, and find the minimum such i if it exists.\n\nLet s' be the concatenation of 10^{100} copies of s. t is a subsequence of the string {s'}_1{s'}_2\\ldots{s'}_i (the first i characters in s').\n\nNotes\n\nA subsequence of a string a is a string obtained by deleting zero or more characters from a and concatenating the remaining characters without changing the relative order. For example, the subsequences of contest include net, c, and contest.\n\nConstraints\n\n1 \\leq |s| \\leq 10^5\n\n1 \\leq |t| \\leq 10^5\n\ns and t consists of lowercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\ns\nt\n\nOutput\n\nIf there exists an integer i satisfying the following condition, print the minimum such i; otherwise, print -1.\n\nSample Input 1\n\ncontest\nson\n\nSample Output 1\n\n10\n\nt = son is a subsequence of the string contestcon (the first 10 characters in s' = contestcontestcontest...), so i = 10 satisfies the condition.\n\nOn the other hand, t is not a subsequence of the string contestco (the first 9 characters in s'), so i = 9 does not satisfy the condition.\n\nSimilarly, any integer less than 9 does not satisfy the condition, either. Thus, the minimum integer i satisfying the condition is 10.\n\nSample Input 2\n\ncontest\nprogramming\n\nSample Output 2\n\n-1\n\nt = programming is not a substring of s' = contestcontestcontest.... Thus, there is no integer i satisfying the condition.\n\nSample Input 3\n\ncontest\nsentence\n\nSample Output 3\n\n33\n\nNote that the answer may not fit into a 32-bit integer type, though we cannot put such a case here.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2367, "cpu_time_ms": 181, "memory_kb": 35756}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s749385071", "group_id": "codeNet:p02937", "input_text": "local DBG = false\nif not DBG then\n assert = function()end\nend\nlocal function dbgpr(...)\n if DBG then\n io.write(\"[dbg]\")\n print(...)\n end\nend\n\nlocal function dbgpr_t(tbl, use_pairs)\n if DBG then\n local enum = ipairs\n if use_pairs then\n enum = pairs\n end\n dbgpr(tbl)\n io.write(\"[dbg]\")\n for i,v in enum(tbl) do\n io.write(i)\n io.write(\":\")\n io.write(tostring(v))\n io.write(\" \")\n end\n print(\"\")\n end\nend\n\nlocal function dbgpr_tp(tbl)\n dbgpr_t(tbl, true)\nend\n\nlocal function str2tbl(s)\n -- limit of #s is approximately 999959\n local t = {string.byte(s, 1, #s)}\n local a = string.byte('a')\n local char = string.char\n for i=1, #t do\n t[i] = t[i] - a + 1\n end\n return t\nend\n\n-- E\nlocal S = str2tbl(io.read(\"*l\"))\nlocal T = str2tbl(io.read(\"*l\"))\n--dbgpr_t(S)\n--dbgpr_t(T)\nlocal function search_s(n, c)\n for i=n,#S do\n if S[i] == c then\n --return i\n return i - n + 1\n end\n end\n return false\nend\nlocal lookup = {}\nlookup[0] = {}\nfor c=1,26 do\n lookup[0][c] = search_s(1, c)\nend\nfor i=1,#S do\n lookup[i] = {}\n for c=1,26 do\n if c == S[i] then\n lookup[i][c] = search_s(i+1, c)\n else\n local prev = lookup[i-1][c]\n lookup[i][c] = prev and prev - 1 or false\n end\n end\nend\n\nif DBG then\n for i=0,#S do\n local tbl = lookup[i]\n dbgpr(tbl)\n dbgpr(i)\n io.write(\"[dbg]\")\n for j,v in ipairs(tbl) do\n io.write(string.char(j+96))\n io.write(\":\")\n io.write(v and v or '*')\n io.write(\" \")\n end\n print(\"\")\n end\nend\nlocal cur = 0\nlocal ans = 0\nlocal i = 1\nwhile i <= #T do\n local c = T[i]\n dbgpr(\"!\", \"i=\", i, ans, \"c=\", c, \"cur=\", cur, \"#lookup\", #lookup)\n local step = lookup[cur][c]\n dbgpr(i, ans, c, cur, step)\n if step then\n dbgpr(cur, step)\n ans = ans + step\n cur = cur + step\n assert(cur <= #S)\n i = i + 1\n elseif cur ~= 0 then\n ans = ans + (#S - cur)\n cur = 0\n else\n -- cur == 0\n print(\"-1\")\n return\n end\nend\nprint(ans)", "language": "Lua", "metadata": {"date": 1566181719, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p02937.html", "problem_id": "p02937", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02937/input.txt", "sample_output_relpath": "derived/input_output/data/p02937/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02937/Lua/s749385071.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s749385071", "user_id": "u162773977"}, "prompt_components": {"gold_output": "10\n", "input_to_evaluate": "local DBG = false\nif not DBG then\n assert = function()end\nend\nlocal function dbgpr(...)\n if DBG then\n io.write(\"[dbg]\")\n print(...)\n end\nend\n\nlocal function dbgpr_t(tbl, use_pairs)\n if DBG then\n local enum = ipairs\n if use_pairs then\n enum = pairs\n end\n dbgpr(tbl)\n io.write(\"[dbg]\")\n for i,v in enum(tbl) do\n io.write(i)\n io.write(\":\")\n io.write(tostring(v))\n io.write(\" \")\n end\n print(\"\")\n end\nend\n\nlocal function dbgpr_tp(tbl)\n dbgpr_t(tbl, true)\nend\n\nlocal function str2tbl(s)\n -- limit of #s is approximately 999959\n local t = {string.byte(s, 1, #s)}\n local a = string.byte('a')\n local char = string.char\n for i=1, #t do\n t[i] = t[i] - a + 1\n end\n return t\nend\n\n-- E\nlocal S = str2tbl(io.read(\"*l\"))\nlocal T = str2tbl(io.read(\"*l\"))\n--dbgpr_t(S)\n--dbgpr_t(T)\nlocal function search_s(n, c)\n for i=n,#S do\n if S[i] == c then\n --return i\n return i - n + 1\n end\n end\n return false\nend\nlocal lookup = {}\nlookup[0] = {}\nfor c=1,26 do\n lookup[0][c] = search_s(1, c)\nend\nfor i=1,#S do\n lookup[i] = {}\n for c=1,26 do\n if c == S[i] then\n lookup[i][c] = search_s(i+1, c)\n else\n local prev = lookup[i-1][c]\n lookup[i][c] = prev and prev - 1 or false\n end\n end\nend\n\nif DBG then\n for i=0,#S do\n local tbl = lookup[i]\n dbgpr(tbl)\n dbgpr(i)\n io.write(\"[dbg]\")\n for j,v in ipairs(tbl) do\n io.write(string.char(j+96))\n io.write(\":\")\n io.write(v and v or '*')\n io.write(\" \")\n end\n print(\"\")\n end\nend\nlocal cur = 0\nlocal ans = 0\nlocal i = 1\nwhile i <= #T do\n local c = T[i]\n dbgpr(\"!\", \"i=\", i, ans, \"c=\", c, \"cur=\", cur, \"#lookup\", #lookup)\n local step = lookup[cur][c]\n dbgpr(i, ans, c, cur, step)\n if step then\n dbgpr(cur, step)\n ans = ans + step\n cur = cur + step\n assert(cur <= #S)\n i = i + 1\n elseif cur ~= 0 then\n ans = ans + (#S - cur)\n cur = 0\n else\n -- cur == 0\n print(\"-1\")\n return\n end\nend\nprint(ans)", "problem_context": "Score : 500 points\n\nProblem Statement\n\nGiven are two strings s and t consisting of lowercase English letters. Determine if there exists an integer i satisfying the following condition, and find the minimum such i if it exists.\n\nLet s' be the concatenation of 10^{100} copies of s. t is a subsequence of the string {s'}_1{s'}_2\\ldots{s'}_i (the first i characters in s').\n\nNotes\n\nA subsequence of a string a is a string obtained by deleting zero or more characters from a and concatenating the remaining characters without changing the relative order. For example, the subsequences of contest include net, c, and contest.\n\nConstraints\n\n1 \\leq |s| \\leq 10^5\n\n1 \\leq |t| \\leq 10^5\n\ns and t consists of lowercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\ns\nt\n\nOutput\n\nIf there exists an integer i satisfying the following condition, print the minimum such i; otherwise, print -1.\n\nSample Input 1\n\ncontest\nson\n\nSample Output 1\n\n10\n\nt = son is a subsequence of the string contestcon (the first 10 characters in s' = contestcontestcontest...), so i = 10 satisfies the condition.\n\nOn the other hand, t is not a subsequence of the string contestco (the first 9 characters in s'), so i = 9 does not satisfy the condition.\n\nSimilarly, any integer less than 9 does not satisfy the condition, either. Thus, the minimum integer i satisfying the condition is 10.\n\nSample Input 2\n\ncontest\nprogramming\n\nSample Output 2\n\n-1\n\nt = programming is not a substring of s' = contestcontestcontest.... Thus, there is no integer i satisfying the condition.\n\nSample Input 3\n\ncontest\nsentence\n\nSample Output 3\n\n33\n\nNote that the answer may not fit into a 32-bit integer type, though we cannot put such a case here.", "sample_input": "contest\nson\n"}, "reference_outputs": ["10\n"], "source_document_id": "p02937", "source_text": "Score : 500 points\n\nProblem Statement\n\nGiven are two strings s and t consisting of lowercase English letters. Determine if there exists an integer i satisfying the following condition, and find the minimum such i if it exists.\n\nLet s' be the concatenation of 10^{100} copies of s. t is a subsequence of the string {s'}_1{s'}_2\\ldots{s'}_i (the first i characters in s').\n\nNotes\n\nA subsequence of a string a is a string obtained by deleting zero or more characters from a and concatenating the remaining characters without changing the relative order. For example, the subsequences of contest include net, c, and contest.\n\nConstraints\n\n1 \\leq |s| \\leq 10^5\n\n1 \\leq |t| \\leq 10^5\n\ns and t consists of lowercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\ns\nt\n\nOutput\n\nIf there exists an integer i satisfying the following condition, print the minimum such i; otherwise, print -1.\n\nSample Input 1\n\ncontest\nson\n\nSample Output 1\n\n10\n\nt = son is a subsequence of the string contestcon (the first 10 characters in s' = contestcontestcontest...), so i = 10 satisfies the condition.\n\nOn the other hand, t is not a subsequence of the string contestco (the first 9 characters in s'), so i = 9 does not satisfy the condition.\n\nSimilarly, any integer less than 9 does not satisfy the condition, either. Thus, the minimum integer i satisfying the condition is 10.\n\nSample Input 2\n\ncontest\nprogramming\n\nSample Output 2\n\n-1\n\nt = programming is not a substring of s' = contestcontestcontest.... Thus, there is no integer i satisfying the condition.\n\nSample Input 3\n\ncontest\nsentence\n\nSample Output 3\n\n33\n\nNote that the answer may not fit into a 32-bit integer type, though we cannot put such a case here.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2272, "cpu_time_ms": 1, "memory_kb": 512}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s930421364", "group_id": "codeNet:p02941", "input_text": "local mfl, mce = math.floor, math.ceil\nlocal mmi, mma = math.min, math.max\nlocal bls, brs = bit.lshift, bit.rshift\nlocal SegTree = {}\nSegTree.updateAll = function(self)\n for i = self.stagenum - 1, 1, -1 do\n local cnt = bls(1, i - 1)\n for j = 1, cnt do\n self.stage[i][j] = self.func(self.stage[i + 1][j * 2 - 1], self.stage[i + 1][j * 2])\n end\n end\nend\nSegTree.create = function(self, n, func, emptyvalue)\n self.func, self.emptyvalue = func, emptyvalue\n local stagenum, mul = 1, 1\n self.stage = {{}}\n while mul < n do\n mul, stagenum = mul * 2, stagenum + 1\n self.stage[stagenum] = {}\n end\n self.stagenum = stagenum\n self.left_stage = {}\n for i = 1, n do\n local sp, sz = 1, bls(1, stagenum - 1)\n while(i - 1) % sz ~= 0 do\n sp, sz = sp + 1, brs(sz, 1)\n end\n self.left_stage[i] = sp\n end\n self.sz_stage = {}\n local tmp, sp = 1, stagenum\n for i = 1, n do\n if tmp * 2 == i then tmp, sp = tmp * 2, sp - 1 end\n self.sz_stage[i] = sp\n end\n for i = 1, n do self.stage[stagenum][i] = i end\n for i = n + 1, mul do self.stage[stagenum][i] = emptyvalue end\n self:updateAll()\nend\nSegTree.getRange = function(self, left, right)\n if left == right then return self.stage[self.stagenum][left] end\n local stagenum = self.stagenum\n local ret = self.emptyvalue\n while left <= right do\n local stage = mma(self.left_stage[left], self.sz_stage[right - left + 1])\n local sz = bls(1, stagenum - stage)\n ret = self.func(ret, self.stage[stage][1 + brs(left - 1, stagenum - stage)])\n left = left + sz\n end\n return ret\nend\nSegTree.update = function(self, idx)\n for i = self.stagenum - 1, 1, -1 do\n local dst = brs(idx + 1, 1)\n local rem = dst * 4 - 1 - idx\n self.stage[i][dst] = self.func(self.stage[i + 1][idx], self.stage[i + 1][rem])\n idx = dst\n end\nend\nSegTree.new = function(n, func, emptyvalue)\n local obj = {}\n setmetatable(obj, {__index = SegTree})\n obj:create(n, func, emptyvalue)\n return obj\nend\n\nlocal n = io.read(\"*n\")\nlocal a = {}\nfor i = 1, n do\n a[i] = io.read(\"*n\")\nend\nlocal b = {}\nfor i = 1, n do\n b[i] = io.read(\"*n\")\nend\nlocal fixedcnt = 0\nlocal fixed = {}\nfor i = 1, n do\n fixed[i] = a[i] == b[i]\n if fixed[i] then fixedcnt = fixedcnt + 1 end\nend\nfixed[n + 1] = true\n\nlocal function mergefunc(x, y)\n if fixed[x] then return y\n elseif fixed[y] then return x\n else\n return b[x] < b[y] and y or x\n end\nend\n\nlocal cnt = 0\nlocal st = SegTree.new(n, mergefunc, n + 1)\nwhile true do\n local top = st.stage[1][1]\n if fixed[top] then break end\n local left = top - 1\n if left == 0 then left = n end\n local right = top + 1\n if right == n + 1 then right = 1 end\n local dec = b[left] + b[right]\n local declim1 = mce((b[top] - b[left]) / dec)\n local declim2 = mce((b[top] - b[right]) / dec)\n local declim3 = mce((b[top] - a[top]) / dec)\n local deccnt = mmi(declim1, declim2, declim3)\n deccnt = mma(deccnt, 1)\n b[top] = b[top] - dec * deccnt\n cnt = cnt + deccnt\n if b[top] < a[top] then\n break\n elseif b[top] == a[top] then\n fixed[top] = true\n fixedcnt = fixedcnt + 1\n if fixedcnt == n then break end\n end\n st:update(top)\nend\nprint(fixedcnt == n and cnt or -1)\n", "language": "Lua", "metadata": {"date": 1589252168, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p02941.html", "problem_id": "p02941", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02941/input.txt", "sample_output_relpath": "derived/input_output/data/p02941/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02941/Lua/s930421364.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s930421364", "user_id": "u120582723"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "local mfl, mce = math.floor, math.ceil\nlocal mmi, mma = math.min, math.max\nlocal bls, brs = bit.lshift, bit.rshift\nlocal SegTree = {}\nSegTree.updateAll = function(self)\n for i = self.stagenum - 1, 1, -1 do\n local cnt = bls(1, i - 1)\n for j = 1, cnt do\n self.stage[i][j] = self.func(self.stage[i + 1][j * 2 - 1], self.stage[i + 1][j * 2])\n end\n end\nend\nSegTree.create = function(self, n, func, emptyvalue)\n self.func, self.emptyvalue = func, emptyvalue\n local stagenum, mul = 1, 1\n self.stage = {{}}\n while mul < n do\n mul, stagenum = mul * 2, stagenum + 1\n self.stage[stagenum] = {}\n end\n self.stagenum = stagenum\n self.left_stage = {}\n for i = 1, n do\n local sp, sz = 1, bls(1, stagenum - 1)\n while(i - 1) % sz ~= 0 do\n sp, sz = sp + 1, brs(sz, 1)\n end\n self.left_stage[i] = sp\n end\n self.sz_stage = {}\n local tmp, sp = 1, stagenum\n for i = 1, n do\n if tmp * 2 == i then tmp, sp = tmp * 2, sp - 1 end\n self.sz_stage[i] = sp\n end\n for i = 1, n do self.stage[stagenum][i] = i end\n for i = n + 1, mul do self.stage[stagenum][i] = emptyvalue end\n self:updateAll()\nend\nSegTree.getRange = function(self, left, right)\n if left == right then return self.stage[self.stagenum][left] end\n local stagenum = self.stagenum\n local ret = self.emptyvalue\n while left <= right do\n local stage = mma(self.left_stage[left], self.sz_stage[right - left + 1])\n local sz = bls(1, stagenum - stage)\n ret = self.func(ret, self.stage[stage][1 + brs(left - 1, stagenum - stage)])\n left = left + sz\n end\n return ret\nend\nSegTree.update = function(self, idx)\n for i = self.stagenum - 1, 1, -1 do\n local dst = brs(idx + 1, 1)\n local rem = dst * 4 - 1 - idx\n self.stage[i][dst] = self.func(self.stage[i + 1][idx], self.stage[i + 1][rem])\n idx = dst\n end\nend\nSegTree.new = function(n, func, emptyvalue)\n local obj = {}\n setmetatable(obj, {__index = SegTree})\n obj:create(n, func, emptyvalue)\n return obj\nend\n\nlocal n = io.read(\"*n\")\nlocal a = {}\nfor i = 1, n do\n a[i] = io.read(\"*n\")\nend\nlocal b = {}\nfor i = 1, n do\n b[i] = io.read(\"*n\")\nend\nlocal fixedcnt = 0\nlocal fixed = {}\nfor i = 1, n do\n fixed[i] = a[i] == b[i]\n if fixed[i] then fixedcnt = fixedcnt + 1 end\nend\nfixed[n + 1] = true\n\nlocal function mergefunc(x, y)\n if fixed[x] then return y\n elseif fixed[y] then return x\n else\n return b[x] < b[y] and y or x\n end\nend\n\nlocal cnt = 0\nlocal st = SegTree.new(n, mergefunc, n + 1)\nwhile true do\n local top = st.stage[1][1]\n if fixed[top] then break end\n local left = top - 1\n if left == 0 then left = n end\n local right = top + 1\n if right == n + 1 then right = 1 end\n local dec = b[left] + b[right]\n local declim1 = mce((b[top] - b[left]) / dec)\n local declim2 = mce((b[top] - b[right]) / dec)\n local declim3 = mce((b[top] - a[top]) / dec)\n local deccnt = mmi(declim1, declim2, declim3)\n deccnt = mma(deccnt, 1)\n b[top] = b[top] - dec * deccnt\n cnt = cnt + deccnt\n if b[top] < a[top] then\n break\n elseif b[top] == a[top] then\n fixed[top] = true\n fixedcnt = fixedcnt + 1\n if fixedcnt == n then break end\n end\n st:update(top)\nend\nprint(fixedcnt == n and cnt or -1)\n", "problem_context": "Score : 800 points\n\nProblem Statement\n\nThere are N positive integers arranged in a circle.\n\nNow, the i-th number is A_i. Takahashi wants the i-th number to be B_i. For this objective, he will repeatedly perform the following operation:\n\nChoose an integer i such that 1 \\leq i \\leq N.\n\nLet a, b, c be the (i-1)-th, i-th, and (i+1)-th numbers, respectively. Replace the i-th number with a+b+c.\n\nHere the 0-th number is the N-th number, and the (N+1)-th number is the 1-st number.\n\nDetermine if Takahashi can achieve his objective.\nIf the answer is yes, find the minimum number of operations required.\n\nConstraints\n\n3 \\leq N \\leq 2 \\times 10^5\n\n1 \\leq A_i, B_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\nB_1 B_2 ... B_N\n\nOutput\n\nPrint the minimum number of operations required, or -1 if the objective cannot be achieved.\n\nSample Input 1\n\n3\n1 1 1\n13 5 7\n\nSample Output 1\n\n4\n\nTakahashi can achieve his objective by, for example, performing the following operations:\n\nReplace the second number with 3.\n\nReplace the second number with 5.\n\nReplace the third number with 7.\n\nReplace the first number with 13.\n\nSample Input 2\n\n4\n1 2 3 4\n2 3 4 5\n\nSample Output 2\n\n-1\n\nSample Input 3\n\n5\n5 6 5 2 1\n9817 1108 6890 4343 8704\n\nSample Output 3\n\n25", "sample_input": "3\n1 1 1\n13 5 7\n"}, "reference_outputs": ["4\n"], "source_document_id": "p02941", "source_text": "Score : 800 points\n\nProblem Statement\n\nThere are N positive integers arranged in a circle.\n\nNow, the i-th number is A_i. Takahashi wants the i-th number to be B_i. For this objective, he will repeatedly perform the following operation:\n\nChoose an integer i such that 1 \\leq i \\leq N.\n\nLet a, b, c be the (i-1)-th, i-th, and (i+1)-th numbers, respectively. Replace the i-th number with a+b+c.\n\nHere the 0-th number is the N-th number, and the (N+1)-th number is the 1-st number.\n\nDetermine if Takahashi can achieve his objective.\nIf the answer is yes, find the minimum number of operations required.\n\nConstraints\n\n3 \\leq N \\leq 2 \\times 10^5\n\n1 \\leq A_i, B_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\nB_1 B_2 ... B_N\n\nOutput\n\nPrint the minimum number of operations required, or -1 if the objective cannot be achieved.\n\nSample Input 1\n\n3\n1 1 1\n13 5 7\n\nSample Output 1\n\n4\n\nTakahashi can achieve his objective by, for example, performing the following operations:\n\nReplace the second number with 3.\n\nReplace the second number with 5.\n\nReplace the third number with 7.\n\nReplace the first number with 13.\n\nSample Input 2\n\n4\n1 2 3 4\n2 3 4 5\n\nSample Output 2\n\n-1\n\nSample Input 3\n\n5\n5 6 5 2 1\n9817 1108 6890 4343 8704\n\nSample Output 3\n\n25", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 3173, "cpu_time_ms": 731, "memory_kb": 14720}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s756050631", "group_id": "codeNet:p02941", "input_text": "local mfl, mce = math.floor, math.ceil\nlocal mmi, mma = math.min, math.max\nlocal bls, brs = bit.lshift, bit.rshift\nlocal SegTree = {}\nSegTree.updateAll = function(self)\n for i = self.stagenum - 1, 1, -1 do\n local cnt = bls(1, i - 1)\n for j = 1, cnt do\n self.stage[i][j] = self.func(self.stage[i + 1][j * 2 - 1], self.stage[i + 1][j * 2])\n end\n end\nend\nSegTree.create = function(self, n, func, emptyvalue)\n self.func, self.emptyvalue = func, emptyvalue\n local stagenum, mul = 1, 1\n self.stage = {{}}\n while mul < n do\n mul, stagenum = mul * 2, stagenum + 1\n self.stage[stagenum] = {}\n end\n self.stagenum = stagenum\n self.left_stage = {}\n for i = 1, n do\n local sp, sz = 1, bls(1, stagenum - 1)\n while(i - 1) % sz ~= 0 do\n sp, sz = sp + 1, brs(sz, 1)\n end\n self.left_stage[i] = sp\n end\n self.sz_stage = {}\n local tmp, sp = 1, stagenum\n for i = 1, n do\n if tmp * 2 == i then tmp, sp = tmp * 2, sp - 1 end\n self.sz_stage[i] = sp\n end\n for i = 1, n do self.stage[stagenum][i] = i end\n for i = n + 1, mul do self.stage[stagenum][i] = emptyvalue end\n self:updateAll()\nend\nSegTree.getRange = function(self, left, right)\n if left == right then return self.stage[self.stagenum][left] end\n local stagenum = self.stagenum\n local ret = self.emptyvalue\n while left <= right do\n local stage = mma(self.left_stage[left], self.sz_stage[right - left + 1])\n local sz = bls(1, stagenum - stage)\n ret = self.func(ret, self.stage[stage][1 + brs(left - 1, stagenum - stage)])\n left = left + sz\n end\n return ret\nend\nSegTree.update = function(self, idx)\n for i = self.stagenum - 1, 1, -1 do\n local dst = brs(idx + 1, 1)\n local rem = dst * 4 - 1 - idx\n self.stage[i][dst] = self.func(self.stage[i + 1][idx], self.stage[i + 1][rem])\n idx = dst\n end\nend\nSegTree.new = function(n, func, emptyvalue)\n local obj = {}\n setmetatable(obj, {__index = SegTree})\n obj:create(n, func, emptyvalue)\n return obj\nend\n\nlocal n = io.read(\"*n\")\nlocal a = {}\nfor i = 1, n do\n a[i] = io.read(\"*n\")\nend\nlocal b = {}\nfor i = 1, n do\n b[i] = io.read(\"*n\")\nend\nlocal fixedcnt = 0\nlocal fixed = {}\nfor i = 1, n do\n fixed[i] = a[i] == b[i]\n if fixed[i] then fixedcnt = fixedcnt + 1 end\nend\nfixed[n + 1] = true\n\nlocal function mergefunc(x, y)\n if fixed[x] then return y\n elseif fixed[y] then return x\n else\n return b[x] < b[y] and y or x\n end\nend\n\nlocal cnt = 0\nlocal st = SegTree.new(n, mergefunc, n + 1)\nwhile true do\n local top = st.stage[1][1]\n if fixed[top] then break end\n local left = top - 1\n if left == 0 then left = n end\n local right = top + 1\n if right == n + 1 then right = 1 end\n b[top] = b[top] - b[left] - b[right]\n cnt = cnt + 1\n if b[top] < a[top] then\n break\n elseif b[top] == a[top] then\n fixed[top] = true\n fixedcnt = fixedcnt + 1\n if fixedcnt == n then break end\n end\n st:update(top)\nend\nprint(fixedcnt == n and cnt or -1)\n", "language": "Lua", "metadata": {"date": 1589250546, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p02941.html", "problem_id": "p02941", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02941/input.txt", "sample_output_relpath": "derived/input_output/data/p02941/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02941/Lua/s756050631.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s756050631", "user_id": "u120582723"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "local mfl, mce = math.floor, math.ceil\nlocal mmi, mma = math.min, math.max\nlocal bls, brs = bit.lshift, bit.rshift\nlocal SegTree = {}\nSegTree.updateAll = function(self)\n for i = self.stagenum - 1, 1, -1 do\n local cnt = bls(1, i - 1)\n for j = 1, cnt do\n self.stage[i][j] = self.func(self.stage[i + 1][j * 2 - 1], self.stage[i + 1][j * 2])\n end\n end\nend\nSegTree.create = function(self, n, func, emptyvalue)\n self.func, self.emptyvalue = func, emptyvalue\n local stagenum, mul = 1, 1\n self.stage = {{}}\n while mul < n do\n mul, stagenum = mul * 2, stagenum + 1\n self.stage[stagenum] = {}\n end\n self.stagenum = stagenum\n self.left_stage = {}\n for i = 1, n do\n local sp, sz = 1, bls(1, stagenum - 1)\n while(i - 1) % sz ~= 0 do\n sp, sz = sp + 1, brs(sz, 1)\n end\n self.left_stage[i] = sp\n end\n self.sz_stage = {}\n local tmp, sp = 1, stagenum\n for i = 1, n do\n if tmp * 2 == i then tmp, sp = tmp * 2, sp - 1 end\n self.sz_stage[i] = sp\n end\n for i = 1, n do self.stage[stagenum][i] = i end\n for i = n + 1, mul do self.stage[stagenum][i] = emptyvalue end\n self:updateAll()\nend\nSegTree.getRange = function(self, left, right)\n if left == right then return self.stage[self.stagenum][left] end\n local stagenum = self.stagenum\n local ret = self.emptyvalue\n while left <= right do\n local stage = mma(self.left_stage[left], self.sz_stage[right - left + 1])\n local sz = bls(1, stagenum - stage)\n ret = self.func(ret, self.stage[stage][1 + brs(left - 1, stagenum - stage)])\n left = left + sz\n end\n return ret\nend\nSegTree.update = function(self, idx)\n for i = self.stagenum - 1, 1, -1 do\n local dst = brs(idx + 1, 1)\n local rem = dst * 4 - 1 - idx\n self.stage[i][dst] = self.func(self.stage[i + 1][idx], self.stage[i + 1][rem])\n idx = dst\n end\nend\nSegTree.new = function(n, func, emptyvalue)\n local obj = {}\n setmetatable(obj, {__index = SegTree})\n obj:create(n, func, emptyvalue)\n return obj\nend\n\nlocal n = io.read(\"*n\")\nlocal a = {}\nfor i = 1, n do\n a[i] = io.read(\"*n\")\nend\nlocal b = {}\nfor i = 1, n do\n b[i] = io.read(\"*n\")\nend\nlocal fixedcnt = 0\nlocal fixed = {}\nfor i = 1, n do\n fixed[i] = a[i] == b[i]\n if fixed[i] then fixedcnt = fixedcnt + 1 end\nend\nfixed[n + 1] = true\n\nlocal function mergefunc(x, y)\n if fixed[x] then return y\n elseif fixed[y] then return x\n else\n return b[x] < b[y] and y or x\n end\nend\n\nlocal cnt = 0\nlocal st = SegTree.new(n, mergefunc, n + 1)\nwhile true do\n local top = st.stage[1][1]\n if fixed[top] then break end\n local left = top - 1\n if left == 0 then left = n end\n local right = top + 1\n if right == n + 1 then right = 1 end\n b[top] = b[top] - b[left] - b[right]\n cnt = cnt + 1\n if b[top] < a[top] then\n break\n elseif b[top] == a[top] then\n fixed[top] = true\n fixedcnt = fixedcnt + 1\n if fixedcnt == n then break end\n end\n st:update(top)\nend\nprint(fixedcnt == n and cnt or -1)\n", "problem_context": "Score : 800 points\n\nProblem Statement\n\nThere are N positive integers arranged in a circle.\n\nNow, the i-th number is A_i. Takahashi wants the i-th number to be B_i. For this objective, he will repeatedly perform the following operation:\n\nChoose an integer i such that 1 \\leq i \\leq N.\n\nLet a, b, c be the (i-1)-th, i-th, and (i+1)-th numbers, respectively. Replace the i-th number with a+b+c.\n\nHere the 0-th number is the N-th number, and the (N+1)-th number is the 1-st number.\n\nDetermine if Takahashi can achieve his objective.\nIf the answer is yes, find the minimum number of operations required.\n\nConstraints\n\n3 \\leq N \\leq 2 \\times 10^5\n\n1 \\leq A_i, B_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\nB_1 B_2 ... B_N\n\nOutput\n\nPrint the minimum number of operations required, or -1 if the objective cannot be achieved.\n\nSample Input 1\n\n3\n1 1 1\n13 5 7\n\nSample Output 1\n\n4\n\nTakahashi can achieve his objective by, for example, performing the following operations:\n\nReplace the second number with 3.\n\nReplace the second number with 5.\n\nReplace the third number with 7.\n\nReplace the first number with 13.\n\nSample Input 2\n\n4\n1 2 3 4\n2 3 4 5\n\nSample Output 2\n\n-1\n\nSample Input 3\n\n5\n5 6 5 2 1\n9817 1108 6890 4343 8704\n\nSample Output 3\n\n25", "sample_input": "3\n1 1 1\n13 5 7\n"}, "reference_outputs": ["4\n"], "source_document_id": "p02941", "source_text": "Score : 800 points\n\nProblem Statement\n\nThere are N positive integers arranged in a circle.\n\nNow, the i-th number is A_i. Takahashi wants the i-th number to be B_i. For this objective, he will repeatedly perform the following operation:\n\nChoose an integer i such that 1 \\leq i \\leq N.\n\nLet a, b, c be the (i-1)-th, i-th, and (i+1)-th numbers, respectively. Replace the i-th number with a+b+c.\n\nHere the 0-th number is the N-th number, and the (N+1)-th number is the 1-st number.\n\nDetermine if Takahashi can achieve his objective.\nIf the answer is yes, find the minimum number of operations required.\n\nConstraints\n\n3 \\leq N \\leq 2 \\times 10^5\n\n1 \\leq A_i, B_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\nB_1 B_2 ... B_N\n\nOutput\n\nPrint the minimum number of operations required, or -1 if the objective cannot be achieved.\n\nSample Input 1\n\n3\n1 1 1\n13 5 7\n\nSample Output 1\n\n4\n\nTakahashi can achieve his objective by, for example, performing the following operations:\n\nReplace the second number with 3.\n\nReplace the second number with 5.\n\nReplace the third number with 7.\n\nReplace the first number with 13.\n\nSample Input 2\n\n4\n1 2 3 4\n2 3 4 5\n\nSample Output 2\n\n-1\n\nSample Input 3\n\n5\n5 6 5 2 1\n9817 1108 6890 4343 8704\n\nSample Output 3\n\n25", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2923, "cpu_time_ms": 2104, "memory_kb": 16764}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s306291218", "group_id": "codeNet:p02945", "input_text": "local a,b=io.read(\"*n\",\"*n\")\nprint(math.max(a+b,a-b,a*b))", "language": "Lua", "metadata": {"date": 1576477711, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p02945.html", "problem_id": "p02945", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02945/input.txt", "sample_output_relpath": "derived/input_output/data/p02945/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02945/Lua/s306291218.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s306291218", "user_id": "u373958718"}, "prompt_components": {"gold_output": "-10\n", "input_to_evaluate": "local a,b=io.read(\"*n\",\"*n\")\nprint(math.max(a+b,a-b,a*b))", "problem_context": "Score : 100 points\n\nProblem Statement\n\nWe have two integers: A and B.\n\nPrint the largest number among A + B, A - B, and A \\times B.\n\nConstraints\n\nAll values in input are integers.\n\n-100 \\leq A,\\ B \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nPrint the largest number among A + B, A - B, and A \\times B.\n\nSample Input 1\n\n-13 3\n\nSample Output 1\n\n-10\n\nThe largest number among A + B = -10, A - B = -16, and A \\times B = -39 is -10.\n\nSample Input 2\n\n1 -33\n\nSample Output 2\n\n34\n\nThe largest number among A + B = -32, A - B = 34, and A \\times B = -33 is 34.\n\nSample Input 3\n\n13 3\n\nSample Output 3\n\n39\n\nThe largest number among A + B = 16, A - B = 10, and A \\times B = 39 is 39.", "sample_input": "-13 3\n"}, "reference_outputs": ["-10\n"], "source_document_id": "p02945", "source_text": "Score : 100 points\n\nProblem Statement\n\nWe have two integers: A and B.\n\nPrint the largest number among A + B, A - B, and A \\times B.\n\nConstraints\n\nAll values in input are integers.\n\n-100 \\leq A,\\ B \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nPrint the largest number among A + B, A - B, and A \\times B.\n\nSample Input 1\n\n-13 3\n\nSample Output 1\n\n-10\n\nThe largest number among A + B = -10, A - B = -16, and A \\times B = -39 is -10.\n\nSample Input 2\n\n1 -33\n\nSample Output 2\n\n34\n\nThe largest number among A + B = -32, A - B = 34, and A \\times B = -33 is 34.\n\nSample Input 3\n\n13 3\n\nSample Output 3\n\n39\n\nThe largest number among A + B = 16, A - B = 10, and A \\times B = 39 is 39.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 57, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s627053816", "group_id": "codeNet:p02945", "input_text": "local A, B = io.read(\"n\", \"n\")\nlocal x, y, z = A+B, A-B, A*B\nprint(math.max(x,y,z))", "language": "Lua", "metadata": {"date": 1565485311, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p02945.html", "problem_id": "p02945", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02945/input.txt", "sample_output_relpath": "derived/input_output/data/p02945/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02945/Lua/s627053816.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s627053816", "user_id": "u162773977"}, "prompt_components": {"gold_output": "-10\n", "input_to_evaluate": "local A, B = io.read(\"n\", \"n\")\nlocal x, y, z = A+B, A-B, A*B\nprint(math.max(x,y,z))", "problem_context": "Score : 100 points\n\nProblem Statement\n\nWe have two integers: A and B.\n\nPrint the largest number among A + B, A - B, and A \\times B.\n\nConstraints\n\nAll values in input are integers.\n\n-100 \\leq A,\\ B \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nPrint the largest number among A + B, A - B, and A \\times B.\n\nSample Input 1\n\n-13 3\n\nSample Output 1\n\n-10\n\nThe largest number among A + B = -10, A - B = -16, and A \\times B = -39 is -10.\n\nSample Input 2\n\n1 -33\n\nSample Output 2\n\n34\n\nThe largest number among A + B = -32, A - B = 34, and A \\times B = -33 is 34.\n\nSample Input 3\n\n13 3\n\nSample Output 3\n\n39\n\nThe largest number among A + B = 16, A - B = 10, and A \\times B = 39 is 39.", "sample_input": "-13 3\n"}, "reference_outputs": ["-10\n"], "source_document_id": "p02945", "source_text": "Score : 100 points\n\nProblem Statement\n\nWe have two integers: A and B.\n\nPrint the largest number among A + B, A - B, and A \\times B.\n\nConstraints\n\nAll values in input are integers.\n\n-100 \\leq A,\\ B \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nPrint the largest number among A + B, A - B, and A \\times B.\n\nSample Input 1\n\n-13 3\n\nSample Output 1\n\n-10\n\nThe largest number among A + B = -10, A - B = -16, and A \\times B = -39 is -10.\n\nSample Input 2\n\n1 -33\n\nSample Output 2\n\n34\n\nThe largest number among A + B = -32, A - B = 34, and A \\times B = -33 is 34.\n\nSample Input 3\n\n13 3\n\nSample Output 3\n\n39\n\nThe largest number among A + B = 16, A - B = 10, and A \\times B = 39 is 39.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 83, "cpu_time_ms": 7, "memory_kb": 760}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s250716250", "group_id": "codeNet:p02946", "input_text": "local k, x = io.read(\"*n\", \"*n\")\nlocal t = {}\nfor i = x - k + 1, x + k - 1 do\n table.insert(t, i)\nend\nprint(table.concat(t, \" \"))\n", "language": "Lua", "metadata": {"date": 1565485401, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p02946.html", "problem_id": "p02946", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02946/input.txt", "sample_output_relpath": "derived/input_output/data/p02946/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02946/Lua/s250716250.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s250716250", "user_id": "u120582723"}, "prompt_components": {"gold_output": "5 6 7 8 9\n", "input_to_evaluate": "local k, x = io.read(\"*n\", \"*n\")\nlocal t = {}\nfor i = x - k + 1, x + k - 1 do\n table.insert(t, i)\nend\nprint(table.concat(t, \" \"))\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nThere are 2000001 stones placed on a number line. The coordinates of these stones are -1000000, -999999, -999998, \\ldots, 999999, 1000000.\n\nAmong them, some K consecutive stones are painted black, and the others are painted white.\n\nAdditionally, we know that the stone at coordinate X is painted black.\n\nPrint all coordinates that potentially contain a stone painted black, in ascending order.\n\nConstraints\n\n1 \\leq K \\leq 100\n\n0 \\leq X \\leq 100\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nK X\n\nOutput\n\nPrint all coordinates that potentially contain a stone painted black, in ascending order, with spaces in between.\n\nSample Input 1\n\n3 7\n\nSample Output 1\n\n5 6 7 8 9\n\nWe know that there are three stones painted black, and the stone at coordinate 7 is painted black. There are three possible cases:\n\nThe three stones painted black are placed at coordinates 5, 6, and 7.\n\nThe three stones painted black are placed at coordinates 6, 7, and 8.\n\nThe three stones painted black are placed at coordinates 7, 8, and 9.\n\nThus, five coordinates potentially contain a stone painted black: 5, 6, 7, 8, and 9.\n\nSample Input 2\n\n4 0\n\nSample Output 2\n\n-3 -2 -1 0 1 2 3\n\nNegative coordinates can also contain a stone painted black.\n\nSample Input 3\n\n1 100\n\nSample Output 3\n\n100", "sample_input": "3 7\n"}, "reference_outputs": ["5 6 7 8 9\n"], "source_document_id": "p02946", "source_text": "Score : 200 points\n\nProblem Statement\n\nThere are 2000001 stones placed on a number line. The coordinates of these stones are -1000000, -999999, -999998, \\ldots, 999999, 1000000.\n\nAmong them, some K consecutive stones are painted black, and the others are painted white.\n\nAdditionally, we know that the stone at coordinate X is painted black.\n\nPrint all coordinates that potentially contain a stone painted black, in ascending order.\n\nConstraints\n\n1 \\leq K \\leq 100\n\n0 \\leq X \\leq 100\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nK X\n\nOutput\n\nPrint all coordinates that potentially contain a stone painted black, in ascending order, with spaces in between.\n\nSample Input 1\n\n3 7\n\nSample Output 1\n\n5 6 7 8 9\n\nWe know that there are three stones painted black, and the stone at coordinate 7 is painted black. There are three possible cases:\n\nThe three stones painted black are placed at coordinates 5, 6, and 7.\n\nThe three stones painted black are placed at coordinates 6, 7, and 8.\n\nThe three stones painted black are placed at coordinates 7, 8, and 9.\n\nThus, five coordinates potentially contain a stone painted black: 5, 6, 7, 8, and 9.\n\nSample Input 2\n\n4 0\n\nSample Output 2\n\n-3 -2 -1 0 1 2 3\n\nNegative coordinates can also contain a stone painted black.\n\nSample Input 3\n\n1 100\n\nSample Output 3\n\n100", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 131, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s830881304", "group_id": "codeNet:p02947", "input_text": "local num = tonumber(io.read())\nlocal input = {}\n\nfor i = 1, num do\n local v = table.pack(string.byte(io.read(), 1, 10))\n table.sort(v)\n v = string.char(table.unpack(v))\n if input[v] ~= nil then\n input[v] = input[v] + 1\n else\n input[v] = 1\n end\nend\n\nlocal t = 0\nfor k, v in pairs(input) do\n t = t + v * (v - 1) // 2\nend\nprint(t)", "language": "Lua", "metadata": {"date": 1565487197, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p02947.html", "problem_id": "p02947", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02947/input.txt", "sample_output_relpath": "derived/input_output/data/p02947/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02947/Lua/s830881304.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s830881304", "user_id": "u061001716"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "local num = tonumber(io.read())\nlocal input = {}\n\nfor i = 1, num do\n local v = table.pack(string.byte(io.read(), 1, 10))\n table.sort(v)\n v = string.char(table.unpack(v))\n if input[v] ~= nil then\n input[v] = input[v] + 1\n else\n input[v] = 1\n end\nend\n\nlocal t = 0\nfor k, v in pairs(input) do\n t = t + v * (v - 1) // 2\nend\nprint(t)", "problem_context": "Score : 300 points\n\nProblem Statement\n\nWe will call a string obtained by arranging the characters contained in a string a in some order, an anagram of a.\n\nFor example, greenbin is an anagram of beginner. As seen here, when the same character occurs multiple times, that character must be used that number of times.\n\nGiven are N strings s_1, s_2, \\ldots, s_N. Each of these strings has a length of 10 and consists of lowercase English characters. Additionally, all of these strings are distinct. Find the number of pairs of integers i, j (1 \\leq i < j \\leq N) such that s_i is an anagram of s_j.\n\nConstraints\n\n2 \\leq N \\leq 10^5\n\ns_i is a string of length 10.\n\nEach character in s_i is a lowercase English letter.\n\ns_1, s_2, \\ldots, s_N are all distinct.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\ns_1\ns_2\n:\ns_N\n\nOutput\n\nPrint the number of pairs of integers i, j (1 \\leq i < j \\leq N) such that s_i is an anagram of s_j.\n\nSample Input 1\n\n3\nacornistnt\npeanutbomb\nconstraint\n\nSample Output 1\n\n1\n\ns_1 = acornistnt is an anagram of s_3 = constraint. There are no other pairs i, j such that s_i is an anagram of s_j, so the answer is 1.\n\nSample Input 2\n\n2\noneplustwo\nninemodsix\n\nSample Output 2\n\n0\n\nIf there is no pair i, j such that s_i is an anagram of s_j, print 0.\n\nSample Input 3\n\n5\nabaaaaaaaa\noneplustwo\naaaaaaaaba\ntwoplusone\naaaabaaaaa\n\nSample Output 3\n\n4\n\nNote that the answer may not fit into a 32-bit integer type, though we cannot put such a case here.", "sample_input": "3\nacornistnt\npeanutbomb\nconstraint\n"}, "reference_outputs": ["1\n"], "source_document_id": "p02947", "source_text": "Score : 300 points\n\nProblem Statement\n\nWe will call a string obtained by arranging the characters contained in a string a in some order, an anagram of a.\n\nFor example, greenbin is an anagram of beginner. As seen here, when the same character occurs multiple times, that character must be used that number of times.\n\nGiven are N strings s_1, s_2, \\ldots, s_N. Each of these strings has a length of 10 and consists of lowercase English characters. Additionally, all of these strings are distinct. Find the number of pairs of integers i, j (1 \\leq i < j \\leq N) such that s_i is an anagram of s_j.\n\nConstraints\n\n2 \\leq N \\leq 10^5\n\ns_i is a string of length 10.\n\nEach character in s_i is a lowercase English letter.\n\ns_1, s_2, \\ldots, s_N are all distinct.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\ns_1\ns_2\n:\ns_N\n\nOutput\n\nPrint the number of pairs of integers i, j (1 \\leq i < j \\leq N) such that s_i is an anagram of s_j.\n\nSample Input 1\n\n3\nacornistnt\npeanutbomb\nconstraint\n\nSample Output 1\n\n1\n\ns_1 = acornistnt is an anagram of s_3 = constraint. There are no other pairs i, j such that s_i is an anagram of s_j, so the answer is 1.\n\nSample Input 2\n\n2\noneplustwo\nninemodsix\n\nSample Output 2\n\n0\n\nIf there is no pair i, j such that s_i is an anagram of s_j, print 0.\n\nSample Input 3\n\n5\nabaaaaaaaa\noneplustwo\naaaaaaaaba\ntwoplusone\naaaabaaaaa\n\nSample Output 3\n\n4\n\nNote that the answer may not fit into a 32-bit integer type, though we cannot put such a case here.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 341, "cpu_time_ms": 354, "memory_kb": 23268}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s912975205", "group_id": "codeNet:p02948", "input_text": "local mma = math.max\nlocal mfl, mce, mmi = math.floor, math.ceil, math.min\n\nlocal AvlTree = {}\nAvlTree.makenode = function(self, val, parent)\n local i = self.box[#self.box]\n if not i then i = #self.v + 1\n else table.remove(self.box)\n end\n self.v[i], self.p[i] = val, parent\n self.lc[i], self.rc[i], self.l[i], self.r[i] = 0, 0, 1, 1\n return i\nend\nAvlTree.create = function(self, lessthan, n)\n self.lessthan = lessthan\n self.root = 1\n self.box = {}\n for i = n + 1, 2, -1 do table.insert(self.box, i) end\n -- value, leftCount, rightCount, left, right, parent\n self.v, self.lc, self.rc, self.l, self.r, self.p = {}, {}, {}, {}, {}, {}\n for i = 1, n + 1 do\n self.v[i], self.p[i] = 0, 1\n self.lc[i], self.rc[i], self.l[i], self.r[i] = 0, 0, 1, 1\n end\nend\n\nAvlTree.recalc = function(self, i)\n local kl, kr = self.l[i], self.r[i]\n if 1 < kl then self.lc[i] = 1 + mma(self.lc[kl], self.rc[kl])\n else self.lc[i] = 0\n end\n if 1 < kr then self.rc[i] = 1 + mma(self.lc[kr], self.rc[kr])\n else self.rc[i] = 0\n end\nend\nAvlTree.recalcAll = function(self, i)\n while 1 < i do\n self:recalc(i)\n i = self.p[i]\n end\nend\n\nAvlTree.rotR = function(self, parent)\n local granp, child = self.p[parent], self.l[parent]\n self.r[child], self.l[parent] = parent, self.r[child]\n self.p[child], self.p[parent] = granp, child\n self.p[self.l[parent]] = parent\n if 1 < granp then\n if self.l[granp] == parent then\n self.l[granp] = child\n else\n self.r[granp] = child\n end\n else\n self.root = child\n end\nend\n\nAvlTree.rotL = function(self, parent)\n local granp, child = self.p[parent], self.r[parent]\n self.l[child], self.r[parent] = parent, self.l[child]\n self.p[child], self.p[parent] = granp, child\n self.p[self.r[parent]] = parent\n if 1 < granp then\n if self.r[granp] == parent then\n self.r[granp] = child\n else\n self.l[granp] = child\n end\n else\n self.root = child\n end\nend\n\nAvlTree.rotLR = function(self, lparent, rparent)\n local sp, sl, sr = self.p, self.l, self.r\n local granp, d = sp[rparent], sr[lparent]\n sp[lparent], sr[lparent] = d, sl[d]\n sp[rparent], sl[rparent] = d, sr[d]\n sp[sl[d]], sp[sr[d]] = lparent, rparent\n sp[d], sl[d], sr[d] = granp, lparent, rparent\n if 1 < granp then\n if sr[granp] == rparent then sr[granp] = d\n else sl[granp] = d\n end\n else self.root = d\n end\nend\n\nAvlTree.rotRL = function(self, rparent, lparent)\n local sp, sl, sr = self.p, self.l, self.r\n local granp, d = sp[lparent], sl[rparent]\n sp[rparent], sl[rparent] = d, sr[d]\n sp[lparent], sr[lparent] = d, sl[d]\n sp[sr[d]], sp[sl[d]] = rparent, lparent\n sp[d], sr[d], sl[d] = granp, rparent, lparent\n if 1 < granp then\n if sl[granp] == lparent then sl[granp] = d\n else sr[granp] = d\n end\n else self.root = d\n end\nend\n\nAvlTree.empty = function(self)\n return self.root <= 1\nend\n\nAvlTree.push = function(self, val)\n if self.root <= 1 then self.root = self:makenode(val, 1) return end\n local pos = self.root\n while true do\n if self.lessthan(val, self.v[pos]) then\n if 1 < self.l[pos] then\n pos = self.l[pos]\n else\n self.l[pos] = self:makenode(val, pos)\n pos = self.l[pos]\n break\n end\n else\n if 1 < self.r[pos] then\n pos = self.r[pos]\n else\n self.r[pos] = self:makenode(val, pos)\n pos = self.r[pos]\n break\n end\n end\n end\n while 1 < pos do\n local child, parent = pos, self.p[pos]\n if parent <= 1 then\n break\n end\n self:recalc(parent)\n local lcp_m_rcp = self.lc[parent] - self.rc[parent]\n if lcp_m_rcp % 2 ~= 0 then -- 1 or -1\n pos = parent\n elseif lcp_m_rcp == 2 then\n if self.lc[child] - 1 == self.rc[child] then\n self:rotR(parent)\n self:recalcAll(parent)\n else\n self:rotLR(child, parent)\n self:recalc(child)\n self:recalcAll(parent)\n end\n break\n elseif lcp_m_rcp == -2 then\n if self.rc[child] - 1 == self.lc[child] then\n self:rotL(parent)\n self:recalcAll(parent)\n else\n self:rotRL(child, parent)\n self:recalc(child)\n self:recalcAll(parent)\n end\n break\n else\n break\n end\n end\nend\n\nAvlTree.rmsub = function(self, node)\n while 1 < node do\n self:recalc(node)\n if self.lc[node] == self.rc[node] then\n node = self.p[node]\n elseif self.lc[node] + 1 == self.rc[node] then\n self:recalcAll(self.p[node])\n break\n else\n if self.lc[self.r[node]] == self.rc[self.r[node]] then\n self:rotL(node)\n self:recalcAll(node)\n break\n elseif self.lc[self.r[node]] + 1 == self.rc[self.r[node]] then\n local nr = self.r[node]\n self:rotL(node)\n self:recalc(node)\n node = nr\n else\n local nr = self.r[node]\n local nrl = self.l[nr]\n self:rotRL(nr, node)\n self:recalc(nr)\n self:recalc(node)\n node = nrl\n end\n end\n end\nend\n\nAvlTree.pop = function(self)\n local node = self.root\n while 1 < self.l[node] do\n node = self.l[node]\n end\n local v = self.v[node]\n local kp = self.p[node]\n self.p[self.r[node]] = kp\n if 1 < kp then\n self.l[kp] = self.r[node]\n self:rmsub(kp)\n else\n self.root = self.r[node]\n end\n table.insert(self.box, node)\n return v\nend\n\nAvlTree.new = function(lessthan, n)\n local obj = {}\n setmetatable(obj, {__index = AvlTree})\n obj:create(lessthan, n)\n return obj\nend\n\nlocal n, m = io.read(\"*n\", \"*n\")\nlocal t = {}\nfor i = 1, m do\n t[i] = {}\nend\nfor i = 1, n do\n local a, b = io.read(\"*n\", \"*n\")\n a = m + 1 - a\n if 0 < a then\n table.insert(t[a], b)\n end\nend\nlocal ret = 0\nlocal avl = AvlTree.new(function(x, y) return x > y end, 1)\nfor i = m, 1, -1 do\n for j = 1, #t[i] do\n avl:push(t[i][j])\n end\n if not avl:empty() then\n ret = ret + avl:pop()\n end\nend\nprint(ret)\n", "language": "Lua", "metadata": {"date": 1594175945, "filename_ext": "lua", "original_language": "Lua (Lua 5.3.5)", "problem_description_relpath": "problem_descriptions/p02948.html", "problem_id": "p02948", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02948/input.txt", "sample_output_relpath": "derived/input_output/data/p02948/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02948/Lua/s912975205.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s912975205", "user_id": "u120582723"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "local mma = math.max\nlocal mfl, mce, mmi = math.floor, math.ceil, math.min\n\nlocal AvlTree = {}\nAvlTree.makenode = function(self, val, parent)\n local i = self.box[#self.box]\n if not i then i = #self.v + 1\n else table.remove(self.box)\n end\n self.v[i], self.p[i] = val, parent\n self.lc[i], self.rc[i], self.l[i], self.r[i] = 0, 0, 1, 1\n return i\nend\nAvlTree.create = function(self, lessthan, n)\n self.lessthan = lessthan\n self.root = 1\n self.box = {}\n for i = n + 1, 2, -1 do table.insert(self.box, i) end\n -- value, leftCount, rightCount, left, right, parent\n self.v, self.lc, self.rc, self.l, self.r, self.p = {}, {}, {}, {}, {}, {}\n for i = 1, n + 1 do\n self.v[i], self.p[i] = 0, 1\n self.lc[i], self.rc[i], self.l[i], self.r[i] = 0, 0, 1, 1\n end\nend\n\nAvlTree.recalc = function(self, i)\n local kl, kr = self.l[i], self.r[i]\n if 1 < kl then self.lc[i] = 1 + mma(self.lc[kl], self.rc[kl])\n else self.lc[i] = 0\n end\n if 1 < kr then self.rc[i] = 1 + mma(self.lc[kr], self.rc[kr])\n else self.rc[i] = 0\n end\nend\nAvlTree.recalcAll = function(self, i)\n while 1 < i do\n self:recalc(i)\n i = self.p[i]\n end\nend\n\nAvlTree.rotR = function(self, parent)\n local granp, child = self.p[parent], self.l[parent]\n self.r[child], self.l[parent] = parent, self.r[child]\n self.p[child], self.p[parent] = granp, child\n self.p[self.l[parent]] = parent\n if 1 < granp then\n if self.l[granp] == parent then\n self.l[granp] = child\n else\n self.r[granp] = child\n end\n else\n self.root = child\n end\nend\n\nAvlTree.rotL = function(self, parent)\n local granp, child = self.p[parent], self.r[parent]\n self.l[child], self.r[parent] = parent, self.l[child]\n self.p[child], self.p[parent] = granp, child\n self.p[self.r[parent]] = parent\n if 1 < granp then\n if self.r[granp] == parent then\n self.r[granp] = child\n else\n self.l[granp] = child\n end\n else\n self.root = child\n end\nend\n\nAvlTree.rotLR = function(self, lparent, rparent)\n local sp, sl, sr = self.p, self.l, self.r\n local granp, d = sp[rparent], sr[lparent]\n sp[lparent], sr[lparent] = d, sl[d]\n sp[rparent], sl[rparent] = d, sr[d]\n sp[sl[d]], sp[sr[d]] = lparent, rparent\n sp[d], sl[d], sr[d] = granp, lparent, rparent\n if 1 < granp then\n if sr[granp] == rparent then sr[granp] = d\n else sl[granp] = d\n end\n else self.root = d\n end\nend\n\nAvlTree.rotRL = function(self, rparent, lparent)\n local sp, sl, sr = self.p, self.l, self.r\n local granp, d = sp[lparent], sl[rparent]\n sp[rparent], sl[rparent] = d, sr[d]\n sp[lparent], sr[lparent] = d, sl[d]\n sp[sr[d]], sp[sl[d]] = rparent, lparent\n sp[d], sr[d], sl[d] = granp, rparent, lparent\n if 1 < granp then\n if sl[granp] == lparent then sl[granp] = d\n else sr[granp] = d\n end\n else self.root = d\n end\nend\n\nAvlTree.empty = function(self)\n return self.root <= 1\nend\n\nAvlTree.push = function(self, val)\n if self.root <= 1 then self.root = self:makenode(val, 1) return end\n local pos = self.root\n while true do\n if self.lessthan(val, self.v[pos]) then\n if 1 < self.l[pos] then\n pos = self.l[pos]\n else\n self.l[pos] = self:makenode(val, pos)\n pos = self.l[pos]\n break\n end\n else\n if 1 < self.r[pos] then\n pos = self.r[pos]\n else\n self.r[pos] = self:makenode(val, pos)\n pos = self.r[pos]\n break\n end\n end\n end\n while 1 < pos do\n local child, parent = pos, self.p[pos]\n if parent <= 1 then\n break\n end\n self:recalc(parent)\n local lcp_m_rcp = self.lc[parent] - self.rc[parent]\n if lcp_m_rcp % 2 ~= 0 then -- 1 or -1\n pos = parent\n elseif lcp_m_rcp == 2 then\n if self.lc[child] - 1 == self.rc[child] then\n self:rotR(parent)\n self:recalcAll(parent)\n else\n self:rotLR(child, parent)\n self:recalc(child)\n self:recalcAll(parent)\n end\n break\n elseif lcp_m_rcp == -2 then\n if self.rc[child] - 1 == self.lc[child] then\n self:rotL(parent)\n self:recalcAll(parent)\n else\n self:rotRL(child, parent)\n self:recalc(child)\n self:recalcAll(parent)\n end\n break\n else\n break\n end\n end\nend\n\nAvlTree.rmsub = function(self, node)\n while 1 < node do\n self:recalc(node)\n if self.lc[node] == self.rc[node] then\n node = self.p[node]\n elseif self.lc[node] + 1 == self.rc[node] then\n self:recalcAll(self.p[node])\n break\n else\n if self.lc[self.r[node]] == self.rc[self.r[node]] then\n self:rotL(node)\n self:recalcAll(node)\n break\n elseif self.lc[self.r[node]] + 1 == self.rc[self.r[node]] then\n local nr = self.r[node]\n self:rotL(node)\n self:recalc(node)\n node = nr\n else\n local nr = self.r[node]\n local nrl = self.l[nr]\n self:rotRL(nr, node)\n self:recalc(nr)\n self:recalc(node)\n node = nrl\n end\n end\n end\nend\n\nAvlTree.pop = function(self)\n local node = self.root\n while 1 < self.l[node] do\n node = self.l[node]\n end\n local v = self.v[node]\n local kp = self.p[node]\n self.p[self.r[node]] = kp\n if 1 < kp then\n self.l[kp] = self.r[node]\n self:rmsub(kp)\n else\n self.root = self.r[node]\n end\n table.insert(self.box, node)\n return v\nend\n\nAvlTree.new = function(lessthan, n)\n local obj = {}\n setmetatable(obj, {__index = AvlTree})\n obj:create(lessthan, n)\n return obj\nend\n\nlocal n, m = io.read(\"*n\", \"*n\")\nlocal t = {}\nfor i = 1, m do\n t[i] = {}\nend\nfor i = 1, n do\n local a, b = io.read(\"*n\", \"*n\")\n a = m + 1 - a\n if 0 < a then\n table.insert(t[a], b)\n end\nend\nlocal ret = 0\nlocal avl = AvlTree.new(function(x, y) return x > y end, 1)\nfor i = m, 1, -1 do\n for j = 1, #t[i] do\n avl:push(t[i][j])\n end\n if not avl:empty() then\n ret = ret + avl:pop()\n end\nend\nprint(ret)\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nThere are N one-off jobs available. If you take the i-th job and complete it, you will earn the reward of B_i after A_i days from the day you do it.\n\nYou can take and complete at most one of these jobs in a day.\n\nHowever, you cannot retake a job that you have already done.\n\nFind the maximum total reward that you can earn no later than M days from today.\n\nYou can already start working today.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^5\n\n1 \\leq A_i \\leq 10^5\n\n1 \\leq B_i \\leq 10^4\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nA_1 B_1\nA_2 B_2\n\\vdots\nA_N B_N\n\nOutput\n\nPrint the maximum total reward that you can earn no later than M days from today.\n\nSample Input 1\n\n3 4\n4 3\n4 1\n2 2\n\nSample Output 1\n\n5\n\nYou can earn the total reward of 5 by taking the jobs as follows:\n\nTake and complete the first job today. You will earn the reward of 3 after four days from today.\n\nTake and complete the third job tomorrow. You will earn the reward of 2 after two days from tomorrow, that is, after three days from today.\n\nSample Input 2\n\n5 3\n1 2\n1 3\n1 4\n2 1\n2 3\n\nSample Output 2\n\n10\n\nSample Input 3\n\n1 1\n2 1\n\nSample Output 3\n\n0", "sample_input": "3 4\n4 3\n4 1\n2 2\n"}, "reference_outputs": ["5\n"], "source_document_id": "p02948", "source_text": "Score : 400 points\n\nProblem Statement\n\nThere are N one-off jobs available. If you take the i-th job and complete it, you will earn the reward of B_i after A_i days from the day you do it.\n\nYou can take and complete at most one of these jobs in a day.\n\nHowever, you cannot retake a job that you have already done.\n\nFind the maximum total reward that you can earn no later than M days from today.\n\nYou can already start working today.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^5\n\n1 \\leq A_i \\leq 10^5\n\n1 \\leq B_i \\leq 10^4\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nA_1 B_1\nA_2 B_2\n\\vdots\nA_N B_N\n\nOutput\n\nPrint the maximum total reward that you can earn no later than M days from today.\n\nSample Input 1\n\n3 4\n4 3\n4 1\n2 2\n\nSample Output 1\n\n5\n\nYou can earn the total reward of 5 by taking the jobs as follows:\n\nTake and complete the first job today. You will earn the reward of 3 after four days from today.\n\nTake and complete the third job tomorrow. You will earn the reward of 2 after two days from tomorrow, that is, after three days from today.\n\nSample Input 2\n\n5 3\n1 2\n1 3\n1 4\n2 1\n2 3\n\nSample Output 2\n\n10\n\nSample Input 3\n\n1 1\n2 1\n\nSample Output 3\n\n0", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 5863, "cpu_time_ms": 1181, "memory_kb": 27896}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s045372969", "group_id": "codeNet:p02948", "input_text": "local num, day = string.match(io.read(), \"(%d+) (%d+)\")\nnum, day = tonumber(num), tonumber(day)\nlocal input = {}\nfor i = 1, num do\n local a, b = string.match(io.read(), \"(%d+) (%d+)\")\n table.insert(input, {\n\tday = tonumber(a),\n result = tonumber(b)\n })\nend\n\ntable.sort(input, function (a, b)\n if a.result == b.result then\n return a.day > b.day\n else\n return a.result > b.result\n end\n end)\n\nlocal sum = 0\nfor i = 1, #input do\n if day >= input[i].day then\n sum = sum + input[i].result\n day = day - 1\n end\n if day <= 0 then\n break\n end\nend\nprint(sum)", "language": "Lua", "metadata": {"date": 1565489726, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p02948.html", "problem_id": "p02948", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02948/input.txt", "sample_output_relpath": "derived/input_output/data/p02948/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02948/Lua/s045372969.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s045372969", "user_id": "u061001716"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "local num, day = string.match(io.read(), \"(%d+) (%d+)\")\nnum, day = tonumber(num), tonumber(day)\nlocal input = {}\nfor i = 1, num do\n local a, b = string.match(io.read(), \"(%d+) (%d+)\")\n table.insert(input, {\n\tday = tonumber(a),\n result = tonumber(b)\n })\nend\n\ntable.sort(input, function (a, b)\n if a.result == b.result then\n return a.day > b.day\n else\n return a.result > b.result\n end\n end)\n\nlocal sum = 0\nfor i = 1, #input do\n if day >= input[i].day then\n sum = sum + input[i].result\n day = day - 1\n end\n if day <= 0 then\n break\n end\nend\nprint(sum)", "problem_context": "Score : 400 points\n\nProblem Statement\n\nThere are N one-off jobs available. If you take the i-th job and complete it, you will earn the reward of B_i after A_i days from the day you do it.\n\nYou can take and complete at most one of these jobs in a day.\n\nHowever, you cannot retake a job that you have already done.\n\nFind the maximum total reward that you can earn no later than M days from today.\n\nYou can already start working today.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^5\n\n1 \\leq A_i \\leq 10^5\n\n1 \\leq B_i \\leq 10^4\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nA_1 B_1\nA_2 B_2\n\\vdots\nA_N B_N\n\nOutput\n\nPrint the maximum total reward that you can earn no later than M days from today.\n\nSample Input 1\n\n3 4\n4 3\n4 1\n2 2\n\nSample Output 1\n\n5\n\nYou can earn the total reward of 5 by taking the jobs as follows:\n\nTake and complete the first job today. You will earn the reward of 3 after four days from today.\n\nTake and complete the third job tomorrow. You will earn the reward of 2 after two days from tomorrow, that is, after three days from today.\n\nSample Input 2\n\n5 3\n1 2\n1 3\n1 4\n2 1\n2 3\n\nSample Output 2\n\n10\n\nSample Input 3\n\n1 1\n2 1\n\nSample Output 3\n\n0", "sample_input": "3 4\n4 3\n4 1\n2 2\n"}, "reference_outputs": ["5\n"], "source_document_id": "p02948", "source_text": "Score : 400 points\n\nProblem Statement\n\nThere are N one-off jobs available. If you take the i-th job and complete it, you will earn the reward of B_i after A_i days from the day you do it.\n\nYou can take and complete at most one of these jobs in a day.\n\nHowever, you cannot retake a job that you have already done.\n\nFind the maximum total reward that you can earn no later than M days from today.\n\nYou can already start working today.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^5\n\n1 \\leq A_i \\leq 10^5\n\n1 \\leq B_i \\leq 10^4\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nA_1 B_1\nA_2 B_2\n\\vdots\nA_N B_N\n\nOutput\n\nPrint the maximum total reward that you can earn no later than M days from today.\n\nSample Input 1\n\n3 4\n4 3\n4 1\n2 2\n\nSample Output 1\n\n5\n\nYou can earn the total reward of 5 by taking the jobs as follows:\n\nTake and complete the first job today. You will earn the reward of 3 after four days from today.\n\nTake and complete the third job tomorrow. You will earn the reward of 2 after two days from tomorrow, that is, after three days from today.\n\nSample Input 2\n\n5 3\n1 2\n1 3\n1 4\n2 1\n2 3\n\nSample Output 2\n\n10\n\nSample Input 3\n\n1 1\n2 1\n\nSample Output 3\n\n0", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 586, "cpu_time_ms": 536, "memory_kb": 24504}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s897910055", "group_id": "codeNet:p02951", "input_text": "a,b,c=io.read(\"*n\",\"*n\",\"*n\")\nif c-(a-b)>=0 then\n print(c-(a-b))\nelse\n print(0)\nend", "language": "Lua", "metadata": {"date": 1587320906, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p02951.html", "problem_id": "p02951", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02951/input.txt", "sample_output_relpath": "derived/input_output/data/p02951/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02951/Lua/s897910055.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s897910055", "user_id": "u045238009"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "a,b,c=io.read(\"*n\",\"*n\",\"*n\")\nif c-(a-b)>=0 then\n print(c-(a-b))\nelse\n print(0)\nend", "problem_context": "Score : 100 points\n\nProblem Statement\n\nWe have two bottles for holding water.\n\nBottle 1 can hold up to A milliliters of water, and now it contains B milliliters of water.\n\nBottle 2 contains C milliliters of water.\n\nWe will transfer water from Bottle 2 to Bottle 1 as much as possible.\n\nHow much amount of water will remain in Bottle 2?\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq B \\leq A \\leq 20\n\n1 \\leq C \\leq 20\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C\n\nOutput\n\nPrint the integer representing the amount of water, in milliliters, that will remain in Bottle 2.\n\nSample Input 1\n\n6 4 3\n\nSample Output 1\n\n1\n\nWe will transfer two milliliters of water from Bottle 2 to Bottle 1, and one milliliter of water will remain in Bottle 2.\n\nSample Input 2\n\n8 3 9\n\nSample Output 2\n\n4\n\nSample Input 3\n\n12 3 7\n\nSample Output 3\n\n0", "sample_input": "6 4 3\n"}, "reference_outputs": ["1\n"], "source_document_id": "p02951", "source_text": "Score : 100 points\n\nProblem Statement\n\nWe have two bottles for holding water.\n\nBottle 1 can hold up to A milliliters of water, and now it contains B milliliters of water.\n\nBottle 2 contains C milliliters of water.\n\nWe will transfer water from Bottle 2 to Bottle 1 as much as possible.\n\nHow much amount of water will remain in Bottle 2?\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq B \\leq A \\leq 20\n\n1 \\leq C \\leq 20\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C\n\nOutput\n\nPrint the integer representing the amount of water, in milliliters, that will remain in Bottle 2.\n\nSample Input 1\n\n6 4 3\n\nSample Output 1\n\n1\n\nWe will transfer two milliliters of water from Bottle 2 to Bottle 1, and one milliliter of water will remain in Bottle 2.\n\nSample Input 2\n\n8 3 9\n\nSample Output 2\n\n4\n\nSample Input 3\n\n12 3 7\n\nSample Output 3\n\n0", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 89, "cpu_time_ms": 7, "memory_kb": 888}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s034440822", "group_id": "codeNet:p02951", "input_text": "local a,b,c=io.read(\"*n\",\"*n\",\"*n\")\nprint(c-math.min(a-b,c))", "language": "Lua", "metadata": {"date": 1576477365, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p02951.html", "problem_id": "p02951", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02951/input.txt", "sample_output_relpath": "derived/input_output/data/p02951/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02951/Lua/s034440822.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s034440822", "user_id": "u373958718"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "local a,b,c=io.read(\"*n\",\"*n\",\"*n\")\nprint(c-math.min(a-b,c))", "problem_context": "Score : 100 points\n\nProblem Statement\n\nWe have two bottles for holding water.\n\nBottle 1 can hold up to A milliliters of water, and now it contains B milliliters of water.\n\nBottle 2 contains C milliliters of water.\n\nWe will transfer water from Bottle 2 to Bottle 1 as much as possible.\n\nHow much amount of water will remain in Bottle 2?\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq B \\leq A \\leq 20\n\n1 \\leq C \\leq 20\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C\n\nOutput\n\nPrint the integer representing the amount of water, in milliliters, that will remain in Bottle 2.\n\nSample Input 1\n\n6 4 3\n\nSample Output 1\n\n1\n\nWe will transfer two milliliters of water from Bottle 2 to Bottle 1, and one milliliter of water will remain in Bottle 2.\n\nSample Input 2\n\n8 3 9\n\nSample Output 2\n\n4\n\nSample Input 3\n\n12 3 7\n\nSample Output 3\n\n0", "sample_input": "6 4 3\n"}, "reference_outputs": ["1\n"], "source_document_id": "p02951", "source_text": "Score : 100 points\n\nProblem Statement\n\nWe have two bottles for holding water.\n\nBottle 1 can hold up to A milliliters of water, and now it contains B milliliters of water.\n\nBottle 2 contains C milliliters of water.\n\nWe will transfer water from Bottle 2 to Bottle 1 as much as possible.\n\nHow much amount of water will remain in Bottle 2?\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq B \\leq A \\leq 20\n\n1 \\leq C \\leq 20\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C\n\nOutput\n\nPrint the integer representing the amount of water, in milliliters, that will remain in Bottle 2.\n\nSample Input 1\n\n6 4 3\n\nSample Output 1\n\n1\n\nWe will transfer two milliliters of water from Bottle 2 to Bottle 1, and one milliliter of water will remain in Bottle 2.\n\nSample Input 2\n\n8 3 9\n\nSample Output 2\n\n4\n\nSample Input 3\n\n12 3 7\n\nSample Output 3\n\n0", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 60, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s387634716", "group_id": "codeNet:p02952", "input_text": "n=io.read(\"*n\")\n\nfunction digit(n)\n local dig=1\n local c=n\n while math.floor(c/10)~=0 do\n dig=dig+1\n c=math.floor(c/10)\n end\n return dig\nend\n\nans=0\nfor i=1,n do\n if digit(i)%2==1 then\n ans=ans+1\n end\nend\n\nprint(ans)", "language": "Lua", "metadata": {"date": 1572686310, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p02952.html", "problem_id": "p02952", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02952/input.txt", "sample_output_relpath": "derived/input_output/data/p02952/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02952/Lua/s387634716.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s387634716", "user_id": "u535423069"}, "prompt_components": {"gold_output": "9\n", "input_to_evaluate": "n=io.read(\"*n\")\n\nfunction digit(n)\n local dig=1\n local c=n\n while math.floor(c/10)~=0 do\n dig=dig+1\n c=math.floor(c/10)\n end\n return dig\nend\n\nans=0\nfor i=1,n do\n if digit(i)%2==1 then\n ans=ans+1\n end\nend\n\nprint(ans)", "problem_context": "Score : 200 points\n\nProblem Statement\n\nGiven is an integer N. Find the number of positive integers less than or equal to N that have an odd number of digits (in base ten without leading zeros).\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the number of positive integers less than or equal to N that have an odd number of digits.\n\nSample Input 1\n\n11\n\nSample Output 1\n\n9\n\nAmong the positive integers less than or equal to 11, nine integers have an odd number of digits: 1, 2, \\ldots, 9.\n\nSample Input 2\n\n136\n\nSample Output 2\n\n46\n\nIn addition to 1, 2, \\ldots, 9, another 37 integers also have an odd number of digits: 100, 101, \\ldots, 136.\n\nSample Input 3\n\n100000\n\nSample Output 3\n\n90909", "sample_input": "11\n"}, "reference_outputs": ["9\n"], "source_document_id": "p02952", "source_text": "Score : 200 points\n\nProblem Statement\n\nGiven is an integer N. Find the number of positive integers less than or equal to N that have an odd number of digits (in base ten without leading zeros).\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the number of positive integers less than or equal to N that have an odd number of digits.\n\nSample Input 1\n\n11\n\nSample Output 1\n\n9\n\nAmong the positive integers less than or equal to 11, nine integers have an odd number of digits: 1, 2, \\ldots, 9.\n\nSample Input 2\n\n136\n\nSample Output 2\n\n46\n\nIn addition to 1, 2, \\ldots, 9, another 37 integers also have an odd number of digits: 100, 101, \\ldots, 136.\n\nSample Input 3\n\n100000\n\nSample Output 3\n\n90909", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 231, "cpu_time_ms": 4, "memory_kb": 256}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s735016504", "group_id": "codeNet:p02955", "input_text": "local mce, msq = math.ceil, math.sqrt\nlocal function getprimes(x)\n local primes = {}\n local allnums = {}\n for i = 1, x do allnums[i] = true end\n for i = 2, x do\n if allnums[i] then\n table.insert(primes, i)\n local lim = x // i\n for j = 2, lim do\n allnums[j * i] = false\n end\n end\n end\n return primes\nend\n\n\nlocal function getdivisorparts(x, primes)\n local prime_num = #primes\n local tmp = {}\n local lim = mce(msq(x))\n local primepos = 1\n local dv = primes[primepos]\n while primepos <= prime_num and dv <= lim do\n if x % dv == 0 then\n local t = {}\n t.p = dv\n t.cnt = 1\n x = x // dv\n while x % dv == 0 do\n x = x // dv\n t.cnt = t.cnt + 1\n end\n table.insert(tmp, t)\n lim = mce(msq(x))\n end\n if primepos == prime_num then break end\n primepos = primepos + 1\n dv = primes[primepos]\n end\n if x ~= 1 then\n local t = {}\n t.p, t.cnt = x, 1\n table.insert(tmp, t)\n end\n return tmp\nend\n\nlocal function getdivisorCore(divisorparts)\n local t = {}\n local pat = 1\n local len = #divisorparts\n local allpat = 1\n for i = 1, len do\n allpat = allpat * (1 + divisorparts[i].cnt)\n end\n for t_i_pat = 0, allpat - 1 do\n local div = allpat\n local i_pat = t_i_pat\n local ret = 1\n for i = 1, len do\n div = div // (divisorparts[i].cnt + 1)\n local mul = i_pat // div\n i_pat = i_pat % div\n for j = 1, mul do\n ret = ret * divisorparts[i].p\n end\n end\n table.insert(t, ret)\n end\n table.sort(t)\n return t\nend\n\nlocal primes = getprimes(mce(msq(1000000007)))\n\nlocal n, k = io.read(\"*n\", \"*n\")\nlocal a = {}\nlocal sum = 0\nfor i = 1, n do\n a[i] = io.read(\"*n\")\n sum = sum + a[i]\nend\n\nlocal dvp = getdivisorparts(sum, primes)\nlocal dvs = getdivisorCore(dvp)\n\nfor id = #dvs, 1, -1 do\n local dv = dvs[id]\n local plus, minus = {}, {}\n local z = 0\n local c = 0\n for i = 1, n do\n local v = a[i] % dv\n if v <= dv - v then\n table.insert(minus, v)\n z = z - v\n else\n table.insert(plus, dv - v)\n z = z + dv - v\n c = c + dv - v\n end\n end\n if 0 < z then\n table.sort(plus)\n for i = #plus, 1, -1 do\n local v = plus[i]\n z = z - dv\n c = c - v\n if z == 0 then break end\n end\n elseif z < 0 then\n table.sort(minus)\n for i = #minus, 1, -1 do\n local v = minus[i]\n z = z + dv\n c = c + (dv - v)\n if z == 0 then break end\n end\n end\n if c <= k then print(dv) break end\nend\n", "language": "Lua", "metadata": {"date": 1597427168, "filename_ext": "lua", "original_language": "Lua (Lua 5.3.5)", "problem_description_relpath": "problem_descriptions/p02955.html", "problem_id": "p02955", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02955/input.txt", "sample_output_relpath": "derived/input_output/data/p02955/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02955/Lua/s735016504.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s735016504", "user_id": "u120582723"}, "prompt_components": {"gold_output": "7\n", "input_to_evaluate": "local mce, msq = math.ceil, math.sqrt\nlocal function getprimes(x)\n local primes = {}\n local allnums = {}\n for i = 1, x do allnums[i] = true end\n for i = 2, x do\n if allnums[i] then\n table.insert(primes, i)\n local lim = x // i\n for j = 2, lim do\n allnums[j * i] = false\n end\n end\n end\n return primes\nend\n\n\nlocal function getdivisorparts(x, primes)\n local prime_num = #primes\n local tmp = {}\n local lim = mce(msq(x))\n local primepos = 1\n local dv = primes[primepos]\n while primepos <= prime_num and dv <= lim do\n if x % dv == 0 then\n local t = {}\n t.p = dv\n t.cnt = 1\n x = x // dv\n while x % dv == 0 do\n x = x // dv\n t.cnt = t.cnt + 1\n end\n table.insert(tmp, t)\n lim = mce(msq(x))\n end\n if primepos == prime_num then break end\n primepos = primepos + 1\n dv = primes[primepos]\n end\n if x ~= 1 then\n local t = {}\n t.p, t.cnt = x, 1\n table.insert(tmp, t)\n end\n return tmp\nend\n\nlocal function getdivisorCore(divisorparts)\n local t = {}\n local pat = 1\n local len = #divisorparts\n local allpat = 1\n for i = 1, len do\n allpat = allpat * (1 + divisorparts[i].cnt)\n end\n for t_i_pat = 0, allpat - 1 do\n local div = allpat\n local i_pat = t_i_pat\n local ret = 1\n for i = 1, len do\n div = div // (divisorparts[i].cnt + 1)\n local mul = i_pat // div\n i_pat = i_pat % div\n for j = 1, mul do\n ret = ret * divisorparts[i].p\n end\n end\n table.insert(t, ret)\n end\n table.sort(t)\n return t\nend\n\nlocal primes = getprimes(mce(msq(1000000007)))\n\nlocal n, k = io.read(\"*n\", \"*n\")\nlocal a = {}\nlocal sum = 0\nfor i = 1, n do\n a[i] = io.read(\"*n\")\n sum = sum + a[i]\nend\n\nlocal dvp = getdivisorparts(sum, primes)\nlocal dvs = getdivisorCore(dvp)\n\nfor id = #dvs, 1, -1 do\n local dv = dvs[id]\n local plus, minus = {}, {}\n local z = 0\n local c = 0\n for i = 1, n do\n local v = a[i] % dv\n if v <= dv - v then\n table.insert(minus, v)\n z = z - v\n else\n table.insert(plus, dv - v)\n z = z + dv - v\n c = c + dv - v\n end\n end\n if 0 < z then\n table.sort(plus)\n for i = #plus, 1, -1 do\n local v = plus[i]\n z = z - dv\n c = c - v\n if z == 0 then break end\n end\n elseif z < 0 then\n table.sort(minus)\n for i = #minus, 1, -1 do\n local v = minus[i]\n z = z + dv\n c = c + (dv - v)\n if z == 0 then break end\n end\n end\n if c <= k then print(dv) break end\nend\n", "problem_context": "Score : 500 points\n\nProblem Statement\n\nWe have a sequence of N integers: A_1, A_2, \\cdots, A_N.\n\nYou can perform the following operation between 0 and K times (inclusive):\n\nChoose two integers i and j such that i \\neq j, each between 1 and N (inclusive). Add 1 to A_i and -1 to A_j, possibly producing a negative element.\n\nCompute the maximum possible positive integer that divides every element of A after the operations. Here a positive integer x divides an integer y if and only if there exists an integer z such that y = xz.\n\nConstraints\n\n2 \\leq N \\leq 500\n\n1 \\leq A_i \\leq 10^6\n\n0 \\leq K \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nA_1 A_2 \\cdots A_{N-1} A_{N}\n\nOutput\n\nPrint the maximum possible positive integer that divides every element of A after the operations.\n\nSample Input 1\n\n2 3\n8 20\n\nSample Output 1\n\n7\n\n7 will divide every element of A if, for example, we perform the following operation:\n\nChoose i = 2, j = 1. A becomes (7, 21).\n\nWe cannot reach the situation where 8 or greater integer divides every element of A.\n\nSample Input 2\n\n2 10\n3 5\n\nSample Output 2\n\n8\n\nConsider performing the following five operations:\n\nChoose i = 2, j = 1. A becomes (2, 6).\n\nChoose i = 2, j = 1. A becomes (1, 7).\n\nChoose i = 2, j = 1. A becomes (0, 8).\n\nChoose i = 2, j = 1. A becomes (-1, 9).\n\nChoose i = 1, j = 2. A becomes (0, 8).\n\nThen, 0 = 8 \\times 0 and 8 = 8 \\times 1, so 8 divides every element of A. We cannot reach the situation where 9 or greater integer divides every element of A.\n\nSample Input 3\n\n4 5\n10 1 2 22\n\nSample Output 3\n\n7\n\nSample Input 4\n\n8 7\n1 7 5 6 8 2 6 5\n\nSample Output 4\n\n5", "sample_input": "2 3\n8 20\n"}, "reference_outputs": ["7\n"], "source_document_id": "p02955", "source_text": "Score : 500 points\n\nProblem Statement\n\nWe have a sequence of N integers: A_1, A_2, \\cdots, A_N.\n\nYou can perform the following operation between 0 and K times (inclusive):\n\nChoose two integers i and j such that i \\neq j, each between 1 and N (inclusive). Add 1 to A_i and -1 to A_j, possibly producing a negative element.\n\nCompute the maximum possible positive integer that divides every element of A after the operations. Here a positive integer x divides an integer y if and only if there exists an integer z such that y = xz.\n\nConstraints\n\n2 \\leq N \\leq 500\n\n1 \\leq A_i \\leq 10^6\n\n0 \\leq K \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nA_1 A_2 \\cdots A_{N-1} A_{N}\n\nOutput\n\nPrint the maximum possible positive integer that divides every element of A after the operations.\n\nSample Input 1\n\n2 3\n8 20\n\nSample Output 1\n\n7\n\n7 will divide every element of A if, for example, we perform the following operation:\n\nChoose i = 2, j = 1. A becomes (7, 21).\n\nWe cannot reach the situation where 8 or greater integer divides every element of A.\n\nSample Input 2\n\n2 10\n3 5\n\nSample Output 2\n\n8\n\nConsider performing the following five operations:\n\nChoose i = 2, j = 1. A becomes (2, 6).\n\nChoose i = 2, j = 1. A becomes (1, 7).\n\nChoose i = 2, j = 1. A becomes (0, 8).\n\nChoose i = 2, j = 1. A becomes (-1, 9).\n\nChoose i = 1, j = 2. A becomes (0, 8).\n\nThen, 0 = 8 \\times 0 and 8 = 8 \\times 1, so 8 divides every element of A. We cannot reach the situation where 9 or greater integer divides every element of A.\n\nSample Input 3\n\n4 5\n10 1 2 22\n\nSample Output 3\n\n7\n\nSample Input 4\n\n8 7\n1 7 5 6 8 2 6 5\n\nSample Output 4\n\n5", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2500, "cpu_time_ms": 200, "memory_kb": 3260}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s346140649", "group_id": "codeNet:p02956", "input_text": "local mfl, mce = math.floor, math.ceil\nlocal mmi, mma = math.min, math.max\nlocal bls, brs = bit.lshift, bit.rshift\nlocal SegTree = {}\nSegTree.updateAll = function(self)\n for i = self.stagenum - 1, 1, -1 do\n local cnt = bls(1, i - 1)\n for j = 1, cnt do\n self.stage[i][j] = self.func(self.stage[i + 1][j * 2 - 1], self.stage[i + 1][j * 2])\n end\n end\nend\nSegTree.create = function(self, n, func, emptyvalue)\n self.func, self.emptyvalue = func, emptyvalue\n local stagenum, mul = 1, 1\n self.stage = {{}}\n while mul < n do\n mul, stagenum = mul * 2, stagenum + 1\n self.stage[stagenum] = {}\n end\n self.stagenum = stagenum\n self.left_stage = {}\n for i = 1, n do\n local sp, sz = 1, bls(1, stagenum - 1)\n while(i - 1) % sz ~= 0 do\n sp, sz = sp + 1, brs(sz, 1)\n end\n self.left_stage[i] = sp\n end\n self.sz_stage = {}\n local tmp, sp = 1, stagenum\n for i = 1, n do\n if tmp * 2 == i then tmp, sp = tmp * 2, sp - 1 end\n self.sz_stage[i] = sp\n end\n for i = 1, mul do self.stage[stagenum][i] = emptyvalue end\n self:updateAll()\nend\nSegTree.getRange = function(self, left, right)\n if left == right then return self.stage[self.stagenum][left] end\n local stagenum = self.stagenum\n local ret = self.emptyvalue\n while left <= right do\n local stage = mma(self.left_stage[left], self.sz_stage[right - left + 1])\n local sz = bls(1, stagenum - stage)\n ret = self.func(ret, self.stage[stage][1 + brs(left - 1, stagenum - stage)])\n left = left + sz\n end\n return ret\nend\nSegTree.addValue = function(self, idx, value, silent)\n self.stage[self.stagenum][idx] = self.stage[self.stagenum][idx] + value\n for i = self.stagenum - 1, 1, -1 do\n local dst = brs(idx + 1, 1)\n local rem = dst * 4 - 1 - idx\n self.stage[i][dst] = self.func(self.stage[i + 1][idx], self.stage[i + 1][rem])\n idx = dst\n end\nend\nSegTree.new = function(n, func, emptyvalue)\n local obj = {}\n setmetatable(obj, {__index = SegTree})\n obj:create(n, func, emptyvalue)\n return obj\nend\n\nlocal mod = 998244353\n\nlocal function comp(a, b) return a < b end\n\nlocal function lower_bound(ary, x)\n local num = #ary\n if num == 0 then return 1 end\n if not comp(ary[1], x) then return 1 end\n if comp(ary[num], x) then return num + 1 end\n local min, max = 1, num\n while 1 < max - min do\n local mid = mfl((min + max) / 2)\n if comp(ary[mid], x) then\n min = mid\n else\n max = mid\n end\n end\n return max\nend\n\nlocal function upper_bound(ary, x)\n local num = #ary\n if num == 0 then return 1 end\n if comp(x, ary[1]) then return 1 end\n if not comp(x, ary[num]) then return num + 1 end\n local min, max = 1, num\n while 1 < max - min do\n local mid = mfl((min + max) / 2)\n if not comp(x, ary[mid]) then\n min = mid\n else\n max = mid\n end\n end\n return max\nend\n\nlocal function bmul(x, y)\n local x0, y0 = x % 31596, y % 31596\n local x1, y1 = mfl(x / 31596), mfl(y / 31596)\n return (x1 * y1 * 62863 + (x1 * y0 + x0 * y1) * 31596 + x0 * y0) % mod\nend\nlocal function badd(x, y)\n return (x + y) % mod\nend\n\nlocal function bsub(x, y)\n return x < y and x - y + mod or x - y\nend\n\nlocal function modpow(src, pow)\n local res = 1\n while 0 < pow do\n if pow % 2 == 1 then\n res = bmul(res, src)\n pow = pow - 1\n end\n src = bmul(src, src)\n pow = mfl(pow / 2)\n end\n return res\nend\n\nlocal function modinv(src)\n return modpow(src, mod - 2)\nend\n\nlocal p2 = {2}\nfor i = 2, 200010 do p2[i] = badd(p2[i - 1], p2[i - 1]) end\nlocal function getpow2(x)\n if x == 0 then return 1\n else return p2[x] end\nend\n\nlocal n = io.read(\"*n\")\nlocal xs, ys = {}, {}\nlocal idx_by_x = {}\nlocal sorted_x, sorted_y = {}, {}\nlocal ymap = {}\nfor i = 1, n do\n xs[i], ys[i] = io.read(\"*n\", \"*n\")\n idx_by_x[i] = i\n sorted_x[i] = xs[i]\n sorted_y[i] = ys[i]\n ymap[ys[i]] = true\nend\ntable.sort(idx_by_x, function(a, b) return xs[a] < xs[b] end)\ntable.sort(sorted_x)\ntable.sort(sorted_y)\nlocal y_uniq = {}\nfor k, _u in pairs(ymap) do\n table.insert(y_uniq, k)\nend\ntable.sort(y_uniq)\nlocal y_uniq_inv = {}\nfor i = 1, #y_uniq do\n y_uniq_inv[y_uniq[i]] = i\nend\n\nlocal stLeft = SegTree.new(#y_uniq, function(a, b) return a + b end, 0)\n\n-- by x_sorted index\nlocal x_pattern = {}\n\nlocal x_left_pos = 1\nlocal x_right_pos = 1\nfor i_x = 1, n do\n local x = sorted_x[i_x]\n if 1 < i_x and sorted_x[i_x - 1] < x then\n for i = x_left_pos, i_x - 1 do\n local y = ys[idx_by_x[i]]\n local yu = y_uniq_inv[y]\n stLeft:addValue(yu, 1)\n end\n x_left_pos = i_x\n end\n while x_right_pos < n and x == sorted_x[x_right_pos + 1] do\n x_right_pos = x_right_pos + 1\n end\n local x_small_count = x_left_pos - 1\n local x_large_count = n - x_right_pos\n local pat_all = bsub(getpow2(n), 1)\n local pat_xsmall = bsub(getpow2(x_small_count), 1)\n local pat_xlarge = bsub(getpow2(x_large_count), 1)\n\n local src = idx_by_x[i_x]\n local y = ys[src]\n local y_small_count = lower_bound(sorted_y, y) - 1\n local y_large_count = n + 1 - upper_bound(sorted_y, y)\n local pat_ysmall = bsub(getpow2(y_small_count), 1)\n local pat_ylarge = bsub(getpow2(y_large_count), 1)\n\n local yu = y_uniq_inv[y]\n local x_small_y_small_count = 0\n if 1 < yu then\n x_small_y_small_count = stLeft:getRange(1, yu - 1)\n end\n local pat_x_small_y_small_count = bsub(getpow2(x_small_y_small_count), 1)\n local x_small_y_large_count = 0\n if yu < #y_uniq then\n x_small_y_large_count = stLeft:getRange(yu + 1, #y_uniq)\n end\n local pat_x_small_y_large_count = bsub(getpow2(x_small_y_large_count), 1)\n\n local v = badd(pat_all, badd(pat_x_small_y_small_count, pat_x_small_y_large_count))\n v = bsub(v, pat_xsmall)\n v = bsub(v, pat_xlarge)\n v = bsub(v, pat_ysmall)\n v = bsub(v, pat_ylarge)\n x_pattern[i_x] = v\nend\nx_right_pos = n\nlocal stRight = SegTree.new(#y_uniq, function(a, b) return a + b end, 0)\nfor i_x = n, 1, -1 do\n local x = sorted_x[i_x]\n if i_x < n and x < sorted_x[i_x + 1] then\n for i = x_right_pos, i_x + 1, -1 do\n local y = ys[idx_by_x[i]]\n local yu = y_uniq_inv[y]\n stRight:addValue(yu, 1)\n end\n x_right_pos = i_x\n end\n local src = idx_by_x[i_x]\n local y = ys[src]\n local yu = y_uniq_inv[y]\n local x_large_y_small_count = 0\n if 1 < yu then\n x_large_y_small_count = stRight:getRange(1, yu - 1)\n end\n local pat_x_large_y_small_count = bsub(getpow2(x_large_y_small_count), 1)\n local x_large_y_large_count = 0\n if yu < #y_uniq then\n x_large_y_large_count = stRight:getRange(yu + 1, #y_uniq)\n end\n local pat_x_large_y_large_count = bsub(getpow2(x_large_y_large_count), 1)\n local v = badd(pat_x_large_y_small_count, pat_x_large_y_large_count)\n x_pattern[i_x] = badd(x_pattern[i_x], v)\nend\nlocal ret = 0\nfor i = 1, n do\n ret = badd(ret, x_pattern[i])\nend\nprint(ret)\n", "language": "Lua", "metadata": {"date": 1597419120, "filename_ext": "lua", "original_language": "Lua (LuaJIT 2.1.0)", "problem_description_relpath": "problem_descriptions/p02956.html", "problem_id": "p02956", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02956/input.txt", "sample_output_relpath": "derived/input_output/data/p02956/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02956/Lua/s346140649.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s346140649", "user_id": "u120582723"}, "prompt_components": {"gold_output": "13\n", "input_to_evaluate": "local mfl, mce = math.floor, math.ceil\nlocal mmi, mma = math.min, math.max\nlocal bls, brs = bit.lshift, bit.rshift\nlocal SegTree = {}\nSegTree.updateAll = function(self)\n for i = self.stagenum - 1, 1, -1 do\n local cnt = bls(1, i - 1)\n for j = 1, cnt do\n self.stage[i][j] = self.func(self.stage[i + 1][j * 2 - 1], self.stage[i + 1][j * 2])\n end\n end\nend\nSegTree.create = function(self, n, func, emptyvalue)\n self.func, self.emptyvalue = func, emptyvalue\n local stagenum, mul = 1, 1\n self.stage = {{}}\n while mul < n do\n mul, stagenum = mul * 2, stagenum + 1\n self.stage[stagenum] = {}\n end\n self.stagenum = stagenum\n self.left_stage = {}\n for i = 1, n do\n local sp, sz = 1, bls(1, stagenum - 1)\n while(i - 1) % sz ~= 0 do\n sp, sz = sp + 1, brs(sz, 1)\n end\n self.left_stage[i] = sp\n end\n self.sz_stage = {}\n local tmp, sp = 1, stagenum\n for i = 1, n do\n if tmp * 2 == i then tmp, sp = tmp * 2, sp - 1 end\n self.sz_stage[i] = sp\n end\n for i = 1, mul do self.stage[stagenum][i] = emptyvalue end\n self:updateAll()\nend\nSegTree.getRange = function(self, left, right)\n if left == right then return self.stage[self.stagenum][left] end\n local stagenum = self.stagenum\n local ret = self.emptyvalue\n while left <= right do\n local stage = mma(self.left_stage[left], self.sz_stage[right - left + 1])\n local sz = bls(1, stagenum - stage)\n ret = self.func(ret, self.stage[stage][1 + brs(left - 1, stagenum - stage)])\n left = left + sz\n end\n return ret\nend\nSegTree.addValue = function(self, idx, value, silent)\n self.stage[self.stagenum][idx] = self.stage[self.stagenum][idx] + value\n for i = self.stagenum - 1, 1, -1 do\n local dst = brs(idx + 1, 1)\n local rem = dst * 4 - 1 - idx\n self.stage[i][dst] = self.func(self.stage[i + 1][idx], self.stage[i + 1][rem])\n idx = dst\n end\nend\nSegTree.new = function(n, func, emptyvalue)\n local obj = {}\n setmetatable(obj, {__index = SegTree})\n obj:create(n, func, emptyvalue)\n return obj\nend\n\nlocal mod = 998244353\n\nlocal function comp(a, b) return a < b end\n\nlocal function lower_bound(ary, x)\n local num = #ary\n if num == 0 then return 1 end\n if not comp(ary[1], x) then return 1 end\n if comp(ary[num], x) then return num + 1 end\n local min, max = 1, num\n while 1 < max - min do\n local mid = mfl((min + max) / 2)\n if comp(ary[mid], x) then\n min = mid\n else\n max = mid\n end\n end\n return max\nend\n\nlocal function upper_bound(ary, x)\n local num = #ary\n if num == 0 then return 1 end\n if comp(x, ary[1]) then return 1 end\n if not comp(x, ary[num]) then return num + 1 end\n local min, max = 1, num\n while 1 < max - min do\n local mid = mfl((min + max) / 2)\n if not comp(x, ary[mid]) then\n min = mid\n else\n max = mid\n end\n end\n return max\nend\n\nlocal function bmul(x, y)\n local x0, y0 = x % 31596, y % 31596\n local x1, y1 = mfl(x / 31596), mfl(y / 31596)\n return (x1 * y1 * 62863 + (x1 * y0 + x0 * y1) * 31596 + x0 * y0) % mod\nend\nlocal function badd(x, y)\n return (x + y) % mod\nend\n\nlocal function bsub(x, y)\n return x < y and x - y + mod or x - y\nend\n\nlocal function modpow(src, pow)\n local res = 1\n while 0 < pow do\n if pow % 2 == 1 then\n res = bmul(res, src)\n pow = pow - 1\n end\n src = bmul(src, src)\n pow = mfl(pow / 2)\n end\n return res\nend\n\nlocal function modinv(src)\n return modpow(src, mod - 2)\nend\n\nlocal p2 = {2}\nfor i = 2, 200010 do p2[i] = badd(p2[i - 1], p2[i - 1]) end\nlocal function getpow2(x)\n if x == 0 then return 1\n else return p2[x] end\nend\n\nlocal n = io.read(\"*n\")\nlocal xs, ys = {}, {}\nlocal idx_by_x = {}\nlocal sorted_x, sorted_y = {}, {}\nlocal ymap = {}\nfor i = 1, n do\n xs[i], ys[i] = io.read(\"*n\", \"*n\")\n idx_by_x[i] = i\n sorted_x[i] = xs[i]\n sorted_y[i] = ys[i]\n ymap[ys[i]] = true\nend\ntable.sort(idx_by_x, function(a, b) return xs[a] < xs[b] end)\ntable.sort(sorted_x)\ntable.sort(sorted_y)\nlocal y_uniq = {}\nfor k, _u in pairs(ymap) do\n table.insert(y_uniq, k)\nend\ntable.sort(y_uniq)\nlocal y_uniq_inv = {}\nfor i = 1, #y_uniq do\n y_uniq_inv[y_uniq[i]] = i\nend\n\nlocal stLeft = SegTree.new(#y_uniq, function(a, b) return a + b end, 0)\n\n-- by x_sorted index\nlocal x_pattern = {}\n\nlocal x_left_pos = 1\nlocal x_right_pos = 1\nfor i_x = 1, n do\n local x = sorted_x[i_x]\n if 1 < i_x and sorted_x[i_x - 1] < x then\n for i = x_left_pos, i_x - 1 do\n local y = ys[idx_by_x[i]]\n local yu = y_uniq_inv[y]\n stLeft:addValue(yu, 1)\n end\n x_left_pos = i_x\n end\n while x_right_pos < n and x == sorted_x[x_right_pos + 1] do\n x_right_pos = x_right_pos + 1\n end\n local x_small_count = x_left_pos - 1\n local x_large_count = n - x_right_pos\n local pat_all = bsub(getpow2(n), 1)\n local pat_xsmall = bsub(getpow2(x_small_count), 1)\n local pat_xlarge = bsub(getpow2(x_large_count), 1)\n\n local src = idx_by_x[i_x]\n local y = ys[src]\n local y_small_count = lower_bound(sorted_y, y) - 1\n local y_large_count = n + 1 - upper_bound(sorted_y, y)\n local pat_ysmall = bsub(getpow2(y_small_count), 1)\n local pat_ylarge = bsub(getpow2(y_large_count), 1)\n\n local yu = y_uniq_inv[y]\n local x_small_y_small_count = 0\n if 1 < yu then\n x_small_y_small_count = stLeft:getRange(1, yu - 1)\n end\n local pat_x_small_y_small_count = bsub(getpow2(x_small_y_small_count), 1)\n local x_small_y_large_count = 0\n if yu < #y_uniq then\n x_small_y_large_count = stLeft:getRange(yu + 1, #y_uniq)\n end\n local pat_x_small_y_large_count = bsub(getpow2(x_small_y_large_count), 1)\n\n local v = badd(pat_all, badd(pat_x_small_y_small_count, pat_x_small_y_large_count))\n v = bsub(v, pat_xsmall)\n v = bsub(v, pat_xlarge)\n v = bsub(v, pat_ysmall)\n v = bsub(v, pat_ylarge)\n x_pattern[i_x] = v\nend\nx_right_pos = n\nlocal stRight = SegTree.new(#y_uniq, function(a, b) return a + b end, 0)\nfor i_x = n, 1, -1 do\n local x = sorted_x[i_x]\n if i_x < n and x < sorted_x[i_x + 1] then\n for i = x_right_pos, i_x + 1, -1 do\n local y = ys[idx_by_x[i]]\n local yu = y_uniq_inv[y]\n stRight:addValue(yu, 1)\n end\n x_right_pos = i_x\n end\n local src = idx_by_x[i_x]\n local y = ys[src]\n local yu = y_uniq_inv[y]\n local x_large_y_small_count = 0\n if 1 < yu then\n x_large_y_small_count = stRight:getRange(1, yu - 1)\n end\n local pat_x_large_y_small_count = bsub(getpow2(x_large_y_small_count), 1)\n local x_large_y_large_count = 0\n if yu < #y_uniq then\n x_large_y_large_count = stRight:getRange(yu + 1, #y_uniq)\n end\n local pat_x_large_y_large_count = bsub(getpow2(x_large_y_large_count), 1)\n local v = badd(pat_x_large_y_small_count, pat_x_large_y_large_count)\n x_pattern[i_x] = badd(x_pattern[i_x], v)\nend\nlocal ret = 0\nfor i = 1, n do\n ret = badd(ret, x_pattern[i])\nend\nprint(ret)\n", "problem_context": "Score : 600 points\n\nProblem Statement\n\nWe have a set S of N points in a two-dimensional plane. The coordinates of the i-th point are (x_i, y_i). The N points have distinct x-coordinates and distinct y-coordinates.\n\nFor a non-empty subset T of S, let f(T) be the number of points contained in the smallest rectangle, whose sides are parallel to the coordinate axes, that contains all the points in T. More formally, we define f(T) as follows:\n\nf(T) := (the number of integers i (1 \\leq i \\leq N) such that a \\leq x_i \\leq b and c \\leq y_i \\leq d, where a, b, c, and d are the minimum x-coordinate, the maximum x-coordinate, the minimum y-coordinate, and the maximum y-coordinate of the points in T)\n\nFind the sum of f(T) over all non-empty subset T of S. Since it can be enormous, print the sum modulo 998244353.\n\nConstraints\n\n1 \\leq N \\leq 2 \\times 10^5\n\n-10^9 \\leq x_i, y_i \\leq 10^9\n\nx_i \\neq x_j (i \\neq j)\n\ny_i \\neq y_j (i \\neq j)\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nx_1 y_1\n:\nx_N y_N\n\nOutput\n\nPrint the sum of f(T) over all non-empty subset T of S, modulo 998244353.\n\nSample Input 1\n\n3\n-1 3\n2 1\n3 -2\n\nSample Output 1\n\n13\n\nLet the first, second, and third points be P_1, P_2, and P_3, respectively. S = \\{P_1, P_2, P_3\\} has seven non-empty subsets, and f has the following values for each of them:\n\nf(\\{P_1\\}) = 1\n\nf(\\{P_2\\}) = 1\n\nf(\\{P_3\\}) = 1\n\nf(\\{P_1, P_2\\}) = 2\n\nf(\\{P_2, P_3\\}) = 2\n\nf(\\{P_3, P_1\\}) = 3\n\nf(\\{P_1, P_2, P_3\\}) = 3\n\nThe sum of these is 13.\n\nSample Input 2\n\n4\n1 4\n2 1\n3 3\n4 2\n\nSample Output 2\n\n34\n\nSample Input 3\n\n10\n19 -11\n-3 -12\n5 3\n3 -15\n8 -14\n-9 -20\n10 -9\n0 2\n-7 17\n6 -6\n\nSample Output 3\n\n7222\n\nBe sure to print the sum modulo 998244353.", "sample_input": "3\n-1 3\n2 1\n3 -2\n"}, "reference_outputs": ["13\n"], "source_document_id": "p02956", "source_text": "Score : 600 points\n\nProblem Statement\n\nWe have a set S of N points in a two-dimensional plane. The coordinates of the i-th point are (x_i, y_i). The N points have distinct x-coordinates and distinct y-coordinates.\n\nFor a non-empty subset T of S, let f(T) be the number of points contained in the smallest rectangle, whose sides are parallel to the coordinate axes, that contains all the points in T. More formally, we define f(T) as follows:\n\nf(T) := (the number of integers i (1 \\leq i \\leq N) such that a \\leq x_i \\leq b and c \\leq y_i \\leq d, where a, b, c, and d are the minimum x-coordinate, the maximum x-coordinate, the minimum y-coordinate, and the maximum y-coordinate of the points in T)\n\nFind the sum of f(T) over all non-empty subset T of S. Since it can be enormous, print the sum modulo 998244353.\n\nConstraints\n\n1 \\leq N \\leq 2 \\times 10^5\n\n-10^9 \\leq x_i, y_i \\leq 10^9\n\nx_i \\neq x_j (i \\neq j)\n\ny_i \\neq y_j (i \\neq j)\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nx_1 y_1\n:\nx_N y_N\n\nOutput\n\nPrint the sum of f(T) over all non-empty subset T of S, modulo 998244353.\n\nSample Input 1\n\n3\n-1 3\n2 1\n3 -2\n\nSample Output 1\n\n13\n\nLet the first, second, and third points be P_1, P_2, and P_3, respectively. S = \\{P_1, P_2, P_3\\} has seven non-empty subsets, and f has the following values for each of them:\n\nf(\\{P_1\\}) = 1\n\nf(\\{P_2\\}) = 1\n\nf(\\{P_3\\}) = 1\n\nf(\\{P_1, P_2\\}) = 2\n\nf(\\{P_2, P_3\\}) = 2\n\nf(\\{P_3, P_1\\}) = 3\n\nf(\\{P_1, P_2, P_3\\}) = 3\n\nThe sum of these is 13.\n\nSample Input 2\n\n4\n1 4\n2 1\n3 3\n4 2\n\nSample Output 2\n\n34\n\nSample Input 3\n\n10\n19 -11\n-3 -12\n5 3\n3 -15\n8 -14\n-9 -20\n10 -9\n0 2\n-7 17\n6 -6\n\nSample Output 3\n\n7222\n\nBe sure to print the sum modulo 998244353.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 6739, "cpu_time_ms": 1275, "memory_kb": 48236}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s443355013", "group_id": "codeNet:p02957", "input_text": "local A,B=io.read(\"n\",\"n\")\nif (A-B)%2==0 then\n print(math.abs(A-B)//2)\nelse\n print(\"IMPOSSIBLE\")\nend", "language": "Lua", "metadata": {"date": 1576037393, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p02957.html", "problem_id": "p02957", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02957/input.txt", "sample_output_relpath": "derived/input_output/data/p02957/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02957/Lua/s443355013.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s443355013", "user_id": "u162773977"}, "prompt_components": {"gold_output": "9\n", "input_to_evaluate": "local A,B=io.read(\"n\",\"n\")\nif (A-B)%2==0 then\n print(math.abs(A-B)//2)\nelse\n print(\"IMPOSSIBLE\")\nend", "problem_context": "Score: 100 points\n\nProblem Statement\n\nWe have two distinct integers A and B.\n\nPrint the integer K such that |A - K| = |B - K|.\n\nIf such an integer does not exist, print IMPOSSIBLE instead.\n\nConstraints\n\nAll values in input are integers.\n\n0 \\leq A,\\ B \\leq 10^9\n\nA and B are distinct.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nPrint the integer K satisfying the condition.\n\nIf such an integer does not exist, print IMPOSSIBLE instead.\n\nSample Input 1\n\n2 16\n\nSample Output 1\n\n9\n\n|2 - 9| = 7 and |16 - 9| = 7, so 9 satisfies the condition.\n\nSample Input 2\n\n0 3\n\nSample Output 2\n\nIMPOSSIBLE\n\nNo integer satisfies the condition.\n\nSample Input 3\n\n998244353 99824435\n\nSample Output 3\n\n549034394", "sample_input": "2 16\n"}, "reference_outputs": ["9\n"], "source_document_id": "p02957", "source_text": "Score: 100 points\n\nProblem Statement\n\nWe have two distinct integers A and B.\n\nPrint the integer K such that |A - K| = |B - K|.\n\nIf such an integer does not exist, print IMPOSSIBLE instead.\n\nConstraints\n\nAll values in input are integers.\n\n0 \\leq A,\\ B \\leq 10^9\n\nA and B are distinct.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nPrint the integer K satisfying the condition.\n\nIf such an integer does not exist, print IMPOSSIBLE instead.\n\nSample Input 1\n\n2 16\n\nSample Output 1\n\n9\n\n|2 - 9| = 7 and |16 - 9| = 7, so 9 satisfies the condition.\n\nSample Input 2\n\n0 3\n\nSample Output 2\n\nIMPOSSIBLE\n\nNo integer satisfies the condition.\n\nSample Input 3\n\n998244353 99824435\n\nSample Output 3\n\n549034394", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 102, "cpu_time_ms": 8, "memory_kb": 888}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s340886479", "group_id": "codeNet:p02957", "input_text": "local a, b = io.read(\"*n\", \"*n\")\nif (math.abs(a - b)) % 2 == 1 then\n print(\"IMPOSSIBLE\")\nelse\n mid = (a + b) // 2\n print(mid)\nend\n", "language": "Lua", "metadata": {"date": 1564275701, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p02957.html", "problem_id": "p02957", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02957/input.txt", "sample_output_relpath": "derived/input_output/data/p02957/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02957/Lua/s340886479.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s340886479", "user_id": "u120582723"}, "prompt_components": {"gold_output": "9\n", "input_to_evaluate": "local a, b = io.read(\"*n\", \"*n\")\nif (math.abs(a - b)) % 2 == 1 then\n print(\"IMPOSSIBLE\")\nelse\n mid = (a + b) // 2\n print(mid)\nend\n", "problem_context": "Score: 100 points\n\nProblem Statement\n\nWe have two distinct integers A and B.\n\nPrint the integer K such that |A - K| = |B - K|.\n\nIf such an integer does not exist, print IMPOSSIBLE instead.\n\nConstraints\n\nAll values in input are integers.\n\n0 \\leq A,\\ B \\leq 10^9\n\nA and B are distinct.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nPrint the integer K satisfying the condition.\n\nIf such an integer does not exist, print IMPOSSIBLE instead.\n\nSample Input 1\n\n2 16\n\nSample Output 1\n\n9\n\n|2 - 9| = 7 and |16 - 9| = 7, so 9 satisfies the condition.\n\nSample Input 2\n\n0 3\n\nSample Output 2\n\nIMPOSSIBLE\n\nNo integer satisfies the condition.\n\nSample Input 3\n\n998244353 99824435\n\nSample Output 3\n\n549034394", "sample_input": "2 16\n"}, "reference_outputs": ["9\n"], "source_document_id": "p02957", "source_text": "Score: 100 points\n\nProblem Statement\n\nWe have two distinct integers A and B.\n\nPrint the integer K such that |A - K| = |B - K|.\n\nIf such an integer does not exist, print IMPOSSIBLE instead.\n\nConstraints\n\nAll values in input are integers.\n\n0 \\leq A,\\ B \\leq 10^9\n\nA and B are distinct.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nPrint the integer K satisfying the condition.\n\nIf such an integer does not exist, print IMPOSSIBLE instead.\n\nSample Input 1\n\n2 16\n\nSample Output 1\n\n9\n\n|2 - 9| = 7 and |16 - 9| = 7, so 9 satisfies the condition.\n\nSample Input 2\n\n0 3\n\nSample Output 2\n\nIMPOSSIBLE\n\nNo integer satisfies the condition.\n\nSample Input 3\n\n998244353 99824435\n\nSample Output 3\n\n549034394", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 133, "cpu_time_ms": 11, "memory_kb": 1012}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s038938401", "group_id": "codeNet:p02958", "input_text": "local N=io.read(\"n\")\nlocal w=0\nfor i=1,N do\n local p = io.read(\"n\")\n if p~=i then\n w=w+1\n end\nend\nif w<=2 then\n print(\"Yes\")\nelse\n print(\"No\")\nend", "language": "Lua", "metadata": {"date": 1576037782, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p02958.html", "problem_id": "p02958", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02958/input.txt", "sample_output_relpath": "derived/input_output/data/p02958/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02958/Lua/s038938401.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s038938401", "user_id": "u162773977"}, "prompt_components": {"gold_output": "YES\n", "input_to_evaluate": "local N=io.read(\"n\")\nlocal w=0\nfor i=1,N do\n local p = io.read(\"n\")\n if p~=i then\n w=w+1\n end\nend\nif w<=2 then\n print(\"Yes\")\nelse\n print(\"No\")\nend", "problem_context": "Score : 200 points\n\nProblem Statement\n\nWe have a sequence p = {p_1,\\ p_2,\\ ...,\\ p_N} which is a permutation of {1,\\ 2,\\ ...,\\ N}.\n\nYou can perform the following operation at most once: choose integers i and j (1 \\leq i < j \\leq N), and swap p_i and p_j. Note that you can also choose not to perform it.\n\nPrint YES if you can sort p in ascending order in this way, and NO otherwise.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 50\n\np is a permutation of {1,\\ 2,\\ ...,\\ N}.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\np_1 p_2 ... p_N\n\nOutput\n\nPrint YES if you can sort p in ascending order in the way stated in the problem statement, and NO otherwise.\n\nSample Input 1\n\n5\n5 2 3 4 1\n\nSample Output 1\n\nYES\n\nYou can sort p in ascending order by swapping p_1 and p_5.\n\nSample Input 2\n\n5\n2 4 3 5 1\n\nSample Output 2\n\nNO\n\nIn this case, swapping any two elements does not sort p in ascending order.\n\nSample Input 3\n\n7\n1 2 3 4 5 6 7\n\nSample Output 3\n\nYES\n\np is already sorted in ascending order, so no operation is needed.", "sample_input": "5\n5 2 3 4 1\n"}, "reference_outputs": ["YES\n"], "source_document_id": "p02958", "source_text": "Score : 200 points\n\nProblem Statement\n\nWe have a sequence p = {p_1,\\ p_2,\\ ...,\\ p_N} which is a permutation of {1,\\ 2,\\ ...,\\ N}.\n\nYou can perform the following operation at most once: choose integers i and j (1 \\leq i < j \\leq N), and swap p_i and p_j. Note that you can also choose not to perform it.\n\nPrint YES if you can sort p in ascending order in this way, and NO otherwise.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 50\n\np is a permutation of {1,\\ 2,\\ ...,\\ N}.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\np_1 p_2 ... p_N\n\nOutput\n\nPrint YES if you can sort p in ascending order in the way stated in the problem statement, and NO otherwise.\n\nSample Input 1\n\n5\n5 2 3 4 1\n\nSample Output 1\n\nYES\n\nYou can sort p in ascending order by swapping p_1 and p_5.\n\nSample Input 2\n\n5\n2 4 3 5 1\n\nSample Output 2\n\nNO\n\nIn this case, swapping any two elements does not sort p in ascending order.\n\nSample Input 3\n\n7\n1 2 3 4 5 6 7\n\nSample Output 3\n\nYES\n\np is already sorted in ascending order, so no operation is needed.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 154, "cpu_time_ms": 7, "memory_kb": 760}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s809278029", "group_id": "codeNet:p02958", "input_text": "n=io.read(\"*n\")\np={}\n\nfor i=1,n do\n table.insert(p, io.read(\"*n\"))\nend\n\nc=0\nj=0\nfor i=1,n do\n if p[i]~=j+1 then\n c=c+1\n end\n j=j+1\nend\n\nif c<=2 then\n print(\"YES\")\nelse\n print(c)\n print(\"NO\")\nend", "language": "Lua", "metadata": {"date": 1572980155, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p02958.html", "problem_id": "p02958", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02958/input.txt", "sample_output_relpath": "derived/input_output/data/p02958/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02958/Lua/s809278029.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s809278029", "user_id": "u535423069"}, "prompt_components": {"gold_output": "YES\n", "input_to_evaluate": "n=io.read(\"*n\")\np={}\n\nfor i=1,n do\n table.insert(p, io.read(\"*n\"))\nend\n\nc=0\nj=0\nfor i=1,n do\n if p[i]~=j+1 then\n c=c+1\n end\n j=j+1\nend\n\nif c<=2 then\n print(\"YES\")\nelse\n print(c)\n print(\"NO\")\nend", "problem_context": "Score : 200 points\n\nProblem Statement\n\nWe have a sequence p = {p_1,\\ p_2,\\ ...,\\ p_N} which is a permutation of {1,\\ 2,\\ ...,\\ N}.\n\nYou can perform the following operation at most once: choose integers i and j (1 \\leq i < j \\leq N), and swap p_i and p_j. Note that you can also choose not to perform it.\n\nPrint YES if you can sort p in ascending order in this way, and NO otherwise.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 50\n\np is a permutation of {1,\\ 2,\\ ...,\\ N}.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\np_1 p_2 ... p_N\n\nOutput\n\nPrint YES if you can sort p in ascending order in the way stated in the problem statement, and NO otherwise.\n\nSample Input 1\n\n5\n5 2 3 4 1\n\nSample Output 1\n\nYES\n\nYou can sort p in ascending order by swapping p_1 and p_5.\n\nSample Input 2\n\n5\n2 4 3 5 1\n\nSample Output 2\n\nNO\n\nIn this case, swapping any two elements does not sort p in ascending order.\n\nSample Input 3\n\n7\n1 2 3 4 5 6 7\n\nSample Output 3\n\nYES\n\np is already sorted in ascending order, so no operation is needed.", "sample_input": "5\n5 2 3 4 1\n"}, "reference_outputs": ["YES\n"], "source_document_id": "p02958", "source_text": "Score : 200 points\n\nProblem Statement\n\nWe have a sequence p = {p_1,\\ p_2,\\ ...,\\ p_N} which is a permutation of {1,\\ 2,\\ ...,\\ N}.\n\nYou can perform the following operation at most once: choose integers i and j (1 \\leq i < j \\leq N), and swap p_i and p_j. Note that you can also choose not to perform it.\n\nPrint YES if you can sort p in ascending order in this way, and NO otherwise.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 50\n\np is a permutation of {1,\\ 2,\\ ...,\\ N}.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\np_1 p_2 ... p_N\n\nOutput\n\nPrint YES if you can sort p in ascending order in the way stated in the problem statement, and NO otherwise.\n\nSample Input 1\n\n5\n5 2 3 4 1\n\nSample Output 1\n\nYES\n\nYou can sort p in ascending order by swapping p_1 and p_5.\n\nSample Input 2\n\n5\n2 4 3 5 1\n\nSample Output 2\n\nNO\n\nIn this case, swapping any two elements does not sort p in ascending order.\n\nSample Input 3\n\n7\n1 2 3 4 5 6 7\n\nSample Output 3\n\nYES\n\np is already sorted in ascending order, so no operation is needed.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 204, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s565953461", "group_id": "codeNet:p02958", "input_text": "io.write('Yes')", "language": "Lua", "metadata": {"date": 1564275849, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p02958.html", "problem_id": "p02958", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02958/input.txt", "sample_output_relpath": "derived/input_output/data/p02958/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02958/Lua/s565953461.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s565953461", "user_id": "u918364989"}, "prompt_components": {"gold_output": "YES\n", "input_to_evaluate": "io.write('Yes')", "problem_context": "Score : 200 points\n\nProblem Statement\n\nWe have a sequence p = {p_1,\\ p_2,\\ ...,\\ p_N} which is a permutation of {1,\\ 2,\\ ...,\\ N}.\n\nYou can perform the following operation at most once: choose integers i and j (1 \\leq i < j \\leq N), and swap p_i and p_j. Note that you can also choose not to perform it.\n\nPrint YES if you can sort p in ascending order in this way, and NO otherwise.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 50\n\np is a permutation of {1,\\ 2,\\ ...,\\ N}.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\np_1 p_2 ... p_N\n\nOutput\n\nPrint YES if you can sort p in ascending order in the way stated in the problem statement, and NO otherwise.\n\nSample Input 1\n\n5\n5 2 3 4 1\n\nSample Output 1\n\nYES\n\nYou can sort p in ascending order by swapping p_1 and p_5.\n\nSample Input 2\n\n5\n2 4 3 5 1\n\nSample Output 2\n\nNO\n\nIn this case, swapping any two elements does not sort p in ascending order.\n\nSample Input 3\n\n7\n1 2 3 4 5 6 7\n\nSample Output 3\n\nYES\n\np is already sorted in ascending order, so no operation is needed.", "sample_input": "5\n5 2 3 4 1\n"}, "reference_outputs": ["YES\n"], "source_document_id": "p02958", "source_text": "Score : 200 points\n\nProblem Statement\n\nWe have a sequence p = {p_1,\\ p_2,\\ ...,\\ p_N} which is a permutation of {1,\\ 2,\\ ...,\\ N}.\n\nYou can perform the following operation at most once: choose integers i and j (1 \\leq i < j \\leq N), and swap p_i and p_j. Note that you can also choose not to perform it.\n\nPrint YES if you can sort p in ascending order in this way, and NO otherwise.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 50\n\np is a permutation of {1,\\ 2,\\ ...,\\ N}.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\np_1 p_2 ... p_N\n\nOutput\n\nPrint YES if you can sort p in ascending order in the way stated in the problem statement, and NO otherwise.\n\nSample Input 1\n\n5\n5 2 3 4 1\n\nSample Output 1\n\nYES\n\nYou can sort p in ascending order by swapping p_1 and p_5.\n\nSample Input 2\n\n5\n2 4 3 5 1\n\nSample Output 2\n\nNO\n\nIn this case, swapping any two elements does not sort p in ascending order.\n\nSample Input 3\n\n7\n1 2 3 4 5 6 7\n\nSample Output 3\n\nYES\n\np is already sorted in ascending order, so no operation is needed.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 15, "cpu_time_ms": 8, "memory_kb": 760}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s746218515", "group_id": "codeNet:p02959", "input_text": "n=io.read(\"*n\")\na={}\nb={}\n\nfor i=1,n+1 do\n table.insert(a,io.read(\"*n\"))\nend\n\nfor i=1,n do\n table.insert(b,io.read(\"*n\"))\nend\n\nans=0\nfor i=1,n do\n local s=math.min(a[i], b[i])\n ans=ans+s\n a[i]=a[i]-s\n b[i]=b[i]-s\n local s2=math.min(a[i+1], b[i])\n ans=ans+s2\n a[i+1]=a[i+1]-s2\n b[i]=b[i]-s2\nend\n\nprint(ans)", "language": "Lua", "metadata": {"date": 1572984426, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p02959.html", "problem_id": "p02959", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02959/input.txt", "sample_output_relpath": "derived/input_output/data/p02959/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02959/Lua/s746218515.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s746218515", "user_id": "u535423069"}, "prompt_components": {"gold_output": "9\n", "input_to_evaluate": "n=io.read(\"*n\")\na={}\nb={}\n\nfor i=1,n+1 do\n table.insert(a,io.read(\"*n\"))\nend\n\nfor i=1,n do\n table.insert(b,io.read(\"*n\"))\nend\n\nans=0\nfor i=1,n do\n local s=math.min(a[i], b[i])\n ans=ans+s\n a[i]=a[i]-s\n b[i]=b[i]-s\n local s2=math.min(a[i+1], b[i])\n ans=ans+s2\n a[i+1]=a[i+1]-s2\n b[i]=b[i]-s2\nend\n\nprint(ans)", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere are N+1 towns. The i-th town is being attacked by A_i monsters.\n\nWe have N heroes. The i-th hero can defeat monsters attacking the i-th or (i+1)-th town, for a total of at most B_i monsters.\n\nWhat is the maximum total number of monsters the heroes can cooperate to defeat?\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^5\n\n1 \\leq A_i \\leq 10^9\n\n1 \\leq B_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_{N+1}\nB_1 B_2 ... B_N\n\nOutput\n\nPrint the maximum total number of monsters the heroes can defeat.\n\nSample Input 1\n\n2\n3 5 2\n4 5\n\nSample Output 1\n\n9\n\nIf the heroes choose the monsters to defeat as follows, they can defeat nine monsters in total, which is the maximum result.\n\nThe first hero defeats two monsters attacking the first town and two monsters attacking the second town.\n\nThe second hero defeats three monsters attacking the second town and two monsters attacking the third town.\n\nSample Input 2\n\n3\n5 6 3 8\n5 100 8\n\nSample Output 2\n\n22\n\nSample Input 3\n\n2\n100 1 1\n1 100\n\nSample Output 3\n\n3", "sample_input": "2\n3 5 2\n4 5\n"}, "reference_outputs": ["9\n"], "source_document_id": "p02959", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere are N+1 towns. The i-th town is being attacked by A_i monsters.\n\nWe have N heroes. The i-th hero can defeat monsters attacking the i-th or (i+1)-th town, for a total of at most B_i monsters.\n\nWhat is the maximum total number of monsters the heroes can cooperate to defeat?\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^5\n\n1 \\leq A_i \\leq 10^9\n\n1 \\leq B_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_{N+1}\nB_1 B_2 ... B_N\n\nOutput\n\nPrint the maximum total number of monsters the heroes can defeat.\n\nSample Input 1\n\n2\n3 5 2\n4 5\n\nSample Output 1\n\n9\n\nIf the heroes choose the monsters to defeat as follows, they can defeat nine monsters in total, which is the maximum result.\n\nThe first hero defeats two monsters attacking the first town and two monsters attacking the second town.\n\nThe second hero defeats three monsters attacking the second town and two monsters attacking the third town.\n\nSample Input 2\n\n3\n5 6 3 8\n5 100 8\n\nSample Output 2\n\n22\n\nSample Input 3\n\n2\n100 1 1\n1 100\n\nSample Output 3\n\n3", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 315, "cpu_time_ms": 72, "memory_kb": 2304}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s963135297", "group_id": "codeNet:p02959", "input_text": "n=io.read(\"*n\")\na={}\nb={}\n\nfor i=1,n+1 do\n table.insert(a,io.read(\"*n\"))\nend\n\nfor i=1,n do\n table.insert(b,io.read(\"*n\"))\nend\n\nans=0\nfor i=1,n do\n local s=math.min(a[i], b[i])\n ans=ans+s\n a[i]=a[i]-s\n b[i]=b[i]-s\n if b[i]>0 then\n local s2=math.min(a[i+1], b[i])\n ans=ans+s2\n a[i+1]=a[i+1]-s\n b[i]=b[i]-s2\n end\nend\n\nprint(ans)", "language": "Lua", "metadata": {"date": 1572984168, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p02959.html", "problem_id": "p02959", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02959/input.txt", "sample_output_relpath": "derived/input_output/data/p02959/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02959/Lua/s963135297.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s963135297", "user_id": "u535423069"}, "prompt_components": {"gold_output": "9\n", "input_to_evaluate": "n=io.read(\"*n\")\na={}\nb={}\n\nfor i=1,n+1 do\n table.insert(a,io.read(\"*n\"))\nend\n\nfor i=1,n do\n table.insert(b,io.read(\"*n\"))\nend\n\nans=0\nfor i=1,n do\n local s=math.min(a[i], b[i])\n ans=ans+s\n a[i]=a[i]-s\n b[i]=b[i]-s\n if b[i]>0 then\n local s2=math.min(a[i+1], b[i])\n ans=ans+s2\n a[i+1]=a[i+1]-s\n b[i]=b[i]-s2\n end\nend\n\nprint(ans)", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere are N+1 towns. The i-th town is being attacked by A_i monsters.\n\nWe have N heroes. The i-th hero can defeat monsters attacking the i-th or (i+1)-th town, for a total of at most B_i monsters.\n\nWhat is the maximum total number of monsters the heroes can cooperate to defeat?\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^5\n\n1 \\leq A_i \\leq 10^9\n\n1 \\leq B_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_{N+1}\nB_1 B_2 ... B_N\n\nOutput\n\nPrint the maximum total number of monsters the heroes can defeat.\n\nSample Input 1\n\n2\n3 5 2\n4 5\n\nSample Output 1\n\n9\n\nIf the heroes choose the monsters to defeat as follows, they can defeat nine monsters in total, which is the maximum result.\n\nThe first hero defeats two monsters attacking the first town and two monsters attacking the second town.\n\nThe second hero defeats three monsters attacking the second town and two monsters attacking the third town.\n\nSample Input 2\n\n3\n5 6 3 8\n5 100 8\n\nSample Output 2\n\n22\n\nSample Input 3\n\n2\n100 1 1\n1 100\n\nSample Output 3\n\n3", "sample_input": "2\n3 5 2\n4 5\n"}, "reference_outputs": ["9\n"], "source_document_id": "p02959", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere are N+1 towns. The i-th town is being attacked by A_i monsters.\n\nWe have N heroes. The i-th hero can defeat monsters attacking the i-th or (i+1)-th town, for a total of at most B_i monsters.\n\nWhat is the maximum total number of monsters the heroes can cooperate to defeat?\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^5\n\n1 \\leq A_i \\leq 10^9\n\n1 \\leq B_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_{N+1}\nB_1 B_2 ... B_N\n\nOutput\n\nPrint the maximum total number of monsters the heroes can defeat.\n\nSample Input 1\n\n2\n3 5 2\n4 5\n\nSample Output 1\n\n9\n\nIf the heroes choose the monsters to defeat as follows, they can defeat nine monsters in total, which is the maximum result.\n\nThe first hero defeats two monsters attacking the first town and two monsters attacking the second town.\n\nThe second hero defeats three monsters attacking the second town and two monsters attacking the third town.\n\nSample Input 2\n\n3\n5 6 3 8\n5 100 8\n\nSample Output 2\n\n22\n\nSample Input 3\n\n2\n100 1 1\n1 100\n\nSample Output 3\n\n3", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 345, "cpu_time_ms": 76, "memory_kb": 2304}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s783809595", "group_id": "codeNet:p02960", "input_text": "local read = setmetatable({}, {__index = function(t, k) local a = {} for i=1,#k do table.insert(a, '*'..string.sub(k, i, i)) end local r = io.read local u = table.unpack or unpack return function() return r(u(a)) end end})\nread.N = function(N) local t={} for i=1,N do t[i]=read.n() end return t end\nstring.totable = function(s) local t={} local u=string.sub for i=1,#s do t[i] = u(s, i, i) end return t end\nstring.split = function(s) local t={} for w in string.gmatch(s, \"[^%s]+\") do table.insert(t, w) end return (table.unpack or unpack)(t) end\nlocal function array(dimension, default_val) local n=dimension local m={}if default_val~=nil then m[1]={__index=function()return default_val end}end for i=2,n do m[i]={__index=function(p, k)local c=setmetatable({},m[i-1])rawset(p,k,c)return c end}end return setmetatable({},m[n])end\n----\nlocal MOD = math.floor(10^9)+7\n\nlocal tmp = read.l():totable()\nlocal S = {}\nlocal numflag = false\nfor i=1,#tmp do\n if tmp[i] == '?' then\n S[i] = '?'\n else\n S[i] = tonumber(tmp[i])\n numflag = true\n end\nend\nif not numflag then\n print(765928472)\n return\nend\nlocal N = #S\nlocal tbl = array(2, 0)\ntbl[0][0] = 1\nfor i=1,N do\n if S[i] == '?' then\n for nd=0,9 do\n for oldm=0,12 do\n local newm = (oldm * 10 + nd) % 13\n tbl[i][newm] = (tbl[i][newm] + tbl[i-1][oldm]) % MOD\n end\n end\n else\n for oldm=0,12 do\n local newm = (oldm * 10 + S[i]) % 13\n tbl[i][newm] = tbl[i-1][oldm]\n end\n end\nend\nprint(tbl[N][5])", "language": "Lua", "metadata": {"date": 1582550563, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p02960.html", "problem_id": "p02960", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02960/input.txt", "sample_output_relpath": "derived/input_output/data/p02960/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02960/Lua/s783809595.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s783809595", "user_id": "u162773977"}, "prompt_components": {"gold_output": "768\n", "input_to_evaluate": "local read = setmetatable({}, {__index = function(t, k) local a = {} for i=1,#k do table.insert(a, '*'..string.sub(k, i, i)) end local r = io.read local u = table.unpack or unpack return function() return r(u(a)) end end})\nread.N = function(N) local t={} for i=1,N do t[i]=read.n() end return t end\nstring.totable = function(s) local t={} local u=string.sub for i=1,#s do t[i] = u(s, i, i) end return t end\nstring.split = function(s) local t={} for w in string.gmatch(s, \"[^%s]+\") do table.insert(t, w) end return (table.unpack or unpack)(t) end\nlocal function array(dimension, default_val) local n=dimension local m={}if default_val~=nil then m[1]={__index=function()return default_val end}end for i=2,n do m[i]={__index=function(p, k)local c=setmetatable({},m[i-1])rawset(p,k,c)return c end}end return setmetatable({},m[n])end\n----\nlocal MOD = math.floor(10^9)+7\n\nlocal tmp = read.l():totable()\nlocal S = {}\nlocal numflag = false\nfor i=1,#tmp do\n if tmp[i] == '?' then\n S[i] = '?'\n else\n S[i] = tonumber(tmp[i])\n numflag = true\n end\nend\nif not numflag then\n print(765928472)\n return\nend\nlocal N = #S\nlocal tbl = array(2, 0)\ntbl[0][0] = 1\nfor i=1,N do\n if S[i] == '?' then\n for nd=0,9 do\n for oldm=0,12 do\n local newm = (oldm * 10 + nd) % 13\n tbl[i][newm] = (tbl[i][newm] + tbl[i-1][oldm]) % MOD\n end\n end\n else\n for oldm=0,12 do\n local newm = (oldm * 10 + S[i]) % 13\n tbl[i][newm] = tbl[i-1][oldm]\n end\n end\nend\nprint(tbl[N][5])", "problem_context": "Score : 400 points\n\nProblem Statement\n\nGiven is a string S. Each character in S is either a digit (0, ..., 9) or ?.\n\nAmong the integers obtained by replacing each occurrence of ? with a digit, how many have a remainder of 5 when divided by 13? An integer may begin with 0.\n\nSince the answer can be enormous, print the count modulo 10^9+7.\n\nConstraints\n\nS is a string consisting of digits (0, ..., 9) and ?.\n\n1 \\leq |S| \\leq 10^5\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the number of integers satisfying the condition, modulo 10^9+7.\n\nSample Input 1\n\n??2??5\n\nSample Output 1\n\n768\n\nFor example, 482305, 002865, and 972665 satisfy the condition.\n\nSample Input 2\n\n?44\n\nSample Output 2\n\n1\n\nOnly 044 satisfies the condition.\n\nSample Input 3\n\n7?4\n\nSample Output 3\n\n0\n\nWe may not be able to produce an integer satisfying the condition.\n\nSample Input 4\n\n?6?42???8??2??06243????9??3???7258??5??7???????774????4?1??17???9?5?70???76???\n\nSample Output 4\n\n153716888", "sample_input": "??2??5\n"}, "reference_outputs": ["768\n"], "source_document_id": "p02960", "source_text": "Score : 400 points\n\nProblem Statement\n\nGiven is a string S. Each character in S is either a digit (0, ..., 9) or ?.\n\nAmong the integers obtained by replacing each occurrence of ? with a digit, how many have a remainder of 5 when divided by 13? An integer may begin with 0.\n\nSince the answer can be enormous, print the count modulo 10^9+7.\n\nConstraints\n\nS is a string consisting of digits (0, ..., 9) and ?.\n\n1 \\leq |S| \\leq 10^5\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the number of integers satisfying the condition, modulo 10^9+7.\n\nSample Input 1\n\n??2??5\n\nSample Output 1\n\n768\n\nFor example, 482305, 002865, and 972665 satisfy the condition.\n\nSample Input 2\n\n?44\n\nSample Output 2\n\n1\n\nOnly 044 satisfies the condition.\n\nSample Input 3\n\n7?4\n\nSample Output 3\n\n0\n\nWe may not be able to produce an integer satisfying the condition.\n\nSample Input 4\n\n?6?42???8??2??06243????9??3???7258??5??7???????774????4?1??17???9?5?70???76???\n\nSample Output 4\n\n153716888", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1577, "cpu_time_ms": 1849, "memory_kb": 45972}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s272561582", "group_id": "codeNet:p02962", "input_text": "local s = io.read()\nlocal t = io.read()\nlocal swapped = false\nif #s < #t then\n swapped = true\n s, t = t, s\nend\nlocal slen = #s\nlocal tlen = #t\ns = s .. s\n\nlocal mma = math.max\nlocal findpos = s:find(t, 1)\nlocal maxlength = 0\nwhile findpos do\n if slen < findpos then\n break\n end\n local curlength = 1\n while true do\n local p = findpos + tlen * curlength\n if p < findpos + slen and t == s:sub(p, p + tlen - 1) then\n curlength = curlength + 1\n else\n break\n end\n end\n maxlength = mma(maxlength, curlength)\n if slen % tlen == 0 and curlength == slen / tlen then\n maxlength = -1\n break\n end\n findpos = s:find(t, findpos + tlen * curlength)\nend\n\nlocal same_s, same_t = true, true\nfor i = 2, slen do if s:sub(1, 1) ~= s:sub(i, i) then same_s = false break end end\nfor i = 2, tlen do if t:sub(1, 1) ~= t:sub(i, i) then same_t = false break end end\nif same_s and same_t and s:sub(1, 1) == t:sub(1, 1) then\n maxlength = -1\nend\nif swapped then\n if 0 < maxlength then\n maxlength = 0\n end\nend\nprint(maxlength)\n", "language": "Lua", "metadata": {"date": 1564280095, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p02962.html", "problem_id": "p02962", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02962/input.txt", "sample_output_relpath": "derived/input_output/data/p02962/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02962/Lua/s272561582.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s272561582", "user_id": "u120582723"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "local s = io.read()\nlocal t = io.read()\nlocal swapped = false\nif #s < #t then\n swapped = true\n s, t = t, s\nend\nlocal slen = #s\nlocal tlen = #t\ns = s .. s\n\nlocal mma = math.max\nlocal findpos = s:find(t, 1)\nlocal maxlength = 0\nwhile findpos do\n if slen < findpos then\n break\n end\n local curlength = 1\n while true do\n local p = findpos + tlen * curlength\n if p < findpos + slen and t == s:sub(p, p + tlen - 1) then\n curlength = curlength + 1\n else\n break\n end\n end\n maxlength = mma(maxlength, curlength)\n if slen % tlen == 0 and curlength == slen / tlen then\n maxlength = -1\n break\n end\n findpos = s:find(t, findpos + tlen * curlength)\nend\n\nlocal same_s, same_t = true, true\nfor i = 2, slen do if s:sub(1, 1) ~= s:sub(i, i) then same_s = false break end end\nfor i = 2, tlen do if t:sub(1, 1) ~= t:sub(i, i) then same_t = false break end end\nif same_s and same_t and s:sub(1, 1) == t:sub(1, 1) then\n maxlength = -1\nend\nif swapped then\n if 0 < maxlength then\n maxlength = 0\n end\nend\nprint(maxlength)\n", "problem_context": "Score : 600 points\n\nProblem Statement\n\nGiven are two strings s and t consisting of lowercase English letters. Determine if the number of non-negative integers i satisfying the following condition is finite, and find the maximum value of such i if the number is finite.\n\nThere 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.\n\nNotes\n\nA string a is a substring of another string b if and only if there exists an integer x (0 \\leq x \\leq |b| - |a|) such that, for any y (1 \\leq y \\leq |a|), a_y = b_{x+y} holds.\n\nWe assume that the concatenation of zero copies of any string is the empty string. From the definition above, the empty string is a substring of any string. Thus, for any two strings s and t, i = 0 satisfies the condition in the problem statement.\n\nConstraints\n\n1 \\leq |s| \\leq 5 \\times 10^5\n\n1 \\leq |t| \\leq 5 \\times 10^5\n\ns and t consist of lowercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\ns\nt\n\nOutput\n\nIf the number of non-negative integers i satisfying the following condition is finite, print the maximum value of such i; if the number is infinite, print -1.\n\nSample Input 1\n\nabcabab\nab\n\nSample Output 1\n\n3\n\nThe concatenation of three copies of t, ababab, is a substring of the concatenation of two copies of s, abcabababcabab, so i = 3 satisfies the condition.\n\nOn the other hand, the concatenation of four copies of t, abababab, is not a substring of the concatenation of any number of copies of s, so i = 4 does not satisfy the condition.\n\nSimilarly, any integer greater than 4 does not satisfy the condition, either. Thus, the number of non-negative integers i satisfying the condition is finite, and the maximum value of such i is 3.\n\nSample Input 2\n\naa\naaaaaaa\n\nSample Output 2\n\n-1\n\nFor any non-negative integer i, the concatenation of i copies of t is a substring of the concatenation of 4i copies of s. Thus, there are infinitely many non-negative integers i that satisfy the condition.\n\nSample Input 3\n\naba\nbaaab\n\nSample Output 3\n\n0\n\nAs stated in Notes, i = 0 always satisfies the condition.", "sample_input": "abcabab\nab\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02962", "source_text": "Score : 600 points\n\nProblem Statement\n\nGiven are two strings s and t consisting of lowercase English letters. Determine if the number of non-negative integers i satisfying the following condition is finite, and find the maximum value of such i if the number is finite.\n\nThere 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.\n\nNotes\n\nA string a is a substring of another string b if and only if there exists an integer x (0 \\leq x \\leq |b| - |a|) such that, for any y (1 \\leq y \\leq |a|), a_y = b_{x+y} holds.\n\nWe assume that the concatenation of zero copies of any string is the empty string. From the definition above, the empty string is a substring of any string. Thus, for any two strings s and t, i = 0 satisfies the condition in the problem statement.\n\nConstraints\n\n1 \\leq |s| \\leq 5 \\times 10^5\n\n1 \\leq |t| \\leq 5 \\times 10^5\n\ns and t consist of lowercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\ns\nt\n\nOutput\n\nIf the number of non-negative integers i satisfying the following condition is finite, print the maximum value of such i; if the number is infinite, print -1.\n\nSample Input 1\n\nabcabab\nab\n\nSample Output 1\n\n3\n\nThe concatenation of three copies of t, ababab, is a substring of the concatenation of two copies of s, abcabababcabab, so i = 3 satisfies the condition.\n\nOn the other hand, the concatenation of four copies of t, abababab, is not a substring of the concatenation of any number of copies of s, so i = 4 does not satisfy the condition.\n\nSimilarly, any integer greater than 4 does not satisfy the condition, either. Thus, the number of non-negative integers i satisfying the condition is finite, and the maximum value of such i is 3.\n\nSample Input 2\n\naa\naaaaaaa\n\nSample Output 2\n\n-1\n\nFor any non-negative integer i, the concatenation of i copies of t is a substring of the concatenation of 4i copies of s. Thus, there are infinitely many non-negative integers i that satisfy the condition.\n\nSample Input 3\n\naba\nbaaab\n\nSample Output 3\n\n0\n\nAs stated in Notes, i = 0 always satisfies the condition.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1043, "cpu_time_ms": 2103, "memory_kb": 3728}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s531066682", "group_id": "codeNet:p02962", "input_text": "local s = io.read()\nlocal t = io.read()\nif #s < #t then\n s, t = t, s\nend\nlocal slen = #s\nlocal tlen = #t\ns = s .. s\n\nlocal mma = math.max\nlocal findpos = s:find(t, 1)\nlocal maxlength = 0\nwhile findpos do\n if slen < findpos then\n break\n end\n local curlength = 1\n while true do\n local p = findpos + tlen * curlength\n if p < findpos + slen and t == s:sub(p, p + tlen - 1) then\n curlength = curlength + 1\n else\n break\n end\n end\n maxlength = mma(maxlength, curlength)\n if slen % tlen == 0 and curlength == slen / tlen then\n maxlength = -1\n break\n end\n findpos = s:find(t, findpos + tlen * curlength)\nend\n\nlocal same_s, same_t = true, true\nfor i = 2, slen do if s:sub(1, 1) ~= s:sub(i, i) then same_s = false break end end\nfor i = 2, tlen do if t:sub(1, 1) ~= t:sub(i, i) then same_t = false break end end\nif same_s and same_t and s:sub(1, 1) == t:sub(1, 1) then\n maxlength = -1\nend\nprint(maxlength)\n", "language": "Lua", "metadata": {"date": 1564279781, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p02962.html", "problem_id": "p02962", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02962/input.txt", "sample_output_relpath": "derived/input_output/data/p02962/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02962/Lua/s531066682.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s531066682", "user_id": "u120582723"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "local s = io.read()\nlocal t = io.read()\nif #s < #t then\n s, t = t, s\nend\nlocal slen = #s\nlocal tlen = #t\ns = s .. s\n\nlocal mma = math.max\nlocal findpos = s:find(t, 1)\nlocal maxlength = 0\nwhile findpos do\n if slen < findpos then\n break\n end\n local curlength = 1\n while true do\n local p = findpos + tlen * curlength\n if p < findpos + slen and t == s:sub(p, p + tlen - 1) then\n curlength = curlength + 1\n else\n break\n end\n end\n maxlength = mma(maxlength, curlength)\n if slen % tlen == 0 and curlength == slen / tlen then\n maxlength = -1\n break\n end\n findpos = s:find(t, findpos + tlen * curlength)\nend\n\nlocal same_s, same_t = true, true\nfor i = 2, slen do if s:sub(1, 1) ~= s:sub(i, i) then same_s = false break end end\nfor i = 2, tlen do if t:sub(1, 1) ~= t:sub(i, i) then same_t = false break end end\nif same_s and same_t and s:sub(1, 1) == t:sub(1, 1) then\n maxlength = -1\nend\nprint(maxlength)\n", "problem_context": "Score : 600 points\n\nProblem Statement\n\nGiven are two strings s and t consisting of lowercase English letters. Determine if the number of non-negative integers i satisfying the following condition is finite, and find the maximum value of such i if the number is finite.\n\nThere 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.\n\nNotes\n\nA string a is a substring of another string b if and only if there exists an integer x (0 \\leq x \\leq |b| - |a|) such that, for any y (1 \\leq y \\leq |a|), a_y = b_{x+y} holds.\n\nWe assume that the concatenation of zero copies of any string is the empty string. From the definition above, the empty string is a substring of any string. Thus, for any two strings s and t, i = 0 satisfies the condition in the problem statement.\n\nConstraints\n\n1 \\leq |s| \\leq 5 \\times 10^5\n\n1 \\leq |t| \\leq 5 \\times 10^5\n\ns and t consist of lowercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\ns\nt\n\nOutput\n\nIf the number of non-negative integers i satisfying the following condition is finite, print the maximum value of such i; if the number is infinite, print -1.\n\nSample Input 1\n\nabcabab\nab\n\nSample Output 1\n\n3\n\nThe concatenation of three copies of t, ababab, is a substring of the concatenation of two copies of s, abcabababcabab, so i = 3 satisfies the condition.\n\nOn the other hand, the concatenation of four copies of t, abababab, is not a substring of the concatenation of any number of copies of s, so i = 4 does not satisfy the condition.\n\nSimilarly, any integer greater than 4 does not satisfy the condition, either. Thus, the number of non-negative integers i satisfying the condition is finite, and the maximum value of such i is 3.\n\nSample Input 2\n\naa\naaaaaaa\n\nSample Output 2\n\n-1\n\nFor any non-negative integer i, the concatenation of i copies of t is a substring of the concatenation of 4i copies of s. Thus, there are infinitely many non-negative integers i that satisfy the condition.\n\nSample Input 3\n\naba\nbaaab\n\nSample Output 3\n\n0\n\nAs stated in Notes, i = 0 always satisfies the condition.", "sample_input": "abcabab\nab\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02962", "source_text": "Score : 600 points\n\nProblem Statement\n\nGiven are two strings s and t consisting of lowercase English letters. Determine if the number of non-negative integers i satisfying the following condition is finite, and find the maximum value of such i if the number is finite.\n\nThere 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.\n\nNotes\n\nA string a is a substring of another string b if and only if there exists an integer x (0 \\leq x \\leq |b| - |a|) such that, for any y (1 \\leq y \\leq |a|), a_y = b_{x+y} holds.\n\nWe assume that the concatenation of zero copies of any string is the empty string. From the definition above, the empty string is a substring of any string. Thus, for any two strings s and t, i = 0 satisfies the condition in the problem statement.\n\nConstraints\n\n1 \\leq |s| \\leq 5 \\times 10^5\n\n1 \\leq |t| \\leq 5 \\times 10^5\n\ns and t consist of lowercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\ns\nt\n\nOutput\n\nIf the number of non-negative integers i satisfying the following condition is finite, print the maximum value of such i; if the number is infinite, print -1.\n\nSample Input 1\n\nabcabab\nab\n\nSample Output 1\n\n3\n\nThe concatenation of three copies of t, ababab, is a substring of the concatenation of two copies of s, abcabababcabab, so i = 3 satisfies the condition.\n\nOn the other hand, the concatenation of four copies of t, abababab, is not a substring of the concatenation of any number of copies of s, so i = 4 does not satisfy the condition.\n\nSimilarly, any integer greater than 4 does not satisfy the condition, either. Thus, the number of non-negative integers i satisfying the condition is finite, and the maximum value of such i is 3.\n\nSample Input 2\n\naa\naaaaaaa\n\nSample Output 2\n\n-1\n\nFor any non-negative integer i, the concatenation of i copies of t is a substring of the concatenation of 4i copies of s. Thus, there are infinitely many non-negative integers i that satisfy the condition.\n\nSample Input 3\n\naba\nbaaab\n\nSample Output 3\n\n0\n\nAs stated in Notes, i = 0 always satisfies the condition.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 936, "cpu_time_ms": 2103, "memory_kb": 3728}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s551171058", "group_id": "codeNet:p02962", "input_text": "local s = io.read()\nlocal t = io.read()\nif #s < #t then\n s, t = t, s\nend\nlocal slen = #s\nlocal tlen = #t\ns = s .. s\n\nlocal mma = math.max\nlocal findpos = s:find(t, 1)\nlocal maxlength = 0\nwhile findpos do\n if slen < findpos then\n break\n end\n local curlength = 1\n while true do\n local p = findpos + tlen * curlength\n if p < findpos + slen and t == s:sub(p, p + tlen - 1) then\n curlength = curlength + 1\n else\n break\n end\n end\n maxlength = mma(maxlength, curlength)\n if slen <= curlength * tlen then\n maxlength = -1\n break\n end\n findpos = s:find(t, findpos + tlen)\nend\nprint(maxlength)\n", "language": "Lua", "metadata": {"date": 1564279523, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p02962.html", "problem_id": "p02962", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02962/input.txt", "sample_output_relpath": "derived/input_output/data/p02962/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02962/Lua/s551171058.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s551171058", "user_id": "u120582723"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "local s = io.read()\nlocal t = io.read()\nif #s < #t then\n s, t = t, s\nend\nlocal slen = #s\nlocal tlen = #t\ns = s .. s\n\nlocal mma = math.max\nlocal findpos = s:find(t, 1)\nlocal maxlength = 0\nwhile findpos do\n if slen < findpos then\n break\n end\n local curlength = 1\n while true do\n local p = findpos + tlen * curlength\n if p < findpos + slen and t == s:sub(p, p + tlen - 1) then\n curlength = curlength + 1\n else\n break\n end\n end\n maxlength = mma(maxlength, curlength)\n if slen <= curlength * tlen then\n maxlength = -1\n break\n end\n findpos = s:find(t, findpos + tlen)\nend\nprint(maxlength)\n", "problem_context": "Score : 600 points\n\nProblem Statement\n\nGiven are two strings s and t consisting of lowercase English letters. Determine if the number of non-negative integers i satisfying the following condition is finite, and find the maximum value of such i if the number is finite.\n\nThere 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.\n\nNotes\n\nA string a is a substring of another string b if and only if there exists an integer x (0 \\leq x \\leq |b| - |a|) such that, for any y (1 \\leq y \\leq |a|), a_y = b_{x+y} holds.\n\nWe assume that the concatenation of zero copies of any string is the empty string. From the definition above, the empty string is a substring of any string. Thus, for any two strings s and t, i = 0 satisfies the condition in the problem statement.\n\nConstraints\n\n1 \\leq |s| \\leq 5 \\times 10^5\n\n1 \\leq |t| \\leq 5 \\times 10^5\n\ns and t consist of lowercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\ns\nt\n\nOutput\n\nIf the number of non-negative integers i satisfying the following condition is finite, print the maximum value of such i; if the number is infinite, print -1.\n\nSample Input 1\n\nabcabab\nab\n\nSample Output 1\n\n3\n\nThe concatenation of three copies of t, ababab, is a substring of the concatenation of two copies of s, abcabababcabab, so i = 3 satisfies the condition.\n\nOn the other hand, the concatenation of four copies of t, abababab, is not a substring of the concatenation of any number of copies of s, so i = 4 does not satisfy the condition.\n\nSimilarly, any integer greater than 4 does not satisfy the condition, either. Thus, the number of non-negative integers i satisfying the condition is finite, and the maximum value of such i is 3.\n\nSample Input 2\n\naa\naaaaaaa\n\nSample Output 2\n\n-1\n\nFor any non-negative integer i, the concatenation of i copies of t is a substring of the concatenation of 4i copies of s. Thus, there are infinitely many non-negative integers i that satisfy the condition.\n\nSample Input 3\n\naba\nbaaab\n\nSample Output 3\n\n0\n\nAs stated in Notes, i = 0 always satisfies the condition.", "sample_input": "abcabab\nab\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02962", "source_text": "Score : 600 points\n\nProblem Statement\n\nGiven are two strings s and t consisting of lowercase English letters. Determine if the number of non-negative integers i satisfying the following condition is finite, and find the maximum value of such i if the number is finite.\n\nThere 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.\n\nNotes\n\nA string a is a substring of another string b if and only if there exists an integer x (0 \\leq x \\leq |b| - |a|) such that, for any y (1 \\leq y \\leq |a|), a_y = b_{x+y} holds.\n\nWe assume that the concatenation of zero copies of any string is the empty string. From the definition above, the empty string is a substring of any string. Thus, for any two strings s and t, i = 0 satisfies the condition in the problem statement.\n\nConstraints\n\n1 \\leq |s| \\leq 5 \\times 10^5\n\n1 \\leq |t| \\leq 5 \\times 10^5\n\ns and t consist of lowercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\ns\nt\n\nOutput\n\nIf the number of non-negative integers i satisfying the following condition is finite, print the maximum value of such i; if the number is infinite, print -1.\n\nSample Input 1\n\nabcabab\nab\n\nSample Output 1\n\n3\n\nThe concatenation of three copies of t, ababab, is a substring of the concatenation of two copies of s, abcabababcabab, so i = 3 satisfies the condition.\n\nOn the other hand, the concatenation of four copies of t, abababab, is not a substring of the concatenation of any number of copies of s, so i = 4 does not satisfy the condition.\n\nSimilarly, any integer greater than 4 does not satisfy the condition, either. Thus, the number of non-negative integers i satisfying the condition is finite, and the maximum value of such i is 3.\n\nSample Input 2\n\naa\naaaaaaa\n\nSample Output 2\n\n-1\n\nFor any non-negative integer i, the concatenation of i copies of t is a substring of the concatenation of 4i copies of s. Thus, there are infinitely many non-negative integers i that satisfy the condition.\n\nSample Input 3\n\naba\nbaaab\n\nSample Output 3\n\n0\n\nAs stated in Notes, i = 0 always satisfies the condition.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 624, "cpu_time_ms": 2103, "memory_kb": 3712}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s724297302", "group_id": "codeNet:p02963", "input_text": "local s=io.read(\"n\")\nlocal mod=1000000000\nlocal x=(mod-s%mod)%mod\nlocal y=(s+x)//mod\nprint(0,0,1000000000,1,x,y)", "language": "Lua", "metadata": {"date": 1592198659, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p02963.html", "problem_id": "p02963", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02963/input.txt", "sample_output_relpath": "derived/input_output/data/p02963/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02963/Lua/s724297302.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s724297302", "user_id": "u045238009"}, "prompt_components": {"gold_output": "1 0 2 2 0 1\n", "input_to_evaluate": "local s=io.read(\"n\")\nlocal mod=1000000000\nlocal x=(mod-s%mod)%mod\nlocal y=(s+x)//mod\nprint(0,0,1000000000,1,x,y)", "problem_context": "Score : 400 points\n\nProblem Statement\n\nGiven is an integer S.\nFind a combination of six integers X_1,Y_1,X_2,Y_2,X_3, and Y_3 that satisfies all of the following conditions:\n\n0 \\leq X_1,Y_1,X_2,Y_2,X_3,Y_3 \\leq 10^9\n\nThe area of the triangle in a two-dimensional plane whose vertices are (X_1,Y_1),(X_2,Y_2), and (X_3,Y_3) is S/2.\n\nWe can prove that there always exist six integers that satisfy the conditions under the constraints of this problem.\n\nConstraints\n\n1 \\leq S \\leq 10^{18}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint six integers X_1,Y_1,X_2,Y_2,X_3, and Y_3 that satisfy the conditions, in this order, with spaces in between.\nIf multiple solutions exist, any of them will be accepted.\n\nSample Input 1\n\n3\n\nSample Output 1\n\n1 0 2 2 0 1\n\nThe area of the triangle in a two-dimensional plane whose vertices are (1,0),(2,2), and (0,1) is 3/2.\nPrinting 3 0 3 1 0 1 or 1 0 0 1 2 2 will also be accepted.\n\nSample Input 2\n\n100\n\nSample Output 2\n\n0 0 10 0 0 10\n\nSample Input 3\n\n311114770564041497\n\nSample Output 3\n\n314159265 358979323 846264338 327950288 419716939 937510582", "sample_input": "3\n"}, "reference_outputs": ["1 0 2 2 0 1\n"], "source_document_id": "p02963", "source_text": "Score : 400 points\n\nProblem Statement\n\nGiven is an integer S.\nFind a combination of six integers X_1,Y_1,X_2,Y_2,X_3, and Y_3 that satisfies all of the following conditions:\n\n0 \\leq X_1,Y_1,X_2,Y_2,X_3,Y_3 \\leq 10^9\n\nThe area of the triangle in a two-dimensional plane whose vertices are (X_1,Y_1),(X_2,Y_2), and (X_3,Y_3) is S/2.\n\nWe can prove that there always exist six integers that satisfy the conditions under the constraints of this problem.\n\nConstraints\n\n1 \\leq S \\leq 10^{18}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint six integers X_1,Y_1,X_2,Y_2,X_3, and Y_3 that satisfy the conditions, in this order, with spaces in between.\nIf multiple solutions exist, any of them will be accepted.\n\nSample Input 1\n\n3\n\nSample Output 1\n\n1 0 2 2 0 1\n\nThe area of the triangle in a two-dimensional plane whose vertices are (1,0),(2,2), and (0,1) is 3/2.\nPrinting 3 0 3 1 0 1 or 1 0 0 1 2 2 will also be accepted.\n\nSample Input 2\n\n100\n\nSample Output 2\n\n0 0 10 0 0 10\n\nSample Input 3\n\n311114770564041497\n\nSample Output 3\n\n314159265 358979323 846264338 327950288 419716939 937510582", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 112, "cpu_time_ms": 7, "memory_kb": 760}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s845170320", "group_id": "codeNet:p02963", "input_text": "local s=io.read(\"n\")\nlocal h=1\nlocal w=s\n\nfor i=2,math.sqrt(math.sqrt(s)) do\n if w%i==0 then\n while w%i==0 do\n w=w//i\n h=h*i\n end\n end\nend\nprint(0,0,0,h,w,0)", "language": "Lua", "metadata": {"date": 1592197408, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p02963.html", "problem_id": "p02963", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02963/input.txt", "sample_output_relpath": "derived/input_output/data/p02963/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02963/Lua/s845170320.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s845170320", "user_id": "u045238009"}, "prompt_components": {"gold_output": "1 0 2 2 0 1\n", "input_to_evaluate": "local s=io.read(\"n\")\nlocal h=1\nlocal w=s\n\nfor i=2,math.sqrt(math.sqrt(s)) do\n if w%i==0 then\n while w%i==0 do\n w=w//i\n h=h*i\n end\n end\nend\nprint(0,0,0,h,w,0)", "problem_context": "Score : 400 points\n\nProblem Statement\n\nGiven is an integer S.\nFind a combination of six integers X_1,Y_1,X_2,Y_2,X_3, and Y_3 that satisfies all of the following conditions:\n\n0 \\leq X_1,Y_1,X_2,Y_2,X_3,Y_3 \\leq 10^9\n\nThe area of the triangle in a two-dimensional plane whose vertices are (X_1,Y_1),(X_2,Y_2), and (X_3,Y_3) is S/2.\n\nWe can prove that there always exist six integers that satisfy the conditions under the constraints of this problem.\n\nConstraints\n\n1 \\leq S \\leq 10^{18}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint six integers X_1,Y_1,X_2,Y_2,X_3, and Y_3 that satisfy the conditions, in this order, with spaces in between.\nIf multiple solutions exist, any of them will be accepted.\n\nSample Input 1\n\n3\n\nSample Output 1\n\n1 0 2 2 0 1\n\nThe area of the triangle in a two-dimensional plane whose vertices are (1,0),(2,2), and (0,1) is 3/2.\nPrinting 3 0 3 1 0 1 or 1 0 0 1 2 2 will also be accepted.\n\nSample Input 2\n\n100\n\nSample Output 2\n\n0 0 10 0 0 10\n\nSample Input 3\n\n311114770564041497\n\nSample Output 3\n\n314159265 358979323 846264338 327950288 419716939 937510582", "sample_input": "3\n"}, "reference_outputs": ["1 0 2 2 0 1\n"], "source_document_id": "p02963", "source_text": "Score : 400 points\n\nProblem Statement\n\nGiven is an integer S.\nFind a combination of six integers X_1,Y_1,X_2,Y_2,X_3, and Y_3 that satisfies all of the following conditions:\n\n0 \\leq X_1,Y_1,X_2,Y_2,X_3,Y_3 \\leq 10^9\n\nThe area of the triangle in a two-dimensional plane whose vertices are (X_1,Y_1),(X_2,Y_2), and (X_3,Y_3) is S/2.\n\nWe can prove that there always exist six integers that satisfy the conditions under the constraints of this problem.\n\nConstraints\n\n1 \\leq S \\leq 10^{18}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint six integers X_1,Y_1,X_2,Y_2,X_3, and Y_3 that satisfy the conditions, in this order, with spaces in between.\nIf multiple solutions exist, any of them will be accepted.\n\nSample Input 1\n\n3\n\nSample Output 1\n\n1 0 2 2 0 1\n\nThe area of the triangle in a two-dimensional plane whose vertices are (1,0),(2,2), and (0,1) is 3/2.\nPrinting 3 0 3 1 0 1 or 1 0 0 1 2 2 will also be accepted.\n\nSample Input 2\n\n100\n\nSample Output 2\n\n0 0 10 0 0 10\n\nSample Input 3\n\n311114770564041497\n\nSample Output 3\n\n314159265 358979323 846264338 327950288 419716939 937510582", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 199, "cpu_time_ms": 7, "memory_kb": 760}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s775900191", "group_id": "codeNet:p02969", "input_text": "r=io.read(\"n\")\nprint(r*r*3)", "language": "Lua", "metadata": {"date": 1579314855, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p02969.html", "problem_id": "p02969", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02969/input.txt", "sample_output_relpath": "derived/input_output/data/p02969/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02969/Lua/s775900191.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s775900191", "user_id": "u720483676"}, "prompt_components": {"gold_output": "48\n", "input_to_evaluate": "r=io.read(\"n\")\nprint(r*r*3)", "problem_context": "Score : 100 points\n\nProblem Statement\n\nIt is known that the area of a regular dodecagon inscribed in a circle of radius a is 3a^2.\n\nGiven an integer r, find the area of a regular dodecagon inscribed in a circle of radius r.\n\nConstraints\n\n1 \\leq r \\leq 100\n\nr is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nr\n\nOutput\n\nPrint an integer representing the area of the regular dodecagon.\n\nSample Input 1\n\n4\n\nSample Output 1\n\n48\n\nThe area of the regular dodecagon is 3 \\times 4^2 = 48.\n\nSample Input 2\n\n15\n\nSample Output 2\n\n675\n\nSample Input 3\n\n80\n\nSample Output 3\n\n19200", "sample_input": "4\n"}, "reference_outputs": ["48\n"], "source_document_id": "p02969", "source_text": "Score : 100 points\n\nProblem Statement\n\nIt is known that the area of a regular dodecagon inscribed in a circle of radius a is 3a^2.\n\nGiven an integer r, find the area of a regular dodecagon inscribed in a circle of radius r.\n\nConstraints\n\n1 \\leq r \\leq 100\n\nr is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nr\n\nOutput\n\nPrint an integer representing the area of the regular dodecagon.\n\nSample Input 1\n\n4\n\nSample Output 1\n\n48\n\nThe area of the regular dodecagon is 3 \\times 4^2 = 48.\n\nSample Input 2\n\n15\n\nSample Output 2\n\n675\n\nSample Input 3\n\n80\n\nSample Output 3\n\n19200", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 27, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s603371347", "group_id": "codeNet:p02970", "input_text": "local mce, mfl, msq, mmi, mma = math.ceil, math.floor, math.sqrt, math.min, math.max\nlocal n, d = io.read(\"*n\", \"*n\")\nprint(mce(n / (d * 2 + 1)))\n", "language": "Lua", "metadata": {"date": 1563670945, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p02970.html", "problem_id": "p02970", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02970/input.txt", "sample_output_relpath": "derived/input_output/data/p02970/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02970/Lua/s603371347.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s603371347", "user_id": "u120582723"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "local mce, mfl, msq, mmi, mma = math.ceil, math.floor, math.sqrt, math.min, math.max\nlocal n, d = io.read(\"*n\", \"*n\")\nprint(mce(n / (d * 2 + 1)))\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nThere are N apple trees in a row. People say that one of them will bear golden apples.\n\nWe want to deploy some number of inspectors so that each of these trees will be inspected.\n\nEach inspector will be deployed under one of the trees. For convenience, we will assign numbers from 1 through N to the trees. An inspector deployed under the i-th tree (1 \\leq i \\leq N) will inspect the trees with numbers between i-D and i+D (inclusive).\n\nFind the minimum number of inspectors that we need to deploy to achieve the objective.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 20\n\n1 \\leq D \\leq 20\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN D\n\nOutput\n\nPrint the minimum number of inspectors that we need to deploy to achieve the objective.\n\nSample Input 1\n\n6 2\n\nSample Output 1\n\n2\n\nWe can achieve the objective by, for example, placing an inspector under Tree 3 and Tree 4.\n\nSample Input 2\n\n14 3\n\nSample Output 2\n\n2\n\nSample Input 3\n\n20 4\n\nSample Output 3\n\n3", "sample_input": "6 2\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02970", "source_text": "Score : 200 points\n\nProblem Statement\n\nThere are N apple trees in a row. People say that one of them will bear golden apples.\n\nWe want to deploy some number of inspectors so that each of these trees will be inspected.\n\nEach inspector will be deployed under one of the trees. For convenience, we will assign numbers from 1 through N to the trees. An inspector deployed under the i-th tree (1 \\leq i \\leq N) will inspect the trees with numbers between i-D and i+D (inclusive).\n\nFind the minimum number of inspectors that we need to deploy to achieve the objective.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 20\n\n1 \\leq D \\leq 20\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN D\n\nOutput\n\nPrint the minimum number of inspectors that we need to deploy to achieve the objective.\n\nSample Input 1\n\n6 2\n\nSample Output 1\n\n2\n\nWe can achieve the objective by, for example, placing an inspector under Tree 3 and Tree 4.\n\nSample Input 2\n\n14 3\n\nSample Output 2\n\n2\n\nSample Input 3\n\n20 4\n\nSample Output 3\n\n3", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 146, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s338884212", "group_id": "codeNet:p02971", "input_text": "n = io.read(\"*n\")\nt = {}\nfor i = 1, n do\n t[i] = io.read(\"*n\")\nend\nlocal mma = math.max\nleft = {t[1]}\nfor i = 2, n do\n left[i] = mma(left[i - 1], t[i])\nend\nlocal right = {}\nfor i = 1, n do right[i] = 0 end\nright[n] = t[n]\nfor i = n - 1, 1, -1 do\n right[i] = mma(right[i + 1], t[i])\nend\nprint(right[2])\nif 2 < n then\n for i = 2, n - 1 do\n print(math.max(left[i - 1], right[i + 1]))\n end\n print(left[n - 1])\nend\n", "language": "Lua", "metadata": {"date": 1597758262, "filename_ext": "lua", "original_language": "Lua (Lua 5.3.5)", "problem_description_relpath": "problem_descriptions/p02971.html", "problem_id": "p02971", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02971/input.txt", "sample_output_relpath": "derived/input_output/data/p02971/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02971/Lua/s338884212.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s338884212", "user_id": "u120582723"}, "prompt_components": {"gold_output": "4\n3\n4\n", "input_to_evaluate": "n = io.read(\"*n\")\nt = {}\nfor i = 1, n do\n t[i] = io.read(\"*n\")\nend\nlocal mma = math.max\nleft = {t[1]}\nfor i = 2, n do\n left[i] = mma(left[i - 1], t[i])\nend\nlocal right = {}\nfor i = 1, n do right[i] = 0 end\nright[n] = t[n]\nfor i = n - 1, 1, -1 do\n right[i] = mma(right[i + 1], t[i])\nend\nprint(right[2])\nif 2 < n then\n for i = 2, n - 1 do\n print(math.max(left[i - 1], right[i + 1]))\n end\n print(left[n - 1])\nend\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nYou are given a sequence of length N: A_1, A_2, ..., A_N.\nFor each integer i between 1 and N (inclusive), answer the following question:\n\nFind the maximum value among the N-1 elements other than A_i in the sequence.\n\nConstraints\n\n2 \\leq N \\leq 200000\n\n1 \\leq A_i \\leq 200000\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1\n:\nA_N\n\nOutput\n\nPrint N lines. The i-th line (1 \\leq i \\leq N) should contain the maximum value among the N-1 elements other than A_i in the sequence.\n\nSample Input 1\n\n3\n1\n4\n3\n\nSample Output 1\n\n4\n3\n4\n\nThe maximum value among the two elements other than A_1, that is, A_2 = 4 and A_3 = 3, is 4.\n\nThe maximum value among the two elements other than A_2, that is, A_1 = 1 and A_3 = 3, is 3.\n\nThe maximum value among the two elements other than A_3, that is, A_1 = 1 and A_2 = 4, is 4.\n\nSample Input 2\n\n2\n5\n5\n\nSample Output 2\n\n5\n5", "sample_input": "3\n1\n4\n3\n"}, "reference_outputs": ["4\n3\n4\n"], "source_document_id": "p02971", "source_text": "Score : 300 points\n\nProblem Statement\n\nYou are given a sequence of length N: A_1, A_2, ..., A_N.\nFor each integer i between 1 and N (inclusive), answer the following question:\n\nFind the maximum value among the N-1 elements other than A_i in the sequence.\n\nConstraints\n\n2 \\leq N \\leq 200000\n\n1 \\leq A_i \\leq 200000\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1\n:\nA_N\n\nOutput\n\nPrint N lines. The i-th line (1 \\leq i \\leq N) should contain the maximum value among the N-1 elements other than A_i in the sequence.\n\nSample Input 1\n\n3\n1\n4\n3\n\nSample Output 1\n\n4\n3\n4\n\nThe maximum value among the two elements other than A_1, that is, A_2 = 4 and A_3 = 3, is 4.\n\nThe maximum value among the two elements other than A_2, that is, A_1 = 1 and A_3 = 3, is 3.\n\nThe maximum value among the two elements other than A_3, that is, A_1 = 1 and A_2 = 4, is 4.\n\nSample Input 2\n\n2\n5\n5\n\nSample Output 2\n\n5\n5", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 419, "cpu_time_ms": 436, "memory_kb": 14528}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s439406130", "group_id": "codeNet:p02971", "input_text": "local mce, mfl, msq, mmi, mma = math.ceil, math.floor, math.sqrt, math.min, math.max\nlocal n = io.read(\"*n\")\nlocal a, b = {}, {}\nfor i = 1, n do\n a[i] = io.read(\"*n\")\n b[i] = a[i]\nend\ntable.sort(b)\nlocal m1, m2 = b[n], b[n - 1]\nfor i = 1, n do\n if a[i] == m1 then\n print(m2)\n else\n print(m1)\n end\nend\n", "language": "Lua", "metadata": {"date": 1563671064, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p02971.html", "problem_id": "p02971", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02971/input.txt", "sample_output_relpath": "derived/input_output/data/p02971/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02971/Lua/s439406130.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s439406130", "user_id": "u120582723"}, "prompt_components": {"gold_output": "4\n3\n4\n", "input_to_evaluate": "local mce, mfl, msq, mmi, mma = math.ceil, math.floor, math.sqrt, math.min, math.max\nlocal n = io.read(\"*n\")\nlocal a, b = {}, {}\nfor i = 1, n do\n a[i] = io.read(\"*n\")\n b[i] = a[i]\nend\ntable.sort(b)\nlocal m1, m2 = b[n], b[n - 1]\nfor i = 1, n do\n if a[i] == m1 then\n print(m2)\n else\n print(m1)\n end\nend\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nYou are given a sequence of length N: A_1, A_2, ..., A_N.\nFor each integer i between 1 and N (inclusive), answer the following question:\n\nFind the maximum value among the N-1 elements other than A_i in the sequence.\n\nConstraints\n\n2 \\leq N \\leq 200000\n\n1 \\leq A_i \\leq 200000\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1\n:\nA_N\n\nOutput\n\nPrint N lines. The i-th line (1 \\leq i \\leq N) should contain the maximum value among the N-1 elements other than A_i in the sequence.\n\nSample Input 1\n\n3\n1\n4\n3\n\nSample Output 1\n\n4\n3\n4\n\nThe maximum value among the two elements other than A_1, that is, A_2 = 4 and A_3 = 3, is 4.\n\nThe maximum value among the two elements other than A_2, that is, A_1 = 1 and A_3 = 3, is 3.\n\nThe maximum value among the two elements other than A_3, that is, A_1 = 1 and A_2 = 4, is 4.\n\nSample Input 2\n\n2\n5\n5\n\nSample Output 2\n\n5\n5", "sample_input": "3\n1\n4\n3\n"}, "reference_outputs": ["4\n3\n4\n"], "source_document_id": "p02971", "source_text": "Score : 300 points\n\nProblem Statement\n\nYou are given a sequence of length N: A_1, A_2, ..., A_N.\nFor each integer i between 1 and N (inclusive), answer the following question:\n\nFind the maximum value among the N-1 elements other than A_i in the sequence.\n\nConstraints\n\n2 \\leq N \\leq 200000\n\n1 \\leq A_i \\leq 200000\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1\n:\nA_N\n\nOutput\n\nPrint N lines. The i-th line (1 \\leq i \\leq N) should contain the maximum value among the N-1 elements other than A_i in the sequence.\n\nSample Input 1\n\n3\n1\n4\n3\n\nSample Output 1\n\n4\n3\n4\n\nThe maximum value among the two elements other than A_1, that is, A_2 = 4 and A_3 = 3, is 4.\n\nThe maximum value among the two elements other than A_2, that is, A_1 = 1 and A_3 = 3, is 3.\n\nThe maximum value among the two elements other than A_3, that is, A_1 = 1 and A_2 = 4, is 4.\n\nSample Input 2\n\n2\n5\n5\n\nSample Output 2\n\n5\n5", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 312, "cpu_time_ms": 265, "memory_kb": 5888}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s421564587", "group_id": "codeNet:p02973", "input_text": "local function lower_bound(key,ary)\n local n=#ary\n if n==0 then\n return 1 \n end\n if key<=ary[1] then\n return 1\n end\n if key>ary[n] then\n return n+1\n end\n local min,max=1,n\n while 1ary[mid] then\n min=mid\n else\n max=mid\n end\n end\n return max\nend\n\nlocal n=io.read(\"n\")\nlocal a={}\nlocal a_map={}\nfor i=1,n do\n local input=io.read(\"n\")\n a[i]=input\n a_map[input]=(a_map[input] or 0)+1\nend\n\nlocal INF=math.maxinteger\nlocal LISt={}\nfor i=1,n do\n LISt[i]=INF\nend\n\nlocal function recLIS(counter)\n local len=0\n for i=1,n do\n if a_map[a[i]]>0 then\n local k=lower_bound(a[i],LISt)\n if LISt[k]ary[n] then\n return n+1\n end\n local min,max=1,n\n while 1ary[mid] then\n min=mid\n else\n max=mid\n end\n end\n return max\nend\n\nlocal n=io.read(\"n\")\nlocal a={}\nlocal a_map={}\nfor i=1,n do\n local input=io.read(\"n\")\n a[i]=input\n a_map[input]=(a_map[input] or 0)+1\nend\n\nlocal INF=math.maxinteger\nlocal LISt={}\nfor i=1,n do\n LISt[i]=INF\nend\n\nlocal function recLIS(counter)\n local len=0\n for i=1,n do\n if a_map[a[i]]>0 then\n local k=lower_bound(a[i],LISt)\n if LISt[k] b then\n print(\"No\")\n return\n else\n cursor = cursor + a\n end\nend\nprint(\"Yes\")", "language": "Lua", "metadata": {"date": 1565771589, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p02996.html", "problem_id": "p02996", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02996/input.txt", "sample_output_relpath": "derived/input_output/data/p02996/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02996/Lua/s004518574.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s004518574", "user_id": "u162773977"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "local N = io.read(\"n\")\nlocal jobs = {}\nfor i=1, N do\n local a, b = io.read(\"n\", \"n\")\n jobs[i] = {a, b}\nend\ntable.sort(jobs, function(x1, x2)\n return x1[2] < x2[2]\nend)\nlocal cursor = 0\nfor i=1, N do\n local a, b = jobs[i][1], jobs[i][2]\n if cursor + a > b then\n print(\"No\")\n return\n else\n cursor = cursor + a\n end\nend\nprint(\"Yes\")", "problem_context": "Score: 400 points\n\nProblem Statement\n\nKizahashi, who was appointed as the administrator of ABC at National Problem Workshop in the Kingdom of AtCoder, got too excited and took on too many jobs.\n\nLet the current time be time 0. Kizahashi has N jobs numbered 1 to N.\n\nIt takes A_i units of time for Kizahashi to complete Job i. The deadline for Job i is time B_i, and he must complete the job before or at this time.\n\nKizahashi cannot work on two or more jobs simultaneously, but when he completes a job, he can start working on another immediately.\n\nCan Kizahashi complete all the jobs in time? If he can, print Yes; if he cannot, print No.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 2 \\times 10^5\n\n1 \\leq A_i, B_i \\leq 10^9 (1 \\leq i \\leq N)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 B_1\n.\n.\n.\nA_N B_N\n\nOutput\n\nIf Kizahashi can complete all the jobs in time, print Yes; if he cannot, print No.\n\nSample Input 1\n\n5\n2 4\n1 9\n1 8\n4 9\n3 12\n\nSample Output 1\n\nYes\n\nHe can complete all the jobs in time by, for example, doing them in the following order:\n\nDo Job 2 from time 0 to 1.\n\nDo Job 1 from time 1 to 3.\n\nDo Job 4 from time 3 to 7.\n\nDo Job 3 from time 7 to 8.\n\nDo Job 5 from time 8 to 11.\n\nNote that it is fine to complete Job 3 exactly at the deadline, time 8.\n\nSample Input 2\n\n3\n334 1000\n334 1000\n334 1000\n\nSample Output 2\n\nNo\n\nHe cannot complete all the jobs in time, no matter what order he does them in.\n\nSample Input 3\n\n30\n384 8895\n1725 9791\n170 1024\n4 11105\n2 6\n578 1815\n702 3352\n143 5141\n1420 6980\n24 1602\n849 999\n76 7586\n85 5570\n444 4991\n719 11090\n470 10708\n1137 4547\n455 9003\n110 9901\n15 8578\n368 3692\n104 1286\n3 4\n366 12143\n7 6649\n610 2374\n152 7324\n4 7042\n292 11386\n334 5720\n\nSample Output 3\n\nYes", "sample_input": "5\n2 4\n1 9\n1 8\n4 9\n3 12\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p02996", "source_text": "Score: 400 points\n\nProblem Statement\n\nKizahashi, who was appointed as the administrator of ABC at National Problem Workshop in the Kingdom of AtCoder, got too excited and took on too many jobs.\n\nLet the current time be time 0. Kizahashi has N jobs numbered 1 to N.\n\nIt takes A_i units of time for Kizahashi to complete Job i. The deadline for Job i is time B_i, and he must complete the job before or at this time.\n\nKizahashi cannot work on two or more jobs simultaneously, but when he completes a job, he can start working on another immediately.\n\nCan Kizahashi complete all the jobs in time? If he can, print Yes; if he cannot, print No.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 2 \\times 10^5\n\n1 \\leq A_i, B_i \\leq 10^9 (1 \\leq i \\leq N)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 B_1\n.\n.\n.\nA_N B_N\n\nOutput\n\nIf Kizahashi can complete all the jobs in time, print Yes; if he cannot, print No.\n\nSample Input 1\n\n5\n2 4\n1 9\n1 8\n4 9\n3 12\n\nSample Output 1\n\nYes\n\nHe can complete all the jobs in time by, for example, doing them in the following order:\n\nDo Job 2 from time 0 to 1.\n\nDo Job 1 from time 1 to 3.\n\nDo Job 4 from time 3 to 7.\n\nDo Job 3 from time 7 to 8.\n\nDo Job 5 from time 8 to 11.\n\nNote that it is fine to complete Job 3 exactly at the deadline, time 8.\n\nSample Input 2\n\n3\n334 1000\n334 1000\n334 1000\n\nSample Output 2\n\nNo\n\nHe cannot complete all the jobs in time, no matter what order he does them in.\n\nSample Input 3\n\n30\n384 8895\n1725 9791\n170 1024\n4 11105\n2 6\n578 1815\n702 3352\n143 5141\n1420 6980\n24 1602\n849 999\n76 7586\n85 5570\n444 4991\n719 11090\n470 10708\n1137 4547\n455 9003\n110 9901\n15 8578\n368 3692\n104 1286\n3 4\n366 12143\n7 6649\n610 2374\n152 7324\n4 7042\n292 11386\n334 5720\n\nSample Output 3\n\nYes", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 371, "cpu_time_ms": 669, "memory_kb": 26232}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s911562623", "group_id": "codeNet:p02997", "input_text": "local mfl = math.floor\nlocal n, k = io.read(\"*n\", \"*n\")\nk = mfl((n - 1) * (n - 2) / 2) - k\nif k < 0 then\n print(-1)\nelse\n local cur = 0\n print(n - 1 + k)\n for i = 2, n do\n print(1 .. \" \" .. i)\n end\n if k ~= 0 then\n for i = 2, n - 1 do\n for j = i + 1, n do\n print(i ..\" \" .. j)\n cur = cur + 1\n if cur == k then break end\n end\n if cur == k then break end\n end\n end\nend\n", "language": "Lua", "metadata": {"date": 1561242209, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p02997.html", "problem_id": "p02997", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02997/input.txt", "sample_output_relpath": "derived/input_output/data/p02997/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02997/Lua/s911562623.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s911562623", "user_id": "u120582723"}, "prompt_components": {"gold_output": "5\n4 3\n1 2\n3 1\n4 5\n2 3\n", "input_to_evaluate": "local mfl = math.floor\nlocal n, k = io.read(\"*n\", \"*n\")\nk = mfl((n - 1) * (n - 2) / 2) - k\nif k < 0 then\n print(-1)\nelse\n local cur = 0\n print(n - 1 + k)\n for i = 2, n do\n print(1 .. \" \" .. i)\n end\n if k ~= 0 then\n for i = 2, n - 1 do\n for j = i + 1, n do\n print(i ..\" \" .. j)\n cur = cur + 1\n if cur == k then break end\n end\n if cur == k then break end\n end\n end\nend\n", "problem_context": "Score: 500 points\n\nProblem Statement\n\nDoes there exist an undirected graph with N vertices satisfying the following conditions?\n\nThe graph is simple and connected.\n\nThe vertices are numbered 1, 2, ..., N.\n\nLet M be the number of edges in the graph. The edges are numbered 1, 2, ..., M, the length of each edge is 1, and Edge i connects Vertex u_i and Vertex v_i.\n\nThere are exactly K pairs of vertices (i,\\ j)\\ (i < j) such that the shortest distance between them is 2.\n\nIf there exists such a graph, construct an example.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 100\n\n0 \\leq K \\leq \\frac{N(N - 1)}{2}\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\n\nOutput\n\nIf there does not exist an undirected graph with N vertices satisfying the conditions, print -1.\n\nIf there exists such a graph, print an example in the following format (refer to Problem Statement for what the symbols stand for):\n\nM\nu_1 v_1\n:\nu_M v_M\n\nIf there exist multiple graphs satisfying the conditions, any of them will be accepted.\n\nSample Input 1\n\n5 3\n\nSample Output 1\n\n5\n4 3\n1 2\n3 1\n4 5\n2 3\n\nThis graph has three pairs of vertices such that the shortest distance between them is 2: (1,\\ 4), (2,\\ 4), and (3,\\ 5). Thus, the condition is satisfied.\n\nSample Input 2\n\n5 8\n\nSample Output 2\n\n-1\n\nThere is no graph satisfying the conditions.", "sample_input": "5 3\n"}, "reference_outputs": ["5\n4 3\n1 2\n3 1\n4 5\n2 3\n"], "source_document_id": "p02997", "source_text": "Score: 500 points\n\nProblem Statement\n\nDoes there exist an undirected graph with N vertices satisfying the following conditions?\n\nThe graph is simple and connected.\n\nThe vertices are numbered 1, 2, ..., N.\n\nLet M be the number of edges in the graph. The edges are numbered 1, 2, ..., M, the length of each edge is 1, and Edge i connects Vertex u_i and Vertex v_i.\n\nThere are exactly K pairs of vertices (i,\\ j)\\ (i < j) such that the shortest distance between them is 2.\n\nIf there exists such a graph, construct an example.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 100\n\n0 \\leq K \\leq \\frac{N(N - 1)}{2}\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\n\nOutput\n\nIf there does not exist an undirected graph with N vertices satisfying the conditions, print -1.\n\nIf there exists such a graph, print an example in the following format (refer to Problem Statement for what the symbols stand for):\n\nM\nu_1 v_1\n:\nu_M v_M\n\nIf there exist multiple graphs satisfying the conditions, any of them will be accepted.\n\nSample Input 1\n\n5 3\n\nSample Output 1\n\n5\n4 3\n1 2\n3 1\n4 5\n2 3\n\nThis graph has three pairs of vertices such that the shortest distance between them is 2: (1,\\ 4), (2,\\ 4), and (3,\\ 5). Thus, the condition is satisfied.\n\nSample Input 2\n\n5 8\n\nSample Output 2\n\n-1\n\nThere is no graph satisfying the conditions.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 419, "cpu_time_ms": 5, "memory_kb": 384}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s904155981", "group_id": "codeNet:p02999", "input_text": "local x, a = io.read(\"*n\", \"*n\")\n\nif x < a then\n print(0)\nelse\n print(10)\nend", "language": "Lua", "metadata": {"date": 1561141006, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p02999.html", "problem_id": "p02999", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02999/input.txt", "sample_output_relpath": "derived/input_output/data/p02999/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02999/Lua/s904155981.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s904155981", "user_id": "u678875535"}, "prompt_components": {"gold_output": "0\n", "input_to_evaluate": "local x, a = io.read(\"*n\", \"*n\")\n\nif x < a then\n print(0)\nelse\n print(10)\nend", "problem_context": "Score : 100 points\n\nProblem Statement\n\nX and A are integers between 0 and 9 (inclusive).\n\nIf X is less than A, print 0; if X is not less than A, print 10.\n\nConstraints\n\n0 \\leq X, A \\leq 9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX A\n\nOutput\n\nIf X is less than A, print 0; if X is not less than A, print 10.\n\nSample Input 1\n\n3 5\n\nSample Output 1\n\n0\n\n3 is less than 5, so we should print 0.\n\nSample Input 2\n\n7 5\n\nSample Output 2\n\n10\n\n7 is not less than 5, so we should print 10.\n\nSample Input 3\n\n6 6\n\nSample Output 3\n\n10\n\n6 is not less than 6, so we should print 10.", "sample_input": "3 5\n"}, "reference_outputs": ["0\n"], "source_document_id": "p02999", "source_text": "Score : 100 points\n\nProblem Statement\n\nX and A are integers between 0 and 9 (inclusive).\n\nIf X is less than A, print 0; if X is not less than A, print 10.\n\nConstraints\n\n0 \\leq X, A \\leq 9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX A\n\nOutput\n\nIf X is less than A, print 0; if X is not less than A, print 10.\n\nSample Input 1\n\n3 5\n\nSample Output 1\n\n0\n\n3 is less than 5, so we should print 0.\n\nSample Input 2\n\n7 5\n\nSample Output 2\n\n10\n\n7 is not less than 5, so we should print 10.\n\nSample Input 3\n\n6 6\n\nSample Output 3\n\n10\n\n6 is not less than 6, so we should print 10.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 79, "cpu_time_ms": 8, "memory_kb": 888}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s752007484", "group_id": "codeNet:p02999", "input_text": "local x, a = io.read(\"*n\", \"*n\")\nif x < a then print(0) else print(10) end", "language": "Lua", "metadata": {"date": 1560711656, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p02999.html", "problem_id": "p02999", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02999/input.txt", "sample_output_relpath": "derived/input_output/data/p02999/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02999/Lua/s752007484.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s752007484", "user_id": "u120582723"}, "prompt_components": {"gold_output": "0\n", "input_to_evaluate": "local x, a = io.read(\"*n\", \"*n\")\nif x < a then print(0) else print(10) end", "problem_context": "Score : 100 points\n\nProblem Statement\n\nX and A are integers between 0 and 9 (inclusive).\n\nIf X is less than A, print 0; if X is not less than A, print 10.\n\nConstraints\n\n0 \\leq X, A \\leq 9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX A\n\nOutput\n\nIf X is less than A, print 0; if X is not less than A, print 10.\n\nSample Input 1\n\n3 5\n\nSample Output 1\n\n0\n\n3 is less than 5, so we should print 0.\n\nSample Input 2\n\n7 5\n\nSample Output 2\n\n10\n\n7 is not less than 5, so we should print 10.\n\nSample Input 3\n\n6 6\n\nSample Output 3\n\n10\n\n6 is not less than 6, so we should print 10.", "sample_input": "3 5\n"}, "reference_outputs": ["0\n"], "source_document_id": "p02999", "source_text": "Score : 100 points\n\nProblem Statement\n\nX and A are integers between 0 and 9 (inclusive).\n\nIf X is less than A, print 0; if X is not less than A, print 10.\n\nConstraints\n\n0 \\leq X, A \\leq 9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX A\n\nOutput\n\nIf X is less than A, print 0; if X is not less than A, print 10.\n\nSample Input 1\n\n3 5\n\nSample Output 1\n\n0\n\n3 is less than 5, so we should print 0.\n\nSample Input 2\n\n7 5\n\nSample Output 2\n\n10\n\n7 is not less than 5, so we should print 10.\n\nSample Input 3\n\n6 6\n\nSample Output 3\n\n10\n\n6 is not less than 6, so we should print 10.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 74, "cpu_time_ms": 12, "memory_kb": 1136}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s107432533", "group_id": "codeNet:p03000", "input_text": "local n, x = io.read(\"*n\", \"*n\")\n\nL = {}\nfor i=1, n do\n L[i] = io.read(\"*n\")\nend\n\nlocal cnt = 1\nlocal bound = 0\n\nfor i = 1, n do\n bound = bound + L[i]\n if L[i] <= x then\n cnt = cnt + 1\n end\nend\n\nprint(cnt)", "language": "Lua", "metadata": {"date": 1561159741, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03000.html", "problem_id": "p03000", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03000/input.txt", "sample_output_relpath": "derived/input_output/data/p03000/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03000/Lua/s107432533.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s107432533", "user_id": "u678875535"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "local n, x = io.read(\"*n\", \"*n\")\n\nL = {}\nfor i=1, n do\n L[i] = io.read(\"*n\")\nend\n\nlocal cnt = 1\nlocal bound = 0\n\nfor i = 1, n do\n bound = bound + L[i]\n if L[i] <= x then\n cnt = cnt + 1\n end\nend\n\nprint(cnt)", "problem_context": "Score : 200 points\n\nProblem Statement\n\nA ball will bounce along a number line, making N + 1 bounces. It will make the first bounce at coordinate D_1 = 0, and the i-th bounce (2 \\leq i \\leq N+1) at coordinate D_i = D_{i-1} + L_{i-1}.\n\nHow many times will the ball make a bounce where the coordinate is at most X?\n\nConstraints\n\n1 \\leq N \\leq 100\n\n1 \\leq L_i \\leq 100\n\n1 \\leq X \\leq 10000\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN X\nL_1 L_2 ... L_{N-1} L_N\n\nOutput\n\nPrint the number of times the ball will make a bounce where the coordinate is at most X.\n\nSample Input 1\n\n3 6\n3 4 5\n\nSample Output 1\n\n2\n\nThe ball will make a bounce at the coordinates 0, 3, 7 and 12, among which two are less than or equal to 6.\n\nSample Input 2\n\n4 9\n3 3 3 3\n\nSample Output 2\n\n4\n\nThe ball will make a bounce at the coordinates 0, 3, 6, 9 and 12, among which four are less than or equal to 9.", "sample_input": "3 6\n3 4 5\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03000", "source_text": "Score : 200 points\n\nProblem Statement\n\nA ball will bounce along a number line, making N + 1 bounces. It will make the first bounce at coordinate D_1 = 0, and the i-th bounce (2 \\leq i \\leq N+1) at coordinate D_i = D_{i-1} + L_{i-1}.\n\nHow many times will the ball make a bounce where the coordinate is at most X?\n\nConstraints\n\n1 \\leq N \\leq 100\n\n1 \\leq L_i \\leq 100\n\n1 \\leq X \\leq 10000\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN X\nL_1 L_2 ... L_{N-1} L_N\n\nOutput\n\nPrint the number of times the ball will make a bounce where the coordinate is at most X.\n\nSample Input 1\n\n3 6\n3 4 5\n\nSample Output 1\n\n2\n\nThe ball will make a bounce at the coordinates 0, 3, 7 and 12, among which two are less than or equal to 6.\n\nSample Input 2\n\n4 9\n3 3 3 3\n\nSample Output 2\n\n4\n\nThe ball will make a bounce at the coordinates 0, 3, 6, 9 and 12, among which four are less than or equal to 9.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 212, "cpu_time_ms": 8, "memory_kb": 760}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s447793055", "group_id": "codeNet:p03000", "input_text": "local n, x = io.read(\"*n\", \"*n\")\n\nL = {}\nfor i=1, n do\n L[i] = io.read(\"*n\")\nend\n\nlocal cnt = 0\nlocal bound = 0\n\nfor i = 1, n do\n bound = bound + L[i]\n if L[i] <= x then\n cnt = cnt + 1\n end\nend\n\nprint(cnt)", "language": "Lua", "metadata": {"date": 1561158955, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03000.html", "problem_id": "p03000", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03000/input.txt", "sample_output_relpath": "derived/input_output/data/p03000/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03000/Lua/s447793055.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s447793055", "user_id": "u678875535"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "local n, x = io.read(\"*n\", \"*n\")\n\nL = {}\nfor i=1, n do\n L[i] = io.read(\"*n\")\nend\n\nlocal cnt = 0\nlocal bound = 0\n\nfor i = 1, n do\n bound = bound + L[i]\n if L[i] <= x then\n cnt = cnt + 1\n end\nend\n\nprint(cnt)", "problem_context": "Score : 200 points\n\nProblem Statement\n\nA ball will bounce along a number line, making N + 1 bounces. It will make the first bounce at coordinate D_1 = 0, and the i-th bounce (2 \\leq i \\leq N+1) at coordinate D_i = D_{i-1} + L_{i-1}.\n\nHow many times will the ball make a bounce where the coordinate is at most X?\n\nConstraints\n\n1 \\leq N \\leq 100\n\n1 \\leq L_i \\leq 100\n\n1 \\leq X \\leq 10000\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN X\nL_1 L_2 ... L_{N-1} L_N\n\nOutput\n\nPrint the number of times the ball will make a bounce where the coordinate is at most X.\n\nSample Input 1\n\n3 6\n3 4 5\n\nSample Output 1\n\n2\n\nThe ball will make a bounce at the coordinates 0, 3, 7 and 12, among which two are less than or equal to 6.\n\nSample Input 2\n\n4 9\n3 3 3 3\n\nSample Output 2\n\n4\n\nThe ball will make a bounce at the coordinates 0, 3, 6, 9 and 12, among which four are less than or equal to 9.", "sample_input": "3 6\n3 4 5\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03000", "source_text": "Score : 200 points\n\nProblem Statement\n\nA ball will bounce along a number line, making N + 1 bounces. It will make the first bounce at coordinate D_1 = 0, and the i-th bounce (2 \\leq i \\leq N+1) at coordinate D_i = D_{i-1} + L_{i-1}.\n\nHow many times will the ball make a bounce where the coordinate is at most X?\n\nConstraints\n\n1 \\leq N \\leq 100\n\n1 \\leq L_i \\leq 100\n\n1 \\leq X \\leq 10000\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN X\nL_1 L_2 ... L_{N-1} L_N\n\nOutput\n\nPrint the number of times the ball will make a bounce where the coordinate is at most X.\n\nSample Input 1\n\n3 6\n3 4 5\n\nSample Output 1\n\n2\n\nThe ball will make a bounce at the coordinates 0, 3, 7 and 12, among which two are less than or equal to 6.\n\nSample Input 2\n\n4 9\n3 3 3 3\n\nSample Output 2\n\n4\n\nThe ball will make a bounce at the coordinates 0, 3, 6, 9 and 12, among which four are less than or equal to 9.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 212, "cpu_time_ms": 34, "memory_kb": 760}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s611452799", "group_id": "codeNet:p03001", "input_text": "local w,h,x,y=io.read(\"*n\",\"*n\",\"*n\",\"*n\")\nlocal tate=math.min(x*h,(w-x)*h)\nlocal yoko=math.min(y*w,(h-y)*w)\nlocal tatemax=(w//2)*h\nlocal yokomax=(h//2)*w\n\ntate=tate+(tatemax-tate)/2\nyoko=yoko+(yokomax-yoko)/2\nlocal max=string.format(\"%.10f\",math.max(tate,yoko))\nprint(max,tate==yoko and 1 or 0)", "language": "Lua", "metadata": {"date": 1589705962, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03001.html", "problem_id": "p03001", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03001/input.txt", "sample_output_relpath": "derived/input_output/data/p03001/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03001/Lua/s611452799.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s611452799", "user_id": "u045238009"}, "prompt_components": {"gold_output": "3.000000 0\n", "input_to_evaluate": "local w,h,x,y=io.read(\"*n\",\"*n\",\"*n\",\"*n\")\nlocal tate=math.min(x*h,(w-x)*h)\nlocal yoko=math.min(y*w,(h-y)*w)\nlocal tatemax=(w//2)*h\nlocal yokomax=(h//2)*w\n\ntate=tate+(tatemax-tate)/2\nyoko=yoko+(yokomax-yoko)/2\nlocal max=string.format(\"%.10f\",math.max(tate,yoko))\nprint(max,tate==yoko and 1 or 0)", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere is a rectangle in a coordinate plane. The coordinates of the four vertices are (0,0), (W,0), (W,H), and (0,H).\nYou are given a point (x,y) which is within the rectangle or on its border. We will draw a straight line passing through (x,y) to cut the rectangle into two parts. Find the maximum possible area of the part whose area is not larger than that of the other. Additionally, determine if there are multiple ways to cut the rectangle and achieve that maximum.\n\nConstraints\n\n1 \\leq W,H \\leq 10^9\n\n0\\leq x\\leq W\n\n0\\leq y\\leq H\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nW H x y\n\nOutput\n\nPrint the maximum possible area of the part whose area is not larger than that of the other, followed by 1 if there are multiple ways to cut the rectangle and achieve that maximum, and 0 otherwise.\n\nThe area printed will be judged correct when its absolute or relative error is at most 10^{-9}.\n\nSample Input 1\n\n2 3 1 2\n\nSample Output 1\n\n3.000000 0\n\nThe line x=1 gives the optimal cut, and no other line does.\n\nSample Input 2\n\n2 2 1 1\n\nSample Output 2\n\n2.000000 1", "sample_input": "2 3 1 2\n"}, "reference_outputs": ["3.000000 0\n"], "source_document_id": "p03001", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere is a rectangle in a coordinate plane. The coordinates of the four vertices are (0,0), (W,0), (W,H), and (0,H).\nYou are given a point (x,y) which is within the rectangle or on its border. We will draw a straight line passing through (x,y) to cut the rectangle into two parts. Find the maximum possible area of the part whose area is not larger than that of the other. Additionally, determine if there are multiple ways to cut the rectangle and achieve that maximum.\n\nConstraints\n\n1 \\leq W,H \\leq 10^9\n\n0\\leq x\\leq W\n\n0\\leq y\\leq H\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nW H x y\n\nOutput\n\nPrint the maximum possible area of the part whose area is not larger than that of the other, followed by 1 if there are multiple ways to cut the rectangle and achieve that maximum, and 0 otherwise.\n\nThe area printed will be judged correct when its absolute or relative error is at most 10^{-9}.\n\nSample Input 1\n\n2 3 1 2\n\nSample Output 1\n\n3.000000 0\n\nThe line x=1 gives the optimal cut, and no other line does.\n\nSample Input 2\n\n2 2 1 1\n\nSample Output 2\n\n2.000000 1", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 295, "cpu_time_ms": 7, "memory_kb": 760}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s753915763", "group_id": "codeNet:p03001", "input_text": "local w, h = io.read(\"*n\", \"*n\")\nlocal x, y = io.read(\"*n\", \"*n\")\nlocal menseki = w * h / 2\nlocal flag = 0\nif x * 2 == w and y * 2 == h then\n flag = 1\nend\nio.write(string.format(\"%.10f\", menseki))\nio.write(\" \" .. flag .. \"\\n\")\n", "language": "Lua", "metadata": {"date": 1560712124, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03001.html", "problem_id": "p03001", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03001/input.txt", "sample_output_relpath": "derived/input_output/data/p03001/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03001/Lua/s753915763.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s753915763", "user_id": "u120582723"}, "prompt_components": {"gold_output": "3.000000 0\n", "input_to_evaluate": "local w, h = io.read(\"*n\", \"*n\")\nlocal x, y = io.read(\"*n\", \"*n\")\nlocal menseki = w * h / 2\nlocal flag = 0\nif x * 2 == w and y * 2 == h then\n flag = 1\nend\nio.write(string.format(\"%.10f\", menseki))\nio.write(\" \" .. flag .. \"\\n\")\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere is a rectangle in a coordinate plane. The coordinates of the four vertices are (0,0), (W,0), (W,H), and (0,H).\nYou are given a point (x,y) which is within the rectangle or on its border. We will draw a straight line passing through (x,y) to cut the rectangle into two parts. Find the maximum possible area of the part whose area is not larger than that of the other. Additionally, determine if there are multiple ways to cut the rectangle and achieve that maximum.\n\nConstraints\n\n1 \\leq W,H \\leq 10^9\n\n0\\leq x\\leq W\n\n0\\leq y\\leq H\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nW H x y\n\nOutput\n\nPrint the maximum possible area of the part whose area is not larger than that of the other, followed by 1 if there are multiple ways to cut the rectangle and achieve that maximum, and 0 otherwise.\n\nThe area printed will be judged correct when its absolute or relative error is at most 10^{-9}.\n\nSample Input 1\n\n2 3 1 2\n\nSample Output 1\n\n3.000000 0\n\nThe line x=1 gives the optimal cut, and no other line does.\n\nSample Input 2\n\n2 2 1 1\n\nSample Output 2\n\n2.000000 1", "sample_input": "2 3 1 2\n"}, "reference_outputs": ["3.000000 0\n"], "source_document_id": "p03001", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere is a rectangle in a coordinate plane. The coordinates of the four vertices are (0,0), (W,0), (W,H), and (0,H).\nYou are given a point (x,y) which is within the rectangle or on its border. We will draw a straight line passing through (x,y) to cut the rectangle into two parts. Find the maximum possible area of the part whose area is not larger than that of the other. Additionally, determine if there are multiple ways to cut the rectangle and achieve that maximum.\n\nConstraints\n\n1 \\leq W,H \\leq 10^9\n\n0\\leq x\\leq W\n\n0\\leq y\\leq H\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nW H x y\n\nOutput\n\nPrint the maximum possible area of the part whose area is not larger than that of the other, followed by 1 if there are multiple ways to cut the rectangle and achieve that maximum, and 0 otherwise.\n\nThe area printed will be judged correct when its absolute or relative error is at most 10^{-9}.\n\nSample Input 1\n\n2 3 1 2\n\nSample Output 1\n\n3.000000 0\n\nThe line x=1 gives the optimal cut, and no other line does.\n\nSample Input 2\n\n2 2 1 1\n\nSample Output 2\n\n2.000000 1", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 228, "cpu_time_ms": 7, "memory_kb": 888}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s165608606", "group_id": "codeNet:p03004", "input_text": "local mce, mfl, msq, mmi, mma = math.ceil, math.floor, math.sqrt, math.min, math.max\nlocal n = io.read(\"*n\", \"*l\")\n-- local left, right, up, down = {}, {}, {}, {}\nlocal cxmin, cxmax, cymin, cymax = nil, nil, nil, nil\nlocal xinc_max, xinc_min, xdec_max, xdec_min = nil, nil, nil, nil\nlocal str = \"\"\nfor i = 1, n do\n str = io.read()\n local x, y, d = str:match(\"(-?%d+) (-?%d+) (%w)\")\n x, y = tonumber(x), tonumber(y)\n -- print(x, y, d)\n if d == \"R\" then\n if not cymin then\n cymin, cymax = y, y\n else\n cymin, cymax = mmi(cymin, y), mma(cymax, y)\n end\n if not xinc_min then\n xinc_min, xinc_max = x, x\n else\n xinc_min, xinc_max =mmi(xinc_min, x), mma(xinc_max, x)\n end\n elseif d == \"L\" then\n if not cymin then\n cymin, cymax = y, y\n else\n cymin, cymax = mmi(cymin, y), mma(cymax, y)\n end\n if not xdec_min then\n xdec_min, xdec_max = x, x\n else\n xdec_min, xdec_max =mmi(xdec_min, x), mma(xdec_max, x)\n end\n elseif d == \"U\" then\n if not cxmin then\n cxmin, cxmax = x, x\n else\n cxmin, cxmax = mmi(cxmin, x), mma(cxmax, x)\n end\n if not yinc_min then\n yinc_min, yinc_max = y, y\n else\n yinc_min, yinc_max =mmi(yinc_min, y), mma(yinc_max, y)\n end\n else\n if not cxmin then\n cxmin, cxmax = x, x\n else\n cxmin, cxmax = mmi(cxmin, x), mma(cxmax, x)\n end\n if not ydec_min then\n ydec_min, ydec_max = y, y\n else\n ydec_min, ydec_max =mmi(ydec_min, y), mma(ydec_max, y)\n end\n end\nend\n-- print(xinc_min, xinc_max, xdec_min, xdec_max)\n-- print(yinc_min, yinc_max, ydec_min, ydec_max)\n-- print(cxmin, cxmax, cymin, cymax)\n\nlocal candidate_t = {0}\nif xinc_min then\n if xdec_min then\n if xinc_min < xdec_min then\n table.insert(candidate_t, (xdec_min - xinc_min) / 2)\n end\n if xinc_min < xdec_max then\n table.insert(candidate_t, (xdec_max - xinc_min) / 2)\n end\n if xinc_max < xdec_min then\n table.insert(candidate_t, (xdec_min - xinc_max) / 2)\n end\n if xinc_max < xdec_max then\n table.insert(candidate_t, (xdec_max - xinc_max) / 2)\n end\n end\n if cxmin then\n if xinc_min < cxmin then\n table.insert(candidate_t, cxmin - xinc_min)\n end\n if xinc_min < cxmax then\n table.insert(candidate_t, cxmax - xinc_min)\n end\n if xinc_max < cxmin then\n table.insert(candidate_t, cxmin - xinc_max)\n end\n if xinc_max < cxmax then\n table.insert(candidate_t, cxmax - xinc_max)\n end\n end\nend\nif xdec_min then\n if cxmin then\n if xdec_min > cxmin then\n table.insert(candidate_t, -cxmin + xdec_min)\n end\n if xdec_min > cxmax then\n table.insert(candidate_t, -cxmax + xdec_min)\n end\n if xdec_max > cxmin then\n table.insert(candidate_t, -cxmin + xdec_max)\n end\n if xdec_max > cxmax then\n table.insert(candidate_t, -cxmax + xdec_max)\n end\n end\nend\n-- y\nif yinc_min then\n if ydec_min then\n if yinc_min < ydec_min then\n table.insert(candidate_t, (ydec_min - yinc_min) / 2)\n end\n if yinc_min < ydec_max then\n table.insert(candidate_t, (ydec_max - yinc_min) / 2)\n end\n if yinc_max < ydec_min then\n table.insert(candidate_t, (ydec_min - yinc_max) / 2)\n end\n if yinc_max < ydec_max then\n table.insert(candidate_t, (ydec_max - yinc_max) / 2)\n end\n end\n if cymin then\n if yinc_min < cymin then\n table.insert(candidate_t, cymin - yinc_min)\n end\n if yinc_min < cymax then\n table.insert(candidate_t, cymax - yinc_min)\n end\n if yinc_max < cymin then\n table.insert(candidate_t, cymin - yinc_max)\n end\n if yinc_max < cymax then\n table.insert(candidate_t, cymax - yinc_max)\n end\n end\nend\nif ydec_min then\n if cymin then\n if ydec_min > cymin then\n table.insert(candidate_t, -cymin + ydec_min)\n end\n if ydec_min > cymax then\n table.insert(candidate_t, -cymax + ydec_min)\n end\n if ydec_max > cymin then\n table.insert(candidate_t, -cymin + ydec_max)\n end\n if ydec_max > cymax then\n table.insert(candidate_t, -cymax + ydec_max)\n end\n end\nend\n\nlocal ret = nil\nfor i = 1, #candidate_t do\n local time = candidate_t[i]\n local qxmin, qxmax = nil, nil\n local qymin, qymax = nil, nil\n if xdec_min then\n if not qxmin then qxmin, qxmax = xdec_min - time, xdec_max - time\n else qxmin, qxmax = mmi(qxmin, xdec_min - time), mma(qxmax, xdec_max - time)\n end\n end\n if xinc_min then\n if not qxmin then qxmin, qxmax = xinc_min - time, xinc_max - time\n else qxmin, qxmax = mmi(qxmin, xinc_min + time), mma(qxmax, xinc_max + time)\n end\n end\n if cxmin then\n if not qxmin then qxmin, qxmax = cxmin, cxmax\n else qxmin, qxmax = mmi(qxmin, cxmin), mma(qxmax, cxmax)\n end\n end\n\n if ydec_min then\n if not qymin then qymin, qymax = ydec_min - time, ydec_max - time\n else qymin, qymax = mmi(qymin, ydec_min - time), mma(qymax, ydec_max - time)\n end\n end\n if yinc_min then\n if not qymin then qymin, qymax = yinc_min - time, yinc_max - time\n else qymin, qymax = mmi(qymin, yinc_min + time), mma(qymax, yinc_max + time)\n end\n end\n if cymin then\n if not qymin then qymin, qymax = cymin, cymax\n else qymin, qymax = mmi(qymin, cymin), mma(qymax, cymax)\n end\n end\n local tmp = 0\n if qxmin and qymin then\n tmp = (qxmax - qxmin) * (qymax - qymin)\n else\n tmp = 0\n end\n -- print(time, tmp)\n if not ret then ret = tmp\n else ret = mmi(ret, tmp)\n end\nend\nprint(ret)\n", "language": "Lua", "metadata": {"date": 1560738707, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p03004.html", "problem_id": "p03004", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03004/input.txt", "sample_output_relpath": "derived/input_output/data/p03004/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03004/Lua/s165608606.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s165608606", "user_id": "u120582723"}, "prompt_components": {"gold_output": "0\n", "input_to_evaluate": "local mce, mfl, msq, mmi, mma = math.ceil, math.floor, math.sqrt, math.min, math.max\nlocal n = io.read(\"*n\", \"*l\")\n-- local left, right, up, down = {}, {}, {}, {}\nlocal cxmin, cxmax, cymin, cymax = nil, nil, nil, nil\nlocal xinc_max, xinc_min, xdec_max, xdec_min = nil, nil, nil, nil\nlocal str = \"\"\nfor i = 1, n do\n str = io.read()\n local x, y, d = str:match(\"(-?%d+) (-?%d+) (%w)\")\n x, y = tonumber(x), tonumber(y)\n -- print(x, y, d)\n if d == \"R\" then\n if not cymin then\n cymin, cymax = y, y\n else\n cymin, cymax = mmi(cymin, y), mma(cymax, y)\n end\n if not xinc_min then\n xinc_min, xinc_max = x, x\n else\n xinc_min, xinc_max =mmi(xinc_min, x), mma(xinc_max, x)\n end\n elseif d == \"L\" then\n if not cymin then\n cymin, cymax = y, y\n else\n cymin, cymax = mmi(cymin, y), mma(cymax, y)\n end\n if not xdec_min then\n xdec_min, xdec_max = x, x\n else\n xdec_min, xdec_max =mmi(xdec_min, x), mma(xdec_max, x)\n end\n elseif d == \"U\" then\n if not cxmin then\n cxmin, cxmax = x, x\n else\n cxmin, cxmax = mmi(cxmin, x), mma(cxmax, x)\n end\n if not yinc_min then\n yinc_min, yinc_max = y, y\n else\n yinc_min, yinc_max =mmi(yinc_min, y), mma(yinc_max, y)\n end\n else\n if not cxmin then\n cxmin, cxmax = x, x\n else\n cxmin, cxmax = mmi(cxmin, x), mma(cxmax, x)\n end\n if not ydec_min then\n ydec_min, ydec_max = y, y\n else\n ydec_min, ydec_max =mmi(ydec_min, y), mma(ydec_max, y)\n end\n end\nend\n-- print(xinc_min, xinc_max, xdec_min, xdec_max)\n-- print(yinc_min, yinc_max, ydec_min, ydec_max)\n-- print(cxmin, cxmax, cymin, cymax)\n\nlocal candidate_t = {0}\nif xinc_min then\n if xdec_min then\n if xinc_min < xdec_min then\n table.insert(candidate_t, (xdec_min - xinc_min) / 2)\n end\n if xinc_min < xdec_max then\n table.insert(candidate_t, (xdec_max - xinc_min) / 2)\n end\n if xinc_max < xdec_min then\n table.insert(candidate_t, (xdec_min - xinc_max) / 2)\n end\n if xinc_max < xdec_max then\n table.insert(candidate_t, (xdec_max - xinc_max) / 2)\n end\n end\n if cxmin then\n if xinc_min < cxmin then\n table.insert(candidate_t, cxmin - xinc_min)\n end\n if xinc_min < cxmax then\n table.insert(candidate_t, cxmax - xinc_min)\n end\n if xinc_max < cxmin then\n table.insert(candidate_t, cxmin - xinc_max)\n end\n if xinc_max < cxmax then\n table.insert(candidate_t, cxmax - xinc_max)\n end\n end\nend\nif xdec_min then\n if cxmin then\n if xdec_min > cxmin then\n table.insert(candidate_t, -cxmin + xdec_min)\n end\n if xdec_min > cxmax then\n table.insert(candidate_t, -cxmax + xdec_min)\n end\n if xdec_max > cxmin then\n table.insert(candidate_t, -cxmin + xdec_max)\n end\n if xdec_max > cxmax then\n table.insert(candidate_t, -cxmax + xdec_max)\n end\n end\nend\n-- y\nif yinc_min then\n if ydec_min then\n if yinc_min < ydec_min then\n table.insert(candidate_t, (ydec_min - yinc_min) / 2)\n end\n if yinc_min < ydec_max then\n table.insert(candidate_t, (ydec_max - yinc_min) / 2)\n end\n if yinc_max < ydec_min then\n table.insert(candidate_t, (ydec_min - yinc_max) / 2)\n end\n if yinc_max < ydec_max then\n table.insert(candidate_t, (ydec_max - yinc_max) / 2)\n end\n end\n if cymin then\n if yinc_min < cymin then\n table.insert(candidate_t, cymin - yinc_min)\n end\n if yinc_min < cymax then\n table.insert(candidate_t, cymax - yinc_min)\n end\n if yinc_max < cymin then\n table.insert(candidate_t, cymin - yinc_max)\n end\n if yinc_max < cymax then\n table.insert(candidate_t, cymax - yinc_max)\n end\n end\nend\nif ydec_min then\n if cymin then\n if ydec_min > cymin then\n table.insert(candidate_t, -cymin + ydec_min)\n end\n if ydec_min > cymax then\n table.insert(candidate_t, -cymax + ydec_min)\n end\n if ydec_max > cymin then\n table.insert(candidate_t, -cymin + ydec_max)\n end\n if ydec_max > cymax then\n table.insert(candidate_t, -cymax + ydec_max)\n end\n end\nend\n\nlocal ret = nil\nfor i = 1, #candidate_t do\n local time = candidate_t[i]\n local qxmin, qxmax = nil, nil\n local qymin, qymax = nil, nil\n if xdec_min then\n if not qxmin then qxmin, qxmax = xdec_min - time, xdec_max - time\n else qxmin, qxmax = mmi(qxmin, xdec_min - time), mma(qxmax, xdec_max - time)\n end\n end\n if xinc_min then\n if not qxmin then qxmin, qxmax = xinc_min - time, xinc_max - time\n else qxmin, qxmax = mmi(qxmin, xinc_min + time), mma(qxmax, xinc_max + time)\n end\n end\n if cxmin then\n if not qxmin then qxmin, qxmax = cxmin, cxmax\n else qxmin, qxmax = mmi(qxmin, cxmin), mma(qxmax, cxmax)\n end\n end\n\n if ydec_min then\n if not qymin then qymin, qymax = ydec_min - time, ydec_max - time\n else qymin, qymax = mmi(qymin, ydec_min - time), mma(qymax, ydec_max - time)\n end\n end\n if yinc_min then\n if not qymin then qymin, qymax = yinc_min - time, yinc_max - time\n else qymin, qymax = mmi(qymin, yinc_min + time), mma(qymax, yinc_max + time)\n end\n end\n if cymin then\n if not qymin then qymin, qymax = cymin, cymax\n else qymin, qymax = mmi(qymin, cymin), mma(qymax, cymax)\n end\n end\n local tmp = 0\n if qxmin and qymin then\n tmp = (qxmax - qxmin) * (qymax - qymin)\n else\n tmp = 0\n end\n -- print(time, tmp)\n if not ret then ret = tmp\n else ret = mmi(ret, tmp)\n end\nend\nprint(ret)\n", "problem_context": "Score : 600 points\n\nProblem Statement\n\nThere are N points in a two-dimensional plane. The initial coordinates of the i-th point are (x_i, y_i). Now, each point starts moving at a speed of 1 per second, in a direction parallel to the x- or y- axis. You are given a character d_i that represents the specific direction in which the i-th point moves, as follows:\n\nIf d_i = R, the i-th point moves in the positive x direction;\n\nIf d_i = L, the i-th point moves in the negative x direction;\n\nIf d_i = U, the i-th point moves in the positive y direction;\n\nIf d_i = D, the i-th point moves in the negative y direction.\n\nYou can stop all the points at some moment of your choice after they start moving (including the moment they start moving).\nThen, let x_{max} and x_{min} be the maximum and minimum among the x-coordinates of the N points, respectively. Similarly, let y_{max} and y_{min} be the maximum and minimum among the y-coordinates of the N points, respectively.\n\nFind the minimum possible value of (x_{max} - x_{min}) \\times (y_{max} - y_{min}) and print it.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n-10^8 \\leq x_i,\\ y_i \\leq 10^8\n\nx_i and y_i are integers.\n\nd_i is R, L, U, or D.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nx_1 y_1 d_1\nx_2 y_2 d_2\n.\n.\n.\nx_N y_N d_N\n\nOutput\n\nPrint the minimum possible value of (x_{max} - x_{min}) \\times (y_{max} - y_{min}).\n\nThe output will be considered correct when its absolute or relative error from the judge's output is at most 10^{-9}.\n\nSample Input 1\n\n2\n0 3 D\n3 0 L\n\nSample Output 1\n\n0\n\nAfter three seconds, the two points will meet at the origin. The value in question will be 0 at that moment.\n\nSample Input 2\n\n5\n-7 -10 U\n7 -6 U\n-8 7 D\n-3 3 D\n0 -6 R\n\nSample Output 2\n\n97.5\n\nThe answer may not be an integer.\n\nSample Input 3\n\n20\n6 -10 R\n-4 -9 U\n9 6 D\n-3 -2 R\n0 7 D\n4 5 D\n10 -10 U\n-1 -8 U\n10 -6 D\n8 -5 U\n6 4 D\n0 3 D\n7 9 R\n9 -4 R\n3 10 D\n1 9 U\n1 -6 U\n9 -8 R\n6 7 D\n7 -3 D\n\nSample Output 3\n\n273", "sample_input": "2\n0 3 D\n3 0 L\n"}, "reference_outputs": ["0\n"], "source_document_id": "p03004", "source_text": "Score : 600 points\n\nProblem Statement\n\nThere are N points in a two-dimensional plane. The initial coordinates of the i-th point are (x_i, y_i). Now, each point starts moving at a speed of 1 per second, in a direction parallel to the x- or y- axis. You are given a character d_i that represents the specific direction in which the i-th point moves, as follows:\n\nIf d_i = R, the i-th point moves in the positive x direction;\n\nIf d_i = L, the i-th point moves in the negative x direction;\n\nIf d_i = U, the i-th point moves in the positive y direction;\n\nIf d_i = D, the i-th point moves in the negative y direction.\n\nYou can stop all the points at some moment of your choice after they start moving (including the moment they start moving).\nThen, let x_{max} and x_{min} be the maximum and minimum among the x-coordinates of the N points, respectively. Similarly, let y_{max} and y_{min} be the maximum and minimum among the y-coordinates of the N points, respectively.\n\nFind the minimum possible value of (x_{max} - x_{min}) \\times (y_{max} - y_{min}) and print it.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n-10^8 \\leq x_i,\\ y_i \\leq 10^8\n\nx_i and y_i are integers.\n\nd_i is R, L, U, or D.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nx_1 y_1 d_1\nx_2 y_2 d_2\n.\n.\n.\nx_N y_N d_N\n\nOutput\n\nPrint the minimum possible value of (x_{max} - x_{min}) \\times (y_{max} - y_{min}).\n\nThe output will be considered correct when its absolute or relative error from the judge's output is at most 10^{-9}.\n\nSample Input 1\n\n2\n0 3 D\n3 0 L\n\nSample Output 1\n\n0\n\nAfter three seconds, the two points will meet at the origin. The value in question will be 0 at that moment.\n\nSample Input 2\n\n5\n-7 -10 U\n7 -6 U\n-8 7 D\n-3 3 D\n0 -6 R\n\nSample Output 2\n\n97.5\n\nThe answer may not be an integer.\n\nSample Input 3\n\n20\n6 -10 R\n-4 -9 U\n9 6 D\n-3 -2 R\n0 7 D\n4 5 D\n10 -10 U\n-1 -8 U\n10 -6 D\n8 -5 U\n6 4 D\n0 3 D\n7 9 R\n9 -4 R\n3 10 D\n1 9 U\n1 -6 U\n9 -8 R\n6 7 D\n7 -3 D\n\nSample Output 3\n\n273", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 5465, "cpu_time_ms": 95, "memory_kb": 384}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s456452963", "group_id": "codeNet:p03005", "input_text": "local n, k = io.read(\"*n\", \"*n\")\nif k == 1 then print(0) else print(n - k) end", "language": "Lua", "metadata": {"date": 1560646921, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03005.html", "problem_id": "p03005", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03005/input.txt", "sample_output_relpath": "derived/input_output/data/p03005/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03005/Lua/s456452963.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s456452963", "user_id": "u120582723"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "local n, k = io.read(\"*n\", \"*n\")\nif k == 1 then print(0) else print(n - k) end", "problem_context": "Score : 100 points\n\nProblem Statement\n\nTakahashi is distributing N balls to K persons.\n\nIf each person has to receive at least one ball, what is the maximum possible difference in the number of balls received between the person with the most balls and the person with the fewest balls?\n\nConstraints\n\n1 \\leq K \\leq N \\leq 100\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\n\nOutput\n\nPrint the maximum possible difference in the number of balls received.\n\nSample Input 1\n\n3 2\n\nSample Output 1\n\n1\n\nThe only way to distribute three balls to two persons so that each of them receives at least one ball is to give one ball to one person and give two balls to the other person.\n\nThus, the maximum possible difference in the number of balls received is 1.\n\nSample Input 2\n\n3 1\n\nSample Output 2\n\n0\n\nWe have no choice but to give three balls to the only person, in which case the difference in the number of balls received is 0.\n\nSample Input 3\n\n8 5\n\nSample Output 3\n\n3\n\nFor example, if we give 1, 4, 1, 1, 1 balls to the five persons, the number of balls received between the person with the most balls and the person with the fewest balls would be 3, which is the maximum result.", "sample_input": "3 2\n"}, "reference_outputs": ["1\n"], "source_document_id": "p03005", "source_text": "Score : 100 points\n\nProblem Statement\n\nTakahashi is distributing N balls to K persons.\n\nIf each person has to receive at least one ball, what is the maximum possible difference in the number of balls received between the person with the most balls and the person with the fewest balls?\n\nConstraints\n\n1 \\leq K \\leq N \\leq 100\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\n\nOutput\n\nPrint the maximum possible difference in the number of balls received.\n\nSample Input 1\n\n3 2\n\nSample Output 1\n\n1\n\nThe only way to distribute three balls to two persons so that each of them receives at least one ball is to give one ball to one person and give two balls to the other person.\n\nThus, the maximum possible difference in the number of balls received is 1.\n\nSample Input 2\n\n3 1\n\nSample Output 2\n\n0\n\nWe have no choice but to give three balls to the only person, in which case the difference in the number of balls received is 0.\n\nSample Input 3\n\n8 5\n\nSample Output 3\n\n3\n\nFor example, if we give 1, 4, 1, 1, 1 balls to the five persons, the number of balls received between the person with the most balls and the person with the fewest balls would be 3, which is the maximum result.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 78, "cpu_time_ms": 8, "memory_kb": 1008}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s664293359", "group_id": "codeNet:p03006", "input_text": "local mce, mfl, msq, mmi, mma = math.ceil, math.floor, math.sqrt, math.min, math.max\nlocal n = io.read(\"*n\")\nlocal t = {}\nfor i = 1, n do\n t[i] = {}\n t[i].x, t[i].y = io.read(\"*n\", \"*n\")\nend\ntable.sort(t, function(v, w)\n if v.x == w.x then\n return v.y < w.y\n else\n return v.x < w.x\n end\nend\n)\n\nlocal function getcost(p, q)\n local cost = 0\n if p == 0 then\n local done = 0\n local donelist = {}\n for i = 1, n do donelist[i] = false end\n while done < n do\n cost = cost + 1\n local idx = 1\n for i = 1, n do\n if donelist[i] then idx = i break end\n end\n donelist[idx] = true\n done = done + 1\n local nx, ny = t[idx].x, t[idx].y + q\n local rep = true\n while rep do\n rep = false\n for i = 1, n do\n if nx == t[i].x and ny == t[i].y and not donelist[i] then\n ny = ny + q\n donelist[i] = true\n done = done + 1\n rep = true\n end\n end\n end\n end\n else\n local done = 0\n local donelist = {}\n for i = 1, n do donelist[i] = false end\n while done < n do\n cost = cost + 1\n local idx = 1\n for i = 1, n do\n if donelist[i] then idx = i break end\n end\n donelist[idx] = true\n done = done + 1\n local nx, ny = t[idx].x + p, t[idx].y + q\n for i = idx + 1, n do\n if nx == t[i].x and ny == t[i].y then\n nx, ny = nx + p, ny + q\n donelist[i] = true\n done = done + 1\n end\n end\n end\n end\n return cost\nend\n\nlocal ret = 50\nfor i = 1, n - 1 do\n for j = i + 1, n do\n local c = getcost(t[j].x - t[i].x, t[j].y - t[i].y)\n ret = mmi(ret, c)\n end\nend\nprint(ret)\n", "language": "Lua", "metadata": {"date": 1560648196, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p03006.html", "problem_id": "p03006", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03006/input.txt", "sample_output_relpath": "derived/input_output/data/p03006/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03006/Lua/s664293359.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s664293359", "user_id": "u120582723"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "local mce, mfl, msq, mmi, mma = math.ceil, math.floor, math.sqrt, math.min, math.max\nlocal n = io.read(\"*n\")\nlocal t = {}\nfor i = 1, n do\n t[i] = {}\n t[i].x, t[i].y = io.read(\"*n\", \"*n\")\nend\ntable.sort(t, function(v, w)\n if v.x == w.x then\n return v.y < w.y\n else\n return v.x < w.x\n end\nend\n)\n\nlocal function getcost(p, q)\n local cost = 0\n if p == 0 then\n local done = 0\n local donelist = {}\n for i = 1, n do donelist[i] = false end\n while done < n do\n cost = cost + 1\n local idx = 1\n for i = 1, n do\n if donelist[i] then idx = i break end\n end\n donelist[idx] = true\n done = done + 1\n local nx, ny = t[idx].x, t[idx].y + q\n local rep = true\n while rep do\n rep = false\n for i = 1, n do\n if nx == t[i].x and ny == t[i].y and not donelist[i] then\n ny = ny + q\n donelist[i] = true\n done = done + 1\n rep = true\n end\n end\n end\n end\n else\n local done = 0\n local donelist = {}\n for i = 1, n do donelist[i] = false end\n while done < n do\n cost = cost + 1\n local idx = 1\n for i = 1, n do\n if donelist[i] then idx = i break end\n end\n donelist[idx] = true\n done = done + 1\n local nx, ny = t[idx].x + p, t[idx].y + q\n for i = idx + 1, n do\n if nx == t[i].x and ny == t[i].y then\n nx, ny = nx + p, ny + q\n donelist[i] = true\n done = done + 1\n end\n end\n end\n end\n return cost\nend\n\nlocal ret = 50\nfor i = 1, n - 1 do\n for j = i + 1, n do\n local c = getcost(t[j].x - t[i].x, t[j].y - t[i].y)\n ret = mmi(ret, c)\n end\nend\nprint(ret)\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere are N balls in a two-dimensional plane. The i-th ball is at coordinates (x_i, y_i).\n\nWe will collect all of these balls, by choosing two integers p and q such that p \\neq 0 or q \\neq 0 and then repeating the following operation:\n\nChoose a ball remaining in the plane and collect it. Let (a, b) be the coordinates of this ball. If we collected a ball at coordinates (a - p, b - q) in the previous operation, the cost of this operation is 0. Otherwise, including when this is the first time to do this operation, the cost of this operation is 1.\n\nFind the minimum total cost required to collect all the balls when we optimally choose p and q.\n\nConstraints\n\n1 \\leq N \\leq 50\n\n|x_i|, |y_i| \\leq 10^9\n\nIf i \\neq j, x_i \\neq x_j or y_i \\neq y_j.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nx_1 y_1\n:\nx_N y_N\n\nOutput\n\nPrint the minimum total cost required to collect all the balls.\n\nSample Input 1\n\n2\n1 1\n2 2\n\nSample Output 1\n\n1\n\nIf we choose p = 1, q = 1, we can collect all the balls at a cost of 1 by collecting them in the order (1, 1), (2, 2).\n\nSample Input 2\n\n3\n1 4\n4 6\n7 8\n\nSample Output 2\n\n1\n\nIf we choose p = -3, q = -2, we can collect all the balls at a cost of 1 by collecting them in the order (7, 8), (4, 6), (1, 4).\n\nSample Input 3\n\n4\n1 1\n1 2\n2 1\n2 2\n\nSample Output 3\n\n2", "sample_input": "2\n1 1\n2 2\n"}, "reference_outputs": ["1\n"], "source_document_id": "p03006", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere are N balls in a two-dimensional plane. The i-th ball is at coordinates (x_i, y_i).\n\nWe will collect all of these balls, by choosing two integers p and q such that p \\neq 0 or q \\neq 0 and then repeating the following operation:\n\nChoose a ball remaining in the plane and collect it. Let (a, b) be the coordinates of this ball. If we collected a ball at coordinates (a - p, b - q) in the previous operation, the cost of this operation is 0. Otherwise, including when this is the first time to do this operation, the cost of this operation is 1.\n\nFind the minimum total cost required to collect all the balls when we optimally choose p and q.\n\nConstraints\n\n1 \\leq N \\leq 50\n\n|x_i|, |y_i| \\leq 10^9\n\nIf i \\neq j, x_i \\neq x_j or y_i \\neq y_j.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nx_1 y_1\n:\nx_N y_N\n\nOutput\n\nPrint the minimum total cost required to collect all the balls.\n\nSample Input 1\n\n2\n1 1\n2 2\n\nSample Output 1\n\n1\n\nIf we choose p = 1, q = 1, we can collect all the balls at a cost of 1 by collecting them in the order (1, 1), (2, 2).\n\nSample Input 2\n\n3\n1 4\n4 6\n7 8\n\nSample Output 2\n\n1\n\nIf we choose p = -3, q = -2, we can collect all the balls at a cost of 1 by collecting them in the order (7, 8), (4, 6), (1, 4).\n\nSample Input 3\n\n4\n1 1\n1 2\n2 1\n2 2\n\nSample Output 3\n\n2", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1701, "cpu_time_ms": 26, "memory_kb": 384}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s952792484", "group_id": "codeNet:p03008", "input_text": "local mce, mfl, msq, mmi, mma = math.ceil, math.floor, math.sqrt, math.min, math.max\n\nlocal n = io.read(\"*n\")\nlocal ga, sa, ba = io.read(\"*n\", \"*n\", \"*n\")\nlocal gb, sb, bb = io.read(\"*n\", \"*n\", \"*n\")\n\nlocal dp = {}\nfor i = 1, n do\n dp[i] = 0\nend\nif ga < gb then\n local max = mfl(n / ga)\n for i = 1, max do\n dp[i * ga] = i * gb\n end\nend\nif sa < sb then\n for i = n - 1, 1, -1 do\n if 0 < dp[i] then\n local addable = mfl((n - i) / sa)\n for j = 1, addable do\n dp[i + j * sa] = mma(dp[i + j * sa], dp[i] + j * sb)\n end\n end\n end\n local max = mfl(n / sa)\n for i = 1, max do\n dp[i * sa] = mma(dp[i * sa], i * sb)\n end\nend\nif ba < bb then\n for i = n - 1, 1, -1 do\n if 0 < dp[i] then\n local addable = mfl((n - i) / ba)\n for j = 1, addable do\n dp[i + j * ba] = mma(dp[i + j * ba], dp[i] + j * bb)\n end\n end\n end\n local max = mfl(n / ba)\n for i = 1, max do\n dp[i * ba] = mma(dp[i * ba], i * bb)\n end\nend\nlocal newn = n\nfor i = 1, n do\n newn = mma(newn, dp[i])\nend\nn = newn\n\n-- B to A\ndp = {}\nfor i = 1, n do\n dp[i] = 0\nend\nif gb < ga then\n local max = mfl(n / gb)\n for i = 1, max do\n dp[i * gb] = i * ga\n end\nend\nif sb < sa then\n for i = n - 1, 1, -1 do\n if 0 < dp[i] then\n local addable = mfl((n - i) / sb)\n for j = 1, addable do\n dp[i + j * sb] = mma(dp[i + j * sb], dp[i] + j * sa)\n end\n end\n end\n local max = mfl(n / sb)\n for i = 1, max do\n dp[i * sb] = mma(dp[i * sb], i * sa)\n end\nend\nif bb < ba then\n for i = n - 1, 1, -1 do\n if 0 < dp[i] then\n local addable = mfl((n - i) / bb)\n for j = 1, addable do\n dp[i + j * bb] = mma(dp[i + j * bb], dp[i] + j * ba)\n end\n end\n end\n local max = mfl(n / bb)\n for i = 1, max do\n dp[i * bb] = mma(dp[i * bb], i * ba)\n end\nend\nlocal newn = n\nfor i = 1, n do\n newn = mma(newn, dp[i])\nend\nprint(newn)\n", "language": "Lua", "metadata": {"date": 1560651171, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p03008.html", "problem_id": "p03008", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03008/input.txt", "sample_output_relpath": "derived/input_output/data/p03008/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03008/Lua/s952792484.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s952792484", "user_id": "u120582723"}, "prompt_components": {"gold_output": "46\n", "input_to_evaluate": "local mce, mfl, msq, mmi, mma = math.ceil, math.floor, math.sqrt, math.min, math.max\n\nlocal n = io.read(\"*n\")\nlocal ga, sa, ba = io.read(\"*n\", \"*n\", \"*n\")\nlocal gb, sb, bb = io.read(\"*n\", \"*n\", \"*n\")\n\nlocal dp = {}\nfor i = 1, n do\n dp[i] = 0\nend\nif ga < gb then\n local max = mfl(n / ga)\n for i = 1, max do\n dp[i * ga] = i * gb\n end\nend\nif sa < sb then\n for i = n - 1, 1, -1 do\n if 0 < dp[i] then\n local addable = mfl((n - i) / sa)\n for j = 1, addable do\n dp[i + j * sa] = mma(dp[i + j * sa], dp[i] + j * sb)\n end\n end\n end\n local max = mfl(n / sa)\n for i = 1, max do\n dp[i * sa] = mma(dp[i * sa], i * sb)\n end\nend\nif ba < bb then\n for i = n - 1, 1, -1 do\n if 0 < dp[i] then\n local addable = mfl((n - i) / ba)\n for j = 1, addable do\n dp[i + j * ba] = mma(dp[i + j * ba], dp[i] + j * bb)\n end\n end\n end\n local max = mfl(n / ba)\n for i = 1, max do\n dp[i * ba] = mma(dp[i * ba], i * bb)\n end\nend\nlocal newn = n\nfor i = 1, n do\n newn = mma(newn, dp[i])\nend\nn = newn\n\n-- B to A\ndp = {}\nfor i = 1, n do\n dp[i] = 0\nend\nif gb < ga then\n local max = mfl(n / gb)\n for i = 1, max do\n dp[i * gb] = i * ga\n end\nend\nif sb < sa then\n for i = n - 1, 1, -1 do\n if 0 < dp[i] then\n local addable = mfl((n - i) / sb)\n for j = 1, addable do\n dp[i + j * sb] = mma(dp[i + j * sb], dp[i] + j * sa)\n end\n end\n end\n local max = mfl(n / sb)\n for i = 1, max do\n dp[i * sb] = mma(dp[i * sb], i * sa)\n end\nend\nif bb < ba then\n for i = n - 1, 1, -1 do\n if 0 < dp[i] then\n local addable = mfl((n - i) / bb)\n for j = 1, addable do\n dp[i + j * bb] = mma(dp[i + j * bb], dp[i] + j * ba)\n end\n end\n end\n local max = mfl(n / bb)\n for i = 1, max do\n dp[i * bb] = mma(dp[i * bb], i * ba)\n end\nend\nlocal newn = n\nfor i = 1, n do\n newn = mma(newn, dp[i])\nend\nprint(newn)\n", "problem_context": "Score : 600 points\n\nProblem Statement\n\nThe squirrel Chokudai has N acorns.\nOne day, he decides to do some trades in multiple precious metal exchanges to make more acorns.\n\nHis plan is as follows:\n\nGet out of the nest with N acorns in his hands.\n\nGo to Exchange A and do some trades.\n\nGo to Exchange B and do some trades.\n\nGo to Exchange A and do some trades.\n\nGo back to the nest.\n\nIn Exchange X (X = A, B), he can perform the following operations any integer number of times (possibly zero) in any order:\n\nLose g_{X} acorns and gain 1 gram of gold.\n\nGain g_{X} acorns and lose 1 gram of gold.\n\nLose s_{X} acorns and gain 1 gram of silver.\n\nGain s_{X} acorns and lose 1 gram of silver.\n\nLose b_{X} acorns and gain 1 gram of bronze.\n\nGain b_{X} acorns and lose 1 gram of bronze.\n\nNaturally, he cannot perform an operation that would leave him with a negative amount of acorns, gold, silver, or bronze.\n\nWhat is the maximum number of acorns that he can bring to the nest?\nNote that gold, silver, or bronze brought to the nest would be worthless because he is just a squirrel.\n\nConstraints\n\n1 \\leq N \\leq 5000\n\n1 \\leq g_{X} \\leq 5000\n\n1 \\leq s_{X} \\leq 5000\n\n1 \\leq b_{X} \\leq 5000\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\ng_A s_A b_A\ng_B s_B b_B\n\nOutput\n\nPrint the maximum number of acorns that Chokudai can bring to the nest.\n\nSample Input 1\n\n23\n1 1 1\n2 1 1\n\nSample Output 1\n\n46\n\nHe can bring 46 acorns to the nest, as follows:\n\nIn Exchange A, trade 23 acorns for 23 grams of gold. {acorns, gold, silver, bronze}={ 0,23,0,0 }\n\nIn Exchange B, trade 23 grams of gold for 46 acorns. {acorns, gold, silver, bronze}={ 46,0,0,0 }\n\nIn Exchange A, trade nothing. {acorns, gold, silver, bronze}={ 46,0,0,0 }\n\nHe cannot have 47 or more acorns, so the answer is 46.", "sample_input": "23\n1 1 1\n2 1 1\n"}, "reference_outputs": ["46\n"], "source_document_id": "p03008", "source_text": "Score : 600 points\n\nProblem Statement\n\nThe squirrel Chokudai has N acorns.\nOne day, he decides to do some trades in multiple precious metal exchanges to make more acorns.\n\nHis plan is as follows:\n\nGet out of the nest with N acorns in his hands.\n\nGo to Exchange A and do some trades.\n\nGo to Exchange B and do some trades.\n\nGo to Exchange A and do some trades.\n\nGo back to the nest.\n\nIn Exchange X (X = A, B), he can perform the following operations any integer number of times (possibly zero) in any order:\n\nLose g_{X} acorns and gain 1 gram of gold.\n\nGain g_{X} acorns and lose 1 gram of gold.\n\nLose s_{X} acorns and gain 1 gram of silver.\n\nGain s_{X} acorns and lose 1 gram of silver.\n\nLose b_{X} acorns and gain 1 gram of bronze.\n\nGain b_{X} acorns and lose 1 gram of bronze.\n\nNaturally, he cannot perform an operation that would leave him with a negative amount of acorns, gold, silver, or bronze.\n\nWhat is the maximum number of acorns that he can bring to the nest?\nNote that gold, silver, or bronze brought to the nest would be worthless because he is just a squirrel.\n\nConstraints\n\n1 \\leq N \\leq 5000\n\n1 \\leq g_{X} \\leq 5000\n\n1 \\leq s_{X} \\leq 5000\n\n1 \\leq b_{X} \\leq 5000\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\ng_A s_A b_A\ng_B s_B b_B\n\nOutput\n\nPrint the maximum number of acorns that Chokudai can bring to the nest.\n\nSample Input 1\n\n23\n1 1 1\n2 1 1\n\nSample Output 1\n\n46\n\nHe can bring 46 acorns to the nest, as follows:\n\nIn Exchange A, trade 23 acorns for 23 grams of gold. {acorns, gold, silver, bronze}={ 0,23,0,0 }\n\nIn Exchange B, trade 23 grams of gold for 46 acorns. {acorns, gold, silver, bronze}={ 46,0,0,0 }\n\nIn Exchange A, trade nothing. {acorns, gold, silver, bronze}={ 46,0,0,0 }\n\nHe cannot have 47 or more acorns, so the answer is 46.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1889, "cpu_time_ms": 2105, "memory_kb": 264572}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s264730505", "group_id": "codeNet:p03011", "input_text": "a, b, c = io.read(\"*n\", \"*n\", \"*n\")\nprint(a + b + c - math.max(a, b, c))\n", "language": "Lua", "metadata": {"date": 1597605045, "filename_ext": "lua", "original_language": "Lua (Lua 5.3.5)", "problem_description_relpath": "problem_descriptions/p03011.html", "problem_id": "p03011", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03011/input.txt", "sample_output_relpath": "derived/input_output/data/p03011/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03011/Lua/s264730505.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s264730505", "user_id": "u120582723"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "a, b, c = io.read(\"*n\", \"*n\", \"*n\")\nprint(a + b + c - math.max(a, b, c))\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nThere are three airports A, B and C, and flights between each pair of airports in both directions.\n\nA one-way flight between airports A and B takes P hours, a one-way flight between airports B and C takes Q hours, and a one-way flight between airports C and A takes R hours.\n\nConsider a route where we start at one of the airports, fly to another airport and then fly to the other airport.\n\nWhat is the minimum possible sum of the flight times?\n\nConstraints\n\n1 \\leq P,Q,R \\leq 100\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nP Q R\n\nOutput\n\nPrint the minimum possible sum of the flight times.\n\nSample Input 1\n\n1 3 4\n\nSample Output 1\n\n4\n\nThe sum of the flight times in the route A \\rightarrow B \\rightarrow C: 1 + 3 = 4 hours\n\nThe sum of the flight times in the route A \\rightarrow C \\rightarrow C: 4 + 3 = 7 hours\n\nThe sum of the flight times in the route B \\rightarrow A \\rightarrow C: 1 + 4 = 5 hours\n\nThe sum of the flight times in the route B \\rightarrow C \\rightarrow A: 3 + 4 = 7 hours\n\nThe sum of the flight times in the route C \\rightarrow A \\rightarrow B: 4 + 1 = 5 hours\n\nThe sum of the flight times in the route C \\rightarrow B \\rightarrow A: 3 + 1 = 4 hours\n\nThe minimum of these is 4 hours.\n\nSample Input 2\n\n3 2 3\n\nSample Output 2\n\n5", "sample_input": "1 3 4\n"}, "reference_outputs": ["4\n"], "source_document_id": "p03011", "source_text": "Score : 100 points\n\nProblem Statement\n\nThere are three airports A, B and C, and flights between each pair of airports in both directions.\n\nA one-way flight between airports A and B takes P hours, a one-way flight between airports B and C takes Q hours, and a one-way flight between airports C and A takes R hours.\n\nConsider a route where we start at one of the airports, fly to another airport and then fly to the other airport.\n\nWhat is the minimum possible sum of the flight times?\n\nConstraints\n\n1 \\leq P,Q,R \\leq 100\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nP Q R\n\nOutput\n\nPrint the minimum possible sum of the flight times.\n\nSample Input 1\n\n1 3 4\n\nSample Output 1\n\n4\n\nThe sum of the flight times in the route A \\rightarrow B \\rightarrow C: 1 + 3 = 4 hours\n\nThe sum of the flight times in the route A \\rightarrow C \\rightarrow C: 4 + 3 = 7 hours\n\nThe sum of the flight times in the route B \\rightarrow A \\rightarrow C: 1 + 4 = 5 hours\n\nThe sum of the flight times in the route B \\rightarrow C \\rightarrow A: 3 + 4 = 7 hours\n\nThe sum of the flight times in the route C \\rightarrow A \\rightarrow B: 4 + 1 = 5 hours\n\nThe sum of the flight times in the route C \\rightarrow B \\rightarrow A: 3 + 1 = 4 hours\n\nThe minimum of these is 4 hours.\n\nSample Input 2\n\n3 2 3\n\nSample Output 2\n\n5", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 73, "cpu_time_ms": 7, "memory_kb": 2768}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s343096586", "group_id": "codeNet:p03013", "input_text": "local MOD = 1000000007\nlocal N, M = io.read(\"n\", \"n\")\nlocal broken = {}\nfor i=1,N do\n broken[i] = false\nend\nfor i=1,M do\n local a = io.read(\"n\")\n broken[a] = true\nend\n\nlocal dp = {}\ndp[-1] = 0\ndp[0] = 1\nfor i=1,N do\n if broken[i] then\n dp[i] = 0\n else\n dp[i] = (dp[i-1] + dp[i-2]) % MOD\n end\nend\nprint(dp[N])", "language": "Lua", "metadata": {"date": 1565495045, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03013.html", "problem_id": "p03013", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03013/input.txt", "sample_output_relpath": "derived/input_output/data/p03013/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03013/Lua/s343096586.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s343096586", "user_id": "u162773977"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "local MOD = 1000000007\nlocal N, M = io.read(\"n\", \"n\")\nlocal broken = {}\nfor i=1,N do\n broken[i] = false\nend\nfor i=1,M do\n local a = io.read(\"n\")\n broken[a] = true\nend\n\nlocal dp = {}\ndp[-1] = 0\ndp[0] = 1\nfor i=1,N do\n if broken[i] then\n dp[i] = 0\n else\n dp[i] = (dp[i-1] + dp[i-2]) % MOD\n end\nend\nprint(dp[N])", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere is a staircase with N steps. Takahashi is now standing at the foot of the stairs, that is, on the 0-th step.\nHe can climb up one or two steps at a time.\n\nHowever, the treads of the a_1-th, a_2-th, a_3-th, \\ldots, a_M-th steps are broken, so it is dangerous to set foot on those steps.\n\nHow many are there to climb up to the top step, that is, the N-th step, without setting foot on the broken steps?\nFind the count modulo 1\\ 000\\ 000\\ 007.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n0 \\leq M \\leq N-1\n\n1 \\leq a_1 < a_2 < ... < a_M \\leq N-1\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\na_1\na_2\n.\n.\n.\na_M\n\nOutput\n\nPrint the number of ways to climb up the stairs under the condition, modulo 1\\ 000\\ 000\\ 007.\n\nSample Input 1\n\n6 1\n3\n\nSample Output 1\n\n4\n\nThere are four ways to climb up the stairs, as follows:\n\n0 \\to 1 \\to 2 \\to 4 \\to 5 \\to 6\n\n0 \\to 1 \\to 2 \\to 4 \\to 6\n\n0 \\to 2 \\to 4 \\to 5 \\to 6\n\n0 \\to 2 \\to 4 \\to 6\n\nSample Input 2\n\n10 2\n4\n5\n\nSample Output 2\n\n0\n\nThere may be no way to climb up the stairs without setting foot on the broken steps.\n\nSample Input 3\n\n100 5\n1\n23\n45\n67\n89\n\nSample Output 3\n\n608200469\n\nBe sure to print the count modulo 1\\ 000\\ 000\\ 007.", "sample_input": "6 1\n3\n"}, "reference_outputs": ["4\n"], "source_document_id": "p03013", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere is a staircase with N steps. Takahashi is now standing at the foot of the stairs, that is, on the 0-th step.\nHe can climb up one or two steps at a time.\n\nHowever, the treads of the a_1-th, a_2-th, a_3-th, \\ldots, a_M-th steps are broken, so it is dangerous to set foot on those steps.\n\nHow many are there to climb up to the top step, that is, the N-th step, without setting foot on the broken steps?\nFind the count modulo 1\\ 000\\ 000\\ 007.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n0 \\leq M \\leq N-1\n\n1 \\leq a_1 < a_2 < ... < a_M \\leq N-1\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\na_1\na_2\n.\n.\n.\na_M\n\nOutput\n\nPrint the number of ways to climb up the stairs under the condition, modulo 1\\ 000\\ 000\\ 007.\n\nSample Input 1\n\n6 1\n3\n\nSample Output 1\n\n4\n\nThere are four ways to climb up the stairs, as follows:\n\n0 \\to 1 \\to 2 \\to 4 \\to 5 \\to 6\n\n0 \\to 1 \\to 2 \\to 4 \\to 6\n\n0 \\to 2 \\to 4 \\to 5 \\to 6\n\n0 \\to 2 \\to 4 \\to 6\n\nSample Input 2\n\n10 2\n4\n5\n\nSample Output 2\n\n0\n\nThere may be no way to climb up the stairs without setting foot on the broken steps.\n\nSample Input 3\n\n100 5\n1\n23\n45\n67\n89\n\nSample Output 3\n\n608200469\n\nBe sure to print the count modulo 1\\ 000\\ 000\\ 007.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 340, "cpu_time_ms": 31, "memory_kb": 4472}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s895445746", "group_id": "codeNet:p03014", "input_text": "local h,w=io.read(\"n\",\"n\",\"l\")\nlocal s={}\nfor i=1,h do\n local input=io.read()\n s[i]={}\n for j=1,w do\n s[i][j]=input:byte(j)\n end\nend\n\nlocal u,d,l,r={},{},{},{}\nfor j=1,w do\n for i=1,h do\n u[i]=u[i] or {}\n if s[i][j]==35 then\n u[i][j]=0\n else\n if i==1 then\n u[i][j]=1\n else\n u[i][j]=u[i-1][j]+1\n end\n end\n end\nend\nfor j=1,w do\n for i=h,1,-1 do\n d[i]=d[i] or {}\n if s[i][j]==35 then\n d[i][j]=0\n else\n if i==h then\n d[i][j]=1\n else\n d[i][j]=d[i+1][j]+1\n end\n end\n end\nend\nfor i=1,h do\n l[i]={}\n for j=1,w do\n if s[i][j]==35 then\n l[i][j]=0\n else\n if j==1 then\n l[i][j]=1\n else\n l[i][j]=l[i][j-1]+1\n end\n end\n end\nend\nfor i=1,h do\n r[i]={}\n for j=w,1,-1 do\n if s[i][j]==35 then\n r[i][j]=0\n else\n if j==w then\n r[i][j]=1\n else\n r[i][j]=r[i][j+1]+1\n end\n end\n end\nend\n\nlocal max=0\nfor i=1,h do\n for j=1,w do\n max=math.max(max,u[i][j]+d[i][j]+l[i][j]+r[i][j]-3)\n end\nend\nprint(max)", "language": "Lua", "metadata": {"date": 1593690621, "filename_ext": "lua", "original_language": "Lua (LuaJIT 2.1.0)", "problem_description_relpath": "problem_descriptions/p03014.html", "problem_id": "p03014", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03014/input.txt", "sample_output_relpath": "derived/input_output/data/p03014/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03014/Lua/s895445746.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s895445746", "user_id": "u045238009"}, "prompt_components": {"gold_output": "8\n", "input_to_evaluate": "local h,w=io.read(\"n\",\"n\",\"l\")\nlocal s={}\nfor i=1,h do\n local input=io.read()\n s[i]={}\n for j=1,w do\n s[i][j]=input:byte(j)\n end\nend\n\nlocal u,d,l,r={},{},{},{}\nfor j=1,w do\n for i=1,h do\n u[i]=u[i] or {}\n if s[i][j]==35 then\n u[i][j]=0\n else\n if i==1 then\n u[i][j]=1\n else\n u[i][j]=u[i-1][j]+1\n end\n end\n end\nend\nfor j=1,w do\n for i=h,1,-1 do\n d[i]=d[i] or {}\n if s[i][j]==35 then\n d[i][j]=0\n else\n if i==h then\n d[i][j]=1\n else\n d[i][j]=d[i+1][j]+1\n end\n end\n end\nend\nfor i=1,h do\n l[i]={}\n for j=1,w do\n if s[i][j]==35 then\n l[i][j]=0\n else\n if j==1 then\n l[i][j]=1\n else\n l[i][j]=l[i][j-1]+1\n end\n end\n end\nend\nfor i=1,h do\n r[i]={}\n for j=w,1,-1 do\n if s[i][j]==35 then\n r[i][j]=0\n else\n if j==w then\n r[i][j]=1\n else\n r[i][j]=r[i][j+1]+1\n end\n end\n end\nend\n\nlocal max=0\nfor i=1,h do\n for j=1,w do\n max=math.max(max,u[i][j]+d[i][j]+l[i][j]+r[i][j]-3)\n end\nend\nprint(max)", "problem_context": "Score : 400 points\n\nProblem Statement\n\nThere is a grid with H horizontal rows and W vertical columns, and there are obstacles on some of the squares.\n\nSnuke is going to choose one of the squares not occupied by an obstacle and place a lamp on it.\nThe lamp placed on the square will emit straight beams of light in four cardinal directions: up, down, left, and right.\nIn each direction, the beam will continue traveling until it hits a square occupied by an obstacle or it hits the border of the grid. It will light all the squares on the way, including the square on which the lamp is placed, but not the square occupied by an obstacle.\n\nSnuke wants to maximize the number of squares lighted by the lamp.\n\nYou are given H strings S_i (1 \\leq i \\leq H), each of length W. If the j-th character (1 \\leq j \\leq W) of S_i is #, there is an obstacle on the square at the i-th row from the top and the j-th column from the left; if that character is ., there is no obstacle on that square.\n\nFind the maximum possible number of squares lighted by the lamp.\n\nConstraints\n\n1 \\leq H \\leq 2,000\n\n1 \\leq W \\leq 2,000\n\nS_i is a string of length W consisting of # and ..\n\n. occurs at least once in one of the strings S_i (1 \\leq i \\leq H).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\nS_1\n:\nS_H\n\nOutput\n\nPrint the maximum possible number of squares lighted by the lamp.\n\nSample Input 1\n\n4 6\n#..#..\n.....#\n....#.\n#.#...\n\nSample Output 1\n\n8\n\nIf Snuke places the lamp on the square at the second row from the top and the second column from the left, it will light the following squares: the first through fifth squares from the left in the second row, and the first through fourth squares from the top in the second column, for a total of eight squares.\n\nSample Input 2\n\n8 8\n..#...#.\n....#...\n##......\n..###..#\n...#..#.\n##....#.\n#...#...\n###.#..#\n\nSample Output 2\n\n13", "sample_input": "4 6\n#..#..\n.....#\n....#.\n#.#...\n"}, "reference_outputs": ["8\n"], "source_document_id": "p03014", "source_text": "Score : 400 points\n\nProblem Statement\n\nThere is a grid with H horizontal rows and W vertical columns, and there are obstacles on some of the squares.\n\nSnuke is going to choose one of the squares not occupied by an obstacle and place a lamp on it.\nThe lamp placed on the square will emit straight beams of light in four cardinal directions: up, down, left, and right.\nIn each direction, the beam will continue traveling until it hits a square occupied by an obstacle or it hits the border of the grid. It will light all the squares on the way, including the square on which the lamp is placed, but not the square occupied by an obstacle.\n\nSnuke wants to maximize the number of squares lighted by the lamp.\n\nYou are given H strings S_i (1 \\leq i \\leq H), each of length W. If the j-th character (1 \\leq j \\leq W) of S_i is #, there is an obstacle on the square at the i-th row from the top and the j-th column from the left; if that character is ., there is no obstacle on that square.\n\nFind the maximum possible number of squares lighted by the lamp.\n\nConstraints\n\n1 \\leq H \\leq 2,000\n\n1 \\leq W \\leq 2,000\n\nS_i is a string of length W consisting of # and ..\n\n. occurs at least once in one of the strings S_i (1 \\leq i \\leq H).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\nS_1\n:\nS_H\n\nOutput\n\nPrint the maximum possible number of squares lighted by the lamp.\n\nSample Input 1\n\n4 6\n#..#..\n.....#\n....#.\n#.#...\n\nSample Output 1\n\n8\n\nIf Snuke places the lamp on the square at the second row from the top and the second column from the left, it will light the following squares: the first through fifth squares from the left in the second row, and the first through fourth squares from the top in the second column, for a total of eight squares.\n\nSample Input 2\n\n8 8\n..#...#.\n....#...\n##......\n..###..#\n...#..#.\n##....#.\n#...#...\n###.#..#\n\nSample Output 2\n\n13", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1330, "cpu_time_ms": 592, "memory_kb": 166548}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s539041226", "group_id": "codeNet:p03016", "input_text": "local n, a, b, mod = io.read(\"*n\", \"*n\", \"*n\", \"*n\")\n\nlocal function badd(x, y) return (x + y) % mod end\nlocal function bsub(x, y) return (mod + x - y) % mod end\nlocal function bmul(x, y) return (x * y) % mod end\nlocal function modpow(src, pow)\n local res = 1\n while 0 < pow do\n if pow % 2 == 1 then\n res, pow = bmul(res, src), pow - 1\n end\n src, pow = bmul(src, src), pow // 2\n end\n return res\nend\n\nlocal function func(i)\n local c, z = 0, a + b * (i - 1)\n while 0 < z do\n c, z = c + 1, z // 10\n end\n return c\nend\n\nlocal function getright(d, left)\n local min = left\n local max = n\n if d < func(min) then return left - 1 end\n if func(max) == d then return max end\n while 1 < max - min do\n local mid = (min + max) // 2\n if d < func(mid) then max = mid\n else min = mid\n end\n end\n return min\nend\n\nlocal function solve1(d, n)\n if n == 1 then return 1 end\n local add = 0\n local tend = modpow(10, d)\n if n % 2 == 1 then\n add = modpow(tend, n - 1)\n n = n - 1\n end\n n = n // 2\n local v = solve1(d, n)\n v = bmul(v, badd(1, modpow(tend, n)))\n return badd(add, v)\nend\n\nlocal function solve2(d, n)\n if n == 1 then return 0 end\n local add = 0\n local tend = modpow(10, d)\n if n % 2 == 1 then\n add = bmul((n - 1) % mod, modpow(tend, n - 1))\n n = n - 1\n end\n n = n // 2\n local v1 = solve2(d, n)\n v1 = bmul(v1, badd(1, modpow(tend, n)))\n local v2 = solve1(d, n)\n v2 = bmul(v2, bmul(n % mod, modpow(tend, n)))\n return badd(add, badd(v1, v2))\nend\nlocal cur_digsum = 0\nlocal left = 1\nlocal ret = 0\nfor d = 1, 18 do\n local right = getright(d, left)\n if left <= right then\n local s1 = solve1(d, right - left + 1)\n local v1 = bmul(a % mod, s1)\n local v2 = bmul(b % mod, (right - 1) % mod)\n v2 = bmul(v2, s1)\n local v3 = bmul(b % mod, solve2(d, right - left + 1))\n local tend = modpow(10, d)\n ret = bmul(ret, modpow(tend, right - left + 1))\n ret = badd(ret, badd(v1, bsub(v2, v3)))\n cur_digsum = cur_digsum + (right - left + 1) * d\n left = right + 1\n end\n if n < left then break end\nend\nprint(ret)\n", "language": "Lua", "metadata": {"date": 1597338523, "filename_ext": "lua", "original_language": "Lua (Lua 5.3.5)", "problem_description_relpath": "problem_descriptions/p03016.html", "problem_id": "p03016", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03016/input.txt", "sample_output_relpath": "derived/input_output/data/p03016/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03016/Lua/s539041226.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s539041226", "user_id": "u120582723"}, "prompt_components": {"gold_output": "5563\n", "input_to_evaluate": "local n, a, b, mod = io.read(\"*n\", \"*n\", \"*n\", \"*n\")\n\nlocal function badd(x, y) return (x + y) % mod end\nlocal function bsub(x, y) return (mod + x - y) % mod end\nlocal function bmul(x, y) return (x * y) % mod end\nlocal function modpow(src, pow)\n local res = 1\n while 0 < pow do\n if pow % 2 == 1 then\n res, pow = bmul(res, src), pow - 1\n end\n src, pow = bmul(src, src), pow // 2\n end\n return res\nend\n\nlocal function func(i)\n local c, z = 0, a + b * (i - 1)\n while 0 < z do\n c, z = c + 1, z // 10\n end\n return c\nend\n\nlocal function getright(d, left)\n local min = left\n local max = n\n if d < func(min) then return left - 1 end\n if func(max) == d then return max end\n while 1 < max - min do\n local mid = (min + max) // 2\n if d < func(mid) then max = mid\n else min = mid\n end\n end\n return min\nend\n\nlocal function solve1(d, n)\n if n == 1 then return 1 end\n local add = 0\n local tend = modpow(10, d)\n if n % 2 == 1 then\n add = modpow(tend, n - 1)\n n = n - 1\n end\n n = n // 2\n local v = solve1(d, n)\n v = bmul(v, badd(1, modpow(tend, n)))\n return badd(add, v)\nend\n\nlocal function solve2(d, n)\n if n == 1 then return 0 end\n local add = 0\n local tend = modpow(10, d)\n if n % 2 == 1 then\n add = bmul((n - 1) % mod, modpow(tend, n - 1))\n n = n - 1\n end\n n = n // 2\n local v1 = solve2(d, n)\n v1 = bmul(v1, badd(1, modpow(tend, n)))\n local v2 = solve1(d, n)\n v2 = bmul(v2, bmul(n % mod, modpow(tend, n)))\n return badd(add, badd(v1, v2))\nend\nlocal cur_digsum = 0\nlocal left = 1\nlocal ret = 0\nfor d = 1, 18 do\n local right = getright(d, left)\n if left <= right then\n local s1 = solve1(d, right - left + 1)\n local v1 = bmul(a % mod, s1)\n local v2 = bmul(b % mod, (right - 1) % mod)\n v2 = bmul(v2, s1)\n local v3 = bmul(b % mod, solve2(d, right - left + 1))\n local tend = modpow(10, d)\n ret = bmul(ret, modpow(tend, right - left + 1))\n ret = badd(ret, badd(v1, bsub(v2, v3)))\n cur_digsum = cur_digsum + (right - left + 1) * d\n left = right + 1\n end\n if n < left then break end\nend\nprint(ret)\n", "problem_context": "Score : 600 points\n\nProblem Statement\n\nThere is an arithmetic progression with L terms: s_0, s_1, s_2, ... , s_{L-1}.\n\nThe initial term is A, and the common difference is B. That is, s_i = A + B \\times i holds.\n\nConsider 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\nAll values in input are integers.\n\n1 \\leq L, A, B < 10^{18}\n\n2 \\leq M \\leq 10^9\n\nAll terms in the arithmetic progression are less than 10^{18}.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nL A B M\n\nOutput\n\nPrint the remainder when the integer obtained by concatenating the terms is divided by M.\n\nSample Input 1\n\n5 3 4 10007\n\nSample Output 1\n\n5563\n\nOur arithmetic progression is 3, 7, 11, 15, 19, so the answer is 37111519 mod 10007, that is, 5563.\n\nSample Input 2\n\n4 8 1 1000000\n\nSample Output 2\n\n891011\n\nSample Input 3\n\n107 10000000000007 1000000000000007 998244353\n\nSample Output 3\n\n39122908", "sample_input": "5 3 4 10007\n"}, "reference_outputs": ["5563\n"], "source_document_id": "p03016", "source_text": "Score : 600 points\n\nProblem Statement\n\nThere is an arithmetic progression with L terms: s_0, s_1, s_2, ... , s_{L-1}.\n\nThe initial term is A, and the common difference is B. That is, s_i = A + B \\times i holds.\n\nConsider 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\nAll values in input are integers.\n\n1 \\leq L, A, B < 10^{18}\n\n2 \\leq M \\leq 10^9\n\nAll terms in the arithmetic progression are less than 10^{18}.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nL A B M\n\nOutput\n\nPrint the remainder when the integer obtained by concatenating the terms is divided by M.\n\nSample Input 1\n\n5 3 4 10007\n\nSample Output 1\n\n5563\n\nOur arithmetic progression is 3, 7, 11, 15, 19, so the answer is 37111519 mod 10007, that is, 5563.\n\nSample Input 2\n\n4 8 1 1000000\n\nSample Output 2\n\n891011\n\nSample Input 3\n\n107 10000000000007 1000000000000007 998244353\n\nSample Output 3\n\n39122908", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2083, "cpu_time_ms": 67, "memory_kb": 2728}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s761537128", "group_id": "codeNet:p03016", "input_text": "local n, a, b, mod = io.read(\"*n\", \"*n\", \"*n\", \"*n\")\n\nlocal function badd(x, y) return (x + y) % mod end\nlocal function bsub(x, y) return (mod + x - y) % mod end\nlocal function bmul(x, y) return (x * y) % mod end\nlocal function bmul_m(x, y) return (x * y) % (mod - 1) end\nlocal function modpow(src, pow)\n local res = 1\n while 0 < pow do\n if pow % 2 == 1 then\n res, pow = bmul(res, src), pow - 1\n end\n src, pow = bmul(src, src), pow // 2\n end\n return res\nend\n\nlocal function func(i)\n local c, z = 0, a + b * (i - 1)\n while 0 < z do\n c, z = c + 1, z // 10\n end\n return c\nend\n\nlocal function getright(d, left)\n local min = left\n local max = n\n if d < func(min) then return left - 1 end\n if func(max) == d then return max end\n while 1 < max - min do\n local mid = (min + max) // 2\n if d < func(mid) then max = mid\n else min = mid\n end\n end\n return min\nend\n\nlocal function solve1(d, n)\n if n == 1 then return 1 end\n local add = 0\n local tend = modpow(10, d)\n if n % 2 == 1 then\n add = add + modpow(tend, n - 1)\n n = n - 1\n end\n n = n // 2\n local v = solve1(d, n)\n v = bmul(v, badd(1, modpow(tend, n)))\n return badd(add, v)\nend\n\nlocal function solve2(d, n)\n if n == 1 then return 0 end\n local add = 0\n local tend = modpow(10, d)\n if n % 2 == 1 then\n add = add + bmul(n - 1, modpow(tend, n - 1))\n n = n - 1\n end\n n = n // 2\n local v1 = solve2(d, n)\n v1 = bmul(v1, badd(1, modpow(tend, n)))\n local v2 = solve1(d, n)\n v2 = bmul(v2, bmul(n % mod, modpow(tend, n)))\n return badd(add, badd(v1, v2))\nend\n\nlocal cur_digsum = 0\nlocal left = 1\nlocal ret = 0\nfor d = 1, 18 do\n local right = getright(d, left)\n if left <= right then\n local s1 = solve1(d, right - left + 1)\n local v1 = bmul(a % mod, s1)\n local v2 = bmul(b % mod, (right - 1) % mod)\n v2 = bmul(v2, s1)\n local v3 = bmul(b % mod, solve2(d, right - left + 1))\n ret = bmul(ret, modpow(10, bmul_m((right - left + 1), d)))\n ret = badd(ret, badd(v1, bsub(v2, v3)))\n cur_digsum = cur_digsum + (right - left + 1) * d\n left = right + 1\n end\n if n < left then break end\nend\nprint(ret)\n", "language": "Lua", "metadata": {"date": 1597334583, "filename_ext": "lua", "original_language": "Lua (Lua 5.3.5)", "problem_description_relpath": "problem_descriptions/p03016.html", "problem_id": "p03016", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03016/input.txt", "sample_output_relpath": "derived/input_output/data/p03016/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03016/Lua/s761537128.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s761537128", "user_id": "u120582723"}, "prompt_components": {"gold_output": "5563\n", "input_to_evaluate": "local n, a, b, mod = io.read(\"*n\", \"*n\", \"*n\", \"*n\")\n\nlocal function badd(x, y) return (x + y) % mod end\nlocal function bsub(x, y) return (mod + x - y) % mod end\nlocal function bmul(x, y) return (x * y) % mod end\nlocal function bmul_m(x, y) return (x * y) % (mod - 1) end\nlocal function modpow(src, pow)\n local res = 1\n while 0 < pow do\n if pow % 2 == 1 then\n res, pow = bmul(res, src), pow - 1\n end\n src, pow = bmul(src, src), pow // 2\n end\n return res\nend\n\nlocal function func(i)\n local c, z = 0, a + b * (i - 1)\n while 0 < z do\n c, z = c + 1, z // 10\n end\n return c\nend\n\nlocal function getright(d, left)\n local min = left\n local max = n\n if d < func(min) then return left - 1 end\n if func(max) == d then return max end\n while 1 < max - min do\n local mid = (min + max) // 2\n if d < func(mid) then max = mid\n else min = mid\n end\n end\n return min\nend\n\nlocal function solve1(d, n)\n if n == 1 then return 1 end\n local add = 0\n local tend = modpow(10, d)\n if n % 2 == 1 then\n add = add + modpow(tend, n - 1)\n n = n - 1\n end\n n = n // 2\n local v = solve1(d, n)\n v = bmul(v, badd(1, modpow(tend, n)))\n return badd(add, v)\nend\n\nlocal function solve2(d, n)\n if n == 1 then return 0 end\n local add = 0\n local tend = modpow(10, d)\n if n % 2 == 1 then\n add = add + bmul(n - 1, modpow(tend, n - 1))\n n = n - 1\n end\n n = n // 2\n local v1 = solve2(d, n)\n v1 = bmul(v1, badd(1, modpow(tend, n)))\n local v2 = solve1(d, n)\n v2 = bmul(v2, bmul(n % mod, modpow(tend, n)))\n return badd(add, badd(v1, v2))\nend\n\nlocal cur_digsum = 0\nlocal left = 1\nlocal ret = 0\nfor d = 1, 18 do\n local right = getright(d, left)\n if left <= right then\n local s1 = solve1(d, right - left + 1)\n local v1 = bmul(a % mod, s1)\n local v2 = bmul(b % mod, (right - 1) % mod)\n v2 = bmul(v2, s1)\n local v3 = bmul(b % mod, solve2(d, right - left + 1))\n ret = bmul(ret, modpow(10, bmul_m((right - left + 1), d)))\n ret = badd(ret, badd(v1, bsub(v2, v3)))\n cur_digsum = cur_digsum + (right - left + 1) * d\n left = right + 1\n end\n if n < left then break end\nend\nprint(ret)\n", "problem_context": "Score : 600 points\n\nProblem Statement\n\nThere is an arithmetic progression with L terms: s_0, s_1, s_2, ... , s_{L-1}.\n\nThe initial term is A, and the common difference is B. That is, s_i = A + B \\times i holds.\n\nConsider 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\nAll values in input are integers.\n\n1 \\leq L, A, B < 10^{18}\n\n2 \\leq M \\leq 10^9\n\nAll terms in the arithmetic progression are less than 10^{18}.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nL A B M\n\nOutput\n\nPrint the remainder when the integer obtained by concatenating the terms is divided by M.\n\nSample Input 1\n\n5 3 4 10007\n\nSample Output 1\n\n5563\n\nOur arithmetic progression is 3, 7, 11, 15, 19, so the answer is 37111519 mod 10007, that is, 5563.\n\nSample Input 2\n\n4 8 1 1000000\n\nSample Output 2\n\n891011\n\nSample Input 3\n\n107 10000000000007 1000000000000007 998244353\n\nSample Output 3\n\n39122908", "sample_input": "5 3 4 10007\n"}, "reference_outputs": ["5563\n"], "source_document_id": "p03016", "source_text": "Score : 600 points\n\nProblem Statement\n\nThere is an arithmetic progression with L terms: s_0, s_1, s_2, ... , s_{L-1}.\n\nThe initial term is A, and the common difference is B. That is, s_i = A + B \\times i holds.\n\nConsider 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\nAll values in input are integers.\n\n1 \\leq L, A, B < 10^{18}\n\n2 \\leq M \\leq 10^9\n\nAll terms in the arithmetic progression are less than 10^{18}.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nL A B M\n\nOutput\n\nPrint the remainder when the integer obtained by concatenating the terms is divided by M.\n\nSample Input 1\n\n5 3 4 10007\n\nSample Output 1\n\n5563\n\nOur arithmetic progression is 3, 7, 11, 15, 19, so the answer is 37111519 mod 10007, that is, 5563.\n\nSample Input 2\n\n4 8 1 1000000\n\nSample Output 2\n\n891011\n\nSample Input 3\n\n107 10000000000007 1000000000000007 998244353\n\nSample Output 3\n\n39122908", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2127, "cpu_time_ms": 66, "memory_kb": 2804}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s085946569", "group_id": "codeNet:p03017", "input_text": "local n,a,b,c,d=io.read(\"*n\",\"*n\",\"*n\",\"*n\",\"*n\",\"*l\")\nlocal s=io.read()\n\nif cd then\n local flag=true\n for i=a,c-1 do\n if s:sub(i,i+1)==\"##\" then\n flag=false\n end\n end\n for i=b,d-1 do\n if s:sub(i,i+1)==\"##\" then\n flag=false\n end\n end\n if flag then\n flag=false\n for i=b-1,d-1 do\n if s:sub(i,i+2)==\"...\" then\n flag=true\n end\n end\n end\n print(flag and \"Yes\" or \"No\")\nend", "language": "Lua", "metadata": {"date": 1590149301, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03017.html", "problem_id": "p03017", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03017/input.txt", "sample_output_relpath": "derived/input_output/data/p03017/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03017/Lua/s085946569.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s085946569", "user_id": "u045238009"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "local n,a,b,c,d=io.read(\"*n\",\"*n\",\"*n\",\"*n\",\"*n\",\"*l\")\nlocal s=io.read()\n\nif cd then\n local flag=true\n for i=a,c-1 do\n if s:sub(i,i+1)==\"##\" then\n flag=false\n end\n end\n for i=b,d-1 do\n if s:sub(i,i+1)==\"##\" then\n flag=false\n end\n end\n if flag then\n flag=false\n for i=b-1,d-1 do\n if s:sub(i,i+2)==\"...\" then\n flag=true\n end\n end\n end\n print(flag and \"Yes\" or \"No\")\nend", "problem_context": "Score : 400 points\n\nProblem Statement\n\nThere are N squares arranged in a row, numbered 1, 2, ..., N from left to right.\nYou are given a string S of length N consisting of . and #. If the i-th character of S is #, Square i contains a rock; if the i-th character of S is ., Square i is empty.\n\nIn the beginning, Snuke stands on Square A, and Fnuke stands on Square B.\n\nYou can repeat the following operation any number of times:\n\nChoose Snuke or Fnuke, and make him jump one or two squares to the right. The destination must be one of the squares, and it must not contain a rock or the other person.\n\nYou want to repeat this operation so that Snuke will stand on Square C and Fnuke will stand on Square D.\n\nDetermine whether this is possible.\n\nConstraints\n\n4 \\leq N \\leq 200\\ 000\n\nS is a string of length N consisting of . and #.\n\n1 \\leq A, B, C, D \\leq N\n\nSquare A, B, C and D do not contain a rock.\n\nA, B, C and D are all different.\n\nA < B\n\nA < C\n\nB < D\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN A B C D\nS\n\nOutput\n\nPrint Yes if the objective is achievable, and No if it is not.\n\nSample Input 1\n\n7 1 3 6 7\n.#..#..\n\nSample Output 1\n\nYes\n\nThe objective is achievable by, for example, moving the two persons as follows. (A and B represent Snuke and Fnuke, respectively.)\n\nA#B.#..\n\nA#.B#..\n\n.#AB#..\n\n.#A.#B.\n\n.#.A#B.\n\n.#.A#.B\n\n.#..#AB\n\nSample Input 2\n\n7 1 3 7 6\n.#..#..\n\nSample Output 2\n\nNo\n\nSample Input 3\n\n15 1 3 15 13\n...#.#...#.#...\n\nSample Output 3\n\nYes", "sample_input": "7 1 3 6 7\n.#..#..\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03017", "source_text": "Score : 400 points\n\nProblem Statement\n\nThere are N squares arranged in a row, numbered 1, 2, ..., N from left to right.\nYou are given a string S of length N consisting of . and #. If the i-th character of S is #, Square i contains a rock; if the i-th character of S is ., Square i is empty.\n\nIn the beginning, Snuke stands on Square A, and Fnuke stands on Square B.\n\nYou can repeat the following operation any number of times:\n\nChoose Snuke or Fnuke, and make him jump one or two squares to the right. The destination must be one of the squares, and it must not contain a rock or the other person.\n\nYou want to repeat this operation so that Snuke will stand on Square C and Fnuke will stand on Square D.\n\nDetermine whether this is possible.\n\nConstraints\n\n4 \\leq N \\leq 200\\ 000\n\nS is a string of length N consisting of . and #.\n\n1 \\leq A, B, C, D \\leq N\n\nSquare A, B, C and D do not contain a rock.\n\nA, B, C and D are all different.\n\nA < B\n\nA < C\n\nB < D\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN A B C D\nS\n\nOutput\n\nPrint Yes if the objective is achievable, and No if it is not.\n\nSample Input 1\n\n7 1 3 6 7\n.#..#..\n\nSample Output 1\n\nYes\n\nThe objective is achievable by, for example, moving the two persons as follows. (A and B represent Snuke and Fnuke, respectively.)\n\nA#B.#..\n\nA#.B#..\n\n.#AB#..\n\n.#A.#B.\n\n.#.A#B.\n\n.#.A#.B\n\n.#..#AB\n\nSample Input 2\n\n7 1 3 7 6\n.#..#..\n\nSample Output 2\n\nNo\n\nSample Input 3\n\n15 1 3 15 13\n...#.#...#.#...\n\nSample Output 3\n\nYes", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 764, "cpu_time_ms": 33, "memory_kb": 760}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s708812160", "group_id": "codeNet:p03017", "input_text": "local n,a,b,c,d=io.read(\"*n\",\"*n\",\"*n\",\"*n\",\"*n\",\"*l\")\nlocal s=io.read()\nif #s:sub(a,c):match(\"#+\")>1 or #s:sub(b,d):match(\"#+\")>1 then\n print(\"No\")\nelse\n print(\"Yes\")\nend", "language": "Lua", "metadata": {"date": 1590147403, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03017.html", "problem_id": "p03017", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03017/input.txt", "sample_output_relpath": "derived/input_output/data/p03017/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03017/Lua/s708812160.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s708812160", "user_id": "u045238009"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "local n,a,b,c,d=io.read(\"*n\",\"*n\",\"*n\",\"*n\",\"*n\",\"*l\")\nlocal s=io.read()\nif #s:sub(a,c):match(\"#+\")>1 or #s:sub(b,d):match(\"#+\")>1 then\n print(\"No\")\nelse\n print(\"Yes\")\nend", "problem_context": "Score : 400 points\n\nProblem Statement\n\nThere are N squares arranged in a row, numbered 1, 2, ..., N from left to right.\nYou are given a string S of length N consisting of . and #. If the i-th character of S is #, Square i contains a rock; if the i-th character of S is ., Square i is empty.\n\nIn the beginning, Snuke stands on Square A, and Fnuke stands on Square B.\n\nYou can repeat the following operation any number of times:\n\nChoose Snuke or Fnuke, and make him jump one or two squares to the right. The destination must be one of the squares, and it must not contain a rock or the other person.\n\nYou want to repeat this operation so that Snuke will stand on Square C and Fnuke will stand on Square D.\n\nDetermine whether this is possible.\n\nConstraints\n\n4 \\leq N \\leq 200\\ 000\n\nS is a string of length N consisting of . and #.\n\n1 \\leq A, B, C, D \\leq N\n\nSquare A, B, C and D do not contain a rock.\n\nA, B, C and D are all different.\n\nA < B\n\nA < C\n\nB < D\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN A B C D\nS\n\nOutput\n\nPrint Yes if the objective is achievable, and No if it is not.\n\nSample Input 1\n\n7 1 3 6 7\n.#..#..\n\nSample Output 1\n\nYes\n\nThe objective is achievable by, for example, moving the two persons as follows. (A and B represent Snuke and Fnuke, respectively.)\n\nA#B.#..\n\nA#.B#..\n\n.#AB#..\n\n.#A.#B.\n\n.#.A#B.\n\n.#.A#.B\n\n.#..#AB\n\nSample Input 2\n\n7 1 3 7 6\n.#..#..\n\nSample Output 2\n\nNo\n\nSample Input 3\n\n15 1 3 15 13\n...#.#...#.#...\n\nSample Output 3\n\nYes", "sample_input": "7 1 3 6 7\n.#..#..\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03017", "source_text": "Score : 400 points\n\nProblem Statement\n\nThere are N squares arranged in a row, numbered 1, 2, ..., N from left to right.\nYou are given a string S of length N consisting of . and #. If the i-th character of S is #, Square i contains a rock; if the i-th character of S is ., Square i is empty.\n\nIn the beginning, Snuke stands on Square A, and Fnuke stands on Square B.\n\nYou can repeat the following operation any number of times:\n\nChoose Snuke or Fnuke, and make him jump one or two squares to the right. The destination must be one of the squares, and it must not contain a rock or the other person.\n\nYou want to repeat this operation so that Snuke will stand on Square C and Fnuke will stand on Square D.\n\nDetermine whether this is possible.\n\nConstraints\n\n4 \\leq N \\leq 200\\ 000\n\nS is a string of length N consisting of . and #.\n\n1 \\leq A, B, C, D \\leq N\n\nSquare A, B, C and D do not contain a rock.\n\nA, B, C and D are all different.\n\nA < B\n\nA < C\n\nB < D\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN A B C D\nS\n\nOutput\n\nPrint Yes if the objective is achievable, and No if it is not.\n\nSample Input 1\n\n7 1 3 6 7\n.#..#..\n\nSample Output 1\n\nYes\n\nThe objective is achievable by, for example, moving the two persons as follows. (A and B represent Snuke and Fnuke, respectively.)\n\nA#B.#..\n\nA#.B#..\n\n.#AB#..\n\n.#A.#B.\n\n.#.A#B.\n\n.#.A#.B\n\n.#..#AB\n\nSample Input 2\n\n7 1 3 7 6\n.#..#..\n\nSample Output 2\n\nNo\n\nSample Input 3\n\n15 1 3 15 13\n...#.#...#.#...\n\nSample Output 3\n\nYes", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 177, "cpu_time_ms": 8, "memory_kb": 760}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s454905744", "group_id": "codeNet:p03017", "input_text": "local n, a, b, c, d = io.read(\"*n\", \"*n\", \"*n\", \"*n\", \"*n\", \"*l\")\nlocal s = io.read()\n\nlocal function check1(l, r)\n for i = l, r - 1 do\n if s:sub(i, i) == \"#\" and s:sub(i + 1, i + 1) == \"#\" then\n return false\n end\n end\n return true\nend\n\nlocal function check2(l, r)\n for i = l, r - 2 do\n if s:sub(i, i) == \".\" and s:sub(i + 1, i + 1) == \".\" and s:sub(i + 2, i + 2) == \".\" then\n return true\n end\n end\n return false\nend\n\nif c < d then\n local r = check1(a, c) and check1(b, d)\n print(r and \"Yes\" or \"No\")\nelse\n local r = check1(a, c)\n if not r then print(\"No\")\n else\n r = check2(b - 1, d - 1)\n print(r and \"Yes\" or \"No\")\n end\nend\n", "language": "Lua", "metadata": {"date": 1563332951, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03017.html", "problem_id": "p03017", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03017/input.txt", "sample_output_relpath": "derived/input_output/data/p03017/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03017/Lua/s454905744.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s454905744", "user_id": "u120582723"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "local n, a, b, c, d = io.read(\"*n\", \"*n\", \"*n\", \"*n\", \"*n\", \"*l\")\nlocal s = io.read()\n\nlocal function check1(l, r)\n for i = l, r - 1 do\n if s:sub(i, i) == \"#\" and s:sub(i + 1, i + 1) == \"#\" then\n return false\n end\n end\n return true\nend\n\nlocal function check2(l, r)\n for i = l, r - 2 do\n if s:sub(i, i) == \".\" and s:sub(i + 1, i + 1) == \".\" and s:sub(i + 2, i + 2) == \".\" then\n return true\n end\n end\n return false\nend\n\nif c < d then\n local r = check1(a, c) and check1(b, d)\n print(r and \"Yes\" or \"No\")\nelse\n local r = check1(a, c)\n if not r then print(\"No\")\n else\n r = check2(b - 1, d - 1)\n print(r and \"Yes\" or \"No\")\n end\nend\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nThere are N squares arranged in a row, numbered 1, 2, ..., N from left to right.\nYou are given a string S of length N consisting of . and #. If the i-th character of S is #, Square i contains a rock; if the i-th character of S is ., Square i is empty.\n\nIn the beginning, Snuke stands on Square A, and Fnuke stands on Square B.\n\nYou can repeat the following operation any number of times:\n\nChoose Snuke or Fnuke, and make him jump one or two squares to the right. The destination must be one of the squares, and it must not contain a rock or the other person.\n\nYou want to repeat this operation so that Snuke will stand on Square C and Fnuke will stand on Square D.\n\nDetermine whether this is possible.\n\nConstraints\n\n4 \\leq N \\leq 200\\ 000\n\nS is a string of length N consisting of . and #.\n\n1 \\leq A, B, C, D \\leq N\n\nSquare A, B, C and D do not contain a rock.\n\nA, B, C and D are all different.\n\nA < B\n\nA < C\n\nB < D\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN A B C D\nS\n\nOutput\n\nPrint Yes if the objective is achievable, and No if it is not.\n\nSample Input 1\n\n7 1 3 6 7\n.#..#..\n\nSample Output 1\n\nYes\n\nThe objective is achievable by, for example, moving the two persons as follows. (A and B represent Snuke and Fnuke, respectively.)\n\nA#B.#..\n\nA#.B#..\n\n.#AB#..\n\n.#A.#B.\n\n.#.A#B.\n\n.#.A#.B\n\n.#..#AB\n\nSample Input 2\n\n7 1 3 7 6\n.#..#..\n\nSample Output 2\n\nNo\n\nSample Input 3\n\n15 1 3 15 13\n...#.#...#.#...\n\nSample Output 3\n\nYes", "sample_input": "7 1 3 6 7\n.#..#..\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03017", "source_text": "Score : 400 points\n\nProblem Statement\n\nThere are N squares arranged in a row, numbered 1, 2, ..., N from left to right.\nYou are given a string S of length N consisting of . and #. If the i-th character of S is #, Square i contains a rock; if the i-th character of S is ., Square i is empty.\n\nIn the beginning, Snuke stands on Square A, and Fnuke stands on Square B.\n\nYou can repeat the following operation any number of times:\n\nChoose Snuke or Fnuke, and make him jump one or two squares to the right. The destination must be one of the squares, and it must not contain a rock or the other person.\n\nYou want to repeat this operation so that Snuke will stand on Square C and Fnuke will stand on Square D.\n\nDetermine whether this is possible.\n\nConstraints\n\n4 \\leq N \\leq 200\\ 000\n\nS is a string of length N consisting of . and #.\n\n1 \\leq A, B, C, D \\leq N\n\nSquare A, B, C and D do not contain a rock.\n\nA, B, C and D are all different.\n\nA < B\n\nA < C\n\nB < D\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN A B C D\nS\n\nOutput\n\nPrint Yes if the objective is achievable, and No if it is not.\n\nSample Input 1\n\n7 1 3 6 7\n.#..#..\n\nSample Output 1\n\nYes\n\nThe objective is achievable by, for example, moving the two persons as follows. (A and B represent Snuke and Fnuke, respectively.)\n\nA#B.#..\n\nA#.B#..\n\n.#AB#..\n\n.#A.#B.\n\n.#.A#B.\n\n.#.A#.B\n\n.#..#AB\n\nSample Input 2\n\n7 1 3 7 6\n.#..#..\n\nSample Output 2\n\nNo\n\nSample Input 3\n\n15 1 3 15 13\n...#.#...#.#...\n\nSample Output 3\n\nYes", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 666, "cpu_time_ms": 45, "memory_kb": 760}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s910616208", "group_id": "codeNet:p03023", "input_text": "local n = io.read(\"*n\")\nprint(180 * (n - 2))\n", "language": "Lua", "metadata": {"date": 1559437249, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03023.html", "problem_id": "p03023", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03023/input.txt", "sample_output_relpath": "derived/input_output/data/p03023/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03023/Lua/s910616208.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s910616208", "user_id": "u120582723"}, "prompt_components": {"gold_output": "180\n", "input_to_evaluate": "local n = io.read(\"*n\")\nprint(180 * (n - 2))\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nGiven an integer N not less than 3, find the sum of the interior angles of a regular polygon with N sides.\n\nPrint the answer in degrees, but do not print units.\n\nConstraints\n\n3 \\leq N \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint an integer representing the sum of the interior angles of a regular polygon with N sides.\n\nSample Input 1\n\n3\n\nSample Output 1\n\n180\n\nThe sum of the interior angles of a regular triangle is 180 degrees.\n\nSample Input 2\n\n100\n\nSample Output 2\n\n17640", "sample_input": "3\n"}, "reference_outputs": ["180\n"], "source_document_id": "p03023", "source_text": "Score : 100 points\n\nProblem Statement\n\nGiven an integer N not less than 3, find the sum of the interior angles of a regular polygon with N sides.\n\nPrint the answer in degrees, but do not print units.\n\nConstraints\n\n3 \\leq N \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint an integer representing the sum of the interior angles of a regular polygon with N sides.\n\nSample Input 1\n\n3\n\nSample Output 1\n\n180\n\nThe sum of the interior angles of a regular triangle is 180 degrees.\n\nSample Input 2\n\n100\n\nSample Output 2\n\n17640", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 45, "cpu_time_ms": 10, "memory_kb": 760}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s529498113", "group_id": "codeNet:p03027", "input_text": "local bls, brs = bit.lshift, bit.rshift\nlocal mod = 1000003\nlocal function badd(x, y) return (x + y) % mod end\nlocal function bmul(x, y) return (x * y) % mod end\n\nlocal function modpow(src, pow)\n local res = 1\n while 0 < pow do\n if pow % 2 == 1 then\n res = bmul(res, src)\n pow = pow - 1\n end\n src = bmul(src, src)\n pow = brs(pow, 1)\n end\n return res\nend\n\nlocal function modinv(src)\n return modpow(src, mod - 2)\nend\n\nlocal fact = {1}\nfor i = 2, mod - 1 do\n fact[i] = bmul(fact[i - 1], i)\nend\n\nlocal q = io.read(\"*n\")\nfor iq = 1, q do\n local x, d, n = io.read(\"*n\", \"*n\", \"*n\")\n if d == 0 then\n print(modpow(x, n))\n else\n local a = bmul(x, modinv(d))\n local lim = a + n - 1\n if mod <= lim then\n print(0)\n else\n local numer = fact[lim]\n numer = bmul(numer, modpow(d, n))\n local denom = 1\n if 1 < a then\n denom = fact[a - 1]\n end\n local ret = bmul(numer, modinv(denom))\n print(ret)\n end\n end\nend\n", "language": "Lua", "metadata": {"date": 1585348839, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p03027.html", "problem_id": "p03027", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03027/input.txt", "sample_output_relpath": "derived/input_output/data/p03027/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03027/Lua/s529498113.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s529498113", "user_id": "u120582723"}, "prompt_components": {"gold_output": "9009\n916936\n", "input_to_evaluate": "local bls, brs = bit.lshift, bit.rshift\nlocal mod = 1000003\nlocal function badd(x, y) return (x + y) % mod end\nlocal function bmul(x, y) return (x * y) % mod end\n\nlocal function modpow(src, pow)\n local res = 1\n while 0 < pow do\n if pow % 2 == 1 then\n res = bmul(res, src)\n pow = pow - 1\n end\n src = bmul(src, src)\n pow = brs(pow, 1)\n end\n return res\nend\n\nlocal function modinv(src)\n return modpow(src, mod - 2)\nend\n\nlocal fact = {1}\nfor i = 2, mod - 1 do\n fact[i] = bmul(fact[i - 1], i)\nend\n\nlocal q = io.read(\"*n\")\nfor iq = 1, q do\n local x, d, n = io.read(\"*n\", \"*n\", \"*n\")\n if d == 0 then\n print(modpow(x, n))\n else\n local a = bmul(x, modinv(d))\n local lim = a + n - 1\n if mod <= lim then\n print(0)\n else\n local numer = fact[lim]\n numer = bmul(numer, modpow(d, n))\n local denom = 1\n if 1 < a then\n denom = fact[a - 1]\n end\n local ret = bmul(numer, modinv(denom))\n print(ret)\n end\n end\nend\n", "problem_context": "Score : 600 points\n\nProblem Statement\n\nConsider the following arithmetic progression with n terms:\n\nx, x + d, x + 2d, \\ldots, x + (n-1)d\n\nWhat is the product of all terms in this sequence?\nCompute the answer modulo 1\\ 000\\ 003.\n\nYou are given Q queries of this form.\nIn the i-th query, compute the answer in case x = x_i, d = d_i, n = n_i.\n\nConstraints\n\n1 \\leq Q \\leq 10^5\n\n0 \\leq x_i, d_i \\leq 1\\ 000\\ 002\n\n1 \\leq n_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nQ\nx_1 d_1 n_1\n:\nx_Q d_Q n_Q\n\nOutput\n\nPrint Q lines.\n\nIn the i-th line, print the answer for the i-th query.\n\nSample Input 1\n\n2\n7 2 4\n12345 67890 2019\n\nSample Output 1\n\n9009\n916936\n\nFor the first query, the answer is 7 \\times 9 \\times 11 \\times 13 = 9009.\nDon't forget to compute the answer modulo 1\\ 000\\ 003.", "sample_input": "2\n7 2 4\n12345 67890 2019\n"}, "reference_outputs": ["9009\n916936\n"], "source_document_id": "p03027", "source_text": "Score : 600 points\n\nProblem Statement\n\nConsider the following arithmetic progression with n terms:\n\nx, x + d, x + 2d, \\ldots, x + (n-1)d\n\nWhat is the product of all terms in this sequence?\nCompute the answer modulo 1\\ 000\\ 003.\n\nYou are given Q queries of this form.\nIn the i-th query, compute the answer in case x = x_i, d = d_i, n = n_i.\n\nConstraints\n\n1 \\leq Q \\leq 10^5\n\n0 \\leq x_i, d_i \\leq 1\\ 000\\ 002\n\n1 \\leq n_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nQ\nx_1 d_1 n_1\n:\nx_Q d_Q n_Q\n\nOutput\n\nPrint Q lines.\n\nIn the i-th line, print the answer for the i-th query.\n\nSample Input 1\n\n2\n7 2 4\n12345 67890 2019\n\nSample Output 1\n\n9009\n916936\n\nFor the first query, the answer is 7 \\times 9 \\times 11 \\times 13 = 9009.\nDon't forget to compute the answer modulo 1\\ 000\\ 003.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 989, "cpu_time_ms": 196, "memory_kb": 10880}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s673010352", "group_id": "codeNet:p03029", "input_text": "a, p = io.read(\"*n\", \"*n\")\nprint(math.floor((a * 3 + p)) / 2)", "language": "Lua", "metadata": {"date": 1579359083, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03029.html", "problem_id": "p03029", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03029/input.txt", "sample_output_relpath": "derived/input_output/data/p03029/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03029/Lua/s673010352.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s673010352", "user_id": "u720483676"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "a, p = io.read(\"*n\", \"*n\")\nprint(math.floor((a * 3 + p)) / 2)", "problem_context": "Score : 100 points\n\nProblem Statement\n\nWe have A apples and P pieces of apple.\n\nWe can cut an apple into three pieces of apple, and make one apple pie by simmering two pieces of apple in a pan.\n\nFind the maximum number of apple pies we can make with what we have now.\n\nConstraints\n\nAll values in input are integers.\n\n0 \\leq A, P \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA P\n\nOutput\n\nPrint the maximum number of apple pies we can make with what we have.\n\nSample Input 1\n\n1 3\n\nSample Output 1\n\n3\n\nWe can first make one apple pie by simmering two of the three pieces of apple. Then, we can make two more by simmering the remaining piece and three more pieces obtained by cutting the whole apple.\n\nSample Input 2\n\n0 1\n\nSample Output 2\n\n0\n\nWe cannot make an apple pie in this case, unfortunately.\n\nSample Input 3\n\n32 21\n\nSample Output 3\n\n58", "sample_input": "1 3\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03029", "source_text": "Score : 100 points\n\nProblem Statement\n\nWe have A apples and P pieces of apple.\n\nWe can cut an apple into three pieces of apple, and make one apple pie by simmering two pieces of apple in a pan.\n\nFind the maximum number of apple pies we can make with what we have now.\n\nConstraints\n\nAll values in input are integers.\n\n0 \\leq A, P \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA P\n\nOutput\n\nPrint the maximum number of apple pies we can make with what we have.\n\nSample Input 1\n\n1 3\n\nSample Output 1\n\n3\n\nWe can first make one apple pie by simmering two of the three pieces of apple. Then, we can make two more by simmering the remaining piece and three more pieces obtained by cutting the whole apple.\n\nSample Input 2\n\n0 1\n\nSample Output 2\n\n0\n\nWe cannot make an apple pie in this case, unfortunately.\n\nSample Input 3\n\n32 21\n\nSample Output 3\n\n58", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 61, "cpu_time_ms": 4, "memory_kb": 508}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s346585251", "group_id": "codeNet:p03030", "input_text": "n = io.read(\"*n\", \"*l\")\nt = {}\nfor i = 1, n do\n s = io.read()\n name, p = s:match(\"(%w+) (%d+)\")\n t[i] = {name, tonumber(p), i}\nend\ntable.sort(t, function(a, b)\n if a[1] ~= b[1] then\n return a[1] < b[1]\n else\n return a[2] > b[2]\n end\nend)\nfor i = 1, n do\n print(t[i][3])\nend\n", "language": "Lua", "metadata": {"date": 1589672131, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03030.html", "problem_id": "p03030", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03030/input.txt", "sample_output_relpath": "derived/input_output/data/p03030/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03030/Lua/s346585251.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s346585251", "user_id": "u120582723"}, "prompt_components": {"gold_output": "3\n4\n6\n1\n5\n2\n", "input_to_evaluate": "n = io.read(\"*n\", \"*l\")\nt = {}\nfor i = 1, n do\n s = io.read()\n name, p = s:match(\"(%w+) (%d+)\")\n t[i] = {name, tonumber(p), i}\nend\ntable.sort(t, function(a, b)\n if a[1] ~= b[1] then\n return a[1] < b[1]\n else\n return a[2] > b[2]\n end\nend)\nfor i = 1, n do\n print(t[i][3])\nend\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nYou have decided to write a book introducing good restaurants.\nThere are N restaurants that you want to introduce: Restaurant 1, Restaurant 2, ..., Restaurant N. Restaurant i is in city S_i, and your assessment score of that restaurant on a 100-point scale is P_i.\nNo two restaurants have the same score.\n\nYou want to introduce the restaurants in the following order:\n\nThe restaurants are arranged in lexicographical order of the names of their cities.\n\nIf there are multiple restaurants in the same city, they are arranged in descending order of score.\n\nPrint the identification numbers of the restaurants in the order they are introduced in the book.\n\nConstraints\n\n1 ≤ N ≤ 100\n\nS is a string of length between 1 and 10 (inclusive) consisting of lowercase English letters.\n\n0 ≤ P_i ≤ 100\n\nP_i is an integer.\n\nP_i ≠ P_j (1 ≤ i < j ≤ N)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS_1 P_1\n:\nS_N P_N\n\nOutput\n\nPrint N lines. The i-th line (1 ≤ i ≤ N) should contain the identification number of the restaurant that is introduced i-th in the book.\n\nSample Input 1\n\n6\nkhabarovsk 20\nmoscow 10\nkazan 50\nkazan 35\nmoscow 60\nkhabarovsk 40\n\nSample Output 1\n\n3\n4\n6\n1\n5\n2\n\nThe lexicographical order of the names of the three cities is kazan < khabarovsk < moscow. For each of these cities, the restaurants in it are introduced in descending order of score. Thus, the restaurants are introduced in the order 3,4,6,1,5,2.\n\nSample Input 2\n\n10\nyakutsk 10\nyakutsk 20\nyakutsk 30\nyakutsk 40\nyakutsk 50\nyakutsk 60\nyakutsk 70\nyakutsk 80\nyakutsk 90\nyakutsk 100\n\nSample Output 2\n\n10\n9\n8\n7\n6\n5\n4\n3\n2\n1", "sample_input": "6\nkhabarovsk 20\nmoscow 10\nkazan 50\nkazan 35\nmoscow 60\nkhabarovsk 40\n"}, "reference_outputs": ["3\n4\n6\n1\n5\n2\n"], "source_document_id": "p03030", "source_text": "Score : 200 points\n\nProblem Statement\n\nYou have decided to write a book introducing good restaurants.\nThere are N restaurants that you want to introduce: Restaurant 1, Restaurant 2, ..., Restaurant N. Restaurant i is in city S_i, and your assessment score of that restaurant on a 100-point scale is P_i.\nNo two restaurants have the same score.\n\nYou want to introduce the restaurants in the following order:\n\nThe restaurants are arranged in lexicographical order of the names of their cities.\n\nIf there are multiple restaurants in the same city, they are arranged in descending order of score.\n\nPrint the identification numbers of the restaurants in the order they are introduced in the book.\n\nConstraints\n\n1 ≤ N ≤ 100\n\nS is a string of length between 1 and 10 (inclusive) consisting of lowercase English letters.\n\n0 ≤ P_i ≤ 100\n\nP_i is an integer.\n\nP_i ≠ P_j (1 ≤ i < j ≤ N)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS_1 P_1\n:\nS_N P_N\n\nOutput\n\nPrint N lines. The i-th line (1 ≤ i ≤ N) should contain the identification number of the restaurant that is introduced i-th in the book.\n\nSample Input 1\n\n6\nkhabarovsk 20\nmoscow 10\nkazan 50\nkazan 35\nmoscow 60\nkhabarovsk 40\n\nSample Output 1\n\n3\n4\n6\n1\n5\n2\n\nThe lexicographical order of the names of the three cities is kazan < khabarovsk < moscow. For each of these cities, the restaurants in it are introduced in descending order of score. Thus, the restaurants are introduced in the order 3,4,6,1,5,2.\n\nSample Input 2\n\n10\nyakutsk 10\nyakutsk 20\nyakutsk 30\nyakutsk 40\nyakutsk 50\nyakutsk 60\nyakutsk 70\nyakutsk 80\nyakutsk 90\nyakutsk 100\n\nSample Output 2\n\n10\n9\n8\n7\n6\n5\n4\n3\n2\n1", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 287, "cpu_time_ms": 7, "memory_kb": 888}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s749791588", "group_id": "codeNet:p03030", "input_text": "n=io.read(\"*n\",\"*l\")\nt={}\nfor i=1,n do\n x=io.read()\n s,p=x:match(\"(%w+) (%d+)\")\n table.insert(t, {s,tonumber(p),i})\nend\ntable.sort(t,function(x,y)\n if x[1]~=y[1] then\n return x[1]y[2]\n end\nend)\nfor i=1,n do\n print(t[i][3])\nend", "language": "Lua", "metadata": {"date": 1587394707, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03030.html", "problem_id": "p03030", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03030/input.txt", "sample_output_relpath": "derived/input_output/data/p03030/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03030/Lua/s749791588.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s749791588", "user_id": "u045238009"}, "prompt_components": {"gold_output": "3\n4\n6\n1\n5\n2\n", "input_to_evaluate": "n=io.read(\"*n\",\"*l\")\nt={}\nfor i=1,n do\n x=io.read()\n s,p=x:match(\"(%w+) (%d+)\")\n table.insert(t, {s,tonumber(p),i})\nend\ntable.sort(t,function(x,y)\n if x[1]~=y[1] then\n return x[1]y[2]\n end\nend)\nfor i=1,n do\n print(t[i][3])\nend", "problem_context": "Score : 200 points\n\nProblem Statement\n\nYou have decided to write a book introducing good restaurants.\nThere are N restaurants that you want to introduce: Restaurant 1, Restaurant 2, ..., Restaurant N. Restaurant i is in city S_i, and your assessment score of that restaurant on a 100-point scale is P_i.\nNo two restaurants have the same score.\n\nYou want to introduce the restaurants in the following order:\n\nThe restaurants are arranged in lexicographical order of the names of their cities.\n\nIf there are multiple restaurants in the same city, they are arranged in descending order of score.\n\nPrint the identification numbers of the restaurants in the order they are introduced in the book.\n\nConstraints\n\n1 ≤ N ≤ 100\n\nS is a string of length between 1 and 10 (inclusive) consisting of lowercase English letters.\n\n0 ≤ P_i ≤ 100\n\nP_i is an integer.\n\nP_i ≠ P_j (1 ≤ i < j ≤ N)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS_1 P_1\n:\nS_N P_N\n\nOutput\n\nPrint N lines. The i-th line (1 ≤ i ≤ N) should contain the identification number of the restaurant that is introduced i-th in the book.\n\nSample Input 1\n\n6\nkhabarovsk 20\nmoscow 10\nkazan 50\nkazan 35\nmoscow 60\nkhabarovsk 40\n\nSample Output 1\n\n3\n4\n6\n1\n5\n2\n\nThe lexicographical order of the names of the three cities is kazan < khabarovsk < moscow. For each of these cities, the restaurants in it are introduced in descending order of score. Thus, the restaurants are introduced in the order 3,4,6,1,5,2.\n\nSample Input 2\n\n10\nyakutsk 10\nyakutsk 20\nyakutsk 30\nyakutsk 40\nyakutsk 50\nyakutsk 60\nyakutsk 70\nyakutsk 80\nyakutsk 90\nyakutsk 100\n\nSample Output 2\n\n10\n9\n8\n7\n6\n5\n4\n3\n2\n1", "sample_input": "6\nkhabarovsk 20\nmoscow 10\nkazan 50\nkazan 35\nmoscow 60\nkhabarovsk 40\n"}, "reference_outputs": ["3\n4\n6\n1\n5\n2\n"], "source_document_id": "p03030", "source_text": "Score : 200 points\n\nProblem Statement\n\nYou have decided to write a book introducing good restaurants.\nThere are N restaurants that you want to introduce: Restaurant 1, Restaurant 2, ..., Restaurant N. Restaurant i is in city S_i, and your assessment score of that restaurant on a 100-point scale is P_i.\nNo two restaurants have the same score.\n\nYou want to introduce the restaurants in the following order:\n\nThe restaurants are arranged in lexicographical order of the names of their cities.\n\nIf there are multiple restaurants in the same city, they are arranged in descending order of score.\n\nPrint the identification numbers of the restaurants in the order they are introduced in the book.\n\nConstraints\n\n1 ≤ N ≤ 100\n\nS is a string of length between 1 and 10 (inclusive) consisting of lowercase English letters.\n\n0 ≤ P_i ≤ 100\n\nP_i is an integer.\n\nP_i ≠ P_j (1 ≤ i < j ≤ N)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS_1 P_1\n:\nS_N P_N\n\nOutput\n\nPrint N lines. The i-th line (1 ≤ i ≤ N) should contain the identification number of the restaurant that is introduced i-th in the book.\n\nSample Input 1\n\n6\nkhabarovsk 20\nmoscow 10\nkazan 50\nkazan 35\nmoscow 60\nkhabarovsk 40\n\nSample Output 1\n\n3\n4\n6\n1\n5\n2\n\nThe lexicographical order of the names of the three cities is kazan < khabarovsk < moscow. For each of these cities, the restaurants in it are introduced in descending order of score. Thus, the restaurants are introduced in the order 3,4,6,1,5,2.\n\nSample Input 2\n\n10\nyakutsk 10\nyakutsk 20\nyakutsk 30\nyakutsk 40\nyakutsk 50\nyakutsk 60\nyakutsk 70\nyakutsk 80\nyakutsk 90\nyakutsk 100\n\nSample Output 2\n\n10\n9\n8\n7\n6\n5\n4\n3\n2\n1", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 286, "cpu_time_ms": 2, "memory_kb": 256}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s994753193", "group_id": "codeNet:p03030", "input_text": "local function str2tbl(s)\n -- limit of #s is approximately 999959\n local t = {string.byte(s, 1, #s)}\n local char = string.char\n for i=1, #t do\n t[i] = char(t[i])\n end\n return t\nend\n--\nlocal N = io.read(\"n\", \"l\")\nlocal restaurants = {}\nfor i=1,N do\n local tmp = io.read(\"l\")\n local tbl = str2tbl(tmp)\n local s, p\n for j=1, #tbl do\n if tbl[j] == ' ' then\n s = string.sub(tmp, 1, j-1)\n p = tonumber(string.sub(tmp, j+1))\n break\n end\n end\n --print(s, p)\n table.insert(restaurants, {i, s, p})\nend\n\ntable.sort(restaurants, function(x, y)\n if x[2] ~= y[2] then\n return x[2] < y[2]\n else\n return x[3] > y[3]\n end\nend)\nfor i=1, N do\n print(restaurants[i][1])\nend", "language": "Lua", "metadata": {"date": 1565144467, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03030.html", "problem_id": "p03030", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03030/input.txt", "sample_output_relpath": "derived/input_output/data/p03030/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03030/Lua/s994753193.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s994753193", "user_id": "u162773977"}, "prompt_components": {"gold_output": "3\n4\n6\n1\n5\n2\n", "input_to_evaluate": "local function str2tbl(s)\n -- limit of #s is approximately 999959\n local t = {string.byte(s, 1, #s)}\n local char = string.char\n for i=1, #t do\n t[i] = char(t[i])\n end\n return t\nend\n--\nlocal N = io.read(\"n\", \"l\")\nlocal restaurants = {}\nfor i=1,N do\n local tmp = io.read(\"l\")\n local tbl = str2tbl(tmp)\n local s, p\n for j=1, #tbl do\n if tbl[j] == ' ' then\n s = string.sub(tmp, 1, j-1)\n p = tonumber(string.sub(tmp, j+1))\n break\n end\n end\n --print(s, p)\n table.insert(restaurants, {i, s, p})\nend\n\ntable.sort(restaurants, function(x, y)\n if x[2] ~= y[2] then\n return x[2] < y[2]\n else\n return x[3] > y[3]\n end\nend)\nfor i=1, N do\n print(restaurants[i][1])\nend", "problem_context": "Score : 200 points\n\nProblem Statement\n\nYou have decided to write a book introducing good restaurants.\nThere are N restaurants that you want to introduce: Restaurant 1, Restaurant 2, ..., Restaurant N. Restaurant i is in city S_i, and your assessment score of that restaurant on a 100-point scale is P_i.\nNo two restaurants have the same score.\n\nYou want to introduce the restaurants in the following order:\n\nThe restaurants are arranged in lexicographical order of the names of their cities.\n\nIf there are multiple restaurants in the same city, they are arranged in descending order of score.\n\nPrint the identification numbers of the restaurants in the order they are introduced in the book.\n\nConstraints\n\n1 ≤ N ≤ 100\n\nS is a string of length between 1 and 10 (inclusive) consisting of lowercase English letters.\n\n0 ≤ P_i ≤ 100\n\nP_i is an integer.\n\nP_i ≠ P_j (1 ≤ i < j ≤ N)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS_1 P_1\n:\nS_N P_N\n\nOutput\n\nPrint N lines. The i-th line (1 ≤ i ≤ N) should contain the identification number of the restaurant that is introduced i-th in the book.\n\nSample Input 1\n\n6\nkhabarovsk 20\nmoscow 10\nkazan 50\nkazan 35\nmoscow 60\nkhabarovsk 40\n\nSample Output 1\n\n3\n4\n6\n1\n5\n2\n\nThe lexicographical order of the names of the three cities is kazan < khabarovsk < moscow. For each of these cities, the restaurants in it are introduced in descending order of score. Thus, the restaurants are introduced in the order 3,4,6,1,5,2.\n\nSample Input 2\n\n10\nyakutsk 10\nyakutsk 20\nyakutsk 30\nyakutsk 40\nyakutsk 50\nyakutsk 60\nyakutsk 70\nyakutsk 80\nyakutsk 90\nyakutsk 100\n\nSample Output 2\n\n10\n9\n8\n7\n6\n5\n4\n3\n2\n1", "sample_input": "6\nkhabarovsk 20\nmoscow 10\nkazan 50\nkazan 35\nmoscow 60\nkhabarovsk 40\n"}, "reference_outputs": ["3\n4\n6\n1\n5\n2\n"], "source_document_id": "p03030", "source_text": "Score : 200 points\n\nProblem Statement\n\nYou have decided to write a book introducing good restaurants.\nThere are N restaurants that you want to introduce: Restaurant 1, Restaurant 2, ..., Restaurant N. Restaurant i is in city S_i, and your assessment score of that restaurant on a 100-point scale is P_i.\nNo two restaurants have the same score.\n\nYou want to introduce the restaurants in the following order:\n\nThe restaurants are arranged in lexicographical order of the names of their cities.\n\nIf there are multiple restaurants in the same city, they are arranged in descending order of score.\n\nPrint the identification numbers of the restaurants in the order they are introduced in the book.\n\nConstraints\n\n1 ≤ N ≤ 100\n\nS is a string of length between 1 and 10 (inclusive) consisting of lowercase English letters.\n\n0 ≤ P_i ≤ 100\n\nP_i is an integer.\n\nP_i ≠ P_j (1 ≤ i < j ≤ N)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS_1 P_1\n:\nS_N P_N\n\nOutput\n\nPrint N lines. The i-th line (1 ≤ i ≤ N) should contain the identification number of the restaurant that is introduced i-th in the book.\n\nSample Input 1\n\n6\nkhabarovsk 20\nmoscow 10\nkazan 50\nkazan 35\nmoscow 60\nkhabarovsk 40\n\nSample Output 1\n\n3\n4\n6\n1\n5\n2\n\nThe lexicographical order of the names of the three cities is kazan < khabarovsk < moscow. For each of these cities, the restaurants in it are introduced in descending order of score. Thus, the restaurants are introduced in the order 3,4,6,1,5,2.\n\nSample Input 2\n\n10\nyakutsk 10\nyakutsk 20\nyakutsk 30\nyakutsk 40\nyakutsk 50\nyakutsk 60\nyakutsk 70\nyakutsk 80\nyakutsk 90\nyakutsk 100\n\nSample Output 2\n\n10\n9\n8\n7\n6\n5\n4\n3\n2\n1", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 772, "cpu_time_ms": 8, "memory_kb": 760}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s602205573", "group_id": "codeNet:p03031", "input_text": "local n, m = io.read(\"*n\", \"*n\")\nlocal t = {}\nfor i = 1, m do\n z = io.read(\"*n\")\n t[i] = {}\n for j = 1, z do\n table.insert(t[i], io.read(\"*n\"))\n end\nend\nlocal p = {}\nfor i = 1, m do\n p[i] = io.read(\"*n\")\nend\nlocal ret = 0\nlocal tot = 1\nfor i = 1, n do tot = tot * 2 end\nlocal use = {}\nfor i = 0, tot - 1 do\n local ti = i\n for j = 1, n do\n use[j] = ti % 2\n ti = ti // 2\n end\n local v = true\n for j = 1, m do\n local q = 0\n for k = 1, #t[j] do\n q = q + use[t[j][k]]\n end\n if q % 2 ~= p[j] then v = false break end\n end\n if v then ret = ret + 1 end\nend\nprint(ret)\n", "language": "Lua", "metadata": {"date": 1589674599, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03031.html", "problem_id": "p03031", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03031/input.txt", "sample_output_relpath": "derived/input_output/data/p03031/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03031/Lua/s602205573.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s602205573", "user_id": "u120582723"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "local n, m = io.read(\"*n\", \"*n\")\nlocal t = {}\nfor i = 1, m do\n z = io.read(\"*n\")\n t[i] = {}\n for j = 1, z do\n table.insert(t[i], io.read(\"*n\"))\n end\nend\nlocal p = {}\nfor i = 1, m do\n p[i] = io.read(\"*n\")\nend\nlocal ret = 0\nlocal tot = 1\nfor i = 1, n do tot = tot * 2 end\nlocal use = {}\nfor i = 0, tot - 1 do\n local ti = i\n for j = 1, n do\n use[j] = ti % 2\n ti = ti // 2\n end\n local v = true\n for j = 1, m do\n local q = 0\n for k = 1, #t[j] do\n q = q + use[t[j][k]]\n end\n if q % 2 ~= p[j] then v = false break end\n end\n if v then ret = ret + 1 end\nend\nprint(ret)\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nWe have N switches with \"on\" and \"off\" state, and M bulbs. The switches are numbered 1 to N, and the bulbs are numbered 1 to M.\n\nBulb i is connected to k_i switches: Switch s_{i1}, s_{i2}, ..., and s_{ik_i}. It is lighted when the number of switches that are \"on\" among these switches is congruent to p_i modulo 2.\n\nHow many combinations of \"on\" and \"off\" states of the switches light all the bulbs?\n\nConstraints\n\n1 \\leq N, M \\leq 10\n\n1 \\leq k_i \\leq N\n\n1 \\leq s_{ij} \\leq N\n\ns_{ia} \\neq s_{ib} (a \\neq b)\n\np_i is 0 or 1.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nk_1 s_{11} s_{12} ... s_{1k_1}\n:\nk_M s_{M1} s_{M2} ... s_{Mk_M}\np_1 p_2 ... p_M\n\nOutput\n\nPrint the number of combinations of \"on\" and \"off\" states of the switches that light all the bulbs.\n\nSample Input 1\n\n2 2\n2 1 2\n1 2\n0 1\n\nSample Output 1\n\n1\n\nBulb 1 is lighted when there is an even number of switches that are \"on\" among the following: Switch 1 and 2.\n\nBulb 2 is lighted when there is an odd number of switches that are \"on\" among the following: Switch 2.\n\nThere are four possible combinations of states of (Switch 1, Switch 2): (on, on), (on, off), (off, on) and (off, off). Among them, only (on, on) lights all the bulbs, so we should print 1.\n\nSample Input 2\n\n2 3\n2 1 2\n1 1\n1 2\n0 0 1\n\nSample Output 2\n\n0\n\nBulb 1 is lighted when there is an even number of switches that are \"on\" among the following: Switch 1 and 2.\n\nBulb 2 is lighted when there is an even number of switches that are \"on\" among the following: Switch 1.\n\nBulb 3 is lighted when there is an odd number of switches that are \"on\" among the following: Switch 2.\n\nSwitch 1 has to be \"off\" to light Bulb 2 and Switch 2 has to be \"on\" to light Bulb 3, but then Bulb 1 will not be lighted. Thus, there are no combinations of states of the switches that light all the bulbs, so we should print 0.\n\nSample Input 3\n\n5 2\n3 1 2 5\n2 2 3\n1 0\n\nSample Output 3\n\n8", "sample_input": "2 2\n2 1 2\n1 2\n0 1\n"}, "reference_outputs": ["1\n"], "source_document_id": "p03031", "source_text": "Score : 300 points\n\nProblem Statement\n\nWe have N switches with \"on\" and \"off\" state, and M bulbs. The switches are numbered 1 to N, and the bulbs are numbered 1 to M.\n\nBulb i is connected to k_i switches: Switch s_{i1}, s_{i2}, ..., and s_{ik_i}. It is lighted when the number of switches that are \"on\" among these switches is congruent to p_i modulo 2.\n\nHow many combinations of \"on\" and \"off\" states of the switches light all the bulbs?\n\nConstraints\n\n1 \\leq N, M \\leq 10\n\n1 \\leq k_i \\leq N\n\n1 \\leq s_{ij} \\leq N\n\ns_{ia} \\neq s_{ib} (a \\neq b)\n\np_i is 0 or 1.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nk_1 s_{11} s_{12} ... s_{1k_1}\n:\nk_M s_{M1} s_{M2} ... s_{Mk_M}\np_1 p_2 ... p_M\n\nOutput\n\nPrint the number of combinations of \"on\" and \"off\" states of the switches that light all the bulbs.\n\nSample Input 1\n\n2 2\n2 1 2\n1 2\n0 1\n\nSample Output 1\n\n1\n\nBulb 1 is lighted when there is an even number of switches that are \"on\" among the following: Switch 1 and 2.\n\nBulb 2 is lighted when there is an odd number of switches that are \"on\" among the following: Switch 2.\n\nThere are four possible combinations of states of (Switch 1, Switch 2): (on, on), (on, off), (off, on) and (off, off). Among them, only (on, on) lights all the bulbs, so we should print 1.\n\nSample Input 2\n\n2 3\n2 1 2\n1 1\n1 2\n0 0 1\n\nSample Output 2\n\n0\n\nBulb 1 is lighted when there is an even number of switches that are \"on\" among the following: Switch 1 and 2.\n\nBulb 2 is lighted when there is an even number of switches that are \"on\" among the following: Switch 1.\n\nBulb 3 is lighted when there is an odd number of switches that are \"on\" among the following: Switch 2.\n\nSwitch 1 has to be \"off\" to light Bulb 2 and Switch 2 has to be \"on\" to light Bulb 3, but then Bulb 1 will not be lighted. Thus, there are no combinations of states of the switches that light all the bulbs, so we should print 0.\n\nSample Input 3\n\n5 2\n3 1 2 5\n2 2 3\n1 0\n\nSample Output 3\n\n8", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 598, "cpu_time_ms": 10, "memory_kb": 760}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s788923592", "group_id": "codeNet:p03031", "input_text": "local Nsw, Nli = io.read(\"n\", \"n\")\nlocal switches = {}\nlocal onconds = {}\nfor i=1,Nli do\n local k = io.read(\"n\")\n local swi = {}\n switches[i] = swi\n for j=1,k do\n swi[j] = io.read(\"n\")\n end\nend\nfor i=1,Nli do\n onconds[i] = io.read(\"n\")\nend\n-- Cartesian product\nlocal function carprod(seqs)\n return coroutine.wrap(function()\n if #seqs == 0 then\n coroutine.yield({})\n return\n end\n local s1 = seqs[1]\n for _,v in ipairs(s1) do\n for t in carprod({select(2, table.unpack(seqs))}) do\n coroutine.yield({v, table.unpack(t)})\n end\n end\n end)\nend\n\nlocal zo = {0,1}\nlocal set = {}\nfor i=1,Nsw do\n set[i] = zo\nend\nlocal ans = 0\nfor ss in carprod(set) do -- 1024 times\n --print(table.concat(ss, \"\"))\n local all_on = true\n for i=1,Nli do -- 10 times\n local swi = switches[i]\n local sum = 0\n for k,v in ipairs(swi) do -- 10 times\n if ss[v] == 1 then\n sum = sum + 1\n end\n end\n if sum % 2 == onconds[i] then\n else\n all_on = false\n break\n end\n end\n if all_on then\n ans = ans + 1\n end\nend\nprint(ans)", "language": "Lua", "metadata": {"date": 1565229300, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03031.html", "problem_id": "p03031", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03031/input.txt", "sample_output_relpath": "derived/input_output/data/p03031/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03031/Lua/s788923592.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s788923592", "user_id": "u162773977"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "local Nsw, Nli = io.read(\"n\", \"n\")\nlocal switches = {}\nlocal onconds = {}\nfor i=1,Nli do\n local k = io.read(\"n\")\n local swi = {}\n switches[i] = swi\n for j=1,k do\n swi[j] = io.read(\"n\")\n end\nend\nfor i=1,Nli do\n onconds[i] = io.read(\"n\")\nend\n-- Cartesian product\nlocal function carprod(seqs)\n return coroutine.wrap(function()\n if #seqs == 0 then\n coroutine.yield({})\n return\n end\n local s1 = seqs[1]\n for _,v in ipairs(s1) do\n for t in carprod({select(2, table.unpack(seqs))}) do\n coroutine.yield({v, table.unpack(t)})\n end\n end\n end)\nend\n\nlocal zo = {0,1}\nlocal set = {}\nfor i=1,Nsw do\n set[i] = zo\nend\nlocal ans = 0\nfor ss in carprod(set) do -- 1024 times\n --print(table.concat(ss, \"\"))\n local all_on = true\n for i=1,Nli do -- 10 times\n local swi = switches[i]\n local sum = 0\n for k,v in ipairs(swi) do -- 10 times\n if ss[v] == 1 then\n sum = sum + 1\n end\n end\n if sum % 2 == onconds[i] then\n else\n all_on = false\n break\n end\n end\n if all_on then\n ans = ans + 1\n end\nend\nprint(ans)", "problem_context": "Score : 300 points\n\nProblem Statement\n\nWe have N switches with \"on\" and \"off\" state, and M bulbs. The switches are numbered 1 to N, and the bulbs are numbered 1 to M.\n\nBulb i is connected to k_i switches: Switch s_{i1}, s_{i2}, ..., and s_{ik_i}. It is lighted when the number of switches that are \"on\" among these switches is congruent to p_i modulo 2.\n\nHow many combinations of \"on\" and \"off\" states of the switches light all the bulbs?\n\nConstraints\n\n1 \\leq N, M \\leq 10\n\n1 \\leq k_i \\leq N\n\n1 \\leq s_{ij} \\leq N\n\ns_{ia} \\neq s_{ib} (a \\neq b)\n\np_i is 0 or 1.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nk_1 s_{11} s_{12} ... s_{1k_1}\n:\nk_M s_{M1} s_{M2} ... s_{Mk_M}\np_1 p_2 ... p_M\n\nOutput\n\nPrint the number of combinations of \"on\" and \"off\" states of the switches that light all the bulbs.\n\nSample Input 1\n\n2 2\n2 1 2\n1 2\n0 1\n\nSample Output 1\n\n1\n\nBulb 1 is lighted when there is an even number of switches that are \"on\" among the following: Switch 1 and 2.\n\nBulb 2 is lighted when there is an odd number of switches that are \"on\" among the following: Switch 2.\n\nThere are four possible combinations of states of (Switch 1, Switch 2): (on, on), (on, off), (off, on) and (off, off). Among them, only (on, on) lights all the bulbs, so we should print 1.\n\nSample Input 2\n\n2 3\n2 1 2\n1 1\n1 2\n0 0 1\n\nSample Output 2\n\n0\n\nBulb 1 is lighted when there is an even number of switches that are \"on\" among the following: Switch 1 and 2.\n\nBulb 2 is lighted when there is an even number of switches that are \"on\" among the following: Switch 1.\n\nBulb 3 is lighted when there is an odd number of switches that are \"on\" among the following: Switch 2.\n\nSwitch 1 has to be \"off\" to light Bulb 2 and Switch 2 has to be \"on\" to light Bulb 3, but then Bulb 1 will not be lighted. Thus, there are no combinations of states of the switches that light all the bulbs, so we should print 0.\n\nSample Input 3\n\n5 2\n3 1 2 5\n2 2 3\n1 0\n\nSample Output 3\n\n8", "sample_input": "2 2\n2 1 2\n1 2\n0 1\n"}, "reference_outputs": ["1\n"], "source_document_id": "p03031", "source_text": "Score : 300 points\n\nProblem Statement\n\nWe have N switches with \"on\" and \"off\" state, and M bulbs. The switches are numbered 1 to N, and the bulbs are numbered 1 to M.\n\nBulb i is connected to k_i switches: Switch s_{i1}, s_{i2}, ..., and s_{ik_i}. It is lighted when the number of switches that are \"on\" among these switches is congruent to p_i modulo 2.\n\nHow many combinations of \"on\" and \"off\" states of the switches light all the bulbs?\n\nConstraints\n\n1 \\leq N, M \\leq 10\n\n1 \\leq k_i \\leq N\n\n1 \\leq s_{ij} \\leq N\n\ns_{ia} \\neq s_{ib} (a \\neq b)\n\np_i is 0 or 1.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nk_1 s_{11} s_{12} ... s_{1k_1}\n:\nk_M s_{M1} s_{M2} ... s_{Mk_M}\np_1 p_2 ... p_M\n\nOutput\n\nPrint the number of combinations of \"on\" and \"off\" states of the switches that light all the bulbs.\n\nSample Input 1\n\n2 2\n2 1 2\n1 2\n0 1\n\nSample Output 1\n\n1\n\nBulb 1 is lighted when there is an even number of switches that are \"on\" among the following: Switch 1 and 2.\n\nBulb 2 is lighted when there is an odd number of switches that are \"on\" among the following: Switch 2.\n\nThere are four possible combinations of states of (Switch 1, Switch 2): (on, on), (on, off), (off, on) and (off, off). Among them, only (on, on) lights all the bulbs, so we should print 1.\n\nSample Input 2\n\n2 3\n2 1 2\n1 1\n1 2\n0 0 1\n\nSample Output 2\n\n0\n\nBulb 1 is lighted when there is an even number of switches that are \"on\" among the following: Switch 1 and 2.\n\nBulb 2 is lighted when there is an even number of switches that are \"on\" among the following: Switch 1.\n\nBulb 3 is lighted when there is an odd number of switches that are \"on\" among the following: Switch 2.\n\nSwitch 1 has to be \"off\" to light Bulb 2 and Switch 2 has to be \"on\" to light Bulb 3, but then Bulb 1 will not be lighted. Thus, there are no combinations of states of the switches that light all the bulbs, so we should print 0.\n\nSample Input 3\n\n5 2\n3 1 2 5\n2 2 3\n1 0\n\nSample Output 3\n\n8", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1241, "cpu_time_ms": 18, "memory_kb": 752}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s782890645", "group_id": "codeNet:p03033", "input_text": "local mce, mfl, msq, mmi, mma = math.ceil, math.floor, math.sqrt, math.min, math.max\nlocal ior = io.input()\nlocal n, q = ior:read(\"*n\", \"*n\")\nlocal s, t, x, d = {}, {}, {}, {}\nfor i = 1, n do\n s[i], t[i], x[i] = ior:read(\"*n\", \"*n\", \"*n\")\nend\n\nlocal timelist = {}\nlocal omitinfo = {}\nfor i = 1, q do\n local tmp = ior:read(\"*n\")\n d[i] = tmp\n table.insert(timelist, tmp)\n local tmptbl = {}\n table.insert(omitinfo, tmptbl)\nend\n-- table.sort(timelist)\n\nlocal function lower_bound(ary, x)\n if(x <= ary[1]) then return 1 end\n local num = #ary\n if(ary[num] < x) then return num + 1 end\n local min, max = 1, num\n while(1 < max - min) do\n local mid = mfl((min + max) / 2)\n if(ary[mid] < x) then\n min = mid\n else\n max = mid\n end\n end\n return max\nend\n\nlocal function upper_bound(ary, x)\n if(x < ary[1]) then return 1 end\n local num = #ary\n if(ary[num] <= x) then return num + 1 end\n local min, max = 1, num\n while(1 < max - min) do\n local mid = mfl((min + max) / 2)\n if(ary[mid] <= x) then\n min = mid\n else\n max = mid\n end\n end\n return max\nend\n\nfor i = 1, n do\n -- [ngfrom, ngto]\n local ngfrom, ngto = s[i] - x[i], t[i] - x[i] - 1\n local real_ngfrom_pos_idx = lower_bound(timelist, ngfrom)\n local real_ngto_pos_idx = upper_bound(timelist, ngto) - 1\n -- print(i, ngfrom, ngto, real_ngfrom_pos_idx, real_ngto_pos_idx)\n if(real_ngfrom_pos_idx <= q and 1 <= real_ngto_pos_idx and real_ngfrom_pos_idx <= real_ngto_pos_idx) then\n table.insert(omitinfo[real_ngfrom_pos_idx], x[i])\n table.insert(omitinfo[real_ngto_pos_idx], -x[i])\n end\nend\n-- for i = 1, q do\n-- print(i, \"-- \", unpack(omitinfo[i]))\n-- end\nlocal cur_omit_list = {}\nlocal cur_min_omit_x = -1\nfor i = 1, q do\n for j = 1, #omitinfo[i] do\n local val = omitinfo[i][j]\n if(0 < val) then\n cur_omit_list[val] = true\n if(cur_min_omit_x < 0 or val < cur_min_omit_x) then\n cur_min_omit_x = val\n end\n end\n end\n print(cur_min_omit_x)\n\n for j = 1, #omitinfo[i] do\n local val = omitinfo[i][j]\n if(val < 0) then\n cur_omit_list[-val] = nil\n if(cur_min_omit_x == -val) then\n cur_min_omit_x = -1\n for key, value in pairs(cur_omit_list) do\n if(cur_min_omit_x < 0 or key < cur_min_omit_x) then\n cur_min_omit_x = key\n end\n end\n end\n end\n end\nend\n", "language": "Lua", "metadata": {"date": 1558922251, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p03033.html", "problem_id": "p03033", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03033/input.txt", "sample_output_relpath": "derived/input_output/data/p03033/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03033/Lua/s782890645.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s782890645", "user_id": "u120582723"}, "prompt_components": {"gold_output": "2\n2\n10\n-1\n13\n-1\n", "input_to_evaluate": "local mce, mfl, msq, mmi, mma = math.ceil, math.floor, math.sqrt, math.min, math.max\nlocal ior = io.input()\nlocal n, q = ior:read(\"*n\", \"*n\")\nlocal s, t, x, d = {}, {}, {}, {}\nfor i = 1, n do\n s[i], t[i], x[i] = ior:read(\"*n\", \"*n\", \"*n\")\nend\n\nlocal timelist = {}\nlocal omitinfo = {}\nfor i = 1, q do\n local tmp = ior:read(\"*n\")\n d[i] = tmp\n table.insert(timelist, tmp)\n local tmptbl = {}\n table.insert(omitinfo, tmptbl)\nend\n-- table.sort(timelist)\n\nlocal function lower_bound(ary, x)\n if(x <= ary[1]) then return 1 end\n local num = #ary\n if(ary[num] < x) then return num + 1 end\n local min, max = 1, num\n while(1 < max - min) do\n local mid = mfl((min + max) / 2)\n if(ary[mid] < x) then\n min = mid\n else\n max = mid\n end\n end\n return max\nend\n\nlocal function upper_bound(ary, x)\n if(x < ary[1]) then return 1 end\n local num = #ary\n if(ary[num] <= x) then return num + 1 end\n local min, max = 1, num\n while(1 < max - min) do\n local mid = mfl((min + max) / 2)\n if(ary[mid] <= x) then\n min = mid\n else\n max = mid\n end\n end\n return max\nend\n\nfor i = 1, n do\n -- [ngfrom, ngto]\n local ngfrom, ngto = s[i] - x[i], t[i] - x[i] - 1\n local real_ngfrom_pos_idx = lower_bound(timelist, ngfrom)\n local real_ngto_pos_idx = upper_bound(timelist, ngto) - 1\n -- print(i, ngfrom, ngto, real_ngfrom_pos_idx, real_ngto_pos_idx)\n if(real_ngfrom_pos_idx <= q and 1 <= real_ngto_pos_idx and real_ngfrom_pos_idx <= real_ngto_pos_idx) then\n table.insert(omitinfo[real_ngfrom_pos_idx], x[i])\n table.insert(omitinfo[real_ngto_pos_idx], -x[i])\n end\nend\n-- for i = 1, q do\n-- print(i, \"-- \", unpack(omitinfo[i]))\n-- end\nlocal cur_omit_list = {}\nlocal cur_min_omit_x = -1\nfor i = 1, q do\n for j = 1, #omitinfo[i] do\n local val = omitinfo[i][j]\n if(0 < val) then\n cur_omit_list[val] = true\n if(cur_min_omit_x < 0 or val < cur_min_omit_x) then\n cur_min_omit_x = val\n end\n end\n end\n print(cur_min_omit_x)\n\n for j = 1, #omitinfo[i] do\n local val = omitinfo[i][j]\n if(val < 0) then\n cur_omit_list[-val] = nil\n if(cur_min_omit_x == -val) then\n cur_min_omit_x = -1\n for key, value in pairs(cur_omit_list) do\n if(cur_min_omit_x < 0 or key < cur_min_omit_x) then\n cur_min_omit_x = key\n end\n end\n end\n end\n end\nend\n", "problem_context": "Score : 500 points\n\nProblem Statement\n\nThere is an infinitely long street that runs west to east, which we consider as a number line.\n\nThere are N roadworks scheduled on this street.\nThe i-th roadwork blocks the point at coordinate X_i from time S_i - 0.5 to time T_i - 0.5.\n\nQ people are standing at coordinate 0. The i-th person will start the coordinate 0 at time D_i, continue to walk with speed 1 in the positive direction and stop walking when reaching a blocked point.\n\nFind the distance each of the Q people will walk.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N, Q \\leq 2 \\times 10^5\n\n0 \\leq S_i < T_i \\leq 10^9\n\n1 \\leq X_i \\leq 10^9\n\n0 \\leq D_1 < D_2 < ... < D_Q \\leq 10^9\n\nIf i \\neq j and X_i = X_j, the intervals [S_i, T_i) and [S_j, T_j) do not overlap.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN Q\nS_1 T_1 X_1\n:\nS_N T_N X_N\nD_1\n:\nD_Q\n\nOutput\n\nPrint Q lines. The i-th line should contain the distance the i-th person will walk or -1 if that person walks forever.\n\nSample Input 1\n\n4 6\n1 3 2\n7 13 10\n18 20 13\n3 4 2\n0\n1\n2\n3\n5\n8\n\nSample Output 1\n\n2\n2\n10\n-1\n13\n-1\n\nThe first person starts coordinate 0 at time 0 and stops walking at coordinate 2 when reaching a point blocked by the first roadwork at time 2.\n\nThe second person starts coordinate 0 at time 1 and reaches coordinate 2 at time 3. The first roadwork has ended, but the fourth roadwork has begun, so this person also stops walking at coordinate 2.\n\nThe fourth and sixth persons encounter no roadworks while walking, so they walk forever. The output for these cases is -1.", "sample_input": "4 6\n1 3 2\n7 13 10\n18 20 13\n3 4 2\n0\n1\n2\n3\n5\n8\n"}, "reference_outputs": ["2\n2\n10\n-1\n13\n-1\n"], "source_document_id": "p03033", "source_text": "Score : 500 points\n\nProblem Statement\n\nThere is an infinitely long street that runs west to east, which we consider as a number line.\n\nThere are N roadworks scheduled on this street.\nThe i-th roadwork blocks the point at coordinate X_i from time S_i - 0.5 to time T_i - 0.5.\n\nQ people are standing at coordinate 0. The i-th person will start the coordinate 0 at time D_i, continue to walk with speed 1 in the positive direction and stop walking when reaching a blocked point.\n\nFind the distance each of the Q people will walk.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N, Q \\leq 2 \\times 10^5\n\n0 \\leq S_i < T_i \\leq 10^9\n\n1 \\leq X_i \\leq 10^9\n\n0 \\leq D_1 < D_2 < ... < D_Q \\leq 10^9\n\nIf i \\neq j and X_i = X_j, the intervals [S_i, T_i) and [S_j, T_j) do not overlap.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN Q\nS_1 T_1 X_1\n:\nS_N T_N X_N\nD_1\n:\nD_Q\n\nOutput\n\nPrint Q lines. The i-th line should contain the distance the i-th person will walk or -1 if that person walks forever.\n\nSample Input 1\n\n4 6\n1 3 2\n7 13 10\n18 20 13\n3 4 2\n0\n1\n2\n3\n5\n8\n\nSample Output 1\n\n2\n2\n10\n-1\n13\n-1\n\nThe first person starts coordinate 0 at time 0 and stops walking at coordinate 2 when reaching a point blocked by the first roadwork at time 2.\n\nThe second person starts coordinate 0 at time 1 and reaches coordinate 2 at time 3. The first roadwork has ended, but the fourth roadwork has begun, so this person also stops walking at coordinate 2.\n\nThe fourth and sixth persons encounter no roadworks while walking, so they walk forever. The output for these cases is -1.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2361, "cpu_time_ms": 610, "memory_kb": 38388}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s633072666", "group_id": "codeNet:p03034", "input_text": "local mfl, mce = math.floor, math.ceil\nlocal bls, brs = bit.lshift, bit.rshift\nlocal mmi, mma = math.min, math.max\nlocal n = io.read(\"*n\")\nlocal t = {}\n_u = io.read(\"*n\")\nfor i = 1, n - 1 do\n t[i] = io.read(\"*n\")\nend\nn = n - 1\nlocal ret = 0\nlocal lim = brs(n - 1, 1)\nfor i = 1, lim do\n local lim2 = mfl(lim / i)\n local c = 0\n for j = 1, n do\n if n % i == 0 then\n if n - i * j <= i * j then break end\n end\n if n - i * j < j then break end\n c = c + t[i * j] + t[n - i * j]\n ret = mma(ret, c)\n end\nend\nprint(ret)\n", "language": "Lua", "metadata": {"date": 1587527380, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p03034.html", "problem_id": "p03034", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03034/input.txt", "sample_output_relpath": "derived/input_output/data/p03034/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03034/Lua/s633072666.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s633072666", "user_id": "u120582723"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "local mfl, mce = math.floor, math.ceil\nlocal bls, brs = bit.lshift, bit.rshift\nlocal mmi, mma = math.min, math.max\nlocal n = io.read(\"*n\")\nlocal t = {}\n_u = io.read(\"*n\")\nfor i = 1, n - 1 do\n t[i] = io.read(\"*n\")\nend\nn = n - 1\nlocal ret = 0\nlocal lim = brs(n - 1, 1)\nfor i = 1, lim do\n local lim2 = mfl(lim / i)\n local c = 0\n for j = 1, n do\n if n % i == 0 then\n if n - i * j <= i * j then break end\n end\n if n - i * j < j then break end\n c = c + t[i * j] + t[n - i * j]\n ret = mma(ret, c)\n end\nend\nprint(ret)\n", "problem_context": "Score : 600 points\n\nProblem Statement\n\nThere is an infinitely large pond, which we consider as a number line.\nIn this pond, there are N lotuses floating at coordinates 0, 1, 2, ..., N-2 and N-1.\nOn the lotus at coordinate i, an integer s_i is written.\n\nYou are standing on the lotus at coordinate 0. You will play a game that proceeds as follows:\n\n1. Choose positive integers A and B. Your score is initially 0.\n\n2. Let x be your current coordinate, and y = x+A. The lotus at coordinate x disappears, and you move to coordinate y.\n\nIf y = N-1, the game ends.\n\nIf y \\neq N-1 and there is a lotus floating at coordinate y, your score increases by s_y.\n\nIf y \\neq N-1 and there is no lotus floating at coordinate y, you drown. Your score decreases by 10^{100} points, and the game ends.\n\n3. Let x be your current coordinate, and y = x-B. The lotus at coordinate x disappears, and you move to coordinate y.\n\nIf y = N-1, the game ends.\n\nIf y \\neq N-1 and there is a lotus floating at coordinate y, your score increases by s_y.\n\nIf y \\neq N-1 and there is no lotus floating at coordinate y, you drown. Your score decreases by 10^{100} points, and the game ends.\n\n4. Go back to step 2.\n\nYou want to end the game with as high a score as possible.\nWhat is the score obtained by the optimal choice of A and B?\n\nConstraints\n\n3 \\leq N \\leq 10^5\n\n-10^9 \\leq s_i \\leq 10^9\n\ns_0=s_{N-1}=0\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\ns_0 s_1 ...... s_{N-1}\n\nOutput\n\nPrint the score obtained by the optimal choice of A and B.\n\nSample Input 1\n\n5\n0 2 5 1 0\n\nSample Output 1\n\n3\n\nIf you choose A = 3 and B = 2, the game proceeds as follows:\n\nMove to coordinate 0 + 3 = 3. Your score increases by s_3 = 1.\n\nMove to coordinate 3 - 2 = 1. Your score increases by s_1 = 2.\n\nMove to coordinate 1 + 3 = 4. The game ends with a score of 3.\n\nThere is no way to end the game with a score of 4 or higher, so the answer is 3. Note that you cannot land the lotus at coordinate 2 without drowning later.\n\nSample Input 2\n\n6\n0 10 -7 -4 -13 0\n\nSample Output 2\n\n0\n\nThe optimal strategy here is to land the final lotus immediately by choosing A = 5 (the value of B does not matter).\n\nSample Input 3\n\n11\n0 -4 0 -99 31 14 -15 -39 43 18 0\n\nSample Output 3\n\n59", "sample_input": "5\n0 2 5 1 0\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03034", "source_text": "Score : 600 points\n\nProblem Statement\n\nThere is an infinitely large pond, which we consider as a number line.\nIn this pond, there are N lotuses floating at coordinates 0, 1, 2, ..., N-2 and N-1.\nOn the lotus at coordinate i, an integer s_i is written.\n\nYou are standing on the lotus at coordinate 0. You will play a game that proceeds as follows:\n\n1. Choose positive integers A and B. Your score is initially 0.\n\n2. Let x be your current coordinate, and y = x+A. The lotus at coordinate x disappears, and you move to coordinate y.\n\nIf y = N-1, the game ends.\n\nIf y \\neq N-1 and there is a lotus floating at coordinate y, your score increases by s_y.\n\nIf y \\neq N-1 and there is no lotus floating at coordinate y, you drown. Your score decreases by 10^{100} points, and the game ends.\n\n3. Let x be your current coordinate, and y = x-B. The lotus at coordinate x disappears, and you move to coordinate y.\n\nIf y = N-1, the game ends.\n\nIf y \\neq N-1 and there is a lotus floating at coordinate y, your score increases by s_y.\n\nIf y \\neq N-1 and there is no lotus floating at coordinate y, you drown. Your score decreases by 10^{100} points, and the game ends.\n\n4. Go back to step 2.\n\nYou want to end the game with as high a score as possible.\nWhat is the score obtained by the optimal choice of A and B?\n\nConstraints\n\n3 \\leq N \\leq 10^5\n\n-10^9 \\leq s_i \\leq 10^9\n\ns_0=s_{N-1}=0\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\ns_0 s_1 ...... s_{N-1}\n\nOutput\n\nPrint the score obtained by the optimal choice of A and B.\n\nSample Input 1\n\n5\n0 2 5 1 0\n\nSample Output 1\n\n3\n\nIf you choose A = 3 and B = 2, the game proceeds as follows:\n\nMove to coordinate 0 + 3 = 3. Your score increases by s_3 = 1.\n\nMove to coordinate 3 - 2 = 1. Your score increases by s_1 = 2.\n\nMove to coordinate 1 + 3 = 4. The game ends with a score of 3.\n\nThere is no way to end the game with a score of 4 or higher, so the answer is 3. Note that you cannot land the lotus at coordinate 2 without drowning later.\n\nSample Input 2\n\n6\n0 10 -7 -4 -13 0\n\nSample Output 2\n\n0\n\nThe optimal strategy here is to land the final lotus immediately by choosing A = 5 (the value of B does not matter).\n\nSample Input 3\n\n11\n0 -4 0 -99 31 14 -15 -39 43 18 0\n\nSample Output 3\n\n59", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 535, "cpu_time_ms": 41, "memory_kb": 1280}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s355756987", "group_id": "codeNet:p03034", "input_text": "local mfl, mce = math.floor, math.ceil\nlocal bls, brs = bit.lshift, bit.rshift\nlocal mmi, mma = math.min, math.max\nlocal n = io.read(\"*n\")\nlocal t = {}\n_u = io.read(\"*n\")\nfor i = 1, n - 1 do\n t[i] = io.read(\"*n\")\nend\nn = n - 1\nlocal ret = 0\nlocal lim = brs(n - 2, 1)\nfor i = 1, lim do\n local lim2 = mfl(lim / i)\n local c = 0\n for j = 1, lim2 do\n c = c + t[i * j] + t[n - i * j]\n ret = mma(ret, c)\n end\nend\nprint(ret)\n", "language": "Lua", "metadata": {"date": 1587525844, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p03034.html", "problem_id": "p03034", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03034/input.txt", "sample_output_relpath": "derived/input_output/data/p03034/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03034/Lua/s355756987.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s355756987", "user_id": "u120582723"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "local mfl, mce = math.floor, math.ceil\nlocal bls, brs = bit.lshift, bit.rshift\nlocal mmi, mma = math.min, math.max\nlocal n = io.read(\"*n\")\nlocal t = {}\n_u = io.read(\"*n\")\nfor i = 1, n - 1 do\n t[i] = io.read(\"*n\")\nend\nn = n - 1\nlocal ret = 0\nlocal lim = brs(n - 2, 1)\nfor i = 1, lim do\n local lim2 = mfl(lim / i)\n local c = 0\n for j = 1, lim2 do\n c = c + t[i * j] + t[n - i * j]\n ret = mma(ret, c)\n end\nend\nprint(ret)\n", "problem_context": "Score : 600 points\n\nProblem Statement\n\nThere is an infinitely large pond, which we consider as a number line.\nIn this pond, there are N lotuses floating at coordinates 0, 1, 2, ..., N-2 and N-1.\nOn the lotus at coordinate i, an integer s_i is written.\n\nYou are standing on the lotus at coordinate 0. You will play a game that proceeds as follows:\n\n1. Choose positive integers A and B. Your score is initially 0.\n\n2. Let x be your current coordinate, and y = x+A. The lotus at coordinate x disappears, and you move to coordinate y.\n\nIf y = N-1, the game ends.\n\nIf y \\neq N-1 and there is a lotus floating at coordinate y, your score increases by s_y.\n\nIf y \\neq N-1 and there is no lotus floating at coordinate y, you drown. Your score decreases by 10^{100} points, and the game ends.\n\n3. Let x be your current coordinate, and y = x-B. The lotus at coordinate x disappears, and you move to coordinate y.\n\nIf y = N-1, the game ends.\n\nIf y \\neq N-1 and there is a lotus floating at coordinate y, your score increases by s_y.\n\nIf y \\neq N-1 and there is no lotus floating at coordinate y, you drown. Your score decreases by 10^{100} points, and the game ends.\n\n4. Go back to step 2.\n\nYou want to end the game with as high a score as possible.\nWhat is the score obtained by the optimal choice of A and B?\n\nConstraints\n\n3 \\leq N \\leq 10^5\n\n-10^9 \\leq s_i \\leq 10^9\n\ns_0=s_{N-1}=0\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\ns_0 s_1 ...... s_{N-1}\n\nOutput\n\nPrint the score obtained by the optimal choice of A and B.\n\nSample Input 1\n\n5\n0 2 5 1 0\n\nSample Output 1\n\n3\n\nIf you choose A = 3 and B = 2, the game proceeds as follows:\n\nMove to coordinate 0 + 3 = 3. Your score increases by s_3 = 1.\n\nMove to coordinate 3 - 2 = 1. Your score increases by s_1 = 2.\n\nMove to coordinate 1 + 3 = 4. The game ends with a score of 3.\n\nThere is no way to end the game with a score of 4 or higher, so the answer is 3. Note that you cannot land the lotus at coordinate 2 without drowning later.\n\nSample Input 2\n\n6\n0 10 -7 -4 -13 0\n\nSample Output 2\n\n0\n\nThe optimal strategy here is to land the final lotus immediately by choosing A = 5 (the value of B does not matter).\n\nSample Input 3\n\n11\n0 -4 0 -99 31 14 -15 -39 43 18 0\n\nSample Output 3\n\n59", "sample_input": "5\n0 2 5 1 0\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03034", "source_text": "Score : 600 points\n\nProblem Statement\n\nThere is an infinitely large pond, which we consider as a number line.\nIn this pond, there are N lotuses floating at coordinates 0, 1, 2, ..., N-2 and N-1.\nOn the lotus at coordinate i, an integer s_i is written.\n\nYou are standing on the lotus at coordinate 0. You will play a game that proceeds as follows:\n\n1. Choose positive integers A and B. Your score is initially 0.\n\n2. Let x be your current coordinate, and y = x+A. The lotus at coordinate x disappears, and you move to coordinate y.\n\nIf y = N-1, the game ends.\n\nIf y \\neq N-1 and there is a lotus floating at coordinate y, your score increases by s_y.\n\nIf y \\neq N-1 and there is no lotus floating at coordinate y, you drown. Your score decreases by 10^{100} points, and the game ends.\n\n3. Let x be your current coordinate, and y = x-B. The lotus at coordinate x disappears, and you move to coordinate y.\n\nIf y = N-1, the game ends.\n\nIf y \\neq N-1 and there is a lotus floating at coordinate y, your score increases by s_y.\n\nIf y \\neq N-1 and there is no lotus floating at coordinate y, you drown. Your score decreases by 10^{100} points, and the game ends.\n\n4. Go back to step 2.\n\nYou want to end the game with as high a score as possible.\nWhat is the score obtained by the optimal choice of A and B?\n\nConstraints\n\n3 \\leq N \\leq 10^5\n\n-10^9 \\leq s_i \\leq 10^9\n\ns_0=s_{N-1}=0\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\ns_0 s_1 ...... s_{N-1}\n\nOutput\n\nPrint the score obtained by the optimal choice of A and B.\n\nSample Input 1\n\n5\n0 2 5 1 0\n\nSample Output 1\n\n3\n\nIf you choose A = 3 and B = 2, the game proceeds as follows:\n\nMove to coordinate 0 + 3 = 3. Your score increases by s_3 = 1.\n\nMove to coordinate 3 - 2 = 1. Your score increases by s_1 = 2.\n\nMove to coordinate 1 + 3 = 4. The game ends with a score of 3.\n\nThere is no way to end the game with a score of 4 or higher, so the answer is 3. Note that you cannot land the lotus at coordinate 2 without drowning later.\n\nSample Input 2\n\n6\n0 10 -7 -4 -13 0\n\nSample Output 2\n\n0\n\nThe optimal strategy here is to land the final lotus immediately by choosing A = 5 (the value of B does not matter).\n\nSample Input 3\n\n11\n0 -4 0 -99 31 14 -15 -39 43 18 0\n\nSample Output 3\n\n59", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 428, "cpu_time_ms": 32, "memory_kb": 1280}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s019444063", "group_id": "codeNet:p03035", "input_text": "a, b = io.read(\"*n\", \"*n\")\nif a <= 5 then\n print(0)\nelseif a <= 12 then\n print(b // 2)\nelse\n print(b)\nend", "language": "Lua", "metadata": {"date": 1579359313, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03035.html", "problem_id": "p03035", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03035/input.txt", "sample_output_relpath": "derived/input_output/data/p03035/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03035/Lua/s019444063.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s019444063", "user_id": "u720483676"}, "prompt_components": {"gold_output": "100\n", "input_to_evaluate": "a, b = io.read(\"*n\", \"*n\")\nif a <= 5 then\n print(0)\nelseif a <= 12 then\n print(b // 2)\nelse\n print(b)\nend", "problem_context": "Score : 100 points\n\nProblem Statement\n\nTakahashi, who is A years old, is riding a Ferris wheel.\n\nIt costs B yen (B is an even number) to ride the Ferris wheel if you are 13 years old or older, but children between 6 and 12 years old (inclusive) can ride it for half the cost, and children who are 5 years old or younger are free of charge. (Yen is the currency of Japan.)\n\nFind the cost of the Ferris wheel for Takahashi.\n\nConstraints\n\n0 ≤ A ≤ 100\n\n2 ≤ B ≤ 1000\n\nB is an even number.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nPrint the cost of the Ferris wheel for Takahashi.\n\nSample Input 1\n\n30 100\n\nSample Output 1\n\n100\n\nTakahashi is 30 years old now, and the cost of the Ferris wheel is 100 yen.\n\nSample Input 2\n\n12 100\n\nSample Output 2\n\n50\n\nTakahashi is 12 years old, and the cost of the Ferris wheel is the half of 100 yen, that is, 50 yen.\n\nSample Input 3\n\n0 100\n\nSample Output 3\n\n0\n\nTakahashi is 0 years old, and he can ride the Ferris wheel for free.", "sample_input": "30 100\n"}, "reference_outputs": ["100\n"], "source_document_id": "p03035", "source_text": "Score : 100 points\n\nProblem Statement\n\nTakahashi, who is A years old, is riding a Ferris wheel.\n\nIt costs B yen (B is an even number) to ride the Ferris wheel if you are 13 years old or older, but children between 6 and 12 years old (inclusive) can ride it for half the cost, and children who are 5 years old or younger are free of charge. (Yen is the currency of Japan.)\n\nFind the cost of the Ferris wheel for Takahashi.\n\nConstraints\n\n0 ≤ A ≤ 100\n\n2 ≤ B ≤ 1000\n\nB is an even number.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nPrint the cost of the Ferris wheel for Takahashi.\n\nSample Input 1\n\n30 100\n\nSample Output 1\n\n100\n\nTakahashi is 30 years old now, and the cost of the Ferris wheel is 100 yen.\n\nSample Input 2\n\n12 100\n\nSample Output 2\n\n50\n\nTakahashi is 12 years old, and the cost of the Ferris wheel is the half of 100 yen, that is, 50 yen.\n\nSample Input 3\n\n0 100\n\nSample Output 3\n\n0\n\nTakahashi is 0 years old, and he can ride the Ferris wheel for free.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 114, "cpu_time_ms": 4, "memory_kb": 508}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s899885059", "group_id": "codeNet:p03035", "input_text": "local ior = io.input()\nlocal a, b = ior:read(\"*n\", \"*n\")\nif a <= 5 then\n print(0)\nelseif a <= 12 then\n print(b // 2)\nelse\n print(b)\nend\n", "language": "Lua", "metadata": {"date": 1558832613, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03035.html", "problem_id": "p03035", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03035/input.txt", "sample_output_relpath": "derived/input_output/data/p03035/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03035/Lua/s899885059.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s899885059", "user_id": "u120582723"}, "prompt_components": {"gold_output": "100\n", "input_to_evaluate": "local ior = io.input()\nlocal a, b = ior:read(\"*n\", \"*n\")\nif a <= 5 then\n print(0)\nelseif a <= 12 then\n print(b // 2)\nelse\n print(b)\nend\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nTakahashi, who is A years old, is riding a Ferris wheel.\n\nIt costs B yen (B is an even number) to ride the Ferris wheel if you are 13 years old or older, but children between 6 and 12 years old (inclusive) can ride it for half the cost, and children who are 5 years old or younger are free of charge. (Yen is the currency of Japan.)\n\nFind the cost of the Ferris wheel for Takahashi.\n\nConstraints\n\n0 ≤ A ≤ 100\n\n2 ≤ B ≤ 1000\n\nB is an even number.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nPrint the cost of the Ferris wheel for Takahashi.\n\nSample Input 1\n\n30 100\n\nSample Output 1\n\n100\n\nTakahashi is 30 years old now, and the cost of the Ferris wheel is 100 yen.\n\nSample Input 2\n\n12 100\n\nSample Output 2\n\n50\n\nTakahashi is 12 years old, and the cost of the Ferris wheel is the half of 100 yen, that is, 50 yen.\n\nSample Input 3\n\n0 100\n\nSample Output 3\n\n0\n\nTakahashi is 0 years old, and he can ride the Ferris wheel for free.", "sample_input": "30 100\n"}, "reference_outputs": ["100\n"], "source_document_id": "p03035", "source_text": "Score : 100 points\n\nProblem Statement\n\nTakahashi, who is A years old, is riding a Ferris wheel.\n\nIt costs B yen (B is an even number) to ride the Ferris wheel if you are 13 years old or older, but children between 6 and 12 years old (inclusive) can ride it for half the cost, and children who are 5 years old or younger are free of charge. (Yen is the currency of Japan.)\n\nFind the cost of the Ferris wheel for Takahashi.\n\nConstraints\n\n0 ≤ A ≤ 100\n\n2 ≤ B ≤ 1000\n\nB is an even number.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nPrint the cost of the Ferris wheel for Takahashi.\n\nSample Input 1\n\n30 100\n\nSample Output 1\n\n100\n\nTakahashi is 30 years old now, and the cost of the Ferris wheel is 100 yen.\n\nSample Input 2\n\n12 100\n\nSample Output 2\n\n50\n\nTakahashi is 12 years old, and the cost of the Ferris wheel is the half of 100 yen, that is, 50 yen.\n\nSample Input 3\n\n0 100\n\nSample Output 3\n\n0\n\nTakahashi is 0 years old, and he can ride the Ferris wheel for free.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 139, "cpu_time_ms": 8, "memory_kb": 1012}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s096735724", "group_id": "codeNet:p03036", "input_text": "local ior = io.input()\nlocal r, d, x = ior:read(\"*n\", \"*n\", \"*n\")\nfor i = 1, 10 do\n x = r * x - d\n print(string.format(\"%d\", x))\nend", "language": "Lua", "metadata": {"date": 1558832532, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03036.html", "problem_id": "p03036", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03036/input.txt", "sample_output_relpath": "derived/input_output/data/p03036/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03036/Lua/s096735724.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s096735724", "user_id": "u120582723"}, "prompt_components": {"gold_output": "30\n50\n90\n170\n330\n650\n1290\n2570\n5130\n10250\n", "input_to_evaluate": "local ior = io.input()\nlocal r, d, x = ior:read(\"*n\", \"*n\", \"*n\")\nfor i = 1, 10 do\n x = r * x - d\n print(string.format(\"%d\", x))\nend", "problem_context": "Score : 200 points\n\nProblem Statement\n\nThe development of algae in a pond is as follows.\n\nLet the total weight of the algae at the beginning of the year i be x_i gram. For i≥2000, the following formula holds:\n\nx_{i+1} = rx_i - D\n\nYou are given r, D and x_{2000}. Calculate x_{2001}, ..., x_{2010} and print them in order.\n\nConstraints\n\n2 ≤ r ≤ 5\n\n1 ≤ D ≤ 100\n\nD < x_{2000} ≤ 200\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nr D x_{2000}\n\nOutput\n\nPrint 10 lines. The i-th line (1 ≤ i ≤ 10) should contain x_{2000+i} as an integer.\n\nSample Input 1\n\n2 10 20\n\nSample Output 1\n\n30\n50\n90\n170\n330\n650\n1290\n2570\n5130\n10250\n\nFor example, x_{2001} = rx_{2000} - D = 2 \\times 20 - 10 = 30 and x_{2002} = rx_{2001} - D = 2 \\times 30 - 10 = 50.\n\nSample Input 2\n\n4 40 60\n\nSample Output 2\n\n200\n760\n3000\n11960\n47800\n191160\n764600\n3058360\n12233400\n48933560", "sample_input": "2 10 20\n"}, "reference_outputs": ["30\n50\n90\n170\n330\n650\n1290\n2570\n5130\n10250\n"], "source_document_id": "p03036", "source_text": "Score : 200 points\n\nProblem Statement\n\nThe development of algae in a pond is as follows.\n\nLet the total weight of the algae at the beginning of the year i be x_i gram. For i≥2000, the following formula holds:\n\nx_{i+1} = rx_i - D\n\nYou are given r, D and x_{2000}. Calculate x_{2001}, ..., x_{2010} and print them in order.\n\nConstraints\n\n2 ≤ r ≤ 5\n\n1 ≤ D ≤ 100\n\nD < x_{2000} ≤ 200\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nr D x_{2000}\n\nOutput\n\nPrint 10 lines. The i-th line (1 ≤ i ≤ 10) should contain x_{2000+i} as an integer.\n\nSample Input 1\n\n2 10 20\n\nSample Output 1\n\n30\n50\n90\n170\n330\n650\n1290\n2570\n5130\n10250\n\nFor example, x_{2001} = rx_{2000} - D = 2 \\times 20 - 10 = 30 and x_{2002} = rx_{2001} - D = 2 \\times 30 - 10 = 50.\n\nSample Input 2\n\n4 40 60\n\nSample Output 2\n\n200\n760\n3000\n11960\n47800\n191160\n764600\n3058360\n12233400\n48933560", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 134, "cpu_time_ms": 8, "memory_kb": 1132}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s584564667", "group_id": "codeNet:p03037", "input_text": "N, M = io.read(\"*n\", \"*n\", \"*l\")\nL_max = 0\nR_min = 10^5\nfor i = 1, M do\n L, R = io.read(\"*n\", \"*n\", \"*l\")\n L_max = math.max(L, L_max)\n R_min = math.min(R, R_min)\nend\nprint(math.max(0, R_min-L_max+1))", "language": "Lua", "metadata": {"date": 1587092258, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03037.html", "problem_id": "p03037", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03037/input.txt", "sample_output_relpath": "derived/input_output/data/p03037/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03037/Lua/s584564667.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s584564667", "user_id": "u045238009"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "N, M = io.read(\"*n\", \"*n\", \"*l\")\nL_max = 0\nR_min = 10^5\nfor i = 1, M do\n L, R = io.read(\"*n\", \"*n\", \"*l\")\n L_max = math.max(L, L_max)\n R_min = math.min(R, R_min)\nend\nprint(math.max(0, R_min-L_max+1))", "problem_context": "Score : 300 points\n\nProblem Statement\n\nWe have N ID cards, and there are M gates.\n\nWe can pass the i-th gate if we have one of the following ID cards: the L_i-th, (L_i+1)-th, ..., and R_i-th ID cards.\n\nHow many of the ID cards allow us to pass all the gates alone?\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^5\n\n1 \\leq L_i \\leq R_i \\leq N\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nL_1 R_1\nL_2 R_2\n\\vdots\nL_M R_M\n\nOutput\n\nPrint the number of ID cards that allow us to pass all the gates alone.\n\nSample Input 1\n\n4 2\n1 3\n2 4\n\nSample Output 1\n\n2\n\nTwo ID cards allow us to pass all the gates alone, as follows:\n\nThe first ID card does not allow us to pass the second gate.\n\nThe second ID card allows us to pass all the gates.\n\nThe third ID card allows us to pass all the gates.\n\nThe fourth ID card does not allow us to pass the first gate.\n\nSample Input 2\n\n10 3\n3 6\n5 7\n6 9\n\nSample Output 2\n\n1\n\nSample Input 3\n\n100000 1\n1 100000\n\nSample Output 3\n\n100000", "sample_input": "4 2\n1 3\n2 4\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03037", "source_text": "Score : 300 points\n\nProblem Statement\n\nWe have N ID cards, and there are M gates.\n\nWe can pass the i-th gate if we have one of the following ID cards: the L_i-th, (L_i+1)-th, ..., and R_i-th ID cards.\n\nHow many of the ID cards allow us to pass all the gates alone?\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^5\n\n1 \\leq L_i \\leq R_i \\leq N\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nL_1 R_1\nL_2 R_2\n\\vdots\nL_M R_M\n\nOutput\n\nPrint the number of ID cards that allow us to pass all the gates alone.\n\nSample Input 1\n\n4 2\n1 3\n2 4\n\nSample Output 1\n\n2\n\nTwo ID cards allow us to pass all the gates alone, as follows:\n\nThe first ID card does not allow us to pass the second gate.\n\nThe second ID card allows us to pass all the gates.\n\nThe third ID card allows us to pass all the gates.\n\nThe fourth ID card does not allow us to pass the first gate.\n\nSample Input 2\n\n10 3\n3 6\n5 7\n6 9\n\nSample Output 2\n\n1\n\nSample Input 3\n\n100000 1\n1 100000\n\nSample Output 3\n\n100000", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 208, "cpu_time_ms": 72, "memory_kb": 760}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s890688408", "group_id": "codeNet:p03037", "input_text": "N, M = io.read(\"*n\", \"*n\", \"*l\")\nL_max = 0\nR_min = 10^5\nfor i = 1, M do\n L, R = io.read(\"*n\", \"*n\", \"*l\")\n if L <= R_min then\n L_max = math.max(L, L_max)\n end\n if R >= L_max then\n R_min = math.min(R, R_min)\n end\nend\nif R_min > L_max then\n print(string.format(\"%d\", R_min-L_max+1))\nelse\n print(0)\nend", "language": "Lua", "metadata": {"date": 1587092102, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03037.html", "problem_id": "p03037", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03037/input.txt", "sample_output_relpath": "derived/input_output/data/p03037/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03037/Lua/s890688408.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s890688408", "user_id": "u045238009"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "N, M = io.read(\"*n\", \"*n\", \"*l\")\nL_max = 0\nR_min = 10^5\nfor i = 1, M do\n L, R = io.read(\"*n\", \"*n\", \"*l\")\n if L <= R_min then\n L_max = math.max(L, L_max)\n end\n if R >= L_max then\n R_min = math.min(R, R_min)\n end\nend\nif R_min > L_max then\n print(string.format(\"%d\", R_min-L_max+1))\nelse\n print(0)\nend", "problem_context": "Score : 300 points\n\nProblem Statement\n\nWe have N ID cards, and there are M gates.\n\nWe can pass the i-th gate if we have one of the following ID cards: the L_i-th, (L_i+1)-th, ..., and R_i-th ID cards.\n\nHow many of the ID cards allow us to pass all the gates alone?\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^5\n\n1 \\leq L_i \\leq R_i \\leq N\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nL_1 R_1\nL_2 R_2\n\\vdots\nL_M R_M\n\nOutput\n\nPrint the number of ID cards that allow us to pass all the gates alone.\n\nSample Input 1\n\n4 2\n1 3\n2 4\n\nSample Output 1\n\n2\n\nTwo ID cards allow us to pass all the gates alone, as follows:\n\nThe first ID card does not allow us to pass the second gate.\n\nThe second ID card allows us to pass all the gates.\n\nThe third ID card allows us to pass all the gates.\n\nThe fourth ID card does not allow us to pass the first gate.\n\nSample Input 2\n\n10 3\n3 6\n5 7\n6 9\n\nSample Output 2\n\n1\n\nSample Input 3\n\n100000 1\n1 100000\n\nSample Output 3\n\n100000", "sample_input": "4 2\n1 3\n2 4\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03037", "source_text": "Score : 300 points\n\nProblem Statement\n\nWe have N ID cards, and there are M gates.\n\nWe can pass the i-th gate if we have one of the following ID cards: the L_i-th, (L_i+1)-th, ..., and R_i-th ID cards.\n\nHow many of the ID cards allow us to pass all the gates alone?\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^5\n\n1 \\leq L_i \\leq R_i \\leq N\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nL_1 R_1\nL_2 R_2\n\\vdots\nL_M R_M\n\nOutput\n\nPrint the number of ID cards that allow us to pass all the gates alone.\n\nSample Input 1\n\n4 2\n1 3\n2 4\n\nSample Output 1\n\n2\n\nTwo ID cards allow us to pass all the gates alone, as follows:\n\nThe first ID card does not allow us to pass the second gate.\n\nThe second ID card allows us to pass all the gates.\n\nThe third ID card allows us to pass all the gates.\n\nThe fourth ID card does not allow us to pass the first gate.\n\nSample Input 2\n\n10 3\n3 6\n5 7\n6 9\n\nSample Output 2\n\n1\n\nSample Input 3\n\n100000 1\n1 100000\n\nSample Output 3\n\n100000", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 334, "cpu_time_ms": 80, "memory_kb": 256}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s056368141", "group_id": "codeNet:p03037", "input_text": "N, M = io.read(\"*n\", \"*n\", \"*l\")\nL_max = 0\nR_min = 10^5\nfor i = 1, M do\n L, R = io.read(\"*n\", \"*n\", \"*l\")\n if L < R_min then\n L_max = math.max(L, L_max)\n elseif R > L_max then\n R_min = math.min(R, R_min)\n end\nend\nprint(R_min-L_max+1)", "language": "Lua", "metadata": {"date": 1587091341, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03037.html", "problem_id": "p03037", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03037/input.txt", "sample_output_relpath": "derived/input_output/data/p03037/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03037/Lua/s056368141.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s056368141", "user_id": "u045238009"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "N, M = io.read(\"*n\", \"*n\", \"*l\")\nL_max = 0\nR_min = 10^5\nfor i = 1, M do\n L, R = io.read(\"*n\", \"*n\", \"*l\")\n if L < R_min then\n L_max = math.max(L, L_max)\n elseif R > L_max then\n R_min = math.min(R, R_min)\n end\nend\nprint(R_min-L_max+1)", "problem_context": "Score : 300 points\n\nProblem Statement\n\nWe have N ID cards, and there are M gates.\n\nWe can pass the i-th gate if we have one of the following ID cards: the L_i-th, (L_i+1)-th, ..., and R_i-th ID cards.\n\nHow many of the ID cards allow us to pass all the gates alone?\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^5\n\n1 \\leq L_i \\leq R_i \\leq N\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nL_1 R_1\nL_2 R_2\n\\vdots\nL_M R_M\n\nOutput\n\nPrint the number of ID cards that allow us to pass all the gates alone.\n\nSample Input 1\n\n4 2\n1 3\n2 4\n\nSample Output 1\n\n2\n\nTwo ID cards allow us to pass all the gates alone, as follows:\n\nThe first ID card does not allow us to pass the second gate.\n\nThe second ID card allows us to pass all the gates.\n\nThe third ID card allows us to pass all the gates.\n\nThe fourth ID card does not allow us to pass the first gate.\n\nSample Input 2\n\n10 3\n3 6\n5 7\n6 9\n\nSample Output 2\n\n1\n\nSample Input 3\n\n100000 1\n1 100000\n\nSample Output 3\n\n100000", "sample_input": "4 2\n1 3\n2 4\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03037", "source_text": "Score : 300 points\n\nProblem Statement\n\nWe have N ID cards, and there are M gates.\n\nWe can pass the i-th gate if we have one of the following ID cards: the L_i-th, (L_i+1)-th, ..., and R_i-th ID cards.\n\nHow many of the ID cards allow us to pass all the gates alone?\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^5\n\n1 \\leq L_i \\leq R_i \\leq N\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nL_1 R_1\nL_2 R_2\n\\vdots\nL_M R_M\n\nOutput\n\nPrint the number of ID cards that allow us to pass all the gates alone.\n\nSample Input 1\n\n4 2\n1 3\n2 4\n\nSample Output 1\n\n2\n\nTwo ID cards allow us to pass all the gates alone, as follows:\n\nThe first ID card does not allow us to pass the second gate.\n\nThe second ID card allows us to pass all the gates.\n\nThe third ID card allows us to pass all the gates.\n\nThe fourth ID card does not allow us to pass the first gate.\n\nSample Input 2\n\n10 3\n3 6\n5 7\n6 9\n\nSample Output 2\n\n1\n\nSample Input 3\n\n100000 1\n1 100000\n\nSample Output 3\n\n100000", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 259, "cpu_time_ms": 62, "memory_kb": 760}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s972912177", "group_id": "codeNet:p03037", "input_text": "local mab, mce, mfl, msq, mmi, mma = math.abs, math.ceil, math.floor, math.sqrt, math.min, math.max\nlocal ior = io.input()\nlocal n, m = ior:read(\"*n\", \"*n\")\nlocal left, right = ior:read(\"*n\", \"*n\")\nfor i = 2, m do\n local x, y = ior:read(\"*n\", \"*n\")\n left, right = mma(left, x), mmi(right, y)\nend\nif left <= right then\n print(right - left + 1)\nelse\n print(0)\nend\n", "language": "Lua", "metadata": {"date": 1558832755, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p03037.html", "problem_id": "p03037", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03037/input.txt", "sample_output_relpath": "derived/input_output/data/p03037/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03037/Lua/s972912177.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s972912177", "user_id": "u120582723"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "local mab, mce, mfl, msq, mmi, mma = math.abs, math.ceil, math.floor, math.sqrt, math.min, math.max\nlocal ior = io.input()\nlocal n, m = ior:read(\"*n\", \"*n\")\nlocal left, right = ior:read(\"*n\", \"*n\")\nfor i = 2, m do\n local x, y = ior:read(\"*n\", \"*n\")\n left, right = mma(left, x), mmi(right, y)\nend\nif left <= right then\n print(right - left + 1)\nelse\n print(0)\nend\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nWe have N ID cards, and there are M gates.\n\nWe can pass the i-th gate if we have one of the following ID cards: the L_i-th, (L_i+1)-th, ..., and R_i-th ID cards.\n\nHow many of the ID cards allow us to pass all the gates alone?\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^5\n\n1 \\leq L_i \\leq R_i \\leq N\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nL_1 R_1\nL_2 R_2\n\\vdots\nL_M R_M\n\nOutput\n\nPrint the number of ID cards that allow us to pass all the gates alone.\n\nSample Input 1\n\n4 2\n1 3\n2 4\n\nSample Output 1\n\n2\n\nTwo ID cards allow us to pass all the gates alone, as follows:\n\nThe first ID card does not allow us to pass the second gate.\n\nThe second ID card allows us to pass all the gates.\n\nThe third ID card allows us to pass all the gates.\n\nThe fourth ID card does not allow us to pass the first gate.\n\nSample Input 2\n\n10 3\n3 6\n5 7\n6 9\n\nSample Output 2\n\n1\n\nSample Input 3\n\n100000 1\n1 100000\n\nSample Output 3\n\n100000", "sample_input": "4 2\n1 3\n2 4\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03037", "source_text": "Score : 300 points\n\nProblem Statement\n\nWe have N ID cards, and there are M gates.\n\nWe can pass the i-th gate if we have one of the following ID cards: the L_i-th, (L_i+1)-th, ..., and R_i-th ID cards.\n\nHow many of the ID cards allow us to pass all the gates alone?\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^5\n\n1 \\leq L_i \\leq R_i \\leq N\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nL_1 R_1\nL_2 R_2\n\\vdots\nL_M R_M\n\nOutput\n\nPrint the number of ID cards that allow us to pass all the gates alone.\n\nSample Input 1\n\n4 2\n1 3\n2 4\n\nSample Output 1\n\n2\n\nTwo ID cards allow us to pass all the gates alone, as follows:\n\nThe first ID card does not allow us to pass the second gate.\n\nThe second ID card allows us to pass all the gates.\n\nThe third ID card allows us to pass all the gates.\n\nThe fourth ID card does not allow us to pass the first gate.\n\nSample Input 2\n\n10 3\n3 6\n5 7\n6 9\n\nSample Output 2\n\n1\n\nSample Input 3\n\n100000 1\n1 100000\n\nSample Output 3\n\n100000", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 366, "cpu_time_ms": 40, "memory_kb": 256}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s737184159", "group_id": "codeNet:p03039", "input_text": "local mod = 1000000007\n\nlocal function bmul(x, y)\n return (x * y) % mod\nend\n\nlocal function badd(x, y)\n return (x + y) % mod\nend\n\nlocal function bsub(x, y)\n return x < y and x - y + mod or x - y\nend\n\nlocal function modpow(src, pow)\n local res = 1\n while 0 < pow do\n if pow % 2 == 1 then\n res = bmul(res, src)\n pow = pow - 1\n end\n src = bmul(src, src)\n pow = pow // 2\n end\n return res\nend\n\nlocal function modinv(src)\n return modpow(src, mod - 2)\nend\n\nlocal function getComb(n, k)\n local ret = 1\n local inv = 1\n for i = 1, k do\n ret = bmul(ret, n + 1 - i)\n inv = bmul(inv, i)\n end\n return bmul(ret, modinv(inv))\nend\n\nlocal n, m, k = io.read(\"*n\", \"*n\", \"*n\")\nlocal a = bmul(n, n)\na = bmul(a, bmul(modinv(6), bmul(bmul(m + 1, m), m - 1)))\nlocal b = bmul(m, m)\nb = bmul(b, bmul(modinv(6), bmul(bmul(n + 1, n), n - 1)))\nlocal r = badd(a, b)\nr = bmul(r, getComb(n * m - 2, k - 2))\nprint(r)\n", "language": "Lua", "metadata": {"date": 1589425283, "filename_ext": "lua", "original_language": "Lua (Lua 5.3.5)", "problem_description_relpath": "problem_descriptions/p03039.html", "problem_id": "p03039", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03039/input.txt", "sample_output_relpath": "derived/input_output/data/p03039/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03039/Lua/s737184159.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s737184159", "user_id": "u120582723"}, "prompt_components": {"gold_output": "8\n", "input_to_evaluate": "local mod = 1000000007\n\nlocal function bmul(x, y)\n return (x * y) % mod\nend\n\nlocal function badd(x, y)\n return (x + y) % mod\nend\n\nlocal function bsub(x, y)\n return x < y and x - y + mod or x - y\nend\n\nlocal function modpow(src, pow)\n local res = 1\n while 0 < pow do\n if pow % 2 == 1 then\n res = bmul(res, src)\n pow = pow - 1\n end\n src = bmul(src, src)\n pow = pow // 2\n end\n return res\nend\n\nlocal function modinv(src)\n return modpow(src, mod - 2)\nend\n\nlocal function getComb(n, k)\n local ret = 1\n local inv = 1\n for i = 1, k do\n ret = bmul(ret, n + 1 - i)\n inv = bmul(inv, i)\n end\n return bmul(ret, modinv(inv))\nend\n\nlocal n, m, k = io.read(\"*n\", \"*n\", \"*n\")\nlocal a = bmul(n, n)\na = bmul(a, bmul(modinv(6), bmul(bmul(m + 1, m), m - 1)))\nlocal b = bmul(m, m)\nb = bmul(b, bmul(modinv(6), bmul(bmul(n + 1, n), n - 1)))\nlocal r = badd(a, b)\nr = bmul(r, getComb(n * m - 2, k - 2))\nprint(r)\n", "problem_context": "Score : 500 points\n\nProblem Statement\n\nWe have a grid of squares with N rows and M columns. Let (i, j) denote the square at the i-th row from the top and j-th column from the left. We will choose K of the squares and put a piece on each of them.\n\nIf we place the K pieces on squares (x_1, y_1), (x_2, y_2), ..., and (x_K, y_K), the cost of this arrangement is computed as:\n\n\\sum_{i=1}^{K-1} \\sum_{j=i+1}^K (|x_i - x_j| + |y_i - y_j|)\n\nFind the sum of the costs of all possible arrangements of the pieces. Since this value can be tremendous, print it modulo 10^9+7.\n\nWe consider two arrangements of the pieces different if and only if there is a square that contains a piece in one of the arrangements but not in the other.\n\nConstraints\n\n2 \\leq N \\times M \\leq 2 \\times 10^5\n\n2 \\leq K \\leq N \\times M\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M K\n\nOutput\n\nPrint the sum of the costs of all possible arrangements of the pieces, modulo 10^9+7.\n\nSample Input 1\n\n2 2 2\n\nSample Output 1\n\n8\n\nThere are six possible arrangements of the pieces, as follows:\n\n((1,1),(1,2)), with the cost |1-1|+|1-2| = 1\n\n((1,1),(2,1)), with the cost |1-2|+|1-1| = 1\n\n((1,1),(2,2)), with the cost |1-2|+|1-2| = 2\n\n((1,2),(2,1)), with the cost |1-2|+|2-1| = 2\n\n((1,2),(2,2)), with the cost |1-2|+|2-2| = 1\n\n((2,1),(2,2)), with the cost |2-2|+|1-2| = 1\n\nThe sum of these costs is 8.\n\nSample Input 2\n\n4 5 4\n\nSample Output 2\n\n87210\n\nSample Input 3\n\n100 100 5000\n\nSample Output 3\n\n817260251\n\nBe sure to print the sum modulo 10^9+7.", "sample_input": "2 2 2\n"}, "reference_outputs": ["8\n"], "source_document_id": "p03039", "source_text": "Score : 500 points\n\nProblem Statement\n\nWe have a grid of squares with N rows and M columns. Let (i, j) denote the square at the i-th row from the top and j-th column from the left. We will choose K of the squares and put a piece on each of them.\n\nIf we place the K pieces on squares (x_1, y_1), (x_2, y_2), ..., and (x_K, y_K), the cost of this arrangement is computed as:\n\n\\sum_{i=1}^{K-1} \\sum_{j=i+1}^K (|x_i - x_j| + |y_i - y_j|)\n\nFind the sum of the costs of all possible arrangements of the pieces. Since this value can be tremendous, print it modulo 10^9+7.\n\nWe consider two arrangements of the pieces different if and only if there is a square that contains a piece in one of the arrangements but not in the other.\n\nConstraints\n\n2 \\leq N \\times M \\leq 2 \\times 10^5\n\n2 \\leq K \\leq N \\times M\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M K\n\nOutput\n\nPrint the sum of the costs of all possible arrangements of the pieces, modulo 10^9+7.\n\nSample Input 1\n\n2 2 2\n\nSample Output 1\n\n8\n\nThere are six possible arrangements of the pieces, as follows:\n\n((1,1),(1,2)), with the cost |1-1|+|1-2| = 1\n\n((1,1),(2,1)), with the cost |1-2|+|1-1| = 1\n\n((1,1),(2,2)), with the cost |1-2|+|1-2| = 2\n\n((1,2),(2,1)), with the cost |1-2|+|2-1| = 2\n\n((1,2),(2,2)), with the cost |1-2|+|2-2| = 1\n\n((2,1),(2,2)), with the cost |2-2|+|1-2| = 1\n\nThe sum of these costs is 8.\n\nSample Input 2\n\n4 5 4\n\nSample Output 2\n\n87210\n\nSample Input 3\n\n100 100 5000\n\nSample Output 3\n\n817260251\n\nBe sure to print the sum modulo 10^9+7.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 925, "cpu_time_ms": 32, "memory_kb": 2748}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s979560716", "group_id": "codeNet:p03040", "input_text": "local mfl, mce, mmi = math.floor, math.ceil, math.min\nlocal SegTree = {}\nSegTree.updateAll = function(self)\n for i = self.stagenum - 1, 1, -1 do\n for j = 1, self.cnt[i] do\n self.stage[i][j] = self.func(self.stage[i + 1][j * 2 - 1], self.stage[i + 1][j * 2])\n end\n end\nend\nSegTree.create = function(self, ary, func, emptyvalue)\n self.func, self.emptyvalue = func, emptyvalue\n local stagenum, mul = 1, 1\n self.cnt, self.stage, self.size = {1}, {{}}, {}\n while mul < #ary do\n mul, stagenum = mul * 2, stagenum + 1\n self.cnt[stagenum], self.stage[stagenum] = mul, {}\n end\n for i = 1, stagenum do self.size[i] = self.cnt[stagenum + 1 - i] end\n self.stagenum = stagenum\n for i = 1, #ary do self.stage[stagenum][i] = ary[i] end\n for i = #ary + 1, mul do self.stage[stagenum][i] = emptyvalue end\n self:updateAll()\nend\nSegTree.getRange = function(self, left, right)\n if left == right then return self.stage[self.stagenum][left] end\n local start_stage = 1\n while right - left + 1 < self.size[start_stage] do\n start_stage = start_stage + 1\n end\n local ret = self.emptyvalue\n local t1, t2, t3 = {start_stage}, {left}, {right}\n while 0 < #t1 do\n local stage, l, r = t1[#t1], t2[#t1], t3[#t1]\n table.remove(t1) table.remove(t2) table.remove(t3)\n local sz = self.size[stage]\n if (l - 1) % sz ~= 0 then\n local newr = mmi(r, mce((l - 1) / sz) * sz)\n table.insert(t1, stage + 1) table.insert(t2, l) table.insert(t3, newr)\n l = newr + 1\n end\n if sz <= r + 1 - l then\n ret = self.func(ret, self.stage[stage][mce(l / sz)])\n l = l + sz\n end\n if l <= r then\n table.insert(t1, stage + 1) table.insert(t2, l) table.insert(t3, r)\n end\n end\n return ret\nend\nSegTree.setValue = function(self, idx, value, silent)\n self.stage[self.stagenum][idx] = value\n if not silent then\n for i = self.stagenum - 1, 1, -1 do\n local dst = mce(idx / 2)\n local rem = dst * 4 - 1 - idx\n self.stage[i][dst] = self.func(self.stage[i + 1][idx], self.stage[i + 1][rem])\n idx = dst\n end\n end\nend\nSegTree.new = function(ary, func, emptyvalue)\n local obj = {}\n setmetatable(obj, {__index = SegTree})\n obj:create(ary, func, emptyvalue)\n return obj\nend\n\nSegTree.lower_bound = function(self, val)\n local ret, retpos = self.emptyvalue, 0\n local t1, t2, t3 = {1}, {1}, {self.size[1]}\n local retval = 0\n while 0 < #t1 do\n local stage, l, r = t1[#t1], t2[#t1], t3[#t1]\n table.remove(t1) table.remove(t2) table.remove(t3)\n local sz = self.size[stage]\n if sz <= r + 1 - l then\n local tmp = self.func(ret, self.stage[stage][mce(l / sz)])\n if tmp[1] < val then\n ret, retpos = tmp, l + sz - 1\n retval = tmp[2]\n if sz ~= 1 then table.insert(t1, stage + 1) table.insert(t2, l + sz) table.insert(t3, r) end\n else\n if sz ~= 1 then table.insert(t1, stage + 1) table.insert(t2, l) table.insert(t3, l + sz - 2) end\n end\n else\n table.insert(t1, stage + 1) table.insert(t2, l) table.insert(t3, r)\n end\n end\n return retpos + 1, retval\nend\n\nlocal q = io.read(\"*n\")\nlocal qlist = {}\nlocal alist = {}\nfor i = 1, q do\n local tp = io.read(\"*n\")\n if tp == 1 then\n local a, b = io.read(\"*n\", \"*n\")\n qlist[i] = {a, b}\n table.insert(alist, a)\n else\n qlist[i] = false\n end\nend\ntable.sort(alist)\nlocal amap = {}\nlocal asum = {}\nfor i = 1, #alist do\n if not amap[alist[i]] then\n amap[alist[i]] = i\n end\n if i == 1 then asum[i] = alist[i]\n else asum[i] = asum[i - 1] + alist[i]\n end\nend\nlocal stary = {}\nfor i = 1, #alist do stary[i] = {0, 0LL} end\nlocal tree = SegTree.new(stary, function(x, y) return {x[1] + y[1], x[2] + y[2]} end, {0, 0LL})\nlocal addcnt = {}\nlocal acnt = 0\nlocal bsum = 0\nfor i = 1, q do\n local query = qlist[i]\n if query then\n local a = query[1]\n local addpos = amap[query[1]]\n if addcnt[a] then\n addpos = addpos + addcnt[a]\n addcnt[a] = addcnt[a] + 1\n else\n addcnt[a] = 1\n end\n tree:setValue(addpos, {1, 0LL + a})\n bsum = bsum + query[2]\n acnt = acnt + 1\n else\n local half = mfl((acnt + 1) / 2)\n local calcpos, preval = tree:lower_bound(half)\n local src = alist[calcpos]\n preval = preval + src\n local curtot = tree.stage[1][1][2]\n local result = bsum + half * src - preval\n + (curtot - preval) - (acnt - half) * src\n local resultstr = tostring(result):gsub(\"LL\", \"\")\n print(src .. \" \" .. resultstr)\n end\nend\n", "language": "Lua", "metadata": {"date": 1567368230, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p03040.html", "problem_id": "p03040", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03040/input.txt", "sample_output_relpath": "derived/input_output/data/p03040/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03040/Lua/s979560716.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s979560716", "user_id": "u120582723"}, "prompt_components": {"gold_output": "4 2\n1 -3\n", "input_to_evaluate": "local mfl, mce, mmi = math.floor, math.ceil, math.min\nlocal SegTree = {}\nSegTree.updateAll = function(self)\n for i = self.stagenum - 1, 1, -1 do\n for j = 1, self.cnt[i] do\n self.stage[i][j] = self.func(self.stage[i + 1][j * 2 - 1], self.stage[i + 1][j * 2])\n end\n end\nend\nSegTree.create = function(self, ary, func, emptyvalue)\n self.func, self.emptyvalue = func, emptyvalue\n local stagenum, mul = 1, 1\n self.cnt, self.stage, self.size = {1}, {{}}, {}\n while mul < #ary do\n mul, stagenum = mul * 2, stagenum + 1\n self.cnt[stagenum], self.stage[stagenum] = mul, {}\n end\n for i = 1, stagenum do self.size[i] = self.cnt[stagenum + 1 - i] end\n self.stagenum = stagenum\n for i = 1, #ary do self.stage[stagenum][i] = ary[i] end\n for i = #ary + 1, mul do self.stage[stagenum][i] = emptyvalue end\n self:updateAll()\nend\nSegTree.getRange = function(self, left, right)\n if left == right then return self.stage[self.stagenum][left] end\n local start_stage = 1\n while right - left + 1 < self.size[start_stage] do\n start_stage = start_stage + 1\n end\n local ret = self.emptyvalue\n local t1, t2, t3 = {start_stage}, {left}, {right}\n while 0 < #t1 do\n local stage, l, r = t1[#t1], t2[#t1], t3[#t1]\n table.remove(t1) table.remove(t2) table.remove(t3)\n local sz = self.size[stage]\n if (l - 1) % sz ~= 0 then\n local newr = mmi(r, mce((l - 1) / sz) * sz)\n table.insert(t1, stage + 1) table.insert(t2, l) table.insert(t3, newr)\n l = newr + 1\n end\n if sz <= r + 1 - l then\n ret = self.func(ret, self.stage[stage][mce(l / sz)])\n l = l + sz\n end\n if l <= r then\n table.insert(t1, stage + 1) table.insert(t2, l) table.insert(t3, r)\n end\n end\n return ret\nend\nSegTree.setValue = function(self, idx, value, silent)\n self.stage[self.stagenum][idx] = value\n if not silent then\n for i = self.stagenum - 1, 1, -1 do\n local dst = mce(idx / 2)\n local rem = dst * 4 - 1 - idx\n self.stage[i][dst] = self.func(self.stage[i + 1][idx], self.stage[i + 1][rem])\n idx = dst\n end\n end\nend\nSegTree.new = function(ary, func, emptyvalue)\n local obj = {}\n setmetatable(obj, {__index = SegTree})\n obj:create(ary, func, emptyvalue)\n return obj\nend\n\nSegTree.lower_bound = function(self, val)\n local ret, retpos = self.emptyvalue, 0\n local t1, t2, t3 = {1}, {1}, {self.size[1]}\n local retval = 0\n while 0 < #t1 do\n local stage, l, r = t1[#t1], t2[#t1], t3[#t1]\n table.remove(t1) table.remove(t2) table.remove(t3)\n local sz = self.size[stage]\n if sz <= r + 1 - l then\n local tmp = self.func(ret, self.stage[stage][mce(l / sz)])\n if tmp[1] < val then\n ret, retpos = tmp, l + sz - 1\n retval = tmp[2]\n if sz ~= 1 then table.insert(t1, stage + 1) table.insert(t2, l + sz) table.insert(t3, r) end\n else\n if sz ~= 1 then table.insert(t1, stage + 1) table.insert(t2, l) table.insert(t3, l + sz - 2) end\n end\n else\n table.insert(t1, stage + 1) table.insert(t2, l) table.insert(t3, r)\n end\n end\n return retpos + 1, retval\nend\n\nlocal q = io.read(\"*n\")\nlocal qlist = {}\nlocal alist = {}\nfor i = 1, q do\n local tp = io.read(\"*n\")\n if tp == 1 then\n local a, b = io.read(\"*n\", \"*n\")\n qlist[i] = {a, b}\n table.insert(alist, a)\n else\n qlist[i] = false\n end\nend\ntable.sort(alist)\nlocal amap = {}\nlocal asum = {}\nfor i = 1, #alist do\n if not amap[alist[i]] then\n amap[alist[i]] = i\n end\n if i == 1 then asum[i] = alist[i]\n else asum[i] = asum[i - 1] + alist[i]\n end\nend\nlocal stary = {}\nfor i = 1, #alist do stary[i] = {0, 0LL} end\nlocal tree = SegTree.new(stary, function(x, y) return {x[1] + y[1], x[2] + y[2]} end, {0, 0LL})\nlocal addcnt = {}\nlocal acnt = 0\nlocal bsum = 0\nfor i = 1, q do\n local query = qlist[i]\n if query then\n local a = query[1]\n local addpos = amap[query[1]]\n if addcnt[a] then\n addpos = addpos + addcnt[a]\n addcnt[a] = addcnt[a] + 1\n else\n addcnt[a] = 1\n end\n tree:setValue(addpos, {1, 0LL + a})\n bsum = bsum + query[2]\n acnt = acnt + 1\n else\n local half = mfl((acnt + 1) / 2)\n local calcpos, preval = tree:lower_bound(half)\n local src = alist[calcpos]\n preval = preval + src\n local curtot = tree.stage[1][1][2]\n local result = bsum + half * src - preval\n + (curtot - preval) - (acnt - half) * src\n local resultstr = tostring(result):gsub(\"LL\", \"\")\n print(src .. \" \" .. resultstr)\n end\nend\n", "problem_context": "Score : 600 points\n\nProblem Statement\n\nThere is a function f(x), which is initially a constant function f(x) = 0.\n\nWe will ask you to process Q queries in order. There are two kinds of queries, update queries and evaluation queries, as follows:\n\nAn update query 1 a b: Given two integers a and b, let g(x) = f(x) + |x - a| + b and replace f(x) with g(x).\n\nAn evaluation query 2: Print x that minimizes f(x), and the minimum value of f(x). If there are multiple such values of x, choose the minimum such value.\n\nWe can show that the values to be output in an evaluation query are always integers, so we ask you to print those values as integers without decimal points.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq Q \\leq 2 \\times 10^5\n\n-10^9 \\leq a, b \\leq 10^9\n\nThe first query is an update query.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nQ\nQuery_1\n:\nQuery_Q\n\nSee Sample Input 1 for an example.\n\nOutput\n\nFor each evaluation query, print a line containing the response, in the order in which the queries are given.\n\nThe response to each evaluation query should be the minimum value of x that minimizes f(x), and the minimum value of f(x), in this order, with space in between.\n\nSample Input 1\n\n4\n1 4 2\n2\n1 1 -8\n2\n\nSample Output 1\n\n4 2\n1 -3\n\nIn the first evaluation query, f(x) = |x - 4| + 2, which attains the minimum value of 2 at x = 4.\n\nIn the second evaluation query, f(x) = |x - 1| + |x - 4| - 6, which attains the minimum value of -3 when 1 \\leq x \\leq 4. Among the multiple values of x that minimize f(x), we ask you to print the minimum, that is, 1.\n\nSample Input 2\n\n4\n1 -1000000000 1000000000\n1 -1000000000 1000000000\n1 -1000000000 1000000000\n2\n\nSample Output 2\n\n-1000000000 3000000000", "sample_input": "4\n1 4 2\n2\n1 1 -8\n2\n"}, "reference_outputs": ["4 2\n1 -3\n"], "source_document_id": "p03040", "source_text": "Score : 600 points\n\nProblem Statement\n\nThere is a function f(x), which is initially a constant function f(x) = 0.\n\nWe will ask you to process Q queries in order. There are two kinds of queries, update queries and evaluation queries, as follows:\n\nAn update query 1 a b: Given two integers a and b, let g(x) = f(x) + |x - a| + b and replace f(x) with g(x).\n\nAn evaluation query 2: Print x that minimizes f(x), and the minimum value of f(x). If there are multiple such values of x, choose the minimum such value.\n\nWe can show that the values to be output in an evaluation query are always integers, so we ask you to print those values as integers without decimal points.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq Q \\leq 2 \\times 10^5\n\n-10^9 \\leq a, b \\leq 10^9\n\nThe first query is an update query.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nQ\nQuery_1\n:\nQuery_Q\n\nSee Sample Input 1 for an example.\n\nOutput\n\nFor each evaluation query, print a line containing the response, in the order in which the queries are given.\n\nThe response to each evaluation query should be the minimum value of x that minimizes f(x), and the minimum value of f(x), in this order, with space in between.\n\nSample Input 1\n\n4\n1 4 2\n2\n1 1 -8\n2\n\nSample Output 1\n\n4 2\n1 -3\n\nIn the first evaluation query, f(x) = |x - 4| + 2, which attains the minimum value of 2 at x = 4.\n\nIn the second evaluation query, f(x) = |x - 1| + |x - 4| - 6, which attains the minimum value of -3 when 1 \\leq x \\leq 4. Among the multiple values of x that minimize f(x), we ask you to print the minimum, that is, 1.\n\nSample Input 2\n\n4\n1 -1000000000 1000000000\n1 -1000000000 1000000000\n1 -1000000000 1000000000\n2\n\nSample Output 2\n\n-1000000000 3000000000", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 4445, "cpu_time_ms": 1948, "memory_kb": 202180}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s219100369", "group_id": "codeNet:p03040", "input_text": "local mfl, mce, mmi = math.floor, math.ceil, math.min\nlocal SegTree = {}\nSegTree.updateAll = function(self)\n for i = self.stagenum - 1, 1, -1 do\n for j = 1, self.cnt[i] do\n self.stage[i][j] = self.func(self.stage[i + 1][j * 2 - 1], self.stage[i + 1][j * 2])\n end\n end\nend\nSegTree.create = function(self, ary, func, emptyvalue)\n self.func, self.emptyvalue = func, emptyvalue\n local stagenum, mul = 1, 1\n self.cnt, self.stage, self.size = {1}, {{}}, {}\n while mul < #ary do\n mul, stagenum = mul * 2, stagenum + 1\n self.cnt[stagenum], self.stage[stagenum] = mul, {}\n end\n for i = 1, stagenum do self.size[i] = self.cnt[stagenum + 1 - i] end\n self.stagenum = stagenum\n for i = 1, #ary do self.stage[stagenum][i] = ary[i] end\n for i = #ary + 1, mul do self.stage[stagenum][i] = emptyvalue end\n self:updateAll()\nend\nSegTree.getRange = function(self, left, right)\n if left == right then return self.stage[self.stagenum][left] end\n local start_stage = 1\n while right - left + 1 < self.size[start_stage] do\n start_stage = start_stage + 1\n end\n local ret = self.emptyvalue\n local t1, t2, t3 = {start_stage}, {left}, {right}\n while 0 < #t1 do\n local stage, l, r = t1[#t1], t2[#t1], t3[#t1]\n table.remove(t1) table.remove(t2) table.remove(t3)\n local sz = self.size[stage]\n if (l - 1) % sz ~= 0 then\n local newr = mmi(r, mce((l - 1) / sz) * sz)\n table.insert(t1, stage + 1) table.insert(t2, l) table.insert(t3, newr)\n l = newr + 1\n end\n if sz <= r + 1 - l then\n ret = self.func(ret, self.stage[stage][mce(l / sz)])\n l = l + sz\n end\n if l <= r then\n table.insert(t1, stage + 1) table.insert(t2, l) table.insert(t3, r)\n end\n end\n return ret\nend\nSegTree.setValue = function(self, idx, value, silent)\n self.stage[self.stagenum][idx] = value\n if not silent then\n for i = self.stagenum - 1, 1, -1 do\n local dst = mce(idx / 2)\n local rem = dst * 4 - 1 - idx\n self.stage[i][dst] = self.func(self.stage[i + 1][idx], self.stage[i + 1][rem])\n idx = dst\n end\n end\nend\nSegTree.new = function(ary, func, emptyvalue)\n local obj = {}\n setmetatable(obj, {__index = SegTree})\n obj:create(ary, func, emptyvalue)\n return obj\nend\n\nSegTree.lower_bound = function(self, val)\n local ret, retpos = self.emptyvalue, 0\n local t1, t2, t3 = {1}, {1}, {self.size[1]}\n local retval = 0\n while 0 < #t1 do\n local stage, l, r = t1[#t1], t2[#t1], t3[#t1]\n table.remove(t1) table.remove(t2) table.remove(t3)\n local sz = self.size[stage]\n if sz <= r + 1 - l then\n local tmp = self.func(ret, self.stage[stage][mce(l / sz)])\n if tmp[1] < val then\n ret, retpos = tmp, l + sz - 1\n retval = tmp[2]\n if sz ~= 1 then table.insert(t1, stage + 1) table.insert(t2, l + sz) table.insert(t3, r) end\n else\n if sz ~= 1 then table.insert(t1, stage + 1) table.insert(t2, l) table.insert(t3, l + sz - 2) end\n end\n else\n table.insert(t1, stage + 1) table.insert(t2, l) table.insert(t3, r)\n end\n end\n return retpos + 1, retval\nend\n\nlocal q = io.read(\"*n\")\nlocal qlist = {}\nlocal alist = {}\nfor i = 1, q do\n local tp = io.read(\"*n\")\n if tp == 1 then\n local a, b = io.read(\"*n\", \"*n\")\n qlist[i] = {a, b}\n table.insert(alist, a)\n else\n qlist[i] = false\n end\nend\ntable.sort(alist)\nlocal amap = {}\nlocal asum = {}\nfor i = 1, #alist do\n if not amap[alist[i]] then\n amap[alist[i]] = i\n end\n if i == 1 then asum[i] = alist[i]\n else asum[i] = asum[i - 1] + alist[i]\n end\nend\nlocal stary = {}\nfor i = 1, #alist do stary[i] = {0, 0} end\nlocal tree = SegTree.new(stary, function(x, y) return {x[1] + y[1], x[2] + y[2]} end, {0, 0})\nlocal addcnt = {}\nlocal acnt = 0\nlocal bsum = 0\nfor i = 1, q do\n local query = qlist[i]\n if query then\n local a = query[1]\n local addpos = amap[query[1]]\n if addcnt[a] then\n addpos = addpos + addcnt[a]\n addcnt[a] = addcnt[a] + 1\n else\n addcnt[a] = 1\n end\n tree:setValue(addpos, {1, a})\n bsum = bsum + query[2]\n acnt = acnt + 1\n -- for i = 1, #alist do\n -- print(\"A\", i)\n -- print(unpack(tree.stage[tree.stagenum][i]))\n -- end\n else\n local half = mfl((acnt + 1) / 2)\n local calcpos, preval = tree:lower_bound(half)\n local src = alist[calcpos]\n preval = preval + src\n local curtot = tree.stage[1][1][2]\n -- print(\"B\", half, calcpos, src, bsum, curtot, asum[calcpos])\n local result = bsum + half * src - preval\n + (curtot - preval) - (acnt - half) * src\n print(src .. \" \" .. result)\n end\nend\n", "language": "Lua", "metadata": {"date": 1567367985, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p03040.html", "problem_id": "p03040", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03040/input.txt", "sample_output_relpath": "derived/input_output/data/p03040/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03040/Lua/s219100369.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s219100369", "user_id": "u120582723"}, "prompt_components": {"gold_output": "4 2\n1 -3\n", "input_to_evaluate": "local mfl, mce, mmi = math.floor, math.ceil, math.min\nlocal SegTree = {}\nSegTree.updateAll = function(self)\n for i = self.stagenum - 1, 1, -1 do\n for j = 1, self.cnt[i] do\n self.stage[i][j] = self.func(self.stage[i + 1][j * 2 - 1], self.stage[i + 1][j * 2])\n end\n end\nend\nSegTree.create = function(self, ary, func, emptyvalue)\n self.func, self.emptyvalue = func, emptyvalue\n local stagenum, mul = 1, 1\n self.cnt, self.stage, self.size = {1}, {{}}, {}\n while mul < #ary do\n mul, stagenum = mul * 2, stagenum + 1\n self.cnt[stagenum], self.stage[stagenum] = mul, {}\n end\n for i = 1, stagenum do self.size[i] = self.cnt[stagenum + 1 - i] end\n self.stagenum = stagenum\n for i = 1, #ary do self.stage[stagenum][i] = ary[i] end\n for i = #ary + 1, mul do self.stage[stagenum][i] = emptyvalue end\n self:updateAll()\nend\nSegTree.getRange = function(self, left, right)\n if left == right then return self.stage[self.stagenum][left] end\n local start_stage = 1\n while right - left + 1 < self.size[start_stage] do\n start_stage = start_stage + 1\n end\n local ret = self.emptyvalue\n local t1, t2, t3 = {start_stage}, {left}, {right}\n while 0 < #t1 do\n local stage, l, r = t1[#t1], t2[#t1], t3[#t1]\n table.remove(t1) table.remove(t2) table.remove(t3)\n local sz = self.size[stage]\n if (l - 1) % sz ~= 0 then\n local newr = mmi(r, mce((l - 1) / sz) * sz)\n table.insert(t1, stage + 1) table.insert(t2, l) table.insert(t3, newr)\n l = newr + 1\n end\n if sz <= r + 1 - l then\n ret = self.func(ret, self.stage[stage][mce(l / sz)])\n l = l + sz\n end\n if l <= r then\n table.insert(t1, stage + 1) table.insert(t2, l) table.insert(t3, r)\n end\n end\n return ret\nend\nSegTree.setValue = function(self, idx, value, silent)\n self.stage[self.stagenum][idx] = value\n if not silent then\n for i = self.stagenum - 1, 1, -1 do\n local dst = mce(idx / 2)\n local rem = dst * 4 - 1 - idx\n self.stage[i][dst] = self.func(self.stage[i + 1][idx], self.stage[i + 1][rem])\n idx = dst\n end\n end\nend\nSegTree.new = function(ary, func, emptyvalue)\n local obj = {}\n setmetatable(obj, {__index = SegTree})\n obj:create(ary, func, emptyvalue)\n return obj\nend\n\nSegTree.lower_bound = function(self, val)\n local ret, retpos = self.emptyvalue, 0\n local t1, t2, t3 = {1}, {1}, {self.size[1]}\n local retval = 0\n while 0 < #t1 do\n local stage, l, r = t1[#t1], t2[#t1], t3[#t1]\n table.remove(t1) table.remove(t2) table.remove(t3)\n local sz = self.size[stage]\n if sz <= r + 1 - l then\n local tmp = self.func(ret, self.stage[stage][mce(l / sz)])\n if tmp[1] < val then\n ret, retpos = tmp, l + sz - 1\n retval = tmp[2]\n if sz ~= 1 then table.insert(t1, stage + 1) table.insert(t2, l + sz) table.insert(t3, r) end\n else\n if sz ~= 1 then table.insert(t1, stage + 1) table.insert(t2, l) table.insert(t3, l + sz - 2) end\n end\n else\n table.insert(t1, stage + 1) table.insert(t2, l) table.insert(t3, r)\n end\n end\n return retpos + 1, retval\nend\n\nlocal q = io.read(\"*n\")\nlocal qlist = {}\nlocal alist = {}\nfor i = 1, q do\n local tp = io.read(\"*n\")\n if tp == 1 then\n local a, b = io.read(\"*n\", \"*n\")\n qlist[i] = {a, b}\n table.insert(alist, a)\n else\n qlist[i] = false\n end\nend\ntable.sort(alist)\nlocal amap = {}\nlocal asum = {}\nfor i = 1, #alist do\n if not amap[alist[i]] then\n amap[alist[i]] = i\n end\n if i == 1 then asum[i] = alist[i]\n else asum[i] = asum[i - 1] + alist[i]\n end\nend\nlocal stary = {}\nfor i = 1, #alist do stary[i] = {0, 0} end\nlocal tree = SegTree.new(stary, function(x, y) return {x[1] + y[1], x[2] + y[2]} end, {0, 0})\nlocal addcnt = {}\nlocal acnt = 0\nlocal bsum = 0\nfor i = 1, q do\n local query = qlist[i]\n if query then\n local a = query[1]\n local addpos = amap[query[1]]\n if addcnt[a] then\n addpos = addpos + addcnt[a]\n addcnt[a] = addcnt[a] + 1\n else\n addcnt[a] = 1\n end\n tree:setValue(addpos, {1, a})\n bsum = bsum + query[2]\n acnt = acnt + 1\n -- for i = 1, #alist do\n -- print(\"A\", i)\n -- print(unpack(tree.stage[tree.stagenum][i]))\n -- end\n else\n local half = mfl((acnt + 1) / 2)\n local calcpos, preval = tree:lower_bound(half)\n local src = alist[calcpos]\n preval = preval + src\n local curtot = tree.stage[1][1][2]\n -- print(\"B\", half, calcpos, src, bsum, curtot, asum[calcpos])\n local result = bsum + half * src - preval\n + (curtot - preval) - (acnt - half) * src\n print(src .. \" \" .. result)\n end\nend\n", "problem_context": "Score : 600 points\n\nProblem Statement\n\nThere is a function f(x), which is initially a constant function f(x) = 0.\n\nWe will ask you to process Q queries in order. There are two kinds of queries, update queries and evaluation queries, as follows:\n\nAn update query 1 a b: Given two integers a and b, let g(x) = f(x) + |x - a| + b and replace f(x) with g(x).\n\nAn evaluation query 2: Print x that minimizes f(x), and the minimum value of f(x). If there are multiple such values of x, choose the minimum such value.\n\nWe can show that the values to be output in an evaluation query are always integers, so we ask you to print those values as integers without decimal points.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq Q \\leq 2 \\times 10^5\n\n-10^9 \\leq a, b \\leq 10^9\n\nThe first query is an update query.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nQ\nQuery_1\n:\nQuery_Q\n\nSee Sample Input 1 for an example.\n\nOutput\n\nFor each evaluation query, print a line containing the response, in the order in which the queries are given.\n\nThe response to each evaluation query should be the minimum value of x that minimizes f(x), and the minimum value of f(x), in this order, with space in between.\n\nSample Input 1\n\n4\n1 4 2\n2\n1 1 -8\n2\n\nSample Output 1\n\n4 2\n1 -3\n\nIn the first evaluation query, f(x) = |x - 4| + 2, which attains the minimum value of 2 at x = 4.\n\nIn the second evaluation query, f(x) = |x - 1| + |x - 4| - 6, which attains the minimum value of -3 when 1 \\leq x \\leq 4. Among the multiple values of x that minimize f(x), we ask you to print the minimum, that is, 1.\n\nSample Input 2\n\n4\n1 -1000000000 1000000000\n1 -1000000000 1000000000\n1 -1000000000 1000000000\n2\n\nSample Output 2\n\n-1000000000 3000000000", "sample_input": "4\n1 4 2\n2\n1 1 -8\n2\n"}, "reference_outputs": ["4 2\n1 -3\n"], "source_document_id": "p03040", "source_text": "Score : 600 points\n\nProblem Statement\n\nThere is a function f(x), which is initially a constant function f(x) = 0.\n\nWe will ask you to process Q queries in order. There are two kinds of queries, update queries and evaluation queries, as follows:\n\nAn update query 1 a b: Given two integers a and b, let g(x) = f(x) + |x - a| + b and replace f(x) with g(x).\n\nAn evaluation query 2: Print x that minimizes f(x), and the minimum value of f(x). If there are multiple such values of x, choose the minimum such value.\n\nWe can show that the values to be output in an evaluation query are always integers, so we ask you to print those values as integers without decimal points.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq Q \\leq 2 \\times 10^5\n\n-10^9 \\leq a, b \\leq 10^9\n\nThe first query is an update query.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nQ\nQuery_1\n:\nQuery_Q\n\nSee Sample Input 1 for an example.\n\nOutput\n\nFor each evaluation query, print a line containing the response, in the order in which the queries are given.\n\nThe response to each evaluation query should be the minimum value of x that minimizes f(x), and the minimum value of f(x), in this order, with space in between.\n\nSample Input 1\n\n4\n1 4 2\n2\n1 1 -8\n2\n\nSample Output 1\n\n4 2\n1 -3\n\nIn the first evaluation query, f(x) = |x - 4| + 2, which attains the minimum value of 2 at x = 4.\n\nIn the second evaluation query, f(x) = |x - 1| + |x - 4| - 6, which attains the minimum value of -3 when 1 \\leq x \\leq 4. Among the multiple values of x that minimize f(x), we ask you to print the minimum, that is, 1.\n\nSample Input 2\n\n4\n1 -1000000000 1000000000\n1 -1000000000 1000000000\n1 -1000000000 1000000000\n2\n\nSample Output 2\n\n-1000000000 3000000000", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 4560, "cpu_time_ms": 1156, "memory_kb": 165572}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s556949139", "group_id": "codeNet:p03041", "input_text": "n, k = io.read(\"*n\", \"*n\", \"*l\")\ns = io.read()\nfor i = 1, n do\n if i == k then\n io.write(string.char(s:byte(k) + 32))\n else\n io.write(s:sub(i, i))\n end\nend\nio.write(\"\\n\")\n", "language": "Lua", "metadata": {"date": 1597420600, "filename_ext": "lua", "original_language": "Lua (Lua 5.3.5)", "problem_description_relpath": "problem_descriptions/p03041.html", "problem_id": "p03041", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03041/input.txt", "sample_output_relpath": "derived/input_output/data/p03041/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03041/Lua/s556949139.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s556949139", "user_id": "u120582723"}, "prompt_components": {"gold_output": "aBC\n", "input_to_evaluate": "n, k = io.read(\"*n\", \"*n\", \"*l\")\ns = io.read()\nfor i = 1, n do\n if i == k then\n io.write(string.char(s:byte(k) + 32))\n else\n io.write(s:sub(i, i))\n end\nend\nio.write(\"\\n\")\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nYou are given a string S of length N consisting of A, B and C, and an integer K which is between 1 and N (inclusive).\nPrint the string S after lowercasing the K-th character in it.\n\nConstraints\n\n1 ≤ N ≤ 50\n\n1 ≤ K ≤ N\n\nS is a string of length N consisting of A, B and C.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nS\n\nOutput\n\nPrint the string S after lowercasing the K-th character in it.\n\nSample Input 1\n\n3 1\nABC\n\nSample Output 1\n\naBC\n\nSample Input 2\n\n4 3\nCABA\n\nSample Output 2\n\nCAbA", "sample_input": "3 1\nABC\n"}, "reference_outputs": ["aBC\n"], "source_document_id": "p03041", "source_text": "Score : 100 points\n\nProblem Statement\n\nYou are given a string S of length N consisting of A, B and C, and an integer K which is between 1 and N (inclusive).\nPrint the string S after lowercasing the K-th character in it.\n\nConstraints\n\n1 ≤ N ≤ 50\n\n1 ≤ K ≤ N\n\nS is a string of length N consisting of A, B and C.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nS\n\nOutput\n\nPrint the string S after lowercasing the K-th character in it.\n\nSample Input 1\n\n3 1\nABC\n\nSample Output 1\n\naBC\n\nSample Input 2\n\n4 3\nCABA\n\nSample Output 2\n\nCAbA", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 180, "cpu_time_ms": 11, "memory_kb": 2652}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s338899973", "group_id": "codeNet:p03042", "input_text": "local fst, snd = io.read(2, 2)\nfst = tonumber(fst)\nsnd = tonumber(snd)\nlocal yymm, mmyy = true, true\nif fst >= 13 or fst <= 0 then\n mmyy = false\nend\nif snd >= 13 or snd <= 0 then\n yymm = false\nend\nif yymm and mmyy then\n print(\"AMBIGUOUS\")\nelseif yymm then\n print(\"YYMM\")\nelseif mmyy then\n print(\"MMYY\")\nelse\n print(\"NA\")\nend", "language": "Lua", "metadata": {"date": 1558314568, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03042.html", "problem_id": "p03042", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03042/input.txt", "sample_output_relpath": "derived/input_output/data/p03042/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03042/Lua/s338899973.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s338899973", "user_id": "u162773977"}, "prompt_components": {"gold_output": "YYMM\n", "input_to_evaluate": "local fst, snd = io.read(2, 2)\nfst = tonumber(fst)\nsnd = tonumber(snd)\nlocal yymm, mmyy = true, true\nif fst >= 13 or fst <= 0 then\n mmyy = false\nend\nif snd >= 13 or snd <= 0 then\n yymm = false\nend\nif yymm and mmyy then\n print(\"AMBIGUOUS\")\nelseif yymm then\n print(\"YYMM\")\nelseif mmyy then\n print(\"MMYY\")\nelse\n print(\"NA\")\nend", "problem_context": "Score : 200 points\n\nProblem Statement\n\nYou have a digit sequence S of length 4. You are wondering which of the following formats S is in:\n\nYYMM format: the last two digits of the year and the two-digit representation of the month (example: 01 for January), concatenated in this order\n\nMMYY format: the two-digit representation of the month and the last two digits of the year, concatenated in this order\n\nIf S is valid in only YYMM format, print YYMM; if S is valid in only MMYY format, print MMYY; if S is valid in both formats, print AMBIGUOUS; if S is valid in neither format, print NA.\n\nConstraints\n\nS is a digit sequence of length 4.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the specified string: YYMM, MMYY, AMBIGUOUS or NA.\n\nSample Input 1\n\n1905\n\nSample Output 1\n\nYYMM\n\nMay XX19 is a valid date, but 19 is not valid as a month. Thus, this string is only valid in YYMM format.\n\nSample Input 2\n\n0112\n\nSample Output 2\n\nAMBIGUOUS\n\nBoth December XX01 and January XX12 are valid dates. Thus, this string is valid in both formats.\n\nSample Input 3\n\n1700\n\nSample Output 3\n\nNA\n\nNeither 0 nor 17 is valid as a month. Thus, this string is valid in neither format.", "sample_input": "1905\n"}, "reference_outputs": ["YYMM\n"], "source_document_id": "p03042", "source_text": "Score : 200 points\n\nProblem Statement\n\nYou have a digit sequence S of length 4. You are wondering which of the following formats S is in:\n\nYYMM format: the last two digits of the year and the two-digit representation of the month (example: 01 for January), concatenated in this order\n\nMMYY format: the two-digit representation of the month and the last two digits of the year, concatenated in this order\n\nIf S is valid in only YYMM format, print YYMM; if S is valid in only MMYY format, print MMYY; if S is valid in both formats, print AMBIGUOUS; if S is valid in neither format, print NA.\n\nConstraints\n\nS is a digit sequence of length 4.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the specified string: YYMM, MMYY, AMBIGUOUS or NA.\n\nSample Input 1\n\n1905\n\nSample Output 1\n\nYYMM\n\nMay XX19 is a valid date, but 19 is not valid as a month. Thus, this string is only valid in YYMM format.\n\nSample Input 2\n\n0112\n\nSample Output 2\n\nAMBIGUOUS\n\nBoth December XX01 and January XX12 are valid dates. Thus, this string is valid in both formats.\n\nSample Input 3\n\n1700\n\nSample Output 3\n\nNA\n\nNeither 0 nor 17 is valid as a month. Thus, this string is valid in neither format.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 342, "cpu_time_ms": 12, "memory_kb": 1008}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s149099489", "group_id": "codeNet:p03044", "input_text": "local List = {}\nfunction List.new ()\n return {first = 0, last = -1}\nend\n\nfunction List.pushleft (list, value)\n local first = list.first - 1\n list.first = first\n list[first] = value\nend\n\nfunction List.pushright (list, value)\n local last = list.last + 1\n list.last = last\n list[last] = value\nend\n\nfunction List.popleft (list)\n local first = list.first\n local value = list[first]\n list[first] = nil\n list.first = first + 1\n return value\nend\n\nfunction List.popright (list)\n local last = list.last\n local value = list[last]\n list[last] = nil\n list.last = last - 1\n return value\nend\n\nfunction List.empty (list)\n return list.first > list.last\nend\n\n----------\n\nlocal n=io.read(\"n\")\nlocal graph={}\nfor i=1,n do\n graph[i]={}\nend\nfor i=1,n-1 do\n local u,v,w=io.read(\"n\",\"n\",\"n\")\n w=w%2\n graph[u][v]=w\n graph[v][u]=w\nend\n\nlocal stack=List.new()\nList.pushright(stack,{1,0})\nlocal checked={true}\nlocal color={1}\n\nwhile not List.empty(stack) do\n local pop=List.popright(stack)\n local u=pop[1]\n local w=pop[2]\n for v,_ in pairs(graph[u]) do\n local nw=w+graph[u][v]\n if not checked[v] then\n if nw%2==0 then\n color[v]=1\n else\n color[v]=0\n end\n checked[v]=true\n List.pushright(stack,{v,nw})\n end\n end\nend\n\nfor i=1,n do\n print(color[i])\nend", "language": "Lua", "metadata": {"date": 1598485134, "filename_ext": "lua", "original_language": "Lua (Lua 5.3.5)", "problem_description_relpath": "problem_descriptions/p03044.html", "problem_id": "p03044", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03044/input.txt", "sample_output_relpath": "derived/input_output/data/p03044/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03044/Lua/s149099489.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s149099489", "user_id": "u045238009"}, "prompt_components": {"gold_output": "0\n0\n1\n", "input_to_evaluate": "local List = {}\nfunction List.new ()\n return {first = 0, last = -1}\nend\n\nfunction List.pushleft (list, value)\n local first = list.first - 1\n list.first = first\n list[first] = value\nend\n\nfunction List.pushright (list, value)\n local last = list.last + 1\n list.last = last\n list[last] = value\nend\n\nfunction List.popleft (list)\n local first = list.first\n local value = list[first]\n list[first] = nil\n list.first = first + 1\n return value\nend\n\nfunction List.popright (list)\n local last = list.last\n local value = list[last]\n list[last] = nil\n list.last = last - 1\n return value\nend\n\nfunction List.empty (list)\n return list.first > list.last\nend\n\n----------\n\nlocal n=io.read(\"n\")\nlocal graph={}\nfor i=1,n do\n graph[i]={}\nend\nfor i=1,n-1 do\n local u,v,w=io.read(\"n\",\"n\",\"n\")\n w=w%2\n graph[u][v]=w\n graph[v][u]=w\nend\n\nlocal stack=List.new()\nList.pushright(stack,{1,0})\nlocal checked={true}\nlocal color={1}\n\nwhile not List.empty(stack) do\n local pop=List.popright(stack)\n local u=pop[1]\n local w=pop[2]\n for v,_ in pairs(graph[u]) do\n local nw=w+graph[u][v]\n if not checked[v] then\n if nw%2==0 then\n color[v]=1\n else\n color[v]=0\n end\n checked[v]=true\n List.pushright(stack,{v,nw})\n end\n end\nend\n\nfor i=1,n do\n print(color[i])\nend", "problem_context": "Score : 400 points\n\nProblem Statement\n\nWe have a tree with N vertices numbered 1 to N.\nThe i-th edge in the tree connects Vertex u_i and Vertex v_i, and its length is w_i.\nYour objective is to paint each vertex in the tree white or black (it is fine to paint all vertices the same color) so that the following condition is satisfied:\n\nFor any two vertices painted in the same color, the distance between them is an even number.\n\nFind a coloring of the vertices that satisfies the condition and print it. It can be proved that at least one such coloring exists under the constraints of this problem.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^5\n\n1 \\leq u_i < v_i \\leq N\n\n1 \\leq w_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nu_1 v_1 w_1\nu_2 v_2 w_2\n.\n.\n.\nu_{N - 1} v_{N - 1} w_{N - 1}\n\nOutput\n\nPrint a coloring of the vertices that satisfies the condition, in N lines.\nThe i-th line should contain 0 if Vertex i is painted white and 1 if it is painted black.\n\nIf there are multiple colorings that satisfy the condition, any of them will be accepted.\n\nSample Input 1\n\n3\n1 2 2\n2 3 1\n\nSample Output 1\n\n0\n0\n1\n\nSample Input 2\n\n5\n2 5 2\n2 3 10\n1 3 8\n3 4 2\n\nSample Output 2\n\n1\n0\n1\n0\n1", "sample_input": "3\n1 2 2\n2 3 1\n"}, "reference_outputs": ["0\n0\n1\n"], "source_document_id": "p03044", "source_text": "Score : 400 points\n\nProblem Statement\n\nWe have a tree with N vertices numbered 1 to N.\nThe i-th edge in the tree connects Vertex u_i and Vertex v_i, and its length is w_i.\nYour objective is to paint each vertex in the tree white or black (it is fine to paint all vertices the same color) so that the following condition is satisfied:\n\nFor any two vertices painted in the same color, the distance between them is an even number.\n\nFind a coloring of the vertices that satisfies the condition and print it. It can be proved that at least one such coloring exists under the constraints of this problem.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^5\n\n1 \\leq u_i < v_i \\leq N\n\n1 \\leq w_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nu_1 v_1 w_1\nu_2 v_2 w_2\n.\n.\n.\nu_{N - 1} v_{N - 1} w_{N - 1}\n\nOutput\n\nPrint a coloring of the vertices that satisfies the condition, in N lines.\nThe i-th line should contain 0 if Vertex i is painted white and 1 if it is painted black.\n\nIf there are multiple colorings that satisfy the condition, any of them will be accepted.\n\nSample Input 1\n\n3\n1 2 2\n2 3 1\n\nSample Output 1\n\n0\n0\n1\n\nSample Input 2\n\n5\n2 5 2\n2 3 10\n1 3 8\n3 4 2\n\nSample Output 2\n\n1\n0\n1\n0\n1", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1413, "cpu_time_ms": 404, "memory_kb": 32560}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s134407636", "group_id": "codeNet:p03045", "input_text": "local ior = io.input()\nlocal n, m = ior:read(\"*n\", \"*n\")\n\nlocal parent = {}\nfor i = 1, n do parent[i] = i end\n-- for i = 1, n do groupsize[i] = 1 end\n\nlocal function getroot(idx)\n while(parent[idx] ~= idx) do\n idx = parent[idx]\n end\n return idx\nend\n\nfor i = 1, m do\n local x, y, z = ior:read(\"*n\", \"*n\", \"*n\")\n local xroot, yroot = getroot(x), getroot(y)\n parent[x] = xroot\n parent[yroot] = xroot\n parent[y] = xroot\nend\nlocal grouplist = {}\nlocal cnt = 0\nfor i = 1, n do\n local r = getroot(i)\n if(grouplist[r] == nil) then\n grouplist[r] = true\n cnt = cnt + 1\n end\nend\nprint(cnt)\n", "language": "Lua", "metadata": {"date": 1558315640, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p03045.html", "problem_id": "p03045", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03045/input.txt", "sample_output_relpath": "derived/input_output/data/p03045/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03045/Lua/s134407636.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s134407636", "user_id": "u120582723"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "local ior = io.input()\nlocal n, m = ior:read(\"*n\", \"*n\")\n\nlocal parent = {}\nfor i = 1, n do parent[i] = i end\n-- for i = 1, n do groupsize[i] = 1 end\n\nlocal function getroot(idx)\n while(parent[idx] ~= idx) do\n idx = parent[idx]\n end\n return idx\nend\n\nfor i = 1, m do\n local x, y, z = ior:read(\"*n\", \"*n\", \"*n\")\n local xroot, yroot = getroot(x), getroot(y)\n parent[x] = xroot\n parent[yroot] = xroot\n parent[y] = xroot\nend\nlocal grouplist = {}\nlocal cnt = 0\nfor i = 1, n do\n local r = getroot(i)\n if(grouplist[r] == nil) then\n grouplist[r] = true\n cnt = cnt + 1\n end\nend\nprint(cnt)\n", "problem_context": "Score : 500 points\n\nProblem Statement\n\nThere are N cards placed face down in a row. On each card, an integer 1 or 2 is written.\n\nLet A_i be the integer written on the i-th card.\n\nYour objective is to guess A_1, A_2, ..., A_N correctly.\n\nYou know the following facts:\n\nFor each i = 1, 2, ..., M, the value A_{X_i} + A_{Y_i} + Z_i is an even number.\n\nYou are a magician and can use the following magic any number of times:\n\nMagic: Choose one card and know the integer A_i written on it. The cost of using this magic is 1.\n\nWhat is the minimum cost required to determine all of A_1, A_2, ..., A_N?\n\nIt is guaranteed that there is no contradiction in given input.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^5\n\n1 \\leq X_i < Y_i \\leq N\n\n1 \\leq Z_i \\leq 100\n\nThe pairs (X_i, Y_i) are distinct.\n\nThere is no contradiction in input. (That is, there exist integers A_1, A_2, ..., A_N that satisfy the conditions.)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nX_1 Y_1 Z_1\nX_2 Y_2 Z_2\n\\vdots\nX_M Y_M Z_M\n\nOutput\n\nPrint the minimum total cost required to determine all of A_1, A_2, ..., A_N.\n\nSample Input 1\n\n3 1\n1 2 1\n\nSample Output 1\n\n2\n\nYou can determine all of A_1, A_2, A_3 by using the magic for the first and third cards.\n\nSample Input 2\n\n6 5\n1 2 1\n2 3 2\n1 3 3\n4 5 4\n5 6 5\n\nSample Output 2\n\n2\n\nSample Input 3\n\n100000 1\n1 100000 100\n\nSample Output 3\n\n99999", "sample_input": "3 1\n1 2 1\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03045", "source_text": "Score : 500 points\n\nProblem Statement\n\nThere are N cards placed face down in a row. On each card, an integer 1 or 2 is written.\n\nLet A_i be the integer written on the i-th card.\n\nYour objective is to guess A_1, A_2, ..., A_N correctly.\n\nYou know the following facts:\n\nFor each i = 1, 2, ..., M, the value A_{X_i} + A_{Y_i} + Z_i is an even number.\n\nYou are a magician and can use the following magic any number of times:\n\nMagic: Choose one card and know the integer A_i written on it. The cost of using this magic is 1.\n\nWhat is the minimum cost required to determine all of A_1, A_2, ..., A_N?\n\nIt is guaranteed that there is no contradiction in given input.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^5\n\n1 \\leq X_i < Y_i \\leq N\n\n1 \\leq Z_i \\leq 100\n\nThe pairs (X_i, Y_i) are distinct.\n\nThere is no contradiction in input. (That is, there exist integers A_1, A_2, ..., A_N that satisfy the conditions.)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nX_1 Y_1 Z_1\nX_2 Y_2 Z_2\n\\vdots\nX_M Y_M Z_M\n\nOutput\n\nPrint the minimum total cost required to determine all of A_1, A_2, ..., A_N.\n\nSample Input 1\n\n3 1\n1 2 1\n\nSample Output 1\n\n2\n\nYou can determine all of A_1, A_2, A_3 by using the magic for the first and third cards.\n\nSample Input 2\n\n6 5\n1 2 1\n2 3 2\n1 3 3\n4 5 4\n5 6 5\n\nSample Output 2\n\n2\n\nSample Input 3\n\n100000 1\n1 100000 100\n\nSample Output 3\n\n99999", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 599, "cpu_time_ms": 2103, "memory_kb": 2432}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s708381870", "group_id": "codeNet:p03047", "input_text": "r,g,b,n=io.read(\"*n\",\"*n\",\"*n\",\"*n\")\n\ncounter=0\nfor i=0,n do\n for j=0,n-i do\n rg=r*i+g*j\n if n>=rg and (n-rg)%b==0 then\n counter=counter+1\n end\n end\nend\nprint(counter)", "language": "Lua", "metadata": {"date": 1589151322, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03047.html", "problem_id": "p03047", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03047/input.txt", "sample_output_relpath": "derived/input_output/data/p03047/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03047/Lua/s708381870.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s708381870", "user_id": "u045238009"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "r,g,b,n=io.read(\"*n\",\"*n\",\"*n\",\"*n\")\n\ncounter=0\nfor i=0,n do\n for j=0,n-i do\n rg=r*i+g*j\n if n>=rg and (n-rg)%b==0 then\n counter=counter+1\n end\n end\nend\nprint(counter)", "problem_context": "Score : 100 points\n\nProblem Statement\n\nSnuke has N integers: 1,2,\\ldots,N.\nHe will choose K of them and give those to Takahashi.\n\nHow many ways are there to choose K consecutive integers?\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq K \\leq N \\leq 50\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n3 2\n\nSample Output 1\n\n2\n\nThere are two ways to choose two consecutive integers: (1,2) and (2,3).\n\nSample Input 2\n\n13 3\n\nSample Output 2\n\n11", "sample_input": "3 2\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03047", "source_text": "Score : 100 points\n\nProblem Statement\n\nSnuke has N integers: 1,2,\\ldots,N.\nHe will choose K of them and give those to Takahashi.\n\nHow many ways are there to choose K consecutive integers?\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq K \\leq N \\leq 50\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n3 2\n\nSample Output 1\n\n2\n\nThere are two ways to choose two consecutive integers: (1,2) and (2,3).\n\nSample Input 2\n\n13 3\n\nSample Output 2\n\n11", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 205, "cpu_time_ms": 9, "memory_kb": 760}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s291526703", "group_id": "codeNet:p03048", "input_text": "local ior = io.input()\nlocal r, g, b, n = ior:read(\"*n\", \"*n\", \"*n\", \"*n\")\nlocal cnt = 0\nfor i = 0, n do\n for j = 0, n - i do\n local k = n - i - j\n if i % r == 0 and j % g == 0 and k % b == 0 then cnt = cnt + 1 end\n end\nend\nprint(cnt)\n", "language": "Lua", "metadata": {"date": 1557624002, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p03048.html", "problem_id": "p03048", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03048/input.txt", "sample_output_relpath": "derived/input_output/data/p03048/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03048/Lua/s291526703.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s291526703", "user_id": "u120582723"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "local ior = io.input()\nlocal r, g, b, n = ior:read(\"*n\", \"*n\", \"*n\", \"*n\")\nlocal cnt = 0\nfor i = 0, n do\n for j = 0, n - i do\n local k = n - i - j\n if i % r == 0 and j % g == 0 and k % b == 0 then cnt = cnt + 1 end\n end\nend\nprint(cnt)\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nSnuke has come to a store that sells boxes containing balls. The store sells the following three kinds of boxes:\n\nRed boxes, each containing R red balls\n\nGreen boxes, each containing G green balls\n\nBlue boxes, each containing B blue balls\n\nSnuke wants to get a total of exactly N balls by buying r red boxes, g green boxes and b blue boxes.\nHow many triples of non-negative integers (r,g,b) achieve this?\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq R,G,B,N \\leq 3000\n\nInput\n\nInput is given from Standard Input in the following format:\n\nR G B N\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n1 2 3 4\n\nSample Output 1\n\n4\n\nFour triples achieve the objective, as follows:\n\n(4,0,0)\n\n(2,1,0)\n\n(1,0,1)\n\n(0,2,0)\n\nSample Input 2\n\n13 1 4 3000\n\nSample Output 2\n\n87058", "sample_input": "1 2 3 4\n"}, "reference_outputs": ["4\n"], "source_document_id": "p03048", "source_text": "Score : 200 points\n\nProblem Statement\n\nSnuke has come to a store that sells boxes containing balls. The store sells the following three kinds of boxes:\n\nRed boxes, each containing R red balls\n\nGreen boxes, each containing G green balls\n\nBlue boxes, each containing B blue balls\n\nSnuke wants to get a total of exactly N balls by buying r red boxes, g green boxes and b blue boxes.\nHow many triples of non-negative integers (r,g,b) achieve this?\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq R,G,B,N \\leq 3000\n\nInput\n\nInput is given from Standard Input in the following format:\n\nR G B N\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n1 2 3 4\n\nSample Output 1\n\n4\n\nFour triples achieve the objective, as follows:\n\n(4,0,0)\n\n(2,1,0)\n\n(1,0,1)\n\n(0,2,0)\n\nSample Input 2\n\n13 1 4 3000\n\nSample Output 2\n\n87058", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 243, "cpu_time_ms": 28, "memory_kb": 256}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s954277006", "group_id": "codeNet:p03049", "input_text": "local ior = io.input()\nlocal n = ior:read(\"*n\", \"*l\")\nlocal num_b_st_a_ed = 0\nlocal num_b_st = 0\nlocal num_a_ed = 0\n\nlocal tot = 0\n\nfor i = 1, n do\n local str = ior:read()\n local len = #str\n local isfirst = true\n local bcand = false\n local adet = false\n if(str:sub(1, 1) == \"B\") then bcand = true end\n if(str:sub(len, len) == \"A\") then adet = true end\n for j = 1, len - 1 do\n if(str:sub(j, j) == \"A\" and str:sub(j + 1, j + 1) == \"B\") then\n tot = tot + 1\n -- print(\"FOUND\")\n end\n end\n if(adet and bcand) then\n num_b_st_a_ed = num_b_st_a_ed + 1\n -- print(i, \"AB\")\n elseif(adet) then\n num_a_ed = num_a_ed + 1\n -- print(i, \"A\")\n elseif(bcand) then\n num_b_st = num_b_st + 1\n -- print(i, \"B\")\n end\nend\n\nlocal min = math.min(num_a_ed, math.min(num_b_st, num_b_st_a_ed))\ntot = tot + min * 2\nnum_a_ed, num_b_st, num_b_st_a_ed = num_a_ed - min, num_b_st - min, num_b_st_a_ed - min\n\nif(num_b_st_a_ed == 0) then\n tot = tot + math.min(num_a_ed, num_b_st)\nelseif(num_a_ed == 0) then\n if(0 < num_b_st_a_ed) then\n tot = tot + (num_b_st_a_ed - 1)\n if(0 < num_b_st) then tot = tot + 1 end\n end\nelse\n if(0 < num_b_st_a_ed) then\n tot = tot + (num_b_st_a_ed - 1)\n if(0 < num_a_ed) then tot = tot + 1 end\n end\nend\n-- print(num_a_ed, num_b_st, num_b_st_a_ed)\nprint(tot)\n", "language": "Lua", "metadata": {"date": 1557625805, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p03049.html", "problem_id": "p03049", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03049/input.txt", "sample_output_relpath": "derived/input_output/data/p03049/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03049/Lua/s954277006.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s954277006", "user_id": "u120582723"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "local ior = io.input()\nlocal n = ior:read(\"*n\", \"*l\")\nlocal num_b_st_a_ed = 0\nlocal num_b_st = 0\nlocal num_a_ed = 0\n\nlocal tot = 0\n\nfor i = 1, n do\n local str = ior:read()\n local len = #str\n local isfirst = true\n local bcand = false\n local adet = false\n if(str:sub(1, 1) == \"B\") then bcand = true end\n if(str:sub(len, len) == \"A\") then adet = true end\n for j = 1, len - 1 do\n if(str:sub(j, j) == \"A\" and str:sub(j + 1, j + 1) == \"B\") then\n tot = tot + 1\n -- print(\"FOUND\")\n end\n end\n if(adet and bcand) then\n num_b_st_a_ed = num_b_st_a_ed + 1\n -- print(i, \"AB\")\n elseif(adet) then\n num_a_ed = num_a_ed + 1\n -- print(i, \"A\")\n elseif(bcand) then\n num_b_st = num_b_st + 1\n -- print(i, \"B\")\n end\nend\n\nlocal min = math.min(num_a_ed, math.min(num_b_st, num_b_st_a_ed))\ntot = tot + min * 2\nnum_a_ed, num_b_st, num_b_st_a_ed = num_a_ed - min, num_b_st - min, num_b_st_a_ed - min\n\nif(num_b_st_a_ed == 0) then\n tot = tot + math.min(num_a_ed, num_b_st)\nelseif(num_a_ed == 0) then\n if(0 < num_b_st_a_ed) then\n tot = tot + (num_b_st_a_ed - 1)\n if(0 < num_b_st) then tot = tot + 1 end\n end\nelse\n if(0 < num_b_st_a_ed) then\n tot = tot + (num_b_st_a_ed - 1)\n if(0 < num_a_ed) then tot = tot + 1 end\n end\nend\n-- print(num_a_ed, num_b_st, num_b_st_a_ed)\nprint(tot)\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nSnuke has N strings. The i-th string is s_i.\n\nLet us concatenate these strings into one string after arranging them in some order.\nFind the maximum possible number of occurrences of AB in the resulting string.\n\nConstraints\n\n1 \\leq N \\leq 10^{4}\n\n2 \\leq |s_i| \\leq 10\n\ns_i consists of uppercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\ns_1\n\\vdots\ns_N\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n3\nABCA\nXBAZ\nBAD\n\nSample Output 1\n\n2\n\nFor example, if we concatenate ABCA, BAD and XBAZ in this order, the resulting string ABCABADXBAZ has two occurrences of AB.\n\nSample Input 2\n\n9\nBEWPVCRWH\nZZNQYIJX\nBAVREA\nPA\nHJMYITEOX\nBCJHMRMNK\nBP\nQVFABZ\nPRGKSPUNA\n\nSample Output 2\n\n4\n\nSample Input 3\n\n7\nRABYBBE\nJOZ\nBMHQUVA\nBPA\nISU\nMCMABAOBHZ\nSZMEHMA\n\nSample Output 3\n\n4", "sample_input": "3\nABCA\nXBAZ\nBAD\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03049", "source_text": "Score : 400 points\n\nProblem Statement\n\nSnuke has N strings. The i-th string is s_i.\n\nLet us concatenate these strings into one string after arranging them in some order.\nFind the maximum possible number of occurrences of AB in the resulting string.\n\nConstraints\n\n1 \\leq N \\leq 10^{4}\n\n2 \\leq |s_i| \\leq 10\n\ns_i consists of uppercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\ns_1\n\\vdots\ns_N\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n3\nABCA\nXBAZ\nBAD\n\nSample Output 1\n\n2\n\nFor example, if we concatenate ABCA, BAD and XBAZ in this order, the resulting string ABCABADXBAZ has two occurrences of AB.\n\nSample Input 2\n\n9\nBEWPVCRWH\nZZNQYIJX\nBAVREA\nPA\nHJMYITEOX\nBCJHMRMNK\nBP\nQVFABZ\nPRGKSPUNA\n\nSample Output 2\n\n4\n\nSample Input 3\n\n7\nRABYBBE\nJOZ\nBMHQUVA\nBPA\nISU\nMCMABAOBHZ\nSZMEHMA\n\nSample Output 3\n\n4", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1311, "cpu_time_ms": 6, "memory_kb": 512}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s163735423", "group_id": "codeNet:p03050", "input_text": "local n=io.read(\"n\")\n\nlocal t={}\nfor i=1,math.sqrt(n) do\n if n%i==0 then\n if i>1 then\n table.insert(t,i)\n end\n if i~=n//i then\n table.insert(t,n//i)\n end\n end\nend\ntable.sort(t)\n\nlocal sum=0\nfor i=1,#t do\n local m=t[i]-1\n if (m+1)*(n//m)==n then\n sum=sum+m\n end\nend\nprint(sum)", "language": "Lua", "metadata": {"date": 1593644549, "filename_ext": "lua", "original_language": "Lua (Lua 5.3.5)", "problem_description_relpath": "problem_descriptions/p03050.html", "problem_id": "p03050", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03050/input.txt", "sample_output_relpath": "derived/input_output/data/p03050/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03050/Lua/s163735423.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s163735423", "user_id": "u045238009"}, "prompt_components": {"gold_output": "10\n", "input_to_evaluate": "local n=io.read(\"n\")\n\nlocal t={}\nfor i=1,math.sqrt(n) do\n if n%i==0 then\n if i>1 then\n table.insert(t,i)\n end\n if i~=n//i then\n table.insert(t,n//i)\n end\n end\nend\ntable.sort(t)\n\nlocal sum=0\nfor i=1,#t do\n local m=t[i]-1\n if (m+1)*(n//m)==n then\n sum=sum+m\n end\nend\nprint(sum)", "problem_context": "Score : 500 points\n\nProblem Statement\n\nSnuke received a positive integer N from Takahashi.\nA positive integer m is called a favorite number when the following condition is satisfied:\n\nThe quotient and remainder of N divided by m are equal, that is, \\lfloor \\frac{N}{m} \\rfloor = N \\bmod m holds.\n\nFind all favorite numbers and print the sum of those.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^{12}\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n8\n\nSample Output 1\n\n10\n\nThere are two favorite numbers: 3 and 7. Print the sum of these, 10.\n\nSample Input 2\n\n1000000000000\n\nSample Output 2\n\n2499686339916\n\nWatch out for overflow.", "sample_input": "8\n"}, "reference_outputs": ["10\n"], "source_document_id": "p03050", "source_text": "Score : 500 points\n\nProblem Statement\n\nSnuke received a positive integer N from Takahashi.\nA positive integer m is called a favorite number when the following condition is satisfied:\n\nThe quotient and remainder of N divided by m are equal, that is, \\lfloor \\frac{N}{m} \\rfloor = N \\bmod m holds.\n\nFind all favorite numbers and print the sum of those.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^{12}\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n8\n\nSample Output 1\n\n10\n\nThere are two favorite numbers: 3 and 7. Print the sum of these, 10.\n\nSample Input 2\n\n1000000000000\n\nSample Output 2\n\n2499686339916\n\nWatch out for overflow.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 347, "cpu_time_ms": 41, "memory_kb": 2780}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s066039416", "group_id": "codeNet:p03059", "input_text": "a,b,t=io.read(\"*n\",\"*n\",\"*n\")\nprint((t//a)*b)\n", "language": "Lua", "metadata": {"date": 1556413455, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03059.html", "problem_id": "p03059", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03059/input.txt", "sample_output_relpath": "derived/input_output/data/p03059/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03059/Lua/s066039416.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s066039416", "user_id": "u965456277"}, "prompt_components": {"gold_output": "10\n", "input_to_evaluate": "a,b,t=io.read(\"*n\",\"*n\",\"*n\")\nprint((t//a)*b)\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nA biscuit making machine produces B biscuits at the following moments: A seconds, 2A seconds, 3A seconds and each subsequent multiple of A seconds after activation.\n\nFind the total number of biscuits produced within T + 0.5 seconds after activation.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq A, B, T \\leq 20\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B T\n\nOutput\n\nPrint the total number of biscuits produced within T + 0.5 seconds after activation.\n\nSample Input 1\n\n3 5 7\n\nSample Output 1\n\n10\n\nFive biscuits will be produced three seconds after activation.\n\nAnother five biscuits will be produced six seconds after activation.\n\nThus, a total of ten biscuits will be produced within 7.5 seconds after activation.\n\nSample Input 2\n\n3 2 9\n\nSample Output 2\n\n6\n\nSample Input 3\n\n20 20 19\n\nSample Output 3\n\n0", "sample_input": "3 5 7\n"}, "reference_outputs": ["10\n"], "source_document_id": "p03059", "source_text": "Score : 100 points\n\nProblem Statement\n\nA biscuit making machine produces B biscuits at the following moments: A seconds, 2A seconds, 3A seconds and each subsequent multiple of A seconds after activation.\n\nFind the total number of biscuits produced within T + 0.5 seconds after activation.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq A, B, T \\leq 20\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B T\n\nOutput\n\nPrint the total number of biscuits produced within T + 0.5 seconds after activation.\n\nSample Input 1\n\n3 5 7\n\nSample Output 1\n\n10\n\nFive biscuits will be produced three seconds after activation.\n\nAnother five biscuits will be produced six seconds after activation.\n\nThus, a total of ten biscuits will be produced within 7.5 seconds after activation.\n\nSample Input 2\n\n3 2 9\n\nSample Output 2\n\n6\n\nSample Input 3\n\n20 20 19\n\nSample Output 3\n\n0", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 46, "cpu_time_ms": 126, "memory_kb": 760}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s933401885", "group_id": "codeNet:p03060", "input_text": "-- Vicfred\n-- https://atcoder.jp/contests/abc125/tasks/abc125_b\n-- greedy\nn = io.read(\"*n\")\nv, c = {}, {}\nfor i = 1, n do v[i] = io.read(\"*n\") end\nfor i = 1, n do c[i] = io.read(\"*n\") end\nans = 0\nfor i = 1, n do\n if(c[i] < v[i]) then\n ans = ans + v[i] - c[i]\n end\nend\nprint(ans)\n\n", "language": "Lua", "metadata": {"date": 1599946794, "filename_ext": "lua", "original_language": "Lua (Lua 5.3.5)", "problem_description_relpath": "problem_descriptions/p03060.html", "problem_id": "p03060", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03060/input.txt", "sample_output_relpath": "derived/input_output/data/p03060/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03060/Lua/s933401885.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s933401885", "user_id": "u737840172"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "-- Vicfred\n-- https://atcoder.jp/contests/abc125/tasks/abc125_b\n-- greedy\nn = io.read(\"*n\")\nv, c = {}, {}\nfor i = 1, n do v[i] = io.read(\"*n\") end\nfor i = 1, n do c[i] = io.read(\"*n\") end\nans = 0\nfor i = 1, n do\n if(c[i] < v[i]) then\n ans = ans + v[i] - c[i]\n end\nend\nprint(ans)\n\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nThere are N gems. The value of the i-th gem is V_i.\n\nYou will choose some of these gems, possibly all or none, and get them.\n\nHowever, you need to pay a cost of C_i to get the i-th gem.\n\nLet X be the sum of the values of the gems obtained, and Y be the sum of the costs paid.\n\nFind the maximum possible value of X-Y.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 20\n\n1 \\leq C_i, V_i \\leq 50\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nV_1 V_2 ... V_N\nC_1 C_2 ... C_N\n\nOutput\n\nPrint the maximum possible value of X-Y.\n\nSample Input 1\n\n3\n10 2 5\n6 3 4\n\nSample Output 1\n\n5\n\nIf we choose the first and third gems, X = 10 + 5 = 15 and Y = 6 + 4 = 10.\nWe have X-Y = 5 here, which is the maximum possible value.\n\nSample Input 2\n\n4\n13 21 6 19\n11 30 6 15\n\nSample Output 2\n\n6\n\nSample Input 3\n\n1\n1\n50\n\nSample Output 3\n\n0", "sample_input": "3\n10 2 5\n6 3 4\n"}, "reference_outputs": ["5\n"], "source_document_id": "p03060", "source_text": "Score : 200 points\n\nProblem Statement\n\nThere are N gems. The value of the i-th gem is V_i.\n\nYou will choose some of these gems, possibly all or none, and get them.\n\nHowever, you need to pay a cost of C_i to get the i-th gem.\n\nLet X be the sum of the values of the gems obtained, and Y be the sum of the costs paid.\n\nFind the maximum possible value of X-Y.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 20\n\n1 \\leq C_i, V_i \\leq 50\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nV_1 V_2 ... V_N\nC_1 C_2 ... C_N\n\nOutput\n\nPrint the maximum possible value of X-Y.\n\nSample Input 1\n\n3\n10 2 5\n6 3 4\n\nSample Output 1\n\n5\n\nIf we choose the first and third gems, X = 10 + 5 = 15 and Y = 6 + 4 = 10.\nWe have X-Y = 5 here, which is the maximum possible value.\n\nSample Input 2\n\n4\n13 21 6 19\n11 30 6 15\n\nSample Output 2\n\n6\n\nSample Input 3\n\n1\n1\n50\n\nSample Output 3\n\n0", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 293, "cpu_time_ms": 9, "memory_kb": 2716}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s448880599", "group_id": "codeNet:p03060", "input_text": "local n = io.read(\"*n\")\nlocal v, c = {}, {}\nfor i = 1, n do v[i] = io.read(\"*n\") end\nfor i = 1, n do c[i] = io.read(\"*n\") end\nlocal sum = 0\nfor i = 1, n do\n if(c[i] < v[i]) then sum = sum + v[i] - c[i] end\nend\nprint(sum)\n", "language": "Lua", "metadata": {"date": 1556413484, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03060.html", "problem_id": "p03060", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03060/input.txt", "sample_output_relpath": "derived/input_output/data/p03060/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03060/Lua/s448880599.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s448880599", "user_id": "u120582723"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "local n = io.read(\"*n\")\nlocal v, c = {}, {}\nfor i = 1, n do v[i] = io.read(\"*n\") end\nfor i = 1, n do c[i] = io.read(\"*n\") end\nlocal sum = 0\nfor i = 1, n do\n if(c[i] < v[i]) then sum = sum + v[i] - c[i] end\nend\nprint(sum)\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nThere are N gems. The value of the i-th gem is V_i.\n\nYou will choose some of these gems, possibly all or none, and get them.\n\nHowever, you need to pay a cost of C_i to get the i-th gem.\n\nLet X be the sum of the values of the gems obtained, and Y be the sum of the costs paid.\n\nFind the maximum possible value of X-Y.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 20\n\n1 \\leq C_i, V_i \\leq 50\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nV_1 V_2 ... V_N\nC_1 C_2 ... C_N\n\nOutput\n\nPrint the maximum possible value of X-Y.\n\nSample Input 1\n\n3\n10 2 5\n6 3 4\n\nSample Output 1\n\n5\n\nIf we choose the first and third gems, X = 10 + 5 = 15 and Y = 6 + 4 = 10.\nWe have X-Y = 5 here, which is the maximum possible value.\n\nSample Input 2\n\n4\n13 21 6 19\n11 30 6 15\n\nSample Output 2\n\n6\n\nSample Input 3\n\n1\n1\n50\n\nSample Output 3\n\n0", "sample_input": "3\n10 2 5\n6 3 4\n"}, "reference_outputs": ["5\n"], "source_document_id": "p03060", "source_text": "Score : 200 points\n\nProblem Statement\n\nThere are N gems. The value of the i-th gem is V_i.\n\nYou will choose some of these gems, possibly all or none, and get them.\n\nHowever, you need to pay a cost of C_i to get the i-th gem.\n\nLet X be the sum of the values of the gems obtained, and Y be the sum of the costs paid.\n\nFind the maximum possible value of X-Y.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 20\n\n1 \\leq C_i, V_i \\leq 50\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nV_1 V_2 ... V_N\nC_1 C_2 ... C_N\n\nOutput\n\nPrint the maximum possible value of X-Y.\n\nSample Input 1\n\n3\n10 2 5\n6 3 4\n\nSample Output 1\n\n5\n\nIf we choose the first and third gems, X = 10 + 5 = 15 and Y = 6 + 4 = 10.\nWe have X-Y = 5 here, which is the maximum possible value.\n\nSample Input 2\n\n4\n13 21 6 19\n11 30 6 15\n\nSample Output 2\n\n6\n\nSample Input 3\n\n1\n1\n50\n\nSample Output 3\n\n0", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 222, "cpu_time_ms": 15, "memory_kb": 1008}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s384305627", "group_id": "codeNet:p03062", "input_text": "local n=io.read(\"n\")\nlocal a={}\nfor i=1,n do\n a[i]=io.read(\"n\")\nend\n\nlocal dp={{0,-10^12}}\nfor i=1,n do\n dp[i+1]={}\n dp[i+1][1]=math.max(dp[i][1]+a[i],dp[i][2]-a[i])\n dp[i+1][2]=math.max(dp[i][1]-a[i],dp[i][2]+a[i])\nend\nprint(dp[n+1][1])", "language": "Lua", "metadata": {"date": 1591564875, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03062.html", "problem_id": "p03062", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03062/input.txt", "sample_output_relpath": "derived/input_output/data/p03062/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03062/Lua/s384305627.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s384305627", "user_id": "u045238009"}, "prompt_components": {"gold_output": "19\n", "input_to_evaluate": "local n=io.read(\"n\")\nlocal a={}\nfor i=1,n do\n a[i]=io.read(\"n\")\nend\n\nlocal dp={{0,-10^12}}\nfor i=1,n do\n dp[i+1]={}\n dp[i+1][1]=math.max(dp[i][1]+a[i],dp[i][2]-a[i])\n dp[i+1][2]=math.max(dp[i][1]-a[i],dp[i][2]+a[i])\nend\nprint(dp[n+1][1])", "problem_context": "Score : 400 points\n\nProblem Statement\n\nThere are N integers, A_1, A_2, ..., A_N, arranged in a row in this order.\n\nYou can perform the following operation on this integer sequence any number of times:\n\nOperation: Choose an integer i satisfying 1 \\leq i \\leq N-1. Multiply both A_i and A_{i+1} by -1.\n\nLet B_1, B_2, ..., B_N be the integer sequence after your operations.\n\nFind the maximum possible value of B_1 + B_2 + ... + B_N.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 10^5\n\n-10^9 \\leq A_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the maximum possible value of B_1 + B_2 + ... + B_N.\n\nSample Input 1\n\n3\n-10 5 -4\n\nSample Output 1\n\n19\n\nIf we perform the operation as follows:\n\nChoose 1 as i, which changes the sequence to 10, -5, -4.\n\nChoose 2 as i, which changes the sequence to 10, 5, 4.\n\nwe have B_1 = 10, B_2 = 5, B_3 = 4. The sum here, B_1 + B_2 + B_3 = 10 + 5 + 4 = 19, is the maximum possible result.\n\nSample Input 2\n\n5\n10 -4 -8 -11 3\n\nSample Output 2\n\n30\n\nSample Input 3\n\n11\n-1000000000 1000000000 -1000000000 1000000000 -1000000000 0 1000000000 -1000000000 1000000000 -1000000000 1000000000\n\nSample Output 3\n\n10000000000\n\nThe output may not fit into a 32-bit integer type.", "sample_input": "3\n-10 5 -4\n"}, "reference_outputs": ["19\n"], "source_document_id": "p03062", "source_text": "Score : 400 points\n\nProblem Statement\n\nThere are N integers, A_1, A_2, ..., A_N, arranged in a row in this order.\n\nYou can perform the following operation on this integer sequence any number of times:\n\nOperation: Choose an integer i satisfying 1 \\leq i \\leq N-1. Multiply both A_i and A_{i+1} by -1.\n\nLet B_1, B_2, ..., B_N be the integer sequence after your operations.\n\nFind the maximum possible value of B_1 + B_2 + ... + B_N.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 10^5\n\n-10^9 \\leq A_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the maximum possible value of B_1 + B_2 + ... + B_N.\n\nSample Input 1\n\n3\n-10 5 -4\n\nSample Output 1\n\n19\n\nIf we perform the operation as follows:\n\nChoose 1 as i, which changes the sequence to 10, -5, -4.\n\nChoose 2 as i, which changes the sequence to 10, 5, 4.\n\nwe have B_1 = 10, B_2 = 5, B_3 = 4. The sum here, B_1 + B_2 + B_3 = 10 + 5 + 4 = 19, is the maximum possible result.\n\nSample Input 2\n\n5\n10 -4 -8 -11 3\n\nSample Output 2\n\n30\n\nSample Input 3\n\n11\n-1000000000 1000000000 -1000000000 1000000000 -1000000000 0 1000000000 -1000000000 1000000000 -1000000000 1000000000\n\nSample Output 3\n\n10000000000\n\nThe output may not fit into a 32-bit integer type.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 249, "cpu_time_ms": 115, "memory_kb": 15352}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s577399511", "group_id": "codeNet:p03062", "input_text": "local N = io.read(\"n\")\nlocal A = {} for i=1,N do A[i] = io.read(\"n\") end\n\nlocal minus = false\nlocal abs_min = 1000000001\nlocal abs_sum = 0\nfor i=1,N do\n if A[i] < 0 then\n minus = not minus\n end\n abs_min = math.min(abs_min, math.abs(A[i]))\n abs_sum = abs_sum + math.abs(A[i])\nend\nlocal ans = abs_sum\nif minus then\n ans = ans - 2 * abs_min\nend\n--print(minus, abs_min, abs_sum)\nprint(ans)\n", "language": "Lua", "metadata": {"date": 1556414580, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03062.html", "problem_id": "p03062", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03062/input.txt", "sample_output_relpath": "derived/input_output/data/p03062/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03062/Lua/s577399511.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s577399511", "user_id": "u162773977"}, "prompt_components": {"gold_output": "19\n", "input_to_evaluate": "local N = io.read(\"n\")\nlocal A = {} for i=1,N do A[i] = io.read(\"n\") end\n\nlocal minus = false\nlocal abs_min = 1000000001\nlocal abs_sum = 0\nfor i=1,N do\n if A[i] < 0 then\n minus = not minus\n end\n abs_min = math.min(abs_min, math.abs(A[i]))\n abs_sum = abs_sum + math.abs(A[i])\nend\nlocal ans = abs_sum\nif minus then\n ans = ans - 2 * abs_min\nend\n--print(minus, abs_min, abs_sum)\nprint(ans)\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nThere are N integers, A_1, A_2, ..., A_N, arranged in a row in this order.\n\nYou can perform the following operation on this integer sequence any number of times:\n\nOperation: Choose an integer i satisfying 1 \\leq i \\leq N-1. Multiply both A_i and A_{i+1} by -1.\n\nLet B_1, B_2, ..., B_N be the integer sequence after your operations.\n\nFind the maximum possible value of B_1 + B_2 + ... + B_N.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 10^5\n\n-10^9 \\leq A_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the maximum possible value of B_1 + B_2 + ... + B_N.\n\nSample Input 1\n\n3\n-10 5 -4\n\nSample Output 1\n\n19\n\nIf we perform the operation as follows:\n\nChoose 1 as i, which changes the sequence to 10, -5, -4.\n\nChoose 2 as i, which changes the sequence to 10, 5, 4.\n\nwe have B_1 = 10, B_2 = 5, B_3 = 4. The sum here, B_1 + B_2 + B_3 = 10 + 5 + 4 = 19, is the maximum possible result.\n\nSample Input 2\n\n5\n10 -4 -8 -11 3\n\nSample Output 2\n\n30\n\nSample Input 3\n\n11\n-1000000000 1000000000 -1000000000 1000000000 -1000000000 0 1000000000 -1000000000 1000000000 -1000000000 1000000000\n\nSample Output 3\n\n10000000000\n\nThe output may not fit into a 32-bit integer type.", "sample_input": "3\n-10 5 -4\n"}, "reference_outputs": ["19\n"], "source_document_id": "p03062", "source_text": "Score : 400 points\n\nProblem Statement\n\nThere are N integers, A_1, A_2, ..., A_N, arranged in a row in this order.\n\nYou can perform the following operation on this integer sequence any number of times:\n\nOperation: Choose an integer i satisfying 1 \\leq i \\leq N-1. Multiply both A_i and A_{i+1} by -1.\n\nLet B_1, B_2, ..., B_N be the integer sequence after your operations.\n\nFind the maximum possible value of B_1 + B_2 + ... + B_N.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 10^5\n\n-10^9 \\leq A_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the maximum possible value of B_1 + B_2 + ... + B_N.\n\nSample Input 1\n\n3\n-10 5 -4\n\nSample Output 1\n\n19\n\nIf we perform the operation as follows:\n\nChoose 1 as i, which changes the sequence to 10, -5, -4.\n\nChoose 2 as i, which changes the sequence to 10, 5, 4.\n\nwe have B_1 = 10, B_2 = 5, B_3 = 4. The sum here, B_1 + B_2 + B_3 = 10 + 5 + 4 = 19, is the maximum possible result.\n\nSample Input 2\n\n5\n10 -4 -8 -11 3\n\nSample Output 2\n\n30\n\nSample Input 3\n\n11\n-1000000000 1000000000 -1000000000 1000000000 -1000000000 0 1000000000 -1000000000 1000000000 -1000000000 1000000000\n\nSample Output 3\n\n10000000000\n\nThe output may not fit into a 32-bit integer type.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 408, "cpu_time_ms": 56, "memory_kb": 2424}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s275491262", "group_id": "codeNet:p03067", "input_text": "a,b,c=io.read(\"*n\",\"*n\",\"*n\")\nprint((a-c)*(b-c)<0 and \"Yes\" or \"No\")\n", "language": "Lua", "metadata": {"date": 1555819923, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p03067.html", "problem_id": "p03067", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03067/input.txt", "sample_output_relpath": "derived/input_output/data/p03067/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03067/Lua/s275491262.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s275491262", "user_id": "u120582723"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "a,b,c=io.read(\"*n\",\"*n\",\"*n\")\nprint((a-c)*(b-c)<0 and \"Yes\" or \"No\")\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nThere are three houses on a number line: House 1, 2 and 3, with coordinates A, B and C, respectively.\nPrint Yes if we pass the coordinate of House 3 on the straight way from House 1 to House 2 without making a detour, and print No otherwise.\n\nConstraints\n\n0\\leq A,B,C\\leq 100\n\nA, B and C are distinct integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C\n\nOutput\n\nPrint Yes if we pass the coordinate of House 3 on the straight way from House 1 to House 2 without making a detour, and print No otherwise.\n\nSample Input 1\n\n3 8 5\n\nSample Output 1\n\nYes\n\nWe pass the coordinate 5 on the straight way from the house at coordinate 3 to the house at coordinate 8.\n\nSample Input 2\n\n7 3 1\n\nSample Output 2\n\nNo\n\nSample Input 3\n\n10 2 4\n\nSample Output 3\n\nYes\n\nSample Input 4\n\n31 41 59\n\nSample Output 4\n\nNo", "sample_input": "3 8 5\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03067", "source_text": "Score : 100 points\n\nProblem Statement\n\nThere are three houses on a number line: House 1, 2 and 3, with coordinates A, B and C, respectively.\nPrint Yes if we pass the coordinate of House 3 on the straight way from House 1 to House 2 without making a detour, and print No otherwise.\n\nConstraints\n\n0\\leq A,B,C\\leq 100\n\nA, B and C are distinct integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C\n\nOutput\n\nPrint Yes if we pass the coordinate of House 3 on the straight way from House 1 to House 2 without making a detour, and print No otherwise.\n\nSample Input 1\n\n3 8 5\n\nSample Output 1\n\nYes\n\nWe pass the coordinate 5 on the straight way from the house at coordinate 3 to the house at coordinate 8.\n\nSample Input 2\n\n7 3 1\n\nSample Output 2\n\nNo\n\nSample Input 3\n\n10 2 4\n\nSample Output 3\n\nYes\n\nSample Input 4\n\n31 41 59\n\nSample Output 4\n\nNo", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 69, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s666792232", "group_id": "codeNet:p03068", "input_text": "n = io.read(\"*n\", \"*l\")\ns = io.read()\nk = io.read(\"*n\")\nz = s:sub(k, k)\nfor i = 1, n do\n if z == s:sub(i, i) then\n io.write(z)\n else\n io.write(\"*\")\n end\nend\nio.write(\"\\n\")\n", "language": "Lua", "metadata": {"date": 1595699156, "filename_ext": "lua", "original_language": "Lua (Lua 5.3.5)", "problem_description_relpath": "problem_descriptions/p03068.html", "problem_id": "p03068", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03068/input.txt", "sample_output_relpath": "derived/input_output/data/p03068/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03068/Lua/s666792232.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s666792232", "user_id": "u120582723"}, "prompt_components": {"gold_output": "*rr*r\n", "input_to_evaluate": "n = io.read(\"*n\", \"*l\")\ns = io.read()\nk = io.read(\"*n\")\nz = s:sub(k, k)\nfor i = 1, n do\n if z == s:sub(i, i) then\n io.write(z)\n else\n io.write(\"*\")\n end\nend\nio.write(\"\\n\")\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nYou are given a string S of length N consisting of lowercase English letters, and an integer K.\nPrint the string obtained by replacing every character in S that differs from the K-th character of S, with *.\n\nConstraints\n\n1 \\leq K \\leq N\\leq 10\n\nS is a string of length N consisting of lowercase English letters.\n\nN and K are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS\nK\n\nOutput\n\nPrint the string obtained by replacing every character in S that differs from the K-th character of S, with *.\n\nSample Input 1\n\n5\nerror\n2\n\nSample Output 1\n\n*rr*r\n\nThe second character of S is r. When we replace every character in error that differs from r with *, we get the string *rr*r.\n\nSample Input 2\n\n6\neleven\n5\n\nSample Output 2\n\ne*e*e*\n\nSample Input 3\n\n9\neducation\n7\n\nSample Output 3\n\n******i**", "sample_input": "5\nerror\n2\n"}, "reference_outputs": ["*rr*r\n"], "source_document_id": "p03068", "source_text": "Score : 200 points\n\nProblem Statement\n\nYou are given a string S of length N consisting of lowercase English letters, and an integer K.\nPrint the string obtained by replacing every character in S that differs from the K-th character of S, with *.\n\nConstraints\n\n1 \\leq K \\leq N\\leq 10\n\nS is a string of length N consisting of lowercase English letters.\n\nN and K are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS\nK\n\nOutput\n\nPrint the string obtained by replacing every character in S that differs from the K-th character of S, with *.\n\nSample Input 1\n\n5\nerror\n2\n\nSample Output 1\n\n*rr*r\n\nThe second character of S is r. When we replace every character in error that differs from r with *, we get the string *rr*r.\n\nSample Input 2\n\n6\neleven\n5\n\nSample Output 2\n\ne*e*e*\n\nSample Input 3\n\n9\neducation\n7\n\nSample Output 3\n\n******i**", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 181, "cpu_time_ms": 8, "memory_kb": 2628}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s988038774", "group_id": "codeNet:p03069", "input_text": "local n=io.read(\"n\",\"l\")\nlocal s=io.read()\n\nlocal _,white=s:gsub(\"%.\",\"\")\nlocal black=0\nlocal result=black+white\nfor i=1,n do\n if s:sub(i,i)==\"#\" then\n black=black+1\n else\n white=white-1\n end\n result=math.min(result,black+white)\nend\nprint(result)", "language": "Lua", "metadata": {"date": 1592710505, "filename_ext": "lua", "original_language": "Lua (LuaJIT 2.1.0)", "problem_description_relpath": "problem_descriptions/p03069.html", "problem_id": "p03069", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03069/input.txt", "sample_output_relpath": "derived/input_output/data/p03069/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03069/Lua/s988038774.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s988038774", "user_id": "u045238009"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "local n=io.read(\"n\",\"l\")\nlocal s=io.read()\n\nlocal _,white=s:gsub(\"%.\",\"\")\nlocal black=0\nlocal result=black+white\nfor i=1,n do\n if s:sub(i,i)==\"#\" then\n black=black+1\n else\n white=white-1\n end\n result=math.min(result,black+white)\nend\nprint(result)", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere are N stones arranged in a row. Every stone is painted white or black.\nA string S represents the color of the stones. The i-th stone from the left is white if the i-th character of S is ., and the stone is black if the character is #.\n\nTakahashi wants to change the colors of some stones to black or white so that there will be no white stone immediately to the right of a black stone.\nFind the minimum number of stones that needs to be recolored.\n\nConstraints\n\n1 \\leq N \\leq 2\\times 10^5\n\nS is a string of length N consisting of . and #.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS\n\nOutput\n\nPrint the minimum number of stones that needs to be recolored.\n\nSample Input 1\n\n3\n#.#\n\nSample Output 1\n\n1\n\nIt is enough to change the color of the first stone to white.\n\nSample Input 2\n\n5\n#.##.\n\nSample Output 2\n\n2\n\nSample Input 3\n\n9\n.........\n\nSample Output 3\n\n0", "sample_input": "3\n#.#\n"}, "reference_outputs": ["1\n"], "source_document_id": "p03069", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere are N stones arranged in a row. Every stone is painted white or black.\nA string S represents the color of the stones. The i-th stone from the left is white if the i-th character of S is ., and the stone is black if the character is #.\n\nTakahashi wants to change the colors of some stones to black or white so that there will be no white stone immediately to the right of a black stone.\nFind the minimum number of stones that needs to be recolored.\n\nConstraints\n\n1 \\leq N \\leq 2\\times 10^5\n\nS is a string of length N consisting of . and #.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS\n\nOutput\n\nPrint the minimum number of stones that needs to be recolored.\n\nSample Input 1\n\n3\n#.#\n\nSample Output 1\n\n1\n\nIt is enough to change the color of the first stone to white.\n\nSample Input 2\n\n5\n#.##.\n\nSample Output 2\n\n2\n\nSample Input 3\n\n9\n.........\n\nSample Output 3\n\n0", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 272, "cpu_time_ms": 21, "memory_kb": 3016}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s087403678", "group_id": "codeNet:p03071", "input_text": "a, b = io.read(\"*n\", \"*n\")\nif (a == b) then\n print(a + b)\nelseif (a > b) then\n print(2 * a - 1)\nelse\n print(2 * b - 1)\nend", "language": "Lua", "metadata": {"date": 1598247004, "filename_ext": "lua", "original_language": "Lua (Lua 5.3.5)", "problem_description_relpath": "problem_descriptions/p03071.html", "problem_id": "p03071", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03071/input.txt", "sample_output_relpath": "derived/input_output/data/p03071/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03071/Lua/s087403678.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s087403678", "user_id": "u266666911"}, "prompt_components": {"gold_output": "9\n", "input_to_evaluate": "a, b = io.read(\"*n\", \"*n\")\nif (a == b) then\n print(a + b)\nelseif (a > b) then\n print(2 * a - 1)\nelse\n print(2 * b - 1)\nend", "problem_context": "Score : 100 points\n\nProblem Statement\n\nThere are two buttons, one of size A and one of size B.\n\nWhen you press a button of size X, you get X coins and the size of that button decreases by 1.\n\nYou will press a button twice. Here, you can press the same button twice, or press both buttons once.\n\nAt most how many coins can you get?\n\nConstraints\n\nAll values in input are integers.\n\n3 \\leq A, B \\leq 20\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nPrint the maximum number of coins you can get.\n\nSample Input 1\n\n5 3\n\nSample Output 1\n\n9\n\nYou can get 5 + 4 = 9 coins by pressing the button of size 5 twice, and this is the maximum result.\n\nSample Input 2\n\n3 4\n\nSample Output 2\n\n7\n\nSample Input 3\n\n6 6\n\nSample Output 3\n\n12", "sample_input": "5 3\n"}, "reference_outputs": ["9\n"], "source_document_id": "p03071", "source_text": "Score : 100 points\n\nProblem Statement\n\nThere are two buttons, one of size A and one of size B.\n\nWhen you press a button of size X, you get X coins and the size of that button decreases by 1.\n\nYou will press a button twice. Here, you can press the same button twice, or press both buttons once.\n\nAt most how many coins can you get?\n\nConstraints\n\nAll values in input are integers.\n\n3 \\leq A, B \\leq 20\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nPrint the maximum number of coins you can get.\n\nSample Input 1\n\n5 3\n\nSample Output 1\n\n9\n\nYou can get 5 + 4 = 9 coins by pressing the button of size 5 twice, and this is the maximum result.\n\nSample Input 2\n\n3 4\n\nSample Output 2\n\n7\n\nSample Input 3\n\n6 6\n\nSample Output 3\n\n12", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 131, "cpu_time_ms": 7, "memory_kb": 2692}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s675989894", "group_id": "codeNet:p03071", "input_text": "a, b = io.read(\"*n\", \"*n\")\nprint(math.max(a + a - 1, b + b - 1, a + b))", "language": "Lua", "metadata": {"date": 1579338724, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03071.html", "problem_id": "p03071", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03071/input.txt", "sample_output_relpath": "derived/input_output/data/p03071/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03071/Lua/s675989894.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s675989894", "user_id": "u720483676"}, "prompt_components": {"gold_output": "9\n", "input_to_evaluate": "a, b = io.read(\"*n\", \"*n\")\nprint(math.max(a + a - 1, b + b - 1, a + b))", "problem_context": "Score : 100 points\n\nProblem Statement\n\nThere are two buttons, one of size A and one of size B.\n\nWhen you press a button of size X, you get X coins and the size of that button decreases by 1.\n\nYou will press a button twice. Here, you can press the same button twice, or press both buttons once.\n\nAt most how many coins can you get?\n\nConstraints\n\nAll values in input are integers.\n\n3 \\leq A, B \\leq 20\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nPrint the maximum number of coins you can get.\n\nSample Input 1\n\n5 3\n\nSample Output 1\n\n9\n\nYou can get 5 + 4 = 9 coins by pressing the button of size 5 twice, and this is the maximum result.\n\nSample Input 2\n\n3 4\n\nSample Output 2\n\n7\n\nSample Input 3\n\n6 6\n\nSample Output 3\n\n12", "sample_input": "5 3\n"}, "reference_outputs": ["9\n"], "source_document_id": "p03071", "source_text": "Score : 100 points\n\nProblem Statement\n\nThere are two buttons, one of size A and one of size B.\n\nWhen you press a button of size X, you get X coins and the size of that button decreases by 1.\n\nYou will press a button twice. Here, you can press the same button twice, or press both buttons once.\n\nAt most how many coins can you get?\n\nConstraints\n\nAll values in input are integers.\n\n3 \\leq A, B \\leq 20\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nPrint the maximum number of coins you can get.\n\nSample Input 1\n\n5 3\n\nSample Output 1\n\n9\n\nYou can get 5 + 4 = 9 coins by pressing the button of size 5 twice, and this is the maximum result.\n\nSample Input 2\n\n3 4\n\nSample Output 2\n\n7\n\nSample Input 3\n\n6 6\n\nSample Output 3\n\n12", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 71, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s805135485", "group_id": "codeNet:p03072", "input_text": "local N=tonumber(io.read())\nlocal H={}\nfor s in io.read():gmatch(\"(%S+)%s*\")do\n H[#H+1]=tonumber(s)\nend\nlocal max=0\nlocal cnt=0\n\nfor i=1,N do\n if(max<=H[i])then\n cnt=cnt+1\n max=H[i]\n end\nend\nprint(cnt)", "language": "Lua", "metadata": {"date": 1555289567, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p03072.html", "problem_id": "p03072", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03072/input.txt", "sample_output_relpath": "derived/input_output/data/p03072/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03072/Lua/s805135485.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s805135485", "user_id": "u726173718"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "local N=tonumber(io.read())\nlocal H={}\nfor s in io.read():gmatch(\"(%S+)%s*\")do\n H[#H+1]=tonumber(s)\nend\nlocal max=0\nlocal cnt=0\n\nfor i=1,N do\n if(max<=H[i])then\n cnt=cnt+1\n max=H[i]\n end\nend\nprint(cnt)", "problem_context": "Score : 200 points\n\nProblem Statement\n\nThere are N mountains ranging from east to west, and an ocean to the west.\n\nAt the top of each mountain, there is an inn. You have decided to choose where to stay from these inns.\n\nThe height of the i-th mountain from the west is H_i.\n\nYou can certainly see the ocean from the inn at the top of the westmost mountain.\n\nFor the inn at the top of the i-th mountain from the west (i = 2, 3, ..., N), you can see the ocean if and only if H_1 \\leq H_i, H_2 \\leq H_i, ..., and H_{i-1} \\leq H_i.\n\nFrom how many of these N inns can you see the ocean?\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 20\n\n1 \\leq H_i \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nH_1 H_2 ... H_N\n\nOutput\n\nPrint the number of inns from which you can see the ocean.\n\nSample Input 1\n\n4\n6 5 6 8\n\nSample Output 1\n\n3\n\nYou can see the ocean from the first, third and fourth inns from the west.\n\nSample Input 2\n\n5\n4 5 3 5 4\n\nSample Output 2\n\n3\n\nSample Input 3\n\n5\n9 5 6 8 4\n\nSample Output 3\n\n1", "sample_input": "4\n6 5 6 8\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03072", "source_text": "Score : 200 points\n\nProblem Statement\n\nThere are N mountains ranging from east to west, and an ocean to the west.\n\nAt the top of each mountain, there is an inn. You have decided to choose where to stay from these inns.\n\nThe height of the i-th mountain from the west is H_i.\n\nYou can certainly see the ocean from the inn at the top of the westmost mountain.\n\nFor the inn at the top of the i-th mountain from the west (i = 2, 3, ..., N), you can see the ocean if and only if H_1 \\leq H_i, H_2 \\leq H_i, ..., and H_{i-1} \\leq H_i.\n\nFrom how many of these N inns can you see the ocean?\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 20\n\n1 \\leq H_i \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nH_1 H_2 ... H_N\n\nOutput\n\nPrint the number of inns from which you can see the ocean.\n\nSample Input 1\n\n4\n6 5 6 8\n\nSample Output 1\n\n3\n\nYou can see the ocean from the first, third and fourth inns from the west.\n\nSample Input 2\n\n5\n4 5 3 5 4\n\nSample Output 2\n\n3\n\nSample Input 3\n\n5\n9 5 6 8 4\n\nSample Output 3\n\n1", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 210, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s619042323", "group_id": "codeNet:p03073", "input_text": "local S=io.read()\n\nlocal cnt=0\nfor i=1,#S do\n if(tonumber(S:sub(i,i))==i%2)then\n cnt=cnt+1\n end\nend\nprint(math.min(cnt,#S-cnt))", "language": "Lua", "metadata": {"date": 1555289839, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p03073.html", "problem_id": "p03073", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03073/input.txt", "sample_output_relpath": "derived/input_output/data/p03073/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03073/Lua/s619042323.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s619042323", "user_id": "u726173718"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "local S=io.read()\n\nlocal cnt=0\nfor i=1,#S do\n if(tonumber(S:sub(i,i))==i%2)then\n cnt=cnt+1\n end\nend\nprint(math.min(cnt,#S-cnt))", "problem_context": "Score : 300 points\n\nProblem Statement\n\nN tiles are arranged in a row from left to right. The initial color of each tile is represented by a string S of length N.\n\nThe i-th tile from the left is painted black if the i-th character of S is 0, and painted white if that character is 1.\n\nYou want to repaint some of the tiles black or white, so that any two adjacent tiles have different colors.\n\nAt least how many tiles need to be repainted to satisfy the condition?\n\nConstraints\n\n1 \\leq |S| \\leq 10^5\n\nS_i is 0 or 1.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the minimum number of tiles that need to be repainted to satisfy the condition.\n\nSample Input 1\n\n000\n\nSample Output 1\n\n1\n\nThe condition can be satisfied by repainting the middle tile white.\n\nSample Input 2\n\n10010010\n\nSample Output 2\n\n3\n\nSample Input 3\n\n0\n\nSample Output 3\n\n0", "sample_input": "000\n"}, "reference_outputs": ["1\n"], "source_document_id": "p03073", "source_text": "Score : 300 points\n\nProblem Statement\n\nN tiles are arranged in a row from left to right. The initial color of each tile is represented by a string S of length N.\n\nThe i-th tile from the left is painted black if the i-th character of S is 0, and painted white if that character is 1.\n\nYou want to repaint some of the tiles black or white, so that any two adjacent tiles have different colors.\n\nAt least how many tiles need to be repainted to satisfy the condition?\n\nConstraints\n\n1 \\leq |S| \\leq 10^5\n\nS_i is 0 or 1.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the minimum number of tiles that need to be repainted to satisfy the condition.\n\nSample Input 1\n\n000\n\nSample Output 1\n\n1\n\nThe condition can be satisfied by repainting the middle tile white.\n\nSample Input 2\n\n10010010\n\nSample Output 2\n\n3\n\nSample Input 3\n\n0\n\nSample Output 3\n\n0", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 132, "cpu_time_ms": 5, "memory_kb": 512}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s501779521", "group_id": "codeNet:p03074", "input_text": "local n,k=io.read(\"n\",\"n\",\"l\")\nlocal s=io.read()\nlocal t={1}\nfor i=2,#s do\n if s:byte(i-1)~=s:byte(i) then\n table.insert(t,i)\n end\nend\n\nlocal max=0\nfor i=1,#t do\n local x\n if s:byte(t[i])==48 then\n x=(t[i+2*k] or #s+1)-t[i]\n else\n x=(t[i+2*k+1] or #s+1)-t[i]\n end\n max=math.max(x,max)\nend\nprint(max)", "language": "Lua", "metadata": {"date": 1595105651, "filename_ext": "lua", "original_language": "Lua (LuaJIT 2.1.0)", "problem_description_relpath": "problem_descriptions/p03074.html", "problem_id": "p03074", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03074/input.txt", "sample_output_relpath": "derived/input_output/data/p03074/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03074/Lua/s501779521.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s501779521", "user_id": "u045238009"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "local n,k=io.read(\"n\",\"n\",\"l\")\nlocal s=io.read()\nlocal t={1}\nfor i=2,#s do\n if s:byte(i-1)~=s:byte(i) then\n table.insert(t,i)\n end\nend\n\nlocal max=0\nfor i=1,#t do\n local x\n if s:byte(t[i])==48 then\n x=(t[i+2*k] or #s+1)-t[i]\n else\n x=(t[i+2*k+1] or #s+1)-t[i]\n end\n max=math.max(x,max)\nend\nprint(max)", "problem_context": "Score : 400 points\n\nProblem Statement\n\nN people are arranged in a row from left to right.\n\nYou are given a string S of length N consisting of 0 and 1, and a positive integer K.\n\nThe i-th person from the left is standing on feet if the i-th character of S is 0, and standing on hands if that character is 1.\n\nYou will give the following direction at most K times (possibly zero):\n\nDirection: Choose integers l and r satisfying 1 \\leq l \\leq r \\leq N, and flip the l-th, (l+1)-th, ..., and r-th persons. That is, for each i = l, l+1, ..., r, the i-th person from the left now stands on hands if he/she was standing on feet, and stands on feet if he/she was standing on hands.\n\nFind the maximum possible number of consecutive people standing on hands after at most K directions.\n\nConstraints\n\nN is an integer satisfying 1 \\leq N \\leq 10^5.\n\nK is an integer satisfying 1 \\leq K \\leq 10^5.\n\nThe length of the string S is N.\n\nEach character of the string S is 0 or 1.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nS\n\nOutput\n\nPrint the maximum possible number of consecutive people standing on hands after at most K directions.\n\nSample Input 1\n\n5 1\n00010\n\nSample Output 1\n\n4\n\nWe can have four consecutive people standing on hands, which is the maximum result, by giving the following direction:\n\nGive the direction with l = 1, r = 3, which flips the first, second and third persons from the left.\n\nSample Input 2\n\n14 2\n11101010110011\n\nSample Output 2\n\n8\n\nSample Input 3\n\n1 1\n1\n\nSample Output 3\n\n1\n\nNo directions are necessary.", "sample_input": "5 1\n00010\n"}, "reference_outputs": ["4\n"], "source_document_id": "p03074", "source_text": "Score : 400 points\n\nProblem Statement\n\nN people are arranged in a row from left to right.\n\nYou are given a string S of length N consisting of 0 and 1, and a positive integer K.\n\nThe i-th person from the left is standing on feet if the i-th character of S is 0, and standing on hands if that character is 1.\n\nYou will give the following direction at most K times (possibly zero):\n\nDirection: Choose integers l and r satisfying 1 \\leq l \\leq r \\leq N, and flip the l-th, (l+1)-th, ..., and r-th persons. That is, for each i = l, l+1, ..., r, the i-th person from the left now stands on hands if he/she was standing on feet, and stands on feet if he/she was standing on hands.\n\nFind the maximum possible number of consecutive people standing on hands after at most K directions.\n\nConstraints\n\nN is an integer satisfying 1 \\leq N \\leq 10^5.\n\nK is an integer satisfying 1 \\leq K \\leq 10^5.\n\nThe length of the string S is N.\n\nEach character of the string S is 0 or 1.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nS\n\nOutput\n\nPrint the maximum possible number of consecutive people standing on hands after at most K directions.\n\nSample Input 1\n\n5 1\n00010\n\nSample Output 1\n\n4\n\nWe can have four consecutive people standing on hands, which is the maximum result, by giving the following direction:\n\nGive the direction with l = 1, r = 3, which flips the first, second and third persons from the left.\n\nSample Input 2\n\n14 2\n11101010110011\n\nSample Output 2\n\n8\n\nSample Input 3\n\n1 1\n1\n\nSample Output 3\n\n1\n\nNo directions are necessary.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 341, "cpu_time_ms": 20, "memory_kb": 3872}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s852241750", "group_id": "codeNet:p03074", "input_text": "n, k = io.read(\"*n\", \"*n\", \"*l\")\ns = io.read()\npos = 1\nposlist = {}\ncnt = 0\np1, p2 = string.find(s, \"1+\", pos)\nwhile(p1 ~= nil) do\n cnt = cnt + 1\n poslist[cnt] = {}\n poslist[cnt].fst, poslist[cnt].lst = p1, p2\n pos = p2 + 1\n p1, p2 = string.find(s, \"1+\", pos)\nend\n\nif(#poslist < k) then\n print(n)\nelse\n res = 0\n for i = 1, #poslist - k do\n res = math.max(res, poslist[i + k].lst - poslist[i].fst + 1)\n end\n res = math.max(res, poslist[k].lst)\n res = math.max(res, n - poslist[#poslist - k + 1].fst + 1)\n print(res)\nend\n", "language": "Lua", "metadata": {"date": 1555190687, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p03074.html", "problem_id": "p03074", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03074/input.txt", "sample_output_relpath": "derived/input_output/data/p03074/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03074/Lua/s852241750.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s852241750", "user_id": "u120582723"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "n, k = io.read(\"*n\", \"*n\", \"*l\")\ns = io.read()\npos = 1\nposlist = {}\ncnt = 0\np1, p2 = string.find(s, \"1+\", pos)\nwhile(p1 ~= nil) do\n cnt = cnt + 1\n poslist[cnt] = {}\n poslist[cnt].fst, poslist[cnt].lst = p1, p2\n pos = p2 + 1\n p1, p2 = string.find(s, \"1+\", pos)\nend\n\nif(#poslist < k) then\n print(n)\nelse\n res = 0\n for i = 1, #poslist - k do\n res = math.max(res, poslist[i + k].lst - poslist[i].fst + 1)\n end\n res = math.max(res, poslist[k].lst)\n res = math.max(res, n - poslist[#poslist - k + 1].fst + 1)\n print(res)\nend\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nN people are arranged in a row from left to right.\n\nYou are given a string S of length N consisting of 0 and 1, and a positive integer K.\n\nThe i-th person from the left is standing on feet if the i-th character of S is 0, and standing on hands if that character is 1.\n\nYou will give the following direction at most K times (possibly zero):\n\nDirection: Choose integers l and r satisfying 1 \\leq l \\leq r \\leq N, and flip the l-th, (l+1)-th, ..., and r-th persons. That is, for each i = l, l+1, ..., r, the i-th person from the left now stands on hands if he/she was standing on feet, and stands on feet if he/she was standing on hands.\n\nFind the maximum possible number of consecutive people standing on hands after at most K directions.\n\nConstraints\n\nN is an integer satisfying 1 \\leq N \\leq 10^5.\n\nK is an integer satisfying 1 \\leq K \\leq 10^5.\n\nThe length of the string S is N.\n\nEach character of the string S is 0 or 1.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nS\n\nOutput\n\nPrint the maximum possible number of consecutive people standing on hands after at most K directions.\n\nSample Input 1\n\n5 1\n00010\n\nSample Output 1\n\n4\n\nWe can have four consecutive people standing on hands, which is the maximum result, by giving the following direction:\n\nGive the direction with l = 1, r = 3, which flips the first, second and third persons from the left.\n\nSample Input 2\n\n14 2\n11101010110011\n\nSample Output 2\n\n8\n\nSample Input 3\n\n1 1\n1\n\nSample Output 3\n\n1\n\nNo directions are necessary.", "sample_input": "5 1\n00010\n"}, "reference_outputs": ["4\n"], "source_document_id": "p03074", "source_text": "Score : 400 points\n\nProblem Statement\n\nN people are arranged in a row from left to right.\n\nYou are given a string S of length N consisting of 0 and 1, and a positive integer K.\n\nThe i-th person from the left is standing on feet if the i-th character of S is 0, and standing on hands if that character is 1.\n\nYou will give the following direction at most K times (possibly zero):\n\nDirection: Choose integers l and r satisfying 1 \\leq l \\leq r \\leq N, and flip the l-th, (l+1)-th, ..., and r-th persons. That is, for each i = l, l+1, ..., r, the i-th person from the left now stands on hands if he/she was standing on feet, and stands on feet if he/she was standing on hands.\n\nFind the maximum possible number of consecutive people standing on hands after at most K directions.\n\nConstraints\n\nN is an integer satisfying 1 \\leq N \\leq 10^5.\n\nK is an integer satisfying 1 \\leq K \\leq 10^5.\n\nThe length of the string S is N.\n\nEach character of the string S is 0 or 1.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nS\n\nOutput\n\nPrint the maximum possible number of consecutive people standing on hands after at most K directions.\n\nSample Input 1\n\n5 1\n00010\n\nSample Output 1\n\n4\n\nWe can have four consecutive people standing on hands, which is the maximum result, by giving the following direction:\n\nGive the direction with l = 1, r = 3, which flips the first, second and third persons from the left.\n\nSample Input 2\n\n14 2\n11101010110011\n\nSample Output 2\n\n8\n\nSample Input 3\n\n1 1\n1\n\nSample Output 3\n\n1\n\nNo directions are necessary.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 533, "cpu_time_ms": 21, "memory_kb": 5596}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s304819327", "group_id": "codeNet:p03075", "input_text": "a = io.read(\"*n\")\nb = 0\nfor i = 2, 5 do b = io.read(\"*n\") end\nc = io.read(\"*n\")\nprint(c < b - a and \":(\" or \"Yay!\")\n", "language": "Lua", "metadata": {"date": 1595145891, "filename_ext": "lua", "original_language": "Lua (Lua 5.3.5)", "problem_description_relpath": "problem_descriptions/p03075.html", "problem_id": "p03075", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03075/input.txt", "sample_output_relpath": "derived/input_output/data/p03075/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03075/Lua/s304819327.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s304819327", "user_id": "u120582723"}, "prompt_components": {"gold_output": "Yay!\n", "input_to_evaluate": "a = io.read(\"*n\")\nb = 0\nfor i = 2, 5 do b = io.read(\"*n\") end\nc = io.read(\"*n\")\nprint(c < b - a and \":(\" or \"Yay!\")\n", "problem_context": "Score: 100 points\n\nProblem Statement\n\nIn AtCoder city, there are five antennas standing in a straight line. They are called Antenna A, B, C, D and E from west to east, and their coordinates are a, b, c, d and e, respectively.\n\nTwo antennas can communicate directly if the distance between them is k or less, and they cannot if the distance is greater than k.\n\nDetermine if there exists a pair of antennas that cannot communicate directly.\n\nHere, assume that the distance between two antennas at coordinates p and q (p < q) is q - p.\n\nConstraints\n\na, b, c, d, e and k are integers between 0 and 123 (inclusive).\n\na < b < c < d < e\n\nInput\n\nInput is given from Standard Input in the following format:\n\na\nb\nc\nd\ne\nk\n\nOutput\n\nPrint :( if there exists a pair of antennas that cannot communicate directly, and print Yay! if there is no such pair.\n\nSample Input 1\n\n1\n2\n4\n8\n9\n15\n\nSample Output 1\n\nYay!\n\nIn this case, there is no pair of antennas that cannot communicate directly, because:\n\nthe distance between A and B is 2 - 1 = 1\n\nthe distance between A and C is 4 - 1 = 3\n\nthe distance between A and D is 8 - 1 = 7\n\nthe distance between A and E is 9 - 1 = 8\n\nthe distance between B and C is 4 - 2 = 2\n\nthe distance between B and D is 8 - 2 = 6\n\nthe distance between B and E is 9 - 2 = 7\n\nthe distance between C and D is 8 - 4 = 4\n\nthe distance between C and E is 9 - 4 = 5\n\nthe distance between D and E is 9 - 8 = 1\n\nand none of them is greater than 15. Thus, the correct output is Yay!.\n\nSample Input 2\n\n15\n18\n26\n35\n36\n18\n\nSample Output 2\n\n:(\n\nIn this case, the distance between antennas A and D is 35 - 15 = 20 and exceeds 18, so they cannot communicate directly.\nThus, the correct output is :(.", "sample_input": "1\n2\n4\n8\n9\n15\n"}, "reference_outputs": ["Yay!\n"], "source_document_id": "p03075", "source_text": "Score: 100 points\n\nProblem Statement\n\nIn AtCoder city, there are five antennas standing in a straight line. They are called Antenna A, B, C, D and E from west to east, and their coordinates are a, b, c, d and e, respectively.\n\nTwo antennas can communicate directly if the distance between them is k or less, and they cannot if the distance is greater than k.\n\nDetermine if there exists a pair of antennas that cannot communicate directly.\n\nHere, assume that the distance between two antennas at coordinates p and q (p < q) is q - p.\n\nConstraints\n\na, b, c, d, e and k are integers between 0 and 123 (inclusive).\n\na < b < c < d < e\n\nInput\n\nInput is given from Standard Input in the following format:\n\na\nb\nc\nd\ne\nk\n\nOutput\n\nPrint :( if there exists a pair of antennas that cannot communicate directly, and print Yay! if there is no such pair.\n\nSample Input 1\n\n1\n2\n4\n8\n9\n15\n\nSample Output 1\n\nYay!\n\nIn this case, there is no pair of antennas that cannot communicate directly, because:\n\nthe distance between A and B is 2 - 1 = 1\n\nthe distance between A and C is 4 - 1 = 3\n\nthe distance between A and D is 8 - 1 = 7\n\nthe distance between A and E is 9 - 1 = 8\n\nthe distance between B and C is 4 - 2 = 2\n\nthe distance between B and D is 8 - 2 = 6\n\nthe distance between B and E is 9 - 2 = 7\n\nthe distance between C and D is 8 - 4 = 4\n\nthe distance between C and E is 9 - 4 = 5\n\nthe distance between D and E is 9 - 8 = 1\n\nand none of them is greater than 15. Thus, the correct output is Yay!.\n\nSample Input 2\n\n15\n18\n26\n35\n36\n18\n\nSample Output 2\n\n:(\n\nIn this case, the distance between antennas A and D is 35 - 15 = 20 and exceeds 18, so they cannot communicate directly.\nThus, the correct output is :(.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 116, "cpu_time_ms": 5, "memory_kb": 2612}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s539636377", "group_id": "codeNet:p03075", "input_text": "a=io.read(\"*n\")\nb=io.read(\"*n\")\nc=io.read(\"*n\")\nd=io.read(\"*n\")\ne=io.read(\"*n\")\nk=io.read(\"*n\")\nif e-a<=k then\n print(\"Yay!\")\nelse \n print(\":(\")\nend", "language": "Lua", "metadata": {"date": 1576566400, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p03075.html", "problem_id": "p03075", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03075/input.txt", "sample_output_relpath": "derived/input_output/data/p03075/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03075/Lua/s539636377.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s539636377", "user_id": "u373958718"}, "prompt_components": {"gold_output": "Yay!\n", "input_to_evaluate": "a=io.read(\"*n\")\nb=io.read(\"*n\")\nc=io.read(\"*n\")\nd=io.read(\"*n\")\ne=io.read(\"*n\")\nk=io.read(\"*n\")\nif e-a<=k then\n print(\"Yay!\")\nelse \n print(\":(\")\nend", "problem_context": "Score: 100 points\n\nProblem Statement\n\nIn AtCoder city, there are five antennas standing in a straight line. They are called Antenna A, B, C, D and E from west to east, and their coordinates are a, b, c, d and e, respectively.\n\nTwo antennas can communicate directly if the distance between them is k or less, and they cannot if the distance is greater than k.\n\nDetermine if there exists a pair of antennas that cannot communicate directly.\n\nHere, assume that the distance between two antennas at coordinates p and q (p < q) is q - p.\n\nConstraints\n\na, b, c, d, e and k are integers between 0 and 123 (inclusive).\n\na < b < c < d < e\n\nInput\n\nInput is given from Standard Input in the following format:\n\na\nb\nc\nd\ne\nk\n\nOutput\n\nPrint :( if there exists a pair of antennas that cannot communicate directly, and print Yay! if there is no such pair.\n\nSample Input 1\n\n1\n2\n4\n8\n9\n15\n\nSample Output 1\n\nYay!\n\nIn this case, there is no pair of antennas that cannot communicate directly, because:\n\nthe distance between A and B is 2 - 1 = 1\n\nthe distance between A and C is 4 - 1 = 3\n\nthe distance between A and D is 8 - 1 = 7\n\nthe distance between A and E is 9 - 1 = 8\n\nthe distance between B and C is 4 - 2 = 2\n\nthe distance between B and D is 8 - 2 = 6\n\nthe distance between B and E is 9 - 2 = 7\n\nthe distance between C and D is 8 - 4 = 4\n\nthe distance between C and E is 9 - 4 = 5\n\nthe distance between D and E is 9 - 8 = 1\n\nand none of them is greater than 15. Thus, the correct output is Yay!.\n\nSample Input 2\n\n15\n18\n26\n35\n36\n18\n\nSample Output 2\n\n:(\n\nIn this case, the distance between antennas A and D is 35 - 15 = 20 and exceeds 18, so they cannot communicate directly.\nThus, the correct output is :(.", "sample_input": "1\n2\n4\n8\n9\n15\n"}, "reference_outputs": ["Yay!\n"], "source_document_id": "p03075", "source_text": "Score: 100 points\n\nProblem Statement\n\nIn AtCoder city, there are five antennas standing in a straight line. They are called Antenna A, B, C, D and E from west to east, and their coordinates are a, b, c, d and e, respectively.\n\nTwo antennas can communicate directly if the distance between them is k or less, and they cannot if the distance is greater than k.\n\nDetermine if there exists a pair of antennas that cannot communicate directly.\n\nHere, assume that the distance between two antennas at coordinates p and q (p < q) is q - p.\n\nConstraints\n\na, b, c, d, e and k are integers between 0 and 123 (inclusive).\n\na < b < c < d < e\n\nInput\n\nInput is given from Standard Input in the following format:\n\na\nb\nc\nd\ne\nk\n\nOutput\n\nPrint :( if there exists a pair of antennas that cannot communicate directly, and print Yay! if there is no such pair.\n\nSample Input 1\n\n1\n2\n4\n8\n9\n15\n\nSample Output 1\n\nYay!\n\nIn this case, there is no pair of antennas that cannot communicate directly, because:\n\nthe distance between A and B is 2 - 1 = 1\n\nthe distance between A and C is 4 - 1 = 3\n\nthe distance between A and D is 8 - 1 = 7\n\nthe distance between A and E is 9 - 1 = 8\n\nthe distance between B and C is 4 - 2 = 2\n\nthe distance between B and D is 8 - 2 = 6\n\nthe distance between B and E is 9 - 2 = 7\n\nthe distance between C and D is 8 - 4 = 4\n\nthe distance between C and E is 9 - 4 = 5\n\nthe distance between D and E is 9 - 8 = 1\n\nand none of them is greater than 15. Thus, the correct output is Yay!.\n\nSample Input 2\n\n15\n18\n26\n35\n36\n18\n\nSample Output 2\n\n:(\n\nIn this case, the distance between antennas A and D is 35 - 15 = 20 and exceeds 18, so they cannot communicate directly.\nThus, the correct output is :(.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 150, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s466368051", "group_id": "codeNet:p03075", "input_text": "a={}\nfor i = 1,5 do\n\ta[i]=io.read()*1\nend\nprint(a[5]-a[1]>io.read()*1 and \":(\"or\"Yay!\")", "language": "Lua", "metadata": {"date": 1557491900, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p03075.html", "problem_id": "p03075", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03075/input.txt", "sample_output_relpath": "derived/input_output/data/p03075/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03075/Lua/s466368051.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s466368051", "user_id": "u837412668"}, "prompt_components": {"gold_output": "Yay!\n", "input_to_evaluate": "a={}\nfor i = 1,5 do\n\ta[i]=io.read()*1\nend\nprint(a[5]-a[1]>io.read()*1 and \":(\"or\"Yay!\")", "problem_context": "Score: 100 points\n\nProblem Statement\n\nIn AtCoder city, there are five antennas standing in a straight line. They are called Antenna A, B, C, D and E from west to east, and their coordinates are a, b, c, d and e, respectively.\n\nTwo antennas can communicate directly if the distance between them is k or less, and they cannot if the distance is greater than k.\n\nDetermine if there exists a pair of antennas that cannot communicate directly.\n\nHere, assume that the distance between two antennas at coordinates p and q (p < q) is q - p.\n\nConstraints\n\na, b, c, d, e and k are integers between 0 and 123 (inclusive).\n\na < b < c < d < e\n\nInput\n\nInput is given from Standard Input in the following format:\n\na\nb\nc\nd\ne\nk\n\nOutput\n\nPrint :( if there exists a pair of antennas that cannot communicate directly, and print Yay! if there is no such pair.\n\nSample Input 1\n\n1\n2\n4\n8\n9\n15\n\nSample Output 1\n\nYay!\n\nIn this case, there is no pair of antennas that cannot communicate directly, because:\n\nthe distance between A and B is 2 - 1 = 1\n\nthe distance between A and C is 4 - 1 = 3\n\nthe distance between A and D is 8 - 1 = 7\n\nthe distance between A and E is 9 - 1 = 8\n\nthe distance between B and C is 4 - 2 = 2\n\nthe distance between B and D is 8 - 2 = 6\n\nthe distance between B and E is 9 - 2 = 7\n\nthe distance between C and D is 8 - 4 = 4\n\nthe distance between C and E is 9 - 4 = 5\n\nthe distance between D and E is 9 - 8 = 1\n\nand none of them is greater than 15. Thus, the correct output is Yay!.\n\nSample Input 2\n\n15\n18\n26\n35\n36\n18\n\nSample Output 2\n\n:(\n\nIn this case, the distance between antennas A and D is 35 - 15 = 20 and exceeds 18, so they cannot communicate directly.\nThus, the correct output is :(.", "sample_input": "1\n2\n4\n8\n9\n15\n"}, "reference_outputs": ["Yay!\n"], "source_document_id": "p03075", "source_text": "Score: 100 points\n\nProblem Statement\n\nIn AtCoder city, there are five antennas standing in a straight line. They are called Antenna A, B, C, D and E from west to east, and their coordinates are a, b, c, d and e, respectively.\n\nTwo antennas can communicate directly if the distance between them is k or less, and they cannot if the distance is greater than k.\n\nDetermine if there exists a pair of antennas that cannot communicate directly.\n\nHere, assume that the distance between two antennas at coordinates p and q (p < q) is q - p.\n\nConstraints\n\na, b, c, d, e and k are integers between 0 and 123 (inclusive).\n\na < b < c < d < e\n\nInput\n\nInput is given from Standard Input in the following format:\n\na\nb\nc\nd\ne\nk\n\nOutput\n\nPrint :( if there exists a pair of antennas that cannot communicate directly, and print Yay! if there is no such pair.\n\nSample Input 1\n\n1\n2\n4\n8\n9\n15\n\nSample Output 1\n\nYay!\n\nIn this case, there is no pair of antennas that cannot communicate directly, because:\n\nthe distance between A and B is 2 - 1 = 1\n\nthe distance between A and C is 4 - 1 = 3\n\nthe distance between A and D is 8 - 1 = 7\n\nthe distance between A and E is 9 - 1 = 8\n\nthe distance between B and C is 4 - 2 = 2\n\nthe distance between B and D is 8 - 2 = 6\n\nthe distance between B and E is 9 - 2 = 7\n\nthe distance between C and D is 8 - 4 = 4\n\nthe distance between C and E is 9 - 4 = 5\n\nthe distance between D and E is 9 - 8 = 1\n\nand none of them is greater than 15. Thus, the correct output is Yay!.\n\nSample Input 2\n\n15\n18\n26\n35\n36\n18\n\nSample Output 2\n\n:(\n\nIn this case, the distance between antennas A and D is 35 - 15 = 20 and exceeds 18, so they cannot communicate directly.\nThus, the correct output is :(.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 87, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s477617781", "group_id": "codeNet:p03076", "input_text": "-- B\nlocal a,b,c,d,e = io.read(\"n\", \"n\", \"n\", \"n\", \"n\")\nlocal tbl = {a,b,c,d,e}\ntable.sort(tbl, function(x,y)\n local rx = x % 10\n if rx == 0 then\n rx = 10\n end\n local ry = y % 10\n if ry == 0 then\n ry = 10\n end\n return rx > ry\nend)\n\nlocal tm = 0\nfor i=1, #tbl-1 do\n local r = 10 - tbl[i] % 10\n if r == 10 then\n r = 0\n end\n tm = tm + tbl[i] + r\nend\ntm = tm + tbl[#tbl]\n\nprint(tm)\n", "language": "Lua", "metadata": {"date": 1554578168, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03076.html", "problem_id": "p03076", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03076/input.txt", "sample_output_relpath": "derived/input_output/data/p03076/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03076/Lua/s477617781.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s477617781", "user_id": "u162773977"}, "prompt_components": {"gold_output": "215\n", "input_to_evaluate": "-- B\nlocal a,b,c,d,e = io.read(\"n\", \"n\", \"n\", \"n\", \"n\")\nlocal tbl = {a,b,c,d,e}\ntable.sort(tbl, function(x,y)\n local rx = x % 10\n if rx == 0 then\n rx = 10\n end\n local ry = y % 10\n if ry == 0 then\n ry = 10\n end\n return rx > ry\nend)\n\nlocal tm = 0\nfor i=1, #tbl-1 do\n local r = 10 - tbl[i] % 10\n if r == 10 then\n r = 0\n end\n tm = tm + tbl[i] + r\nend\ntm = tm + tbl[#tbl]\n\nprint(tm)\n", "problem_context": "Score: 200 points\n\nProblem Statement\n\nThe restaurant AtCoder serves the following five dishes:\n\nABC Don (rice bowl): takes A minutes to serve.\n\nARC Curry: takes B minutes to serve.\n\nAGC Pasta: takes C minutes to serve.\n\nAPC Ramen: takes D minutes to serve.\n\nATC Hanbagu (hamburger patty): takes E minutes to serve.\n\nHere, the time to serve a dish is the time between when an order is placed and when the dish is delivered.\n\nThis restaurant has the following rules on orders:\n\nAn order can only be placed at a time that is a multiple of 10 (time 0, 10, 20, ...).\n\nOnly one dish can be ordered at a time.\n\nNo new order can be placed when an order is already placed and the dish is still not delivered, but a new order can be placed at the exact time when the dish is delivered.\n\nE869120 arrives at this restaurant at time 0. He will order all five dishes. Find the earliest possible time for the last dish to be delivered.\n\nHere, he can order the dishes in any order he likes, and he can place an order already at time 0.\n\nConstraints\n\nA, B, C, D and E are integers between 1 and 123 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA\nB\nC\nD\nE\n\nOutput\n\nPrint the earliest possible time for the last dish to be delivered, as an integer.\n\nSample Input 1\n\n29\n20\n7\n35\n120\n\nSample Output 1\n\n215\n\nIf we decide to order the dishes in the order ABC Don, ARC Curry, AGC Pasta, ATC Hanbagu, APC Ramen, the earliest possible time for each order is as follows:\n\nOrder ABC Don at time 0, which will be delivered at time 29.\n\nOrder ARC Curry at time 30, which will be delivered at time 50.\n\nOrder AGC Pasta at time 50, which will be delivered at time 57.\n\nOrder ATC Hanbagu at time 60, which will be delivered at time 180.\n\nOrder APC Ramen at time 180, which will be delivered at time 215.\n\nThere is no way to order the dishes in which the last dish will be delivered earlier than this.\n\nSample Input 2\n\n101\n86\n119\n108\n57\n\nSample Output 2\n\n481\n\nIf we decide to order the dishes in the order AGC Pasta, ARC Curry, ATC Hanbagu, APC Ramen, ABC Don, the earliest possible time for each order is as follows:\n\nOrder AGC Pasta at time 0, which will be delivered at time 119.\n\nOrder ARC Curry at time 120, which will be delivered at time 206.\n\nOrder ATC Hanbagu at time 210, which will be delivered at time 267.\n\nOrder APC Ramen at time 270, which will be delivered at time 378.\n\nOrder ABC Don at time 380, which will be delivered at time 481.\n\nThere is no way to order the dishes in which the last dish will be delivered earlier than this.\n\nSample Input 3\n\n123\n123\n123\n123\n123\n\nSample Output 3\n\n643\n\nThis is the largest valid case.", "sample_input": "29\n20\n7\n35\n120\n"}, "reference_outputs": ["215\n"], "source_document_id": "p03076", "source_text": "Score: 200 points\n\nProblem Statement\n\nThe restaurant AtCoder serves the following five dishes:\n\nABC Don (rice bowl): takes A minutes to serve.\n\nARC Curry: takes B minutes to serve.\n\nAGC Pasta: takes C minutes to serve.\n\nAPC Ramen: takes D minutes to serve.\n\nATC Hanbagu (hamburger patty): takes E minutes to serve.\n\nHere, the time to serve a dish is the time between when an order is placed and when the dish is delivered.\n\nThis restaurant has the following rules on orders:\n\nAn order can only be placed at a time that is a multiple of 10 (time 0, 10, 20, ...).\n\nOnly one dish can be ordered at a time.\n\nNo new order can be placed when an order is already placed and the dish is still not delivered, but a new order can be placed at the exact time when the dish is delivered.\n\nE869120 arrives at this restaurant at time 0. He will order all five dishes. Find the earliest possible time for the last dish to be delivered.\n\nHere, he can order the dishes in any order he likes, and he can place an order already at time 0.\n\nConstraints\n\nA, B, C, D and E are integers between 1 and 123 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA\nB\nC\nD\nE\n\nOutput\n\nPrint the earliest possible time for the last dish to be delivered, as an integer.\n\nSample Input 1\n\n29\n20\n7\n35\n120\n\nSample Output 1\n\n215\n\nIf we decide to order the dishes in the order ABC Don, ARC Curry, AGC Pasta, ATC Hanbagu, APC Ramen, the earliest possible time for each order is as follows:\n\nOrder ABC Don at time 0, which will be delivered at time 29.\n\nOrder ARC Curry at time 30, which will be delivered at time 50.\n\nOrder AGC Pasta at time 50, which will be delivered at time 57.\n\nOrder ATC Hanbagu at time 60, which will be delivered at time 180.\n\nOrder APC Ramen at time 180, which will be delivered at time 215.\n\nThere is no way to order the dishes in which the last dish will be delivered earlier than this.\n\nSample Input 2\n\n101\n86\n119\n108\n57\n\nSample Output 2\n\n481\n\nIf we decide to order the dishes in the order AGC Pasta, ARC Curry, ATC Hanbagu, APC Ramen, ABC Don, the earliest possible time for each order is as follows:\n\nOrder AGC Pasta at time 0, which will be delivered at time 119.\n\nOrder ARC Curry at time 120, which will be delivered at time 206.\n\nOrder ATC Hanbagu at time 210, which will be delivered at time 267.\n\nOrder APC Ramen at time 270, which will be delivered at time 378.\n\nOrder ABC Don at time 380, which will be delivered at time 481.\n\nThere is no way to order the dishes in which the last dish will be delivered earlier than this.\n\nSample Input 3\n\n123\n123\n123\n123\n123\n\nSample Output 3\n\n643\n\nThis is the largest valid case.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 432, "cpu_time_ms": 51, "memory_kb": 1008}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s220866713", "group_id": "codeNet:p03077", "input_text": "local n=io.read(\"*n\")\nlocal min=10^15+1\nfor i=1,5 do\n min=math.min(min,io.read(\"*n\"))\nend\nprint(n//min+(n%min>0 and 1 or 0)+4)", "language": "Lua", "metadata": {"date": 1590318509, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03077.html", "problem_id": "p03077", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03077/input.txt", "sample_output_relpath": "derived/input_output/data/p03077/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03077/Lua/s220866713.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s220866713", "user_id": "u045238009"}, "prompt_components": {"gold_output": "7\n", "input_to_evaluate": "local n=io.read(\"*n\")\nlocal min=10^15+1\nfor i=1,5 do\n min=math.min(min,io.read(\"*n\"))\nend\nprint(n//min+(n%min>0 and 1 or 0)+4)", "problem_context": "Score: 300 points\n\nProblem Statement\n\nIn 2028 and after a continuous growth, AtCoder Inc. finally built an empire with six cities (City 1, 2, 3, 4, 5, 6)!\n\nThere are five means of transport in this empire:\n\nTrain: travels from City 1 to 2 in one minute. A train can occupy at most A people.\n\nBus: travels from City 2 to 3 in one minute. A bus can occupy at most B people.\n\nTaxi: travels from City 3 to 4 in one minute. A taxi can occupy at most C people.\n\nAirplane: travels from City 4 to 5 in one minute. An airplane can occupy at most D people.\n\nShip: travels from City 5 to 6 in one minute. A ship can occupy at most E people.\n\nFor each of them, one vehicle leaves the city at each integer time (time 0, 1, 2, ...).\n\nThere is a group of N people at City 1, and they all want to go to City 6.\n\nAt least how long does it take for all of them to reach there?\nYou can ignore the time needed to transfer.\n\nConstraints\n\n1 \\leq N, A, B, C, D, E \\leq 10^{15}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA\nB\nC\nD\nE\n\nOutput\n\nPrint the minimum time required for all of the people to reach City 6, in minutes.\n\nSample Input 1\n\n5\n3\n2\n4\n3\n5\n\nSample Output 1\n\n7\n\nOne possible way to travel is as follows.\nFirst, there are N = 5 people at City 1, as shown in the following image:\n\nIn the first minute, three people travels from City 1 to City 2 by train. Note that a train can only occupy at most three people.\n\nIn the second minute, the remaining two people travels from City 1 to City 2 by train, and two of the three people who were already at City 2 travels to City 3 by bus. Note that a bus can only occupy at most two people.\n\nIn the third minute, two people travels from City 2 to City 3 by train, and another two people travels from City 3 to City 4 by taxi.\n\nFrom then on, if they continue traveling without stopping until they reach City 6, all of them can reach there in seven minutes.\n\nThere is no way for them to reach City 6 in 6 minutes or less.\n\nSample Input 2\n\n10\n123\n123\n123\n123\n123\n\nSample Output 2\n\n5\n\nAll kinds of vehicles can occupy N = 10 people at a time.\nThus, if they continue traveling without stopping until they reach City 6, all of them can reach there in five minutes.\n\nSample Input 3\n\n10000000007\n2\n3\n5\n7\n11\n\nSample Output 3\n\n5000000008\n\nNote that the input or output may not fit into a 32-bit integer type.", "sample_input": "5\n3\n2\n4\n3\n5\n"}, "reference_outputs": ["7\n"], "source_document_id": "p03077", "source_text": "Score: 300 points\n\nProblem Statement\n\nIn 2028 and after a continuous growth, AtCoder Inc. finally built an empire with six cities (City 1, 2, 3, 4, 5, 6)!\n\nThere are five means of transport in this empire:\n\nTrain: travels from City 1 to 2 in one minute. A train can occupy at most A people.\n\nBus: travels from City 2 to 3 in one minute. A bus can occupy at most B people.\n\nTaxi: travels from City 3 to 4 in one minute. A taxi can occupy at most C people.\n\nAirplane: travels from City 4 to 5 in one minute. An airplane can occupy at most D people.\n\nShip: travels from City 5 to 6 in one minute. A ship can occupy at most E people.\n\nFor each of them, one vehicle leaves the city at each integer time (time 0, 1, 2, ...).\n\nThere is a group of N people at City 1, and they all want to go to City 6.\n\nAt least how long does it take for all of them to reach there?\nYou can ignore the time needed to transfer.\n\nConstraints\n\n1 \\leq N, A, B, C, D, E \\leq 10^{15}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA\nB\nC\nD\nE\n\nOutput\n\nPrint the minimum time required for all of the people to reach City 6, in minutes.\n\nSample Input 1\n\n5\n3\n2\n4\n3\n5\n\nSample Output 1\n\n7\n\nOne possible way to travel is as follows.\nFirst, there are N = 5 people at City 1, as shown in the following image:\n\nIn the first minute, three people travels from City 1 to City 2 by train. Note that a train can only occupy at most three people.\n\nIn the second minute, the remaining two people travels from City 1 to City 2 by train, and two of the three people who were already at City 2 travels to City 3 by bus. Note that a bus can only occupy at most two people.\n\nIn the third minute, two people travels from City 2 to City 3 by train, and another two people travels from City 3 to City 4 by taxi.\n\nFrom then on, if they continue traveling without stopping until they reach City 6, all of them can reach there in seven minutes.\n\nThere is no way for them to reach City 6 in 6 minutes or less.\n\nSample Input 2\n\n10\n123\n123\n123\n123\n123\n\nSample Output 2\n\n5\n\nAll kinds of vehicles can occupy N = 10 people at a time.\nThus, if they continue traveling without stopping until they reach City 6, all of them can reach there in five minutes.\n\nSample Input 3\n\n10000000007\n2\n3\n5\n7\n11\n\nSample Output 3\n\n5000000008\n\nNote that the input or output may not fit into a 32-bit integer type.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 129, "cpu_time_ms": 7, "memory_kb": 760}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s679872150", "group_id": "codeNet:p03077", "input_text": "local n=io.read(\"*n\")\nlocal min=10^15+1\nfor i=1,5 do\n min=math.min(min,io.read(\"*n\"))\nend\nprint(n//min+(n%min and 1 or 0)+4)", "language": "Lua", "metadata": {"date": 1590318315, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03077.html", "problem_id": "p03077", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03077/input.txt", "sample_output_relpath": "derived/input_output/data/p03077/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03077/Lua/s679872150.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s679872150", "user_id": "u045238009"}, "prompt_components": {"gold_output": "7\n", "input_to_evaluate": "local n=io.read(\"*n\")\nlocal min=10^15+1\nfor i=1,5 do\n min=math.min(min,io.read(\"*n\"))\nend\nprint(n//min+(n%min and 1 or 0)+4)", "problem_context": "Score: 300 points\n\nProblem Statement\n\nIn 2028 and after a continuous growth, AtCoder Inc. finally built an empire with six cities (City 1, 2, 3, 4, 5, 6)!\n\nThere are five means of transport in this empire:\n\nTrain: travels from City 1 to 2 in one minute. A train can occupy at most A people.\n\nBus: travels from City 2 to 3 in one minute. A bus can occupy at most B people.\n\nTaxi: travels from City 3 to 4 in one minute. A taxi can occupy at most C people.\n\nAirplane: travels from City 4 to 5 in one minute. An airplane can occupy at most D people.\n\nShip: travels from City 5 to 6 in one minute. A ship can occupy at most E people.\n\nFor each of them, one vehicle leaves the city at each integer time (time 0, 1, 2, ...).\n\nThere is a group of N people at City 1, and they all want to go to City 6.\n\nAt least how long does it take for all of them to reach there?\nYou can ignore the time needed to transfer.\n\nConstraints\n\n1 \\leq N, A, B, C, D, E \\leq 10^{15}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA\nB\nC\nD\nE\n\nOutput\n\nPrint the minimum time required for all of the people to reach City 6, in minutes.\n\nSample Input 1\n\n5\n3\n2\n4\n3\n5\n\nSample Output 1\n\n7\n\nOne possible way to travel is as follows.\nFirst, there are N = 5 people at City 1, as shown in the following image:\n\nIn the first minute, three people travels from City 1 to City 2 by train. Note that a train can only occupy at most three people.\n\nIn the second minute, the remaining two people travels from City 1 to City 2 by train, and two of the three people who were already at City 2 travels to City 3 by bus. Note that a bus can only occupy at most two people.\n\nIn the third minute, two people travels from City 2 to City 3 by train, and another two people travels from City 3 to City 4 by taxi.\n\nFrom then on, if they continue traveling without stopping until they reach City 6, all of them can reach there in seven minutes.\n\nThere is no way for them to reach City 6 in 6 minutes or less.\n\nSample Input 2\n\n10\n123\n123\n123\n123\n123\n\nSample Output 2\n\n5\n\nAll kinds of vehicles can occupy N = 10 people at a time.\nThus, if they continue traveling without stopping until they reach City 6, all of them can reach there in five minutes.\n\nSample Input 3\n\n10000000007\n2\n3\n5\n7\n11\n\nSample Output 3\n\n5000000008\n\nNote that the input or output may not fit into a 32-bit integer type.", "sample_input": "5\n3\n2\n4\n3\n5\n"}, "reference_outputs": ["7\n"], "source_document_id": "p03077", "source_text": "Score: 300 points\n\nProblem Statement\n\nIn 2028 and after a continuous growth, AtCoder Inc. finally built an empire with six cities (City 1, 2, 3, 4, 5, 6)!\n\nThere are five means of transport in this empire:\n\nTrain: travels from City 1 to 2 in one minute. A train can occupy at most A people.\n\nBus: travels from City 2 to 3 in one minute. A bus can occupy at most B people.\n\nTaxi: travels from City 3 to 4 in one minute. A taxi can occupy at most C people.\n\nAirplane: travels from City 4 to 5 in one minute. An airplane can occupy at most D people.\n\nShip: travels from City 5 to 6 in one minute. A ship can occupy at most E people.\n\nFor each of them, one vehicle leaves the city at each integer time (time 0, 1, 2, ...).\n\nThere is a group of N people at City 1, and they all want to go to City 6.\n\nAt least how long does it take for all of them to reach there?\nYou can ignore the time needed to transfer.\n\nConstraints\n\n1 \\leq N, A, B, C, D, E \\leq 10^{15}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA\nB\nC\nD\nE\n\nOutput\n\nPrint the minimum time required for all of the people to reach City 6, in minutes.\n\nSample Input 1\n\n5\n3\n2\n4\n3\n5\n\nSample Output 1\n\n7\n\nOne possible way to travel is as follows.\nFirst, there are N = 5 people at City 1, as shown in the following image:\n\nIn the first minute, three people travels from City 1 to City 2 by train. Note that a train can only occupy at most three people.\n\nIn the second minute, the remaining two people travels from City 1 to City 2 by train, and two of the three people who were already at City 2 travels to City 3 by bus. Note that a bus can only occupy at most two people.\n\nIn the third minute, two people travels from City 2 to City 3 by train, and another two people travels from City 3 to City 4 by taxi.\n\nFrom then on, if they continue traveling without stopping until they reach City 6, all of them can reach there in seven minutes.\n\nThere is no way for them to reach City 6 in 6 minutes or less.\n\nSample Input 2\n\n10\n123\n123\n123\n123\n123\n\nSample Output 2\n\n5\n\nAll kinds of vehicles can occupy N = 10 people at a time.\nThus, if they continue traveling without stopping until they reach City 6, all of them can reach there in five minutes.\n\nSample Input 3\n\n10000000007\n2\n3\n5\n7\n11\n\nSample Output 3\n\n5000000008\n\nNote that the input or output may not fit into a 32-bit integer type.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 127, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s566809483", "group_id": "codeNet:p03078", "input_text": "local DBG = true\nlocal function dbgpr(...)\n if DBG then\n io.write(\"[dbg]\")\n print(...)\n end\nend\n\nlocal function dbgpr_t(tbl, use_pairs)\n if DBG then\n local enum = ipairs\n if use_pairs then\n enum = pairs\n end\n dbgpr(tbl)\n io.write(\"[dbg]\")\n for i,v in enum(tbl) do\n io.write(i)\n io.write(\":\")\n io.write(tostring(v))\n io.write(\" \")\n end\n print(\"\")\n end\nend\n\nlocal function dbgpr_tp(tbl)\n dbgpr_t(tbl, true)\nend\n\n-- D\nlocal X, Y, Z, K = io.read(\"n\", \"n\", \"n\", \"n\")\nlocal A, B, C = {}, {}, {}\n\nfor i, tbl in ipairs {A, B, C} do\n local nums = {X, Y, Z}\n local count = nums[i]\n for j=1, count do\n tbl[j] = io.read(\"n\")\n end\n table.sort(tbl, function (x,y)\n return x > y\n end)\nend\n\nlocal function goodness(a, b, c)\n if a > #A or b > #B or c > #C then\n return -10000000000000\n end\n return A[a] + B[b] + C[c]\nend\n\nlocal visited = {}\nlocal function visit(a,b,c)\n visited[tostring(a) .. \"*\" .. tostring(b) .. \"*\" .. tostring(c)] = true\nend\nlocal function isvisited(a,b,c)\n return visited[tostring(a) .. \"*\" .. tostring(b) .. \"*\" .. tostring(c)]\nend\n\n-- most good comb right\nlocal items = {}\nlocal function item_sort(tbl)\n table.sort(items, function(x,y)\n return x[4] < y[4]\n end)\nend\nlocal function items_count()\n return #items\nend\nlocal function items_add(a, b, c)\n table.insert(items, {a,b,c,goodness(a,b,c)})\n return true\nend\nlocal function check_add(a,b,c)\n if a > #A or b > #B or c > #C then\n return -1\n end\n if isvisited(a, b, c) then\n return -2\n end\n visit(a,b,c)\n items_add(a, b, c)\nend\nlocal ans = {}\nlocal a, b, c = 1, 1, 1\ncheck_add(a, b, c)\nwhile #ans < K do\n local e = table.remove(items)\n table.insert(ans, e[4])\n local a,b,c = e[1], e[2], e[3]\n check_add(a+1,b,c)\n check_add(a,b+1,c)\n check_add(a,b,c+1)\n item_sort(items)\nend\n\n--table.sort(ans, function(x,y) return x>y end)\nfor i=1,K do\n print(ans[i])\nend\n\n", "language": "Lua", "metadata": {"date": 1554636749, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03078.html", "problem_id": "p03078", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03078/input.txt", "sample_output_relpath": "derived/input_output/data/p03078/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03078/Lua/s566809483.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s566809483", "user_id": "u162773977"}, "prompt_components": {"gold_output": "19\n17\n15\n14\n13\n12\n10\n8\n", "input_to_evaluate": "local DBG = true\nlocal function dbgpr(...)\n if DBG then\n io.write(\"[dbg]\")\n print(...)\n end\nend\n\nlocal function dbgpr_t(tbl, use_pairs)\n if DBG then\n local enum = ipairs\n if use_pairs then\n enum = pairs\n end\n dbgpr(tbl)\n io.write(\"[dbg]\")\n for i,v in enum(tbl) do\n io.write(i)\n io.write(\":\")\n io.write(tostring(v))\n io.write(\" \")\n end\n print(\"\")\n end\nend\n\nlocal function dbgpr_tp(tbl)\n dbgpr_t(tbl, true)\nend\n\n-- D\nlocal X, Y, Z, K = io.read(\"n\", \"n\", \"n\", \"n\")\nlocal A, B, C = {}, {}, {}\n\nfor i, tbl in ipairs {A, B, C} do\n local nums = {X, Y, Z}\n local count = nums[i]\n for j=1, count do\n tbl[j] = io.read(\"n\")\n end\n table.sort(tbl, function (x,y)\n return x > y\n end)\nend\n\nlocal function goodness(a, b, c)\n if a > #A or b > #B or c > #C then\n return -10000000000000\n end\n return A[a] + B[b] + C[c]\nend\n\nlocal visited = {}\nlocal function visit(a,b,c)\n visited[tostring(a) .. \"*\" .. tostring(b) .. \"*\" .. tostring(c)] = true\nend\nlocal function isvisited(a,b,c)\n return visited[tostring(a) .. \"*\" .. tostring(b) .. \"*\" .. tostring(c)]\nend\n\n-- most good comb right\nlocal items = {}\nlocal function item_sort(tbl)\n table.sort(items, function(x,y)\n return x[4] < y[4]\n end)\nend\nlocal function items_count()\n return #items\nend\nlocal function items_add(a, b, c)\n table.insert(items, {a,b,c,goodness(a,b,c)})\n return true\nend\nlocal function check_add(a,b,c)\n if a > #A or b > #B or c > #C then\n return -1\n end\n if isvisited(a, b, c) then\n return -2\n end\n visit(a,b,c)\n items_add(a, b, c)\nend\nlocal ans = {}\nlocal a, b, c = 1, 1, 1\ncheck_add(a, b, c)\nwhile #ans < K do\n local e = table.remove(items)\n table.insert(ans, e[4])\n local a,b,c = e[1], e[2], e[3]\n check_add(a+1,b,c)\n check_add(a,b+1,c)\n check_add(a,b,c+1)\n item_sort(items)\nend\n\n--table.sort(ans, function(x,y) return x>y end)\nfor i=1,K do\n print(ans[i])\nend\n\n", "problem_context": "Score: 400 points\n\nProblem Statement\n\nThe Patisserie AtCoder sells cakes with number-shaped candles.\nThere are X, Y and Z kinds of cakes with 1-shaped, 2-shaped and 3-shaped candles, respectively.\nEach cake has an integer value called deliciousness, as follows:\n\nThe deliciousness of the cakes with 1-shaped candles are A_1, A_2, ..., A_X.\n\nThe deliciousness of the cakes with 2-shaped candles are B_1, B_2, ..., B_Y.\n\nThe deliciousness of the cakes with 3-shaped candles are C_1, C_2, ..., C_Z.\n\nTakahashi decides to buy three cakes, one for each of the three shapes of the candles, to celebrate ABC 123.\n\nThere are X \\times Y \\times Z such ways to choose three cakes.\n\nWe will arrange these X \\times Y \\times Z ways in descending order of the sum of the deliciousness of the cakes.\n\nPrint the sums of the deliciousness of the cakes for the first, second, ..., K-th ways in this list.\n\nConstraints\n\n1 \\leq X \\leq 1 \\ 000\n\n1 \\leq Y \\leq 1 \\ 000\n\n1 \\leq Z \\leq 1 \\ 000\n\n1 \\leq K \\leq \\min(3 \\ 000, X \\times Y \\times Z)\n\n1 \\leq A_i \\leq 10 \\ 000 \\ 000 \\ 000\n\n1 \\leq B_i \\leq 10 \\ 000 \\ 000 \\ 000\n\n1 \\leq C_i \\leq 10 \\ 000 \\ 000 \\ 000\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX Y Z K\nA_1 \\ A_2 \\ A_3 \\ ... \\ A_X\nB_1 \\ B_2 \\ B_3 \\ ... \\ B_Y\nC_1 \\ C_2 \\ C_3 \\ ... \\ C_Z\n\nOutput\n\nPrint K lines. The i-th line should contain the i-th value stated in the problem statement.\n\nSample Input 1\n\n2 2 2 8\n4 6\n1 5\n3 8\n\nSample Output 1\n\n19\n17\n15\n14\n13\n12\n10\n8\n\nThere are 2 \\times 2 \\times 2 = 8 ways to choose three cakes, as shown below in descending order of the sum of the deliciousness of the cakes:\n\n(A_2, B_2, C_2): 6 + 5 + 8 = 19\n\n(A_1, B_2, C_2): 4 + 5 + 8 = 17\n\n(A_2, B_1, C_2): 6 + 1 + 8 = 15\n\n(A_2, B_2, C_1): 6 + 5 + 3 = 14\n\n(A_1, B_1, C_2): 4 + 1 + 8 = 13\n\n(A_1, B_2, C_1): 4 + 5 + 3 = 12\n\n(A_2, B_1, C_1): 6 + 1 + 3 = 10\n\n(A_1, B_1, C_1): 4 + 1 + 3 = 8\n\nSample Input 2\n\n3 3 3 5\n1 10 100\n2 20 200\n1 10 100\n\nSample Output 2\n\n400\n310\n310\n301\n301\n\nThere may be multiple combinations of cakes with the same sum of the deliciousness. For example, in this test case, the sum of A_1, B_3, C_3 and the sum of A_3, B_3, C_1 are both 301.\nHowever, they are different ways of choosing cakes, so 301 occurs twice in the output.\n\nSample Input 3\n\n10 10 10 20\n7467038376 5724769290 292794712 2843504496 3381970101 8402252870 249131806 6310293640 6690322794 6082257488\n1873977926 2576529623 1144842195 1379118507 6003234687 4925540914 3902539811 3326692703 484657758 2877436338\n4975681328 8974383988 2882263257 7690203955 514305523 6679823484 4263279310 585966808 3752282379 620585736\n\nSample Output 3\n\n23379871545\n22444657051\n22302177772\n22095691512\n21667941469\n21366963278\n21287912315\n21279176669\n21160477018\n21085311041\n21059876163\n21017997739\n20703329561\n20702387965\n20590247696\n20383761436\n20343962175\n20254073196\n20210218542\n20150096547\n\nNote that the input or output may not fit into a 32-bit integer type.", "sample_input": "2 2 2 8\n4 6\n1 5\n3 8\n"}, "reference_outputs": ["19\n17\n15\n14\n13\n12\n10\n8\n"], "source_document_id": "p03078", "source_text": "Score: 400 points\n\nProblem Statement\n\nThe Patisserie AtCoder sells cakes with number-shaped candles.\nThere are X, Y and Z kinds of cakes with 1-shaped, 2-shaped and 3-shaped candles, respectively.\nEach cake has an integer value called deliciousness, as follows:\n\nThe deliciousness of the cakes with 1-shaped candles are A_1, A_2, ..., A_X.\n\nThe deliciousness of the cakes with 2-shaped candles are B_1, B_2, ..., B_Y.\n\nThe deliciousness of the cakes with 3-shaped candles are C_1, C_2, ..., C_Z.\n\nTakahashi decides to buy three cakes, one for each of the three shapes of the candles, to celebrate ABC 123.\n\nThere are X \\times Y \\times Z such ways to choose three cakes.\n\nWe will arrange these X \\times Y \\times Z ways in descending order of the sum of the deliciousness of the cakes.\n\nPrint the sums of the deliciousness of the cakes for the first, second, ..., K-th ways in this list.\n\nConstraints\n\n1 \\leq X \\leq 1 \\ 000\n\n1 \\leq Y \\leq 1 \\ 000\n\n1 \\leq Z \\leq 1 \\ 000\n\n1 \\leq K \\leq \\min(3 \\ 000, X \\times Y \\times Z)\n\n1 \\leq A_i \\leq 10 \\ 000 \\ 000 \\ 000\n\n1 \\leq B_i \\leq 10 \\ 000 \\ 000 \\ 000\n\n1 \\leq C_i \\leq 10 \\ 000 \\ 000 \\ 000\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX Y Z K\nA_1 \\ A_2 \\ A_3 \\ ... \\ A_X\nB_1 \\ B_2 \\ B_3 \\ ... \\ B_Y\nC_1 \\ C_2 \\ C_3 \\ ... \\ C_Z\n\nOutput\n\nPrint K lines. The i-th line should contain the i-th value stated in the problem statement.\n\nSample Input 1\n\n2 2 2 8\n4 6\n1 5\n3 8\n\nSample Output 1\n\n19\n17\n15\n14\n13\n12\n10\n8\n\nThere are 2 \\times 2 \\times 2 = 8 ways to choose three cakes, as shown below in descending order of the sum of the deliciousness of the cakes:\n\n(A_2, B_2, C_2): 6 + 5 + 8 = 19\n\n(A_1, B_2, C_2): 4 + 5 + 8 = 17\n\n(A_2, B_1, C_2): 6 + 1 + 8 = 15\n\n(A_2, B_2, C_1): 6 + 5 + 3 = 14\n\n(A_1, B_1, C_2): 4 + 1 + 8 = 13\n\n(A_1, B_2, C_1): 4 + 5 + 3 = 12\n\n(A_2, B_1, C_1): 6 + 1 + 3 = 10\n\n(A_1, B_1, C_1): 4 + 1 + 3 = 8\n\nSample Input 2\n\n3 3 3 5\n1 10 100\n2 20 200\n1 10 100\n\nSample Output 2\n\n400\n310\n310\n301\n301\n\nThere may be multiple combinations of cakes with the same sum of the deliciousness. For example, in this test case, the sum of A_1, B_3, C_3 and the sum of A_3, B_3, C_1 are both 301.\nHowever, they are different ways of choosing cakes, so 301 occurs twice in the output.\n\nSample Input 3\n\n10 10 10 20\n7467038376 5724769290 292794712 2843504496 3381970101 8402252870 249131806 6310293640 6690322794 6082257488\n1873977926 2576529623 1144842195 1379118507 6003234687 4925540914 3902539811 3326692703 484657758 2877436338\n4975681328 8974383988 2882263257 7690203955 514305523 6679823484 4263279310 585966808 3752282379 620585736\n\nSample Output 3\n\n23379871545\n22444657051\n22302177772\n22095691512\n21667941469\n21366963278\n21287912315\n21279176669\n21160477018\n21085311041\n21059876163\n21017997739\n20703329561\n20702387965\n20590247696\n20383761436\n20343962175\n20254073196\n20210218542\n20150096547\n\nNote that the input or output may not fit into a 32-bit integer type.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2084, "cpu_time_ms": 2103, "memory_kb": 1400}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s409794602", "group_id": "codeNet:p03081", "input_text": "local n, q = io.read(\"*n\", \"*n\", \"*l\")\nlocal s = io.read()\nlocal t = {}\nfor i = 1, n do t[i] = s:sub(i, i):byte() end\nlocal target, way = {}, {}\nfor i = 1, q do\n local strt, strway = io.read():match(\"(%w) (%w)\")\n target[i] = strt:byte()\n way[i] = strway == \"R\"\nend\nlocal function solve(x)\n local result = 0\n for i = 1, q do\n if t[x] == target[i] then\n if way[i] then\n if x < n then x = x + 1\n else result = 1 break\n end\n else\n if 1 < x then x = x - 1\n else result = -1 break\n end\n end\n end\n end\n return result\nend\nlocal leftok = n + 1\nif 0 <= solve(n) then\n leftok = n\n if 0 <= solve(1) then\n leftok = 1\n else\n local leftng = 1\n while 1 < leftok - leftng do\n local leftmid = (leftok + leftng) // 2\n if 0 <= solve(leftmid) then\n leftok = leftmid\n else\n leftng = leftmid\n end\n end\n end\nend\nlocal rightok = 0\nif solve(1) <= 0 then\n rightok = 1\n if solve(n) <= 0 then\n rightok = n\n else\n local rightng = n\n while 1 < rightng - rightok do\n local rightmid = (rightng + rightok) // 2\n if solve(rightmid) <= 0 then\n rightok = rightmid\n else\n rightng = rightmid\n end\n end\n end\nend\nprint(math.max(0, rightok - leftok + 1))\n", "language": "Lua", "metadata": {"date": 1585126062, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03081.html", "problem_id": "p03081", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03081/input.txt", "sample_output_relpath": "derived/input_output/data/p03081/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03081/Lua/s409794602.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s409794602", "user_id": "u120582723"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "local n, q = io.read(\"*n\", \"*n\", \"*l\")\nlocal s = io.read()\nlocal t = {}\nfor i = 1, n do t[i] = s:sub(i, i):byte() end\nlocal target, way = {}, {}\nfor i = 1, q do\n local strt, strway = io.read():match(\"(%w) (%w)\")\n target[i] = strt:byte()\n way[i] = strway == \"R\"\nend\nlocal function solve(x)\n local result = 0\n for i = 1, q do\n if t[x] == target[i] then\n if way[i] then\n if x < n then x = x + 1\n else result = 1 break\n end\n else\n if 1 < x then x = x - 1\n else result = -1 break\n end\n end\n end\n end\n return result\nend\nlocal leftok = n + 1\nif 0 <= solve(n) then\n leftok = n\n if 0 <= solve(1) then\n leftok = 1\n else\n local leftng = 1\n while 1 < leftok - leftng do\n local leftmid = (leftok + leftng) // 2\n if 0 <= solve(leftmid) then\n leftok = leftmid\n else\n leftng = leftmid\n end\n end\n end\nend\nlocal rightok = 0\nif solve(1) <= 0 then\n rightok = 1\n if solve(n) <= 0 then\n rightok = n\n else\n local rightng = n\n while 1 < rightng - rightok do\n local rightmid = (rightng + rightok) // 2\n if solve(rightmid) <= 0 then\n rightok = rightmid\n else\n rightng = rightmid\n end\n end\n end\nend\nprint(math.max(0, rightok - leftok + 1))\n", "problem_context": "Score : 500 points\n\nProblem Statement\n\nThere are N squares numbered 1 to N from left to right.\nEach square has a character written on it, and Square i has a letter s_i. Besides, there is initially one golem on each square.\n\nSnuke cast Q spells to move the golems.\n\nThe i-th spell consisted of two characters t_i and d_i, where d_i is L or R.\nWhen Snuke cast this spell, for each square with the character t_i, all golems on that square moved to the square adjacent to the left if d_i is L, and moved to the square adjacent to the right if d_i is R.\n\nHowever, when a golem tried to move left from Square 1 or move right from Square N, it disappeared.\n\nFind the number of golems remaining after Snuke cast the Q spells.\n\nConstraints\n\n1 \\leq N,Q \\leq 2 \\times 10^{5}\n\n|s| = N\n\ns_i and t_i are uppercase English letters.\n\nd_i is L or R.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN Q\ns\nt_1 d_1\n\\vdots\nt_{Q} d_Q\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n3 4\nABC\nA L\nB L\nB R\nA R\n\nSample Output 1\n\n2\n\nInitially, there is one golem on each square.\n\nIn the first spell, the golem on Square 1 tries to move left and disappears.\n\nIn the second spell, the golem on Square 2 moves left.\n\nIn the third spell, no golem moves.\n\nIn the fourth spell, the golem on Square 1 moves right.\n\nAfter the four spells are cast, there is one golem on Square 2 and one golem on Square 3, for a total of two golems remaining.\n\nSample Input 2\n\n8 3\nAABCBDBA\nA L\nB R\nA R\n\nSample Output 2\n\n5\n\nAfter the three spells are cast, there is one golem on Square 2, two golems on Square 4 and two golems on Square 6, for a total of five golems remaining.\n\nNote that a single spell may move multiple golems.\n\nSample Input 3\n\n10 15\nSNCZWRCEWB\nB R\nR R\nE R\nW R\nZ L\nS R\nQ L\nW L\nB R\nC L\nA L\nN L\nE R\nZ L\nS L\n\nSample Output 3\n\n3", "sample_input": "3 4\nABC\nA L\nB L\nB R\nA R\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03081", "source_text": "Score : 500 points\n\nProblem Statement\n\nThere are N squares numbered 1 to N from left to right.\nEach square has a character written on it, and Square i has a letter s_i. Besides, there is initially one golem on each square.\n\nSnuke cast Q spells to move the golems.\n\nThe i-th spell consisted of two characters t_i and d_i, where d_i is L or R.\nWhen Snuke cast this spell, for each square with the character t_i, all golems on that square moved to the square adjacent to the left if d_i is L, and moved to the square adjacent to the right if d_i is R.\n\nHowever, when a golem tried to move left from Square 1 or move right from Square N, it disappeared.\n\nFind the number of golems remaining after Snuke cast the Q spells.\n\nConstraints\n\n1 \\leq N,Q \\leq 2 \\times 10^{5}\n\n|s| = N\n\ns_i and t_i are uppercase English letters.\n\nd_i is L or R.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN Q\ns\nt_1 d_1\n\\vdots\nt_{Q} d_Q\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n3 4\nABC\nA L\nB L\nB R\nA R\n\nSample Output 1\n\n2\n\nInitially, there is one golem on each square.\n\nIn the first spell, the golem on Square 1 tries to move left and disappears.\n\nIn the second spell, the golem on Square 2 moves left.\n\nIn the third spell, no golem moves.\n\nIn the fourth spell, the golem on Square 1 moves right.\n\nAfter the four spells are cast, there is one golem on Square 2 and one golem on Square 3, for a total of two golems remaining.\n\nSample Input 2\n\n8 3\nAABCBDBA\nA L\nB R\nA R\n\nSample Output 2\n\n5\n\nAfter the three spells are cast, there is one golem on Square 2, two golems on Square 4 and two golems on Square 6, for a total of five golems remaining.\n\nNote that a single spell may move multiple golems.\n\nSample Input 3\n\n10 15\nSNCZWRCEWB\nB R\nR R\nE R\nW R\nZ L\nS R\nQ L\nW L\nB R\nC L\nA L\nN L\nE R\nZ L\nS L\n\nSample Output 3\n\n3", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1283, "cpu_time_ms": 884, "memory_kb": 13192}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s181553607", "group_id": "codeNet:p03081", "input_text": "\n-- C\nlocal DBG = true\nlocal function dbgpr(...)\n if DBG then\n io.write(\"[dbg]\")\n print(...)\n end\nend\n\nlocal function dbgpr_t(tbl, use_pairs)\n if DBG then\n local enum = ipairs\n if use_pairs then\n enum = pairs\n end\n dbgpr(tbl)\n io.write(\"[dbg]\")\n for i,v in enum(tbl) do\n io.write(i)\n io.write(\":\")\n io.write(tostring(v))\n io.write(\" \")\n end\n print(\"\")\n end\nend\n\nlocal function dbgpr_tp(tbl)\n dbgpr_t(tbl, true)\nend\n\n-- https://golang.org/src/sort/search.go?s=2246:2286#L49\nlocal function find_min_true(n, f)\n local function range_ok(x)\n return x >= 1 and x <= n\n end\n local function loop(i, j)\n -- Define f(0) == false, f(n+1) == true\n -- Invariant: f(i-1) == false and f(j) == true\n if i == j then\n assert(i >= 1 and i <= n + 1) -- i == n + 1 is valid\n -- i == j, f(i-1) == false, f(i) == true\n -- i is the minimum number that f(i) == true\n return i\n end\n local h = (i + j) // 2\n assert(h >= 1 and h <= n)\n if f(h) then\n -- f(h) == true\n -- j = h ==> f(j) == true\n return loop(i, h)\n else\n -- f(h) == false\n -- i = h + 1 ==> f(i-1) == false\n return loop(h + 1, j)\n end\n end\n -- f(i-1) == f(0) == false\n -- f(j) == f(n+1) == true\n return loop(1, n + 1)\nend\n\nlocal function str2tbl(s)\n local t = {string.byte(s, 1, #s)}\n for i=1, #t do\n t[i] = string.char(t[i])\n end\n return t\nend\n\nlocal function each_char(s)\n local f = function(_, i)\n i = i + 1\n if i <= #s then\n return i, string.sub(s, i, i)\n end\n end\n return f, nil, 0\nend\n\nlocal N, Q, _ = io.read(\"n\", \"n\", \"l\")\nlocal s = io.read(\"l\")\nassert(#s == N)\nlocal spells = {}\nfor i=1,Q do\n local t, _, d, _ = io.read(1, 1, 1, \"l\")\n spells[i] = {t, d}\nend\n\nlocal place = str2tbl(s)\n\nlocal function simulation_leftdeath(pos)\n for i=1,Q do\n local t, d = spells[i][1], spells[i][2]\n if place[pos] == t then\n if d == 'L' then\n pos = pos - 1\n else\n pos = pos + 1\n end\n if pos == 0 then\n return true\n end\n if pos == N + 1 then\n return false\n end\n end\n end\n return false\nend\nlocal function simulation_rightdeath(pos)\n for i=1,Q do\n local t, d = spells[i][1], spells[i][2]\n if place[pos] == t then\n if d == 'L' then\n pos = pos - 1\n else\n pos = pos + 1\n end\n if pos == 0 then\n return false\n end\n if pos == N + 1 then\n return true\n end\n end\n end\n return false\nend\n\nlocal rightmost_dead_of_left = -1 + find_min_true(N, function(x)\n return simulation_leftdeath(x) == false\nend)\n\nlocal leftmost_dead_of_right = find_min_true(N, function(x)\n return simulation_rightdeath(x) == true\nend)\n\nlocal dead = 0\nfor i=1,N do\n if i <= rightmost_dead_of_left or i >= leftmost_dead_of_right then\n dead = dead + 1\n end\nend\nprint(N - dead)", "language": "Lua", "metadata": {"date": 1553989891, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03081.html", "problem_id": "p03081", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03081/input.txt", "sample_output_relpath": "derived/input_output/data/p03081/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03081/Lua/s181553607.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s181553607", "user_id": "u162773977"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "\n-- C\nlocal DBG = true\nlocal function dbgpr(...)\n if DBG then\n io.write(\"[dbg]\")\n print(...)\n end\nend\n\nlocal function dbgpr_t(tbl, use_pairs)\n if DBG then\n local enum = ipairs\n if use_pairs then\n enum = pairs\n end\n dbgpr(tbl)\n io.write(\"[dbg]\")\n for i,v in enum(tbl) do\n io.write(i)\n io.write(\":\")\n io.write(tostring(v))\n io.write(\" \")\n end\n print(\"\")\n end\nend\n\nlocal function dbgpr_tp(tbl)\n dbgpr_t(tbl, true)\nend\n\n-- https://golang.org/src/sort/search.go?s=2246:2286#L49\nlocal function find_min_true(n, f)\n local function range_ok(x)\n return x >= 1 and x <= n\n end\n local function loop(i, j)\n -- Define f(0) == false, f(n+1) == true\n -- Invariant: f(i-1) == false and f(j) == true\n if i == j then\n assert(i >= 1 and i <= n + 1) -- i == n + 1 is valid\n -- i == j, f(i-1) == false, f(i) == true\n -- i is the minimum number that f(i) == true\n return i\n end\n local h = (i + j) // 2\n assert(h >= 1 and h <= n)\n if f(h) then\n -- f(h) == true\n -- j = h ==> f(j) == true\n return loop(i, h)\n else\n -- f(h) == false\n -- i = h + 1 ==> f(i-1) == false\n return loop(h + 1, j)\n end\n end\n -- f(i-1) == f(0) == false\n -- f(j) == f(n+1) == true\n return loop(1, n + 1)\nend\n\nlocal function str2tbl(s)\n local t = {string.byte(s, 1, #s)}\n for i=1, #t do\n t[i] = string.char(t[i])\n end\n return t\nend\n\nlocal function each_char(s)\n local f = function(_, i)\n i = i + 1\n if i <= #s then\n return i, string.sub(s, i, i)\n end\n end\n return f, nil, 0\nend\n\nlocal N, Q, _ = io.read(\"n\", \"n\", \"l\")\nlocal s = io.read(\"l\")\nassert(#s == N)\nlocal spells = {}\nfor i=1,Q do\n local t, _, d, _ = io.read(1, 1, 1, \"l\")\n spells[i] = {t, d}\nend\n\nlocal place = str2tbl(s)\n\nlocal function simulation_leftdeath(pos)\n for i=1,Q do\n local t, d = spells[i][1], spells[i][2]\n if place[pos] == t then\n if d == 'L' then\n pos = pos - 1\n else\n pos = pos + 1\n end\n if pos == 0 then\n return true\n end\n if pos == N + 1 then\n return false\n end\n end\n end\n return false\nend\nlocal function simulation_rightdeath(pos)\n for i=1,Q do\n local t, d = spells[i][1], spells[i][2]\n if place[pos] == t then\n if d == 'L' then\n pos = pos - 1\n else\n pos = pos + 1\n end\n if pos == 0 then\n return false\n end\n if pos == N + 1 then\n return true\n end\n end\n end\n return false\nend\n\nlocal rightmost_dead_of_left = -1 + find_min_true(N, function(x)\n return simulation_leftdeath(x) == false\nend)\n\nlocal leftmost_dead_of_right = find_min_true(N, function(x)\n return simulation_rightdeath(x) == true\nend)\n\nlocal dead = 0\nfor i=1,N do\n if i <= rightmost_dead_of_left or i >= leftmost_dead_of_right then\n dead = dead + 1\n end\nend\nprint(N - dead)", "problem_context": "Score : 500 points\n\nProblem Statement\n\nThere are N squares numbered 1 to N from left to right.\nEach square has a character written on it, and Square i has a letter s_i. Besides, there is initially one golem on each square.\n\nSnuke cast Q spells to move the golems.\n\nThe i-th spell consisted of two characters t_i and d_i, where d_i is L or R.\nWhen Snuke cast this spell, for each square with the character t_i, all golems on that square moved to the square adjacent to the left if d_i is L, and moved to the square adjacent to the right if d_i is R.\n\nHowever, when a golem tried to move left from Square 1 or move right from Square N, it disappeared.\n\nFind the number of golems remaining after Snuke cast the Q spells.\n\nConstraints\n\n1 \\leq N,Q \\leq 2 \\times 10^{5}\n\n|s| = N\n\ns_i and t_i are uppercase English letters.\n\nd_i is L or R.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN Q\ns\nt_1 d_1\n\\vdots\nt_{Q} d_Q\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n3 4\nABC\nA L\nB L\nB R\nA R\n\nSample Output 1\n\n2\n\nInitially, there is one golem on each square.\n\nIn the first spell, the golem on Square 1 tries to move left and disappears.\n\nIn the second spell, the golem on Square 2 moves left.\n\nIn the third spell, no golem moves.\n\nIn the fourth spell, the golem on Square 1 moves right.\n\nAfter the four spells are cast, there is one golem on Square 2 and one golem on Square 3, for a total of two golems remaining.\n\nSample Input 2\n\n8 3\nAABCBDBA\nA L\nB R\nA R\n\nSample Output 2\n\n5\n\nAfter the three spells are cast, there is one golem on Square 2, two golems on Square 4 and two golems on Square 6, for a total of five golems remaining.\n\nNote that a single spell may move multiple golems.\n\nSample Input 3\n\n10 15\nSNCZWRCEWB\nB R\nR R\nE R\nW R\nZ L\nS R\nQ L\nW L\nB R\nC L\nA L\nN L\nE R\nZ L\nS L\n\nSample Output 3\n\n3", "sample_input": "3 4\nABC\nA L\nB L\nB R\nA R\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03081", "source_text": "Score : 500 points\n\nProblem Statement\n\nThere are N squares numbered 1 to N from left to right.\nEach square has a character written on it, and Square i has a letter s_i. Besides, there is initially one golem on each square.\n\nSnuke cast Q spells to move the golems.\n\nThe i-th spell consisted of two characters t_i and d_i, where d_i is L or R.\nWhen Snuke cast this spell, for each square with the character t_i, all golems on that square moved to the square adjacent to the left if d_i is L, and moved to the square adjacent to the right if d_i is R.\n\nHowever, when a golem tried to move left from Square 1 or move right from Square N, it disappeared.\n\nFind the number of golems remaining after Snuke cast the Q spells.\n\nConstraints\n\n1 \\leq N,Q \\leq 2 \\times 10^{5}\n\n|s| = N\n\ns_i and t_i are uppercase English letters.\n\nd_i is L or R.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN Q\ns\nt_1 d_1\n\\vdots\nt_{Q} d_Q\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n3 4\nABC\nA L\nB L\nB R\nA R\n\nSample Output 1\n\n2\n\nInitially, there is one golem on each square.\n\nIn the first spell, the golem on Square 1 tries to move left and disappears.\n\nIn the second spell, the golem on Square 2 moves left.\n\nIn the third spell, no golem moves.\n\nIn the fourth spell, the golem on Square 1 moves right.\n\nAfter the four spells are cast, there is one golem on Square 2 and one golem on Square 3, for a total of two golems remaining.\n\nSample Input 2\n\n8 3\nAABCBDBA\nA L\nB R\nA R\n\nSample Output 2\n\n5\n\nAfter the three spells are cast, there is one golem on Square 2, two golems on Square 4 and two golems on Square 6, for a total of five golems remaining.\n\nNote that a single spell may move multiple golems.\n\nSample Input 3\n\n10 15\nSNCZWRCEWB\nB R\nR R\nE R\nW R\nZ L\nS R\nQ L\nW L\nB R\nC L\nA L\nN L\nE R\nZ L\nS L\n\nSample Output 3\n\n3", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 3317, "cpu_time_ms": 1422, "memory_kb": 34740}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s893414491", "group_id": "codeNet:p03081", "input_text": "-- C\nlocal DBG = true\nlocal function dbgpr(...)\n if DBG then\n io.write(\"[dbg]\")\n print(...)\n end\nend\n\nlocal function dbgpr_t(tbl, use_pairs)\n if DBG then\n local enum = ipairs\n if use_pairs then\n enum = pairs\n end\n dbgpr(tbl)\n io.write(\"[dbg]\")\n for i,v in enum(tbl) do\n io.write(i)\n io.write(\":\")\n io.write(tostring(v))\n io.write(\" \")\n end\n print(\"\")\n end\nend\n\nlocal function dbgpr_tp(tbl)\n dbgpr_t(tbl, true)\nend\n\nlocal function str2tbl(s)\n local t = {string.byte(s, 1, #s)}\n for i=1, #t do\n t[i] = string.char(t[i])\n end\n return t\nend\n\nlocal function each_char(s)\n local f = function(_, i)\n i = i + 1\n if i <= #s then\n return i, string.sub(s, i, i)\n end\n end\n return f, nil, 0\nend\nlocal N, Q, _ = io.read(\"n\", \"n\", \"l\")\nlocal s = io.read(\"l\")\nassert(#s == N)\nlocal spells = {}\nfor i=1,Q do\n local t, _, d, _ = io.read(1, 1, 1, \"l\")\n spells[i] = {t, d}\nend\n\nlocal place = str2tbl(s)\n\nlocal paths = {}\n\nlocal function new_path(pos)\n local p = {pos, 1}\n return p\nend\nlocal function push_path(p)\n table.insert(paths, p)\nend\n\nlocal death = {}\nfor i=1,N do\n death[i] = false\nend\n\nfor i=Q,1,-1 do\n local t, d = spells[i][1], spells[i][2]\n local flag = true\n if d == 'L' then\n if t == place[1] and not left then\n local p = new_path(1)\n push_path(p)\n death[1] = true\n flag = false\n left = true\n end\n else\n if t == place[N] and not right then\n local p = new_path(N)\n push_path(p)\n death[N] = true\n flag = false\n right = true\n end\n end\n if flag then\n for _,p in ipairs(paths) do\n local pos, count = p[1], p[2]\n if d == 'L' then\n if t == place[pos+1] then\n p[1], p[2] = pos+1, count+1\n death[pos+1] = true\n end\n else\n if t == place[pos-1] then\n p[1], p[2] = pos-1, count+1\n death[pos-1] = true\n end\n end\n end\n end\nend\nlocal dead = 0\nfor i=1,N do\n if death[i] then\n dead = dead + 1\n end\nend\nprint(N - dead)", "language": "Lua", "metadata": {"date": 1553983618, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03081.html", "problem_id": "p03081", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03081/input.txt", "sample_output_relpath": "derived/input_output/data/p03081/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03081/Lua/s893414491.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s893414491", "user_id": "u162773977"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "-- C\nlocal DBG = true\nlocal function dbgpr(...)\n if DBG then\n io.write(\"[dbg]\")\n print(...)\n end\nend\n\nlocal function dbgpr_t(tbl, use_pairs)\n if DBG then\n local enum = ipairs\n if use_pairs then\n enum = pairs\n end\n dbgpr(tbl)\n io.write(\"[dbg]\")\n for i,v in enum(tbl) do\n io.write(i)\n io.write(\":\")\n io.write(tostring(v))\n io.write(\" \")\n end\n print(\"\")\n end\nend\n\nlocal function dbgpr_tp(tbl)\n dbgpr_t(tbl, true)\nend\n\nlocal function str2tbl(s)\n local t = {string.byte(s, 1, #s)}\n for i=1, #t do\n t[i] = string.char(t[i])\n end\n return t\nend\n\nlocal function each_char(s)\n local f = function(_, i)\n i = i + 1\n if i <= #s then\n return i, string.sub(s, i, i)\n end\n end\n return f, nil, 0\nend\nlocal N, Q, _ = io.read(\"n\", \"n\", \"l\")\nlocal s = io.read(\"l\")\nassert(#s == N)\nlocal spells = {}\nfor i=1,Q do\n local t, _, d, _ = io.read(1, 1, 1, \"l\")\n spells[i] = {t, d}\nend\n\nlocal place = str2tbl(s)\n\nlocal paths = {}\n\nlocal function new_path(pos)\n local p = {pos, 1}\n return p\nend\nlocal function push_path(p)\n table.insert(paths, p)\nend\n\nlocal death = {}\nfor i=1,N do\n death[i] = false\nend\n\nfor i=Q,1,-1 do\n local t, d = spells[i][1], spells[i][2]\n local flag = true\n if d == 'L' then\n if t == place[1] and not left then\n local p = new_path(1)\n push_path(p)\n death[1] = true\n flag = false\n left = true\n end\n else\n if t == place[N] and not right then\n local p = new_path(N)\n push_path(p)\n death[N] = true\n flag = false\n right = true\n end\n end\n if flag then\n for _,p in ipairs(paths) do\n local pos, count = p[1], p[2]\n if d == 'L' then\n if t == place[pos+1] then\n p[1], p[2] = pos+1, count+1\n death[pos+1] = true\n end\n else\n if t == place[pos-1] then\n p[1], p[2] = pos-1, count+1\n death[pos-1] = true\n end\n end\n end\n end\nend\nlocal dead = 0\nfor i=1,N do\n if death[i] then\n dead = dead + 1\n end\nend\nprint(N - dead)", "problem_context": "Score : 500 points\n\nProblem Statement\n\nThere are N squares numbered 1 to N from left to right.\nEach square has a character written on it, and Square i has a letter s_i. Besides, there is initially one golem on each square.\n\nSnuke cast Q spells to move the golems.\n\nThe i-th spell consisted of two characters t_i and d_i, where d_i is L or R.\nWhen Snuke cast this spell, for each square with the character t_i, all golems on that square moved to the square adjacent to the left if d_i is L, and moved to the square adjacent to the right if d_i is R.\n\nHowever, when a golem tried to move left from Square 1 or move right from Square N, it disappeared.\n\nFind the number of golems remaining after Snuke cast the Q spells.\n\nConstraints\n\n1 \\leq N,Q \\leq 2 \\times 10^{5}\n\n|s| = N\n\ns_i and t_i are uppercase English letters.\n\nd_i is L or R.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN Q\ns\nt_1 d_1\n\\vdots\nt_{Q} d_Q\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n3 4\nABC\nA L\nB L\nB R\nA R\n\nSample Output 1\n\n2\n\nInitially, there is one golem on each square.\n\nIn the first spell, the golem on Square 1 tries to move left and disappears.\n\nIn the second spell, the golem on Square 2 moves left.\n\nIn the third spell, no golem moves.\n\nIn the fourth spell, the golem on Square 1 moves right.\n\nAfter the four spells are cast, there is one golem on Square 2 and one golem on Square 3, for a total of two golems remaining.\n\nSample Input 2\n\n8 3\nAABCBDBA\nA L\nB R\nA R\n\nSample Output 2\n\n5\n\nAfter the three spells are cast, there is one golem on Square 2, two golems on Square 4 and two golems on Square 6, for a total of five golems remaining.\n\nNote that a single spell may move multiple golems.\n\nSample Input 3\n\n10 15\nSNCZWRCEWB\nB R\nR R\nE R\nW R\nZ L\nS R\nQ L\nW L\nB R\nC L\nA L\nN L\nE R\nZ L\nS L\n\nSample Output 3\n\n3", "sample_input": "3 4\nABC\nA L\nB L\nB R\nA R\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03081", "source_text": "Score : 500 points\n\nProblem Statement\n\nThere are N squares numbered 1 to N from left to right.\nEach square has a character written on it, and Square i has a letter s_i. Besides, there is initially one golem on each square.\n\nSnuke cast Q spells to move the golems.\n\nThe i-th spell consisted of two characters t_i and d_i, where d_i is L or R.\nWhen Snuke cast this spell, for each square with the character t_i, all golems on that square moved to the square adjacent to the left if d_i is L, and moved to the square adjacent to the right if d_i is R.\n\nHowever, when a golem tried to move left from Square 1 or move right from Square N, it disappeared.\n\nFind the number of golems remaining after Snuke cast the Q spells.\n\nConstraints\n\n1 \\leq N,Q \\leq 2 \\times 10^{5}\n\n|s| = N\n\ns_i and t_i are uppercase English letters.\n\nd_i is L or R.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN Q\ns\nt_1 d_1\n\\vdots\nt_{Q} d_Q\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n3 4\nABC\nA L\nB L\nB R\nA R\n\nSample Output 1\n\n2\n\nInitially, there is one golem on each square.\n\nIn the first spell, the golem on Square 1 tries to move left and disappears.\n\nIn the second spell, the golem on Square 2 moves left.\n\nIn the third spell, no golem moves.\n\nIn the fourth spell, the golem on Square 1 moves right.\n\nAfter the four spells are cast, there is one golem on Square 2 and one golem on Square 3, for a total of two golems remaining.\n\nSample Input 2\n\n8 3\nAABCBDBA\nA L\nB R\nA R\n\nSample Output 2\n\n5\n\nAfter the three spells are cast, there is one golem on Square 2, two golems on Square 4 and two golems on Square 6, for a total of five golems remaining.\n\nNote that a single spell may move multiple golems.\n\nSample Input 3\n\n10 15\nSNCZWRCEWB\nB R\nR R\nE R\nW R\nZ L\nS R\nQ L\nW L\nB R\nC L\nA L\nN L\nE R\nZ L\nS L\n\nSample Output 3\n\n3", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2379, "cpu_time_ms": 296, "memory_kb": 37044}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s868294649", "group_id": "codeNet:p03082", "input_text": "local mod = 1000000007\nlocal mfl = math.floor\n\nlocal function bmul(x, y)\n local x1, y1 = mfl(x / 31623), mfl(y / 31623)\n local x0, y0 = x - x1 * 31623, y - y1 * 31623\n return (x1 * y1 * 14122 + (x1 * y0 + x0 * y1) * 31623 + x0 * y0) % mod\nend\n\nlocal function badd(x, y)\n return (x + y) % mod\nend\n\nlocal function bsub(x, y)\n return x < y and x - y + mod or x - y\nend\n\nlocal function modpow(src, pow)\n local res = 1\n while 0 < pow do\n if pow % 2 == 1 then\n res = bmul(res, src)\n pow = pow - 1\n end\n src = bmul(src, src)\n pow = mfl(pow / 2)\n end\n return res\nend\n\nlocal function modinv(src)\n return modpow(src, mod - 2)\nend\n\n\nlocal fact = {1}\nlocal invs = {1}\nlocal invfact = {1}\nfor i = 2, 100010 do\n fact[i] = bmul(fact[i - 1], i)\n invs[i] = bmul(mfl(mod / i), mod - invs[mod % i])\n invfact[i] = bmul(invfact[i - 1], invs[i])\nend\n\nlocal function getPerm(n, k)\n if n == 0 then return 1 end\n if k == n then return fact[n] end\n return bmul(fact[n], invfact[n - k])\nend\n\nlocal function comp(a, b)\n return a < b\nend\n\nlocal function lower_bound(ary, x)\n local num = #ary\n if num == 0 then return 1 end\n if not comp(ary[1], x) then return 1 end\n if comp(ary[num], x) then return num + 1 end\n local min, max = 1, num\n while 1 < max - min do\n local mid = mfl((min + max) / 2)\n if comp(ary[mid], x) then\n min = mid\n else\n max = mid\n end\n end\n return max\nend\n\nlocal function upper_bound(ary, x)\n local num = #ary\n if num == 0 then return 1 end\n if comp(x, ary[1]) then return 1 end\n if not comp(x, ary[num]) then return num + 1 end\n local min, max = 1, num\n while 1 < max - min do\n local mid = mfl((min + max) / 2)\n if not comp(x, ary[mid]) then\n min = mid\n else\n max = mid\n end\n end\n return max\nend\n\nlocal n, x = io.read(\"*n\", \"*n\")\nlocal s = {}\nlocal tbl = {}\nfor i = 1, n do\n s[i] = io.read(\"*n\")\n tbl[i] = {}\nend\ntable.sort(s)\nfor i = n, 1, -1 do\n local rem = x % s[i]\n if 0 < rem then\n tbl[i][rem] = getPerm(n - 1, n - i)\n end\nend\nlocal ret = 0\nfor src = n, 2, -1 do\n for val, cnt in pairs(tbl[src]) do\n local ub = upper_bound(s, val)\n if ub == 1 then\n ret = badd(ret, bmul(val, bmul(fact[src - 1], cnt)))\n else\n local skipfact = getPerm(src - 1, src - ub)\n cnt = bmul(cnt, skipfact)\n for dst = ub - 1, 1, -1 do\n local vc = bmul(cnt, getPerm(ub - 2, ub - 1 - dst))\n local rem = val % s[dst]\n if 0 < rem then\n if tbl[dst][rem] then\n tbl[dst][rem] = badd(tbl[dst][rem], vc)\n else\n tbl[dst][rem] = vc\n end\n end\n end\n end\n end\nend\nfor val, cnt in pairs(tbl[1]) do\n ret = badd(ret, bmul(val, cnt))\nend\nprint(ret)\n", "language": "Lua", "metadata": {"date": 1598566534, "filename_ext": "lua", "original_language": "Lua (LuaJIT 2.1.0)", "problem_description_relpath": "problem_descriptions/p03082.html", "problem_id": "p03082", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03082/input.txt", "sample_output_relpath": "derived/input_output/data/p03082/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03082/Lua/s868294649.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s868294649", "user_id": "u120582723"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "local mod = 1000000007\nlocal mfl = math.floor\n\nlocal function bmul(x, y)\n local x1, y1 = mfl(x / 31623), mfl(y / 31623)\n local x0, y0 = x - x1 * 31623, y - y1 * 31623\n return (x1 * y1 * 14122 + (x1 * y0 + x0 * y1) * 31623 + x0 * y0) % mod\nend\n\nlocal function badd(x, y)\n return (x + y) % mod\nend\n\nlocal function bsub(x, y)\n return x < y and x - y + mod or x - y\nend\n\nlocal function modpow(src, pow)\n local res = 1\n while 0 < pow do\n if pow % 2 == 1 then\n res = bmul(res, src)\n pow = pow - 1\n end\n src = bmul(src, src)\n pow = mfl(pow / 2)\n end\n return res\nend\n\nlocal function modinv(src)\n return modpow(src, mod - 2)\nend\n\n\nlocal fact = {1}\nlocal invs = {1}\nlocal invfact = {1}\nfor i = 2, 100010 do\n fact[i] = bmul(fact[i - 1], i)\n invs[i] = bmul(mfl(mod / i), mod - invs[mod % i])\n invfact[i] = bmul(invfact[i - 1], invs[i])\nend\n\nlocal function getPerm(n, k)\n if n == 0 then return 1 end\n if k == n then return fact[n] end\n return bmul(fact[n], invfact[n - k])\nend\n\nlocal function comp(a, b)\n return a < b\nend\n\nlocal function lower_bound(ary, x)\n local num = #ary\n if num == 0 then return 1 end\n if not comp(ary[1], x) then return 1 end\n if comp(ary[num], x) then return num + 1 end\n local min, max = 1, num\n while 1 < max - min do\n local mid = mfl((min + max) / 2)\n if comp(ary[mid], x) then\n min = mid\n else\n max = mid\n end\n end\n return max\nend\n\nlocal function upper_bound(ary, x)\n local num = #ary\n if num == 0 then return 1 end\n if comp(x, ary[1]) then return 1 end\n if not comp(x, ary[num]) then return num + 1 end\n local min, max = 1, num\n while 1 < max - min do\n local mid = mfl((min + max) / 2)\n if not comp(x, ary[mid]) then\n min = mid\n else\n max = mid\n end\n end\n return max\nend\n\nlocal n, x = io.read(\"*n\", \"*n\")\nlocal s = {}\nlocal tbl = {}\nfor i = 1, n do\n s[i] = io.read(\"*n\")\n tbl[i] = {}\nend\ntable.sort(s)\nfor i = n, 1, -1 do\n local rem = x % s[i]\n if 0 < rem then\n tbl[i][rem] = getPerm(n - 1, n - i)\n end\nend\nlocal ret = 0\nfor src = n, 2, -1 do\n for val, cnt in pairs(tbl[src]) do\n local ub = upper_bound(s, val)\n if ub == 1 then\n ret = badd(ret, bmul(val, bmul(fact[src - 1], cnt)))\n else\n local skipfact = getPerm(src - 1, src - ub)\n cnt = bmul(cnt, skipfact)\n for dst = ub - 1, 1, -1 do\n local vc = bmul(cnt, getPerm(ub - 2, ub - 1 - dst))\n local rem = val % s[dst]\n if 0 < rem then\n if tbl[dst][rem] then\n tbl[dst][rem] = badd(tbl[dst][rem], vc)\n else\n tbl[dst][rem] = vc\n end\n end\n end\n end\n end\nend\nfor val, cnt in pairs(tbl[1]) do\n ret = badd(ret, bmul(val, cnt))\nend\nprint(ret)\n", "problem_context": "Score : 600 points\n\nProblem Statement\n\nSnuke has a blackboard and a set S consisting of N integers.\nThe i-th element in S is S_i.\n\nHe wrote an integer X on the blackboard, then performed the following operation N times:\n\nChoose one element from S and remove it.\n\nLet 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 \\bmod {y}.\n\nThere are N! possible orders in which the elements are removed from S.\nFor 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\nAll values in input are integers.\n\n1 \\leq N \\leq 200\n\n1 \\leq S_i, X \\leq 10^{5}\n\nS_i are pairwise distinct.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN X\nS_1 S_2 \\ldots S_{N}\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n2 19\n3 7\n\nSample Output 1\n\n3\n\nThere are two possible orders in which we remove the numbers from S.\n\nIf we remove 3 and 7 in this order, the number on the blackboard changes as follows: 19 \\rightarrow 1 \\rightarrow 1.\n\nIf we remove 7 and 3 in this order, the number on the blackboard changes as follows: 19 \\rightarrow 5 \\rightarrow 2.\n\nThe output should be the sum of these: 3.\n\nSample Input 2\n\n5 82\n22 11 6 5 13\n\nSample Output 2\n\n288\n\nSample Input 3\n\n10 100000\n50000 50001 50002 50003 50004 50005 50006 50007 50008 50009\n\nSample Output 3\n\n279669259\n\nBe sure to compute the sum modulo 10^{9}+7.", "sample_input": "2 19\n3 7\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03082", "source_text": "Score : 600 points\n\nProblem Statement\n\nSnuke has a blackboard and a set S consisting of N integers.\nThe i-th element in S is S_i.\n\nHe wrote an integer X on the blackboard, then performed the following operation N times:\n\nChoose one element from S and remove it.\n\nLet 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 \\bmod {y}.\n\nThere are N! possible orders in which the elements are removed from S.\nFor 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\nAll values in input are integers.\n\n1 \\leq N \\leq 200\n\n1 \\leq S_i, X \\leq 10^{5}\n\nS_i are pairwise distinct.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN X\nS_1 S_2 \\ldots S_{N}\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n2 19\n3 7\n\nSample Output 1\n\n3\n\nThere are two possible orders in which we remove the numbers from S.\n\nIf we remove 3 and 7 in this order, the number on the blackboard changes as follows: 19 \\rightarrow 1 \\rightarrow 1.\n\nIf we remove 7 and 3 in this order, the number on the blackboard changes as follows: 19 \\rightarrow 5 \\rightarrow 2.\n\nThe output should be the sum of these: 3.\n\nSample Input 2\n\n5 82\n22 11 6 5 13\n\nSample Output 2\n\n288\n\nSample Input 3\n\n10 100000\n50000 50001 50002 50003 50004 50005 50006 50007 50008 50009\n\nSample Output 3\n\n279669259\n\nBe sure to compute the sum modulo 10^{9}+7.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2724, "cpu_time_ms": 345, "memory_kb": 9712}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s835512470", "group_id": "codeNet:p03082", "input_text": "local mod = 1000000007\nlocal mfl = math.floor\nlocal mmi = math.min\n\nlocal function bmul(x, y)\n local x0, y0 = x % 31623, y % 31623\n local x1, y1 = mfl(x / 31623), mfl(y / 31623)\n return (x1 * y1 * 14122 + (x1 * y0 + x0 * y1) * 31623 + x0 * y0) % mod\nend\nlocal function badd(x, y)\n return (x + y) % mod\nend\n\nlocal function modpow(src, pow)\n local res = 1\n while 0 < pow do\n if pow % 2 == 1 then\n res = bmul(res, src)\n pow = pow - 1\n end\n src = bmul(src, src)\n pow = mfl(pow / 2)\n end\n return res\nend\n\nlocal function modinv(src)\n return modpow(src, mod - 2)\nend\n\nlocal n, x = io.read(\"*n\", \"*n\")\nlocal fact = {1}\nfor i = 2, 200 do\n fact[i] = bmul(fact[i - 1], i)\nend\nlocal combfact = {}\nfor i = 1, 200 do\n combfact[i] = {}\n local c = 1\n for j = 1, i do\n c = bmul(c, i + 1 - j)\n c = bmul(c, modinv(j))\n combfact[i][j] = bmul(c, fact[j])\n end\nend\nlocal function getCombFact(n, k)\n if n == 0 then return 1 end\n if k == 0 then return 1 end\n return combfact[n][k]\nend\n\nlocal a = {}\nfor i = 1, n do\n a[i] = io.read(\"*n\")\nend\ntable.sort(a)\nlocal t = {}\nfor i = 1, n do\n t[i] = {}\nend\nfor i = 1, n - 1 do\n t[i][x % a[i]] = getCombFact(n - 1, n - i)\nend\nt[n][x % a[n]] = 1\n\nfor src = n, 1, -1 do\n for val, cnt in pairs(t[src]) do\n for dst = src - 1, 1, -1 do\n local k = cnt\n local nval = val % a[dst]\n local step = src - dst - 1\n k = bmul(k, getCombFact(src - 2, step))\n local precnt = t[dst][nval]\n if precnt then\n t[dst][nval] = badd(precnt, k)\n else\n t[dst][nval] = k\n end\n end\n end\nend\nlocal ret = 0\nfor k, v in pairs(t[1]) do\n ret = badd(ret, bmul(k, v))\nend\nprint(ret)\n", "language": "Lua", "metadata": {"date": 1582047310, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p03082.html", "problem_id": "p03082", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03082/input.txt", "sample_output_relpath": "derived/input_output/data/p03082/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03082/Lua/s835512470.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s835512470", "user_id": "u120582723"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "local mod = 1000000007\nlocal mfl = math.floor\nlocal mmi = math.min\n\nlocal function bmul(x, y)\n local x0, y0 = x % 31623, y % 31623\n local x1, y1 = mfl(x / 31623), mfl(y / 31623)\n return (x1 * y1 * 14122 + (x1 * y0 + x0 * y1) * 31623 + x0 * y0) % mod\nend\nlocal function badd(x, y)\n return (x + y) % mod\nend\n\nlocal function modpow(src, pow)\n local res = 1\n while 0 < pow do\n if pow % 2 == 1 then\n res = bmul(res, src)\n pow = pow - 1\n end\n src = bmul(src, src)\n pow = mfl(pow / 2)\n end\n return res\nend\n\nlocal function modinv(src)\n return modpow(src, mod - 2)\nend\n\nlocal n, x = io.read(\"*n\", \"*n\")\nlocal fact = {1}\nfor i = 2, 200 do\n fact[i] = bmul(fact[i - 1], i)\nend\nlocal combfact = {}\nfor i = 1, 200 do\n combfact[i] = {}\n local c = 1\n for j = 1, i do\n c = bmul(c, i + 1 - j)\n c = bmul(c, modinv(j))\n combfact[i][j] = bmul(c, fact[j])\n end\nend\nlocal function getCombFact(n, k)\n if n == 0 then return 1 end\n if k == 0 then return 1 end\n return combfact[n][k]\nend\n\nlocal a = {}\nfor i = 1, n do\n a[i] = io.read(\"*n\")\nend\ntable.sort(a)\nlocal t = {}\nfor i = 1, n do\n t[i] = {}\nend\nfor i = 1, n - 1 do\n t[i][x % a[i]] = getCombFact(n - 1, n - i)\nend\nt[n][x % a[n]] = 1\n\nfor src = n, 1, -1 do\n for val, cnt in pairs(t[src]) do\n for dst = src - 1, 1, -1 do\n local k = cnt\n local nval = val % a[dst]\n local step = src - dst - 1\n k = bmul(k, getCombFact(src - 2, step))\n local precnt = t[dst][nval]\n if precnt then\n t[dst][nval] = badd(precnt, k)\n else\n t[dst][nval] = k\n end\n end\n end\nend\nlocal ret = 0\nfor k, v in pairs(t[1]) do\n ret = badd(ret, bmul(k, v))\nend\nprint(ret)\n", "problem_context": "Score : 600 points\n\nProblem Statement\n\nSnuke has a blackboard and a set S consisting of N integers.\nThe i-th element in S is S_i.\n\nHe wrote an integer X on the blackboard, then performed the following operation N times:\n\nChoose one element from S and remove it.\n\nLet 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 \\bmod {y}.\n\nThere are N! possible orders in which the elements are removed from S.\nFor 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\nAll values in input are integers.\n\n1 \\leq N \\leq 200\n\n1 \\leq S_i, X \\leq 10^{5}\n\nS_i are pairwise distinct.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN X\nS_1 S_2 \\ldots S_{N}\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n2 19\n3 7\n\nSample Output 1\n\n3\n\nThere are two possible orders in which we remove the numbers from S.\n\nIf we remove 3 and 7 in this order, the number on the blackboard changes as follows: 19 \\rightarrow 1 \\rightarrow 1.\n\nIf we remove 7 and 3 in this order, the number on the blackboard changes as follows: 19 \\rightarrow 5 \\rightarrow 2.\n\nThe output should be the sum of these: 3.\n\nSample Input 2\n\n5 82\n22 11 6 5 13\n\nSample Output 2\n\n288\n\nSample Input 3\n\n10 100000\n50000 50001 50002 50003 50004 50005 50006 50007 50008 50009\n\nSample Output 3\n\n279669259\n\nBe sure to compute the sum modulo 10^{9}+7.", "sample_input": "2 19\n3 7\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03082", "source_text": "Score : 600 points\n\nProblem Statement\n\nSnuke has a blackboard and a set S consisting of N integers.\nThe i-th element in S is S_i.\n\nHe wrote an integer X on the blackboard, then performed the following operation N times:\n\nChoose one element from S and remove it.\n\nLet 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 \\bmod {y}.\n\nThere are N! possible orders in which the elements are removed from S.\nFor 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\nAll values in input are integers.\n\n1 \\leq N \\leq 200\n\n1 \\leq S_i, X \\leq 10^{5}\n\nS_i are pairwise distinct.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN X\nS_1 S_2 \\ldots S_{N}\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n2 19\n3 7\n\nSample Output 1\n\n3\n\nThere are two possible orders in which we remove the numbers from S.\n\nIf we remove 3 and 7 in this order, the number on the blackboard changes as follows: 19 \\rightarrow 1 \\rightarrow 1.\n\nIf we remove 7 and 3 in this order, the number on the blackboard changes as follows: 19 \\rightarrow 5 \\rightarrow 2.\n\nThe output should be the sum of these: 3.\n\nSample Input 2\n\n5 82\n22 11 6 5 13\n\nSample Output 2\n\n288\n\nSample Input 3\n\n10 100000\n50000 50001 50002 50003 50004 50005 50006 50007 50008 50009\n\nSample Output 3\n\n279669259\n\nBe sure to compute the sum modulo 10^{9}+7.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1678, "cpu_time_ms": 2104, "memory_kb": 15872}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s240152080", "group_id": "codeNet:p03085", "input_text": "s = io.read()\nif(s == \"A\") then print(\"T\") elseif(s == \"T\") then print (\"A\") elseif(s == \"G\") then print(\"C\") else print(\"G\") end", "language": "Lua", "metadata": {"date": 1553975608, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03085.html", "problem_id": "p03085", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03085/input.txt", "sample_output_relpath": "derived/input_output/data/p03085/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03085/Lua/s240152080.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s240152080", "user_id": "u120582723"}, "prompt_components": {"gold_output": "T\n", "input_to_evaluate": "s = io.read()\nif(s == \"A\") then print(\"T\") elseif(s == \"T\") then print (\"A\") elseif(s == \"G\") then print(\"C\") else print(\"G\") end", "problem_context": "Score : 100 points\n\nProblem Statement\n\nOn the Planet AtCoder, there are four types of bases: A, C, G and T. A bonds with T, and C bonds with G.\n\nYou are given a letter b as input, which is A, C, G or T. Write a program that prints the letter representing the base that bonds with the base b.\n\nConstraints\n\nb is one of the letters A, C, G and T.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nb\n\nOutput\n\nPrint the letter representing the base that bonds with the base b.\n\nSample Input 1\n\nA\n\nSample Output 1\n\nT\n\nSample Input 2\n\nG\n\nSample Output 2\n\nC", "sample_input": "A\n"}, "reference_outputs": ["T\n"], "source_document_id": "p03085", "source_text": "Score : 100 points\n\nProblem Statement\n\nOn the Planet AtCoder, there are four types of bases: A, C, G and T. A bonds with T, and C bonds with G.\n\nYou are given a letter b as input, which is A, C, G or T. Write a program that prints the letter representing the base that bonds with the base b.\n\nConstraints\n\nb is one of the letters A, C, G and T.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nb\n\nOutput\n\nPrint the letter representing the base that bonds with the base b.\n\nSample Input 1\n\nA\n\nSample Output 1\n\nT\n\nSample Input 2\n\nG\n\nSample Output 2\n\nC", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 129, "cpu_time_ms": 75, "memory_kb": 1008}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s455322251", "group_id": "codeNet:p03086", "input_text": "local S = io.read()..\"X\"\n\nlocal length = 0\nlocal counter = 0\n\nfor i = 1, #S do\n local PS = string.sub(S,i,i)\n if PS == \"A\" or PS == \"C\" or PS == \"G\" or PS == \"T\" then\n counter = counter + 1\n else\n length = math.max(counter, length)\n counter = 0\n end\nend\n\nprint(length)", "language": "Lua", "metadata": {"date": 1586891560, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03086.html", "problem_id": "p03086", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03086/input.txt", "sample_output_relpath": "derived/input_output/data/p03086/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03086/Lua/s455322251.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s455322251", "user_id": "u045238009"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "local S = io.read()..\"X\"\n\nlocal length = 0\nlocal counter = 0\n\nfor i = 1, #S do\n local PS = string.sub(S,i,i)\n if PS == \"A\" or PS == \"C\" or PS == \"G\" or PS == \"T\" then\n counter = counter + 1\n else\n length = math.max(counter, length)\n counter = 0\n end\nend\n\nprint(length)", "problem_context": "Score : 200 points\n\nProblem Statement\n\nYou are given a string S consisting of uppercase English letters. Find the length of the longest ACGT string that is a substring (see Notes) of S.\n\nHere, a ACGT string is a string that contains no characters other than A, C, G and T.\n\nNotes\n\nA substring of a string T is a string obtained by removing zero or more characters from the beginning and the end of T.\n\nFor example, the substrings of ATCODER include TCO, AT, CODER, ATCODER and (the empty string), but not AC.\n\nConstraints\n\nS is a string of length between 1 and 10 (inclusive).\n\nEach character in S is an uppercase English letter.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the length of the longest ACGT string that is a substring of S.\n\nSample Input 1\n\nATCODER\n\nSample Output 1\n\n3\n\nAmong the ACGT strings that are substrings of ATCODER, the longest one is ATC.\n\nSample Input 2\n\nHATAGAYA\n\nSample Output 2\n\n5\n\nAmong the ACGT strings that are substrings of HATAGAYA, the longest one is ATAGA.\n\nSample Input 3\n\nSHINJUKU\n\nSample Output 3\n\n0\n\nAmong the ACGT strings that are substrings of SHINJUKU, the longest one is (the empty string).", "sample_input": "ATCODER\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03086", "source_text": "Score : 200 points\n\nProblem Statement\n\nYou are given a string S consisting of uppercase English letters. Find the length of the longest ACGT string that is a substring (see Notes) of S.\n\nHere, a ACGT string is a string that contains no characters other than A, C, G and T.\n\nNotes\n\nA substring of a string T is a string obtained by removing zero or more characters from the beginning and the end of T.\n\nFor example, the substrings of ATCODER include TCO, AT, CODER, ATCODER and (the empty string), but not AC.\n\nConstraints\n\nS is a string of length between 1 and 10 (inclusive).\n\nEach character in S is an uppercase English letter.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the length of the longest ACGT string that is a substring of S.\n\nSample Input 1\n\nATCODER\n\nSample Output 1\n\n3\n\nAmong the ACGT strings that are substrings of ATCODER, the longest one is ATC.\n\nSample Input 2\n\nHATAGAYA\n\nSample Output 2\n\n5\n\nAmong the ACGT strings that are substrings of HATAGAYA, the longest one is ATAGA.\n\nSample Input 3\n\nSHINJUKU\n\nSample Output 3\n\n0\n\nAmong the ACGT strings that are substrings of SHINJUKU, the longest one is (the empty string).", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 301, "cpu_time_ms": 7, "memory_kb": 884}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s246793345", "group_id": "codeNet:p03087", "input_text": "local n,q=io.read(\"n\",\"n\",\"l\")\nlocal s=io.read()\nlocal t={0}\nfor i=1,n-1 do\n t[i+1]=t[i]+(s:sub(i,i+1)==\"AC\" and 1 or 0)\nend\nfor i=1,q do\n local l,r=io.read(\"n\",\"n\")\n print(t[r]-t[l])\nend", "language": "Lua", "metadata": {"date": 1590821438, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03087.html", "problem_id": "p03087", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03087/input.txt", "sample_output_relpath": "derived/input_output/data/p03087/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03087/Lua/s246793345.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s246793345", "user_id": "u045238009"}, "prompt_components": {"gold_output": "2\n0\n3\n", "input_to_evaluate": "local n,q=io.read(\"n\",\"n\",\"l\")\nlocal s=io.read()\nlocal t={0}\nfor i=1,n-1 do\n t[i+1]=t[i]+(s:sub(i,i+1)==\"AC\" and 1 or 0)\nend\nfor i=1,q do\n local l,r=io.read(\"n\",\"n\")\n print(t[r]-t[l])\nend", "problem_context": "Score : 300 points\n\nProblem Statement\n\nYou are given a string S of length N consisting of A, C, G and T. Answer the following Q queries:\n\nQuery i (1 \\leq i \\leq Q): You will be given integers l_i and r_i (1 \\leq l_i < r_i \\leq N). Consider the substring of S starting at index l_i and ending at index r_i (both inclusive). In this string, how many times does AC occurs as a substring?\n\nNotes\n\nA substring of a string T is a string obtained by removing zero or more characters from the beginning and the end of T.\n\nFor example, the substrings of ATCODER include TCO, AT, CODER, ATCODER and (the empty string), but not AC.\n\nConstraints\n\n2 \\leq N \\leq 10^5\n\n1 \\leq Q \\leq 10^5\n\nS is a string of length N.\n\nEach character in S is A, C, G or T.\n\n1 \\leq l_i < r_i \\leq N\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN Q\nS\nl_1 r_1\n:\nl_Q r_Q\n\nOutput\n\nPrint Q lines. The i-th line should contain the answer to the i-th query.\n\nSample Input 1\n\n8 3\nACACTACG\n3 7\n2 3\n1 8\n\nSample Output 1\n\n2\n0\n3\n\nQuery 1: the substring of S starting at index 3 and ending at index 7 is ACTAC. In this string, AC occurs twice as a substring.\n\nQuery 2: the substring of S starting at index 2 and ending at index 3 is CA. In this string, AC occurs zero times as a substring.\n\nQuery 3: the substring of S starting at index 1 and ending at index 8 is ACACTACG. In this string, AC occurs three times as a substring.", "sample_input": "8 3\nACACTACG\n3 7\n2 3\n1 8\n"}, "reference_outputs": ["2\n0\n3\n"], "source_document_id": "p03087", "source_text": "Score : 300 points\n\nProblem Statement\n\nYou are given a string S of length N consisting of A, C, G and T. Answer the following Q queries:\n\nQuery i (1 \\leq i \\leq Q): You will be given integers l_i and r_i (1 \\leq l_i < r_i \\leq N). Consider the substring of S starting at index l_i and ending at index r_i (both inclusive). In this string, how many times does AC occurs as a substring?\n\nNotes\n\nA substring of a string T is a string obtained by removing zero or more characters from the beginning and the end of T.\n\nFor example, the substrings of ATCODER include TCO, AT, CODER, ATCODER and (the empty string), but not AC.\n\nConstraints\n\n2 \\leq N \\leq 10^5\n\n1 \\leq Q \\leq 10^5\n\nS is a string of length N.\n\nEach character in S is A, C, G or T.\n\n1 \\leq l_i < r_i \\leq N\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN Q\nS\nl_1 r_1\n:\nl_Q r_Q\n\nOutput\n\nPrint Q lines. The i-th line should contain the answer to the i-th query.\n\nSample Input 1\n\n8 3\nACACTACG\n3 7\n2 3\n1 8\n\nSample Output 1\n\n2\n0\n3\n\nQuery 1: the substring of S starting at index 3 and ending at index 7 is ACTAC. In this string, AC occurs twice as a substring.\n\nQuery 2: the substring of S starting at index 2 and ending at index 3 is CA. In this string, AC occurs zero times as a substring.\n\nQuery 3: the substring of S starting at index 1 and ending at index 8 is ACACTACG. In this string, AC occurs three times as a substring.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 196, "cpu_time_ms": 333, "memory_kb": 5012}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s242998898", "group_id": "codeNet:p03087", "input_text": "n,q=io.read():match(\"(.+)%s(.+)\")\ns=io.read()\nfor i=1,q do\n l,r=io.read():match(\"(.+)%s(.+)\")\n x,y=s:sub(l,r):gsub(\"AC\",\"\")\n print(y)\nend", "language": "Lua", "metadata": {"date": 1553458269, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03087.html", "problem_id": "p03087", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03087/input.txt", "sample_output_relpath": "derived/input_output/data/p03087/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03087/Lua/s242998898.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s242998898", "user_id": "u837412668"}, "prompt_components": {"gold_output": "2\n0\n3\n", "input_to_evaluate": "n,q=io.read():match(\"(.+)%s(.+)\")\ns=io.read()\nfor i=1,q do\n l,r=io.read():match(\"(.+)%s(.+)\")\n x,y=s:sub(l,r):gsub(\"AC\",\"\")\n print(y)\nend", "problem_context": "Score : 300 points\n\nProblem Statement\n\nYou are given a string S of length N consisting of A, C, G and T. Answer the following Q queries:\n\nQuery i (1 \\leq i \\leq Q): You will be given integers l_i and r_i (1 \\leq l_i < r_i \\leq N). Consider the substring of S starting at index l_i and ending at index r_i (both inclusive). In this string, how many times does AC occurs as a substring?\n\nNotes\n\nA substring of a string T is a string obtained by removing zero or more characters from the beginning and the end of T.\n\nFor example, the substrings of ATCODER include TCO, AT, CODER, ATCODER and (the empty string), but not AC.\n\nConstraints\n\n2 \\leq N \\leq 10^5\n\n1 \\leq Q \\leq 10^5\n\nS is a string of length N.\n\nEach character in S is A, C, G or T.\n\n1 \\leq l_i < r_i \\leq N\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN Q\nS\nl_1 r_1\n:\nl_Q r_Q\n\nOutput\n\nPrint Q lines. The i-th line should contain the answer to the i-th query.\n\nSample Input 1\n\n8 3\nACACTACG\n3 7\n2 3\n1 8\n\nSample Output 1\n\n2\n0\n3\n\nQuery 1: the substring of S starting at index 3 and ending at index 7 is ACTAC. In this string, AC occurs twice as a substring.\n\nQuery 2: the substring of S starting at index 2 and ending at index 3 is CA. In this string, AC occurs zero times as a substring.\n\nQuery 3: the substring of S starting at index 1 and ending at index 8 is ACACTACG. In this string, AC occurs three times as a substring.", "sample_input": "8 3\nACACTACG\n3 7\n2 3\n1 8\n"}, "reference_outputs": ["2\n0\n3\n"], "source_document_id": "p03087", "source_text": "Score : 300 points\n\nProblem Statement\n\nYou are given a string S of length N consisting of A, C, G and T. Answer the following Q queries:\n\nQuery i (1 \\leq i \\leq Q): You will be given integers l_i and r_i (1 \\leq l_i < r_i \\leq N). Consider the substring of S starting at index l_i and ending at index r_i (both inclusive). In this string, how many times does AC occurs as a substring?\n\nNotes\n\nA substring of a string T is a string obtained by removing zero or more characters from the beginning and the end of T.\n\nFor example, the substrings of ATCODER include TCO, AT, CODER, ATCODER and (the empty string), but not AC.\n\nConstraints\n\n2 \\leq N \\leq 10^5\n\n1 \\leq Q \\leq 10^5\n\nS is a string of length N.\n\nEach character in S is A, C, G or T.\n\n1 \\leq l_i < r_i \\leq N\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN Q\nS\nl_1 r_1\n:\nl_Q r_Q\n\nOutput\n\nPrint Q lines. The i-th line should contain the answer to the i-th query.\n\nSample Input 1\n\n8 3\nACACTACG\n3 7\n2 3\n1 8\n\nSample Output 1\n\n2\n0\n3\n\nQuery 1: the substring of S starting at index 3 and ending at index 7 is ACTAC. In this string, AC occurs twice as a substring.\n\nQuery 2: the substring of S starting at index 2 and ending at index 3 is CA. In this string, AC occurs zero times as a substring.\n\nQuery 3: the substring of S starting at index 1 and ending at index 8 is ACACTACG. In this string, AC occurs three times as a substring.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 140, "cpu_time_ms": 2103, "memory_kb": 1512}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s491807376", "group_id": "codeNet:p03088", "input_text": "local DBG = false\nlocal function dbgpr(...)\n if DBG then\n io.write(\"[dbg]\")\n print(...)\n end\nend\n\nlocal function dbgpr_t(tbl, use_pairs)\n if DBG then\n local enum = ipairs\n if use_pairs then\n enum = pairs\n end\n dbgpr(tbl)\n io.write(\"[dbg]\")\n for i,v in enum(tbl) do\n io.write(i)\n io.write(\":\")\n io.write(tostring(v))\n io.write(\" \")\n end\n print(\"\")\n end\nend\n\nlocal function dbgpr_tp(tbl)\n dbgpr_t(tbl, true)\nend\n-----------------------------------------\nlocal MOD = 1000000007\n\nlocal function pow4(n)\n local a = 1\n for i=1,n do\n a = a * 4 % MOD\n end\n return a\nend\n\nlocal ng_a, ng_c, ng_g, ng_t, ng\n\nlocal ng_a_tbl = {0,0,2}\nng_a = function(k)\n dbgpr(\"ng_a\", k)\n if ng_a_tbl[k] ~= nil then\n return ng_a_tbl[k]\n end\n local x = (ng_a(k-1) + pow4(k-3) + ng_t(k-1) + pow4(k-3)) % MOD\n ng_a_tbl[k] = x\n return x\nend\n\nlocal ng_c_tbl = {0,0,0}\nng_c = function(k)\n dbgpr(\"ng_c\", k)\n if ng_c_tbl[k] ~= nil then\n return ng_c_tbl[k]\n end\n local x = ng(k-1)\n ng_c_tbl[k] = x\n return x\nend\n\nlocal ng_t_tbl = {0,0,0}\nng_t = function(k)\n dbgpr(\"ng_t\", k)\n if ng_t_tbl[k] ~= nil then\n return ng_t_tbl[k]\n end\n local x = ng(k-1)\n ng_t_tbl[k] = x\n return x\nend\n\nlocal ng_g_tbl = {0,0,1}\nng_g = function(k)\n dbgpr(\"ng_g\", k)\n if ng_g_tbl[k] ~= nil then\n return ng_g_tbl[k]\n end\n local x = (ng_c(k-1) + ng_g(k-1) + ng_t(k-1) + pow4(k-3)) % MOD\n ng_g_tbl[k] = x\n return x\nend\n\nlocal ng_tbl = {0,0,3}\nng = function(k)\n dbgpr(\"ng\", k)\n if ng_tbl[k] ~= nil then\n return ng_tbl[k]\n end\n local x = (ng_a(k) + ng_c(k) + ng_g(k) + ng_t(k)) % MOD\n ng_tbl[k] = x\n return x\nend\n\nlocal function ok(k)\n return (pow4(k) - ng(k) + MOD) % MOD\nend\n\n--for i=3,6 do\n-- print(i, ok(i))\n--end\n\nlocal N = io.read(\"n\")\nprint(ok(N))\n", "language": "Lua", "metadata": {"date": 1553463573, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03088.html", "problem_id": "p03088", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03088/input.txt", "sample_output_relpath": "derived/input_output/data/p03088/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03088/Lua/s491807376.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s491807376", "user_id": "u162773977"}, "prompt_components": {"gold_output": "61\n", "input_to_evaluate": "local DBG = false\nlocal function dbgpr(...)\n if DBG then\n io.write(\"[dbg]\")\n print(...)\n end\nend\n\nlocal function dbgpr_t(tbl, use_pairs)\n if DBG then\n local enum = ipairs\n if use_pairs then\n enum = pairs\n end\n dbgpr(tbl)\n io.write(\"[dbg]\")\n for i,v in enum(tbl) do\n io.write(i)\n io.write(\":\")\n io.write(tostring(v))\n io.write(\" \")\n end\n print(\"\")\n end\nend\n\nlocal function dbgpr_tp(tbl)\n dbgpr_t(tbl, true)\nend\n-----------------------------------------\nlocal MOD = 1000000007\n\nlocal function pow4(n)\n local a = 1\n for i=1,n do\n a = a * 4 % MOD\n end\n return a\nend\n\nlocal ng_a, ng_c, ng_g, ng_t, ng\n\nlocal ng_a_tbl = {0,0,2}\nng_a = function(k)\n dbgpr(\"ng_a\", k)\n if ng_a_tbl[k] ~= nil then\n return ng_a_tbl[k]\n end\n local x = (ng_a(k-1) + pow4(k-3) + ng_t(k-1) + pow4(k-3)) % MOD\n ng_a_tbl[k] = x\n return x\nend\n\nlocal ng_c_tbl = {0,0,0}\nng_c = function(k)\n dbgpr(\"ng_c\", k)\n if ng_c_tbl[k] ~= nil then\n return ng_c_tbl[k]\n end\n local x = ng(k-1)\n ng_c_tbl[k] = x\n return x\nend\n\nlocal ng_t_tbl = {0,0,0}\nng_t = function(k)\n dbgpr(\"ng_t\", k)\n if ng_t_tbl[k] ~= nil then\n return ng_t_tbl[k]\n end\n local x = ng(k-1)\n ng_t_tbl[k] = x\n return x\nend\n\nlocal ng_g_tbl = {0,0,1}\nng_g = function(k)\n dbgpr(\"ng_g\", k)\n if ng_g_tbl[k] ~= nil then\n return ng_g_tbl[k]\n end\n local x = (ng_c(k-1) + ng_g(k-1) + ng_t(k-1) + pow4(k-3)) % MOD\n ng_g_tbl[k] = x\n return x\nend\n\nlocal ng_tbl = {0,0,3}\nng = function(k)\n dbgpr(\"ng\", k)\n if ng_tbl[k] ~= nil then\n return ng_tbl[k]\n end\n local x = (ng_a(k) + ng_c(k) + ng_g(k) + ng_t(k)) % MOD\n ng_tbl[k] = x\n return x\nend\n\nlocal function ok(k)\n return (pow4(k) - ng(k) + MOD) % MOD\nend\n\n--for i=3,6 do\n-- print(i, ok(i))\n--end\n\nlocal N = io.read(\"n\")\nprint(ok(N))\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nYou are given an integer N. Find the number of strings of length N that satisfy the following conditions, modulo 10^9+7:\n\nThe string does not contain characters other than A, C, G and T.\n\nThe string does not contain AGC as a substring.\n\nThe condition above cannot be violated by swapping two adjacent characters once.\n\nNotes\n\nA substring of a string T is a string obtained by removing zero or more characters from the beginning and the end of T.\n\nFor example, the substrings of ATCODER include TCO, AT, CODER, ATCODER and (the empty string), but not AC.\n\nConstraints\n\n3 \\leq N \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the number of strings of length N that satisfy the following conditions, modulo 10^9+7.\n\nSample Input 1\n\n3\n\nSample Output 1\n\n61\n\nThere are 4^3 = 64 strings of length 3 that do not contain characters other than A, C, G and T. Among them, only AGC, ACG and GAC violate the condition, so the answer is 64 - 3 = 61.\n\nSample Input 2\n\n4\n\nSample Output 2\n\n230\n\nSample Input 3\n\n100\n\nSample Output 3\n\n388130742\n\nBe sure to print the number of strings modulo 10^9+7.", "sample_input": "3\n"}, "reference_outputs": ["61\n"], "source_document_id": "p03088", "source_text": "Score : 400 points\n\nProblem Statement\n\nYou are given an integer N. Find the number of strings of length N that satisfy the following conditions, modulo 10^9+7:\n\nThe string does not contain characters other than A, C, G and T.\n\nThe string does not contain AGC as a substring.\n\nThe condition above cannot be violated by swapping two adjacent characters once.\n\nNotes\n\nA substring of a string T is a string obtained by removing zero or more characters from the beginning and the end of T.\n\nFor example, the substrings of ATCODER include TCO, AT, CODER, ATCODER and (the empty string), but not AC.\n\nConstraints\n\n3 \\leq N \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the number of strings of length N that satisfy the following conditions, modulo 10^9+7.\n\nSample Input 1\n\n3\n\nSample Output 1\n\n61\n\nThere are 4^3 = 64 strings of length 3 that do not contain characters other than A, C, G and T. Among them, only AGC, ACG and GAC violate the condition, so the answer is 64 - 3 = 61.\n\nSample Input 2\n\n4\n\nSample Output 2\n\n230\n\nSample Input 3\n\n100\n\nSample Output 3\n\n388130742\n\nBe sure to print the number of strings modulo 10^9+7.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1976, "cpu_time_ms": 132, "memory_kb": 888}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s512050433", "group_id": "codeNet:p03089", "input_text": "local n = io.read(\"n\")\nlocal b = {}\nfor i = 1, n do\n b[i] = io.read(\"n\")\nend\nlocal a = {}\nfor i = n,1,-1 do\n for j = i,1,-1 do\n if b[j] == j then\n a[i] = j\n table.remove(b, j)\n break\n end\n end\n if #b == i then\n print(-1)\n return 0\n end\nend\nfor i = 1,n do\n print(a[i])\nend", "language": "Lua", "metadata": {"date": 1553376761, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03089.html", "problem_id": "p03089", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03089/input.txt", "sample_output_relpath": "derived/input_output/data/p03089/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03089/Lua/s512050433.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s512050433", "user_id": "u914762730"}, "prompt_components": {"gold_output": "1\n1\n2\n", "input_to_evaluate": "local n = io.read(\"n\")\nlocal b = {}\nfor i = 1, n do\n b[i] = io.read(\"n\")\nend\nlocal a = {}\nfor i = n,1,-1 do\n for j = i,1,-1 do\n if b[j] == j then\n a[i] = j\n table.remove(b, j)\n break\n end\n end\n if #b == i then\n print(-1)\n return 0\n end\nend\nfor i = 1,n do\n print(a[i])\nend", "problem_context": "Score : 400 points\n\nProblem Statement\n\nSnuke has an empty sequence a.\n\nHe will perform N operations on this sequence.\n\nIn the i-th operation, he chooses an integer j satisfying 1 \\leq j \\leq i, and insert j at position j in a (the beginning is position 1).\n\nYou are given a sequence b of length N. Determine if it is possible that a is equal to b after N operations. If it is, show one possible sequence of operations that achieves it.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 100\n\n1 \\leq b_i \\leq N\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nb_1 \\dots b_N\n\nOutput\n\nIf there is no sequence of N operations after which a would be equal to b, print -1.\nIf there is, print N lines. In the i-th line, the integer chosen in the i-th operation should be printed. If there are multiple solutions, any of them is accepted.\n\nSample Input 1\n\n3\n1 2 1\n\nSample Output 1\n\n1\n1\n2\n\nIn this sequence of operations, the sequence a changes as follows:\n\nAfter the first operation: (1)\n\nAfter the second operation: (1,1)\n\nAfter the third operation: (1,2,1)\n\nSample Input 2\n\n2\n2 2\n\nSample Output 2\n\n-1\n\n2 cannot be inserted at the beginning of the sequence, so this is impossible.\n\nSample Input 3\n\n9\n1 1 1 2 2 1 2 3 2\n\nSample Output 3\n\n1\n2\n2\n3\n1\n2\n2\n1\n1", "sample_input": "3\n1 2 1\n"}, "reference_outputs": ["1\n1\n2\n"], "source_document_id": "p03089", "source_text": "Score : 400 points\n\nProblem Statement\n\nSnuke has an empty sequence a.\n\nHe will perform N operations on this sequence.\n\nIn the i-th operation, he chooses an integer j satisfying 1 \\leq j \\leq i, and insert j at position j in a (the beginning is position 1).\n\nYou are given a sequence b of length N. Determine if it is possible that a is equal to b after N operations. If it is, show one possible sequence of operations that achieves it.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 100\n\n1 \\leq b_i \\leq N\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nb_1 \\dots b_N\n\nOutput\n\nIf there is no sequence of N operations after which a would be equal to b, print -1.\nIf there is, print N lines. In the i-th line, the integer chosen in the i-th operation should be printed. If there are multiple solutions, any of them is accepted.\n\nSample Input 1\n\n3\n1 2 1\n\nSample Output 1\n\n1\n1\n2\n\nIn this sequence of operations, the sequence a changes as follows:\n\nAfter the first operation: (1)\n\nAfter the second operation: (1,1)\n\nAfter the third operation: (1,2,1)\n\nSample Input 2\n\n2\n2 2\n\nSample Output 2\n\n-1\n\n2 cannot be inserted at the beginning of the sequence, so this is impossible.\n\nSample Input 3\n\n9\n1 1 1 2 2 1 2 3 2\n\nSample Output 3\n\n1\n2\n2\n3\n1\n2\n2\n1\n1", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 350, "cpu_time_ms": 88, "memory_kb": 760}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s706060637", "group_id": "codeNet:p03095", "input_text": "local n=io.read(\"n\",\"l\")\nlocal t={}\nfor _,a in utf8.codes(io.read()) do\n if not t[a] then\n t[a]=1\n else\n t[a]=t[a]+1\n end\nend\n\nlocal combination=1\nfor _,frequency in pairs(t) do\n combination=combination*(frequency+1)%1000000007\nend\nprint(combination-1)", "language": "Lua", "metadata": {"date": 1590482635, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03095.html", "problem_id": "p03095", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03095/input.txt", "sample_output_relpath": "derived/input_output/data/p03095/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03095/Lua/s706060637.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s706060637", "user_id": "u045238009"}, "prompt_components": {"gold_output": "15\n", "input_to_evaluate": "local n=io.read(\"n\",\"l\")\nlocal t={}\nfor _,a in utf8.codes(io.read()) do\n if not t[a] then\n t[a]=1\n else\n t[a]=t[a]+1\n end\nend\n\nlocal combination=1\nfor _,frequency in pairs(t) do\n combination=combination*(frequency+1)%1000000007\nend\nprint(combination-1)", "problem_context": "Score : 200 points\n\nProblem Statement\n\nYou are given a string S of length N.\nAmong its subsequences, count the ones such that all characters are different, modulo 10^9+7. Two subsequences are considered different if their characters come from different positions in the string, even if they are the same as strings.\n\nHere, a subsequence of a string is a concatenation of one or more characters from the string without changing the order.\n\nConstraints\n\n1 \\leq N \\leq 100000\n\nS consists of lowercase English letters.\n\n|S|=N\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS\n\nOutput\n\nPrint the number of the subsequences such that all characters are different, modulo 10^9+7.\n\nSample Input 1\n\n4\nabcd\n\nSample Output 1\n\n15\n\nSince all characters in S itself are different, all its subsequences satisfy the condition.\n\nSample Input 2\n\n3\nbaa\n\nSample Output 2\n\n5\n\nThe answer is five: b, two occurrences of a, two occurrences of ba. Note that we do not count baa, since it contains two as.\n\nSample Input 3\n\n5\nabcab\n\nSample Output 3\n\n17", "sample_input": "4\nabcd\n"}, "reference_outputs": ["15\n"], "source_document_id": "p03095", "source_text": "Score : 200 points\n\nProblem Statement\n\nYou are given a string S of length N.\nAmong its subsequences, count the ones such that all characters are different, modulo 10^9+7. Two subsequences are considered different if their characters come from different positions in the string, even if they are the same as strings.\n\nHere, a subsequence of a string is a concatenation of one or more characters from the string without changing the order.\n\nConstraints\n\n1 \\leq N \\leq 100000\n\nS consists of lowercase English letters.\n\n|S|=N\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS\n\nOutput\n\nPrint the number of the subsequences such that all characters are different, modulo 10^9+7.\n\nSample Input 1\n\n4\nabcd\n\nSample Output 1\n\n15\n\nSince all characters in S itself are different, all its subsequences satisfy the condition.\n\nSample Input 2\n\n3\nbaa\n\nSample Output 2\n\n5\n\nThe answer is five: b, two occurrences of a, two occurrences of ba. Note that we do not count baa, since it contains two as.\n\nSample Input 3\n\n5\nabcab\n\nSample Output 3\n\n17", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 278, "cpu_time_ms": 12, "memory_kb": 504}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s816960736", "group_id": "codeNet:p03096", "input_text": "local mod = 1000000007\nlocal function badd(x, y)\n return (x + y) % mod\nend\nlocal n = io.read(\"*n\")\nlocal t = {}\nlocal colors = {}\nlocal pos = {}\nfor i = 1, n do\n local c = io.read(\"*n\")\n t[i] = c\n if not colors[c] then colors[c] = {} end\n table.insert(colors[c], i)\n pos[i] = #colors[c]\nend\nlocal cnt = {}\nfor i = 1, n do\n cnt[i] = 1\nend\nfor i = n - 1, 1, -1 do\n local c, p = t[i], pos[i]\n if p < #colors[c] and i + 1 < colors[c][p + 1] then\n cnt[i] = badd(cnt[i + 1], cnt[colors[c][p + 1]])\n else\n cnt[i] = cnt[i + 1]\n end\nend\nprint(cnt[1])\n", "language": "Lua", "metadata": {"date": 1569354238, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03096.html", "problem_id": "p03096", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03096/input.txt", "sample_output_relpath": "derived/input_output/data/p03096/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03096/Lua/s816960736.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s816960736", "user_id": "u120582723"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "local mod = 1000000007\nlocal function badd(x, y)\n return (x + y) % mod\nend\nlocal n = io.read(\"*n\")\nlocal t = {}\nlocal colors = {}\nlocal pos = {}\nfor i = 1, n do\n local c = io.read(\"*n\")\n t[i] = c\n if not colors[c] then colors[c] = {} end\n table.insert(colors[c], i)\n pos[i] = #colors[c]\nend\nlocal cnt = {}\nfor i = 1, n do\n cnt[i] = 1\nend\nfor i = n - 1, 1, -1 do\n local c, p = t[i], pos[i]\n if p < #colors[c] and i + 1 < colors[c][p + 1] then\n cnt[i] = badd(cnt[i + 1], cnt[colors[c][p + 1]])\n else\n cnt[i] = cnt[i + 1]\n end\nend\nprint(cnt[1])\n", "problem_context": "Score : 700 points\n\nProblem Statement\n\nThere are N stones arranged in a row. The i-th stone from the left is painted in the color C_i.\n\nSnuke will perform the following operation zero or more times:\n\nChoose two stones painted in the same color. Repaint all the stones between them, with the color of the chosen stones.\n\nFind the number of possible final sequences of colors of the stones, modulo 10^9+7.\n\nConstraints\n\n1 \\leq N \\leq 2\\times 10^5\n\n1 \\leq C_i \\leq 2\\times 10^5(1\\leq i\\leq N)\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nC_1\n:\nC_N\n\nOutput\n\nPrint the number of possible final sequences of colors of the stones, modulo 10^9+7.\n\nSample Input 1\n\n5\n1\n2\n1\n2\n2\n\nSample Output 1\n\n3\n\nWe can make three sequences of colors of stones, as follows:\n\n(1,2,1,2,2), by doing nothing.\n\n(1,1,1,2,2), by choosing the first and third stones to perform the operation.\n\n(1,2,2,2,2), by choosing the second and fourth stones to perform the operation.\n\nSample Input 2\n\n6\n4\n2\n5\n4\n2\n4\n\nSample Output 2\n\n5\n\nSample Input 3\n\n7\n1\n3\n1\n2\n3\n3\n2\n\nSample Output 3\n\n5", "sample_input": "5\n1\n2\n1\n2\n2\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03096", "source_text": "Score : 700 points\n\nProblem Statement\n\nThere are N stones arranged in a row. The i-th stone from the left is painted in the color C_i.\n\nSnuke will perform the following operation zero or more times:\n\nChoose two stones painted in the same color. Repaint all the stones between them, with the color of the chosen stones.\n\nFind the number of possible final sequences of colors of the stones, modulo 10^9+7.\n\nConstraints\n\n1 \\leq N \\leq 2\\times 10^5\n\n1 \\leq C_i \\leq 2\\times 10^5(1\\leq i\\leq N)\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nC_1\n:\nC_N\n\nOutput\n\nPrint the number of possible final sequences of colors of the stones, modulo 10^9+7.\n\nSample Input 1\n\n5\n1\n2\n1\n2\n2\n\nSample Output 1\n\n3\n\nWe can make three sequences of colors of stones, as follows:\n\n(1,2,1,2,2), by doing nothing.\n\n(1,1,1,2,2), by choosing the first and third stones to perform the operation.\n\n(1,2,2,2,2), by choosing the second and fourth stones to perform the operation.\n\nSample Input 2\n\n6\n4\n2\n5\n4\n2\n4\n\nSample Output 2\n\n5\n\nSample Input 3\n\n7\n1\n3\n1\n2\n3\n3\n2\n\nSample Output 3\n\n5", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 559, "cpu_time_ms": 249, "memory_kb": 37080}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s273651224", "group_id": "codeNet:p03101", "input_text": "a,b=io.read():match(\"(.+)%s(.+)\")\nc,d=io.read():match(\"(.+)%s(.+)\")\nprint(math.floor((a-c)*(b-d)))", "language": "Lua", "metadata": {"date": 1552161679, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03101.html", "problem_id": "p03101", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03101/input.txt", "sample_output_relpath": "derived/input_output/data/p03101/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03101/Lua/s273651224.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s273651224", "user_id": "u837412668"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "a,b=io.read():match(\"(.+)%s(.+)\")\nc,d=io.read():match(\"(.+)%s(.+)\")\nprint(math.floor((a-c)*(b-d)))", "problem_context": "Score : 100 points\n\nProblem Statement\n\nThere are H rows and W columns of white square cells.\n\nYou will choose h of the rows and w of the columns, and paint all of the cells contained in those rows or columns.\n\nHow many white cells will remain?\n\nIt can be proved that this count does not depend on what rows and columns are chosen.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq H, W \\leq 20\n\n1 \\leq h \\leq H\n\n1 \\leq w \\leq W\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\nh w\n\nOutput\n\nPrint the number of white cells that will remain.\n\nSample Input 1\n\n3 2\n2 1\n\nSample Output 1\n\n1\n\nThere are 3 rows and 2 columns of cells. When two rows and one column are chosen and painted in black, there is always one white cell that remains.\n\nSample Input 2\n\n5 5\n2 3\n\nSample Output 2\n\n6\n\nSample Input 3\n\n2 4\n2 4\n\nSample Output 3\n\n0", "sample_input": "3 2\n2 1\n"}, "reference_outputs": ["1\n"], "source_document_id": "p03101", "source_text": "Score : 100 points\n\nProblem Statement\n\nThere are H rows and W columns of white square cells.\n\nYou will choose h of the rows and w of the columns, and paint all of the cells contained in those rows or columns.\n\nHow many white cells will remain?\n\nIt can be proved that this count does not depend on what rows and columns are chosen.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq H, W \\leq 20\n\n1 \\leq h \\leq H\n\n1 \\leq w \\leq W\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\nh w\n\nOutput\n\nPrint the number of white cells that will remain.\n\nSample Input 1\n\n3 2\n2 1\n\nSample Output 1\n\n1\n\nThere are 3 rows and 2 columns of cells. When two rows and one column are chosen and painted in black, there is always one white cell that remains.\n\nSample Input 2\n\n5 5\n2 3\n\nSample Output 2\n\n6\n\nSample Input 3\n\n2 4\n2 4\n\nSample Output 3\n\n0", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 98, "cpu_time_ms": 49, "memory_kb": 1012}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s200537167", "group_id": "codeNet:p03102", "input_text": "n,m,c=io.read(\"*n\", \"*n\", \"*n\")\nb={}\nfor i = 1, m do\n b[i] = io.read(\"*n\")\nend\ncnt = 0\nfor j = 1, n do\n ans = c\n for i = 1, m do\n ans = ans + b[i] * io.read(\"*n\")\n end\n if(0 < ans) then cnt = cnt + 1 end\nend\nprint(cnt)", "language": "Lua", "metadata": {"date": 1554568297, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p03102.html", "problem_id": "p03102", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03102/input.txt", "sample_output_relpath": "derived/input_output/data/p03102/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03102/Lua/s200537167.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s200537167", "user_id": "u120582723"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "n,m,c=io.read(\"*n\", \"*n\", \"*n\")\nb={}\nfor i = 1, m do\n b[i] = io.read(\"*n\")\nend\ncnt = 0\nfor j = 1, n do\n ans = c\n for i = 1, m do\n ans = ans + b[i] * io.read(\"*n\")\n end\n if(0 < ans) then cnt = cnt + 1 end\nend\nprint(cnt)", "problem_context": "Score : 200 points\n\nProblem Statement\n\nThere are N pieces of source code. The characteristics of the i-th code is represented by M integers A_{i1}, A_{i2}, ..., A_{iM}.\n\nAdditionally, you are given integers B_1, B_2, ..., B_M and C.\n\nThe i-th code correctly solves this problem if and only if A_{i1} B_1 + A_{i2} B_2 + ... + A_{iM} B_M + C > 0.\n\nAmong the N codes, find the number of codes that correctly solve this problem.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N, M \\leq 20\n\n-100 \\leq A_{ij} \\leq 100\n\n-100 \\leq B_i \\leq 100\n\n-100 \\leq C \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M C\nB_1 B_2 ... B_M\nA_{11} A_{12} ... A_{1M}\nA_{21} A_{22} ... A_{2M}\n\\vdots\nA_{N1} A_{N2} ... A_{NM}\n\nOutput\n\nPrint the number of codes among the given N codes that correctly solve this problem.\n\nSample Input 1\n\n2 3 -10\n1 2 3\n3 2 1\n1 2 2\n\nSample Output 1\n\n1\n\nOnly the second code correctly solves this problem, as follows:\n\nSince 3 \\times 1 + 2 \\times 2 + 1 \\times 3 + (-10) = 0 \\leq 0, the first code does not solve this problem.\n\n1 \\times 1 + 2 \\times 2 + 2 \\times 3 + (-10) = 1 > 0, the second code solves this problem.\n\nSample Input 2\n\n5 2 -4\n-2 5\n100 41\n100 40\n-3 0\n-6 -2\n18 -13\n\nSample Output 2\n\n2\n\nSample Input 3\n\n3 3 0\n100 -100 0\n0 100 100\n100 100 100\n-100 100 100\n\nSample Output 3\n\n0\n\nAll of them are Wrong Answer. Except yours.", "sample_input": "2 3 -10\n1 2 3\n3 2 1\n1 2 2\n"}, "reference_outputs": ["1\n"], "source_document_id": "p03102", "source_text": "Score : 200 points\n\nProblem Statement\n\nThere are N pieces of source code. The characteristics of the i-th code is represented by M integers A_{i1}, A_{i2}, ..., A_{iM}.\n\nAdditionally, you are given integers B_1, B_2, ..., B_M and C.\n\nThe i-th code correctly solves this problem if and only if A_{i1} B_1 + A_{i2} B_2 + ... + A_{iM} B_M + C > 0.\n\nAmong the N codes, find the number of codes that correctly solve this problem.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N, M \\leq 20\n\n-100 \\leq A_{ij} \\leq 100\n\n-100 \\leq B_i \\leq 100\n\n-100 \\leq C \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M C\nB_1 B_2 ... B_M\nA_{11} A_{12} ... A_{1M}\nA_{21} A_{22} ... A_{2M}\n\\vdots\nA_{N1} A_{N2} ... A_{NM}\n\nOutput\n\nPrint the number of codes among the given N codes that correctly solve this problem.\n\nSample Input 1\n\n2 3 -10\n1 2 3\n3 2 1\n1 2 2\n\nSample Output 1\n\n1\n\nOnly the second code correctly solves this problem, as follows:\n\nSince 3 \\times 1 + 2 \\times 2 + 1 \\times 3 + (-10) = 0 \\leq 0, the first code does not solve this problem.\n\n1 \\times 1 + 2 \\times 2 + 2 \\times 3 + (-10) = 1 > 0, the second code solves this problem.\n\nSample Input 2\n\n5 2 -4\n-2 5\n100 41\n100 40\n-3 0\n-6 -2\n18 -13\n\nSample Output 2\n\n2\n\nSample Input 3\n\n3 3 0\n100 -100 0\n0 100 100\n100 100 100\n-100 100 100\n\nSample Output 3\n\n0\n\nAll of them are Wrong Answer. Except yours.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 240, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s788451896", "group_id": "codeNet:p03103", "input_text": "n,m=io.read(\"*n\",\"*n\",\"*l\")\na={}\nfor i=1,n do\n a[i]={}\n a[i][1],a[i][2]=io.read(\"*n\",\"*n\")\nend\ntable.sort(a,function(x,y)\n if x[1]~=y[1] then\n return x[1]y[2]\n end\nend)\n\ndrink=0\nyen=0\nfor i=1,n do\n if m-drinky[2]\n end\nend)\n\ndrink=0\nyen=0\nfor i=1,n do\n if m-drinkself.rank[y] then\n x,y=y,x\n elseif self.rank[x]==self.rank[y] then\n self.rank[x]=self.rank[x]+1\n end\n self.par[x]=y\n self.size[y]=self.size[y]+self.size[x]\nend\n\nUnionFind.getsize=function(self,x)\n return self.size[self:getroot(x)]\nend\n\nUnionFind.new=function(self,n)\n local obj={}\n setmetatable(obj,{__index=UnionFind})\n obj:create(n)\n return obj\nend\n\n----------\n\nlocal n,m=io.read(\"n\",\"n\")\nlocal a,b={},{}\nfor i=1,m do\n a[i],b[i]=io.read(\"n\",\"n\")\nend\n\nlocal t={[m]=n*(n-1)//2}\nlocal uf=UnionFind:new(n)\nfor i=m-1,1,-1 do\n if uf:same(a[i+1],b[i+1]) then\n t[i]=t[i+1]\n else\n local ua=uf:getsize(a[i+1])\n local ub=uf:getsize(b[i+1])\n uf:unite(a[i+1],b[i+1])\n t[i]=t[i+1]-ua*ub\n end\nend\n\nfor i=1,m do\n print(t[i])\nend", "language": "Lua", "metadata": {"date": 1598732288, "filename_ext": "lua", "original_language": "Lua (Lua 5.3.5)", "problem_description_relpath": "problem_descriptions/p03108.html", "problem_id": "p03108", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03108/input.txt", "sample_output_relpath": "derived/input_output/data/p03108/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03108/Lua/s132298275.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s132298275", "user_id": "u045238009"}, "prompt_components": {"gold_output": "0\n0\n4\n5\n6\n", "input_to_evaluate": "local UnionFind={}\n\nUnionFind.create=function(self,n)\n self.par={}\n self.rank={}\n self.size={}\n for i=1,n do\n self.par[i]=i\n self.rank[i]=1\n self.size[i]=1\n end\nend\n\nUnionFind.getroot=function(self,x)\n local nx=x\n while self.par[x]~=x do\n x=self.par[x]\n end\n while self.par[nx]~=x do\n self.par[nx],nx=x,self.par[nx]\n end\n return x\nend\n\nUnionFind.same=function(self,x,y)\n return self:getroot(x)==self:getroot(y)\nend\n\nUnionFind.unite=function(self,x,y)\n x=self:getroot(x)\n y=self:getroot(y)\n if x==y then\n return\n end\n if self.rank[x]>self.rank[y] then\n x,y=y,x\n elseif self.rank[x]==self.rank[y] then\n self.rank[x]=self.rank[x]+1\n end\n self.par[x]=y\n self.size[y]=self.size[y]+self.size[x]\nend\n\nUnionFind.getsize=function(self,x)\n return self.size[self:getroot(x)]\nend\n\nUnionFind.new=function(self,n)\n local obj={}\n setmetatable(obj,{__index=UnionFind})\n obj:create(n)\n return obj\nend\n\n----------\n\nlocal n,m=io.read(\"n\",\"n\")\nlocal a,b={},{}\nfor i=1,m do\n a[i],b[i]=io.read(\"n\",\"n\")\nend\n\nlocal t={[m]=n*(n-1)//2}\nlocal uf=UnionFind:new(n)\nfor i=m-1,1,-1 do\n if uf:same(a[i+1],b[i+1]) then\n t[i]=t[i+1]\n else\n local ua=uf:getsize(a[i+1])\n local ub=uf:getsize(b[i+1])\n uf:unite(a[i+1],b[i+1])\n t[i]=t[i+1]-ua*ub\n end\nend\n\nfor i=1,m do\n print(t[i])\nend", "problem_context": "Score : 400 points\n\nProblem Statement\n\nThere are N islands and M bridges.\n\nThe i-th bridge connects the A_i-th and B_i-th islands bidirectionally.\n\nInitially, we can travel between any two islands using some of these bridges.\n\nHowever, the results of a survey show that these bridges will all collapse because of aging, in the order from the first bridge to the M-th bridge.\n\nLet the inconvenience be the number of pairs of islands (a, b) (a < b) such that we are no longer able to travel between the a-th and b-th islands using some of the bridges remaining.\n\nFor each i (1 \\leq i \\leq M), find the inconvenience just after the i-th bridge collapses.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^5\n\n1 \\leq A_i < B_i \\leq N\n\nAll pairs (A_i, B_i) are distinct.\n\nThe inconvenience is initially 0.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nA_1 B_1\nA_2 B_2\n\\vdots\nA_M B_M\n\nOutput\n\nIn the order i = 1, 2, ..., M, print the inconvenience just after the i-th bridge collapses.\nNote that the answer may not fit into a 32-bit integer type.\n\nSample Input 1\n\n4 5\n1 2\n3 4\n1 3\n2 3\n1 4\n\nSample Output 1\n\n0\n0\n4\n5\n6\n\nFor example, when the first to third bridges have collapsed, the inconvenience is 4 since we can no longer travel between the pairs (1, 2), (1, 3), (2, 4) and (3, 4).\n\nSample Input 2\n\n6 5\n2 3\n1 2\n5 6\n3 4\n4 5\n\nSample Output 2\n\n8\n9\n12\n14\n15\n\nSample Input 3\n\n2 1\n1 2\n\nSample Output 3\n\n1", "sample_input": "4 5\n1 2\n3 4\n1 3\n2 3\n1 4\n"}, "reference_outputs": ["0\n0\n4\n5\n6\n"], "source_document_id": "p03108", "source_text": "Score : 400 points\n\nProblem Statement\n\nThere are N islands and M bridges.\n\nThe i-th bridge connects the A_i-th and B_i-th islands bidirectionally.\n\nInitially, we can travel between any two islands using some of these bridges.\n\nHowever, the results of a survey show that these bridges will all collapse because of aging, in the order from the first bridge to the M-th bridge.\n\nLet the inconvenience be the number of pairs of islands (a, b) (a < b) such that we are no longer able to travel between the a-th and b-th islands using some of the bridges remaining.\n\nFor each i (1 \\leq i \\leq M), find the inconvenience just after the i-th bridge collapses.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^5\n\n1 \\leq A_i < B_i \\leq N\n\nAll pairs (A_i, B_i) are distinct.\n\nThe inconvenience is initially 0.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nA_1 B_1\nA_2 B_2\n\\vdots\nA_M B_M\n\nOutput\n\nIn the order i = 1, 2, ..., M, print the inconvenience just after the i-th bridge collapses.\nNote that the answer may not fit into a 32-bit integer type.\n\nSample Input 1\n\n4 5\n1 2\n3 4\n1 3\n2 3\n1 4\n\nSample Output 1\n\n0\n0\n4\n5\n6\n\nFor example, when the first to third bridges have collapsed, the inconvenience is 4 since we can no longer travel between the pairs (1, 2), (1, 3), (2, 4) and (3, 4).\n\nSample Input 2\n\n6 5\n2 3\n1 2\n5 6\n3 4\n4 5\n\nSample Output 2\n\n8\n9\n12\n14\n15\n\nSample Input 3\n\n2 1\n1 2\n\nSample Output 3\n\n1", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1431, "cpu_time_ms": 420, "memory_kb": 20524}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s497371672", "group_id": "codeNet:p03109", "input_text": "s=io.read()\nb=tonumber(s:sub(6,7))\nif b<5 then\n\tprint(\"Heisei\")\nelse\n\tprint(\"TBD\")\nend", "language": "Lua", "metadata": {"date": 1579346128, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03109.html", "problem_id": "p03109", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03109/input.txt", "sample_output_relpath": "derived/input_output/data/p03109/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03109/Lua/s497371672.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s497371672", "user_id": "u720483676"}, "prompt_components": {"gold_output": "Heisei\n", "input_to_evaluate": "s=io.read()\nb=tonumber(s:sub(6,7))\nif b<5 then\n\tprint(\"Heisei\")\nelse\n\tprint(\"TBD\")\nend", "problem_context": "Score : 100 points\n\nProblem Statement\n\nYou are given a string S as input. This represents a valid date in the year 2019 in the yyyy/mm/dd format. (For example, April 30, 2019 is represented as 2019/04/30.)\n\nWrite a program that prints Heisei if the date represented by S is not later than April 30, 2019, and prints TBD otherwise.\n\nConstraints\n\nS is a string that represents a valid date in the year 2019 in the yyyy/mm/dd format.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint Heisei if the date represented by S is not later than April 30, 2019, and print TBD otherwise.\n\nSample Input 1\n\n2019/04/30\n\nSample Output 1\n\nHeisei\n\nSample Input 2\n\n2019/11/01\n\nSample Output 2\n\nTBD", "sample_input": "2019/04/30\n"}, "reference_outputs": ["Heisei\n"], "source_document_id": "p03109", "source_text": "Score : 100 points\n\nProblem Statement\n\nYou are given a string S as input. This represents a valid date in the year 2019 in the yyyy/mm/dd format. (For example, April 30, 2019 is represented as 2019/04/30.)\n\nWrite a program that prints Heisei if the date represented by S is not later than April 30, 2019, and prints TBD otherwise.\n\nConstraints\n\nS is a string that represents a valid date in the year 2019 in the yyyy/mm/dd format.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint Heisei if the date represented by S is not later than April 30, 2019, and print TBD otherwise.\n\nSample Input 1\n\n2019/04/30\n\nSample Output 1\n\nHeisei\n\nSample Input 2\n\n2019/11/01\n\nSample Output 2\n\nTBD", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 86, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s995740960", "group_id": "codeNet:p03109", "input_text": "S=io.read()\nb=tonumber(string.sub(S,6,7))\nprint(b)\nif b<=4 then\n print(\"Heisei\")\nelse \n print(\"TBD\")\nend", "language": "Lua", "metadata": {"date": 1551708174, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03109.html", "problem_id": "p03109", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03109/input.txt", "sample_output_relpath": "derived/input_output/data/p03109/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03109/Lua/s995740960.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s995740960", "user_id": "u015229643"}, "prompt_components": {"gold_output": "Heisei\n", "input_to_evaluate": "S=io.read()\nb=tonumber(string.sub(S,6,7))\nprint(b)\nif b<=4 then\n print(\"Heisei\")\nelse \n print(\"TBD\")\nend", "problem_context": "Score : 100 points\n\nProblem Statement\n\nYou are given a string S as input. This represents a valid date in the year 2019 in the yyyy/mm/dd format. (For example, April 30, 2019 is represented as 2019/04/30.)\n\nWrite a program that prints Heisei if the date represented by S is not later than April 30, 2019, and prints TBD otherwise.\n\nConstraints\n\nS is a string that represents a valid date in the year 2019 in the yyyy/mm/dd format.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint Heisei if the date represented by S is not later than April 30, 2019, and print TBD otherwise.\n\nSample Input 1\n\n2019/04/30\n\nSample Output 1\n\nHeisei\n\nSample Input 2\n\n2019/11/01\n\nSample Output 2\n\nTBD", "sample_input": "2019/04/30\n"}, "reference_outputs": ["Heisei\n"], "source_document_id": "p03109", "source_text": "Score : 100 points\n\nProblem Statement\n\nYou are given a string S as input. This represents a valid date in the year 2019 in the yyyy/mm/dd format. (For example, April 30, 2019 is represented as 2019/04/30.)\n\nWrite a program that prints Heisei if the date represented by S is not later than April 30, 2019, and prints TBD otherwise.\n\nConstraints\n\nS is a string that represents a valid date in the year 2019 in the yyyy/mm/dd format.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint Heisei if the date represented by S is not later than April 30, 2019, and print TBD otherwise.\n\nSample Input 1\n\n2019/04/30\n\nSample Output 1\n\nHeisei\n\nSample Input 2\n\n2019/11/01\n\nSample Output 2\n\nTBD", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 106, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s277822303", "group_id": "codeNet:p03109", "input_text": "a=io.read()\nprint(a<=\"2019/04/30\"and\"Heisei\"or\"TBD\")\n", "language": "Lua", "metadata": {"date": 1551100972, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p03109.html", "problem_id": "p03109", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03109/input.txt", "sample_output_relpath": "derived/input_output/data/p03109/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03109/Lua/s277822303.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s277822303", "user_id": "u837412668"}, "prompt_components": {"gold_output": "Heisei\n", "input_to_evaluate": "a=io.read()\nprint(a<=\"2019/04/30\"and\"Heisei\"or\"TBD\")\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nYou are given a string S as input. This represents a valid date in the year 2019 in the yyyy/mm/dd format. (For example, April 30, 2019 is represented as 2019/04/30.)\n\nWrite a program that prints Heisei if the date represented by S is not later than April 30, 2019, and prints TBD otherwise.\n\nConstraints\n\nS is a string that represents a valid date in the year 2019 in the yyyy/mm/dd format.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint Heisei if the date represented by S is not later than April 30, 2019, and print TBD otherwise.\n\nSample Input 1\n\n2019/04/30\n\nSample Output 1\n\nHeisei\n\nSample Input 2\n\n2019/11/01\n\nSample Output 2\n\nTBD", "sample_input": "2019/04/30\n"}, "reference_outputs": ["Heisei\n"], "source_document_id": "p03109", "source_text": "Score : 100 points\n\nProblem Statement\n\nYou are given a string S as input. This represents a valid date in the year 2019 in the yyyy/mm/dd format. (For example, April 30, 2019 is represented as 2019/04/30.)\n\nWrite a program that prints Heisei if the date represented by S is not later than April 30, 2019, and prints TBD otherwise.\n\nConstraints\n\nS is a string that represents a valid date in the year 2019 in the yyyy/mm/dd format.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint Heisei if the date represented by S is not later than April 30, 2019, and print TBD otherwise.\n\nSample Input 1\n\n2019/04/30\n\nSample Output 1\n\nHeisei\n\nSample Input 2\n\n2019/11/01\n\nSample Output 2\n\nTBD", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 53, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s265169457", "group_id": "codeNet:p03110", "input_text": "N=io.read(\"n\")\nx={}\nu={}\nlocal total=0\nfor i=1,N do\n x[i]=io.read(\"n\")\n u[i]=string.match(io.read(),\"%a+\")\n if u[i]==\"BTC\" then\n x[i]=380000*x[i]\n end\n total=total+x[i]\nend\nprint(total)\n", "language": "Lua", "metadata": {"date": 1551715447, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03110.html", "problem_id": "p03110", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03110/input.txt", "sample_output_relpath": "derived/input_output/data/p03110/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03110/Lua/s265169457.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s265169457", "user_id": "u015229643"}, "prompt_components": {"gold_output": "48000.0\n", "input_to_evaluate": "N=io.read(\"n\")\nx={}\nu={}\nlocal total=0\nfor i=1,N do\n x[i]=io.read(\"n\")\n u[i]=string.match(io.read(),\"%a+\")\n if u[i]==\"BTC\" then\n x[i]=380000*x[i]\n end\n total=total+x[i]\nend\nprint(total)\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nTakahashi received otoshidama (New Year's money gifts) from N of his relatives.\n\nYou are given N values x_1, x_2, ..., x_N and N strings u_1, u_2, ..., u_N as input. Each string u_i is either JPY or BTC, and x_i and u_i represent the content of the otoshidama from the i-th relative.\n\nFor example, if x_1 = 10000 and u_1 = JPY, the otoshidama from the first relative is 10000 Japanese yen; if x_2 = 0.10000000 and u_2 = BTC, the otoshidama from the second relative is 0.1 bitcoins.\n\nIf we convert the bitcoins into yen at the rate of 380000.0 JPY per 1.0 BTC, how much are the gifts worth in total?\n\nConstraints\n\n2 \\leq N \\leq 10\n\nu_i = JPY or BTC.\n\nIf u_i = JPY, x_i is an integer such that 1 \\leq x_i \\leq 10^8.\n\nIf u_i = BTC, x_i is a decimal with 8 decimal digits, such that 0.00000001 \\leq x_i \\leq 100.00000000.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nx_1 u_1\nx_2 u_2\n:\nx_N u_N\n\nOutput\n\nIf the gifts are worth Y yen in total, print the value Y (not necessarily an integer).\n\nOutput will be judged correct when the absolute or relative error from the judge's output is at most 10^{-5}.\n\nSample Input 1\n\n2\n10000 JPY\n0.10000000 BTC\n\nSample Output 1\n\n48000.0\n\nThe otoshidama from the first relative is 10000 yen. The otoshidama from the second relative is 0.1 bitcoins, which is worth 38000.0 yen if converted at the rate of 380000.0 JPY per 1.0 BTC. The sum of these is 48000.0 yen.\n\nOutputs such as 48000 and 48000.1 will also be judged correct.\n\nSample Input 2\n\n3\n100000000 JPY\n100.00000000 BTC\n0.00000001 BTC\n\nSample Output 2\n\n138000000.0038\n\nIn this case, outputs such as 138001000 and 1.38e8 will also be judged correct.", "sample_input": "2\n10000 JPY\n0.10000000 BTC\n"}, "reference_outputs": ["48000.0\n"], "source_document_id": "p03110", "source_text": "Score : 200 points\n\nProblem Statement\n\nTakahashi received otoshidama (New Year's money gifts) from N of his relatives.\n\nYou are given N values x_1, x_2, ..., x_N and N strings u_1, u_2, ..., u_N as input. Each string u_i is either JPY or BTC, and x_i and u_i represent the content of the otoshidama from the i-th relative.\n\nFor example, if x_1 = 10000 and u_1 = JPY, the otoshidama from the first relative is 10000 Japanese yen; if x_2 = 0.10000000 and u_2 = BTC, the otoshidama from the second relative is 0.1 bitcoins.\n\nIf we convert the bitcoins into yen at the rate of 380000.0 JPY per 1.0 BTC, how much are the gifts worth in total?\n\nConstraints\n\n2 \\leq N \\leq 10\n\nu_i = JPY or BTC.\n\nIf u_i = JPY, x_i is an integer such that 1 \\leq x_i \\leq 10^8.\n\nIf u_i = BTC, x_i is a decimal with 8 decimal digits, such that 0.00000001 \\leq x_i \\leq 100.00000000.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nx_1 u_1\nx_2 u_2\n:\nx_N u_N\n\nOutput\n\nIf the gifts are worth Y yen in total, print the value Y (not necessarily an integer).\n\nOutput will be judged correct when the absolute or relative error from the judge's output is at most 10^{-5}.\n\nSample Input 1\n\n2\n10000 JPY\n0.10000000 BTC\n\nSample Output 1\n\n48000.0\n\nThe otoshidama from the first relative is 10000 yen. The otoshidama from the second relative is 0.1 bitcoins, which is worth 38000.0 yen if converted at the rate of 380000.0 JPY per 1.0 BTC. The sum of these is 48000.0 yen.\n\nOutputs such as 48000 and 48000.1 will also be judged correct.\n\nSample Input 2\n\n3\n100000000 JPY\n100.00000000 BTC\n0.00000001 BTC\n\nSample Output 2\n\n138000000.0038\n\nIn this case, outputs such as 138001000 and 1.38e8 will also be judged correct.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 194, "cpu_time_ms": 15, "memory_kb": 1008}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s082594407", "group_id": "codeNet:p03110", "input_text": "N=io.read(\"n\")\nx={}\nu={}\nlocal total=0\nfor i=1,N do\n x[i]=io.read(\"n\")\n u[i]=io.read()\n if u[i]==\"BTC\" then\n x[i]=380000*x[i]\n end\n total=total+x[i]\nend\nprint(total)", "language": "Lua", "metadata": {"date": 1551713570, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03110.html", "problem_id": "p03110", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03110/input.txt", "sample_output_relpath": "derived/input_output/data/p03110/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03110/Lua/s082594407.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s082594407", "user_id": "u015229643"}, "prompt_components": {"gold_output": "48000.0\n", "input_to_evaluate": "N=io.read(\"n\")\nx={}\nu={}\nlocal total=0\nfor i=1,N do\n x[i]=io.read(\"n\")\n u[i]=io.read()\n if u[i]==\"BTC\" then\n x[i]=380000*x[i]\n end\n total=total+x[i]\nend\nprint(total)", "problem_context": "Score : 200 points\n\nProblem Statement\n\nTakahashi received otoshidama (New Year's money gifts) from N of his relatives.\n\nYou are given N values x_1, x_2, ..., x_N and N strings u_1, u_2, ..., u_N as input. Each string u_i is either JPY or BTC, and x_i and u_i represent the content of the otoshidama from the i-th relative.\n\nFor example, if x_1 = 10000 and u_1 = JPY, the otoshidama from the first relative is 10000 Japanese yen; if x_2 = 0.10000000 and u_2 = BTC, the otoshidama from the second relative is 0.1 bitcoins.\n\nIf we convert the bitcoins into yen at the rate of 380000.0 JPY per 1.0 BTC, how much are the gifts worth in total?\n\nConstraints\n\n2 \\leq N \\leq 10\n\nu_i = JPY or BTC.\n\nIf u_i = JPY, x_i is an integer such that 1 \\leq x_i \\leq 10^8.\n\nIf u_i = BTC, x_i is a decimal with 8 decimal digits, such that 0.00000001 \\leq x_i \\leq 100.00000000.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nx_1 u_1\nx_2 u_2\n:\nx_N u_N\n\nOutput\n\nIf the gifts are worth Y yen in total, print the value Y (not necessarily an integer).\n\nOutput will be judged correct when the absolute or relative error from the judge's output is at most 10^{-5}.\n\nSample Input 1\n\n2\n10000 JPY\n0.10000000 BTC\n\nSample Output 1\n\n48000.0\n\nThe otoshidama from the first relative is 10000 yen. The otoshidama from the second relative is 0.1 bitcoins, which is worth 38000.0 yen if converted at the rate of 380000.0 JPY per 1.0 BTC. The sum of these is 48000.0 yen.\n\nOutputs such as 48000 and 48000.1 will also be judged correct.\n\nSample Input 2\n\n3\n100000000 JPY\n100.00000000 BTC\n0.00000001 BTC\n\nSample Output 2\n\n138000000.0038\n\nIn this case, outputs such as 138001000 and 1.38e8 will also be judged correct.", "sample_input": "2\n10000 JPY\n0.10000000 BTC\n"}, "reference_outputs": ["48000.0\n"], "source_document_id": "p03110", "source_text": "Score : 200 points\n\nProblem Statement\n\nTakahashi received otoshidama (New Year's money gifts) from N of his relatives.\n\nYou are given N values x_1, x_2, ..., x_N and N strings u_1, u_2, ..., u_N as input. Each string u_i is either JPY or BTC, and x_i and u_i represent the content of the otoshidama from the i-th relative.\n\nFor example, if x_1 = 10000 and u_1 = JPY, the otoshidama from the first relative is 10000 Japanese yen; if x_2 = 0.10000000 and u_2 = BTC, the otoshidama from the second relative is 0.1 bitcoins.\n\nIf we convert the bitcoins into yen at the rate of 380000.0 JPY per 1.0 BTC, how much are the gifts worth in total?\n\nConstraints\n\n2 \\leq N \\leq 10\n\nu_i = JPY or BTC.\n\nIf u_i = JPY, x_i is an integer such that 1 \\leq x_i \\leq 10^8.\n\nIf u_i = BTC, x_i is a decimal with 8 decimal digits, such that 0.00000001 \\leq x_i \\leq 100.00000000.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nx_1 u_1\nx_2 u_2\n:\nx_N u_N\n\nOutput\n\nIf the gifts are worth Y yen in total, print the value Y (not necessarily an integer).\n\nOutput will be judged correct when the absolute or relative error from the judge's output is at most 10^{-5}.\n\nSample Input 1\n\n2\n10000 JPY\n0.10000000 BTC\n\nSample Output 1\n\n48000.0\n\nThe otoshidama from the first relative is 10000 yen. The otoshidama from the second relative is 0.1 bitcoins, which is worth 38000.0 yen if converted at the rate of 380000.0 JPY per 1.0 BTC. The sum of these is 48000.0 yen.\n\nOutputs such as 48000 and 48000.1 will also be judged correct.\n\nSample Input 2\n\n3\n100000000 JPY\n100.00000000 BTC\n0.00000001 BTC\n\nSample Output 2\n\n138000000.0038\n\nIn this case, outputs such as 138001000 and 1.38e8 will also be judged correct.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 173, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s852842106", "group_id": "codeNet:p03111", "input_text": "local n = io.read(\"n\")\nlocal c = io.read(\"n\")\nlocal b = io.read(\"n\")\nlocal a = io.read(\"n\")\nfunction pay(x,y,z)\n return math.abs(x-a)+math.abs(y-b)+math.abs(z-c)\nend\nlocal bamboos = {}\nfunction dfs(cur,a,b,c)\n if cur == #bamboos+1 then\n return math.min(a,b,c) > 0 and pay(a,b,c) - 30 or math.huge\n end\n local vcur = bamboos[cur]\n local toa = 10 + dfs(cur+1, a+vcur, b, c)\n local tob = 10 + dfs(cur+1, a, b+vcur, c)\n local toc = 10 + dfs(cur+1, a, b, c+vcur)\n local skip = dfs(cur+1, a, b, c)\n return math.min(toa, tob, toc, skip)\nend\n\nfor i=1,n do\n bamboos[i] = io.read(\"n\")\nend\nprint(dfs(1,0,0,0))", "language": "Lua", "metadata": {"date": 1551641262, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03111.html", "problem_id": "p03111", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03111/input.txt", "sample_output_relpath": "derived/input_output/data/p03111/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03111/Lua/s852842106.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s852842106", "user_id": "u914762730"}, "prompt_components": {"gold_output": "23\n", "input_to_evaluate": "local n = io.read(\"n\")\nlocal c = io.read(\"n\")\nlocal b = io.read(\"n\")\nlocal a = io.read(\"n\")\nfunction pay(x,y,z)\n return math.abs(x-a)+math.abs(y-b)+math.abs(z-c)\nend\nlocal bamboos = {}\nfunction dfs(cur,a,b,c)\n if cur == #bamboos+1 then\n return math.min(a,b,c) > 0 and pay(a,b,c) - 30 or math.huge\n end\n local vcur = bamboos[cur]\n local toa = 10 + dfs(cur+1, a+vcur, b, c)\n local tob = 10 + dfs(cur+1, a, b+vcur, c)\n local toc = 10 + dfs(cur+1, a, b, c+vcur)\n local skip = dfs(cur+1, a, b, c)\n return math.min(toa, tob, toc, skip)\nend\n\nfor i=1,n do\n bamboos[i] = io.read(\"n\")\nend\nprint(dfs(1,0,0,0))", "problem_context": "Score : 300 points\n\nProblem Statement\n\nYou have N bamboos. The lengths (in centimeters) of these are l_1, l_2, ..., l_N, respectively.\n\nYour objective is to use some of these bamboos (possibly all) to obtain three bamboos of length A, B, C. For that, you can use the following three kinds of magics any number:\n\nExtension Magic: Consumes 1 MP (magic point). Choose one bamboo and increase its length by 1.\n\nShortening Magic: Consumes 1 MP. Choose one bamboo of length at least 2 and decrease its length by 1.\n\nComposition Magic: Consumes 10 MP. Choose two bamboos and combine them into one bamboo. The length of this new bamboo is equal to the sum of the lengths of the two bamboos combined. (Afterwards, further magics can be used on this bamboo.)\n\nAt least how much MP is needed to achieve the objective?\n\nConstraints\n\n3 \\leq N \\leq 8\n\n1 \\leq C < B < A \\leq 1000\n\n1 \\leq l_i \\leq 1000\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN A B C\nl_1\nl_2\n:\nl_N\n\nOutput\n\nPrint the minimum amount of MP needed to achieve the objective.\n\nSample Input 1\n\n5 100 90 80\n98\n40\n30\n21\n80\n\nSample Output 1\n\n23\n\nWe are obtaining three bamboos of lengths 100, 90, 80 from five bamboos 98, 40, 30, 21, 80. We already have a bamboo of length 80, and we can obtain bamboos of lengths 100, 90 by using the magics as follows at the total cost of 23 MP, which is optimal.\n\nUse Extension Magic twice on the bamboo of length 98 to obtain a bamboo of length 100. (MP consumed: 2)\n\nUse Composition Magic on the bamboos of lengths 40, 30 to obtain a bamboo of length 70. (MP consumed: 10)\n\nUse Shortening Magic once on the bamboo of length 21 to obtain a bamboo of length 20. (MP consumed: 1)\n\nUse Composition Magic on the bamboo of length 70 obtained in step 2 and the bamboo of length 20 obtained in step 3 to obtain a bamboo of length 90. (MP consumed: 10)\n\nSample Input 2\n\n8 100 90 80\n100\n100\n90\n90\n90\n80\n80\n80\n\nSample Output 2\n\n0\n\nIf we already have all bamboos of the desired lengths, the amount of MP needed is 0. As seen here, we do not necessarily need to use all the bamboos.\n\nSample Input 3\n\n8 1000 800 100\n300\n333\n400\n444\n500\n555\n600\n666\n\nSample Output 3\n\n243", "sample_input": "5 100 90 80\n98\n40\n30\n21\n80\n"}, "reference_outputs": ["23\n"], "source_document_id": "p03111", "source_text": "Score : 300 points\n\nProblem Statement\n\nYou have N bamboos. The lengths (in centimeters) of these are l_1, l_2, ..., l_N, respectively.\n\nYour objective is to use some of these bamboos (possibly all) to obtain three bamboos of length A, B, C. For that, you can use the following three kinds of magics any number:\n\nExtension Magic: Consumes 1 MP (magic point). Choose one bamboo and increase its length by 1.\n\nShortening Magic: Consumes 1 MP. Choose one bamboo of length at least 2 and decrease its length by 1.\n\nComposition Magic: Consumes 10 MP. Choose two bamboos and combine them into one bamboo. The length of this new bamboo is equal to the sum of the lengths of the two bamboos combined. (Afterwards, further magics can be used on this bamboo.)\n\nAt least how much MP is needed to achieve the objective?\n\nConstraints\n\n3 \\leq N \\leq 8\n\n1 \\leq C < B < A \\leq 1000\n\n1 \\leq l_i \\leq 1000\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN A B C\nl_1\nl_2\n:\nl_N\n\nOutput\n\nPrint the minimum amount of MP needed to achieve the objective.\n\nSample Input 1\n\n5 100 90 80\n98\n40\n30\n21\n80\n\nSample Output 1\n\n23\n\nWe are obtaining three bamboos of lengths 100, 90, 80 from five bamboos 98, 40, 30, 21, 80. We already have a bamboo of length 80, and we can obtain bamboos of lengths 100, 90 by using the magics as follows at the total cost of 23 MP, which is optimal.\n\nUse Extension Magic twice on the bamboo of length 98 to obtain a bamboo of length 100. (MP consumed: 2)\n\nUse Composition Magic on the bamboos of lengths 40, 30 to obtain a bamboo of length 70. (MP consumed: 10)\n\nUse Shortening Magic once on the bamboo of length 21 to obtain a bamboo of length 20. (MP consumed: 1)\n\nUse Composition Magic on the bamboo of length 70 obtained in step 2 and the bamboo of length 20 obtained in step 3 to obtain a bamboo of length 90. (MP consumed: 10)\n\nSample Input 2\n\n8 100 90 80\n100\n100\n90\n90\n90\n80\n80\n80\n\nSample Output 2\n\n0\n\nIf we already have all bamboos of the desired lengths, the amount of MP needed is 0. As seen here, we do not necessarily need to use all the bamboos.\n\nSample Input 3\n\n8 1000 800 100\n300\n333\n400\n444\n500\n555\n600\n666\n\nSample Output 3\n\n243", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 635, "cpu_time_ms": 41, "memory_kb": 256}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s124882184", "group_id": "codeNet:p03125", "input_text": "a, b = io.read(\"*n\", \"*n\")\nprint(b % a == 0 and a + b or b - a)", "language": "Lua", "metadata": {"date": 1558359705, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p03125.html", "problem_id": "p03125", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03125/input.txt", "sample_output_relpath": "derived/input_output/data/p03125/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03125/Lua/s124882184.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s124882184", "user_id": "u120582723"}, "prompt_components": {"gold_output": "16\n", "input_to_evaluate": "a, b = io.read(\"*n\", \"*n\")\nprint(b % a == 0 and a + b or b - a)", "problem_context": "Score : 100 points\n\nProblem Statement\n\nYou are given positive integers A and B.\n\nIf A is a divisor of B, print A + B; otherwise, print B - A.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq A \\leq B \\leq 20\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nIf A is a divisor of B, print A + B; otherwise, print B - A.\n\nSample Input 1\n\n4 12\n\nSample Output 1\n\n16\n\nAs 4 is a divisor of 12, 4 + 12 = 16 should be printed.\n\nSample Input 2\n\n8 20\n\nSample Output 2\n\n12\n\nSample Input 3\n\n1 1\n\nSample Output 3\n\n2\n\n1 is a divisor of 1.", "sample_input": "4 12\n"}, "reference_outputs": ["16\n"], "source_document_id": "p03125", "source_text": "Score : 100 points\n\nProblem Statement\n\nYou are given positive integers A and B.\n\nIf A is a divisor of B, print A + B; otherwise, print B - A.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq A \\leq B \\leq 20\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nIf A is a divisor of B, print A + B; otherwise, print B - A.\n\nSample Input 1\n\n4 12\n\nSample Output 1\n\n16\n\nAs 4 is a divisor of 12, 4 + 12 = 16 should be printed.\n\nSample Input 2\n\n8 20\n\nSample Output 2\n\n12\n\nSample Input 3\n\n1 1\n\nSample Output 3\n\n2\n\n1 is a divisor of 1.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 63, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s444274456", "group_id": "codeNet:p03125", "input_text": "a,b=io.read():match(\"(.+)%s(.+)\")\nprint(string.format(\"%d\",b%a==0 and b+a or b-a))", "language": "Lua", "metadata": {"date": 1551532689, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p03125.html", "problem_id": "p03125", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03125/input.txt", "sample_output_relpath": "derived/input_output/data/p03125/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03125/Lua/s444274456.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s444274456", "user_id": "u837412668"}, "prompt_components": {"gold_output": "16\n", "input_to_evaluate": "a,b=io.read():match(\"(.+)%s(.+)\")\nprint(string.format(\"%d\",b%a==0 and b+a or b-a))", "problem_context": "Score : 100 points\n\nProblem Statement\n\nYou are given positive integers A and B.\n\nIf A is a divisor of B, print A + B; otherwise, print B - A.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq A \\leq B \\leq 20\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nIf A is a divisor of B, print A + B; otherwise, print B - A.\n\nSample Input 1\n\n4 12\n\nSample Output 1\n\n16\n\nAs 4 is a divisor of 12, 4 + 12 = 16 should be printed.\n\nSample Input 2\n\n8 20\n\nSample Output 2\n\n12\n\nSample Input 3\n\n1 1\n\nSample Output 3\n\n2\n\n1 is a divisor of 1.", "sample_input": "4 12\n"}, "reference_outputs": ["16\n"], "source_document_id": "p03125", "source_text": "Score : 100 points\n\nProblem Statement\n\nYou are given positive integers A and B.\n\nIf A is a divisor of B, print A + B; otherwise, print B - A.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq A \\leq B \\leq 20\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nIf A is a divisor of B, print A + B; otherwise, print B - A.\n\nSample Input 1\n\n4 12\n\nSample Output 1\n\n16\n\nAs 4 is a divisor of 12, 4 + 12 = 16 should be printed.\n\nSample Input 2\n\n8 20\n\nSample Output 2\n\n12\n\nSample Input 3\n\n1 1\n\nSample Output 3\n\n2\n\n1 is a divisor of 1.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 82, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s102840170", "group_id": "codeNet:p03126", "input_text": "N=io.read(\"n\")\nM=io.read(\"n\")\nk={}\nA={}\nt={}\nfor i=1,N do\n k[i]=io.read(\"n\")\n A[i]={}\n for j=1,k[i] do\n A[i][j]=io.read(\"n\")\n t[A[i][j]]=(t[A[i][j]] or 0)+1\n end\nend\nlocal count=0\nfor i,v in pairs(t) do\n if v==M then\n count=count+1\n end\nend\nprint(count)\n \n ", "language": "Lua", "metadata": {"date": 1551490965, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03126.html", "problem_id": "p03126", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03126/input.txt", "sample_output_relpath": "derived/input_output/data/p03126/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03126/Lua/s102840170.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s102840170", "user_id": "u015229643"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "N=io.read(\"n\")\nM=io.read(\"n\")\nk={}\nA={}\nt={}\nfor i=1,N do\n k[i]=io.read(\"n\")\n A[i]={}\n for j=1,k[i] do\n A[i][j]=io.read(\"n\")\n t[A[i][j]]=(t[A[i][j]] or 0)+1\n end\nend\nlocal count=0\nfor i,v in pairs(t) do\n if v==M then\n count=count+1\n end\nend\nprint(count)\n \n ", "problem_context": "Score : 200 points\n\nProblem Statement\n\nKatsusando loves omelette rice.\n\nBesides, he loves crème brûlée, tenderloin steak and so on, and believes that these foods are all loved by everyone.\n\nTo prove that hypothesis, he conducted a survey on M kinds of foods and asked N people whether they like these foods or not.\n\nThe i-th person answered that he/she only likes the A_{i1}-th, A_{i2}-th, ..., A_{iK_i}-th food.\n\nFind the number of the foods liked by all the N people.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N, M \\leq 30\n\n1 \\leq K_i \\leq M\n\n1 \\leq A_{ij} \\leq M\n\nFor each i (1 \\leq i \\leq N), A_{i1}, A_{i2}, ..., A_{iK_i} are distinct.\n\nConstraints\n\nInput is given from Standard Input in the following format:\n\nN M\nK_1 A_{11} A_{12} ... A_{1K_1}\nK_2 A_{21} A_{22} ... A_{2K_2}\n:\nK_N A_{N1} A_{N2} ... A_{NK_N}\n\nOutput\n\nPrint the number of the foods liked by all the N people.\n\nSample Input 1\n\n3 4\n2 1 3\n3 1 2 3\n2 3 2\n\nSample Output 1\n\n1\n\nAs only the third food is liked by all the three people, 1 should be printed.\n\nSample Input 2\n\n5 5\n4 2 3 4 5\n4 1 3 4 5\n4 1 2 4 5\n4 1 2 3 5\n4 1 2 3 4\n\nSample Output 2\n\n0\n\nKatsusando's hypothesis turned out to be wrong.\n\nSample Input 3\n\n1 30\n3 5 10 30\n\nSample Output 3\n\n3", "sample_input": "3 4\n2 1 3\n3 1 2 3\n2 3 2\n"}, "reference_outputs": ["1\n"], "source_document_id": "p03126", "source_text": "Score : 200 points\n\nProblem Statement\n\nKatsusando loves omelette rice.\n\nBesides, he loves crème brûlée, tenderloin steak and so on, and believes that these foods are all loved by everyone.\n\nTo prove that hypothesis, he conducted a survey on M kinds of foods and asked N people whether they like these foods or not.\n\nThe i-th person answered that he/she only likes the A_{i1}-th, A_{i2}-th, ..., A_{iK_i}-th food.\n\nFind the number of the foods liked by all the N people.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N, M \\leq 30\n\n1 \\leq K_i \\leq M\n\n1 \\leq A_{ij} \\leq M\n\nFor each i (1 \\leq i \\leq N), A_{i1}, A_{i2}, ..., A_{iK_i} are distinct.\n\nConstraints\n\nInput is given from Standard Input in the following format:\n\nN M\nK_1 A_{11} A_{12} ... A_{1K_1}\nK_2 A_{21} A_{22} ... A_{2K_2}\n:\nK_N A_{N1} A_{N2} ... A_{NK_N}\n\nOutput\n\nPrint the number of the foods liked by all the N people.\n\nSample Input 1\n\n3 4\n2 1 3\n3 1 2 3\n2 3 2\n\nSample Output 1\n\n1\n\nAs only the third food is liked by all the three people, 1 should be printed.\n\nSample Input 2\n\n5 5\n4 2 3 4 5\n4 1 3 4 5\n4 1 2 4 5\n4 1 2 3 5\n4 1 2 3 4\n\nSample Output 2\n\n0\n\nKatsusando's hypothesis turned out to be wrong.\n\nSample Input 3\n\n1 30\n3 5 10 30\n\nSample Output 3\n\n3", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 276, "cpu_time_ms": 6, "memory_kb": 760}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s098567818", "group_id": "codeNet:p03127", "input_text": "local function gcd(a,b)\n if b>0 then\n return gcd(b,a%b)\n else\n return a\n end\nend\n\nlocal n=io.read(\"*n\")\nlocal a={}\nfor i=1,n do\n a[i]=io.read(\"*n\")\nend\nfor i=1,n-1 do\n a[i+1]=gcd(a[i],a[i+1])\nend\nprint(a[n])", "language": "Lua", "metadata": {"date": 1590190565, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03127.html", "problem_id": "p03127", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03127/input.txt", "sample_output_relpath": "derived/input_output/data/p03127/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03127/Lua/s098567818.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s098567818", "user_id": "u045238009"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "local function gcd(a,b)\n if b>0 then\n return gcd(b,a%b)\n else\n return a\n end\nend\n\nlocal n=io.read(\"*n\")\nlocal a={}\nfor i=1,n do\n a[i]=io.read(\"*n\")\nend\nfor i=1,n-1 do\n a[i+1]=gcd(a[i],a[i+1])\nend\nprint(a[n])", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere are N monsters, numbered 1, 2, ..., N.\n\nInitially, the health of Monster i is A_i.\n\nBelow, a monster with at least 1 health is called alive.\n\nUntil there is only one alive monster, the following is repeated:\n\nA random alive monster attacks another random alive monster.\n\nAs a result, the health of the monster attacked is reduced by the amount equal to the current health of the monster attacking.\n\nFind the minimum possible final health of the last monster alive.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 10^5\n\n1 \\leq A_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the minimum possible final health of the last monster alive.\n\nSample Input 1\n\n4\n2 10 8 40\n\nSample Output 1\n\n2\n\nWhen only the first monster keeps on attacking, the final health of the last monster will be 2, which is minimum.\n\nSample Input 2\n\n4\n5 13 8 1000000000\n\nSample Output 2\n\n1\n\nSample Input 3\n\n3\n1000000000 1000000000 1000000000\n\nSample Output 3\n\n1000000000", "sample_input": "4\n2 10 8 40\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03127", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere are N monsters, numbered 1, 2, ..., N.\n\nInitially, the health of Monster i is A_i.\n\nBelow, a monster with at least 1 health is called alive.\n\nUntil there is only one alive monster, the following is repeated:\n\nA random alive monster attacks another random alive monster.\n\nAs a result, the health of the monster attacked is reduced by the amount equal to the current health of the monster attacking.\n\nFind the minimum possible final health of the last monster alive.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 10^5\n\n1 \\leq A_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the minimum possible final health of the last monster alive.\n\nSample Input 1\n\n4\n2 10 8 40\n\nSample Output 1\n\n2\n\nWhen only the first monster keeps on attacking, the final health of the last monster will be 2, which is minimum.\n\nSample Input 2\n\n4\n5 13 8 1000000000\n\nSample Output 2\n\n1\n\nSample Input 3\n\n3\n1000000000 1000000000 1000000000\n\nSample Output 3\n\n1000000000", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 236, "cpu_time_ms": 53, "memory_kb": 2424}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s837676367", "group_id": "codeNet:p03127", "input_text": "local function getgcd(x, y)\n while 0 < x do\n x, y = y % x, x\n end\n return y\nend\nlocal n = io.read(\"*n\")\nlocal a = io.read(\"*n\")\nfor i = 2, n do\n local b = io.read(\"*n\")\n a = getgcd(a, b)\nend\nprint(a)\n", "language": "Lua", "metadata": {"date": 1585108744, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03127.html", "problem_id": "p03127", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03127/input.txt", "sample_output_relpath": "derived/input_output/data/p03127/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03127/Lua/s837676367.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s837676367", "user_id": "u120582723"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "local function getgcd(x, y)\n while 0 < x do\n x, y = y % x, x\n end\n return y\nend\nlocal n = io.read(\"*n\")\nlocal a = io.read(\"*n\")\nfor i = 2, n do\n local b = io.read(\"*n\")\n a = getgcd(a, b)\nend\nprint(a)\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere are N monsters, numbered 1, 2, ..., N.\n\nInitially, the health of Monster i is A_i.\n\nBelow, a monster with at least 1 health is called alive.\n\nUntil there is only one alive monster, the following is repeated:\n\nA random alive monster attacks another random alive monster.\n\nAs a result, the health of the monster attacked is reduced by the amount equal to the current health of the monster attacking.\n\nFind the minimum possible final health of the last monster alive.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 10^5\n\n1 \\leq A_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the minimum possible final health of the last monster alive.\n\nSample Input 1\n\n4\n2 10 8 40\n\nSample Output 1\n\n2\n\nWhen only the first monster keeps on attacking, the final health of the last monster will be 2, which is minimum.\n\nSample Input 2\n\n4\n5 13 8 1000000000\n\nSample Output 2\n\n1\n\nSample Input 3\n\n3\n1000000000 1000000000 1000000000\n\nSample Output 3\n\n1000000000", "sample_input": "4\n2 10 8 40\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03127", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere are N monsters, numbered 1, 2, ..., N.\n\nInitially, the health of Monster i is A_i.\n\nBelow, a monster with at least 1 health is called alive.\n\nUntil there is only one alive monster, the following is repeated:\n\nA random alive monster attacks another random alive monster.\n\nAs a result, the health of the monster attacked is reduced by the amount equal to the current health of the monster attacking.\n\nFind the minimum possible final health of the last monster alive.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 10^5\n\n1 \\leq A_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the minimum possible final health of the last monster alive.\n\nSample Input 1\n\n4\n2 10 8 40\n\nSample Output 1\n\n2\n\nWhen only the first monster keeps on attacking, the final health of the last monster will be 2, which is minimum.\n\nSample Input 2\n\n4\n5 13 8 1000000000\n\nSample Output 2\n\n1\n\nSample Input 3\n\n3\n1000000000 1000000000 1000000000\n\nSample Output 3\n\n1000000000", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 208, "cpu_time_ms": 35, "memory_kb": 760}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s654668855", "group_id": "codeNet:p03127", "input_text": "function gcd(a,b)\n if a 1 do\n attack(hptbl)\n dbgpr_t(hptbl)\n end\n print(hptbl[1])\nend\nmain()\n", "language": "Lua", "metadata": {"date": 1550371967, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03127.html", "problem_id": "p03127", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03127/input.txt", "sample_output_relpath": "derived/input_output/data/p03127/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03127/Lua/s998320166.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s998320166", "user_id": "u162773977"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "local DBG = false\nfunction dbgpr(...)\n if DBG then\n io.write(\"[dbg]\")\n print(...)\n end\nend\nfunction dbgpr_t(tbl)\n if DBG then\n dbgpr(tbl)\n for i,v in ipairs(tbl) do\n io.write(\"[dbg]\")\n print(i,v)\n end\n end\nend\nfunction swap(tbl, i, j)\n local oldj = tbl[j]\n tbl[j] = tbl[i]\n tbl[i] = oldj\nend\nfunction parse_table(N)\n local tbl = {}\n for i=1,N do\n table.insert(tbl, io.read(\"n\"))\n end\n return tbl\nend\nfunction getline()\n local k = io.read(\"n\")\n local tbl = parse_table(k)\n io.read(\"l\")\n return tbl\nend\nfunction attack(hptbl)\n hptbl[2] = hptbl[2] % hptbl[1]\n if hptbl[2] == 0 then\n table.remove(hptbl, 2)\n else\n swap(hptbl, 1, 2)\n end\nend\nfunction main()\n local n = io.read(\"n\")\n io.read(\"l\")\n local hptbl = parse_table(n)\n table.sort(hptbl)\n dbgpr_t(hptbl)\n while #hptbl > 1 do\n attack(hptbl)\n dbgpr_t(hptbl)\n end\n print(hptbl[1])\nend\nmain()\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere are N monsters, numbered 1, 2, ..., N.\n\nInitially, the health of Monster i is A_i.\n\nBelow, a monster with at least 1 health is called alive.\n\nUntil there is only one alive monster, the following is repeated:\n\nA random alive monster attacks another random alive monster.\n\nAs a result, the health of the monster attacked is reduced by the amount equal to the current health of the monster attacking.\n\nFind the minimum possible final health of the last monster alive.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 10^5\n\n1 \\leq A_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the minimum possible final health of the last monster alive.\n\nSample Input 1\n\n4\n2 10 8 40\n\nSample Output 1\n\n2\n\nWhen only the first monster keeps on attacking, the final health of the last monster will be 2, which is minimum.\n\nSample Input 2\n\n4\n5 13 8 1000000000\n\nSample Output 2\n\n1\n\nSample Input 3\n\n3\n1000000000 1000000000 1000000000\n\nSample Output 3\n\n1000000000", "sample_input": "4\n2 10 8 40\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03127", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere are N monsters, numbered 1, 2, ..., N.\n\nInitially, the health of Monster i is A_i.\n\nBelow, a monster with at least 1 health is called alive.\n\nUntil there is only one alive monster, the following is repeated:\n\nA random alive monster attacks another random alive monster.\n\nAs a result, the health of the monster attacked is reduced by the amount equal to the current health of the monster attacking.\n\nFind the minimum possible final health of the last monster alive.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 10^5\n\n1 \\leq A_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the minimum possible final health of the last monster alive.\n\nSample Input 1\n\n4\n2 10 8 40\n\nSample Output 1\n\n2\n\nWhen only the first monster keeps on attacking, the final health of the last monster will be 2, which is minimum.\n\nSample Input 2\n\n4\n5 13 8 1000000000\n\nSample Output 2\n\n1\n\nSample Input 3\n\n3\n1000000000 1000000000 1000000000\n\nSample Output 3\n\n1000000000", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1014, "cpu_time_ms": 2103, "memory_kb": 2424}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s879021330", "group_id": "codeNet:p03127", "input_text": "local DBG = false\nfunction dbgpr(...)\n if DBG then\n io.write(\"[dbg]\")\n print(...)\n end\nend\nfunction dbgpr_t(tbl)\n if DBG then\n dbgpr(tbl)\n for i,v in ipairs(tbl) do\n io.write(\"[dbg]\")\n print(i,v)\n end\n end\nend\nfunction parse_table(N)\n local tbl = {}\n for i=1,N do\n table.insert(tbl, io.read(\"n\"))\n end\n return tbl\nend\nfunction getline()\n local k = io.read(\"n\")\n local tbl = parse_table(k)\n io.read(\"l\")\n return tbl\nend\nfunction attack(hptbl)\n hptbl[2] = hptbl[2] % hptbl[1]\n if hptbl[2] == 0 then\n table.remove(hptbl, 2)\n end\n table.sort(hptbl)\nend\nfunction main()\n local n = io.read(\"n\")\n io.read(\"l\")\n local hptbl = parse_table(n)\n table.sort(hptbl)\n dbgpr_t(hptbl)\n while #hptbl > 1 do\n attack(hptbl)\n dbgpr_t(hptbl)\n end\n print(hptbl[1])\nend\nmain()\n", "language": "Lua", "metadata": {"date": 1550371217, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03127.html", "problem_id": "p03127", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03127/input.txt", "sample_output_relpath": "derived/input_output/data/p03127/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03127/Lua/s879021330.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s879021330", "user_id": "u162773977"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "local DBG = false\nfunction dbgpr(...)\n if DBG then\n io.write(\"[dbg]\")\n print(...)\n end\nend\nfunction dbgpr_t(tbl)\n if DBG then\n dbgpr(tbl)\n for i,v in ipairs(tbl) do\n io.write(\"[dbg]\")\n print(i,v)\n end\n end\nend\nfunction parse_table(N)\n local tbl = {}\n for i=1,N do\n table.insert(tbl, io.read(\"n\"))\n end\n return tbl\nend\nfunction getline()\n local k = io.read(\"n\")\n local tbl = parse_table(k)\n io.read(\"l\")\n return tbl\nend\nfunction attack(hptbl)\n hptbl[2] = hptbl[2] % hptbl[1]\n if hptbl[2] == 0 then\n table.remove(hptbl, 2)\n end\n table.sort(hptbl)\nend\nfunction main()\n local n = io.read(\"n\")\n io.read(\"l\")\n local hptbl = parse_table(n)\n table.sort(hptbl)\n dbgpr_t(hptbl)\n while #hptbl > 1 do\n attack(hptbl)\n dbgpr_t(hptbl)\n end\n print(hptbl[1])\nend\nmain()\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere are N monsters, numbered 1, 2, ..., N.\n\nInitially, the health of Monster i is A_i.\n\nBelow, a monster with at least 1 health is called alive.\n\nUntil there is only one alive monster, the following is repeated:\n\nA random alive monster attacks another random alive monster.\n\nAs a result, the health of the monster attacked is reduced by the amount equal to the current health of the monster attacking.\n\nFind the minimum possible final health of the last monster alive.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 10^5\n\n1 \\leq A_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the minimum possible final health of the last monster alive.\n\nSample Input 1\n\n4\n2 10 8 40\n\nSample Output 1\n\n2\n\nWhen only the first monster keeps on attacking, the final health of the last monster will be 2, which is minimum.\n\nSample Input 2\n\n4\n5 13 8 1000000000\n\nSample Output 2\n\n1\n\nSample Input 3\n\n3\n1000000000 1000000000 1000000000\n\nSample Output 3\n\n1000000000", "sample_input": "4\n2 10 8 40\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03127", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere are N monsters, numbered 1, 2, ..., N.\n\nInitially, the health of Monster i is A_i.\n\nBelow, a monster with at least 1 health is called alive.\n\nUntil there is only one alive monster, the following is repeated:\n\nA random alive monster attacks another random alive monster.\n\nAs a result, the health of the monster attacked is reduced by the amount equal to the current health of the monster attacking.\n\nFind the minimum possible final health of the last monster alive.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 10^5\n\n1 \\leq A_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the minimum possible final health of the last monster alive.\n\nSample Input 1\n\n4\n2 10 8 40\n\nSample Output 1\n\n2\n\nWhen only the first monster keeps on attacking, the final health of the last monster will be 2, which is minimum.\n\nSample Input 2\n\n4\n5 13 8 1000000000\n\nSample Output 2\n\n1\n\nSample Input 3\n\n3\n1000000000 1000000000 1000000000\n\nSample Output 3\n\n1000000000", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 910, "cpu_time_ms": 2107, "memory_kb": 2424}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s809519328", "group_id": "codeNet:p03128", "input_text": "local n, m = io.read(\"*n\", \"*n\")\nlocal a = {}\nfor i = 1, 9 do a[i] = false end\nlocal num_to_line = {2, 5, 5, 4, 5, 6, 3, 7, 6}\nlocal topval = {0, 0, 0, 0, 0, 0, 0}\nfor i = 1, m do\n local tmp = io.read(\"*n\")\n a[tmp] = true\n local line = num_to_line[tmp]\n topval[line] = math.max(topval[line], tmp)\nend\nlocal r = {}\nlocal ins = table.insert\nif a[1] then\n if n % 2 == 1 then\n local tmp = {7, 5, 3, 2, 8}\n for i = 1, 5 do\n if a[tmp[i]] then\n ins(r, tmp[i])\n n = n - num_to_line[tmp[i]]\n break\n end\n end\n end\n for i = 1, n / 2 do ins(r, 1) end\nelseif a[7] then\n if n % 3 == 1 then\n if a[4] then ins(r, 4) n = n - 4\n elseif a[8] then ins(r, 8) n = n - 7\n else ins(r, topval[5]) ins(r, topval[5]) n = n - 10\n end\n elseif n % 3 == 2 then\n if 0 < topval[5] then ins(r, topval[5]) n = n - 5\n elseif a[4] then ins(r, 4) ins(r, 4) n = n - 8\n else ins(r, 8) ins(r, 8) n = n - 14\n end\n end\n for i = 1, n / 3 do ins(r, 7) end\nelseif a[4] then\n if n % 4 == 1 then\n if 0 < topval[5] then ins(r, topval[5]) n = n - 5\n elseif 0 < topval[6] then ins(r, topval[6]) ins(r, 8) n = n - 13\n else ins(r, 8) ins(r, 8) ins(r, 8) n = n - 21\n end\n elseif n % 4 == 2 then\n if 0 < topval[6] then ins(r, topval[6]) n = n - 6\n elseif 0 < topval[5] then ins(r, topval[5]) ins(r, topval[5]) n = n - 10\n else ins(r, 8) ins(r, 8) n = n - 14\n end\n elseif n % 4 == 3 then\n if a[9] and 0 < topval[5] then ins(r, 9) ins(r, topval[5]) n = n - 11\n elseif a[8] then ins(r, 8) n = n - 7\n elseif a[6] then ins(r, 6) ins(r, topval[5]) n = n - 11\n else ins(r, topval[5]) ins(r, topval[5]) ins(r, topval[5]) n = n - 15\n end\n end\n for i = 1, n / 4 do ins(r, 4) end\nelseif 0 < topval[5] then\n if n % 5 == 1 then\n if 0 < topval[6] then ins(r, topval[6]) n = n - 6\n else ins(r, 8) ins(r, 8) ins(r, 8) n = n - 21\n end\n elseif n % 5 == 2 then\n if a[9] then ins(r, 9) ins(r, 9) n = n - 12\n elseif a[8] then ins(r, 8) n = n - 7\n else ins(r, 6) ins(r, 6) n = n - 12\n end\n elseif n % 5 == 3 then\n if 0 < topval[6] and a[8] then ins(r, topval[6]) ins(r, 8) n = n - 13\n elseif 0 < topval[6] then ins(r, topval[6]) ins(r, topval[6]) ins(r, topval[6]) n = n - 18\n else ins(r, 8) ins(r, 8) ins(r, 8) ins(r, 8) n = n - 28\n end\n elseif n % 5 == 4 then\n if a[8] then ins(r, 8) ins(r, 8) n = n - 14\n else\n for i = 1, 4 do ins(r, topval[6]) end\n n = n - 24\n end\n end\n for i = 1, n / 5 do ins(r, topval[5]) end\nelseif 0 < topval[6] then\n for i = 1, n % 6 do ins(r, 8) end\n n = n - 7 * (n % 6)\n for i = 1, n / 6 do ins(r, topval[6]) end\nelse\n for i = 1, n / 7 do ins(r, 8) end\nend\ntable.sort(r, function(a, b) return a > b end)\nprint(table.concat(r, \"\"))\n", "language": "Lua", "metadata": {"date": 1566102860, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p03128.html", "problem_id": "p03128", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03128/input.txt", "sample_output_relpath": "derived/input_output/data/p03128/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03128/Lua/s809519328.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s809519328", "user_id": "u120582723"}, "prompt_components": {"gold_output": "777773\n", "input_to_evaluate": "local n, m = io.read(\"*n\", \"*n\")\nlocal a = {}\nfor i = 1, 9 do a[i] = false end\nlocal num_to_line = {2, 5, 5, 4, 5, 6, 3, 7, 6}\nlocal topval = {0, 0, 0, 0, 0, 0, 0}\nfor i = 1, m do\n local tmp = io.read(\"*n\")\n a[tmp] = true\n local line = num_to_line[tmp]\n topval[line] = math.max(topval[line], tmp)\nend\nlocal r = {}\nlocal ins = table.insert\nif a[1] then\n if n % 2 == 1 then\n local tmp = {7, 5, 3, 2, 8}\n for i = 1, 5 do\n if a[tmp[i]] then\n ins(r, tmp[i])\n n = n - num_to_line[tmp[i]]\n break\n end\n end\n end\n for i = 1, n / 2 do ins(r, 1) end\nelseif a[7] then\n if n % 3 == 1 then\n if a[4] then ins(r, 4) n = n - 4\n elseif a[8] then ins(r, 8) n = n - 7\n else ins(r, topval[5]) ins(r, topval[5]) n = n - 10\n end\n elseif n % 3 == 2 then\n if 0 < topval[5] then ins(r, topval[5]) n = n - 5\n elseif a[4] then ins(r, 4) ins(r, 4) n = n - 8\n else ins(r, 8) ins(r, 8) n = n - 14\n end\n end\n for i = 1, n / 3 do ins(r, 7) end\nelseif a[4] then\n if n % 4 == 1 then\n if 0 < topval[5] then ins(r, topval[5]) n = n - 5\n elseif 0 < topval[6] then ins(r, topval[6]) ins(r, 8) n = n - 13\n else ins(r, 8) ins(r, 8) ins(r, 8) n = n - 21\n end\n elseif n % 4 == 2 then\n if 0 < topval[6] then ins(r, topval[6]) n = n - 6\n elseif 0 < topval[5] then ins(r, topval[5]) ins(r, topval[5]) n = n - 10\n else ins(r, 8) ins(r, 8) n = n - 14\n end\n elseif n % 4 == 3 then\n if a[9] and 0 < topval[5] then ins(r, 9) ins(r, topval[5]) n = n - 11\n elseif a[8] then ins(r, 8) n = n - 7\n elseif a[6] then ins(r, 6) ins(r, topval[5]) n = n - 11\n else ins(r, topval[5]) ins(r, topval[5]) ins(r, topval[5]) n = n - 15\n end\n end\n for i = 1, n / 4 do ins(r, 4) end\nelseif 0 < topval[5] then\n if n % 5 == 1 then\n if 0 < topval[6] then ins(r, topval[6]) n = n - 6\n else ins(r, 8) ins(r, 8) ins(r, 8) n = n - 21\n end\n elseif n % 5 == 2 then\n if a[9] then ins(r, 9) ins(r, 9) n = n - 12\n elseif a[8] then ins(r, 8) n = n - 7\n else ins(r, 6) ins(r, 6) n = n - 12\n end\n elseif n % 5 == 3 then\n if 0 < topval[6] and a[8] then ins(r, topval[6]) ins(r, 8) n = n - 13\n elseif 0 < topval[6] then ins(r, topval[6]) ins(r, topval[6]) ins(r, topval[6]) n = n - 18\n else ins(r, 8) ins(r, 8) ins(r, 8) ins(r, 8) n = n - 28\n end\n elseif n % 5 == 4 then\n if a[8] then ins(r, 8) ins(r, 8) n = n - 14\n else\n for i = 1, 4 do ins(r, topval[6]) end\n n = n - 24\n end\n end\n for i = 1, n / 5 do ins(r, topval[5]) end\nelseif 0 < topval[6] then\n for i = 1, n % 6 do ins(r, 8) end\n n = n - 7 * (n % 6)\n for i = 1, n / 6 do ins(r, topval[6]) end\nelse\n for i = 1, n / 7 do ins(r, 8) end\nend\ntable.sort(r, function(a, b) return a > b end)\nprint(table.concat(r, \"\"))\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nFind the largest integer that can be formed with exactly N matchsticks, under the following conditions:\n\nEvery digit in the integer must be one of the digits A_1, A_2, ..., A_M (1 \\leq A_i \\leq 9).\n\nThe number of matchsticks used to form digits 1, 2, 3, 4, 5, 6, 7, 8, 9 should be 2, 5, 5, 4, 5, 6, 3, 7, 6, respectively.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 10^4\n\n1 \\leq M \\leq 9\n\n1 \\leq A_i \\leq 9\n\nA_i are all different.\n\nThere exists an integer that can be formed by exactly N matchsticks under the conditions.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nA_1 A_2 ... A_M\n\nOutput\n\nPrint the largest integer that can be formed with exactly N matchsticks under the conditions in the problem statement.\n\nSample Input 1\n\n20 4\n3 7 8 4\n\nSample Output 1\n\n777773\n\nThe integer 777773 can be formed with 3 + 3 + 3 + 3 + 3 + 5 = 20 matchsticks, and this is the largest integer that can be formed by 20 matchsticks under the conditions.\n\nSample Input 2\n\n101 9\n9 8 7 6 5 4 3 2 1\n\nSample Output 2\n\n71111111111111111111111111111111111111111111111111\n\nThe output may not fit into a 64-bit integer type.\n\nSample Input 3\n\n15 3\n5 4 6\n\nSample Output 3\n\n654", "sample_input": "20 4\n3 7 8 4\n"}, "reference_outputs": ["777773\n"], "source_document_id": "p03128", "source_text": "Score : 400 points\n\nProblem Statement\n\nFind the largest integer that can be formed with exactly N matchsticks, under the following conditions:\n\nEvery digit in the integer must be one of the digits A_1, A_2, ..., A_M (1 \\leq A_i \\leq 9).\n\nThe number of matchsticks used to form digits 1, 2, 3, 4, 5, 6, 7, 8, 9 should be 2, 5, 5, 4, 5, 6, 3, 7, 6, respectively.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 10^4\n\n1 \\leq M \\leq 9\n\n1 \\leq A_i \\leq 9\n\nA_i are all different.\n\nThere exists an integer that can be formed by exactly N matchsticks under the conditions.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nA_1 A_2 ... A_M\n\nOutput\n\nPrint the largest integer that can be formed with exactly N matchsticks under the conditions in the problem statement.\n\nSample Input 1\n\n20 4\n3 7 8 4\n\nSample Output 1\n\n777773\n\nThe integer 777773 can be formed with 3 + 3 + 3 + 3 + 3 + 5 = 20 matchsticks, and this is the largest integer that can be formed by 20 matchsticks under the conditions.\n\nSample Input 2\n\n101 9\n9 8 7 6 5 4 3 2 1\n\nSample Output 2\n\n71111111111111111111111111111111111111111111111111\n\nThe output may not fit into a 64-bit integer type.\n\nSample Input 3\n\n15 3\n5 4 6\n\nSample Output 3\n\n654", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2764, "cpu_time_ms": 6, "memory_kb": 256}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s802703490", "group_id": "codeNet:p03131", "input_text": "local k, a, b = io.read(\"*n\", \"*n\", \"*n\")\nif b - a <= 2 then\n print(k + 1)\nelseif k < a + 1 then\n print(k + 1)\nelse\n k = k - (a - 1)\n local mul = k // 2\n print(a + mul * (b - a) + k % 2)\nend\n", "language": "Lua", "metadata": {"date": 1564108892, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03131.html", "problem_id": "p03131", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03131/input.txt", "sample_output_relpath": "derived/input_output/data/p03131/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03131/Lua/s802703490.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s802703490", "user_id": "u120582723"}, "prompt_components": {"gold_output": "7\n", "input_to_evaluate": "local k, a, b = io.read(\"*n\", \"*n\", \"*n\")\nif b - a <= 2 then\n print(k + 1)\nelseif k < a + 1 then\n print(k + 1)\nelse\n k = k - (a - 1)\n local mul = k // 2\n print(a + mul * (b - a) + k % 2)\nend\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nSnuke has one biscuit and zero Japanese yen (the currency) in his pocket.\nHe will perform the following operations exactly K times in total, in the order he likes:\n\nHit his pocket, which magically increases the number of biscuits by one.\n\nExchange A biscuits to 1 yen.\n\nExchange 1 yen to B biscuits.\n\nFind the maximum possible number of biscuits in Snuke's pocket after K operations.\n\nConstraints\n\n1 \\leq K,A,B \\leq 10^9\n\nK,A and B are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nK A B\n\nOutput\n\nPrint the maximum possible number of biscuits in Snuke's pocket after K operations.\n\nSample Input 1\n\n4 2 6\n\nSample Output 1\n\n7\n\nThe number of biscuits in Snuke's pocket after K operations is maximized as follows:\n\nHit his pocket. Now he has 2 biscuits and 0 yen.\n\nExchange 2 biscuits to 1 yen. his pocket. Now he has 0 biscuits and 1 yen.\n\nHit his pocket. Now he has 1 biscuits and 1 yen.\n\nExchange 1 yen to 6 biscuits. his pocket. Now he has 7 biscuits and 0 yen.\n\nSample Input 2\n\n7 3 4\n\nSample Output 2\n\n8\n\nSample Input 3\n\n314159265 35897932 384626433\n\nSample Output 3\n\n48518828981938099", "sample_input": "4 2 6\n"}, "reference_outputs": ["7\n"], "source_document_id": "p03131", "source_text": "Score : 400 points\n\nProblem Statement\n\nSnuke has one biscuit and zero Japanese yen (the currency) in his pocket.\nHe will perform the following operations exactly K times in total, in the order he likes:\n\nHit his pocket, which magically increases the number of biscuits by one.\n\nExchange A biscuits to 1 yen.\n\nExchange 1 yen to B biscuits.\n\nFind the maximum possible number of biscuits in Snuke's pocket after K operations.\n\nConstraints\n\n1 \\leq K,A,B \\leq 10^9\n\nK,A and B are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nK A B\n\nOutput\n\nPrint the maximum possible number of biscuits in Snuke's pocket after K operations.\n\nSample Input 1\n\n4 2 6\n\nSample Output 1\n\n7\n\nThe number of biscuits in Snuke's pocket after K operations is maximized as follows:\n\nHit his pocket. Now he has 2 biscuits and 0 yen.\n\nExchange 2 biscuits to 1 yen. his pocket. Now he has 0 biscuits and 1 yen.\n\nHit his pocket. Now he has 1 biscuits and 1 yen.\n\nExchange 1 yen to 6 biscuits. his pocket. Now he has 7 biscuits and 0 yen.\n\nSample Input 2\n\n7 3 4\n\nSample Output 2\n\n8\n\nSample Input 3\n\n314159265 35897932 384626433\n\nSample Output 3\n\n48518828981938099", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 196, "cpu_time_ms": 7, "memory_kb": 760}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s585161987", "group_id": "codeNet:p03135", "input_text": "T=io.read(\"n\")\nX=io.read(\"n\")\nprint(T/X)", "language": "Lua", "metadata": {"date": 1549997162, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03135.html", "problem_id": "p03135", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03135/input.txt", "sample_output_relpath": "derived/input_output/data/p03135/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03135/Lua/s585161987.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s585161987", "user_id": "u015229643"}, "prompt_components": {"gold_output": "2.6666666667\n", "input_to_evaluate": "T=io.read(\"n\")\nX=io.read(\"n\")\nprint(T/X)", "problem_context": "Score : 100 points\n\nProblem Statement\n\nIn order to pass the entrance examination tomorrow, Taro has to study for T more hours.\n\nFortunately, he can leap to World B where time passes X times as fast as it does in our world (World A).\n\nWhile (X \\times t) hours pass in World B, t hours pass in World A.\n\nHow many hours will pass in World A while Taro studies for T hours in World B?\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq T \\leq 100\n\n1 \\leq X \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nT X\n\nOutput\n\nPrint the number of hours that will pass in World A.\n\nThe output will be regarded as correct when its absolute or relative error from the judge's output is at most 10^{-3}.\n\nSample Input 1\n\n8 3\n\nSample Output 1\n\n2.6666666667\n\nWhile Taro studies for eight hours in World B where time passes three times as fast, 2.6666... hours will pass in World A.\n\nNote that an absolute or relative error of at most 10^{-3} is allowed.\n\nSample Input 2\n\n99 1\n\nSample Output 2\n\n99.0000000000\n\nSample Input 3\n\n1 100\n\nSample Output 3\n\n0.0100000000", "sample_input": "8 3\n"}, "reference_outputs": ["2.6666666667\n"], "source_document_id": "p03135", "source_text": "Score : 100 points\n\nProblem Statement\n\nIn order to pass the entrance examination tomorrow, Taro has to study for T more hours.\n\nFortunately, he can leap to World B where time passes X times as fast as it does in our world (World A).\n\nWhile (X \\times t) hours pass in World B, t hours pass in World A.\n\nHow many hours will pass in World A while Taro studies for T hours in World B?\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq T \\leq 100\n\n1 \\leq X \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nT X\n\nOutput\n\nPrint the number of hours that will pass in World A.\n\nThe output will be regarded as correct when its absolute or relative error from the judge's output is at most 10^{-3}.\n\nSample Input 1\n\n8 3\n\nSample Output 1\n\n2.6666666667\n\nWhile Taro studies for eight hours in World B where time passes three times as fast, 2.6666... hours will pass in World A.\n\nNote that an absolute or relative error of at most 10^{-3} is allowed.\n\nSample Input 2\n\n99 1\n\nSample Output 2\n\n99.0000000000\n\nSample Input 3\n\n1 100\n\nSample Output 3\n\n0.0100000000", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 40, "cpu_time_ms": 7, "memory_kb": 888}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s115690475", "group_id": "codeNet:p03137", "input_text": "local DBG = false\nfunction dbgpr(...)\n if DBG then\n io.write(\"[dbg]\")\n print(...)\n end\nend\nfunction dbgpr_t(tbl)\n if DBG then\n dbgpr(tbl)\n io.write(\"[dbg]\")\n for i,v in ipairs(tbl) do\n io.write(i)\n io.write(\":\")\n io.write(tostring(v))\n io.write(\" \")\n end\n print(\"\")\n end\nend\n\nfunction parse_problem()\n local N = io.read(\"n\")\n local M = io.read(\"n\")\n local goals = {}\n for i=1,M do\n local l, _ = io.read(\"n\")\n table.insert(goals, l)\n end\n return N, M, goals\nend\n\nfunction main()\n local N, M, goals = parse_problem()\n table.sort(goals)\n local INF = 10000000\n local diffs = {}\n for i=1, #goals-1 do\n diffs[i] = goals[i + 1] - goals[i]\n end\n table.sort(diffs)\n dbgpr_t(goals)\n dbgpr_t(diffs)\n if N >= M then\n print(0)\n else\n local sum = 0\n for i=1, M-N do\n sum = sum + diffs[i]\n end\n print(sum)\n end\nend\nmain()\n", "language": "Lua", "metadata": {"date": 1551587797, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03137.html", "problem_id": "p03137", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03137/input.txt", "sample_output_relpath": "derived/input_output/data/p03137/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03137/Lua/s115690475.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s115690475", "user_id": "u162773977"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "local DBG = false\nfunction dbgpr(...)\n if DBG then\n io.write(\"[dbg]\")\n print(...)\n end\nend\nfunction dbgpr_t(tbl)\n if DBG then\n dbgpr(tbl)\n io.write(\"[dbg]\")\n for i,v in ipairs(tbl) do\n io.write(i)\n io.write(\":\")\n io.write(tostring(v))\n io.write(\" \")\n end\n print(\"\")\n end\nend\n\nfunction parse_problem()\n local N = io.read(\"n\")\n local M = io.read(\"n\")\n local goals = {}\n for i=1,M do\n local l, _ = io.read(\"n\")\n table.insert(goals, l)\n end\n return N, M, goals\nend\n\nfunction main()\n local N, M, goals = parse_problem()\n table.sort(goals)\n local INF = 10000000\n local diffs = {}\n for i=1, #goals-1 do\n diffs[i] = goals[i + 1] - goals[i]\n end\n table.sort(diffs)\n dbgpr_t(goals)\n dbgpr_t(diffs)\n if N >= M then\n print(0)\n else\n local sum = 0\n for i=1, M-N do\n sum = sum + diffs[i]\n end\n print(sum)\n end\nend\nmain()\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nWe will play a one-player game using a number line and N pieces.\n\nFirst, we place each of these pieces at some integer coordinate.\n\nHere, multiple pieces can be placed at the same coordinate.\n\nOur objective is to visit all of the M coordinates X_1, X_2, ..., X_M with these pieces, by repeating the following move:\n\nMove: Choose a piece and let x be its coordinate. Put that piece at coordinate x+1 or x-1.\n\nNote that the coordinates where we initially place the pieces are already regarded as visited.\n\nFind the minimum number of moves required to achieve the objective.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^5\n\n-10^5 \\leq X_i \\leq 10^5\n\nX_1, X_2, ..., X_M are all different.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nX_1 X_2 ... X_M\n\nOutput\n\nFind the minimum number of moves required to achieve the objective.\n\nSample Input 1\n\n2 5\n10 12 1 2 14\n\nSample Output 1\n\n5\n\nThe objective can be achieved in five moves as follows, and this is the minimum number of moves required.\n\nInitially, put the two pieces at coordinates 1 and 10.\n\nMove the piece at coordinate 1 to 2.\n\nMove the piece at coordinate 10 to 11.\n\nMove the piece at coordinate 11 to 12.\n\nMove the piece at coordinate 12 to 13.\n\nMove the piece at coordinate 13 to 14.\n\nSample Input 2\n\n3 7\n-10 -3 0 9 -100 2 17\n\nSample Output 2\n\n19\n\nSample Input 3\n\n100 1\n-100000\n\nSample Output 3\n\n0", "sample_input": "2 5\n10 12 1 2 14\n"}, "reference_outputs": ["5\n"], "source_document_id": "p03137", "source_text": "Score : 300 points\n\nProblem Statement\n\nWe will play a one-player game using a number line and N pieces.\n\nFirst, we place each of these pieces at some integer coordinate.\n\nHere, multiple pieces can be placed at the same coordinate.\n\nOur objective is to visit all of the M coordinates X_1, X_2, ..., X_M with these pieces, by repeating the following move:\n\nMove: Choose a piece and let x be its coordinate. Put that piece at coordinate x+1 or x-1.\n\nNote that the coordinates where we initially place the pieces are already regarded as visited.\n\nFind the minimum number of moves required to achieve the objective.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^5\n\n-10^5 \\leq X_i \\leq 10^5\n\nX_1, X_2, ..., X_M are all different.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nX_1 X_2 ... X_M\n\nOutput\n\nFind the minimum number of moves required to achieve the objective.\n\nSample Input 1\n\n2 5\n10 12 1 2 14\n\nSample Output 1\n\n5\n\nThe objective can be achieved in five moves as follows, and this is the minimum number of moves required.\n\nInitially, put the two pieces at coordinates 1 and 10.\n\nMove the piece at coordinate 1 to 2.\n\nMove the piece at coordinate 10 to 11.\n\nMove the piece at coordinate 11 to 12.\n\nMove the piece at coordinate 12 to 13.\n\nMove the piece at coordinate 13 to 14.\n\nSample Input 2\n\n3 7\n-10 -3 0 9 -100 2 17\n\nSample Output 2\n\n19\n\nSample Input 3\n\n100 1\n-100000\n\nSample Output 3\n\n0", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1033, "cpu_time_ms": 168, "memory_kb": 4600}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s119269873", "group_id": "codeNet:p03141", "input_text": "local n=io.read(\"n\")\nlocal t={}\nfor i=1,n do\n t[i]={io.read(\"n\",\"n\")}\nend\ntable.sort(t,function(a,b)\n return a[1]+a[2]>b[1]+b[2]\nend)\n\nlocal total=0\nfor i=1,n do\n total=total-t[i][2]\nend\nfor i=1,n,2 do\n total=total+t[i][1]+t[i][2]\nend\nprint(total)", "language": "Lua", "metadata": {"date": 1595380491, "filename_ext": "lua", "original_language": "Lua (Lua 5.3.5)", "problem_description_relpath": "problem_descriptions/p03141.html", "problem_id": "p03141", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03141/input.txt", "sample_output_relpath": "derived/input_output/data/p03141/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03141/Lua/s119269873.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s119269873", "user_id": "u045238009"}, "prompt_components": {"gold_output": "20\n", "input_to_evaluate": "local n=io.read(\"n\")\nlocal t={}\nfor i=1,n do\n t[i]={io.read(\"n\",\"n\")}\nend\ntable.sort(t,function(a,b)\n return a[1]+a[2]>b[1]+b[2]\nend)\n\nlocal total=0\nfor i=1,n do\n total=total-t[i][2]\nend\nfor i=1,n,2 do\n total=total+t[i][1]+t[i][2]\nend\nprint(total)", "problem_context": "Score : 400 points\n\nProblem Statement\n\nThere are N dishes of cuisine placed in front of Takahashi and Aoki.\nFor convenience, we call these dishes Dish 1, Dish 2, ..., Dish N.\n\nWhen Takahashi eats Dish i, he earns A_i points of happiness; when Aoki eats Dish i, she earns B_i points of happiness.\n\nStarting from Takahashi, they alternately choose one dish and eat it, until there is no more dish to eat.\nHere, both of them choose dishes so that the following value is maximized: \"the sum of the happiness he/she will earn in the end\" minus \"the sum of the happiness the other person will earn in the end\".\n\nFind the value: \"the sum of the happiness Takahashi earns in the end\" minus \"the sum of the happiness Aoki earns in the end\".\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n1 \\leq A_i \\leq 10^9\n\n1 \\leq B_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 B_1\n:\nA_N B_N\n\nOutput\n\nPrint the value: \"the sum of the happiness Takahashi earns in the end\" minus \"the sum of the happiness Aoki earns in the end\".\n\nSample Input 1\n\n3\n10 10\n20 20\n30 30\n\nSample Output 1\n\n20\n\nIn this sample, both of them earns 10 points of happiness by eating Dish 1, 20 points by eating Dish 2, and 30 points by eating Dish 3.\n\nIn this case, since Takahashi and Aoki have the same \"taste\", each time they will choose the dish with which they can earn the greatest happiness. Thus, first Takahashi will choose Dish 3, then Aoki will choose Dish 2, and finally Takahashi will choose Dish 1, so the answer is (30 + 10) - 20 = 20.\n\nSample Input 2\n\n3\n20 10\n20 20\n20 30\n\nSample Output 2\n\n20\n\nIn this sample, Takahashi earns 20 points of happiness by eating any one of the dishes 1, 2 and 3, but Aoki earns 10 points of happiness by eating Dish 1, 20 points by eating Dish 2, and 30 points by eating Dish 3.\n\nIn this case, since only Aoki has likes and dislikes, each time they will choose the dish with which Aoki can earn the greatest happiness. Thus, first Takahashi will choose Dish 3, then Aoki will choose Dish 2, and finally Takahashi will choose Dish 1, so the answer is (20 + 20) - 20 = 20.\n\nSample Input 3\n\n6\n1 1000000000\n1 1000000000\n1 1000000000\n1 1000000000\n1 1000000000\n1 1000000000\n\nSample Output 3\n\n-2999999997\n\nNote that the answer may not fit into a 32-bit integer.", "sample_input": "3\n10 10\n20 20\n30 30\n"}, "reference_outputs": ["20\n"], "source_document_id": "p03141", "source_text": "Score : 400 points\n\nProblem Statement\n\nThere are N dishes of cuisine placed in front of Takahashi and Aoki.\nFor convenience, we call these dishes Dish 1, Dish 2, ..., Dish N.\n\nWhen Takahashi eats Dish i, he earns A_i points of happiness; when Aoki eats Dish i, she earns B_i points of happiness.\n\nStarting from Takahashi, they alternately choose one dish and eat it, until there is no more dish to eat.\nHere, both of them choose dishes so that the following value is maximized: \"the sum of the happiness he/she will earn in the end\" minus \"the sum of the happiness the other person will earn in the end\".\n\nFind the value: \"the sum of the happiness Takahashi earns in the end\" minus \"the sum of the happiness Aoki earns in the end\".\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n1 \\leq A_i \\leq 10^9\n\n1 \\leq B_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 B_1\n:\nA_N B_N\n\nOutput\n\nPrint the value: \"the sum of the happiness Takahashi earns in the end\" minus \"the sum of the happiness Aoki earns in the end\".\n\nSample Input 1\n\n3\n10 10\n20 20\n30 30\n\nSample Output 1\n\n20\n\nIn this sample, both of them earns 10 points of happiness by eating Dish 1, 20 points by eating Dish 2, and 30 points by eating Dish 3.\n\nIn this case, since Takahashi and Aoki have the same \"taste\", each time they will choose the dish with which they can earn the greatest happiness. Thus, first Takahashi will choose Dish 3, then Aoki will choose Dish 2, and finally Takahashi will choose Dish 1, so the answer is (30 + 10) - 20 = 20.\n\nSample Input 2\n\n3\n20 10\n20 20\n20 30\n\nSample Output 2\n\n20\n\nIn this sample, Takahashi earns 20 points of happiness by eating any one of the dishes 1, 2 and 3, but Aoki earns 10 points of happiness by eating Dish 1, 20 points by eating Dish 2, and 30 points by eating Dish 3.\n\nIn this case, since only Aoki has likes and dislikes, each time they will choose the dish with which Aoki can earn the greatest happiness. Thus, first Takahashi will choose Dish 3, then Aoki will choose Dish 2, and finally Takahashi will choose Dish 1, so the answer is (20 + 20) - 20 = 20.\n\nSample Input 3\n\n6\n1 1000000000\n1 1000000000\n1 1000000000\n1 1000000000\n1 1000000000\n1 1000000000\n\nSample Output 3\n\n-2999999997\n\nNote that the answer may not fit into a 32-bit integer.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 259, "cpu_time_ms": 273, "memory_kb": 15352}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s447025861", "group_id": "codeNet:p03142", "input_text": "local n, m = io.read(\"*n\", \"*n\")\nlocal edge_c, edge_p_cnt = {}, {}\nlocal p = {}\nfor i = 1, n do\n edge_c[i] = {}\n edge_p_cnt[i] = 0\n p[i] = 0\nend\nfor i = 1, n + m - 1 do\n local a, b = io.read(\"*n\", \"*n\")\n table.insert(edge_c[a], b)\n edge_p_cnt[b] = edge_p_cnt[b] + 1\nend\n\nlocal tasks = {}\nfor i = 1, n do\n if edge_p_cnt[i] == 0 then\n p[i] = 0\n table.insert(tasks, i)\n end\nend\n\nwhile 0 < #tasks do\n local src = tasks[#tasks]\n table.remove(tasks)\n for i = 1, #edge_c[src] do\n local dst = edge_c[src][i]\n edge_p_cnt[dst] = edge_p_cnt[dst] - 1\n if edge_p_cnt[dst] == 0 then\n p[dst] = src\n table.insert(tasks, dst)\n end\n end\nend\nfor i = 1, n do\n print(p[i])\nend\n", "language": "Lua", "metadata": {"date": 1569332193, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p03142.html", "problem_id": "p03142", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03142/input.txt", "sample_output_relpath": "derived/input_output/data/p03142/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03142/Lua/s447025861.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s447025861", "user_id": "u120582723"}, "prompt_components": {"gold_output": "0\n1\n2\n", "input_to_evaluate": "local n, m = io.read(\"*n\", \"*n\")\nlocal edge_c, edge_p_cnt = {}, {}\nlocal p = {}\nfor i = 1, n do\n edge_c[i] = {}\n edge_p_cnt[i] = 0\n p[i] = 0\nend\nfor i = 1, n + m - 1 do\n local a, b = io.read(\"*n\", \"*n\")\n table.insert(edge_c[a], b)\n edge_p_cnt[b] = edge_p_cnt[b] + 1\nend\n\nlocal tasks = {}\nfor i = 1, n do\n if edge_p_cnt[i] == 0 then\n p[i] = 0\n table.insert(tasks, i)\n end\nend\n\nwhile 0 < #tasks do\n local src = tasks[#tasks]\n table.remove(tasks)\n for i = 1, #edge_c[src] do\n local dst = edge_c[src][i]\n edge_p_cnt[dst] = edge_p_cnt[dst] - 1\n if edge_p_cnt[dst] == 0 then\n p[dst] = src\n table.insert(tasks, dst)\n end\n end\nend\nfor i = 1, n do\n print(p[i])\nend\n", "problem_context": "Score : 500 points\n\nProblem Statement\n\nThere is a rooted tree (see Notes) with N vertices numbered 1 to N.\nEach of the vertices, except the root, has a directed edge coming from its parent.\nNote that the root may not be Vertex 1.\n\nTakahashi has added M new directed edges to this graph.\nEach of these M edges, u \\rightarrow v, extends from some vertex u to its descendant v.\n\nYou are given the directed graph with N vertices and N-1+M edges after Takahashi added edges.\nMore specifically, you are given N-1+M pairs of integers, (A_1, B_1), ..., (A_{N-1+M}, B_{N-1+M}), which represent that the i-th edge extends from Vertex A_i to Vertex B_i.\n\nRestore the original rooted tree.\n\nNotes\n\nFor \"tree\" and other related terms in graph theory, see the article in Wikipedia, for example.\n\nConstraints\n\n3 \\leq N\n\n1 \\leq M\n\nN + M \\leq 10^5\n\n1 \\leq A_i, B_i \\leq N\n\nA_i \\neq B_i\n\nIf i \\neq j, (A_i, B_i) \\neq (A_j, B_j).\n\nThe graph in input can be obtained by adding M edges satisfying the condition in the problem statement to a rooted tree with N vertices.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nA_1 B_1\n:\nA_{N-1+M} B_{N-1+M}\n\nOutput\n\nPrint N lines.\nIn the i-th line, print 0 if Vertex i is the root of the original tree, and otherwise print the integer representing the parent of Vertex i in the original tree.\n\nNote that it can be shown that the original tree is uniquely determined.\n\nSample Input 1\n\n3 1\n1 2\n1 3\n2 3\n\nSample Output 1\n\n0\n1\n2\n\nThe graph in this input is shown below:\n\nIt can be seen that this graph is obtained by adding the edge 1 \\rightarrow 3 to the rooted tree 1 \\rightarrow 2 \\rightarrow 3.\n\nSample Input 2\n\n6 3\n2 1\n2 3\n4 1\n4 2\n6 1\n2 6\n4 6\n6 5\n\nSample Output 2\n\n6\n4\n2\n0\n6\n2", "sample_input": "3 1\n1 2\n1 3\n2 3\n"}, "reference_outputs": ["0\n1\n2\n"], "source_document_id": "p03142", "source_text": "Score : 500 points\n\nProblem Statement\n\nThere is a rooted tree (see Notes) with N vertices numbered 1 to N.\nEach of the vertices, except the root, has a directed edge coming from its parent.\nNote that the root may not be Vertex 1.\n\nTakahashi has added M new directed edges to this graph.\nEach of these M edges, u \\rightarrow v, extends from some vertex u to its descendant v.\n\nYou are given the directed graph with N vertices and N-1+M edges after Takahashi added edges.\nMore specifically, you are given N-1+M pairs of integers, (A_1, B_1), ..., (A_{N-1+M}, B_{N-1+M}), which represent that the i-th edge extends from Vertex A_i to Vertex B_i.\n\nRestore the original rooted tree.\n\nNotes\n\nFor \"tree\" and other related terms in graph theory, see the article in Wikipedia, for example.\n\nConstraints\n\n3 \\leq N\n\n1 \\leq M\n\nN + M \\leq 10^5\n\n1 \\leq A_i, B_i \\leq N\n\nA_i \\neq B_i\n\nIf i \\neq j, (A_i, B_i) \\neq (A_j, B_j).\n\nThe graph in input can be obtained by adding M edges satisfying the condition in the problem statement to a rooted tree with N vertices.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nA_1 B_1\n:\nA_{N-1+M} B_{N-1+M}\n\nOutput\n\nPrint N lines.\nIn the i-th line, print 0 if Vertex i is the root of the original tree, and otherwise print the integer representing the parent of Vertex i in the original tree.\n\nNote that it can be shown that the original tree is uniquely determined.\n\nSample Input 1\n\n3 1\n1 2\n1 3\n2 3\n\nSample Output 1\n\n0\n1\n2\n\nThe graph in this input is shown below:\n\nIt can be seen that this graph is obtained by adding the edge 1 \\rightarrow 3 to the rooted tree 1 \\rightarrow 2 \\rightarrow 3.\n\nSample Input 2\n\n6 3\n2 1\n2 3\n4 1\n4 2\n6 1\n2 6\n4 6\n6 5\n\nSample Output 2\n\n6\n4\n2\n0\n6\n2", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 697, "cpu_time_ms": 135, "memory_kb": 10876}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s168816540", "group_id": "codeNet:p03145", "input_text": "local a = io.read(\"n\")\nlocal b = io.read(\"n\")\nprint(a*b//2)", "language": "Lua", "metadata": {"date": 1548866298, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03145.html", "problem_id": "p03145", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03145/input.txt", "sample_output_relpath": "derived/input_output/data/p03145/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03145/Lua/s168816540.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s168816540", "user_id": "u200201528"}, "prompt_components": {"gold_output": "6\n", "input_to_evaluate": "local a = io.read(\"n\")\nlocal b = io.read(\"n\")\nprint(a*b//2)", "problem_context": "Score : 100 points\n\nProblem Statement\n\nThere is a right triangle ABC with ∠ABC=90°.\n\nGiven the lengths of the three sides, |AB|,|BC| and |CA|, find the area of the right triangle ABC.\n\nIt is guaranteed that the area of the triangle ABC is an integer.\n\nConstraints\n\n1 \\leq |AB|,|BC|,|CA| \\leq 100\n\nAll values in input are integers.\n\nThe area of the triangle ABC is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\n|AB| |BC| |CA|\n\nOutput\n\nPrint the area of the triangle ABC.\n\nSample Input 1\n\n3 4 5\n\nSample Output 1\n\n6\n\nThis triangle has an area of 6.\n\nSample Input 2\n\n5 12 13\n\nSample Output 2\n\n30\n\nThis triangle has an area of 30.\n\nSample Input 3\n\n45 28 53\n\nSample Output 3\n\n630\n\nThis triangle has an area of 630.", "sample_input": "3 4 5\n"}, "reference_outputs": ["6\n"], "source_document_id": "p03145", "source_text": "Score : 100 points\n\nProblem Statement\n\nThere is a right triangle ABC with ∠ABC=90°.\n\nGiven the lengths of the three sides, |AB|,|BC| and |CA|, find the area of the right triangle ABC.\n\nIt is guaranteed that the area of the triangle ABC is an integer.\n\nConstraints\n\n1 \\leq |AB|,|BC|,|CA| \\leq 100\n\nAll values in input are integers.\n\nThe area of the triangle ABC is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\n|AB| |BC| |CA|\n\nOutput\n\nPrint the area of the triangle ABC.\n\nSample Input 1\n\n3 4 5\n\nSample Output 1\n\n6\n\nThis triangle has an area of 6.\n\nSample Input 2\n\n5 12 13\n\nSample Output 2\n\n30\n\nThis triangle has an area of 30.\n\nSample Input 3\n\n45 28 53\n\nSample Output 3\n\n630\n\nThis triangle has an area of 630.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 59, "cpu_time_ms": 7, "memory_kb": 760}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s864780745", "group_id": "codeNet:p03146", "input_text": "local a = {}\na[1] = io.read(\"*n\")\n\nlocal function f(n)\n local x\n if n%2==0 then\n return n/2\n else\n return 3*n+1\n end\nend\n\nfor i = 2, 1000000 do\n a[i] = f(a[i-1])\nend\n\nfor i = 1, 1000000 do\n if a[i]==4 then\n print(i+3)\n break\n end\nend", "language": "Lua", "metadata": {"date": 1586930657, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03146.html", "problem_id": "p03146", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03146/input.txt", "sample_output_relpath": "derived/input_output/data/p03146/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03146/Lua/s864780745.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s864780745", "user_id": "u045238009"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "local a = {}\na[1] = io.read(\"*n\")\n\nlocal function f(n)\n local x\n if n%2==0 then\n return n/2\n else\n return 3*n+1\n end\nend\n\nfor i = 2, 1000000 do\n a[i] = f(a[i-1])\nend\n\nfor i = 1, 1000000 do\n if a[i]==4 then\n print(i+3)\n break\n end\nend", "problem_context": "Score : 200 points\n\nProblem Statement\n\nA sequence a=\\{a_1,a_2,a_3,......\\} is determined as follows:\n\nThe first term s is given as input.\n\nLet f(n) be the following function: f(n) = n/2 if n is even, and f(n) = 3n+1 if n is odd.\n\na_i = s when i = 1, and a_i = f(a_{i-1}) when i > 1.\n\nFind the minimum integer m that satisfies the following condition:\n\nThere exists an integer n such that a_m = a_n (m > n).\n\nConstraints\n\n1 \\leq s \\leq 100\n\nAll values in input are integers.\n\nIt is guaranteed that all elements in a and the minimum m that satisfies the condition are at most 1000000.\n\nInput\n\nInput is given from Standard Input in the following format:\n\ns\n\nOutput\n\nPrint the minimum integer m that satisfies the condition.\n\nSample Input 1\n\n8\n\nSample Output 1\n\n5\n\na=\\{8,4,2,1,4,2,1,4,2,1,......\\}. As a_5=a_2, the answer is 5.\n\nSample Input 2\n\n7\n\nSample Output 2\n\n18\n\na=\\{7,22,11,34,17,52,26,13,40,20,10,5,16,8,4,2,1,4,2,1,......\\}.\n\nSample Input 3\n\n54\n\nSample Output 3\n\n114", "sample_input": "8\n"}, "reference_outputs": ["5\n"], "source_document_id": "p03146", "source_text": "Score : 200 points\n\nProblem Statement\n\nA sequence a=\\{a_1,a_2,a_3,......\\} is determined as follows:\n\nThe first term s is given as input.\n\nLet f(n) be the following function: f(n) = n/2 if n is even, and f(n) = 3n+1 if n is odd.\n\na_i = s when i = 1, and a_i = f(a_{i-1}) when i > 1.\n\nFind the minimum integer m that satisfies the following condition:\n\nThere exists an integer n such that a_m = a_n (m > n).\n\nConstraints\n\n1 \\leq s \\leq 100\n\nAll values in input are integers.\n\nIt is guaranteed that all elements in a and the minimum m that satisfies the condition are at most 1000000.\n\nInput\n\nInput is given from Standard Input in the following format:\n\ns\n\nOutput\n\nPrint the minimum integer m that satisfies the condition.\n\nSample Input 1\n\n8\n\nSample Output 1\n\n5\n\na=\\{8,4,2,1,4,2,1,4,2,1,......\\}. As a_5=a_2, the answer is 5.\n\nSample Input 2\n\n7\n\nSample Output 2\n\n18\n\na=\\{7,22,11,34,17,52,26,13,40,20,10,5,16,8,4,2,1,4,2,1,......\\}.\n\nSample Input 3\n\n54\n\nSample Output 3\n\n114", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 281, "cpu_time_ms": 127, "memory_kb": 17264}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s646259889", "group_id": "codeNet:p03146", "input_text": "local s=io.read(\"n\")\nt={}\nt[1]=s\nk={}\nk[s]=true\ni=1\nwhile true do\n i=i+1\n if t[i-1]%2==0 then\n t[i]=t[i-1]/2\n else\n t[i]=t[i-1]*3+1\n end\n if not k[t[i]] then\n k[t[i]]=true\n else print(i)\n break\n end\n end\n", "language": "Lua", "metadata": {"date": 1548887863, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03146.html", "problem_id": "p03146", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03146/input.txt", "sample_output_relpath": "derived/input_output/data/p03146/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03146/Lua/s646259889.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s646259889", "user_id": "u015229643"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "local s=io.read(\"n\")\nt={}\nt[1]=s\nk={}\nk[s]=true\ni=1\nwhile true do\n i=i+1\n if t[i-1]%2==0 then\n t[i]=t[i-1]/2\n else\n t[i]=t[i-1]*3+1\n end\n if not k[t[i]] then\n k[t[i]]=true\n else print(i)\n break\n end\n end\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nA sequence a=\\{a_1,a_2,a_3,......\\} is determined as follows:\n\nThe first term s is given as input.\n\nLet f(n) be the following function: f(n) = n/2 if n is even, and f(n) = 3n+1 if n is odd.\n\na_i = s when i = 1, and a_i = f(a_{i-1}) when i > 1.\n\nFind the minimum integer m that satisfies the following condition:\n\nThere exists an integer n such that a_m = a_n (m > n).\n\nConstraints\n\n1 \\leq s \\leq 100\n\nAll values in input are integers.\n\nIt is guaranteed that all elements in a and the minimum m that satisfies the condition are at most 1000000.\n\nInput\n\nInput is given from Standard Input in the following format:\n\ns\n\nOutput\n\nPrint the minimum integer m that satisfies the condition.\n\nSample Input 1\n\n8\n\nSample Output 1\n\n5\n\na=\\{8,4,2,1,4,2,1,4,2,1,......\\}. As a_5=a_2, the answer is 5.\n\nSample Input 2\n\n7\n\nSample Output 2\n\n18\n\na=\\{7,22,11,34,17,52,26,13,40,20,10,5,16,8,4,2,1,4,2,1,......\\}.\n\nSample Input 3\n\n54\n\nSample Output 3\n\n114", "sample_input": "8\n"}, "reference_outputs": ["5\n"], "source_document_id": "p03146", "source_text": "Score : 200 points\n\nProblem Statement\n\nA sequence a=\\{a_1,a_2,a_3,......\\} is determined as follows:\n\nThe first term s is given as input.\n\nLet f(n) be the following function: f(n) = n/2 if n is even, and f(n) = 3n+1 if n is odd.\n\na_i = s when i = 1, and a_i = f(a_{i-1}) when i > 1.\n\nFind the minimum integer m that satisfies the following condition:\n\nThere exists an integer n such that a_m = a_n (m > n).\n\nConstraints\n\n1 \\leq s \\leq 100\n\nAll values in input are integers.\n\nIt is guaranteed that all elements in a and the minimum m that satisfies the condition are at most 1000000.\n\nInput\n\nInput is given from Standard Input in the following format:\n\ns\n\nOutput\n\nPrint the minimum integer m that satisfies the condition.\n\nSample Input 1\n\n8\n\nSample Output 1\n\n5\n\na=\\{8,4,2,1,4,2,1,4,2,1,......\\}. As a_5=a_2, the answer is 5.\n\nSample Input 2\n\n7\n\nSample Output 2\n\n18\n\na=\\{7,22,11,34,17,52,26,13,40,20,10,5,16,8,4,2,1,4,2,1,......\\}.\n\nSample Input 3\n\n54\n\nSample Output 3\n\n114", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 232, "cpu_time_ms": 4, "memory_kb": 376}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s987872828", "group_id": "codeNet:p03146", "input_text": "local s=io.read(\"n\")\nt={}\nt[1]=s\nk={}\ni=1\nwhile true do\n i=i+1\n if t[i-1]%2==0 then\n t[i]=t[i-1]/2\n else\n t[i]=t[i-1]*3+1\n end\n if not k[t[i]] then\n k[t[i]]=true\n else print(i)\n break\n end\n end", "language": "Lua", "metadata": {"date": 1548885195, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03146.html", "problem_id": "p03146", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03146/input.txt", "sample_output_relpath": "derived/input_output/data/p03146/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03146/Lua/s987872828.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s987872828", "user_id": "u015229643"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "local s=io.read(\"n\")\nt={}\nt[1]=s\nk={}\ni=1\nwhile true do\n i=i+1\n if t[i-1]%2==0 then\n t[i]=t[i-1]/2\n else\n t[i]=t[i-1]*3+1\n end\n if not k[t[i]] then\n k[t[i]]=true\n else print(i)\n break\n end\n end", "problem_context": "Score : 200 points\n\nProblem Statement\n\nA sequence a=\\{a_1,a_2,a_3,......\\} is determined as follows:\n\nThe first term s is given as input.\n\nLet f(n) be the following function: f(n) = n/2 if n is even, and f(n) = 3n+1 if n is odd.\n\na_i = s when i = 1, and a_i = f(a_{i-1}) when i > 1.\n\nFind the minimum integer m that satisfies the following condition:\n\nThere exists an integer n such that a_m = a_n (m > n).\n\nConstraints\n\n1 \\leq s \\leq 100\n\nAll values in input are integers.\n\nIt is guaranteed that all elements in a and the minimum m that satisfies the condition are at most 1000000.\n\nInput\n\nInput is given from Standard Input in the following format:\n\ns\n\nOutput\n\nPrint the minimum integer m that satisfies the condition.\n\nSample Input 1\n\n8\n\nSample Output 1\n\n5\n\na=\\{8,4,2,1,4,2,1,4,2,1,......\\}. As a_5=a_2, the answer is 5.\n\nSample Input 2\n\n7\n\nSample Output 2\n\n18\n\na=\\{7,22,11,34,17,52,26,13,40,20,10,5,16,8,4,2,1,4,2,1,......\\}.\n\nSample Input 3\n\n54\n\nSample Output 3\n\n114", "sample_input": "8\n"}, "reference_outputs": ["5\n"], "source_document_id": "p03146", "source_text": "Score : 200 points\n\nProblem Statement\n\nA sequence a=\\{a_1,a_2,a_3,......\\} is determined as follows:\n\nThe first term s is given as input.\n\nLet f(n) be the following function: f(n) = n/2 if n is even, and f(n) = 3n+1 if n is odd.\n\na_i = s when i = 1, and a_i = f(a_{i-1}) when i > 1.\n\nFind the minimum integer m that satisfies the following condition:\n\nThere exists an integer n such that a_m = a_n (m > n).\n\nConstraints\n\n1 \\leq s \\leq 100\n\nAll values in input are integers.\n\nIt is guaranteed that all elements in a and the minimum m that satisfies the condition are at most 1000000.\n\nInput\n\nInput is given from Standard Input in the following format:\n\ns\n\nOutput\n\nPrint the minimum integer m that satisfies the condition.\n\nSample Input 1\n\n8\n\nSample Output 1\n\n5\n\na=\\{8,4,2,1,4,2,1,4,2,1,......\\}. As a_5=a_2, the answer is 5.\n\nSample Input 2\n\n7\n\nSample Output 2\n\n18\n\na=\\{7,22,11,34,17,52,26,13,40,20,10,5,16,8,4,2,1,4,2,1,......\\}.\n\nSample Input 3\n\n54\n\nSample Output 3\n\n114", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 221, "cpu_time_ms": 4, "memory_kb": 376}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s111266736", "group_id": "codeNet:p03146", "input_text": "local s = io.read(\"n\")\nif s == 1 or s == 2 then\n print(4)\nelse\n local i = 1\n while true do\n if s == 4 then\n print(i + 3)\n break\n end\n i = i + 1\n if (s % 2 == 0) then\n s = s // 2\n else\n s = s * 3 + 1\n end\n end\nend\n", "language": "Lua", "metadata": {"date": 1548883421, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03146.html", "problem_id": "p03146", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03146/input.txt", "sample_output_relpath": "derived/input_output/data/p03146/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03146/Lua/s111266736.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s111266736", "user_id": "u200201528"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "local s = io.read(\"n\")\nif s == 1 or s == 2 then\n print(4)\nelse\n local i = 1\n while true do\n if s == 4 then\n print(i + 3)\n break\n end\n i = i + 1\n if (s % 2 == 0) then\n s = s // 2\n else\n s = s * 3 + 1\n end\n end\nend\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nA sequence a=\\{a_1,a_2,a_3,......\\} is determined as follows:\n\nThe first term s is given as input.\n\nLet f(n) be the following function: f(n) = n/2 if n is even, and f(n) = 3n+1 if n is odd.\n\na_i = s when i = 1, and a_i = f(a_{i-1}) when i > 1.\n\nFind the minimum integer m that satisfies the following condition:\n\nThere exists an integer n such that a_m = a_n (m > n).\n\nConstraints\n\n1 \\leq s \\leq 100\n\nAll values in input are integers.\n\nIt is guaranteed that all elements in a and the minimum m that satisfies the condition are at most 1000000.\n\nInput\n\nInput is given from Standard Input in the following format:\n\ns\n\nOutput\n\nPrint the minimum integer m that satisfies the condition.\n\nSample Input 1\n\n8\n\nSample Output 1\n\n5\n\na=\\{8,4,2,1,4,2,1,4,2,1,......\\}. As a_5=a_2, the answer is 5.\n\nSample Input 2\n\n7\n\nSample Output 2\n\n18\n\na=\\{7,22,11,34,17,52,26,13,40,20,10,5,16,8,4,2,1,4,2,1,......\\}.\n\nSample Input 3\n\n54\n\nSample Output 3\n\n114", "sample_input": "8\n"}, "reference_outputs": ["5\n"], "source_document_id": "p03146", "source_text": "Score : 200 points\n\nProblem Statement\n\nA sequence a=\\{a_1,a_2,a_3,......\\} is determined as follows:\n\nThe first term s is given as input.\n\nLet f(n) be the following function: f(n) = n/2 if n is even, and f(n) = 3n+1 if n is odd.\n\na_i = s when i = 1, and a_i = f(a_{i-1}) when i > 1.\n\nFind the minimum integer m that satisfies the following condition:\n\nThere exists an integer n such that a_m = a_n (m > n).\n\nConstraints\n\n1 \\leq s \\leq 100\n\nAll values in input are integers.\n\nIt is guaranteed that all elements in a and the minimum m that satisfies the condition are at most 1000000.\n\nInput\n\nInput is given from Standard Input in the following format:\n\ns\n\nOutput\n\nPrint the minimum integer m that satisfies the condition.\n\nSample Input 1\n\n8\n\nSample Output 1\n\n5\n\na=\\{8,4,2,1,4,2,1,4,2,1,......\\}. As a_5=a_2, the answer is 5.\n\nSample Input 2\n\n7\n\nSample Output 2\n\n18\n\na=\\{7,22,11,34,17,52,26,13,40,20,10,5,16,8,4,2,1,4,2,1,......\\}.\n\nSample Input 3\n\n54\n\nSample Output 3\n\n114", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 255, "cpu_time_ms": 8, "memory_kb": 760}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s760993746", "group_id": "codeNet:p03146", "input_text": "local s=io.read(\"n\")\nt={}\nt[1]=s\ni=1\nwhile true do\n i=i+1\n if t[i-1]%2==0 then\n t[i]=t[i-1]/2\n else\n t[i]=t[i-1]*3+1\n end\n for k=1,i-1 do\n if t[k]==t[i] then\n print(i)\n break\n end\n end\nend\n \n \n", "language": "Lua", "metadata": {"date": 1548881258, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03146.html", "problem_id": "p03146", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03146/input.txt", "sample_output_relpath": "derived/input_output/data/p03146/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03146/Lua/s760993746.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s760993746", "user_id": "u015229643"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "local s=io.read(\"n\")\nt={}\nt[1]=s\ni=1\nwhile true do\n i=i+1\n if t[i-1]%2==0 then\n t[i]=t[i-1]/2\n else\n t[i]=t[i-1]*3+1\n end\n for k=1,i-1 do\n if t[k]==t[i] then\n print(i)\n break\n end\n end\nend\n \n \n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nA sequence a=\\{a_1,a_2,a_3,......\\} is determined as follows:\n\nThe first term s is given as input.\n\nLet f(n) be the following function: f(n) = n/2 if n is even, and f(n) = 3n+1 if n is odd.\n\na_i = s when i = 1, and a_i = f(a_{i-1}) when i > 1.\n\nFind the minimum integer m that satisfies the following condition:\n\nThere exists an integer n such that a_m = a_n (m > n).\n\nConstraints\n\n1 \\leq s \\leq 100\n\nAll values in input are integers.\n\nIt is guaranteed that all elements in a and the minimum m that satisfies the condition are at most 1000000.\n\nInput\n\nInput is given from Standard Input in the following format:\n\ns\n\nOutput\n\nPrint the minimum integer m that satisfies the condition.\n\nSample Input 1\n\n8\n\nSample Output 1\n\n5\n\na=\\{8,4,2,1,4,2,1,4,2,1,......\\}. As a_5=a_2, the answer is 5.\n\nSample Input 2\n\n7\n\nSample Output 2\n\n18\n\na=\\{7,22,11,34,17,52,26,13,40,20,10,5,16,8,4,2,1,4,2,1,......\\}.\n\nSample Input 3\n\n54\n\nSample Output 3\n\n114", "sample_input": "8\n"}, "reference_outputs": ["5\n"], "source_document_id": "p03146", "source_text": "Score : 200 points\n\nProblem Statement\n\nA sequence a=\\{a_1,a_2,a_3,......\\} is determined as follows:\n\nThe first term s is given as input.\n\nLet f(n) be the following function: f(n) = n/2 if n is even, and f(n) = 3n+1 if n is odd.\n\na_i = s when i = 1, and a_i = f(a_{i-1}) when i > 1.\n\nFind the minimum integer m that satisfies the following condition:\n\nThere exists an integer n such that a_m = a_n (m > n).\n\nConstraints\n\n1 \\leq s \\leq 100\n\nAll values in input are integers.\n\nIt is guaranteed that all elements in a and the minimum m that satisfies the condition are at most 1000000.\n\nInput\n\nInput is given from Standard Input in the following format:\n\ns\n\nOutput\n\nPrint the minimum integer m that satisfies the condition.\n\nSample Input 1\n\n8\n\nSample Output 1\n\n5\n\na=\\{8,4,2,1,4,2,1,4,2,1,......\\}. As a_5=a_2, the answer is 5.\n\nSample Input 2\n\n7\n\nSample Output 2\n\n18\n\na=\\{7,22,11,34,17,52,26,13,40,20,10,5,16,8,4,2,1,4,2,1,......\\}.\n\nSample Input 3\n\n54\n\nSample Output 3\n\n114", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 233, "cpu_time_ms": 2105, "memory_kb": 36472}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s199073220", "group_id": "codeNet:p03147", "input_text": "local n = io.read(\"*n\")\nlocal h = {}\nfor i = 1, n do h[i] = io.read(\"*n\") end\nlocal tasks = {}\nlocal tasknum, done = 0, 0\ntable.insert(tasks, 1 + n * 101)\ntasknum = 1\n\nlocal function getmin(l, r)\n local min, minpos = h[l], l\n for i = l + 1, r do\n if(h[i] < min) then\n min, minpos = h[i], i\n end\n end\n return min, minpos\nend\n\nlocal tot = 0\nlocal curtask = 0\nwhile(done < tasknum) do\n done = done + 1\n local task = tasks[done]\n local left, right = task % 101, task // 101\n local min, minpos = getmin(left, right)\n for i =left, right do\n h[i] = h[i] - min\n end\n if(left < minpos) then\n tasknum = tasknum + 1\n table.insert(tasks, left + (minpos - 1) * 101)\n end\n if(minpos < right) then\n tasknum = tasknum + 1\n table.insert(tasks, minpos + 1 + right * 101)\n end\n tot = tot + min\nend\nprint(tot)\n", "language": "Lua", "metadata": {"date": 1555860680, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03147.html", "problem_id": "p03147", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03147/input.txt", "sample_output_relpath": "derived/input_output/data/p03147/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03147/Lua/s199073220.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s199073220", "user_id": "u120582723"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "local n = io.read(\"*n\")\nlocal h = {}\nfor i = 1, n do h[i] = io.read(\"*n\") end\nlocal tasks = {}\nlocal tasknum, done = 0, 0\ntable.insert(tasks, 1 + n * 101)\ntasknum = 1\n\nlocal function getmin(l, r)\n local min, minpos = h[l], l\n for i = l + 1, r do\n if(h[i] < min) then\n min, minpos = h[i], i\n end\n end\n return min, minpos\nend\n\nlocal tot = 0\nlocal curtask = 0\nwhile(done < tasknum) do\n done = done + 1\n local task = tasks[done]\n local left, right = task % 101, task // 101\n local min, minpos = getmin(left, right)\n for i =left, right do\n h[i] = h[i] - min\n end\n if(left < minpos) then\n tasknum = tasknum + 1\n table.insert(tasks, left + (minpos - 1) * 101)\n end\n if(minpos < right) then\n tasknum = tasknum + 1\n table.insert(tasks, minpos + 1 + right * 101)\n end\n tot = tot + min\nend\nprint(tot)\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nIn a flower bed, there are N flowers, numbered 1,2,......,N. Initially, the heights of all flowers are 0.\nYou are given a sequence h=\\{h_1,h_2,h_3,......\\} as input. You would like to change the height of Flower k to h_k for all k (1 \\leq k \\leq N), by repeating the following \"watering\" operation:\n\nSpecify integers l and r. Increase the height of Flower x by 1 for all x such that l \\leq x \\leq r.\n\nFind the minimum number of watering operations required to satisfy the condition.\n\nConstraints\n\n1 \\leq N \\leq 100\n\n0 \\leq h_i \\leq 100\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nh_1 h_2 h_3 ...... h_N\n\nOutput\n\nPrint the minimum number of watering operations required to satisfy the condition.\n\nSample Input 1\n\n4\n1 2 2 1\n\nSample Output 1\n\n2\n\nThe minimum number of watering operations required is 2.\nOne way to achieve it is:\n\nPerform the operation with (l,r)=(1,3).\n\nPerform the operation with (l,r)=(2,4).\n\nSample Input 2\n\n5\n3 1 2 3 1\n\nSample Output 2\n\n5\n\nSample Input 3\n\n8\n4 23 75 0 23 96 50 100\n\nSample Output 3\n\n221", "sample_input": "4\n1 2 2 1\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03147", "source_text": "Score : 300 points\n\nProblem Statement\n\nIn a flower bed, there are N flowers, numbered 1,2,......,N. Initially, the heights of all flowers are 0.\nYou are given a sequence h=\\{h_1,h_2,h_3,......\\} as input. You would like to change the height of Flower k to h_k for all k (1 \\leq k \\leq N), by repeating the following \"watering\" operation:\n\nSpecify integers l and r. Increase the height of Flower x by 1 for all x such that l \\leq x \\leq r.\n\nFind the minimum number of watering operations required to satisfy the condition.\n\nConstraints\n\n1 \\leq N \\leq 100\n\n0 \\leq h_i \\leq 100\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nh_1 h_2 h_3 ...... h_N\n\nOutput\n\nPrint the minimum number of watering operations required to satisfy the condition.\n\nSample Input 1\n\n4\n1 2 2 1\n\nSample Output 1\n\n2\n\nThe minimum number of watering operations required is 2.\nOne way to achieve it is:\n\nPerform the operation with (l,r)=(1,3).\n\nPerform the operation with (l,r)=(2,4).\n\nSample Input 2\n\n5\n3 1 2 3 1\n\nSample Output 2\n\n5\n\nSample Input 3\n\n8\n4 23 75 0 23 96 50 100\n\nSample Output 3\n\n221", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 831, "cpu_time_ms": 9, "memory_kb": 760}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s447396350", "group_id": "codeNet:p03147", "input_text": "local N=io.read(\"n\")\nh={}\nfor i=1,N do \n h[i]=io.read(\"n\")\n end\na=1\ns=0\nwhile a<=N-s do\n if h[a]==h[a+1] then\n for i=a,N-1-s do \n h[i]=h[i+1]\n end\n s=s+1\n else\n a=a+1\n end\n end\nif N-s==1 then \n print(h[1])\n end\nif N-s==2 then \n if h[1]>h[2] then\n print(h[1])\n else print(h[2])\n end\nend\nD=0\nd=0\nif h[1]>h[2] then\n D=D+h[1]\n end\nif h[N-s]>h[N-s-1] then\n D=D+h[N-s]\n end\nfor i=2,N-s-1 do \n if h[i]>h[i-1] and h[i]>h[i+1] then\n D=D+h[i]\n elseif h[i]h[2] then\n print(h[1])\n else print(h[2])\n end\nend\nD=0\nd=0\nif h[1]>h[2] then\n D=D+h[1]\n end\nif h[N-s]>h[N-s-1] then\n D=D+h[N-s]\n end\nfor i=2,N-s-1 do \n if h[i]>h[i-1] and h[i]>h[i+1] then\n D=D+h[i]\n elseif h[i] b[2]\nend)\n\nlocal type2num = {}\nlocal xcnt = 0\nlocal total = 0\nfor i = 1, k do\n\tlocal node = list[i]\n\tlocal t = node[1]\n\tlocal d = node[2]\n\tlocal num = type2num[t]\n\tif not num then\n\t\txcnt = xcnt + 1\n\t\tnum = 0\n\tend\n\tnum = num + 1\n\ttype2num[t] = num\n\ttotal = total + d\nend\n\nlocal g = total + xcnt * xcnt\nlocal maxv = g\nlocal sp1 = k\nlocal sp2 = k + 1\nfor i = xcnt + 1, n do\n\tlocal v1, v2\n\twhile (sp1 > 0) do\n\t\tlocal node = list[sp1]\n\t\tsp1 = sp1 - 1\n\t\tlocal t = node[1]\n\t\tif type2num[t] > 1 then\n\t\t\tv1 = node[2]\n\t\t\ttype2num[t] = type2num[t] - 1\n\t\t\tbreak\n\t\tend\n\tend\n\twhile (sp2 <= n) do\n\t\tlocal node = list[sp2]\n\t\tsp2 = sp2 + 1\n\t\tlocal t = node[1]\n\t\tif not type2num[t] then\n\t\t\tv2 = node[2]\n\t\t\ttype2num[t] = 1\n\t\t\tbreak\n\t\tend\n\tend\n\tif v1 and v2 then\n\t\ttotal = total - v1 + v2\n\t\tg = total + i * i\n\t\tif g > maxv then\n\t\t\tmaxv = g\n\t\tend\n\telse\n\t\tbreak\n\tend\nend\n\nprint(maxv)", "language": "Lua", "metadata": {"date": 1548871071, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03148.html", "problem_id": "p03148", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03148/input.txt", "sample_output_relpath": "derived/input_output/data/p03148/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03148/Lua/s699989320.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s699989320", "user_id": "u200201528"}, "prompt_components": {"gold_output": "26\n", "input_to_evaluate": "local n = io.read(\"n\")\nlocal k = io.read(\"n\")\nlocal list = {}\nfor _ = 1, n do\n\tlocal t = io.read(\"n\")\n\tlocal d = io.read(\"n\")\n\ttable.insert(list, {t, d})\nend\ntable.sort(list, function(a, b)\n\treturn a[2] > b[2]\nend)\n\nlocal type2num = {}\nlocal xcnt = 0\nlocal total = 0\nfor i = 1, k do\n\tlocal node = list[i]\n\tlocal t = node[1]\n\tlocal d = node[2]\n\tlocal num = type2num[t]\n\tif not num then\n\t\txcnt = xcnt + 1\n\t\tnum = 0\n\tend\n\tnum = num + 1\n\ttype2num[t] = num\n\ttotal = total + d\nend\n\nlocal g = total + xcnt * xcnt\nlocal maxv = g\nlocal sp1 = k\nlocal sp2 = k + 1\nfor i = xcnt + 1, n do\n\tlocal v1, v2\n\twhile (sp1 > 0) do\n\t\tlocal node = list[sp1]\n\t\tsp1 = sp1 - 1\n\t\tlocal t = node[1]\n\t\tif type2num[t] > 1 then\n\t\t\tv1 = node[2]\n\t\t\ttype2num[t] = type2num[t] - 1\n\t\t\tbreak\n\t\tend\n\tend\n\twhile (sp2 <= n) do\n\t\tlocal node = list[sp2]\n\t\tsp2 = sp2 + 1\n\t\tlocal t = node[1]\n\t\tif not type2num[t] then\n\t\t\tv2 = node[2]\n\t\t\ttype2num[t] = 1\n\t\t\tbreak\n\t\tend\n\tend\n\tif v1 and v2 then\n\t\ttotal = total - v1 + v2\n\t\tg = total + i * i\n\t\tif g > maxv then\n\t\t\tmaxv = g\n\t\tend\n\telse\n\t\tbreak\n\tend\nend\n\nprint(maxv)", "problem_context": "Score : 400 points\n\nProblem Statement\n\nThere are N pieces of sushi. Each piece has two parameters: \"kind of topping\" t_i and \"deliciousness\" d_i.\nYou are choosing K among these N pieces to eat.\nYour \"satisfaction\" here will be calculated as follows:\n\nThe satisfaction is the sum of the \"base total deliciousness\" and the \"variety bonus\".\n\nThe base total deliciousness is the sum of the deliciousness of the pieces you eat.\n\nThe variety bonus is x*x, where x is the number of different kinds of toppings of the pieces you eat.\n\nYou want to have as much satisfaction as possible.\nFind this maximum satisfaction.\n\nConstraints\n\n1 \\leq K \\leq N \\leq 10^5\n\n1 \\leq t_i \\leq N\n\n1 \\leq d_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nt_1 d_1\nt_2 d_2\n.\n.\n.\nt_N d_N\n\nOutput\n\nPrint the maximum satisfaction that you can obtain.\n\nSample Input 1\n\n5 3\n1 9\n1 7\n2 6\n2 5\n3 1\n\nSample Output 1\n\n26\n\nIf you eat Sushi 1,2 and 3:\n\nThe base total deliciousness is 9+7+6=22.\n\nThe variety bonus is 2*2=4.\n\nThus, your satisfaction will be 26, which is optimal.\n\nSample Input 2\n\n7 4\n1 1\n2 1\n3 1\n4 6\n4 5\n4 5\n4 5\n\nSample Output 2\n\n25\n\nIt is optimal to eat Sushi 1,2,3 and 4.\n\nSample Input 3\n\n6 5\n5 1000000000\n2 990000000\n3 980000000\n6 970000000\n6 960000000\n4 950000000\n\nSample Output 3\n\n4900000016\n\nNote that the output may not fit into a 32-bit integer type.", "sample_input": "5 3\n1 9\n1 7\n2 6\n2 5\n3 1\n"}, "reference_outputs": ["26\n"], "source_document_id": "p03148", "source_text": "Score : 400 points\n\nProblem Statement\n\nThere are N pieces of sushi. Each piece has two parameters: \"kind of topping\" t_i and \"deliciousness\" d_i.\nYou are choosing K among these N pieces to eat.\nYour \"satisfaction\" here will be calculated as follows:\n\nThe satisfaction is the sum of the \"base total deliciousness\" and the \"variety bonus\".\n\nThe base total deliciousness is the sum of the deliciousness of the pieces you eat.\n\nThe variety bonus is x*x, where x is the number of different kinds of toppings of the pieces you eat.\n\nYou want to have as much satisfaction as possible.\nFind this maximum satisfaction.\n\nConstraints\n\n1 \\leq K \\leq N \\leq 10^5\n\n1 \\leq t_i \\leq N\n\n1 \\leq d_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nt_1 d_1\nt_2 d_2\n.\n.\n.\nt_N d_N\n\nOutput\n\nPrint the maximum satisfaction that you can obtain.\n\nSample Input 1\n\n5 3\n1 9\n1 7\n2 6\n2 5\n3 1\n\nSample Output 1\n\n26\n\nIf you eat Sushi 1,2 and 3:\n\nThe base total deliciousness is 9+7+6=22.\n\nThe variety bonus is 2*2=4.\n\nThus, your satisfaction will be 26, which is optimal.\n\nSample Input 2\n\n7 4\n1 1\n2 1\n3 1\n4 6\n4 5\n4 5\n4 5\n\nSample Output 2\n\n25\n\nIt is optimal to eat Sushi 1,2,3 and 4.\n\nSample Input 3\n\n6 5\n5 1000000000\n2 990000000\n3 980000000\n6 970000000\n6 960000000\n4 950000000\n\nSample Output 3\n\n4900000016\n\nNote that the output may not fit into a 32-bit integer type.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1066, "cpu_time_ms": 365, "memory_kb": 16496}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s566901659", "group_id": "codeNet:p03150", "input_text": "s=io.read()\nif s:match(\"%l*(keyence)\") or s:match(\"(k)%l*(eyence)\") or s:match(\"(ke)%l*(yence)\") or s:match(\"(key)%l*(ence)\") or s:match(\"(keye)%l*(nce)\") or s:match(\"(keyen)%l*(ce)\") or s:match(\"(keyenc)%l*(e)\") or s:match(\"(keyence)%l*\") then\n print(\"YES\")\nelse\n print(\"NO\")\nend", "language": "Lua", "metadata": {"date": 1589098538, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03150.html", "problem_id": "p03150", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03150/input.txt", "sample_output_relpath": "derived/input_output/data/p03150/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03150/Lua/s566901659.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s566901659", "user_id": "u045238009"}, "prompt_components": {"gold_output": "YES\n", "input_to_evaluate": "s=io.read()\nif s:match(\"%l*(keyence)\") or s:match(\"(k)%l*(eyence)\") or s:match(\"(ke)%l*(yence)\") or s:match(\"(key)%l*(ence)\") or s:match(\"(keye)%l*(nce)\") or s:match(\"(keyen)%l*(ce)\") or s:match(\"(keyenc)%l*(e)\") or s:match(\"(keyence)%l*\") then\n print(\"YES\")\nelse\n print(\"NO\")\nend", "problem_context": "Score : 200 points\n\nProblem Statement\n\nA string is called a KEYENCE string when it can be changed to keyence by removing its contiguous substring (possibly empty) only once.\n\nGiven a string S consisting of lowercase English letters, determine if S is a KEYENCE string.\n\nConstraints\n\nThe length of S is between 7 and 100 (inclusive).\n\nS consists of lowercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nIf S is a KEYENCE string, print YES; otherwise, print NO.\n\nSample Input 1\n\nkeyofscience\n\nSample Output 1\n\nYES\n\nkeyence is an abbreviation of key of science.\n\nSample Input 2\n\nmpyszsbznf\n\nSample Output 2\n\nNO\n\nSample Input 3\n\nashlfyha\n\nSample Output 3\n\nNO\n\nSample Input 4\n\nkeyence\n\nSample Output 4\n\nYES", "sample_input": "keyofscience\n"}, "reference_outputs": ["YES\n"], "source_document_id": "p03150", "source_text": "Score : 200 points\n\nProblem Statement\n\nA string is called a KEYENCE string when it can be changed to keyence by removing its contiguous substring (possibly empty) only once.\n\nGiven a string S consisting of lowercase English letters, determine if S is a KEYENCE string.\n\nConstraints\n\nThe length of S is between 7 and 100 (inclusive).\n\nS consists of lowercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nIf S is a KEYENCE string, print YES; otherwise, print NO.\n\nSample Input 1\n\nkeyofscience\n\nSample Output 1\n\nYES\n\nkeyence is an abbreviation of key of science.\n\nSample Input 2\n\nmpyszsbznf\n\nSample Output 2\n\nNO\n\nSample Input 3\n\nashlfyha\n\nSample Output 3\n\nNO\n\nSample Input 4\n\nkeyence\n\nSample Output 4\n\nYES", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 286, "cpu_time_ms": 6, "memory_kb": 888}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s176661230", "group_id": "codeNet:p03151", "input_text": "N=io.read\"*n\"\nA={}\nfor i=1,N do A[i]=io.read\"*n\"end\nB={}\nfor i=1,N do B[i]=io.read\"*n\"end\nas=0\nbs=0\nD={}\nfor i=1,N do\nas=as+A[i]\nbs=bs+B[i]\nD[i]=A[i]-B[i]\nend\nif(as=0)then break end dms=dms+D[i] end\n\ni=1\nwhile(D[i]<0)do\n\ti=i+1\nend\n\nj=N\nwhile(dms<0 and j>0)do\n\tdms=dms+D[j]\n\tj=j-1\nend\n\nprint(i+N-j-1)", "language": "Lua", "metadata": {"date": 1587511405, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p03151.html", "problem_id": "p03151", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03151/input.txt", "sample_output_relpath": "derived/input_output/data/p03151/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03151/Lua/s176661230.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s176661230", "user_id": "u726173718"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "N=io.read\"*n\"\nA={}\nfor i=1,N do A[i]=io.read\"*n\"end\nB={}\nfor i=1,N do B[i]=io.read\"*n\"end\nas=0\nbs=0\nD={}\nfor i=1,N do\nas=as+A[i]\nbs=bs+B[i]\nD[i]=A[i]-B[i]\nend\nif(as=0)then break end dms=dms+D[i] end\n\ni=1\nwhile(D[i]<0)do\n\ti=i+1\nend\n\nj=N\nwhile(dms<0 and j>0)do\n\tdms=dms+D[j]\n\tj=j-1\nend\n\nprint(i+N-j-1)", "problem_context": "Score : 400 points\n\nProblem Statement\n\nA university student, Takahashi, has to take N examinations and pass all of them.\nCurrently, his readiness for the i-th examination is A_{i}, and according to his investigation, it is known that he needs readiness of at least B_{i} in order to pass the i-th examination.\n\nTakahashi thinks that he may not be able to pass all the examinations, and he has decided to ask a magician, Aoki, to change the readiness for as few examinations as possible so that he can pass all of them, while not changing the total readiness.\n\nFor Takahashi, find the minimum possible number of indices i such that A_i and C_i are different, for a sequence C_1, C_2, ..., C_{N} that satisfies the following conditions:\n\nThe sum of the sequence A_1, A_2, ..., A_{N} and the sum of the sequence C_1, C_2, ..., C_{N} are equal.\n\nFor every i, B_i \\leq C_i holds.\n\nIf such a sequence C_1, C_2, ..., C_{N} cannot be constructed, print -1.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n1 \\leq A_i \\leq 10^9\n\n1 \\leq B_i \\leq 10^9\n\nA_i and B_i are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_{N}\nB_1 B_2 ... B_{N}\n\nOutput\n\nPrint the minimum possible number of indices i such that A_i and C_i are different, for a sequence C_1, C_2, ..., C_{N} that satisfies the conditions.\nIf such a sequence C_1, C_2, ..., C_{N} cannot be constructed, print -1.\n\nSample Input 1\n\n3\n2 3 5\n3 4 1\n\nSample Output 1\n\n3\n\n(A_1, A_2, A_3) = (2, 3, 5) and (B_1, B_2, B_3) = (3, 4, 1). If nothing is done, he cannot pass the first and second exams.\nThe minimum possible number of indices i such that A_i and C_i are different, 3, is achieved when:\n\n(C_1, C_2, C_3) = (3, 5, 2)\n\nSample Input 2\n\n3\n2 3 3\n2 2 1\n\nSample Output 2\n\n0\n\nIn this case, he has to do nothing in order to pass all the exams.\n\nSample Input 3\n\n3\n17 7 1\n25 6 14\n\nSample Output 3\n\n-1\n\nIn this case, no matter what is done, he cannot pass all the exams.\n\nSample Input 4\n\n12\n757232153 372327760 440075441 195848680 354974235 458054863 463477172 740174259 615762794 632963102 529866931 64991604\n74164189 98239366 465611891 362739947 147060907 118867039 63189252 78303147 501410831 110823640 122948912 572905212\n\nSample Output 4\n\n5", "sample_input": "3\n2 3 5\n3 4 1\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03151", "source_text": "Score : 400 points\n\nProblem Statement\n\nA university student, Takahashi, has to take N examinations and pass all of them.\nCurrently, his readiness for the i-th examination is A_{i}, and according to his investigation, it is known that he needs readiness of at least B_{i} in order to pass the i-th examination.\n\nTakahashi thinks that he may not be able to pass all the examinations, and he has decided to ask a magician, Aoki, to change the readiness for as few examinations as possible so that he can pass all of them, while not changing the total readiness.\n\nFor Takahashi, find the minimum possible number of indices i such that A_i and C_i are different, for a sequence C_1, C_2, ..., C_{N} that satisfies the following conditions:\n\nThe sum of the sequence A_1, A_2, ..., A_{N} and the sum of the sequence C_1, C_2, ..., C_{N} are equal.\n\nFor every i, B_i \\leq C_i holds.\n\nIf such a sequence C_1, C_2, ..., C_{N} cannot be constructed, print -1.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n1 \\leq A_i \\leq 10^9\n\n1 \\leq B_i \\leq 10^9\n\nA_i and B_i are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_{N}\nB_1 B_2 ... B_{N}\n\nOutput\n\nPrint the minimum possible number of indices i such that A_i and C_i are different, for a sequence C_1, C_2, ..., C_{N} that satisfies the conditions.\nIf such a sequence C_1, C_2, ..., C_{N} cannot be constructed, print -1.\n\nSample Input 1\n\n3\n2 3 5\n3 4 1\n\nSample Output 1\n\n3\n\n(A_1, A_2, A_3) = (2, 3, 5) and (B_1, B_2, B_3) = (3, 4, 1). If nothing is done, he cannot pass the first and second exams.\nThe minimum possible number of indices i such that A_i and C_i are different, 3, is achieved when:\n\n(C_1, C_2, C_3) = (3, 5, 2)\n\nSample Input 2\n\n3\n2 3 3\n2 2 1\n\nSample Output 2\n\n0\n\nIn this case, he has to do nothing in order to pass all the exams.\n\nSample Input 3\n\n3\n17 7 1\n25 6 14\n\nSample Output 3\n\n-1\n\nIn this case, no matter what is done, he cannot pass all the exams.\n\nSample Input 4\n\n12\n757232153 372327760 440075441 195848680 354974235 458054863 463477172 740174259 615762794 632963102 529866931 64991604\n74164189 98239366 465611891 362739947 147060907 118867039 63189252 78303147 501410831 110823640 122948912 572905212\n\nSample Output 4\n\n5", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 371, "cpu_time_ms": 97, "memory_kb": 3456}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s919737747", "group_id": "codeNet:p03155", "input_text": "local a, b, c = io.read(\"*n\", \"*n\", \"*n\")\nprint((a + 1 - b) * (a + 1 - c))", "language": "Lua", "metadata": {"date": 1568153246, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03155.html", "problem_id": "p03155", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03155/input.txt", "sample_output_relpath": "derived/input_output/data/p03155/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03155/Lua/s919737747.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s919737747", "user_id": "u120582723"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "local a, b, c = io.read(\"*n\", \"*n\", \"*n\")\nprint((a + 1 - b) * (a + 1 - c))", "problem_context": "Score : 100 points\n\nProblem Statement\n\nIt has been decided that a programming contest sponsored by company A will be held, so we will post the notice on a bulletin board.\n\nThe bulletin board is in the form of a grid with N rows and N columns, and the notice will occupy a rectangular region with H rows and W columns.\n\nHow many ways are there to choose where to put the notice so that it completely covers exactly HW squares?\n\nConstraints\n\n1 \\leq H, W \\leq N \\leq 100\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nH\nW\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n3\n2\n3\n\nSample Output 1\n\n2\n\nThere are two ways to put the notice, as follows:\n\n### ...\n### ###\n... ###\n\nHere, # represents a square covered by the notice, and . represents a square not covered.\n\nSample Input 2\n\n100\n1\n1\n\nSample Output 2\n\n10000\n\nSample Input 3\n\n5\n4\n2\n\nSample Output 3\n\n8", "sample_input": "3\n2\n3\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03155", "source_text": "Score : 100 points\n\nProblem Statement\n\nIt has been decided that a programming contest sponsored by company A will be held, so we will post the notice on a bulletin board.\n\nThe bulletin board is in the form of a grid with N rows and N columns, and the notice will occupy a rectangular region with H rows and W columns.\n\nHow many ways are there to choose where to put the notice so that it completely covers exactly HW squares?\n\nConstraints\n\n1 \\leq H, W \\leq N \\leq 100\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nH\nW\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n3\n2\n3\n\nSample Output 1\n\n2\n\nThere are two ways to put the notice, as follows:\n\n### ...\n### ###\n... ###\n\nHere, # represents a square covered by the notice, and . represents a square not covered.\n\nSample Input 2\n\n100\n1\n1\n\nSample Output 2\n\n10000\n\nSample Input 3\n\n5\n4\n2\n\nSample Output 3\n\n8", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 74, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s879998864", "group_id": "codeNet:p03157", "input_text": "local ior = io.input()\nlocal h, w = ior:read(\"*n\", \"*n\", \"*l\")\n\nlocal function getindex(i_h, i_w)\n return i_w + (i_h - 1) * w\nend\n\nlocal function createMap()\n local str = \"\"\n local map = {}\n for i_h = 1, h do\n str = ior:read()\n for i_w = 1, w do\n map[getindex(i_h, i_w)] = (str:sub(i_w, i_w) == \"#\")\n end\n end\n return map\nend\n\nlocal function uf_initialize(n)\n local parent = {}\n for i = 1, n do parent[i] = i end\n return parent\nend\n\nlocal function uf_findroot(idx, parent)\n while parent[idx] ~= idx do\n idx = parent[idx]\n end\n return idx\nend\n\nlocal map = createMap()\nlocal parent = uf_initialize(h * w)\n\nlocal function walk(src, dst)\n if map[src] ~= map[dst] then\n local sr, dr = uf_findroot(src, parent), uf_findroot(dst, parent)\n parent[src], parent[dst] = sr, dr\n if sr ~= dr then\n parent[dst], parent[dr] = sr, sr\n end\n end\nend\n\nfor idx = 1, h * w do\n if w < idx then walk(idx, idx - w) end\n if idx <= (h - 1) * w then walk(idx, idx + w) end\n if 1 < w then\n if idx % w ~= 0 then walk(idx, idx + 1) end\n if idx % w ~= 1 then walk(idx, idx - 1) end\n end\nend\nlocal groups = {}\nfor idx = 1, h * w do\n local r = uf_findroot(idx, parent)\n if not groups[r] then\n local tmp = {0, 0}\n groups[r] = tmp\n end\n if map[idx] then\n groups[r][1] = groups[r][1] + 1\n else\n groups[r][2] = groups[r][2] + 1\n end\nend\nlocal ret = 0\nfor k, v in pairs(groups) do\n ret = ret + v[1] * v[2]\nend\nprint(ret)\n", "language": "Lua", "metadata": {"date": 1563710401, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p03157.html", "problem_id": "p03157", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03157/input.txt", "sample_output_relpath": "derived/input_output/data/p03157/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03157/Lua/s879998864.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s879998864", "user_id": "u120582723"}, "prompt_components": {"gold_output": "10\n", "input_to_evaluate": "local ior = io.input()\nlocal h, w = ior:read(\"*n\", \"*n\", \"*l\")\n\nlocal function getindex(i_h, i_w)\n return i_w + (i_h - 1) * w\nend\n\nlocal function createMap()\n local str = \"\"\n local map = {}\n for i_h = 1, h do\n str = ior:read()\n for i_w = 1, w do\n map[getindex(i_h, i_w)] = (str:sub(i_w, i_w) == \"#\")\n end\n end\n return map\nend\n\nlocal function uf_initialize(n)\n local parent = {}\n for i = 1, n do parent[i] = i end\n return parent\nend\n\nlocal function uf_findroot(idx, parent)\n while parent[idx] ~= idx do\n idx = parent[idx]\n end\n return idx\nend\n\nlocal map = createMap()\nlocal parent = uf_initialize(h * w)\n\nlocal function walk(src, dst)\n if map[src] ~= map[dst] then\n local sr, dr = uf_findroot(src, parent), uf_findroot(dst, parent)\n parent[src], parent[dst] = sr, dr\n if sr ~= dr then\n parent[dst], parent[dr] = sr, sr\n end\n end\nend\n\nfor idx = 1, h * w do\n if w < idx then walk(idx, idx - w) end\n if idx <= (h - 1) * w then walk(idx, idx + w) end\n if 1 < w then\n if idx % w ~= 0 then walk(idx, idx + 1) end\n if idx % w ~= 1 then walk(idx, idx - 1) end\n end\nend\nlocal groups = {}\nfor idx = 1, h * w do\n local r = uf_findroot(idx, parent)\n if not groups[r] then\n local tmp = {0, 0}\n groups[r] = tmp\n end\n if map[idx] then\n groups[r][1] = groups[r][1] + 1\n else\n groups[r][2] = groups[r][2] + 1\n end\nend\nlocal ret = 0\nfor k, v in pairs(groups) do\n ret = ret + v[1] * v[2]\nend\nprint(ret)\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere is a grid with H rows and W columns, where each square is painted black or white.\n\nYou are given H strings S_1, S_2, ..., S_H, each of length W.\nIf the square at the i-th row from the top and the j-th column from the left is painted black, the j-th character in the string S_i is #; if that square is painted white, the j-th character in the string S_i is ..\n\nFind the number of pairs of a black square c_1 and a white square c_2 that satisfy the following condition:\n\nThere is a path from the square c_1 to the square c_2 where we repeatedly move to a vertically or horizontally adjacent square through an alternating sequence of black and white squares: black, white, black, white...\n\nConstraints\n\n1 \\leq H, W \\leq 400\n\n|S_i| = W (1 \\leq i \\leq H)\n\nFor each i (1 \\leq i \\leq H), the string S_i consists of characters # and ..\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\nS_1\nS_2\n:\nS_H\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n3 3\n.#.\n..#\n#..\n\nSample Output 1\n\n10\n\nSome of the pairs satisfying the condition are ((1, 2), (3, 3)) and ((3, 1), (3, 2)), where (i, j) denotes the square at the i-th row from the top and the j-th column from the left.\n\nSample Input 2\n\n2 4\n....\n....\n\nSample Output 2\n\n0\n\nSample Input 3\n\n4 3\n###\n###\n...\n###\n\nSample Output 3\n\n6", "sample_input": "3 3\n.#.\n..#\n#..\n"}, "reference_outputs": ["10\n"], "source_document_id": "p03157", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere is a grid with H rows and W columns, where each square is painted black or white.\n\nYou are given H strings S_1, S_2, ..., S_H, each of length W.\nIf the square at the i-th row from the top and the j-th column from the left is painted black, the j-th character in the string S_i is #; if that square is painted white, the j-th character in the string S_i is ..\n\nFind the number of pairs of a black square c_1 and a white square c_2 that satisfy the following condition:\n\nThere is a path from the square c_1 to the square c_2 where we repeatedly move to a vertically or horizontally adjacent square through an alternating sequence of black and white squares: black, white, black, white...\n\nConstraints\n\n1 \\leq H, W \\leq 400\n\n|S_i| = W (1 \\leq i \\leq H)\n\nFor each i (1 \\leq i \\leq H), the string S_i consists of characters # and ..\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\nS_1\nS_2\n:\nS_H\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n3 3\n.#.\n..#\n#..\n\nSample Output 1\n\n10\n\nSome of the pairs satisfying the condition are ((1, 2), (3, 3)) and ((3, 1), (3, 2)), where (i, j) denotes the square at the i-th row from the top and the j-th column from the left.\n\nSample Input 2\n\n2 4\n....\n....\n\nSample Output 2\n\n0\n\nSample Input 3\n\n4 3\n###\n###\n...\n###\n\nSample Output 3\n\n6", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1460, "cpu_time_ms": 297, "memory_kb": 15092}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s537462448", "group_id": "codeNet:p03158", "input_text": "local mfl = math.floor\n\nlocal function comp(a, b)\n return a < b\nend\n\nlocal function lower_bound(ary, x)\n local num = #ary\n if num == 0 then return 1 end\n if not comp(ary[1], x) then return 1 end\n if comp(ary[num], x) then return num + 1 end\n local min, max = 1, num\n while 1 < max - min do\n local mid = mfl((min + max) / 2)\n if comp(ary[mid], x) then\n min = mid\n else\n max = mid\n end\n end\n return max\nend\n\nlocal function upper_bound(ary, x)\n local num = #ary\n if num == 0 then return 1 end\n if comp(x, ary[1]) then return 1 end\n if not comp(x, ary[num]) then return num + 1 end\n local min, max = 1, num\n while 1 < max - min do\n local mid = mfl((min + max) / 2)\n if not comp(x, ary[mid]) then\n min = mid\n else\n max = mid\n end\n end\n return max\nend\n\nlocal n, q = io.read(\"*n\", \"*n\")\nlocal a = {io.read(\"*n\")}\nlocal asum = {a[1]}\nfor i = 2, n do\n a[i] = io.read(\"*n\")\n asum[i] = asum[i - 1] + a[i]\nend\nlocal oddsum = {a[1]}\nfor i = 2, n do\n if i % 2 == 0 then\n oddsum[i] = oddsum[i - 1]\n else\n oddsum[i] = oddsum[i - 1] + a[i]\n end\nend\n\nlocal function get_ao_state(x, taka_count)\n local p_right = n - taka_count\n local len = a[p_right] - x\n if len <= 0 then\n -- taka_count should be smaller\n return true, 0\n end\n local p_left = lower_bound(a, x - len)\n local need_ao_count = p_right - p_left + 1\n if taka_count < need_ao_count then\n -- taka_count should be larger\n return false\n else\n return true, need_ao_count\n end\nend\n\nfor iq = 1, q do\n local x = io.read(\"*n\")\n local x_lbpos = lower_bound(a, x)\n local taka_count_lim = n + 1 - x_lbpos\n local taka_count, ao_count = 0, 0\n if 0 < taka_count_lim then\n local f = get_ao_state(x, 0)\n if not f then\n local min, max = 0, taka_count_lim\n while 1 < max - min do\n local mid = mfl((max + min) / 2)\n if get_ao_state(x, mid) then\n max = mid\n else\n min = mid\n end\n end\n taka_count = max\n end\n end\n local _u, ao_count = get_ao_state(x, taka_count)\n if ao_count < taka_count - 1 then\n ao_count = taka_count - 1\n end\n local takasum = asum[n] - asum[n - taka_count]\n local rem = n - taka_count - ao_count\n if 0 < rem then\n if rem % 2 == 0 then\n if ao_count < taka_count then\n takasum = takasum + oddsum[n - taka_count - ao_count]\n else\n takasum = takasum + asum[n - taka_count - ao_count] - oddsum[n - taka_count - ao_count]\n end\n else\n if ao_count < taka_count then\n takasum = takasum + asum[n - taka_count - ao_count] - oddsum[n - taka_count - ao_count]\n else\n takasum = takasum + oddsum[n - taka_count - ao_count]\n end\n end\n end\n print(takasum)\nend\n", "language": "Lua", "metadata": {"date": 1575760061, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p03158.html", "problem_id": "p03158", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03158/input.txt", "sample_output_relpath": "derived/input_output/data/p03158/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03158/Lua/s537462448.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s537462448", "user_id": "u120582723"}, "prompt_components": {"gold_output": "31\n31\n27\n23\n23\n", "input_to_evaluate": "local mfl = math.floor\n\nlocal function comp(a, b)\n return a < b\nend\n\nlocal function lower_bound(ary, x)\n local num = #ary\n if num == 0 then return 1 end\n if not comp(ary[1], x) then return 1 end\n if comp(ary[num], x) then return num + 1 end\n local min, max = 1, num\n while 1 < max - min do\n local mid = mfl((min + max) / 2)\n if comp(ary[mid], x) then\n min = mid\n else\n max = mid\n end\n end\n return max\nend\n\nlocal function upper_bound(ary, x)\n local num = #ary\n if num == 0 then return 1 end\n if comp(x, ary[1]) then return 1 end\n if not comp(x, ary[num]) then return num + 1 end\n local min, max = 1, num\n while 1 < max - min do\n local mid = mfl((min + max) / 2)\n if not comp(x, ary[mid]) then\n min = mid\n else\n max = mid\n end\n end\n return max\nend\n\nlocal n, q = io.read(\"*n\", \"*n\")\nlocal a = {io.read(\"*n\")}\nlocal asum = {a[1]}\nfor i = 2, n do\n a[i] = io.read(\"*n\")\n asum[i] = asum[i - 1] + a[i]\nend\nlocal oddsum = {a[1]}\nfor i = 2, n do\n if i % 2 == 0 then\n oddsum[i] = oddsum[i - 1]\n else\n oddsum[i] = oddsum[i - 1] + a[i]\n end\nend\n\nlocal function get_ao_state(x, taka_count)\n local p_right = n - taka_count\n local len = a[p_right] - x\n if len <= 0 then\n -- taka_count should be smaller\n return true, 0\n end\n local p_left = lower_bound(a, x - len)\n local need_ao_count = p_right - p_left + 1\n if taka_count < need_ao_count then\n -- taka_count should be larger\n return false\n else\n return true, need_ao_count\n end\nend\n\nfor iq = 1, q do\n local x = io.read(\"*n\")\n local x_lbpos = lower_bound(a, x)\n local taka_count_lim = n + 1 - x_lbpos\n local taka_count, ao_count = 0, 0\n if 0 < taka_count_lim then\n local f = get_ao_state(x, 0)\n if not f then\n local min, max = 0, taka_count_lim\n while 1 < max - min do\n local mid = mfl((max + min) / 2)\n if get_ao_state(x, mid) then\n max = mid\n else\n min = mid\n end\n end\n taka_count = max\n end\n end\n local _u, ao_count = get_ao_state(x, taka_count)\n if ao_count < taka_count - 1 then\n ao_count = taka_count - 1\n end\n local takasum = asum[n] - asum[n - taka_count]\n local rem = n - taka_count - ao_count\n if 0 < rem then\n if rem % 2 == 0 then\n if ao_count < taka_count then\n takasum = takasum + oddsum[n - taka_count - ao_count]\n else\n takasum = takasum + asum[n - taka_count - ao_count] - oddsum[n - taka_count - ao_count]\n end\n else\n if ao_count < taka_count then\n takasum = takasum + asum[n - taka_count - ao_count] - oddsum[n - taka_count - ao_count]\n else\n takasum = takasum + oddsum[n - taka_count - ao_count]\n end\n end\n end\n print(takasum)\nend\n", "problem_context": "Score : 500 points\n\nProblem Statement\n\nThere are N cards. The i-th card has an integer A_i written on it.\nFor any two cards, the integers on those cards are different.\n\nUsing these cards, Takahashi and Aoki will play the following game:\n\nAoki chooses an integer x.\n\nStarting from Takahashi, the two players alternately take a card. The card should be chosen in the following manner:\n\nTakahashi should take the card with the largest integer among the remaining card.\n\nAoki should take the card with the integer closest to x among the remaining card. If there are multiple such cards, he should take the card with the smallest integer among those cards.\n\nThe game ends when there is no card remaining.\n\nYou are given Q candidates for the value of x: X_1, X_2, ..., X_Q.\nFor each i (1 \\leq i \\leq Q), find the sum of the integers written on the cards that Takahashi will take if Aoki chooses x = X_i.\n\nConstraints\n\n2 \\leq N \\leq 100 000\n\n1 \\leq Q \\leq 100 000\n\n1 \\leq A_1 < A_2 < ... < A_N \\leq 10^9\n\n1 \\leq X_i \\leq 10^9 (1 \\leq i \\leq Q)\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN Q\nA_1 A_2 ... A_N\nX_1\nX_2\n:\nX_Q\n\nOutput\n\nPrint Q lines. The i-th line (1 \\leq i \\leq Q) should contain the answer for x = X_i.\n\nSample Input 1\n\n5 5\n3 5 7 11 13\n1\n4\n9\n10\n13\n\nSample Output 1\n\n31\n31\n27\n23\n23\n\nFor example, when x = X_3(= 9), the game proceeds as follows:\n\nTakahashi takes the card with 13.\n\nAoki takes the card with 7.\n\nTakahashi takes the card with 11.\n\nAoki takes the card with 5.\n\nTakahashi takes the card with 3.\n\nThus, 13 + 11 + 3 = 27 should be printed on the third line.\n\nSample Input 2\n\n4 3\n10 20 30 40\n2\n34\n34\n\nSample Output 2\n\n70\n60\n60", "sample_input": "5 5\n3 5 7 11 13\n1\n4\n9\n10\n13\n"}, "reference_outputs": ["31\n31\n27\n23\n23\n"], "source_document_id": "p03158", "source_text": "Score : 500 points\n\nProblem Statement\n\nThere are N cards. The i-th card has an integer A_i written on it.\nFor any two cards, the integers on those cards are different.\n\nUsing these cards, Takahashi and Aoki will play the following game:\n\nAoki chooses an integer x.\n\nStarting from Takahashi, the two players alternately take a card. The card should be chosen in the following manner:\n\nTakahashi should take the card with the largest integer among the remaining card.\n\nAoki should take the card with the integer closest to x among the remaining card. If there are multiple such cards, he should take the card with the smallest integer among those cards.\n\nThe game ends when there is no card remaining.\n\nYou are given Q candidates for the value of x: X_1, X_2, ..., X_Q.\nFor each i (1 \\leq i \\leq Q), find the sum of the integers written on the cards that Takahashi will take if Aoki chooses x = X_i.\n\nConstraints\n\n2 \\leq N \\leq 100 000\n\n1 \\leq Q \\leq 100 000\n\n1 \\leq A_1 < A_2 < ... < A_N \\leq 10^9\n\n1 \\leq X_i \\leq 10^9 (1 \\leq i \\leq Q)\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN Q\nA_1 A_2 ... A_N\nX_1\nX_2\n:\nX_Q\n\nOutput\n\nPrint Q lines. The i-th line (1 \\leq i \\leq Q) should contain the answer for x = X_i.\n\nSample Input 1\n\n5 5\n3 5 7 11 13\n1\n4\n9\n10\n13\n\nSample Output 1\n\n31\n31\n27\n23\n23\n\nFor example, when x = X_3(= 9), the game proceeds as follows:\n\nTakahashi takes the card with 13.\n\nAoki takes the card with 7.\n\nTakahashi takes the card with 11.\n\nAoki takes the card with 5.\n\nTakahashi takes the card with 3.\n\nThus, 13 + 11 + 3 = 27 should be printed on the third line.\n\nSample Input 2\n\n4 3\n10 20 30 40\n2\n34\n34\n\nSample Output 2\n\n70\n60\n60", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2739, "cpu_time_ms": 723, "memory_kb": 5120}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s945993465", "group_id": "codeNet:p03162", "input_text": "local n=io.read(\"n\")\nlocal t={}\nfor i=1,n do\n t[i]={}\n for j=1,3 do\n t[i][j]=io.read(\"n\")\n end\nend\n\nlocal dp={}\nfor i=1,n+1 do\n dp[i]={0,0,0}\nend\n\nfor i=1,n do\n for j=1,3 do\n for k=1,3 do\n if j~=k then\n dp[i+1][k]=math.max(dp[i+1][k],dp[i][j]+t[i][k])\n end\n end\n end\nend\n\nprint(math.max(table.unpack(dp[n+1])))", "language": "Lua", "metadata": {"date": 1600460552, "filename_ext": "lua", "original_language": "Lua (Lua 5.3.5)", "problem_description_relpath": "problem_descriptions/p03162.html", "problem_id": "p03162", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03162/input.txt", "sample_output_relpath": "derived/input_output/data/p03162/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03162/Lua/s945993465.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s945993465", "user_id": "u045238009"}, "prompt_components": {"gold_output": "210\n", "input_to_evaluate": "local n=io.read(\"n\")\nlocal t={}\nfor i=1,n do\n t[i]={}\n for j=1,3 do\n t[i][j]=io.read(\"n\")\n end\nend\n\nlocal dp={}\nfor i=1,n+1 do\n dp[i]={0,0,0}\nend\n\nfor i=1,n do\n for j=1,3 do\n for k=1,3 do\n if j~=k then\n dp[i+1][k]=math.max(dp[i+1][k],dp[i][j]+t[i][k])\n end\n end\n end\nend\n\nprint(math.max(table.unpack(dp[n+1])))", "problem_context": "Score : 100 points\n\nProblem Statement\n\nTaro's summer vacation starts tomorrow, and he has decided to make plans for it now.\n\nThe vacation consists of N days.\nFor each i (1 \\leq i \\leq N), Taro will choose one of the following activities and do it on the i-th day:\n\nA: Swim in the sea. Gain a_i points of happiness.\n\nB: Catch bugs in the mountains. Gain b_i points of happiness.\n\nC: Do homework at home. Gain c_i points of happiness.\n\nAs Taro gets bored easily, he cannot do the same activities for two or more consecutive days.\n\nFind the maximum possible total points of happiness that Taro gains.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^5\n\n1 \\leq a_i, b_i, c_i \\leq 10^4\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 b_1 c_1\na_2 b_2 c_2\n:\na_N b_N c_N\n\nOutput\n\nPrint the maximum possible total points of happiness that Taro gains.\n\nSample Input 1\n\n3\n10 40 70\n20 50 80\n30 60 90\n\nSample Output 1\n\n210\n\nIf Taro does activities in the order C, B, C, he will gain 70 + 50 + 90 = 210 points of happiness.\n\nSample Input 2\n\n1\n100 10 1\n\nSample Output 2\n\n100\n\nSample Input 3\n\n7\n6 7 8\n8 8 3\n2 5 2\n7 8 6\n4 6 8\n2 3 4\n7 5 1\n\nSample Output 3\n\n46\n\nTaro should do activities in the order C, A, B, A, C, B, A.", "sample_input": "3\n10 40 70\n20 50 80\n30 60 90\n"}, "reference_outputs": ["210\n"], "source_document_id": "p03162", "source_text": "Score : 100 points\n\nProblem Statement\n\nTaro's summer vacation starts tomorrow, and he has decided to make plans for it now.\n\nThe vacation consists of N days.\nFor each i (1 \\leq i \\leq N), Taro will choose one of the following activities and do it on the i-th day:\n\nA: Swim in the sea. Gain a_i points of happiness.\n\nB: Catch bugs in the mountains. Gain b_i points of happiness.\n\nC: Do homework at home. Gain c_i points of happiness.\n\nAs Taro gets bored easily, he cannot do the same activities for two or more consecutive days.\n\nFind the maximum possible total points of happiness that Taro gains.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^5\n\n1 \\leq a_i, b_i, c_i \\leq 10^4\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 b_1 c_1\na_2 b_2 c_2\n:\na_N b_N c_N\n\nOutput\n\nPrint the maximum possible total points of happiness that Taro gains.\n\nSample Input 1\n\n3\n10 40 70\n20 50 80\n30 60 90\n\nSample Output 1\n\n210\n\nIf Taro does activities in the order C, B, C, he will gain 70 + 50 + 90 = 210 points of happiness.\n\nSample Input 2\n\n1\n100 10 1\n\nSample Output 2\n\n100\n\nSample Input 3\n\n7\n6 7 8\n8 8 3\n2 5 2\n7 8 6\n4 6 8\n2 3 4\n7 5 1\n\nSample Output 3\n\n46\n\nTaro should do activities in the order C, A, B, A, C, B, A.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 386, "cpu_time_ms": 229, "memory_kb": 32976}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s118529969", "group_id": "codeNet:p03162", "input_text": "n=io.read\"*n\"\na,b,c={},{},{}for i=1,n do\na[i]=io.read\"*n\"\nb[i]=io.read\"*n\"\nc[i]=io.read\"*n\"end\n\ndp={{a[1],b[1],c[1]}}\nfor i=2,n do dp[i]={}end\n\nfor i=2,n do\ndp[i][1]=math.max(dp[i-1][2],dp[i-1][3])+a[i]\ndp[i][2]=math.max(dp[i-1][3],dp[i-1][1])+b[i]\ndp[i][3]=math.max(dp[i-1][1],dp[i-1][2])+c[i]\nend\nprint(math.max(dp[n][1],dp[n][2],dp[n][3]))", "language": "Lua", "metadata": {"date": 1587338700, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p03162.html", "problem_id": "p03162", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03162/input.txt", "sample_output_relpath": "derived/input_output/data/p03162/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03162/Lua/s118529969.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s118529969", "user_id": "u726173718"}, "prompt_components": {"gold_output": "210\n", "input_to_evaluate": "n=io.read\"*n\"\na,b,c={},{},{}for i=1,n do\na[i]=io.read\"*n\"\nb[i]=io.read\"*n\"\nc[i]=io.read\"*n\"end\n\ndp={{a[1],b[1],c[1]}}\nfor i=2,n do dp[i]={}end\n\nfor i=2,n do\ndp[i][1]=math.max(dp[i-1][2],dp[i-1][3])+a[i]\ndp[i][2]=math.max(dp[i-1][3],dp[i-1][1])+b[i]\ndp[i][3]=math.max(dp[i-1][1],dp[i-1][2])+c[i]\nend\nprint(math.max(dp[n][1],dp[n][2],dp[n][3]))", "problem_context": "Score : 100 points\n\nProblem Statement\n\nTaro's summer vacation starts tomorrow, and he has decided to make plans for it now.\n\nThe vacation consists of N days.\nFor each i (1 \\leq i \\leq N), Taro will choose one of the following activities and do it on the i-th day:\n\nA: Swim in the sea. Gain a_i points of happiness.\n\nB: Catch bugs in the mountains. Gain b_i points of happiness.\n\nC: Do homework at home. Gain c_i points of happiness.\n\nAs Taro gets bored easily, he cannot do the same activities for two or more consecutive days.\n\nFind the maximum possible total points of happiness that Taro gains.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^5\n\n1 \\leq a_i, b_i, c_i \\leq 10^4\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 b_1 c_1\na_2 b_2 c_2\n:\na_N b_N c_N\n\nOutput\n\nPrint the maximum possible total points of happiness that Taro gains.\n\nSample Input 1\n\n3\n10 40 70\n20 50 80\n30 60 90\n\nSample Output 1\n\n210\n\nIf Taro does activities in the order C, B, C, he will gain 70 + 50 + 90 = 210 points of happiness.\n\nSample Input 2\n\n1\n100 10 1\n\nSample Output 2\n\n100\n\nSample Input 3\n\n7\n6 7 8\n8 8 3\n2 5 2\n7 8 6\n4 6 8\n2 3 4\n7 5 1\n\nSample Output 3\n\n46\n\nTaro should do activities in the order C, A, B, A, C, B, A.", "sample_input": "3\n10 40 70\n20 50 80\n30 60 90\n"}, "reference_outputs": ["210\n"], "source_document_id": "p03162", "source_text": "Score : 100 points\n\nProblem Statement\n\nTaro's summer vacation starts tomorrow, and he has decided to make plans for it now.\n\nThe vacation consists of N days.\nFor each i (1 \\leq i \\leq N), Taro will choose one of the following activities and do it on the i-th day:\n\nA: Swim in the sea. Gain a_i points of happiness.\n\nB: Catch bugs in the mountains. Gain b_i points of happiness.\n\nC: Do homework at home. Gain c_i points of happiness.\n\nAs Taro gets bored easily, he cannot do the same activities for two or more consecutive days.\n\nFind the maximum possible total points of happiness that Taro gains.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^5\n\n1 \\leq a_i, b_i, c_i \\leq 10^4\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 b_1 c_1\na_2 b_2 c_2\n:\na_N b_N c_N\n\nOutput\n\nPrint the maximum possible total points of happiness that Taro gains.\n\nSample Input 1\n\n3\n10 40 70\n20 50 80\n30 60 90\n\nSample Output 1\n\n210\n\nIf Taro does activities in the order C, B, C, he will gain 70 + 50 + 90 = 210 points of happiness.\n\nSample Input 2\n\n1\n100 10 1\n\nSample Output 2\n\n100\n\nSample Input 3\n\n7\n6 7 8\n8 8 3\n2 5 2\n7 8 6\n4 6 8\n2 3 4\n7 5 1\n\nSample Output 3\n\n46\n\nTaro should do activities in the order C, A, B, A, C, B, A.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 342, "cpu_time_ms": 91, "memory_kb": 12928}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s890992091", "group_id": "codeNet:p03164", "input_text": "local read = setmetatable({}, {__index = function(t, k) local a = {} for i=1,#k do table.insert(a, '*'..string.sub(k, i, i)) end local r = io.read local u = table.unpack or unpack return function() return r(u(a)) end end})\nread.N = function(N) local t={} for i=1,N do t[i]=read.n() end return t end\nstring.totable = function(s) local t={} local u=string.sub for i=1,#s do t[i] = u(s, i, i) end return t end\nstring.split = function(s) local t={} for w in string.gmatch(s, \"[^%s]+\") do table.insert(t, w) end return (table.unpack or unpack)(t) end\nlocal function array(dimension, default_val) local n=dimension local m={default_val and {__index=function()return default_val end}}for i=2,n do m[i]={__index=function(p, k)local c=setmetatable({},m[i-1])rawset(p,k,c)return c end}end return setmetatable({},m[n])end\n----\nlocal N, W = read.nn()\nlocal w, v = {}, {}\nfor i=1,N do\n w[i], v[i] = read.nn()\nend\nlocal tbl = array(2, 10^10)\ntbl[0][0] = 0\nfor i=0,N-1 do\n local nw, nv = w[i+1], v[i+1]\n for j=0,100000 do\n if tbl[i+1][j] > tbl[i][j] then\n tbl[i+1][j] = tbl[i][j]\n end\n if tbl[i+1][j+nv] > tbl[i][j] + nw then\n tbl[i+1][j+nv] = tbl[i][j] + nw\n end\n end\nend\nlocal ans = 0\nfor j=0,100000 do\n if tbl[N][j] <= W then\n ans = math.max(ans, j)\n end\nend\nprint(ans)", "language": "Lua", "metadata": {"date": 1581807403, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p03164.html", "problem_id": "p03164", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03164/input.txt", "sample_output_relpath": "derived/input_output/data/p03164/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03164/Lua/s890992091.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s890992091", "user_id": "u162773977"}, "prompt_components": {"gold_output": "90\n", "input_to_evaluate": "local read = setmetatable({}, {__index = function(t, k) local a = {} for i=1,#k do table.insert(a, '*'..string.sub(k, i, i)) end local r = io.read local u = table.unpack or unpack return function() return r(u(a)) end end})\nread.N = function(N) local t={} for i=1,N do t[i]=read.n() end return t end\nstring.totable = function(s) local t={} local u=string.sub for i=1,#s do t[i] = u(s, i, i) end return t end\nstring.split = function(s) local t={} for w in string.gmatch(s, \"[^%s]+\") do table.insert(t, w) end return (table.unpack or unpack)(t) end\nlocal function array(dimension, default_val) local n=dimension local m={default_val and {__index=function()return default_val end}}for i=2,n do m[i]={__index=function(p, k)local c=setmetatable({},m[i-1])rawset(p,k,c)return c end}end return setmetatable({},m[n])end\n----\nlocal N, W = read.nn()\nlocal w, v = {}, {}\nfor i=1,N do\n w[i], v[i] = read.nn()\nend\nlocal tbl = array(2, 10^10)\ntbl[0][0] = 0\nfor i=0,N-1 do\n local nw, nv = w[i+1], v[i+1]\n for j=0,100000 do\n if tbl[i+1][j] > tbl[i][j] then\n tbl[i+1][j] = tbl[i][j]\n end\n if tbl[i+1][j+nv] > tbl[i][j] + nw then\n tbl[i+1][j+nv] = tbl[i][j] + nw\n end\n end\nend\nlocal ans = 0\nfor j=0,100000 do\n if tbl[N][j] <= W then\n ans = math.max(ans, j)\n end\nend\nprint(ans)", "problem_context": "Score : 100 points\n\nProblem Statement\n\nThere are N items, numbered 1, 2, \\ldots, N.\nFor each i (1 \\leq i \\leq N), Item i has a weight of w_i and a value of v_i.\n\nTaro has decided to choose some of the N items and carry them home in a knapsack.\nThe capacity of the knapsack is W, which means that the sum of the weights of items taken must be at most W.\n\nFind the maximum possible sum of the values of items that Taro takes home.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 100\n\n1 \\leq W \\leq 10^9\n\n1 \\leq w_i \\leq W\n\n1 \\leq v_i \\leq 10^3\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN W\nw_1 v_1\nw_2 v_2\n:\nw_N v_N\n\nOutput\n\nPrint the maximum possible sum of the values of items that Taro takes home.\n\nSample Input 1\n\n3 8\n3 30\n4 50\n5 60\n\nSample Output 1\n\n90\n\nItems 1 and 3 should be taken.\nThen, the sum of the weights is 3 + 5 = 8, and the sum of the values is 30 + 60 = 90.\n\nSample Input 2\n\n1 1000000000\n1000000000 10\n\nSample Output 2\n\n10\n\nSample Input 3\n\n6 15\n6 5\n5 6\n6 4\n6 6\n3 5\n7 2\n\nSample Output 3\n\n17\n\nItems 2, 4 and 5 should be taken.\nThen, the sum of the weights is 5 + 6 + 3 = 14, and the sum of the values is 6 + 6 + 5 = 17.", "sample_input": "3 8\n3 30\n4 50\n5 60\n"}, "reference_outputs": ["90\n"], "source_document_id": "p03164", "source_text": "Score : 100 points\n\nProblem Statement\n\nThere are N items, numbered 1, 2, \\ldots, N.\nFor each i (1 \\leq i \\leq N), Item i has a weight of w_i and a value of v_i.\n\nTaro has decided to choose some of the N items and carry them home in a knapsack.\nThe capacity of the knapsack is W, which means that the sum of the weights of items taken must be at most W.\n\nFind the maximum possible sum of the values of items that Taro takes home.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 100\n\n1 \\leq W \\leq 10^9\n\n1 \\leq w_i \\leq W\n\n1 \\leq v_i \\leq 10^3\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN W\nw_1 v_1\nw_2 v_2\n:\nw_N v_N\n\nOutput\n\nPrint the maximum possible sum of the values of items that Taro takes home.\n\nSample Input 1\n\n3 8\n3 30\n4 50\n5 60\n\nSample Output 1\n\n90\n\nItems 1 and 3 should be taken.\nThen, the sum of the weights is 3 + 5 = 8, and the sum of the values is 30 + 60 = 90.\n\nSample Input 2\n\n1 1000000000\n1000000000 10\n\nSample Output 2\n\n10\n\nSample Input 3\n\n6 15\n6 5\n5 6\n6 4\n6 6\n3 5\n7 2\n\nSample Output 3\n\n17\n\nItems 2, 4 and 5 should be taken.\nThen, the sum of the weights is 5 + 6 + 3 = 14, and the sum of the values is 6 + 6 + 5 = 17.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1332, "cpu_time_ms": 1165, "memory_kb": 45848}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s856663120", "group_id": "codeNet:p03164", "input_text": "local mma, mmi = math.max, math.min\nlocal mfl, mce = math.floor, math.ceil\nlocal function comp(a, b)\n return a < b\nend\nlocal function upper_bound(ary, x)\n local num = #ary\n if num == 0 then return 1 end\n if comp(x, ary[1]) then return 1 end\n if not comp(x, ary[num]) then return num + 1 end\n local min, max = 1, num\n while 1 < max - min do\n local mid = mfl((min + max) / 2)\n if not comp(x, ary[mid]) then\n min = mid\n else\n max = mid\n end\n end\n return max\nend\n\nlocal n, W = io.read(\"*n\", \"*n\")\nlocal v, w = {}, {}\nlocal low_w = true\nfor i = 1, n do\n w[i], v[i] = io.read(\"*n\", \"*n\")\nend\n\nlocal function solve_low_w()\n local t = {}\n for i = 1, W do t[i] = 0 end\n for i = 1, n do\n for j = W - w[i], 1, -1 do\n if 0 < t[j] then\n t[j + w[i]] = mma(t[j + w[i]], t[j] + v[i])\n end\n end\n t[w[i]] = mma(t[w[i]], v[i])\n end\n local ret = 0\n for i = 1, W do ret = mma(ret, t[i]) end\n return ret\nend\n\nlocal function solve_low_v()\n local t = {}\n for i = 1, 200000 do t[i] = 0 end\n local v_cursum = 0\n for i = 1, n do\n local vlim = mmi(v_cursum, 200000 - v[i])\n for j = vlim, 1, -1 do\n if 0 < t[j] then\n if t[j + v[i]] == 0 then\n t[j + v[i]] = t[j] + w[i]\n else\n t[j + v[i]] = mmi(t[j + v[i]], t[j] + w[i])\n end\n end\n end\n if t[v[i]] == 0 then\n t[v[i]] = w[i]\n else\n t[v[i]] = mmi(t[v[i]], w[i])\n end\n v_cursum = v_cursum + v[i]\n end\n local ret = 0\n for i = 200000, 1, -1 do\n if 0 < t[i] and t[i] <= W then ret = i break end\n end\n return ret\nend\nprint(solve_low_v())\n", "language": "Lua", "metadata": {"date": 1565604698, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p03164.html", "problem_id": "p03164", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03164/input.txt", "sample_output_relpath": "derived/input_output/data/p03164/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03164/Lua/s856663120.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s856663120", "user_id": "u120582723"}, "prompt_components": {"gold_output": "90\n", "input_to_evaluate": "local mma, mmi = math.max, math.min\nlocal mfl, mce = math.floor, math.ceil\nlocal function comp(a, b)\n return a < b\nend\nlocal function upper_bound(ary, x)\n local num = #ary\n if num == 0 then return 1 end\n if comp(x, ary[1]) then return 1 end\n if not comp(x, ary[num]) then return num + 1 end\n local min, max = 1, num\n while 1 < max - min do\n local mid = mfl((min + max) / 2)\n if not comp(x, ary[mid]) then\n min = mid\n else\n max = mid\n end\n end\n return max\nend\n\nlocal n, W = io.read(\"*n\", \"*n\")\nlocal v, w = {}, {}\nlocal low_w = true\nfor i = 1, n do\n w[i], v[i] = io.read(\"*n\", \"*n\")\nend\n\nlocal function solve_low_w()\n local t = {}\n for i = 1, W do t[i] = 0 end\n for i = 1, n do\n for j = W - w[i], 1, -1 do\n if 0 < t[j] then\n t[j + w[i]] = mma(t[j + w[i]], t[j] + v[i])\n end\n end\n t[w[i]] = mma(t[w[i]], v[i])\n end\n local ret = 0\n for i = 1, W do ret = mma(ret, t[i]) end\n return ret\nend\n\nlocal function solve_low_v()\n local t = {}\n for i = 1, 200000 do t[i] = 0 end\n local v_cursum = 0\n for i = 1, n do\n local vlim = mmi(v_cursum, 200000 - v[i])\n for j = vlim, 1, -1 do\n if 0 < t[j] then\n if t[j + v[i]] == 0 then\n t[j + v[i]] = t[j] + w[i]\n else\n t[j + v[i]] = mmi(t[j + v[i]], t[j] + w[i])\n end\n end\n end\n if t[v[i]] == 0 then\n t[v[i]] = w[i]\n else\n t[v[i]] = mmi(t[v[i]], w[i])\n end\n v_cursum = v_cursum + v[i]\n end\n local ret = 0\n for i = 200000, 1, -1 do\n if 0 < t[i] and t[i] <= W then ret = i break end\n end\n return ret\nend\nprint(solve_low_v())\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nThere are N items, numbered 1, 2, \\ldots, N.\nFor each i (1 \\leq i \\leq N), Item i has a weight of w_i and a value of v_i.\n\nTaro has decided to choose some of the N items and carry them home in a knapsack.\nThe capacity of the knapsack is W, which means that the sum of the weights of items taken must be at most W.\n\nFind the maximum possible sum of the values of items that Taro takes home.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 100\n\n1 \\leq W \\leq 10^9\n\n1 \\leq w_i \\leq W\n\n1 \\leq v_i \\leq 10^3\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN W\nw_1 v_1\nw_2 v_2\n:\nw_N v_N\n\nOutput\n\nPrint the maximum possible sum of the values of items that Taro takes home.\n\nSample Input 1\n\n3 8\n3 30\n4 50\n5 60\n\nSample Output 1\n\n90\n\nItems 1 and 3 should be taken.\nThen, the sum of the weights is 3 + 5 = 8, and the sum of the values is 30 + 60 = 90.\n\nSample Input 2\n\n1 1000000000\n1000000000 10\n\nSample Output 2\n\n10\n\nSample Input 3\n\n6 15\n6 5\n5 6\n6 4\n6 6\n3 5\n7 2\n\nSample Output 3\n\n17\n\nItems 2, 4 and 5 should be taken.\nThen, the sum of the weights is 5 + 6 + 3 = 14, and the sum of the values is 6 + 6 + 5 = 17.", "sample_input": "3 8\n3 30\n4 50\n5 60\n"}, "reference_outputs": ["90\n"], "source_document_id": "p03164", "source_text": "Score : 100 points\n\nProblem Statement\n\nThere are N items, numbered 1, 2, \\ldots, N.\nFor each i (1 \\leq i \\leq N), Item i has a weight of w_i and a value of v_i.\n\nTaro has decided to choose some of the N items and carry them home in a knapsack.\nThe capacity of the knapsack is W, which means that the sum of the weights of items taken must be at most W.\n\nFind the maximum possible sum of the values of items that Taro takes home.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 100\n\n1 \\leq W \\leq 10^9\n\n1 \\leq w_i \\leq W\n\n1 \\leq v_i \\leq 10^3\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN W\nw_1 v_1\nw_2 v_2\n:\nw_N v_N\n\nOutput\n\nPrint the maximum possible sum of the values of items that Taro takes home.\n\nSample Input 1\n\n3 8\n3 30\n4 50\n5 60\n\nSample Output 1\n\n90\n\nItems 1 and 3 should be taken.\nThen, the sum of the weights is 3 + 5 = 8, and the sum of the values is 30 + 60 = 90.\n\nSample Input 2\n\n1 1000000000\n1000000000 10\n\nSample Output 2\n\n10\n\nSample Input 3\n\n6 15\n6 5\n5 6\n6 4\n6 6\n3 5\n7 2\n\nSample Output 3\n\n17\n\nItems 2, 4 and 5 should be taken.\nThen, the sum of the weights is 5 + 6 + 3 = 14, and the sum of the values is 6 + 6 + 5 = 17.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1608, "cpu_time_ms": 66, "memory_kb": 2304}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s481255393", "group_id": "codeNet:p03166", "input_text": "local read = setmetatable({}, {__index = function(t, k) local a = {} for i=1,#k do table.insert(a, '*'..string.sub(k, i, i)) end local r = io.read local u = table.unpack or unpack return function() return r(u(a)) end end})\nread.N = function(N) local t={} for i=1,N do t[i]=read.n() end return t end\nstring.totable = function(s) local t={} local u=string.sub for i=1,#s do t[i] = u(s, i, i) end return t end\nstring.split = function(s) local t={} for w in string.gmatch(s, \"[^%s]+\") do table.insert(t, w) end return (table.unpack or unpack)(t) end\nlocal function array(dimension, default_val) local n=dimension local m={}if default_val~=nil then m[1]={__index=function()return default_val end}end for i=2,n do m[i]={__index=function(p, k)local c=setmetatable({},m[i-1])rawset(p,k,c)return c end}end return setmetatable({},m[n])end\nlocal unpack = table.unpack or unpack\nlocal insert = table.insert or insert\nlocal max = math.max\n----\nlocal function adj_list(num_nodes)\n local t = {}\n for n=1, num_nodes do\n t[n] = {}\n end\n return t\nend\n----\nlocal N, M = read.nn()\nlocal edges = adj_list(N)\nlocal rev_adj_mat = array(2, nil)\nfor i=1,M do\n local x, y = read.nn()\n edges[x][#edges[x] + 1] = y\n rev_adj_mat[y][x] = true\nend\nlocal function indeg_zero(n)\n for k, v in pairs(rev_adj_mat[n]) do\n if v then\n return false\n end\n end\n return true\nend\n\nlocal toposorted = {}\nlocal q = {}\nfor n=1,N do\n if indeg_zero(n) then\n insert(q, n)\n end\nend\nlocal front = 1\nlocal back = #q + 1\nlocal function push(v)\n q[back] = v\n back = back + 1\nend\nlocal function pop()\n local r = q[front]\n front = front + 1\n return r\nend\nlocal function empty()\n return back - front == 0\nend\n\nwhile not empty() do\n local n = pop()\n insert(toposorted, n)\n for k, m in pairs(edges[n]) do\n rev_adj_mat[m][n] = nil\n if indeg_zero(m) then\n push(m)\n end\n end\nend\n--[[\nfor k, v in pairs(toposorted) do\n print(k, v)\nend\n]]\nlocal lp_from = array(1, 0)\nfor _, n in pairs(toposorted) do\n for _, m in pairs(edges[n]) do\n lp_from[m] = max(lp_from[m], lp_from[n] + 1)\n end\nend\nlocal ans = 0\nfor _, lp in pairs(lp_from) do\n ans = max(ans, lp)\nend\nprint(ans)", "language": "Lua", "metadata": {"date": 1581973949, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03166.html", "problem_id": "p03166", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03166/input.txt", "sample_output_relpath": "derived/input_output/data/p03166/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03166/Lua/s481255393.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s481255393", "user_id": "u162773977"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "local read = setmetatable({}, {__index = function(t, k) local a = {} for i=1,#k do table.insert(a, '*'..string.sub(k, i, i)) end local r = io.read local u = table.unpack or unpack return function() return r(u(a)) end end})\nread.N = function(N) local t={} for i=1,N do t[i]=read.n() end return t end\nstring.totable = function(s) local t={} local u=string.sub for i=1,#s do t[i] = u(s, i, i) end return t end\nstring.split = function(s) local t={} for w in string.gmatch(s, \"[^%s]+\") do table.insert(t, w) end return (table.unpack or unpack)(t) end\nlocal function array(dimension, default_val) local n=dimension local m={}if default_val~=nil then m[1]={__index=function()return default_val end}end for i=2,n do m[i]={__index=function(p, k)local c=setmetatable({},m[i-1])rawset(p,k,c)return c end}end return setmetatable({},m[n])end\nlocal unpack = table.unpack or unpack\nlocal insert = table.insert or insert\nlocal max = math.max\n----\nlocal function adj_list(num_nodes)\n local t = {}\n for n=1, num_nodes do\n t[n] = {}\n end\n return t\nend\n----\nlocal N, M = read.nn()\nlocal edges = adj_list(N)\nlocal rev_adj_mat = array(2, nil)\nfor i=1,M do\n local x, y = read.nn()\n edges[x][#edges[x] + 1] = y\n rev_adj_mat[y][x] = true\nend\nlocal function indeg_zero(n)\n for k, v in pairs(rev_adj_mat[n]) do\n if v then\n return false\n end\n end\n return true\nend\n\nlocal toposorted = {}\nlocal q = {}\nfor n=1,N do\n if indeg_zero(n) then\n insert(q, n)\n end\nend\nlocal front = 1\nlocal back = #q + 1\nlocal function push(v)\n q[back] = v\n back = back + 1\nend\nlocal function pop()\n local r = q[front]\n front = front + 1\n return r\nend\nlocal function empty()\n return back - front == 0\nend\n\nwhile not empty() do\n local n = pop()\n insert(toposorted, n)\n for k, m in pairs(edges[n]) do\n rev_adj_mat[m][n] = nil\n if indeg_zero(m) then\n push(m)\n end\n end\nend\n--[[\nfor k, v in pairs(toposorted) do\n print(k, v)\nend\n]]\nlocal lp_from = array(1, 0)\nfor _, n in pairs(toposorted) do\n for _, m in pairs(edges[n]) do\n lp_from[m] = max(lp_from[m], lp_from[n] + 1)\n end\nend\nlocal ans = 0\nfor _, lp in pairs(lp_from) do\n ans = max(ans, lp)\nend\nprint(ans)", "problem_context": "Score : 100 points\n\nProblem Statement\n\nThere is a directed graph G with N vertices and M edges.\nThe vertices are numbered 1, 2, \\ldots, N, and for each i (1 \\leq i \\leq M), the i-th directed edge goes from Vertex x_i to y_i.\nG does not contain directed cycles.\n\nFind the length of the longest directed path in G.\nHere, the length of a directed path is the number of edges in it.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^5\n\n1 \\leq x_i, y_i \\leq N\n\nAll pairs (x_i, y_i) are distinct.\n\nG does not contain directed cycles.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nx_1 y_1\nx_2 y_2\n:\nx_M y_M\n\nOutput\n\nPrint the length of the longest directed path in G.\n\nSample Input 1\n\n4 5\n1 2\n1 3\n3 2\n2 4\n3 4\n\nSample Output 1\n\n3\n\nThe red directed path in the following figure is the longest:\n\nSample Input 2\n\n6 3\n2 3\n4 5\n5 6\n\nSample Output 2\n\n2\n\nThe red directed path in the following figure is the longest:\n\nSample Input 3\n\n5 8\n5 3\n2 3\n2 4\n5 2\n5 1\n1 4\n4 3\n1 3\n\nSample Output 3\n\n3\n\nThe red directed path in the following figure is one of the longest:", "sample_input": "4 5\n1 2\n1 3\n3 2\n2 4\n3 4\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03166", "source_text": "Score : 100 points\n\nProblem Statement\n\nThere is a directed graph G with N vertices and M edges.\nThe vertices are numbered 1, 2, \\ldots, N, and for each i (1 \\leq i \\leq M), the i-th directed edge goes from Vertex x_i to y_i.\nG does not contain directed cycles.\n\nFind the length of the longest directed path in G.\nHere, the length of a directed path is the number of edges in it.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^5\n\n1 \\leq x_i, y_i \\leq N\n\nAll pairs (x_i, y_i) are distinct.\n\nG does not contain directed cycles.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nx_1 y_1\nx_2 y_2\n:\nx_M y_M\n\nOutput\n\nPrint the length of the longest directed path in G.\n\nSample Input 1\n\n4 5\n1 2\n1 3\n3 2\n2 4\n3 4\n\nSample Output 1\n\n3\n\nThe red directed path in the following figure is the longest:\n\nSample Input 2\n\n6 3\n2 3\n4 5\n5 6\n\nSample Output 2\n\n2\n\nThe red directed path in the following figure is the longest:\n\nSample Input 3\n\n5 8\n5 3\n2 3\n2 4\n5 2\n5 1\n1 4\n4 3\n1 3\n\nSample Output 3\n\n3\n\nThe red directed path in the following figure is one of the longest:", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2257, "cpu_time_ms": 575, "memory_kb": 64232}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s162083261", "group_id": "codeNet:p03167", "input_text": "local h,w=io.read(\"n\",\"n\",\"l\")\nlocal a={}\nfor i=1,h do\n local input=io.read()\n a[i]={}\n for j=1,w do\n a[i][j]=input:byte(j)\n end\nend\n\nlocal dp={}\nfor i=1,h do\n dp[i]={}\n for j=1,w do\n dp[i][j]=0\n end\nend\ndp[1][1]=1\n\nlocal mod=1000000007\nfor i=1,h do\n for j=1,w do\n if i=0 then\n return dp[i][j][k]\n end\n if i==1 and j==1 and k==1 then\n return 0\n end\n local total=0\n if i>1 then\n total=total+solve(i-1,j,k)*(i-1)\n end\n if n+1>i and j>1 then\n total=total+solve(i+1,j-1,k)*(j-1)\n end\n if n+1>j and k>1 then\n total=total+solve(i,j+1,k-1)*(k-1)\n end\n total=total+n\n total=total*(1/(i+j+k-3))\n \n dp[i][j][k]=total\n return dp[i][j][k]\nend\n\nprint(solve(a[1],a[2],a[3]))", "language": "Lua", "metadata": {"date": 1600624744, "filename_ext": "lua", "original_language": "Lua (LuaJIT 2.1.0)", "problem_description_relpath": "problem_descriptions/p03169.html", "problem_id": "p03169", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03169/input.txt", "sample_output_relpath": "derived/input_output/data/p03169/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03169/Lua/s881935028.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s881935028", "user_id": "u045238009"}, "prompt_components": {"gold_output": "5.5\n", "input_to_evaluate": "local n=io.read(\"n\")\nlocal a={1,1,1}\nfor i=1,n do\n local input=io.read(\"n\")\n a[input]=a[input]+1\nend\n\nlocal dp={}\nfor i=1,n+1 do\n dp[i]={}\n for j=1,n+1 do\n dp[i][j]={}\n for k=1,n+1 do\n dp[i][j][k]=-1\n end\n end\nend\n\n\nlocal function solve(i,j,k)\n if dp[i][j][k]>=0 then\n return dp[i][j][k]\n end\n if i==1 and j==1 and k==1 then\n return 0\n end\n local total=0\n if i>1 then\n total=total+solve(i-1,j,k)*(i-1)\n end\n if n+1>i and j>1 then\n total=total+solve(i+1,j-1,k)*(j-1)\n end\n if n+1>j and k>1 then\n total=total+solve(i,j+1,k-1)*(k-1)\n end\n total=total+n\n total=total*(1/(i+j+k-3))\n \n dp[i][j][k]=total\n return dp[i][j][k]\nend\n\nprint(solve(a[1],a[2],a[3]))", "problem_context": "Score : 100 points\n\nProblem Statement\n\nThere are N dishes, numbered 1, 2, \\ldots, N.\nInitially, for each i (1 \\leq i \\leq N), Dish i has a_i (1 \\leq a_i \\leq 3) pieces of sushi on it.\n\nTaro will perform the following operation repeatedly until all the pieces of sushi are eaten:\n\nRoll a die that shows the numbers 1, 2, \\ldots, N with equal probabilities, and let i be the outcome. If there are some pieces of sushi on Dish i, eat one of them; if there is none, do nothing.\n\nFind the expected number of times the operation is performed before all the pieces of sushi are eaten.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 300\n\n1 \\leq a_i \\leq 3\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 \\ldots a_N\n\nOutput\n\nPrint the expected number of times the operation is performed before all the pieces of sushi are eaten.\nThe output is considered correct when the relative difference is not greater than 10^{-9}.\n\nSample Input 1\n\n3\n1 1 1\n\nSample Output 1\n\n5.5\n\nThe expected number of operations before the first piece of sushi is eaten, is 1.\nAfter that, the expected number of operations before the second sushi is eaten, is 1.5.\nAfter that, the expected number of operations before the third sushi is eaten, is 3.\nThus, the expected total number of operations is 1 + 1.5 + 3 = 5.5.\n\nSample Input 2\n\n1\n3\n\nSample Output 2\n\n3\n\nOutputs such as 3.00, 3.000000003 and 2.999999997 will also be accepted.\n\nSample Input 3\n\n2\n1 2\n\nSample Output 3\n\n4.5\n\nSample Input 4\n\n10\n1 3 2 3 3 2 3 2 1 3\n\nSample Output 4\n\n54.48064457488221", "sample_input": "3\n1 1 1\n"}, "reference_outputs": ["5.5\n"], "source_document_id": "p03169", "source_text": "Score : 100 points\n\nProblem Statement\n\nThere are N dishes, numbered 1, 2, \\ldots, N.\nInitially, for each i (1 \\leq i \\leq N), Dish i has a_i (1 \\leq a_i \\leq 3) pieces of sushi on it.\n\nTaro will perform the following operation repeatedly until all the pieces of sushi are eaten:\n\nRoll a die that shows the numbers 1, 2, \\ldots, N with equal probabilities, and let i be the outcome. If there are some pieces of sushi on Dish i, eat one of them; if there is none, do nothing.\n\nFind the expected number of times the operation is performed before all the pieces of sushi are eaten.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 300\n\n1 \\leq a_i \\leq 3\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 \\ldots a_N\n\nOutput\n\nPrint the expected number of times the operation is performed before all the pieces of sushi are eaten.\nThe output is considered correct when the relative difference is not greater than 10^{-9}.\n\nSample Input 1\n\n3\n1 1 1\n\nSample Output 1\n\n5.5\n\nThe expected number of operations before the first piece of sushi is eaten, is 1.\nAfter that, the expected number of operations before the second sushi is eaten, is 1.5.\nAfter that, the expected number of operations before the third sushi is eaten, is 3.\nThus, the expected total number of operations is 1 + 1.5 + 3 = 5.5.\n\nSample Input 2\n\n1\n3\n\nSample Output 2\n\n3\n\nOutputs such as 3.00, 3.000000003 and 2.999999997 will also be accepted.\n\nSample Input 3\n\n2\n1 2\n\nSample Output 3\n\n4.5\n\nSample Input 4\n\n10\n1 3 2 3 3 2 3 2 1 3\n\nSample Output 4\n\n54.48064457488221", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 781, "cpu_time_ms": 856, "memory_kb": 371376}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s362343425", "group_id": "codeNet:p03170", "input_text": "local n,k=io.read(\"n\",\"n\")\nlocal a={}\nfor i=1,n do\n a[i]=io.read(\"n\")\nend\n\nlocal dp={}\nfor i=0,k do\n if not dp[i] then\n for j=1,n do\n dp[i+a[j]]=true\n end\n end\nend\nprint(dp[k] and \"First\" or \"Second\")", "language": "Lua", "metadata": {"date": 1600686853, "filename_ext": "lua", "original_language": "Lua (Lua 5.3.5)", "problem_description_relpath": "problem_descriptions/p03170.html", "problem_id": "p03170", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03170/input.txt", "sample_output_relpath": "derived/input_output/data/p03170/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03170/Lua/s362343425.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s362343425", "user_id": "u045238009"}, "prompt_components": {"gold_output": "First\n", "input_to_evaluate": "local n,k=io.read(\"n\",\"n\")\nlocal a={}\nfor i=1,n do\n a[i]=io.read(\"n\")\nend\n\nlocal dp={}\nfor i=0,k do\n if not dp[i] then\n for j=1,n do\n dp[i+a[j]]=true\n end\n end\nend\nprint(dp[k] and \"First\" or \"Second\")", "problem_context": "Score : 100 points\n\nProblem Statement\n\nThere is a set A = \\{ a_1, a_2, \\ldots, a_N \\} consisting of N positive integers.\nTaro and Jiro will play the following game against each other.\n\nInitially, we have a pile consisting of K stones.\nThe two players perform the following operation alternately, starting from Taro:\n\nChoose an element x in A, and remove exactly x stones from the pile.\n\nA player loses when he becomes unable to play.\nAssuming that both players play optimally, determine the winner.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 100\n\n1 \\leq K \\leq 10^5\n\n1 \\leq a_1 < a_2 < \\cdots < a_N \\leq K\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\na_1 a_2 \\ldots a_N\n\nOutput\n\nIf Taro will win, print First; if Jiro will win, print Second.\n\nSample Input 1\n\n2 4\n2 3\n\nSample Output 1\n\nFirst\n\nIf Taro removes three stones, Jiro cannot make a move.\nThus, Taro wins.\n\nSample Input 2\n\n2 5\n2 3\n\nSample Output 2\n\nSecond\n\nWhatever Taro does in his operation, Jiro wins, as follows:\n\nIf Taro removes two stones, Jiro can remove three stones to make Taro unable to make a move.\n\nIf Taro removes three stones, Jiro can remove two stones to make Taro unable to make a move.\n\nSample Input 3\n\n2 7\n2 3\n\nSample Output 3\n\nFirst\n\nTaro should remove two stones. Then, whatever Jiro does in his operation, Taro wins, as follows:\n\nIf Jiro removes two stones, Taro can remove three stones to make Jiro unable to make a move.\n\nIf Jiro removes three stones, Taro can remove two stones to make Jiro unable to make a move.\n\nSample Input 4\n\n3 20\n1 2 3\n\nSample Output 4\n\nSecond\n\nSample Input 5\n\n3 21\n1 2 3\n\nSample Output 5\n\nFirst\n\nSample Input 6\n\n1 100000\n1\n\nSample Output 6\n\nSecond", "sample_input": "2 4\n2 3\n"}, "reference_outputs": ["First\n"], "source_document_id": "p03170", "source_text": "Score : 100 points\n\nProblem Statement\n\nThere is a set A = \\{ a_1, a_2, \\ldots, a_N \\} consisting of N positive integers.\nTaro and Jiro will play the following game against each other.\n\nInitially, we have a pile consisting of K stones.\nThe two players perform the following operation alternately, starting from Taro:\n\nChoose an element x in A, and remove exactly x stones from the pile.\n\nA player loses when he becomes unable to play.\nAssuming that both players play optimally, determine the winner.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 100\n\n1 \\leq K \\leq 10^5\n\n1 \\leq a_1 < a_2 < \\cdots < a_N \\leq K\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\na_1 a_2 \\ldots a_N\n\nOutput\n\nIf Taro will win, print First; if Jiro will win, print Second.\n\nSample Input 1\n\n2 4\n2 3\n\nSample Output 1\n\nFirst\n\nIf Taro removes three stones, Jiro cannot make a move.\nThus, Taro wins.\n\nSample Input 2\n\n2 5\n2 3\n\nSample Output 2\n\nSecond\n\nWhatever Taro does in his operation, Jiro wins, as follows:\n\nIf Taro removes two stones, Jiro can remove three stones to make Taro unable to make a move.\n\nIf Taro removes three stones, Jiro can remove two stones to make Taro unable to make a move.\n\nSample Input 3\n\n2 7\n2 3\n\nSample Output 3\n\nFirst\n\nTaro should remove two stones. Then, whatever Jiro does in his operation, Taro wins, as follows:\n\nIf Jiro removes two stones, Taro can remove three stones to make Jiro unable to make a move.\n\nIf Jiro removes three stones, Taro can remove two stones to make Jiro unable to make a move.\n\nSample Input 4\n\n3 20\n1 2 3\n\nSample Output 4\n\nSecond\n\nSample Input 5\n\n3 21\n1 2 3\n\nSample Output 5\n\nFirst\n\nSample Input 6\n\n1 100000\n1\n\nSample Output 6\n\nSecond", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 234, "cpu_time_ms": 43, "memory_kb": 8616}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s949942161", "group_id": "codeNet:p03170", "input_text": "local n,k=io.read(\"n\",\"n\")\nlocal a={}\nlocal dp={}\nfor i=1,n do\n local input=io.read(\"n\")\n a[i]=input\n dp[input]=true\nend\n\nfor i=0,k do\n for j=1,n do\n if not dp[i] then\n dp[i+a[j]]=true\n end\n end\nend\nprint(dp[k] and \"First\" or \"Second\")", "language": "Lua", "metadata": {"date": 1600660422, "filename_ext": "lua", "original_language": "Lua (Lua 5.3.5)", "problem_description_relpath": "problem_descriptions/p03170.html", "problem_id": "p03170", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03170/input.txt", "sample_output_relpath": "derived/input_output/data/p03170/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03170/Lua/s949942161.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s949942161", "user_id": "u045238009"}, "prompt_components": {"gold_output": "First\n", "input_to_evaluate": "local n,k=io.read(\"n\",\"n\")\nlocal a={}\nlocal dp={}\nfor i=1,n do\n local input=io.read(\"n\")\n a[i]=input\n dp[input]=true\nend\n\nfor i=0,k do\n for j=1,n do\n if not dp[i] then\n dp[i+a[j]]=true\n end\n end\nend\nprint(dp[k] and \"First\" or \"Second\")", "problem_context": "Score : 100 points\n\nProblem Statement\n\nThere is a set A = \\{ a_1, a_2, \\ldots, a_N \\} consisting of N positive integers.\nTaro and Jiro will play the following game against each other.\n\nInitially, we have a pile consisting of K stones.\nThe two players perform the following operation alternately, starting from Taro:\n\nChoose an element x in A, and remove exactly x stones from the pile.\n\nA player loses when he becomes unable to play.\nAssuming that both players play optimally, determine the winner.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 100\n\n1 \\leq K \\leq 10^5\n\n1 \\leq a_1 < a_2 < \\cdots < a_N \\leq K\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\na_1 a_2 \\ldots a_N\n\nOutput\n\nIf Taro will win, print First; if Jiro will win, print Second.\n\nSample Input 1\n\n2 4\n2 3\n\nSample Output 1\n\nFirst\n\nIf Taro removes three stones, Jiro cannot make a move.\nThus, Taro wins.\n\nSample Input 2\n\n2 5\n2 3\n\nSample Output 2\n\nSecond\n\nWhatever Taro does in his operation, Jiro wins, as follows:\n\nIf Taro removes two stones, Jiro can remove three stones to make Taro unable to make a move.\n\nIf Taro removes three stones, Jiro can remove two stones to make Taro unable to make a move.\n\nSample Input 3\n\n2 7\n2 3\n\nSample Output 3\n\nFirst\n\nTaro should remove two stones. Then, whatever Jiro does in his operation, Taro wins, as follows:\n\nIf Jiro removes two stones, Taro can remove three stones to make Jiro unable to make a move.\n\nIf Jiro removes three stones, Taro can remove two stones to make Jiro unable to make a move.\n\nSample Input 4\n\n3 20\n1 2 3\n\nSample Output 4\n\nSecond\n\nSample Input 5\n\n3 21\n1 2 3\n\nSample Output 5\n\nFirst\n\nSample Input 6\n\n1 100000\n1\n\nSample Output 6\n\nSecond", "sample_input": "2 4\n2 3\n"}, "reference_outputs": ["First\n"], "source_document_id": "p03170", "source_text": "Score : 100 points\n\nProblem Statement\n\nThere is a set A = \\{ a_1, a_2, \\ldots, a_N \\} consisting of N positive integers.\nTaro and Jiro will play the following game against each other.\n\nInitially, we have a pile consisting of K stones.\nThe two players perform the following operation alternately, starting from Taro:\n\nChoose an element x in A, and remove exactly x stones from the pile.\n\nA player loses when he becomes unable to play.\nAssuming that both players play optimally, determine the winner.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 100\n\n1 \\leq K \\leq 10^5\n\n1 \\leq a_1 < a_2 < \\cdots < a_N \\leq K\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\na_1 a_2 \\ldots a_N\n\nOutput\n\nIf Taro will win, print First; if Jiro will win, print Second.\n\nSample Input 1\n\n2 4\n2 3\n\nSample Output 1\n\nFirst\n\nIf Taro removes three stones, Jiro cannot make a move.\nThus, Taro wins.\n\nSample Input 2\n\n2 5\n2 3\n\nSample Output 2\n\nSecond\n\nWhatever Taro does in his operation, Jiro wins, as follows:\n\nIf Taro removes two stones, Jiro can remove three stones to make Taro unable to make a move.\n\nIf Taro removes three stones, Jiro can remove two stones to make Taro unable to make a move.\n\nSample Input 3\n\n2 7\n2 3\n\nSample Output 3\n\nFirst\n\nTaro should remove two stones. Then, whatever Jiro does in his operation, Taro wins, as follows:\n\nIf Jiro removes two stones, Taro can remove three stones to make Jiro unable to make a move.\n\nIf Jiro removes three stones, Taro can remove two stones to make Jiro unable to make a move.\n\nSample Input 4\n\n3 20\n1 2 3\n\nSample Output 4\n\nSecond\n\nSample Input 5\n\n3 21\n1 2 3\n\nSample Output 5\n\nFirst\n\nSample Input 6\n\n1 100000\n1\n\nSample Output 6\n\nSecond", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 275, "cpu_time_ms": 176, "memory_kb": 8564}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s091589794", "group_id": "codeNet:p03170", "input_text": "local n,k=io.read(\"n\",\"n\")\nlocal a={}\nlocal m={}\nfor i=1,n do\n local input=io.read(\"n\")\n a[i]=input\n m[input]=true\nend\n\nlocal dp={}\nfor i=0,k do\n if m[i] then\n dp[i]=true\n end\n for j=1,n do\n if not dp[i] then\n dp[i+a[j]]=true\n end\n end\nend\nprint(dp[k] and \"First\" or \"Second\")", "language": "Lua", "metadata": {"date": 1600660069, "filename_ext": "lua", "original_language": "Lua (Lua 5.3.5)", "problem_description_relpath": "problem_descriptions/p03170.html", "problem_id": "p03170", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03170/input.txt", "sample_output_relpath": "derived/input_output/data/p03170/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03170/Lua/s091589794.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s091589794", "user_id": "u045238009"}, "prompt_components": {"gold_output": "First\n", "input_to_evaluate": "local n,k=io.read(\"n\",\"n\")\nlocal a={}\nlocal m={}\nfor i=1,n do\n local input=io.read(\"n\")\n a[i]=input\n m[input]=true\nend\n\nlocal dp={}\nfor i=0,k do\n if m[i] then\n dp[i]=true\n end\n for j=1,n do\n if not dp[i] then\n dp[i+a[j]]=true\n end\n end\nend\nprint(dp[k] and \"First\" or \"Second\")", "problem_context": "Score : 100 points\n\nProblem Statement\n\nThere is a set A = \\{ a_1, a_2, \\ldots, a_N \\} consisting of N positive integers.\nTaro and Jiro will play the following game against each other.\n\nInitially, we have a pile consisting of K stones.\nThe two players perform the following operation alternately, starting from Taro:\n\nChoose an element x in A, and remove exactly x stones from the pile.\n\nA player loses when he becomes unable to play.\nAssuming that both players play optimally, determine the winner.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 100\n\n1 \\leq K \\leq 10^5\n\n1 \\leq a_1 < a_2 < \\cdots < a_N \\leq K\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\na_1 a_2 \\ldots a_N\n\nOutput\n\nIf Taro will win, print First; if Jiro will win, print Second.\n\nSample Input 1\n\n2 4\n2 3\n\nSample Output 1\n\nFirst\n\nIf Taro removes three stones, Jiro cannot make a move.\nThus, Taro wins.\n\nSample Input 2\n\n2 5\n2 3\n\nSample Output 2\n\nSecond\n\nWhatever Taro does in his operation, Jiro wins, as follows:\n\nIf Taro removes two stones, Jiro can remove three stones to make Taro unable to make a move.\n\nIf Taro removes three stones, Jiro can remove two stones to make Taro unable to make a move.\n\nSample Input 3\n\n2 7\n2 3\n\nSample Output 3\n\nFirst\n\nTaro should remove two stones. Then, whatever Jiro does in his operation, Taro wins, as follows:\n\nIf Jiro removes two stones, Taro can remove three stones to make Jiro unable to make a move.\n\nIf Jiro removes three stones, Taro can remove two stones to make Jiro unable to make a move.\n\nSample Input 4\n\n3 20\n1 2 3\n\nSample Output 4\n\nSecond\n\nSample Input 5\n\n3 21\n1 2 3\n\nSample Output 5\n\nFirst\n\nSample Input 6\n\n1 100000\n1\n\nSample Output 6\n\nSecond", "sample_input": "2 4\n2 3\n"}, "reference_outputs": ["First\n"], "source_document_id": "p03170", "source_text": "Score : 100 points\n\nProblem Statement\n\nThere is a set A = \\{ a_1, a_2, \\ldots, a_N \\} consisting of N positive integers.\nTaro and Jiro will play the following game against each other.\n\nInitially, we have a pile consisting of K stones.\nThe two players perform the following operation alternately, starting from Taro:\n\nChoose an element x in A, and remove exactly x stones from the pile.\n\nA player loses when he becomes unable to play.\nAssuming that both players play optimally, determine the winner.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 100\n\n1 \\leq K \\leq 10^5\n\n1 \\leq a_1 < a_2 < \\cdots < a_N \\leq K\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\na_1 a_2 \\ldots a_N\n\nOutput\n\nIf Taro will win, print First; if Jiro will win, print Second.\n\nSample Input 1\n\n2 4\n2 3\n\nSample Output 1\n\nFirst\n\nIf Taro removes three stones, Jiro cannot make a move.\nThus, Taro wins.\n\nSample Input 2\n\n2 5\n2 3\n\nSample Output 2\n\nSecond\n\nWhatever Taro does in his operation, Jiro wins, as follows:\n\nIf Taro removes two stones, Jiro can remove three stones to make Taro unable to make a move.\n\nIf Taro removes three stones, Jiro can remove two stones to make Taro unable to make a move.\n\nSample Input 3\n\n2 7\n2 3\n\nSample Output 3\n\nFirst\n\nTaro should remove two stones. Then, whatever Jiro does in his operation, Taro wins, as follows:\n\nIf Jiro removes two stones, Taro can remove three stones to make Jiro unable to make a move.\n\nIf Jiro removes three stones, Taro can remove two stones to make Jiro unable to make a move.\n\nSample Input 4\n\n3 20\n1 2 3\n\nSample Output 4\n\nSecond\n\nSample Input 5\n\n3 21\n1 2 3\n\nSample Output 5\n\nFirst\n\nSample Input 6\n\n1 100000\n1\n\nSample Output 6\n\nSecond", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 329, "cpu_time_ms": 171, "memory_kb": 8388}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s426506602", "group_id": "codeNet:p03170", "input_text": "local read = setmetatable({}, {__index = function(t, k) local a = {} for i=1,#k do table.insert(a, '*'..string.sub(k, i, i)) end local r = io.read local u = table.unpack or unpack return function() return r(u(a)) end end})\nread.N = function(N) local t={} for i=1,N do t[i]=read.n() end return t end\nstring.totable = function(s) local t={} local u=string.sub for i=1,#s do t[i] = u(s, i, i) end return t end\nstring.split = function(s) local t={} for w in string.gmatch(s, \"[^%s]+\") do table.insert(t, w) end return (table.unpack or unpack)(t) end\nlocal function array(dimension, default_val) local n=dimension local m={}if default_val~=nil then m[1]={__index=function()return default_val end}end for i=2,n do m[i]={__index=function(p, k)local c=setmetatable({},m[i-1])rawset(p,k,c)return c end}end return setmetatable({},m[n])end\nlocal function tostringx(o)if type(o) == 'table' then local keys = {}for k in pairs(o) do table.insert(keys, k) end table.sort(keys)local inside = {}for i=1,#keys do local k = keys[i]local v = o[k]if type(k) == 'string' then k = string.format('%q', k)end table.insert(inside, '['..k..'] = ' .. tostringx(v))end return '{' .. table.concat(inside, ', ') .. '}'else if type(o) == 'string' then o = string.format('%q', o)end return tostring(o)end end\n----\nlocal N, K = read.nn()\nlocal A = read.N(N)\ntable.sort(A)\nlocal amin = A[1]\nlocal tbl = {}\nlocal rev = {['😞']='🏆', ['🏆']='😞'}\nfor i=0,amin-1 do\n tbl[i] = '😞'\nend\nfor i=0,K-1 do\n if tbl[i] == '😞' then\n for _,a in ipairs(A) do\n tbl[i+a] = '🏆'\n end\n else\n for _,a in ipairs(A) do\n if tbl[i+a] == nil then\n tbl[i+a] = '😞'\n end\n end\n end\nend\n--print(tostringx(tbl))\nif tbl[K]=='🏆' then\n print('First')\nelseif tbl[K]=='😞' then\n print('Second')\nelse\n error()\nend", "language": "Lua", "metadata": {"date": 1582378713, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03170.html", "problem_id": "p03170", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03170/input.txt", "sample_output_relpath": "derived/input_output/data/p03170/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03170/Lua/s426506602.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s426506602", "user_id": "u162773977"}, "prompt_components": {"gold_output": "First\n", "input_to_evaluate": "local read = setmetatable({}, {__index = function(t, k) local a = {} for i=1,#k do table.insert(a, '*'..string.sub(k, i, i)) end local r = io.read local u = table.unpack or unpack return function() return r(u(a)) end end})\nread.N = function(N) local t={} for i=1,N do t[i]=read.n() end return t end\nstring.totable = function(s) local t={} local u=string.sub for i=1,#s do t[i] = u(s, i, i) end return t end\nstring.split = function(s) local t={} for w in string.gmatch(s, \"[^%s]+\") do table.insert(t, w) end return (table.unpack or unpack)(t) end\nlocal function array(dimension, default_val) local n=dimension local m={}if default_val~=nil then m[1]={__index=function()return default_val end}end for i=2,n do m[i]={__index=function(p, k)local c=setmetatable({},m[i-1])rawset(p,k,c)return c end}end return setmetatable({},m[n])end\nlocal function tostringx(o)if type(o) == 'table' then local keys = {}for k in pairs(o) do table.insert(keys, k) end table.sort(keys)local inside = {}for i=1,#keys do local k = keys[i]local v = o[k]if type(k) == 'string' then k = string.format('%q', k)end table.insert(inside, '['..k..'] = ' .. tostringx(v))end return '{' .. table.concat(inside, ', ') .. '}'else if type(o) == 'string' then o = string.format('%q', o)end return tostring(o)end end\n----\nlocal N, K = read.nn()\nlocal A = read.N(N)\ntable.sort(A)\nlocal amin = A[1]\nlocal tbl = {}\nlocal rev = {['😞']='🏆', ['🏆']='😞'}\nfor i=0,amin-1 do\n tbl[i] = '😞'\nend\nfor i=0,K-1 do\n if tbl[i] == '😞' then\n for _,a in ipairs(A) do\n tbl[i+a] = '🏆'\n end\n else\n for _,a in ipairs(A) do\n if tbl[i+a] == nil then\n tbl[i+a] = '😞'\n end\n end\n end\nend\n--print(tostringx(tbl))\nif tbl[K]=='🏆' then\n print('First')\nelseif tbl[K]=='😞' then\n print('Second')\nelse\n error()\nend", "problem_context": "Score : 100 points\n\nProblem Statement\n\nThere is a set A = \\{ a_1, a_2, \\ldots, a_N \\} consisting of N positive integers.\nTaro and Jiro will play the following game against each other.\n\nInitially, we have a pile consisting of K stones.\nThe two players perform the following operation alternately, starting from Taro:\n\nChoose an element x in A, and remove exactly x stones from the pile.\n\nA player loses when he becomes unable to play.\nAssuming that both players play optimally, determine the winner.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 100\n\n1 \\leq K \\leq 10^5\n\n1 \\leq a_1 < a_2 < \\cdots < a_N \\leq K\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\na_1 a_2 \\ldots a_N\n\nOutput\n\nIf Taro will win, print First; if Jiro will win, print Second.\n\nSample Input 1\n\n2 4\n2 3\n\nSample Output 1\n\nFirst\n\nIf Taro removes three stones, Jiro cannot make a move.\nThus, Taro wins.\n\nSample Input 2\n\n2 5\n2 3\n\nSample Output 2\n\nSecond\n\nWhatever Taro does in his operation, Jiro wins, as follows:\n\nIf Taro removes two stones, Jiro can remove three stones to make Taro unable to make a move.\n\nIf Taro removes three stones, Jiro can remove two stones to make Taro unable to make a move.\n\nSample Input 3\n\n2 7\n2 3\n\nSample Output 3\n\nFirst\n\nTaro should remove two stones. Then, whatever Jiro does in his operation, Taro wins, as follows:\n\nIf Jiro removes two stones, Taro can remove three stones to make Jiro unable to make a move.\n\nIf Jiro removes three stones, Taro can remove two stones to make Jiro unable to make a move.\n\nSample Input 4\n\n3 20\n1 2 3\n\nSample Output 4\n\nSecond\n\nSample Input 5\n\n3 21\n1 2 3\n\nSample Output 5\n\nFirst\n\nSample Input 6\n\n1 100000\n1\n\nSample Output 6\n\nSecond", "sample_input": "2 4\n2 3\n"}, "reference_outputs": ["First\n"], "source_document_id": "p03170", "source_text": "Score : 100 points\n\nProblem Statement\n\nThere is a set A = \\{ a_1, a_2, \\ldots, a_N \\} consisting of N positive integers.\nTaro and Jiro will play the following game against each other.\n\nInitially, we have a pile consisting of K stones.\nThe two players perform the following operation alternately, starting from Taro:\n\nChoose an element x in A, and remove exactly x stones from the pile.\n\nA player loses when he becomes unable to play.\nAssuming that both players play optimally, determine the winner.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 100\n\n1 \\leq K \\leq 10^5\n\n1 \\leq a_1 < a_2 < \\cdots < a_N \\leq K\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\na_1 a_2 \\ldots a_N\n\nOutput\n\nIf Taro will win, print First; if Jiro will win, print Second.\n\nSample Input 1\n\n2 4\n2 3\n\nSample Output 1\n\nFirst\n\nIf Taro removes three stones, Jiro cannot make a move.\nThus, Taro wins.\n\nSample Input 2\n\n2 5\n2 3\n\nSample Output 2\n\nSecond\n\nWhatever Taro does in his operation, Jiro wins, as follows:\n\nIf Taro removes two stones, Jiro can remove three stones to make Taro unable to make a move.\n\nIf Taro removes three stones, Jiro can remove two stones to make Taro unable to make a move.\n\nSample Input 3\n\n2 7\n2 3\n\nSample Output 3\n\nFirst\n\nTaro should remove two stones. Then, whatever Jiro does in his operation, Taro wins, as follows:\n\nIf Jiro removes two stones, Taro can remove three stones to make Jiro unable to make a move.\n\nIf Jiro removes three stones, Taro can remove two stones to make Jiro unable to make a move.\n\nSample Input 4\n\n3 20\n1 2 3\n\nSample Output 4\n\nSecond\n\nSample Input 5\n\n3 21\n1 2 3\n\nSample Output 5\n\nFirst\n\nSample Input 6\n\n1 100000\n1\n\nSample Output 6\n\nSecond", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1862, "cpu_time_ms": 848, "memory_kb": 4580}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s641948687", "group_id": "codeNet:p03173", "input_text": "local mmi = math.min\nlocal n = io.read(\"*n\")\nlocal sum = {io.read(\"*n\")}\nfor i = 2, n do\n sum[i] = sum[i - 1] + io.read(\"*n\")\nend\nlocal dp = {}\ndp[1] = {}\nfor i = 1, n do\n dp[1][i] = 0\nend\nfor i = 2, n do\n dp[i] = {}\n local leftposlim = n - i + 1\n for j = 1, leftposlim do\n local v = dp[1][j] + dp[i - 1][j + 1]\n for k = 2, i - 1 do\n v = mmi(v, dp[k][j] + dp[i - k][j + k])\n end\n v = v + sum[j + i - 1]\n if 1 < j then v = v - sum[j - 1] end\n dp[i][j] = v\n end\nend\nprint(dp[n][1])\n", "language": "Lua", "metadata": {"date": 1587558578, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p03173.html", "problem_id": "p03173", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03173/input.txt", "sample_output_relpath": "derived/input_output/data/p03173/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03173/Lua/s641948687.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s641948687", "user_id": "u120582723"}, "prompt_components": {"gold_output": "190\n", "input_to_evaluate": "local mmi = math.min\nlocal n = io.read(\"*n\")\nlocal sum = {io.read(\"*n\")}\nfor i = 2, n do\n sum[i] = sum[i - 1] + io.read(\"*n\")\nend\nlocal dp = {}\ndp[1] = {}\nfor i = 1, n do\n dp[1][i] = 0\nend\nfor i = 2, n do\n dp[i] = {}\n local leftposlim = n - i + 1\n for j = 1, leftposlim do\n local v = dp[1][j] + dp[i - 1][j + 1]\n for k = 2, i - 1 do\n v = mmi(v, dp[k][j] + dp[i - k][j + k])\n end\n v = v + sum[j + i - 1]\n if 1 < j then v = v - sum[j - 1] end\n dp[i][j] = v\n end\nend\nprint(dp[n][1])\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nThere are N slimes lining up in a row.\nInitially, the i-th slime from the left has a size of a_i.\n\nTaro is trying to combine all the slimes into a larger slime.\nHe will perform the following operation repeatedly until there is only one slime:\n\nChoose two adjacent slimes, and combine them into a new slime. The new slime has a size of x + y, where x and y are the sizes of the slimes before combining them. Here, a cost of x + y is incurred. The positional relationship of the slimes does not change while combining slimes.\n\nFind the minimum possible total cost incurred.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 400\n\n1 \\leq a_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 \\ldots a_N\n\nOutput\n\nPrint the minimum possible total cost incurred.\n\nSample Input 1\n\n4\n10 20 30 40\n\nSample Output 1\n\n190\n\nTaro should do as follows (slimes being combined are shown in bold):\n\n(10, 20, 30, 40) → (30, 30, 40)\n\n(30, 30, 40) → (60, 40)\n\n(60, 40) → (100)\n\nSample Input 2\n\n5\n10 10 10 10 10\n\nSample Output 2\n\n120\n\nTaro should do, for example, as follows:\n\n(10, 10, 10, 10, 10) → (20, 10, 10, 10)\n\n(20, 10, 10, 10) → (20, 20, 10)\n\n(20, 20, 10) → (20, 30)\n\n(20, 30) → (50)\n\nSample Input 3\n\n3\n1000000000 1000000000 1000000000\n\nSample Output 3\n\n5000000000\n\nThe answer may not fit into a 32-bit integer type.\n\nSample Input 4\n\n6\n7 6 8 6 1 1\n\nSample Output 4\n\n68\n\nTaro should do, for example, as follows:\n\n(7, 6, 8, 6, 1, 1) → (7, 6, 8, 6, 2)\n\n(7, 6, 8, 6, 2) → (7, 6, 8, 8)\n\n(7, 6, 8, 8) → (13, 8, 8)\n\n(13, 8, 8) → (13, 16)\n\n(13, 16) → (29)", "sample_input": "4\n10 20 30 40\n"}, "reference_outputs": ["190\n"], "source_document_id": "p03173", "source_text": "Score : 100 points\n\nProblem Statement\n\nThere are N slimes lining up in a row.\nInitially, the i-th slime from the left has a size of a_i.\n\nTaro is trying to combine all the slimes into a larger slime.\nHe will perform the following operation repeatedly until there is only one slime:\n\nChoose two adjacent slimes, and combine them into a new slime. The new slime has a size of x + y, where x and y are the sizes of the slimes before combining them. Here, a cost of x + y is incurred. The positional relationship of the slimes does not change while combining slimes.\n\nFind the minimum possible total cost incurred.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 400\n\n1 \\leq a_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 \\ldots a_N\n\nOutput\n\nPrint the minimum possible total cost incurred.\n\nSample Input 1\n\n4\n10 20 30 40\n\nSample Output 1\n\n190\n\nTaro should do as follows (slimes being combined are shown in bold):\n\n(10, 20, 30, 40) → (30, 30, 40)\n\n(30, 30, 40) → (60, 40)\n\n(60, 40) → (100)\n\nSample Input 2\n\n5\n10 10 10 10 10\n\nSample Output 2\n\n120\n\nTaro should do, for example, as follows:\n\n(10, 10, 10, 10, 10) → (20, 10, 10, 10)\n\n(20, 10, 10, 10) → (20, 20, 10)\n\n(20, 20, 10) → (20, 30)\n\n(20, 30) → (50)\n\nSample Input 3\n\n3\n1000000000 1000000000 1000000000\n\nSample Output 3\n\n5000000000\n\nThe answer may not fit into a 32-bit integer type.\n\nSample Input 4\n\n6\n7 6 8 6 1 1\n\nSample Output 4\n\n68\n\nTaro should do, for example, as follows:\n\n(7, 6, 8, 6, 1, 1) → (7, 6, 8, 6, 2)\n\n(7, 6, 8, 6, 2) → (7, 6, 8, 8)\n\n(7, 6, 8, 8) → (13, 8, 8)\n\n(13, 8, 8) → (13, 16)\n\n(13, 16) → (29)", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 509, "cpu_time_ms": 118, "memory_kb": 1280}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s885935414", "group_id": "codeNet:p03174", "input_text": "local mod = 1000000007\nlocal bls, brs = bit.lshift, bit.rshift\nlocal n = io.read(\"*n\")\nlocal t = {}\nfor i = 1, n do\n t[i] = {}\n for j = 1, n do\n t[i][j] = io.read(\"*n\") == 1\n end\nend\n\nlocal tot = bls(1, n)\nlocal alltask = {}\nlocal stagetask = {}\ndo\n for i = 1, n do\n stagetask[i] = {}\n end\n for i = 1, tot - 1 do\n -- set empty state\n alltask[i] = 0\n end\n for i = 1, tot - 1 do\n local ti = i\n local cnt = 0\n for j = 1, n do\n if ti % 2 == 1 then\n cnt = cnt + 1\n ti = ti - 1\n end\n ti = ti / 2\n end\n table.insert(stagetask[cnt], i)\n end\n -- set first state\n local tmp = 1\n for i = 1, n do\n alltask[tmp] = t[1][i] and 1 or 0\n tmp = tmp * 2\n end\nend\n\nfor stage = 1, n - 1 do\n local stlen = #stagetask[stage]\n for i_stagetask = 1, stlen do\n local used = stagetask[stage][i_stagetask]\n local mul = 1\n local tmp = used\n for j = 1, n do\n if tmp % 2 == 0 then\n if t[stage + 1][j] then\n alltask[used + mul] = (alltask[used + mul] + alltask[used]) % mod\n end\n else\n tmp = tmp - 1\n end\n tmp = tmp / 2\n mul = mul * 2\n end\n end\nend\nprint(alltask[tot - 1])\n", "language": "Lua", "metadata": {"date": 1587429143, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p03174.html", "problem_id": "p03174", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03174/input.txt", "sample_output_relpath": "derived/input_output/data/p03174/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03174/Lua/s885935414.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s885935414", "user_id": "u120582723"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "local mod = 1000000007\nlocal bls, brs = bit.lshift, bit.rshift\nlocal n = io.read(\"*n\")\nlocal t = {}\nfor i = 1, n do\n t[i] = {}\n for j = 1, n do\n t[i][j] = io.read(\"*n\") == 1\n end\nend\n\nlocal tot = bls(1, n)\nlocal alltask = {}\nlocal stagetask = {}\ndo\n for i = 1, n do\n stagetask[i] = {}\n end\n for i = 1, tot - 1 do\n -- set empty state\n alltask[i] = 0\n end\n for i = 1, tot - 1 do\n local ti = i\n local cnt = 0\n for j = 1, n do\n if ti % 2 == 1 then\n cnt = cnt + 1\n ti = ti - 1\n end\n ti = ti / 2\n end\n table.insert(stagetask[cnt], i)\n end\n -- set first state\n local tmp = 1\n for i = 1, n do\n alltask[tmp] = t[1][i] and 1 or 0\n tmp = tmp * 2\n end\nend\n\nfor stage = 1, n - 1 do\n local stlen = #stagetask[stage]\n for i_stagetask = 1, stlen do\n local used = stagetask[stage][i_stagetask]\n local mul = 1\n local tmp = used\n for j = 1, n do\n if tmp % 2 == 0 then\n if t[stage + 1][j] then\n alltask[used + mul] = (alltask[used + mul] + alltask[used]) % mod\n end\n else\n tmp = tmp - 1\n end\n tmp = tmp / 2\n mul = mul * 2\n end\n end\nend\nprint(alltask[tot - 1])\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nThere are N men and N women, both numbered 1, 2, \\ldots, N.\n\nFor each i, j (1 \\leq i, j \\leq N), the compatibility of Man i and Woman j is given as an integer a_{i, j}.\nIf a_{i, j} = 1, Man i and Woman j are compatible; if a_{i, j} = 0, they are not.\n\nTaro is trying to make N pairs, each consisting of a man and a woman who are compatible.\nHere, each man and each woman must belong to exactly one pair.\n\nFind the number of ways in which Taro can make N pairs, modulo 10^9 + 7.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 21\n\na_{i, j} is 0 or 1.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_{1, 1} \\ldots a_{1, N}\n:\na_{N, 1} \\ldots a_{N, N}\n\nOutput\n\nPrint the number of ways in which Taro can make N pairs, modulo 10^9 + 7.\n\nSample Input 1\n\n3\n0 1 1\n1 0 1\n1 1 1\n\nSample Output 1\n\n3\n\nThere are three ways to make pairs, as follows ((i, j) denotes a pair of Man i and Woman j):\n\n(1, 2), (2, 1), (3, 3)\n\n(1, 2), (2, 3), (3, 1)\n\n(1, 3), (2, 1), (3, 2)\n\nSample Input 2\n\n4\n0 1 0 0\n0 0 0 1\n1 0 0 0\n0 0 1 0\n\nSample Output 2\n\n1\n\nThere is one way to make pairs, as follows:\n\n(1, 2), (2, 4), (3, 1), (4, 3)\n\nSample Input 3\n\n1\n0\n\nSample Output 3\n\n0\n\nSample Input 4\n\n21\n0 0 0 0 0 0 0 1 1 0 1 1 1 1 0 0 0 1 0 0 1\n1 1 1 0 0 1 0 0 0 1 0 0 0 0 1 1 1 0 1 1 0\n0 0 1 1 1 1 0 1 1 0 0 1 0 0 1 1 0 0 0 1 1\n0 1 1 0 1 1 0 1 0 1 0 0 1 0 0 0 0 0 1 1 0\n1 1 0 0 1 0 1 0 0 1 1 1 1 0 0 0 0 0 0 0 0\n0 1 1 0 1 1 1 0 1 1 1 0 0 0 1 1 1 1 0 0 1\n0 1 0 0 0 1 0 1 0 0 0 1 1 1 0 0 1 1 0 1 0\n0 0 0 0 1 1 0 0 1 1 0 0 0 0 0 1 1 1 1 1 1\n0 0 1 0 0 1 0 0 1 0 1 1 0 0 1 0 1 0 1 1 1\n0 0 0 0 1 1 0 0 1 1 1 0 0 0 0 1 1 0 0 0 1\n0 1 1 0 1 1 0 0 1 1 0 0 0 1 1 1 1 0 1 1 0\n0 0 1 0 0 1 1 1 1 0 1 1 0 1 1 1 0 0 0 0 1\n0 1 1 0 0 1 1 1 1 0 0 0 1 0 1 1 0 1 0 1 1\n1 1 1 1 1 0 0 0 0 1 0 0 1 1 0 1 1 1 0 0 1\n0 0 0 1 1 0 1 1 1 1 0 0 0 0 0 0 1 1 1 1 1\n1 0 1 1 0 1 0 1 0 0 1 0 0 1 1 0 1 0 1 1 0\n0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 1 1 0 0 1\n0 0 0 1 0 0 1 1 0 1 0 1 0 1 1 0 0 1 1 0 1\n0 0 0 0 1 1 1 0 1 0 1 1 1 0 1 1 0 0 1 1 0\n1 1 0 1 1 0 0 1 1 0 1 1 0 1 1 1 1 1 0 1 0\n1 0 0 1 1 0 1 1 1 1 1 0 1 0 1 1 0 0 0 0 0\n\nSample Output 4\n\n102515160\n\nBe sure to print the number modulo 10^9 + 7.", "sample_input": "3\n0 1 1\n1 0 1\n1 1 1\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03174", "source_text": "Score : 100 points\n\nProblem Statement\n\nThere are N men and N women, both numbered 1, 2, \\ldots, N.\n\nFor each i, j (1 \\leq i, j \\leq N), the compatibility of Man i and Woman j is given as an integer a_{i, j}.\nIf a_{i, j} = 1, Man i and Woman j are compatible; if a_{i, j} = 0, they are not.\n\nTaro is trying to make N pairs, each consisting of a man and a woman who are compatible.\nHere, each man and each woman must belong to exactly one pair.\n\nFind the number of ways in which Taro can make N pairs, modulo 10^9 + 7.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 21\n\na_{i, j} is 0 or 1.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_{1, 1} \\ldots a_{1, N}\n:\na_{N, 1} \\ldots a_{N, N}\n\nOutput\n\nPrint the number of ways in which Taro can make N pairs, modulo 10^9 + 7.\n\nSample Input 1\n\n3\n0 1 1\n1 0 1\n1 1 1\n\nSample Output 1\n\n3\n\nThere are three ways to make pairs, as follows ((i, j) denotes a pair of Man i and Woman j):\n\n(1, 2), (2, 1), (3, 3)\n\n(1, 2), (2, 3), (3, 1)\n\n(1, 3), (2, 1), (3, 2)\n\nSample Input 2\n\n4\n0 1 0 0\n0 0 0 1\n1 0 0 0\n0 0 1 0\n\nSample Output 2\n\n1\n\nThere is one way to make pairs, as follows:\n\n(1, 2), (2, 4), (3, 1), (4, 3)\n\nSample Input 3\n\n1\n0\n\nSample Output 3\n\n0\n\nSample Input 4\n\n21\n0 0 0 0 0 0 0 1 1 0 1 1 1 1 0 0 0 1 0 0 1\n1 1 1 0 0 1 0 0 0 1 0 0 0 0 1 1 1 0 1 1 0\n0 0 1 1 1 1 0 1 1 0 0 1 0 0 1 1 0 0 0 1 1\n0 1 1 0 1 1 0 1 0 1 0 0 1 0 0 0 0 0 1 1 0\n1 1 0 0 1 0 1 0 0 1 1 1 1 0 0 0 0 0 0 0 0\n0 1 1 0 1 1 1 0 1 1 1 0 0 0 1 1 1 1 0 0 1\n0 1 0 0 0 1 0 1 0 0 0 1 1 1 0 0 1 1 0 1 0\n0 0 0 0 1 1 0 0 1 1 0 0 0 0 0 1 1 1 1 1 1\n0 0 1 0 0 1 0 0 1 0 1 1 0 0 1 0 1 0 1 1 1\n0 0 0 0 1 1 0 0 1 1 1 0 0 0 0 1 1 0 0 0 1\n0 1 1 0 1 1 0 0 1 1 0 0 0 1 1 1 1 0 1 1 0\n0 0 1 0 0 1 1 1 1 0 1 1 0 1 1 1 0 0 0 0 1\n0 1 1 0 0 1 1 1 1 0 0 0 1 0 1 1 0 1 0 1 1\n1 1 1 1 1 0 0 0 0 1 0 0 1 1 0 1 1 1 0 0 1\n0 0 0 1 1 0 1 1 1 1 0 0 0 0 0 0 1 1 1 1 1\n1 0 1 1 0 1 0 1 0 0 1 0 0 1 1 0 1 0 1 1 0\n0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 1 1 0 0 1\n0 0 0 1 0 0 1 1 0 1 0 1 0 1 1 0 0 1 1 0 1\n0 0 0 0 1 1 1 0 1 0 1 1 1 0 1 1 0 0 1 1 0\n1 1 0 1 1 0 0 1 1 0 1 1 0 1 1 1 1 1 0 1 0\n1 0 0 1 1 0 1 1 1 1 1 0 1 0 1 1 0 0 0 0 0\n\nSample Output 4\n\n102515160\n\nBe sure to print the number modulo 10^9 + 7.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1188, "cpu_time_ms": 1217, "memory_kb": 43204}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s237390402", "group_id": "codeNet:p03175", "input_text": "local n=io.read(\"n\")\nlocal g={}\nfor i=1,n do\n g[i]={}\nend\nfor i=1,n-1 do\n local x,y=io.read(\"n\",\"n\")\n g[x][y]=true\n g[y][x]=true\nend\n\nlocal bp,wp={},{}\nlocal mod=1000000007\nlocal function solve(cur,frm)\n bp[cur]=1\n wp[cur]=1\n for nxt in pairs(g[cur]) do\n if nxt~=frm then\n solve(nxt,cur)\n wp[cur]=wp[cur]*(wp[nxt]+bp[nxt])%mod\n bp[cur]=bp[cur]*wp[nxt]%mod\n end\n end\n return (bp[cur]+wp[cur])%mod\nend\nprint(solve(1,0))", "language": "Lua", "metadata": {"date": 1600730613, "filename_ext": "lua", "original_language": "Lua (Lua 5.3.5)", "problem_description_relpath": "problem_descriptions/p03175.html", "problem_id": "p03175", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03175/input.txt", "sample_output_relpath": "derived/input_output/data/p03175/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03175/Lua/s237390402.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s237390402", "user_id": "u045238009"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "local n=io.read(\"n\")\nlocal g={}\nfor i=1,n do\n g[i]={}\nend\nfor i=1,n-1 do\n local x,y=io.read(\"n\",\"n\")\n g[x][y]=true\n g[y][x]=true\nend\n\nlocal bp,wp={},{}\nlocal mod=1000000007\nlocal function solve(cur,frm)\n bp[cur]=1\n wp[cur]=1\n for nxt in pairs(g[cur]) do\n if nxt~=frm then\n solve(nxt,cur)\n wp[cur]=wp[cur]*(wp[nxt]+bp[nxt])%mod\n bp[cur]=bp[cur]*wp[nxt]%mod\n end\n end\n return (bp[cur]+wp[cur])%mod\nend\nprint(solve(1,0))", "problem_context": "Score : 100 points\n\nProblem Statement\n\nThere is a tree with N vertices, numbered 1, 2, \\ldots, N.\nFor each i (1 \\leq i \\leq N - 1), the i-th edge connects Vertex x_i and y_i.\n\nTaro has decided to paint each vertex in white or black.\nHere, it is not allowed to paint two adjacent vertices both in black.\n\nFind the number of ways in which the vertices can be painted, modulo 10^9 + 7.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^5\n\n1 \\leq x_i, y_i \\leq N\n\nThe given graph is a tree.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nx_1 y_1\nx_2 y_2\n:\nx_{N - 1} y_{N - 1}\n\nOutput\n\nPrint the number of ways in which the vertices can be painted, modulo 10^9 + 7.\n\nSample Input 1\n\n3\n1 2\n2 3\n\nSample Output 1\n\n5\n\nThere are five ways to paint the vertices, as follows:\n\nSample Input 2\n\n4\n1 2\n1 3\n1 4\n\nSample Output 2\n\n9\n\nThere are nine ways to paint the vertices, as follows:\n\nSample Input 3\n\n1\n\nSample Output 3\n\n2\n\nSample Input 4\n\n10\n8 5\n10 8\n6 5\n1 5\n4 8\n2 10\n3 6\n9 2\n1 7\n\nSample Output 4\n\n157", "sample_input": "3\n1 2\n2 3\n"}, "reference_outputs": ["5\n"], "source_document_id": "p03175", "source_text": "Score : 100 points\n\nProblem Statement\n\nThere is a tree with N vertices, numbered 1, 2, \\ldots, N.\nFor each i (1 \\leq i \\leq N - 1), the i-th edge connects Vertex x_i and y_i.\n\nTaro has decided to paint each vertex in white or black.\nHere, it is not allowed to paint two adjacent vertices both in black.\n\nFind the number of ways in which the vertices can be painted, modulo 10^9 + 7.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^5\n\n1 \\leq x_i, y_i \\leq N\n\nThe given graph is a tree.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nx_1 y_1\nx_2 y_2\n:\nx_{N - 1} y_{N - 1}\n\nOutput\n\nPrint the number of ways in which the vertices can be painted, modulo 10^9 + 7.\n\nSample Input 1\n\n3\n1 2\n2 3\n\nSample Output 1\n\n5\n\nThere are five ways to paint the vertices, as follows:\n\nSample Input 2\n\n4\n1 2\n1 3\n1 4\n\nSample Output 2\n\n9\n\nThere are nine ways to paint the vertices, as follows:\n\nSample Input 3\n\n1\n\nSample Output 3\n\n2\n\nSample Input 4\n\n10\n8 5\n10 8\n6 5\n1 5\n4 8\n2 10\n3 6\n9 2\n1 7\n\nSample Output 4\n\n157", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 491, "cpu_time_ms": 244, "memory_kb": 45832}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s334465066", "group_id": "codeNet:p03175", "input_text": "local n=io.read(\"n\")\nlocal g={}\nfor i=1,n do\n g[i]={}\nend\nfor i=1,n-1 do\n local x,y=io.read(\"n\",\"n\")\n g[x][y]=true\n g[y][x]=true\nend\n\nlocal bp,wp={},{}\nlocal mod=1000000007\nlocal function solve(cur,frm)\n bp[cur]=1\n wp[cur]=1\n for nxt in pairs(g[cur]) do\n if nxt~=frm then\n solve(nxt,cur)\n wp[cur]=wp[cur]*(wp[nxt]+bp[nxt])%mod\n bp[cur]=bp[cur]*wp[nxt]%mod\n end\n end\nend\nsolve(1,0)\nprint(bp[1]+wp[1])", "language": "Lua", "metadata": {"date": 1600730202, "filename_ext": "lua", "original_language": "Lua (Lua 5.3.5)", "problem_description_relpath": "problem_descriptions/p03175.html", "problem_id": "p03175", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03175/input.txt", "sample_output_relpath": "derived/input_output/data/p03175/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03175/Lua/s334465066.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s334465066", "user_id": "u045238009"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "local n=io.read(\"n\")\nlocal g={}\nfor i=1,n do\n g[i]={}\nend\nfor i=1,n-1 do\n local x,y=io.read(\"n\",\"n\")\n g[x][y]=true\n g[y][x]=true\nend\n\nlocal bp,wp={},{}\nlocal mod=1000000007\nlocal function solve(cur,frm)\n bp[cur]=1\n wp[cur]=1\n for nxt in pairs(g[cur]) do\n if nxt~=frm then\n solve(nxt,cur)\n wp[cur]=wp[cur]*(wp[nxt]+bp[nxt])%mod\n bp[cur]=bp[cur]*wp[nxt]%mod\n end\n end\nend\nsolve(1,0)\nprint(bp[1]+wp[1])", "problem_context": "Score : 100 points\n\nProblem Statement\n\nThere is a tree with N vertices, numbered 1, 2, \\ldots, N.\nFor each i (1 \\leq i \\leq N - 1), the i-th edge connects Vertex x_i and y_i.\n\nTaro has decided to paint each vertex in white or black.\nHere, it is not allowed to paint two adjacent vertices both in black.\n\nFind the number of ways in which the vertices can be painted, modulo 10^9 + 7.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^5\n\n1 \\leq x_i, y_i \\leq N\n\nThe given graph is a tree.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nx_1 y_1\nx_2 y_2\n:\nx_{N - 1} y_{N - 1}\n\nOutput\n\nPrint the number of ways in which the vertices can be painted, modulo 10^9 + 7.\n\nSample Input 1\n\n3\n1 2\n2 3\n\nSample Output 1\n\n5\n\nThere are five ways to paint the vertices, as follows:\n\nSample Input 2\n\n4\n1 2\n1 3\n1 4\n\nSample Output 2\n\n9\n\nThere are nine ways to paint the vertices, as follows:\n\nSample Input 3\n\n1\n\nSample Output 3\n\n2\n\nSample Input 4\n\n10\n8 5\n10 8\n6 5\n1 5\n4 8\n2 10\n3 6\n9 2\n1 7\n\nSample Output 4\n\n157", "sample_input": "3\n1 2\n2 3\n"}, "reference_outputs": ["5\n"], "source_document_id": "p03175", "source_text": "Score : 100 points\n\nProblem Statement\n\nThere is a tree with N vertices, numbered 1, 2, \\ldots, N.\nFor each i (1 \\leq i \\leq N - 1), the i-th edge connects Vertex x_i and y_i.\n\nTaro has decided to paint each vertex in white or black.\nHere, it is not allowed to paint two adjacent vertices both in black.\n\nFind the number of ways in which the vertices can be painted, modulo 10^9 + 7.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^5\n\n1 \\leq x_i, y_i \\leq N\n\nThe given graph is a tree.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nx_1 y_1\nx_2 y_2\n:\nx_{N - 1} y_{N - 1}\n\nOutput\n\nPrint the number of ways in which the vertices can be painted, modulo 10^9 + 7.\n\nSample Input 1\n\n3\n1 2\n2 3\n\nSample Output 1\n\n5\n\nThere are five ways to paint the vertices, as follows:\n\nSample Input 2\n\n4\n1 2\n1 3\n1 4\n\nSample Output 2\n\n9\n\nThere are nine ways to paint the vertices, as follows:\n\nSample Input 3\n\n1\n\nSample Output 3\n\n2\n\nSample Input 4\n\n10\n8 5\n10 8\n6 5\n1 5\n4 8\n2 10\n3 6\n9 2\n1 7\n\nSample Output 4\n\n157", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 470, "cpu_time_ms": 219, "memory_kb": 45848}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s975370221", "group_id": "codeNet:p03175", "input_text": "local n=io.read(\"n\")\nlocal g={}\nfor i=1,n do\n g[i]={}\nend\nfor i=1,n-1 do\n local x,y=io.read(\"n\",\"n\")\n g[x][y]=true\n g[y][x]=true\nend\n\nlocal bp,wp={},{}\nlocal mod=1000000007\nlocal function solve(cur,frm)\n bp[cur]=1\n wp[cur]=1\n for nxt in pairs(g[cur]) do\n if nxt~=frm then\n solve(nxt,cur)\n bp[cur]=bp[cur]*wp[nxt]%mod\n wp[cur]=wp[cur]*(wp[nxt]+bp[nxt])%mod\n end\n end\nend\nsolve(1,0)\nprint(bp[1]+wp[1])", "language": "Lua", "metadata": {"date": 1600730103, "filename_ext": "lua", "original_language": "Lua (Lua 5.3.5)", "problem_description_relpath": "problem_descriptions/p03175.html", "problem_id": "p03175", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03175/input.txt", "sample_output_relpath": "derived/input_output/data/p03175/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03175/Lua/s975370221.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s975370221", "user_id": "u045238009"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "local n=io.read(\"n\")\nlocal g={}\nfor i=1,n do\n g[i]={}\nend\nfor i=1,n-1 do\n local x,y=io.read(\"n\",\"n\")\n g[x][y]=true\n g[y][x]=true\nend\n\nlocal bp,wp={},{}\nlocal mod=1000000007\nlocal function solve(cur,frm)\n bp[cur]=1\n wp[cur]=1\n for nxt in pairs(g[cur]) do\n if nxt~=frm then\n solve(nxt,cur)\n bp[cur]=bp[cur]*wp[nxt]%mod\n wp[cur]=wp[cur]*(wp[nxt]+bp[nxt])%mod\n end\n end\nend\nsolve(1,0)\nprint(bp[1]+wp[1])", "problem_context": "Score : 100 points\n\nProblem Statement\n\nThere is a tree with N vertices, numbered 1, 2, \\ldots, N.\nFor each i (1 \\leq i \\leq N - 1), the i-th edge connects Vertex x_i and y_i.\n\nTaro has decided to paint each vertex in white or black.\nHere, it is not allowed to paint two adjacent vertices both in black.\n\nFind the number of ways in which the vertices can be painted, modulo 10^9 + 7.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^5\n\n1 \\leq x_i, y_i \\leq N\n\nThe given graph is a tree.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nx_1 y_1\nx_2 y_2\n:\nx_{N - 1} y_{N - 1}\n\nOutput\n\nPrint the number of ways in which the vertices can be painted, modulo 10^9 + 7.\n\nSample Input 1\n\n3\n1 2\n2 3\n\nSample Output 1\n\n5\n\nThere are five ways to paint the vertices, as follows:\n\nSample Input 2\n\n4\n1 2\n1 3\n1 4\n\nSample Output 2\n\n9\n\nThere are nine ways to paint the vertices, as follows:\n\nSample Input 3\n\n1\n\nSample Output 3\n\n2\n\nSample Input 4\n\n10\n8 5\n10 8\n6 5\n1 5\n4 8\n2 10\n3 6\n9 2\n1 7\n\nSample Output 4\n\n157", "sample_input": "3\n1 2\n2 3\n"}, "reference_outputs": ["5\n"], "source_document_id": "p03175", "source_text": "Score : 100 points\n\nProblem Statement\n\nThere is a tree with N vertices, numbered 1, 2, \\ldots, N.\nFor each i (1 \\leq i \\leq N - 1), the i-th edge connects Vertex x_i and y_i.\n\nTaro has decided to paint each vertex in white or black.\nHere, it is not allowed to paint two adjacent vertices both in black.\n\nFind the number of ways in which the vertices can be painted, modulo 10^9 + 7.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^5\n\n1 \\leq x_i, y_i \\leq N\n\nThe given graph is a tree.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nx_1 y_1\nx_2 y_2\n:\nx_{N - 1} y_{N - 1}\n\nOutput\n\nPrint the number of ways in which the vertices can be painted, modulo 10^9 + 7.\n\nSample Input 1\n\n3\n1 2\n2 3\n\nSample Output 1\n\n5\n\nThere are five ways to paint the vertices, as follows:\n\nSample Input 2\n\n4\n1 2\n1 3\n1 4\n\nSample Output 2\n\n9\n\nThere are nine ways to paint the vertices, as follows:\n\nSample Input 3\n\n1\n\nSample Output 3\n\n2\n\nSample Input 4\n\n10\n8 5\n10 8\n6 5\n1 5\n4 8\n2 10\n3 6\n9 2\n1 7\n\nSample Output 4\n\n157", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 470, "cpu_time_ms": 233, "memory_kb": 45668}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s732470519", "group_id": "codeNet:p03175", "input_text": "local n=io.read(\"n\")\nlocal g={}\nfor i=1,n do\n g[i]={}\nend\nfor i=1,n-1 do\n local x,y=io.read(\"n\",\"n\")\n g[x][y]=true\n g[y][x]=true\nend\n\nlocal bp,wp={},{}\nlocal mod=1000000007\nlocal function solve(cur,frm)\n bp[cur]=1\n wp[cur]=1\n for nxt in pairs(g[cur]) do\n if nxt~=frm then\n solve(nxt,cur)\n bp[cur]=bp[cur]*wp[nxt]%mod\n wp[cur]=wp[cur]*(wp[nxt]+bp[nxt])%mod\n end\n end\n if cur==1 then\n return bp[cur]+wp[cur]\n end\nend\n\nprint(solve(1,0))", "language": "Lua", "metadata": {"date": 1600729920, "filename_ext": "lua", "original_language": "Lua (Lua 5.3.5)", "problem_description_relpath": "problem_descriptions/p03175.html", "problem_id": "p03175", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03175/input.txt", "sample_output_relpath": "derived/input_output/data/p03175/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03175/Lua/s732470519.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s732470519", "user_id": "u045238009"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "local n=io.read(\"n\")\nlocal g={}\nfor i=1,n do\n g[i]={}\nend\nfor i=1,n-1 do\n local x,y=io.read(\"n\",\"n\")\n g[x][y]=true\n g[y][x]=true\nend\n\nlocal bp,wp={},{}\nlocal mod=1000000007\nlocal function solve(cur,frm)\n bp[cur]=1\n wp[cur]=1\n for nxt in pairs(g[cur]) do\n if nxt~=frm then\n solve(nxt,cur)\n bp[cur]=bp[cur]*wp[nxt]%mod\n wp[cur]=wp[cur]*(wp[nxt]+bp[nxt])%mod\n end\n end\n if cur==1 then\n return bp[cur]+wp[cur]\n end\nend\n\nprint(solve(1,0))", "problem_context": "Score : 100 points\n\nProblem Statement\n\nThere is a tree with N vertices, numbered 1, 2, \\ldots, N.\nFor each i (1 \\leq i \\leq N - 1), the i-th edge connects Vertex x_i and y_i.\n\nTaro has decided to paint each vertex in white or black.\nHere, it is not allowed to paint two adjacent vertices both in black.\n\nFind the number of ways in which the vertices can be painted, modulo 10^9 + 7.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^5\n\n1 \\leq x_i, y_i \\leq N\n\nThe given graph is a tree.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nx_1 y_1\nx_2 y_2\n:\nx_{N - 1} y_{N - 1}\n\nOutput\n\nPrint the number of ways in which the vertices can be painted, modulo 10^9 + 7.\n\nSample Input 1\n\n3\n1 2\n2 3\n\nSample Output 1\n\n5\n\nThere are five ways to paint the vertices, as follows:\n\nSample Input 2\n\n4\n1 2\n1 3\n1 4\n\nSample Output 2\n\n9\n\nThere are nine ways to paint the vertices, as follows:\n\nSample Input 3\n\n1\n\nSample Output 3\n\n2\n\nSample Input 4\n\n10\n8 5\n10 8\n6 5\n1 5\n4 8\n2 10\n3 6\n9 2\n1 7\n\nSample Output 4\n\n157", "sample_input": "3\n1 2\n2 3\n"}, "reference_outputs": ["5\n"], "source_document_id": "p03175", "source_text": "Score : 100 points\n\nProblem Statement\n\nThere is a tree with N vertices, numbered 1, 2, \\ldots, N.\nFor each i (1 \\leq i \\leq N - 1), the i-th edge connects Vertex x_i and y_i.\n\nTaro has decided to paint each vertex in white or black.\nHere, it is not allowed to paint two adjacent vertices both in black.\n\nFind the number of ways in which the vertices can be painted, modulo 10^9 + 7.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^5\n\n1 \\leq x_i, y_i \\leq N\n\nThe given graph is a tree.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nx_1 y_1\nx_2 y_2\n:\nx_{N - 1} y_{N - 1}\n\nOutput\n\nPrint the number of ways in which the vertices can be painted, modulo 10^9 + 7.\n\nSample Input 1\n\n3\n1 2\n2 3\n\nSample Output 1\n\n5\n\nThere are five ways to paint the vertices, as follows:\n\nSample Input 2\n\n4\n1 2\n1 3\n1 4\n\nSample Output 2\n\n9\n\nThere are nine ways to paint the vertices, as follows:\n\nSample Input 3\n\n1\n\nSample Output 3\n\n2\n\nSample Input 4\n\n10\n8 5\n10 8\n6 5\n1 5\n4 8\n2 10\n3 6\n9 2\n1 7\n\nSample Output 4\n\n157", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 517, "cpu_time_ms": 257, "memory_kb": 45760}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s605596114", "group_id": "codeNet:p03176", "input_text": "local function lower_bound(ary,key)\n local n=#ary\n if n==0 then\n return 1 \n end\n if key<=ary[1] then\n return 1\n end\n if key>ary[n] then\n return n+1\n end\n local min,max=1,n\n while 1ary[mid] then\n min=mid\n else\n max=mid\n end\n end\n return max\nend\n\n----------\n\nlocal n=io.read(\"n\")\nlocal h,a={},{}\nfor i=1,n do\n h[i]=io.read(\"n\")\nend\nfor i=1,n do\n a[i]=io.read(\"n\")\nend\n\nlocal INF=10^20\nlocal hp={}\nlocal ap={}\nfor i=1,n do\n hp[i]=INF\n ap[i]=0\nend\n\nfor i=1,n do\n local H,A=h[i],a[i]\n local k=lower_bound(hp,H)\n hp[k]=H\n ap[k]=math.max(ap[k],A)\nend\n\nlocal total=0\nfor i=1,n do\n total=total+ap[i]\nend\nprint(total)", "language": "Lua", "metadata": {"date": 1600731733, "filename_ext": "lua", "original_language": "Lua (Lua 5.3.5)", "problem_description_relpath": "problem_descriptions/p03176.html", "problem_id": "p03176", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03176/input.txt", "sample_output_relpath": "derived/input_output/data/p03176/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03176/Lua/s605596114.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s605596114", "user_id": "u045238009"}, "prompt_components": {"gold_output": "60\n", "input_to_evaluate": "local function lower_bound(ary,key)\n local n=#ary\n if n==0 then\n return 1 \n end\n if key<=ary[1] then\n return 1\n end\n if key>ary[n] then\n return n+1\n end\n local min,max=1,n\n while 1ary[mid] then\n min=mid\n else\n max=mid\n end\n end\n return max\nend\n\n----------\n\nlocal n=io.read(\"n\")\nlocal h,a={},{}\nfor i=1,n do\n h[i]=io.read(\"n\")\nend\nfor i=1,n do\n a[i]=io.read(\"n\")\nend\n\nlocal INF=10^20\nlocal hp={}\nlocal ap={}\nfor i=1,n do\n hp[i]=INF\n ap[i]=0\nend\n\nfor i=1,n do\n local H,A=h[i],a[i]\n local k=lower_bound(hp,H)\n hp[k]=H\n ap[k]=math.max(ap[k],A)\nend\n\nlocal total=0\nfor i=1,n do\n total=total+ap[i]\nend\nprint(total)", "problem_context": "Score : 100 points\n\nProblem Statement\n\nThere are N flowers arranged in a row.\nFor each i (1 \\leq i \\leq N), the height and the beauty of the i-th flower from the left is h_i and a_i, respectively.\nHere, h_1, h_2, \\ldots, h_N are all distinct.\n\nTaro is pulling out some flowers so that the following condition is met:\n\nThe heights of the remaining flowers are monotonically increasing from left to right.\n\nFind the maximum possible sum of the beauties of the remaining flowers.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 2 × 10^5\n\n1 \\leq h_i \\leq N\n\nh_1, h_2, \\ldots, h_N are all distinct.\n\n1 \\leq a_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nh_1 h_2 \\ldots h_N\na_1 a_2 \\ldots a_N\n\nOutput\n\nPrint the maximum possible sum of the beauties of the remaining flowers.\n\nSample Input 1\n\n4\n3 1 4 2\n10 20 30 40\n\nSample Output 1\n\n60\n\nWe should keep the second and fourth flowers from the left.\nThen, the heights would be 1, 2 from left to right, which is monotonically increasing, and the sum of the beauties would be 20 + 40 = 60.\n\nSample Input 2\n\n1\n1\n10\n\nSample Output 2\n\n10\n\nThe condition is met already at the beginning.\n\nSample Input 3\n\n5\n1 2 3 4 5\n1000000000 1000000000 1000000000 1000000000 1000000000\n\nSample Output 3\n\n5000000000\n\nThe answer may not fit into a 32-bit integer type.\n\nSample Input 4\n\n9\n4 2 5 8 3 6 1 7 9\n6 8 8 4 6 3 5 7 5\n\nSample Output 4\n\n31\n\nWe should keep the second, third, sixth, eighth and ninth flowers from the left.", "sample_input": "4\n3 1 4 2\n10 20 30 40\n"}, "reference_outputs": ["60\n"], "source_document_id": "p03176", "source_text": "Score : 100 points\n\nProblem Statement\n\nThere are N flowers arranged in a row.\nFor each i (1 \\leq i \\leq N), the height and the beauty of the i-th flower from the left is h_i and a_i, respectively.\nHere, h_1, h_2, \\ldots, h_N are all distinct.\n\nTaro is pulling out some flowers so that the following condition is met:\n\nThe heights of the remaining flowers are monotonically increasing from left to right.\n\nFind the maximum possible sum of the beauties of the remaining flowers.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 2 × 10^5\n\n1 \\leq h_i \\leq N\n\nh_1, h_2, \\ldots, h_N are all distinct.\n\n1 \\leq a_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nh_1 h_2 \\ldots h_N\na_1 a_2 \\ldots a_N\n\nOutput\n\nPrint the maximum possible sum of the beauties of the remaining flowers.\n\nSample Input 1\n\n4\n3 1 4 2\n10 20 30 40\n\nSample Output 1\n\n60\n\nWe should keep the second and fourth flowers from the left.\nThen, the heights would be 1, 2 from left to right, which is monotonically increasing, and the sum of the beauties would be 20 + 40 = 60.\n\nSample Input 2\n\n1\n1\n10\n\nSample Output 2\n\n10\n\nThe condition is met already at the beginning.\n\nSample Input 3\n\n5\n1 2 3 4 5\n1000000000 1000000000 1000000000 1000000000 1000000000\n\nSample Output 3\n\n5000000000\n\nThe answer may not fit into a 32-bit integer type.\n\nSample Input 4\n\n9\n4 2 5 8 3 6 1 7 9\n6 8 8 4 6 3 5 7 5\n\nSample Output 4\n\n31\n\nWe should keep the second, third, sixth, eighth and ninth flowers from the left.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 793, "cpu_time_ms": 445, "memory_kb": 18800}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s764928203", "group_id": "codeNet:p03176", "input_text": "local mfl, mce, mmi = math.floor, math.ceil, math.min\nlocal SegTree = {}\nSegTree.updateAll = function(self)\n for i = self.stagenum - 1, 1, -1 do\n for j = 1, self.cnt[i] do\n self.stage[i][j] = self.func(self.stage[i + 1][j * 2 - 1], self.stage[i + 1][j * 2])\n end\n end\nend\nSegTree.create = function(self, n, func, emptyvalue)\n self.func, self.emptyvalue = func, emptyvalue\n local stagenum, mul = 1, 1\n self.cnt, self.stage, self.size = {1}, {{}}, {}\n while mul < n do\n mul, stagenum = mul * 2, stagenum + 1\n self.cnt[stagenum], self.stage[stagenum] = mul, {}\n end\n for i = 1, stagenum do self.size[i] = self.cnt[stagenum + 1 - i] end\n self.stagenum = stagenum\n for i = 1, mul do self.stage[stagenum][i] = emptyvalue end\n self:updateAll()\nend\nSegTree.getRange = function(self, left, right)\n if left == right then return self.stage[self.stagenum][left] end\n local start_stage = 1\n while right - left + 1 < self.size[start_stage] do\n start_stage = start_stage + 1\n end\n local ret = self.emptyvalue\n local t1, t2, t3 = {start_stage}, {left}, {right}\n while 0 < #t1 do\n local stage, l, r = t1[#t1], t2[#t1], t3[#t1]\n table.remove(t1) table.remove(t2) table.remove(t3)\n local sz = self.size[stage]\n if (l - 1) % sz ~= 0 then\n local newr = mmi(r, mce((l - 1) / sz) * sz)\n table.insert(t1, stage + 1) table.insert(t2, l) table.insert(t3, newr)\n l = newr + 1\n end\n if sz <= r + 1 - l then\n ret = self.func(ret, self.stage[stage][mce(l / sz)])\n l = l + sz\n end\n if l <= r then\n table.insert(t1, stage + 1) table.insert(t2, l) table.insert(t3, r)\n end\n end\n return ret\nend\nSegTree.update = function(self, idx, value)\n if self.stage[self.stagenum][idx] < value then\n self.stage[self.stagenum][idx] = value\n for i = self.stagenum - 1, 1, -1 do\n local dst = mce(idx / 2)\n local rem = dst * 4 - 1 - idx\n self.stage[i][dst] = self.func(self.stage[i + 1][idx], self.stage[i + 1][rem])\n idx = dst\n end\n end\nend\nSegTree.new = function(n, func, emptyvalue)\n local obj = {}\n setmetatable(obj, {__index = SegTree})\n obj:create(n, func, emptyvalue)\n return obj\nend\n\nlocal n = io.read(\"*n\")\nlocal h = {}\nlocal a = {}\nfor i = 1, n do h[i] = io.read(\"*n\") end\nfor i = 1, n do a[i] = 0LL + io.read(\"*n\") end\nlocal st = SegTree.new(n, function(x, y) return x < y and y or x end, 0)\nfor i = 1, n do\n if h[i] == 1 then\n st:update(h[i], a[i])\n else\n local cur = st:getRange(1, h[i] - 1)\n st:update(h[i], cur + a[i])\n end\nend\nlocal str = tostring(st.stage[1][1]):gsub(\"LL\", \"\")\nprint(str)\n", "language": "Lua", "metadata": {"date": 1582812821, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p03176.html", "problem_id": "p03176", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03176/input.txt", "sample_output_relpath": "derived/input_output/data/p03176/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03176/Lua/s764928203.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s764928203", "user_id": "u120582723"}, "prompt_components": {"gold_output": "60\n", "input_to_evaluate": "local mfl, mce, mmi = math.floor, math.ceil, math.min\nlocal SegTree = {}\nSegTree.updateAll = function(self)\n for i = self.stagenum - 1, 1, -1 do\n for j = 1, self.cnt[i] do\n self.stage[i][j] = self.func(self.stage[i + 1][j * 2 - 1], self.stage[i + 1][j * 2])\n end\n end\nend\nSegTree.create = function(self, n, func, emptyvalue)\n self.func, self.emptyvalue = func, emptyvalue\n local stagenum, mul = 1, 1\n self.cnt, self.stage, self.size = {1}, {{}}, {}\n while mul < n do\n mul, stagenum = mul * 2, stagenum + 1\n self.cnt[stagenum], self.stage[stagenum] = mul, {}\n end\n for i = 1, stagenum do self.size[i] = self.cnt[stagenum + 1 - i] end\n self.stagenum = stagenum\n for i = 1, mul do self.stage[stagenum][i] = emptyvalue end\n self:updateAll()\nend\nSegTree.getRange = function(self, left, right)\n if left == right then return self.stage[self.stagenum][left] end\n local start_stage = 1\n while right - left + 1 < self.size[start_stage] do\n start_stage = start_stage + 1\n end\n local ret = self.emptyvalue\n local t1, t2, t3 = {start_stage}, {left}, {right}\n while 0 < #t1 do\n local stage, l, r = t1[#t1], t2[#t1], t3[#t1]\n table.remove(t1) table.remove(t2) table.remove(t3)\n local sz = self.size[stage]\n if (l - 1) % sz ~= 0 then\n local newr = mmi(r, mce((l - 1) / sz) * sz)\n table.insert(t1, stage + 1) table.insert(t2, l) table.insert(t3, newr)\n l = newr + 1\n end\n if sz <= r + 1 - l then\n ret = self.func(ret, self.stage[stage][mce(l / sz)])\n l = l + sz\n end\n if l <= r then\n table.insert(t1, stage + 1) table.insert(t2, l) table.insert(t3, r)\n end\n end\n return ret\nend\nSegTree.update = function(self, idx, value)\n if self.stage[self.stagenum][idx] < value then\n self.stage[self.stagenum][idx] = value\n for i = self.stagenum - 1, 1, -1 do\n local dst = mce(idx / 2)\n local rem = dst * 4 - 1 - idx\n self.stage[i][dst] = self.func(self.stage[i + 1][idx], self.stage[i + 1][rem])\n idx = dst\n end\n end\nend\nSegTree.new = function(n, func, emptyvalue)\n local obj = {}\n setmetatable(obj, {__index = SegTree})\n obj:create(n, func, emptyvalue)\n return obj\nend\n\nlocal n = io.read(\"*n\")\nlocal h = {}\nlocal a = {}\nfor i = 1, n do h[i] = io.read(\"*n\") end\nfor i = 1, n do a[i] = 0LL + io.read(\"*n\") end\nlocal st = SegTree.new(n, function(x, y) return x < y and y or x end, 0)\nfor i = 1, n do\n if h[i] == 1 then\n st:update(h[i], a[i])\n else\n local cur = st:getRange(1, h[i] - 1)\n st:update(h[i], cur + a[i])\n end\nend\nlocal str = tostring(st.stage[1][1]):gsub(\"LL\", \"\")\nprint(str)\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nThere are N flowers arranged in a row.\nFor each i (1 \\leq i \\leq N), the height and the beauty of the i-th flower from the left is h_i and a_i, respectively.\nHere, h_1, h_2, \\ldots, h_N are all distinct.\n\nTaro is pulling out some flowers so that the following condition is met:\n\nThe heights of the remaining flowers are monotonically increasing from left to right.\n\nFind the maximum possible sum of the beauties of the remaining flowers.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 2 × 10^5\n\n1 \\leq h_i \\leq N\n\nh_1, h_2, \\ldots, h_N are all distinct.\n\n1 \\leq a_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nh_1 h_2 \\ldots h_N\na_1 a_2 \\ldots a_N\n\nOutput\n\nPrint the maximum possible sum of the beauties of the remaining flowers.\n\nSample Input 1\n\n4\n3 1 4 2\n10 20 30 40\n\nSample Output 1\n\n60\n\nWe should keep the second and fourth flowers from the left.\nThen, the heights would be 1, 2 from left to right, which is monotonically increasing, and the sum of the beauties would be 20 + 40 = 60.\n\nSample Input 2\n\n1\n1\n10\n\nSample Output 2\n\n10\n\nThe condition is met already at the beginning.\n\nSample Input 3\n\n5\n1 2 3 4 5\n1000000000 1000000000 1000000000 1000000000 1000000000\n\nSample Output 3\n\n5000000000\n\nThe answer may not fit into a 32-bit integer type.\n\nSample Input 4\n\n9\n4 2 5 8 3 6 1 7 9\n6 8 8 4 6 3 5 7 5\n\nSample Output 4\n\n31\n\nWe should keep the second, third, sixth, eighth and ninth flowers from the left.", "sample_input": "4\n3 1 4 2\n10 20 30 40\n"}, "reference_outputs": ["60\n"], "source_document_id": "p03176", "source_text": "Score : 100 points\n\nProblem Statement\n\nThere are N flowers arranged in a row.\nFor each i (1 \\leq i \\leq N), the height and the beauty of the i-th flower from the left is h_i and a_i, respectively.\nHere, h_1, h_2, \\ldots, h_N are all distinct.\n\nTaro is pulling out some flowers so that the following condition is met:\n\nThe heights of the remaining flowers are monotonically increasing from left to right.\n\nFind the maximum possible sum of the beauties of the remaining flowers.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 2 × 10^5\n\n1 \\leq h_i \\leq N\n\nh_1, h_2, \\ldots, h_N are all distinct.\n\n1 \\leq a_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nh_1 h_2 \\ldots h_N\na_1 a_2 \\ldots a_N\n\nOutput\n\nPrint the maximum possible sum of the beauties of the remaining flowers.\n\nSample Input 1\n\n4\n3 1 4 2\n10 20 30 40\n\nSample Output 1\n\n60\n\nWe should keep the second and fourth flowers from the left.\nThen, the heights would be 1, 2 from left to right, which is monotonically increasing, and the sum of the beauties would be 20 + 40 = 60.\n\nSample Input 2\n\n1\n1\n10\n\nSample Output 2\n\n10\n\nThe condition is met already at the beginning.\n\nSample Input 3\n\n5\n1 2 3 4 5\n1000000000 1000000000 1000000000 1000000000 1000000000\n\nSample Output 3\n\n5000000000\n\nThe answer may not fit into a 32-bit integer type.\n\nSample Input 4\n\n9\n4 2 5 8 3 6 1 7 9\n6 8 8 4 6 3 5 7 5\n\nSample Output 4\n\n31\n\nWe should keep the second, third, sixth, eighth and ninth flowers from the left.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2600, "cpu_time_ms": 599, "memory_kb": 58596}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s618040964", "group_id": "codeNet:p03177", "input_text": "local mfl = math.floor\nlocal mod = 1000000007\nlocal function badd(x, y) return (x + y) % mod end\nlocal function bmul(x, y)\n local x1, y1 = mfl(x / 31623), mfl(y / 31623)\n local x0, y0 = x - x1 * 31623, y - y1 * 31623\n return (x1 * y1 * 14122 + (x1 * y0 + x0 * y1) * 31623 + x0 * y0) % mod\nend\nlocal function lltonumber(str)\n local ret = 0LL\n for i = 1, #str do\n ret = ret * 10LL + str:sub(i, i):byte() - 48\n end\n return ret\nend\n\nlocal s = io.read()\nlocal n, k = s:match(\"(%d+) (%d+)\")\nn = tonumber(n)\nk = lltonumber(k)\nlocal t = {}\nfor i = 1, n do\n t[i] = {}\n for j = 1, n do\n t[i][j] = io.read(\"*n\")\n end\nend\nlocal cpy = {}\nfor i = 1, n do\n cpy[i] = {}\n for j = 1, n do\n cpy[i][j] = 0\n end\nend\nlocal function update()\n for i = 1, n do\n for j = 1, n do\n cpy[i][j] = 0\n end\n end\n for i = 1, n do\n for j = 1, n do\n for k = 1, n do\n cpy[i][k] = badd(cpy[i][k], bmul(t[i][j], t[j][k]))\n end\n end\n end\n for i = 1, n do\n for j = 1, n do\n t[i][j] = cpy[i][j]\n end\n end\nend\nlocal src, dst = {}, {}\nfor i = 1, n do\n src[i] = 1\n dst[i] = 0\nend\nwhile 0LL < k do\n if k % 2LL == 1LL then\n for i = 1, n do\n dst[i] = 0\n end\n for i = 1, n do\n for j = 1, n do\n dst[j] = badd(dst[j], bmul(t[i][j], src[i]))\n end\n end\n for i = 1, n do\n src[i] = dst[i]\n end\n end\n update()\n k = k / 2LL\nend\nlocal ret = 0\nfor i = 1, n do\n ret = badd(ret, src[i])\nend\nprint(ret)\n", "language": "Lua", "metadata": {"date": 1587473187, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p03177.html", "problem_id": "p03177", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03177/input.txt", "sample_output_relpath": "derived/input_output/data/p03177/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03177/Lua/s618040964.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s618040964", "user_id": "u120582723"}, "prompt_components": {"gold_output": "6\n", "input_to_evaluate": "local mfl = math.floor\nlocal mod = 1000000007\nlocal function badd(x, y) return (x + y) % mod end\nlocal function bmul(x, y)\n local x1, y1 = mfl(x / 31623), mfl(y / 31623)\n local x0, y0 = x - x1 * 31623, y - y1 * 31623\n return (x1 * y1 * 14122 + (x1 * y0 + x0 * y1) * 31623 + x0 * y0) % mod\nend\nlocal function lltonumber(str)\n local ret = 0LL\n for i = 1, #str do\n ret = ret * 10LL + str:sub(i, i):byte() - 48\n end\n return ret\nend\n\nlocal s = io.read()\nlocal n, k = s:match(\"(%d+) (%d+)\")\nn = tonumber(n)\nk = lltonumber(k)\nlocal t = {}\nfor i = 1, n do\n t[i] = {}\n for j = 1, n do\n t[i][j] = io.read(\"*n\")\n end\nend\nlocal cpy = {}\nfor i = 1, n do\n cpy[i] = {}\n for j = 1, n do\n cpy[i][j] = 0\n end\nend\nlocal function update()\n for i = 1, n do\n for j = 1, n do\n cpy[i][j] = 0\n end\n end\n for i = 1, n do\n for j = 1, n do\n for k = 1, n do\n cpy[i][k] = badd(cpy[i][k], bmul(t[i][j], t[j][k]))\n end\n end\n end\n for i = 1, n do\n for j = 1, n do\n t[i][j] = cpy[i][j]\n end\n end\nend\nlocal src, dst = {}, {}\nfor i = 1, n do\n src[i] = 1\n dst[i] = 0\nend\nwhile 0LL < k do\n if k % 2LL == 1LL then\n for i = 1, n do\n dst[i] = 0\n end\n for i = 1, n do\n for j = 1, n do\n dst[j] = badd(dst[j], bmul(t[i][j], src[i]))\n end\n end\n for i = 1, n do\n src[i] = dst[i]\n end\n end\n update()\n k = k / 2LL\nend\nlocal ret = 0\nfor i = 1, n do\n ret = badd(ret, src[i])\nend\nprint(ret)\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nThere is a simple directed graph G with N vertices, numbered 1, 2, \\ldots, N.\n\nFor each i and j (1 \\leq i, j \\leq N), you are given an integer a_{i, j} that represents whether there is a directed edge from Vertex i to j.\nIf a_{i, j} = 1, there is a directed edge from Vertex i to j; if a_{i, j} = 0, there is not.\n\nFind the number of different directed paths of length K in G, modulo 10^9 + 7.\nWe will also count a path that traverses the same edge multiple times.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 50\n\n1 \\leq K \\leq 10^{18}\n\na_{i, j} is 0 or 1.\n\na_{i, i} = 0\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\na_{1, 1} \\ldots a_{1, N}\n:\na_{N, 1} \\ldots a_{N, N}\n\nOutput\n\nPrint the number of different directed paths of length K in G, modulo 10^9 + 7.\n\nSample Input 1\n\n4 2\n0 1 0 0\n0 0 1 1\n0 0 0 1\n1 0 0 0\n\nSample Output 1\n\n6\n\nG is drawn in the figure below:\n\nThere are six directed paths of length 2:\n\n1 → 2 → 3\n\n1 → 2 → 4\n\n2 → 3 → 4\n\n2 → 4 → 1\n\n3 → 4 → 1\n\n4 → 1 → 2\n\nSample Input 2\n\n3 3\n0 1 0\n1 0 1\n0 0 0\n\nSample Output 2\n\n3\n\nG is drawn in the figure below:\n\nThere are three directed paths of length 3:\n\n1 → 2 → 1 → 2\n\n2 → 1 → 2 → 1\n\n2 → 1 → 2 → 3\n\nSample Input 3\n\n6 2\n0 0 0 0 0 0\n0 0 1 0 0 0\n0 0 0 0 0 0\n0 0 0 0 1 0\n0 0 0 0 0 1\n0 0 0 0 0 0\n\nSample Output 3\n\n1\n\nG is drawn in the figure below:\n\nThere is one directed path of length 2:\n\n4 → 5 → 6\n\nSample Input 4\n\n1 1\n0\n\nSample Output 4\n\n0\n\nSample Input 5\n\n10 1000000000000000000\n0 0 1 1 0 0 0 1 1 0\n0 0 0 0 0 1 1 1 0 0\n0 1 0 0 0 1 0 1 0 1\n1 1 1 0 1 1 0 1 1 0\n0 1 1 1 0 1 0 1 1 1\n0 0 0 1 0 0 1 0 1 0\n0 0 0 1 1 0 0 1 0 1\n1 0 0 0 1 0 1 0 0 0\n0 0 0 0 0 1 0 0 0 0\n1 0 1 1 1 0 1 1 1 0\n\nSample Output 5\n\n957538352\n\nBe sure to print the count modulo 10^9 + 7.", "sample_input": "4 2\n0 1 0 0\n0 0 1 1\n0 0 0 1\n1 0 0 0\n"}, "reference_outputs": ["6\n"], "source_document_id": "p03177", "source_text": "Score : 100 points\n\nProblem Statement\n\nThere is a simple directed graph G with N vertices, numbered 1, 2, \\ldots, N.\n\nFor each i and j (1 \\leq i, j \\leq N), you are given an integer a_{i, j} that represents whether there is a directed edge from Vertex i to j.\nIf a_{i, j} = 1, there is a directed edge from Vertex i to j; if a_{i, j} = 0, there is not.\n\nFind the number of different directed paths of length K in G, modulo 10^9 + 7.\nWe will also count a path that traverses the same edge multiple times.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 50\n\n1 \\leq K \\leq 10^{18}\n\na_{i, j} is 0 or 1.\n\na_{i, i} = 0\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\na_{1, 1} \\ldots a_{1, N}\n:\na_{N, 1} \\ldots a_{N, N}\n\nOutput\n\nPrint the number of different directed paths of length K in G, modulo 10^9 + 7.\n\nSample Input 1\n\n4 2\n0 1 0 0\n0 0 1 1\n0 0 0 1\n1 0 0 0\n\nSample Output 1\n\n6\n\nG is drawn in the figure below:\n\nThere are six directed paths of length 2:\n\n1 → 2 → 3\n\n1 → 2 → 4\n\n2 → 3 → 4\n\n2 → 4 → 1\n\n3 → 4 → 1\n\n4 → 1 → 2\n\nSample Input 2\n\n3 3\n0 1 0\n1 0 1\n0 0 0\n\nSample Output 2\n\n3\n\nG is drawn in the figure below:\n\nThere are three directed paths of length 3:\n\n1 → 2 → 1 → 2\n\n2 → 1 → 2 → 1\n\n2 → 1 → 2 → 3\n\nSample Input 3\n\n6 2\n0 0 0 0 0 0\n0 0 1 0 0 0\n0 0 0 0 0 0\n0 0 0 0 1 0\n0 0 0 0 0 1\n0 0 0 0 0 0\n\nSample Output 3\n\n1\n\nG is drawn in the figure below:\n\nThere is one directed path of length 2:\n\n4 → 5 → 6\n\nSample Input 4\n\n1 1\n0\n\nSample Output 4\n\n0\n\nSample Input 5\n\n10 1000000000000000000\n0 0 1 1 0 0 0 1 1 0\n0 0 0 0 0 1 1 1 0 0\n0 1 0 0 0 1 0 1 0 1\n1 1 1 0 1 1 0 1 1 0\n0 1 1 1 0 1 0 1 1 1\n0 0 0 1 0 0 1 0 1 0\n0 0 0 1 1 0 0 1 0 1\n1 0 0 0 1 0 1 0 0 0\n0 0 0 0 0 1 0 0 0 0\n1 0 1 1 1 0 1 1 1 0\n\nSample Output 5\n\n957538352\n\nBe sure to print the count modulo 10^9 + 7.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1465, "cpu_time_ms": 154, "memory_kb": 384}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s036571212", "group_id": "codeNet:p03178", "input_text": "local mod = 1000000007\nlocal function badd(x, y) return (x + y) % mod end\n\nlocal s = io.read()\nlocal d = io.read(\"*n\")\nlocal dpmax, dpnormal = {}, {}\nfor i = 1, d do\n dpmax[i] = 0\n dpnormal[i] = 0\nend\ndpmax[d] = 1\nlocal nxt_max, nxt_normal = {}, {}\nfor i = 1, #s do\n for j = 1, d do\n nxt_max[j] = 0\n nxt_normal[j] = 0\n end\n local v = s:sub(i, i):byte() - 48\n for src = 1, d do\n for add = 0, v do\n local dst = (add + src) % d\n if dst == 0 then dst = d end\n if add == v then\n nxt_max[dst] = badd(nxt_max[dst], dpmax[src])\n else\n nxt_normal[dst] = badd(nxt_normal[dst], dpmax[src])\n end\n end\n for add = 0, 9 do\n local dst = (add + src) % d\n if dst == 0 then dst = d end\n nxt_normal[dst] = badd(nxt_normal[dst], dpnormal[src])\n end\n end\n for j = 1, d do\n dpmax[j] = nxt_max[j]\n dpnormal[j] = nxt_normal[j]\n end\nend\nlocal ret = badd(dpmax[d], dpnormal[d])\nret = badd(ret, mod - 1)\nprint(ret)\n", "language": "Lua", "metadata": {"date": 1587430729, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p03178.html", "problem_id": "p03178", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03178/input.txt", "sample_output_relpath": "derived/input_output/data/p03178/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03178/Lua/s036571212.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s036571212", "user_id": "u120582723"}, "prompt_components": {"gold_output": "6\n", "input_to_evaluate": "local mod = 1000000007\nlocal function badd(x, y) return (x + y) % mod end\n\nlocal s = io.read()\nlocal d = io.read(\"*n\")\nlocal dpmax, dpnormal = {}, {}\nfor i = 1, d do\n dpmax[i] = 0\n dpnormal[i] = 0\nend\ndpmax[d] = 1\nlocal nxt_max, nxt_normal = {}, {}\nfor i = 1, #s do\n for j = 1, d do\n nxt_max[j] = 0\n nxt_normal[j] = 0\n end\n local v = s:sub(i, i):byte() - 48\n for src = 1, d do\n for add = 0, v do\n local dst = (add + src) % d\n if dst == 0 then dst = d end\n if add == v then\n nxt_max[dst] = badd(nxt_max[dst], dpmax[src])\n else\n nxt_normal[dst] = badd(nxt_normal[dst], dpmax[src])\n end\n end\n for add = 0, 9 do\n local dst = (add + src) % d\n if dst == 0 then dst = d end\n nxt_normal[dst] = badd(nxt_normal[dst], dpnormal[src])\n end\n end\n for j = 1, d do\n dpmax[j] = nxt_max[j]\n dpnormal[j] = nxt_normal[j]\n end\nend\nlocal ret = badd(dpmax[d], dpnormal[d])\nret = badd(ret, mod - 1)\nprint(ret)\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nFind the number of integers between 1 and K (inclusive) satisfying the following condition, modulo 10^9 + 7:\n\nThe sum of the digits in base ten is a multiple of D.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq K < 10^{10000}\n\n1 \\leq D \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nK\nD\n\nOutput\n\nPrint the number of integers satisfying the condition, modulo 10^9 + 7.\n\nSample Input 1\n\n30\n4\n\nSample Output 1\n\n6\n\nThose six integers are: 4, 8, 13, 17, 22 and 26.\n\nSample Input 2\n\n1000000009\n1\n\nSample Output 2\n\n2\n\nBe sure to print the number modulo 10^9 + 7.\n\nSample Input 3\n\n98765432109876543210\n58\n\nSample Output 3\n\n635270834", "sample_input": "30\n4\n"}, "reference_outputs": ["6\n"], "source_document_id": "p03178", "source_text": "Score : 100 points\n\nProblem Statement\n\nFind the number of integers between 1 and K (inclusive) satisfying the following condition, modulo 10^9 + 7:\n\nThe sum of the digits in base ten is a multiple of D.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq K < 10^{10000}\n\n1 \\leq D \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nK\nD\n\nOutput\n\nPrint the number of integers satisfying the condition, modulo 10^9 + 7.\n\nSample Input 1\n\n30\n4\n\nSample Output 1\n\n6\n\nThose six integers are: 4, 8, 13, 17, 22 and 26.\n\nSample Input 2\n\n1000000009\n1\n\nSample Output 2\n\n2\n\nBe sure to print the number modulo 10^9 + 7.\n\nSample Input 3\n\n98765432109876543210\n58\n\nSample Output 3\n\n635270834", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 974, "cpu_time_ms": 225, "memory_kb": 256}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s953566181", "group_id": "codeNet:p03186", "input_text": "local a, b, c = io.read(\"*n\", \"*n\", \"*n\")\nlocal ret = 0\nc = math.min(c, a + b + 1)\nprint(b + c)\n", "language": "Lua", "metadata": {"date": 1563249597, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03186.html", "problem_id": "p03186", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03186/input.txt", "sample_output_relpath": "derived/input_output/data/p03186/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03186/Lua/s953566181.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s953566181", "user_id": "u120582723"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "local a, b, c = io.read(\"*n\", \"*n\", \"*n\")\nlocal ret = 0\nc = math.min(c, a + b + 1)\nprint(b + c)\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nTakahashi has A untasty cookies containing antidotes, B tasty cookies containing antidotes and C tasty cookies containing poison.\n\nEating a cookie containing poison results in a stomachache, and eating a cookie containing poison while having a stomachache results in a death.\nAs he wants to live, he cannot eat one in such a situation.\nEating a cookie containing antidotes while having a stomachache cures it, and there is no other way to cure stomachaches.\n\nFind the maximum number of tasty cookies that Takahashi can eat.\n\nConstraints\n\n0 \\leq A,B,C \\leq 10^9\n\nA,B and C are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C\n\nOutput\n\nPrint the maximum number of tasty cookies that Takahashi can eat.\n\nSample Input 1\n\n3 1 4\n\nSample Output 1\n\n5\n\nWe can eat all tasty cookies, in the following order:\n\nA tasty cookie containing poison\n\nAn untasty cookie containing antidotes\n\nA tasty cookie containing poison\n\nA tasty cookie containing antidotes\n\nA tasty cookie containing poison\n\nAn untasty cookie containing antidotes\n\nA tasty cookie containing poison\n\nSample Input 2\n\n5 2 9\n\nSample Output 2\n\n10\n\nSample Input 3\n\n8 8 1\n\nSample Output 3\n\n9", "sample_input": "3 1 4\n"}, "reference_outputs": ["5\n"], "source_document_id": "p03186", "source_text": "Score : 200 points\n\nProblem Statement\n\nTakahashi has A untasty cookies containing antidotes, B tasty cookies containing antidotes and C tasty cookies containing poison.\n\nEating a cookie containing poison results in a stomachache, and eating a cookie containing poison while having a stomachache results in a death.\nAs he wants to live, he cannot eat one in such a situation.\nEating a cookie containing antidotes while having a stomachache cures it, and there is no other way to cure stomachaches.\n\nFind the maximum number of tasty cookies that Takahashi can eat.\n\nConstraints\n\n0 \\leq A,B,C \\leq 10^9\n\nA,B and C are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C\n\nOutput\n\nPrint the maximum number of tasty cookies that Takahashi can eat.\n\nSample Input 1\n\n3 1 4\n\nSample Output 1\n\n5\n\nWe can eat all tasty cookies, in the following order:\n\nA tasty cookie containing poison\n\nAn untasty cookie containing antidotes\n\nA tasty cookie containing poison\n\nA tasty cookie containing antidotes\n\nA tasty cookie containing poison\n\nAn untasty cookie containing antidotes\n\nA tasty cookie containing poison\n\nSample Input 2\n\n5 2 9\n\nSample Output 2\n\n10\n\nSample Input 3\n\n8 8 1\n\nSample Output 3\n\n9", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 96, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s124081563", "group_id": "codeNet:p03187", "input_text": "local ior = io.read\nlocal l, n = ior(\"*n\", \"*n\")\nlocal x = {}\nfor i = 1, n do\n x[i] = ior(\"*n\")\nend\nlocal dpl, dpr = {}, {}\ndpl[1 + 0] = 0\ndpr[1 + 0] = l - x[n]\ndpl[1 + 1] = x[1]\ndpr[1 + 1] = 0\n\nlocal altl, altr = {}, {}\nlocal srcl, srcr, dstl, dstr = dpl, dpr, altl, altr\nlocal mma = math.max\n\nlocal function getlen(idx_from, idx_to)\n local len = x[idx_to] - x[idx_from]\n if(len < 0) then len = len + l end\n return len\nend\n\nfor i = 2, n do\n dstl[1 + 0] = 0\n dstl[1 + 1] = srcr[1 + 0] + getlen(n + 1 - (i - 1), 1)\n for j = 2, i - 1 do\n dstl[1 + j] = mma(srcl[1 + j - 1] + getlen(j - 1, j), srcr[1 + j - 1] + getlen(n + 1 - (i - j), j))\n end\n dstl[1 + i] = srcl[1 + i - 1] + getlen(i - 1, i)\n\n dstr[1 + 0] = srcr[1 + 0] + getlen(n + 1 - i, n + 1 - (i - 1))\n for j = 1, i - 2 do\n dstr[1 + j] = mma(srcr[1 + j] + getlen(n + 1 - (i - j), n + 1 - (i - 1 - j)), srcl[1 + j] + getlen(n + 1 - (i - j), j))\n end\n dstr[1 + i - 1] = srcl[1 + i - 1] + getlen(n, i - 1)\n dstr[1 + i] = 0\n\n srcl, srcr, dstl, dstr = dstl, dstr, srcl, srcr\n\nend\n\nlocal max = 0\nfor k, v in pairs(srcl) do\n max = mma(max, v)\nend\nfor k, v in pairs(srcr) do\n max = mma(max, v)\nend\nprint(max)\n", "language": "Lua", "metadata": {"date": 1556251417, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p03187.html", "problem_id": "p03187", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03187/input.txt", "sample_output_relpath": "derived/input_output/data/p03187/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03187/Lua/s124081563.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s124081563", "user_id": "u120582723"}, "prompt_components": {"gold_output": "15\n", "input_to_evaluate": "local ior = io.read\nlocal l, n = ior(\"*n\", \"*n\")\nlocal x = {}\nfor i = 1, n do\n x[i] = ior(\"*n\")\nend\nlocal dpl, dpr = {}, {}\ndpl[1 + 0] = 0\ndpr[1 + 0] = l - x[n]\ndpl[1 + 1] = x[1]\ndpr[1 + 1] = 0\n\nlocal altl, altr = {}, {}\nlocal srcl, srcr, dstl, dstr = dpl, dpr, altl, altr\nlocal mma = math.max\n\nlocal function getlen(idx_from, idx_to)\n local len = x[idx_to] - x[idx_from]\n if(len < 0) then len = len + l end\n return len\nend\n\nfor i = 2, n do\n dstl[1 + 0] = 0\n dstl[1 + 1] = srcr[1 + 0] + getlen(n + 1 - (i - 1), 1)\n for j = 2, i - 1 do\n dstl[1 + j] = mma(srcl[1 + j - 1] + getlen(j - 1, j), srcr[1 + j - 1] + getlen(n + 1 - (i - j), j))\n end\n dstl[1 + i] = srcl[1 + i - 1] + getlen(i - 1, i)\n\n dstr[1 + 0] = srcr[1 + 0] + getlen(n + 1 - i, n + 1 - (i - 1))\n for j = 1, i - 2 do\n dstr[1 + j] = mma(srcr[1 + j] + getlen(n + 1 - (i - j), n + 1 - (i - 1 - j)), srcl[1 + j] + getlen(n + 1 - (i - j), j))\n end\n dstr[1 + i - 1] = srcl[1 + i - 1] + getlen(n, i - 1)\n dstr[1 + i] = 0\n\n srcl, srcr, dstl, dstr = dstl, dstr, srcl, srcr\n\nend\n\nlocal max = 0\nfor k, v in pairs(srcl) do\n max = mma(max, v)\nend\nfor k, v in pairs(srcr) do\n max = mma(max, v)\nend\nprint(max)\n", "problem_context": "Score : 800 points\n\nProblem Statement\n\nTakahashi Lake has a perimeter of L. On the circumference of the lake, there is a residence of the lake's owner, Takahashi.\nEach point on the circumference of the lake has a coordinate between 0 and L (including 0 but not L), which is the distance from the Takahashi's residence, measured counter-clockwise.\n\nThere 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.\n\nStarting at his residence, Takahashi will repeat the following action:\n\nIf all trees are burnt, terminate the process.\n\nSpecify a direction: clockwise or counter-clockwise.\n\nWalk around the lake in the specified direction, until the coordinate of a tree that is not yet burnt is reached for the first time.\n\nWhen the coordinate with the tree is reached, burn that tree, stay at the position and go back to the first step.\n\nFind the longest possible total distance Takahashi walks during the process.\n\nPartial Score\n\nA partial score can be obtained in this problem:\n\n300 points will be awarded for passing the input satisfying N \\leq 2000.\n\nConstraints\n\n2 \\leq L \\leq 10^9\n\n1 \\leq N \\leq 2\\times 10^5\n\n1 \\leq X_1 < ... < X_N \\leq L-1\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nL N\nX_1\n:\nX_N\n\nOutput\n\nPrint the longest possible total distance Takahashi walks during the process.\n\nSample Input 1\n\n10 3\n2\n7\n9\n\nSample Output 1\n\n15\n\nTakahashi walks the distance of 15 if the process goes as follows:\n\nWalk a distance of 2 counter-clockwise, burn the tree at the coordinate 2 and stay there.\n\nWalk a distance of 5 counter-clockwise, burn the tree at the coordinate 7 and stay there.\n\nWalk a distance of 8 clockwise, burn the tree at the coordinate 9 and stay there.\n\nSample Input 2\n\n10 6\n1\n2\n3\n6\n7\n9\n\nSample Output 2\n\n27\n\nSample Input 3\n\n314159265 7\n21662711\n77271666\n89022761\n156626166\n160332356\n166902656\n298992265\n\nSample Output 3\n\n1204124749", "sample_input": "10 3\n2\n7\n9\n"}, "reference_outputs": ["15\n"], "source_document_id": "p03187", "source_text": "Score : 800 points\n\nProblem Statement\n\nTakahashi Lake has a perimeter of L. On the circumference of the lake, there is a residence of the lake's owner, Takahashi.\nEach point on the circumference of the lake has a coordinate between 0 and L (including 0 but not L), which is the distance from the Takahashi's residence, measured counter-clockwise.\n\nThere 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.\n\nStarting at his residence, Takahashi will repeat the following action:\n\nIf all trees are burnt, terminate the process.\n\nSpecify a direction: clockwise or counter-clockwise.\n\nWalk around the lake in the specified direction, until the coordinate of a tree that is not yet burnt is reached for the first time.\n\nWhen the coordinate with the tree is reached, burn that tree, stay at the position and go back to the first step.\n\nFind the longest possible total distance Takahashi walks during the process.\n\nPartial Score\n\nA partial score can be obtained in this problem:\n\n300 points will be awarded for passing the input satisfying N \\leq 2000.\n\nConstraints\n\n2 \\leq L \\leq 10^9\n\n1 \\leq N \\leq 2\\times 10^5\n\n1 \\leq X_1 < ... < X_N \\leq L-1\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nL N\nX_1\n:\nX_N\n\nOutput\n\nPrint the longest possible total distance Takahashi walks during the process.\n\nSample Input 1\n\n10 3\n2\n7\n9\n\nSample Output 1\n\n15\n\nTakahashi walks the distance of 15 if the process goes as follows:\n\nWalk a distance of 2 counter-clockwise, burn the tree at the coordinate 2 and stay there.\n\nWalk a distance of 5 counter-clockwise, burn the tree at the coordinate 7 and stay there.\n\nWalk a distance of 8 clockwise, burn the tree at the coordinate 9 and stay there.\n\nSample Input 2\n\n10 6\n1\n2\n3\n6\n7\n9\n\nSample Output 2\n\n27\n\nSample Input 3\n\n314159265 7\n21662711\n77271666\n89022761\n156626166\n160332356\n166902656\n298992265\n\nSample Output 3\n\n1204124749", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1178, "cpu_time_ms": 2103, "memory_kb": 3200}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s030199906", "group_id": "codeNet:p03192", "input_text": "local n = io.read(\"*n\")\nlocal cnt = 0\nwhile 0 < n do\n if n % 10 == 2 then cnt = cnt + 1 end\n n = n // 10\nend\nprint(cnt)\n", "language": "Lua", "metadata": {"date": 1565912186, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03192.html", "problem_id": "p03192", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03192/input.txt", "sample_output_relpath": "derived/input_output/data/p03192/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03192/Lua/s030199906.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s030199906", "user_id": "u120582723"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "local n = io.read(\"*n\")\nlocal cnt = 0\nwhile 0 < n do\n if n % 10 == 2 then cnt = cnt + 1 end\n n = n // 10\nend\nprint(cnt)\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nYou are given an integer N that has exactly four digits in base ten.\nHow many times does 2 occur in the base-ten representation of N?\n\nConstraints\n\n1000 \\leq N \\leq 9999\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n1222\n\nSample Output 1\n\n3\n\n2 occurs three times in 1222. By the way, this contest is held on December 22 (JST).\n\nSample Input 2\n\n3456\n\nSample Output 2\n\n0\n\nSample Input 3\n\n9592\n\nSample Output 3\n\n1", "sample_input": "1222\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03192", "source_text": "Score : 100 points\n\nProblem Statement\n\nYou are given an integer N that has exactly four digits in base ten.\nHow many times does 2 occur in the base-ten representation of N?\n\nConstraints\n\n1000 \\leq N \\leq 9999\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n1222\n\nSample Output 1\n\n3\n\n2 occurs three times in 1222. By the way, this contest is held on December 22 (JST).\n\nSample Input 2\n\n3456\n\nSample Output 2\n\n0\n\nSample Input 3\n\n9592\n\nSample Output 3\n\n1", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 122, "cpu_time_ms": 8, "memory_kb": 888}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s674492751", "group_id": "codeNet:p03193", "input_text": "local n = io.read(\"*n\")\nlocal a, b = io.read(\"*n\", \"*n\")\nlocal cnt = 0\nfor i = 1, n do\n local x, y = io.read(\"*n\", \"*n\")\n if a <= x and b <= y then cnt = cnt + 1 end\nend\nprint(cnt)\n", "language": "Lua", "metadata": {"date": 1565912126, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p03193.html", "problem_id": "p03193", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03193/input.txt", "sample_output_relpath": "derived/input_output/data/p03193/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03193/Lua/s674492751.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s674492751", "user_id": "u120582723"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "local n = io.read(\"*n\")\nlocal a, b = io.read(\"*n\", \"*n\")\nlocal cnt = 0\nfor i = 1, n do\n local x, y = io.read(\"*n\", \"*n\")\n if a <= x and b <= y then cnt = cnt + 1 end\nend\nprint(cnt)\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nThere are N rectangular plate materials made of special metal called AtCoder Alloy.\nThe dimensions of the i-th material are A_i \\times B_i (A_i vertically and B_i horizontally).\n\nTakahashi wants a rectangular plate made of AtCoder Alloy whose dimensions are exactly H \\times W.\nHe is trying to obtain such a plate by choosing one of the N materials and cutting it if necessary.\nWhen cutting a material, the cuts must be parallel to one of the sides of the material.\nAlso, the materials have fixed directions and cannot be rotated.\nFor example, a 5 \\times 3 material cannot be used as a 3 \\times 5 plate.\n\nOut of the N materials, how many can produce an H \\times W plate if properly cut?\n\nConstraints\n\n1 \\leq N \\leq 1000\n\n1 \\leq H \\leq 10^9\n\n1 \\leq W \\leq 10^9\n\n1 \\leq A_i \\leq 10^9\n\n1 \\leq B_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN H W\nA_1 B_1\nA_2 B_2\n:\nA_N B_N\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n3 5 2\n10 3\n5 2\n2 5\n\nSample Output 1\n\n2\n\nTakahashi wants a 5 \\times 2 plate.\n\nThe dimensions of the first material are 10 \\times 3. We can obtain a 5 \\times 2 plate by properly cutting it.\n\nThe dimensions of the second material are 5 \\times 2. We can obtain a 5 \\times 2 plate without cutting it.\n\nThe dimensions of the third material are 2 \\times 5. We cannot obtain a 5 \\times 2 plate, whatever cuts are made. Note that the material cannot be rotated and used as a 5 \\times 2 plate.\n\nSample Input 2\n\n10 587586158 185430194\n894597290 708587790\n680395892 306946994\n590262034 785368612\n922328576 106880540\n847058850 326169610\n936315062 193149191\n702035777 223363392\n11672949 146832978\n779291680 334178158\n615808191 701464268\n\nSample Output 2\n\n8", "sample_input": "3 5 2\n10 3\n5 2\n2 5\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03193", "source_text": "Score : 200 points\n\nProblem Statement\n\nThere are N rectangular plate materials made of special metal called AtCoder Alloy.\nThe dimensions of the i-th material are A_i \\times B_i (A_i vertically and B_i horizontally).\n\nTakahashi wants a rectangular plate made of AtCoder Alloy whose dimensions are exactly H \\times W.\nHe is trying to obtain such a plate by choosing one of the N materials and cutting it if necessary.\nWhen cutting a material, the cuts must be parallel to one of the sides of the material.\nAlso, the materials have fixed directions and cannot be rotated.\nFor example, a 5 \\times 3 material cannot be used as a 3 \\times 5 plate.\n\nOut of the N materials, how many can produce an H \\times W plate if properly cut?\n\nConstraints\n\n1 \\leq N \\leq 1000\n\n1 \\leq H \\leq 10^9\n\n1 \\leq W \\leq 10^9\n\n1 \\leq A_i \\leq 10^9\n\n1 \\leq B_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN H W\nA_1 B_1\nA_2 B_2\n:\nA_N B_N\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n3 5 2\n10 3\n5 2\n2 5\n\nSample Output 1\n\n2\n\nTakahashi wants a 5 \\times 2 plate.\n\nThe dimensions of the first material are 10 \\times 3. We can obtain a 5 \\times 2 plate by properly cutting it.\n\nThe dimensions of the second material are 5 \\times 2. We can obtain a 5 \\times 2 plate without cutting it.\n\nThe dimensions of the third material are 2 \\times 5. We cannot obtain a 5 \\times 2 plate, whatever cuts are made. Note that the material cannot be rotated and used as a 5 \\times 2 plate.\n\nSample Input 2\n\n10 587586158 185430194\n894597290 708587790\n680395892 306946994\n590262034 785368612\n922328576 106880540\n847058850 326169610\n936315062 193149191\n702035777 223363392\n11672949 146832978\n779291680 334178158\n615808191 701464268\n\nSample Output 2\n\n8", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 183, "cpu_time_ms": 2, "memory_kb": 256}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s860508003", "group_id": "codeNet:p03194", "input_text": "N, P = io.read(\"*n\",\"*n\")\nio.read()\n\ni = 2\na = 1\n\nwhile i^N <= P do\n v = i^N\n while P % v ==0 do\n P = P // v\n a = a * i\n end\n \n i = i + 1\nend\n\nprint(a)\n", "language": "Lua", "metadata": {"date": 1545535487, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03194.html", "problem_id": "p03194", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03194/input.txt", "sample_output_relpath": "derived/input_output/data/p03194/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03194/Lua/s860508003.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s860508003", "user_id": "u374892957"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "N, P = io.read(\"*n\",\"*n\")\nio.read()\n\ni = 2\na = 1\n\nwhile i^N <= P do\n v = i^N\n while P % v ==0 do\n P = P // v\n a = a * i\n end\n \n i = i + 1\nend\n\nprint(a)\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere are N integers a_1, a_2, ..., a_N not less than 1.\nThe values of a_1, a_2, ..., a_N are not known, but it is known that a_1 \\times a_2 \\times ... \\times a_N = P.\n\nFind the maximum possible greatest common divisor of a_1, a_2, ..., a_N.\n\nConstraints\n\n1 \\leq N \\leq 10^{12}\n\n1 \\leq P \\leq 10^{12}\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN P\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n3 24\n\nSample Output 1\n\n2\n\nThe greatest common divisor would be 2 when, for example, a_1=2, a_2=6 and a_3=2.\n\nSample Input 2\n\n5 1\n\nSample Output 2\n\n1\n\nAs a_i are positive integers, the only possible case is a_1 = a_2 = a_3 = a_4 = a_5 = 1.\n\nSample Input 3\n\n1 111\n\nSample Output 3\n\n111\n\nSample Input 4\n\n4 972439611840\n\nSample Output 4\n\n206", "sample_input": "3 24\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03194", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere are N integers a_1, a_2, ..., a_N not less than 1.\nThe values of a_1, a_2, ..., a_N are not known, but it is known that a_1 \\times a_2 \\times ... \\times a_N = P.\n\nFind the maximum possible greatest common divisor of a_1, a_2, ..., a_N.\n\nConstraints\n\n1 \\leq N \\leq 10^{12}\n\n1 \\leq P \\leq 10^{12}\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN P\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n3 24\n\nSample Output 1\n\n2\n\nThe greatest common divisor would be 2 when, for example, a_1=2, a_2=6 and a_3=2.\n\nSample Input 2\n\n5 1\n\nSample Output 2\n\n1\n\nAs a_i are positive integers, the only possible case is a_1 = a_2 = a_3 = a_4 = a_5 = 1.\n\nSample Input 3\n\n1 111\n\nSample Output 3\n\n111\n\nSample Input 4\n\n4 972439611840\n\nSample Output 4\n\n206", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 163, "cpu_time_ms": 2103, "memory_kb": 760}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s163935982", "group_id": "codeNet:p03196", "input_text": "local mce, mfl, msq, mmi, mma, mab = math.ceil, math.floor, math.sqrt, math.min, math.max, math.abs\n\nlocal function getprimes(x)\n local primes = {}\n local allnums = {}\n for i = 1, x do allnums[i] = true end\n for i = 2, x do\n if allnums[i] then\n table.insert(primes, i)\n local lim = mfl(x / i)\n for j = 2, lim do\n allnums[j * i] = false\n end\n end\n end\n return primes\nend\n\nlocal function getdivisorparts(x, primes)\n local prime_num = #primes\n local tmp = {}\n local lim = mce(msq(x))\n local primepos = 1\n local dv = primes[primepos]\n while primepos <= prime_num and dv <= lim do\n if x % dv == 0 then\n local t = {}\n t.p = dv\n t.cnt = 1\n x = mfl(x / dv)\n while x % dv == 0 do\n x = mfl(x / dv)\n t.cnt = t.cnt + 1\n end\n table.insert(tmp, t)\n lim = mce(msq(x))\n end\n if primepos == prime_num then break end\n primepos = primepos + 1\n dv = primes[primepos]\n end\n if x ~= 1 then\n local t = {}\n t.p, t.cnt = x, 1\n table.insert(tmp, t)\n end\n return tmp\nend\n\nlocal n, p = io.read(\"*n\", \"*n\")\nlocal primes = getprimes(1000000)\nlocal dvp = getdivisorparts(p, primes)\nlocal ret = 1\nfor id = 1, #dvp do\n local v, cnt = dvp[id].p, dvp[id].cnt\n local z = cnt // n\n for i = 1, z do\n ret = ret * v\n end\nend\nprint(ret)\n", "language": "Lua", "metadata": {"date": 1595707882, "filename_ext": "lua", "original_language": "Lua (Lua 5.3.5)", "problem_description_relpath": "problem_descriptions/p03196.html", "problem_id": "p03196", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03196/input.txt", "sample_output_relpath": "derived/input_output/data/p03196/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03196/Lua/s163935982.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s163935982", "user_id": "u120582723"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "local mce, mfl, msq, mmi, mma, mab = math.ceil, math.floor, math.sqrt, math.min, math.max, math.abs\n\nlocal function getprimes(x)\n local primes = {}\n local allnums = {}\n for i = 1, x do allnums[i] = true end\n for i = 2, x do\n if allnums[i] then\n table.insert(primes, i)\n local lim = mfl(x / i)\n for j = 2, lim do\n allnums[j * i] = false\n end\n end\n end\n return primes\nend\n\nlocal function getdivisorparts(x, primes)\n local prime_num = #primes\n local tmp = {}\n local lim = mce(msq(x))\n local primepos = 1\n local dv = primes[primepos]\n while primepos <= prime_num and dv <= lim do\n if x % dv == 0 then\n local t = {}\n t.p = dv\n t.cnt = 1\n x = mfl(x / dv)\n while x % dv == 0 do\n x = mfl(x / dv)\n t.cnt = t.cnt + 1\n end\n table.insert(tmp, t)\n lim = mce(msq(x))\n end\n if primepos == prime_num then break end\n primepos = primepos + 1\n dv = primes[primepos]\n end\n if x ~= 1 then\n local t = {}\n t.p, t.cnt = x, 1\n table.insert(tmp, t)\n end\n return tmp\nend\n\nlocal n, p = io.read(\"*n\", \"*n\")\nlocal primes = getprimes(1000000)\nlocal dvp = getdivisorparts(p, primes)\nlocal ret = 1\nfor id = 1, #dvp do\n local v, cnt = dvp[id].p, dvp[id].cnt\n local z = cnt // n\n for i = 1, z do\n ret = ret * v\n end\nend\nprint(ret)\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere are N integers a_1, a_2, ..., a_N not less than 1.\nThe values of a_1, a_2, ..., a_N are not known, but it is known that a_1 \\times a_2 \\times ... \\times a_N = P.\n\nFind the maximum possible greatest common divisor of a_1, a_2, ..., a_N.\n\nConstraints\n\n1 \\leq N \\leq 10^{12}\n\n1 \\leq P \\leq 10^{12}\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN P\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n3 24\n\nSample Output 1\n\n2\n\nThe greatest common divisor would be 2 when, for example, a_1=2, a_2=6 and a_3=2.\n\nSample Input 2\n\n5 1\n\nSample Output 2\n\n1\n\nAs a_i are positive integers, the only possible case is a_1 = a_2 = a_3 = a_4 = a_5 = 1.\n\nSample Input 3\n\n1 111\n\nSample Output 3\n\n111\n\nSample Input 4\n\n4 972439611840\n\nSample Output 4\n\n206", "sample_input": "3 24\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03196", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere are N integers a_1, a_2, ..., a_N not less than 1.\nThe values of a_1, a_2, ..., a_N are not known, but it is known that a_1 \\times a_2 \\times ... \\times a_N = P.\n\nFind the maximum possible greatest common divisor of a_1, a_2, ..., a_N.\n\nConstraints\n\n1 \\leq N \\leq 10^{12}\n\n1 \\leq P \\leq 10^{12}\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN P\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n3 24\n\nSample Output 1\n\n2\n\nThe greatest common divisor would be 2 when, for example, a_1=2, a_2=6 and a_3=2.\n\nSample Input 2\n\n5 1\n\nSample Output 2\n\n1\n\nAs a_i are positive integers, the only possible case is a_1 = a_2 = a_3 = a_4 = a_5 = 1.\n\nSample Input 3\n\n1 111\n\nSample Output 3\n\n111\n\nSample Input 4\n\n4 972439611840\n\nSample Output 4\n\n206", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1330, "cpu_time_ms": 138, "memory_kb": 20664}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s880952533", "group_id": "codeNet:p03200", "input_text": "local white=0\nlocal counter=0\nfor i,_ in io.read():gmatch(\"B*W\") do\n white=white+#i-1\n counter=counter+white\nend\nprint(counter)", "language": "Lua", "metadata": {"date": 1589681021, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p03200.html", "problem_id": "p03200", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03200/input.txt", "sample_output_relpath": "derived/input_output/data/p03200/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03200/Lua/s880952533.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s880952533", "user_id": "u045238009"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "local white=0\nlocal counter=0\nfor i,_ in io.read():gmatch(\"B*W\") do\n white=white+#i-1\n counter=counter+white\nend\nprint(counter)", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere are N Reversi pieces arranged in a row. (A Reversi piece is a disc with a black side and a white side.)\nThe state of each piece is represented by a string S of length N.\nIf S_i=B, the i-th piece from the left is showing black;\nIf S_i=W, the i-th piece from the left is showing white.\n\nConsider performing the following operation:\n\nChoose i (1 \\leq i < N) such that the i-th piece from the left is showing black and the (i+1)-th piece from the left is showing white, then flip both of those pieces. That is, the i-th piece from the left is now showing white and the (i+1)-th piece from the left is now showing black.\n\nFind the maximum possible number of times this operation can be performed.\n\nConstraints\n\n1 \\leq |S| \\leq 2\\times 10^5\n\nS_i=B or W\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the maximum possible number of times the operation can be performed.\n\nSample Input 1\n\nBBW\n\nSample Output 1\n\n2\n\nThe operation can be performed twice, as follows:\n\nFlip the second and third pieces from the left.\n\nFlip the first and second pieces from the left.\n\nSample Input 2\n\nBWBWBW\n\nSample Output 2\n\n6", "sample_input": "BBW\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03200", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere are N Reversi pieces arranged in a row. (A Reversi piece is a disc with a black side and a white side.)\nThe state of each piece is represented by a string S of length N.\nIf S_i=B, the i-th piece from the left is showing black;\nIf S_i=W, the i-th piece from the left is showing white.\n\nConsider performing the following operation:\n\nChoose i (1 \\leq i < N) such that the i-th piece from the left is showing black and the (i+1)-th piece from the left is showing white, then flip both of those pieces. That is, the i-th piece from the left is now showing white and the (i+1)-th piece from the left is now showing black.\n\nFind the maximum possible number of times this operation can be performed.\n\nConstraints\n\n1 \\leq |S| \\leq 2\\times 10^5\n\nS_i=B or W\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the maximum possible number of times the operation can be performed.\n\nSample Input 1\n\nBBW\n\nSample Output 1\n\n2\n\nThe operation can be performed twice, as follows:\n\nFlip the second and third pieces from the left.\n\nFlip the first and second pieces from the left.\n\nSample Input 2\n\nBWBWBW\n\nSample Output 2\n\n6", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 133, "cpu_time_ms": 2103, "memory_kb": 768}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s151275576", "group_id": "codeNet:p03201", "input_text": "local n=io.read(\"n\")\nlocal a,a_map={},{}\nfor i=1,n do\n local x=io.read(\"n\")\n a[i]=x\n a_map[x]=(a_map[x] or 0)+1\nend\ntable.sort(a)\n\nlocal counter=0\nfor i=n,2,-1 do\n local p=1\n while a[i]>=p do\n p=p*2\n end\n if a_map[a[i]] and a_map[a[i]]>0 then\n a_map[a[i]]=a_map[a[i]]-1\n if a_map[p-a[i]] and a_map[p-a[i]]>0 then\n a_map[p-a[i]]=a_map[p-a[i]]-1\n counter=counter+1\n end\n end\nend\nprint(counter)", "language": "Lua", "metadata": {"date": 1591807442, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03201.html", "problem_id": "p03201", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03201/input.txt", "sample_output_relpath": "derived/input_output/data/p03201/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03201/Lua/s151275576.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s151275576", "user_id": "u045238009"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "local n=io.read(\"n\")\nlocal a,a_map={},{}\nfor i=1,n do\n local x=io.read(\"n\")\n a[i]=x\n a_map[x]=(a_map[x] or 0)+1\nend\ntable.sort(a)\n\nlocal counter=0\nfor i=n,2,-1 do\n local p=1\n while a[i]>=p do\n p=p*2\n end\n if a_map[a[i]] and a_map[a[i]]>0 then\n a_map[a[i]]=a_map[a[i]]-1\n if a_map[p-a[i]] and a_map[p-a[i]]>0 then\n a_map[p-a[i]]=a_map[p-a[i]]-1\n counter=counter+1\n end\n end\nend\nprint(counter)", "problem_context": "Score : 600 points\n\nProblem Statement\n\nTakahashi has N balls with positive integers written on them. The integer written on the i-th ball is A_i.\nHe would like to form some number of pairs such that the sum of the integers written on each pair of balls is a power of 2.\nNote that a ball cannot belong to multiple pairs.\nFind the maximum possible number of pairs that can be formed.\n\nHere, a positive integer is said to be a power of 2 when it can be written as 2^t using some non-negative integer t.\n\nConstraints\n\n1 \\leq N \\leq 2\\times 10^5\n\n1 \\leq A_i \\leq 10^9\n\nA_i is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the maximum possible number of pairs such that the sum of the integers written on each pair of balls is a power of 2.\n\nSample Input 1\n\n3\n1 2 3\n\nSample Output 1\n\n1\n\nWe can form one pair whose sum of the written numbers is 4 by pairing the first and third balls.\nNote that we cannot pair the second ball with itself.\n\nSample Input 2\n\n5\n3 11 14 5 13\n\nSample Output 2\n\n2", "sample_input": "3\n1 2 3\n"}, "reference_outputs": ["1\n"], "source_document_id": "p03201", "source_text": "Score : 600 points\n\nProblem Statement\n\nTakahashi has N balls with positive integers written on them. The integer written on the i-th ball is A_i.\nHe would like to form some number of pairs such that the sum of the integers written on each pair of balls is a power of 2.\nNote that a ball cannot belong to multiple pairs.\nFind the maximum possible number of pairs that can be formed.\n\nHere, a positive integer is said to be a power of 2 when it can be written as 2^t using some non-negative integer t.\n\nConstraints\n\n1 \\leq N \\leq 2\\times 10^5\n\n1 \\leq A_i \\leq 10^9\n\nA_i is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the maximum possible number of pairs such that the sum of the integers written on each pair of balls is a power of 2.\n\nSample Input 1\n\n3\n1 2 3\n\nSample Output 1\n\n1\n\nWe can form one pair whose sum of the written numbers is 4 by pairing the first and third balls.\nNote that we cannot pair the second ball with itself.\n\nSample Input 2\n\n5\n3 11 14 5 13\n\nSample Output 2\n\n2", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 465, "cpu_time_ms": 440, "memory_kb": 17500}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s878505044", "group_id": "codeNet:p03201", "input_text": "local N = io.read(\"n\")\nlocal A = {}\nlocal S = {}\nfor i=1,N do\n local n = io.read(\"n\")\n A[i] = n\n if not S[n] then\n S[n] = 0\n end\n S[n] = S[n] + 1\nend\ntable.sort(A)\n\nlocal function target(r)\n local r2 = r + 1\n local t = 2\n while t < r2 do\n t = t * 2\n end\n return t, t - r\nend\n\nlocal ans = 0\nfor i=N,1,-1 do\n local r = A[i]\n local t, c = target(r)\n local hit = false\n if S[c] then\n if r ~= c and S[r] > 0 and S[c] > 0 then\n ans = ans + 1\n S[r] = S[r] - 1\n S[c] = S[c] - 1\n hit = true\n elseif S[c] > 1 then\n ans = ans + 1\n S[c] = S[c] - 2\n hit = true\n end\n end\n --print(r, t, c, hit)\nend\nprint(ans)", "language": "Lua", "metadata": {"date": 1552632456, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03201.html", "problem_id": "p03201", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03201/input.txt", "sample_output_relpath": "derived/input_output/data/p03201/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03201/Lua/s878505044.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s878505044", "user_id": "u162773977"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "local N = io.read(\"n\")\nlocal A = {}\nlocal S = {}\nfor i=1,N do\n local n = io.read(\"n\")\n A[i] = n\n if not S[n] then\n S[n] = 0\n end\n S[n] = S[n] + 1\nend\ntable.sort(A)\n\nlocal function target(r)\n local r2 = r + 1\n local t = 2\n while t < r2 do\n t = t * 2\n end\n return t, t - r\nend\n\nlocal ans = 0\nfor i=N,1,-1 do\n local r = A[i]\n local t, c = target(r)\n local hit = false\n if S[c] then\n if r ~= c and S[r] > 0 and S[c] > 0 then\n ans = ans + 1\n S[r] = S[r] - 1\n S[c] = S[c] - 1\n hit = true\n elseif S[c] > 1 then\n ans = ans + 1\n S[c] = S[c] - 2\n hit = true\n end\n end\n --print(r, t, c, hit)\nend\nprint(ans)", "problem_context": "Score : 600 points\n\nProblem Statement\n\nTakahashi has N balls with positive integers written on them. The integer written on the i-th ball is A_i.\nHe would like to form some number of pairs such that the sum of the integers written on each pair of balls is a power of 2.\nNote that a ball cannot belong to multiple pairs.\nFind the maximum possible number of pairs that can be formed.\n\nHere, a positive integer is said to be a power of 2 when it can be written as 2^t using some non-negative integer t.\n\nConstraints\n\n1 \\leq N \\leq 2\\times 10^5\n\n1 \\leq A_i \\leq 10^9\n\nA_i is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the maximum possible number of pairs such that the sum of the integers written on each pair of balls is a power of 2.\n\nSample Input 1\n\n3\n1 2 3\n\nSample Output 1\n\n1\n\nWe can form one pair whose sum of the written numbers is 4 by pairing the first and third balls.\nNote that we cannot pair the second ball with itself.\n\nSample Input 2\n\n5\n3 11 14 5 13\n\nSample Output 2\n\n2", "sample_input": "3\n1 2 3\n"}, "reference_outputs": ["1\n"], "source_document_id": "p03201", "source_text": "Score : 600 points\n\nProblem Statement\n\nTakahashi has N balls with positive integers written on them. The integer written on the i-th ball is A_i.\nHe would like to form some number of pairs such that the sum of the integers written on each pair of balls is a power of 2.\nNote that a ball cannot belong to multiple pairs.\nFind the maximum possible number of pairs that can be formed.\n\nHere, a positive integer is said to be a power of 2 when it can be written as 2^t using some non-negative integer t.\n\nConstraints\n\n1 \\leq N \\leq 2\\times 10^5\n\n1 \\leq A_i \\leq 10^9\n\nA_i is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the maximum possible number of pairs such that the sum of the integers written on each pair of balls is a power of 2.\n\nSample Input 1\n\n3\n1 2 3\n\nSample Output 1\n\n1\n\nWe can form one pair whose sum of the written numbers is 4 by pairing the first and third balls.\nNote that we cannot pair the second ball with itself.\n\nSample Input 2\n\n5\n3 11 14 5 13\n\nSample Output 2\n\n2", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 755, "cpu_time_ms": 392, "memory_kb": 17500}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s483429420", "group_id": "codeNet:p03207", "input_text": "print((function (fh)\n\tlocal r,m = 0,0\n\tfor _=1,fh:read(\"*n\") do\n\t\tlocal t=fh:read(\"*n\")\n\t\tr,m = r+t,mmaxp then\n maxp = p[i]\n end\nend\nprint(sum-maxp//2)\n\n", "language": "Lua", "metadata": {"date": 1544398178, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03207.html", "problem_id": "p03207", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03207/input.txt", "sample_output_relpath": "derived/input_output/data/p03207/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03207/Lua/s763776786.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s763776786", "user_id": "u030685402"}, "prompt_components": {"gold_output": "15950\n", "input_to_evaluate": "local n = tonumber(io.read())\nlocal p = {}\nlocal maxp = 0\nlocal sum = 0\nfor i=1,n,1 do\n p[i] = tonumber(io.read())\n sum = sum + p[i]\n if p[i]>maxp then\n maxp = p[i]\n end\nend\nprint(sum-maxp//2)\n\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nIn some other world, today is the day before Christmas Eve.\n\nMr. Takaha is buying N items at a department store. The regular price of the i-th item (1 \\leq i \\leq N) is p_i yen (the currency of Japan).\n\nHe has a discount coupon, and can buy one item with the highest price for half the regular price. The remaining N-1 items cost their regular prices. What is the total amount he will pay?\n\nConstraints\n\n2 \\leq N \\leq 10\n\n100 \\leq p_i \\leq 10000\n\np_i is an even number.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\np_1\np_2\n:\np_N\n\nOutput\n\nPrint the total amount Mr. Takaha will pay.\n\nSample Input 1\n\n3\n4980\n7980\n6980\n\nSample Output 1\n\n15950\n\nThe 7980-yen item gets the discount and the total is 4980 + 7980 / 2 + 6980 = 15950 yen.\n\nNote that outputs such as 15950.0 will be judged as Wrong Answer.\n\nSample Input 2\n\n4\n4320\n4320\n4320\n4320\n\nSample Output 2\n\n15120\n\nOnly one of the four items gets the discount and the total is 4320 / 2 + 4320 + 4320 + 4320 = 15120 yen.", "sample_input": "3\n4980\n7980\n6980\n"}, "reference_outputs": ["15950\n"], "source_document_id": "p03207", "source_text": "Score : 200 points\n\nProblem Statement\n\nIn some other world, today is the day before Christmas Eve.\n\nMr. Takaha is buying N items at a department store. The regular price of the i-th item (1 \\leq i \\leq N) is p_i yen (the currency of Japan).\n\nHe has a discount coupon, and can buy one item with the highest price for half the regular price. The remaining N-1 items cost their regular prices. What is the total amount he will pay?\n\nConstraints\n\n2 \\leq N \\leq 10\n\n100 \\leq p_i \\leq 10000\n\np_i is an even number.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\np_1\np_2\n:\np_N\n\nOutput\n\nPrint the total amount Mr. Takaha will pay.\n\nSample Input 1\n\n3\n4980\n7980\n6980\n\nSample Output 1\n\n15950\n\nThe 7980-yen item gets the discount and the total is 4980 + 7980 / 2 + 6980 = 15950 yen.\n\nNote that outputs such as 15950.0 will be judged as Wrong Answer.\n\nSample Input 2\n\n4\n4320\n4320\n4320\n4320\n\nSample Output 2\n\n15120\n\nOnly one of the four items gets the discount and the total is 4320 / 2 + 4320 + 4320 + 4320 = 15120 yen.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 201, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s005383582", "group_id": "codeNet:p03208", "input_text": "n,k=io.read(\"*n\",\"*n\",\"*l\")\nh={}\nfor i=1,n do\n h[i]=io.read(\"*n\")\nend\ntable.sort(h)\n\nminth=10^9+1\nfor i=1,n-k+1 do\n minth=math.min(minth,h[i+k-1]-h[i])\nend\nprint(minth)", "language": "Lua", "metadata": {"date": 1587778216, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03208.html", "problem_id": "p03208", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03208/input.txt", "sample_output_relpath": "derived/input_output/data/p03208/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03208/Lua/s005383582.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s005383582", "user_id": "u045238009"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "n,k=io.read(\"*n\",\"*n\",\"*l\")\nh={}\nfor i=1,n do\n h[i]=io.read(\"*n\")\nend\ntable.sort(h)\n\nminth=10^9+1\nfor i=1,n-k+1 do\n minth=math.min(minth,h[i+k-1]-h[i])\nend\nprint(minth)", "problem_context": "Score : 300 points\n\nProblem Statement\n\nIn some other world, today is Christmas Eve.\n\nThere are N trees planted in Mr. Takaha's garden. The height of the i-th tree (1 \\leq i \\leq N) is h_i meters.\n\nHe decides to choose K trees from these trees and decorate them with electric lights. To make the scenery more beautiful, the heights of the decorated trees should be as close to each other as possible.\n\nMore specifically, let the height of the tallest decorated tree be h_{max} meters, and the height of the shortest decorated tree be h_{min} meters. The smaller the value h_{max} - h_{min} is, the better. What is the minimum possible value of h_{max} - h_{min}?\n\nConstraints\n\n2 \\leq K < N \\leq 10^5\n\n1 \\leq h_i \\leq 10^9\n\nh_i is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nh_1\nh_2\n:\nh_N\n\nOutput\n\nPrint the minimum possible value of h_{max} - h_{min}.\n\nSample Input 1\n\n5 3\n10\n15\n11\n14\n12\n\nSample Output 1\n\n2\n\nIf we decorate the first, third and fifth trees, h_{max} = 12, h_{min} = 10 so h_{max} - h_{min} = 2. This is optimal.\n\nSample Input 2\n\n5 3\n5\n7\n5\n7\n7\n\nSample Output 2\n\n0\n\nIf we decorate the second, fourth and fifth trees, h_{max} = 7, h_{min} = 7 so h_{max} - h_{min} = 0. This is optimal.\n\nThere are not too many trees in these sample inputs, but note that there can be at most one hundred thousand trees (we just can't put a sample with a hundred thousand lines here).", "sample_input": "5 3\n10\n15\n11\n14\n12\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03208", "source_text": "Score : 300 points\n\nProblem Statement\n\nIn some other world, today is Christmas Eve.\n\nThere are N trees planted in Mr. Takaha's garden. The height of the i-th tree (1 \\leq i \\leq N) is h_i meters.\n\nHe decides to choose K trees from these trees and decorate them with electric lights. To make the scenery more beautiful, the heights of the decorated trees should be as close to each other as possible.\n\nMore specifically, let the height of the tallest decorated tree be h_{max} meters, and the height of the shortest decorated tree be h_{min} meters. The smaller the value h_{max} - h_{min} is, the better. What is the minimum possible value of h_{max} - h_{min}?\n\nConstraints\n\n2 \\leq K < N \\leq 10^5\n\n1 \\leq h_i \\leq 10^9\n\nh_i is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nh_1\nh_2\n:\nh_N\n\nOutput\n\nPrint the minimum possible value of h_{max} - h_{min}.\n\nSample Input 1\n\n5 3\n10\n15\n11\n14\n12\n\nSample Output 1\n\n2\n\nIf we decorate the first, third and fifth trees, h_{max} = 12, h_{min} = 10 so h_{max} - h_{min} = 2. This is optimal.\n\nSample Input 2\n\n5 3\n5\n7\n5\n7\n7\n\nSample Output 2\n\n0\n\nIf we decorate the second, fourth and fifth trees, h_{max} = 7, h_{min} = 7 so h_{max} - h_{min} = 0. This is optimal.\n\nThere are not too many trees in these sample inputs, but note that there can be at most one hundred thousand trees (we just can't put a sample with a hundred thousand lines here).", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 174, "cpu_time_ms": 110, "memory_kb": 2424}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s749822844", "group_id": "codeNet:p03208", "input_text": "n=io.read(\"n\")\nk=io.read(\"n\")\nh={}\nfor i=1,n do \n h[i]=io.read(\"n\")\nend\ntable.sort(h)\nt={}\nfor i=1,n-k+1 do\n t[i]=h[k]-h[i]\n k=k+1\nend\ntable.sort(t)\nprint(t[1])\n \n", "language": "Lua", "metadata": {"date": 1548981825, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03208.html", "problem_id": "p03208", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03208/input.txt", "sample_output_relpath": "derived/input_output/data/p03208/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03208/Lua/s749822844.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s749822844", "user_id": "u015229643"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "n=io.read(\"n\")\nk=io.read(\"n\")\nh={}\nfor i=1,n do \n h[i]=io.read(\"n\")\nend\ntable.sort(h)\nt={}\nfor i=1,n-k+1 do\n t[i]=h[k]-h[i]\n k=k+1\nend\ntable.sort(t)\nprint(t[1])\n \n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nIn some other world, today is Christmas Eve.\n\nThere are N trees planted in Mr. Takaha's garden. The height of the i-th tree (1 \\leq i \\leq N) is h_i meters.\n\nHe decides to choose K trees from these trees and decorate them with electric lights. To make the scenery more beautiful, the heights of the decorated trees should be as close to each other as possible.\n\nMore specifically, let the height of the tallest decorated tree be h_{max} meters, and the height of the shortest decorated tree be h_{min} meters. The smaller the value h_{max} - h_{min} is, the better. What is the minimum possible value of h_{max} - h_{min}?\n\nConstraints\n\n2 \\leq K < N \\leq 10^5\n\n1 \\leq h_i \\leq 10^9\n\nh_i is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nh_1\nh_2\n:\nh_N\n\nOutput\n\nPrint the minimum possible value of h_{max} - h_{min}.\n\nSample Input 1\n\n5 3\n10\n15\n11\n14\n12\n\nSample Output 1\n\n2\n\nIf we decorate the first, third and fifth trees, h_{max} = 12, h_{min} = 10 so h_{max} - h_{min} = 2. This is optimal.\n\nSample Input 2\n\n5 3\n5\n7\n5\n7\n7\n\nSample Output 2\n\n0\n\nIf we decorate the second, fourth and fifth trees, h_{max} = 7, h_{min} = 7 so h_{max} - h_{min} = 0. This is optimal.\n\nThere are not too many trees in these sample inputs, but note that there can be at most one hundred thousand trees (we just can't put a sample with a hundred thousand lines here).", "sample_input": "5 3\n10\n15\n11\n14\n12\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03208", "source_text": "Score : 300 points\n\nProblem Statement\n\nIn some other world, today is Christmas Eve.\n\nThere are N trees planted in Mr. Takaha's garden. The height of the i-th tree (1 \\leq i \\leq N) is h_i meters.\n\nHe decides to choose K trees from these trees and decorate them with electric lights. To make the scenery more beautiful, the heights of the decorated trees should be as close to each other as possible.\n\nMore specifically, let the height of the tallest decorated tree be h_{max} meters, and the height of the shortest decorated tree be h_{min} meters. The smaller the value h_{max} - h_{min} is, the better. What is the minimum possible value of h_{max} - h_{min}?\n\nConstraints\n\n2 \\leq K < N \\leq 10^5\n\n1 \\leq h_i \\leq 10^9\n\nh_i is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nh_1\nh_2\n:\nh_N\n\nOutput\n\nPrint the minimum possible value of h_{max} - h_{min}.\n\nSample Input 1\n\n5 3\n10\n15\n11\n14\n12\n\nSample Output 1\n\n2\n\nIf we decorate the first, third and fifth trees, h_{max} = 12, h_{min} = 10 so h_{max} - h_{min} = 2. This is optimal.\n\nSample Input 2\n\n5 3\n5\n7\n5\n7\n7\n\nSample Output 2\n\n0\n\nIf we decorate the second, fourth and fifth trees, h_{max} = 7, h_{min} = 7 so h_{max} - h_{min} = 0. This is optimal.\n\nThere are not too many trees in these sample inputs, but note that there can be at most one hundred thousand trees (we just can't put a sample with a hundred thousand lines here).", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 167, "cpu_time_ms": 169, "memory_kb": 4472}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s900210425", "group_id": "codeNet:p03208", "input_text": "local inp = io.read()\nlocal n,k\nfor i=1,string.len(inp),1 do\n if inp:sub(i,i)==' ' then\n n = tonumber(inp:sub(1,i-1))\n k = tonumber(inp:sub(i+1,string.len(inp)))\n end\nend\nlocal h = {}\nfor i=1,n,1 do\n h[i] = tonumber(io.read())\nend\ntable.sort(h)\nlocal ans=1000000000\nfor i=1,n-k+1,1 do\n if ans>h[i+k-1]-h[i] then\n ans = h[i+k-1]-h[i]\n end\nend\nprint(ans)", "language": "Lua", "metadata": {"date": 1544399650, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03208.html", "problem_id": "p03208", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03208/input.txt", "sample_output_relpath": "derived/input_output/data/p03208/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03208/Lua/s900210425.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s900210425", "user_id": "u030685402"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "local inp = io.read()\nlocal n,k\nfor i=1,string.len(inp),1 do\n if inp:sub(i,i)==' ' then\n n = tonumber(inp:sub(1,i-1))\n k = tonumber(inp:sub(i+1,string.len(inp)))\n end\nend\nlocal h = {}\nfor i=1,n,1 do\n h[i] = tonumber(io.read())\nend\ntable.sort(h)\nlocal ans=1000000000\nfor i=1,n-k+1,1 do\n if ans>h[i+k-1]-h[i] then\n ans = h[i+k-1]-h[i]\n end\nend\nprint(ans)", "problem_context": "Score : 300 points\n\nProblem Statement\n\nIn some other world, today is Christmas Eve.\n\nThere are N trees planted in Mr. Takaha's garden. The height of the i-th tree (1 \\leq i \\leq N) is h_i meters.\n\nHe decides to choose K trees from these trees and decorate them with electric lights. To make the scenery more beautiful, the heights of the decorated trees should be as close to each other as possible.\n\nMore specifically, let the height of the tallest decorated tree be h_{max} meters, and the height of the shortest decorated tree be h_{min} meters. The smaller the value h_{max} - h_{min} is, the better. What is the minimum possible value of h_{max} - h_{min}?\n\nConstraints\n\n2 \\leq K < N \\leq 10^5\n\n1 \\leq h_i \\leq 10^9\n\nh_i is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nh_1\nh_2\n:\nh_N\n\nOutput\n\nPrint the minimum possible value of h_{max} - h_{min}.\n\nSample Input 1\n\n5 3\n10\n15\n11\n14\n12\n\nSample Output 1\n\n2\n\nIf we decorate the first, third and fifth trees, h_{max} = 12, h_{min} = 10 so h_{max} - h_{min} = 2. This is optimal.\n\nSample Input 2\n\n5 3\n5\n7\n5\n7\n7\n\nSample Output 2\n\n0\n\nIf we decorate the second, fourth and fifth trees, h_{max} = 7, h_{min} = 7 so h_{max} - h_{min} = 0. This is optimal.\n\nThere are not too many trees in these sample inputs, but note that there can be at most one hundred thousand trees (we just can't put a sample with a hundred thousand lines here).", "sample_input": "5 3\n10\n15\n11\n14\n12\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03208", "source_text": "Score : 300 points\n\nProblem Statement\n\nIn some other world, today is Christmas Eve.\n\nThere are N trees planted in Mr. Takaha's garden. The height of the i-th tree (1 \\leq i \\leq N) is h_i meters.\n\nHe decides to choose K trees from these trees and decorate them with electric lights. To make the scenery more beautiful, the heights of the decorated trees should be as close to each other as possible.\n\nMore specifically, let the height of the tallest decorated tree be h_{max} meters, and the height of the shortest decorated tree be h_{min} meters. The smaller the value h_{max} - h_{min} is, the better. What is the minimum possible value of h_{max} - h_{min}?\n\nConstraints\n\n2 \\leq K < N \\leq 10^5\n\n1 \\leq h_i \\leq 10^9\n\nh_i is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nh_1\nh_2\n:\nh_N\n\nOutput\n\nPrint the minimum possible value of h_{max} - h_{min}.\n\nSample Input 1\n\n5 3\n10\n15\n11\n14\n12\n\nSample Output 1\n\n2\n\nIf we decorate the first, third and fifth trees, h_{max} = 12, h_{min} = 10 so h_{max} - h_{min} = 2. This is optimal.\n\nSample Input 2\n\n5 3\n5\n7\n5\n7\n7\n\nSample Output 2\n\n0\n\nIf we decorate the second, fourth and fifth trees, h_{max} = 7, h_{min} = 7 so h_{max} - h_{min} = 0. This is optimal.\n\nThere are not too many trees in these sample inputs, but note that there can be at most one hundred thousand trees (we just can't put a sample with a hundred thousand lines here).", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 366, "cpu_time_ms": 109, "memory_kb": 4536}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s109634964", "group_id": "codeNet:p03209", "input_text": "n=io.read(\"n\")\nx=io.read(\"n\")\nf={0}\nfor i=1,n do\n\tw={}\n\ttable.insert(w,1)\n\tfor i=1,#f do\n\t\ttable.insert(w,f[i])\n\tend\n\ttable.insert(w,0)\n\tfor i=1,#f do\n\t\ttable.insert(w,f[i])\n\tend\n\ttable.insert(w,1)\n\tf=w\nend\ns=0\nfor i=1,x do\n\tif w[i]==0 then\n\t\ts=s+1\n\tend\nend\nprint(s)\n", "language": "Lua", "metadata": {"date": 1548992390, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03209.html", "problem_id": "p03209", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03209/input.txt", "sample_output_relpath": "derived/input_output/data/p03209/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03209/Lua/s109634964.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s109634964", "user_id": "u015229643"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "n=io.read(\"n\")\nx=io.read(\"n\")\nf={0}\nfor i=1,n do\n\tw={}\n\ttable.insert(w,1)\n\tfor i=1,#f do\n\t\ttable.insert(w,f[i])\n\tend\n\ttable.insert(w,0)\n\tfor i=1,#f do\n\t\ttable.insert(w,f[i])\n\tend\n\ttable.insert(w,1)\n\tf=w\nend\ns=0\nfor i=1,x do\n\tif w[i]==0 then\n\t\ts=s+1\n\tend\nend\nprint(s)\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nIn some other world, today is Christmas.\n\nMr. Takaha decides to make a multi-dimensional burger in his party. A level-L burger (L is an integer greater than or equal to 0) is the following thing:\n\nA level-0 burger is a patty.\n\nA level-L burger (L \\geq 1) is a bun, a level-(L-1) burger, a patty, another level-(L-1) burger and another bun, stacked vertically in this order from the bottom.\n\nFor example, a level-1 burger and a level-2 burger look like BPPPB and BBPPPBPBPPPBB (rotated 90 degrees), where B and P stands for a bun and a patty.\n\nThe burger Mr. Takaha will make is a level-N burger. Lunlun the Dachshund will eat X layers from the bottom of this burger (a layer is a patty or a bun). How many patties will she eat?\n\nConstraints\n\n1 \\leq N \\leq 50\n\n1 \\leq X \\leq ( the total number of layers in a level-N burger )\n\nN and X are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN X\n\nOutput\n\nPrint the number of patties in the bottom-most X layers from the bottom of a level-N burger.\n\nSample Input 1\n\n2 7\n\nSample Output 1\n\n4\n\nThere are 4 patties in the bottom-most 7 layers of a level-2 burger (BBPPPBPBPPPBB).\n\nSample Input 2\n\n1 1\n\nSample Output 2\n\n0\n\nThe bottom-most layer of a level-1 burger is a bun.\n\nSample Input 3\n\n50 4321098765432109\n\nSample Output 3\n\n2160549382716056\n\nA level-50 burger is rather thick, to the extent that the number of its layers does not fit into a 32-bit integer.", "sample_input": "2 7\n"}, "reference_outputs": ["4\n"], "source_document_id": "p03209", "source_text": "Score : 400 points\n\nProblem Statement\n\nIn some other world, today is Christmas.\n\nMr. Takaha decides to make a multi-dimensional burger in his party. A level-L burger (L is an integer greater than or equal to 0) is the following thing:\n\nA level-0 burger is a patty.\n\nA level-L burger (L \\geq 1) is a bun, a level-(L-1) burger, a patty, another level-(L-1) burger and another bun, stacked vertically in this order from the bottom.\n\nFor example, a level-1 burger and a level-2 burger look like BPPPB and BBPPPBPBPPPBB (rotated 90 degrees), where B and P stands for a bun and a patty.\n\nThe burger Mr. Takaha will make is a level-N burger. Lunlun the Dachshund will eat X layers from the bottom of this burger (a layer is a patty or a bun). How many patties will she eat?\n\nConstraints\n\n1 \\leq N \\leq 50\n\n1 \\leq X \\leq ( the total number of layers in a level-N burger )\n\nN and X are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN X\n\nOutput\n\nPrint the number of patties in the bottom-most X layers from the bottom of a level-N burger.\n\nSample Input 1\n\n2 7\n\nSample Output 1\n\n4\n\nThere are 4 patties in the bottom-most 7 layers of a level-2 burger (BBPPPBPBPPPBB).\n\nSample Input 2\n\n1 1\n\nSample Output 2\n\n0\n\nThe bottom-most layer of a level-1 burger is a bun.\n\nSample Input 3\n\n50 4321098765432109\n\nSample Output 3\n\n2160549382716056\n\nA level-50 burger is rather thick, to the extent that the number of its layers does not fit into a 32-bit integer.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 267, "cpu_time_ms": 2108, "memory_kb": 129252}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s519182680", "group_id": "codeNet:p03210", "input_text": "local n = io.read(\"n\")\n-- local n = 999999999\nlocal total = 0\nlocal value_stack = {0}\nlocal mark_stack = {0}\nwhile true do\n\tlocal len = #value_stack\n\tlocal value = value_stack[len]\n\tlocal mark = mark_stack[len]\n\tif not value then\n\t\tbreak\n\tend\n\ttable.remove(value_stack, len)\n\ttable.remove(mark_stack, len)\n\tif value <= n then\n\t\tif mark == 7 then\n\t\t\ttotal = total + 1\n\t\tend\n\t\ttable.insert(value_stack, value * 10 + 3)\n\t\ttable.insert(mark_stack, mark | 1)\n\t\ttable.insert(value_stack, value * 10 + 5)\n\t\ttable.insert(mark_stack, mark | 2)\n\t\ttable.insert(value_stack, value * 10 + 7)\n\t\ttable.insert(mark_stack, mark | 4)\n\tend\nend\nprint(total)", "language": "Lua", "metadata": {"date": 1550350819, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03210.html", "problem_id": "p03210", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03210/input.txt", "sample_output_relpath": "derived/input_output/data/p03210/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03210/Lua/s519182680.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s519182680", "user_id": "u200201528"}, "prompt_components": {"gold_output": "YES\n", "input_to_evaluate": "local n = io.read(\"n\")\n-- local n = 999999999\nlocal total = 0\nlocal value_stack = {0}\nlocal mark_stack = {0}\nwhile true do\n\tlocal len = #value_stack\n\tlocal value = value_stack[len]\n\tlocal mark = mark_stack[len]\n\tif not value then\n\t\tbreak\n\tend\n\ttable.remove(value_stack, len)\n\ttable.remove(mark_stack, len)\n\tif value <= n then\n\t\tif mark == 7 then\n\t\t\ttotal = total + 1\n\t\tend\n\t\ttable.insert(value_stack, value * 10 + 3)\n\t\ttable.insert(mark_stack, mark | 1)\n\t\ttable.insert(value_stack, value * 10 + 5)\n\t\ttable.insert(mark_stack, mark | 2)\n\t\ttable.insert(value_stack, value * 10 + 7)\n\t\ttable.insert(mark_stack, mark | 4)\n\tend\nend\nprint(total)", "problem_context": "Score : 100 points\n\nProblem Statement\n\nShichi-Go-San (literally \"Seven-Five-Three\") is a traditional event in a certain country to celebrate the growth of seven-, five- and three-year-old children.\n\nTakahashi is now X years old. Will his growth be celebrated in Shichi-Go-San this time?\n\nConstraints\n\n1 ≤ X ≤ 9\n\nX is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX\n\nOutput\n\nIf Takahashi's growth will be celebrated, print YES; if it will not, print NO.\n\nSample Input 1\n\n5\n\nSample Output 1\n\nYES\n\nThe growth of a five-year-old child will be celebrated.\n\nSample Input 2\n\n6\n\nSample Output 2\n\nNO\n\nSee you next year.", "sample_input": "5\n"}, "reference_outputs": ["YES\n"], "source_document_id": "p03210", "source_text": "Score : 100 points\n\nProblem Statement\n\nShichi-Go-San (literally \"Seven-Five-Three\") is a traditional event in a certain country to celebrate the growth of seven-, five- and three-year-old children.\n\nTakahashi is now X years old. Will his growth be celebrated in Shichi-Go-San this time?\n\nConstraints\n\n1 ≤ X ≤ 9\n\nX is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX\n\nOutput\n\nIf Takahashi's growth will be celebrated, print YES; if it will not, print NO.\n\nSample Input 1\n\n5\n\nSample Output 1\n\nYES\n\nThe growth of a five-year-old child will be celebrated.\n\nSample Input 2\n\n6\n\nSample Output 2\n\nNO\n\nSee you next year.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 637, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s499160435", "group_id": "codeNet:p03210", "input_text": "a=io.read()*1\nif(a==5 or a==7 or a==3)then \n\tprint(\"YES\")\nelse\n\tprint(\"NO\")\nend", "language": "Lua", "metadata": {"date": 1547583961, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03210.html", "problem_id": "p03210", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03210/input.txt", "sample_output_relpath": "derived/input_output/data/p03210/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03210/Lua/s499160435.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s499160435", "user_id": "u837412668"}, "prompt_components": {"gold_output": "YES\n", "input_to_evaluate": "a=io.read()*1\nif(a==5 or a==7 or a==3)then \n\tprint(\"YES\")\nelse\n\tprint(\"NO\")\nend", "problem_context": "Score : 100 points\n\nProblem Statement\n\nShichi-Go-San (literally \"Seven-Five-Three\") is a traditional event in a certain country to celebrate the growth of seven-, five- and three-year-old children.\n\nTakahashi is now X years old. Will his growth be celebrated in Shichi-Go-San this time?\n\nConstraints\n\n1 ≤ X ≤ 9\n\nX is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX\n\nOutput\n\nIf Takahashi's growth will be celebrated, print YES; if it will not, print NO.\n\nSample Input 1\n\n5\n\nSample Output 1\n\nYES\n\nThe growth of a five-year-old child will be celebrated.\n\nSample Input 2\n\n6\n\nSample Output 2\n\nNO\n\nSee you next year.", "sample_input": "5\n"}, "reference_outputs": ["YES\n"], "source_document_id": "p03210", "source_text": "Score : 100 points\n\nProblem Statement\n\nShichi-Go-San (literally \"Seven-Five-Three\") is a traditional event in a certain country to celebrate the growth of seven-, five- and three-year-old children.\n\nTakahashi is now X years old. Will his growth be celebrated in Shichi-Go-San this time?\n\nConstraints\n\n1 ≤ X ≤ 9\n\nX is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX\n\nOutput\n\nIf Takahashi's growth will be celebrated, print YES; if it will not, print NO.\n\nSample Input 1\n\n5\n\nSample Output 1\n\nYES\n\nThe growth of a five-year-old child will be celebrated.\n\nSample Input 2\n\n6\n\nSample Output 2\n\nNO\n\nSee you next year.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 79, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s025895978", "group_id": "codeNet:p03211", "input_text": "local S = io.read(\"n\")\nlocal function take3(n)\n return ((S // math.floor(10^n)) % 1000)\nend\nlocal ans = 1000\nfor i=0,7 do\n ans = math.min(ans, math.abs(753 - take3(i)))\nend\nprint(ans)", "language": "Lua", "metadata": {"date": 1565540081, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03211.html", "problem_id": "p03211", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03211/input.txt", "sample_output_relpath": "derived/input_output/data/p03211/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03211/Lua/s025895978.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s025895978", "user_id": "u162773977"}, "prompt_components": {"gold_output": "34\n", "input_to_evaluate": "local S = io.read(\"n\")\nlocal function take3(n)\n return ((S // math.floor(10^n)) % 1000)\nend\nlocal ans = 1000\nfor i=0,7 do\n ans = math.min(ans, math.abs(753 - take3(i)))\nend\nprint(ans)", "problem_context": "Score : 200 points\n\nProblem Statement\n\nThere is a string S consisting of digits 1, 2, ..., 9.\nLunlun, the Dachshund, will take out three consecutive digits from S, treat them as a single integer X and bring it to her master. (She cannot rearrange the digits.)\n\nThe master's favorite number is 753. The closer to this number, the better.\nWhat is the minimum possible (absolute) difference between X and 753?\n\nConstraints\n\nS is a string of length between 4 and 10 (inclusive).\n\nEach character in S is 1, 2, ..., or 9.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the minimum possible difference between X and 753.\n\nSample Input 1\n\n1234567876\n\nSample Output 1\n\n34\n\nTaking out the seventh to ninth characters results in X = 787, and the difference between this and 753 is 787 - 753 = 34. The difference cannot be made smaller, no matter where X is taken from.\n\nNote that the digits cannot be rearranged. For example, taking out 567 and rearranging it to 765 is not allowed.\n\nWe cannot take out three digits that are not consecutive from S, either. For example, taking out the seventh digit 7, the ninth digit 7 and the tenth digit 6 to obtain 776 is not allowed.\n\nSample Input 2\n\n35753\n\nSample Output 2\n\n0\n\nIf 753 itself can be taken out, the answer is 0.\n\nSample Input 3\n\n1111111111\n\nSample Output 3\n\n642\n\nNo matter where X is taken from, X = 111, with the difference 753 - 111 = 642.", "sample_input": "1234567876\n"}, "reference_outputs": ["34\n"], "source_document_id": "p03211", "source_text": "Score : 200 points\n\nProblem Statement\n\nThere is a string S consisting of digits 1, 2, ..., 9.\nLunlun, the Dachshund, will take out three consecutive digits from S, treat them as a single integer X and bring it to her master. (She cannot rearrange the digits.)\n\nThe master's favorite number is 753. The closer to this number, the better.\nWhat is the minimum possible (absolute) difference between X and 753?\n\nConstraints\n\nS is a string of length between 4 and 10 (inclusive).\n\nEach character in S is 1, 2, ..., or 9.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the minimum possible difference between X and 753.\n\nSample Input 1\n\n1234567876\n\nSample Output 1\n\n34\n\nTaking out the seventh to ninth characters results in X = 787, and the difference between this and 753 is 787 - 753 = 34. The difference cannot be made smaller, no matter where X is taken from.\n\nNote that the digits cannot be rearranged. For example, taking out 567 and rearranging it to 765 is not allowed.\n\nWe cannot take out three digits that are not consecutive from S, either. For example, taking out the seventh digit 7, the ninth digit 7 and the tenth digit 6 to obtain 776 is not allowed.\n\nSample Input 2\n\n35753\n\nSample Output 2\n\n0\n\nIf 753 itself can be taken out, the answer is 0.\n\nSample Input 3\n\n1111111111\n\nSample Output 3\n\n642\n\nNo matter where X is taken from, X = 111, with the difference 753 - 111 = 642.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 189, "cpu_time_ms": 8, "memory_kb": 760}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s242883350", "group_id": "codeNet:p03211", "input_text": "local str = io.read()\nlocal n = tonumber(str)\nlocal min = 753\nfor i=1,#str-2 do\n\tlocal newmin = math.abs(753 - tonumber(string.sub(str,i,i)..string.sub(str,i+1,i+1)..string.sub(str,i+2,i+2)))\n\tif min > newmin then min = newmin end\nend\nprint(min)", "language": "Lua", "metadata": {"date": 1543883445, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03211.html", "problem_id": "p03211", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03211/input.txt", "sample_output_relpath": "derived/input_output/data/p03211/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03211/Lua/s242883350.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s242883350", "user_id": "u102354963"}, "prompt_components": {"gold_output": "34\n", "input_to_evaluate": "local str = io.read()\nlocal n = tonumber(str)\nlocal min = 753\nfor i=1,#str-2 do\n\tlocal newmin = math.abs(753 - tonumber(string.sub(str,i,i)..string.sub(str,i+1,i+1)..string.sub(str,i+2,i+2)))\n\tif min > newmin then min = newmin end\nend\nprint(min)", "problem_context": "Score : 200 points\n\nProblem Statement\n\nThere is a string S consisting of digits 1, 2, ..., 9.\nLunlun, the Dachshund, will take out three consecutive digits from S, treat them as a single integer X and bring it to her master. (She cannot rearrange the digits.)\n\nThe master's favorite number is 753. The closer to this number, the better.\nWhat is the minimum possible (absolute) difference between X and 753?\n\nConstraints\n\nS is a string of length between 4 and 10 (inclusive).\n\nEach character in S is 1, 2, ..., or 9.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the minimum possible difference between X and 753.\n\nSample Input 1\n\n1234567876\n\nSample Output 1\n\n34\n\nTaking out the seventh to ninth characters results in X = 787, and the difference between this and 753 is 787 - 753 = 34. The difference cannot be made smaller, no matter where X is taken from.\n\nNote that the digits cannot be rearranged. For example, taking out 567 and rearranging it to 765 is not allowed.\n\nWe cannot take out three digits that are not consecutive from S, either. For example, taking out the seventh digit 7, the ninth digit 7 and the tenth digit 6 to obtain 776 is not allowed.\n\nSample Input 2\n\n35753\n\nSample Output 2\n\n0\n\nIf 753 itself can be taken out, the answer is 0.\n\nSample Input 3\n\n1111111111\n\nSample Output 3\n\n642\n\nNo matter where X is taken from, X = 111, with the difference 753 - 111 = 642.", "sample_input": "1234567876\n"}, "reference_outputs": ["34\n"], "source_document_id": "p03211", "source_text": "Score : 200 points\n\nProblem Statement\n\nThere is a string S consisting of digits 1, 2, ..., 9.\nLunlun, the Dachshund, will take out three consecutive digits from S, treat them as a single integer X and bring it to her master. (She cannot rearrange the digits.)\n\nThe master's favorite number is 753. The closer to this number, the better.\nWhat is the minimum possible (absolute) difference between X and 753?\n\nConstraints\n\nS is a string of length between 4 and 10 (inclusive).\n\nEach character in S is 1, 2, ..., or 9.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the minimum possible difference between X and 753.\n\nSample Input 1\n\n1234567876\n\nSample Output 1\n\n34\n\nTaking out the seventh to ninth characters results in X = 787, and the difference between this and 753 is 787 - 753 = 34. The difference cannot be made smaller, no matter where X is taken from.\n\nNote that the digits cannot be rearranged. For example, taking out 567 and rearranging it to 765 is not allowed.\n\nWe cannot take out three digits that are not consecutive from S, either. For example, taking out the seventh digit 7, the ninth digit 7 and the tenth digit 6 to obtain 776 is not allowed.\n\nSample Input 2\n\n35753\n\nSample Output 2\n\n0\n\nIf 753 itself can be taken out, the answer is 0.\n\nSample Input 3\n\n1111111111\n\nSample Output 3\n\n642\n\nNo matter where X is taken from, X = 111, with the difference 753 - 111 = 642.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 245, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s246294182", "group_id": "codeNet:p03212", "input_text": "local n = io.read(\"*n\")\nlocal dignum = 0\nlocal digits = {}\nwhile 0 < n do\n table.insert(digits, n % 10)\n n = n // 10\n dignum = dignum + 1\nend\nlocal norm = {}\nlocal maymax = {}\n\n-- 0, 03, 05, 07, 035, 037, 057, 0357\nfor i = 1, 8 do\n norm[i] = {}\n maymax[i] = {}\n for j = 1, dignum do\n norm[i][j] = 0\n maymax[i][j] = 0\n end\nend\nlocal digval = digits[dignum]\nnorm[1][dignum] = 1\nif 8 <= digval then\n norm[2][dignum] = 1\n norm[3][dignum] = 1\n norm[4][dignum] = 1\nelseif 7 == digval then\n norm[2][dignum] = 1\n norm[3][dignum] = 1\n maymax[4][dignum] = 1\nelseif 6 == digval then\n norm[2][dignum] = 1\n norm[3][dignum] = 1\nelseif 5 == digval then\n norm[2][dignum] = 1\n maymax[3][dignum] = 1\nelseif 4 == digval then\n norm[2][dignum] = 1\nelseif 3 == digval then\n maymax[2][dignum] = 1\nend\n\nfor i = dignum - 1, 1, -1 do\n local digval = digits[i]\n norm[1][i] = 1\n -- 03, 05, 07\n for j = 2, 4 do\n local tgt = j * 2 - 1\n if tgt < digval then\n norm[j][i] = norm[1][i + 1] + norm[j][i + 1] + maymax[j][i + 1]\n maymax[j][i] = 0\n elseif tgt == digval then\n norm[j][i] = norm[1][i + 1] + norm[j][i + 1]\n maymax[j][i] = maymax[j][i + 1]\n else\n norm[j][i] = norm[1][i + 1] + norm[j][i + 1]\n maymax[j][i] = 0\n end\n end\n -- 035, 037, 057\n for j = 5, 7 do\n local rightval = j == 5 and 5 or 7\n local rightidx = j == 5 and 3 or 4\n local leftval = j == 7 and 5 or 3\n local leftidx = j == 7 and 3 or 2\n if rightval < digval then\n norm[j][i] = norm[leftidx][i + 1] + norm[rightidx][i + 1] + norm[j][i + 1] * 2\n + maymax[leftidx][i + 1] + maymax[rightidx][i + 1] + maymax[j][i + 1] * 2\n maymax[j][i] = 0\n elseif rightval == digval then\n norm[j][i] = norm[leftidx][i + 1] + norm[rightidx][i + 1] + norm[j][i + 1] * 2\n + maymax[rightidx][i + 1] + maymax[j][i + 1]\n maymax[j][i] = maymax[leftidx][i + 1] + maymax[j][i + 1]\n elseif leftval < digval then\n norm[j][i] = norm[leftidx][i + 1] + norm[rightidx][i + 1] + norm[j][i + 1] * 2\n + maymax[rightidx][i + 1] + maymax[j][i + 1]\n maymax[j][i] = 0\n elseif leftval == digval then\n norm[j][i] = norm[leftidx][i + 1] + norm[rightidx][i + 1] + norm[j][i + 1] * 2\n maymax[j][i] = maymax[rightidx][i + 1] + maymax[j][i + 1]\n else\n norm[j][i] = norm[leftidx][i + 1] + norm[rightidx][i + 1] + norm[j][i + 1] * 2\n maymax[j][i] = 0\n end\n end\n if 7 < digval then\n norm[8][i] = norm[5][i + 1] + norm[6][i + 1] + norm[7][i + 1] + norm[8][i + 1] * 3\n + maymax[5][i + 1] + maymax[6][i + 1] + maymax[7][i + 1] + maymax[8][i + 1] * 3\n maymax[8][i] = 0\n elseif 7 == digval then\n norm[8][i] = norm[5][i + 1] + norm[6][i + 1] + norm[7][i + 1] + norm[8][i + 1] * 3\n + maymax[6][i + 1] + maymax[7][i + 1] + maymax[8][i + 1] * 2\n maymax[8][i] = maymax[5][i + 1] + maymax[8][i + 1]\n elseif 6 == digval then\n norm[8][i] = norm[5][i + 1] + norm[6][i + 1] + norm[7][i + 1] + norm[8][i + 1] * 3\n + maymax[6][i + 1] + maymax[7][i + 1] + maymax[8][i + 1] * 2\n maymax[8][i] = 0\n elseif 5 == digval then\n norm[8][i] = norm[5][i + 1] + norm[6][i + 1] + norm[7][i + 1] + norm[8][i + 1] * 3\n + maymax[7][i + 1] + maymax[8][i + 1]\n maymax[8][i] = maymax[6][i + 1] + maymax[8][i + 1]\n elseif 4 == digval then\n norm[8][i] = norm[5][i + 1] + norm[6][i + 1] + norm[7][i + 1] + norm[8][i + 1] * 3\n + maymax[7][i + 1] + maymax[8][i + 1]\n maymax[8][i] = 0\n elseif 3 == digval then\n norm[8][i] = norm[5][i + 1] + norm[6][i + 1] + norm[7][i + 1] + norm[8][i + 1] * 3\n maymax[8][i] = maymax[7][i + 1] + maymax[8][i + 1]\n else\n norm[8][i] = norm[5][i + 1] + norm[6][i + 1] + norm[7][i + 1] + norm[8][i + 1] * 3\n maymax[8][i] = 0\n end\nend\nprint(norm[8][1] + maymax[8][1])\n", "language": "Lua", "metadata": {"date": 1558638447, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03212.html", "problem_id": "p03212", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03212/input.txt", "sample_output_relpath": "derived/input_output/data/p03212/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03212/Lua/s246294182.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s246294182", "user_id": "u120582723"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "local n = io.read(\"*n\")\nlocal dignum = 0\nlocal digits = {}\nwhile 0 < n do\n table.insert(digits, n % 10)\n n = n // 10\n dignum = dignum + 1\nend\nlocal norm = {}\nlocal maymax = {}\n\n-- 0, 03, 05, 07, 035, 037, 057, 0357\nfor i = 1, 8 do\n norm[i] = {}\n maymax[i] = {}\n for j = 1, dignum do\n norm[i][j] = 0\n maymax[i][j] = 0\n end\nend\nlocal digval = digits[dignum]\nnorm[1][dignum] = 1\nif 8 <= digval then\n norm[2][dignum] = 1\n norm[3][dignum] = 1\n norm[4][dignum] = 1\nelseif 7 == digval then\n norm[2][dignum] = 1\n norm[3][dignum] = 1\n maymax[4][dignum] = 1\nelseif 6 == digval then\n norm[2][dignum] = 1\n norm[3][dignum] = 1\nelseif 5 == digval then\n norm[2][dignum] = 1\n maymax[3][dignum] = 1\nelseif 4 == digval then\n norm[2][dignum] = 1\nelseif 3 == digval then\n maymax[2][dignum] = 1\nend\n\nfor i = dignum - 1, 1, -1 do\n local digval = digits[i]\n norm[1][i] = 1\n -- 03, 05, 07\n for j = 2, 4 do\n local tgt = j * 2 - 1\n if tgt < digval then\n norm[j][i] = norm[1][i + 1] + norm[j][i + 1] + maymax[j][i + 1]\n maymax[j][i] = 0\n elseif tgt == digval then\n norm[j][i] = norm[1][i + 1] + norm[j][i + 1]\n maymax[j][i] = maymax[j][i + 1]\n else\n norm[j][i] = norm[1][i + 1] + norm[j][i + 1]\n maymax[j][i] = 0\n end\n end\n -- 035, 037, 057\n for j = 5, 7 do\n local rightval = j == 5 and 5 or 7\n local rightidx = j == 5 and 3 or 4\n local leftval = j == 7 and 5 or 3\n local leftidx = j == 7 and 3 or 2\n if rightval < digval then\n norm[j][i] = norm[leftidx][i + 1] + norm[rightidx][i + 1] + norm[j][i + 1] * 2\n + maymax[leftidx][i + 1] + maymax[rightidx][i + 1] + maymax[j][i + 1] * 2\n maymax[j][i] = 0\n elseif rightval == digval then\n norm[j][i] = norm[leftidx][i + 1] + norm[rightidx][i + 1] + norm[j][i + 1] * 2\n + maymax[rightidx][i + 1] + maymax[j][i + 1]\n maymax[j][i] = maymax[leftidx][i + 1] + maymax[j][i + 1]\n elseif leftval < digval then\n norm[j][i] = norm[leftidx][i + 1] + norm[rightidx][i + 1] + norm[j][i + 1] * 2\n + maymax[rightidx][i + 1] + maymax[j][i + 1]\n maymax[j][i] = 0\n elseif leftval == digval then\n norm[j][i] = norm[leftidx][i + 1] + norm[rightidx][i + 1] + norm[j][i + 1] * 2\n maymax[j][i] = maymax[rightidx][i + 1] + maymax[j][i + 1]\n else\n norm[j][i] = norm[leftidx][i + 1] + norm[rightidx][i + 1] + norm[j][i + 1] * 2\n maymax[j][i] = 0\n end\n end\n if 7 < digval then\n norm[8][i] = norm[5][i + 1] + norm[6][i + 1] + norm[7][i + 1] + norm[8][i + 1] * 3\n + maymax[5][i + 1] + maymax[6][i + 1] + maymax[7][i + 1] + maymax[8][i + 1] * 3\n maymax[8][i] = 0\n elseif 7 == digval then\n norm[8][i] = norm[5][i + 1] + norm[6][i + 1] + norm[7][i + 1] + norm[8][i + 1] * 3\n + maymax[6][i + 1] + maymax[7][i + 1] + maymax[8][i + 1] * 2\n maymax[8][i] = maymax[5][i + 1] + maymax[8][i + 1]\n elseif 6 == digval then\n norm[8][i] = norm[5][i + 1] + norm[6][i + 1] + norm[7][i + 1] + norm[8][i + 1] * 3\n + maymax[6][i + 1] + maymax[7][i + 1] + maymax[8][i + 1] * 2\n maymax[8][i] = 0\n elseif 5 == digval then\n norm[8][i] = norm[5][i + 1] + norm[6][i + 1] + norm[7][i + 1] + norm[8][i + 1] * 3\n + maymax[7][i + 1] + maymax[8][i + 1]\n maymax[8][i] = maymax[6][i + 1] + maymax[8][i + 1]\n elseif 4 == digval then\n norm[8][i] = norm[5][i + 1] + norm[6][i + 1] + norm[7][i + 1] + norm[8][i + 1] * 3\n + maymax[7][i + 1] + maymax[8][i + 1]\n maymax[8][i] = 0\n elseif 3 == digval then\n norm[8][i] = norm[5][i + 1] + norm[6][i + 1] + norm[7][i + 1] + norm[8][i + 1] * 3\n maymax[8][i] = maymax[7][i + 1] + maymax[8][i + 1]\n else\n norm[8][i] = norm[5][i + 1] + norm[6][i + 1] + norm[7][i + 1] + norm[8][i + 1] * 3\n maymax[8][i] = 0\n end\nend\nprint(norm[8][1] + maymax[8][1])\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nYou are given an integer N. Among the integers between 1 and N (inclusive), how many Shichi-Go-San numbers (literally \"Seven-Five-Three numbers\") are there?\n\nHere, a Shichi-Go-San number is a positive integer that satisfies the following condition:\n\nWhen the number is written in base ten, each of the digits 7, 5 and 3 appears at least once, and the other digits never appear.\n\nConstraints\n\n1 \\leq N < 10^9\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the number of the Shichi-Go-San numbers between 1 and N (inclusive).\n\nSample Input 1\n\n575\n\nSample Output 1\n\n4\n\nThere are four Shichi-Go-San numbers not greater than 575: 357, 375, 537 and 573.\n\nSample Input 2\n\n3600\n\nSample Output 2\n\n13\n\nThere are 13 Shichi-Go-San numbers not greater than 3600: the above four numbers, 735, 753, 3357, 3375, 3537, 3557, 3573, 3575 and 3577.\n\nSample Input 3\n\n999999999\n\nSample Output 3\n\n26484", "sample_input": "575\n"}, "reference_outputs": ["4\n"], "source_document_id": "p03212", "source_text": "Score : 300 points\n\nProblem Statement\n\nYou are given an integer N. Among the integers between 1 and N (inclusive), how many Shichi-Go-San numbers (literally \"Seven-Five-Three numbers\") are there?\n\nHere, a Shichi-Go-San number is a positive integer that satisfies the following condition:\n\nWhen the number is written in base ten, each of the digits 7, 5 and 3 appears at least once, and the other digits never appear.\n\nConstraints\n\n1 \\leq N < 10^9\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the number of the Shichi-Go-San numbers between 1 and N (inclusive).\n\nSample Input 1\n\n575\n\nSample Output 1\n\n4\n\nThere are four Shichi-Go-San numbers not greater than 575: 357, 375, 537 and 573.\n\nSample Input 2\n\n3600\n\nSample Output 2\n\n13\n\nThere are 13 Shichi-Go-San numbers not greater than 3600: the above four numbers, 735, 753, 3357, 3375, 3537, 3557, 3573, 3575 and 3577.\n\nSample Input 3\n\n999999999\n\nSample Output 3\n\n26484", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 3793, "cpu_time_ms": 8, "memory_kb": 888}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s114686749", "group_id": "codeNet:p03216", "input_text": "local mfl = math.floor\n\nlocal n = io.read(\"*n\", \"*l\")\nlocal s = io.read()\nlocal m_cnt = {}\nlocal d_pos = {}\nlocal c_pos = {}\nlocal ss = \"\"\nlocal mc = 0LL\nfor i = 1, n do\n ss = s:sub(i, i)\n if ss == \"D\" then\n table.insert(d_pos, i)\n elseif ss == \"C\" then\n table.insert(c_pos, i)\n elseif ss == \"M\" then\n mc = mc + 1LL\n end\n m_cnt[i] = mc\nend\nlocal m_sum_per_c = {}\nfor i = 1, #c_pos do\n local ic = c_pos[i]\n if i == 1 then\n m_sum_per_c[i] = m_cnt[ic]\n else\n m_sum_per_c[i] = m_sum_per_c[i - 1] + m_cnt[ic]\n end\nend\n\nlocal function llprint(llnumber)\n local str = tostring(llnumber):gsub(\"LL\", \"\")\n print(str)\nend\n\nlocal cposall = {}\nlocal tmp = 1\nfor i = 1, n + 1 do\n while c_pos[tmp] and c_pos[tmp] < i do\n tmp = tmp + 1\n end\n cposall[i] = tmp\nend\nlocal mmi = math.min\nlocal q = io.read(\"*n\")\nfor i = 1, q do\n local k = io.read(\"*n\")\n local ret = 0LL\n for id = 1, #d_pos do\n local dp = d_pos[id]\n local c_from = cposall[dp]\n local c_to = cposall[mmi(n + 1, dp + k)] - 1\n if 1 <= c_to then\n ret = ret + m_sum_per_c[c_to] - (c_to - c_from + 1) * m_cnt[dp]\n if 1 < c_from then\n ret = ret - m_sum_per_c[c_from - 1]\n end\n end\n end\n llprint(ret)\nend\n", "language": "Lua", "metadata": {"date": 1571459632, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p03216.html", "problem_id": "p03216", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03216/input.txt", "sample_output_relpath": "derived/input_output/data/p03216/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03216/Lua/s114686749.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s114686749", "user_id": "u120582723"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "local mfl = math.floor\n\nlocal n = io.read(\"*n\", \"*l\")\nlocal s = io.read()\nlocal m_cnt = {}\nlocal d_pos = {}\nlocal c_pos = {}\nlocal ss = \"\"\nlocal mc = 0LL\nfor i = 1, n do\n ss = s:sub(i, i)\n if ss == \"D\" then\n table.insert(d_pos, i)\n elseif ss == \"C\" then\n table.insert(c_pos, i)\n elseif ss == \"M\" then\n mc = mc + 1LL\n end\n m_cnt[i] = mc\nend\nlocal m_sum_per_c = {}\nfor i = 1, #c_pos do\n local ic = c_pos[i]\n if i == 1 then\n m_sum_per_c[i] = m_cnt[ic]\n else\n m_sum_per_c[i] = m_sum_per_c[i - 1] + m_cnt[ic]\n end\nend\n\nlocal function llprint(llnumber)\n local str = tostring(llnumber):gsub(\"LL\", \"\")\n print(str)\nend\n\nlocal cposall = {}\nlocal tmp = 1\nfor i = 1, n + 1 do\n while c_pos[tmp] and c_pos[tmp] < i do\n tmp = tmp + 1\n end\n cposall[i] = tmp\nend\nlocal mmi = math.min\nlocal q = io.read(\"*n\")\nfor i = 1, q do\n local k = io.read(\"*n\")\n local ret = 0LL\n for id = 1, #d_pos do\n local dp = d_pos[id]\n local c_from = cposall[dp]\n local c_to = cposall[mmi(n + 1, dp + k)] - 1\n if 1 <= c_to then\n ret = ret + m_sum_per_c[c_to] - (c_to - c_from + 1) * m_cnt[dp]\n if 1 < c_from then\n ret = ret - m_sum_per_c[c_from - 1]\n end\n end\n end\n llprint(ret)\nend\n", "problem_context": "Score : 600 points\n\nProblem Statement\n\nIn Dwango Co., Ltd., there is a content distribution system named 'Dwango Media Cluster', and it is called 'DMC' for short.\n\nThe 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 \\geq 3),\nhe defines the k-DMC number of S as the number of triples (a, b, c) of integers that satisfy the following conditions:\n\n0 \\leq a < b < c \\leq N - 1\n\nS[a] = D\n\nS[b] = M\n\nS[c] = C\n\nc-a < k\n\nHere S[a] is the a-th character of the string S. Indexing is zero-based, that is, 0 \\leq a \\leq N - 1 holds.\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 \\leq i \\leq Q-1).\n\nConstraints\n\n3 \\leq N \\leq 10^6\n\nS consists of uppercase English letters\n\n1 \\leq Q \\leq 75\n\n3 \\leq k_i \\leq N\n\nAll numbers given in input are integers\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS\nQ\nk_{0} k_{1} ... k_{Q-1}\n\nOutput\n\nPrint Q lines.\nThe i-th line should contain the k_i-DMC number of the string S.\n\nSample Input 1\n\n18\nDWANGOMEDIACLUSTER\n1\n18\n\nSample Output 1\n\n1\n\n(a,b,c) = (0, 6, 11) satisfies the conditions.\n\nStrangely, Dwango Media Cluster does not have so much DMC-ness by his definition.\n\nSample Input 2\n\n18\nDDDDDDMMMMMCCCCCCC\n1\n18\n\nSample Output 2\n\n210\n\nThe number of triples can be calculated as 6\\times 5\\times 7.\n\nSample Input 3\n\n54\nDIALUPWIDEAREANETWORKGAMINGOPERATIONCORPORATIONLIMITED\n3\n20 30 40\n\nSample Output 3\n\n0\n1\n2\n\n(a, b, c) = (0, 23, 36), (8, 23, 36) satisfy the conditions except the last one, namely, c-a < k_i.\n\nBy the way, DWANGO is an acronym for \"Dial-up Wide Area Network Gaming Operation\".\n\nSample Output 4\n\n30\nDMCDMCDMCDMCDMCDMCDMCDMCDMCDMC\n4\n5 10 15 20\n\nSample Output 4\n\n10\n52\n110\n140", "sample_input": "18\nDWANGOMEDIACLUSTER\n1\n18\n"}, "reference_outputs": ["1\n"], "source_document_id": "p03216", "source_text": "Score : 600 points\n\nProblem Statement\n\nIn Dwango Co., Ltd., there is a content distribution system named 'Dwango Media Cluster', and it is called 'DMC' for short.\n\nThe 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 \\geq 3),\nhe defines the k-DMC number of S as the number of triples (a, b, c) of integers that satisfy the following conditions:\n\n0 \\leq a < b < c \\leq N - 1\n\nS[a] = D\n\nS[b] = M\n\nS[c] = C\n\nc-a < k\n\nHere S[a] is the a-th character of the string S. Indexing is zero-based, that is, 0 \\leq a \\leq N - 1 holds.\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 \\leq i \\leq Q-1).\n\nConstraints\n\n3 \\leq N \\leq 10^6\n\nS consists of uppercase English letters\n\n1 \\leq Q \\leq 75\n\n3 \\leq k_i \\leq N\n\nAll numbers given in input are integers\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS\nQ\nk_{0} k_{1} ... k_{Q-1}\n\nOutput\n\nPrint Q lines.\nThe i-th line should contain the k_i-DMC number of the string S.\n\nSample Input 1\n\n18\nDWANGOMEDIACLUSTER\n1\n18\n\nSample Output 1\n\n1\n\n(a,b,c) = (0, 6, 11) satisfies the conditions.\n\nStrangely, Dwango Media Cluster does not have so much DMC-ness by his definition.\n\nSample Input 2\n\n18\nDDDDDDMMMMMCCCCCCC\n1\n18\n\nSample Output 2\n\n210\n\nThe number of triples can be calculated as 6\\times 5\\times 7.\n\nSample Input 3\n\n54\nDIALUPWIDEAREANETWORKGAMINGOPERATIONCORPORATIONLIMITED\n3\n20 30 40\n\nSample Output 3\n\n0\n1\n2\n\n(a, b, c) = (0, 23, 36), (8, 23, 36) satisfy the conditions except the last one, namely, c-a < k_i.\n\nBy the way, DWANGO is an acronym for \"Dial-up Wide Area Network Gaming Operation\".\n\nSample Output 4\n\n30\nDMCDMCDMCDMCDMCDMCDMCDMCDMCDMC\n4\n5 10 15 20\n\nSample Output 4\n\n10\n52\n110\n140", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1217, "cpu_time_ms": 2458, "memory_kb": 77536}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s930020104", "group_id": "codeNet:p03216", "input_text": "local mfl = math.floor\n\nlocal function comp(a, b)\n return a < b\nend\n\nlocal function lower_bound(ary, x)\n local num = #ary\n if num == 0 then return 1 end\n if not comp(ary[1], x) then return 1 end\n if comp(ary[num], x) then return num + 1 end\n local min, max = 1, num\n while 1 < max - min do\n local mid = mfl((min + max) / 2)\n if comp(ary[mid], x) then\n min = mid\n else\n max = mid\n end\n end\n return max\nend\n\nlocal n = io.read(\"*n\", \"*l\")\nlocal s = io.read()\nlocal m_cnt = {}\nlocal d_pos = {}\nlocal c_pos = {}\nlocal ss = \"\"\nlocal mc = 0\nfor i = 1, n do\n ss = s:sub(i, i)\n if ss == \"D\" then\n table.insert(d_pos, i)\n elseif ss == \"C\" then\n table.insert(c_pos, i)\n elseif ss == \"M\" then\n mc = mc + 1\n end\n m_cnt[i] = mc\nend\nlocal c_froms = {}\nfor id = 1, #d_pos do\n c_froms[id] = lower_bound(c_pos, d_pos[id])\nend\nlocal q = io.read(\"*n\")\nfor i = 1, q do\n local k = io.read(\"*n\")\n local ret = 0\n for id = 1, #d_pos do\n local dp = d_pos[id]\n local c_from = c_froms[id]\n local c_to = lower_bound(c_pos, dp + k) - 1\n for ic = c_from, c_to do\n local cp = c_pos[ic]\n ret = ret + m_cnt[cp] - m_cnt[dp]\n end\n end\n print(ret)\nend\n", "language": "Lua", "metadata": {"date": 1571371195, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p03216.html", "problem_id": "p03216", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03216/input.txt", "sample_output_relpath": "derived/input_output/data/p03216/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03216/Lua/s930020104.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s930020104", "user_id": "u120582723"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "local mfl = math.floor\n\nlocal function comp(a, b)\n return a < b\nend\n\nlocal function lower_bound(ary, x)\n local num = #ary\n if num == 0 then return 1 end\n if not comp(ary[1], x) then return 1 end\n if comp(ary[num], x) then return num + 1 end\n local min, max = 1, num\n while 1 < max - min do\n local mid = mfl((min + max) / 2)\n if comp(ary[mid], x) then\n min = mid\n else\n max = mid\n end\n end\n return max\nend\n\nlocal n = io.read(\"*n\", \"*l\")\nlocal s = io.read()\nlocal m_cnt = {}\nlocal d_pos = {}\nlocal c_pos = {}\nlocal ss = \"\"\nlocal mc = 0\nfor i = 1, n do\n ss = s:sub(i, i)\n if ss == \"D\" then\n table.insert(d_pos, i)\n elseif ss == \"C\" then\n table.insert(c_pos, i)\n elseif ss == \"M\" then\n mc = mc + 1\n end\n m_cnt[i] = mc\nend\nlocal c_froms = {}\nfor id = 1, #d_pos do\n c_froms[id] = lower_bound(c_pos, d_pos[id])\nend\nlocal q = io.read(\"*n\")\nfor i = 1, q do\n local k = io.read(\"*n\")\n local ret = 0\n for id = 1, #d_pos do\n local dp = d_pos[id]\n local c_from = c_froms[id]\n local c_to = lower_bound(c_pos, dp + k) - 1\n for ic = c_from, c_to do\n local cp = c_pos[ic]\n ret = ret + m_cnt[cp] - m_cnt[dp]\n end\n end\n print(ret)\nend\n", "problem_context": "Score : 600 points\n\nProblem Statement\n\nIn Dwango Co., Ltd., there is a content distribution system named 'Dwango Media Cluster', and it is called 'DMC' for short.\n\nThe 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 \\geq 3),\nhe defines the k-DMC number of S as the number of triples (a, b, c) of integers that satisfy the following conditions:\n\n0 \\leq a < b < c \\leq N - 1\n\nS[a] = D\n\nS[b] = M\n\nS[c] = C\n\nc-a < k\n\nHere S[a] is the a-th character of the string S. Indexing is zero-based, that is, 0 \\leq a \\leq N - 1 holds.\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 \\leq i \\leq Q-1).\n\nConstraints\n\n3 \\leq N \\leq 10^6\n\nS consists of uppercase English letters\n\n1 \\leq Q \\leq 75\n\n3 \\leq k_i \\leq N\n\nAll numbers given in input are integers\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS\nQ\nk_{0} k_{1} ... k_{Q-1}\n\nOutput\n\nPrint Q lines.\nThe i-th line should contain the k_i-DMC number of the string S.\n\nSample Input 1\n\n18\nDWANGOMEDIACLUSTER\n1\n18\n\nSample Output 1\n\n1\n\n(a,b,c) = (0, 6, 11) satisfies the conditions.\n\nStrangely, Dwango Media Cluster does not have so much DMC-ness by his definition.\n\nSample Input 2\n\n18\nDDDDDDMMMMMCCCCCCC\n1\n18\n\nSample Output 2\n\n210\n\nThe number of triples can be calculated as 6\\times 5\\times 7.\n\nSample Input 3\n\n54\nDIALUPWIDEAREANETWORKGAMINGOPERATIONCORPORATIONLIMITED\n3\n20 30 40\n\nSample Output 3\n\n0\n1\n2\n\n(a, b, c) = (0, 23, 36), (8, 23, 36) satisfy the conditions except the last one, namely, c-a < k_i.\n\nBy the way, DWANGO is an acronym for \"Dial-up Wide Area Network Gaming Operation\".\n\nSample Output 4\n\n30\nDMCDMCDMCDMCDMCDMCDMCDMCDMCDMC\n4\n5 10 15 20\n\nSample Output 4\n\n10\n52\n110\n140", "sample_input": "18\nDWANGOMEDIACLUSTER\n1\n18\n"}, "reference_outputs": ["1\n"], "source_document_id": "p03216", "source_text": "Score : 600 points\n\nProblem Statement\n\nIn Dwango Co., Ltd., there is a content distribution system named 'Dwango Media Cluster', and it is called 'DMC' for short.\n\nThe 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 \\geq 3),\nhe defines the k-DMC number of S as the number of triples (a, b, c) of integers that satisfy the following conditions:\n\n0 \\leq a < b < c \\leq N - 1\n\nS[a] = D\n\nS[b] = M\n\nS[c] = C\n\nc-a < k\n\nHere S[a] is the a-th character of the string S. Indexing is zero-based, that is, 0 \\leq a \\leq N - 1 holds.\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 \\leq i \\leq Q-1).\n\nConstraints\n\n3 \\leq N \\leq 10^6\n\nS consists of uppercase English letters\n\n1 \\leq Q \\leq 75\n\n3 \\leq k_i \\leq N\n\nAll numbers given in input are integers\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS\nQ\nk_{0} k_{1} ... k_{Q-1}\n\nOutput\n\nPrint Q lines.\nThe i-th line should contain the k_i-DMC number of the string S.\n\nSample Input 1\n\n18\nDWANGOMEDIACLUSTER\n1\n18\n\nSample Output 1\n\n1\n\n(a,b,c) = (0, 6, 11) satisfies the conditions.\n\nStrangely, Dwango Media Cluster does not have so much DMC-ness by his definition.\n\nSample Input 2\n\n18\nDDDDDDMMMMMCCCCCCC\n1\n18\n\nSample Output 2\n\n210\n\nThe number of triples can be calculated as 6\\times 5\\times 7.\n\nSample Input 3\n\n54\nDIALUPWIDEAREANETWORKGAMINGOPERATIONCORPORATIONLIMITED\n3\n20 30 40\n\nSample Output 3\n\n0\n1\n2\n\n(a, b, c) = (0, 23, 36), (8, 23, 36) satisfy the conditions except the last one, namely, c-a < k_i.\n\nBy the way, DWANGO is an acronym for \"Dial-up Wide Area Network Gaming Operation\".\n\nSample Output 4\n\n30\nDMCDMCDMCDMCDMCDMCDMCDMCDMCDMC\n4\n5 10 15 20\n\nSample Output 4\n\n10\n52\n110\n140", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1192, "cpu_time_ms": 2656, "memory_kb": 27432}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s809859805", "group_id": "codeNet:p03219", "input_text": "x, y = io.read(\"*n\", \"*n\")\nprint(x + math.floor(y / 2))", "language": "Lua", "metadata": {"date": 1579358783, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03219.html", "problem_id": "p03219", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03219/input.txt", "sample_output_relpath": "derived/input_output/data/p03219/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03219/Lua/s809859805.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s809859805", "user_id": "u720483676"}, "prompt_components": {"gold_output": "110\n", "input_to_evaluate": "x, y = io.read(\"*n\", \"*n\")\nprint(x + math.floor(y / 2))", "problem_context": "Score: 100 points\n\nProblem Statement\n\nThere is a train going from Station A to Station B that costs X yen (the currency of Japan).\n\nAlso, there is a bus going from Station B to Station C that costs Y yen.\n\nJoisino got a special ticket. With this ticket, she can take the bus for half the fare if she travels from Station A to Station B by train and then travels from Station B to Station C by bus.\n\nHow much does it cost to travel from Station A to Station C if she uses this ticket?\n\nConstraints\n\n1 \\leq X,Y \\leq 100\n\nY is an even number.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX Y\n\nOutput\n\nIf it costs x yen to travel from Station A to Station C, print x.\n\nSample Input 1\n\n81 58\n\nSample Output 1\n\n110\n\nThe train fare is 81 yen.\n\nThe train fare is 58 ⁄ 2=29 yen with the 50% discount.\n\nThus, it costs 110 yen to travel from Station A to Station C.\n\nSample Input 2\n\n4 54\n\nSample Output 2\n\n31", "sample_input": "81 58\n"}, "reference_outputs": ["110\n"], "source_document_id": "p03219", "source_text": "Score: 100 points\n\nProblem Statement\n\nThere is a train going from Station A to Station B that costs X yen (the currency of Japan).\n\nAlso, there is a bus going from Station B to Station C that costs Y yen.\n\nJoisino got a special ticket. With this ticket, she can take the bus for half the fare if she travels from Station A to Station B by train and then travels from Station B to Station C by bus.\n\nHow much does it cost to travel from Station A to Station C if she uses this ticket?\n\nConstraints\n\n1 \\leq X,Y \\leq 100\n\nY is an even number.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX Y\n\nOutput\n\nIf it costs x yen to travel from Station A to Station C, print x.\n\nSample Input 1\n\n81 58\n\nSample Output 1\n\n110\n\nThe train fare is 81 yen.\n\nThe train fare is 58 ⁄ 2=29 yen with the 50% discount.\n\nThus, it costs 110 yen to travel from Station A to Station C.\n\nSample Input 2\n\n4 54\n\nSample Output 2\n\n31", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 55, "cpu_time_ms": 8, "memory_kb": 888}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s607121017", "group_id": "codeNet:p03219", "input_text": "local inp = io.read()\nt={}\nstring.gsub(inp,\"(%S+)\", function (v) table.insert(t,tonumber(v)) end)\nprint(t[1]+t[2]//2)", "language": "Lua", "metadata": {"date": 1544409324, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03219.html", "problem_id": "p03219", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03219/input.txt", "sample_output_relpath": "derived/input_output/data/p03219/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03219/Lua/s607121017.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s607121017", "user_id": "u030685402"}, "prompt_components": {"gold_output": "110\n", "input_to_evaluate": "local inp = io.read()\nt={}\nstring.gsub(inp,\"(%S+)\", function (v) table.insert(t,tonumber(v)) end)\nprint(t[1]+t[2]//2)", "problem_context": "Score: 100 points\n\nProblem Statement\n\nThere is a train going from Station A to Station B that costs X yen (the currency of Japan).\n\nAlso, there is a bus going from Station B to Station C that costs Y yen.\n\nJoisino got a special ticket. With this ticket, she can take the bus for half the fare if she travels from Station A to Station B by train and then travels from Station B to Station C by bus.\n\nHow much does it cost to travel from Station A to Station C if she uses this ticket?\n\nConstraints\n\n1 \\leq X,Y \\leq 100\n\nY is an even number.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX Y\n\nOutput\n\nIf it costs x yen to travel from Station A to Station C, print x.\n\nSample Input 1\n\n81 58\n\nSample Output 1\n\n110\n\nThe train fare is 81 yen.\n\nThe train fare is 58 ⁄ 2=29 yen with the 50% discount.\n\nThus, it costs 110 yen to travel from Station A to Station C.\n\nSample Input 2\n\n4 54\n\nSample Output 2\n\n31", "sample_input": "81 58\n"}, "reference_outputs": ["110\n"], "source_document_id": "p03219", "source_text": "Score: 100 points\n\nProblem Statement\n\nThere is a train going from Station A to Station B that costs X yen (the currency of Japan).\n\nAlso, there is a bus going from Station B to Station C that costs Y yen.\n\nJoisino got a special ticket. With this ticket, she can take the bus for half the fare if she travels from Station A to Station B by train and then travels from Station B to Station C by bus.\n\nHow much does it cost to travel from Station A to Station C if she uses this ticket?\n\nConstraints\n\n1 \\leq X,Y \\leq 100\n\nY is an even number.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX Y\n\nOutput\n\nIf it costs x yen to travel from Station A to Station C, print x.\n\nSample Input 1\n\n81 58\n\nSample Output 1\n\n110\n\nThe train fare is 81 yen.\n\nThe train fare is 58 ⁄ 2=29 yen with the 50% discount.\n\nThus, it costs 110 yen to travel from Station A to Station C.\n\nSample Input 2\n\n4 54\n\nSample Output 2\n\n31", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 117, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s727722518", "group_id": "codeNet:p03220", "input_text": "local N, T, A = io.read(\"*n\", \"*n\", \"*n\")\nlocal H = {}\nfor i = 1, N do\n H[i] = io.read(\"*n\")\nend\n\nlocal near_index = 0\nH[near_index] = 100000\nfor i = 1, N do\n if math.abs(A - (T - H[i] * 0.006)) \n < math.abs(A - (T - H[near_index] * 0.006)) then\n near_index = i\n end\nend\n\nprint(near_index)", "language": "Lua", "metadata": {"date": 1587073908, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p03220.html", "problem_id": "p03220", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03220/input.txt", "sample_output_relpath": "derived/input_output/data/p03220/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03220/Lua/s727722518.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s727722518", "user_id": "u793881115"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "local N, T, A = io.read(\"*n\", \"*n\", \"*n\")\nlocal H = {}\nfor i = 1, N do\n H[i] = io.read(\"*n\")\nend\n\nlocal near_index = 0\nH[near_index] = 100000\nfor i = 1, N do\n if math.abs(A - (T - H[i] * 0.006)) \n < math.abs(A - (T - H[near_index] * 0.006)) then\n near_index = i\n end\nend\n\nprint(near_index)", "problem_context": "Score: 200 points\n\nProblem Statement\n\nA country decides to build a palace.\n\nIn this country, the average temperature of a point at an elevation of x meters is T-x \\times 0.006 degrees Celsius.\n\nThere are N places proposed for the place. The elevation of Place i is H_i meters.\n\nAmong them, Princess Joisino orders you to select the place whose average temperature is the closest to A degrees Celsius, and build the palace there.\n\nPrint the index of the place where the palace should be built.\n\nIt is guaranteed that the solution is unique.\n\nConstraints\n\n1 \\leq N \\leq 1000\n\n0 \\leq T \\leq 50\n\n-60 \\leq A \\leq T\n\n0 \\leq H_i \\leq 10^5\n\nAll values in input are integers.\n\nThe solution is unique.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nT A\nH_1 H_2 ... H_N\n\nOutput\n\nPrint the index of the place where the palace should be built.\n\nSample Input 1\n\n2\n12 5\n1000 2000\n\nSample Output 1\n\n1\n\nThe average temperature of Place 1 is 12-1000 \\times 0.006=6 degrees Celsius.\n\nThe average temperature of Place 2 is 12-2000 \\times 0.006=0 degrees Celsius.\n\nThus, the palace should be built at Place 1.\n\nSample Input 2\n\n3\n21 -11\n81234 94124 52141\n\nSample Output 2\n\n3", "sample_input": "2\n12 5\n1000 2000\n"}, "reference_outputs": ["1\n"], "source_document_id": "p03220", "source_text": "Score: 200 points\n\nProblem Statement\n\nA country decides to build a palace.\n\nIn this country, the average temperature of a point at an elevation of x meters is T-x \\times 0.006 degrees Celsius.\n\nThere are N places proposed for the place. The elevation of Place i is H_i meters.\n\nAmong them, Princess Joisino orders you to select the place whose average temperature is the closest to A degrees Celsius, and build the palace there.\n\nPrint the index of the place where the palace should be built.\n\nIt is guaranteed that the solution is unique.\n\nConstraints\n\n1 \\leq N \\leq 1000\n\n0 \\leq T \\leq 50\n\n-60 \\leq A \\leq T\n\n0 \\leq H_i \\leq 10^5\n\nAll values in input are integers.\n\nThe solution is unique.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nT A\nH_1 H_2 ... H_N\n\nOutput\n\nPrint the index of the place where the palace should be built.\n\nSample Input 1\n\n2\n12 5\n1000 2000\n\nSample Output 1\n\n1\n\nThe average temperature of Place 1 is 12-1000 \\times 0.006=6 degrees Celsius.\n\nThe average temperature of Place 2 is 12-2000 \\times 0.006=0 degrees Celsius.\n\nThus, the palace should be built at Place 1.\n\nSample Input 2\n\n3\n21 -11\n81234 94124 52141\n\nSample Output 2\n\n3", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 309, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s494439979", "group_id": "codeNet:p03221", "input_text": "local str = io.read(\"*l\")\nlocal tb = {}\nfor i = 1, string.len(str) do\n table.insert(tb,string.sub(str,i,i))\nend\n\nlocal finalA = io.read(\"*n\")\nlocal finalB = io.read(\"*n\")\nio.read()\n\nlocal dirTb = {\n {0,1},\n {0,-1},\n {-1,0},\n {1,0}\n}\n\nlocal turnTb = {\n {3,4},\n {3,4},\n {1,2},\n {1,2}\n}\nfunction digui( a,b,idx,curDir )\n print(a..\" \"..b)\n if a == finalA and b == finalB then\n return true\n end\n\n if idx > #tb then\n return false\n end\n\n if a < 0 or a > 8000 or b < 0 or b > 8000 then\n return false\n end\n\n if tb[idx] == 'F' then\n return digui(a+dirTb[curDir][1],b+dirTb[curDir][2],idx+1,curDir)\n else\n return digui(a+dirTb[turnTb[curDir][1]][1],b+dirTb[turnTb[curDir][1]][2],idx+1,turnTb[curDir][1]) or digui(a+dirTb[turnTb[curDir][2]][1],b+dirTb[turnTb[curDir][2]][2],idx+1,turnTb[curDir][2]) \n end\n\nend\n\nlocal f = digui(1,1,1,1) or digui(1,1,1,2) or digui(1,1,1,3) digui(1,1,1,4)\nprint(f and \"yes\" or \"no\")", "language": "Lua", "metadata": {"date": 1594164596, "filename_ext": "lua", "original_language": "Lua (Lua 5.3.5)", "problem_description_relpath": "problem_descriptions/p03221.html", "problem_id": "p03221", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03221/input.txt", "sample_output_relpath": "derived/input_output/data/p03221/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03221/Lua/s494439979.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s494439979", "user_id": "u353919145"}, "prompt_components": {"gold_output": "000001000002\n000002000001\n000001000001\n", "input_to_evaluate": "local str = io.read(\"*l\")\nlocal tb = {}\nfor i = 1, string.len(str) do\n table.insert(tb,string.sub(str,i,i))\nend\n\nlocal finalA = io.read(\"*n\")\nlocal finalB = io.read(\"*n\")\nio.read()\n\nlocal dirTb = {\n {0,1},\n {0,-1},\n {-1,0},\n {1,0}\n}\n\nlocal turnTb = {\n {3,4},\n {3,4},\n {1,2},\n {1,2}\n}\nfunction digui( a,b,idx,curDir )\n print(a..\" \"..b)\n if a == finalA and b == finalB then\n return true\n end\n\n if idx > #tb then\n return false\n end\n\n if a < 0 or a > 8000 or b < 0 or b > 8000 then\n return false\n end\n\n if tb[idx] == 'F' then\n return digui(a+dirTb[curDir][1],b+dirTb[curDir][2],idx+1,curDir)\n else\n return digui(a+dirTb[turnTb[curDir][1]][1],b+dirTb[turnTb[curDir][1]][2],idx+1,turnTb[curDir][1]) or digui(a+dirTb[turnTb[curDir][2]][1],b+dirTb[turnTb[curDir][2]][2],idx+1,turnTb[curDir][2]) \n end\n\nend\n\nlocal f = digui(1,1,1,1) or digui(1,1,1,2) or digui(1,1,1,3) digui(1,1,1,4)\nprint(f and \"yes\" or \"no\")", "problem_context": "Score: 300 points\n\nProblem Statement\n\nIn Republic of Atcoder, there are N prefectures, and a total of M cities that belong to those prefectures.\n\nCity i is established in year Y_i and belongs to Prefecture P_i.\n\nYou can assume that there are no multiple cities that are established in the same year.\n\nIt is decided to allocate a 12-digit ID number to each city.\n\nIf City i is the x-th established city among the cities that belong to Prefecture i, the first six digits of the ID number of City i is P_i, and the last six digits of the ID number is x.\n\nHere, if P_i or x (or both) has less than six digits, zeros are added to the left until it has six digits.\n\nFind the ID numbers for all the cities.\n\nNote that there can be a prefecture with no cities.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^5\n\n1 \\leq P_i \\leq N\n\n1 \\leq Y_i \\leq 10^9\n\nY_i are all different.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nP_1 Y_1\n:\nP_M Y_M\n\nOutput\n\nPrint the ID numbers for all the cities, in ascending order of indices (City 1, City 2, ...).\n\nSample Input 1\n\n2 3\n1 32\n2 63\n1 12\n\nSample Output 1\n\n000001000002\n000002000001\n000001000001\n\nAs City 1 is the second established city among the cities that belong to Prefecture 1, its ID number is 000001000002.\n\nAs City 2 is the first established city among the cities that belong to Prefecture 2, its ID number is 000002000001.\n\nAs City 3 is the first established city among the cities that belong to Prefecture 1, its ID number is 000001000001.\n\nSample Input 2\n\n2 3\n2 55\n2 77\n2 99\n\nSample Output 2\n\n000002000001\n000002000002\n000002000003", "sample_input": "2 3\n1 32\n2 63\n1 12\n"}, "reference_outputs": ["000001000002\n000002000001\n000001000001\n"], "source_document_id": "p03221", "source_text": "Score: 300 points\n\nProblem Statement\n\nIn Republic of Atcoder, there are N prefectures, and a total of M cities that belong to those prefectures.\n\nCity i is established in year Y_i and belongs to Prefecture P_i.\n\nYou can assume that there are no multiple cities that are established in the same year.\n\nIt is decided to allocate a 12-digit ID number to each city.\n\nIf City i is the x-th established city among the cities that belong to Prefecture i, the first six digits of the ID number of City i is P_i, and the last six digits of the ID number is x.\n\nHere, if P_i or x (or both) has less than six digits, zeros are added to the left until it has six digits.\n\nFind the ID numbers for all the cities.\n\nNote that there can be a prefecture with no cities.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^5\n\n1 \\leq P_i \\leq N\n\n1 \\leq Y_i \\leq 10^9\n\nY_i are all different.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nP_1 Y_1\n:\nP_M Y_M\n\nOutput\n\nPrint the ID numbers for all the cities, in ascending order of indices (City 1, City 2, ...).\n\nSample Input 1\n\n2 3\n1 32\n2 63\n1 12\n\nSample Output 1\n\n000001000002\n000002000001\n000001000001\n\nAs City 1 is the second established city among the cities that belong to Prefecture 1, its ID number is 000001000002.\n\nAs City 2 is the first established city among the cities that belong to Prefecture 2, its ID number is 000002000001.\n\nAs City 3 is the first established city among the cities that belong to Prefecture 1, its ID number is 000001000001.\n\nSample Input 2\n\n2 3\n2 55\n2 77\n2 99\n\nSample Output 2\n\n000002000001\n000002000002\n000002000003", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 993, "cpu_time_ms": 61, "memory_kb": 2712}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s580804684", "group_id": "codeNet:p03221", "input_text": "function read()\n return io.read(\"*num\")\nend\nn = read()\nm = read()\na = {}\nfor i = 1, m do\n p = read()\n y = read()\n a[i] = {p = p, y = y, id = i}\nend\ntable.sort(a, function(A, B)\n return A.y < B.y\n end)\n\na[1].c = 1\nb = {}\nfor i = 2, m do\n if a[i].y > a[i - 1].y then\n a[i].c = a[i - 1].c + 1\n else\n a[i].c = a[i - 1].c\n end\nend\n\nfor i = 1, m do\n b[a[i].id] = a[i]\nend\n\nfor i = 1, m do\n str = string.format(\"%06d%06d\", b[i].p, b[i].c)\n print(str)\nend\n\n\n", "language": "Lua", "metadata": {"date": 1573274012, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03221.html", "problem_id": "p03221", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03221/input.txt", "sample_output_relpath": "derived/input_output/data/p03221/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03221/Lua/s580804684.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s580804684", "user_id": "u089230684"}, "prompt_components": {"gold_output": "000001000002\n000002000001\n000001000001\n", "input_to_evaluate": "function read()\n return io.read(\"*num\")\nend\nn = read()\nm = read()\na = {}\nfor i = 1, m do\n p = read()\n y = read()\n a[i] = {p = p, y = y, id = i}\nend\ntable.sort(a, function(A, B)\n return A.y < B.y\n end)\n\na[1].c = 1\nb = {}\nfor i = 2, m do\n if a[i].y > a[i - 1].y then\n a[i].c = a[i - 1].c + 1\n else\n a[i].c = a[i - 1].c\n end\nend\n\nfor i = 1, m do\n b[a[i].id] = a[i]\nend\n\nfor i = 1, m do\n str = string.format(\"%06d%06d\", b[i].p, b[i].c)\n print(str)\nend\n\n\n", "problem_context": "Score: 300 points\n\nProblem Statement\n\nIn Republic of Atcoder, there are N prefectures, and a total of M cities that belong to those prefectures.\n\nCity i is established in year Y_i and belongs to Prefecture P_i.\n\nYou can assume that there are no multiple cities that are established in the same year.\n\nIt is decided to allocate a 12-digit ID number to each city.\n\nIf City i is the x-th established city among the cities that belong to Prefecture i, the first six digits of the ID number of City i is P_i, and the last six digits of the ID number is x.\n\nHere, if P_i or x (or both) has less than six digits, zeros are added to the left until it has six digits.\n\nFind the ID numbers for all the cities.\n\nNote that there can be a prefecture with no cities.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^5\n\n1 \\leq P_i \\leq N\n\n1 \\leq Y_i \\leq 10^9\n\nY_i are all different.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nP_1 Y_1\n:\nP_M Y_M\n\nOutput\n\nPrint the ID numbers for all the cities, in ascending order of indices (City 1, City 2, ...).\n\nSample Input 1\n\n2 3\n1 32\n2 63\n1 12\n\nSample Output 1\n\n000001000002\n000002000001\n000001000001\n\nAs City 1 is the second established city among the cities that belong to Prefecture 1, its ID number is 000001000002.\n\nAs City 2 is the first established city among the cities that belong to Prefecture 2, its ID number is 000002000001.\n\nAs City 3 is the first established city among the cities that belong to Prefecture 1, its ID number is 000001000001.\n\nSample Input 2\n\n2 3\n2 55\n2 77\n2 99\n\nSample Output 2\n\n000002000001\n000002000002\n000002000003", "sample_input": "2 3\n1 32\n2 63\n1 12\n"}, "reference_outputs": ["000001000002\n000002000001\n000001000001\n"], "source_document_id": "p03221", "source_text": "Score: 300 points\n\nProblem Statement\n\nIn Republic of Atcoder, there are N prefectures, and a total of M cities that belong to those prefectures.\n\nCity i is established in year Y_i and belongs to Prefecture P_i.\n\nYou can assume that there are no multiple cities that are established in the same year.\n\nIt is decided to allocate a 12-digit ID number to each city.\n\nIf City i is the x-th established city among the cities that belong to Prefecture i, the first six digits of the ID number of City i is P_i, and the last six digits of the ID number is x.\n\nHere, if P_i or x (or both) has less than six digits, zeros are added to the left until it has six digits.\n\nFind the ID numbers for all the cities.\n\nNote that there can be a prefecture with no cities.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^5\n\n1 \\leq P_i \\leq N\n\n1 \\leq Y_i \\leq 10^9\n\nY_i are all different.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nP_1 Y_1\n:\nP_M Y_M\n\nOutput\n\nPrint the ID numbers for all the cities, in ascending order of indices (City 1, City 2, ...).\n\nSample Input 1\n\n2 3\n1 32\n2 63\n1 12\n\nSample Output 1\n\n000001000002\n000002000001\n000001000001\n\nAs City 1 is the second established city among the cities that belong to Prefecture 1, its ID number is 000001000002.\n\nAs City 2 is the first established city among the cities that belong to Prefecture 2, its ID number is 000002000001.\n\nAs City 3 is the first established city among the cities that belong to Prefecture 1, its ID number is 000001000001.\n\nSample Input 2\n\n2 3\n2 55\n2 77\n2 99\n\nSample Output 2\n\n000002000001\n000002000002\n000002000003", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 520, "cpu_time_ms": 780, "memory_kb": 32344}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s294401026", "group_id": "codeNet:p03221", "input_text": "local zones = io.read(\"*n\")\nlocal num = io.read(\"*n\")\nlocal data = {}\nfor j = 1,num do\n\tlocal idx = io.read(\"*n\")\n\tlocal y = io.read(\"*n\")\n\tlocal d = {n = 0, year = y,i=j,z = idx}\n\ttable.insert(data,d)\nend\nlocal tmp = {}\ntable.sort(data,function(a,b)\n \treturn a.year < b.year\nend)\n\n-- for k,v in ipairs(data) do\n-- \tv.k = k\n-- end\nfor k,v in ipairs(data) do\n\tif not tmp[v.z] then\n\t\ttmp[v.z] = 1\n\telse\n\t\ttmp[v.z] = tmp[v.z] + 1\n\tend\n\tv.n = tmp[v.z]\nend\n\nlocal x = {}\nfor k,v in pairs(data) do\n\tx[v.i]={v.z,v.n}\nend\n\nfor i = 1,#x do\n\tlocal digits = 0\n\tif x[i][1] < 100000 then\n\t\tlocal num = x[i][1]\n\n\t\tfor i= 1,5 do\n\t\t\tnum = num/10\n\t\t\tif num >= 10 then\n\t\t\t\tdigits = digits + 1\n\t\t\tend\n\t\tend\n\tend\n\tx[i][1] = string.rep(\"0\",5-digits)..x[i][1]\n\tif x[i][2] < 100000 then\n\t\tlocal num = x[i][2]\n\t\tfor i= 1,5 do\n\t\t\tnum = num/10\n\t\t\tif num >= 10 then\n\t\t\t\tdigits = digits + 1\n\t\t\tend\n\t\tend\n\tend\n\tx[i][2] = string.rep(\"0\",5-digits)..x[i][2]\n\tprint(x[i][1]..x[i][2])\nend", "language": "Lua", "metadata": {"date": 1553568222, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03221.html", "problem_id": "p03221", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03221/input.txt", "sample_output_relpath": "derived/input_output/data/p03221/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03221/Lua/s294401026.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s294401026", "user_id": "u089230684"}, "prompt_components": {"gold_output": "000001000002\n000002000001\n000001000001\n", "input_to_evaluate": "local zones = io.read(\"*n\")\nlocal num = io.read(\"*n\")\nlocal data = {}\nfor j = 1,num do\n\tlocal idx = io.read(\"*n\")\n\tlocal y = io.read(\"*n\")\n\tlocal d = {n = 0, year = y,i=j,z = idx}\n\ttable.insert(data,d)\nend\nlocal tmp = {}\ntable.sort(data,function(a,b)\n \treturn a.year < b.year\nend)\n\n-- for k,v in ipairs(data) do\n-- \tv.k = k\n-- end\nfor k,v in ipairs(data) do\n\tif not tmp[v.z] then\n\t\ttmp[v.z] = 1\n\telse\n\t\ttmp[v.z] = tmp[v.z] + 1\n\tend\n\tv.n = tmp[v.z]\nend\n\nlocal x = {}\nfor k,v in pairs(data) do\n\tx[v.i]={v.z,v.n}\nend\n\nfor i = 1,#x do\n\tlocal digits = 0\n\tif x[i][1] < 100000 then\n\t\tlocal num = x[i][1]\n\n\t\tfor i= 1,5 do\n\t\t\tnum = num/10\n\t\t\tif num >= 10 then\n\t\t\t\tdigits = digits + 1\n\t\t\tend\n\t\tend\n\tend\n\tx[i][1] = string.rep(\"0\",5-digits)..x[i][1]\n\tif x[i][2] < 100000 then\n\t\tlocal num = x[i][2]\n\t\tfor i= 1,5 do\n\t\t\tnum = num/10\n\t\t\tif num >= 10 then\n\t\t\t\tdigits = digits + 1\n\t\t\tend\n\t\tend\n\tend\n\tx[i][2] = string.rep(\"0\",5-digits)..x[i][2]\n\tprint(x[i][1]..x[i][2])\nend", "problem_context": "Score: 300 points\n\nProblem Statement\n\nIn Republic of Atcoder, there are N prefectures, and a total of M cities that belong to those prefectures.\n\nCity i is established in year Y_i and belongs to Prefecture P_i.\n\nYou can assume that there are no multiple cities that are established in the same year.\n\nIt is decided to allocate a 12-digit ID number to each city.\n\nIf City i is the x-th established city among the cities that belong to Prefecture i, the first six digits of the ID number of City i is P_i, and the last six digits of the ID number is x.\n\nHere, if P_i or x (or both) has less than six digits, zeros are added to the left until it has six digits.\n\nFind the ID numbers for all the cities.\n\nNote that there can be a prefecture with no cities.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^5\n\n1 \\leq P_i \\leq N\n\n1 \\leq Y_i \\leq 10^9\n\nY_i are all different.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nP_1 Y_1\n:\nP_M Y_M\n\nOutput\n\nPrint the ID numbers for all the cities, in ascending order of indices (City 1, City 2, ...).\n\nSample Input 1\n\n2 3\n1 32\n2 63\n1 12\n\nSample Output 1\n\n000001000002\n000002000001\n000001000001\n\nAs City 1 is the second established city among the cities that belong to Prefecture 1, its ID number is 000001000002.\n\nAs City 2 is the first established city among the cities that belong to Prefecture 2, its ID number is 000002000001.\n\nAs City 3 is the first established city among the cities that belong to Prefecture 1, its ID number is 000001000001.\n\nSample Input 2\n\n2 3\n2 55\n2 77\n2 99\n\nSample Output 2\n\n000002000001\n000002000002\n000002000003", "sample_input": "2 3\n1 32\n2 63\n1 12\n"}, "reference_outputs": ["000001000002\n000002000001\n000001000001\n"], "source_document_id": "p03221", "source_text": "Score: 300 points\n\nProblem Statement\n\nIn Republic of Atcoder, there are N prefectures, and a total of M cities that belong to those prefectures.\n\nCity i is established in year Y_i and belongs to Prefecture P_i.\n\nYou can assume that there are no multiple cities that are established in the same year.\n\nIt is decided to allocate a 12-digit ID number to each city.\n\nIf City i is the x-th established city among the cities that belong to Prefecture i, the first six digits of the ID number of City i is P_i, and the last six digits of the ID number is x.\n\nHere, if P_i or x (or both) has less than six digits, zeros are added to the left until it has six digits.\n\nFind the ID numbers for all the cities.\n\nNote that there can be a prefecture with no cities.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^5\n\n1 \\leq P_i \\leq N\n\n1 \\leq Y_i \\leq 10^9\n\nY_i are all different.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nP_1 Y_1\n:\nP_M Y_M\n\nOutput\n\nPrint the ID numbers for all the cities, in ascending order of indices (City 1, City 2, ...).\n\nSample Input 1\n\n2 3\n1 32\n2 63\n1 12\n\nSample Output 1\n\n000001000002\n000002000001\n000001000001\n\nAs City 1 is the second established city among the cities that belong to Prefecture 1, its ID number is 000001000002.\n\nAs City 2 is the first established city among the cities that belong to Prefecture 2, its ID number is 000002000001.\n\nAs City 3 is the first established city among the cities that belong to Prefecture 1, its ID number is 000001000001.\n\nSample Input 2\n\n2 3\n2 55\n2 77\n2 99\n\nSample Output 2\n\n000002000001\n000002000002\n000002000003", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 954, "cpu_time_ms": 999, "memory_kb": 57308}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s402001686", "group_id": "codeNet:p03221", "input_text": "local sheng = io.read(\"*n\")\nlocal shi = io.read(\"*n\")\n\nlocal tab = {}\nlocal tab1 = {}\nlocal t = {}\n\nfor i=1,shi do\n\tlocal s1 = io.read(\"*n\")\n\tlocal s2 = io.read(\"*n\")\n\tif not tab[s1] then\n\t\ttab[s1] = {}\n\tend\n\ttable.insert(tab[s1], {s1, s2, i})\n\ttab1[s1] = true\nend\n\nfor v,_ in pairs(tab1) do\n\ttable.sort(tab[v], function(a,b)\n\t\treturn a[2] < b[2]\n\tend)\n\tfor i,v in ipairs(tab[v]) do\n\t\tt[v[3]] = string.format(\"%06d%06d\", v[1], i)\n\tend\nend\n\nfor i,v in ipairs(t) do\n\tprint(v)\nend", "language": "Lua", "metadata": {"date": 1553564547, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03221.html", "problem_id": "p03221", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03221/input.txt", "sample_output_relpath": "derived/input_output/data/p03221/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03221/Lua/s402001686.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s402001686", "user_id": "u089230684"}, "prompt_components": {"gold_output": "000001000002\n000002000001\n000001000001\n", "input_to_evaluate": "local sheng = io.read(\"*n\")\nlocal shi = io.read(\"*n\")\n\nlocal tab = {}\nlocal tab1 = {}\nlocal t = {}\n\nfor i=1,shi do\n\tlocal s1 = io.read(\"*n\")\n\tlocal s2 = io.read(\"*n\")\n\tif not tab[s1] then\n\t\ttab[s1] = {}\n\tend\n\ttable.insert(tab[s1], {s1, s2, i})\n\ttab1[s1] = true\nend\n\nfor v,_ in pairs(tab1) do\n\ttable.sort(tab[v], function(a,b)\n\t\treturn a[2] < b[2]\n\tend)\n\tfor i,v in ipairs(tab[v]) do\n\t\tt[v[3]] = string.format(\"%06d%06d\", v[1], i)\n\tend\nend\n\nfor i,v in ipairs(t) do\n\tprint(v)\nend", "problem_context": "Score: 300 points\n\nProblem Statement\n\nIn Republic of Atcoder, there are N prefectures, and a total of M cities that belong to those prefectures.\n\nCity i is established in year Y_i and belongs to Prefecture P_i.\n\nYou can assume that there are no multiple cities that are established in the same year.\n\nIt is decided to allocate a 12-digit ID number to each city.\n\nIf City i is the x-th established city among the cities that belong to Prefecture i, the first six digits of the ID number of City i is P_i, and the last six digits of the ID number is x.\n\nHere, if P_i or x (or both) has less than six digits, zeros are added to the left until it has six digits.\n\nFind the ID numbers for all the cities.\n\nNote that there can be a prefecture with no cities.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^5\n\n1 \\leq P_i \\leq N\n\n1 \\leq Y_i \\leq 10^9\n\nY_i are all different.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nP_1 Y_1\n:\nP_M Y_M\n\nOutput\n\nPrint the ID numbers for all the cities, in ascending order of indices (City 1, City 2, ...).\n\nSample Input 1\n\n2 3\n1 32\n2 63\n1 12\n\nSample Output 1\n\n000001000002\n000002000001\n000001000001\n\nAs City 1 is the second established city among the cities that belong to Prefecture 1, its ID number is 000001000002.\n\nAs City 2 is the first established city among the cities that belong to Prefecture 2, its ID number is 000002000001.\n\nAs City 3 is the first established city among the cities that belong to Prefecture 1, its ID number is 000001000001.\n\nSample Input 2\n\n2 3\n2 55\n2 77\n2 99\n\nSample Output 2\n\n000002000001\n000002000002\n000002000003", "sample_input": "2 3\n1 32\n2 63\n1 12\n"}, "reference_outputs": ["000001000002\n000002000001\n000001000001\n"], "source_document_id": "p03221", "source_text": "Score: 300 points\n\nProblem Statement\n\nIn Republic of Atcoder, there are N prefectures, and a total of M cities that belong to those prefectures.\n\nCity i is established in year Y_i and belongs to Prefecture P_i.\n\nYou can assume that there are no multiple cities that are established in the same year.\n\nIt is decided to allocate a 12-digit ID number to each city.\n\nIf City i is the x-th established city among the cities that belong to Prefecture i, the first six digits of the ID number of City i is P_i, and the last six digits of the ID number is x.\n\nHere, if P_i or x (or both) has less than six digits, zeros are added to the left until it has six digits.\n\nFind the ID numbers for all the cities.\n\nNote that there can be a prefecture with no cities.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^5\n\n1 \\leq P_i \\leq N\n\n1 \\leq Y_i \\leq 10^9\n\nY_i are all different.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nP_1 Y_1\n:\nP_M Y_M\n\nOutput\n\nPrint the ID numbers for all the cities, in ascending order of indices (City 1, City 2, ...).\n\nSample Input 1\n\n2 3\n1 32\n2 63\n1 12\n\nSample Output 1\n\n000001000002\n000002000001\n000001000001\n\nAs City 1 is the second established city among the cities that belong to Prefecture 1, its ID number is 000001000002.\n\nAs City 2 is the first established city among the cities that belong to Prefecture 2, its ID number is 000002000001.\n\nAs City 3 is the first established city among the cities that belong to Prefecture 1, its ID number is 000001000001.\n\nSample Input 2\n\n2 3\n2 55\n2 77\n2 99\n\nSample Output 2\n\n000002000001\n000002000002\n000002000003", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 477, "cpu_time_ms": 618, "memory_kb": 36172}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s045482893", "group_id": "codeNet:p03227", "input_text": "S = io.read()\n\nif #S == 2 then\n print(S)\nelseif #S == 3 then\n print(string.reverse(S))\nend\n", "language": "Lua", "metadata": {"date": 1540688681, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03227.html", "problem_id": "p03227", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03227/input.txt", "sample_output_relpath": "derived/input_output/data/p03227/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03227/Lua/s045482893.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s045482893", "user_id": "u374892957"}, "prompt_components": {"gold_output": "cba\n", "input_to_evaluate": "S = io.read()\n\nif #S == 2 then\n print(S)\nelseif #S == 3 then\n print(string.reverse(S))\nend\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nYou 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\nThe length of S is 2 or 3.\n\nS consists of lowercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\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\n\nabc\n\nSample Output 1\n\ncba\n\nAs the length of S is 3, we print it after reversing it.\n\nSample Input 2\n\nac\n\nSample Output 2\n\nac\n\nAs the length of S is 2, we print it as is.", "sample_input": "abc\n"}, "reference_outputs": ["cba\n"], "source_document_id": "p03227", "source_text": "Score : 100 points\n\nProblem Statement\n\nYou 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\nThe length of S is 2 or 3.\n\nS consists of lowercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\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\n\nabc\n\nSample Output 1\n\ncba\n\nAs the length of S is 3, we print it after reversing it.\n\nSample Input 2\n\nac\n\nSample Output 2\n\nac\n\nAs the length of S is 2, we print it as is.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 93, "cpu_time_ms": 117, "memory_kb": 760}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s667315313", "group_id": "codeNet:p03228", "input_text": "a, b, k = io.read(\"*n\", \"*n\", \"*n\")\nfor i = 1, k do\n if i % 2 == 1 then\n if a % 2 == 1 then a = a - 1 end\n a = a // 2\n b = b + a\n else\n if b % 2 == 1 then b = b - 1 end\n b = b // 2\n a = a + b\n end\nend\nprint(a .. \" \" .. b)\n", "language": "Lua", "metadata": {"date": 1594699567, "filename_ext": "lua", "original_language": "Lua (Lua 5.3.5)", "problem_description_relpath": "problem_descriptions/p03228.html", "problem_id": "p03228", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03228/input.txt", "sample_output_relpath": "derived/input_output/data/p03228/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03228/Lua/s667315313.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s667315313", "user_id": "u120582723"}, "prompt_components": {"gold_output": "5 3\n", "input_to_evaluate": "a, b, k = io.read(\"*n\", \"*n\", \"*n\")\nfor i = 1, k do\n if i % 2 == 1 then\n if a % 2 == 1 then a = a - 1 end\n a = a // 2\n b = b + a\n else\n if b % 2 == 1 then b = b - 1 end\n b = b // 2\n a = a + b\n end\nend\nprint(a .. \" \" .. b)\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nIn the beginning, Takahashi has A cookies, and Aoki has B cookies.\nThey will perform the following operation alternately, starting from Takahashi:\n\nIf the number of cookies in his hand is odd, eat one of those cookies; if the number is even, do nothing. Then, give one-half of the cookies in his hand to the other person.\n\nFind the numbers of cookies Takahashi and Aoki respectively have after performing K operations in total.\n\nConstraints\n\n1 \\leq A,B \\leq 10^9\n\n1 \\leq K \\leq 100\n\nA,B and K are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B K\n\nOutput\n\nPrint the number of cookies Takahashi has, and the number of cookies Aoki has, in this order, after performing K operations in total.\n\nSample Input 1\n\n5 4 2\n\nSample Output 1\n\n5 3\n\nThe process will go as follows:\n\nIn the beginning, Takahashi and Aoki have 5 and 4 cookies, respectively.\n\nTakahashi eats one cookie and gives two cookies to Aoki. They now have 2 and 6 cookies, respectively.\n\nAoki gives three cookies to Takahashi. They now have 5 and 3 cookies, respectively.\n\nSample Input 2\n\n3 3 3\n\nSample Output 2\n\n1 3\n\nSample Input 3\n\n314159265 358979323 84\n\nSample Output 3\n\n448759046 224379523", "sample_input": "5 4 2\n"}, "reference_outputs": ["5 3\n"], "source_document_id": "p03228", "source_text": "Score : 200 points\n\nProblem Statement\n\nIn the beginning, Takahashi has A cookies, and Aoki has B cookies.\nThey will perform the following operation alternately, starting from Takahashi:\n\nIf the number of cookies in his hand is odd, eat one of those cookies; if the number is even, do nothing. Then, give one-half of the cookies in his hand to the other person.\n\nFind the numbers of cookies Takahashi and Aoki respectively have after performing K operations in total.\n\nConstraints\n\n1 \\leq A,B \\leq 10^9\n\n1 \\leq K \\leq 100\n\nA,B and K are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B K\n\nOutput\n\nPrint the number of cookies Takahashi has, and the number of cookies Aoki has, in this order, after performing K operations in total.\n\nSample Input 1\n\n5 4 2\n\nSample Output 1\n\n5 3\n\nThe process will go as follows:\n\nIn the beginning, Takahashi and Aoki have 5 and 4 cookies, respectively.\n\nTakahashi eats one cookie and gives two cookies to Aoki. They now have 2 and 6 cookies, respectively.\n\nAoki gives three cookies to Takahashi. They now have 5 and 3 cookies, respectively.\n\nSample Input 2\n\n3 3 3\n\nSample Output 2\n\n1 3\n\nSample Input 3\n\n314159265 358979323 84\n\nSample Output 3\n\n448759046 224379523", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 243, "cpu_time_ms": 10, "memory_kb": 2616}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s949777949", "group_id": "codeNet:p03229", "input_text": "local n = io.read(\"*n\")\nlocal a = {}\nfor i = 1, n do a[i] = io.read(\"*n\") end\ntable.sort(a)\n\nif n % 2 == 0 then\n local sum = 0\n local half = n / 2\n for i = 1, half do\n sum = sum - a[i] + a[half + i]\n end\n sum = sum * 2 - a[half + 1] + a[half]\n print(sum)\nelse\n local sum = 0\n local half = (n - 1) / 2\n for i = 1, half do\n sum = sum - a[i]\n end\n for i = half + 1, n do\n sum = sum + a[i]\n end\n sum = sum * 2 - a[half + 1] - a[half + 2]\n local cand = sum\n sum = 0\n half = (n + 1) / 2\n for i = 1, half do\n sum = sum - a[i]\n end\n for i = half + 1, n do\n sum = sum + a[i]\n end\n sum = sum * 2 + a[half - 1] + a[half]\n print(math.max(cand, sum))\nend\n", "language": "Lua", "metadata": {"date": 1565017863, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p03229.html", "problem_id": "p03229", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03229/input.txt", "sample_output_relpath": "derived/input_output/data/p03229/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03229/Lua/s949777949.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s949777949", "user_id": "u120582723"}, "prompt_components": {"gold_output": "21\n", "input_to_evaluate": "local n = io.read(\"*n\")\nlocal a = {}\nfor i = 1, n do a[i] = io.read(\"*n\") end\ntable.sort(a)\n\nif n % 2 == 0 then\n local sum = 0\n local half = n / 2\n for i = 1, half do\n sum = sum - a[i] + a[half + i]\n end\n sum = sum * 2 - a[half + 1] + a[half]\n print(sum)\nelse\n local sum = 0\n local half = (n - 1) / 2\n for i = 1, half do\n sum = sum - a[i]\n end\n for i = half + 1, n do\n sum = sum + a[i]\n end\n sum = sum * 2 - a[half + 1] - a[half + 2]\n local cand = sum\n sum = 0\n half = (n + 1) / 2\n for i = 1, half do\n sum = sum - a[i]\n end\n for i = half + 1, n do\n sum = sum + a[i]\n end\n sum = sum * 2 + a[half - 1] + a[half]\n print(math.max(cand, sum))\nend\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nYou are given N integers; the i-th of them is A_i.\nFind the maximum possible sum of the absolute differences between the adjacent elements after arranging these integers in a row in any order you like.\n\nConstraints\n\n2 \\leq N \\leq 10^5\n\n1 \\leq A_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1\n:\nA_N\n\nOutput\n\nPrint the maximum possible sum of the absolute differences between the adjacent elements after arranging the given integers in a row in any order you like.\n\nSample Input 1\n\n5\n6\n8\n1\n2\n3\n\nSample Output 1\n\n21\n\nWhen the integers are arranged as 3,8,1,6,2, the sum of the absolute differences between the adjacent elements is |3 - 8| + |8 - 1| + |1 - 6| + |6 - 2| = 21. This is the maximum possible sum.\n\nSample Input 2\n\n6\n3\n1\n4\n1\n5\n9\n\nSample Output 2\n\n25\n\nSample Input 3\n\n3\n5\n5\n1\n\nSample Output 3\n\n8", "sample_input": "5\n6\n8\n1\n2\n3\n"}, "reference_outputs": ["21\n"], "source_document_id": "p03229", "source_text": "Score : 400 points\n\nProblem Statement\n\nYou are given N integers; the i-th of them is A_i.\nFind the maximum possible sum of the absolute differences between the adjacent elements after arranging these integers in a row in any order you like.\n\nConstraints\n\n2 \\leq N \\leq 10^5\n\n1 \\leq A_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1\n:\nA_N\n\nOutput\n\nPrint the maximum possible sum of the absolute differences between the adjacent elements after arranging the given integers in a row in any order you like.\n\nSample Input 1\n\n5\n6\n8\n1\n2\n3\n\nSample Output 1\n\n21\n\nWhen the integers are arranged as 3,8,1,6,2, the sum of the absolute differences between the adjacent elements is |3 - 8| + |8 - 1| + |1 - 6| + |6 - 2| = 21. This is the maximum possible sum.\n\nSample Input 2\n\n6\n3\n1\n4\n1\n5\n9\n\nSample Output 2\n\n25\n\nSample Input 3\n\n3\n5\n5\n1\n\nSample Output 3\n\n8", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 679, "cpu_time_ms": 76, "memory_kb": 1280}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s419707118", "group_id": "codeNet:p03231", "input_text": "local function gcd(a,b)\n if b>0 then\n return gcd(b,a%b)\n else\n return a\n end\nend\n\nlocal n,m=io.read(\"*n\",\"*n\",\"*l\")\nlocal s=io.read()\nlocal t=io.read()\n\nlocal l=n*m//gcd(n,m)\nlocal ln=m//gcd(n,m)\nlocal lm=n//gcd(n,m)\n\nlocal x={}\nfor i=1,n do\n local p=(i-1)*ln+1\n x[p]=s:sub(i,i)\nend\n\nlocal bool=true\nfor i=1,m do\n local p=(i-1)*lm+1\n if x[p] and x[p]~=t:sub(i,i) then\n bool=false\n break\n end\nend\nprint(bool and l or -1)", "language": "Lua", "metadata": {"date": 1590283504, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03231.html", "problem_id": "p03231", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03231/input.txt", "sample_output_relpath": "derived/input_output/data/p03231/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03231/Lua/s419707118.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s419707118", "user_id": "u045238009"}, "prompt_components": {"gold_output": "6\n", "input_to_evaluate": "local function gcd(a,b)\n if b>0 then\n return gcd(b,a%b)\n else\n return a\n end\nend\n\nlocal n,m=io.read(\"*n\",\"*n\",\"*l\")\nlocal s=io.read()\nlocal t=io.read()\n\nlocal l=n*m//gcd(n,m)\nlocal ln=m//gcd(n,m)\nlocal lm=n//gcd(n,m)\n\nlocal x={}\nfor i=1,n do\n local p=(i-1)*ln+1\n x[p]=s:sub(i,i)\nend\n\nlocal bool=true\nfor i=1,m do\n local p=(i-1)*lm+1\n if x[p] and x[p]~=t:sub(i,i) then\n bool=false\n break\n end\nend\nprint(bool and l or -1)", "problem_context": "Score : 300 points\n\nProblem Statement\n\nYou are given a string S of length N and another string T of length M.\nThese strings consist of lowercase English letters.\n\nA string X is called a good string when the following conditions are all met:\n\nLet L be the length of X. L is divisible by both N and M.\n\nConcatenating the 1-st, (\\frac{L}{N}+1)-th, (2 \\times \\frac{L}{N}+1)-th, ..., ((N-1)\\times\\frac{L}{N}+1)-th characters of X, without changing the order, results in S.\n\nConcatenating the 1-st, (\\frac{L}{M}+1)-th, (2 \\times \\frac{L}{M}+1)-th, ..., ((M-1)\\times\\frac{L}{M}+1)-th characters of X, without changing the order, results in T.\n\nDetermine if there exists a good string. If it exists, find the length of the shortest such string.\n\nConstraints\n\n1 \\leq N,M \\leq 10^5\n\nS and T consist of lowercase English letters.\n\n|S|=N\n\n|T|=M\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nS\nT\n\nOutput\n\nIf a good string does not exist, print -1; if it exists, print the length of the shortest such string.\n\nSample Input 1\n\n3 2\nacp\nae\n\nSample Output 1\n\n6\n\nFor example, the string accept is a good string.\nThere is no good string shorter than this, so the answer is 6.\n\nSample Input 2\n\n6 3\nabcdef\nabc\n\nSample Output 2\n\n-1\n\nSample Input 3\n\n15 9\ndnsusrayukuaiia\ndujrunuma\n\nSample Output 3\n\n45", "sample_input": "3 2\nacp\nae\n"}, "reference_outputs": ["6\n"], "source_document_id": "p03231", "source_text": "Score : 300 points\n\nProblem Statement\n\nYou are given a string S of length N and another string T of length M.\nThese strings consist of lowercase English letters.\n\nA string X is called a good string when the following conditions are all met:\n\nLet L be the length of X. L is divisible by both N and M.\n\nConcatenating the 1-st, (\\frac{L}{N}+1)-th, (2 \\times \\frac{L}{N}+1)-th, ..., ((N-1)\\times\\frac{L}{N}+1)-th characters of X, without changing the order, results in S.\n\nConcatenating the 1-st, (\\frac{L}{M}+1)-th, (2 \\times \\frac{L}{M}+1)-th, ..., ((M-1)\\times\\frac{L}{M}+1)-th characters of X, without changing the order, results in T.\n\nDetermine if there exists a good string. If it exists, find the length of the shortest such string.\n\nConstraints\n\n1 \\leq N,M \\leq 10^5\n\nS and T consist of lowercase English letters.\n\n|S|=N\n\n|T|=M\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nS\nT\n\nOutput\n\nIf a good string does not exist, print -1; if it exists, print the length of the shortest such string.\n\nSample Input 1\n\n3 2\nacp\nae\n\nSample Output 1\n\n6\n\nFor example, the string accept is a good string.\nThere is no good string shorter than this, so the answer is 6.\n\nSample Input 2\n\n6 3\nabcdef\nabc\n\nSample Output 2\n\n-1\n\nSample Input 3\n\n15 9\ndnsusrayukuaiia\ndujrunuma\n\nSample Output 3\n\n45", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 471, "cpu_time_ms": 23, "memory_kb": 6816}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s843014475", "group_id": "codeNet:p03232", "input_text": "local mod = 1000000007\nlocal mfl, mce = math.floor, math.ceil\nlocal function bmul(x, y)\n local x0, y0 = x % 31623, y % 31623\n local x1, y1 = mfl(x / 31623), mfl(y / 31623)\n return (x1 * y1 * 14122 + (x1 * y0 + x0 * y1) * 31623 + x0 * y0) % mod\nend\nlocal function badd(x, y) return mod <= x + y and x + y - mod or x + y end\nlocal n = io.read(\"*n\")\nlocal invs = {1}\nlocal invsum = {1}\nfor i = 2, n do\n invs[i] = bmul(mfl(mod / i), mod - invs[mod % i])\n invsum[i] = badd(invsum[i - 1], invs[i])\nend\nlocal fact = 1\nfor i = 2, n do\n fact = bmul(fact, i)\nend\nlocal ret = 0\nfor i = 1, n do\n local a = io.read(\"*n\")\n local mul = 1\n if 1 < i then\n mul = badd(mul, invsum[i])\n mul = badd(mul, mod - 1)\n end\n if i < n then\n mul = badd(mul, invsum[n + 1 - i])\n mul = badd(mul, mod - 1)\n end\n mul = bmul(mul, fact)\n ret = badd(ret, bmul(a, mul))\nend\nprint(ret)\n", "language": "Lua", "metadata": {"date": 1585714268, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p03232.html", "problem_id": "p03232", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03232/input.txt", "sample_output_relpath": "derived/input_output/data/p03232/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03232/Lua/s843014475.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s843014475", "user_id": "u120582723"}, "prompt_components": {"gold_output": "9\n", "input_to_evaluate": "local mod = 1000000007\nlocal mfl, mce = math.floor, math.ceil\nlocal function bmul(x, y)\n local x0, y0 = x % 31623, y % 31623\n local x1, y1 = mfl(x / 31623), mfl(y / 31623)\n return (x1 * y1 * 14122 + (x1 * y0 + x0 * y1) * 31623 + x0 * y0) % mod\nend\nlocal function badd(x, y) return mod <= x + y and x + y - mod or x + y end\nlocal n = io.read(\"*n\")\nlocal invs = {1}\nlocal invsum = {1}\nfor i = 2, n do\n invs[i] = bmul(mfl(mod / i), mod - invs[mod % i])\n invsum[i] = badd(invsum[i - 1], invs[i])\nend\nlocal fact = 1\nfor i = 2, n do\n fact = bmul(fact, i)\nend\nlocal ret = 0\nfor i = 1, n do\n local a = io.read(\"*n\")\n local mul = 1\n if 1 < i then\n mul = badd(mul, invsum[i])\n mul = badd(mul, mod - 1)\n end\n if i < n then\n mul = badd(mul, invsum[n + 1 - i])\n mul = badd(mul, mod - 1)\n end\n mul = bmul(mul, fact)\n ret = badd(ret, bmul(a, mul))\nend\nprint(ret)\n", "problem_context": "Score : 600 points\n\nProblem Statement\n\nThere are N blocks arranged in a row, numbered 1 to N from left to right.\nEach block has a weight, and the weight of Block i is A_i.\nSnuke will perform the following operation on these blocks N times:\n\nChoose one block that is still not removed, and remove it.\nThe cost of this operation is the sum of the weights of the blocks that are connected to the block being removed (including itself).\nHere, two blocks x and y ( x \\leq y ) are connected when, for all z ( x \\leq z \\leq y ), Block z is still not removed.\n\nThere are N! possible orders in which Snuke removes the blocks.\nFor all of those N! orders, find the total cost of the N operations, and calculate the sum of those N! total costs.\nAs the answer can be extremely large, compute the sum modulo 10^9+7.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n1 \\leq A_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nFor all of the N! orders, find the total cost of the N operations, and print the sum of those N! total costs, modulo 10^9+7.\n\nSample Input 1\n\n2\n1 2\n\nSample Output 1\n\n9\n\nFirst, we will consider the order \"Block 1 -> Block 2\".\nIn the first operation, the cost of the operation is 1+2=3, as Block 1 and 2 are connected.\nIn the second operation, the cost of the operation is 2, as only Block 2 remains.\nThus, the total cost of the two operations for this order is 3+2=5.\n\nThen, we will consider the order \"Block 2 -> Block 1\".\nIn the first operation, the cost of the operation is 1+2=3, as Block 1 and 2 are connected.\nIn the second operation, the cost of the operation is 1, as only Block 1 remains.\nThus, the total cost of the two operations for this order is 3+1=4.\n\nTherefore, the answer is 5+4=9.\n\nSample Input 2\n\n4\n1 1 1 1\n\nSample Output 2\n\n212\n\nSample Input 3\n\n10\n1 2 4 8 16 32 64 128 256 512\n\nSample Output 3\n\n880971923", "sample_input": "2\n1 2\n"}, "reference_outputs": ["9\n"], "source_document_id": "p03232", "source_text": "Score : 600 points\n\nProblem Statement\n\nThere are N blocks arranged in a row, numbered 1 to N from left to right.\nEach block has a weight, and the weight of Block i is A_i.\nSnuke will perform the following operation on these blocks N times:\n\nChoose one block that is still not removed, and remove it.\nThe cost of this operation is the sum of the weights of the blocks that are connected to the block being removed (including itself).\nHere, two blocks x and y ( x \\leq y ) are connected when, for all z ( x \\leq z \\leq y ), Block z is still not removed.\n\nThere are N! possible orders in which Snuke removes the blocks.\nFor all of those N! orders, find the total cost of the N operations, and calculate the sum of those N! total costs.\nAs the answer can be extremely large, compute the sum modulo 10^9+7.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n1 \\leq A_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nFor all of the N! orders, find the total cost of the N operations, and print the sum of those N! total costs, modulo 10^9+7.\n\nSample Input 1\n\n2\n1 2\n\nSample Output 1\n\n9\n\nFirst, we will consider the order \"Block 1 -> Block 2\".\nIn the first operation, the cost of the operation is 1+2=3, as Block 1 and 2 are connected.\nIn the second operation, the cost of the operation is 2, as only Block 2 remains.\nThus, the total cost of the two operations for this order is 3+2=5.\n\nThen, we will consider the order \"Block 2 -> Block 1\".\nIn the first operation, the cost of the operation is 1+2=3, as Block 1 and 2 are connected.\nIn the second operation, the cost of the operation is 1, as only Block 1 remains.\nThus, the total cost of the two operations for this order is 3+1=4.\n\nTherefore, the answer is 5+4=9.\n\nSample Input 2\n\n4\n1 1 1 1\n\nSample Output 2\n\n212\n\nSample Input 3\n\n10\n1 2 4 8 16 32 64 128 256 512\n\nSample Output 3\n\n880971923", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 874, "cpu_time_ms": 56, "memory_kb": 2560}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s455190556", "group_id": "codeNet:p03238", "input_text": "a = io.read(\"*n\")\nif a == 1 then print(\"Hello World\")\nelse b, c = io.read(\"*n\", \"*n\") print(b + c)\nend\n", "language": "Lua", "metadata": {"date": 1560778562, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03238.html", "problem_id": "p03238", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03238/input.txt", "sample_output_relpath": "derived/input_output/data/p03238/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03238/Lua/s455190556.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s455190556", "user_id": "u120582723"}, "prompt_components": {"gold_output": "Hello World\n", "input_to_evaluate": "a = io.read(\"*n\")\nif a == 1 then print(\"Hello World\")\nelse b, c = io.read(\"*n\", \"*n\") print(b + c)\nend\n", "problem_context": "Score: 100 points\n\nProblem Statement\n\nIn 2020, AtCoder Inc. with an annual sales of more than one billion yen (the currency of Japan) has started a business in programming education.\n\nOne day, there was an exam where a one-year-old child must write a program that prints Hello World, and a two-year-old child must write a program that receives integers A, B and prints A+B.\n\nTakahashi, who is taking this exam, suddenly forgets his age.\n\nHe decides to write a program that first receives his age N (1 or 2) as input, then prints Hello World if N=1, and additionally receives integers A, B and prints A+B if N=2.\n\nWrite this program for him.\n\nConstraints\n\nN is 1 or 2.\n\nA is an integer between 1 and 9 (inclusive).\n\nB is an integer between 1 and 9 (inclusive).\n\nInput\n\nInput is given from Standard Input in one of the following formats:\n\n1\n\n2\nA\nB\n\nOutput\n\nIf N=1, print Hello World; if N=2, print A+B.\n\nSample Input 1\n\n1\n\nSample Output 1\n\nHello World\n\nAs N=1, Takahashi is one year old. Thus, we should print Hello World.\n\nSample Input 2\n\n2\n3\n5\n\nSample Output 2\n\n8\n\nAs N=2, Takahashi is two years old. Thus, we should print A+B, which is 8 since A=3 and B=5.", "sample_input": "1\n"}, "reference_outputs": ["Hello World\n"], "source_document_id": "p03238", "source_text": "Score: 100 points\n\nProblem Statement\n\nIn 2020, AtCoder Inc. with an annual sales of more than one billion yen (the currency of Japan) has started a business in programming education.\n\nOne day, there was an exam where a one-year-old child must write a program that prints Hello World, and a two-year-old child must write a program that receives integers A, B and prints A+B.\n\nTakahashi, who is taking this exam, suddenly forgets his age.\n\nHe decides to write a program that first receives his age N (1 or 2) as input, then prints Hello World if N=1, and additionally receives integers A, B and prints A+B if N=2.\n\nWrite this program for him.\n\nConstraints\n\nN is 1 or 2.\n\nA is an integer between 1 and 9 (inclusive).\n\nB is an integer between 1 and 9 (inclusive).\n\nInput\n\nInput is given from Standard Input in one of the following formats:\n\n1\n\n2\nA\nB\n\nOutput\n\nIf N=1, print Hello World; if N=2, print A+B.\n\nSample Input 1\n\n1\n\nSample Output 1\n\nHello World\n\nAs N=1, Takahashi is one year old. Thus, we should print Hello World.\n\nSample Input 2\n\n2\n3\n5\n\nSample Output 2\n\n8\n\nAs N=2, Takahashi is two years old. Thus, we should print A+B, which is 8 since A=3 and B=5.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 103, "cpu_time_ms": 7, "memory_kb": 760}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s630569892", "group_id": "codeNet:p03238", "input_text": "local n = tonumber(io.read())\nif n==1 then\n print(\"Hello World\")\nelse\n local a = tonumber(io.read())\n local b = tonumber(io.read())\n print(a+b)\nend", "language": "Lua", "metadata": {"date": 1544409975, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03238.html", "problem_id": "p03238", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03238/input.txt", "sample_output_relpath": "derived/input_output/data/p03238/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03238/Lua/s630569892.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s630569892", "user_id": "u030685402"}, "prompt_components": {"gold_output": "Hello World\n", "input_to_evaluate": "local n = tonumber(io.read())\nif n==1 then\n print(\"Hello World\")\nelse\n local a = tonumber(io.read())\n local b = tonumber(io.read())\n print(a+b)\nend", "problem_context": "Score: 100 points\n\nProblem Statement\n\nIn 2020, AtCoder Inc. with an annual sales of more than one billion yen (the currency of Japan) has started a business in programming education.\n\nOne day, there was an exam where a one-year-old child must write a program that prints Hello World, and a two-year-old child must write a program that receives integers A, B and prints A+B.\n\nTakahashi, who is taking this exam, suddenly forgets his age.\n\nHe decides to write a program that first receives his age N (1 or 2) as input, then prints Hello World if N=1, and additionally receives integers A, B and prints A+B if N=2.\n\nWrite this program for him.\n\nConstraints\n\nN is 1 or 2.\n\nA is an integer between 1 and 9 (inclusive).\n\nB is an integer between 1 and 9 (inclusive).\n\nInput\n\nInput is given from Standard Input in one of the following formats:\n\n1\n\n2\nA\nB\n\nOutput\n\nIf N=1, print Hello World; if N=2, print A+B.\n\nSample Input 1\n\n1\n\nSample Output 1\n\nHello World\n\nAs N=1, Takahashi is one year old. Thus, we should print Hello World.\n\nSample Input 2\n\n2\n3\n5\n\nSample Output 2\n\n8\n\nAs N=2, Takahashi is two years old. Thus, we should print A+B, which is 8 since A=3 and B=5.", "sample_input": "1\n"}, "reference_outputs": ["Hello World\n"], "source_document_id": "p03238", "source_text": "Score: 100 points\n\nProblem Statement\n\nIn 2020, AtCoder Inc. with an annual sales of more than one billion yen (the currency of Japan) has started a business in programming education.\n\nOne day, there was an exam where a one-year-old child must write a program that prints Hello World, and a two-year-old child must write a program that receives integers A, B and prints A+B.\n\nTakahashi, who is taking this exam, suddenly forgets his age.\n\nHe decides to write a program that first receives his age N (1 or 2) as input, then prints Hello World if N=1, and additionally receives integers A, B and prints A+B if N=2.\n\nWrite this program for him.\n\nConstraints\n\nN is 1 or 2.\n\nA is an integer between 1 and 9 (inclusive).\n\nB is an integer between 1 and 9 (inclusive).\n\nInput\n\nInput is given from Standard Input in one of the following formats:\n\n1\n\n2\nA\nB\n\nOutput\n\nIf N=1, print Hello World; if N=2, print A+B.\n\nSample Input 1\n\n1\n\nSample Output 1\n\nHello World\n\nAs N=1, Takahashi is one year old. Thus, we should print Hello World.\n\nSample Input 2\n\n2\n3\n5\n\nSample Output 2\n\n8\n\nAs N=2, Takahashi is two years old. Thus, we should print A+B, which is 8 since A=3 and B=5.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 151, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s798873481", "group_id": "codeNet:p03238", "input_text": "local n = io.read()\n\nif n == \"1\" then\n print(\"Hello World\")\nelse\n local a = tonumber(io.read())\n local b = tonumber(io.read())\n print(a+b)\nend\n", "language": "Lua", "metadata": {"date": 1538874134, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03238.html", "problem_id": "p03238", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03238/input.txt", "sample_output_relpath": "derived/input_output/data/p03238/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03238/Lua/s798873481.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s798873481", "user_id": "u061001716"}, "prompt_components": {"gold_output": "Hello World\n", "input_to_evaluate": "local n = io.read()\n\nif n == \"1\" then\n print(\"Hello World\")\nelse\n local a = tonumber(io.read())\n local b = tonumber(io.read())\n print(a+b)\nend\n", "problem_context": "Score: 100 points\n\nProblem Statement\n\nIn 2020, AtCoder Inc. with an annual sales of more than one billion yen (the currency of Japan) has started a business in programming education.\n\nOne day, there was an exam where a one-year-old child must write a program that prints Hello World, and a two-year-old child must write a program that receives integers A, B and prints A+B.\n\nTakahashi, who is taking this exam, suddenly forgets his age.\n\nHe decides to write a program that first receives his age N (1 or 2) as input, then prints Hello World if N=1, and additionally receives integers A, B and prints A+B if N=2.\n\nWrite this program for him.\n\nConstraints\n\nN is 1 or 2.\n\nA is an integer between 1 and 9 (inclusive).\n\nB is an integer between 1 and 9 (inclusive).\n\nInput\n\nInput is given from Standard Input in one of the following formats:\n\n1\n\n2\nA\nB\n\nOutput\n\nIf N=1, print Hello World; if N=2, print A+B.\n\nSample Input 1\n\n1\n\nSample Output 1\n\nHello World\n\nAs N=1, Takahashi is one year old. Thus, we should print Hello World.\n\nSample Input 2\n\n2\n3\n5\n\nSample Output 2\n\n8\n\nAs N=2, Takahashi is two years old. Thus, we should print A+B, which is 8 since A=3 and B=5.", "sample_input": "1\n"}, "reference_outputs": ["Hello World\n"], "source_document_id": "p03238", "source_text": "Score: 100 points\n\nProblem Statement\n\nIn 2020, AtCoder Inc. with an annual sales of more than one billion yen (the currency of Japan) has started a business in programming education.\n\nOne day, there was an exam where a one-year-old child must write a program that prints Hello World, and a two-year-old child must write a program that receives integers A, B and prints A+B.\n\nTakahashi, who is taking this exam, suddenly forgets his age.\n\nHe decides to write a program that first receives his age N (1 or 2) as input, then prints Hello World if N=1, and additionally receives integers A, B and prints A+B if N=2.\n\nWrite this program for him.\n\nConstraints\n\nN is 1 or 2.\n\nA is an integer between 1 and 9 (inclusive).\n\nB is an integer between 1 and 9 (inclusive).\n\nInput\n\nInput is given from Standard Input in one of the following formats:\n\n1\n\n2\nA\nB\n\nOutput\n\nIf N=1, print Hello World; if N=2, print A+B.\n\nSample Input 1\n\n1\n\nSample Output 1\n\nHello World\n\nAs N=1, Takahashi is one year old. Thus, we should print Hello World.\n\nSample Input 2\n\n2\n3\n5\n\nSample Output 2\n\n8\n\nAs N=2, Takahashi is two years old. Thus, we should print A+B, which is 8 since A=3 and B=5.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 147, "cpu_time_ms": 73, "memory_kb": 1008}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s477368721", "group_id": "codeNet:p03239", "input_text": "N = tonumber(io.read())\nT = tonumber(io.read())\n\nmax = 2000\ncnt = 0\nans = max\nwhile cnt < N do\n c = tonumber(io.read())\n t = tonumber(io.read())\n if t < N and c < ans then\n ans = c\n end\nend\n\nif ans >= max then\n e1 = \"TLE\"\n print(e1)\nelse\n print(ans)\nend", "language": "Lua", "metadata": {"date": 1540856612, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03239.html", "problem_id": "p03239", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03239/input.txt", "sample_output_relpath": "derived/input_output/data/p03239/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03239/Lua/s477368721.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s477368721", "user_id": "u017797845"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "N = tonumber(io.read())\nT = tonumber(io.read())\n\nmax = 2000\ncnt = 0\nans = max\nwhile cnt < N do\n c = tonumber(io.read())\n t = tonumber(io.read())\n if t < N and c < ans then\n ans = c\n end\nend\n\nif ans >= max then\n e1 = \"TLE\"\n print(e1)\nelse\n print(ans)\nend", "problem_context": "Score : 200 points\n\nProblem Statement\n\nWhen Mr. X is away from home, he has decided to use his smartwatch to search the best route to go back home, to participate in ABC.\n\nYou, the smartwatch, has found N routes to his home.\n\nIf Mr. X uses the i-th of these routes, he will get home in time t_i at cost c_i.\n\nFind the smallest cost of a route that takes not longer than time T.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 100\n\n1 \\leq T \\leq 1000\n\n1 \\leq c_i \\leq 1000\n\n1 \\leq t_i \\leq 1000\n\nThe pairs (c_i, t_i) are distinct.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN T\nc_1 t_1\nc_2 t_2\n:\nc_N t_N\n\nOutput\n\nPrint the smallest cost of a route that takes not longer than time T.\n\nIf there is no route that takes not longer than time T, print TLE instead.\n\nSample Input 1\n\n3 70\n7 60\n1 80\n4 50\n\nSample Output 1\n\n4\n\nThe first route gets him home at cost 7.\n\nThe second route takes longer than time T = 70.\n\nThe third route gets him home at cost 4.\n\nThus, the cost 4 of the third route is the minimum.\n\nSample Input 2\n\n4 3\n1 1000\n2 4\n3 1000\n4 500\n\nSample Output 2\n\nTLE\n\nThere is no route that takes not longer than time T = 3.\n\nSample Input 3\n\n5 9\n25 8\n5 9\n4 10\n1000 1000\n6 1\n\nSample Output 3\n\n5", "sample_input": "3 70\n7 60\n1 80\n4 50\n"}, "reference_outputs": ["4\n"], "source_document_id": "p03239", "source_text": "Score : 200 points\n\nProblem Statement\n\nWhen Mr. X is away from home, he has decided to use his smartwatch to search the best route to go back home, to participate in ABC.\n\nYou, the smartwatch, has found N routes to his home.\n\nIf Mr. X uses the i-th of these routes, he will get home in time t_i at cost c_i.\n\nFind the smallest cost of a route that takes not longer than time T.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 100\n\n1 \\leq T \\leq 1000\n\n1 \\leq c_i \\leq 1000\n\n1 \\leq t_i \\leq 1000\n\nThe pairs (c_i, t_i) are distinct.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN T\nc_1 t_1\nc_2 t_2\n:\nc_N t_N\n\nOutput\n\nPrint the smallest cost of a route that takes not longer than time T.\n\nIf there is no route that takes not longer than time T, print TLE instead.\n\nSample Input 1\n\n3 70\n7 60\n1 80\n4 50\n\nSample Output 1\n\n4\n\nThe first route gets him home at cost 7.\n\nThe second route takes longer than time T = 70.\n\nThe third route gets him home at cost 4.\n\nThus, the cost 4 of the third route is the minimum.\n\nSample Input 2\n\n4 3\n1 1000\n2 4\n3 1000\n4 500\n\nSample Output 2\n\nTLE\n\nThere is no route that takes not longer than time T = 3.\n\nSample Input 3\n\n5 9\n25 8\n5 9\n4 10\n1000 1000\n6 1\n\nSample Output 3\n\n5", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 284, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s965384215", "group_id": "codeNet:p03241", "input_text": "local n,m=io.read(\"n\",\"n\")\nif m%n==0 then\n print(m//n)\nelse\n local d={}\n for i=1,math.sqrt(m) do\n if m%i==0 then\n table.insert(d,i)\n table.insert(d,m//i)\n end\n end\n table.sort(d)\n\n local max=0\n for _,v in pairs(d) do\n if v*n<=m then\n max=math.max(max,v)\n end\n end\n print(max)\nend", "language": "Lua", "metadata": {"date": 1593400914, "filename_ext": "lua", "original_language": "Lua (Lua 5.3.5)", "problem_description_relpath": "problem_descriptions/p03241.html", "problem_id": "p03241", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03241/input.txt", "sample_output_relpath": "derived/input_output/data/p03241/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03241/Lua/s965384215.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s965384215", "user_id": "u045238009"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "local n,m=io.read(\"n\",\"n\")\nif m%n==0 then\n print(m//n)\nelse\n local d={}\n for i=1,math.sqrt(m) do\n if m%i==0 then\n table.insert(d,i)\n table.insert(d,m//i)\n end\n end\n table.sort(d)\n\n local max=0\n for _,v in pairs(d) do\n if v*n<=m then\n max=math.max(max,v)\n end\n end\n print(max)\nend", "problem_context": "Score : 400 points\n\nProblem Statement\n\nYou are given integers N and M.\n\nConsider a sequence a of length N consisting of positive integers such that a_1 + a_2 + ... + a_N = M. Find the maximum possible value of the greatest common divisor of a_1, a_2, ..., a_N.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^5\n\nN \\leq M \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\n\nOutput\n\nPrint the maximum possible value of the greatest common divisor of a sequence a_1, a_2, ..., a_N that satisfies the condition.\n\nSample Input 1\n\n3 14\n\nSample Output 1\n\n2\n\nConsider the sequence (a_1, a_2, a_3) = (2, 4, 8). Their greatest common divisor is 2, and this is the maximum value.\n\nSample Input 2\n\n10 123\n\nSample Output 2\n\n3\n\nSample Input 3\n\n100000 1000000000\n\nSample Output 3\n\n10000", "sample_input": "3 14\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03241", "source_text": "Score : 400 points\n\nProblem Statement\n\nYou are given integers N and M.\n\nConsider a sequence a of length N consisting of positive integers such that a_1 + a_2 + ... + a_N = M. Find the maximum possible value of the greatest common divisor of a_1, a_2, ..., a_N.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^5\n\nN \\leq M \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\n\nOutput\n\nPrint the maximum possible value of the greatest common divisor of a sequence a_1, a_2, ..., a_N that satisfies the condition.\n\nSample Input 1\n\n3 14\n\nSample Output 1\n\n2\n\nConsider the sequence (a_1, a_2, a_3) = (2, 4, 8). Their greatest common divisor is 2, and this is the maximum value.\n\nSample Input 2\n\n10 123\n\nSample Output 2\n\n3\n\nSample Input 3\n\n100000 1000000000\n\nSample Output 3\n\n10000", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 367, "cpu_time_ms": 7, "memory_kb": 2724}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s598660479", "group_id": "codeNet:p03241", "input_text": "local n,m=io.read(\"n\",\"n\")\nif m%n==0 then\n print(m//n)\nelse\n local d=0\n for i=2,math.sqrt(m) do\n if m%i==0 and i<=m/n then\n d=i\n end\n end\n print(d)\nend", "language": "Lua", "metadata": {"date": 1593399743, "filename_ext": "lua", "original_language": "Lua (Lua 5.3.5)", "problem_description_relpath": "problem_descriptions/p03241.html", "problem_id": "p03241", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03241/input.txt", "sample_output_relpath": "derived/input_output/data/p03241/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03241/Lua/s598660479.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s598660479", "user_id": "u045238009"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "local n,m=io.read(\"n\",\"n\")\nif m%n==0 then\n print(m//n)\nelse\n local d=0\n for i=2,math.sqrt(m) do\n if m%i==0 and i<=m/n then\n d=i\n end\n end\n print(d)\nend", "problem_context": "Score : 400 points\n\nProblem Statement\n\nYou are given integers N and M.\n\nConsider a sequence a of length N consisting of positive integers such that a_1 + a_2 + ... + a_N = M. Find the maximum possible value of the greatest common divisor of a_1, a_2, ..., a_N.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^5\n\nN \\leq M \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\n\nOutput\n\nPrint the maximum possible value of the greatest common divisor of a sequence a_1, a_2, ..., a_N that satisfies the condition.\n\nSample Input 1\n\n3 14\n\nSample Output 1\n\n2\n\nConsider the sequence (a_1, a_2, a_3) = (2, 4, 8). Their greatest common divisor is 2, and this is the maximum value.\n\nSample Input 2\n\n10 123\n\nSample Output 2\n\n3\n\nSample Input 3\n\n100000 1000000000\n\nSample Output 3\n\n10000", "sample_input": "3 14\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03241", "source_text": "Score : 400 points\n\nProblem Statement\n\nYou are given integers N and M.\n\nConsider a sequence a of length N consisting of positive integers such that a_1 + a_2 + ... + a_N = M. Find the maximum possible value of the greatest common divisor of a_1, a_2, ..., a_N.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^5\n\nN \\leq M \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\n\nOutput\n\nPrint the maximum possible value of the greatest common divisor of a sequence a_1, a_2, ..., a_N that satisfies the condition.\n\nSample Input 1\n\n3 14\n\nSample Output 1\n\n2\n\nConsider the sequence (a_1, a_2, a_3) = (2, 4, 8). Their greatest common divisor is 2, and this is the maximum value.\n\nSample Input 2\n\n10 123\n\nSample Output 2\n\n3\n\nSample Input 3\n\n100000 1000000000\n\nSample Output 3\n\n10000", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 191, "cpu_time_ms": 9, "memory_kb": 2792}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s909288901", "group_id": "codeNet:p03242", "input_text": "s=io.read()\nfor i = 1, 3 do\n if s:sub(i,i) == \"1\" then io.write(9) else io.write(1) end\nend\nio.write(\"\\n\")", "language": "Lua", "metadata": {"date": 1569556926, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03242.html", "problem_id": "p03242", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03242/input.txt", "sample_output_relpath": "derived/input_output/data/p03242/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03242/Lua/s909288901.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s909288901", "user_id": "u120582723"}, "prompt_components": {"gold_output": "991\n", "input_to_evaluate": "s=io.read()\nfor i = 1, 3 do\n if s:sub(i,i) == \"1\" then io.write(9) else io.write(1) end\nend\nio.write(\"\\n\")", "problem_context": "Score : 100 points\n\nProblem Statement\n\nCat Snuke is learning to write characters.\nToday, he practiced writing digits 1 and 9, but he did it the other way around.\n\nYou are given a three-digit integer n written by Snuke.\nPrint the integer obtained by replacing each digit 1 with 9 and each digit 9 with 1 in n.\n\nConstraints\n\n111 \\leq n \\leq 999\n\nn is an integer consisting of digits 1 and 9.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nn\n\nOutput\n\nPrint the integer obtained by replacing each occurrence of 1 with 9 and each occurrence of 9 with 1 in n.\n\nSample Input 1\n\n119\n\nSample Output 1\n\n991\n\nReplace the 9 in the ones place with 1, the 1 in the tens place with 9 and the 1 in the hundreds place with 9. The answer is 991.\n\nSample Input 2\n\n999\n\nSample Output 2\n\n111", "sample_input": "119\n"}, "reference_outputs": ["991\n"], "source_document_id": "p03242", "source_text": "Score : 100 points\n\nProblem Statement\n\nCat Snuke is learning to write characters.\nToday, he practiced writing digits 1 and 9, but he did it the other way around.\n\nYou are given a three-digit integer n written by Snuke.\nPrint the integer obtained by replacing each digit 1 with 9 and each digit 9 with 1 in n.\n\nConstraints\n\n111 \\leq n \\leq 999\n\nn is an integer consisting of digits 1 and 9.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nn\n\nOutput\n\nPrint the integer obtained by replacing each occurrence of 1 with 9 and each occurrence of 9 with 1 in n.\n\nSample Input 1\n\n119\n\nSample Output 1\n\n991\n\nReplace the 9 in the ones place with 1, the 1 in the tens place with 9 and the 1 in the hundreds place with 9. The answer is 991.\n\nSample Input 2\n\n999\n\nSample Output 2\n\n111", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 107, "cpu_time_ms": 10, "memory_kb": 760}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s752831757", "group_id": "codeNet:p03242", "input_text": "n=io.read(\"n\")\nprint(100*(10-n//100)+10*(10-n%100//10)+(10-n%10))", "language": "Lua", "metadata": {"date": 1550108825, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03242.html", "problem_id": "p03242", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03242/input.txt", "sample_output_relpath": "derived/input_output/data/p03242/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03242/Lua/s752831757.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s752831757", "user_id": "u015229643"}, "prompt_components": {"gold_output": "991\n", "input_to_evaluate": "n=io.read(\"n\")\nprint(100*(10-n//100)+10*(10-n%100//10)+(10-n%10))", "problem_context": "Score : 100 points\n\nProblem Statement\n\nCat Snuke is learning to write characters.\nToday, he practiced writing digits 1 and 9, but he did it the other way around.\n\nYou are given a three-digit integer n written by Snuke.\nPrint the integer obtained by replacing each digit 1 with 9 and each digit 9 with 1 in n.\n\nConstraints\n\n111 \\leq n \\leq 999\n\nn is an integer consisting of digits 1 and 9.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nn\n\nOutput\n\nPrint the integer obtained by replacing each occurrence of 1 with 9 and each occurrence of 9 with 1 in n.\n\nSample Input 1\n\n119\n\nSample Output 1\n\n991\n\nReplace the 9 in the ones place with 1, the 1 in the tens place with 9 and the 1 in the hundreds place with 9. The answer is 991.\n\nSample Input 2\n\n999\n\nSample Output 2\n\n111", "sample_input": "119\n"}, "reference_outputs": ["991\n"], "source_document_id": "p03242", "source_text": "Score : 100 points\n\nProblem Statement\n\nCat Snuke is learning to write characters.\nToday, he practiced writing digits 1 and 9, but he did it the other way around.\n\nYou are given a three-digit integer n written by Snuke.\nPrint the integer obtained by replacing each digit 1 with 9 and each digit 9 with 1 in n.\n\nConstraints\n\n111 \\leq n \\leq 999\n\nn is an integer consisting of digits 1 and 9.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nn\n\nOutput\n\nPrint the integer obtained by replacing each occurrence of 1 with 9 and each occurrence of 9 with 1 in n.\n\nSample Input 1\n\n119\n\nSample Output 1\n\n991\n\nReplace the 9 in the ones place with 1, the 1 in the tens place with 9 and the 1 in the hundreds place with 9. The answer is 991.\n\nSample Input 2\n\n999\n\nSample Output 2\n\n111", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 65, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s111654464", "group_id": "codeNet:p03243", "input_text": "n=io.read(\"*n\")\nprint(math.floor((n+110)/111)*111)", "language": "Lua", "metadata": {"date": 1538779696, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p03243.html", "problem_id": "p03243", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03243/input.txt", "sample_output_relpath": "derived/input_output/data/p03243/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03243/Lua/s111654464.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s111654464", "user_id": "u781091740"}, "prompt_components": {"gold_output": "111\n", "input_to_evaluate": "n=io.read(\"*n\")\nprint(math.floor((n+110)/111)*111)", "problem_context": "Score : 200 points\n\nProblem Statement\n\nKurohashi has never participated in AtCoder Beginner Contest (ABC).\n\nThe next ABC to be held is ABC N (the N-th ABC ever held).\nKurohashi wants to make his debut in some ABC x such that all the digits of x in base ten are the same.\n\nWhat is the earliest ABC where Kurohashi can make his debut?\n\nConstraints\n\n100 \\leq N \\leq 999\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nIf the earliest ABC where Kurohashi can make his debut is ABC n, print n.\n\nSample Input 1\n\n111\n\nSample Output 1\n\n111\n\nThe next ABC to be held is ABC 111, where Kurohashi can make his debut.\n\nSample Input 2\n\n112\n\nSample Output 2\n\n222\n\nThe next ABC to be held is ABC 112, which means Kurohashi can no longer participate in ABC 111.\nAmong the ABCs where Kurohashi can make his debut, the earliest one is ABC 222.\n\nSample Input 3\n\n750\n\nSample Output 3\n\n777", "sample_input": "111\n"}, "reference_outputs": ["111\n"], "source_document_id": "p03243", "source_text": "Score : 200 points\n\nProblem Statement\n\nKurohashi has never participated in AtCoder Beginner Contest (ABC).\n\nThe next ABC to be held is ABC N (the N-th ABC ever held).\nKurohashi wants to make his debut in some ABC x such that all the digits of x in base ten are the same.\n\nWhat is the earliest ABC where Kurohashi can make his debut?\n\nConstraints\n\n100 \\leq N \\leq 999\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nIf the earliest ABC where Kurohashi can make his debut is ABC n, print n.\n\nSample Input 1\n\n111\n\nSample Output 1\n\n111\n\nThe next ABC to be held is ABC 111, where Kurohashi can make his debut.\n\nSample Input 2\n\n112\n\nSample Output 2\n\n222\n\nThe next ABC to be held is ABC 112, which means Kurohashi can no longer participate in ABC 111.\nAmong the ABCs where Kurohashi can make his debut, the earliest one is ABC 222.\n\nSample Input 3\n\n750\n\nSample Output 3\n\n777", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 50, "cpu_time_ms": 2, "memory_kb": 256}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s788560267", "group_id": "codeNet:p03243", "input_text": "n=io.read(\"*n\")\nwhile 1 do\n\ts={}\n\ta=n\n\tcnt=0\n\twhile a~=0 do\n\t\tif s[a%10]==nil then\n\t\t\tcnt=cnt+1\n\t\tend\n\t\ts[a%10]=1\n\t\ta=math.floor(a/10)\n\tend\n\tif cnt==1 then\n\t\tprint(n)\n\t\tos.exit()\n\tend\n\tn=n+1\nend", "language": "Lua", "metadata": {"date": 1538779635, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p03243.html", "problem_id": "p03243", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03243/input.txt", "sample_output_relpath": "derived/input_output/data/p03243/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03243/Lua/s788560267.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s788560267", "user_id": "u781091740"}, "prompt_components": {"gold_output": "111\n", "input_to_evaluate": "n=io.read(\"*n\")\nwhile 1 do\n\ts={}\n\ta=n\n\tcnt=0\n\twhile a~=0 do\n\t\tif s[a%10]==nil then\n\t\t\tcnt=cnt+1\n\t\tend\n\t\ts[a%10]=1\n\t\ta=math.floor(a/10)\n\tend\n\tif cnt==1 then\n\t\tprint(n)\n\t\tos.exit()\n\tend\n\tn=n+1\nend", "problem_context": "Score : 200 points\n\nProblem Statement\n\nKurohashi has never participated in AtCoder Beginner Contest (ABC).\n\nThe next ABC to be held is ABC N (the N-th ABC ever held).\nKurohashi wants to make his debut in some ABC x such that all the digits of x in base ten are the same.\n\nWhat is the earliest ABC where Kurohashi can make his debut?\n\nConstraints\n\n100 \\leq N \\leq 999\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nIf the earliest ABC where Kurohashi can make his debut is ABC n, print n.\n\nSample Input 1\n\n111\n\nSample Output 1\n\n111\n\nThe next ABC to be held is ABC 111, where Kurohashi can make his debut.\n\nSample Input 2\n\n112\n\nSample Output 2\n\n222\n\nThe next ABC to be held is ABC 112, which means Kurohashi can no longer participate in ABC 111.\nAmong the ABCs where Kurohashi can make his debut, the earliest one is ABC 222.\n\nSample Input 3\n\n750\n\nSample Output 3\n\n777", "sample_input": "111\n"}, "reference_outputs": ["111\n"], "source_document_id": "p03243", "source_text": "Score : 200 points\n\nProblem Statement\n\nKurohashi has never participated in AtCoder Beginner Contest (ABC).\n\nThe next ABC to be held is ABC N (the N-th ABC ever held).\nKurohashi wants to make his debut in some ABC x such that all the digits of x in base ten are the same.\n\nWhat is the earliest ABC where Kurohashi can make his debut?\n\nConstraints\n\n100 \\leq N \\leq 999\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nIf the earliest ABC where Kurohashi can make his debut is ABC n, print n.\n\nSample Input 1\n\n111\n\nSample Output 1\n\n111\n\nThe next ABC to be held is ABC 111, where Kurohashi can make his debut.\n\nSample Input 2\n\n112\n\nSample Output 2\n\n222\n\nThe next ABC to be held is ABC 112, which means Kurohashi can no longer participate in ABC 111.\nAmong the ABCs where Kurohashi can make his debut, the earliest one is ABC 222.\n\nSample Input 3\n\n750\n\nSample Output 3\n\n777", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 194, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s326262585", "group_id": "codeNet:p03244", "input_text": "n=io.read(\"*n\",\"*l\")\nv={}\nfor i=1,n do\n x=io.read(\"*n\")\n if i%2==1 then\n if not v[x] then\n v[x]={1,0}\n else\n v[x][1]=v[x][1]+1\n end\n else\n if not v[x] then\n v[x]={0,1}\n else\n v[x][2]=v[x][2]+1\n end\n end\nend\n\ntable.sort(v, function(a,b)\n return a[1]= 0 then\n x = x - A[i]\n counter = counter + 1\n end\nend\nprint(counter)", "language": "Lua", "metadata": {"date": 1586936734, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03254.html", "problem_id": "p03254", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03254/input.txt", "sample_output_relpath": "derived/input_output/data/p03254/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03254/Lua/s308329537.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s308329537", "user_id": "u045238009"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "local N, x = io.read(\"*n\", \"*n\")\nlocal A = {}\nfor i = 1, N do\n A[i] = io.read(\"*n\")\nend\ntable.sort(A)\n\nlocal counter = 0\nfor i = 1, N do\n if x - A[i] >= 0 then\n x = x - A[i]\n counter = counter + 1\n end\nend\nprint(counter)", "problem_context": "Score : 200 points\n\nProblem Statement\n\nThere are N children, numbered 1, 2, ..., N.\n\nSnuke has decided to distribute x sweets among them.\nHe needs to give out all the x sweets, but some of the children may get zero sweets.\n\nFor each i (1 \\leq i \\leq N), Child i will be happy if he/she gets exactly a_i sweets.\nSnuke is trying to maximize the number of happy children by optimally distributing the sweets.\nFind the maximum possible number of happy children.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 100\n\n1 \\leq x \\leq 10^9\n\n1 \\leq a_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN x\na_1 a_2 ... a_N\n\nOutput\n\nPrint the maximum possible number of happy children.\n\nSample Input 1\n\n3 70\n20 30 10\n\nSample Output 1\n\n2\n\nOne optimal way to distribute sweets is (20, 30, 20).\n\nSample Input 2\n\n3 10\n20 30 10\n\nSample Output 2\n\n1\n\nThe optimal way to distribute sweets is (0, 0, 10).\n\nSample Input 3\n\n4 1111\n1 10 100 1000\n\nSample Output 3\n\n4\n\nThe optimal way to distribute sweets is (1, 10, 100, 1000).\n\nSample Input 4\n\n2 10\n20 20\n\nSample Output 4\n\n0\n\nNo children will be happy, no matter how the sweets are distributed.", "sample_input": "3 70\n20 30 10\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03254", "source_text": "Score : 200 points\n\nProblem Statement\n\nThere are N children, numbered 1, 2, ..., N.\n\nSnuke has decided to distribute x sweets among them.\nHe needs to give out all the x sweets, but some of the children may get zero sweets.\n\nFor each i (1 \\leq i \\leq N), Child i will be happy if he/she gets exactly a_i sweets.\nSnuke is trying to maximize the number of happy children by optimally distributing the sweets.\nFind the maximum possible number of happy children.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 100\n\n1 \\leq x \\leq 10^9\n\n1 \\leq a_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN x\na_1 a_2 ... a_N\n\nOutput\n\nPrint the maximum possible number of happy children.\n\nSample Input 1\n\n3 70\n20 30 10\n\nSample Output 1\n\n2\n\nOne optimal way to distribute sweets is (20, 30, 20).\n\nSample Input 2\n\n3 10\n20 30 10\n\nSample Output 2\n\n1\n\nThe optimal way to distribute sweets is (0, 0, 10).\n\nSample Input 3\n\n4 1111\n1 10 100 1000\n\nSample Output 3\n\n4\n\nThe optimal way to distribute sweets is (1, 10, 100, 1000).\n\nSample Input 4\n\n2 10\n20 20\n\nSample Output 4\n\n0\n\nNo children will be happy, no matter how the sweets are distributed.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 243, "cpu_time_ms": 11, "memory_kb": 888}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s132435470", "group_id": "codeNet:p03254", "input_text": "function split(str,sep)\n\tlocal ret = {}\n\tlocal pos = 0\n\twhile true do\n\t\tlocal pp = string.find(str,sep,pos+1)\n\t\tif pp == nil then\n\t\t\ttable.insert(ret,string.sub(str,pos+1))\n\t\t\tbreak\n\t\telse\n\t\t\ttable.insert(ret,string.sub(str,pos+1,pp-1))\n\t\t\tpos = pp\n\t\tend\n\tend\n\treturn ret\nend\na = io.read()\nt = split(a, \" \")\nn, x = tonumber(t[1]), tonumber(t[2])\ns = {}\nfor i = 1, n do\n\ts[i] = io.read(\"*n\")\nend\ntable.sort(s)\nret = 0\nfor i = 1, n do\n\tif x >= s[i] then\n\t\tx = x - s[i]\n\t\tret = ret + 1\n\telse\n\t\tbreak\n\tend\nend\nif x > 0 and ret > 0 then\n\tret = ret - 1\nend\nprint(ret)", "language": "Lua", "metadata": {"date": 1542341417, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03254.html", "problem_id": "p03254", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03254/input.txt", "sample_output_relpath": "derived/input_output/data/p03254/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03254/Lua/s132435470.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s132435470", "user_id": "u353919145"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "function split(str,sep)\n\tlocal ret = {}\n\tlocal pos = 0\n\twhile true do\n\t\tlocal pp = string.find(str,sep,pos+1)\n\t\tif pp == nil then\n\t\t\ttable.insert(ret,string.sub(str,pos+1))\n\t\t\tbreak\n\t\telse\n\t\t\ttable.insert(ret,string.sub(str,pos+1,pp-1))\n\t\t\tpos = pp\n\t\tend\n\tend\n\treturn ret\nend\na = io.read()\nt = split(a, \" \")\nn, x = tonumber(t[1]), tonumber(t[2])\ns = {}\nfor i = 1, n do\n\ts[i] = io.read(\"*n\")\nend\ntable.sort(s)\nret = 0\nfor i = 1, n do\n\tif x >= s[i] then\n\t\tx = x - s[i]\n\t\tret = ret + 1\n\telse\n\t\tbreak\n\tend\nend\nif x > 0 and ret > 0 then\n\tret = ret - 1\nend\nprint(ret)", "problem_context": "Score : 200 points\n\nProblem Statement\n\nThere are N children, numbered 1, 2, ..., N.\n\nSnuke has decided to distribute x sweets among them.\nHe needs to give out all the x sweets, but some of the children may get zero sweets.\n\nFor each i (1 \\leq i \\leq N), Child i will be happy if he/she gets exactly a_i sweets.\nSnuke is trying to maximize the number of happy children by optimally distributing the sweets.\nFind the maximum possible number of happy children.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 100\n\n1 \\leq x \\leq 10^9\n\n1 \\leq a_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN x\na_1 a_2 ... a_N\n\nOutput\n\nPrint the maximum possible number of happy children.\n\nSample Input 1\n\n3 70\n20 30 10\n\nSample Output 1\n\n2\n\nOne optimal way to distribute sweets is (20, 30, 20).\n\nSample Input 2\n\n3 10\n20 30 10\n\nSample Output 2\n\n1\n\nThe optimal way to distribute sweets is (0, 0, 10).\n\nSample Input 3\n\n4 1111\n1 10 100 1000\n\nSample Output 3\n\n4\n\nThe optimal way to distribute sweets is (1, 10, 100, 1000).\n\nSample Input 4\n\n2 10\n20 20\n\nSample Output 4\n\n0\n\nNo children will be happy, no matter how the sweets are distributed.", "sample_input": "3 70\n20 30 10\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03254", "source_text": "Score : 200 points\n\nProblem Statement\n\nThere are N children, numbered 1, 2, ..., N.\n\nSnuke has decided to distribute x sweets among them.\nHe needs to give out all the x sweets, but some of the children may get zero sweets.\n\nFor each i (1 \\leq i \\leq N), Child i will be happy if he/she gets exactly a_i sweets.\nSnuke is trying to maximize the number of happy children by optimally distributing the sweets.\nFind the maximum possible number of happy children.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 100\n\n1 \\leq x \\leq 10^9\n\n1 \\leq a_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN x\na_1 a_2 ... a_N\n\nOutput\n\nPrint the maximum possible number of happy children.\n\nSample Input 1\n\n3 70\n20 30 10\n\nSample Output 1\n\n2\n\nOne optimal way to distribute sweets is (20, 30, 20).\n\nSample Input 2\n\n3 10\n20 30 10\n\nSample Output 2\n\n1\n\nThe optimal way to distribute sweets is (0, 0, 10).\n\nSample Input 3\n\n4 1111\n1 10 100 1000\n\nSample Output 3\n\n4\n\nThe optimal way to distribute sweets is (1, 10, 100, 1000).\n\nSample Input 4\n\n2 10\n20 20\n\nSample Output 4\n\n0\n\nNo children will be happy, no matter how the sweets are distributed.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 561, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s033018767", "group_id": "codeNet:p03254", "input_text": "function split(str,sep)\n\tlocal ret = {}\n\tlocal pos = 0\n\twhile true do\n\t\tlocal pp = string.find(str,sep,pos+1)\n\t\tif pp == nil then\n\t\t\ttable.insert(ret,string.sub(str,pos+1))\n\t\t\tbreak\n\t\telse\n\t\t\ttable.insert(ret,string.sub(str,pos+1,pp-1))\n\t\t\tpos = pp\n\t\tend\n\tend\n\treturn ret\nend\na = io.read()\nt = split(a, \" \")\nn, x = tonumber(t[1]), tonumber(t[2])\nb = io.read()\nt = split(b, \" \")\ns = {}\nfor i = 1, n do\n\ts[i] = tonumber(t[i])\nend\ntable.sort(s)\nret = 0\nfor i = 1, n do\n\tif x >= s[i] then\n\t\tx = x - s[i]\n\t\tret = ret + 1\n\telse\n\t\tbreak\n\tend\nend\nif x > 0 and ret > 0 then\n\tret = ret - 1\nend\nprint(ret)\n", "language": "Lua", "metadata": {"date": 1542341416, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03254.html", "problem_id": "p03254", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03254/input.txt", "sample_output_relpath": "derived/input_output/data/p03254/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03254/Lua/s033018767.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s033018767", "user_id": "u863370423"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "function split(str,sep)\n\tlocal ret = {}\n\tlocal pos = 0\n\twhile true do\n\t\tlocal pp = string.find(str,sep,pos+1)\n\t\tif pp == nil then\n\t\t\ttable.insert(ret,string.sub(str,pos+1))\n\t\t\tbreak\n\t\telse\n\t\t\ttable.insert(ret,string.sub(str,pos+1,pp-1))\n\t\t\tpos = pp\n\t\tend\n\tend\n\treturn ret\nend\na = io.read()\nt = split(a, \" \")\nn, x = tonumber(t[1]), tonumber(t[2])\nb = io.read()\nt = split(b, \" \")\ns = {}\nfor i = 1, n do\n\ts[i] = tonumber(t[i])\nend\ntable.sort(s)\nret = 0\nfor i = 1, n do\n\tif x >= s[i] then\n\t\tx = x - s[i]\n\t\tret = ret + 1\n\telse\n\t\tbreak\n\tend\nend\nif x > 0 and ret > 0 then\n\tret = ret - 1\nend\nprint(ret)\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nThere are N children, numbered 1, 2, ..., N.\n\nSnuke has decided to distribute x sweets among them.\nHe needs to give out all the x sweets, but some of the children may get zero sweets.\n\nFor each i (1 \\leq i \\leq N), Child i will be happy if he/she gets exactly a_i sweets.\nSnuke is trying to maximize the number of happy children by optimally distributing the sweets.\nFind the maximum possible number of happy children.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 100\n\n1 \\leq x \\leq 10^9\n\n1 \\leq a_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN x\na_1 a_2 ... a_N\n\nOutput\n\nPrint the maximum possible number of happy children.\n\nSample Input 1\n\n3 70\n20 30 10\n\nSample Output 1\n\n2\n\nOne optimal way to distribute sweets is (20, 30, 20).\n\nSample Input 2\n\n3 10\n20 30 10\n\nSample Output 2\n\n1\n\nThe optimal way to distribute sweets is (0, 0, 10).\n\nSample Input 3\n\n4 1111\n1 10 100 1000\n\nSample Output 3\n\n4\n\nThe optimal way to distribute sweets is (1, 10, 100, 1000).\n\nSample Input 4\n\n2 10\n20 20\n\nSample Output 4\n\n0\n\nNo children will be happy, no matter how the sweets are distributed.", "sample_input": "3 70\n20 30 10\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03254", "source_text": "Score : 200 points\n\nProblem Statement\n\nThere are N children, numbered 1, 2, ..., N.\n\nSnuke has decided to distribute x sweets among them.\nHe needs to give out all the x sweets, but some of the children may get zero sweets.\n\nFor each i (1 \\leq i \\leq N), Child i will be happy if he/she gets exactly a_i sweets.\nSnuke is trying to maximize the number of happy children by optimally distributing the sweets.\nFind the maximum possible number of happy children.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 100\n\n1 \\leq x \\leq 10^9\n\n1 \\leq a_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN x\na_1 a_2 ... a_N\n\nOutput\n\nPrint the maximum possible number of happy children.\n\nSample Input 1\n\n3 70\n20 30 10\n\nSample Output 1\n\n2\n\nOne optimal way to distribute sweets is (20, 30, 20).\n\nSample Input 2\n\n3 10\n20 30 10\n\nSample Output 2\n\n1\n\nThe optimal way to distribute sweets is (0, 0, 10).\n\nSample Input 3\n\n4 1111\n1 10 100 1000\n\nSample Output 3\n\n4\n\nThe optimal way to distribute sweets is (1, 10, 100, 1000).\n\nSample Input 4\n\n2 10\n20 20\n\nSample Output 4\n\n0\n\nNo children will be happy, no matter how the sweets are distributed.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 595, "cpu_time_ms": 7, "memory_kb": 884}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s953967153", "group_id": "codeNet:p03256", "input_text": "local n, m = io.read(\"*n\", \"*n\", \"*l\")\nlocal s = io.read()\nlocal v = {}\nlocal edge = {}\nlocal acnt, bcnt = {}, {}\nfor i = 1, n do\n v[i] = s:byte(i) - 64\n edge[i] = {}\n acnt[i], bcnt[i] = 0, 0\nend\nfor i = 1, m do\n local a, b = io.read(\"*n\", \"*n\")\n table.insert(edge[a], b)\n table.insert(edge[b], a)\n if v[a] == 1 then\n acnt[b] = acnt[b] + 1\n else\n bcnt[b] = bcnt[b] + 1\n end\n if v[b] == 1 then\n acnt[a] = acnt[a] + 1\n else\n bcnt[a] = bcnt[a] + 1\n end\nend\nlocal tasks = {}\nfor i = 1, n do\n if acnt[i] * bcnt[i] == 0 then\n table.insert(tasks, i)\n end\nend\nlocal done = 0\nwhile done < #tasks do\n done = done + 1\n local src = tasks[done]\n local cnttbl = v[src] == 1 and acnt or bcnt\n for j = 1, #edge[src] do\n local dst = edge[src][j]\n if 0 < acnt[dst] and 0 < bcnt[dst] then\n cnttbl[dst] = cnttbl[dst] - 1\n if cnttbl[dst] == 0 then\n table.insert(tasks, dst)\n end\n end\n end\nend\nprint(#tasks == n and \"No\" or \"Yes\")\n", "language": "Lua", "metadata": {"date": 1595615150, "filename_ext": "lua", "original_language": "Lua (LuaJIT 2.1.0)", "problem_description_relpath": "problem_descriptions/p03256.html", "problem_id": "p03256", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03256/input.txt", "sample_output_relpath": "derived/input_output/data/p03256/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03256/Lua/s953967153.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s953967153", "user_id": "u120582723"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "local n, m = io.read(\"*n\", \"*n\", \"*l\")\nlocal s = io.read()\nlocal v = {}\nlocal edge = {}\nlocal acnt, bcnt = {}, {}\nfor i = 1, n do\n v[i] = s:byte(i) - 64\n edge[i] = {}\n acnt[i], bcnt[i] = 0, 0\nend\nfor i = 1, m do\n local a, b = io.read(\"*n\", \"*n\")\n table.insert(edge[a], b)\n table.insert(edge[b], a)\n if v[a] == 1 then\n acnt[b] = acnt[b] + 1\n else\n bcnt[b] = bcnt[b] + 1\n end\n if v[b] == 1 then\n acnt[a] = acnt[a] + 1\n else\n bcnt[a] = bcnt[a] + 1\n end\nend\nlocal tasks = {}\nfor i = 1, n do\n if acnt[i] * bcnt[i] == 0 then\n table.insert(tasks, i)\n end\nend\nlocal done = 0\nwhile done < #tasks do\n done = done + 1\n local src = tasks[done]\n local cnttbl = v[src] == 1 and acnt or bcnt\n for j = 1, #edge[src] do\n local dst = edge[src][j]\n if 0 < acnt[dst] and 0 < bcnt[dst] then\n cnttbl[dst] = cnttbl[dst] - 1\n if cnttbl[dst] == 0 then\n table.insert(tasks, dst)\n end\n end\n end\nend\nprint(#tasks == n and \"No\" or \"Yes\")\n", "problem_context": "Score : 900 points\n\nProblem Statement\n\nYou are given an undirected graph consisting of N vertices and M edges.\nThe vertices are numbered 1 to N, and the edges are numbered 1 to M.\nIn addition, each vertex has a label, A or B. The label of Vertex i is s_i.\nEdge i bidirectionally connects vertex a_i and b_i.\n\nThe phantom thief Nusook likes to choose some vertex as the startpoint and traverse an edge zero or more times.\nToday, he will make a string after traveling as above, by placing the labels of the visited vertices in the order visited, beginning from the startpoint.\n\nFor example, in a graph where Vertex 1 has the label A and Vertex 2 has the label B, if Nusook travels along the path 1 \\rightarrow 2 \\rightarrow 1 \\rightarrow 2 \\rightarrow 2, the resulting string is ABABB.\n\nDetermine if Nusook can make all strings consisting of A and B.\n\nConstraints\n\n2 \\leq N \\leq 2 \\times 10^{5}\n\n1 \\leq M \\leq 2 \\times 10^{5}\n\n|s| = N\n\ns_i is A or B.\n\n1 \\leq a_i, b_i \\leq N\n\nThe given graph may NOT be simple or connected.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\ns\na_1 b_1\n:\na_{M} b_{M}\n\nOutput\n\nIf Nusook can make all strings consisting of A and B, print Yes; otherwise, print No.\n\nSample Input 1\n\n2 3\nAB\n1 1\n1 2\n2 2\n\nSample Output 1\n\nYes\n\nSince Nusook can visit Vertex 1 and Vertex 2 in any way he likes, he can make all strings consisting of A and B.\n\nSample Input 2\n\n4 3\nABAB\n1 2\n2 3\n3 1\n\nSample Output 2\n\nNo\n\nFor example, Nusook cannot make BB.\n\nThe given graph may not be connected.\n\nSample Input 3\n\n13 23\nABAAAABBBBAAB\n7 1\n10 6\n1 11\n2 10\n2 8\n2 11\n11 12\n8 3\n7 12\n11 2\n13 13\n11 9\n4 1\n9 7\n9 6\n8 13\n8 6\n4 10\n8 7\n4 3\n2 1\n8 12\n6 9\n\nSample Output 3\n\nYes\n\nSample Input 4\n\n13 17\nBBABBBAABABBA\n7 1\n7 9\n11 12\n3 9\n11 9\n2 1\n11 5\n12 11\n10 8\n1 11\n1 8\n7 7\n9 10\n8 8\n8 12\n6 2\n13 11\n\nSample Output 4\n\nNo", "sample_input": "2 3\nAB\n1 1\n1 2\n2 2\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03256", "source_text": "Score : 900 points\n\nProblem Statement\n\nYou are given an undirected graph consisting of N vertices and M edges.\nThe vertices are numbered 1 to N, and the edges are numbered 1 to M.\nIn addition, each vertex has a label, A or B. The label of Vertex i is s_i.\nEdge i bidirectionally connects vertex a_i and b_i.\n\nThe phantom thief Nusook likes to choose some vertex as the startpoint and traverse an edge zero or more times.\nToday, he will make a string after traveling as above, by placing the labels of the visited vertices in the order visited, beginning from the startpoint.\n\nFor example, in a graph where Vertex 1 has the label A and Vertex 2 has the label B, if Nusook travels along the path 1 \\rightarrow 2 \\rightarrow 1 \\rightarrow 2 \\rightarrow 2, the resulting string is ABABB.\n\nDetermine if Nusook can make all strings consisting of A and B.\n\nConstraints\n\n2 \\leq N \\leq 2 \\times 10^{5}\n\n1 \\leq M \\leq 2 \\times 10^{5}\n\n|s| = N\n\ns_i is A or B.\n\n1 \\leq a_i, b_i \\leq N\n\nThe given graph may NOT be simple or connected.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\ns\na_1 b_1\n:\na_{M} b_{M}\n\nOutput\n\nIf Nusook can make all strings consisting of A and B, print Yes; otherwise, print No.\n\nSample Input 1\n\n2 3\nAB\n1 1\n1 2\n2 2\n\nSample Output 1\n\nYes\n\nSince Nusook can visit Vertex 1 and Vertex 2 in any way he likes, he can make all strings consisting of A and B.\n\nSample Input 2\n\n4 3\nABAB\n1 2\n2 3\n3 1\n\nSample Output 2\n\nNo\n\nFor example, Nusook cannot make BB.\n\nThe given graph may not be connected.\n\nSample Input 3\n\n13 23\nABAAAABBBBAAB\n7 1\n10 6\n1 11\n2 10\n2 8\n2 11\n11 12\n8 3\n7 12\n11 2\n13 13\n11 9\n4 1\n9 7\n9 6\n8 13\n8 6\n4 10\n8 7\n4 3\n2 1\n8 12\n6 9\n\nSample Output 3\n\nYes\n\nSample Input 4\n\n13 17\nBBABBBAABABBA\n7 1\n7 9\n11 12\n3 9\n11 9\n2 1\n11 5\n12 11\n10 8\n1 11\n1 8\n7 7\n9 10\n8 8\n8 12\n6 2\n13 11\n\nSample Output 4\n\nNo", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 974, "cpu_time_ms": 224, "memory_kb": 27268}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s315117865", "group_id": "codeNet:p03263", "input_text": "local h, w = io.read(\"*n\", \"*n\")\n\nlocal function getindex(i_h, i_w)\n return i_w + (i_h - 1) * w\nend\n\nlocal map = {}\nfor i = 1, h * w do map[i] = 0 end\nfor i_h = 1, h do\n for i_w = 1, w do\n local idx = getindex(i_h, i_w)\n map[idx] = io.read(\"*n\")\n end\nend\n\nlocal command = {}\n\nfor i_h = 1, h do\n local inc = i_h % 2 == 1 and 1 or -1\n local bg = i_h % 2 == 1 and 1 or w\n local ed = i_h % 2 == 1 and w or 1\n for i_w = bg, ed, inc do\n local src = getindex(i_h, i_w)\n if i_w == ed then\n if i_h ~= h then\n if map[src] % 2 == 1 then\n local dst = getindex(i_h + 1, i_w)\n local tmp = {i_h, i_w, i_h + 1, i_w}\n table.insert(command, tmp)\n map[src], map[dst] = map[src] - 1, map[dst] + 1\n end\n end\n else\n local dst = getindex(i_h, i_w + inc)\n if map[src] % 2 == 1 then\n local tmp = {i_h, i_w, i_h, i_w + inc}\n table.insert(command, tmp)\n map[src], map[dst] = map[src] - 1, map[dst] + 1\n end\n end\n end\nend\nprint(#command)\nfor i = 1, #command do\n print(table.concat(command[i], \" \"))\nend\n", "language": "Lua", "metadata": {"date": 1563889523, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03263.html", "problem_id": "p03263", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03263/input.txt", "sample_output_relpath": "derived/input_output/data/p03263/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03263/Lua/s315117865.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s315117865", "user_id": "u120582723"}, "prompt_components": {"gold_output": "3\n2 2 2 3\n1 1 1 2\n1 3 1 2\n", "input_to_evaluate": "local h, w = io.read(\"*n\", \"*n\")\n\nlocal function getindex(i_h, i_w)\n return i_w + (i_h - 1) * w\nend\n\nlocal map = {}\nfor i = 1, h * w do map[i] = 0 end\nfor i_h = 1, h do\n for i_w = 1, w do\n local idx = getindex(i_h, i_w)\n map[idx] = io.read(\"*n\")\n end\nend\n\nlocal command = {}\n\nfor i_h = 1, h do\n local inc = i_h % 2 == 1 and 1 or -1\n local bg = i_h % 2 == 1 and 1 or w\n local ed = i_h % 2 == 1 and w or 1\n for i_w = bg, ed, inc do\n local src = getindex(i_h, i_w)\n if i_w == ed then\n if i_h ~= h then\n if map[src] % 2 == 1 then\n local dst = getindex(i_h + 1, i_w)\n local tmp = {i_h, i_w, i_h + 1, i_w}\n table.insert(command, tmp)\n map[src], map[dst] = map[src] - 1, map[dst] + 1\n end\n end\n else\n local dst = getindex(i_h, i_w + inc)\n if map[src] % 2 == 1 then\n local tmp = {i_h, i_w, i_h, i_w + inc}\n table.insert(command, tmp)\n map[src], map[dst] = map[src] - 1, map[dst] + 1\n end\n end\n end\nend\nprint(#command)\nfor i = 1, #command do\n print(table.concat(command[i], \" \"))\nend\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nThere is a grid of square cells with H horizontal rows and W vertical columns. The cell at the i-th row and the j-th column will be denoted as Cell (i, j).\n\nIn Cell (i, j), a_{ij} coins are placed.\n\nYou can perform the following operation any number of times:\n\nOperation: Choose a cell that was not chosen before and contains one or more coins, then move one of those coins to a vertically or horizontally adjacent cell.\n\nMaximize the number of cells containing an even number of coins.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq H, W \\leq 500\n\n0 \\leq a_{ij} \\leq 9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\na_{11} a_{12} ... a_{1W}\na_{21} a_{22} ... a_{2W}\n:\na_{H1} a_{H2} ... a_{HW}\n\nOutput\n\nPrint a sequence of operations that maximizes the number of cells containing an even number of coins, in the following format:\n\nN\ny_1 x_1 y_1' x_1'\ny_2 x_2 y_2' x_2'\n:\ny_N x_N y_N' x_N'\n\nThat is, in the first line, print an integer N between 0 and H \\times W (inclusive), representing the number of operations.\n\nIn the (i+1)-th line (1 \\leq i \\leq N), print four integers y_i, x_i, y_i' and x_i' (1 \\leq y_i, y_i' \\leq H and 1 \\leq x_i, x_i' \\leq W), representing the i-th operation. These four integers represents the operation of moving one of the coins placed in Cell (y_i, x_i) to a vertically or horizontally adjacent cell, (y_i', x_i').\n\nNote that if the specified operation violates the specification in the problem statement or the output format is invalid, it will result in Wrong Answer.\n\nSample Input 1\n\n2 3\n1 2 3\n0 1 1\n\nSample Output 1\n\n3\n2 2 2 3\n1 1 1 2\n1 3 1 2\n\nEvery cell contains an even number of coins after the following sequence of operations:\n\nMove the coin in Cell (2, 2) to Cell (2, 3).\n\nMove the coin in Cell (1, 1) to Cell (1, 2).\n\nMove one of the coins in Cell (1, 3) to Cell (1, 2).\n\nSample Input 2\n\n3 2\n1 0\n2 1\n1 0\n\nSample Output 2\n\n3\n1 1 1 2\n1 2 2 2\n3 1 3 2\n\nSample Input 3\n\n1 5\n9 9 9 9 9\n\nSample Output 3\n\n2\n1 1 1 2\n1 3 1 4", "sample_input": "2 3\n1 2 3\n0 1 1\n"}, "reference_outputs": ["3\n2 2 2 3\n1 1 1 2\n1 3 1 2\n"], "source_document_id": "p03263", "source_text": "Score : 400 points\n\nProblem Statement\n\nThere is a grid of square cells with H horizontal rows and W vertical columns. The cell at the i-th row and the j-th column will be denoted as Cell (i, j).\n\nIn Cell (i, j), a_{ij} coins are placed.\n\nYou can perform the following operation any number of times:\n\nOperation: Choose a cell that was not chosen before and contains one or more coins, then move one of those coins to a vertically or horizontally adjacent cell.\n\nMaximize the number of cells containing an even number of coins.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq H, W \\leq 500\n\n0 \\leq a_{ij} \\leq 9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\na_{11} a_{12} ... a_{1W}\na_{21} a_{22} ... a_{2W}\n:\na_{H1} a_{H2} ... a_{HW}\n\nOutput\n\nPrint a sequence of operations that maximizes the number of cells containing an even number of coins, in the following format:\n\nN\ny_1 x_1 y_1' x_1'\ny_2 x_2 y_2' x_2'\n:\ny_N x_N y_N' x_N'\n\nThat is, in the first line, print an integer N between 0 and H \\times W (inclusive), representing the number of operations.\n\nIn the (i+1)-th line (1 \\leq i \\leq N), print four integers y_i, x_i, y_i' and x_i' (1 \\leq y_i, y_i' \\leq H and 1 \\leq x_i, x_i' \\leq W), representing the i-th operation. These four integers represents the operation of moving one of the coins placed in Cell (y_i, x_i) to a vertically or horizontally adjacent cell, (y_i', x_i').\n\nNote that if the specified operation violates the specification in the problem statement or the output format is invalid, it will result in Wrong Answer.\n\nSample Input 1\n\n2 3\n1 2 3\n0 1 1\n\nSample Output 1\n\n3\n2 2 2 3\n1 1 1 2\n1 3 1 2\n\nEvery cell contains an even number of coins after the following sequence of operations:\n\nMove the coin in Cell (2, 2) to Cell (2, 3).\n\nMove the coin in Cell (1, 1) to Cell (1, 2).\n\nMove one of the coins in Cell (1, 3) to Cell (1, 2).\n\nSample Input 2\n\n3 2\n1 0\n2 1\n1 0\n\nSample Output 2\n\n3\n1 1 1 2\n1 2 2 2\n3 1 3 2\n\nSample Input 3\n\n1 5\n9 9 9 9 9\n\nSample Output 3\n\n2\n1 1 1 2\n1 3 1 4", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1098, "cpu_time_ms": 658, "memory_kb": 32888}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s777530077", "group_id": "codeNet:p03264", "input_text": "K=io.read(\"n\")\nif K%2==0 then\n print(K*K/4)\n else\n print((K*K-1)/4)\nend", "language": "Lua", "metadata": {"date": 1550255863, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03264.html", "problem_id": "p03264", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03264/input.txt", "sample_output_relpath": "derived/input_output/data/p03264/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03264/Lua/s777530077.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s777530077", "user_id": "u015229643"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "K=io.read(\"n\")\nif K%2==0 then\n print(K*K/4)\n else\n print((K*K-1)/4)\nend", "problem_context": "Score : 100 points\n\nProblem Statement\n\nFind the number of ways to choose a pair of an even number and an odd number from the positive integers between 1 and K (inclusive). The order does not matter.\n\nConstraints\n\n2\\leq K\\leq 100\n\nK is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nK\n\nOutput\n\nPrint the number of ways to choose a pair of an even number and an odd number from the positive integers between 1 and K (inclusive).\n\nSample Input 1\n\n3\n\nSample Output 1\n\n2\n\nTwo pairs can be chosen: (2,1) and (2,3).\n\nSample Input 2\n\n6\n\nSample Output 2\n\n9\n\nSample Input 3\n\n11\n\nSample Output 3\n\n30\n\nSample Input 4\n\n50\n\nSample Output 4\n\n625", "sample_input": "3\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03264", "source_text": "Score : 100 points\n\nProblem Statement\n\nFind the number of ways to choose a pair of an even number and an odd number from the positive integers between 1 and K (inclusive). The order does not matter.\n\nConstraints\n\n2\\leq K\\leq 100\n\nK is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nK\n\nOutput\n\nPrint the number of ways to choose a pair of an even number and an odd number from the positive integers between 1 and K (inclusive).\n\nSample Input 1\n\n3\n\nSample Output 1\n\n2\n\nTwo pairs can be chosen: (2,1) and (2,3).\n\nSample Input 2\n\n6\n\nSample Output 2\n\n9\n\nSample Input 3\n\n11\n\nSample Output 3\n\n30\n\nSample Input 4\n\n50\n\nSample Output 4\n\n625", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 74, "cpu_time_ms": 2, "memory_kb": 380}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s850345669", "group_id": "codeNet:p03264", "input_text": "K=io.read(\"n\")\nif K%2==0 then\n print(K*K/4)\n else\n print((K//2)*((K//2)+1))\nend", "language": "Lua", "metadata": {"date": 1550255748, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03264.html", "problem_id": "p03264", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03264/input.txt", "sample_output_relpath": "derived/input_output/data/p03264/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03264/Lua/s850345669.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s850345669", "user_id": "u015229643"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "K=io.read(\"n\")\nif K%2==0 then\n print(K*K/4)\n else\n print((K//2)*((K//2)+1))\nend", "problem_context": "Score : 100 points\n\nProblem Statement\n\nFind the number of ways to choose a pair of an even number and an odd number from the positive integers between 1 and K (inclusive). The order does not matter.\n\nConstraints\n\n2\\leq K\\leq 100\n\nK is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nK\n\nOutput\n\nPrint the number of ways to choose a pair of an even number and an odd number from the positive integers between 1 and K (inclusive).\n\nSample Input 1\n\n3\n\nSample Output 1\n\n2\n\nTwo pairs can be chosen: (2,1) and (2,3).\n\nSample Input 2\n\n6\n\nSample Output 2\n\n9\n\nSample Input 3\n\n11\n\nSample Output 3\n\n30\n\nSample Input 4\n\n50\n\nSample Output 4\n\n625", "sample_input": "3\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03264", "source_text": "Score : 100 points\n\nProblem Statement\n\nFind the number of ways to choose a pair of an even number and an odd number from the positive integers between 1 and K (inclusive). The order does not matter.\n\nConstraints\n\n2\\leq K\\leq 100\n\nK is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nK\n\nOutput\n\nPrint the number of ways to choose a pair of an even number and an odd number from the positive integers between 1 and K (inclusive).\n\nSample Input 1\n\n3\n\nSample Output 1\n\n2\n\nTwo pairs can be chosen: (2,1) and (2,3).\n\nSample Input 2\n\n6\n\nSample Output 2\n\n9\n\nSample Input 3\n\n11\n\nSample Output 3\n\n30\n\nSample Input 4\n\n50\n\nSample Output 4\n\n625", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 82, "cpu_time_ms": 8, "memory_kb": 760}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s197224705", "group_id": "codeNet:p03265", "input_text": "local x1,y1,x2,y2=io.read(\"n\",\"n\",\"n\",\"n\")\nlocal dx,dy=x2-x1,y2-y1\nlocal adx,ady=math.abs(dx),math.abs(dy)\nlocal sdx,sdy=1,1\nif dx<0 then\n sdx=-1\nend\nif dy<0 then\n sdy=-1\nend\nlocal x3=x2 - sdy*ady\nlocal y3=y2 + sdx*adx\nlocal x4=x3 - sdx*adx\nlocal y4=y3 - sdy*ady\nprint(x3,y3,x4,y4)\n", "language": "Lua", "metadata": {"date": 1590710207, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03265.html", "problem_id": "p03265", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03265/input.txt", "sample_output_relpath": "derived/input_output/data/p03265/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03265/Lua/s197224705.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s197224705", "user_id": "u162773977"}, "prompt_components": {"gold_output": "-1 1 -1 0\n", "input_to_evaluate": "local x1,y1,x2,y2=io.read(\"n\",\"n\",\"n\",\"n\")\nlocal dx,dy=x2-x1,y2-y1\nlocal adx,ady=math.abs(dx),math.abs(dy)\nlocal sdx,sdy=1,1\nif dx<0 then\n sdx=-1\nend\nif dy<0 then\n sdy=-1\nend\nlocal x3=x2 - sdy*ady\nlocal y3=y2 + sdx*adx\nlocal x4=x3 - sdx*adx\nlocal y4=y3 - sdy*ady\nprint(x3,y3,x4,y4)\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nThere is a square in the xy-plane. The coordinates of its four vertices are (x_1,y_1),(x_2,y_2),(x_3,y_3) and (x_4,y_4) in counter-clockwise order.\n(Assume that the positive x-axis points right, and the positive y-axis points up.)\n\nTakahashi remembers (x_1,y_1) and (x_2,y_2), but he has forgot (x_3,y_3) and (x_4,y_4).\n\nGiven x_1,x_2,y_1,y_2, restore x_3,y_3,x_4,y_4. It can be shown that x_3,y_3,x_4 and y_4 uniquely exist and have integer values.\n\nConstraints\n\n|x_1|,|y_1|,|x_2|,|y_2| \\leq 100\n\n(x_1,y_1) ≠ (x_2,y_2)\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nx_1 y_1 x_2 y_2\n\nOutput\n\nPrint x_3,y_3,x_4 and y_4 as integers, in this order.\n\nSample Input 1\n\n0 0 0 1\n\nSample Output 1\n\n-1 1 -1 0\n\n(0,0),(0,1),(-1,1),(-1,0) is the four vertices of a square in counter-clockwise order.\nNote that (x_3,y_3)=(1,1),(x_4,y_4)=(1,0) is not accepted, as the vertices are in clockwise order.\n\nSample Input 2\n\n2 3 6 6\n\nSample Output 2\n\n3 10 -1 7\n\nSample Input 3\n\n31 -41 -59 26\n\nSample Output 3\n\n-126 -64 -36 -131", "sample_input": "0 0 0 1\n"}, "reference_outputs": ["-1 1 -1 0\n"], "source_document_id": "p03265", "source_text": "Score : 200 points\n\nProblem Statement\n\nThere is a square in the xy-plane. The coordinates of its four vertices are (x_1,y_1),(x_2,y_2),(x_3,y_3) and (x_4,y_4) in counter-clockwise order.\n(Assume that the positive x-axis points right, and the positive y-axis points up.)\n\nTakahashi remembers (x_1,y_1) and (x_2,y_2), but he has forgot (x_3,y_3) and (x_4,y_4).\n\nGiven x_1,x_2,y_1,y_2, restore x_3,y_3,x_4,y_4. It can be shown that x_3,y_3,x_4 and y_4 uniquely exist and have integer values.\n\nConstraints\n\n|x_1|,|y_1|,|x_2|,|y_2| \\leq 100\n\n(x_1,y_1) ≠ (x_2,y_2)\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nx_1 y_1 x_2 y_2\n\nOutput\n\nPrint x_3,y_3,x_4 and y_4 as integers, in this order.\n\nSample Input 1\n\n0 0 0 1\n\nSample Output 1\n\n-1 1 -1 0\n\n(0,0),(0,1),(-1,1),(-1,0) is the four vertices of a square in counter-clockwise order.\nNote that (x_3,y_3)=(1,1),(x_4,y_4)=(1,0) is not accepted, as the vertices are in clockwise order.\n\nSample Input 2\n\n2 3 6 6\n\nSample Output 2\n\n3 10 -1 7\n\nSample Input 3\n\n31 -41 -59 26\n\nSample Output 3\n\n-126 -64 -36 -131", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 284, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s475157156", "group_id": "codeNet:p03266", "input_text": "N=io.read(\"n\")\nK=io.read(\"n\")\nif K%2==1 then\n s=0\n for i=K,N,K do\n s=s+1\n end\n s=s*s*s\nend\nif K%2==0 then\n s=0\n for i=K//2,N,K//2 do\n s=s+1\n end\n if s%2==0 then\n s=s*s*s//4\n else\n s=math.ceil((s//2)^3+(s//2+1)^3)\n end\nend\nprint(s)", "language": "Lua", "metadata": {"date": 1550272308, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03266.html", "problem_id": "p03266", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03266/input.txt", "sample_output_relpath": "derived/input_output/data/p03266/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03266/Lua/s475157156.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s475157156", "user_id": "u015229643"}, "prompt_components": {"gold_output": "9\n", "input_to_evaluate": "N=io.read(\"n\")\nK=io.read(\"n\")\nif K%2==1 then\n s=0\n for i=K,N,K do\n s=s+1\n end\n s=s*s*s\nend\nif K%2==0 then\n s=0\n for i=K//2,N,K//2 do\n s=s+1\n end\n if s%2==0 then\n s=s*s*s//4\n else\n s=math.ceil((s//2)^3+(s//2+1)^3)\n end\nend\nprint(s)", "problem_context": "Score : 300 points\n\nProblem Statement\n\nYou are given 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.\nThe order of a,b,c does matter, and some of them can be the same.\n\nConstraints\n\n1 \\leq N,K \\leq 2\\times 10^5\n\nN and K are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\n\nOutput\n\nPrint 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.\n\nSample Input 1\n\n3 2\n\nSample Output 1\n\n9\n\n(1,1,1),(1,1,3),(1,3,1),(1,3,3),(2,2,2),(3,1,1),(3,1,3),(3,3,1) and (3,3,3) satisfy the condition.\n\nSample Input 2\n\n5 3\n\nSample Output 2\n\n1\n\nSample Input 3\n\n31415 9265\n\nSample Output 3\n\n27\n\nSample Input 4\n\n35897 932\n\nSample Output 4\n\n114191", "sample_input": "3 2\n"}, "reference_outputs": ["9\n"], "source_document_id": "p03266", "source_text": "Score : 300 points\n\nProblem Statement\n\nYou are given 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.\nThe order of a,b,c does matter, and some of them can be the same.\n\nConstraints\n\n1 \\leq N,K \\leq 2\\times 10^5\n\nN and K are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\n\nOutput\n\nPrint 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.\n\nSample Input 1\n\n3 2\n\nSample Output 1\n\n9\n\n(1,1,1),(1,1,3),(1,3,1),(1,3,3),(2,2,2),(3,1,1),(3,1,3),(3,3,1) and (3,3,3) satisfy the condition.\n\nSample Input 2\n\n5 3\n\nSample Output 2\n\n1\n\nSample Input 3\n\n31415 9265\n\nSample Output 3\n\n27\n\nSample Input 4\n\n35897 932\n\nSample Output 4\n\n114191", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 252, "cpu_time_ms": 13, "memory_kb": 376}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s379491908", "group_id": "codeNet:p03268", "input_text": "local n,a=io.read(\"*n\",\"*n\")\nif a%2==1 then\n x=math.floor(n/a)\n print(x*x*x)\nelse\n x=math.floor((n+math.floor(a/2))/a)\n y=math.floor(n/a)\n print(x*x*x + y*y*y)\nend", "language": "Lua", "metadata": {"date": 1577047000, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p03268.html", "problem_id": "p03268", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03268/input.txt", "sample_output_relpath": "derived/input_output/data/p03268/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03268/Lua/s379491908.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s379491908", "user_id": "u373958718"}, "prompt_components": {"gold_output": "9\n", "input_to_evaluate": "local n,a=io.read(\"*n\",\"*n\")\nif a%2==1 then\n x=math.floor(n/a)\n print(x*x*x)\nelse\n x=math.floor((n+math.floor(a/2))/a)\n y=math.floor(n/a)\n print(x*x*x + y*y*y)\nend", "problem_context": "Score : 300 points\n\nProblem Statement\n\nYou are given 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.\nThe order of a,b,c does matter, and some of them can be the same.\n\nConstraints\n\n1 \\leq N,K \\leq 2\\times 10^5\n\nN and K are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\n\nOutput\n\nPrint 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.\n\nSample Input 1\n\n3 2\n\nSample Output 1\n\n9\n\n(1,1,1),(1,1,3),(1,3,1),(1,3,3),(2,2,2),(3,1,1),(3,1,3),(3,3,1) and (3,3,3) satisfy the condition.\n\nSample Input 2\n\n5 3\n\nSample Output 2\n\n1\n\nSample Input 3\n\n31415 9265\n\nSample Output 3\n\n27\n\nSample Input 4\n\n35897 932\n\nSample Output 4\n\n114191", "sample_input": "3 2\n"}, "reference_outputs": ["9\n"], "source_document_id": "p03268", "source_text": "Score : 300 points\n\nProblem Statement\n\nYou are given 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.\nThe order of a,b,c does matter, and some of them can be the same.\n\nConstraints\n\n1 \\leq N,K \\leq 2\\times 10^5\n\nN and K are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\n\nOutput\n\nPrint 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.\n\nSample Input 1\n\n3 2\n\nSample Output 1\n\n9\n\n(1,1,1),(1,1,3),(1,3,1),(1,3,3),(2,2,2),(3,1,1),(3,1,3),(3,3,1) and (3,3,3) satisfy the condition.\n\nSample Input 2\n\n5 3\n\nSample Output 2\n\n1\n\nSample Input 3\n\n31415 9265\n\nSample Output 3\n\n27\n\nSample Input 4\n\n35897 932\n\nSample Output 4\n\n114191", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 168, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s631972201", "group_id": "codeNet:p03272", "input_text": "a, b = io.read(\"*n\", \"*n\")\nprint(a + 1 - b)", "language": "Lua", "metadata": {"date": 1574166104, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03272.html", "problem_id": "p03272", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03272/input.txt", "sample_output_relpath": "derived/input_output/data/p03272/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03272/Lua/s631972201.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s631972201", "user_id": "u120582723"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "a, b = io.read(\"*n\", \"*n\")\nprint(a + 1 - b)", "problem_context": "Score : 100 points\n\nProblem Statement\n\nThere is an N-car train.\n\nYou are given an integer i. Find the value of j such that the following statement is true: \"the i-th car from the front of the train is the j-th car from the back.\"\n\nConstraints\n\n1 \\leq N \\leq 100\n\n1 \\leq i \\leq N\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN i\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n4 2\n\nSample Output 1\n\n3\n\nThe second car from the front of a 4-car train is the third car from the back.\n\nSample Input 2\n\n1 1\n\nSample Output 2\n\n1\n\nSample Input 3\n\n15 11\n\nSample Output 3\n\n5", "sample_input": "4 2\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03272", "source_text": "Score : 100 points\n\nProblem Statement\n\nThere is an N-car train.\n\nYou are given an integer i. Find the value of j such that the following statement is true: \"the i-th car from the front of the train is the j-th car from the back.\"\n\nConstraints\n\n1 \\leq N \\leq 100\n\n1 \\leq i \\leq N\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN i\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n4 2\n\nSample Output 1\n\n3\n\nThe second car from the front of a 4-car train is the third car from the back.\n\nSample Input 2\n\n1 1\n\nSample Output 2\n\n1\n\nSample Input 3\n\n15 11\n\nSample Output 3\n\n5", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 43, "cpu_time_ms": 8, "memory_kb": 760}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s453516377", "group_id": "codeNet:p03273", "input_text": "local read = io.read\nlocal concat = table.concat\nlocal char = string.char\n\nlocal h, w = read(\"n\", \"n\", \"l\")\nlocal black = string.byte(\"#\")\n\nlocal a_t = {}\nfor i = 1, h do\n\ta_t[i] = read()\nend\n\nlocal del_i_t = {}\nfor i = 1, h do\n\tlocal is_breaked = false\n\tfor j = 1, w do\n\t\tif a_t[i]:byte(j) == black then\n\t\t\tis_breaked = true\n\t\t\tbreak\n\t\tend\n\tend\n\tif not is_breaked then\n\t\tdel_i_t[i] = true\n\tend\nend\n\nlocal del_j_t = {}\nfor j = 1, w do\n\tlocal is_breaked = false\n\tfor i = 1, h do\n\t\tif a_t[i]:byte(j) == black then\n\t\t\tis_breaked = true\n\t\t\tbreak\n\t\tend\n\tend\n\tif not is_breaked then\n\t\tdel_j_t[j] = true\n\tend\nend\n\nlocal copy_a_t = {}\nlocal last_i = 0\nfor i = 1, h do\n\tif not del_i_t[i] then\n\t\tlast_i = last_i + 1\n\t\tlocal last_j = 0\n\t\tcopy_a_t[last_i] = {}\n\t\tfor j = 1, w do\n\t\t\tif not del_j_t[j] then\n\t\t\t\tlast_j = last_j + 1\n\t\t\t\tcopy_a_t[last_i][last_j] = a_t[i]:sub(j, j) --char(a_t[i]:byte(j))\n\t\t\tend\n\t\tend\n\tend\nend\n\nlocal out_t = {}\nfor i = 1, #copy_a_t do\n\tout_t[i] = concat(copy_a_t[i], \"\")\nend\n\nprint(concat(out_t, \"\\n\"))\n", "language": "Lua", "metadata": {"date": 1599099264, "filename_ext": "lua", "original_language": "Lua (Lua 5.3.5)", "problem_description_relpath": "problem_descriptions/p03273.html", "problem_id": "p03273", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03273/input.txt", "sample_output_relpath": "derived/input_output/data/p03273/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03273/Lua/s453516377.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s453516377", "user_id": "u793881115"}, "prompt_components": {"gold_output": "###\n###\n.##\n", "input_to_evaluate": "local read = io.read\nlocal concat = table.concat\nlocal char = string.char\n\nlocal h, w = read(\"n\", \"n\", \"l\")\nlocal black = string.byte(\"#\")\n\nlocal a_t = {}\nfor i = 1, h do\n\ta_t[i] = read()\nend\n\nlocal del_i_t = {}\nfor i = 1, h do\n\tlocal is_breaked = false\n\tfor j = 1, w do\n\t\tif a_t[i]:byte(j) == black then\n\t\t\tis_breaked = true\n\t\t\tbreak\n\t\tend\n\tend\n\tif not is_breaked then\n\t\tdel_i_t[i] = true\n\tend\nend\n\nlocal del_j_t = {}\nfor j = 1, w do\n\tlocal is_breaked = false\n\tfor i = 1, h do\n\t\tif a_t[i]:byte(j) == black then\n\t\t\tis_breaked = true\n\t\t\tbreak\n\t\tend\n\tend\n\tif not is_breaked then\n\t\tdel_j_t[j] = true\n\tend\nend\n\nlocal copy_a_t = {}\nlocal last_i = 0\nfor i = 1, h do\n\tif not del_i_t[i] then\n\t\tlast_i = last_i + 1\n\t\tlocal last_j = 0\n\t\tcopy_a_t[last_i] = {}\n\t\tfor j = 1, w do\n\t\t\tif not del_j_t[j] then\n\t\t\t\tlast_j = last_j + 1\n\t\t\t\tcopy_a_t[last_i][last_j] = a_t[i]:sub(j, j) --char(a_t[i]:byte(j))\n\t\t\tend\n\t\tend\n\tend\nend\n\nlocal out_t = {}\nfor i = 1, #copy_a_t do\n\tout_t[i] = concat(copy_a_t[i], \"\")\nend\n\nprint(concat(out_t, \"\\n\"))\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nThere is a grid of squares with H horizontal rows and W vertical columns.\nThe square at the i-th row from the top and the j-th column from the left is represented as (i, j).\nEach square is black or white.\nThe color of the square is given as an H-by-W matrix (a_{i, j}).\nIf a_{i, j} is ., the square (i, j) is white; if a_{i, j} is #, the square (i, j) is black.\n\nSnuke is compressing this grid.\nHe will do so by repeatedly performing the following operation while there is a row or column that consists only of white squares:\n\nOperation: choose any one row or column that consists only of white squares, remove it and delete the space between the rows or columns.\n\nIt can be shown that the final state of the grid is uniquely determined regardless of what row or column is chosen in each operation.\nFind the final state of the grid.\n\nConstraints\n\n1 \\leq H, W \\leq 100\n\na_{i, j} is . or #.\n\nThere is at least one black square in the whole grid.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\na_{1, 1}...a_{1, W}\n:\na_{H, 1}...a_{H, W}\n\nOutput\n\nPrint the final state of the grid in the same format as input (without the numbers of rows and columns); see the samples for clarity.\n\nSample Input 1\n\n4 4\n##.#\n....\n##.#\n.#.#\n\nSample Output 1\n\n###\n###\n.##\n\nThe second row and the third column in the original grid will be removed.\n\nSample Input 2\n\n3 3\n#..\n.#.\n..#\n\nSample Output 2\n\n#..\n.#.\n..#\n\nAs there is no row or column that consists only of white squares, no operation will be performed.\n\nSample Input 3\n\n4 5\n.....\n.....\n..#..\n.....\n\nSample Output 3\n\n#\n\nSample Input 4\n\n7 6\n......\n....#.\n.#....\n..#...\n..#...\n......\n.#..#.\n\nSample Output 4\n\n..#\n#..\n.#.\n.#.\n#.#", "sample_input": "4 4\n##.#\n....\n##.#\n.#.#\n"}, "reference_outputs": ["###\n###\n.##\n"], "source_document_id": "p03273", "source_text": "Score : 200 points\n\nProblem Statement\n\nThere is a grid of squares with H horizontal rows and W vertical columns.\nThe square at the i-th row from the top and the j-th column from the left is represented as (i, j).\nEach square is black or white.\nThe color of the square is given as an H-by-W matrix (a_{i, j}).\nIf a_{i, j} is ., the square (i, j) is white; if a_{i, j} is #, the square (i, j) is black.\n\nSnuke is compressing this grid.\nHe will do so by repeatedly performing the following operation while there is a row or column that consists only of white squares:\n\nOperation: choose any one row or column that consists only of white squares, remove it and delete the space between the rows or columns.\n\nIt can be shown that the final state of the grid is uniquely determined regardless of what row or column is chosen in each operation.\nFind the final state of the grid.\n\nConstraints\n\n1 \\leq H, W \\leq 100\n\na_{i, j} is . or #.\n\nThere is at least one black square in the whole grid.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\na_{1, 1}...a_{1, W}\n:\na_{H, 1}...a_{H, W}\n\nOutput\n\nPrint the final state of the grid in the same format as input (without the numbers of rows and columns); see the samples for clarity.\n\nSample Input 1\n\n4 4\n##.#\n....\n##.#\n.#.#\n\nSample Output 1\n\n###\n###\n.##\n\nThe second row and the third column in the original grid will be removed.\n\nSample Input 2\n\n3 3\n#..\n.#.\n..#\n\nSample Output 2\n\n#..\n.#.\n..#\n\nAs there is no row or column that consists only of white squares, no operation will be performed.\n\nSample Input 3\n\n4 5\n.....\n.....\n..#..\n.....\n\nSample Output 3\n\n#\n\nSample Input 4\n\n7 6\n......\n....#.\n.#....\n..#...\n..#...\n......\n.#..#.\n\nSample Output 4\n\n..#\n#..\n.#.\n.#.\n#.#", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1020, "cpu_time_ms": 14, "memory_kb": 2852}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s250587226", "group_id": "codeNet:p03273", "input_text": "local read = io.read\nlocal concat = table.concat\nlocal char = string.char\n\nlocal h, w = read(\"n\", \"n\", \"l\")\nlocal black = string.byte(\"#\")\n\nlocal a_t = {}\nfor i = 1, h do\n\ta_t[i] = read()\nend\n\nlocal del_i_t = {}\nfor i = 1, h do\n\tlocal is_breaked = false\n\tfor j = 1, w do\n\t\tif a_t[i]:byte(j) == black then\n\t\t\tis_breaked = true\n\t\t\tbreak\n\t\tend\n\tend\n\tif not is_breaked then\n\t\tdel_i_t[i] = true\n\tend\nend\n\nlocal del_j_t = {}\nfor j = 1, w do\n\tlocal is_breaked = false\n\tfor i = 1, h do\n\t\tif a_t[i]:byte(j) == black then\n\t\t\tis_breaked = true\n\t\t\tbreak\n\t\tend\n\tend\n\tif not is_breaked then\n\t\tdel_j_t[j] = true\n\tend\nend\n\nlocal copy_a_t = {}\nlocal last_i = 0\nfor i = 1, h do\n\tif not del_i_t[i] then\n\t\tlast_i = last_i + 1\n\t\tlocal last_j = 0\n\t\tcopy_a_t[last_i] = {}\n\t\tfor j = 1, w do\n\t\t\tif not del_j_t[j] then\n\t\t\t\tlast_j = last_j + 1\n\t\t\t\tcopy_a_t[last_i][last_j] = char(a_t[i]:byte(j))\n\t\t\tend\n\t\tend\n\tend\nend\n\nlocal out_t = {}\nfor i = 1, #copy_a_t do\n\tout_t[i] = concat(copy_a_t[i], \"\")\nend\n\nprint(concat(out_t, \"\\n\"))\n", "language": "Lua", "metadata": {"date": 1599099042, "filename_ext": "lua", "original_language": "Lua (Lua 5.3.5)", "problem_description_relpath": "problem_descriptions/p03273.html", "problem_id": "p03273", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03273/input.txt", "sample_output_relpath": "derived/input_output/data/p03273/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03273/Lua/s250587226.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s250587226", "user_id": "u793881115"}, "prompt_components": {"gold_output": "###\n###\n.##\n", "input_to_evaluate": "local read = io.read\nlocal concat = table.concat\nlocal char = string.char\n\nlocal h, w = read(\"n\", \"n\", \"l\")\nlocal black = string.byte(\"#\")\n\nlocal a_t = {}\nfor i = 1, h do\n\ta_t[i] = read()\nend\n\nlocal del_i_t = {}\nfor i = 1, h do\n\tlocal is_breaked = false\n\tfor j = 1, w do\n\t\tif a_t[i]:byte(j) == black then\n\t\t\tis_breaked = true\n\t\t\tbreak\n\t\tend\n\tend\n\tif not is_breaked then\n\t\tdel_i_t[i] = true\n\tend\nend\n\nlocal del_j_t = {}\nfor j = 1, w do\n\tlocal is_breaked = false\n\tfor i = 1, h do\n\t\tif a_t[i]:byte(j) == black then\n\t\t\tis_breaked = true\n\t\t\tbreak\n\t\tend\n\tend\n\tif not is_breaked then\n\t\tdel_j_t[j] = true\n\tend\nend\n\nlocal copy_a_t = {}\nlocal last_i = 0\nfor i = 1, h do\n\tif not del_i_t[i] then\n\t\tlast_i = last_i + 1\n\t\tlocal last_j = 0\n\t\tcopy_a_t[last_i] = {}\n\t\tfor j = 1, w do\n\t\t\tif not del_j_t[j] then\n\t\t\t\tlast_j = last_j + 1\n\t\t\t\tcopy_a_t[last_i][last_j] = char(a_t[i]:byte(j))\n\t\t\tend\n\t\tend\n\tend\nend\n\nlocal out_t = {}\nfor i = 1, #copy_a_t do\n\tout_t[i] = concat(copy_a_t[i], \"\")\nend\n\nprint(concat(out_t, \"\\n\"))\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nThere is a grid of squares with H horizontal rows and W vertical columns.\nThe square at the i-th row from the top and the j-th column from the left is represented as (i, j).\nEach square is black or white.\nThe color of the square is given as an H-by-W matrix (a_{i, j}).\nIf a_{i, j} is ., the square (i, j) is white; if a_{i, j} is #, the square (i, j) is black.\n\nSnuke is compressing this grid.\nHe will do so by repeatedly performing the following operation while there is a row or column that consists only of white squares:\n\nOperation: choose any one row or column that consists only of white squares, remove it and delete the space between the rows or columns.\n\nIt can be shown that the final state of the grid is uniquely determined regardless of what row or column is chosen in each operation.\nFind the final state of the grid.\n\nConstraints\n\n1 \\leq H, W \\leq 100\n\na_{i, j} is . or #.\n\nThere is at least one black square in the whole grid.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\na_{1, 1}...a_{1, W}\n:\na_{H, 1}...a_{H, W}\n\nOutput\n\nPrint the final state of the grid in the same format as input (without the numbers of rows and columns); see the samples for clarity.\n\nSample Input 1\n\n4 4\n##.#\n....\n##.#\n.#.#\n\nSample Output 1\n\n###\n###\n.##\n\nThe second row and the third column in the original grid will be removed.\n\nSample Input 2\n\n3 3\n#..\n.#.\n..#\n\nSample Output 2\n\n#..\n.#.\n..#\n\nAs there is no row or column that consists only of white squares, no operation will be performed.\n\nSample Input 3\n\n4 5\n.....\n.....\n..#..\n.....\n\nSample Output 3\n\n#\n\nSample Input 4\n\n7 6\n......\n....#.\n.#....\n..#...\n..#...\n......\n.#..#.\n\nSample Output 4\n\n..#\n#..\n.#.\n.#.\n#.#", "sample_input": "4 4\n##.#\n....\n##.#\n.#.#\n"}, "reference_outputs": ["###\n###\n.##\n"], "source_document_id": "p03273", "source_text": "Score : 200 points\n\nProblem Statement\n\nThere is a grid of squares with H horizontal rows and W vertical columns.\nThe square at the i-th row from the top and the j-th column from the left is represented as (i, j).\nEach square is black or white.\nThe color of the square is given as an H-by-W matrix (a_{i, j}).\nIf a_{i, j} is ., the square (i, j) is white; if a_{i, j} is #, the square (i, j) is black.\n\nSnuke is compressing this grid.\nHe will do so by repeatedly performing the following operation while there is a row or column that consists only of white squares:\n\nOperation: choose any one row or column that consists only of white squares, remove it and delete the space between the rows or columns.\n\nIt can be shown that the final state of the grid is uniquely determined regardless of what row or column is chosen in each operation.\nFind the final state of the grid.\n\nConstraints\n\n1 \\leq H, W \\leq 100\n\na_{i, j} is . or #.\n\nThere is at least one black square in the whole grid.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\na_{1, 1}...a_{1, W}\n:\na_{H, 1}...a_{H, W}\n\nOutput\n\nPrint the final state of the grid in the same format as input (without the numbers of rows and columns); see the samples for clarity.\n\nSample Input 1\n\n4 4\n##.#\n....\n##.#\n.#.#\n\nSample Output 1\n\n###\n###\n.##\n\nThe second row and the third column in the original grid will be removed.\n\nSample Input 2\n\n3 3\n#..\n.#.\n..#\n\nSample Output 2\n\n#..\n.#.\n..#\n\nAs there is no row or column that consists only of white squares, no operation will be performed.\n\nSample Input 3\n\n4 5\n.....\n.....\n..#..\n.....\n\nSample Output 3\n\n#\n\nSample Input 4\n\n7 6\n......\n....#.\n.#....\n..#...\n..#...\n......\n.#..#.\n\nSample Output 4\n\n..#\n#..\n.#.\n.#.\n#.#", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1001, "cpu_time_ms": 13, "memory_kb": 2856}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s583158439", "group_id": "codeNet:p03273", "input_text": "local H, W = io.read(\"n\", \"n\", \"l\")\nlocal A = {}\nfor h=1,H do\n A[h] = {}\n for w=1,W do\n local a = io.read(1)\n A[h][w] = a\n end\n io.read(\"l\")\nend\nlocal RH ={}\nfor h=1,H do\n local remove = true\n for w=1,W do\n if A[h][w] == '#' then\n remove = false\n break\n end\n end\n if remove then\n RH[h] = 1\n end\nend\nlocal RW = {}\nfor w=1,W do\n local remove = true\n for h=1,H do\n if A[h][w] == '#' then\n remove = false\n break\n end\n end\n if remove then\n RW[w] = 1\n end\nend\n\nfor h=1,H do\n if not RH[h] then\n for w=1,W do\n if not RW[w] then\n io.write(A[h][w])\n end\n end\n print()\n end\nend\n\n", "language": "Lua", "metadata": {"date": 1596310682, "filename_ext": "lua", "original_language": "Lua (Lua 5.3.5)", "problem_description_relpath": "problem_descriptions/p03273.html", "problem_id": "p03273", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03273/input.txt", "sample_output_relpath": "derived/input_output/data/p03273/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03273/Lua/s583158439.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s583158439", "user_id": "u162773977"}, "prompt_components": {"gold_output": "###\n###\n.##\n", "input_to_evaluate": "local H, W = io.read(\"n\", \"n\", \"l\")\nlocal A = {}\nfor h=1,H do\n A[h] = {}\n for w=1,W do\n local a = io.read(1)\n A[h][w] = a\n end\n io.read(\"l\")\nend\nlocal RH ={}\nfor h=1,H do\n local remove = true\n for w=1,W do\n if A[h][w] == '#' then\n remove = false\n break\n end\n end\n if remove then\n RH[h] = 1\n end\nend\nlocal RW = {}\nfor w=1,W do\n local remove = true\n for h=1,H do\n if A[h][w] == '#' then\n remove = false\n break\n end\n end\n if remove then\n RW[w] = 1\n end\nend\n\nfor h=1,H do\n if not RH[h] then\n for w=1,W do\n if not RW[w] then\n io.write(A[h][w])\n end\n end\n print()\n end\nend\n\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nThere is a grid of squares with H horizontal rows and W vertical columns.\nThe square at the i-th row from the top and the j-th column from the left is represented as (i, j).\nEach square is black or white.\nThe color of the square is given as an H-by-W matrix (a_{i, j}).\nIf a_{i, j} is ., the square (i, j) is white; if a_{i, j} is #, the square (i, j) is black.\n\nSnuke is compressing this grid.\nHe will do so by repeatedly performing the following operation while there is a row or column that consists only of white squares:\n\nOperation: choose any one row or column that consists only of white squares, remove it and delete the space between the rows or columns.\n\nIt can be shown that the final state of the grid is uniquely determined regardless of what row or column is chosen in each operation.\nFind the final state of the grid.\n\nConstraints\n\n1 \\leq H, W \\leq 100\n\na_{i, j} is . or #.\n\nThere is at least one black square in the whole grid.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\na_{1, 1}...a_{1, W}\n:\na_{H, 1}...a_{H, W}\n\nOutput\n\nPrint the final state of the grid in the same format as input (without the numbers of rows and columns); see the samples for clarity.\n\nSample Input 1\n\n4 4\n##.#\n....\n##.#\n.#.#\n\nSample Output 1\n\n###\n###\n.##\n\nThe second row and the third column in the original grid will be removed.\n\nSample Input 2\n\n3 3\n#..\n.#.\n..#\n\nSample Output 2\n\n#..\n.#.\n..#\n\nAs there is no row or column that consists only of white squares, no operation will be performed.\n\nSample Input 3\n\n4 5\n.....\n.....\n..#..\n.....\n\nSample Output 3\n\n#\n\nSample Input 4\n\n7 6\n......\n....#.\n.#....\n..#...\n..#...\n......\n.#..#.\n\nSample Output 4\n\n..#\n#..\n.#.\n.#.\n#.#", "sample_input": "4 4\n##.#\n....\n##.#\n.#.#\n"}, "reference_outputs": ["###\n###\n.##\n"], "source_document_id": "p03273", "source_text": "Score : 200 points\n\nProblem Statement\n\nThere is a grid of squares with H horizontal rows and W vertical columns.\nThe square at the i-th row from the top and the j-th column from the left is represented as (i, j).\nEach square is black or white.\nThe color of the square is given as an H-by-W matrix (a_{i, j}).\nIf a_{i, j} is ., the square (i, j) is white; if a_{i, j} is #, the square (i, j) is black.\n\nSnuke is compressing this grid.\nHe will do so by repeatedly performing the following operation while there is a row or column that consists only of white squares:\n\nOperation: choose any one row or column that consists only of white squares, remove it and delete the space between the rows or columns.\n\nIt can be shown that the final state of the grid is uniquely determined regardless of what row or column is chosen in each operation.\nFind the final state of the grid.\n\nConstraints\n\n1 \\leq H, W \\leq 100\n\na_{i, j} is . or #.\n\nThere is at least one black square in the whole grid.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\na_{1, 1}...a_{1, W}\n:\na_{H, 1}...a_{H, W}\n\nOutput\n\nPrint the final state of the grid in the same format as input (without the numbers of rows and columns); see the samples for clarity.\n\nSample Input 1\n\n4 4\n##.#\n....\n##.#\n.#.#\n\nSample Output 1\n\n###\n###\n.##\n\nThe second row and the third column in the original grid will be removed.\n\nSample Input 2\n\n3 3\n#..\n.#.\n..#\n\nSample Output 2\n\n#..\n.#.\n..#\n\nAs there is no row or column that consists only of white squares, no operation will be performed.\n\nSample Input 3\n\n4 5\n.....\n.....\n..#..\n.....\n\nSample Output 3\n\n#\n\nSample Input 4\n\n7 6\n......\n....#.\n.#....\n..#...\n..#...\n......\n.#..#.\n\nSample Output 4\n\n..#\n#..\n.#.\n.#.\n#.#", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 654, "cpu_time_ms": 13, "memory_kb": 2824}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s730444310", "group_id": "codeNet:p03273", "input_text": "H=io.read(\"n\")\nW=io.read(\"n\")\nt={}\nfor i=1,H do\n t[i]={}\n for j=1,W do\n t[i][j]=io.read()\n end\nend\nfor i=1,H do\n res=true\n for j=1,W do\n if t[i][j]==\"#\" then\n res=false\n break\n end\n end\n if res==true then\n table.remove(t,i)\n end\nend\nfor i=1,W do\n res=true\n for j=1,#t do\n if t[j][i]==\"#\" then\n res=false\n break\n end\n end\n if res==true then\n for k=1,#t do\n table.remove(t[k],i)\n end\n end\nend\nfor i,v in ipairs(t) do\n for j,p in ipairs(v) do\n io.write(p)\n end\n print()\nend\n", "language": "Lua", "metadata": {"date": 1550282104, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03273.html", "problem_id": "p03273", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03273/input.txt", "sample_output_relpath": "derived/input_output/data/p03273/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03273/Lua/s730444310.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s730444310", "user_id": "u015229643"}, "prompt_components": {"gold_output": "###\n###\n.##\n", "input_to_evaluate": "H=io.read(\"n\")\nW=io.read(\"n\")\nt={}\nfor i=1,H do\n t[i]={}\n for j=1,W do\n t[i][j]=io.read()\n end\nend\nfor i=1,H do\n res=true\n for j=1,W do\n if t[i][j]==\"#\" then\n res=false\n break\n end\n end\n if res==true then\n table.remove(t,i)\n end\nend\nfor i=1,W do\n res=true\n for j=1,#t do\n if t[j][i]==\"#\" then\n res=false\n break\n end\n end\n if res==true then\n for k=1,#t do\n table.remove(t[k],i)\n end\n end\nend\nfor i,v in ipairs(t) do\n for j,p in ipairs(v) do\n io.write(p)\n end\n print()\nend\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nThere is a grid of squares with H horizontal rows and W vertical columns.\nThe square at the i-th row from the top and the j-th column from the left is represented as (i, j).\nEach square is black or white.\nThe color of the square is given as an H-by-W matrix (a_{i, j}).\nIf a_{i, j} is ., the square (i, j) is white; if a_{i, j} is #, the square (i, j) is black.\n\nSnuke is compressing this grid.\nHe will do so by repeatedly performing the following operation while there is a row or column that consists only of white squares:\n\nOperation: choose any one row or column that consists only of white squares, remove it and delete the space between the rows or columns.\n\nIt can be shown that the final state of the grid is uniquely determined regardless of what row or column is chosen in each operation.\nFind the final state of the grid.\n\nConstraints\n\n1 \\leq H, W \\leq 100\n\na_{i, j} is . or #.\n\nThere is at least one black square in the whole grid.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\na_{1, 1}...a_{1, W}\n:\na_{H, 1}...a_{H, W}\n\nOutput\n\nPrint the final state of the grid in the same format as input (without the numbers of rows and columns); see the samples for clarity.\n\nSample Input 1\n\n4 4\n##.#\n....\n##.#\n.#.#\n\nSample Output 1\n\n###\n###\n.##\n\nThe second row and the third column in the original grid will be removed.\n\nSample Input 2\n\n3 3\n#..\n.#.\n..#\n\nSample Output 2\n\n#..\n.#.\n..#\n\nAs there is no row or column that consists only of white squares, no operation will be performed.\n\nSample Input 3\n\n4 5\n.....\n.....\n..#..\n.....\n\nSample Output 3\n\n#\n\nSample Input 4\n\n7 6\n......\n....#.\n.#....\n..#...\n..#...\n......\n.#..#.\n\nSample Output 4\n\n..#\n#..\n.#.\n.#.\n#.#", "sample_input": "4 4\n##.#\n....\n##.#\n.#.#\n"}, "reference_outputs": ["###\n###\n.##\n"], "source_document_id": "p03273", "source_text": "Score : 200 points\n\nProblem Statement\n\nThere is a grid of squares with H horizontal rows and W vertical columns.\nThe square at the i-th row from the top and the j-th column from the left is represented as (i, j).\nEach square is black or white.\nThe color of the square is given as an H-by-W matrix (a_{i, j}).\nIf a_{i, j} is ., the square (i, j) is white; if a_{i, j} is #, the square (i, j) is black.\n\nSnuke is compressing this grid.\nHe will do so by repeatedly performing the following operation while there is a row or column that consists only of white squares:\n\nOperation: choose any one row or column that consists only of white squares, remove it and delete the space between the rows or columns.\n\nIt can be shown that the final state of the grid is uniquely determined regardless of what row or column is chosen in each operation.\nFind the final state of the grid.\n\nConstraints\n\n1 \\leq H, W \\leq 100\n\na_{i, j} is . or #.\n\nThere is at least one black square in the whole grid.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\na_{1, 1}...a_{1, W}\n:\na_{H, 1}...a_{H, W}\n\nOutput\n\nPrint the final state of the grid in the same format as input (without the numbers of rows and columns); see the samples for clarity.\n\nSample Input 1\n\n4 4\n##.#\n....\n##.#\n.#.#\n\nSample Output 1\n\n###\n###\n.##\n\nThe second row and the third column in the original grid will be removed.\n\nSample Input 2\n\n3 3\n#..\n.#.\n..#\n\nSample Output 2\n\n#..\n.#.\n..#\n\nAs there is no row or column that consists only of white squares, no operation will be performed.\n\nSample Input 3\n\n4 5\n.....\n.....\n..#..\n.....\n\nSample Output 3\n\n#\n\nSample Input 4\n\n7 6\n......\n....#.\n.#....\n..#...\n..#...\n......\n.#..#.\n\nSample Output 4\n\n..#\n#..\n.#.\n.#.\n#.#", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 539, "cpu_time_ms": 7, "memory_kb": 256}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s534772421", "group_id": "codeNet:p03273", "input_text": "H=io.read(\"n\")\nW=io.read(\"n\")\nt={}\nfor i=1,H do\n t[i]={}\n for j=1,W do\n t[i][j]=io.read()\n end\nend\nfor i=1,H do\n res=true\n for j=1,W do\n if t[i][j]==\"#\" then\n res=false\n break\n end\n end\n if res==true then\n table.remove(t,i)\n end\nend\nfor i=1,W do\n res=true\n for j=1,#t do\n if t[j][i]==\"#\" then\n res=false\n break\n end\n end\n if res==true then\n for k=1,#t do\n table.remove(t[k],i)\n end\n end\nend\nfor i,v in ipairs(t) do\n for j,p in ipairs(v) do\n io.write(p)\nend\nprint()\nend\n", "language": "Lua", "metadata": {"date": 1550282044, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03273.html", "problem_id": "p03273", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03273/input.txt", "sample_output_relpath": "derived/input_output/data/p03273/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03273/Lua/s534772421.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s534772421", "user_id": "u015229643"}, "prompt_components": {"gold_output": "###\n###\n.##\n", "input_to_evaluate": "H=io.read(\"n\")\nW=io.read(\"n\")\nt={}\nfor i=1,H do\n t[i]={}\n for j=1,W do\n t[i][j]=io.read()\n end\nend\nfor i=1,H do\n res=true\n for j=1,W do\n if t[i][j]==\"#\" then\n res=false\n break\n end\n end\n if res==true then\n table.remove(t,i)\n end\nend\nfor i=1,W do\n res=true\n for j=1,#t do\n if t[j][i]==\"#\" then\n res=false\n break\n end\n end\n if res==true then\n for k=1,#t do\n table.remove(t[k],i)\n end\n end\nend\nfor i,v in ipairs(t) do\n for j,p in ipairs(v) do\n io.write(p)\nend\nprint()\nend\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nThere is a grid of squares with H horizontal rows and W vertical columns.\nThe square at the i-th row from the top and the j-th column from the left is represented as (i, j).\nEach square is black or white.\nThe color of the square is given as an H-by-W matrix (a_{i, j}).\nIf a_{i, j} is ., the square (i, j) is white; if a_{i, j} is #, the square (i, j) is black.\n\nSnuke is compressing this grid.\nHe will do so by repeatedly performing the following operation while there is a row or column that consists only of white squares:\n\nOperation: choose any one row or column that consists only of white squares, remove it and delete the space between the rows or columns.\n\nIt can be shown that the final state of the grid is uniquely determined regardless of what row or column is chosen in each operation.\nFind the final state of the grid.\n\nConstraints\n\n1 \\leq H, W \\leq 100\n\na_{i, j} is . or #.\n\nThere is at least one black square in the whole grid.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\na_{1, 1}...a_{1, W}\n:\na_{H, 1}...a_{H, W}\n\nOutput\n\nPrint the final state of the grid in the same format as input (without the numbers of rows and columns); see the samples for clarity.\n\nSample Input 1\n\n4 4\n##.#\n....\n##.#\n.#.#\n\nSample Output 1\n\n###\n###\n.##\n\nThe second row and the third column in the original grid will be removed.\n\nSample Input 2\n\n3 3\n#..\n.#.\n..#\n\nSample Output 2\n\n#..\n.#.\n..#\n\nAs there is no row or column that consists only of white squares, no operation will be performed.\n\nSample Input 3\n\n4 5\n.....\n.....\n..#..\n.....\n\nSample Output 3\n\n#\n\nSample Input 4\n\n7 6\n......\n....#.\n.#....\n..#...\n..#...\n......\n.#..#.\n\nSample Output 4\n\n..#\n#..\n.#.\n.#.\n#.#", "sample_input": "4 4\n##.#\n....\n##.#\n.#.#\n"}, "reference_outputs": ["###\n###\n.##\n"], "source_document_id": "p03273", "source_text": "Score : 200 points\n\nProblem Statement\n\nThere is a grid of squares with H horizontal rows and W vertical columns.\nThe square at the i-th row from the top and the j-th column from the left is represented as (i, j).\nEach square is black or white.\nThe color of the square is given as an H-by-W matrix (a_{i, j}).\nIf a_{i, j} is ., the square (i, j) is white; if a_{i, j} is #, the square (i, j) is black.\n\nSnuke is compressing this grid.\nHe will do so by repeatedly performing the following operation while there is a row or column that consists only of white squares:\n\nOperation: choose any one row or column that consists only of white squares, remove it and delete the space between the rows or columns.\n\nIt can be shown that the final state of the grid is uniquely determined regardless of what row or column is chosen in each operation.\nFind the final state of the grid.\n\nConstraints\n\n1 \\leq H, W \\leq 100\n\na_{i, j} is . or #.\n\nThere is at least one black square in the whole grid.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\na_{1, 1}...a_{1, W}\n:\na_{H, 1}...a_{H, W}\n\nOutput\n\nPrint the final state of the grid in the same format as input (without the numbers of rows and columns); see the samples for clarity.\n\nSample Input 1\n\n4 4\n##.#\n....\n##.#\n.#.#\n\nSample Output 1\n\n###\n###\n.##\n\nThe second row and the third column in the original grid will be removed.\n\nSample Input 2\n\n3 3\n#..\n.#.\n..#\n\nSample Output 2\n\n#..\n.#.\n..#\n\nAs there is no row or column that consists only of white squares, no operation will be performed.\n\nSample Input 3\n\n4 5\n.....\n.....\n..#..\n.....\n\nSample Output 3\n\n#\n\nSample Input 4\n\n7 6\n......\n....#.\n.#....\n..#...\n..#...\n......\n.#..#.\n\nSample Output 4\n\n..#\n#..\n.#.\n.#.\n#.#", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 533, "cpu_time_ms": 7, "memory_kb": 256}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s016319789", "group_id": "codeNet:p03273", "input_text": "H=io.read(\"n\")\nW=io.read(\"n\")\nt={}\nfor i=1,H do\n t[i]={}\n for j=1,W do\n t[i][j]=io.read()\n end\nend\nfor i=1,H do\n res=true\n for j=1,W do\n if t[i][j]==\"#\" then\n res=false\n break\n end\n end\n if res==true then\n table.remove(t,i)\n end\nend\nfor i=1,W do\n res=true\n for j=1,#t do\n if t[j][i]==\"#\" then\n res=false\n break\n end\n end\n if res==true then\n for k=1,#t do\n table.remove(t[k],i)\n end\n end\nend\nfor i,v in pairs(t) do\n for j,k in pairs(v) do\n io.write(k)\nend\nprint()\nend\n", "language": "Lua", "metadata": {"date": 1550281620, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03273.html", "problem_id": "p03273", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03273/input.txt", "sample_output_relpath": "derived/input_output/data/p03273/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03273/Lua/s016319789.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s016319789", "user_id": "u015229643"}, "prompt_components": {"gold_output": "###\n###\n.##\n", "input_to_evaluate": "H=io.read(\"n\")\nW=io.read(\"n\")\nt={}\nfor i=1,H do\n t[i]={}\n for j=1,W do\n t[i][j]=io.read()\n end\nend\nfor i=1,H do\n res=true\n for j=1,W do\n if t[i][j]==\"#\" then\n res=false\n break\n end\n end\n if res==true then\n table.remove(t,i)\n end\nend\nfor i=1,W do\n res=true\n for j=1,#t do\n if t[j][i]==\"#\" then\n res=false\n break\n end\n end\n if res==true then\n for k=1,#t do\n table.remove(t[k],i)\n end\n end\nend\nfor i,v in pairs(t) do\n for j,k in pairs(v) do\n io.write(k)\nend\nprint()\nend\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nThere is a grid of squares with H horizontal rows and W vertical columns.\nThe square at the i-th row from the top and the j-th column from the left is represented as (i, j).\nEach square is black or white.\nThe color of the square is given as an H-by-W matrix (a_{i, j}).\nIf a_{i, j} is ., the square (i, j) is white; if a_{i, j} is #, the square (i, j) is black.\n\nSnuke is compressing this grid.\nHe will do so by repeatedly performing the following operation while there is a row or column that consists only of white squares:\n\nOperation: choose any one row or column that consists only of white squares, remove it and delete the space between the rows or columns.\n\nIt can be shown that the final state of the grid is uniquely determined regardless of what row or column is chosen in each operation.\nFind the final state of the grid.\n\nConstraints\n\n1 \\leq H, W \\leq 100\n\na_{i, j} is . or #.\n\nThere is at least one black square in the whole grid.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\na_{1, 1}...a_{1, W}\n:\na_{H, 1}...a_{H, W}\n\nOutput\n\nPrint the final state of the grid in the same format as input (without the numbers of rows and columns); see the samples for clarity.\n\nSample Input 1\n\n4 4\n##.#\n....\n##.#\n.#.#\n\nSample Output 1\n\n###\n###\n.##\n\nThe second row and the third column in the original grid will be removed.\n\nSample Input 2\n\n3 3\n#..\n.#.\n..#\n\nSample Output 2\n\n#..\n.#.\n..#\n\nAs there is no row or column that consists only of white squares, no operation will be performed.\n\nSample Input 3\n\n4 5\n.....\n.....\n..#..\n.....\n\nSample Output 3\n\n#\n\nSample Input 4\n\n7 6\n......\n....#.\n.#....\n..#...\n..#...\n......\n.#..#.\n\nSample Output 4\n\n..#\n#..\n.#.\n.#.\n#.#", "sample_input": "4 4\n##.#\n....\n##.#\n.#.#\n"}, "reference_outputs": ["###\n###\n.##\n"], "source_document_id": "p03273", "source_text": "Score : 200 points\n\nProblem Statement\n\nThere is a grid of squares with H horizontal rows and W vertical columns.\nThe square at the i-th row from the top and the j-th column from the left is represented as (i, j).\nEach square is black or white.\nThe color of the square is given as an H-by-W matrix (a_{i, j}).\nIf a_{i, j} is ., the square (i, j) is white; if a_{i, j} is #, the square (i, j) is black.\n\nSnuke is compressing this grid.\nHe will do so by repeatedly performing the following operation while there is a row or column that consists only of white squares:\n\nOperation: choose any one row or column that consists only of white squares, remove it and delete the space between the rows or columns.\n\nIt can be shown that the final state of the grid is uniquely determined regardless of what row or column is chosen in each operation.\nFind the final state of the grid.\n\nConstraints\n\n1 \\leq H, W \\leq 100\n\na_{i, j} is . or #.\n\nThere is at least one black square in the whole grid.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\na_{1, 1}...a_{1, W}\n:\na_{H, 1}...a_{H, W}\n\nOutput\n\nPrint the final state of the grid in the same format as input (without the numbers of rows and columns); see the samples for clarity.\n\nSample Input 1\n\n4 4\n##.#\n....\n##.#\n.#.#\n\nSample Output 1\n\n###\n###\n.##\n\nThe second row and the third column in the original grid will be removed.\n\nSample Input 2\n\n3 3\n#..\n.#.\n..#\n\nSample Output 2\n\n#..\n.#.\n..#\n\nAs there is no row or column that consists only of white squares, no operation will be performed.\n\nSample Input 3\n\n4 5\n.....\n.....\n..#..\n.....\n\nSample Output 3\n\n#\n\nSample Input 4\n\n7 6\n......\n....#.\n.#....\n..#...\n..#...\n......\n.#..#.\n\nSample Output 4\n\n..#\n#..\n.#.\n.#.\n#.#", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 531, "cpu_time_ms": 7, "memory_kb": 256}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s106862609", "group_id": "codeNet:p03274", "input_text": "local n,k=io.read(\"n\",\"n\")\nlocal x={}\nfor i=1,n do\n x[i]=io.read(\"n\")\nend\n\nlocal min=math.maxinteger\nfor i=1,n-k+1 do\n local l=i\n local r=k+i-1\n local ltor=math.abs(x[l])+math.abs(x[r]-x[l])\n local rtol=math.abs(x[r])+math.abs(x[r]-x[l])\n min=math.min(min,ltor,rtol)\nend\nprint(min)", "language": "Lua", "metadata": {"date": 1592018901, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03274.html", "problem_id": "p03274", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03274/input.txt", "sample_output_relpath": "derived/input_output/data/p03274/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03274/Lua/s106862609.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s106862609", "user_id": "u045238009"}, "prompt_components": {"gold_output": "40\n", "input_to_evaluate": "local n,k=io.read(\"n\",\"n\")\nlocal x={}\nfor i=1,n do\n x[i]=io.read(\"n\")\nend\n\nlocal min=math.maxinteger\nfor i=1,n-k+1 do\n local l=i\n local r=k+i-1\n local ltor=math.abs(x[l])+math.abs(x[r]-x[l])\n local rtol=math.abs(x[r])+math.abs(x[r]-x[l])\n min=math.min(min,ltor,rtol)\nend\nprint(min)", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere are N candles placed on a number line.\nThe i-th candle from the left is placed on coordinate x_i.\nHere, x_1 < x_2 < ... < x_N holds.\n\nInitially, no candles are burning.\nSnuke decides to light K of the N candles.\n\nNow, he is at coordinate 0.\nHe can move left and right along the line with speed 1.\nHe can also light a candle when he is at the same position as the candle, in negligible time.\n\nFind the minimum time required to light K candles.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n1 \\leq K \\leq N\n\nx_i is an integer.\n\n|x_i| \\leq 10^8\n\nx_1 < x_2 < ... < x_N\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nx_1 x_2 ... x_N\n\nOutput\n\nPrint the minimum time required to light K candles.\n\nSample Input 1\n\n5 3\n-30 -10 10 20 50\n\nSample Output 1\n\n40\n\nHe should move and light candles as follows:\n\nMove from coordinate 0 to -10.\n\nLight the second candle from the left.\n\nMove from coordinate -10 to 10.\n\nLight the third candle from the left.\n\nMove from coordinate 10 to 20.\n\nLight the fourth candle from the left.\n\nSample Input 2\n\n3 2\n10 20 30\n\nSample Output 2\n\n20\n\nSample Input 3\n\n1 1\n0\n\nSample Output 3\n\n0\n\nThere may be a candle placed at coordinate 0.\n\nSample Input 4\n\n8 5\n-9 -7 -4 -3 1 2 3 4\n\nSample Output 4\n\n10", "sample_input": "5 3\n-30 -10 10 20 50\n"}, "reference_outputs": ["40\n"], "source_document_id": "p03274", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere are N candles placed on a number line.\nThe i-th candle from the left is placed on coordinate x_i.\nHere, x_1 < x_2 < ... < x_N holds.\n\nInitially, no candles are burning.\nSnuke decides to light K of the N candles.\n\nNow, he is at coordinate 0.\nHe can move left and right along the line with speed 1.\nHe can also light a candle when he is at the same position as the candle, in negligible time.\n\nFind the minimum time required to light K candles.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n1 \\leq K \\leq N\n\nx_i is an integer.\n\n|x_i| \\leq 10^8\n\nx_1 < x_2 < ... < x_N\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nx_1 x_2 ... x_N\n\nOutput\n\nPrint the minimum time required to light K candles.\n\nSample Input 1\n\n5 3\n-30 -10 10 20 50\n\nSample Output 1\n\n40\n\nHe should move and light candles as follows:\n\nMove from coordinate 0 to -10.\n\nLight the second candle from the left.\n\nMove from coordinate -10 to 10.\n\nLight the third candle from the left.\n\nMove from coordinate 10 to 20.\n\nLight the fourth candle from the left.\n\nSample Input 2\n\n3 2\n10 20 30\n\nSample Output 2\n\n20\n\nSample Input 3\n\n1 1\n0\n\nSample Output 3\n\n0\n\nThere may be a candle placed at coordinate 0.\n\nSample Input 4\n\n8 5\n-9 -7 -4 -3 1 2 3 4\n\nSample Output 4\n\n10", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 299, "cpu_time_ms": 54, "memory_kb": 2552}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s764132933", "group_id": "codeNet:p03275", "input_text": "local mfl, mce, mmi = math.floor, math.ceil, math.min\nlocal mma = math.max\nlocal SegTree = {}\nSegTree.updateAll = function(self)\n for i = self.stagenum - 1, 1, -1 do\n for j = 1, self.cnt[i] do\n self.stage[i][j] = self.stage[i + 1][j * 2 - 1] + self.stage[i + 1][j * 2]\n end\n end\nend\nSegTree.clear = function(self)\n for i = self.stagenum, 1, -1 do\n for j = 1, self.cnt[i] do\n self.stage[i][j] = 0\n end\n end\nend\nSegTree.create = function(self, n)\n local stagenum, mul = 1, 1\n self.cnt, self.stage, self.size = {1}, {{}}, {}\n while mul < n do\n mul, stagenum = mul * 2, stagenum + 1\n self.cnt[stagenum], self.stage[stagenum] = mul, {}\n end\n for i = 1, stagenum do self.size[i] = self.cnt[stagenum + 1 - i] end\n self.stagenum = stagenum\n self:clear()\nend\nSegTree.getRange = function(self, right)\n local stage = 1\n while right < self.size[stage] do\n stage = stage + 1\n end\n local ret = 0\n local l, r = 1, right\n while true do\n local sz = self.size[stage]\n ret = ret + self.stage[stage][mce(l / sz)]\n l = l + sz\n if l <= r then\n local nsize = r + 1 - l\n while nsize < self.size[stage] do\n stage = stage + 1\n end\n else\n break\n end\n end\n return ret\nend\nSegTree.inc = function(self, idx)\n self.stage[self.stagenum][idx] = self.stage[self.stagenum][idx] + 1\nend\nSegTree.dec = function(self, idx)\n self.stage[self.stagenum][idx] = self.stage[self.stagenum][idx] - 1\n for i = self.stagenum - 1, 1, -1 do\n local dst = mce(idx / 2)\n local rem = dst * 4 - 1 - idx\n self.stage[i][dst] = self.stage[i + 1][idx] + self.stage[i + 1][rem]\n idx = dst\n end\nend\nSegTree.new = function(n)\n local obj = {}\n setmetatable(obj, {__index = SegTree})\n obj:create(n)\n return obj\nend\n\nlocal n = io.read(\"*n\")\nlocal a = {}\nlocal t = {}\nfor i = 1, n do\n a[i] = io.read(\"*n\")\n t[i] = a[i]\nend\ntable.sort(t)\nlocal totcnt = mfl(n * (n + 1) / 2)\nlocal st = SegTree.new(n * 2 + 1)\nlocal z = {}\nlocal function solve(v)\n st:clear()\n local ofst = n + 1\n z[1] = v <= a[1] and 1 or -1\n for i = 2, n do\n z[i] = v <= a[i] and z[i - 1] + 1 or z[i - 1] - 1\n end\n for i = 1, n do\n st:inc(z[i] + ofst)\n end\n st:updateAll()\n local cnt = 0\n local n2_1 = 2 * n + 1\n for i = 1, n do\n local left = i == 1 and ofst or z[i - 1] + ofst\n if left <= 1 then\n cnt = cnt + n + 1 - i\n else\n cnt = cnt + n + 1 - i - st:getRange(left - 1)\n end\n st:dec(z[i] + ofst)\n end\n return totcnt <= cnt * 2\nend\nlocal function solveAll()\n if solve(t[n]) then\n return t[n]\n end\n local min, max = 1, n\n while 1 < max - min do\n local mid = mfl((min + max) / 2)\n if solve(t[mid]) then\n min = mid\n else\n max = mid\n end\n end\n return t[min]\nend\nprint(solveAll())\n", "language": "Lua", "metadata": {"date": 1572754722, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p03275.html", "problem_id": "p03275", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03275/input.txt", "sample_output_relpath": "derived/input_output/data/p03275/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03275/Lua/s764132933.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s764132933", "user_id": "u120582723"}, "prompt_components": {"gold_output": "30\n", "input_to_evaluate": "local mfl, mce, mmi = math.floor, math.ceil, math.min\nlocal mma = math.max\nlocal SegTree = {}\nSegTree.updateAll = function(self)\n for i = self.stagenum - 1, 1, -1 do\n for j = 1, self.cnt[i] do\n self.stage[i][j] = self.stage[i + 1][j * 2 - 1] + self.stage[i + 1][j * 2]\n end\n end\nend\nSegTree.clear = function(self)\n for i = self.stagenum, 1, -1 do\n for j = 1, self.cnt[i] do\n self.stage[i][j] = 0\n end\n end\nend\nSegTree.create = function(self, n)\n local stagenum, mul = 1, 1\n self.cnt, self.stage, self.size = {1}, {{}}, {}\n while mul < n do\n mul, stagenum = mul * 2, stagenum + 1\n self.cnt[stagenum], self.stage[stagenum] = mul, {}\n end\n for i = 1, stagenum do self.size[i] = self.cnt[stagenum + 1 - i] end\n self.stagenum = stagenum\n self:clear()\nend\nSegTree.getRange = function(self, right)\n local stage = 1\n while right < self.size[stage] do\n stage = stage + 1\n end\n local ret = 0\n local l, r = 1, right\n while true do\n local sz = self.size[stage]\n ret = ret + self.stage[stage][mce(l / sz)]\n l = l + sz\n if l <= r then\n local nsize = r + 1 - l\n while nsize < self.size[stage] do\n stage = stage + 1\n end\n else\n break\n end\n end\n return ret\nend\nSegTree.inc = function(self, idx)\n self.stage[self.stagenum][idx] = self.stage[self.stagenum][idx] + 1\nend\nSegTree.dec = function(self, idx)\n self.stage[self.stagenum][idx] = self.stage[self.stagenum][idx] - 1\n for i = self.stagenum - 1, 1, -1 do\n local dst = mce(idx / 2)\n local rem = dst * 4 - 1 - idx\n self.stage[i][dst] = self.stage[i + 1][idx] + self.stage[i + 1][rem]\n idx = dst\n end\nend\nSegTree.new = function(n)\n local obj = {}\n setmetatable(obj, {__index = SegTree})\n obj:create(n)\n return obj\nend\n\nlocal n = io.read(\"*n\")\nlocal a = {}\nlocal t = {}\nfor i = 1, n do\n a[i] = io.read(\"*n\")\n t[i] = a[i]\nend\ntable.sort(t)\nlocal totcnt = mfl(n * (n + 1) / 2)\nlocal st = SegTree.new(n * 2 + 1)\nlocal z = {}\nlocal function solve(v)\n st:clear()\n local ofst = n + 1\n z[1] = v <= a[1] and 1 or -1\n for i = 2, n do\n z[i] = v <= a[i] and z[i - 1] + 1 or z[i - 1] - 1\n end\n for i = 1, n do\n st:inc(z[i] + ofst)\n end\n st:updateAll()\n local cnt = 0\n local n2_1 = 2 * n + 1\n for i = 1, n do\n local left = i == 1 and ofst or z[i - 1] + ofst\n if left <= 1 then\n cnt = cnt + n + 1 - i\n else\n cnt = cnt + n + 1 - i - st:getRange(left - 1)\n end\n st:dec(z[i] + ofst)\n end\n return totcnt <= cnt * 2\nend\nlocal function solveAll()\n if solve(t[n]) then\n return t[n]\n end\n local min, max = 1, n\n while 1 < max - min do\n local mid = mfl((min + max) / 2)\n if solve(t[mid]) then\n min = mid\n else\n max = mid\n end\n end\n return t[min]\nend\nprint(solveAll())\n", "problem_context": "Score : 700 points\n\nProblem Statement\n\nWe will define the median of a sequence b of length M, as follows:\n\nLet b' be the sequence obtained by sorting b in non-decreasing order. Then, the value of the (M / 2 + 1)-th element of b' is the median of b. Here, / is integer division, rounding down.\n\nFor example, the median of (10, 30, 20) is 20; the median of (10, 30, 20, 40) is 30; the median of (10, 10, 10, 20, 30) is 10.\n\nSnuke comes up with the following problem.\n\nYou are given a sequence a of length N.\nFor each pair (l, r) (1 \\leq l \\leq r \\leq N), let m_{l, r} be the median of the contiguous subsequence (a_l, a_{l + 1}, ..., a_r) of a.\nWe will list m_{l, r} for all pairs (l, r) to create a new sequence m.\nFind the median of m.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\na_i is an integer.\n\n1 \\leq a_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 ... a_N\n\nOutput\n\nPrint the median of m.\n\nSample Input 1\n\n3\n10 30 20\n\nSample Output 1\n\n30\n\nThe median of each contiguous subsequence of a is as follows:\n\nThe median of (10) is 10.\n\nThe median of (30) is 30.\n\nThe median of (20) is 20.\n\nThe median of (10, 30) is 30.\n\nThe median of (30, 20) is 30.\n\nThe median of (10, 30, 20) is 20.\n\nThus, m = (10, 30, 20, 30, 30, 20) and the median of m is 30.\n\nSample Input 2\n\n1\n10\n\nSample Output 2\n\n10\n\nSample Input 3\n\n10\n5 9 5 9 8 9 3 5 4 3\n\nSample Output 3\n\n8", "sample_input": "3\n10 30 20\n"}, "reference_outputs": ["30\n"], "source_document_id": "p03275", "source_text": "Score : 700 points\n\nProblem Statement\n\nWe will define the median of a sequence b of length M, as follows:\n\nLet b' be the sequence obtained by sorting b in non-decreasing order. Then, the value of the (M / 2 + 1)-th element of b' is the median of b. Here, / is integer division, rounding down.\n\nFor example, the median of (10, 30, 20) is 20; the median of (10, 30, 20, 40) is 30; the median of (10, 10, 10, 20, 30) is 10.\n\nSnuke comes up with the following problem.\n\nYou are given a sequence a of length N.\nFor each pair (l, r) (1 \\leq l \\leq r \\leq N), let m_{l, r} be the median of the contiguous subsequence (a_l, a_{l + 1}, ..., a_r) of a.\nWe will list m_{l, r} for all pairs (l, r) to create a new sequence m.\nFind the median of m.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\na_i is an integer.\n\n1 \\leq a_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 ... a_N\n\nOutput\n\nPrint the median of m.\n\nSample Input 1\n\n3\n10 30 20\n\nSample Output 1\n\n30\n\nThe median of each contiguous subsequence of a is as follows:\n\nThe median of (10) is 10.\n\nThe median of (30) is 30.\n\nThe median of (20) is 20.\n\nThe median of (10, 30) is 30.\n\nThe median of (30, 20) is 30.\n\nThe median of (10, 30, 20) is 20.\n\nThus, m = (10, 30, 20, 30, 30, 20) and the median of m is 30.\n\nSample Input 2\n\n1\n10\n\nSample Output 2\n\n10\n\nSample Input 3\n\n10\n5 9 5 9 8 9 3 5 4 3\n\nSample Output 3\n\n8", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2769, "cpu_time_ms": 812, "memory_kb": 7676}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s105194448", "group_id": "codeNet:p03280", "input_text": "a,b=io.read():match(\"(.+)%s(.+)\")\nprint(math.floor((a-1)*(b-1)))", "language": "Lua", "metadata": {"date": 1551993471, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p03280.html", "problem_id": "p03280", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03280/input.txt", "sample_output_relpath": "derived/input_output/data/p03280/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03280/Lua/s105194448.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s105194448", "user_id": "u837412668"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "a,b=io.read():match(\"(.+)%s(.+)\")\nprint(math.floor((a-1)*(b-1)))", "problem_context": "Score: 100 points\n\nProblem Statement\n\nThere is a farm whose length and width are A yard and B yard, respectively. A farmer, John, made a vertical road and a horizontal road inside the farm from one border to another, as shown below: (The gray part represents the roads.)\n\nWhat is the area of this yard excluding the roads? Find it.\n\nNote\n\nIt can be proved that the positions of the roads do not affect the area.\n\nConstraints\n\nA is an integer between 2 and 100 (inclusive).\n\nB is an integer between 2 and 100 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nPrint the area of this yard excluding the roads (in square yards).\n\nSample Input 1\n\n2 2\n\nSample Output 1\n\n1\n\nIn this case, the area is 1 square yard.\n\nSample Input 2\n\n5 7\n\nSample Output 2\n\n24\n\nIn this case, the area is 24 square yards.", "sample_input": "2 2\n"}, "reference_outputs": ["1\n"], "source_document_id": "p03280", "source_text": "Score: 100 points\n\nProblem Statement\n\nThere is a farm whose length and width are A yard and B yard, respectively. A farmer, John, made a vertical road and a horizontal road inside the farm from one border to another, as shown below: (The gray part represents the roads.)\n\nWhat is the area of this yard excluding the roads? Find it.\n\nNote\n\nIt can be proved that the positions of the roads do not affect the area.\n\nConstraints\n\nA is an integer between 2 and 100 (inclusive).\n\nB is an integer between 2 and 100 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nPrint the area of this yard excluding the roads (in square yards).\n\nSample Input 1\n\n2 2\n\nSample Output 1\n\n1\n\nIn this case, the area is 1 square yard.\n\nSample Input 2\n\n5 7\n\nSample Output 2\n\n24\n\nIn this case, the area is 24 square yards.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 64, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s413469783", "group_id": "codeNet:p03281", "input_text": "n=io.read(\"n\")\nt={[104]=0,[134]=1,[164]=2,[188]=3,[194]=4,[200]=5}\nfor i=n,200 do\n if t[i] then\n print(t[i])\n break\n end\nend", "language": "Lua", "metadata": {"date": 1573133659, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03281.html", "problem_id": "p03281", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03281/input.txt", "sample_output_relpath": "derived/input_output/data/p03281/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03281/Lua/s413469783.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s413469783", "user_id": "u162773977"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "n=io.read(\"n\")\nt={[104]=0,[134]=1,[164]=2,[188]=3,[194]=4,[200]=5}\nfor i=n,200 do\n if t[i] then\n print(t[i])\n break\n end\nend", "problem_context": "Score: 200 points\n\nProblem Statement\n\nThe number 105 is quite special - it is odd but still it has eight divisors.\nNow, your task is this: how many odd numbers with exactly eight positive divisors are there between 1 and N (inclusive)?\n\nConstraints\n\nN is an integer between 1 and 200 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the count.\n\nSample Input 1\n\n105\n\nSample Output 1\n\n1\n\nAmong the numbers between 1 and 105, the only number that is odd and has exactly eight divisors is 105.\n\nSample Input 2\n\n7\n\nSample Output 2\n\n0\n\n1 has one divisor. 3, 5 and 7 are all prime and have two divisors. Thus, there is no number that satisfies the condition.", "sample_input": "105\n"}, "reference_outputs": ["1\n"], "source_document_id": "p03281", "source_text": "Score: 200 points\n\nProblem Statement\n\nThe number 105 is quite special - it is odd but still it has eight divisors.\nNow, your task is this: how many odd numbers with exactly eight positive divisors are there between 1 and N (inclusive)?\n\nConstraints\n\nN is an integer between 1 and 200 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the count.\n\nSample Input 1\n\n105\n\nSample Output 1\n\n1\n\nAmong the numbers between 1 and 105, the only number that is odd and has exactly eight divisors is 105.\n\nSample Input 2\n\n7\n\nSample Output 2\n\n0\n\n1 has one divisor. 3, 5 and 7 are all prime and have two divisors. Thus, there is no number that satisfies the condition.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 126, "cpu_time_ms": 7, "memory_kb": 752}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s313823152", "group_id": "codeNet:p03281", "input_text": "local n = io.read(\"*n\")\nif 195 <= n then print(5)\nelseif 189 <= n then print(4)\nelseif 165 <= n then print(3)\nelseif 135 <= n then print(2)\nelseif 105 <= n then print(1)\nelse print(0)\nend\n", "language": "Lua", "metadata": {"date": 1559662699, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03281.html", "problem_id": "p03281", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03281/input.txt", "sample_output_relpath": "derived/input_output/data/p03281/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03281/Lua/s313823152.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s313823152", "user_id": "u120582723"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "local n = io.read(\"*n\")\nif 195 <= n then print(5)\nelseif 189 <= n then print(4)\nelseif 165 <= n then print(3)\nelseif 135 <= n then print(2)\nelseif 105 <= n then print(1)\nelse print(0)\nend\n", "problem_context": "Score: 200 points\n\nProblem Statement\n\nThe number 105 is quite special - it is odd but still it has eight divisors.\nNow, your task is this: how many odd numbers with exactly eight positive divisors are there between 1 and N (inclusive)?\n\nConstraints\n\nN is an integer between 1 and 200 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the count.\n\nSample Input 1\n\n105\n\nSample Output 1\n\n1\n\nAmong the numbers between 1 and 105, the only number that is odd and has exactly eight divisors is 105.\n\nSample Input 2\n\n7\n\nSample Output 2\n\n0\n\n1 has one divisor. 3, 5 and 7 are all prime and have two divisors. Thus, there is no number that satisfies the condition.", "sample_input": "105\n"}, "reference_outputs": ["1\n"], "source_document_id": "p03281", "source_text": "Score: 200 points\n\nProblem Statement\n\nThe number 105 is quite special - it is odd but still it has eight divisors.\nNow, your task is this: how many odd numbers with exactly eight positive divisors are there between 1 and N (inclusive)?\n\nConstraints\n\nN is an integer between 1 and 200 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the count.\n\nSample Input 1\n\n105\n\nSample Output 1\n\n1\n\nAmong the numbers between 1 and 105, the only number that is odd and has exactly eight divisors is 105.\n\nSample Input 2\n\n7\n\nSample Output 2\n\n0\n\n1 has one divisor. 3, 5 and 7 are all prime and have two divisors. Thus, there is no number that satisfies the condition.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 188, "cpu_time_ms": 9, "memory_kb": 760}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s227930710", "group_id": "codeNet:p03281", "input_text": "N=io.read(\"n\")\nt=0\nfor i=1,N,2 do\n s=0\n for j=3,i//3,2 do\n if i%j==0 then\n s=s+1\n end\n end\n if s==6 then\n t=t+1\n end\nend\nprint(t)", "language": "Lua", "metadata": {"date": 1550343070, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03281.html", "problem_id": "p03281", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03281/input.txt", "sample_output_relpath": "derived/input_output/data/p03281/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03281/Lua/s227930710.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s227930710", "user_id": "u015229643"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "N=io.read(\"n\")\nt=0\nfor i=1,N,2 do\n s=0\n for j=3,i//3,2 do\n if i%j==0 then\n s=s+1\n end\n end\n if s==6 then\n t=t+1\n end\nend\nprint(t)", "problem_context": "Score: 200 points\n\nProblem Statement\n\nThe number 105 is quite special - it is odd but still it has eight divisors.\nNow, your task is this: how many odd numbers with exactly eight positive divisors are there between 1 and N (inclusive)?\n\nConstraints\n\nN is an integer between 1 and 200 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the count.\n\nSample Input 1\n\n105\n\nSample Output 1\n\n1\n\nAmong the numbers between 1 and 105, the only number that is odd and has exactly eight divisors is 105.\n\nSample Input 2\n\n7\n\nSample Output 2\n\n0\n\n1 has one divisor. 3, 5 and 7 are all prime and have two divisors. Thus, there is no number that satisfies the condition.", "sample_input": "105\n"}, "reference_outputs": ["1\n"], "source_document_id": "p03281", "source_text": "Score: 200 points\n\nProblem Statement\n\nThe number 105 is quite special - it is odd but still it has eight divisors.\nNow, your task is this: how many odd numbers with exactly eight positive divisors are there between 1 and N (inclusive)?\n\nConstraints\n\nN is an integer between 1 and 200 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the count.\n\nSample Input 1\n\n105\n\nSample Output 1\n\n1\n\nAmong the numbers between 1 and 105, the only number that is odd and has exactly eight divisors is 105.\n\nSample Input 2\n\n7\n\nSample Output 2\n\n0\n\n1 has one divisor. 3, 5 and 7 are all prime and have two divisors. Thus, there is no number that satisfies the condition.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 148, "cpu_time_ms": 7, "memory_kb": 888}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s639840433", "group_id": "codeNet:p03282", "input_text": "local s = io.read()\nlocal k = io.read(\"*n\")\nret = \"1\"\nilast = 101\nfor i = 1, #s do\n local a = string.sub(s, i, i)\n if(a ~= \"1\") then\n ilast = i - 1\n ret = a\n break\n end\nend\nif(k <= ilast) then print(\"1\") else print(ret) end\n", "language": "Lua", "metadata": {"date": 1555629974, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03282.html", "problem_id": "p03282", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03282/input.txt", "sample_output_relpath": "derived/input_output/data/p03282/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03282/Lua/s639840433.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s639840433", "user_id": "u120582723"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "local s = io.read()\nlocal k = io.read(\"*n\")\nret = \"1\"\nilast = 101\nfor i = 1, #s do\n local a = string.sub(s, i, i)\n if(a ~= \"1\") then\n ilast = i - 1\n ret = a\n break\n end\nend\nif(k <= ilast) then print(\"1\") else print(ret) end\n", "problem_context": "Score: 300 points\n\nProblem Statement\n\nMr. Infinity has a string S consisting of digits from 1 to 9. Each time the date changes, this string changes as follows:\n\nEach occurrence of 2 in S is replaced with 22. Similarly, each 3 becomes 333, 4 becomes 4444, 5 becomes 55555, 6 becomes 666666, 7 becomes 7777777, 8 becomes 88888888 and 9 becomes 999999999. 1 remains as 1.\n\nFor example, if S is 1324, it becomes 1333224444 the next day, and it becomes 133333333322224444444444444444 the day after next.\nYou are interested in what the string looks like after 5 \\times 10^{15} days. What is the K-th character from the left in the string after 5 \\times 10^{15} days?\n\nConstraints\n\nS is a string of length between 1 and 100 (inclusive).\n\nK is an integer between 1 and 10^{18} (inclusive).\n\nThe length of the string after 5 \\times 10^{15} days is at least K.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\nK\n\nOutput\n\nPrint the K-th character from the left in Mr. Infinity's string after 5 \\times 10^{15} days.\n\nSample Input 1\n\n1214\n4\n\nSample Output 1\n\n2\n\nThe string S changes as follows:\n\nNow: 1214\n\nAfter one day: 12214444\n\nAfter two days: 1222214444444444444444\n\nAfter three days: 12222222214444444444444444444444444444444444444444444444444444444444444444\n\nThe first five characters in the string after 5 \\times 10^{15} days is 12222. As K=4, we should print the fourth character, 2.\n\nSample Input 2\n\n3\n157\n\nSample Output 2\n\n3\n\nThe initial string is 3. The string after 5 \\times 10^{15} days consists only of 3.\n\nSample Input 3\n\n299792458\n9460730472580800\n\nSample Output 3\n\n2", "sample_input": "1214\n4\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03282", "source_text": "Score: 300 points\n\nProblem Statement\n\nMr. Infinity has a string S consisting of digits from 1 to 9. Each time the date changes, this string changes as follows:\n\nEach occurrence of 2 in S is replaced with 22. Similarly, each 3 becomes 333, 4 becomes 4444, 5 becomes 55555, 6 becomes 666666, 7 becomes 7777777, 8 becomes 88888888 and 9 becomes 999999999. 1 remains as 1.\n\nFor example, if S is 1324, it becomes 1333224444 the next day, and it becomes 133333333322224444444444444444 the day after next.\nYou are interested in what the string looks like after 5 \\times 10^{15} days. What is the K-th character from the left in the string after 5 \\times 10^{15} days?\n\nConstraints\n\nS is a string of length between 1 and 100 (inclusive).\n\nK is an integer between 1 and 10^{18} (inclusive).\n\nThe length of the string after 5 \\times 10^{15} days is at least K.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\nK\n\nOutput\n\nPrint the K-th character from the left in Mr. Infinity's string after 5 \\times 10^{15} days.\n\nSample Input 1\n\n1214\n4\n\nSample Output 1\n\n2\n\nThe string S changes as follows:\n\nNow: 1214\n\nAfter one day: 12214444\n\nAfter two days: 1222214444444444444444\n\nAfter three days: 12222222214444444444444444444444444444444444444444444444444444444444444444\n\nThe first five characters in the string after 5 \\times 10^{15} days is 12222. As K=4, we should print the fourth character, 2.\n\nSample Input 2\n\n3\n157\n\nSample Output 2\n\n3\n\nThe initial string is 3. The string after 5 \\times 10^{15} days consists only of 3.\n\nSample Input 3\n\n299792458\n9460730472580800\n\nSample Output 3\n\n2", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 236, "cpu_time_ms": 4, "memory_kb": 636}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s872787080", "group_id": "codeNet:p03283", "input_text": "local n, m, q = io.read(\"*n\", \"*n\", \"*n\")\n\nlocal t = {}\nfor i = 1, n * n do t[i] = 0 end\n\nfor i = 1, m do\n local l, r = io.read(\"*n\", \"*n\")\n local idx = (r - 1) * n + l\n t[idx] = t[idx] + 1\nend\n\nfor l = 1, n do\n for r = 2, n do\n local src = (r - 2) * n + l\n local dst = (r - 1) * n + l\n t[dst] = t[dst] + t[src]\n end\nend\nfor r = 1, n do\n for l = n - 1, 1, -1 do\n local src = (r - 1) * n + l + 1\n local dst = (r - 1) * n + l\n t[dst] = t[dst] + t[src]\n end\nend\n\nfor i = 1, q do\n local a, b = io.read(\"*n\", \"*n\")\n local idx = (b - 1) * n + a\n print(t[idx])\nend\n", "language": "Lua", "metadata": {"date": 1563718569, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p03283.html", "problem_id": "p03283", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03283/input.txt", "sample_output_relpath": "derived/input_output/data/p03283/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03283/Lua/s872787080.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s872787080", "user_id": "u120582723"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "local n, m, q = io.read(\"*n\", \"*n\", \"*n\")\n\nlocal t = {}\nfor i = 1, n * n do t[i] = 0 end\n\nfor i = 1, m do\n local l, r = io.read(\"*n\", \"*n\")\n local idx = (r - 1) * n + l\n t[idx] = t[idx] + 1\nend\n\nfor l = 1, n do\n for r = 2, n do\n local src = (r - 2) * n + l\n local dst = (r - 1) * n + l\n t[dst] = t[dst] + t[src]\n end\nend\nfor r = 1, n do\n for l = n - 1, 1, -1 do\n local src = (r - 1) * n + l + 1\n local dst = (r - 1) * n + l\n t[dst] = t[dst] + t[src]\n end\nend\n\nfor i = 1, q do\n local a, b = io.read(\"*n\", \"*n\")\n local idx = (b - 1) * n + a\n print(t[idx])\nend\n", "problem_context": "Score: 400 points\n\nProblem Statement\n\nIn Takahashi Kingdom, there is a east-west railroad and N cities along it, numbered 1, 2, 3, ..., N from west to east.\nA company called AtCoder Express possesses M trains, and the train i runs from City L_i to City R_i (it is possible that L_i = R_i).\nTakahashi the king is interested in the following Q matters:\n\nThe number of the trains that runs strictly within the section from City p_i to City q_i, that is, the number of trains j such that p_i \\leq L_j and R_j \\leq q_i.\n\nAlthough he is genius, this is too much data to process by himself. Find the answer for each of these Q queries to help him.\n\nConstraints\n\nN is an integer between 1 and 500 (inclusive).\n\nM is an integer between 1 and 200 \\ 000 (inclusive).\n\nQ is an integer between 1 and 100 \\ 000 (inclusive).\n\n1 \\leq L_i \\leq R_i \\leq N (1 \\leq i \\leq M)\n\n1 \\leq p_i \\leq q_i \\leq N (1 \\leq i \\leq Q)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M Q\nL_1 R_1\nL_2 R_2\n:\nL_M R_M\np_1 q_1\np_2 q_2\n:\np_Q q_Q\n\nOutput\n\nPrint Q lines. The i-th line should contain the number of the trains that runs strictly within the section from City p_i to City q_i.\n\nSample Input 1\n\n2 3 1\n1 1\n1 2\n2 2\n1 2\n\nSample Output 1\n\n3\n\nAs all the trains runs within the section from City 1 to City 2, the answer to the only query is 3.\n\nSample Input 2\n\n10 3 2\n1 5\n2 8\n7 10\n1 7\n3 10\n\nSample Output 2\n\n1\n1\n\nThe first query is on the section from City 1 to 7. There is only one train that runs strictly within that section: Train 1.\nThe second query is on the section from City 3 to 10. There is only one train that runs strictly within that section: Train 3.\n\nSample Input 3\n\n10 10 10\n1 6\n2 9\n4 5\n4 7\n4 7\n5 8\n6 6\n6 7\n7 9\n10 10\n1 8\n1 9\n1 10\n2 8\n2 9\n2 10\n3 8\n3 9\n3 10\n1 10\n\nSample Output 3\n\n7\n9\n10\n6\n8\n9\n6\n7\n8\n10", "sample_input": "2 3 1\n1 1\n1 2\n2 2\n1 2\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03283", "source_text": "Score: 400 points\n\nProblem Statement\n\nIn Takahashi Kingdom, there is a east-west railroad and N cities along it, numbered 1, 2, 3, ..., N from west to east.\nA company called AtCoder Express possesses M trains, and the train i runs from City L_i to City R_i (it is possible that L_i = R_i).\nTakahashi the king is interested in the following Q matters:\n\nThe number of the trains that runs strictly within the section from City p_i to City q_i, that is, the number of trains j such that p_i \\leq L_j and R_j \\leq q_i.\n\nAlthough he is genius, this is too much data to process by himself. Find the answer for each of these Q queries to help him.\n\nConstraints\n\nN is an integer between 1 and 500 (inclusive).\n\nM is an integer between 1 and 200 \\ 000 (inclusive).\n\nQ is an integer between 1 and 100 \\ 000 (inclusive).\n\n1 \\leq L_i \\leq R_i \\leq N (1 \\leq i \\leq M)\n\n1 \\leq p_i \\leq q_i \\leq N (1 \\leq i \\leq Q)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M Q\nL_1 R_1\nL_2 R_2\n:\nL_M R_M\np_1 q_1\np_2 q_2\n:\np_Q q_Q\n\nOutput\n\nPrint Q lines. The i-th line should contain the number of the trains that runs strictly within the section from City p_i to City q_i.\n\nSample Input 1\n\n2 3 1\n1 1\n1 2\n2 2\n1 2\n\nSample Output 1\n\n3\n\nAs all the trains runs within the section from City 1 to City 2, the answer to the only query is 3.\n\nSample Input 2\n\n10 3 2\n1 5\n2 8\n7 10\n1 7\n3 10\n\nSample Output 2\n\n1\n1\n\nThe first query is on the section from City 1 to 7. There is only one train that runs strictly within that section: Train 1.\nThe second query is on the section from City 3 to 10. There is only one train that runs strictly within that section: Train 3.\n\nSample Input 3\n\n10 10 10\n1 6\n2 9\n4 5\n4 7\n4 7\n5 8\n6 6\n6 7\n7 9\n10 10\n1 8\n1 9\n1 10\n2 8\n2 9\n2 10\n3 8\n3 9\n3 10\n1 10\n\nSample Output 3\n\n7\n9\n10\n6\n8\n9\n6\n7\n8\n10", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 586, "cpu_time_ms": 168, "memory_kb": 3072}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s478741554", "group_id": "codeNet:p03283", "input_text": "local n, m, q = io.read(\"*n\", \"*n\", \"*n\")\n\nlocal t = {}\nfor i = 1, n * n do t[i] = 0 end\n\nfor i = 1, m do\n local l, r = io.read(\"*n\", \"*n\")\n local idx = (r - 1) * n + l\n t[idx] = t[idx] + 1\nend\n\nfor l = 1, n do\n for r = 2, n do\n local src = (r - 2) * n + l\n local dst = (r - 1) * n + l\n t[dst] = t[dst] + t[src]\n end\nend\nfor r = 1, n do\n for l = n - 1, 1, -1 do\n local src = (r - 1) * n + l + 1\n local dst = (r - 1) * n + l\n t[dst] = t[dst] + t[src]\n end\nend\n\nfor i = 1, q do\n local a, b = io.read(\"*n\", \"*n\")\n local idx = (b - 1) * n + a\n print(t[idx])\nend\n", "language": "Lua", "metadata": {"date": 1563718530, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03283.html", "problem_id": "p03283", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03283/input.txt", "sample_output_relpath": "derived/input_output/data/p03283/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03283/Lua/s478741554.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s478741554", "user_id": "u120582723"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "local n, m, q = io.read(\"*n\", \"*n\", \"*n\")\n\nlocal t = {}\nfor i = 1, n * n do t[i] = 0 end\n\nfor i = 1, m do\n local l, r = io.read(\"*n\", \"*n\")\n local idx = (r - 1) * n + l\n t[idx] = t[idx] + 1\nend\n\nfor l = 1, n do\n for r = 2, n do\n local src = (r - 2) * n + l\n local dst = (r - 1) * n + l\n t[dst] = t[dst] + t[src]\n end\nend\nfor r = 1, n do\n for l = n - 1, 1, -1 do\n local src = (r - 1) * n + l + 1\n local dst = (r - 1) * n + l\n t[dst] = t[dst] + t[src]\n end\nend\n\nfor i = 1, q do\n local a, b = io.read(\"*n\", \"*n\")\n local idx = (b - 1) * n + a\n print(t[idx])\nend\n", "problem_context": "Score: 400 points\n\nProblem Statement\n\nIn Takahashi Kingdom, there is a east-west railroad and N cities along it, numbered 1, 2, 3, ..., N from west to east.\nA company called AtCoder Express possesses M trains, and the train i runs from City L_i to City R_i (it is possible that L_i = R_i).\nTakahashi the king is interested in the following Q matters:\n\nThe number of the trains that runs strictly within the section from City p_i to City q_i, that is, the number of trains j such that p_i \\leq L_j and R_j \\leq q_i.\n\nAlthough he is genius, this is too much data to process by himself. Find the answer for each of these Q queries to help him.\n\nConstraints\n\nN is an integer between 1 and 500 (inclusive).\n\nM is an integer between 1 and 200 \\ 000 (inclusive).\n\nQ is an integer between 1 and 100 \\ 000 (inclusive).\n\n1 \\leq L_i \\leq R_i \\leq N (1 \\leq i \\leq M)\n\n1 \\leq p_i \\leq q_i \\leq N (1 \\leq i \\leq Q)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M Q\nL_1 R_1\nL_2 R_2\n:\nL_M R_M\np_1 q_1\np_2 q_2\n:\np_Q q_Q\n\nOutput\n\nPrint Q lines. The i-th line should contain the number of the trains that runs strictly within the section from City p_i to City q_i.\n\nSample Input 1\n\n2 3 1\n1 1\n1 2\n2 2\n1 2\n\nSample Output 1\n\n3\n\nAs all the trains runs within the section from City 1 to City 2, the answer to the only query is 3.\n\nSample Input 2\n\n10 3 2\n1 5\n2 8\n7 10\n1 7\n3 10\n\nSample Output 2\n\n1\n1\n\nThe first query is on the section from City 1 to 7. There is only one train that runs strictly within that section: Train 1.\nThe second query is on the section from City 3 to 10. There is only one train that runs strictly within that section: Train 3.\n\nSample Input 3\n\n10 10 10\n1 6\n2 9\n4 5\n4 7\n4 7\n5 8\n6 6\n6 7\n7 9\n10 10\n1 8\n1 9\n1 10\n2 8\n2 9\n2 10\n3 8\n3 9\n3 10\n1 10\n\nSample Output 3\n\n7\n9\n10\n6\n8\n9\n6\n7\n8\n10", "sample_input": "2 3 1\n1 1\n1 2\n2 2\n1 2\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03283", "source_text": "Score: 400 points\n\nProblem Statement\n\nIn Takahashi Kingdom, there is a east-west railroad and N cities along it, numbered 1, 2, 3, ..., N from west to east.\nA company called AtCoder Express possesses M trains, and the train i runs from City L_i to City R_i (it is possible that L_i = R_i).\nTakahashi the king is interested in the following Q matters:\n\nThe number of the trains that runs strictly within the section from City p_i to City q_i, that is, the number of trains j such that p_i \\leq L_j and R_j \\leq q_i.\n\nAlthough he is genius, this is too much data to process by himself. Find the answer for each of these Q queries to help him.\n\nConstraints\n\nN is an integer between 1 and 500 (inclusive).\n\nM is an integer between 1 and 200 \\ 000 (inclusive).\n\nQ is an integer between 1 and 100 \\ 000 (inclusive).\n\n1 \\leq L_i \\leq R_i \\leq N (1 \\leq i \\leq M)\n\n1 \\leq p_i \\leq q_i \\leq N (1 \\leq i \\leq Q)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M Q\nL_1 R_1\nL_2 R_2\n:\nL_M R_M\np_1 q_1\np_2 q_2\n:\np_Q q_Q\n\nOutput\n\nPrint Q lines. The i-th line should contain the number of the trains that runs strictly within the section from City p_i to City q_i.\n\nSample Input 1\n\n2 3 1\n1 1\n1 2\n2 2\n1 2\n\nSample Output 1\n\n3\n\nAs all the trains runs within the section from City 1 to City 2, the answer to the only query is 3.\n\nSample Input 2\n\n10 3 2\n1 5\n2 8\n7 10\n1 7\n3 10\n\nSample Output 2\n\n1\n1\n\nThe first query is on the section from City 1 to 7. There is only one train that runs strictly within that section: Train 1.\nThe second query is on the section from City 3 to 10. There is only one train that runs strictly within that section: Train 3.\n\nSample Input 3\n\n10 10 10\n1 6\n2 9\n4 5\n4 7\n4 7\n5 8\n6 6\n6 7\n7 9\n10 10\n1 8\n1 9\n1 10\n2 8\n2 9\n2 10\n3 8\n3 9\n3 10\n1 10\n\nSample Output 3\n\n7\n9\n10\n6\n8\n9\n6\n7\n8\n10", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 586, "cpu_time_ms": 450, "memory_kb": 7288}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s665320942", "group_id": "codeNet:p03284", "input_text": "N, K = io.read(\"*n\", \"*n\")\n\nif N % K > 0 then\n print(1)\nelse\n print(0)\nend", "language": "Lua", "metadata": {"date": 1534036153, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03284.html", "problem_id": "p03284", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03284/input.txt", "sample_output_relpath": "derived/input_output/data/p03284/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03284/Lua/s665320942.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s665320942", "user_id": "u374892957"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "N, K = io.read(\"*n\", \"*n\")\n\nif N % K > 0 then\n print(1)\nelse\n print(0)\nend", "problem_context": "Score : 100 points\n\nProblem Statement\n\nTakahashi has decided to distribute N AtCoder Crackers to K users of as evenly as possible.\nWhen all the crackers are distributed, find the minimum possible (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user.\n\nConstraints\n\n1 \\leq N,K \\leq 100\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\n\nOutput\n\nPrint the minimum possible (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user.\n\nSample Input 1\n\n7 3\n\nSample Output 1\n\n1\n\nWhen the users receive two, two and three crackers, respectively, the (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user, is 1.\n\nSample Input 2\n\n100 10\n\nSample Output 2\n\n0\n\nThe crackers can be distributed evenly.\n\nSample Input 3\n\n1 1\n\nSample Output 3\n\n0", "sample_input": "7 3\n"}, "reference_outputs": ["1\n"], "source_document_id": "p03284", "source_text": "Score : 100 points\n\nProblem Statement\n\nTakahashi has decided to distribute N AtCoder Crackers to K users of as evenly as possible.\nWhen all the crackers are distributed, find the minimum possible (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user.\n\nConstraints\n\n1 \\leq N,K \\leq 100\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\n\nOutput\n\nPrint the minimum possible (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user.\n\nSample Input 1\n\n7 3\n\nSample Output 1\n\n1\n\nWhen the users receive two, two and three crackers, respectively, the (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user, is 1.\n\nSample Input 2\n\n100 10\n\nSample Output 2\n\n0\n\nThe crackers can be distributed evenly.\n\nSample Input 3\n\n1 1\n\nSample Output 3\n\n0", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 76, "cpu_time_ms": 183, "memory_kb": 1012}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s011962925", "group_id": "codeNet:p03285", "input_text": "local n = tonumber(io.read());\nlocal count4, count7 = n // 4, n // 7;\nlocal result = \"No\";\n\nfor i = 0, count4 do\n for j = 0 , count7 do\n if i * 4 + j * 7 == n then\n result = \"Yes\";\n goto exit\n end\n end\nend\n\n::exit::\nprint(result);", "language": "Lua", "metadata": {"date": 1534036299, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03285.html", "problem_id": "p03285", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03285/input.txt", "sample_output_relpath": "derived/input_output/data/p03285/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03285/Lua/s011962925.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s011962925", "user_id": "u061001716"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "local n = tonumber(io.read());\nlocal count4, count7 = n // 4, n // 7;\nlocal result = \"No\";\n\nfor i = 0, count4 do\n for j = 0 , count7 do\n if i * 4 + j * 7 == n then\n result = \"Yes\";\n goto exit\n end\n end\nend\n\n::exit::\nprint(result);", "problem_context": "Score : 200 points\n\nProblem Statement\n\nLa Confiserie d'ABC sells cakes at 4 dollars each and doughnuts at 7 dollars each.\nDetermine if there is a way to buy some of them for exactly N dollars. You can buy two or more doughnuts and two or more cakes, and you can also choose to buy zero doughnuts or zero cakes.\n\nConstraints\n\nN is an integer between 1 and 100, inclusive.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nIf there is a way to buy some cakes and some doughnuts for exactly N dollars, print Yes; otherwise, print No.\n\nSample Input 1\n\n11\n\nSample Output 1\n\nYes\n\nIf you buy one cake and one doughnut, the total will be 4 + 7 = 11 dollars.\n\nSample Input 2\n\n40\n\nSample Output 2\n\nYes\n\nIf you buy ten cakes, the total will be 4 \\times 10 = 40 dollars.\n\nSample Input 3\n\n3\n\nSample Output 3\n\nNo\n\nThe prices of cakes (4 dollars) and doughnuts (7 dollars) are both higher than 3 dollars, so there is no such way.", "sample_input": "11\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03285", "source_text": "Score : 200 points\n\nProblem Statement\n\nLa Confiserie d'ABC sells cakes at 4 dollars each and doughnuts at 7 dollars each.\nDetermine if there is a way to buy some of them for exactly N dollars. You can buy two or more doughnuts and two or more cakes, and you can also choose to buy zero doughnuts or zero cakes.\n\nConstraints\n\nN is an integer between 1 and 100, inclusive.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nIf there is a way to buy some cakes and some doughnuts for exactly N dollars, print Yes; otherwise, print No.\n\nSample Input 1\n\n11\n\nSample Output 1\n\nYes\n\nIf you buy one cake and one doughnut, the total will be 4 + 7 = 11 dollars.\n\nSample Input 2\n\n40\n\nSample Output 2\n\nYes\n\nIf you buy ten cakes, the total will be 4 \\times 10 = 40 dollars.\n\nSample Input 3\n\n3\n\nSample Output 3\n\nNo\n\nThe prices of cakes (4 dollars) and doughnuts (7 dollars) are both higher than 3 dollars, so there is no such way.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 272, "cpu_time_ms": 121, "memory_kb": 760}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s828053717", "group_id": "codeNet:p03286", "input_text": "local n=io.read(\"n\")\nlocal output=\"\"\nwhile n~=0 do\n local r=(n>0 and n%2 or -n%2)\n n=(n-r)//-2\n output=r..output\nend\nprint(#output>0 and output or 0)", "language": "Lua", "metadata": {"date": 1596164955, "filename_ext": "lua", "original_language": "Lua (Lua 5.3.5)", "problem_description_relpath": "problem_descriptions/p03286.html", "problem_id": "p03286", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03286/input.txt", "sample_output_relpath": "derived/input_output/data/p03286/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03286/Lua/s828053717.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s828053717", "user_id": "u045238009"}, "prompt_components": {"gold_output": "1011\n", "input_to_evaluate": "local n=io.read(\"n\")\nlocal output=\"\"\nwhile n~=0 do\n local r=(n>0 and n%2 or -n%2)\n n=(n-r)//-2\n output=r..output\nend\nprint(#output>0 and output or 0)", "problem_context": "Score : 300 points\n\nProblem Statement\n\nGiven an integer N, find the base -2 representation of N.\n\nHere, S is the base -2 representation of N when the following are all satisfied:\n\nS is a string consisting of 0 and 1.\n\nUnless S = 0, the initial character of S is 1.\n\nLet S = S_k S_{k-1} ... S_0, then S_0 \\times (-2)^0 + S_1 \\times (-2)^1 + ... + S_k \\times (-2)^k = N.\n\nIt can be proved that, for any integer M, the base -2 representation of M is uniquely determined.\n\nConstraints\n\nEvery value in input is integer.\n\n-10^9 \\leq N \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the base -2 representation of N.\n\nSample Input 1\n\n-9\n\nSample Output 1\n\n1011\n\nAs (-2)^0 + (-2)^1 + (-2)^3 = 1 + (-2) + (-8) = -9, 1011 is the base -2 representation of -9.\n\nSample Input 2\n\n123456789\n\nSample Output 2\n\n11000101011001101110100010101\n\nSample Input 3\n\n0\n\nSample Output 3\n\n0", "sample_input": "-9\n"}, "reference_outputs": ["1011\n"], "source_document_id": "p03286", "source_text": "Score : 300 points\n\nProblem Statement\n\nGiven an integer N, find the base -2 representation of N.\n\nHere, S is the base -2 representation of N when the following are all satisfied:\n\nS is a string consisting of 0 and 1.\n\nUnless S = 0, the initial character of S is 1.\n\nLet S = S_k S_{k-1} ... S_0, then S_0 \\times (-2)^0 + S_1 \\times (-2)^1 + ... + S_k \\times (-2)^k = N.\n\nIt can be proved that, for any integer M, the base -2 representation of M is uniquely determined.\n\nConstraints\n\nEvery value in input is integer.\n\n-10^9 \\leq N \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the base -2 representation of N.\n\nSample Input 1\n\n-9\n\nSample Output 1\n\n1011\n\nAs (-2)^0 + (-2)^1 + (-2)^3 = 1 + (-2) + (-8) = -9, 1011 is the base -2 representation of -9.\n\nSample Input 2\n\n123456789\n\nSample Output 2\n\n11000101011001101110100010101\n\nSample Input 3\n\n0\n\nSample Output 3\n\n0", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 158, "cpu_time_ms": 6, "memory_kb": 2712}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s925171927", "group_id": "codeNet:p03286", "input_text": "n = io.read(\"*n\")\ndig = 1\nflg = 1\nif(0 < n) then flg = 0 else n = -n end\nt = {}\nwhile(0 < n) do\n rem = n % 2\n if(dig % 2 == flg and rem == 1) then\n n = n + 1\n end\n table.insert(t, 1, rem)\n n = math.floor(n / 2)\n flg = (flg + 1) % 2\nend\nlen = #t\nfor i = 1, len do\n io.write(string.format(\"%d\", t[i]))\nend\nif(len == 0) then io.write(0) end\nio.write(\"\\n\")\n", "language": "Lua", "metadata": {"date": 1554831410, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p03286.html", "problem_id": "p03286", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03286/input.txt", "sample_output_relpath": "derived/input_output/data/p03286/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03286/Lua/s925171927.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s925171927", "user_id": "u120582723"}, "prompt_components": {"gold_output": "1011\n", "input_to_evaluate": "n = io.read(\"*n\")\ndig = 1\nflg = 1\nif(0 < n) then flg = 0 else n = -n end\nt = {}\nwhile(0 < n) do\n rem = n % 2\n if(dig % 2 == flg and rem == 1) then\n n = n + 1\n end\n table.insert(t, 1, rem)\n n = math.floor(n / 2)\n flg = (flg + 1) % 2\nend\nlen = #t\nfor i = 1, len do\n io.write(string.format(\"%d\", t[i]))\nend\nif(len == 0) then io.write(0) end\nio.write(\"\\n\")\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nGiven an integer N, find the base -2 representation of N.\n\nHere, S is the base -2 representation of N when the following are all satisfied:\n\nS is a string consisting of 0 and 1.\n\nUnless S = 0, the initial character of S is 1.\n\nLet S = S_k S_{k-1} ... S_0, then S_0 \\times (-2)^0 + S_1 \\times (-2)^1 + ... + S_k \\times (-2)^k = N.\n\nIt can be proved that, for any integer M, the base -2 representation of M is uniquely determined.\n\nConstraints\n\nEvery value in input is integer.\n\n-10^9 \\leq N \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the base -2 representation of N.\n\nSample Input 1\n\n-9\n\nSample Output 1\n\n1011\n\nAs (-2)^0 + (-2)^1 + (-2)^3 = 1 + (-2) + (-8) = -9, 1011 is the base -2 representation of -9.\n\nSample Input 2\n\n123456789\n\nSample Output 2\n\n11000101011001101110100010101\n\nSample Input 3\n\n0\n\nSample Output 3\n\n0", "sample_input": "-9\n"}, "reference_outputs": ["1011\n"], "source_document_id": "p03286", "source_text": "Score : 300 points\n\nProblem Statement\n\nGiven an integer N, find the base -2 representation of N.\n\nHere, S is the base -2 representation of N when the following are all satisfied:\n\nS is a string consisting of 0 and 1.\n\nUnless S = 0, the initial character of S is 1.\n\nLet S = S_k S_{k-1} ... S_0, then S_0 \\times (-2)^0 + S_1 \\times (-2)^1 + ... + S_k \\times (-2)^k = N.\n\nIt can be proved that, for any integer M, the base -2 representation of M is uniquely determined.\n\nConstraints\n\nEvery value in input is integer.\n\n-10^9 \\leq N \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the base -2 representation of N.\n\nSample Input 1\n\n-9\n\nSample Output 1\n\n1011\n\nAs (-2)^0 + (-2)^1 + (-2)^3 = 1 + (-2) + (-8) = -9, 1011 is the base -2 representation of -9.\n\nSample Input 2\n\n123456789\n\nSample Output 2\n\n11000101011001101110100010101\n\nSample Input 3\n\n0\n\nSample Output 3\n\n0", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 363, "cpu_time_ms": 3, "memory_kb": 384}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s391241595", "group_id": "codeNet:p03288", "input_text": "a=io.read()*1\nprint(a<1200 and\"ABC\"or a<2800 and \"ARC\"or\"AGC\")", "language": "Lua", "metadata": {"date": 1551993157, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03288.html", "problem_id": "p03288", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03288/input.txt", "sample_output_relpath": "derived/input_output/data/p03288/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03288/Lua/s391241595.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s391241595", "user_id": "u837412668"}, "prompt_components": {"gold_output": "ABC\n", "input_to_evaluate": "a=io.read()*1\nprint(a<1200 and\"ABC\"or a<2800 and \"ARC\"or\"AGC\")", "problem_context": "Score : 100 points\n\nProblem Statement\n\nA programming competition site AtCode regularly holds programming contests.\n\nThe next contest on AtCode is called ABC, which is rated for contestants with ratings less than 1200.\n\nThe contest after the ABC is called ARC, which is rated for contestants with ratings less than 2800.\n\nThe contest after the ARC is called AGC, which is rated for all contestants.\n\nTakahashi's rating on AtCode is R. What is the next contest rated for him?\n\nConstraints\n\n0 ≤ R ≤ 4208\n\nR is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nR\n\nOutput\n\nPrint the name of the next contest rated for Takahashi (ABC, ARC or AGC).\n\nSample Input 1\n\n1199\n\nSample Output 1\n\nABC\n\n1199 is less than 1200, so ABC will be rated.\n\nSample Input 2\n\n1200\n\nSample Output 2\n\nARC\n\n1200 is not less than 1200 and ABC will be unrated, but it is less than 2800 and ARC will be rated.\n\nSample Input 3\n\n4208\n\nSample Output 3\n\nAGC", "sample_input": "1199\n"}, "reference_outputs": ["ABC\n"], "source_document_id": "p03288", "source_text": "Score : 100 points\n\nProblem Statement\n\nA programming competition site AtCode regularly holds programming contests.\n\nThe next contest on AtCode is called ABC, which is rated for contestants with ratings less than 1200.\n\nThe contest after the ABC is called ARC, which is rated for contestants with ratings less than 2800.\n\nThe contest after the ARC is called AGC, which is rated for all contestants.\n\nTakahashi's rating on AtCode is R. What is the next contest rated for him?\n\nConstraints\n\n0 ≤ R ≤ 4208\n\nR is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nR\n\nOutput\n\nPrint the name of the next contest rated for Takahashi (ABC, ARC or AGC).\n\nSample Input 1\n\n1199\n\nSample Output 1\n\nABC\n\n1199 is less than 1200, so ABC will be rated.\n\nSample Input 2\n\n1200\n\nSample Output 2\n\nARC\n\n1200 is not less than 1200 and ABC will be unrated, but it is less than 2800 and ARC will be rated.\n\nSample Input 3\n\n4208\n\nSample Output 3\n\nAGC", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 62, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s084545075", "group_id": "codeNet:p03288", "input_text": "R = io.read(\"*n\")\nif R < 1200 then\n print(\"ABC\")\nelseif R < 2800 then\n print(\"ARC\")\nelse\n print(\"AGC\")\nend", "language": "Lua", "metadata": {"date": 1533517888, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03288.html", "problem_id": "p03288", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03288/input.txt", "sample_output_relpath": "derived/input_output/data/p03288/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03288/Lua/s084545075.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s084545075", "user_id": "u374892957"}, "prompt_components": {"gold_output": "ABC\n", "input_to_evaluate": "R = io.read(\"*n\")\nif R < 1200 then\n print(\"ABC\")\nelseif R < 2800 then\n print(\"ARC\")\nelse\n print(\"AGC\")\nend", "problem_context": "Score : 100 points\n\nProblem Statement\n\nA programming competition site AtCode regularly holds programming contests.\n\nThe next contest on AtCode is called ABC, which is rated for contestants with ratings less than 1200.\n\nThe contest after the ABC is called ARC, which is rated for contestants with ratings less than 2800.\n\nThe contest after the ARC is called AGC, which is rated for all contestants.\n\nTakahashi's rating on AtCode is R. What is the next contest rated for him?\n\nConstraints\n\n0 ≤ R ≤ 4208\n\nR is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nR\n\nOutput\n\nPrint the name of the next contest rated for Takahashi (ABC, ARC or AGC).\n\nSample Input 1\n\n1199\n\nSample Output 1\n\nABC\n\n1199 is less than 1200, so ABC will be rated.\n\nSample Input 2\n\n1200\n\nSample Output 2\n\nARC\n\n1200 is not less than 1200 and ABC will be unrated, but it is less than 2800 and ARC will be rated.\n\nSample Input 3\n\n4208\n\nSample Output 3\n\nAGC", "sample_input": "1199\n"}, "reference_outputs": ["ABC\n"], "source_document_id": "p03288", "source_text": "Score : 100 points\n\nProblem Statement\n\nA programming competition site AtCode regularly holds programming contests.\n\nThe next contest on AtCode is called ABC, which is rated for contestants with ratings less than 1200.\n\nThe contest after the ABC is called ARC, which is rated for contestants with ratings less than 2800.\n\nThe contest after the ARC is called AGC, which is rated for all contestants.\n\nTakahashi's rating on AtCode is R. What is the next contest rated for him?\n\nConstraints\n\n0 ≤ R ≤ 4208\n\nR is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nR\n\nOutput\n\nPrint the name of the next contest rated for Takahashi (ABC, ARC or AGC).\n\nSample Input 1\n\n1199\n\nSample Output 1\n\nABC\n\n1199 is less than 1200, so ABC will be rated.\n\nSample Input 2\n\n1200\n\nSample Output 2\n\nARC\n\n1200 is not less than 1200 and ABC will be unrated, but it is less than 2800 and ARC will be rated.\n\nSample Input 3\n\n4208\n\nSample Output 3\n\nAGC", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 109, "cpu_time_ms": 187, "memory_kb": 760}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s321567105", "group_id": "codeNet:p03289", "input_text": "S=io.read()\nres=\"AC\"\nif string.sub(S,1,1)~=\"A\" then\n res=\"WA\"\nend\nif string.sub(S,3,3)~=\"C\" then\n res=\"WA\"\nend\nif string.sub(S,2,2)<\"a\" or string.sub(S,2,2)>\"z\" then\n res=\"WA\"\nend\nfor i=4,#S do\n if string.sub(S,i,i)<\"a\" or string.sub(S,i,i)>\"z\" then\n res=\"WA\"\n break\n end\nend\nprint(res)", "language": "Lua", "metadata": {"date": 1550370410, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03289.html", "problem_id": "p03289", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03289/input.txt", "sample_output_relpath": "derived/input_output/data/p03289/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03289/Lua/s321567105.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s321567105", "user_id": "u015229643"}, "prompt_components": {"gold_output": "AC\n", "input_to_evaluate": "S=io.read()\nres=\"AC\"\nif string.sub(S,1,1)~=\"A\" then\n res=\"WA\"\nend\nif string.sub(S,3,3)~=\"C\" then\n res=\"WA\"\nend\nif string.sub(S,2,2)<\"a\" or string.sub(S,2,2)>\"z\" then\n res=\"WA\"\nend\nfor i=4,#S do\n if string.sub(S,i,i)<\"a\" or string.sub(S,i,i)>\"z\" then\n res=\"WA\"\n break\n end\nend\nprint(res)", "problem_context": "Score : 200 points\n\nProblem Statement\n\nYou are given a string S. Each character of S is uppercase or lowercase English letter.\nDetermine if S satisfies all of the following conditions:\n\nThe initial character of S is an uppercase A.\n\nThere is exactly one occurrence of C between the third character from the beginning and the second to last character (inclusive).\n\nAll letters except the A and C mentioned above are lowercase.\n\nConstraints\n\n4 ≤ |S| ≤ 10 (|S| is the length of the string S.)\n\nEach character of S is uppercase or lowercase English letter.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nIf S satisfies all of the conditions in the problem statement, print AC; otherwise, print WA.\n\nSample Input 1\n\nAtCoder\n\nSample Output 1\n\nAC\n\nThe first letter is A, the third letter is C and the remaining letters are all lowercase, so all the conditions are satisfied.\n\nSample Input 2\n\nACoder\n\nSample Output 2\n\nWA\n\nThe second letter should not be C.\n\nSample Input 3\n\nAcycliC\n\nSample Output 3\n\nWA\n\nThe last letter should not be C, either.\n\nSample Input 4\n\nAtCoCo\n\nSample Output 4\n\nWA\n\nThere should not be two or more occurrences of C.\n\nSample Input 5\n\nAtcoder\n\nSample Output 5\n\nWA\n\nThe number of C should not be zero, either.", "sample_input": "AtCoder\n"}, "reference_outputs": ["AC\n"], "source_document_id": "p03289", "source_text": "Score : 200 points\n\nProblem Statement\n\nYou are given a string S. Each character of S is uppercase or lowercase English letter.\nDetermine if S satisfies all of the following conditions:\n\nThe initial character of S is an uppercase A.\n\nThere is exactly one occurrence of C between the third character from the beginning and the second to last character (inclusive).\n\nAll letters except the A and C mentioned above are lowercase.\n\nConstraints\n\n4 ≤ |S| ≤ 10 (|S| is the length of the string S.)\n\nEach character of S is uppercase or lowercase English letter.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nIf S satisfies all of the conditions in the problem statement, print AC; otherwise, print WA.\n\nSample Input 1\n\nAtCoder\n\nSample Output 1\n\nAC\n\nThe first letter is A, the third letter is C and the remaining letters are all lowercase, so all the conditions are satisfied.\n\nSample Input 2\n\nACoder\n\nSample Output 2\n\nWA\n\nThe second letter should not be C.\n\nSample Input 3\n\nAcycliC\n\nSample Output 3\n\nWA\n\nThe last letter should not be C, either.\n\nSample Input 4\n\nAtCoCo\n\nSample Output 4\n\nWA\n\nThere should not be two or more occurrences of C.\n\nSample Input 5\n\nAtcoder\n\nSample Output 5\n\nWA\n\nThe number of C should not be zero, either.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 297, "cpu_time_ms": 51, "memory_kb": 888}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s243396276", "group_id": "codeNet:p03289", "input_text": "S=io.read()\nres=\"AC\"\nif string.sub(S,1,1)~=\"A\" then\n res=\"WA\"\nend\nif string.sub(S,3,3)~=\"C\" then\n res=\"WA\"\nend\nif string.sub(S,2,2)<\"a\" or string.sub(S,2,2)>\"z\" then\n res=\"WA\"\nend\nfor i=4,#S do\n if string.sub(S,i,i)<\"a\" or string.sub(S,i,i)>\"z\" then\n res=\"WA\"\n end\nend\nprint(res)", "language": "Lua", "metadata": {"date": 1550370167, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03289.html", "problem_id": "p03289", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03289/input.txt", "sample_output_relpath": "derived/input_output/data/p03289/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03289/Lua/s243396276.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s243396276", "user_id": "u015229643"}, "prompt_components": {"gold_output": "AC\n", "input_to_evaluate": "S=io.read()\nres=\"AC\"\nif string.sub(S,1,1)~=\"A\" then\n res=\"WA\"\nend\nif string.sub(S,3,3)~=\"C\" then\n res=\"WA\"\nend\nif string.sub(S,2,2)<\"a\" or string.sub(S,2,2)>\"z\" then\n res=\"WA\"\nend\nfor i=4,#S do\n if string.sub(S,i,i)<\"a\" or string.sub(S,i,i)>\"z\" then\n res=\"WA\"\n end\nend\nprint(res)", "problem_context": "Score : 200 points\n\nProblem Statement\n\nYou are given a string S. Each character of S is uppercase or lowercase English letter.\nDetermine if S satisfies all of the following conditions:\n\nThe initial character of S is an uppercase A.\n\nThere is exactly one occurrence of C between the third character from the beginning and the second to last character (inclusive).\n\nAll letters except the A and C mentioned above are lowercase.\n\nConstraints\n\n4 ≤ |S| ≤ 10 (|S| is the length of the string S.)\n\nEach character of S is uppercase or lowercase English letter.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nIf S satisfies all of the conditions in the problem statement, print AC; otherwise, print WA.\n\nSample Input 1\n\nAtCoder\n\nSample Output 1\n\nAC\n\nThe first letter is A, the third letter is C and the remaining letters are all lowercase, so all the conditions are satisfied.\n\nSample Input 2\n\nACoder\n\nSample Output 2\n\nWA\n\nThe second letter should not be C.\n\nSample Input 3\n\nAcycliC\n\nSample Output 3\n\nWA\n\nThe last letter should not be C, either.\n\nSample Input 4\n\nAtCoCo\n\nSample Output 4\n\nWA\n\nThere should not be two or more occurrences of C.\n\nSample Input 5\n\nAtcoder\n\nSample Output 5\n\nWA\n\nThe number of C should not be zero, either.", "sample_input": "AtCoder\n"}, "reference_outputs": ["AC\n"], "source_document_id": "p03289", "source_text": "Score : 200 points\n\nProblem Statement\n\nYou are given a string S. Each character of S is uppercase or lowercase English letter.\nDetermine if S satisfies all of the following conditions:\n\nThe initial character of S is an uppercase A.\n\nThere is exactly one occurrence of C between the third character from the beginning and the second to last character (inclusive).\n\nAll letters except the A and C mentioned above are lowercase.\n\nConstraints\n\n4 ≤ |S| ≤ 10 (|S| is the length of the string S.)\n\nEach character of S is uppercase or lowercase English letter.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nIf S satisfies all of the conditions in the problem statement, print AC; otherwise, print WA.\n\nSample Input 1\n\nAtCoder\n\nSample Output 1\n\nAC\n\nThe first letter is A, the third letter is C and the remaining letters are all lowercase, so all the conditions are satisfied.\n\nSample Input 2\n\nACoder\n\nSample Output 2\n\nWA\n\nThe second letter should not be C.\n\nSample Input 3\n\nAcycliC\n\nSample Output 3\n\nWA\n\nThe last letter should not be C, either.\n\nSample Input 4\n\nAtCoCo\n\nSample Output 4\n\nWA\n\nThere should not be two or more occurrences of C.\n\nSample Input 5\n\nAtcoder\n\nSample Output 5\n\nWA\n\nThe number of C should not be zero, either.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 287, "cpu_time_ms": 7, "memory_kb": 888}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s970679655", "group_id": "codeNet:p03291", "input_text": "local mod = 1000000007\nlocal mfl = math.floor\n\nlocal function bmul(x, y)\n local x1, y1 = mfl(x / 31623), mfl(y / 31623)\n local x0, y0 = x - x1 * 31623, y - y1 * 31623\n return (x1 * y1 * 14122 + (x1 * y0 + x0 * y1) * 31623 + x0 * y0) % mod\nend\n\nlocal function badd(x, y)\n return (x + y) % mod\nend\n\nlocal s = io.read()\nlocal n = #s\nlocal ret = 0\nlocal acnt = 0\nlocal abcnt = 0\nlocal mul = 1\nfor i = 1, n do\n local ss = s:sub(i, i)\n if ss == \"A\" then\n acnt = badd(acnt, mul)\n elseif ss == \"B\" then\n abcnt = badd(abcnt, acnt)\n elseif ss == \"C\" then\n ret = badd(ret, abcnt)\n else\n ret = badd(bmul(ret, 3), abcnt)\n abcnt = badd(bmul(abcnt, 3), acnt)\n acnt = badd(bmul(acnt, 3), mul)\n mul = bmul(mul, 3)\n end\nend\nprint(ret)\n", "language": "Lua", "metadata": {"date": 1588379538, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p03291.html", "problem_id": "p03291", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03291/input.txt", "sample_output_relpath": "derived/input_output/data/p03291/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03291/Lua/s970679655.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s970679655", "user_id": "u120582723"}, "prompt_components": {"gold_output": "8\n", "input_to_evaluate": "local mod = 1000000007\nlocal mfl = math.floor\n\nlocal function bmul(x, y)\n local x1, y1 = mfl(x / 31623), mfl(y / 31623)\n local x0, y0 = x - x1 * 31623, y - y1 * 31623\n return (x1 * y1 * 14122 + (x1 * y0 + x0 * y1) * 31623 + x0 * y0) % mod\nend\n\nlocal function badd(x, y)\n return (x + y) % mod\nend\n\nlocal s = io.read()\nlocal n = #s\nlocal ret = 0\nlocal acnt = 0\nlocal abcnt = 0\nlocal mul = 1\nfor i = 1, n do\n local ss = s:sub(i, i)\n if ss == \"A\" then\n acnt = badd(acnt, mul)\n elseif ss == \"B\" then\n abcnt = badd(abcnt, acnt)\n elseif ss == \"C\" then\n ret = badd(ret, abcnt)\n else\n ret = badd(bmul(ret, 3), abcnt)\n abcnt = badd(bmul(abcnt, 3), acnt)\n acnt = badd(bmul(acnt, 3), mul)\n mul = bmul(mul, 3)\n end\nend\nprint(ret)\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nThe ABC number of a string T is the number of triples of integers (i, j, k) that satisfy all of the following conditions:\n\n1 ≤ i < j < k ≤ |T| (|T| is the length of T.)\n\nT_i = A (T_i is the i-th character of T from the beginning.)\n\nT_j = B\n\nT_k = C\n\nFor example, when T = ABCBC, there are three triples of integers (i, j, k) that satisfy the conditions: (1, 2, 3), (1, 2, 5), (1, 4, 5). Thus, the ABC number of T is 3.\n\nYou are given a string S. Each character of S is A, B, C or ?.\n\nLet Q be the number of occurrences of ? in S. We can make 3^Q strings by replacing each occurrence of ? in S with A, B or C. Find the sum of the ABC numbers of all these strings.\n\nThis sum can be extremely large, so print the sum modulo 10^9 + 7.\n\nConstraints\n\n3 ≤ |S| ≤ 10^5\n\nEach character of S is A, B, C or ?.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the sum of the ABC numbers of all the 3^Q strings, modulo 10^9 + 7.\n\nSample Input 1\n\nA??C\n\nSample Output 1\n\n8\n\nIn this case, Q = 2, and we can make 3^Q = 9 strings by by replacing each occurrence of ? with A, B or C. The ABC number of each of these strings is as follows:\n\nAAAC: 0\n\nAABC: 2\n\nAACC: 0\n\nABAC: 1\n\nABBC: 2\n\nABCC: 2\n\nACAC: 0\n\nACBC: 1\n\nACCC: 0\n\nThe sum of these is 0 + 2 + 0 + 1 + 2 + 2 + 0 + 1 + 0 = 8, so we print 8 modulo 10^9 + 7, that is, 8.\n\nSample Input 2\n\nABCBC\n\nSample Output 2\n\n3\n\nWhen Q = 0, we print the ABC number of S itself, modulo 10^9 + 7. This string is the same as the one given as an example in the problem statement, and its ABC number is 3.\n\nSample Input 3\n\n????C?????B??????A???????\n\nSample Output 3\n\n979596887\n\nIn this case, the sum of the ABC numbers of all the 3^Q strings is 2291979612924, and we should print this number modulo 10^9 + 7, that is, 979596887.", "sample_input": "A??C\n"}, "reference_outputs": ["8\n"], "source_document_id": "p03291", "source_text": "Score : 400 points\n\nProblem Statement\n\nThe ABC number of a string T is the number of triples of integers (i, j, k) that satisfy all of the following conditions:\n\n1 ≤ i < j < k ≤ |T| (|T| is the length of T.)\n\nT_i = A (T_i is the i-th character of T from the beginning.)\n\nT_j = B\n\nT_k = C\n\nFor example, when T = ABCBC, there are three triples of integers (i, j, k) that satisfy the conditions: (1, 2, 3), (1, 2, 5), (1, 4, 5). Thus, the ABC number of T is 3.\n\nYou are given a string S. Each character of S is A, B, C or ?.\n\nLet Q be the number of occurrences of ? in S. We can make 3^Q strings by replacing each occurrence of ? in S with A, B or C. Find the sum of the ABC numbers of all these strings.\n\nThis sum can be extremely large, so print the sum modulo 10^9 + 7.\n\nConstraints\n\n3 ≤ |S| ≤ 10^5\n\nEach character of S is A, B, C or ?.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the sum of the ABC numbers of all the 3^Q strings, modulo 10^9 + 7.\n\nSample Input 1\n\nA??C\n\nSample Output 1\n\n8\n\nIn this case, Q = 2, and we can make 3^Q = 9 strings by by replacing each occurrence of ? with A, B or C. The ABC number of each of these strings is as follows:\n\nAAAC: 0\n\nAABC: 2\n\nAACC: 0\n\nABAC: 1\n\nABBC: 2\n\nABCC: 2\n\nACAC: 0\n\nACBC: 1\n\nACCC: 0\n\nThe sum of these is 0 + 2 + 0 + 1 + 2 + 2 + 0 + 1 + 0 = 8, so we print 8 modulo 10^9 + 7, that is, 8.\n\nSample Input 2\n\nABCBC\n\nSample Output 2\n\n3\n\nWhen Q = 0, we print the ABC number of S itself, modulo 10^9 + 7. This string is the same as the one given as an example in the problem statement, and its ABC number is 3.\n\nSample Input 3\n\n????C?????B??????A???????\n\nSample Output 3\n\n979596887\n\nIn this case, the sum of the ABC numbers of all the 3^Q strings is 2291979612924, and we should print this number modulo 10^9 + 7, that is, 979596887.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 748, "cpu_time_ms": 7, "memory_kb": 512}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s722450640", "group_id": "codeNet:p03292", "input_text": "a,b,c=io.read(\"n\",\"n\",\"n\")\nprint(math.max(a,b,c)-math.min(a,b,c))", "language": "Lua", "metadata": {"date": 1578267630, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03292.html", "problem_id": "p03292", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03292/input.txt", "sample_output_relpath": "derived/input_output/data/p03292/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03292/Lua/s722450640.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s722450640", "user_id": "u162773977"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "a,b,c=io.read(\"n\",\"n\",\"n\")\nprint(math.max(a,b,c)-math.min(a,b,c))", "problem_context": "Score : 100 points\n\nProblem Statement\n\nYou have three tasks, all of which need to be completed.\n\nFirst, you can complete any one task at cost 0.\n\nThen, just after completing the i-th task, you can complete the j-th task at cost |A_j - A_i|.\n\nHere, |x| denotes the absolute value of x.\n\nFind the minimum total cost required to complete all the task.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq A_1, A_2, A_3 \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA_1 A_2 A_3\n\nOutput\n\nPrint the minimum total cost required to complete all the task.\n\nSample Input 1\n\n1 6 3\n\nSample Output 1\n\n5\n\nWhen the tasks are completed in the following order, the total cost will be 5, which is the minimum:\n\nComplete the first task at cost 0.\n\nComplete the third task at cost 2.\n\nComplete the second task at cost 3.\n\nSample Input 2\n\n11 5 5\n\nSample Output 2\n\n6\n\nSample Input 3\n\n100 100 100\n\nSample Output 3\n\n0", "sample_input": "1 6 3\n"}, "reference_outputs": ["5\n"], "source_document_id": "p03292", "source_text": "Score : 100 points\n\nProblem Statement\n\nYou have three tasks, all of which need to be completed.\n\nFirst, you can complete any one task at cost 0.\n\nThen, just after completing the i-th task, you can complete the j-th task at cost |A_j - A_i|.\n\nHere, |x| denotes the absolute value of x.\n\nFind the minimum total cost required to complete all the task.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq A_1, A_2, A_3 \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA_1 A_2 A_3\n\nOutput\n\nPrint the minimum total cost required to complete all the task.\n\nSample Input 1\n\n1 6 3\n\nSample Output 1\n\n5\n\nWhen the tasks are completed in the following order, the total cost will be 5, which is the minimum:\n\nComplete the first task at cost 0.\n\nComplete the third task at cost 2.\n\nComplete the second task at cost 3.\n\nSample Input 2\n\n11 5 5\n\nSample Output 2\n\n6\n\nSample Input 3\n\n100 100 100\n\nSample Output 3\n\n0", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 65, "cpu_time_ms": 7, "memory_kb": 760}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s562450307", "group_id": "codeNet:p03292", "input_text": "local a, b, c = string.match(io.read(), \"(%d+) (%d+) (%d+)\");\nlocal x = {\n tonumber(a),\n tonumber(b),\n tonumber(c),\n};\n\ntable.sort(x);\n\nprint(math.abs(x[2] - x[1]) + math.abs(x[3] - x[2]));", "language": "Lua", "metadata": {"date": 1532221792, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03292.html", "problem_id": "p03292", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03292/input.txt", "sample_output_relpath": "derived/input_output/data/p03292/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03292/Lua/s562450307.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s562450307", "user_id": "u061001716"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "local a, b, c = string.match(io.read(), \"(%d+) (%d+) (%d+)\");\nlocal x = {\n tonumber(a),\n tonumber(b),\n tonumber(c),\n};\n\ntable.sort(x);\n\nprint(math.abs(x[2] - x[1]) + math.abs(x[3] - x[2]));", "problem_context": "Score : 100 points\n\nProblem Statement\n\nYou have three tasks, all of which need to be completed.\n\nFirst, you can complete any one task at cost 0.\n\nThen, just after completing the i-th task, you can complete the j-th task at cost |A_j - A_i|.\n\nHere, |x| denotes the absolute value of x.\n\nFind the minimum total cost required to complete all the task.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq A_1, A_2, A_3 \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA_1 A_2 A_3\n\nOutput\n\nPrint the minimum total cost required to complete all the task.\n\nSample Input 1\n\n1 6 3\n\nSample Output 1\n\n5\n\nWhen the tasks are completed in the following order, the total cost will be 5, which is the minimum:\n\nComplete the first task at cost 0.\n\nComplete the third task at cost 2.\n\nComplete the second task at cost 3.\n\nSample Input 2\n\n11 5 5\n\nSample Output 2\n\n6\n\nSample Input 3\n\n100 100 100\n\nSample Output 3\n\n0", "sample_input": "1 6 3\n"}, "reference_outputs": ["5\n"], "source_document_id": "p03292", "source_text": "Score : 100 points\n\nProblem Statement\n\nYou have three tasks, all of which need to be completed.\n\nFirst, you can complete any one task at cost 0.\n\nThen, just after completing the i-th task, you can complete the j-th task at cost |A_j - A_i|.\n\nHere, |x| denotes the absolute value of x.\n\nFind the minimum total cost required to complete all the task.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq A_1, A_2, A_3 \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA_1 A_2 A_3\n\nOutput\n\nPrint the minimum total cost required to complete all the task.\n\nSample Input 1\n\n1 6 3\n\nSample Output 1\n\n5\n\nWhen the tasks are completed in the following order, the total cost will be 5, which is the minimum:\n\nComplete the first task at cost 0.\n\nComplete the third task at cost 2.\n\nComplete the second task at cost 3.\n\nSample Input 2\n\n11 5 5\n\nSample Output 2\n\n6\n\nSample Input 3\n\n100 100 100\n\nSample Output 3\n\n0", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 192, "cpu_time_ms": 125, "memory_kb": 760}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s032141443", "group_id": "codeNet:p03293", "input_text": "local s = {};\nlocal t = {};\n\nfor v in string.gmatch(io.read(),\"%w\") do\n table.insert(s, v);\nend\n\nfor v in string.gmatch(io.read(),\"%w\") do\n table.insert(t, v);\nend\n\ntable.sort(s);\ntable.sort(t);\n\nlocal result = \"Yes\";\nfor i = 1, #s do\n if s[i] ~= t[i] then\n result = \"No\";\n break;\n end\nend\n\nprint(result);", "language": "Lua", "metadata": {"date": 1532222846, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03293.html", "problem_id": "p03293", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03293/input.txt", "sample_output_relpath": "derived/input_output/data/p03293/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03293/Lua/s032141443.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s032141443", "user_id": "u061001716"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "local s = {};\nlocal t = {};\n\nfor v in string.gmatch(io.read(),\"%w\") do\n table.insert(s, v);\nend\n\nfor v in string.gmatch(io.read(),\"%w\") do\n table.insert(t, v);\nend\n\ntable.sort(s);\ntable.sort(t);\n\nlocal result = \"Yes\";\nfor i = 1, #s do\n if s[i] ~= t[i] then\n result = \"No\";\n break;\n end\nend\n\nprint(result);", "problem_context": "Score : 200 points\n\nProblem Statement\n\nYou are given string S and T consisting of lowercase English letters.\n\nDetermine if S equals T after rotation.\n\nThat is, determine if S equals T after the following operation is performed some number of times:\n\nOperation: Let S = S_1 S_2 ... S_{|S|}. Change S to S_{|S|} S_1 S_2 ... S_{|S|-1}.\n\nHere, |X| denotes the length of the string X.\n\nConstraints\n\n2 \\leq |S| \\leq 100\n\n|S| = |T|\n\nS and T consist of lowercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\nT\n\nOutput\n\nIf S equals T after rotation, print Yes; if it does not, print No.\n\nSample Input 1\n\nkyoto\ntokyo\n\nSample Output 1\n\nYes\n\nIn the first operation, kyoto becomes okyot.\n\nIn the second operation, okyot becomes tokyo.\n\nSample Input 2\n\nabc\narc\n\nSample Output 2\n\nNo\n\nabc does not equal arc after any number of operations.\n\nSample Input 3\n\naaaaaaaaaaaaaaab\naaaaaaaaaaaaaaab\n\nSample Output 3\n\nYes", "sample_input": "kyoto\ntokyo\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03293", "source_text": "Score : 200 points\n\nProblem Statement\n\nYou are given string S and T consisting of lowercase English letters.\n\nDetermine if S equals T after rotation.\n\nThat is, determine if S equals T after the following operation is performed some number of times:\n\nOperation: Let S = S_1 S_2 ... S_{|S|}. Change S to S_{|S|} S_1 S_2 ... S_{|S|-1}.\n\nHere, |X| denotes the length of the string X.\n\nConstraints\n\n2 \\leq |S| \\leq 100\n\n|S| = |T|\n\nS and T consist of lowercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\nT\n\nOutput\n\nIf S equals T after rotation, print Yes; if it does not, print No.\n\nSample Input 1\n\nkyoto\ntokyo\n\nSample Output 1\n\nYes\n\nIn the first operation, kyoto becomes okyot.\n\nIn the second operation, okyot becomes tokyo.\n\nSample Input 2\n\nabc\narc\n\nSample Output 2\n\nNo\n\nabc does not equal arc after any number of operations.\n\nSample Input 3\n\naaaaaaaaaaaaaaab\naaaaaaaaaaaaaaab\n\nSample Output 3\n\nYes", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 315, "cpu_time_ms": 80, "memory_kb": 760}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s823870033", "group_id": "codeNet:p03294", "input_text": "io.read()\n\nfm = 0\n\nfor v in string.gmatch(io.read(), \"(%d+)\") do\n fm = fm + (tonumber(v) - 1)\nend\n\nprint(fm)", "language": "Lua", "metadata": {"date": 1532223528, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03294.html", "problem_id": "p03294", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03294/input.txt", "sample_output_relpath": "derived/input_output/data/p03294/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03294/Lua/s823870033.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s823870033", "user_id": "u374892957"}, "prompt_components": {"gold_output": "10\n", "input_to_evaluate": "io.read()\n\nfm = 0\n\nfor v in string.gmatch(io.read(), \"(%d+)\") do\n fm = fm + (tonumber(v) - 1)\nend\n\nprint(fm)", "problem_context": "Score : 300 points\n\nProblem Statement\n\nYou are given N positive integers a_1, a_2, ..., a_N.\n\nFor a non-negative integer m, let f(m) = (m\\ mod\\ a_1) + (m\\ mod\\ a_2) + ... + (m\\ mod\\ a_N).\n\nHere, X\\ mod\\ Y denotes the remainder of the division of X by Y.\n\nFind the maximum value of f.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 3000\n\n2 \\leq a_i \\leq 10^5\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 ... a_N\n\nOutput\n\nPrint the maximum value of f.\n\nSample Input 1\n\n3\n3 4 6\n\nSample Output 1\n\n10\n\nf(11) = (11\\ mod\\ 3) + (11\\ mod\\ 4) + (11\\ mod\\ 6) = 10 is the maximum value of f.\n\nSample Input 2\n\n5\n7 46 11 20 11\n\nSample Output 2\n\n90\n\nSample Input 3\n\n7\n994 518 941 851 647 2 581\n\nSample Output 3\n\n4527", "sample_input": "3\n3 4 6\n"}, "reference_outputs": ["10\n"], "source_document_id": "p03294", "source_text": "Score : 300 points\n\nProblem Statement\n\nYou are given N positive integers a_1, a_2, ..., a_N.\n\nFor a non-negative integer m, let f(m) = (m\\ mod\\ a_1) + (m\\ mod\\ a_2) + ... + (m\\ mod\\ a_N).\n\nHere, X\\ mod\\ Y denotes the remainder of the division of X by Y.\n\nFind the maximum value of f.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 3000\n\n2 \\leq a_i \\leq 10^5\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 ... a_N\n\nOutput\n\nPrint the maximum value of f.\n\nSample Input 1\n\n3\n3 4 6\n\nSample Output 1\n\n10\n\nf(11) = (11\\ mod\\ 3) + (11\\ mod\\ 4) + (11\\ mod\\ 6) = 10 is the maximum value of f.\n\nSample Input 2\n\n5\n7 46 11 20 11\n\nSample Output 2\n\n90\n\nSample Input 3\n\n7\n994 518 941 851 647 2 581\n\nSample Output 3\n\n4527", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 109, "cpu_time_ms": 67, "memory_kb": 760}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s922366130", "group_id": "codeNet:p03295", "input_text": "local n, m = io.read(\"*n\", \"*n\")\nlocal left, right = {}, {}\nlocal idx = {}\nfor i = 1, m do\n left[i], right[i] = io.read(\"*n\", \"*n\")\n idx[i] = i\nend\nlocal function sortfunc(a, b)\n if right[a] == right[b] then\n return left[a] < left[b]\n else\n return right[a] < right[b]\n end\nend\ntable.sort(idx, sortfunc)\n\nlocal cnt = 0\nlocal curleft = 1\nfor i = 1, m do\n local l, r = left[idx[i]], right[idx[i]]\n if curleft <= l then\n curleft = r\n cnt = cnt + 1\n end\nend\nprint(cnt)\n", "language": "Lua", "metadata": {"date": 1584828309, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03295.html", "problem_id": "p03295", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03295/input.txt", "sample_output_relpath": "derived/input_output/data/p03295/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03295/Lua/s922366130.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s922366130", "user_id": "u120582723"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "local n, m = io.read(\"*n\", \"*n\")\nlocal left, right = {}, {}\nlocal idx = {}\nfor i = 1, m do\n left[i], right[i] = io.read(\"*n\", \"*n\")\n idx[i] = i\nend\nlocal function sortfunc(a, b)\n if right[a] == right[b] then\n return left[a] < left[b]\n else\n return right[a] < right[b]\n end\nend\ntable.sort(idx, sortfunc)\n\nlocal cnt = 0\nlocal curleft = 1\nfor i = 1, m do\n local l, r = left[idx[i]], right[idx[i]]\n if curleft <= l then\n curleft = r\n cnt = cnt + 1\n end\nend\nprint(cnt)\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nThere are N islands lining up from west to east, connected by N-1 bridges.\n\nThe i-th bridge connects the i-th island from the west and the (i+1)-th island from the west.\n\nOne day, disputes took place between some islands, and there were M requests from the inhabitants of the islands:\n\nRequest i: A dispute took place between the a_i-th island from the west and the b_i-th island from the west. Please make traveling between these islands with bridges impossible.\n\nYou decided to remove some bridges to meet all these M requests.\n\nFind the minimum number of bridges that must be removed.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^5\n\n1 \\leq a_i < b_i \\leq N\n\nAll pairs (a_i, b_i) are distinct.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\na_1 b_1\na_2 b_2\n:\na_M b_M\n\nOutput\n\nPrint the minimum number of bridges that must be removed.\n\nSample Input 1\n\n5 2\n1 4\n2 5\n\nSample Output 1\n\n1\n\nThe requests can be met by removing the bridge connecting the second and third islands from the west.\n\nSample Input 2\n\n9 5\n1 8\n2 7\n3 5\n4 6\n7 9\n\nSample Output 2\n\n2\n\nSample Input 3\n\n5 10\n1 2\n1 3\n1 4\n1 5\n2 3\n2 4\n2 5\n3 4\n3 5\n4 5\n\nSample Output 3\n\n4", "sample_input": "5 2\n1 4\n2 5\n"}, "reference_outputs": ["1\n"], "source_document_id": "p03295", "source_text": "Score : 400 points\n\nProblem Statement\n\nThere are N islands lining up from west to east, connected by N-1 bridges.\n\nThe i-th bridge connects the i-th island from the west and the (i+1)-th island from the west.\n\nOne day, disputes took place between some islands, and there were M requests from the inhabitants of the islands:\n\nRequest i: A dispute took place between the a_i-th island from the west and the b_i-th island from the west. Please make traveling between these islands with bridges impossible.\n\nYou decided to remove some bridges to meet all these M requests.\n\nFind the minimum number of bridges that must be removed.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^5\n\n1 \\leq a_i < b_i \\leq N\n\nAll pairs (a_i, b_i) are distinct.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\na_1 b_1\na_2 b_2\n:\na_M b_M\n\nOutput\n\nPrint the minimum number of bridges that must be removed.\n\nSample Input 1\n\n5 2\n1 4\n2 5\n\nSample Output 1\n\n1\n\nThe requests can be met by removing the bridge connecting the second and third islands from the west.\n\nSample Input 2\n\n9 5\n1 8\n2 7\n3 5\n4 6\n7 9\n\nSample Output 2\n\n2\n\nSample Input 3\n\n5 10\n1 2\n1 3\n1 4\n1 5\n2 3\n2 4\n2 5\n3 4\n3 5\n4 5\n\nSample Output 3\n\n4", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 484, "cpu_time_ms": 371, "memory_kb": 6520}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s648237885", "group_id": "codeNet:p03295", "input_text": "local n, m = io.read(\"*n\", \"*n\")\nlocal t = {}\nfor i = 1, m do\n local a, b = io.read(\"*n\", \"*n\")\n local tmp = {a, b, false}\n table.insert(t, tmp)\nend\ntable.sort(t, function(x, y)\n if x[2] == y[2] then return x[1] < y[1]\n else return x[2] < y[2] end\nend\n)\nlocal curidx = 1\nlocal ret = 0\nwhile curidx <= m do\n local cutpos = t[curidx][2] - 1\n ret = ret + 1\n curidx = curidx + 1\n while curidx <= m and t[curidx][1] <= cutpos do\n curidx = curidx + 1\n end\nend\nprint(ret)\n", "language": "Lua", "metadata": {"date": 1563421805, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p03295.html", "problem_id": "p03295", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03295/input.txt", "sample_output_relpath": "derived/input_output/data/p03295/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03295/Lua/s648237885.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s648237885", "user_id": "u120582723"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "local n, m = io.read(\"*n\", \"*n\")\nlocal t = {}\nfor i = 1, m do\n local a, b = io.read(\"*n\", \"*n\")\n local tmp = {a, b, false}\n table.insert(t, tmp)\nend\ntable.sort(t, function(x, y)\n if x[2] == y[2] then return x[1] < y[1]\n else return x[2] < y[2] end\nend\n)\nlocal curidx = 1\nlocal ret = 0\nwhile curidx <= m do\n local cutpos = t[curidx][2] - 1\n ret = ret + 1\n curidx = curidx + 1\n while curidx <= m and t[curidx][1] <= cutpos do\n curidx = curidx + 1\n end\nend\nprint(ret)\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nThere are N islands lining up from west to east, connected by N-1 bridges.\n\nThe i-th bridge connects the i-th island from the west and the (i+1)-th island from the west.\n\nOne day, disputes took place between some islands, and there were M requests from the inhabitants of the islands:\n\nRequest i: A dispute took place between the a_i-th island from the west and the b_i-th island from the west. Please make traveling between these islands with bridges impossible.\n\nYou decided to remove some bridges to meet all these M requests.\n\nFind the minimum number of bridges that must be removed.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^5\n\n1 \\leq a_i < b_i \\leq N\n\nAll pairs (a_i, b_i) are distinct.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\na_1 b_1\na_2 b_2\n:\na_M b_M\n\nOutput\n\nPrint the minimum number of bridges that must be removed.\n\nSample Input 1\n\n5 2\n1 4\n2 5\n\nSample Output 1\n\n1\n\nThe requests can be met by removing the bridge connecting the second and third islands from the west.\n\nSample Input 2\n\n9 5\n1 8\n2 7\n3 5\n4 6\n7 9\n\nSample Output 2\n\n2\n\nSample Input 3\n\n5 10\n1 2\n1 3\n1 4\n1 5\n2 3\n2 4\n2 5\n3 4\n3 5\n4 5\n\nSample Output 3\n\n4", "sample_input": "5 2\n1 4\n2 5\n"}, "reference_outputs": ["1\n"], "source_document_id": "p03295", "source_text": "Score : 400 points\n\nProblem Statement\n\nThere are N islands lining up from west to east, connected by N-1 bridges.\n\nThe i-th bridge connects the i-th island from the west and the (i+1)-th island from the west.\n\nOne day, disputes took place between some islands, and there were M requests from the inhabitants of the islands:\n\nRequest i: A dispute took place between the a_i-th island from the west and the b_i-th island from the west. Please make traveling between these islands with bridges impossible.\n\nYou decided to remove some bridges to meet all these M requests.\n\nFind the minimum number of bridges that must be removed.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^5\n\n1 \\leq a_i < b_i \\leq N\n\nAll pairs (a_i, b_i) are distinct.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\na_1 b_1\na_2 b_2\n:\na_M b_M\n\nOutput\n\nPrint the minimum number of bridges that must be removed.\n\nSample Input 1\n\n5 2\n1 4\n2 5\n\nSample Output 1\n\n1\n\nThe requests can be met by removing the bridge connecting the second and third islands from the west.\n\nSample Input 2\n\n9 5\n1 8\n2 7\n3 5\n4 6\n7 9\n\nSample Output 2\n\n2\n\nSample Input 3\n\n5 10\n1 2\n1 3\n1 4\n1 5\n2 3\n2 4\n2 5\n3 4\n3 5\n4 5\n\nSample Output 3\n\n4", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 478, "cpu_time_ms": 192, "memory_kb": 8320}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s138951171", "group_id": "codeNet:p03296", "input_text": "io.read()\n\np = 0\nans = 0\n\nfor v in string.gmatch(io.read(), \"(%d+)\") do\n if v == p then\n ans = ans + 1\n p = 0\n else\n p = v\n end\nend\n\nprint(ans)", "language": "Lua", "metadata": {"date": 1531617032, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03296.html", "problem_id": "p03296", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03296/input.txt", "sample_output_relpath": "derived/input_output/data/p03296/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03296/Lua/s138951171.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s138951171", "user_id": "u374892957"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "io.read()\n\np = 0\nans = 0\n\nfor v in string.gmatch(io.read(), \"(%d+)\") do\n if v == p then\n ans = ans + 1\n p = 0\n else\n p = v\n end\nend\n\nprint(ans)", "problem_context": "Score : 200 points\n\nProblem Statement\n\nTakahashi lives in another world. There are slimes (creatures) of 10000 colors in this world. Let us call these colors Color 1, 2, ..., 10000.\n\nTakahashi has N slimes, and they are standing in a row from left to right. The color of the i-th slime from the left is a_i.\nIf two slimes of the same color are adjacent, they will start to combine themselves. Because Takahashi likes smaller slimes, he has decided to change the colors of some of the slimes with his magic.\n\nTakahashi can change the color of one slime to any of the 10000 colors by one spell.\nHow many spells are required so that no slimes will start to combine themselves?\n\nConstraints\n\n2 \\leq N \\leq 100\n\n1 \\leq a_i \\leq N\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 ... a_N\n\nOutput\n\nPrint the minimum number of spells required.\n\nSample Input 1\n\n5\n1 1 2 2 2\n\nSample Output 1\n\n2\n\nFor example, if we change the color of the second slime from the left to 4, and the color of the fourth slime to 5, the colors of the slimes will be 1, 4, 2, 5, 2, which satisfy the condition.\n\nSample Input 2\n\n3\n1 2 1\n\nSample Output 2\n\n0\n\nAlthough the colors of the first and third slimes are the same, they are not adjacent, so no spell is required.\n\nSample Input 3\n\n5\n1 1 1 1 1\n\nSample Output 3\n\n2\n\nFor example, if we change the colors of the second and fourth slimes from the left to 2, the colors of the slimes will be 1, 2, 1, 2, 1, which satisfy the condition.\n\nSample Input 4\n\n14\n1 2 2 3 3 3 4 4 4 4 1 2 3 4\n\nSample Output 4\n\n4", "sample_input": "5\n1 1 2 2 2\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03296", "source_text": "Score : 200 points\n\nProblem Statement\n\nTakahashi lives in another world. There are slimes (creatures) of 10000 colors in this world. Let us call these colors Color 1, 2, ..., 10000.\n\nTakahashi has N slimes, and they are standing in a row from left to right. The color of the i-th slime from the left is a_i.\nIf two slimes of the same color are adjacent, they will start to combine themselves. Because Takahashi likes smaller slimes, he has decided to change the colors of some of the slimes with his magic.\n\nTakahashi can change the color of one slime to any of the 10000 colors by one spell.\nHow many spells are required so that no slimes will start to combine themselves?\n\nConstraints\n\n2 \\leq N \\leq 100\n\n1 \\leq a_i \\leq N\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 ... a_N\n\nOutput\n\nPrint the minimum number of spells required.\n\nSample Input 1\n\n5\n1 1 2 2 2\n\nSample Output 1\n\n2\n\nFor example, if we change the color of the second slime from the left to 4, and the color of the fourth slime to 5, the colors of the slimes will be 1, 4, 2, 5, 2, which satisfy the condition.\n\nSample Input 2\n\n3\n1 2 1\n\nSample Output 2\n\n0\n\nAlthough the colors of the first and third slimes are the same, they are not adjacent, so no spell is required.\n\nSample Input 3\n\n5\n1 1 1 1 1\n\nSample Output 3\n\n2\n\nFor example, if we change the colors of the second and fourth slimes from the left to 2, the colors of the slimes will be 1, 2, 1, 2, 1, which satisfy the condition.\n\nSample Input 4\n\n14\n1 2 2 3 3 3 4 4 4 4 1 2 3 4\n\nSample Output 4\n\n4", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 155, "cpu_time_ms": 96, "memory_kb": 1012}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s521832393", "group_id": "codeNet:p03297", "input_text": "local function getgcd(x, y)\n while(0 < x and 0 < y) do\n if(x < y) then y = y % x else x = x % y end\n end\n return math.max(x, y)\nend\n\nlocal t = io.read(\"*n\")\n\nfor i = 1, t do\n local a, b, c, d = io.read(\"*n\", \"*n\", \"*n\", \"*n\")\n if(a < b) then print(\"No\")\n elseif(d < b) then print(\"No\")\n elseif(b <= c) then print(\"Yes\")\n elseif(d % b == 0) then\n if(a % b <= c) then print(\"Yes\") else print(\"No\") end\n else\n local gcd = getgcd(a, getgcd(b, d))\n if(c // gcd + 1 == b // gcd) then print(\"Yes\") else print(\"No\") end\n end\nend\n", "language": "Lua", "metadata": {"date": 1556075211, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03297.html", "problem_id": "p03297", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03297/input.txt", "sample_output_relpath": "derived/input_output/data/p03297/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03297/Lua/s521832393.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s521832393", "user_id": "u120582723"}, "prompt_components": {"gold_output": "No\nYes\nNo\nYes\nYes\nNo\nNo\nYes\nNo\nYes\nYes\nNo\nNo\nYes\n", "input_to_evaluate": "local function getgcd(x, y)\n while(0 < x and 0 < y) do\n if(x < y) then y = y % x else x = x % y end\n end\n return math.max(x, y)\nend\n\nlocal t = io.read(\"*n\")\n\nfor i = 1, t do\n local a, b, c, d = io.read(\"*n\", \"*n\", \"*n\", \"*n\")\n if(a < b) then print(\"No\")\n elseif(d < b) then print(\"No\")\n elseif(b <= c) then print(\"Yes\")\n elseif(d % b == 0) then\n if(a % b <= c) then print(\"Yes\") else print(\"No\") end\n else\n local gcd = getgcd(a, getgcd(b, d))\n if(c // gcd + 1 == b // gcd) then print(\"Yes\") else print(\"No\") end\n end\nend\n", "problem_context": "Score : 600 points\n\nProblem Statement\n\nRingo Mart, a convenience store, sells apple juice.\n\nOn the opening day of Ringo Mart, there were A cans of juice in stock in the morning.\nSnuke buys B cans of juice here every day in the daytime.\nThen, the manager checks the number of cans of juice remaining in stock every night.\nIf there are C or less cans, D new cans will be added to the stock by the next morning.\n\nDetermine if Snuke can buy juice indefinitely, that is, there is always B or more cans of juice in stock when he attempts to buy them.\nNobody besides Snuke buy juice at this store.\n\nNote that each test case in this problem consists of T queries.\n\nConstraints\n\n1 \\leq T \\leq 300\n\n1 \\leq A, B, C, D \\leq 10^{18}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nT\nA_1 B_1 C_1 D_1\nA_2 B_2 C_2 D_2\n:\nA_T B_T C_T D_T\n\nIn the i-th query, A = A_i, B = B_i, C = C_i, D = D_i.\n\nOutput\n\nPrint T lines. The i-th line should contain Yes if Snuke can buy apple juice indefinitely in the i-th query; No otherwise.\n\nSample Input 1\n\n14\n9 7 5 9\n9 7 6 9\n14 10 7 12\n14 10 8 12\n14 10 9 12\n14 10 7 11\n14 10 8 11\n14 10 9 11\n9 10 5 10\n10 10 5 10\n11 10 5 10\n16 10 5 10\n1000000000000000000 17 14 999999999999999985\n1000000000000000000 17 15 999999999999999985\n\nSample Output 1\n\nNo\nYes\nNo\nYes\nYes\nNo\nNo\nYes\nNo\nYes\nYes\nNo\nNo\nYes\n\nIn the first query, the number of cans of juice in stock changes as follows: (D represents daytime and N represents night.)\n\n9\n→D 2\n→N 11\n→D 4\n→N 13\n→D 6\n→N 6\n→D x\n\nIn the second query, the number of cans of juice in stock changes as follows:\n\n9\n→D 2\n→N 11\n→D 4\n→N 13\n→D 6\n→N 15\n→D 8\n→N 8\n→D 1\n→N 10\n→D 3\n→N 12\n→D 5\n→N 14\n→D 7\n→N 7\n→D 0\n→N 9\n→D 2\n→N 11\n→D …\n\nand so on, thus Snuke can buy juice indefinitely.\n\nSample Input 2\n\n24\n1 2 3 4\n1 2 4 3\n1 3 2 4\n1 3 4 2\n1 4 2 3\n1 4 3 2\n2 1 3 4\n2 1 4 3\n2 3 1 4\n2 3 4 1\n2 4 1 3\n2 4 3 1\n3 1 2 4\n3 1 4 2\n3 2 1 4\n3 2 4 1\n3 4 1 2\n3 4 2 1\n4 1 2 3\n4 1 3 2\n4 2 1 3\n4 2 3 1\n4 3 1 2\n4 3 2 1\n\nSample Output 2\n\nNo\nNo\nNo\nNo\nNo\nNo\nYes\nYes\nNo\nNo\nNo\nNo\nYes\nYes\nYes\nNo\nNo\nNo\nYes\nYes\nYes\nNo\nNo\nNo", "sample_input": "14\n9 7 5 9\n9 7 6 9\n14 10 7 12\n14 10 8 12\n14 10 9 12\n14 10 7 11\n14 10 8 11\n14 10 9 11\n9 10 5 10\n10 10 5 10\n11 10 5 10\n16 10 5 10\n1000000000000000000 17 14 999999999999999985\n1000000000000000000 17 15 999999999999999985\n"}, "reference_outputs": ["No\nYes\nNo\nYes\nYes\nNo\nNo\nYes\nNo\nYes\nYes\nNo\nNo\nYes\n"], "source_document_id": "p03297", "source_text": "Score : 600 points\n\nProblem Statement\n\nRingo Mart, a convenience store, sells apple juice.\n\nOn the opening day of Ringo Mart, there were A cans of juice in stock in the morning.\nSnuke buys B cans of juice here every day in the daytime.\nThen, the manager checks the number of cans of juice remaining in stock every night.\nIf there are C or less cans, D new cans will be added to the stock by the next morning.\n\nDetermine if Snuke can buy juice indefinitely, that is, there is always B or more cans of juice in stock when he attempts to buy them.\nNobody besides Snuke buy juice at this store.\n\nNote that each test case in this problem consists of T queries.\n\nConstraints\n\n1 \\leq T \\leq 300\n\n1 \\leq A, B, C, D \\leq 10^{18}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nT\nA_1 B_1 C_1 D_1\nA_2 B_2 C_2 D_2\n:\nA_T B_T C_T D_T\n\nIn the i-th query, A = A_i, B = B_i, C = C_i, D = D_i.\n\nOutput\n\nPrint T lines. The i-th line should contain Yes if Snuke can buy apple juice indefinitely in the i-th query; No otherwise.\n\nSample Input 1\n\n14\n9 7 5 9\n9 7 6 9\n14 10 7 12\n14 10 8 12\n14 10 9 12\n14 10 7 11\n14 10 8 11\n14 10 9 11\n9 10 5 10\n10 10 5 10\n11 10 5 10\n16 10 5 10\n1000000000000000000 17 14 999999999999999985\n1000000000000000000 17 15 999999999999999985\n\nSample Output 1\n\nNo\nYes\nNo\nYes\nYes\nNo\nNo\nYes\nNo\nYes\nYes\nNo\nNo\nYes\n\nIn the first query, the number of cans of juice in stock changes as follows: (D represents daytime and N represents night.)\n\n9\n→D 2\n→N 11\n→D 4\n→N 13\n→D 6\n→N 6\n→D x\n\nIn the second query, the number of cans of juice in stock changes as follows:\n\n9\n→D 2\n→N 11\n→D 4\n→N 13\n→D 6\n→N 15\n→D 8\n→N 8\n→D 1\n→N 10\n→D 3\n→N 12\n→D 5\n→N 14\n→D 7\n→N 7\n→D 0\n→N 9\n→D 2\n→N 11\n→D …\n\nand so on, thus Snuke can buy juice indefinitely.\n\nSample Input 2\n\n24\n1 2 3 4\n1 2 4 3\n1 3 2 4\n1 3 4 2\n1 4 2 3\n1 4 3 2\n2 1 3 4\n2 1 4 3\n2 3 1 4\n2 3 4 1\n2 4 1 3\n2 4 3 1\n3 1 2 4\n3 1 4 2\n3 2 1 4\n3 2 4 1\n3 4 1 2\n3 4 2 1\n4 1 2 3\n4 1 3 2\n4 2 1 3\n4 2 3 1\n4 3 1 2\n4 3 2 1\n\nSample Output 2\n\nNo\nNo\nNo\nNo\nNo\nNo\nYes\nYes\nNo\nNo\nNo\nNo\nYes\nYes\nYes\nNo\nNo\nNo\nYes\nYes\nYes\nNo\nNo\nNo", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 543, "cpu_time_ms": 10, "memory_kb": 1012}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s323642809", "group_id": "codeNet:p03297", "input_text": "function M(n,t)\n for i,v in pairs(t) do\n if n == v then\n return true\n end\n end\n return false\nend\n\nT = io.read(\"*n\")\n\nA = {}\nB = {}\nC = {}\nD = {}\n\n\nfor v = 1,T do\n table.insert(A, io.read(\"*n\"))\n table.insert(B, io.read(\"*n\"))\n table.insert(C, io.read(\"*n\"))\n table.insert(D, io.read(\"*n\"))\nend\n\nfor v = 1,T do\n local j = A[v]\n local W = {}\n local ret = \"No\"\n\n while j >= 0 do\n if M(j, W) then\n ret = \"Yes\"\n break\n else\n table.insert(W, j)\n end\n\n if j >= B[v] then\n j = j - B[v]\n else\n break\n end\n\n if j <= C[v] then\n j = j + D[v]\n else\n break\n end\n end\n\n print(ret)\nend", "language": "Lua", "metadata": {"date": 1531624997, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03297.html", "problem_id": "p03297", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03297/input.txt", "sample_output_relpath": "derived/input_output/data/p03297/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03297/Lua/s323642809.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s323642809", "user_id": "u374892957"}, "prompt_components": {"gold_output": "No\nYes\nNo\nYes\nYes\nNo\nNo\nYes\nNo\nYes\nYes\nNo\nNo\nYes\n", "input_to_evaluate": "function M(n,t)\n for i,v in pairs(t) do\n if n == v then\n return true\n end\n end\n return false\nend\n\nT = io.read(\"*n\")\n\nA = {}\nB = {}\nC = {}\nD = {}\n\n\nfor v = 1,T do\n table.insert(A, io.read(\"*n\"))\n table.insert(B, io.read(\"*n\"))\n table.insert(C, io.read(\"*n\"))\n table.insert(D, io.read(\"*n\"))\nend\n\nfor v = 1,T do\n local j = A[v]\n local W = {}\n local ret = \"No\"\n\n while j >= 0 do\n if M(j, W) then\n ret = \"Yes\"\n break\n else\n table.insert(W, j)\n end\n\n if j >= B[v] then\n j = j - B[v]\n else\n break\n end\n\n if j <= C[v] then\n j = j + D[v]\n else\n break\n end\n end\n\n print(ret)\nend", "problem_context": "Score : 600 points\n\nProblem Statement\n\nRingo Mart, a convenience store, sells apple juice.\n\nOn the opening day of Ringo Mart, there were A cans of juice in stock in the morning.\nSnuke buys B cans of juice here every day in the daytime.\nThen, the manager checks the number of cans of juice remaining in stock every night.\nIf there are C or less cans, D new cans will be added to the stock by the next morning.\n\nDetermine if Snuke can buy juice indefinitely, that is, there is always B or more cans of juice in stock when he attempts to buy them.\nNobody besides Snuke buy juice at this store.\n\nNote that each test case in this problem consists of T queries.\n\nConstraints\n\n1 \\leq T \\leq 300\n\n1 \\leq A, B, C, D \\leq 10^{18}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nT\nA_1 B_1 C_1 D_1\nA_2 B_2 C_2 D_2\n:\nA_T B_T C_T D_T\n\nIn the i-th query, A = A_i, B = B_i, C = C_i, D = D_i.\n\nOutput\n\nPrint T lines. The i-th line should contain Yes if Snuke can buy apple juice indefinitely in the i-th query; No otherwise.\n\nSample Input 1\n\n14\n9 7 5 9\n9 7 6 9\n14 10 7 12\n14 10 8 12\n14 10 9 12\n14 10 7 11\n14 10 8 11\n14 10 9 11\n9 10 5 10\n10 10 5 10\n11 10 5 10\n16 10 5 10\n1000000000000000000 17 14 999999999999999985\n1000000000000000000 17 15 999999999999999985\n\nSample Output 1\n\nNo\nYes\nNo\nYes\nYes\nNo\nNo\nYes\nNo\nYes\nYes\nNo\nNo\nYes\n\nIn the first query, the number of cans of juice in stock changes as follows: (D represents daytime and N represents night.)\n\n9\n→D 2\n→N 11\n→D 4\n→N 13\n→D 6\n→N 6\n→D x\n\nIn the second query, the number of cans of juice in stock changes as follows:\n\n9\n→D 2\n→N 11\n→D 4\n→N 13\n→D 6\n→N 15\n→D 8\n→N 8\n→D 1\n→N 10\n→D 3\n→N 12\n→D 5\n→N 14\n→D 7\n→N 7\n→D 0\n→N 9\n→D 2\n→N 11\n→D …\n\nand so on, thus Snuke can buy juice indefinitely.\n\nSample Input 2\n\n24\n1 2 3 4\n1 2 4 3\n1 3 2 4\n1 3 4 2\n1 4 2 3\n1 4 3 2\n2 1 3 4\n2 1 4 3\n2 3 1 4\n2 3 4 1\n2 4 1 3\n2 4 3 1\n3 1 2 4\n3 1 4 2\n3 2 1 4\n3 2 4 1\n3 4 1 2\n3 4 2 1\n4 1 2 3\n4 1 3 2\n4 2 1 3\n4 2 3 1\n4 3 1 2\n4 3 2 1\n\nSample Output 2\n\nNo\nNo\nNo\nNo\nNo\nNo\nYes\nYes\nNo\nNo\nNo\nNo\nYes\nYes\nYes\nNo\nNo\nNo\nYes\nYes\nYes\nNo\nNo\nNo", "sample_input": "14\n9 7 5 9\n9 7 6 9\n14 10 7 12\n14 10 8 12\n14 10 9 12\n14 10 7 11\n14 10 8 11\n14 10 9 11\n9 10 5 10\n10 10 5 10\n11 10 5 10\n16 10 5 10\n1000000000000000000 17 14 999999999999999985\n1000000000000000000 17 15 999999999999999985\n"}, "reference_outputs": ["No\nYes\nNo\nYes\nYes\nNo\nNo\nYes\nNo\nYes\nYes\nNo\nNo\nYes\n"], "source_document_id": "p03297", "source_text": "Score : 600 points\n\nProblem Statement\n\nRingo Mart, a convenience store, sells apple juice.\n\nOn the opening day of Ringo Mart, there were A cans of juice in stock in the morning.\nSnuke buys B cans of juice here every day in the daytime.\nThen, the manager checks the number of cans of juice remaining in stock every night.\nIf there are C or less cans, D new cans will be added to the stock by the next morning.\n\nDetermine if Snuke can buy juice indefinitely, that is, there is always B or more cans of juice in stock when he attempts to buy them.\nNobody besides Snuke buy juice at this store.\n\nNote that each test case in this problem consists of T queries.\n\nConstraints\n\n1 \\leq T \\leq 300\n\n1 \\leq A, B, C, D \\leq 10^{18}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nT\nA_1 B_1 C_1 D_1\nA_2 B_2 C_2 D_2\n:\nA_T B_T C_T D_T\n\nIn the i-th query, A = A_i, B = B_i, C = C_i, D = D_i.\n\nOutput\n\nPrint T lines. The i-th line should contain Yes if Snuke can buy apple juice indefinitely in the i-th query; No otherwise.\n\nSample Input 1\n\n14\n9 7 5 9\n9 7 6 9\n14 10 7 12\n14 10 8 12\n14 10 9 12\n14 10 7 11\n14 10 8 11\n14 10 9 11\n9 10 5 10\n10 10 5 10\n11 10 5 10\n16 10 5 10\n1000000000000000000 17 14 999999999999999985\n1000000000000000000 17 15 999999999999999985\n\nSample Output 1\n\nNo\nYes\nNo\nYes\nYes\nNo\nNo\nYes\nNo\nYes\nYes\nNo\nNo\nYes\n\nIn the first query, the number of cans of juice in stock changes as follows: (D represents daytime and N represents night.)\n\n9\n→D 2\n→N 11\n→D 4\n→N 13\n→D 6\n→N 6\n→D x\n\nIn the second query, the number of cans of juice in stock changes as follows:\n\n9\n→D 2\n→N 11\n→D 4\n→N 13\n→D 6\n→N 15\n→D 8\n→N 8\n→D 1\n→N 10\n→D 3\n→N 12\n→D 5\n→N 14\n→D 7\n→N 7\n→D 0\n→N 9\n→D 2\n→N 11\n→D …\n\nand so on, thus Snuke can buy juice indefinitely.\n\nSample Input 2\n\n24\n1 2 3 4\n1 2 4 3\n1 3 2 4\n1 3 4 2\n1 4 2 3\n1 4 3 2\n2 1 3 4\n2 1 4 3\n2 3 1 4\n2 3 4 1\n2 4 1 3\n2 4 3 1\n3 1 2 4\n3 1 4 2\n3 2 1 4\n3 2 4 1\n3 4 1 2\n3 4 2 1\n4 1 2 3\n4 1 3 2\n4 2 1 3\n4 2 3 1\n4 3 1 2\n4 3 2 1\n\nSample Output 2\n\nNo\nNo\nNo\nNo\nNo\nNo\nYes\nYes\nNo\nNo\nNo\nNo\nYes\nYes\nYes\nNo\nNo\nNo\nYes\nYes\nYes\nNo\nNo\nNo", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 655, "cpu_time_ms": 2103, "memory_kb": 760}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s572313037", "group_id": "codeNet:p03298", "input_text": "local n=io.read(\"n\",\"l\")\nlocal s=io.read()\n\nlocal precheck=true\nlocal t={s:byte(1,2*n)}\ntable.sort(t)\nfor i=1,2*n-1,2 do\n if t[i]~=t[i+1] then\n precheck=false\n end\nend\nif not precheck then\n print(0)\n return\nend\n\nlocal rmap={}\nlocal bmap={}\nlocal bit=require(\"bit\")\nlocal lshift=bit.lshift\nlocal band=bit.band\nfor bit=0,lshift(1,n)-1 do\n local r1=\"\"\n local r2=\"\"\n local b1=\"\"\n local b2=\"\"\n for i=0,n-1 do\n if band(bit,lshift(1,i))>0 then\n local r=i+1\n local b=i+1+n\n r1=r1..s:sub(r,r)\n b2=s:sub(b,b)..b2\n else\n local r=i+1\n local b=i+1+n\n b1=s:sub(b,b)..b1\n r2=r2..s:sub(r,r)\n end\n end\n local rkey=r1..\" \"..r2\n local bkey=b1..\" \"..b2\n rmap[rkey]=(rmap[rkey] or 0)+1\n bmap[bkey]=(bmap[bkey] or 0)+1\nend\n\nlocal combination=0\nfor k,_ in pairs(rmap) do\n combination=combination+rmap[k]*(bmap[k] or 0)\nend\nprint(combination)", "language": "Lua", "metadata": {"date": 1598347226, "filename_ext": "lua", "original_language": "Lua (LuaJIT 2.1.0)", "problem_description_relpath": "problem_descriptions/p03298.html", "problem_id": "p03298", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03298/input.txt", "sample_output_relpath": "derived/input_output/data/p03298/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03298/Lua/s572313037.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s572313037", "user_id": "u045238009"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "local n=io.read(\"n\",\"l\")\nlocal s=io.read()\n\nlocal precheck=true\nlocal t={s:byte(1,2*n)}\ntable.sort(t)\nfor i=1,2*n-1,2 do\n if t[i]~=t[i+1] then\n precheck=false\n end\nend\nif not precheck then\n print(0)\n return\nend\n\nlocal rmap={}\nlocal bmap={}\nlocal bit=require(\"bit\")\nlocal lshift=bit.lshift\nlocal band=bit.band\nfor bit=0,lshift(1,n)-1 do\n local r1=\"\"\n local r2=\"\"\n local b1=\"\"\n local b2=\"\"\n for i=0,n-1 do\n if band(bit,lshift(1,i))>0 then\n local r=i+1\n local b=i+1+n\n r1=r1..s:sub(r,r)\n b2=s:sub(b,b)..b2\n else\n local r=i+1\n local b=i+1+n\n b1=s:sub(b,b)..b1\n r2=r2..s:sub(r,r)\n end\n end\n local rkey=r1..\" \"..r2\n local bkey=b1..\" \"..b2\n rmap[rkey]=(rmap[rkey] or 0)+1\n bmap[bkey]=(bmap[bkey] or 0)+1\nend\n\nlocal combination=0\nfor k,_ in pairs(rmap) do\n combination=combination+rmap[k]*(bmap[k] or 0)\nend\nprint(combination)", "problem_context": "Score : 600 points\n\nProblem Statement\n\nYou are given a string S of length 2N consisting of lowercase English letters.\n\nThere are 2^{2N} ways to color each character in S red or blue. Among these ways, how many satisfy the following condition?\n\nThe 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.\n\nConstraints\n\n1 \\leq N \\leq 18\n\nThe length of S is 2N.\n\nS consists of lowercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS\n\nOutput\n\nPrint the number of ways to paint the string that satisfy the condition.\n\nSample Input 1\n\n4\ncabaacba\n\nSample Output 1\n\n4\n\nThere are four ways to paint the string, as follows:\n\ncabaacba\n\ncabaacba\n\ncabaacba\n\ncabaacba\n\nSample Input 2\n\n11\nmippiisssisssiipsspiim\n\nSample Output 2\n\n504\n\nSample Input 3\n\n4\nabcdefgh\n\nSample Output 3\n\n0\n\nSample Input 4\n\n18\naaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n\nSample Output 4\n\n9075135300\n\nThe answer may not be representable as a 32-bit integer.", "sample_input": "4\ncabaacba\n"}, "reference_outputs": ["4\n"], "source_document_id": "p03298", "source_text": "Score : 600 points\n\nProblem Statement\n\nYou are given a string S of length 2N consisting of lowercase English letters.\n\nThere are 2^{2N} ways to color each character in S red or blue. Among these ways, how many satisfy the following condition?\n\nThe 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.\n\nConstraints\n\n1 \\leq N \\leq 18\n\nThe length of S is 2N.\n\nS consists of lowercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS\n\nOutput\n\nPrint the number of ways to paint the string that satisfy the condition.\n\nSample Input 1\n\n4\ncabaacba\n\nSample Output 1\n\n4\n\nThere are four ways to paint the string, as follows:\n\ncabaacba\n\ncabaacba\n\ncabaacba\n\ncabaacba\n\nSample Input 2\n\n11\nmippiisssisssiipsspiim\n\nSample Output 2\n\n504\n\nSample Input 3\n\n4\nabcdefgh\n\nSample Output 3\n\n0\n\nSample Input 4\n\n18\naaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n\nSample Output 4\n\n9075135300\n\nThe answer may not be representable as a 32-bit integer.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 979, "cpu_time_ms": 1249, "memory_kb": 57560}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s746217169", "group_id": "codeNet:p03303", "input_text": "s,w=io.read(),io.read(\"*n\")\nfor i=1,#s,w do\n\tio.write(s:sub(i,i))\nend", "language": "Lua", "metadata": {"date": 1531053710, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p03303.html", "problem_id": "p03303", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03303/input.txt", "sample_output_relpath": "derived/input_output/data/p03303/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03303/Lua/s746217169.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s746217169", "user_id": "u781091740"}, "prompt_components": {"gold_output": "adg\n", "input_to_evaluate": "s,w=io.read(),io.read(\"*n\")\nfor i=1,#s,w do\n\tio.write(s:sub(i,i))\nend", "problem_context": "Score : 200 points\n\nProblem Statement\n\nYou are given a string S consisting of lowercase English letters.\nWe will write down this string, starting a new line after every w letters. Print the string obtained by concatenating the letters at the beginnings of these lines from top to bottom.\n\nConstraints\n\n1 \\leq w \\leq |S| \\leq 1000\n\nS consists of lowercase English letters.\n\nw is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\nw\n\nOutput\n\nPrint the desired string in one line.\n\nSample Input 1\n\nabcdefgh\n3\n\nSample Output 1\n\nadg\n\nWhen we write down abcdefgh, starting a new line after every three letters, we get the following:\n\nabc\n\ndef\n\ngh\n\nConcatenating the letters at the beginnings of these lines, we obtain adg.\n\nSample Input 2\n\nlllll\n1\n\nSample Output 2\n\nlllll\n\nSample Input 3\n\nsouuundhound\n2\n\nSample Output 3\n\nsuudon", "sample_input": "abcdefgh\n3\n"}, "reference_outputs": ["adg\n"], "source_document_id": "p03303", "source_text": "Score : 200 points\n\nProblem Statement\n\nYou are given a string S consisting of lowercase English letters.\nWe will write down this string, starting a new line after every w letters. Print the string obtained by concatenating the letters at the beginnings of these lines from top to bottom.\n\nConstraints\n\n1 \\leq w \\leq |S| \\leq 1000\n\nS consists of lowercase English letters.\n\nw is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\nw\n\nOutput\n\nPrint the desired string in one line.\n\nSample Input 1\n\nabcdefgh\n3\n\nSample Output 1\n\nadg\n\nWhen we write down abcdefgh, starting a new line after every three letters, we get the following:\n\nabc\n\ndef\n\ngh\n\nConcatenating the letters at the beginnings of these lines, we obtain adg.\n\nSample Input 2\n\nlllll\n1\n\nSample Output 2\n\nlllll\n\nSample Input 3\n\nsouuundhound\n2\n\nSample Output 3\n\nsuudon", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 69, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s283771152", "group_id": "codeNet:p03306", "input_text": "local mmi, mma = math.min, math.max\nlocal n, m = io.read(\"*n\", \"*n\")\nlocal edge = {}\nlocal v = {}\nlocal len = {}\nfor i = 1, n do\n edge[i] = {}\n v[i] = false\n len[i] = false\nend\nv[1] = 0\nlen[1] = 0\nlocal evmin = 0\nlocal oddmin = false\nfor i = 1, m do\n local a, b, c = io.read(\"*n\", \"*n\", \"*n\")\n edge[a][b] = c\n edge[b][a] = c\n if a == 1 or b == 1 then\n oddmin = c\n end\nend\nlocal rem_edge = {}\nlocal tasks = {1}\nfor i = 1, n do\n local src = tasks[i]\n for dst, sum in pairs(edge[src]) do\n if not v[dst] then\n edge[dst][src] = nil\n v[dst] = sum - v[src]\n len[dst] = 1 - len[src]\n if len[dst] == 1 then\n oddmin = mmi(oddmin, v[dst])\n else\n evmin = mmi(evmin, v[dst])\n end\n table.insert(tasks, dst)\n else\n table.insert(rem_edge, {src, dst, sum})\n edge[dst][src] = nil\n end\n end\nend\nif #rem_edge == 0 then\n local diff = evmin - 1\n oddmin = oddmin + diff\n print(mma(0, oddmin))\nelse\n local valid = true\n local offset = false\n for i = 1, #rem_edge do\n local p1, p2, sum = rem_edge[i][1], rem_edge[i][2], rem_edge[i][3]\n if len[p1] + len[p2] == 1 then\n if v[p1] + v[p2] ~= sum then\n valid = false break\n end\n else\n if len[p1] + len[p2] == 0 then\n if not offset then\n offset = sum - v[p1] - v[p2]\n if offset % 2 == 1 then valid = false break end\n offset = math.floor(offset / 2)\n else\n if v[p1] + v[p2] + offset * 2 ~= sum then\n valid = false break\n end\n end\n else\n if not offset then\n offset = v[p1] + v[p2] - sum\n if offset % 2 == 1 then valid = false break end\n offset = math.floor(offset / 2)\n else\n if v[p1] + v[p2] - offset * 2 ~= sum then\n valid = false break\n end\n end\n end\n end\n if offset then\n if evmin + offset < 1 then valid = false end\n if oddmin - offset < 1 then valid = false end\n end\n end\n print(valid and 1 or 0)\nend\n", "language": "Lua", "metadata": {"date": 1583019529, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p03306.html", "problem_id": "p03306", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03306/input.txt", "sample_output_relpath": "derived/input_output/data/p03306/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03306/Lua/s283771152.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s283771152", "user_id": "u120582723"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "local mmi, mma = math.min, math.max\nlocal n, m = io.read(\"*n\", \"*n\")\nlocal edge = {}\nlocal v = {}\nlocal len = {}\nfor i = 1, n do\n edge[i] = {}\n v[i] = false\n len[i] = false\nend\nv[1] = 0\nlen[1] = 0\nlocal evmin = 0\nlocal oddmin = false\nfor i = 1, m do\n local a, b, c = io.read(\"*n\", \"*n\", \"*n\")\n edge[a][b] = c\n edge[b][a] = c\n if a == 1 or b == 1 then\n oddmin = c\n end\nend\nlocal rem_edge = {}\nlocal tasks = {1}\nfor i = 1, n do\n local src = tasks[i]\n for dst, sum in pairs(edge[src]) do\n if not v[dst] then\n edge[dst][src] = nil\n v[dst] = sum - v[src]\n len[dst] = 1 - len[src]\n if len[dst] == 1 then\n oddmin = mmi(oddmin, v[dst])\n else\n evmin = mmi(evmin, v[dst])\n end\n table.insert(tasks, dst)\n else\n table.insert(rem_edge, {src, dst, sum})\n edge[dst][src] = nil\n end\n end\nend\nif #rem_edge == 0 then\n local diff = evmin - 1\n oddmin = oddmin + diff\n print(mma(0, oddmin))\nelse\n local valid = true\n local offset = false\n for i = 1, #rem_edge do\n local p1, p2, sum = rem_edge[i][1], rem_edge[i][2], rem_edge[i][3]\n if len[p1] + len[p2] == 1 then\n if v[p1] + v[p2] ~= sum then\n valid = false break\n end\n else\n if len[p1] + len[p2] == 0 then\n if not offset then\n offset = sum - v[p1] - v[p2]\n if offset % 2 == 1 then valid = false break end\n offset = math.floor(offset / 2)\n else\n if v[p1] + v[p2] + offset * 2 ~= sum then\n valid = false break\n end\n end\n else\n if not offset then\n offset = v[p1] + v[p2] - sum\n if offset % 2 == 1 then valid = false break end\n offset = math.floor(offset / 2)\n else\n if v[p1] + v[p2] - offset * 2 ~= sum then\n valid = false break\n end\n end\n end\n end\n if offset then\n if evmin + offset < 1 then valid = false end\n if oddmin - offset < 1 then valid = false end\n end\n end\n print(valid and 1 or 0)\nend\n", "problem_context": "Score : 600 points\n\nProblem Statement\n\nKenkoooo found a simple connected graph.\nThe vertices are numbered 1 through n.\nThe i-th edge connects Vertex u_i and v_i, and has a fixed integer s_i.\n\nKenkoooo is trying to write a positive integer in each vertex so that the following condition is satisfied:\n\nFor every edge i, the sum of the positive integers written in Vertex u_i and v_i is equal to s_i.\n\nFind the number of such ways to write positive integers in the vertices.\n\nConstraints\n\n2 \\leq n \\leq 10^5\n\n1 \\leq m \\leq 10^5\n\n1 \\leq u_i < v_i \\leq n\n\n2 \\leq s_i \\leq 10^9\n\nIf i\\neq j, then u_i \\neq u_j or v_i \\neq v_j.\n\nThe graph is connected.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nn m\nu_1 v_1 s_1\n:\nu_m v_m s_m\n\nOutput\n\nPrint the number of ways to write positive integers in the vertices so that the condition is satisfied.\n\nSample Input 1\n\n3 3\n1 2 3\n2 3 5\n1 3 4\n\nSample Output 1\n\n1\n\nThe condition will be satisfied if we write 1,2 and 3 in vertices 1,2 and 3, respectively.\nThere is no other way to satisfy the condition, so the answer is 1.\n\nSample Input 2\n\n4 3\n1 2 6\n2 3 7\n3 4 5\n\nSample Output 2\n\n3\n\nLet a,b,c and d be the numbers to write in vertices 1,2,3 and 4, respectively.\nThere are three quadruples (a,b,c,d) that satisfy the condition:\n\n(a,b,c,d)=(1,5,2,3)\n\n(a,b,c,d)=(2,4,3,2)\n\n(a,b,c,d)=(3,3,4,1)\n\nSample Input 3\n\n8 7\n1 2 1000000000\n2 3 2\n3 4 1000000000\n4 5 2\n5 6 1000000000\n6 7 2\n7 8 1000000000\n\nSample Output 3\n\n0", "sample_input": "3 3\n1 2 3\n2 3 5\n1 3 4\n"}, "reference_outputs": ["1\n"], "source_document_id": "p03306", "source_text": "Score : 600 points\n\nProblem Statement\n\nKenkoooo found a simple connected graph.\nThe vertices are numbered 1 through n.\nThe i-th edge connects Vertex u_i and v_i, and has a fixed integer s_i.\n\nKenkoooo is trying to write a positive integer in each vertex so that the following condition is satisfied:\n\nFor every edge i, the sum of the positive integers written in Vertex u_i and v_i is equal to s_i.\n\nFind the number of such ways to write positive integers in the vertices.\n\nConstraints\n\n2 \\leq n \\leq 10^5\n\n1 \\leq m \\leq 10^5\n\n1 \\leq u_i < v_i \\leq n\n\n2 \\leq s_i \\leq 10^9\n\nIf i\\neq j, then u_i \\neq u_j or v_i \\neq v_j.\n\nThe graph is connected.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nn m\nu_1 v_1 s_1\n:\nu_m v_m s_m\n\nOutput\n\nPrint the number of ways to write positive integers in the vertices so that the condition is satisfied.\n\nSample Input 1\n\n3 3\n1 2 3\n2 3 5\n1 3 4\n\nSample Output 1\n\n1\n\nThe condition will be satisfied if we write 1,2 and 3 in vertices 1,2 and 3, respectively.\nThere is no other way to satisfy the condition, so the answer is 1.\n\nSample Input 2\n\n4 3\n1 2 6\n2 3 7\n3 4 5\n\nSample Output 2\n\n3\n\nLet a,b,c and d be the numbers to write in vertices 1,2,3 and 4, respectively.\nThere are three quadruples (a,b,c,d) that satisfy the condition:\n\n(a,b,c,d)=(1,5,2,3)\n\n(a,b,c,d)=(2,4,3,2)\n\n(a,b,c,d)=(3,3,4,1)\n\nSample Input 3\n\n8 7\n1 2 1000000000\n2 3 2\n3 4 1000000000\n4 5 2\n5 6 1000000000\n6 7 2\n7 8 1000000000\n\nSample Output 3\n\n0", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2028, "cpu_time_ms": 153, "memory_kb": 17140}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s104490775", "group_id": "codeNet:p03306", "input_text": "local mmi, mma = math.min, math.max\nlocal n, m = io.read(\"*n\", \"*n\")\nlocal edge = {}\nlocal v = {}\nlocal len = {}\nfor i = 1, n do\n edge[i] = {}\n v[i] = false\n len[i] = false\nend\nv[1] = 0\nlen[1] = 0\nlocal evmin = 0\nlocal oddmin = false\nfor i = 1, m do\n local a, b, c = io.read(\"*n\", \"*n\", \"*n\")\n edge[a][b] = c\n edge[b][a] = c\n if a == 1 or b == 1 then\n oddmin = c\n end\nend\nlocal rem_edge = {}\nlocal tasks = {1}\nfor i = 1, n do\n local src = tasks[i]\n for dst, sum in pairs(edge[src]) do\n if not v[dst] then\n edge[dst][src] = nil\n v[dst] = sum - v[src]\n len[dst] = 1 - len[src]\n if len[dst] == 1 then\n oddmin = mmi(oddmin, v[dst])\n else\n evmin = mmi(evmin, v[dst])\n end\n table.insert(tasks, dst)\n else\n table.insert(rem_edge, {src, dst, sum})\n end\n end\nend\nif #rem_edge == 0 then\n local diff = evmin - 1\n oddmin = oddmin + diff\n print(math.max(0, oddmin))\nelse\n local valid = true\n local offset = false\n for i = 1, #rem_edge do\n local p1, p2, sum = rem_edge[i][1], rem_edge[i][2], rem_edge[i][3]\n if len[p1] + len[p2] == 1 then\n if v[p1] + v[p2] ~= sum then\n valid = false break\n end\n else\n if len[p1] + len[p2] == 0 then\n if not offset then\n offset = sum - v[p1] - v[p2]\n if offset % 2 == 1 then valid = false break end\n else\n if v[p1] + v[p2] + offset * 2 ~= sum then\n valid = false break\n end\n end\n else\n if not offset then\n offset = v[p1] + v[p2] - sum\n if offset % 2 == 1 then valid = false break end\n else\n if v[p1] + v[p2] - offset * 2 ~= sum then\n valid = false break\n end\n end\n end\n end\n if offset then\n if evmin + offset < 1 then valid = false end\n if oddmin - offset < 1 then valid = false end\n end\n print(valid and 1 or 0)\n end\nend\n", "language": "Lua", "metadata": {"date": 1583017706, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p03306.html", "problem_id": "p03306", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03306/input.txt", "sample_output_relpath": "derived/input_output/data/p03306/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03306/Lua/s104490775.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s104490775", "user_id": "u120582723"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "local mmi, mma = math.min, math.max\nlocal n, m = io.read(\"*n\", \"*n\")\nlocal edge = {}\nlocal v = {}\nlocal len = {}\nfor i = 1, n do\n edge[i] = {}\n v[i] = false\n len[i] = false\nend\nv[1] = 0\nlen[1] = 0\nlocal evmin = 0\nlocal oddmin = false\nfor i = 1, m do\n local a, b, c = io.read(\"*n\", \"*n\", \"*n\")\n edge[a][b] = c\n edge[b][a] = c\n if a == 1 or b == 1 then\n oddmin = c\n end\nend\nlocal rem_edge = {}\nlocal tasks = {1}\nfor i = 1, n do\n local src = tasks[i]\n for dst, sum in pairs(edge[src]) do\n if not v[dst] then\n edge[dst][src] = nil\n v[dst] = sum - v[src]\n len[dst] = 1 - len[src]\n if len[dst] == 1 then\n oddmin = mmi(oddmin, v[dst])\n else\n evmin = mmi(evmin, v[dst])\n end\n table.insert(tasks, dst)\n else\n table.insert(rem_edge, {src, dst, sum})\n end\n end\nend\nif #rem_edge == 0 then\n local diff = evmin - 1\n oddmin = oddmin + diff\n print(math.max(0, oddmin))\nelse\n local valid = true\n local offset = false\n for i = 1, #rem_edge do\n local p1, p2, sum = rem_edge[i][1], rem_edge[i][2], rem_edge[i][3]\n if len[p1] + len[p2] == 1 then\n if v[p1] + v[p2] ~= sum then\n valid = false break\n end\n else\n if len[p1] + len[p2] == 0 then\n if not offset then\n offset = sum - v[p1] - v[p2]\n if offset % 2 == 1 then valid = false break end\n else\n if v[p1] + v[p2] + offset * 2 ~= sum then\n valid = false break\n end\n end\n else\n if not offset then\n offset = v[p1] + v[p2] - sum\n if offset % 2 == 1 then valid = false break end\n else\n if v[p1] + v[p2] - offset * 2 ~= sum then\n valid = false break\n end\n end\n end\n end\n if offset then\n if evmin + offset < 1 then valid = false end\n if oddmin - offset < 1 then valid = false end\n end\n print(valid and 1 or 0)\n end\nend\n", "problem_context": "Score : 600 points\n\nProblem Statement\n\nKenkoooo found a simple connected graph.\nThe vertices are numbered 1 through n.\nThe i-th edge connects Vertex u_i and v_i, and has a fixed integer s_i.\n\nKenkoooo is trying to write a positive integer in each vertex so that the following condition is satisfied:\n\nFor every edge i, the sum of the positive integers written in Vertex u_i and v_i is equal to s_i.\n\nFind the number of such ways to write positive integers in the vertices.\n\nConstraints\n\n2 \\leq n \\leq 10^5\n\n1 \\leq m \\leq 10^5\n\n1 \\leq u_i < v_i \\leq n\n\n2 \\leq s_i \\leq 10^9\n\nIf i\\neq j, then u_i \\neq u_j or v_i \\neq v_j.\n\nThe graph is connected.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nn m\nu_1 v_1 s_1\n:\nu_m v_m s_m\n\nOutput\n\nPrint the number of ways to write positive integers in the vertices so that the condition is satisfied.\n\nSample Input 1\n\n3 3\n1 2 3\n2 3 5\n1 3 4\n\nSample Output 1\n\n1\n\nThe condition will be satisfied if we write 1,2 and 3 in vertices 1,2 and 3, respectively.\nThere is no other way to satisfy the condition, so the answer is 1.\n\nSample Input 2\n\n4 3\n1 2 6\n2 3 7\n3 4 5\n\nSample Output 2\n\n3\n\nLet a,b,c and d be the numbers to write in vertices 1,2,3 and 4, respectively.\nThere are three quadruples (a,b,c,d) that satisfy the condition:\n\n(a,b,c,d)=(1,5,2,3)\n\n(a,b,c,d)=(2,4,3,2)\n\n(a,b,c,d)=(3,3,4,1)\n\nSample Input 3\n\n8 7\n1 2 1000000000\n2 3 2\n3 4 1000000000\n4 5 2\n5 6 1000000000\n6 7 2\n7 8 1000000000\n\nSample Output 3\n\n0", "sample_input": "3 3\n1 2 3\n2 3 5\n1 3 4\n"}, "reference_outputs": ["1\n"], "source_document_id": "p03306", "source_text": "Score : 600 points\n\nProblem Statement\n\nKenkoooo found a simple connected graph.\nThe vertices are numbered 1 through n.\nThe i-th edge connects Vertex u_i and v_i, and has a fixed integer s_i.\n\nKenkoooo is trying to write a positive integer in each vertex so that the following condition is satisfied:\n\nFor every edge i, the sum of the positive integers written in Vertex u_i and v_i is equal to s_i.\n\nFind the number of such ways to write positive integers in the vertices.\n\nConstraints\n\n2 \\leq n \\leq 10^5\n\n1 \\leq m \\leq 10^5\n\n1 \\leq u_i < v_i \\leq n\n\n2 \\leq s_i \\leq 10^9\n\nIf i\\neq j, then u_i \\neq u_j or v_i \\neq v_j.\n\nThe graph is connected.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nn m\nu_1 v_1 s_1\n:\nu_m v_m s_m\n\nOutput\n\nPrint the number of ways to write positive integers in the vertices so that the condition is satisfied.\n\nSample Input 1\n\n3 3\n1 2 3\n2 3 5\n1 3 4\n\nSample Output 1\n\n1\n\nThe condition will be satisfied if we write 1,2 and 3 in vertices 1,2 and 3, respectively.\nThere is no other way to satisfy the condition, so the answer is 1.\n\nSample Input 2\n\n4 3\n1 2 6\n2 3 7\n3 4 5\n\nSample Output 2\n\n3\n\nLet a,b,c and d be the numbers to write in vertices 1,2,3 and 4, respectively.\nThere are three quadruples (a,b,c,d) that satisfy the condition:\n\n(a,b,c,d)=(1,5,2,3)\n\n(a,b,c,d)=(2,4,3,2)\n\n(a,b,c,d)=(3,3,4,1)\n\nSample Input 3\n\n8 7\n1 2 1000000000\n2 3 2\n3 4 1000000000\n4 5 2\n5 6 1000000000\n6 7 2\n7 8 1000000000\n\nSample Output 3\n\n0", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1924, "cpu_time_ms": 177, "memory_kb": 22648}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s500850761", "group_id": "codeNet:p03307", "input_text": "local N = tonumber(io.read())\nlocal result = N % 2 == 0 and N or N * 2\nio.write(result .. '\\n')", "language": "Lua", "metadata": {"date": 1531324686, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03307.html", "problem_id": "p03307", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03307/input.txt", "sample_output_relpath": "derived/input_output/data/p03307/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03307/Lua/s500850761.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s500850761", "user_id": "u629781446"}, "prompt_components": {"gold_output": "6\n", "input_to_evaluate": "local N = tonumber(io.read())\nlocal result = N % 2 == 0 and N or N * 2\nio.write(result .. '\\n')", "problem_context": "Score : 100 points\n\nProblem Statement\n\nYou are given a positive integer N.\nFind the minimum positive integer divisible by both 2 and N.\n\nConstraints\n\n1 \\leq N \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the minimum positive integer divisible by both 2 and N.\n\nSample Input 1\n\n3\n\nSample Output 1\n\n6\n\n6 is divisible by both 2 and 3.\nAlso, there is no positive integer less than 6 that is divisible by both 2 and 3.\nThus, the answer is 6.\n\nSample Input 2\n\n10\n\nSample Output 2\n\n10\n\nSample Input 3\n\n999999999\n\nSample Output 3\n\n1999999998", "sample_input": "3\n"}, "reference_outputs": ["6\n"], "source_document_id": "p03307", "source_text": "Score : 100 points\n\nProblem Statement\n\nYou are given a positive integer N.\nFind the minimum positive integer divisible by both 2 and N.\n\nConstraints\n\n1 \\leq N \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the minimum positive integer divisible by both 2 and N.\n\nSample Input 1\n\n3\n\nSample Output 1\n\n6\n\n6 is divisible by both 2 and 3.\nAlso, there is no positive integer less than 6 that is divisible by both 2 and 3.\nThus, the answer is 6.\n\nSample Input 2\n\n10\n\nSample Output 2\n\n10\n\nSample Input 3\n\n999999999\n\nSample Output 3\n\n1999999998", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 95, "cpu_time_ms": 8, "memory_kb": 888}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s581239388", "group_id": "codeNet:p03308", "input_text": "local N = io.read(\"*n\")\nlocal A = {}\nfor i = 1, N do\n A[i] = io.read(\"*n\")\nend\n\nlocal biggest, smallest = 0, 1000000000\nfor i = 1, N do\n if biggest < A[i] then\n biggest = A[i]\n end\n if smallest > A[i] then\n smallest = A[i]\n end\nend\nprint(biggest - smallest)", "language": "Lua", "metadata": {"date": 1586789213, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p03308.html", "problem_id": "p03308", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03308/input.txt", "sample_output_relpath": "derived/input_output/data/p03308/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03308/Lua/s581239388.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s581239388", "user_id": "u793881115"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "local N = io.read(\"*n\")\nlocal A = {}\nfor i = 1, N do\n A[i] = io.read(\"*n\")\nend\n\nlocal biggest, smallest = 0, 1000000000\nfor i = 1, N do\n if biggest < A[i] then\n biggest = A[i]\n end\n if smallest > A[i] then\n smallest = A[i]\n end\nend\nprint(biggest - smallest)", "problem_context": "Score : 200 points\n\nProblem Statement\n\nYou are given an integer sequence A of length N.\nFind the maximum absolute difference of two elements (with different indices) in A.\n\nConstraints\n\n2 \\leq N \\leq 100\n\n1 \\leq A_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the maximum absolute difference of two elements (with different indices) in A.\n\nSample Input 1\n\n4\n1 4 6 3\n\nSample Output 1\n\n5\n\nThe maximum absolute difference of two elements is A_3-A_1=6-1=5.\n\nSample Input 2\n\n2\n1000000000 1\n\nSample Output 2\n\n999999999\n\nSample Input 3\n\n5\n1 1 1 1 1\n\nSample Output 3\n\n0", "sample_input": "4\n1 4 6 3\n"}, "reference_outputs": ["5\n"], "source_document_id": "p03308", "source_text": "Score : 200 points\n\nProblem Statement\n\nYou are given an integer sequence A of length N.\nFind the maximum absolute difference of two elements (with different indices) in A.\n\nConstraints\n\n2 \\leq N \\leq 100\n\n1 \\leq A_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the maximum absolute difference of two elements (with different indices) in A.\n\nSample Input 1\n\n4\n1 4 6 3\n\nSample Output 1\n\n5\n\nThe maximum absolute difference of two elements is A_3-A_1=6-1=5.\n\nSample Input 2\n\n2\n1000000000 1\n\nSample Output 2\n\n999999999\n\nSample Input 3\n\n5\n1 1 1 1 1\n\nSample Output 3\n\n0", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 286, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s722066926", "group_id": "codeNet:p03308", "input_text": "local N = tonumber(io.read())\nlocal A = {}\nfor n in io.read():gmatch('%d+') do\n table.insert(A, tonumber(n))\nend\nlocal result = math.max(unpack(A)) - math.min(unpack(A))\nio.write(result .. '\\n')\n", "language": "Lua", "metadata": {"date": 1531328377, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03308.html", "problem_id": "p03308", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03308/input.txt", "sample_output_relpath": "derived/input_output/data/p03308/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03308/Lua/s722066926.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s722066926", "user_id": "u629781446"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "local N = tonumber(io.read())\nlocal A = {}\nfor n in io.read():gmatch('%d+') do\n table.insert(A, tonumber(n))\nend\nlocal result = math.max(unpack(A)) - math.min(unpack(A))\nio.write(result .. '\\n')\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nYou are given an integer sequence A of length N.\nFind the maximum absolute difference of two elements (with different indices) in A.\n\nConstraints\n\n2 \\leq N \\leq 100\n\n1 \\leq A_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the maximum absolute difference of two elements (with different indices) in A.\n\nSample Input 1\n\n4\n1 4 6 3\n\nSample Output 1\n\n5\n\nThe maximum absolute difference of two elements is A_3-A_1=6-1=5.\n\nSample Input 2\n\n2\n1000000000 1\n\nSample Output 2\n\n999999999\n\nSample Input 3\n\n5\n1 1 1 1 1\n\nSample Output 3\n\n0", "sample_input": "4\n1 4 6 3\n"}, "reference_outputs": ["5\n"], "source_document_id": "p03308", "source_text": "Score : 200 points\n\nProblem Statement\n\nYou are given an integer sequence A of length N.\nFind the maximum absolute difference of two elements (with different indices) in A.\n\nConstraints\n\n2 \\leq N \\leq 100\n\n1 \\leq A_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the maximum absolute difference of two elements (with different indices) in A.\n\nSample Input 1\n\n4\n1 4 6 3\n\nSample Output 1\n\n5\n\nThe maximum absolute difference of two elements is A_3-A_1=6-1=5.\n\nSample Input 2\n\n2\n1000000000 1\n\nSample Output 2\n\n999999999\n\nSample Input 3\n\n5\n1 1 1 1 1\n\nSample Output 3\n\n0", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 196, "cpu_time_ms": 7, "memory_kb": 888}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s787433776", "group_id": "codeNet:p03309", "input_text": "local n = io.read(\"*n\")\nlocal a = {}\nfor i = 1, n do\n a[i] = io.read(\"*n\") - i\nend\nif n == 1 then\n print(0)\nelse\n table.sort(a)\n local hn = n // 2\n local pos = a[hn]\n local ret = 0\n for i = 1, hn do\n ret = ret + pos - a[i]\n end\n for i = hn + 1, n do\n ret = ret + a[i] - pos\n end\n print(ret)\nend\n", "language": "Lua", "metadata": {"date": 1584970741, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03309.html", "problem_id": "p03309", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03309/input.txt", "sample_output_relpath": "derived/input_output/data/p03309/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03309/Lua/s787433776.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s787433776", "user_id": "u120582723"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "local n = io.read(\"*n\")\nlocal a = {}\nfor i = 1, n do\n a[i] = io.read(\"*n\") - i\nend\nif n == 1 then\n print(0)\nelse\n table.sort(a)\n local hn = n // 2\n local pos = a[hn]\n local ret = 0\n for i = 1, hn do\n ret = ret + pos - a[i]\n end\n for i = hn + 1, n do\n ret = ret + a[i] - pos\n end\n print(ret)\nend\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nSnuke has an integer sequence A of length N.\n\nHe will freely choose an integer b.\nHere, he will get sad if A_i and b+i are far from each other.\nMore specifically, the sadness of Snuke is calculated as follows:\n\nabs(A_1 - (b+1)) + abs(A_2 - (b+2)) + ... + abs(A_N - (b+N))\n\nHere, abs(x) is a function that returns the absolute value of x.\n\nFind the minimum possible sadness of Snuke.\n\nConstraints\n\n1 \\leq N \\leq 2 \\times 10^5\n\n1 \\leq A_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the minimum possible sadness of Snuke.\n\nSample Input 1\n\n5\n2 2 3 5 5\n\nSample Output 1\n\n2\n\nIf we choose b=0, the sadness of Snuke would be abs(2-(0+1))+abs(2-(0+2))+abs(3-(0+3))+abs(5-(0+4))+abs(5-(0+5))=2.\nAny choice of b does not make the sadness of Snuke less than 2, so the answer is 2.\n\nSample Input 2\n\n9\n1 2 3 4 5 6 7 8 9\n\nSample Output 2\n\n0\n\nSample Input 3\n\n6\n6 5 4 3 2 1\n\nSample Output 3\n\n18\n\nSample Input 4\n\n7\n1 1 1 1 2 3 4\n\nSample Output 4\n\n6", "sample_input": "5\n2 2 3 5 5\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03309", "source_text": "Score : 300 points\n\nProblem Statement\n\nSnuke has an integer sequence A of length N.\n\nHe will freely choose an integer b.\nHere, he will get sad if A_i and b+i are far from each other.\nMore specifically, the sadness of Snuke is calculated as follows:\n\nabs(A_1 - (b+1)) + abs(A_2 - (b+2)) + ... + abs(A_N - (b+N))\n\nHere, abs(x) is a function that returns the absolute value of x.\n\nFind the minimum possible sadness of Snuke.\n\nConstraints\n\n1 \\leq N \\leq 2 \\times 10^5\n\n1 \\leq A_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the minimum possible sadness of Snuke.\n\nSample Input 1\n\n5\n2 2 3 5 5\n\nSample Output 1\n\n2\n\nIf we choose b=0, the sadness of Snuke would be abs(2-(0+1))+abs(2-(0+2))+abs(3-(0+3))+abs(5-(0+4))+abs(5-(0+5))=2.\nAny choice of b does not make the sadness of Snuke less than 2, so the answer is 2.\n\nSample Input 2\n\n9\n1 2 3 4 5 6 7 8 9\n\nSample Output 2\n\n0\n\nSample Input 3\n\n6\n6 5 4 3 2 1\n\nSample Output 3\n\n18\n\nSample Input 4\n\n7\n1 1 1 1 2 3 4\n\nSample Output 4\n\n6", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 312, "cpu_time_ms": 212, "memory_kb": 4472}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s168091814", "group_id": "codeNet:p03309", "input_text": "N=io.read(\"n\")\nt={}\nfor i=1,N do\n t[i]=io.read(\"n\")-i\nend\ntable.sort(t)\ns=(t[#t]-t[1])//2\nres=0\nfor i=1,N do\n res=res+math.abs(t[i]-s)\nend\nser=0\nk=(t[#t]-t[1])//2+1\nfor i=1,N do\n ser=ser+math.abs(t[i]-k)\nend\nprint(math.min(res,ser))", "language": "Lua", "metadata": {"date": 1550537865, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03309.html", "problem_id": "p03309", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03309/input.txt", "sample_output_relpath": "derived/input_output/data/p03309/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03309/Lua/s168091814.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s168091814", "user_id": "u015229643"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "N=io.read(\"n\")\nt={}\nfor i=1,N do\n t[i]=io.read(\"n\")-i\nend\ntable.sort(t)\ns=(t[#t]-t[1])//2\nres=0\nfor i=1,N do\n res=res+math.abs(t[i]-s)\nend\nser=0\nk=(t[#t]-t[1])//2+1\nfor i=1,N do\n ser=ser+math.abs(t[i]-k)\nend\nprint(math.min(res,ser))", "problem_context": "Score : 300 points\n\nProblem Statement\n\nSnuke has an integer sequence A of length N.\n\nHe will freely choose an integer b.\nHere, he will get sad if A_i and b+i are far from each other.\nMore specifically, the sadness of Snuke is calculated as follows:\n\nabs(A_1 - (b+1)) + abs(A_2 - (b+2)) + ... + abs(A_N - (b+N))\n\nHere, abs(x) is a function that returns the absolute value of x.\n\nFind the minimum possible sadness of Snuke.\n\nConstraints\n\n1 \\leq N \\leq 2 \\times 10^5\n\n1 \\leq A_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the minimum possible sadness of Snuke.\n\nSample Input 1\n\n5\n2 2 3 5 5\n\nSample Output 1\n\n2\n\nIf we choose b=0, the sadness of Snuke would be abs(2-(0+1))+abs(2-(0+2))+abs(3-(0+3))+abs(5-(0+4))+abs(5-(0+5))=2.\nAny choice of b does not make the sadness of Snuke less than 2, so the answer is 2.\n\nSample Input 2\n\n9\n1 2 3 4 5 6 7 8 9\n\nSample Output 2\n\n0\n\nSample Input 3\n\n6\n6 5 4 3 2 1\n\nSample Output 3\n\n18\n\nSample Input 4\n\n7\n1 1 1 1 2 3 4\n\nSample Output 4\n\n6", "sample_input": "5\n2 2 3 5 5\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03309", "source_text": "Score : 300 points\n\nProblem Statement\n\nSnuke has an integer sequence A of length N.\n\nHe will freely choose an integer b.\nHere, he will get sad if A_i and b+i are far from each other.\nMore specifically, the sadness of Snuke is calculated as follows:\n\nabs(A_1 - (b+1)) + abs(A_2 - (b+2)) + ... + abs(A_N - (b+N))\n\nHere, abs(x) is a function that returns the absolute value of x.\n\nFind the minimum possible sadness of Snuke.\n\nConstraints\n\n1 \\leq N \\leq 2 \\times 10^5\n\n1 \\leq A_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the minimum possible sadness of Snuke.\n\nSample Input 1\n\n5\n2 2 3 5 5\n\nSample Output 1\n\n2\n\nIf we choose b=0, the sadness of Snuke would be abs(2-(0+1))+abs(2-(0+2))+abs(3-(0+3))+abs(5-(0+4))+abs(5-(0+5))=2.\nAny choice of b does not make the sadness of Snuke less than 2, so the answer is 2.\n\nSample Input 2\n\n9\n1 2 3 4 5 6 7 8 9\n\nSample Output 2\n\n0\n\nSample Input 3\n\n6\n6 5 4 3 2 1\n\nSample Output 3\n\n18\n\nSample Input 4\n\n7\n1 1 1 1 2 3 4\n\nSample Output 4\n\n6", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 235, "cpu_time_ms": 263, "memory_kb": 4472}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s080279458", "group_id": "codeNet:p03310", "input_text": "local mfl, mma, mmi = math.floor, math.max, math.min\nlocal function lower_bound(ary, x, min, max)\n if(x <= ary[min]) then return min end\n if(ary[max] < x) then return max + 1 end\n while(1 < max - min) do\n local mid = mfl((min + max) / 2)\n if(ary[mid] < x) then\n min = mid\n else\n max = mid\n end\n end\n return max\nend\n\nlocal ret = nil\nlocal n = io.read(\"*n\")\nlocal tot = {}\nlocal cur = 0\nfor i = 1, n do\n cur = cur + io.read(\"*n\")\n tot[i] = cur\nend\nfor i = 3, n - 1 do\n local leftsum = tot[i - 1]\n local rightsum = tot[n] - leftsum\n local leftlb = lower_bound(tot, leftsum / 2, 1, i - 1)\n leftlb = mmi(leftlb, i - 2)\n local rightlb = lower_bound(tot, leftsum + rightsum / 2, i, n)\n rightlb = mmi(rightlb, n - 1)\n for k = 1, 4 do\n local v1 = tot[leftlb]\n local v3 = tot[rightlb] - leftsum\n if k <= 2 then\n if(1 < leftlb) then\n v1 = tot[leftlb - 1]\n end\n end\n if k % 2 == 0 then\n if(i < rightlb) then\n v3 = tot[rightlb - 1] - leftsum\n end\n end\n local v2 = leftsum - v1\n local v4 = rightsum - v3\n local mi = mmi(v1, mmi(v2, mmi(v3, v4)))\n local ma = mma(v1, mma(v2, mma(v3, v4)))\n if(ret == nil) then\n ret = ma - mi\n else\n ret = mmi(ret, ma - mi)\n end\n end\nend\nprint(ret)\n", "language": "Lua", "metadata": {"date": 1558497787, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03310.html", "problem_id": "p03310", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03310/input.txt", "sample_output_relpath": "derived/input_output/data/p03310/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03310/Lua/s080279458.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s080279458", "user_id": "u120582723"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "local mfl, mma, mmi = math.floor, math.max, math.min\nlocal function lower_bound(ary, x, min, max)\n if(x <= ary[min]) then return min end\n if(ary[max] < x) then return max + 1 end\n while(1 < max - min) do\n local mid = mfl((min + max) / 2)\n if(ary[mid] < x) then\n min = mid\n else\n max = mid\n end\n end\n return max\nend\n\nlocal ret = nil\nlocal n = io.read(\"*n\")\nlocal tot = {}\nlocal cur = 0\nfor i = 1, n do\n cur = cur + io.read(\"*n\")\n tot[i] = cur\nend\nfor i = 3, n - 1 do\n local leftsum = tot[i - 1]\n local rightsum = tot[n] - leftsum\n local leftlb = lower_bound(tot, leftsum / 2, 1, i - 1)\n leftlb = mmi(leftlb, i - 2)\n local rightlb = lower_bound(tot, leftsum + rightsum / 2, i, n)\n rightlb = mmi(rightlb, n - 1)\n for k = 1, 4 do\n local v1 = tot[leftlb]\n local v3 = tot[rightlb] - leftsum\n if k <= 2 then\n if(1 < leftlb) then\n v1 = tot[leftlb - 1]\n end\n end\n if k % 2 == 0 then\n if(i < rightlb) then\n v3 = tot[rightlb - 1] - leftsum\n end\n end\n local v2 = leftsum - v1\n local v4 = rightsum - v3\n local mi = mmi(v1, mmi(v2, mmi(v3, v4)))\n local ma = mma(v1, mma(v2, mma(v3, v4)))\n if(ret == nil) then\n ret = ma - mi\n else\n ret = mmi(ret, ma - mi)\n end\n end\nend\nprint(ret)\n", "problem_context": "Score : 600 points\n\nProblem Statement\n\nSnuke has an integer sequence A of length N.\n\nHe will make three cuts in A and divide it into four (non-empty) contiguous subsequences B, C, D and E.\nThe positions of the cuts can be freely chosen.\n\nLet P,Q,R,S be the sums of the elements in B,C,D,E, respectively.\nSnuke is happier when the absolute difference of the maximum and the minimum among P,Q,R,S is smaller.\nFind the minimum possible absolute difference of the maximum and the minimum among P,Q,R,S.\n\nConstraints\n\n4 \\leq N \\leq 2 \\times 10^5\n\n1 \\leq A_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nFind the minimum possible absolute difference of the maximum and the minimum among P,Q,R,S.\n\nSample Input 1\n\n5\n3 2 4 1 2\n\nSample Output 1\n\n2\n\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.\nHere, the maximum and the minimum among P,Q,R,S are 4 and 2, with the absolute difference of 2.\nWe cannot make the absolute difference of the maximum and the minimum less than 2, so the answer is 2.\n\nSample Input 2\n\n10\n10 71 84 33 6 47 23 25 52 64\n\nSample Output 2\n\n36\n\nSample Input 3\n\n7\n1 2 3 1000000000 4 5 6\n\nSample Output 3\n\n999999994", "sample_input": "5\n3 2 4 1 2\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03310", "source_text": "Score : 600 points\n\nProblem Statement\n\nSnuke has an integer sequence A of length N.\n\nHe will make three cuts in A and divide it into four (non-empty) contiguous subsequences B, C, D and E.\nThe positions of the cuts can be freely chosen.\n\nLet P,Q,R,S be the sums of the elements in B,C,D,E, respectively.\nSnuke is happier when the absolute difference of the maximum and the minimum among P,Q,R,S is smaller.\nFind the minimum possible absolute difference of the maximum and the minimum among P,Q,R,S.\n\nConstraints\n\n4 \\leq N \\leq 2 \\times 10^5\n\n1 \\leq A_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nFind the minimum possible absolute difference of the maximum and the minimum among P,Q,R,S.\n\nSample Input 1\n\n5\n3 2 4 1 2\n\nSample Output 1\n\n2\n\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.\nHere, the maximum and the minimum among P,Q,R,S are 4 and 2, with the absolute difference of 2.\nWe cannot make the absolute difference of the maximum and the minimum less than 2, so the answer is 2.\n\nSample Input 2\n\n10\n10 71 84 33 6 47 23 25 52 64\n\nSample Output 2\n\n36\n\nSample Input 3\n\n7\n1 2 3 1000000000 4 5 6\n\nSample Output 3\n\n999999994", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1286, "cpu_time_ms": 1286, "memory_kb": 4600}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s076772273", "group_id": "codeNet:p03313", "input_text": "local mfl = math.floor\nlocal alltask = {}\nlocal stagetask = {}\nlocal a = {}\nlocal tot = 1\nlocal function bdp_prepare(n)\n for i = 1, n do\n tot = tot * 2\n stagetask[i] = {}\n end\n local a0 = io.read(\"*n\")\n for i = 1, tot - 1 do\n a[i] = io.read(\"*n\")\n if a[i] < a0 then\n alltask[i] = {tot, i}\n else\n alltask[i] = {i, tot}\n end\n end\n a[tot] = a0\n a[tot + 1] = 0\n for i = 1, tot - 1 do\n local ti = i\n local cnt = 0\n for j = 1, n do\n if ti % 2 == 1 then\n cnt = cnt + 1\n ti = ti - 1\n end\n ti = mfl(ti / 2)\n end\n table.insert(stagetask[cnt], i)\n end\nend\n\nlocal function bdp_walk(src, dst)\n local l1 = alltask[dst][1]\n local l2 = alltask[dst][2]\n local r1 = alltask[src][1]\n local r2 = alltask[src][2]\n if l1 == r1 or l2 == r1 then r1 = tot + 1 end\n if l1 == r2 or l2 == r2 then r2 = tot + 1 end\n if a[l1] < a[r1] then\n alltask[dst][1] = r1\n if a[l1] < a[r2] then\n alltask[dst][2] = r2\n else\n alltask[dst][2] = l1\n end\n else\n alltask[dst][1] = l1\n if a[l2] < a[r1] then\n alltask[dst][2] = r1\n else\n alltask[dst][2] = l2\n end\n end\nend\nlocal function bdp_doall(n)\n for stage = 1, n - 1 do\n local stlen = #stagetask[stage]\n for i_stagetask = 1, stlen do\n local used = stagetask[stage][i_stagetask]\n local mul = 1\n local tmp = used\n for j = 1, n do\n if tmp % 2 == 0 then\n bdp_walk(used, used + mul)\n else\n tmp = tmp - 1\n end\n tmp = mfl(tmp / 2)\n mul = mul * 2\n end\n end\n end\nend\n\nlocal n = io.read(\"*n\")\nbdp_prepare(n)\nbdp_doall(n)\nlocal prv = 0\nfor i = 1, tot - 1 do\n local cur = a[alltask[i][1]] + a[alltask[i][2]]\n if cur < prv then cur = prv end\n print(cur)\n prv = cur\nend\n", "language": "Lua", "metadata": {"date": 1570650743, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p03313.html", "problem_id": "p03313", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03313/input.txt", "sample_output_relpath": "derived/input_output/data/p03313/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03313/Lua/s076772273.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s076772273", "user_id": "u120582723"}, "prompt_components": {"gold_output": "3\n4\n5\n", "input_to_evaluate": "local mfl = math.floor\nlocal alltask = {}\nlocal stagetask = {}\nlocal a = {}\nlocal tot = 1\nlocal function bdp_prepare(n)\n for i = 1, n do\n tot = tot * 2\n stagetask[i] = {}\n end\n local a0 = io.read(\"*n\")\n for i = 1, tot - 1 do\n a[i] = io.read(\"*n\")\n if a[i] < a0 then\n alltask[i] = {tot, i}\n else\n alltask[i] = {i, tot}\n end\n end\n a[tot] = a0\n a[tot + 1] = 0\n for i = 1, tot - 1 do\n local ti = i\n local cnt = 0\n for j = 1, n do\n if ti % 2 == 1 then\n cnt = cnt + 1\n ti = ti - 1\n end\n ti = mfl(ti / 2)\n end\n table.insert(stagetask[cnt], i)\n end\nend\n\nlocal function bdp_walk(src, dst)\n local l1 = alltask[dst][1]\n local l2 = alltask[dst][2]\n local r1 = alltask[src][1]\n local r2 = alltask[src][2]\n if l1 == r1 or l2 == r1 then r1 = tot + 1 end\n if l1 == r2 or l2 == r2 then r2 = tot + 1 end\n if a[l1] < a[r1] then\n alltask[dst][1] = r1\n if a[l1] < a[r2] then\n alltask[dst][2] = r2\n else\n alltask[dst][2] = l1\n end\n else\n alltask[dst][1] = l1\n if a[l2] < a[r1] then\n alltask[dst][2] = r1\n else\n alltask[dst][2] = l2\n end\n end\nend\nlocal function bdp_doall(n)\n for stage = 1, n - 1 do\n local stlen = #stagetask[stage]\n for i_stagetask = 1, stlen do\n local used = stagetask[stage][i_stagetask]\n local mul = 1\n local tmp = used\n for j = 1, n do\n if tmp % 2 == 0 then\n bdp_walk(used, used + mul)\n else\n tmp = tmp - 1\n end\n tmp = mfl(tmp / 2)\n mul = mul * 2\n end\n end\n end\nend\n\nlocal n = io.read(\"*n\")\nbdp_prepare(n)\nbdp_doall(n)\nlocal prv = 0\nfor i = 1, tot - 1 do\n local cur = a[alltask[i][1]] + a[alltask[i][2]]\n if cur < prv then cur = prv end\n print(cur)\n prv = cur\nend\n", "problem_context": "Score : 700 points\n\nProblem Statement\n\nThere is an integer sequence of length 2^N: A_0, A_1, ..., A_{2^N-1}. (Note that the sequence is 0-indexed.)\n\nFor every integer K satisfying 1 \\leq K \\leq 2^N-1, solve the following problem:\n\nLet i and j be integers. Find the maximum value of A_i + A_j where 0 \\leq i < j \\leq 2^N-1 and (i or j) \\leq K.\nHere, or denotes the bitwise OR.\n\nConstraints\n\n1 \\leq N \\leq 18\n\n1 \\leq A_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_0 A_1 ... A_{2^N-1}\n\nOutput\n\nPrint 2^N-1 lines.\nIn the i-th line, print the answer of the problem above for K=i.\n\nSample Input 1\n\n2\n1 2 3 1\n\nSample Output 1\n\n3\n4\n5\n\nFor K=1, the only possible pair of i and j is (i,j)=(0,1), so the answer is A_0+A_1=1+2=3.\n\nFor K=2, the possible pairs of i and j are (i,j)=(0,1),(0,2).\nWhen (i,j)=(0,2), A_i+A_j=1+3=4. This is the maximum value, so the answer is 4.\n\nFor K=3, the possible pairs of i and j are (i,j)=(0,1),(0,2),(0,3),(1,2),(1,3),(2,3) .\nWhen (i,j)=(1,2), A_i+A_j=2+3=5. This is the maximum value, so the answer is 5.\n\nSample Input 2\n\n3\n10 71 84 33 6 47 23 25\n\nSample Output 2\n\n81\n94\n155\n155\n155\n155\n155\n\nSample Input 3\n\n4\n75 26 45 72 81 47 97 97 2 2 25 82 84 17 56 32\n\nSample Output 3\n\n101\n120\n147\n156\n156\n178\n194\n194\n194\n194\n194\n194\n194\n194\n194", "sample_input": "2\n1 2 3 1\n"}, "reference_outputs": ["3\n4\n5\n"], "source_document_id": "p03313", "source_text": "Score : 700 points\n\nProblem Statement\n\nThere is an integer sequence of length 2^N: A_0, A_1, ..., A_{2^N-1}. (Note that the sequence is 0-indexed.)\n\nFor every integer K satisfying 1 \\leq K \\leq 2^N-1, solve the following problem:\n\nLet i and j be integers. Find the maximum value of A_i + A_j where 0 \\leq i < j \\leq 2^N-1 and (i or j) \\leq K.\nHere, or denotes the bitwise OR.\n\nConstraints\n\n1 \\leq N \\leq 18\n\n1 \\leq A_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_0 A_1 ... A_{2^N-1}\n\nOutput\n\nPrint 2^N-1 lines.\nIn the i-th line, print the answer of the problem above for K=i.\n\nSample Input 1\n\n2\n1 2 3 1\n\nSample Output 1\n\n3\n4\n5\n\nFor K=1, the only possible pair of i and j is (i,j)=(0,1), so the answer is A_0+A_1=1+2=3.\n\nFor K=2, the possible pairs of i and j are (i,j)=(0,1),(0,2).\nWhen (i,j)=(0,2), A_i+A_j=1+3=4. This is the maximum value, so the answer is 4.\n\nFor K=3, the possible pairs of i and j are (i,j)=(0,1),(0,2),(0,3),(1,2),(1,3),(2,3) .\nWhen (i,j)=(1,2), A_i+A_j=2+3=5. This is the maximum value, so the answer is 5.\n\nSample Input 2\n\n3\n10 71 84 33 6 47 23 25\n\nSample Output 2\n\n81\n94\n155\n155\n155\n155\n155\n\nSample Input 3\n\n4\n75 26 45 72 81 47 97 97 2 2 25 82 84 17 56 32\n\nSample Output 3\n\n101\n120\n147\n156\n156\n178\n194\n194\n194\n194\n194\n194\n194\n194\n194", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1790, "cpu_time_ms": 551, "memory_kb": 29024}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s850234478", "group_id": "codeNet:p03315", "input_text": "v = 0\n\nfor o in string.gmatch(io.read(), \"(%p)\") do\n if(o == \"+\") then\n v = v + 1\n elseif(o == \"-\") then\n v = v - 1\n end\nend\n\nprint(v)\n", "language": "Lua", "metadata": {"date": 1529802714, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03315.html", "problem_id": "p03315", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03315/input.txt", "sample_output_relpath": "derived/input_output/data/p03315/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03315/Lua/s850234478.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s850234478", "user_id": "u374892957"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "v = 0\n\nfor o in string.gmatch(io.read(), \"(%p)\") do\n if(o == \"+\") then\n v = v + 1\n elseif(o == \"-\") then\n v = v - 1\n end\nend\n\nprint(v)\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nThere is always an integer in Takahashi's mind.\n\nInitially, the integer in Takahashi's mind is 0. Takahashi is now going to eat four symbols, each of which is + or -. When he eats +, the integer in his mind increases by 1; when he eats -, the integer in his mind decreases by 1.\n\nThe symbols Takahashi is going to eat are given to you as a string S. The i-th character in S is the i-th symbol for him to eat.\n\nFind the integer in Takahashi's mind after he eats all the symbols.\n\nConstraints\n\nThe length of S is 4.\n\nEach character in S is + or -.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the integer in Takahashi's mind after he eats all the symbols.\n\nSample Input 1\n\n+-++\n\nSample Output 1\n\n2\n\nInitially, the integer in Takahashi's mind is 0.\n\nThe first integer for him to eat is +. After eating it, the integer in his mind becomes 1.\n\nThe second integer to eat is -. After eating it, the integer in his mind becomes 0.\n\nThe third integer to eat is +. After eating it, the integer in his mind becomes 1.\n\nThe fourth integer to eat is +. After eating it, the integer in his mind becomes 2.\n\nThus, the integer in Takahashi's mind after he eats all the symbols is 2.\n\nSample Input 2\n\n-+--\n\nSample Output 2\n\n-2\n\nSample Input 3\n\n----\n\nSample Output 3\n\n-4", "sample_input": "+-++\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03315", "source_text": "Score : 100 points\n\nProblem Statement\n\nThere is always an integer in Takahashi's mind.\n\nInitially, the integer in Takahashi's mind is 0. Takahashi is now going to eat four symbols, each of which is + or -. When he eats +, the integer in his mind increases by 1; when he eats -, the integer in his mind decreases by 1.\n\nThe symbols Takahashi is going to eat are given to you as a string S. The i-th character in S is the i-th symbol for him to eat.\n\nFind the integer in Takahashi's mind after he eats all the symbols.\n\nConstraints\n\nThe length of S is 4.\n\nEach character in S is + or -.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the integer in Takahashi's mind after he eats all the symbols.\n\nSample Input 1\n\n+-++\n\nSample Output 1\n\n2\n\nInitially, the integer in Takahashi's mind is 0.\n\nThe first integer for him to eat is +. After eating it, the integer in his mind becomes 1.\n\nThe second integer to eat is -. After eating it, the integer in his mind becomes 0.\n\nThe third integer to eat is +. After eating it, the integer in his mind becomes 1.\n\nThe fourth integer to eat is +. After eating it, the integer in his mind becomes 2.\n\nThus, the integer in Takahashi's mind after he eats all the symbols is 2.\n\nSample Input 2\n\n-+--\n\nSample Output 2\n\n-2\n\nSample Input 3\n\n----\n\nSample Output 3\n\n-4", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 144, "cpu_time_ms": 112, "memory_kb": 760}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s700185375", "group_id": "codeNet:p03316", "input_text": "n = io.read(\"*n\")\na, s = n, 0\nwhile(0 < a) do\n s = s + a % 10\n a = math.floor(a / 10)\nend\nprint(n % s == 0 and \"Yes\" or \"No\")", "language": "Lua", "metadata": {"date": 1555202778, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p03316.html", "problem_id": "p03316", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03316/input.txt", "sample_output_relpath": "derived/input_output/data/p03316/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03316/Lua/s700185375.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s700185375", "user_id": "u120582723"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "n = io.read(\"*n\")\na, s = n, 0\nwhile(0 < a) do\n s = s + a % 10\n a = math.floor(a / 10)\nend\nprint(n % s == 0 and \"Yes\" or \"No\")", "problem_context": "Score : 200 points\n\nProblem Statement\n\nLet S(n) denote the sum of the digits in the decimal notation of n.\nFor example, S(101) = 1 + 0 + 1 = 2.\n\nGiven an integer N, determine if S(N) divides N.\n\nConstraints\n\n1 \\leq N \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nIf S(N) divides N, print Yes; if it does not, print No.\n\nSample Input 1\n\n12\n\nSample Output 1\n\nYes\n\nIn this input, N=12.\nAs S(12) = 1 + 2 = 3, S(N) divides N.\n\nSample Input 2\n\n101\n\nSample Output 2\n\nNo\n\nAs S(101) = 1 + 0 + 1 = 2, S(N) does not divide N.\n\nSample Input 3\n\n999999999\n\nSample Output 3\n\nYes", "sample_input": "12\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03316", "source_text": "Score : 200 points\n\nProblem Statement\n\nLet S(n) denote the sum of the digits in the decimal notation of n.\nFor example, S(101) = 1 + 0 + 1 = 2.\n\nGiven an integer N, determine if S(N) divides N.\n\nConstraints\n\n1 \\leq N \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nIf S(N) divides N, print Yes; if it does not, print No.\n\nSample Input 1\n\n12\n\nSample Output 1\n\nYes\n\nIn this input, N=12.\nAs S(12) = 1 + 2 = 3, S(N) divides N.\n\nSample Input 2\n\n101\n\nSample Output 2\n\nNo\n\nAs S(101) = 1 + 0 + 1 = 2, S(N) does not divide N.\n\nSample Input 3\n\n999999999\n\nSample Output 3\n\nYes", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 131, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s832473391", "group_id": "codeNet:p03316", "input_text": "N=io.read(\"n\")\nS=0\nn=N\nwhile(N>0) do\n S=S+N%10\n N=N//10\nend\nif n%S==0 then \n print(\"Yes\")\n else\n print(\"No\")\nend", "language": "Lua", "metadata": {"date": 1550602577, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03316.html", "problem_id": "p03316", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03316/input.txt", "sample_output_relpath": "derived/input_output/data/p03316/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03316/Lua/s832473391.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s832473391", "user_id": "u015229643"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "N=io.read(\"n\")\nS=0\nn=N\nwhile(N>0) do\n S=S+N%10\n N=N//10\nend\nif n%S==0 then \n print(\"Yes\")\n else\n print(\"No\")\nend", "problem_context": "Score : 200 points\n\nProblem Statement\n\nLet S(n) denote the sum of the digits in the decimal notation of n.\nFor example, S(101) = 1 + 0 + 1 = 2.\n\nGiven an integer N, determine if S(N) divides N.\n\nConstraints\n\n1 \\leq N \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nIf S(N) divides N, print Yes; if it does not, print No.\n\nSample Input 1\n\n12\n\nSample Output 1\n\nYes\n\nIn this input, N=12.\nAs S(12) = 1 + 2 = 3, S(N) divides N.\n\nSample Input 2\n\n101\n\nSample Output 2\n\nNo\n\nAs S(101) = 1 + 0 + 1 = 2, S(N) does not divide N.\n\nSample Input 3\n\n999999999\n\nSample Output 3\n\nYes", "sample_input": "12\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03316", "source_text": "Score : 200 points\n\nProblem Statement\n\nLet S(n) denote the sum of the digits in the decimal notation of n.\nFor example, S(101) = 1 + 0 + 1 = 2.\n\nGiven an integer N, determine if S(N) divides N.\n\nConstraints\n\n1 \\leq N \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nIf S(N) divides N, print Yes; if it does not, print No.\n\nSample Input 1\n\n12\n\nSample Output 1\n\nYes\n\nIn this input, N=12.\nAs S(12) = 1 + 2 = 3, S(N) divides N.\n\nSample Input 2\n\n101\n\nSample Output 2\n\nNo\n\nAs S(101) = 1 + 0 + 1 = 2, S(N) does not divide N.\n\nSample Input 3\n\n999999999\n\nSample Output 3\n\nYes", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 117, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s678829044", "group_id": "codeNet:p03317", "input_text": "N=io.read(\"n\")\nK=io.read(\"n\")\nA={}\nfor i=1,N do\n A[i]=io.read(\"n\")\nend\ntable.sort(A)\nminnub=1\nfor i=2,N do\n if A[i]==A[i-1] then\n minnub=minnub+1\n else\n break\n end\nend\nres=0\nif (N-minnub)%(K-1)==0 then\n res=(N-minnub)//(K-1)\n else\n res=(N-minnub)//(K-1)+1\nend\nprint(res)", "language": "Lua", "metadata": {"date": 1550606846, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03317.html", "problem_id": "p03317", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03317/input.txt", "sample_output_relpath": "derived/input_output/data/p03317/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03317/Lua/s678829044.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s678829044", "user_id": "u015229643"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "N=io.read(\"n\")\nK=io.read(\"n\")\nA={}\nfor i=1,N do\n A[i]=io.read(\"n\")\nend\ntable.sort(A)\nminnub=1\nfor i=2,N do\n if A[i]==A[i-1] then\n minnub=minnub+1\n else\n break\n end\nend\nres=0\nif (N-minnub)%(K-1)==0 then\n res=(N-minnub)//(K-1)\n else\n res=(N-minnub)//(K-1)+1\nend\nprint(res)", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere is a sequence of length N: A_1, A_2, ..., A_N. Initially, this sequence is a permutation of 1, 2, ..., N.\n\nOn this sequence, Snuke can perform the following operation:\n\nChoose K consecutive elements in the sequence. Then, replace the value of each chosen element with the minimum value among the chosen elements.\n\nSnuke would like to make all the elements in this sequence equal by repeating the operation above some number of times.\nFind the minimum number of operations required.\nIt can be proved that, Under the constraints of this problem, this objective is always achievable.\n\nConstraints\n\n2 \\leq K \\leq N \\leq 100000\n\nA_1, A_2, ..., A_N is a permutation of 1, 2, ..., N.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the minimum number of operations required.\n\nSample Input 1\n\n4 3\n2 3 1 4\n\nSample Output 1\n\n2\n\nOne optimal strategy is as follows:\n\nIn the first operation, choose the first, second and third elements. The sequence A becomes 1, 1, 1, 4.\n\nIn the second operation, choose the second, third and fourth elements. The sequence A becomes 1, 1, 1, 1.\n\nSample Input 2\n\n3 3\n1 2 3\n\nSample Output 2\n\n1\n\nSample Input 3\n\n8 3\n7 3 1 8 4 6 2 5\n\nSample Output 3\n\n4", "sample_input": "4 3\n2 3 1 4\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03317", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere is a sequence of length N: A_1, A_2, ..., A_N. Initially, this sequence is a permutation of 1, 2, ..., N.\n\nOn this sequence, Snuke can perform the following operation:\n\nChoose K consecutive elements in the sequence. Then, replace the value of each chosen element with the minimum value among the chosen elements.\n\nSnuke would like to make all the elements in this sequence equal by repeating the operation above some number of times.\nFind the minimum number of operations required.\nIt can be proved that, Under the constraints of this problem, this objective is always achievable.\n\nConstraints\n\n2 \\leq K \\leq N \\leq 100000\n\nA_1, A_2, ..., A_N is a permutation of 1, 2, ..., N.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the minimum number of operations required.\n\nSample Input 1\n\n4 3\n2 3 1 4\n\nSample Output 1\n\n2\n\nOne optimal strategy is as follows:\n\nIn the first operation, choose the first, second and third elements. The sequence A becomes 1, 1, 1, 4.\n\nIn the second operation, choose the second, third and fourth elements. The sequence A becomes 1, 1, 1, 1.\n\nSample Input 2\n\n3 3\n1 2 3\n\nSample Output 2\n\n1\n\nSample Input 3\n\n8 3\n7 3 1 8 4 6 2 5\n\nSample Output 3\n\n4", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 285, "cpu_time_ms": 89, "memory_kb": 2424}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s718592428", "group_id": "codeNet:p03318", "input_text": "local function llprint(llnumber)\n local str = tostring(llnumber):gsub(\"LL\", \"\")\n print(str)\nend\n\nlocal function snuke(k)\n local snuke = 0\n local tmp = k\n while 0 < tmp do\n local a = tmp % 10\n snuke = snuke + a\n tmp = (tmp - a) / 10\n end\n return k / snuke\nend\n\nlocal k = io.read(\"*n\")\nlocal dig = 1\nlocal cnt = 0\nlocal min = 1\nwhile cnt < k do\n if dig == 1 then\n for i = 1, 9 do\n cnt = cnt + 1\n print(i)\n if cnt == k then break end\n end\n elseif dig <= 3 then\n -- candidate: 19,29,...,99, 199,299, ..., 999\n base = 0\n mul = 1\n for i = 2, dig do\n base = base * 10 + 9\n mul = mul * 10\n end\n for i = 1, 9 do\n v = base + mul * i\n snk = snuke(v)\n if min <= snk then\n cnt = cnt + 1\n min = snk\n print(v)\n if cnt == k then break end\n end\n end\n elseif dig <= 14 then\n -- candidate: 1z9..9, 2z9..9, ..., 9z9..9 z=[0-9]\n base = 0LL\n mul = 1LL\n for i = 3, dig do\n base = base * 10 + 9\n mul = mul * 10\n end\n for i = 10, 99 do\n v = base + mul * i\n snk = snuke(v)\n if min <= snk then\n cnt = cnt + 1\n min = snk\n llprint(v)\n if cnt == k then break end\n end\n end\n else\n -- candidate: 1xy9..9, 2xy9..9, ..., 9xy9..9 x,y=[0-9]\n base = 0LL\n mul = 1LL\n for i = 4, dig do\n base = base * 10 + 9\n mul = mul * 10\n end\n for i = 100, 999 do\n v = base + mul * i\n snk = snuke(v)\n if min <= snk then\n cnt = cnt + 1\n min = snk\n llprint(v)\n if cnt == k then break end\n end\n end\n end\n dig = dig + 1\n if dig == 16 then break end\nend\n", "language": "Lua", "metadata": {"date": 1571490205, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p03318.html", "problem_id": "p03318", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03318/input.txt", "sample_output_relpath": "derived/input_output/data/p03318/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03318/Lua/s718592428.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s718592428", "user_id": "u120582723"}, "prompt_components": {"gold_output": "1\n2\n3\n4\n5\n6\n7\n8\n9\n19\n", "input_to_evaluate": "local function llprint(llnumber)\n local str = tostring(llnumber):gsub(\"LL\", \"\")\n print(str)\nend\n\nlocal function snuke(k)\n local snuke = 0\n local tmp = k\n while 0 < tmp do\n local a = tmp % 10\n snuke = snuke + a\n tmp = (tmp - a) / 10\n end\n return k / snuke\nend\n\nlocal k = io.read(\"*n\")\nlocal dig = 1\nlocal cnt = 0\nlocal min = 1\nwhile cnt < k do\n if dig == 1 then\n for i = 1, 9 do\n cnt = cnt + 1\n print(i)\n if cnt == k then break end\n end\n elseif dig <= 3 then\n -- candidate: 19,29,...,99, 199,299, ..., 999\n base = 0\n mul = 1\n for i = 2, dig do\n base = base * 10 + 9\n mul = mul * 10\n end\n for i = 1, 9 do\n v = base + mul * i\n snk = snuke(v)\n if min <= snk then\n cnt = cnt + 1\n min = snk\n print(v)\n if cnt == k then break end\n end\n end\n elseif dig <= 14 then\n -- candidate: 1z9..9, 2z9..9, ..., 9z9..9 z=[0-9]\n base = 0LL\n mul = 1LL\n for i = 3, dig do\n base = base * 10 + 9\n mul = mul * 10\n end\n for i = 10, 99 do\n v = base + mul * i\n snk = snuke(v)\n if min <= snk then\n cnt = cnt + 1\n min = snk\n llprint(v)\n if cnt == k then break end\n end\n end\n else\n -- candidate: 1xy9..9, 2xy9..9, ..., 9xy9..9 x,y=[0-9]\n base = 0LL\n mul = 1LL\n for i = 4, dig do\n base = base * 10 + 9\n mul = mul * 10\n end\n for i = 100, 999 do\n v = base + mul * i\n snk = snuke(v)\n if min <= snk then\n cnt = cnt + 1\n min = snk\n llprint(v)\n if cnt == k then break end\n end\n end\n end\n dig = dig + 1\n if dig == 16 then break end\nend\n", "problem_context": "Score : 500 points\n\nProblem Statement\n\nLet S(n) denote the sum of the digits in the decimal notation of n.\nFor example, S(123) = 1 + 2 + 3 = 6.\n\nWe will call an integer n a Snuke number when, for all positive integers m such that m > n, \\frac{n}{S(n)} \\leq \\frac{m}{S(m)} holds.\n\nGiven an integer K, list the K smallest Snuke numbers.\n\nConstraints\n\n1 \\leq K\n\nThe K-th smallest Snuke number is not greater than 10^{15}.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nK\n\nOutput\n\nPrint K lines. The i-th line should contain the i-th smallest Snuke number.\n\nSample Input 1\n\n10\n\nSample Output 1\n\n1\n2\n3\n4\n5\n6\n7\n8\n9\n19", "sample_input": "10\n"}, "reference_outputs": ["1\n2\n3\n4\n5\n6\n7\n8\n9\n19\n"], "source_document_id": "p03318", "source_text": "Score : 500 points\n\nProblem Statement\n\nLet S(n) denote the sum of the digits in the decimal notation of n.\nFor example, S(123) = 1 + 2 + 3 = 6.\n\nWe will call an integer n a Snuke number when, for all positive integers m such that m > n, \\frac{n}{S(n)} \\leq \\frac{m}{S(m)} holds.\n\nGiven an integer K, list the K smallest Snuke numbers.\n\nConstraints\n\n1 \\leq K\n\nThe K-th smallest Snuke number is not greater than 10^{15}.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nK\n\nOutput\n\nPrint K lines. The i-th line should contain the i-th smallest Snuke number.\n\nSample Input 1\n\n10\n\nSample Output 1\n\n1\n2\n3\n4\n5\n6\n7\n8\n9\n19", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1677, "cpu_time_ms": 5, "memory_kb": 384}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s290178377", "group_id": "codeNet:p03318", "input_text": "function snuke(k)\n local snuke = 0\n local tmp = k\n while(0 < tmp) do\n local a = tmp % 10\n snuke = snuke + a\n tmp = (tmp - a) / 10\n end\n return k / snuke\nend\n\nk = io.read(\"*n\")\ndig = 0\ncnt = 0\nmin = 1\nwhile(cnt <= k) do\n for i = 1, 9 do\n v = i\n for j = 1, dig do\n v = v * 10 + 9\n end\n snk = snuke(v)\n if(min <= snk) then\n cnt = cnt + 1\n min = snk\n print(v)\n if(cnt == k) then break end\n end\n end\n dig = dig + 1\nend\n", "language": "Lua", "metadata": {"date": 1554868213, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p03318.html", "problem_id": "p03318", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03318/input.txt", "sample_output_relpath": "derived/input_output/data/p03318/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03318/Lua/s290178377.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s290178377", "user_id": "u120582723"}, "prompt_components": {"gold_output": "1\n2\n3\n4\n5\n6\n7\n8\n9\n19\n", "input_to_evaluate": "function snuke(k)\n local snuke = 0\n local tmp = k\n while(0 < tmp) do\n local a = tmp % 10\n snuke = snuke + a\n tmp = (tmp - a) / 10\n end\n return k / snuke\nend\n\nk = io.read(\"*n\")\ndig = 0\ncnt = 0\nmin = 1\nwhile(cnt <= k) do\n for i = 1, 9 do\n v = i\n for j = 1, dig do\n v = v * 10 + 9\n end\n snk = snuke(v)\n if(min <= snk) then\n cnt = cnt + 1\n min = snk\n print(v)\n if(cnt == k) then break end\n end\n end\n dig = dig + 1\nend\n", "problem_context": "Score : 500 points\n\nProblem Statement\n\nLet S(n) denote the sum of the digits in the decimal notation of n.\nFor example, S(123) = 1 + 2 + 3 = 6.\n\nWe will call an integer n a Snuke number when, for all positive integers m such that m > n, \\frac{n}{S(n)} \\leq \\frac{m}{S(m)} holds.\n\nGiven an integer K, list the K smallest Snuke numbers.\n\nConstraints\n\n1 \\leq K\n\nThe K-th smallest Snuke number is not greater than 10^{15}.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nK\n\nOutput\n\nPrint K lines. The i-th line should contain the i-th smallest Snuke number.\n\nSample Input 1\n\n10\n\nSample Output 1\n\n1\n2\n3\n4\n5\n6\n7\n8\n9\n19", "sample_input": "10\n"}, "reference_outputs": ["1\n2\n3\n4\n5\n6\n7\n8\n9\n19\n"], "source_document_id": "p03318", "source_text": "Score : 500 points\n\nProblem Statement\n\nLet S(n) denote the sum of the digits in the decimal notation of n.\nFor example, S(123) = 1 + 2 + 3 = 6.\n\nWe will call an integer n a Snuke number when, for all positive integers m such that m > n, \\frac{n}{S(n)} \\leq \\frac{m}{S(m)} holds.\n\nGiven an integer K, list the K smallest Snuke numbers.\n\nConstraints\n\n1 \\leq K\n\nThe K-th smallest Snuke number is not greater than 10^{15}.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nK\n\nOutput\n\nPrint K lines. The i-th line should contain the i-th smallest Snuke number.\n\nSample Input 1\n\n10\n\nSample Output 1\n\n1\n2\n3\n4\n5\n6\n7\n8\n9\n19", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 474, "cpu_time_ms": 2103, "memory_kb": 256}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s462215510", "group_id": "codeNet:p03319", "input_text": "local read = io.read\nlocal min = math.min\n\nlocal n, k = read(\"n\", \"n\")\nlocal a_t = {}\nlocal min_num = math.maxinteger\nfor i = 1, n do\n\tlocal a_i = read(\"n\")\n\ta_t[i] = a_i\n\tmin_num = min(min_num, a_i)\nend\n\nlocal not_min_amount = 0\nfor i = 1, n do\n\tif a_t[i] ~= min_num then\n\t\tnot_min_amount = not_min_amount + 1\n\tend\nend\n\nprint(math.ceil(not_min_amount / (k - 1)))\n", "language": "Lua", "metadata": {"date": 1599273345, "filename_ext": "lua", "original_language": "Lua (Lua 5.3.5)", "problem_description_relpath": "problem_descriptions/p03319.html", "problem_id": "p03319", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03319/input.txt", "sample_output_relpath": "derived/input_output/data/p03319/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03319/Lua/s462215510.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s462215510", "user_id": "u793881115"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "local read = io.read\nlocal min = math.min\n\nlocal n, k = read(\"n\", \"n\")\nlocal a_t = {}\nlocal min_num = math.maxinteger\nfor i = 1, n do\n\tlocal a_i = read(\"n\")\n\ta_t[i] = a_i\n\tmin_num = min(min_num, a_i)\nend\n\nlocal not_min_amount = 0\nfor i = 1, n do\n\tif a_t[i] ~= min_num then\n\t\tnot_min_amount = not_min_amount + 1\n\tend\nend\n\nprint(math.ceil(not_min_amount / (k - 1)))\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere is a sequence of length N: A_1, A_2, ..., A_N. Initially, this sequence is a permutation of 1, 2, ..., N.\n\nOn this sequence, Snuke can perform the following operation:\n\nChoose K consecutive elements in the sequence. Then, replace the value of each chosen element with the minimum value among the chosen elements.\n\nSnuke would like to make all the elements in this sequence equal by repeating the operation above some number of times.\nFind the minimum number of operations required.\nIt can be proved that, Under the constraints of this problem, this objective is always achievable.\n\nConstraints\n\n2 \\leq K \\leq N \\leq 100000\n\nA_1, A_2, ..., A_N is a permutation of 1, 2, ..., N.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the minimum number of operations required.\n\nSample Input 1\n\n4 3\n2 3 1 4\n\nSample Output 1\n\n2\n\nOne optimal strategy is as follows:\n\nIn the first operation, choose the first, second and third elements. The sequence A becomes 1, 1, 1, 4.\n\nIn the second operation, choose the second, third and fourth elements. The sequence A becomes 1, 1, 1, 1.\n\nSample Input 2\n\n3 3\n1 2 3\n\nSample Output 2\n\n1\n\nSample Input 3\n\n8 3\n7 3 1 8 4 6 2 5\n\nSample Output 3\n\n4", "sample_input": "4 3\n2 3 1 4\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03319", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere is a sequence of length N: A_1, A_2, ..., A_N. Initially, this sequence is a permutation of 1, 2, ..., N.\n\nOn this sequence, Snuke can perform the following operation:\n\nChoose K consecutive elements in the sequence. Then, replace the value of each chosen element with the minimum value among the chosen elements.\n\nSnuke would like to make all the elements in this sequence equal by repeating the operation above some number of times.\nFind the minimum number of operations required.\nIt can be proved that, Under the constraints of this problem, this objective is always achievable.\n\nConstraints\n\n2 \\leq K \\leq N \\leq 100000\n\nA_1, A_2, ..., A_N is a permutation of 1, 2, ..., N.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the minimum number of operations required.\n\nSample Input 1\n\n4 3\n2 3 1 4\n\nSample Output 1\n\n2\n\nOne optimal strategy is as follows:\n\nIn the first operation, choose the first, second and third elements. The sequence A becomes 1, 1, 1, 4.\n\nIn the second operation, choose the second, third and fourth elements. The sequence A becomes 1, 1, 1, 1.\n\nSample Input 2\n\n3 3\n1 2 3\n\nSample Output 2\n\n1\n\nSample Input 3\n\n8 3\n7 3 1 8 4 6 2 5\n\nSample Output 3\n\n4", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 364, "cpu_time_ms": 38, "memory_kb": 4248}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s424709243", "group_id": "codeNet:p03319", "input_text": "n,k=io.read(\"*n\",\"*n\",\"*l\")\na={}\nfor i=1,n do\n a[i]=io.read(\"*n\")\n if a[i]==1 then\n x=(i-1)//(k-1)+((i-1)%(k-1) and 1 or 0)\n y=(n-i)//(n-k)+((n-i)%(n-k) and 1 or 0)\n print(x+y)\n return\n end\nend", "language": "Lua", "metadata": {"date": 1588628739, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03319.html", "problem_id": "p03319", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03319/input.txt", "sample_output_relpath": "derived/input_output/data/p03319/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03319/Lua/s424709243.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s424709243", "user_id": "u045238009"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "n,k=io.read(\"*n\",\"*n\",\"*l\")\na={}\nfor i=1,n do\n a[i]=io.read(\"*n\")\n if a[i]==1 then\n x=(i-1)//(k-1)+((i-1)%(k-1) and 1 or 0)\n y=(n-i)//(n-k)+((n-i)%(n-k) and 1 or 0)\n print(x+y)\n return\n end\nend", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere is a sequence of length N: A_1, A_2, ..., A_N. Initially, this sequence is a permutation of 1, 2, ..., N.\n\nOn this sequence, Snuke can perform the following operation:\n\nChoose K consecutive elements in the sequence. Then, replace the value of each chosen element with the minimum value among the chosen elements.\n\nSnuke would like to make all the elements in this sequence equal by repeating the operation above some number of times.\nFind the minimum number of operations required.\nIt can be proved that, Under the constraints of this problem, this objective is always achievable.\n\nConstraints\n\n2 \\leq K \\leq N \\leq 100000\n\nA_1, A_2, ..., A_N is a permutation of 1, 2, ..., N.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the minimum number of operations required.\n\nSample Input 1\n\n4 3\n2 3 1 4\n\nSample Output 1\n\n2\n\nOne optimal strategy is as follows:\n\nIn the first operation, choose the first, second and third elements. The sequence A becomes 1, 1, 1, 4.\n\nIn the second operation, choose the second, third and fourth elements. The sequence A becomes 1, 1, 1, 1.\n\nSample Input 2\n\n3 3\n1 2 3\n\nSample Output 2\n\n1\n\nSample Input 3\n\n8 3\n7 3 1 8 4 6 2 5\n\nSample Output 3\n\n4", "sample_input": "4 3\n2 3 1 4\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03319", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere is a sequence of length N: A_1, A_2, ..., A_N. Initially, this sequence is a permutation of 1, 2, ..., N.\n\nOn this sequence, Snuke can perform the following operation:\n\nChoose K consecutive elements in the sequence. Then, replace the value of each chosen element with the minimum value among the chosen elements.\n\nSnuke would like to make all the elements in this sequence equal by repeating the operation above some number of times.\nFind the minimum number of operations required.\nIt can be proved that, Under the constraints of this problem, this objective is always achievable.\n\nConstraints\n\n2 \\leq K \\leq N \\leq 100000\n\nA_1, A_2, ..., A_N is a permutation of 1, 2, ..., N.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the minimum number of operations required.\n\nSample Input 1\n\n4 3\n2 3 1 4\n\nSample Output 1\n\n2\n\nOne optimal strategy is as follows:\n\nIn the first operation, choose the first, second and third elements. The sequence A becomes 1, 1, 1, 4.\n\nIn the second operation, choose the second, third and fourth elements. The sequence A becomes 1, 1, 1, 1.\n\nSample Input 2\n\n3 3\n1 2 3\n\nSample Output 2\n\n1\n\nSample Input 3\n\n8 3\n7 3 1 8 4 6 2 5\n\nSample Output 3\n\n4", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 230, "cpu_time_ms": 27, "memory_kb": 2424}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s498411095", "group_id": "codeNet:p03319", "input_text": "n,k=io.read(\"*n\",\"*n\",\"*l\")\na={}\nfor i=1,n do\n a[i]=io.read(\"*n\")\n if a[i]==1 then\n x=(i-1)//(k-1)+((i-1)//(k-1) and 1 or 0)\n y=(n-i)//(n-k)+((n-i)//(n-k) and 1 or 0)\n print(x+y)\n return\n end\nend", "language": "Lua", "metadata": {"date": 1588628689, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03319.html", "problem_id": "p03319", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03319/input.txt", "sample_output_relpath": "derived/input_output/data/p03319/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03319/Lua/s498411095.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s498411095", "user_id": "u045238009"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "n,k=io.read(\"*n\",\"*n\",\"*l\")\na={}\nfor i=1,n do\n a[i]=io.read(\"*n\")\n if a[i]==1 then\n x=(i-1)//(k-1)+((i-1)//(k-1) and 1 or 0)\n y=(n-i)//(n-k)+((n-i)//(n-k) and 1 or 0)\n print(x+y)\n return\n end\nend", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere is a sequence of length N: A_1, A_2, ..., A_N. Initially, this sequence is a permutation of 1, 2, ..., N.\n\nOn this sequence, Snuke can perform the following operation:\n\nChoose K consecutive elements in the sequence. Then, replace the value of each chosen element with the minimum value among the chosen elements.\n\nSnuke would like to make all the elements in this sequence equal by repeating the operation above some number of times.\nFind the minimum number of operations required.\nIt can be proved that, Under the constraints of this problem, this objective is always achievable.\n\nConstraints\n\n2 \\leq K \\leq N \\leq 100000\n\nA_1, A_2, ..., A_N is a permutation of 1, 2, ..., N.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the minimum number of operations required.\n\nSample Input 1\n\n4 3\n2 3 1 4\n\nSample Output 1\n\n2\n\nOne optimal strategy is as follows:\n\nIn the first operation, choose the first, second and third elements. The sequence A becomes 1, 1, 1, 4.\n\nIn the second operation, choose the second, third and fourth elements. The sequence A becomes 1, 1, 1, 1.\n\nSample Input 2\n\n3 3\n1 2 3\n\nSample Output 2\n\n1\n\nSample Input 3\n\n8 3\n7 3 1 8 4 6 2 5\n\nSample Output 3\n\n4", "sample_input": "4 3\n2 3 1 4\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03319", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere is a sequence of length N: A_1, A_2, ..., A_N. Initially, this sequence is a permutation of 1, 2, ..., N.\n\nOn this sequence, Snuke can perform the following operation:\n\nChoose K consecutive elements in the sequence. Then, replace the value of each chosen element with the minimum value among the chosen elements.\n\nSnuke would like to make all the elements in this sequence equal by repeating the operation above some number of times.\nFind the minimum number of operations required.\nIt can be proved that, Under the constraints of this problem, this objective is always achievable.\n\nConstraints\n\n2 \\leq K \\leq N \\leq 100000\n\nA_1, A_2, ..., A_N is a permutation of 1, 2, ..., N.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the minimum number of operations required.\n\nSample Input 1\n\n4 3\n2 3 1 4\n\nSample Output 1\n\n2\n\nOne optimal strategy is as follows:\n\nIn the first operation, choose the first, second and third elements. The sequence A becomes 1, 1, 1, 4.\n\nIn the second operation, choose the second, third and fourth elements. The sequence A becomes 1, 1, 1, 1.\n\nSample Input 2\n\n3 3\n1 2 3\n\nSample Output 2\n\n1\n\nSample Input 3\n\n8 3\n7 3 1 8 4 6 2 5\n\nSample Output 3\n\n4", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 232, "cpu_time_ms": 26, "memory_kb": 2424}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s963285418", "group_id": "codeNet:p03323", "input_text": "local A, B = io.read(\"n\",\"n\")\nprint( (A <= 8 and B <= 8) and 'Yay!' or ':(' )", "language": "Lua", "metadata": {"date": 1586776174, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03323.html", "problem_id": "p03323", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03323/input.txt", "sample_output_relpath": "derived/input_output/data/p03323/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03323/Lua/s963285418.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s963285418", "user_id": "u162773977"}, "prompt_components": {"gold_output": "Yay!\n", "input_to_evaluate": "local A, B = io.read(\"n\",\"n\")\nprint( (A <= 8 and B <= 8) and 'Yay!' or ':(' )", "problem_context": "Score: 100 points\n\nProblem Statement\n\nE869120's and square1001's 16-th birthday is coming soon.\n\nTakahashi from AtCoder Kingdom gave them a round cake cut into 16 equal fan-shaped pieces.\n\nE869120 and square1001 were just about to eat A and B of those pieces, respectively,\n\nwhen they found a note attached to the cake saying that \"the same person should not take two adjacent pieces of cake\".\n\nCan both of them obey the instruction in the note and take desired numbers of pieces of cake?\n\nConstraints\n\nA and B are integers between 1 and 16 (inclusive).\n\nA+B is at most 16.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nIf both E869120 and square1001 can obey the instruction in the note and take desired numbers of pieces of cake, print Yay!; otherwise, print :(.\n\nSample Input 1\n\n5 4\n\nSample Output 1\n\nYay!\n\nBoth of them can take desired number of pieces as follows:\n\nSample Input 2\n\n8 8\n\nSample Output 2\n\nYay!\n\nBoth of them can take desired number of pieces as follows:\n\nSample Input 3\n\n11 4\n\nSample Output 3\n\n:(\n\nIn this case, there is no way for them to take desired number of pieces, unfortunately.", "sample_input": "5 4\n"}, "reference_outputs": ["Yay!\n"], "source_document_id": "p03323", "source_text": "Score: 100 points\n\nProblem Statement\n\nE869120's and square1001's 16-th birthday is coming soon.\n\nTakahashi from AtCoder Kingdom gave them a round cake cut into 16 equal fan-shaped pieces.\n\nE869120 and square1001 were just about to eat A and B of those pieces, respectively,\n\nwhen they found a note attached to the cake saying that \"the same person should not take two adjacent pieces of cake\".\n\nCan both of them obey the instruction in the note and take desired numbers of pieces of cake?\n\nConstraints\n\nA and B are integers between 1 and 16 (inclusive).\n\nA+B is at most 16.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nIf both E869120 and square1001 can obey the instruction in the note and take desired numbers of pieces of cake, print Yay!; otherwise, print :(.\n\nSample Input 1\n\n5 4\n\nSample Output 1\n\nYay!\n\nBoth of them can take desired number of pieces as follows:\n\nSample Input 2\n\n8 8\n\nSample Output 2\n\nYay!\n\nBoth of them can take desired number of pieces as follows:\n\nSample Input 3\n\n11 4\n\nSample Output 3\n\n:(\n\nIn this case, there is no way for them to take desired number of pieces, unfortunately.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 77, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s771217593", "group_id": "codeNet:p03323", "input_text": "a,b=io.read():match(\"(.+)%s(.+)\")\nprint(a*1<9 and b*1<9 and\"Yay!\"or\":(\")", "language": "Lua", "metadata": {"date": 1551991993, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03323.html", "problem_id": "p03323", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03323/input.txt", "sample_output_relpath": "derived/input_output/data/p03323/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03323/Lua/s771217593.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s771217593", "user_id": "u837412668"}, "prompt_components": {"gold_output": "Yay!\n", "input_to_evaluate": "a,b=io.read():match(\"(.+)%s(.+)\")\nprint(a*1<9 and b*1<9 and\"Yay!\"or\":(\")", "problem_context": "Score: 100 points\n\nProblem Statement\n\nE869120's and square1001's 16-th birthday is coming soon.\n\nTakahashi from AtCoder Kingdom gave them a round cake cut into 16 equal fan-shaped pieces.\n\nE869120 and square1001 were just about to eat A and B of those pieces, respectively,\n\nwhen they found a note attached to the cake saying that \"the same person should not take two adjacent pieces of cake\".\n\nCan both of them obey the instruction in the note and take desired numbers of pieces of cake?\n\nConstraints\n\nA and B are integers between 1 and 16 (inclusive).\n\nA+B is at most 16.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nIf both E869120 and square1001 can obey the instruction in the note and take desired numbers of pieces of cake, print Yay!; otherwise, print :(.\n\nSample Input 1\n\n5 4\n\nSample Output 1\n\nYay!\n\nBoth of them can take desired number of pieces as follows:\n\nSample Input 2\n\n8 8\n\nSample Output 2\n\nYay!\n\nBoth of them can take desired number of pieces as follows:\n\nSample Input 3\n\n11 4\n\nSample Output 3\n\n:(\n\nIn this case, there is no way for them to take desired number of pieces, unfortunately.", "sample_input": "5 4\n"}, "reference_outputs": ["Yay!\n"], "source_document_id": "p03323", "source_text": "Score: 100 points\n\nProblem Statement\n\nE869120's and square1001's 16-th birthday is coming soon.\n\nTakahashi from AtCoder Kingdom gave them a round cake cut into 16 equal fan-shaped pieces.\n\nE869120 and square1001 were just about to eat A and B of those pieces, respectively,\n\nwhen they found a note attached to the cake saying that \"the same person should not take two adjacent pieces of cake\".\n\nCan both of them obey the instruction in the note and take desired numbers of pieces of cake?\n\nConstraints\n\nA and B are integers between 1 and 16 (inclusive).\n\nA+B is at most 16.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nIf both E869120 and square1001 can obey the instruction in the note and take desired numbers of pieces of cake, print Yay!; otherwise, print :(.\n\nSample Input 1\n\n5 4\n\nSample Output 1\n\nYay!\n\nBoth of them can take desired number of pieces as follows:\n\nSample Input 2\n\n8 8\n\nSample Output 2\n\nYay!\n\nBoth of them can take desired number of pieces as follows:\n\nSample Input 3\n\n11 4\n\nSample Output 3\n\n:(\n\nIn this case, there is no way for them to take desired number of pieces, unfortunately.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 72, "cpu_time_ms": 8, "memory_kb": 760}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s405476228", "group_id": "codeNet:p03325", "input_text": "n=io.read(\"*n\",\"*l\")\ncounter=0\nfor i=1,n do\n x=io.read(\"*n\")\n while x%2==0 do\n x=x//2\n counter=counter+1\n end\nend\nprint(counter)", "language": "Lua", "metadata": {"date": 1588035314, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03325.html", "problem_id": "p03325", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03325/input.txt", "sample_output_relpath": "derived/input_output/data/p03325/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03325/Lua/s405476228.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s405476228", "user_id": "u045238009"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "n=io.read(\"*n\",\"*l\")\ncounter=0\nfor i=1,n do\n x=io.read(\"*n\")\n while x%2==0 do\n x=x//2\n counter=counter+1\n end\nend\nprint(counter)", "problem_context": "Score: 300 points\n\nProblem Statement\n\nAs AtCoder Beginner Contest 100 is taking place, the office of AtCoder, Inc. is decorated with a sequence of length N, a = {a_1, a_2, a_3, ..., a_N}.\n\nSnuke, an employee, would like to play with this sequence.\n\nSpecifically, he would like to repeat the following operation as many times as possible:\n\nFor every i satisfying 1 \\leq i \\leq N, perform one of the following: \"divide a_i by 2\" and \"multiply a_i by 3\".\nHere, choosing \"multiply a_i by 3\" for every i is not allowed, and the value of a_i after the operation must be an integer.\n\nAt most how many operations can be performed?\n\nConstraints\n\nN is an integer between 1 and 10 \\ 000 (inclusive).\n\na_i is an integer between 1 and 1 \\ 000 \\ 000 \\ 000 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 a_3 ... a_N\n\nOutput\n\nPrint the maximum number of operations that Snuke can perform.\n\nSample Input 1\n\n3\n5 2 4\n\nSample Output 1\n\n3\n\nThe sequence is initially {5, 2, 4}. Three operations can be performed as follows:\n\nFirst, multiply a_1 by 3, multiply a_2 by 3 and divide a_3 by 2. The sequence is now {15, 6, 2}.\n\nNext, multiply a_1 by 3, divide a_2 by 2 and multiply a_3 by 3. The sequence is now {45, 3, 6}.\n\nFinally, multiply a_1 by 3, multiply a_2 by 3 and divide a_3 by 2. The sequence is now {135, 9, 3}.\n\nSample Input 2\n\n4\n631 577 243 199\n\nSample Output 2\n\n0\n\nNo operation can be performed since all the elements are odd. Thus, the answer is 0.\n\nSample Input 3\n\n10\n2184 2126 1721 1800 1024 2528 3360 1945 1280 1776\n\nSample Output 3\n\n39", "sample_input": "3\n5 2 4\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03325", "source_text": "Score: 300 points\n\nProblem Statement\n\nAs AtCoder Beginner Contest 100 is taking place, the office of AtCoder, Inc. is decorated with a sequence of length N, a = {a_1, a_2, a_3, ..., a_N}.\n\nSnuke, an employee, would like to play with this sequence.\n\nSpecifically, he would like to repeat the following operation as many times as possible:\n\nFor every i satisfying 1 \\leq i \\leq N, perform one of the following: \"divide a_i by 2\" and \"multiply a_i by 3\".\nHere, choosing \"multiply a_i by 3\" for every i is not allowed, and the value of a_i after the operation must be an integer.\n\nAt most how many operations can be performed?\n\nConstraints\n\nN is an integer between 1 and 10 \\ 000 (inclusive).\n\na_i is an integer between 1 and 1 \\ 000 \\ 000 \\ 000 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 a_3 ... a_N\n\nOutput\n\nPrint the maximum number of operations that Snuke can perform.\n\nSample Input 1\n\n3\n5 2 4\n\nSample Output 1\n\n3\n\nThe sequence is initially {5, 2, 4}. Three operations can be performed as follows:\n\nFirst, multiply a_1 by 3, multiply a_2 by 3 and divide a_3 by 2. The sequence is now {15, 6, 2}.\n\nNext, multiply a_1 by 3, divide a_2 by 2 and multiply a_3 by 3. The sequence is now {45, 3, 6}.\n\nFinally, multiply a_1 by 3, multiply a_2 by 3 and divide a_3 by 2. The sequence is now {135, 9, 3}.\n\nSample Input 2\n\n4\n631 577 243 199\n\nSample Output 2\n\n0\n\nNo operation can be performed since all the elements are odd. Thus, the answer is 0.\n\nSample Input 3\n\n10\n2184 2126 1721 1800 1024 2528 3360 1945 1280 1776\n\nSample Output 3\n\n39", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 151, "cpu_time_ms": 49, "memory_kb": 256}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s453061201", "group_id": "codeNet:p03327", "input_text": "a = io.read(\"*n\")\nprint(a <= 999 and \"ABC\" or \"ABD\")\n", "language": "Lua", "metadata": {"date": 1594179122, "filename_ext": "lua", "original_language": "Lua (Lua 5.3.5)", "problem_description_relpath": "problem_descriptions/p03327.html", "problem_id": "p03327", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03327/input.txt", "sample_output_relpath": "derived/input_output/data/p03327/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03327/Lua/s453061201.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s453061201", "user_id": "u120582723"}, "prompt_components": {"gold_output": "ABC\n", "input_to_evaluate": "a = io.read(\"*n\")\nprint(a <= 999 and \"ABC\" or \"ABD\")\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nDecades have passed since the beginning of AtCoder Beginner Contest.\n\nThe contests are labeled as ABC001, ABC002, ... from the first round, but after the 999-th round ABC999, a problem occurred: how the future rounds should be labeled?\n\nIn the end, the labels for the rounds from the 1000-th to the 1998-th are decided: ABD001, ABD002, ..., ABD999.\n\nYou are given an integer N between 1 and 1998 (inclusive). Print the first three characters of the label of the N-th round of AtCoder Beginner Contest.\n\nConstraints\n\n1 \\leq N \\leq 1998\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the first three characters of the label of the N-th round of AtCoder Beginner Contest.\n\nSample Input 1\n\n999\n\nSample Output 1\n\nABC\n\nThe 999-th round of AtCoder Beginner Contest is labeled as ABC999.\n\nSample Input 2\n\n1000\n\nSample Output 2\n\nABD\n\nThe 1000-th round of AtCoder Beginner Contest is labeled as ABD001.\n\nSample Input 3\n\n1481\n\nSample Output 3\n\nABD\n\nThe 1481-th round of AtCoder Beginner Contest is labeled as ABD482.", "sample_input": "999\n"}, "reference_outputs": ["ABC\n"], "source_document_id": "p03327", "source_text": "Score : 100 points\n\nProblem Statement\n\nDecades have passed since the beginning of AtCoder Beginner Contest.\n\nThe contests are labeled as ABC001, ABC002, ... from the first round, but after the 999-th round ABC999, a problem occurred: how the future rounds should be labeled?\n\nIn the end, the labels for the rounds from the 1000-th to the 1998-th are decided: ABD001, ABD002, ..., ABD999.\n\nYou are given an integer N between 1 and 1998 (inclusive). Print the first three characters of the label of the N-th round of AtCoder Beginner Contest.\n\nConstraints\n\n1 \\leq N \\leq 1998\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the first three characters of the label of the N-th round of AtCoder Beginner Contest.\n\nSample Input 1\n\n999\n\nSample Output 1\n\nABC\n\nThe 999-th round of AtCoder Beginner Contest is labeled as ABC999.\n\nSample Input 2\n\n1000\n\nSample Output 2\n\nABD\n\nThe 1000-th round of AtCoder Beginner Contest is labeled as ABD001.\n\nSample Input 3\n\n1481\n\nSample Output 3\n\nABD\n\nThe 1481-th round of AtCoder Beginner Contest is labeled as ABD482.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 53, "cpu_time_ms": 6, "memory_kb": 2608}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s644179582", "group_id": "codeNet:p03327", "input_text": "a=io.read()*1\nprint(a>999 and\"ABD\"or\"ABC\")", "language": "Lua", "metadata": {"date": 1551991722, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03327.html", "problem_id": "p03327", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03327/input.txt", "sample_output_relpath": "derived/input_output/data/p03327/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03327/Lua/s644179582.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s644179582", "user_id": "u837412668"}, "prompt_components": {"gold_output": "ABC\n", "input_to_evaluate": "a=io.read()*1\nprint(a>999 and\"ABD\"or\"ABC\")", "problem_context": "Score : 100 points\n\nProblem Statement\n\nDecades have passed since the beginning of AtCoder Beginner Contest.\n\nThe contests are labeled as ABC001, ABC002, ... from the first round, but after the 999-th round ABC999, a problem occurred: how the future rounds should be labeled?\n\nIn the end, the labels for the rounds from the 1000-th to the 1998-th are decided: ABD001, ABD002, ..., ABD999.\n\nYou are given an integer N between 1 and 1998 (inclusive). Print the first three characters of the label of the N-th round of AtCoder Beginner Contest.\n\nConstraints\n\n1 \\leq N \\leq 1998\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the first three characters of the label of the N-th round of AtCoder Beginner Contest.\n\nSample Input 1\n\n999\n\nSample Output 1\n\nABC\n\nThe 999-th round of AtCoder Beginner Contest is labeled as ABC999.\n\nSample Input 2\n\n1000\n\nSample Output 2\n\nABD\n\nThe 1000-th round of AtCoder Beginner Contest is labeled as ABD001.\n\nSample Input 3\n\n1481\n\nSample Output 3\n\nABD\n\nThe 1481-th round of AtCoder Beginner Contest is labeled as ABD482.", "sample_input": "999\n"}, "reference_outputs": ["ABC\n"], "source_document_id": "p03327", "source_text": "Score : 100 points\n\nProblem Statement\n\nDecades have passed since the beginning of AtCoder Beginner Contest.\n\nThe contests are labeled as ABC001, ABC002, ... from the first round, but after the 999-th round ABC999, a problem occurred: how the future rounds should be labeled?\n\nIn the end, the labels for the rounds from the 1000-th to the 1998-th are decided: ABD001, ABD002, ..., ABD999.\n\nYou are given an integer N between 1 and 1998 (inclusive). Print the first three characters of the label of the N-th round of AtCoder Beginner Contest.\n\nConstraints\n\n1 \\leq N \\leq 1998\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the first three characters of the label of the N-th round of AtCoder Beginner Contest.\n\nSample Input 1\n\n999\n\nSample Output 1\n\nABC\n\nThe 999-th round of AtCoder Beginner Contest is labeled as ABC999.\n\nSample Input 2\n\n1000\n\nSample Output 2\n\nABD\n\nThe 1000-th round of AtCoder Beginner Contest is labeled as ABD001.\n\nSample Input 3\n\n1481\n\nSample Output 3\n\nABD\n\nThe 1481-th round of AtCoder Beginner Contest is labeled as ABD482.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 42, "cpu_time_ms": 8, "memory_kb": 760}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s666486305", "group_id": "codeNet:p03328", "input_text": "local a=io.read(\"n\")\nlocal b=io.read(\"n\")\nlocal s=0\nfor i=1,b-a do\n s=s+i\nend\nprint(s-b)", "language": "Lua", "metadata": {"date": 1550688793, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03328.html", "problem_id": "p03328", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03328/input.txt", "sample_output_relpath": "derived/input_output/data/p03328/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03328/Lua/s666486305.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s666486305", "user_id": "u015229643"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "local a=io.read(\"n\")\nlocal b=io.read(\"n\")\nlocal s=0\nfor i=1,b-a do\n s=s+i\nend\nprint(s-b)", "problem_context": "Score : 200 points\n\nProblem Statement\n\nIn some village, there are 999 towers that are 1,(1+2),(1+2+3),...,(1+2+3+...+999) meters high from west to east, at intervals of 1 meter.\n\nIt had been snowing for a while before it finally stopped. For some two adjacent towers located 1 meter apart, we measured the lengths of the parts of those towers that are not covered with snow, and the results are a meters for the west tower, and b meters for the east tower.\n\nAssuming that the depth of snow cover and the altitude are the same everywhere in the village, find the amount of the snow cover.\n\nAssume also that the depth of the snow cover is always at least 1 meter.\n\nConstraints\n\n1 \\leq a < b < 499500(=1+2+3+...+999)\n\nAll values in input are integers.\n\nThere is no input that contradicts the assumption.\n\nInput\n\nInput is given from Standard Input in the following format:\n\na b\n\nOutput\n\nIf the depth of the snow cover is x meters, print x as an integer.\n\nSample Input 1\n\n8 13\n\nSample Output 1\n\n2\n\nThe heights of the two towers are 10 meters and 15 meters, respectively.\nThus, we can see that the depth of the snow cover is 2 meters.\n\nSample Input 2\n\n54 65\n\nSample Output 2\n\n1", "sample_input": "8 13\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03328", "source_text": "Score : 200 points\n\nProblem Statement\n\nIn some village, there are 999 towers that are 1,(1+2),(1+2+3),...,(1+2+3+...+999) meters high from west to east, at intervals of 1 meter.\n\nIt had been snowing for a while before it finally stopped. For some two adjacent towers located 1 meter apart, we measured the lengths of the parts of those towers that are not covered with snow, and the results are a meters for the west tower, and b meters for the east tower.\n\nAssuming that the depth of snow cover and the altitude are the same everywhere in the village, find the amount of the snow cover.\n\nAssume also that the depth of the snow cover is always at least 1 meter.\n\nConstraints\n\n1 \\leq a < b < 499500(=1+2+3+...+999)\n\nAll values in input are integers.\n\nThere is no input that contradicts the assumption.\n\nInput\n\nInput is given from Standard Input in the following format:\n\na b\n\nOutput\n\nIf the depth of the snow cover is x meters, print x as an integer.\n\nSample Input 1\n\n8 13\n\nSample Output 1\n\n2\n\nThe heights of the two towers are 10 meters and 15 meters, respectively.\nThus, we can see that the depth of the snow cover is 2 meters.\n\nSample Input 2\n\n54 65\n\nSample Output 2\n\n1", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 89, "cpu_time_ms": 7, "memory_kb": 760}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s162280020", "group_id": "codeNet:p03329", "input_text": "local memo={}\nlocal function rec(x)\n if x==0 then \n return 0 \n end\n if memo[x]~=-1 then\n return memo[x]\n end\n local result=x\n local six=1\n while six<=x do\n result=math.min(result,rec(x-six)+1)\n six=six*6\n end\n local nine=1\n while nine<=x do\n result=math.min(result,rec(x-nine)+1)\n nine=nine*9\n end\n memo[x]=result\n return memo[x]\nend\n\nlocal n=io.read(\"n\")\nfor i=1,n do\n memo[i]=-1\nend\nprint(rec(n))", "language": "Lua", "metadata": {"date": 1594607901, "filename_ext": "lua", "original_language": "Lua (Lua 5.3.5)", "problem_description_relpath": "problem_descriptions/p03329.html", "problem_id": "p03329", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03329/input.txt", "sample_output_relpath": "derived/input_output/data/p03329/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03329/Lua/s162280020.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s162280020", "user_id": "u045238009"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "local memo={}\nlocal function rec(x)\n if x==0 then \n return 0 \n end\n if memo[x]~=-1 then\n return memo[x]\n end\n local result=x\n local six=1\n while six<=x do\n result=math.min(result,rec(x-six)+1)\n six=six*6\n end\n local nine=1\n while nine<=x do\n result=math.min(result,rec(x-nine)+1)\n nine=nine*9\n end\n memo[x]=result\n return memo[x]\nend\n\nlocal n=io.read(\"n\")\nfor i=1,n do\n memo[i]=-1\nend\nprint(rec(n))", "problem_context": "Score : 300 points\n\nProblem Statement\n\nTo make it difficult to withdraw money, a certain bank allows its customers to withdraw only one of the following amounts in one operation:\n\n1 yen (the currency of Japan)\n\n6 yen, 6^2(=36) yen, 6^3(=216) yen, ...\n\n9 yen, 9^2(=81) yen, 9^3(=729) yen, ...\n\nAt least how many operations are required to withdraw exactly N yen in total?\n\nIt is not allowed to re-deposit the money you withdrew.\n\nConstraints\n\n1 \\leq N \\leq 100000\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nIf at least x operations are required to withdraw exactly N yen in total, print x.\n\nSample Input 1\n\n127\n\nSample Output 1\n\n4\n\nBy withdrawing 1 yen, 9 yen, 36(=6^2) yen and 81(=9^2) yen, we can withdraw 127 yen in four operations.\n\nSample Input 2\n\n3\n\nSample Output 2\n\n3\n\nBy withdrawing 1 yen three times, we can withdraw 3 yen in three operations.\n\nSample Input 3\n\n44852\n\nSample Output 3\n\n16", "sample_input": "127\n"}, "reference_outputs": ["4\n"], "source_document_id": "p03329", "source_text": "Score : 300 points\n\nProblem Statement\n\nTo make it difficult to withdraw money, a certain bank allows its customers to withdraw only one of the following amounts in one operation:\n\n1 yen (the currency of Japan)\n\n6 yen, 6^2(=36) yen, 6^3(=216) yen, ...\n\n9 yen, 9^2(=81) yen, 9^3(=729) yen, ...\n\nAt least how many operations are required to withdraw exactly N yen in total?\n\nIt is not allowed to re-deposit the money you withdrew.\n\nConstraints\n\n1 \\leq N \\leq 100000\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nIf at least x operations are required to withdraw exactly N yen in total, print x.\n\nSample Input 1\n\n127\n\nSample Output 1\n\n4\n\nBy withdrawing 1 yen, 9 yen, 36(=6^2) yen and 81(=9^2) yen, we can withdraw 127 yen in four operations.\n\nSample Input 2\n\n3\n\nSample Output 2\n\n3\n\nBy withdrawing 1 yen three times, we can withdraw 3 yen in three operations.\n\nSample Input 3\n\n44852\n\nSample Output 3\n\n16", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 482, "cpu_time_ms": 168, "memory_kb": 21772}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s444797787", "group_id": "codeNet:p03329", "input_text": "local tgt = io.read(\"*n\")\ntgt9 = math.floor(tgt / 9)\nlocal first = true\nlocal cnttot = 0\nfor i = 0, tgt9 do\n local tmp = i\n local cnt9, val9 = 0, 0\n local mul = 9\n while(0 < tmp) do\n local a = tmp % 9\n cnt9, val9 = cnt9 + a, val9 + mul * a\n mul, tmp = mul * 9, math.floor(tmp / 9)\n end\n local rem = tgt - val9\n local cnt6, rem6 = 0, rem\n while(0 < rem6)do\n local a = rem6 % 6\n cnt6, rem6 = cnt6 + a, math.floor(rem6 / 6)\n end\n if(first) then first, cnttot = false, cnt6 + cnt9 else cnttot = math.min(cnttot, cnt6 + cnt9) end\nend\nprint(cnttot)", "language": "Lua", "metadata": {"date": 1554683051, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p03329.html", "problem_id": "p03329", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03329/input.txt", "sample_output_relpath": "derived/input_output/data/p03329/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03329/Lua/s444797787.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s444797787", "user_id": "u120582723"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "local tgt = io.read(\"*n\")\ntgt9 = math.floor(tgt / 9)\nlocal first = true\nlocal cnttot = 0\nfor i = 0, tgt9 do\n local tmp = i\n local cnt9, val9 = 0, 0\n local mul = 9\n while(0 < tmp) do\n local a = tmp % 9\n cnt9, val9 = cnt9 + a, val9 + mul * a\n mul, tmp = mul * 9, math.floor(tmp / 9)\n end\n local rem = tgt - val9\n local cnt6, rem6 = 0, rem\n while(0 < rem6)do\n local a = rem6 % 6\n cnt6, rem6 = cnt6 + a, math.floor(rem6 / 6)\n end\n if(first) then first, cnttot = false, cnt6 + cnt9 else cnttot = math.min(cnttot, cnt6 + cnt9) end\nend\nprint(cnttot)", "problem_context": "Score : 300 points\n\nProblem Statement\n\nTo make it difficult to withdraw money, a certain bank allows its customers to withdraw only one of the following amounts in one operation:\n\n1 yen (the currency of Japan)\n\n6 yen, 6^2(=36) yen, 6^3(=216) yen, ...\n\n9 yen, 9^2(=81) yen, 9^3(=729) yen, ...\n\nAt least how many operations are required to withdraw exactly N yen in total?\n\nIt is not allowed to re-deposit the money you withdrew.\n\nConstraints\n\n1 \\leq N \\leq 100000\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nIf at least x operations are required to withdraw exactly N yen in total, print x.\n\nSample Input 1\n\n127\n\nSample Output 1\n\n4\n\nBy withdrawing 1 yen, 9 yen, 36(=6^2) yen and 81(=9^2) yen, we can withdraw 127 yen in four operations.\n\nSample Input 2\n\n3\n\nSample Output 2\n\n3\n\nBy withdrawing 1 yen three times, we can withdraw 3 yen in three operations.\n\nSample Input 3\n\n44852\n\nSample Output 3\n\n16", "sample_input": "127\n"}, "reference_outputs": ["4\n"], "source_document_id": "p03329", "source_text": "Score : 300 points\n\nProblem Statement\n\nTo make it difficult to withdraw money, a certain bank allows its customers to withdraw only one of the following amounts in one operation:\n\n1 yen (the currency of Japan)\n\n6 yen, 6^2(=36) yen, 6^3(=216) yen, ...\n\n9 yen, 9^2(=81) yen, 9^3(=729) yen, ...\n\nAt least how many operations are required to withdraw exactly N yen in total?\n\nIt is not allowed to re-deposit the money you withdrew.\n\nConstraints\n\n1 \\leq N \\leq 100000\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nIf at least x operations are required to withdraw exactly N yen in total, print x.\n\nSample Input 1\n\n127\n\nSample Output 1\n\n4\n\nBy withdrawing 1 yen, 9 yen, 36(=6^2) yen and 81(=9^2) yen, we can withdraw 127 yen in four operations.\n\nSample Input 2\n\n3\n\nSample Output 2\n\n3\n\nBy withdrawing 1 yen three times, we can withdraw 3 yen in three operations.\n\nSample Input 3\n\n44852\n\nSample Output 3\n\n16", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 607, "cpu_time_ms": 2, "memory_kb": 256}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s967401145", "group_id": "codeNet:p03329", "input_text": "N=io.read(\"n\")\nt={}\nfor i=1,N do\n count=0\n k=i\n j=N-i \n while (k>0) do\n count=count+k%6\n k=k//6\n end\n while (j>0) do\n count=count+j%9\n j=j//9\n end\n t[i]=count\nend\ntable.sort(t)\nprint(t[1])", "language": "Lua", "metadata": {"date": 1550702130, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03329.html", "problem_id": "p03329", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03329/input.txt", "sample_output_relpath": "derived/input_output/data/p03329/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03329/Lua/s967401145.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s967401145", "user_id": "u015229643"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "N=io.read(\"n\")\nt={}\nfor i=1,N do\n count=0\n k=i\n j=N-i \n while (k>0) do\n count=count+k%6\n k=k//6\n end\n while (j>0) do\n count=count+j%9\n j=j//9\n end\n t[i]=count\nend\ntable.sort(t)\nprint(t[1])", "problem_context": "Score : 300 points\n\nProblem Statement\n\nTo make it difficult to withdraw money, a certain bank allows its customers to withdraw only one of the following amounts in one operation:\n\n1 yen (the currency of Japan)\n\n6 yen, 6^2(=36) yen, 6^3(=216) yen, ...\n\n9 yen, 9^2(=81) yen, 9^3(=729) yen, ...\n\nAt least how many operations are required to withdraw exactly N yen in total?\n\nIt is not allowed to re-deposit the money you withdrew.\n\nConstraints\n\n1 \\leq N \\leq 100000\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nIf at least x operations are required to withdraw exactly N yen in total, print x.\n\nSample Input 1\n\n127\n\nSample Output 1\n\n4\n\nBy withdrawing 1 yen, 9 yen, 36(=6^2) yen and 81(=9^2) yen, we can withdraw 127 yen in four operations.\n\nSample Input 2\n\n3\n\nSample Output 2\n\n3\n\nBy withdrawing 1 yen three times, we can withdraw 3 yen in three operations.\n\nSample Input 3\n\n44852\n\nSample Output 3\n\n16", "sample_input": "127\n"}, "reference_outputs": ["4\n"], "source_document_id": "p03329", "source_text": "Score : 300 points\n\nProblem Statement\n\nTo make it difficult to withdraw money, a certain bank allows its customers to withdraw only one of the following amounts in one operation:\n\n1 yen (the currency of Japan)\n\n6 yen, 6^2(=36) yen, 6^3(=216) yen, ...\n\n9 yen, 9^2(=81) yen, 9^3(=729) yen, ...\n\nAt least how many operations are required to withdraw exactly N yen in total?\n\nIt is not allowed to re-deposit the money you withdrew.\n\nConstraints\n\n1 \\leq N \\leq 100000\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nIf at least x operations are required to withdraw exactly N yen in total, print x.\n\nSample Input 1\n\n127\n\nSample Output 1\n\n4\n\nBy withdrawing 1 yen, 9 yen, 36(=6^2) yen and 81(=9^2) yen, we can withdraw 127 yen in four operations.\n\nSample Input 2\n\n3\n\nSample Output 2\n\n3\n\nBy withdrawing 1 yen three times, we can withdraw 3 yen in three operations.\n\nSample Input 3\n\n44852\n\nSample Output 3\n\n16", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 208, "cpu_time_ms": 292, "memory_kb": 2424}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s484878819", "group_id": "codeNet:p03330", "input_text": "local mmin, mfl, ior = math.min, math.floor, io.read\nlocal n, c = ior(\"*n\", \"*n\")\nlocal d = {}\nfor i = 1, c * c do\n d[i] = ior(\"*n\")\nend\nlocal diffsum = {}\nfor i = 1, 3 * c do\n diffsum[i] = 0\nend\nfor pos = 1, n * n do\n local row, col = 1 + mfl((pos - 1) / n), pos % n\n if(col == 0) then col = n end\n local md = (row + col) % 3\n local a = ior(\"*n\")\n for i_c = 1, c do\n local idx = md * c + i_c\n diffsum[idx] = diffsum[idx] + d[(a - 1) * c + i_c]\n end\nend\nlocal dfmin = diffsum[1] + diffsum[c + 2] + diffsum[2 * c + 3]\nfor i_1 = 1, c do\n for i_2 = 1, c do\n if(i_1 ~= i_2) then\n for i_3 = 1, c do\n if(i_1 ~= i_3 and i_2 ~= i_3) then\n dfmin = mmin(dfmin, diffsum[i_1] + diffsum[c + i_2] + diffsum[2 * c + i_3])\n end\n end\n end\n end\nend\nprint(dfmin)\n", "language": "Lua", "metadata": {"date": 1556105947, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p03330.html", "problem_id": "p03330", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03330/input.txt", "sample_output_relpath": "derived/input_output/data/p03330/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03330/Lua/s484878819.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s484878819", "user_id": "u120582723"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "local mmin, mfl, ior = math.min, math.floor, io.read\nlocal n, c = ior(\"*n\", \"*n\")\nlocal d = {}\nfor i = 1, c * c do\n d[i] = ior(\"*n\")\nend\nlocal diffsum = {}\nfor i = 1, 3 * c do\n diffsum[i] = 0\nend\nfor pos = 1, n * n do\n local row, col = 1 + mfl((pos - 1) / n), pos % n\n if(col == 0) then col = n end\n local md = (row + col) % 3\n local a = ior(\"*n\")\n for i_c = 1, c do\n local idx = md * c + i_c\n diffsum[idx] = diffsum[idx] + d[(a - 1) * c + i_c]\n end\nend\nlocal dfmin = diffsum[1] + diffsum[c + 2] + diffsum[2 * c + 3]\nfor i_1 = 1, c do\n for i_2 = 1, c do\n if(i_1 ~= i_2) then\n for i_3 = 1, c do\n if(i_1 ~= i_3 and i_2 ~= i_3) then\n dfmin = mmin(dfmin, diffsum[i_1] + diffsum[c + i_2] + diffsum[2 * c + i_3])\n end\n end\n end\n end\nend\nprint(dfmin)\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nThere is a grid with N rows and N columns of squares. Let (i,j) be the square at the i-th row from the top and the j-th column from the left.\n\nThese squares have to be painted in one of the C colors from Color 1 to Color C. Initially, (i,j) is painted in Color c_{i,j}.\n\nWe say the grid is a good grid when the following condition is met for all i,j,x,y satisfying 1 \\leq i,j,x,y \\leq N:\n\nIf (i+j) \\% 3=(x+y) \\% 3, the color of (i,j) and the color of (x,y) are the same.\n\nIf (i+j) \\% 3 \\neq (x+y) \\% 3, the color of (i,j) and the color of (x,y) are different.\n\nHere, X \\% Y represents X modulo Y.\n\nWe will repaint zero or more squares so that the grid will be a good grid.\n\nFor a square, the wrongness when the color of the square is X before repainting and Y after repainting, is D_{X,Y}.\n\nFind the minimum possible sum of the wrongness of all the squares.\n\nConstraints\n\n1 \\leq N \\leq 500\n\n3 \\leq C \\leq 30\n\n1 \\leq D_{i,j} \\leq 1000 (i \\neq j),D_{i,j}=0 (i=j)\n\n1 \\leq c_{i,j} \\leq C\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN C\nD_{1,1} ... D_{1,C}\n:\nD_{C,1} ... D_{C,C}\nc_{1,1} ... c_{1,N}\n:\nc_{N,1} ... c_{N,N}\n\nOutput\n\nIf the minimum possible sum of the wrongness of all the squares is x, print x.\n\nSample Input 1\n\n2 3\n0 1 1\n1 0 1\n1 4 0\n1 2\n3 3\n\nSample Output 1\n\n3\n\nRepaint (1,1) to Color 2. The wrongness of (1,1) becomes D_{1,2}=1.\n\nRepaint (1,2) to Color 3. The wrongness of (1,2) becomes D_{2,3}=1.\n\nRepaint (2,2) to Color 1. The wrongness of (2,2) becomes D_{3,1}=1.\n\nIn this case, the sum of the wrongness of all the squares is 3.\n\nNote that D_{i,j} \\neq D_{j,i} is possible.\n\nSample Input 2\n\n4 3\n0 12 71\n81 0 53\n14 92 0\n1 1 2 1\n2 1 1 2\n2 2 1 3\n1 1 2 2\n\nSample Output 2\n\n428", "sample_input": "2 3\n0 1 1\n1 0 1\n1 4 0\n1 2\n3 3\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03330", "source_text": "Score : 400 points\n\nProblem Statement\n\nThere is a grid with N rows and N columns of squares. Let (i,j) be the square at the i-th row from the top and the j-th column from the left.\n\nThese squares have to be painted in one of the C colors from Color 1 to Color C. Initially, (i,j) is painted in Color c_{i,j}.\n\nWe say the grid is a good grid when the following condition is met for all i,j,x,y satisfying 1 \\leq i,j,x,y \\leq N:\n\nIf (i+j) \\% 3=(x+y) \\% 3, the color of (i,j) and the color of (x,y) are the same.\n\nIf (i+j) \\% 3 \\neq (x+y) \\% 3, the color of (i,j) and the color of (x,y) are different.\n\nHere, X \\% Y represents X modulo Y.\n\nWe will repaint zero or more squares so that the grid will be a good grid.\n\nFor a square, the wrongness when the color of the square is X before repainting and Y after repainting, is D_{X,Y}.\n\nFind the minimum possible sum of the wrongness of all the squares.\n\nConstraints\n\n1 \\leq N \\leq 500\n\n3 \\leq C \\leq 30\n\n1 \\leq D_{i,j} \\leq 1000 (i \\neq j),D_{i,j}=0 (i=j)\n\n1 \\leq c_{i,j} \\leq C\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN C\nD_{1,1} ... D_{1,C}\n:\nD_{C,1} ... D_{C,C}\nc_{1,1} ... c_{1,N}\n:\nc_{N,1} ... c_{N,N}\n\nOutput\n\nIf the minimum possible sum of the wrongness of all the squares is x, print x.\n\nSample Input 1\n\n2 3\n0 1 1\n1 0 1\n1 4 0\n1 2\n3 3\n\nSample Output 1\n\n3\n\nRepaint (1,1) to Color 2. The wrongness of (1,1) becomes D_{1,2}=1.\n\nRepaint (1,2) to Color 3. The wrongness of (1,2) becomes D_{2,3}=1.\n\nRepaint (2,2) to Color 1. The wrongness of (2,2) becomes D_{3,1}=1.\n\nIn this case, the sum of the wrongness of all the squares is 3.\n\nNote that D_{i,j} \\neq D_{j,i} is possible.\n\nSample Input 2\n\n4 3\n0 12 71\n81 0 53\n14 92 0\n1 1 2 1\n2 1 1 2\n2 2 1 3\n1 1 2 2\n\nSample Output 2\n\n428", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 799, "cpu_time_ms": 80, "memory_kb": 384}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s636809821", "group_id": "codeNet:p03330", "input_text": "local n, c = io.read(\"*n\", \"*n\")\nlocal d = {}\nfor i = 1, c * c do\n d[i] = io.read(\"*n\")\nend\nlocal diffsum = {}\nfor i = 1, 3 * c do\n diffsum[i] = 0\nend\nfor pos = 1, n * n do\n local row, col = 1 + math.floor((pos - 1) / n), pos % n\n if(col == 0) then col = n end\n local md = (row + col) % 3\n local a = io.read(\"*n\")\n for i_c = 1, c do\n local idx = md * c + i_c\n diffsum[idx] = diffsum[idx] + d[(a - 1) * c + i_c]\n end\nend\nlocal dfmin = diffsum[1] + diffsum[c + 2] + diffsum[2 * c + 3]\nlocal mmin = math.min\nfor i_1 = 1, c do\n for i_2 = 1, c do\n if(i_1 ~= i_2) then\n for i_3 = 1, c do\n if(i_1 ~= i_3 and i_2 ~= i_3) then\n dfmin = mmin(dfmin, diffsum[i_1] + diffsum[c + i_2] + diffsum[2 * c + i_3])\n end\n end\n end\n end\nend\nprint(dfmin)\n", "language": "Lua", "metadata": {"date": 1556105802, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p03330.html", "problem_id": "p03330", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03330/input.txt", "sample_output_relpath": "derived/input_output/data/p03330/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03330/Lua/s636809821.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s636809821", "user_id": "u120582723"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "local n, c = io.read(\"*n\", \"*n\")\nlocal d = {}\nfor i = 1, c * c do\n d[i] = io.read(\"*n\")\nend\nlocal diffsum = {}\nfor i = 1, 3 * c do\n diffsum[i] = 0\nend\nfor pos = 1, n * n do\n local row, col = 1 + math.floor((pos - 1) / n), pos % n\n if(col == 0) then col = n end\n local md = (row + col) % 3\n local a = io.read(\"*n\")\n for i_c = 1, c do\n local idx = md * c + i_c\n diffsum[idx] = diffsum[idx] + d[(a - 1) * c + i_c]\n end\nend\nlocal dfmin = diffsum[1] + diffsum[c + 2] + diffsum[2 * c + 3]\nlocal mmin = math.min\nfor i_1 = 1, c do\n for i_2 = 1, c do\n if(i_1 ~= i_2) then\n for i_3 = 1, c do\n if(i_1 ~= i_3 and i_2 ~= i_3) then\n dfmin = mmin(dfmin, diffsum[i_1] + diffsum[c + i_2] + diffsum[2 * c + i_3])\n end\n end\n end\n end\nend\nprint(dfmin)\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nThere is a grid with N rows and N columns of squares. Let (i,j) be the square at the i-th row from the top and the j-th column from the left.\n\nThese squares have to be painted in one of the C colors from Color 1 to Color C. Initially, (i,j) is painted in Color c_{i,j}.\n\nWe say the grid is a good grid when the following condition is met for all i,j,x,y satisfying 1 \\leq i,j,x,y \\leq N:\n\nIf (i+j) \\% 3=(x+y) \\% 3, the color of (i,j) and the color of (x,y) are the same.\n\nIf (i+j) \\% 3 \\neq (x+y) \\% 3, the color of (i,j) and the color of (x,y) are different.\n\nHere, X \\% Y represents X modulo Y.\n\nWe will repaint zero or more squares so that the grid will be a good grid.\n\nFor a square, the wrongness when the color of the square is X before repainting and Y after repainting, is D_{X,Y}.\n\nFind the minimum possible sum of the wrongness of all the squares.\n\nConstraints\n\n1 \\leq N \\leq 500\n\n3 \\leq C \\leq 30\n\n1 \\leq D_{i,j} \\leq 1000 (i \\neq j),D_{i,j}=0 (i=j)\n\n1 \\leq c_{i,j} \\leq C\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN C\nD_{1,1} ... D_{1,C}\n:\nD_{C,1} ... D_{C,C}\nc_{1,1} ... c_{1,N}\n:\nc_{N,1} ... c_{N,N}\n\nOutput\n\nIf the minimum possible sum of the wrongness of all the squares is x, print x.\n\nSample Input 1\n\n2 3\n0 1 1\n1 0 1\n1 4 0\n1 2\n3 3\n\nSample Output 1\n\n3\n\nRepaint (1,1) to Color 2. The wrongness of (1,1) becomes D_{1,2}=1.\n\nRepaint (1,2) to Color 3. The wrongness of (1,2) becomes D_{2,3}=1.\n\nRepaint (2,2) to Color 1. The wrongness of (2,2) becomes D_{3,1}=1.\n\nIn this case, the sum of the wrongness of all the squares is 3.\n\nNote that D_{i,j} \\neq D_{j,i} is possible.\n\nSample Input 2\n\n4 3\n0 12 71\n81 0 53\n14 92 0\n1 1 2 1\n2 1 1 2\n2 2 1 3\n1 1 2 2\n\nSample Output 2\n\n428", "sample_input": "2 3\n0 1 1\n1 0 1\n1 4 0\n1 2\n3 3\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03330", "source_text": "Score : 400 points\n\nProblem Statement\n\nThere is a grid with N rows and N columns of squares. Let (i,j) be the square at the i-th row from the top and the j-th column from the left.\n\nThese squares have to be painted in one of the C colors from Color 1 to Color C. Initially, (i,j) is painted in Color c_{i,j}.\n\nWe say the grid is a good grid when the following condition is met for all i,j,x,y satisfying 1 \\leq i,j,x,y \\leq N:\n\nIf (i+j) \\% 3=(x+y) \\% 3, the color of (i,j) and the color of (x,y) are the same.\n\nIf (i+j) \\% 3 \\neq (x+y) \\% 3, the color of (i,j) and the color of (x,y) are different.\n\nHere, X \\% Y represents X modulo Y.\n\nWe will repaint zero or more squares so that the grid will be a good grid.\n\nFor a square, the wrongness when the color of the square is X before repainting and Y after repainting, is D_{X,Y}.\n\nFind the minimum possible sum of the wrongness of all the squares.\n\nConstraints\n\n1 \\leq N \\leq 500\n\n3 \\leq C \\leq 30\n\n1 \\leq D_{i,j} \\leq 1000 (i \\neq j),D_{i,j}=0 (i=j)\n\n1 \\leq c_{i,j} \\leq C\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN C\nD_{1,1} ... D_{1,C}\n:\nD_{C,1} ... D_{C,C}\nc_{1,1} ... c_{1,N}\n:\nc_{N,1} ... c_{N,N}\n\nOutput\n\nIf the minimum possible sum of the wrongness of all the squares is x, print x.\n\nSample Input 1\n\n2 3\n0 1 1\n1 0 1\n1 4 0\n1 2\n3 3\n\nSample Output 1\n\n3\n\nRepaint (1,1) to Color 2. The wrongness of (1,1) becomes D_{1,2}=1.\n\nRepaint (1,2) to Color 3. The wrongness of (1,2) becomes D_{2,3}=1.\n\nRepaint (2,2) to Color 1. The wrongness of (2,2) becomes D_{3,1}=1.\n\nIn this case, the sum of the wrongness of all the squares is 3.\n\nNote that D_{i,j} \\neq D_{j,i} is possible.\n\nSample Input 2\n\n4 3\n0 12 71\n81 0 53\n14 92 0\n1 1 2 1\n2 1 1 2\n2 2 1 3\n1 1 2 2\n\nSample Output 2\n\n428", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 787, "cpu_time_ms": 100, "memory_kb": 256}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s618985273", "group_id": "codeNet:p03331", "input_text": "local floor = math.floor\nlocal min = math.min\nlocal N = io.read(\"*n\")\n\nlocal function idiv(operand1, operand2)\n\treturn floor(operand1 / operand2)\nend\n\nlocal function sumDigits(num)\n\tlocal sum = 0\n\twhile num > 0 do\n\t\tsum = sum + num % 10\n\t\tnum = idiv(num, 10)\n\tend\n\treturn sum\nend\n\nlocal out = 100001\nfor A = 1, idiv(N, 2) do\n\tlocal B = N - A\n\tlocal sum = sumDigits(A) + sumDigits(B)\n\tout = min(out, sum)\nend\n\nprint(out)\n", "language": "Lua", "metadata": {"date": 1591553046, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03331.html", "problem_id": "p03331", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03331/input.txt", "sample_output_relpath": "derived/input_output/data/p03331/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03331/Lua/s618985273.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s618985273", "user_id": "u793881115"}, "prompt_components": {"gold_output": "6\n", "input_to_evaluate": "local floor = math.floor\nlocal min = math.min\nlocal N = io.read(\"*n\")\n\nlocal function idiv(operand1, operand2)\n\treturn floor(operand1 / operand2)\nend\n\nlocal function sumDigits(num)\n\tlocal sum = 0\n\twhile num > 0 do\n\t\tsum = sum + num % 10\n\t\tnum = idiv(num, 10)\n\tend\n\treturn sum\nend\n\nlocal out = 100001\nfor A = 1, idiv(N, 2) do\n\tlocal B = N - A\n\tlocal sum = sumDigits(A) + sumDigits(B)\n\tout = min(out, sum)\nend\n\nprint(out)\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nTakahashi has two positive integers A and B.\n\nIt is known that A plus B equals N.\nFind the minimum possible value of \"the sum of the digits of A\" plus \"the sum of the digits of B\" (in base 10).\n\nConstraints\n\n2 ≤ N ≤ 10^5\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the minimum possible value of \"the sum of the digits of A\" plus \"the sum of the digits of B\".\n\nSample Input 1\n\n15\n\nSample Output 1\n\n6\n\nWhen A=2 and B=13, the sums of their digits are 2 and 4, which minimizes the value in question.\n\nSample Input 2\n\n100000\n\nSample Output 2\n\n10", "sample_input": "15\n"}, "reference_outputs": ["6\n"], "source_document_id": "p03331", "source_text": "Score : 200 points\n\nProblem Statement\n\nTakahashi has two positive integers A and B.\n\nIt is known that A plus B equals N.\nFind the minimum possible value of \"the sum of the digits of A\" plus \"the sum of the digits of B\" (in base 10).\n\nConstraints\n\n2 ≤ N ≤ 10^5\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the minimum possible value of \"the sum of the digits of A\" plus \"the sum of the digits of B\".\n\nSample Input 1\n\n15\n\nSample Output 1\n\n6\n\nWhen A=2 and B=13, the sums of their digits are 2 and 4, which minimizes the value in question.\n\nSample Input 2\n\n100000\n\nSample Output 2\n\n10", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 420, "cpu_time_ms": 73, "memory_kb": 888}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s364353314", "group_id": "codeNet:p03332", "input_text": "local mod = 998244353\nlocal mfl = math.floor\n\nlocal function bmul(x, y)\n return (x * y) % mod\nend\n\nlocal function badd(x, y)\n return (x + y) % mod\nend\n\nlocal function bsub(x, y)\n return x < y and x - y + mod or x - y\nend\n\nlocal function modpow(src, pow)\n local res = 1\n while 0 < pow do\n if pow % 2 == 1 then\n res = bmul(res, src)\n pow = pow - 1\n end\n src = bmul(src, src)\n pow = mfl(pow / 2)\n end\n return res\nend\n\nlocal function modinv(src)\n return modpow(src, mod - 2)\nend\n\nlocal fact = {1}\nlocal invs = {1}\nlocal invfact = {1}\nfor i = 2, 300010 do\n fact[i] = bmul(fact[i - 1], i)\n invs[i] = bmul(mfl(mod / i), mod - invs[mod % i])\n invfact[i] = bmul(invfact[i - 1], invs[i])\nend\n\nlocal function getComb(n, k)\n if k == 0 or k == n then return 1 end\n return bmul(fact[n], bmul(invfact[k], invfact[n - k]))\nend\n\nlocal ret = 0\nlocal n, a, b, k = io.read(\"*n\", \"*n\", \"*n\", \"*n\")\nfor ai = 0, n do\n local acomb = getComb(n, ai)\n local rem = k - ai * a\n if rem % b == 0 and rem // b <= n then\n local bi = rem // b\n local bcomb = getComb(n, bi)\n ret = badd(ret, bmul(acomb, bcomb))\n end\nend\nprint(ret)\n", "language": "Lua", "metadata": {"date": 1589729139, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03332.html", "problem_id": "p03332", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03332/input.txt", "sample_output_relpath": "derived/input_output/data/p03332/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03332/Lua/s364353314.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s364353314", "user_id": "u120582723"}, "prompt_components": {"gold_output": "40\n", "input_to_evaluate": "local mod = 998244353\nlocal mfl = math.floor\n\nlocal function bmul(x, y)\n return (x * y) % mod\nend\n\nlocal function badd(x, y)\n return (x + y) % mod\nend\n\nlocal function bsub(x, y)\n return x < y and x - y + mod or x - y\nend\n\nlocal function modpow(src, pow)\n local res = 1\n while 0 < pow do\n if pow % 2 == 1 then\n res = bmul(res, src)\n pow = pow - 1\n end\n src = bmul(src, src)\n pow = mfl(pow / 2)\n end\n return res\nend\n\nlocal function modinv(src)\n return modpow(src, mod - 2)\nend\n\nlocal fact = {1}\nlocal invs = {1}\nlocal invfact = {1}\nfor i = 2, 300010 do\n fact[i] = bmul(fact[i - 1], i)\n invs[i] = bmul(mfl(mod / i), mod - invs[mod % i])\n invfact[i] = bmul(invfact[i - 1], invs[i])\nend\n\nlocal function getComb(n, k)\n if k == 0 or k == n then return 1 end\n return bmul(fact[n], bmul(invfact[k], invfact[n - k]))\nend\n\nlocal ret = 0\nlocal n, a, b, k = io.read(\"*n\", \"*n\", \"*n\", \"*n\")\nfor ai = 0, n do\n local acomb = getComb(n, ai)\n local rem = k - ai * a\n if rem % b == 0 and rem // b <= n then\n local bi = rem // b\n local bcomb = getComb(n, bi)\n ret = badd(ret, bmul(acomb, bcomb))\n end\nend\nprint(ret)\n", "problem_context": "Score : 700 points\n\nProblem Statement\n\nTakahashi has a tower which is divided into N layers.\nInitially, all the layers are uncolored. Takahashi is going to paint some of the layers in red, green or blue to make a beautiful tower.\nHe defines the beauty of the tower as follows:\n\nThe beauty of the tower is the sum of the scores of the N layers, where the score of a layer is A if the layer is painted red, A+B if the layer is painted green, B if the layer is painted blue, and 0 if the layer is uncolored.\n\nHere, A and B are positive integer constants given beforehand. Also note that a layer may not be painted in two or more colors.\n\nTakahashi is planning to paint the tower so that the beauty of the tower becomes exactly K.\nHow many such ways are there to paint the tower? Find the count modulo 998244353.\nTwo ways to paint the tower are considered different when there exists a layer that is painted in different colors, or a layer that is painted in some color in one of the ways and not in the other.\n\nConstraints\n\n1 ≤ N ≤ 3×10^5\n\n1 ≤ A,B ≤ 3×10^5\n\n0 ≤ K ≤ 18×10^{10}\n\nAll values in the input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN A B K\n\nOutput\n\nPrint the number of the ways to paint tiles, modulo 998244353.\n\nSample Input 1\n\n4 1 2 5\n\nSample Output 1\n\n40\n\nIn this case, a red layer worth 1 points, a green layer worth 3 points and the blue layer worth 2 points. The beauty of the tower is 5 when we have one of the following sets of painted layers:\n\n1 green, 1 blue\n\n1 red, 2 blues\n\n2 reds, 1 green\n\n3 reds, 1 blue\n\nThe total number of the ways to produce them is 40.\n\nSample Input 2\n\n2 5 6 0\n\nSample Output 2\n\n1\n\nThe beauty of the tower is 0 only when all the layers are uncolored. Thus, the answer is 1.\n\nSample Input 3\n\n90081 33447 90629 6391049189\n\nSample Output 3\n\n577742975", "sample_input": "4 1 2 5\n"}, "reference_outputs": ["40\n"], "source_document_id": "p03332", "source_text": "Score : 700 points\n\nProblem Statement\n\nTakahashi has a tower which is divided into N layers.\nInitially, all the layers are uncolored. Takahashi is going to paint some of the layers in red, green or blue to make a beautiful tower.\nHe defines the beauty of the tower as follows:\n\nThe beauty of the tower is the sum of the scores of the N layers, where the score of a layer is A if the layer is painted red, A+B if the layer is painted green, B if the layer is painted blue, and 0 if the layer is uncolored.\n\nHere, A and B are positive integer constants given beforehand. Also note that a layer may not be painted in two or more colors.\n\nTakahashi is planning to paint the tower so that the beauty of the tower becomes exactly K.\nHow many such ways are there to paint the tower? Find the count modulo 998244353.\nTwo ways to paint the tower are considered different when there exists a layer that is painted in different colors, or a layer that is painted in some color in one of the ways and not in the other.\n\nConstraints\n\n1 ≤ N ≤ 3×10^5\n\n1 ≤ A,B ≤ 3×10^5\n\n0 ≤ K ≤ 18×10^{10}\n\nAll values in the input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN A B K\n\nOutput\n\nPrint the number of the ways to paint tiles, modulo 998244353.\n\nSample Input 1\n\n4 1 2 5\n\nSample Output 1\n\n40\n\nIn this case, a red layer worth 1 points, a green layer worth 3 points and the blue layer worth 2 points. The beauty of the tower is 5 when we have one of the following sets of painted layers:\n\n1 green, 1 blue\n\n1 red, 2 blues\n\n2 reds, 1 green\n\n3 reds, 1 blue\n\nThe total number of the ways to produce them is 40.\n\nSample Input 2\n\n2 5 6 0\n\nSample Output 2\n\n1\n\nThe beauty of the tower is 0 only when all the layers are uncolored. Thus, the answer is 1.\n\nSample Input 3\n\n90081 33447 90629 6391049189\n\nSample Output 3\n\n577742975", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1144, "cpu_time_ms": 387, "memory_kb": 25584}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s217591996", "group_id": "codeNet:p03337", "input_text": "a,b=io.read():match(\"(.+)%s(.+)\")\nprint(math.floor(math.max(a*1+b*1,a*1-b*1,a*b*1)))", "language": "Lua", "metadata": {"date": 1551884939, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p03337.html", "problem_id": "p03337", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03337/input.txt", "sample_output_relpath": "derived/input_output/data/p03337/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03337/Lua/s217591996.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s217591996", "user_id": "u837412668"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "a,b=io.read():match(\"(.+)%s(.+)\")\nprint(math.floor(math.max(a*1+b*1,a*1-b*1,a*b*1)))", "problem_context": "Score : 100 points\n\nProblem Statement\n\nYou are given two integers A and B.\nFind the largest value among A+B, A-B and A \\times B.\n\nConstraints\n\n-1000 \\leq A,B \\leq 1000\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nPrint the largest value among A+B, A-B and A \\times B.\n\nSample Input 1\n\n3 1\n\nSample Output 1\n\n4\n\n3+1=4, 3-1=2 and 3 \\times 1=3. The largest among them is 4.\n\nSample Input 2\n\n4 -2\n\nSample Output 2\n\n6\n\nThe largest is 4 - (-2) = 6.\n\nSample Input 3\n\n0 0\n\nSample Output 3\n\n0", "sample_input": "3 1\n"}, "reference_outputs": ["4\n"], "source_document_id": "p03337", "source_text": "Score : 100 points\n\nProblem Statement\n\nYou are given two integers A and B.\nFind the largest value among A+B, A-B and A \\times B.\n\nConstraints\n\n-1000 \\leq A,B \\leq 1000\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nPrint the largest value among A+B, A-B and A \\times B.\n\nSample Input 1\n\n3 1\n\nSample Output 1\n\n4\n\n3+1=4, 3-1=2 and 3 \\times 1=3. The largest among them is 4.\n\nSample Input 2\n\n4 -2\n\nSample Output 2\n\n6\n\nThe largest is 4 - (-2) = 6.\n\nSample Input 3\n\n0 0\n\nSample Output 3\n\n0", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 84, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s942702088", "group_id": "codeNet:p03337", "input_text": "a,b=io.read():match(\"(.+)%s(.+)\")\nprint(math.floor(math.max(a+b,a-b,a*b)))", "language": "Lua", "metadata": {"date": 1551841518, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03337.html", "problem_id": "p03337", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03337/input.txt", "sample_output_relpath": "derived/input_output/data/p03337/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03337/Lua/s942702088.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s942702088", "user_id": "u837412668"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "a,b=io.read():match(\"(.+)%s(.+)\")\nprint(math.floor(math.max(a+b,a-b,a*b)))", "problem_context": "Score : 100 points\n\nProblem Statement\n\nYou are given two integers A and B.\nFind the largest value among A+B, A-B and A \\times B.\n\nConstraints\n\n-1000 \\leq A,B \\leq 1000\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nPrint the largest value among A+B, A-B and A \\times B.\n\nSample Input 1\n\n3 1\n\nSample Output 1\n\n4\n\n3+1=4, 3-1=2 and 3 \\times 1=3. The largest among them is 4.\n\nSample Input 2\n\n4 -2\n\nSample Output 2\n\n6\n\nThe largest is 4 - (-2) = 6.\n\nSample Input 3\n\n0 0\n\nSample Output 3\n\n0", "sample_input": "3 1\n"}, "reference_outputs": ["4\n"], "source_document_id": "p03337", "source_text": "Score : 100 points\n\nProblem Statement\n\nYou are given two integers A and B.\nFind the largest value among A+B, A-B and A \\times B.\n\nConstraints\n\n-1000 \\leq A,B \\leq 1000\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nPrint the largest value among A+B, A-B and A \\times B.\n\nSample Input 1\n\n3 1\n\nSample Output 1\n\n4\n\n3+1=4, 3-1=2 and 3 \\times 1=3. The largest among them is 4.\n\nSample Input 2\n\n4 -2\n\nSample Output 2\n\n6\n\nThe largest is 4 - (-2) = 6.\n\nSample Input 3\n\n0 0\n\nSample Output 3\n\n0", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 74, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s493050757", "group_id": "codeNet:p03338", "input_text": "n=io.read(\"*n\",\"*l\")\ns=io.read()\n\nt={}\nfor i=1,n do\n alphabet=s:sub(i,i)\n if not t[alphabet] then\n t[alphabet]={}\n end\n table.insert(t[alphabet],i)\nend\n\nmax=0\nfor i=1,n do\n counter=0\n for alphabet,_ in pairs(t) do\n if #t[alphabet]>1 then\n if t[alphabet][1]<=i and i<=t[alphabet][#t[alphabet]] then\n counter=counter+1\n end\n end\n end\n max=math.max(counter,max)\nend\nprint(max)", "language": "Lua", "metadata": {"date": 1589055500, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03338.html", "problem_id": "p03338", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03338/input.txt", "sample_output_relpath": "derived/input_output/data/p03338/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03338/Lua/s493050757.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s493050757", "user_id": "u045238009"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "n=io.read(\"*n\",\"*l\")\ns=io.read()\n\nt={}\nfor i=1,n do\n alphabet=s:sub(i,i)\n if not t[alphabet] then\n t[alphabet]={}\n end\n table.insert(t[alphabet],i)\nend\n\nmax=0\nfor i=1,n do\n counter=0\n for alphabet,_ in pairs(t) do\n if #t[alphabet]>1 then\n if t[alphabet][1]<=i and i<=t[alphabet][#t[alphabet]] then\n counter=counter+1\n end\n end\n end\n max=math.max(counter,max)\nend\nprint(max)", "problem_context": "Score : 200 points\n\nProblem Statement\n\nYou are given a string S of length N consisting of lowercase English letters.\nWe will cut this string at one position into two strings X and Y.\nHere, we would like to maximize the number of different letters contained in both X and Y.\nFind the largest possible number of different letters contained in both X and Y when we cut the string at the optimal position.\n\nConstraints\n\n2 \\leq N \\leq 100\n\n|S| = N\n\nS consists of lowercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS\n\nOutput\n\nPrint the largest possible number of different letters contained in both X and Y.\n\nSample Input 1\n\n6\naabbca\n\nSample Output 1\n\n2\n\nIf we cut the string between the third and fourth letters into X = aab and Y = bca, the letters contained in both X and Y are a and b.\nThere will never be three or more different letters contained in both X and Y, so the answer is 2.\n\nSample Input 2\n\n10\naaaaaaaaaa\n\nSample Output 2\n\n1\n\nHowever we divide S, only a will be contained in both X and Y.\n\nSample Input 3\n\n45\ntgxgdqkyjzhyputjjtllptdfxocrylqfqjynmfbfucbir\n\nSample Output 3\n\n9", "sample_input": "6\naabbca\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03338", "source_text": "Score : 200 points\n\nProblem Statement\n\nYou are given a string S of length N consisting of lowercase English letters.\nWe will cut this string at one position into two strings X and Y.\nHere, we would like to maximize the number of different letters contained in both X and Y.\nFind the largest possible number of different letters contained in both X and Y when we cut the string at the optimal position.\n\nConstraints\n\n2 \\leq N \\leq 100\n\n|S| = N\n\nS consists of lowercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS\n\nOutput\n\nPrint the largest possible number of different letters contained in both X and Y.\n\nSample Input 1\n\n6\naabbca\n\nSample Output 1\n\n2\n\nIf we cut the string between the third and fourth letters into X = aab and Y = bca, the letters contained in both X and Y are a and b.\nThere will never be three or more different letters contained in both X and Y, so the answer is 2.\n\nSample Input 2\n\n10\naaaaaaaaaa\n\nSample Output 2\n\n1\n\nHowever we divide S, only a will be contained in both X and Y.\n\nSample Input 3\n\n45\ntgxgdqkyjzhyputjjtllptdfxocrylqfqjynmfbfucbir\n\nSample Output 3\n\n9", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 455, "cpu_time_ms": 2, "memory_kb": 256}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s826839067", "group_id": "codeNet:p03338", "input_text": "function qchong(s)\n local t={}\n for i=1,#s do\n t[i]=string.sub(s,i,i)\n end\n table.sort(t)\n local i=1\n while t[i] do\n if t[i]==t[i+1] then\n table.remove(t,i)\n i=i-1\n end\n i=i+1\n end\n return t\nend\n\nS=io.read()\nres={}\nfor i=1,#S-1 do\n a=string.sub(S,1,i)\n b=string.sub(S,i+1,#S)\n a=qchong(a)\n b=qchong(b)\n local count=0\n for i=1,#a do\n for j=1,#b do\n if a[i]==b[j] then\n count=count+1\n end\n end\n end\n res[i]=count\nend\ntable.sort(res,function (a,b) return a>b end)\nprint(res[1])\n", "language": "Lua", "metadata": {"date": 1550708259, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03338.html", "problem_id": "p03338", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03338/input.txt", "sample_output_relpath": "derived/input_output/data/p03338/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03338/Lua/s826839067.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s826839067", "user_id": "u015229643"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "function qchong(s)\n local t={}\n for i=1,#s do\n t[i]=string.sub(s,i,i)\n end\n table.sort(t)\n local i=1\n while t[i] do\n if t[i]==t[i+1] then\n table.remove(t,i)\n i=i-1\n end\n i=i+1\n end\n return t\nend\n\nS=io.read()\nres={}\nfor i=1,#S-1 do\n a=string.sub(S,1,i)\n b=string.sub(S,i+1,#S)\n a=qchong(a)\n b=qchong(b)\n local count=0\n for i=1,#a do\n for j=1,#b do\n if a[i]==b[j] then\n count=count+1\n end\n end\n end\n res[i]=count\nend\ntable.sort(res,function (a,b) return a>b end)\nprint(res[1])\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nYou are given a string S of length N consisting of lowercase English letters.\nWe will cut this string at one position into two strings X and Y.\nHere, we would like to maximize the number of different letters contained in both X and Y.\nFind the largest possible number of different letters contained in both X and Y when we cut the string at the optimal position.\n\nConstraints\n\n2 \\leq N \\leq 100\n\n|S| = N\n\nS consists of lowercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS\n\nOutput\n\nPrint the largest possible number of different letters contained in both X and Y.\n\nSample Input 1\n\n6\naabbca\n\nSample Output 1\n\n2\n\nIf we cut the string between the third and fourth letters into X = aab and Y = bca, the letters contained in both X and Y are a and b.\nThere will never be three or more different letters contained in both X and Y, so the answer is 2.\n\nSample Input 2\n\n10\naaaaaaaaaa\n\nSample Output 2\n\n1\n\nHowever we divide S, only a will be contained in both X and Y.\n\nSample Input 3\n\n45\ntgxgdqkyjzhyputjjtllptdfxocrylqfqjynmfbfucbir\n\nSample Output 3\n\n9", "sample_input": "6\naabbca\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03338", "source_text": "Score : 200 points\n\nProblem Statement\n\nYou are given a string S of length N consisting of lowercase English letters.\nWe will cut this string at one position into two strings X and Y.\nHere, we would like to maximize the number of different letters contained in both X and Y.\nFind the largest possible number of different letters contained in both X and Y when we cut the string at the optimal position.\n\nConstraints\n\n2 \\leq N \\leq 100\n\n|S| = N\n\nS consists of lowercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS\n\nOutput\n\nPrint the largest possible number of different letters contained in both X and Y.\n\nSample Input 1\n\n6\naabbca\n\nSample Output 1\n\n2\n\nIf we cut the string between the third and fourth letters into X = aab and Y = bca, the letters contained in both X and Y are a and b.\nThere will never be three or more different letters contained in both X and Y, so the answer is 2.\n\nSample Input 2\n\n10\naaaaaaaaaa\n\nSample Output 2\n\n1\n\nHowever we divide S, only a will be contained in both X and Y.\n\nSample Input 3\n\n45\ntgxgdqkyjzhyputjjtllptdfxocrylqfqjynmfbfucbir\n\nSample Output 3\n\n9", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 536, "cpu_time_ms": 10, "memory_kb": 760}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s092615878", "group_id": "codeNet:p03339", "input_text": "N=io.read()\nS=io.read()\ncount=0\nfor i=2,#S do\n if string.sub(S,i,i)==\"E\" then\n count=count+1\n end\nend\nk=count\nfor i=2,#S do\n if string.sub(S,i-1,i-1)==\"W\" then\n k=k+1\n end\n if string.sub(S,i,i)==\"E\" then\n k=k-1\n end\n if k val then\n ret, retpos = tmp, l + sz - 1\n if retpos == right then break end\n if l + sz <= r then stage, l, r = 1, l + sz, r\n else break end\n else\n if sz ~= 1 then stage, l, r = stage + 1, l, l + sz - 2\n else break end\n end\n end\n return retpos + 1\nend\nSegTree.left_bound = function(self, val, left, right)\n local ret, retpos = 1, right + 1\n local stage, l, r = 1, left, right\n while true do\n local sz = self.size[stage]\n while r % sz ~= 0 or r + 1 - l < sz do\n stage = stage + 1\n sz = self.size[stage]\n end\n local tmp = self.func(ret, self.stage[stage][mfl(r / sz)])\n if tmp > val then\n ret, retpos = tmp, r - sz + 1\n if l + sz <= r then stage, l, r = 1, l, r - sz\n else break end\n else\n if sz ~= 1 then stage, l, r = stage + 1, r - sz + 2, r\n else break end\n end\n end\n return retpos - 1\nend\nSegTree.new = function(n, func, emptyvalue)\n local obj = {}\n setmetatable(obj, {__index = SegTree})\n obj:create(n, func, emptyvalue)\n return obj\nend\n\nlocal n, k, q = io.read(\"*n\", \"*n\", \"*n\")\nlocal a = {}\nlocal t = {}\nlocal rank = {}\nfor i = 1, n do\n a[i] = io.read(\"*n\")\n t[i] = i\n rank[i] = 0\nend\ntable.sort(t, function(x, y) return a[x] < a[y] end)\nfor i = 1, n do\n rank[t[i]] = i\nend\n-- availability (1 or 0) by array index\nlocal stFlag = SegTree.new(n, function(x, y) return x * y end, 0)\nfor i = 1, n do\n stFlag:setValue(i, 1, true)\nend\nstFlag:updateAll()\n-- available counts by sorted array index\nlocal stCnt = SegTree.new(n, function(x, y) return x + y end, 0)\nlocal omit = {}\nfor i = 1, n do\n stCnt:setValue(i, 1, true)\n omit[i] = false\nend\nstCnt:updateAll()\nlocal ret = a[t[q]] - a[t[1]]\n\nfor i_sorted = 1, n do\n if stCnt:getRange(i_sorted, i_sorted) == 1 then\n stCnt:setValue(i_sorted, 0)\n local idx = t[i_sorted]\n stFlag:setValue(idx, 0)\n local rb = idx == n and n or stFlag:right_bound(0, idx + 1, n)\n if rb - (idx + 1) < k then\n if idx + 1 < rb then\n for j = idx + 1, rb - 1 do\n stCnt:setValue(rank[j], 0)\n end\n end\n else\n local tmp = {}\n for j = idx + 1, rb - 1 do\n table.insert(tmp, rank[j])\n end\n table.sort(tmp)\n for j = 1, rb - idx - k do\n omit[tmp[j]] = false\n end\n for j = rb - idx - k + 1, #tmp do\n omit[tmp[j]] = true\n end\n end\n local lb = idx == 1 and 1 or stFlag:left_bound(0, 1, idx - 1)\n if idx - 1 - lb < k then\n if lb < idx - 1 then\n for j = lb + 1, idx - 1 do\n stCnt:setValue(rank[j], 0)\n end\n end\n else\n local tmp = {}\n for j = lb + 1, idx - 1 do\n table.insert(tmp, rank[j])\n end\n table.sort(tmp)\n for j = 1, idx - lb - k do\n omit[tmp[j]] = false\n end\n for j = idx - lb - k + 1, #tmp do\n omit[tmp[j]] = true\n end\n end\n local p1, p2 = nil, nil\n local c = 0\n for j = 1, n do\n if stCnt:getRange(j, j) == 1 and not omit[j] then\n c = c + 1\n if c == 1 then p1 = j end\n if c == q then p2 = j break end\n end\n end\n if not p2 then\n break\n else\n ret = mmi(ret, a[t[p2]] - a[t[p1]])\n end\n end\nend\nprint(ret)\n", "language": "Lua", "metadata": {"date": 1573741382, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p03343.html", "problem_id": "p03343", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03343/input.txt", "sample_output_relpath": "derived/input_output/data/p03343/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03343/Lua/s540159700.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s540159700", "user_id": "u120582723"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "local mfl, mce, mmi = math.floor, math.ceil, math.min\nlocal SegTree = {}\nSegTree.updateAll = function(self)\n for i = self.stagenum - 1, 1, -1 do\n for j = 1, self.cnt[i] do\n self.stage[i][j] = self.func(self.stage[i + 1][j * 2 - 1], self.stage[i + 1][j * 2])\n end\n end\nend\nSegTree.create = function(self, n, func, emptyvalue)\n self.func, self.emptyvalue = func, emptyvalue\n local stagenum, mul = 1, 1\n self.cnt, self.stage, self.size = {1}, {{}}, {}\n while mul < n do\n mul, stagenum = mul * 2, stagenum + 1\n self.cnt[stagenum], self.stage[stagenum] = mul, {}\n end\n for i = 1, stagenum do self.size[i] = self.cnt[stagenum + 1 - i] end\n self.stagenum = stagenum\n for i = 1, mul do self.stage[stagenum][i] = emptyvalue end\n self:updateAll()\nend\nSegTree.getRange = function(self, left, right)\n if left == right then return self.stage[self.stagenum][left] end\n local start_stage = 1\n while right - left + 1 < self.size[start_stage] do\n start_stage = start_stage + 1\n end\n local ret = self.emptyvalue\n local t1, t2, t3 = {start_stage}, {left}, {right}\n while 0 < #t1 do\n local stage, l, r = t1[#t1], t2[#t1], t3[#t1]\n table.remove(t1) table.remove(t2) table.remove(t3)\n local sz = self.size[stage]\n if (l - 1) % sz ~= 0 then\n local newr = mmi(r, mce((l - 1) / sz) * sz)\n table.insert(t1, stage + 1) table.insert(t2, l) table.insert(t3, newr)\n l = newr + 1\n end\n if sz <= r + 1 - l then\n ret = self.func(ret, self.stage[stage][mce(l / sz)])\n l = l + sz\n end\n if l <= r then\n table.insert(t1, stage + 1) table.insert(t2, l) table.insert(t3, r)\n end\n end\n return ret\nend\nSegTree.setValue = function(self, idx, value, silent)\n self.stage[self.stagenum][idx] = value\n if not silent then\n for i = self.stagenum - 1, 1, -1 do\n local dst = mce(idx / 2)\n local rem = dst * 4 - 1 - idx\n self.stage[i][dst] = self.func(self.stage[i + 1][idx], self.stage[i + 1][rem])\n idx = dst\n end\n end\nend\nSegTree.setRange = function(self, left, right, value)\n for idx = left, right do\n self.stage[self.stagenum][idx] = value\n end\n for i = self.stagenum - 1, 1, -1 do\n left, right = mce(left / 2), mce(right / 2)\n for j = left, right do\n self.stage[i][j] = self.func(self.stage[i + 1][j * 2 - 1], self.stage[i + 1][j * 2])\n end\n end\nend\nSegTree.lower_bound = function(self, val)\n local ret, retpos = self.emptyvalue, 0\n local stage, l, r = 1, 1, self.size[1]\n while true do\n local sz = self.size[stage]\n local tmp = self.func(ret, self.stage[stage][mce(l / sz)])\n if tmp < val then\n ret, retpos = tmp, l + sz - 1\n if l + sz <= r then stage, l = stage + 1, l + sz\n else break\n end\n else\n if sz ~= 1 then stage, r = stage + 1, l + sz - 2\n else break\n end\n end\n end\n return retpos + 1\nend\nSegTree.right_bound = function(self, val, left, right)\n local ret, retpos = 1, left - 1\n local stage, l, r = 1, left, right\n while true do\n local sz = self.size[stage]\n while (l - 1) % sz ~= 0 or r + 1 - l < sz do\n stage = stage + 1\n sz = self.size[stage]\n end\n local tmp = self.func(ret, self.stage[stage][mce(l / sz)])\n if tmp > val then\n ret, retpos = tmp, l + sz - 1\n if retpos == right then break end\n if l + sz <= r then stage, l, r = 1, l + sz, r\n else break end\n else\n if sz ~= 1 then stage, l, r = stage + 1, l, l + sz - 2\n else break end\n end\n end\n return retpos + 1\nend\nSegTree.left_bound = function(self, val, left, right)\n local ret, retpos = 1, right + 1\n local stage, l, r = 1, left, right\n while true do\n local sz = self.size[stage]\n while r % sz ~= 0 or r + 1 - l < sz do\n stage = stage + 1\n sz = self.size[stage]\n end\n local tmp = self.func(ret, self.stage[stage][mfl(r / sz)])\n if tmp > val then\n ret, retpos = tmp, r - sz + 1\n if l + sz <= r then stage, l, r = 1, l, r - sz\n else break end\n else\n if sz ~= 1 then stage, l, r = stage + 1, r - sz + 2, r\n else break end\n end\n end\n return retpos - 1\nend\nSegTree.new = function(n, func, emptyvalue)\n local obj = {}\n setmetatable(obj, {__index = SegTree})\n obj:create(n, func, emptyvalue)\n return obj\nend\n\nlocal n, k, q = io.read(\"*n\", \"*n\", \"*n\")\nlocal a = {}\nlocal t = {}\nlocal rank = {}\nfor i = 1, n do\n a[i] = io.read(\"*n\")\n t[i] = i\n rank[i] = 0\nend\ntable.sort(t, function(x, y) return a[x] < a[y] end)\nfor i = 1, n do\n rank[t[i]] = i\nend\n-- availability (1 or 0) by array index\nlocal stFlag = SegTree.new(n, function(x, y) return x * y end, 0)\nfor i = 1, n do\n stFlag:setValue(i, 1, true)\nend\nstFlag:updateAll()\n-- available counts by sorted array index\nlocal stCnt = SegTree.new(n, function(x, y) return x + y end, 0)\nlocal omit = {}\nfor i = 1, n do\n stCnt:setValue(i, 1, true)\n omit[i] = false\nend\nstCnt:updateAll()\nlocal ret = a[t[q]] - a[t[1]]\n\nfor i_sorted = 1, n do\n if stCnt:getRange(i_sorted, i_sorted) == 1 then\n stCnt:setValue(i_sorted, 0)\n local idx = t[i_sorted]\n stFlag:setValue(idx, 0)\n local rb = idx == n and n or stFlag:right_bound(0, idx + 1, n)\n if rb - (idx + 1) < k then\n if idx + 1 < rb then\n for j = idx + 1, rb - 1 do\n stCnt:setValue(rank[j], 0)\n end\n end\n else\n local tmp = {}\n for j = idx + 1, rb - 1 do\n table.insert(tmp, rank[j])\n end\n table.sort(tmp)\n for j = 1, rb - idx - k do\n omit[tmp[j]] = false\n end\n for j = rb - idx - k + 1, #tmp do\n omit[tmp[j]] = true\n end\n end\n local lb = idx == 1 and 1 or stFlag:left_bound(0, 1, idx - 1)\n if idx - 1 - lb < k then\n if lb < idx - 1 then\n for j = lb + 1, idx - 1 do\n stCnt:setValue(rank[j], 0)\n end\n end\n else\n local tmp = {}\n for j = lb + 1, idx - 1 do\n table.insert(tmp, rank[j])\n end\n table.sort(tmp)\n for j = 1, idx - lb - k do\n omit[tmp[j]] = false\n end\n for j = idx - lb - k + 1, #tmp do\n omit[tmp[j]] = true\n end\n end\n local p1, p2 = nil, nil\n local c = 0\n for j = 1, n do\n if stCnt:getRange(j, j) == 1 and not omit[j] then\n c = c + 1\n if c == 1 then p1 = j end\n if c == q then p2 = j break end\n end\n end\n if not p2 then\n break\n else\n ret = mmi(ret, a[t[p2]] - a[t[p1]])\n end\n end\nend\nprint(ret)\n", "problem_context": "Score : 600 points\n\nProblem Statement\n\nYou are given an integer sequence A of length N and an integer K.\nYou will perform the following operation on this sequence Q times:\n\nChoose a contiguous subsequence of length K, then remove the smallest element among the K elements contained in the chosen subsequence (if there are multiple such elements, choose one of them as you like).\n\nLet X and Y be the values of the largest and smallest element removed in the Q operations. You would like X-Y to be as small as possible.\nFind the smallest possible value of X-Y when the Q operations are performed optimally.\n\nConstraints\n\n1 \\leq N \\leq 2000\n\n1 \\leq K \\leq N\n\n1 \\leq Q \\leq N-K+1\n\n1 \\leq A_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K Q\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the smallest possible value of X-Y.\n\nSample Input 1\n\n5 3 2\n4 3 1 5 2\n\nSample Output 1\n\n1\n\nIn the first operation, whichever contiguous subsequence of length 3 we choose, the minimum element in it is 1.\nThus, the first operation removes A_3=1 and now we have A=(4,3,5,2).\nIn the second operation, it is optimal to choose (A_2,A_3,A_4)=(3,5,2) as the contiguous subsequence of length 3 and remove A_4=2.\nIn this case, the largest element removed is 2, and the smallest is 1, so their difference is 2-1=1.\n\nSample Input 2\n\n10 1 6\n1 1 2 3 5 8 13 21 34 55\n\nSample Output 2\n\n7\n\nSample Input 3\n\n11 7 5\n24979445 861648772 623690081 433933447 476190629 262703497 211047202 971407775 628894325 731963982 822804784\n\nSample Output 3\n\n451211184", "sample_input": "5 3 2\n4 3 1 5 2\n"}, "reference_outputs": ["1\n"], "source_document_id": "p03343", "source_text": "Score : 600 points\n\nProblem Statement\n\nYou are given an integer sequence A of length N and an integer K.\nYou will perform the following operation on this sequence Q times:\n\nChoose a contiguous subsequence of length K, then remove the smallest element among the K elements contained in the chosen subsequence (if there are multiple such elements, choose one of them as you like).\n\nLet X and Y be the values of the largest and smallest element removed in the Q operations. You would like X-Y to be as small as possible.\nFind the smallest possible value of X-Y when the Q operations are performed optimally.\n\nConstraints\n\n1 \\leq N \\leq 2000\n\n1 \\leq K \\leq N\n\n1 \\leq Q \\leq N-K+1\n\n1 \\leq A_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K Q\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the smallest possible value of X-Y.\n\nSample Input 1\n\n5 3 2\n4 3 1 5 2\n\nSample Output 1\n\n1\n\nIn the first operation, whichever contiguous subsequence of length 3 we choose, the minimum element in it is 1.\nThus, the first operation removes A_3=1 and now we have A=(4,3,5,2).\nIn the second operation, it is optimal to choose (A_2,A_3,A_4)=(3,5,2) as the contiguous subsequence of length 3 and remove A_4=2.\nIn this case, the largest element removed is 2, and the smallest is 1, so their difference is 2-1=1.\n\nSample Input 2\n\n10 1 6\n1 1 2 3 5 8 13 21 34 55\n\nSample Output 2\n\n7\n\nSample Input 3\n\n11 7 5\n24979445 861648772 623690081 433933447 476190629 262703497 211047202 971407775 628894325 731963982 822804784\n\nSample Output 3\n\n451211184", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 6427, "cpu_time_ms": 351, "memory_kb": 1312}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s414297241", "group_id": "codeNet:p03343", "input_text": "local mfl, mce, mmi = math.floor, math.ceil, math.min\nlocal SegTree = {}\nSegTree.updateAll = function(self)\n for i = self.stagenum - 1, 1, -1 do\n for j = 1, self.cnt[i] do\n self.stage[i][j] = self.func(self.stage[i + 1][j * 2 - 1], self.stage[i + 1][j * 2])\n end\n end\nend\nSegTree.create = function(self, n, func, emptyvalue)\n self.func, self.emptyvalue = func, emptyvalue\n local stagenum, mul = 1, 1\n self.cnt, self.stage, self.size = {1}, {{}}, {}\n while mul < n do\n mul, stagenum = mul * 2, stagenum + 1\n self.cnt[stagenum], self.stage[stagenum] = mul, {}\n end\n for i = 1, stagenum do self.size[i] = self.cnt[stagenum + 1 - i] end\n self.stagenum = stagenum\n for i = 1, mul do self.stage[stagenum][i] = emptyvalue end\n self:updateAll()\nend\nSegTree.getRange = function(self, left, right)\n if left == right then return self.stage[self.stagenum][left] end\n local start_stage = 1\n while right - left + 1 < self.size[start_stage] do\n start_stage = start_stage + 1\n end\n local ret = self.emptyvalue\n local t1, t2, t3 = {start_stage}, {left}, {right}\n while 0 < #t1 do\n local stage, l, r = t1[#t1], t2[#t1], t3[#t1]\n table.remove(t1) table.remove(t2) table.remove(t3)\n local sz = self.size[stage]\n if (l - 1) % sz ~= 0 then\n local newr = mmi(r, mce((l - 1) / sz) * sz)\n table.insert(t1, stage + 1) table.insert(t2, l) table.insert(t3, newr)\n l = newr + 1\n end\n if sz <= r + 1 - l then\n ret = self.func(ret, self.stage[stage][mce(l / sz)])\n l = l + sz\n end\n if l <= r then\n table.insert(t1, stage + 1) table.insert(t2, l) table.insert(t3, r)\n end\n end\n return ret\nend\nSegTree.setValue = function(self, idx, value, silent)\n self.stage[self.stagenum][idx] = value\n if not silent then\n for i = self.stagenum - 1, 1, -1 do\n local dst = mce(idx / 2)\n local rem = dst * 4 - 1 - idx\n self.stage[i][dst] = self.func(self.stage[i + 1][idx], self.stage[i + 1][rem])\n idx = dst\n end\n end\nend\nSegTree.setRange = function(self, left, right, value)\n for idx = left, right do\n self.stage[self.stagenum][idx] = value\n end\n for i = self.stagenum - 1, 1, -1 do\n left, right = mce(left / 2), mce(right / 2)\n for j = left, right do\n self.stage[i][j] = self.func(self.stage[i + 1][j * 2 - 1], self.stage[i + 1][j * 2])\n end\n end\nend\nSegTree.lower_bound = function(self, val)\n local ret, retpos = self.emptyvalue, 0\n local stage, l, r = 1, 1, self.size[1]\n while true do\n local sz = self.size[stage]\n local tmp = self.func(ret, self.stage[stage][mce(l / sz)])\n if tmp < val then\n ret, retpos = tmp, l + sz - 1\n if l + sz <= r then stage, l = stage + 1, l + sz\n else break\n end\n else\n if sz ~= 1 then stage, r = stage + 1, l + sz - 2\n else break\n end\n end\n end\n return retpos + 1\nend\nSegTree.right_bound = function(self, val, left, right)\n local ret, retpos = self.emptyvalue, left - 1\n local t1, t2, t3 = {1}, {left}, {right}\n while 0 < #t1 do\n local stage, l, r = t1[#t1], t2[#t1], t3[#t1]\n table.remove(t1) table.remove(t2) table.remove(t3)\n local sz = self.size[stage]\n while (l - 1) % sz ~= 0 or r + 1 - l < sz do\n stage = stage + 1\n sz = self.size[stage]\n end\n local tmp = self.func(ret, self.stage[stage][mce(l / sz)])\n if tmp > val then\n ret, retpos = tmp, l + sz - 1\n if retpos == right then break end\n if l + sz <= r then table.insert(t1, 1) table.insert(t2, l + sz) table.insert(t3, r) end\n else\n if sz ~= 1 then table.insert(t1, stage + 1) table.insert(t2, l) table.insert(t3, l + sz - 2) end\n end\n end\n return retpos + 1\nend\nSegTree.left_bound = function(self, val, left, right)\n local ret, retpos = self.emptyvalue, right + 1\n local t1, t2, t3 = {1}, {left}, {right}\n while 0 < #t1 do\n local stage, l, r = t1[#t1], t2[#t1], t3[#t1]\n table.remove(t1) table.remove(t2) table.remove(t3)\n local sz = self.size[stage]\n while r % sz ~= 0 or r + 1 - l < sz do\n stage = stage + 1\n sz = self.size[stage]\n end\n local tmp = self.func(ret, self.stage[stage][mfl(r / sz)])\n if tmp > val then\n ret, retpos = tmp, r - sz + 1\n if l + sz <= r then table.insert(t1, 1) table.insert(t2, l) table.insert(t3, r - sz) end\n else\n if sz ~= 1 then table.insert(t1, stage + 1) table.insert(t2, r - sz + 2) table.insert(t3, r) end\n end\n end\n return retpos - 1\nend\nSegTree.new = function(n, func, emptyvalue)\n local obj = {}\n setmetatable(obj, {__index = SegTree})\n obj:create(n, func, emptyvalue)\n return obj\nend\n\nlocal n, k, q = io.read(\"*n\", \"*n\", \"*n\")\nlocal a = {}\nlocal t = {}\nlocal rank = {}\nfor i = 1, n do\n a[i] = io.read(\"*n\")\n t[i] = i\n rank[i] = 0\nend\ntable.sort(t, function(x, y) return a[x] < a[y] end)\nfor i = 1, n do\n rank[t[i]] = i\nend\n-- availability (1 or 0) by array index\nlocal stFlag = SegTree.new(n, function(x, y) return x * y end, 1)\nfor i = 1, n do\n stFlag:setValue(i, 1, true)\nend\nstFlag:updateAll()\n-- available counts by sorted array index\nlocal stCnt = SegTree.new(n, function(x, y) return x + y end, 0)\nfor i = 1, n do\n stCnt:setValue(i, 1, true)\nend\nstCnt:updateAll()\nlocal ret = a[t[q]] - a[t[1]]\n\nfor i_sorted = 1, n do\n if stCnt:getRange(i_sorted, i_sorted) == 1 then\n stCnt:setValue(i_sorted, 0)\n local idx = t[i_sorted]\n stFlag:setValue(idx, 0)\n local rb = idx == n and n or stFlag:right_bound(0, idx + 1, n)\n if rb - (idx + 1) < k then\n if idx + 1 < rb then\n stFlag:setRange(idx + 1, rb - 1, 0)\n for j = idx + 1, rb - 1 do\n stCnt:setValue(rank[j], 0)\n end\n end\n end\n local lb = idx == 1 and 1 or stFlag:left_bound(0, 1, idx - 1)\n if idx - 1 - lb < k then\n if lb < idx - 1 then\n stFlag:setRange(lb + 1, idx - 1, 0)\n for j = lb + 1, idx - 1 do\n stCnt:setValue(rank[j], 0)\n end\n end\n end\n local p1, p2 = stCnt:lower_bound(1), stCnt:lower_bound(q)\n if n < p2 then\n break\n else\n ret = mmi(ret, a[t[p2]] - a[t[p1]])\n end\n end\nend\nprint(ret)\n", "language": "Lua", "metadata": {"date": 1573707696, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p03343.html", "problem_id": "p03343", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03343/input.txt", "sample_output_relpath": "derived/input_output/data/p03343/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03343/Lua/s414297241.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s414297241", "user_id": "u120582723"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "local mfl, mce, mmi = math.floor, math.ceil, math.min\nlocal SegTree = {}\nSegTree.updateAll = function(self)\n for i = self.stagenum - 1, 1, -1 do\n for j = 1, self.cnt[i] do\n self.stage[i][j] = self.func(self.stage[i + 1][j * 2 - 1], self.stage[i + 1][j * 2])\n end\n end\nend\nSegTree.create = function(self, n, func, emptyvalue)\n self.func, self.emptyvalue = func, emptyvalue\n local stagenum, mul = 1, 1\n self.cnt, self.stage, self.size = {1}, {{}}, {}\n while mul < n do\n mul, stagenum = mul * 2, stagenum + 1\n self.cnt[stagenum], self.stage[stagenum] = mul, {}\n end\n for i = 1, stagenum do self.size[i] = self.cnt[stagenum + 1 - i] end\n self.stagenum = stagenum\n for i = 1, mul do self.stage[stagenum][i] = emptyvalue end\n self:updateAll()\nend\nSegTree.getRange = function(self, left, right)\n if left == right then return self.stage[self.stagenum][left] end\n local start_stage = 1\n while right - left + 1 < self.size[start_stage] do\n start_stage = start_stage + 1\n end\n local ret = self.emptyvalue\n local t1, t2, t3 = {start_stage}, {left}, {right}\n while 0 < #t1 do\n local stage, l, r = t1[#t1], t2[#t1], t3[#t1]\n table.remove(t1) table.remove(t2) table.remove(t3)\n local sz = self.size[stage]\n if (l - 1) % sz ~= 0 then\n local newr = mmi(r, mce((l - 1) / sz) * sz)\n table.insert(t1, stage + 1) table.insert(t2, l) table.insert(t3, newr)\n l = newr + 1\n end\n if sz <= r + 1 - l then\n ret = self.func(ret, self.stage[stage][mce(l / sz)])\n l = l + sz\n end\n if l <= r then\n table.insert(t1, stage + 1) table.insert(t2, l) table.insert(t3, r)\n end\n end\n return ret\nend\nSegTree.setValue = function(self, idx, value, silent)\n self.stage[self.stagenum][idx] = value\n if not silent then\n for i = self.stagenum - 1, 1, -1 do\n local dst = mce(idx / 2)\n local rem = dst * 4 - 1 - idx\n self.stage[i][dst] = self.func(self.stage[i + 1][idx], self.stage[i + 1][rem])\n idx = dst\n end\n end\nend\nSegTree.setRange = function(self, left, right, value)\n for idx = left, right do\n self.stage[self.stagenum][idx] = value\n end\n for i = self.stagenum - 1, 1, -1 do\n left, right = mce(left / 2), mce(right / 2)\n for j = left, right do\n self.stage[i][j] = self.func(self.stage[i + 1][j * 2 - 1], self.stage[i + 1][j * 2])\n end\n end\nend\nSegTree.lower_bound = function(self, val)\n local ret, retpos = self.emptyvalue, 0\n local stage, l, r = 1, 1, self.size[1]\n while true do\n local sz = self.size[stage]\n local tmp = self.func(ret, self.stage[stage][mce(l / sz)])\n if tmp < val then\n ret, retpos = tmp, l + sz - 1\n if l + sz <= r then stage, l = stage + 1, l + sz\n else break\n end\n else\n if sz ~= 1 then stage, r = stage + 1, l + sz - 2\n else break\n end\n end\n end\n return retpos + 1\nend\nSegTree.right_bound = function(self, val, left, right)\n local ret, retpos = self.emptyvalue, left - 1\n local t1, t2, t3 = {1}, {left}, {right}\n while 0 < #t1 do\n local stage, l, r = t1[#t1], t2[#t1], t3[#t1]\n table.remove(t1) table.remove(t2) table.remove(t3)\n local sz = self.size[stage]\n while (l - 1) % sz ~= 0 or r + 1 - l < sz do\n stage = stage + 1\n sz = self.size[stage]\n end\n local tmp = self.func(ret, self.stage[stage][mce(l / sz)])\n if tmp > val then\n ret, retpos = tmp, l + sz - 1\n if retpos == right then break end\n if l + sz <= r then table.insert(t1, 1) table.insert(t2, l + sz) table.insert(t3, r) end\n else\n if sz ~= 1 then table.insert(t1, stage + 1) table.insert(t2, l) table.insert(t3, l + sz - 2) end\n end\n end\n return retpos + 1\nend\nSegTree.left_bound = function(self, val, left, right)\n local ret, retpos = self.emptyvalue, right + 1\n local t1, t2, t3 = {1}, {left}, {right}\n while 0 < #t1 do\n local stage, l, r = t1[#t1], t2[#t1], t3[#t1]\n table.remove(t1) table.remove(t2) table.remove(t3)\n local sz = self.size[stage]\n while r % sz ~= 0 or r + 1 - l < sz do\n stage = stage + 1\n sz = self.size[stage]\n end\n local tmp = self.func(ret, self.stage[stage][mfl(r / sz)])\n if tmp > val then\n ret, retpos = tmp, r - sz + 1\n if l + sz <= r then table.insert(t1, 1) table.insert(t2, l) table.insert(t3, r - sz) end\n else\n if sz ~= 1 then table.insert(t1, stage + 1) table.insert(t2, r - sz + 2) table.insert(t3, r) end\n end\n end\n return retpos - 1\nend\nSegTree.new = function(n, func, emptyvalue)\n local obj = {}\n setmetatable(obj, {__index = SegTree})\n obj:create(n, func, emptyvalue)\n return obj\nend\n\nlocal n, k, q = io.read(\"*n\", \"*n\", \"*n\")\nlocal a = {}\nlocal t = {}\nlocal rank = {}\nfor i = 1, n do\n a[i] = io.read(\"*n\")\n t[i] = i\n rank[i] = 0\nend\ntable.sort(t, function(x, y) return a[x] < a[y] end)\nfor i = 1, n do\n rank[t[i]] = i\nend\n-- availability (1 or 0) by array index\nlocal stFlag = SegTree.new(n, function(x, y) return x * y end, 1)\nfor i = 1, n do\n stFlag:setValue(i, 1, true)\nend\nstFlag:updateAll()\n-- available counts by sorted array index\nlocal stCnt = SegTree.new(n, function(x, y) return x + y end, 0)\nfor i = 1, n do\n stCnt:setValue(i, 1, true)\nend\nstCnt:updateAll()\nlocal ret = a[t[q]] - a[t[1]]\n\nfor i_sorted = 1, n do\n if stCnt:getRange(i_sorted, i_sorted) == 1 then\n stCnt:setValue(i_sorted, 0)\n local idx = t[i_sorted]\n stFlag:setValue(idx, 0)\n local rb = idx == n and n or stFlag:right_bound(0, idx + 1, n)\n if rb - (idx + 1) < k then\n if idx + 1 < rb then\n stFlag:setRange(idx + 1, rb - 1, 0)\n for j = idx + 1, rb - 1 do\n stCnt:setValue(rank[j], 0)\n end\n end\n end\n local lb = idx == 1 and 1 or stFlag:left_bound(0, 1, idx - 1)\n if idx - 1 - lb < k then\n if lb < idx - 1 then\n stFlag:setRange(lb + 1, idx - 1, 0)\n for j = lb + 1, idx - 1 do\n stCnt:setValue(rank[j], 0)\n end\n end\n end\n local p1, p2 = stCnt:lower_bound(1), stCnt:lower_bound(q)\n if n < p2 then\n break\n else\n ret = mmi(ret, a[t[p2]] - a[t[p1]])\n end\n end\nend\nprint(ret)\n", "problem_context": "Score : 600 points\n\nProblem Statement\n\nYou are given an integer sequence A of length N and an integer K.\nYou will perform the following operation on this sequence Q times:\n\nChoose a contiguous subsequence of length K, then remove the smallest element among the K elements contained in the chosen subsequence (if there are multiple such elements, choose one of them as you like).\n\nLet X and Y be the values of the largest and smallest element removed in the Q operations. You would like X-Y to be as small as possible.\nFind the smallest possible value of X-Y when the Q operations are performed optimally.\n\nConstraints\n\n1 \\leq N \\leq 2000\n\n1 \\leq K \\leq N\n\n1 \\leq Q \\leq N-K+1\n\n1 \\leq A_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K Q\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the smallest possible value of X-Y.\n\nSample Input 1\n\n5 3 2\n4 3 1 5 2\n\nSample Output 1\n\n1\n\nIn the first operation, whichever contiguous subsequence of length 3 we choose, the minimum element in it is 1.\nThus, the first operation removes A_3=1 and now we have A=(4,3,5,2).\nIn the second operation, it is optimal to choose (A_2,A_3,A_4)=(3,5,2) as the contiguous subsequence of length 3 and remove A_4=2.\nIn this case, the largest element removed is 2, and the smallest is 1, so their difference is 2-1=1.\n\nSample Input 2\n\n10 1 6\n1 1 2 3 5 8 13 21 34 55\n\nSample Output 2\n\n7\n\nSample Input 3\n\n11 7 5\n24979445 861648772 623690081 433933447 476190629 262703497 211047202 971407775 628894325 731963982 822804784\n\nSample Output 3\n\n451211184", "sample_input": "5 3 2\n4 3 1 5 2\n"}, "reference_outputs": ["1\n"], "source_document_id": "p03343", "source_text": "Score : 600 points\n\nProblem Statement\n\nYou are given an integer sequence A of length N and an integer K.\nYou will perform the following operation on this sequence Q times:\n\nChoose a contiguous subsequence of length K, then remove the smallest element among the K elements contained in the chosen subsequence (if there are multiple such elements, choose one of them as you like).\n\nLet X and Y be the values of the largest and smallest element removed in the Q operations. You would like X-Y to be as small as possible.\nFind the smallest possible value of X-Y when the Q operations are performed optimally.\n\nConstraints\n\n1 \\leq N \\leq 2000\n\n1 \\leq K \\leq N\n\n1 \\leq Q \\leq N-K+1\n\n1 \\leq A_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K Q\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the smallest possible value of X-Y.\n\nSample Input 1\n\n5 3 2\n4 3 1 5 2\n\nSample Output 1\n\n1\n\nIn the first operation, whichever contiguous subsequence of length 3 we choose, the minimum element in it is 1.\nThus, the first operation removes A_3=1 and now we have A=(4,3,5,2).\nIn the second operation, it is optimal to choose (A_2,A_3,A_4)=(3,5,2) as the contiguous subsequence of length 3 and remove A_4=2.\nIn this case, the largest element removed is 2, and the smallest is 1, so their difference is 2-1=1.\n\nSample Input 2\n\n10 1 6\n1 1 2 3 5 8 13 21 34 55\n\nSample Output 2\n\n7\n\nSample Input 3\n\n11 7 5\n24979445 861648772 623690081 433933447 476190629 262703497 211047202 971407775 628894325 731963982 822804784\n\nSample Output 3\n\n451211184", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 6091, "cpu_time_ms": 11, "memory_kb": 896}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s063369443", "group_id": "codeNet:p03345", "input_text": "local a, b, c, k = io.read(\"*n\", \"*n\", \"*n\", \"*n\")\nret = a - b\nif k % 2 == 1 then ret = -ret end\nprint(ret)\n", "language": "Lua", "metadata": {"date": 1559525948, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03345.html", "problem_id": "p03345", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03345/input.txt", "sample_output_relpath": "derived/input_output/data/p03345/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03345/Lua/s063369443.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s063369443", "user_id": "u120582723"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "local a, b, c, k = io.read(\"*n\", \"*n\", \"*n\", \"*n\")\nret = a - b\nif k % 2 == 1 then ret = -ret end\nprint(ret)\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nTakahashi, Nakahashi and Hikuhashi have integers A, B and C, respectively.\nAfter repeating the following operation K times, find the integer Takahashi will get minus the integer Nakahashi will get:\n\nEach of them simultaneously calculate the sum of the integers that the other two people have, then replace his own integer with the result.\n\nHowever, if the absolute value of the answer exceeds 10^{18}, print Unfair instead.\n\nConstraints\n\n1 \\leq A,B,C \\leq 10^9\n\n0 \\leq K \\leq 10^{18}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C K\n\nOutput\n\nPrint the integer Takahashi will get minus the integer Nakahashi will get, after repeating the following operation K times.\nIf the absolute value of the answer exceeds 10^{18}, print Unfair instead.\n\nSample Input 1\n\n1 2 3 1\n\nSample Output 1\n\n1\n\nAfter one operation, Takahashi, Nakahashi and Hikuhashi have 5, 4 and 3, respectively. We should print 5-4=1.\n\nSample Input 2\n\n2 3 2 0\n\nSample Output 2\n\n-1\n\nSample Input 3\n\n1000000000 1000000000 1000000000 1000000000000000000\n\nSample Output 3\n\n0", "sample_input": "1 2 3 1\n"}, "reference_outputs": ["1\n"], "source_document_id": "p03345", "source_text": "Score : 300 points\n\nProblem Statement\n\nTakahashi, Nakahashi and Hikuhashi have integers A, B and C, respectively.\nAfter repeating the following operation K times, find the integer Takahashi will get minus the integer Nakahashi will get:\n\nEach of them simultaneously calculate the sum of the integers that the other two people have, then replace his own integer with the result.\n\nHowever, if the absolute value of the answer exceeds 10^{18}, print Unfair instead.\n\nConstraints\n\n1 \\leq A,B,C \\leq 10^9\n\n0 \\leq K \\leq 10^{18}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C K\n\nOutput\n\nPrint the integer Takahashi will get minus the integer Nakahashi will get, after repeating the following operation K times.\nIf the absolute value of the answer exceeds 10^{18}, print Unfair instead.\n\nSample Input 1\n\n1 2 3 1\n\nSample Output 1\n\n1\n\nAfter one operation, Takahashi, Nakahashi and Hikuhashi have 5, 4 and 3, respectively. We should print 5-4=1.\n\nSample Input 2\n\n2 3 2 0\n\nSample Output 2\n\n-1\n\nSample Input 3\n\n1000000000 1000000000 1000000000 1000000000000000000\n\nSample Output 3\n\n0", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 108, "cpu_time_ms": 7, "memory_kb": 760}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s021031854", "group_id": "codeNet:p03351", "input_text": "a, b, c, d = io.read(\"*n\", \"*n\", \"*n\", \"*n\")\nif math.abs(a - c) <= d or (math.abs(a - b) <= d and math.abs(c - b) <= d) then\n print(\"Yes\")\nelse\n print(\"No\")\nend\n", "language": "Lua", "metadata": {"date": 1552446512, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p03351.html", "problem_id": "p03351", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03351/input.txt", "sample_output_relpath": "derived/input_output/data/p03351/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03351/Lua/s021031854.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s021031854", "user_id": "u810735437"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "a, b, c, d = io.read(\"*n\", \"*n\", \"*n\", \"*n\")\nif math.abs(a - c) <= d or (math.abs(a - b) <= d and math.abs(c - b) <= d) then\n print(\"Yes\")\nelse\n print(\"No\")\nend\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nThree people, A, B and C, are trying to communicate using transceivers.\nThey are standing along a number line, and the coordinates of A, B and C are a, b and c (in meters), respectively.\nTwo people can directly communicate when the distance between them is at most d meters.\nDetermine if A and C can communicate, either directly or indirectly.\nHere, A and C can indirectly communicate when A and B can directly communicate and also B and C can directly communicate.\n\nConstraints\n\n1 ≤ a,b,c ≤ 100\n\n1 ≤ d ≤ 100\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\na b c d\n\nOutput\n\nIf A and C can communicate, print Yes; if they cannot, print No.\n\nSample Input 1\n\n4 7 9 3\n\nSample Output 1\n\nYes\n\nA and B can directly communicate, and also B and C can directly communicate, so we should print Yes.\n\nSample Input 2\n\n100 10 1 2\n\nSample Output 2\n\nNo\n\nThey cannot communicate in this case.\n\nSample Input 3\n\n10 10 10 1\n\nSample Output 3\n\nYes\n\nThere can be multiple people at the same position.\n\nSample Input 4\n\n1 100 2 10\n\nSample Output 4\n\nYes", "sample_input": "4 7 9 3\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03351", "source_text": "Score : 100 points\n\nProblem Statement\n\nThree people, A, B and C, are trying to communicate using transceivers.\nThey are standing along a number line, and the coordinates of A, B and C are a, b and c (in meters), respectively.\nTwo people can directly communicate when the distance between them is at most d meters.\nDetermine if A and C can communicate, either directly or indirectly.\nHere, A and C can indirectly communicate when A and B can directly communicate and also B and C can directly communicate.\n\nConstraints\n\n1 ≤ a,b,c ≤ 100\n\n1 ≤ d ≤ 100\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\na b c d\n\nOutput\n\nIf A and C can communicate, print Yes; if they cannot, print No.\n\nSample Input 1\n\n4 7 9 3\n\nSample Output 1\n\nYes\n\nA and B can directly communicate, and also B and C can directly communicate, so we should print Yes.\n\nSample Input 2\n\n100 10 1 2\n\nSample Output 2\n\nNo\n\nThey cannot communicate in this case.\n\nSample Input 3\n\n10 10 10 1\n\nSample Output 3\n\nYes\n\nThere can be multiple people at the same position.\n\nSample Input 4\n\n1 100 2 10\n\nSample Output 4\n\nYes", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 163, "cpu_time_ms": 2, "memory_kb": 256}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s597957648", "group_id": "codeNet:p03351", "input_text": "a,b,c,d=io.read():match(\"(.+)%s(.+)%s(.+)%s(.+)\")\nprint(math.abs(a-c)>d*1 and (math.abs(a-b)>d*1 or math.abs(b-c)>d*1)and\"No\"or\"Yes\")", "language": "Lua", "metadata": {"date": 1551841406, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03351.html", "problem_id": "p03351", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03351/input.txt", "sample_output_relpath": "derived/input_output/data/p03351/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03351/Lua/s597957648.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s597957648", "user_id": "u837412668"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "a,b,c,d=io.read():match(\"(.+)%s(.+)%s(.+)%s(.+)\")\nprint(math.abs(a-c)>d*1 and (math.abs(a-b)>d*1 or math.abs(b-c)>d*1)and\"No\"or\"Yes\")", "problem_context": "Score : 100 points\n\nProblem Statement\n\nThree people, A, B and C, are trying to communicate using transceivers.\nThey are standing along a number line, and the coordinates of A, B and C are a, b and c (in meters), respectively.\nTwo people can directly communicate when the distance between them is at most d meters.\nDetermine if A and C can communicate, either directly or indirectly.\nHere, A and C can indirectly communicate when A and B can directly communicate and also B and C can directly communicate.\n\nConstraints\n\n1 ≤ a,b,c ≤ 100\n\n1 ≤ d ≤ 100\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\na b c d\n\nOutput\n\nIf A and C can communicate, print Yes; if they cannot, print No.\n\nSample Input 1\n\n4 7 9 3\n\nSample Output 1\n\nYes\n\nA and B can directly communicate, and also B and C can directly communicate, so we should print Yes.\n\nSample Input 2\n\n100 10 1 2\n\nSample Output 2\n\nNo\n\nThey cannot communicate in this case.\n\nSample Input 3\n\n10 10 10 1\n\nSample Output 3\n\nYes\n\nThere can be multiple people at the same position.\n\nSample Input 4\n\n1 100 2 10\n\nSample Output 4\n\nYes", "sample_input": "4 7 9 3\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03351", "source_text": "Score : 100 points\n\nProblem Statement\n\nThree people, A, B and C, are trying to communicate using transceivers.\nThey are standing along a number line, and the coordinates of A, B and C are a, b and c (in meters), respectively.\nTwo people can directly communicate when the distance between them is at most d meters.\nDetermine if A and C can communicate, either directly or indirectly.\nHere, A and C can indirectly communicate when A and B can directly communicate and also B and C can directly communicate.\n\nConstraints\n\n1 ≤ a,b,c ≤ 100\n\n1 ≤ d ≤ 100\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\na b c d\n\nOutput\n\nIf A and C can communicate, print Yes; if they cannot, print No.\n\nSample Input 1\n\n4 7 9 3\n\nSample Output 1\n\nYes\n\nA and B can directly communicate, and also B and C can directly communicate, so we should print Yes.\n\nSample Input 2\n\n100 10 1 2\n\nSample Output 2\n\nNo\n\nThey cannot communicate in this case.\n\nSample Input 3\n\n10 10 10 1\n\nSample Output 3\n\nYes\n\nThere can be multiple people at the same position.\n\nSample Input 4\n\n1 100 2 10\n\nSample Output 4\n\nYes", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 133, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s658573454", "group_id": "codeNet:p03352", "input_text": "X=io.read(\"n\")\nres=0\nif X<4 then \n\tres=1\nelse\n\tk=math.floor(math.sqrt(X))\n\tfor i=2,k do\n\t\tlocal j=2\n\t\twhile math.pow(i,j)<=X do\n\t\t\tj=j+1\t\t\n\t\tend\n\t\tj=j-1\n\t\tres=math.floor(math.max(res,math.pow(i,j)))\n\tend\nend\nprint(res)\n", "language": "Lua", "metadata": {"date": 1550729626, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03352.html", "problem_id": "p03352", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03352/input.txt", "sample_output_relpath": "derived/input_output/data/p03352/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03352/Lua/s658573454.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s658573454", "user_id": "u015229643"}, "prompt_components": {"gold_output": "9\n", "input_to_evaluate": "X=io.read(\"n\")\nres=0\nif X<4 then \n\tres=1\nelse\n\tk=math.floor(math.sqrt(X))\n\tfor i=2,k do\n\t\tlocal j=2\n\t\twhile math.pow(i,j)<=X do\n\t\t\tj=j+1\t\t\n\t\tend\n\t\tj=j-1\n\t\tres=math.floor(math.max(res,math.pow(i,j)))\n\tend\nend\nprint(res)\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nYou are given a positive integer X.\nFind the largest perfect power that is at most X.\nHere, a perfect power is an integer that can be represented as b^p, where b is an integer not less than 1 and p is an integer not less than 2.\n\nConstraints\n\n1 ≤ X ≤ 1000\n\nX is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX\n\nOutput\n\nPrint the largest perfect power that is at most X.\n\nSample Input 1\n\n10\n\nSample Output 1\n\n9\n\nThere are four perfect powers that are at most 10: 1, 4, 8 and 9.\nWe should print the largest among them, 9.\n\nSample Input 2\n\n1\n\nSample Output 2\n\n1\n\nSample Input 3\n\n999\n\nSample Output 3\n\n961", "sample_input": "10\n"}, "reference_outputs": ["9\n"], "source_document_id": "p03352", "source_text": "Score : 200 points\n\nProblem Statement\n\nYou are given a positive integer X.\nFind the largest perfect power that is at most X.\nHere, a perfect power is an integer that can be represented as b^p, where b is an integer not less than 1 and p is an integer not less than 2.\n\nConstraints\n\n1 ≤ X ≤ 1000\n\nX is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX\n\nOutput\n\nPrint the largest perfect power that is at most X.\n\nSample Input 1\n\n10\n\nSample Output 1\n\n9\n\nThere are four perfect powers that are at most 10: 1, 4, 8 and 9.\nWe should print the largest among them, 9.\n\nSample Input 2\n\n1\n\nSample Output 2\n\n1\n\nSample Input 3\n\n999\n\nSample Output 3\n\n961", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 219, "cpu_time_ms": 8, "memory_kb": 760}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s279941670", "group_id": "codeNet:p03352", "input_text": "x=io.read(\"*n\")\nMax=1\nfor i=2,math.sqrt(x) do\n\ta=i*i\n\twhile a*i<=x do a=a*i end\n\tMax=math.max(Max,a)\nend\nprint(Max)", "language": "Lua", "metadata": {"date": 1526209896, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p03352.html", "problem_id": "p03352", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03352/input.txt", "sample_output_relpath": "derived/input_output/data/p03352/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03352/Lua/s279941670.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s279941670", "user_id": "u781091740"}, "prompt_components": {"gold_output": "9\n", "input_to_evaluate": "x=io.read(\"*n\")\nMax=1\nfor i=2,math.sqrt(x) do\n\ta=i*i\n\twhile a*i<=x do a=a*i end\n\tMax=math.max(Max,a)\nend\nprint(Max)", "problem_context": "Score : 200 points\n\nProblem Statement\n\nYou are given a positive integer X.\nFind the largest perfect power that is at most X.\nHere, a perfect power is an integer that can be represented as b^p, where b is an integer not less than 1 and p is an integer not less than 2.\n\nConstraints\n\n1 ≤ X ≤ 1000\n\nX is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX\n\nOutput\n\nPrint the largest perfect power that is at most X.\n\nSample Input 1\n\n10\n\nSample Output 1\n\n9\n\nThere are four perfect powers that are at most 10: 1, 4, 8 and 9.\nWe should print the largest among them, 9.\n\nSample Input 2\n\n1\n\nSample Output 2\n\n1\n\nSample Input 3\n\n999\n\nSample Output 3\n\n961", "sample_input": "10\n"}, "reference_outputs": ["9\n"], "source_document_id": "p03352", "source_text": "Score : 200 points\n\nProblem Statement\n\nYou are given a positive integer X.\nFind the largest perfect power that is at most X.\nHere, a perfect power is an integer that can be represented as b^p, where b is an integer not less than 1 and p is an integer not less than 2.\n\nConstraints\n\n1 ≤ X ≤ 1000\n\nX is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX\n\nOutput\n\nPrint the largest perfect power that is at most X.\n\nSample Input 1\n\n10\n\nSample Output 1\n\n9\n\nThere are four perfect powers that are at most 10: 1, 4, 8 and 9.\nWe should print the largest among them, 9.\n\nSample Input 2\n\n1\n\nSample Output 2\n\n1\n\nSample Input 3\n\n999\n\nSample Output 3\n\n961", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 115, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s070046045", "group_id": "codeNet:p03354", "input_text": "local par={}\nlocal rank={}\n--local size={}\n\nlocal function init(n)\n for i=1,n do\n par[i]=i\n rank[i]=1\n --size[i]=1\n end\nend\n\nlocal function root(x)\n return par[x]==x and x or root(par[x])\nend\n\nlocal function same(x,y)\n return root(x)==root(y)\nend\n\nlocal function unite(x,y)\n x=root(x)\n y=root(y)\n if x==y then\n return\n end\n if rank[x]>rank[y] then\n par[x]=y\n --size[y]=size[y]+size[x]\n else\n par[x]=y\n --size[y]=size[y]+size[x]\n if rank[x]==rank[y] then\n rank[y]=rank[y]+1\n end\n end\nend\n\nlocal function getsize(x)\n return size[root(x)]\nend\n\n----------\n\nlocal n,m=io.read(\"n\",\"n\")\ninit(n)\n\nlocal p={}\nfor i=1,n do\n p[i]=io.read(\"n\")\nend\n\nfor i=1,m do\n local x,y=io.read(\"n\",\"n\")\n unite(x,y)\nend\n\nlocal counter=0\nfor i=1,n do\n if same(p[i],i) then\n counter=counter+1\n end\nend\nprint(counter)", "language": "Lua", "metadata": {"date": 1598174275, "filename_ext": "lua", "original_language": "Lua (LuaJIT 2.1.0)", "problem_description_relpath": "problem_descriptions/p03354.html", "problem_id": "p03354", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03354/input.txt", "sample_output_relpath": "derived/input_output/data/p03354/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03354/Lua/s070046045.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s070046045", "user_id": "u045238009"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "local par={}\nlocal rank={}\n--local size={}\n\nlocal function init(n)\n for i=1,n do\n par[i]=i\n rank[i]=1\n --size[i]=1\n end\nend\n\nlocal function root(x)\n return par[x]==x and x or root(par[x])\nend\n\nlocal function same(x,y)\n return root(x)==root(y)\nend\n\nlocal function unite(x,y)\n x=root(x)\n y=root(y)\n if x==y then\n return\n end\n if rank[x]>rank[y] then\n par[x]=y\n --size[y]=size[y]+size[x]\n else\n par[x]=y\n --size[y]=size[y]+size[x]\n if rank[x]==rank[y] then\n rank[y]=rank[y]+1\n end\n end\nend\n\nlocal function getsize(x)\n return size[root(x)]\nend\n\n----------\n\nlocal n,m=io.read(\"n\",\"n\")\ninit(n)\n\nlocal p={}\nfor i=1,n do\n p[i]=io.read(\"n\")\nend\n\nfor i=1,m do\n local x,y=io.read(\"n\",\"n\")\n unite(x,y)\nend\n\nlocal counter=0\nfor i=1,n do\n if same(p[i],i) then\n counter=counter+1\n end\nend\nprint(counter)", "problem_context": "Score : 400 points\n\nProblem Statement\n\nWe have a permutation of the integers from 1 through N, p_1, p_2, .., p_N.\nWe also have M pairs of two integers between 1 and N (inclusive), represented as (x_1,y_1), (x_2,y_2), .., (x_M,y_M).\nAtCoDeer the deer is going to perform the following operation on p as many times as desired so that the number of i (1 ≤ i ≤ N) such that p_i = i is maximized:\n\nChoose j such that 1 ≤ j ≤ M, and swap p_{x_j} and p_{y_j}.\n\nFind the maximum possible number of i such that p_i = i after operations.\n\nConstraints\n\n2 ≤ N ≤ 10^5\n\n1 ≤ M ≤ 10^5\n\np is a permutation of integers from 1 through N.\n\n1 ≤ x_j,y_j ≤ N\n\nx_j ≠ y_j\n\nIf i ≠ j, \\{x_i,y_i\\} ≠ \\{x_j,y_j\\}.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\np_1 p_2 .. p_N\nx_1 y_1\nx_2 y_2\n:\nx_M y_M\n\nOutput\n\nPrint the maximum possible number of i such that p_i = i after operations.\n\nSample Input 1\n\n5 2\n5 3 1 4 2\n1 3\n5 4\n\nSample Output 1\n\n2\n\nIf we perform the operation by choosing j=1, p becomes 1 3 5 4 2, which is optimal, so the answer is 2.\n\nSample Input 2\n\n3 2\n3 2 1\n1 2\n2 3\n\nSample Output 2\n\n3\n\nIf we perform the operation by, for example, choosing j=1, j=2, j=1 in this order, p becomes 1 2 3, which is obviously optimal.\nNote that we may choose the same j any number of times.\n\nSample Input 3\n\n10 8\n5 3 6 8 7 10 9 1 2 4\n3 1\n4 1\n5 9\n2 5\n6 5\n3 5\n8 9\n7 9\n\nSample Output 3\n\n8\n\nSample Input 4\n\n5 1\n1 2 3 4 5\n1 5\n\nSample Output 4\n\n5\n\nWe do not have to perform the operation.", "sample_input": "5 2\n5 3 1 4 2\n1 3\n5 4\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03354", "source_text": "Score : 400 points\n\nProblem Statement\n\nWe have a permutation of the integers from 1 through N, p_1, p_2, .., p_N.\nWe also have M pairs of two integers between 1 and N (inclusive), represented as (x_1,y_1), (x_2,y_2), .., (x_M,y_M).\nAtCoDeer the deer is going to perform the following operation on p as many times as desired so that the number of i (1 ≤ i ≤ N) such that p_i = i is maximized:\n\nChoose j such that 1 ≤ j ≤ M, and swap p_{x_j} and p_{y_j}.\n\nFind the maximum possible number of i such that p_i = i after operations.\n\nConstraints\n\n2 ≤ N ≤ 10^5\n\n1 ≤ M ≤ 10^5\n\np is a permutation of integers from 1 through N.\n\n1 ≤ x_j,y_j ≤ N\n\nx_j ≠ y_j\n\nIf i ≠ j, \\{x_i,y_i\\} ≠ \\{x_j,y_j\\}.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\np_1 p_2 .. p_N\nx_1 y_1\nx_2 y_2\n:\nx_M y_M\n\nOutput\n\nPrint the maximum possible number of i such that p_i = i after operations.\n\nSample Input 1\n\n5 2\n5 3 1 4 2\n1 3\n5 4\n\nSample Output 1\n\n2\n\nIf we perform the operation by choosing j=1, p becomes 1 3 5 4 2, which is optimal, so the answer is 2.\n\nSample Input 2\n\n3 2\n3 2 1\n1 2\n2 3\n\nSample Output 2\n\n3\n\nIf we perform the operation by, for example, choosing j=1, j=2, j=1 in this order, p becomes 1 2 3, which is obviously optimal.\nNote that we may choose the same j any number of times.\n\nSample Input 3\n\n10 8\n5 3 6 8 7 10 9 1 2 4\n3 1\n4 1\n5 9\n2 5\n6 5\n3 5\n8 9\n7 9\n\nSample Output 3\n\n8\n\nSample Input 4\n\n5 1\n1 2 3 4 5\n1 5\n\nSample Output 4\n\n5\n\nWe do not have to perform the operation.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 927, "cpu_time_ms": 2205, "memory_kb": 6220}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s701285631", "group_id": "codeNet:p03355", "input_text": "local s=io.read()\nlocal n=#s\nlocal k=io.read(\"n\")\nlocal t1={}\nfor i=1,k do\n for j=1,n-i+1 do\n local sub=s:sub(j,j+i-1)\n table.insert(t1,sub) \n end\nend\ntable.sort(t1)\n\nlocal t2={t1[1]}\nfor i=1,#t1-1 do\n if t1[i]~=t1[i+1] then\n table.insert(t2,t1[i+1])\n end\nend\nprint(t2[k])", "language": "Lua", "metadata": {"date": 1595039185, "filename_ext": "lua", "original_language": "Lua (Lua 5.3.5)", "problem_description_relpath": "problem_descriptions/p03355.html", "problem_id": "p03355", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03355/input.txt", "sample_output_relpath": "derived/input_output/data/p03355/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03355/Lua/s701285631.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s701285631", "user_id": "u045238009"}, "prompt_components": {"gold_output": "b\n", "input_to_evaluate": "local s=io.read()\nlocal n=#s\nlocal k=io.read(\"n\")\nlocal t1={}\nfor i=1,k do\n for j=1,n-i+1 do\n local sub=s:sub(j,j+i-1)\n table.insert(t1,sub) \n end\nend\ntable.sort(t1)\n\nlocal t2={t1[1]}\nfor i=1,#t1-1 do\n if t1[i]~=t1[i+1] then\n table.insert(t2,t1[i+1])\n end\nend\nprint(t2[k])", "problem_context": "Score : 300 points\n\nProblem Statement\n\nYou are given a string s.\nAmong the different substrings of s, print the K-th lexicographically smallest one.\n\nA substring of s is a string obtained by taking out a non-empty contiguous part in s.\nFor example, if s = ababc, a, bab and ababc are substrings of s, while ac, z and an empty string are not.\nAlso, we say that substrings are different when they are different as strings.\n\nLet X = x_{1}x_{2}...x_{n} and Y = y_{1}y_{2}...y_{m} be two distinct strings. X is lexicographically larger than Y if and only if Y is a prefix of X or x_{j} > y_{j} where j is the smallest integer such that x_{j} \\neq y_{j}.\n\nConstraints\n\n1 ≤ |s| ≤ 5000\n\ns consists of lowercase English letters.\n\n1 ≤ K ≤ 5\n\ns has at least K different substrings.\n\nPartial Score\n\n200 points will be awarded as a partial score for passing the test set satisfying |s| ≤ 50.\n\nInput\n\nInput is given from Standard Input in the following format:\n\ns\nK\n\nOutput\n\nPrint the K-th lexicographically smallest substring of K.\n\nSample Input 1\n\naba\n4\n\nSample Output 1\n\nb\n\ns has five substrings: a, b, ab, ba and aba.\nAmong them, we should print the fourth smallest one, b.\nNote that we do not count a twice.\n\nSample Input 2\n\natcoderandatcodeer\n5\n\nSample Output 2\n\nandat\n\nSample Input 3\n\nz\n1\n\nSample Output 3\n\nz", "sample_input": "aba\n4\n"}, "reference_outputs": ["b\n"], "source_document_id": "p03355", "source_text": "Score : 300 points\n\nProblem Statement\n\nYou are given a string s.\nAmong the different substrings of s, print the K-th lexicographically smallest one.\n\nA substring of s is a string obtained by taking out a non-empty contiguous part in s.\nFor example, if s = ababc, a, bab and ababc are substrings of s, while ac, z and an empty string are not.\nAlso, we say that substrings are different when they are different as strings.\n\nLet X = x_{1}x_{2}...x_{n} and Y = y_{1}y_{2}...y_{m} be two distinct strings. X is lexicographically larger than Y if and only if Y is a prefix of X or x_{j} > y_{j} where j is the smallest integer such that x_{j} \\neq y_{j}.\n\nConstraints\n\n1 ≤ |s| ≤ 5000\n\ns consists of lowercase English letters.\n\n1 ≤ K ≤ 5\n\ns has at least K different substrings.\n\nPartial Score\n\n200 points will be awarded as a partial score for passing the test set satisfying |s| ≤ 50.\n\nInput\n\nInput is given from Standard Input in the following format:\n\ns\nK\n\nOutput\n\nPrint the K-th lexicographically smallest substring of K.\n\nSample Input 1\n\naba\n4\n\nSample Output 1\n\nb\n\ns has five substrings: a, b, ab, ba and aba.\nAmong them, we should print the fourth smallest one, b.\nNote that we do not count a twice.\n\nSample Input 2\n\natcoderandatcodeer\n5\n\nSample Output 2\n\nandat\n\nSample Input 3\n\nz\n1\n\nSample Output 3\n\nz", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 306, "cpu_time_ms": 42, "memory_kb": 3980}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s370081713", "group_id": "codeNet:p03356", "input_text": "local n, m = io.read(\"*n\", \"*n\",\"*l\")\nlocal str = io.read()\nlocal posval = {}\nfor strnum in string.gmatch(str, \"%d+\") do\n table.insert(posval, tonumber(strnum))\nend\n\nlocal parent = {}\nfor i = 1, n do parent[i] = 0 end\nfunction findroot(x)\n local cand = x\n while(parent[cand] ~= 0) do\n cand = parent[cand]\n end\n return cand\nend\n\nfor i = 1, m do\n local a, b = io.read(\"*n\", \"*n\")\n local aroot, broot = findroot(a), findroot(b)\n if(aroot ~= broot) then\n parent[broot] = aroot\n end\nend\nlocal ret = 0\nfor i = 1, n do\n local gsrc, gdst = findroot(i), findroot(posval[i])\n if(gsrc ~= 0 and gsrc == gdst) then ret = ret + 1 end\nend\nprint(ret)\n", "language": "Lua", "metadata": {"date": 1555807127, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03356.html", "problem_id": "p03356", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03356/input.txt", "sample_output_relpath": "derived/input_output/data/p03356/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03356/Lua/s370081713.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s370081713", "user_id": "u120582723"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "local n, m = io.read(\"*n\", \"*n\",\"*l\")\nlocal str = io.read()\nlocal posval = {}\nfor strnum in string.gmatch(str, \"%d+\") do\n table.insert(posval, tonumber(strnum))\nend\n\nlocal parent = {}\nfor i = 1, n do parent[i] = 0 end\nfunction findroot(x)\n local cand = x\n while(parent[cand] ~= 0) do\n cand = parent[cand]\n end\n return cand\nend\n\nfor i = 1, m do\n local a, b = io.read(\"*n\", \"*n\")\n local aroot, broot = findroot(a), findroot(b)\n if(aroot ~= broot) then\n parent[broot] = aroot\n end\nend\nlocal ret = 0\nfor i = 1, n do\n local gsrc, gdst = findroot(i), findroot(posval[i])\n if(gsrc ~= 0 and gsrc == gdst) then ret = ret + 1 end\nend\nprint(ret)\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nWe have a permutation of the integers from 1 through N, p_1, p_2, .., p_N.\nWe also have M pairs of two integers between 1 and N (inclusive), represented as (x_1,y_1), (x_2,y_2), .., (x_M,y_M).\nAtCoDeer the deer is going to perform the following operation on p as many times as desired so that the number of i (1 ≤ i ≤ N) such that p_i = i is maximized:\n\nChoose j such that 1 ≤ j ≤ M, and swap p_{x_j} and p_{y_j}.\n\nFind the maximum possible number of i such that p_i = i after operations.\n\nConstraints\n\n2 ≤ N ≤ 10^5\n\n1 ≤ M ≤ 10^5\n\np is a permutation of integers from 1 through N.\n\n1 ≤ x_j,y_j ≤ N\n\nx_j ≠ y_j\n\nIf i ≠ j, \\{x_i,y_i\\} ≠ \\{x_j,y_j\\}.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\np_1 p_2 .. p_N\nx_1 y_1\nx_2 y_2\n:\nx_M y_M\n\nOutput\n\nPrint the maximum possible number of i such that p_i = i after operations.\n\nSample Input 1\n\n5 2\n5 3 1 4 2\n1 3\n5 4\n\nSample Output 1\n\n2\n\nIf we perform the operation by choosing j=1, p becomes 1 3 5 4 2, which is optimal, so the answer is 2.\n\nSample Input 2\n\n3 2\n3 2 1\n1 2\n2 3\n\nSample Output 2\n\n3\n\nIf we perform the operation by, for example, choosing j=1, j=2, j=1 in this order, p becomes 1 2 3, which is obviously optimal.\nNote that we may choose the same j any number of times.\n\nSample Input 3\n\n10 8\n5 3 6 8 7 10 9 1 2 4\n3 1\n4 1\n5 9\n2 5\n6 5\n3 5\n8 9\n7 9\n\nSample Output 3\n\n8\n\nSample Input 4\n\n5 1\n1 2 3 4 5\n1 5\n\nSample Output 4\n\n5\n\nWe do not have to perform the operation.", "sample_input": "5 2\n5 3 1 4 2\n1 3\n5 4\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03356", "source_text": "Score : 400 points\n\nProblem Statement\n\nWe have a permutation of the integers from 1 through N, p_1, p_2, .., p_N.\nWe also have M pairs of two integers between 1 and N (inclusive), represented as (x_1,y_1), (x_2,y_2), .., (x_M,y_M).\nAtCoDeer the deer is going to perform the following operation on p as many times as desired so that the number of i (1 ≤ i ≤ N) such that p_i = i is maximized:\n\nChoose j such that 1 ≤ j ≤ M, and swap p_{x_j} and p_{y_j}.\n\nFind the maximum possible number of i such that p_i = i after operations.\n\nConstraints\n\n2 ≤ N ≤ 10^5\n\n1 ≤ M ≤ 10^5\n\np is a permutation of integers from 1 through N.\n\n1 ≤ x_j,y_j ≤ N\n\nx_j ≠ y_j\n\nIf i ≠ j, \\{x_i,y_i\\} ≠ \\{x_j,y_j\\}.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\np_1 p_2 .. p_N\nx_1 y_1\nx_2 y_2\n:\nx_M y_M\n\nOutput\n\nPrint the maximum possible number of i such that p_i = i after operations.\n\nSample Input 1\n\n5 2\n5 3 1 4 2\n1 3\n5 4\n\nSample Output 1\n\n2\n\nIf we perform the operation by choosing j=1, p becomes 1 3 5 4 2, which is optimal, so the answer is 2.\n\nSample Input 2\n\n3 2\n3 2 1\n1 2\n2 3\n\nSample Output 2\n\n3\n\nIf we perform the operation by, for example, choosing j=1, j=2, j=1 in this order, p becomes 1 2 3, which is obviously optimal.\nNote that we may choose the same j any number of times.\n\nSample Input 3\n\n10 8\n5 3 6 8 7 10 9 1 2 4\n3 1\n4 1\n5 9\n2 5\n6 5\n3 5\n8 9\n7 9\n\nSample Output 3\n\n8\n\nSample Input 4\n\n5 1\n1 2 3 4 5\n1 5\n\nSample Output 4\n\n5\n\nWe do not have to perform the operation.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 652, "cpu_time_ms": 2104, "memory_kb": 10296}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s331619535", "group_id": "codeNet:p03359", "input_text": "local a, b = io.read(\"*n\", \"*n\")\nlocal ret = a - 1\nif a <= b then ret = ret + 1 end\nprint(ret)\n", "language": "Lua", "metadata": {"date": 1563369535, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03359.html", "problem_id": "p03359", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03359/input.txt", "sample_output_relpath": "derived/input_output/data/p03359/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03359/Lua/s331619535.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s331619535", "user_id": "u120582723"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "local a, b = io.read(\"*n\", \"*n\")\nlocal ret = a - 1\nif a <= b then ret = ret + 1 end\nprint(ret)\n", "problem_context": "Score: 100 points\n\nProblem Statement\n\nIn AtCoder Kingdom, Gregorian calendar is used, and dates are written in the \"year-month-day\" order, or the \"month-day\" order without the year.\n\nFor example, May 3, 2018 is written as 2018-5-3, or 5-3 without the year.\n\nIn this country, a date is called Takahashi when the month and the day are equal as numbers. For example, 5-5 is Takahashi.\n\nHow many days from 2018-1-1 through 2018-a-b are Takahashi?\n\nConstraints\n\na is an integer between 1 and 12 (inclusive).\n\nb is an integer between 1 and 31 (inclusive).\n\n2018-a-b is a valid date in Gregorian calendar.\n\nInput\n\nInput is given from Standard Input in the following format:\n\na b\n\nOutput\n\nPrint the number of days from 2018-1-1 through 2018-a-b that are Takahashi.\n\nSample Input 1\n\n5 5\n\nSample Output 1\n\n5\n\nThere are five days that are Takahashi: 1-1, 2-2, 3-3, 4-4 and 5-5.\n\nSample Input 2\n\n2 1\n\nSample Output 2\n\n1\n\nThere is only one day that is Takahashi: 1-1.\n\nSample Input 3\n\n11 30\n\nSample Output 3\n\n11\n\nThere are eleven days that are Takahashi: 1-1, 2-2, 3-3, 4-4, 5-5, 6-6, 7-7, 8-8, 9-9, 10-10 and 11-11.", "sample_input": "5 5\n"}, "reference_outputs": ["5\n"], "source_document_id": "p03359", "source_text": "Score: 100 points\n\nProblem Statement\n\nIn AtCoder Kingdom, Gregorian calendar is used, and dates are written in the \"year-month-day\" order, or the \"month-day\" order without the year.\n\nFor example, May 3, 2018 is written as 2018-5-3, or 5-3 without the year.\n\nIn this country, a date is called Takahashi when the month and the day are equal as numbers. For example, 5-5 is Takahashi.\n\nHow many days from 2018-1-1 through 2018-a-b are Takahashi?\n\nConstraints\n\na is an integer between 1 and 12 (inclusive).\n\nb is an integer between 1 and 31 (inclusive).\n\n2018-a-b is a valid date in Gregorian calendar.\n\nInput\n\nInput is given from Standard Input in the following format:\n\na b\n\nOutput\n\nPrint the number of days from 2018-1-1 through 2018-a-b that are Takahashi.\n\nSample Input 1\n\n5 5\n\nSample Output 1\n\n5\n\nThere are five days that are Takahashi: 1-1, 2-2, 3-3, 4-4 and 5-5.\n\nSample Input 2\n\n2 1\n\nSample Output 2\n\n1\n\nThere is only one day that is Takahashi: 1-1.\n\nSample Input 3\n\n11 30\n\nSample Output 3\n\n11\n\nThere are eleven days that are Takahashi: 1-1, 2-2, 3-3, 4-4, 5-5, 6-6, 7-7, 8-8, 9-9, 10-10 and 11-11.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 95, "cpu_time_ms": 7, "memory_kb": 760}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s585543134", "group_id": "codeNet:p03359", "input_text": "a,b=io.read():match(\"(.+)%s(.+)\")\nprint(a*1>b*1 and math.floor(a-1)or a)", "language": "Lua", "metadata": {"date": 1551841064, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p03359.html", "problem_id": "p03359", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03359/input.txt", "sample_output_relpath": "derived/input_output/data/p03359/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03359/Lua/s585543134.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s585543134", "user_id": "u837412668"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "a,b=io.read():match(\"(.+)%s(.+)\")\nprint(a*1>b*1 and math.floor(a-1)or a)", "problem_context": "Score: 100 points\n\nProblem Statement\n\nIn AtCoder Kingdom, Gregorian calendar is used, and dates are written in the \"year-month-day\" order, or the \"month-day\" order without the year.\n\nFor example, May 3, 2018 is written as 2018-5-3, or 5-3 without the year.\n\nIn this country, a date is called Takahashi when the month and the day are equal as numbers. For example, 5-5 is Takahashi.\n\nHow many days from 2018-1-1 through 2018-a-b are Takahashi?\n\nConstraints\n\na is an integer between 1 and 12 (inclusive).\n\nb is an integer between 1 and 31 (inclusive).\n\n2018-a-b is a valid date in Gregorian calendar.\n\nInput\n\nInput is given from Standard Input in the following format:\n\na b\n\nOutput\n\nPrint the number of days from 2018-1-1 through 2018-a-b that are Takahashi.\n\nSample Input 1\n\n5 5\n\nSample Output 1\n\n5\n\nThere are five days that are Takahashi: 1-1, 2-2, 3-3, 4-4 and 5-5.\n\nSample Input 2\n\n2 1\n\nSample Output 2\n\n1\n\nThere is only one day that is Takahashi: 1-1.\n\nSample Input 3\n\n11 30\n\nSample Output 3\n\n11\n\nThere are eleven days that are Takahashi: 1-1, 2-2, 3-3, 4-4, 5-5, 6-6, 7-7, 8-8, 9-9, 10-10 and 11-11.", "sample_input": "5 5\n"}, "reference_outputs": ["5\n"], "source_document_id": "p03359", "source_text": "Score: 100 points\n\nProblem Statement\n\nIn AtCoder Kingdom, Gregorian calendar is used, and dates are written in the \"year-month-day\" order, or the \"month-day\" order without the year.\n\nFor example, May 3, 2018 is written as 2018-5-3, or 5-3 without the year.\n\nIn this country, a date is called Takahashi when the month and the day are equal as numbers. For example, 5-5 is Takahashi.\n\nHow many days from 2018-1-1 through 2018-a-b are Takahashi?\n\nConstraints\n\na is an integer between 1 and 12 (inclusive).\n\nb is an integer between 1 and 31 (inclusive).\n\n2018-a-b is a valid date in Gregorian calendar.\n\nInput\n\nInput is given from Standard Input in the following format:\n\na b\n\nOutput\n\nPrint the number of days from 2018-1-1 through 2018-a-b that are Takahashi.\n\nSample Input 1\n\n5 5\n\nSample Output 1\n\n5\n\nThere are five days that are Takahashi: 1-1, 2-2, 3-3, 4-4 and 5-5.\n\nSample Input 2\n\n2 1\n\nSample Output 2\n\n1\n\nThere is only one day that is Takahashi: 1-1.\n\nSample Input 3\n\n11 30\n\nSample Output 3\n\n11\n\nThere are eleven days that are Takahashi: 1-1, 2-2, 3-3, 4-4, 5-5, 6-6, 7-7, 8-8, 9-9, 10-10 and 11-11.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 72, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s127318664", "group_id": "codeNet:p03360", "input_text": "local t = {io.read(\"*n\", \"*n\", \"*n\")}\nlocal k = io.read(\"*n\")\ntable.sort(t)\nfor i = 1, k do\n t[3] = t[3] * 2\nend\nprint(t[1] + t[2] + t[3])\n", "language": "Lua", "metadata": {"date": 1563369485, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03360.html", "problem_id": "p03360", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03360/input.txt", "sample_output_relpath": "derived/input_output/data/p03360/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03360/Lua/s127318664.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s127318664", "user_id": "u120582723"}, "prompt_components": {"gold_output": "30\n", "input_to_evaluate": "local t = {io.read(\"*n\", \"*n\", \"*n\")}\nlocal k = io.read(\"*n\")\ntable.sort(t)\nfor i = 1, k do\n t[3] = t[3] * 2\nend\nprint(t[1] + t[2] + t[3])\n", "problem_context": "Score: 200 points\n\nProblem Statement\n\nThere are three positive integers A, B and C written on a blackboard. E869120 performs the following operation K times:\n\nChoose one integer written on the blackboard and let the chosen integer be n. Replace the chosen integer with 2n.\n\nWhat is the largest possible sum of the integers written on the blackboard after K operations?\n\nConstraints\n\nA, B and C are integers between 1 and 50 (inclusive).\n\nK is an integer between 1 and 10 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C\nK\n\nOutput\n\nPrint the largest possible sum of the integers written on the blackboard after K operations by E869220.\n\nSample Input 1\n\n5 3 11\n1\n\nSample Output 1\n\n30\n\nIn this sample, 5, 3, 11 are initially written on the blackboard, and E869120 can perform the operation once.\n\nThere are three choices:\n\nDouble 5: The integers written on the board after the operation are 10, 3, 11.\n\nDouble 3: The integers written on the board after the operation are 5, 6, 11.\n\nDouble 11: The integers written on the board after the operation are 5, 3, 22.\n\nIf he chooses 3., the sum of the integers written on the board afterwards is 5 + 3 + 22 = 30, which is the largest among 1. through 3.\n\nSample Input 2\n\n3 3 4\n2\n\nSample Output 2\n\n22\n\nE869120 can perform the operation twice. The sum of the integers eventually written on the blackboard is maximized as follows:\n\nFirst, double 4. The integers written on the board are now 3, 3, 8.\n\nNext, double 8. The integers written on the board are now 3, 3, 16.\n\nThen, the sum of the integers eventually written on the blackboard is 3 + 3 + 16 = 22.", "sample_input": "5 3 11\n1\n"}, "reference_outputs": ["30\n"], "source_document_id": "p03360", "source_text": "Score: 200 points\n\nProblem Statement\n\nThere are three positive integers A, B and C written on a blackboard. E869120 performs the following operation K times:\n\nChoose one integer written on the blackboard and let the chosen integer be n. Replace the chosen integer with 2n.\n\nWhat is the largest possible sum of the integers written on the blackboard after K operations?\n\nConstraints\n\nA, B and C are integers between 1 and 50 (inclusive).\n\nK is an integer between 1 and 10 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C\nK\n\nOutput\n\nPrint the largest possible sum of the integers written on the blackboard after K operations by E869220.\n\nSample Input 1\n\n5 3 11\n1\n\nSample Output 1\n\n30\n\nIn this sample, 5, 3, 11 are initially written on the blackboard, and E869120 can perform the operation once.\n\nThere are three choices:\n\nDouble 5: The integers written on the board after the operation are 10, 3, 11.\n\nDouble 3: The integers written on the board after the operation are 5, 6, 11.\n\nDouble 11: The integers written on the board after the operation are 5, 3, 22.\n\nIf he chooses 3., the sum of the integers written on the board afterwards is 5 + 3 + 22 = 30, which is the largest among 1. through 3.\n\nSample Input 2\n\n3 3 4\n2\n\nSample Output 2\n\n22\n\nE869120 can perform the operation twice. The sum of the integers eventually written on the blackboard is maximized as follows:\n\nFirst, double 4. The integers written on the board are now 3, 3, 8.\n\nNext, double 8. The integers written on the board are now 3, 3, 16.\n\nThen, the sum of the integers eventually written on the blackboard is 3 + 3 + 16 = 22.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 140, "cpu_time_ms": 7, "memory_kb": 888}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s742989990", "group_id": "codeNet:p03360", "input_text": "a={io.read(\"*n\",\"*n\",\"*n\")}\nk=bit.lshift(1,io.read(\"*n\"))\ntable.sort(a)\nprint(a[3]*k+a[1]+a[2])", "language": "Lua", "metadata": {"date": 1525570005, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p03360.html", "problem_id": "p03360", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03360/input.txt", "sample_output_relpath": "derived/input_output/data/p03360/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03360/Lua/s742989990.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s742989990", "user_id": "u781091740"}, "prompt_components": {"gold_output": "30\n", "input_to_evaluate": "a={io.read(\"*n\",\"*n\",\"*n\")}\nk=bit.lshift(1,io.read(\"*n\"))\ntable.sort(a)\nprint(a[3]*k+a[1]+a[2])", "problem_context": "Score: 200 points\n\nProblem Statement\n\nThere are three positive integers A, B and C written on a blackboard. E869120 performs the following operation K times:\n\nChoose one integer written on the blackboard and let the chosen integer be n. Replace the chosen integer with 2n.\n\nWhat is the largest possible sum of the integers written on the blackboard after K operations?\n\nConstraints\n\nA, B and C are integers between 1 and 50 (inclusive).\n\nK is an integer between 1 and 10 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C\nK\n\nOutput\n\nPrint the largest possible sum of the integers written on the blackboard after K operations by E869220.\n\nSample Input 1\n\n5 3 11\n1\n\nSample Output 1\n\n30\n\nIn this sample, 5, 3, 11 are initially written on the blackboard, and E869120 can perform the operation once.\n\nThere are three choices:\n\nDouble 5: The integers written on the board after the operation are 10, 3, 11.\n\nDouble 3: The integers written on the board after the operation are 5, 6, 11.\n\nDouble 11: The integers written on the board after the operation are 5, 3, 22.\n\nIf he chooses 3., the sum of the integers written on the board afterwards is 5 + 3 + 22 = 30, which is the largest among 1. through 3.\n\nSample Input 2\n\n3 3 4\n2\n\nSample Output 2\n\n22\n\nE869120 can perform the operation twice. The sum of the integers eventually written on the blackboard is maximized as follows:\n\nFirst, double 4. The integers written on the board are now 3, 3, 8.\n\nNext, double 8. The integers written on the board are now 3, 3, 16.\n\nThen, the sum of the integers eventually written on the blackboard is 3 + 3 + 16 = 22.", "sample_input": "5 3 11\n1\n"}, "reference_outputs": ["30\n"], "source_document_id": "p03360", "source_text": "Score: 200 points\n\nProblem Statement\n\nThere are three positive integers A, B and C written on a blackboard. E869120 performs the following operation K times:\n\nChoose one integer written on the blackboard and let the chosen integer be n. Replace the chosen integer with 2n.\n\nWhat is the largest possible sum of the integers written on the blackboard after K operations?\n\nConstraints\n\nA, B and C are integers between 1 and 50 (inclusive).\n\nK is an integer between 1 and 10 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C\nK\n\nOutput\n\nPrint the largest possible sum of the integers written on the blackboard after K operations by E869220.\n\nSample Input 1\n\n5 3 11\n1\n\nSample Output 1\n\n30\n\nIn this sample, 5, 3, 11 are initially written on the blackboard, and E869120 can perform the operation once.\n\nThere are three choices:\n\nDouble 5: The integers written on the board after the operation are 10, 3, 11.\n\nDouble 3: The integers written on the board after the operation are 5, 6, 11.\n\nDouble 11: The integers written on the board after the operation are 5, 3, 22.\n\nIf he chooses 3., the sum of the integers written on the board afterwards is 5 + 3 + 22 = 30, which is the largest among 1. through 3.\n\nSample Input 2\n\n3 3 4\n2\n\nSample Output 2\n\n22\n\nE869120 can perform the operation twice. The sum of the integers eventually written on the blackboard is maximized as follows:\n\nFirst, double 4. The integers written on the board are now 3, 3, 8.\n\nNext, double 8. The integers written on the board are now 3, 3, 16.\n\nThen, the sum of the integers eventually written on the blackboard is 3 + 3 + 16 = 22.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 95, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s585703043", "group_id": "codeNet:p03361", "input_text": "h, w = io.read(\"*n\", \"*n\", \"*l\")\nmap = {}\nfor i = 1, h do\n map[i] = {}\n s = io.read()\n for j = 1, w do\n map[i][j] = s:sub(j, j) == \"#\"\n end\nend\nvalid = true\nfor i = 1, h do\n for j = 1, w do\n if map[i][j] then\n f = false\n if 1 < i and map[i - 1][j] then\n f = true\n elseif i < h and map[i + 1][j] then\n f = true\n elseif 1 < j and map[i][j - 1] then\n f = true\n elseif j < w and map[i][j + 1] then\n f = true\n end\n if not f then valid = false end\n end\n end\nend\nprint(valid and \"Yes\" or \"No\")\n", "language": "Lua", "metadata": {"date": 1594006867, "filename_ext": "lua", "original_language": "Lua (Lua 5.3.5)", "problem_description_relpath": "problem_descriptions/p03361.html", "problem_id": "p03361", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03361/input.txt", "sample_output_relpath": "derived/input_output/data/p03361/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03361/Lua/s585703043.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s585703043", "user_id": "u120582723"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "h, w = io.read(\"*n\", \"*n\", \"*l\")\nmap = {}\nfor i = 1, h do\n map[i] = {}\n s = io.read()\n for j = 1, w do\n map[i][j] = s:sub(j, j) == \"#\"\n end\nend\nvalid = true\nfor i = 1, h do\n for j = 1, w do\n if map[i][j] then\n f = false\n if 1 < i and map[i - 1][j] then\n f = true\n elseif i < h and map[i + 1][j] then\n f = true\n elseif 1 < j and map[i][j - 1] then\n f = true\n elseif j < w and map[i][j + 1] then\n f = true\n end\n if not f then valid = false end\n end\n end\nend\nprint(valid and \"Yes\" or \"No\")\n", "problem_context": "Score: 300 points\n\nProblem Statement\n\nWe have a canvas divided into a grid with H rows and W columns. The square at the i-th row from the top and the j-th column from the left is represented as (i, j).\n\nInitially, all the squares are white. square1001 wants to draw a picture with black paint. His specific objective is to make Square (i, j) black when s_{i, j}= #, and to make Square (i, j) white when s_{i, j}= ..\n\nHowever, since he is not a good painter, he can only choose two squares that are horizontally or vertically adjacent and paint those squares black, for some number of times (possibly zero). He may choose squares that are already painted black, in which case the color of those squares remain black.\n\nDetermine if square1001 can achieve his objective.\n\nConstraints\n\nH is an integer between 1 and 50 (inclusive).\n\nW is an integer between 1 and 50 (inclusive).\n\nFor every (i, j) (1 \\leq i \\leq H, 1 \\leq j \\leq W), s_{i, j} is # or ..\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\ns_{1, 1} s_{1, 2} s_{1, 3} ... s_{1, W}\ns_{2, 1} s_{2, 2} s_{2, 3} ... s_{2, W}\n: :\ns_{H, 1} s_{H, 2} s_{H, 3} ... s_{H, W}\n\nOutput\n\nIf square1001 can achieve his objective, print Yes; if he cannot, print No.\n\nSample Input 1\n\n3 3\n.#.\n###\n.#.\n\nSample Output 1\n\nYes\n\nOne possible way to achieve the objective is shown in the figure below. Here, the squares being painted are marked by stars.\n\nSample Input 2\n\n5 5\n#.#.#\n.#.#.\n#.#.#\n.#.#.\n#.#.#\n\nSample Output 2\n\nNo\n\nsquare1001 cannot achieve his objective here.\n\nSample Input 3\n\n11 11\n...#####...\n.##.....##.\n#..##.##..#\n#..##.##..#\n#.........#\n#...###...#\n.#########.\n.#.#.#.#.#.\n##.#.#.#.##\n..##.#.##..\n.##..#..##.\n\nSample Output 3\n\nYes", "sample_input": "3 3\n.#.\n###\n.#.\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03361", "source_text": "Score: 300 points\n\nProblem Statement\n\nWe have a canvas divided into a grid with H rows and W columns. The square at the i-th row from the top and the j-th column from the left is represented as (i, j).\n\nInitially, all the squares are white. square1001 wants to draw a picture with black paint. His specific objective is to make Square (i, j) black when s_{i, j}= #, and to make Square (i, j) white when s_{i, j}= ..\n\nHowever, since he is not a good painter, he can only choose two squares that are horizontally or vertically adjacent and paint those squares black, for some number of times (possibly zero). He may choose squares that are already painted black, in which case the color of those squares remain black.\n\nDetermine if square1001 can achieve his objective.\n\nConstraints\n\nH is an integer between 1 and 50 (inclusive).\n\nW is an integer between 1 and 50 (inclusive).\n\nFor every (i, j) (1 \\leq i \\leq H, 1 \\leq j \\leq W), s_{i, j} is # or ..\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\ns_{1, 1} s_{1, 2} s_{1, 3} ... s_{1, W}\ns_{2, 1} s_{2, 2} s_{2, 3} ... s_{2, W}\n: :\ns_{H, 1} s_{H, 2} s_{H, 3} ... s_{H, W}\n\nOutput\n\nIf square1001 can achieve his objective, print Yes; if he cannot, print No.\n\nSample Input 1\n\n3 3\n.#.\n###\n.#.\n\nSample Output 1\n\nYes\n\nOne possible way to achieve the objective is shown in the figure below. Here, the squares being painted are marked by stars.\n\nSample Input 2\n\n5 5\n#.#.#\n.#.#.\n#.#.#\n.#.#.\n#.#.#\n\nSample Output 2\n\nNo\n\nsquare1001 cannot achieve his objective here.\n\nSample Input 3\n\n11 11\n...#####...\n.##.....##.\n#..##.##..#\n#..##.##..#\n#.........#\n#...###...#\n.#########.\n.#.#.#.#.#.\n##.#.#.#.##\n..##.#.##..\n.##..#..##.\n\nSample Output 3\n\nYes", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 565, "cpu_time_ms": 7, "memory_kb": 2732}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s017402759", "group_id": "codeNet:p03361", "input_text": "h,w=io.read(\"*n\",\"*n\")\ngrid={}\nfor i=1,h+2 do\n grid[i]={}\n if i~=1 and i~=h+2 then\n s=io.read()\n end\n for j=1,w+2 do\n if i==1 or i==h+2 then\n grid[i][j]=\".\"\n else\n if j==1 or j==w+2 then\n grid[i][j]=\".\"\n else\n grid[i][j]=s:sub(j-1,j-1)\n end\n end\n end\nend\n\nfeasible=true\nfor i=2,h+1 do\n for j=2,w+1 do\n if grid[i][j-1]..grid[i][j]..grid[i][j+1]==\".#.\" and grid[i-1][j]..grid[i][j]..grid[i+1][j]==\".#.\" then\n feasible=false\n end\n end\nend\nif feasible then\n print(\"Yes\")\nelse\n print(\"No\")\nend", "language": "Lua", "metadata": {"date": 1589119028, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03361.html", "problem_id": "p03361", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03361/input.txt", "sample_output_relpath": "derived/input_output/data/p03361/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03361/Lua/s017402759.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s017402759", "user_id": "u045238009"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "h,w=io.read(\"*n\",\"*n\")\ngrid={}\nfor i=1,h+2 do\n grid[i]={}\n if i~=1 and i~=h+2 then\n s=io.read()\n end\n for j=1,w+2 do\n if i==1 or i==h+2 then\n grid[i][j]=\".\"\n else\n if j==1 or j==w+2 then\n grid[i][j]=\".\"\n else\n grid[i][j]=s:sub(j-1,j-1)\n end\n end\n end\nend\n\nfeasible=true\nfor i=2,h+1 do\n for j=2,w+1 do\n if grid[i][j-1]..grid[i][j]..grid[i][j+1]==\".#.\" and grid[i-1][j]..grid[i][j]..grid[i+1][j]==\".#.\" then\n feasible=false\n end\n end\nend\nif feasible then\n print(\"Yes\")\nelse\n print(\"No\")\nend", "problem_context": "Score: 300 points\n\nProblem Statement\n\nWe have a canvas divided into a grid with H rows and W columns. The square at the i-th row from the top and the j-th column from the left is represented as (i, j).\n\nInitially, all the squares are white. square1001 wants to draw a picture with black paint. His specific objective is to make Square (i, j) black when s_{i, j}= #, and to make Square (i, j) white when s_{i, j}= ..\n\nHowever, since he is not a good painter, he can only choose two squares that are horizontally or vertically adjacent and paint those squares black, for some number of times (possibly zero). He may choose squares that are already painted black, in which case the color of those squares remain black.\n\nDetermine if square1001 can achieve his objective.\n\nConstraints\n\nH is an integer between 1 and 50 (inclusive).\n\nW is an integer between 1 and 50 (inclusive).\n\nFor every (i, j) (1 \\leq i \\leq H, 1 \\leq j \\leq W), s_{i, j} is # or ..\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\ns_{1, 1} s_{1, 2} s_{1, 3} ... s_{1, W}\ns_{2, 1} s_{2, 2} s_{2, 3} ... s_{2, W}\n: :\ns_{H, 1} s_{H, 2} s_{H, 3} ... s_{H, W}\n\nOutput\n\nIf square1001 can achieve his objective, print Yes; if he cannot, print No.\n\nSample Input 1\n\n3 3\n.#.\n###\n.#.\n\nSample Output 1\n\nYes\n\nOne possible way to achieve the objective is shown in the figure below. Here, the squares being painted are marked by stars.\n\nSample Input 2\n\n5 5\n#.#.#\n.#.#.\n#.#.#\n.#.#.\n#.#.#\n\nSample Output 2\n\nNo\n\nsquare1001 cannot achieve his objective here.\n\nSample Input 3\n\n11 11\n...#####...\n.##.....##.\n#..##.##..#\n#..##.##..#\n#.........#\n#...###...#\n.#########.\n.#.#.#.#.#.\n##.#.#.#.##\n..##.#.##..\n.##..#..##.\n\nSample Output 3\n\nYes", "sample_input": "3 3\n.#.\n###\n.#.\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03361", "source_text": "Score: 300 points\n\nProblem Statement\n\nWe have a canvas divided into a grid with H rows and W columns. The square at the i-th row from the top and the j-th column from the left is represented as (i, j).\n\nInitially, all the squares are white. square1001 wants to draw a picture with black paint. His specific objective is to make Square (i, j) black when s_{i, j}= #, and to make Square (i, j) white when s_{i, j}= ..\n\nHowever, since he is not a good painter, he can only choose two squares that are horizontally or vertically adjacent and paint those squares black, for some number of times (possibly zero). He may choose squares that are already painted black, in which case the color of those squares remain black.\n\nDetermine if square1001 can achieve his objective.\n\nConstraints\n\nH is an integer between 1 and 50 (inclusive).\n\nW is an integer between 1 and 50 (inclusive).\n\nFor every (i, j) (1 \\leq i \\leq H, 1 \\leq j \\leq W), s_{i, j} is # or ..\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\ns_{1, 1} s_{1, 2} s_{1, 3} ... s_{1, W}\ns_{2, 1} s_{2, 2} s_{2, 3} ... s_{2, W}\n: :\ns_{H, 1} s_{H, 2} s_{H, 3} ... s_{H, W}\n\nOutput\n\nIf square1001 can achieve his objective, print Yes; if he cannot, print No.\n\nSample Input 1\n\n3 3\n.#.\n###\n.#.\n\nSample Output 1\n\nYes\n\nOne possible way to achieve the objective is shown in the figure below. Here, the squares being painted are marked by stars.\n\nSample Input 2\n\n5 5\n#.#.#\n.#.#.\n#.#.#\n.#.#.\n#.#.#\n\nSample Output 2\n\nNo\n\nsquare1001 cannot achieve his objective here.\n\nSample Input 3\n\n11 11\n...#####...\n.##.....##.\n#..##.##..#\n#..##.##..#\n#.........#\n#...###...#\n.#########.\n.#.#.#.#.#.\n##.#.#.#.##\n..##.#.##..\n.##..#..##.\n\nSample Output 3\n\nYes", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 642, "cpu_time_ms": 15, "memory_kb": 880}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s255526575", "group_id": "codeNet:p03362", "input_text": "local n = io.read(\"*n\")\nio.write(\"11\")\nlocal cnt = 1\nlocal ofst = 21\n\nlocal function isprime(x)\n local a = math.ceil(math.sqrt(x))\n for i = 2, a do\n if(x % i == 0) then return false end\n end\n return true\nend\n\nlocal t = {}\nwhile(cnt < n) do\n if(isprime(ofst)) then\n cnt = cnt + 1\n io.write(\" \" .. ofst)\n end\n ofst = ofst + 10\nend\nio.write(\"\\n\")\n", "language": "Lua", "metadata": {"date": 1556192169, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03362.html", "problem_id": "p03362", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03362/input.txt", "sample_output_relpath": "derived/input_output/data/p03362/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03362/Lua/s255526575.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s255526575", "user_id": "u120582723"}, "prompt_components": {"gold_output": "3 5 7 11 31\n", "input_to_evaluate": "local n = io.read(\"*n\")\nio.write(\"11\")\nlocal cnt = 1\nlocal ofst = 21\n\nlocal function isprime(x)\n local a = math.ceil(math.sqrt(x))\n for i = 2, a do\n if(x % i == 0) then return false end\n end\n return true\nend\n\nlocal t = {}\nwhile(cnt < n) do\n if(isprime(ofst)) then\n cnt = cnt + 1\n io.write(\" \" .. ofst)\n end\n ofst = ofst + 10\nend\nio.write(\"\\n\")\n", "problem_context": "Score: 400 points\n\nProblem Statement\n\nPrint a sequence a_1, a_2, ..., a_N whose length is N that satisfies the following conditions:\n\na_i (1 \\leq i \\leq N) is a prime number at most 55 555.\n\nThe values of a_1, a_2, ..., a_N are all different.\n\nIn every choice of five different integers from a_1, a_2, ..., a_N, the sum of those integers is a composite number.\n\nIf there are multiple such sequences, printing any of them is accepted.\n\nNotes\n\nAn integer N not less than 2 is called a prime number if it cannot be divided evenly by any integers except 1 and N, and called a composite number otherwise.\n\nConstraints\n\nN is an integer between 5 and 55 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint N numbers a_1, a_2, a_3, ..., a_N in a line, with spaces in between.\n\nSample Input 1\n\n5\n\nSample Output 1\n\n3 5 7 11 31\n\nLet us see if this output actually satisfies the conditions.\n\nFirst, 3, 5, 7, 11 and 31 are all different, and all of them are prime numbers.\n\nThe only way to choose five among them is to choose all of them, whose sum is a_1+a_2+a_3+a_4+a_5=57, which is a composite number.\n\nThere are also other possible outputs, such as 2 3 5 7 13, 11 13 17 19 31 and 7 11 5 31 3.\n\nSample Input 2\n\n6\n\nSample Output 2\n\n2 3 5 7 11 13\n\n2, 3, 5, 7, 11, 13 are all different prime numbers.\n\n2+3+5+7+11=28 is a composite number.\n\n2+3+5+7+13=30 is a composite number.\n\n2+3+5+11+13=34 is a composite number.\n\n2+3+7+11+13=36 is a composite number.\n\n2+5+7+11+13=38 is a composite number.\n\n3+5+7+11+13=39 is a composite number.\n\nThus, the sequence 2 3 5 7 11 13 satisfies the conditions.\n\nSample Input 3\n\n8\n\nSample Output 3\n\n2 5 7 13 19 37 67 79", "sample_input": "5\n"}, "reference_outputs": ["3 5 7 11 31\n"], "source_document_id": "p03362", "source_text": "Score: 400 points\n\nProblem Statement\n\nPrint a sequence a_1, a_2, ..., a_N whose length is N that satisfies the following conditions:\n\na_i (1 \\leq i \\leq N) is a prime number at most 55 555.\n\nThe values of a_1, a_2, ..., a_N are all different.\n\nIn every choice of five different integers from a_1, a_2, ..., a_N, the sum of those integers is a composite number.\n\nIf there are multiple such sequences, printing any of them is accepted.\n\nNotes\n\nAn integer N not less than 2 is called a prime number if it cannot be divided evenly by any integers except 1 and N, and called a composite number otherwise.\n\nConstraints\n\nN is an integer between 5 and 55 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint N numbers a_1, a_2, a_3, ..., a_N in a line, with spaces in between.\n\nSample Input 1\n\n5\n\nSample Output 1\n\n3 5 7 11 31\n\nLet us see if this output actually satisfies the conditions.\n\nFirst, 3, 5, 7, 11 and 31 are all different, and all of them are prime numbers.\n\nThe only way to choose five among them is to choose all of them, whose sum is a_1+a_2+a_3+a_4+a_5=57, which is a composite number.\n\nThere are also other possible outputs, such as 2 3 5 7 13, 11 13 17 19 31 and 7 11 5 31 3.\n\nSample Input 2\n\n6\n\nSample Output 2\n\n2 3 5 7 11 13\n\n2, 3, 5, 7, 11, 13 are all different prime numbers.\n\n2+3+5+7+11=28 is a composite number.\n\n2+3+5+7+13=30 is a composite number.\n\n2+3+5+11+13=34 is a composite number.\n\n2+3+7+11+13=36 is a composite number.\n\n2+5+7+11+13=38 is a composite number.\n\n3+5+7+11+13=39 is a composite number.\n\nThus, the sequence 2 3 5 7 11 13 satisfies the conditions.\n\nSample Input 3\n\n8\n\nSample Output 3\n\n2 5 7 13 19 37 67 79", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 360, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s845310295", "group_id": "codeNet:p03363", "input_text": "n=io.read(\"*n\")\ns,sum,cnt={[0]=1},0,0\nfor i=1,n do\n\ta=io.read(\"*n\")\n\tsum=sum+a\n\tif s[sum]==nil then s[sum]=0 end\n\tcnt=cnt+s[sum]\n\ts[sum]=s[sum]+1\nend\nprint(cnt)", "language": "Lua", "metadata": {"date": 1525229320, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p03363.html", "problem_id": "p03363", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03363/input.txt", "sample_output_relpath": "derived/input_output/data/p03363/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03363/Lua/s845310295.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s845310295", "user_id": "u781091740"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "n=io.read(\"*n\")\ns,sum,cnt={[0]=1},0,0\nfor i=1,n do\n\ta=io.read(\"*n\")\n\tsum=sum+a\n\tif s[sum]==nil then s[sum]=0 end\n\tcnt=cnt+s[sum]\n\ts[sum]=s[sum]+1\nend\nprint(cnt)", "problem_context": "Score : 200 points\n\nProblem Statement\n\nWe have an integer sequence A, whose length is N.\n\nFind the number of the non-empty contiguous subsequences of A whose sums are 0.\nNote that we are counting the ways to take out subsequences.\nThat is, even if the contents of some two subsequences are the same, they are counted individually if they are taken from different positions.\n\nConstraints\n\n1 \\leq N \\leq 2 \\times 10^5\n\n-10^9 \\leq A_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nFind the number of the non-empty contiguous subsequences of A whose sum is 0.\n\nSample Input 1\n\n6\n1 3 -4 2 2 -2\n\nSample Output 1\n\n3\n\nThere are three contiguous subsequences whose sums are 0: (1,3,-4), (-4,2,2) and (2,-2).\n\nSample Input 2\n\n7\n1 -1 1 -1 1 -1 1\n\nSample Output 2\n\n12\n\nIn this case, some subsequences that have the same contents but are taken from different positions are counted individually.\nFor example, three occurrences of (1, -1) are counted.\n\nSample Input 3\n\n5\n1 -2 3 -4 5\n\nSample Output 3\n\n0\n\nThere are no contiguous subsequences whose sums are 0.", "sample_input": "6\n1 3 -4 2 2 -2\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03363", "source_text": "Score : 200 points\n\nProblem Statement\n\nWe have an integer sequence A, whose length is N.\n\nFind the number of the non-empty contiguous subsequences of A whose sums are 0.\nNote that we are counting the ways to take out subsequences.\nThat is, even if the contents of some two subsequences are the same, they are counted individually if they are taken from different positions.\n\nConstraints\n\n1 \\leq N \\leq 2 \\times 10^5\n\n-10^9 \\leq A_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nFind the number of the non-empty contiguous subsequences of A whose sum is 0.\n\nSample Input 1\n\n6\n1 3 -4 2 2 -2\n\nSample Output 1\n\n3\n\nThere are three contiguous subsequences whose sums are 0: (1,3,-4), (-4,2,2) and (2,-2).\n\nSample Input 2\n\n7\n1 -1 1 -1 1 -1 1\n\nSample Output 2\n\n12\n\nIn this case, some subsequences that have the same contents but are taken from different positions are counted individually.\nFor example, three occurrences of (1, -1) are counted.\n\nSample Input 3\n\n5\n1 -2 3 -4 5\n\nSample Output 3\n\n0\n\nThere are no contiguous subsequences whose sums are 0.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 160, "cpu_time_ms": 184, "memory_kb": 9648}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s660889134", "group_id": "codeNet:p03364", "input_text": "local n = io.read(\"*n\", \"*l\")\nlocal rowmap = {}\nfor i = 1, n do\n local tmps = io.read()\n rowmap[i] = {}\n tmps = tmps .. tmps\n for j = 1, n do\n rowmap[i][j] = tmps:sub(n + 2 - j, n + 2 - j + n - 1)\n end\nend\n\nlocal colmap = {}\nfor i = 1, n do\n local tmps = \"\"\n for j = 1, n do\n tmps = tmps .. rowmap[j][1]:sub(i, i)\n end\n colmap[i] = {}\n tmps = tmps .. tmps\n for j = 1, n do\n colmap[i][j] = tmps:sub(n + 2 - j, n + 2 - j + n - 1)\n end\nend\n\nlocal function check(r, c)\n for k = 1, n do\n local row_tgt = k + n - r\n if n < row_tgt then row_tgt = row_tgt - n end\n local row_ofst = 1 + c\n local col_tgt = k + n - c\n if n < col_tgt then col_tgt = col_tgt - n end\n local col_ofst = 1 + r\n if rowmap[row_tgt][row_ofst] ~= colmap[col_tgt][col_ofst] then return 0 end\n end\n return 1\nend\nlocal ret = 0\nfor i = 0, n - 1 do\n for j = 0, n - 1 do\n ret = ret + check(i, j)\n end\nend\nprint(ret)\n", "language": "Lua", "metadata": {"date": 1565702905, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p03364.html", "problem_id": "p03364", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03364/input.txt", "sample_output_relpath": "derived/input_output/data/p03364/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03364/Lua/s660889134.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s660889134", "user_id": "u120582723"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "local n = io.read(\"*n\", \"*l\")\nlocal rowmap = {}\nfor i = 1, n do\n local tmps = io.read()\n rowmap[i] = {}\n tmps = tmps .. tmps\n for j = 1, n do\n rowmap[i][j] = tmps:sub(n + 2 - j, n + 2 - j + n - 1)\n end\nend\n\nlocal colmap = {}\nfor i = 1, n do\n local tmps = \"\"\n for j = 1, n do\n tmps = tmps .. rowmap[j][1]:sub(i, i)\n end\n colmap[i] = {}\n tmps = tmps .. tmps\n for j = 1, n do\n colmap[i][j] = tmps:sub(n + 2 - j, n + 2 - j + n - 1)\n end\nend\n\nlocal function check(r, c)\n for k = 1, n do\n local row_tgt = k + n - r\n if n < row_tgt then row_tgt = row_tgt - n end\n local row_ofst = 1 + c\n local col_tgt = k + n - c\n if n < col_tgt then col_tgt = col_tgt - n end\n local col_ofst = 1 + r\n if rowmap[row_tgt][row_ofst] ~= colmap[col_tgt][col_ofst] then return 0 end\n end\n return 1\nend\nlocal ret = 0\nfor i = 0, n - 1 do\n for j = 0, n - 1 do\n ret = ret + check(i, j)\n end\nend\nprint(ret)\n", "problem_context": "Score : 500 points\n\nProblem Statement\n\nSnuke has two boards, each divided into a grid with N rows and N columns.\nFor both of these boards, the square at the i-th row from the top and the j-th column from the left is called Square (i,j).\n\nThere is a lowercase English letter written in each square on the first board. The letter written in Square (i,j) is S_{i,j}. On the second board, nothing is written yet.\n\nSnuke will write letters on the second board, as follows:\n\nFirst, choose two integers A and B ( 0 \\leq A, B < N ).\n\nWrite one letter in each square on the second board.\nSpecifically, write the letter written in Square ( i+A, j+B ) on the first board into Square (i,j) on the second board.\nHere, the k-th row is also represented as the (N+k)-th row, and the k-th column is also represented as the (N+k)-th column.\n\nAfter this operation, the second board is called a good board when, for every i and j ( 1 \\leq i, j \\leq N ), the letter in Square (i,j) and the letter in Square (j,i) are equal.\n\nFind the number of the ways to choose integers A and B ( 0 \\leq A, B < N ) such that the second board is a good board.\n\nConstraints\n\n1 \\leq N \\leq 300\n\nS_{i,j} ( 1 \\leq i, j \\leq N ) is a lowercase English letter.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS_{1,1}S_{1,2}..S_{1,N}\nS_{2,1}S_{2,2}..S_{2,N}\n:\nS_{N,1}S_{N,2}..S_{N,N}\n\nOutput\n\nPrint the number of the ways to choose integers A and B ( 0 \\leq A, B < N ) such that the second board is a good board.\n\nSample Input 1\n\n2\nab\nca\n\nSample Output 1\n\n2\n\nFor each pair of A and B, the second board will look as shown below:\n\nThe second board is a good board when (A,B) = (0,1) or (A,B) = (1,0), thus the answer is 2.\n\nSample Input 2\n\n4\naaaa\naaaa\naaaa\naaaa\n\nSample Output 2\n\n16\n\nEvery possible choice of A and B makes the second board good.\n\nSample Input 3\n\n5\nabcde\nfghij\nklmno\npqrst\nuvwxy\n\nSample Output 3\n\n0\n\nNo possible choice of A and B makes the second board good.", "sample_input": "2\nab\nca\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03364", "source_text": "Score : 500 points\n\nProblem Statement\n\nSnuke has two boards, each divided into a grid with N rows and N columns.\nFor both of these boards, the square at the i-th row from the top and the j-th column from the left is called Square (i,j).\n\nThere is a lowercase English letter written in each square on the first board. The letter written in Square (i,j) is S_{i,j}. On the second board, nothing is written yet.\n\nSnuke will write letters on the second board, as follows:\n\nFirst, choose two integers A and B ( 0 \\leq A, B < N ).\n\nWrite one letter in each square on the second board.\nSpecifically, write the letter written in Square ( i+A, j+B ) on the first board into Square (i,j) on the second board.\nHere, the k-th row is also represented as the (N+k)-th row, and the k-th column is also represented as the (N+k)-th column.\n\nAfter this operation, the second board is called a good board when, for every i and j ( 1 \\leq i, j \\leq N ), the letter in Square (i,j) and the letter in Square (j,i) are equal.\n\nFind the number of the ways to choose integers A and B ( 0 \\leq A, B < N ) such that the second board is a good board.\n\nConstraints\n\n1 \\leq N \\leq 300\n\nS_{i,j} ( 1 \\leq i, j \\leq N ) is a lowercase English letter.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS_{1,1}S_{1,2}..S_{1,N}\nS_{2,1}S_{2,2}..S_{2,N}\n:\nS_{N,1}S_{N,2}..S_{N,N}\n\nOutput\n\nPrint the number of the ways to choose integers A and B ( 0 \\leq A, B < N ) such that the second board is a good board.\n\nSample Input 1\n\n2\nab\nca\n\nSample Output 1\n\n2\n\nFor each pair of A and B, the second board will look as shown below:\n\nThe second board is a good board when (A,B) = (0,1) or (A,B) = (1,0), thus the answer is 2.\n\nSample Input 2\n\n4\naaaa\naaaa\naaaa\naaaa\n\nSample Output 2\n\n16\n\nEvery possible choice of A and B makes the second board good.\n\nSample Input 3\n\n5\nabcde\nfghij\nklmno\npqrst\nuvwxy\n\nSample Output 3\n\n0\n\nNo possible choice of A and B makes the second board good.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 924, "cpu_time_ms": 1394, "memory_kb": 62580}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s546370550", "group_id": "codeNet:p03364", "input_text": "local n = io.read(\"*n\", \"*l\")\nlocal rowmap = {}\nlocal coltmp = \"\"\nfor i = 1, n do\n local tmps = io.read()\n coltmp = coltmp .. tmps:sub(1, 1)\n rowmap[i] = {tmps}\n for j = 2, n do\n tmps = tmps:sub(n, n) .. tmps:sub(1, n - 1)\n rowmap[i][j] = tmps\n end\nend\n\nlocal colmap = {}\nfor i = 1, n do\n colmap[i] = {coltmp}\n for j = 2, n do\n coltmp = coltmp:sub(n, n) .. coltmp:sub(1, n - 1)\n colmap[i][j] = coltmp\n end\nend\n\nlocal function check(r, c)\n for k = 1, n do\n local row_tgt = k + n - r\n if n < row_tgt then row_tgt = row_tgt - n end\n local row_ofst = 1 + c\n local col_tgt = k + n - c\n if n < col_tgt then col_tgt = col_tgt - n end\n local col_ofst = 1 + r\n if rowmap[row_tgt][row_ofst] ~= colmap[col_tgt][col_ofst] then return 0 end\n end\n return 1\nend\nlocal ret = 0\nfor i = 0, n - 1 do\n for j = 0, n - 1 do\n ret = ret + check(i, j)\n end\nend\nprint(ret)\n", "language": "Lua", "metadata": {"date": 1565668125, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p03364.html", "problem_id": "p03364", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03364/input.txt", "sample_output_relpath": "derived/input_output/data/p03364/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03364/Lua/s546370550.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s546370550", "user_id": "u120582723"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "local n = io.read(\"*n\", \"*l\")\nlocal rowmap = {}\nlocal coltmp = \"\"\nfor i = 1, n do\n local tmps = io.read()\n coltmp = coltmp .. tmps:sub(1, 1)\n rowmap[i] = {tmps}\n for j = 2, n do\n tmps = tmps:sub(n, n) .. tmps:sub(1, n - 1)\n rowmap[i][j] = tmps\n end\nend\n\nlocal colmap = {}\nfor i = 1, n do\n colmap[i] = {coltmp}\n for j = 2, n do\n coltmp = coltmp:sub(n, n) .. coltmp:sub(1, n - 1)\n colmap[i][j] = coltmp\n end\nend\n\nlocal function check(r, c)\n for k = 1, n do\n local row_tgt = k + n - r\n if n < row_tgt then row_tgt = row_tgt - n end\n local row_ofst = 1 + c\n local col_tgt = k + n - c\n if n < col_tgt then col_tgt = col_tgt - n end\n local col_ofst = 1 + r\n if rowmap[row_tgt][row_ofst] ~= colmap[col_tgt][col_ofst] then return 0 end\n end\n return 1\nend\nlocal ret = 0\nfor i = 0, n - 1 do\n for j = 0, n - 1 do\n ret = ret + check(i, j)\n end\nend\nprint(ret)\n", "problem_context": "Score : 500 points\n\nProblem Statement\n\nSnuke has two boards, each divided into a grid with N rows and N columns.\nFor both of these boards, the square at the i-th row from the top and the j-th column from the left is called Square (i,j).\n\nThere is a lowercase English letter written in each square on the first board. The letter written in Square (i,j) is S_{i,j}. On the second board, nothing is written yet.\n\nSnuke will write letters on the second board, as follows:\n\nFirst, choose two integers A and B ( 0 \\leq A, B < N ).\n\nWrite one letter in each square on the second board.\nSpecifically, write the letter written in Square ( i+A, j+B ) on the first board into Square (i,j) on the second board.\nHere, the k-th row is also represented as the (N+k)-th row, and the k-th column is also represented as the (N+k)-th column.\n\nAfter this operation, the second board is called a good board when, for every i and j ( 1 \\leq i, j \\leq N ), the letter in Square (i,j) and the letter in Square (j,i) are equal.\n\nFind the number of the ways to choose integers A and B ( 0 \\leq A, B < N ) such that the second board is a good board.\n\nConstraints\n\n1 \\leq N \\leq 300\n\nS_{i,j} ( 1 \\leq i, j \\leq N ) is a lowercase English letter.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS_{1,1}S_{1,2}..S_{1,N}\nS_{2,1}S_{2,2}..S_{2,N}\n:\nS_{N,1}S_{N,2}..S_{N,N}\n\nOutput\n\nPrint the number of the ways to choose integers A and B ( 0 \\leq A, B < N ) such that the second board is a good board.\n\nSample Input 1\n\n2\nab\nca\n\nSample Output 1\n\n2\n\nFor each pair of A and B, the second board will look as shown below:\n\nThe second board is a good board when (A,B) = (0,1) or (A,B) = (1,0), thus the answer is 2.\n\nSample Input 2\n\n4\naaaa\naaaa\naaaa\naaaa\n\nSample Output 2\n\n16\n\nEvery possible choice of A and B makes the second board good.\n\nSample Input 3\n\n5\nabcde\nfghij\nklmno\npqrst\nuvwxy\n\nSample Output 3\n\n0\n\nNo possible choice of A and B makes the second board good.", "sample_input": "2\nab\nca\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03364", "source_text": "Score : 500 points\n\nProblem Statement\n\nSnuke has two boards, each divided into a grid with N rows and N columns.\nFor both of these boards, the square at the i-th row from the top and the j-th column from the left is called Square (i,j).\n\nThere is a lowercase English letter written in each square on the first board. The letter written in Square (i,j) is S_{i,j}. On the second board, nothing is written yet.\n\nSnuke will write letters on the second board, as follows:\n\nFirst, choose two integers A and B ( 0 \\leq A, B < N ).\n\nWrite one letter in each square on the second board.\nSpecifically, write the letter written in Square ( i+A, j+B ) on the first board into Square (i,j) on the second board.\nHere, the k-th row is also represented as the (N+k)-th row, and the k-th column is also represented as the (N+k)-th column.\n\nAfter this operation, the second board is called a good board when, for every i and j ( 1 \\leq i, j \\leq N ), the letter in Square (i,j) and the letter in Square (j,i) are equal.\n\nFind the number of the ways to choose integers A and B ( 0 \\leq A, B < N ) such that the second board is a good board.\n\nConstraints\n\n1 \\leq N \\leq 300\n\nS_{i,j} ( 1 \\leq i, j \\leq N ) is a lowercase English letter.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS_{1,1}S_{1,2}..S_{1,N}\nS_{2,1}S_{2,2}..S_{2,N}\n:\nS_{N,1}S_{N,2}..S_{N,N}\n\nOutput\n\nPrint the number of the ways to choose integers A and B ( 0 \\leq A, B < N ) such that the second board is a good board.\n\nSample Input 1\n\n2\nab\nca\n\nSample Output 1\n\n2\n\nFor each pair of A and B, the second board will look as shown below:\n\nThe second board is a good board when (A,B) = (0,1) or (A,B) = (1,0), thus the answer is 2.\n\nSample Input 2\n\n4\naaaa\naaaa\naaaa\naaaa\n\nSample Output 2\n\n16\n\nEvery possible choice of A and B makes the second board good.\n\nSample Input 3\n\n5\nabcde\nfghij\nklmno\npqrst\nuvwxy\n\nSample Output 3\n\n0\n\nNo possible choice of A and B makes the second board good.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 896, "cpu_time_ms": 1603, "memory_kb": 41720}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s677935782", "group_id": "codeNet:p03364", "input_text": "local n = io.read(\"*n\", \"*l\")\nlocal row = {}\nfor i = 1, n do\n row[i] = io.read()\nend\nlocal col = {}\nfor i = 1, n do col[i] = \"\" end\nfor i = 1, n do\n for j = 1, n do\n col[i] = col[i] .. row[j]:sub(i, i)\n end\nend\n\nlocal colmap = {}\nfor i = 1, n do\n local tmps = col[i]\n colmap[i] = {tmps}\n for j = 2, n do\n tmps = tmps:sub(n, n) .. tmps:sub(1, n - 1)\n colmap[i][j] = tmps\n end\nend\nlocal rowmap = {}\nfor i = 1, n do\n local tmps = row[i]\n rowmap[i] = {tmps}\n for j = 2, n do\n tmps = tmps:sub(n, n) .. tmps:sub(1, n - 1)\n rowmap[i][j] = tmps\n end\nend\n\nlocal function check(r, c)\n for k = 1, n do\n local row_tgt = k + n - r\n if n < row_tgt then row_tgt = row_tgt - n end\n local row_ofst = 1 + c\n local col_tgt = k + n - c\n if n < col_tgt then col_tgt = col_tgt - n end\n local col_ofst = 1 + r\n if rowmap[row_tgt][row_ofst] ~= colmap[col_tgt][col_ofst] then return 0 end\n end\n return 1\nend\n\nlocal ret = 0\nfor i = 0, n - 1 do\n for j = 0, n - 1 do\n ret = ret + check(i, j)\n end\nend\nprint(ret)\n", "language": "Lua", "metadata": {"date": 1565665996, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p03364.html", "problem_id": "p03364", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03364/input.txt", "sample_output_relpath": "derived/input_output/data/p03364/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03364/Lua/s677935782.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s677935782", "user_id": "u120582723"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "local n = io.read(\"*n\", \"*l\")\nlocal row = {}\nfor i = 1, n do\n row[i] = io.read()\nend\nlocal col = {}\nfor i = 1, n do col[i] = \"\" end\nfor i = 1, n do\n for j = 1, n do\n col[i] = col[i] .. row[j]:sub(i, i)\n end\nend\n\nlocal colmap = {}\nfor i = 1, n do\n local tmps = col[i]\n colmap[i] = {tmps}\n for j = 2, n do\n tmps = tmps:sub(n, n) .. tmps:sub(1, n - 1)\n colmap[i][j] = tmps\n end\nend\nlocal rowmap = {}\nfor i = 1, n do\n local tmps = row[i]\n rowmap[i] = {tmps}\n for j = 2, n do\n tmps = tmps:sub(n, n) .. tmps:sub(1, n - 1)\n rowmap[i][j] = tmps\n end\nend\n\nlocal function check(r, c)\n for k = 1, n do\n local row_tgt = k + n - r\n if n < row_tgt then row_tgt = row_tgt - n end\n local row_ofst = 1 + c\n local col_tgt = k + n - c\n if n < col_tgt then col_tgt = col_tgt - n end\n local col_ofst = 1 + r\n if rowmap[row_tgt][row_ofst] ~= colmap[col_tgt][col_ofst] then return 0 end\n end\n return 1\nend\n\nlocal ret = 0\nfor i = 0, n - 1 do\n for j = 0, n - 1 do\n ret = ret + check(i, j)\n end\nend\nprint(ret)\n", "problem_context": "Score : 500 points\n\nProblem Statement\n\nSnuke has two boards, each divided into a grid with N rows and N columns.\nFor both of these boards, the square at the i-th row from the top and the j-th column from the left is called Square (i,j).\n\nThere is a lowercase English letter written in each square on the first board. The letter written in Square (i,j) is S_{i,j}. On the second board, nothing is written yet.\n\nSnuke will write letters on the second board, as follows:\n\nFirst, choose two integers A and B ( 0 \\leq A, B < N ).\n\nWrite one letter in each square on the second board.\nSpecifically, write the letter written in Square ( i+A, j+B ) on the first board into Square (i,j) on the second board.\nHere, the k-th row is also represented as the (N+k)-th row, and the k-th column is also represented as the (N+k)-th column.\n\nAfter this operation, the second board is called a good board when, for every i and j ( 1 \\leq i, j \\leq N ), the letter in Square (i,j) and the letter in Square (j,i) are equal.\n\nFind the number of the ways to choose integers A and B ( 0 \\leq A, B < N ) such that the second board is a good board.\n\nConstraints\n\n1 \\leq N \\leq 300\n\nS_{i,j} ( 1 \\leq i, j \\leq N ) is a lowercase English letter.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS_{1,1}S_{1,2}..S_{1,N}\nS_{2,1}S_{2,2}..S_{2,N}\n:\nS_{N,1}S_{N,2}..S_{N,N}\n\nOutput\n\nPrint the number of the ways to choose integers A and B ( 0 \\leq A, B < N ) such that the second board is a good board.\n\nSample Input 1\n\n2\nab\nca\n\nSample Output 1\n\n2\n\nFor each pair of A and B, the second board will look as shown below:\n\nThe second board is a good board when (A,B) = (0,1) or (A,B) = (1,0), thus the answer is 2.\n\nSample Input 2\n\n4\naaaa\naaaa\naaaa\naaaa\n\nSample Output 2\n\n16\n\nEvery possible choice of A and B makes the second board good.\n\nSample Input 3\n\n5\nabcde\nfghij\nklmno\npqrst\nuvwxy\n\nSample Output 3\n\n0\n\nNo possible choice of A and B makes the second board good.", "sample_input": "2\nab\nca\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03364", "source_text": "Score : 500 points\n\nProblem Statement\n\nSnuke has two boards, each divided into a grid with N rows and N columns.\nFor both of these boards, the square at the i-th row from the top and the j-th column from the left is called Square (i,j).\n\nThere is a lowercase English letter written in each square on the first board. The letter written in Square (i,j) is S_{i,j}. On the second board, nothing is written yet.\n\nSnuke will write letters on the second board, as follows:\n\nFirst, choose two integers A and B ( 0 \\leq A, B < N ).\n\nWrite one letter in each square on the second board.\nSpecifically, write the letter written in Square ( i+A, j+B ) on the first board into Square (i,j) on the second board.\nHere, the k-th row is also represented as the (N+k)-th row, and the k-th column is also represented as the (N+k)-th column.\n\nAfter this operation, the second board is called a good board when, for every i and j ( 1 \\leq i, j \\leq N ), the letter in Square (i,j) and the letter in Square (j,i) are equal.\n\nFind the number of the ways to choose integers A and B ( 0 \\leq A, B < N ) such that the second board is a good board.\n\nConstraints\n\n1 \\leq N \\leq 300\n\nS_{i,j} ( 1 \\leq i, j \\leq N ) is a lowercase English letter.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS_{1,1}S_{1,2}..S_{1,N}\nS_{2,1}S_{2,2}..S_{2,N}\n:\nS_{N,1}S_{N,2}..S_{N,N}\n\nOutput\n\nPrint the number of the ways to choose integers A and B ( 0 \\leq A, B < N ) such that the second board is a good board.\n\nSample Input 1\n\n2\nab\nca\n\nSample Output 1\n\n2\n\nFor each pair of A and B, the second board will look as shown below:\n\nThe second board is a good board when (A,B) = (0,1) or (A,B) = (1,0), thus the answer is 2.\n\nSample Input 2\n\n4\naaaa\naaaa\naaaa\naaaa\n\nSample Output 2\n\n16\n\nEvery possible choice of A and B makes the second board good.\n\nSample Input 3\n\n5\nabcde\nfghij\nklmno\npqrst\nuvwxy\n\nSample Output 3\n\n0\n\nNo possible choice of A and B makes the second board good.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1039, "cpu_time_ms": 2103, "memory_kb": 60916}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s774363783", "group_id": "codeNet:p03369", "input_text": "s = io.read()\nr = 700\nfor i = 1, 3 do if s:sub(i, i) == \"o\" then r = r + 100 end end\nprint(r)", "language": "Lua", "metadata": {"date": 1569039127, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03369.html", "problem_id": "p03369", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03369/input.txt", "sample_output_relpath": "derived/input_output/data/p03369/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03369/Lua/s774363783.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s774363783", "user_id": "u120582723"}, "prompt_components": {"gold_output": "900\n", "input_to_evaluate": "s = io.read()\nr = 700\nfor i = 1, 3 do if s:sub(i, i) == \"o\" then r = r + 100 end end\nprint(r)", "problem_context": "Score : 100 points\n\nProblem Statement\n\nIn \"Takahashi-ya\", a ramen restaurant, a bowl of ramen costs 700 yen (the currency of Japan), plus 100 yen for each kind of topping (boiled egg, sliced pork, green onions).\n\nA customer ordered a bowl of ramen and told which toppings to put on his ramen to a clerk. The clerk took a memo of the order as a string S. S is three characters long, and if the first character in S is o, it means the ramen should be topped with boiled egg; if that character is x, it means the ramen should not be topped with boiled egg. Similarly, the second and third characters in S mean the presence or absence of sliced pork and green onions on top of the ramen.\n\nWrite a program that, when S is given, prints the price of the corresponding bowl of ramen.\n\nConstraints\n\nS is a string of length 3.\n\nEach character in S is o or x.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the price of the bowl of ramen corresponding to S.\n\nSample Input 1\n\noxo\n\nSample Output 1\n\n900\n\nThe price of a ramen topped with two kinds of toppings, boiled egg and green onions, is 700 + 100 \\times 2 = 900 yen.\n\nSample Input 2\n\nooo\n\nSample Output 2\n\n1000\n\nThe price of a ramen topped with all three kinds of toppings is 700 + 100 \\times 3 = 1000 yen.\n\nSample Input 3\n\nxxx\n\nSample Output 3\n\n700\n\nThe price of a ramen without any toppings is 700 yen.", "sample_input": "oxo\n"}, "reference_outputs": ["900\n"], "source_document_id": "p03369", "source_text": "Score : 100 points\n\nProblem Statement\n\nIn \"Takahashi-ya\", a ramen restaurant, a bowl of ramen costs 700 yen (the currency of Japan), plus 100 yen for each kind of topping (boiled egg, sliced pork, green onions).\n\nA customer ordered a bowl of ramen and told which toppings to put on his ramen to a clerk. The clerk took a memo of the order as a string S. S is three characters long, and if the first character in S is o, it means the ramen should be topped with boiled egg; if that character is x, it means the ramen should not be topped with boiled egg. Similarly, the second and third characters in S mean the presence or absence of sliced pork and green onions on top of the ramen.\n\nWrite a program that, when S is given, prints the price of the corresponding bowl of ramen.\n\nConstraints\n\nS is a string of length 3.\n\nEach character in S is o or x.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the price of the bowl of ramen corresponding to S.\n\nSample Input 1\n\noxo\n\nSample Output 1\n\n900\n\nThe price of a ramen topped with two kinds of toppings, boiled egg and green onions, is 700 + 100 \\times 2 = 900 yen.\n\nSample Input 2\n\nooo\n\nSample Output 2\n\n1000\n\nThe price of a ramen topped with all three kinds of toppings is 700 + 100 \\times 3 = 1000 yen.\n\nSample Input 3\n\nxxx\n\nSample Output 3\n\n700\n\nThe price of a ramen without any toppings is 700 yen.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 93, "cpu_time_ms": 7, "memory_kb": 760}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s214627381", "group_id": "codeNet:p03369", "input_text": "a,b=io.read():gsub(\"o\",\"\")\nprint(700+b*100)", "language": "Lua", "metadata": {"date": 1551840904, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p03369.html", "problem_id": "p03369", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03369/input.txt", "sample_output_relpath": "derived/input_output/data/p03369/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03369/Lua/s214627381.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s214627381", "user_id": "u837412668"}, "prompt_components": {"gold_output": "900\n", "input_to_evaluate": "a,b=io.read():gsub(\"o\",\"\")\nprint(700+b*100)", "problem_context": "Score : 100 points\n\nProblem Statement\n\nIn \"Takahashi-ya\", a ramen restaurant, a bowl of ramen costs 700 yen (the currency of Japan), plus 100 yen for each kind of topping (boiled egg, sliced pork, green onions).\n\nA customer ordered a bowl of ramen and told which toppings to put on his ramen to a clerk. The clerk took a memo of the order as a string S. S is three characters long, and if the first character in S is o, it means the ramen should be topped with boiled egg; if that character is x, it means the ramen should not be topped with boiled egg. Similarly, the second and third characters in S mean the presence or absence of sliced pork and green onions on top of the ramen.\n\nWrite a program that, when S is given, prints the price of the corresponding bowl of ramen.\n\nConstraints\n\nS is a string of length 3.\n\nEach character in S is o or x.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the price of the bowl of ramen corresponding to S.\n\nSample Input 1\n\noxo\n\nSample Output 1\n\n900\n\nThe price of a ramen topped with two kinds of toppings, boiled egg and green onions, is 700 + 100 \\times 2 = 900 yen.\n\nSample Input 2\n\nooo\n\nSample Output 2\n\n1000\n\nThe price of a ramen topped with all three kinds of toppings is 700 + 100 \\times 3 = 1000 yen.\n\nSample Input 3\n\nxxx\n\nSample Output 3\n\n700\n\nThe price of a ramen without any toppings is 700 yen.", "sample_input": "oxo\n"}, "reference_outputs": ["900\n"], "source_document_id": "p03369", "source_text": "Score : 100 points\n\nProblem Statement\n\nIn \"Takahashi-ya\", a ramen restaurant, a bowl of ramen costs 700 yen (the currency of Japan), plus 100 yen for each kind of topping (boiled egg, sliced pork, green onions).\n\nA customer ordered a bowl of ramen and told which toppings to put on his ramen to a clerk. The clerk took a memo of the order as a string S. S is three characters long, and if the first character in S is o, it means the ramen should be topped with boiled egg; if that character is x, it means the ramen should not be topped with boiled egg. Similarly, the second and third characters in S mean the presence or absence of sliced pork and green onions on top of the ramen.\n\nWrite a program that, when S is given, prints the price of the corresponding bowl of ramen.\n\nConstraints\n\nS is a string of length 3.\n\nEach character in S is o or x.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the price of the bowl of ramen corresponding to S.\n\nSample Input 1\n\noxo\n\nSample Output 1\n\n900\n\nThe price of a ramen topped with two kinds of toppings, boiled egg and green onions, is 700 + 100 \\times 2 = 900 yen.\n\nSample Input 2\n\nooo\n\nSample Output 2\n\n1000\n\nThe price of a ramen topped with all three kinds of toppings is 700 + 100 \\times 3 = 1000 yen.\n\nSample Input 3\n\nxxx\n\nSample Output 3\n\n700\n\nThe price of a ramen without any toppings is 700 yen.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 43, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s506583501", "group_id": "codeNet:p03369", "input_text": "S=io.read()\ncost=700\nfor i=1,#S do\n if string.sub(S,i,i)==\"o\" then\n cost=cost+100\n end\nend\nprint(cost)\n ", "language": "Lua", "metadata": {"date": 1550787550, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03369.html", "problem_id": "p03369", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03369/input.txt", "sample_output_relpath": "derived/input_output/data/p03369/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03369/Lua/s506583501.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s506583501", "user_id": "u015229643"}, "prompt_components": {"gold_output": "900\n", "input_to_evaluate": "S=io.read()\ncost=700\nfor i=1,#S do\n if string.sub(S,i,i)==\"o\" then\n cost=cost+100\n end\nend\nprint(cost)\n ", "problem_context": "Score : 100 points\n\nProblem Statement\n\nIn \"Takahashi-ya\", a ramen restaurant, a bowl of ramen costs 700 yen (the currency of Japan), plus 100 yen for each kind of topping (boiled egg, sliced pork, green onions).\n\nA customer ordered a bowl of ramen and told which toppings to put on his ramen to a clerk. The clerk took a memo of the order as a string S. S is three characters long, and if the first character in S is o, it means the ramen should be topped with boiled egg; if that character is x, it means the ramen should not be topped with boiled egg. Similarly, the second and third characters in S mean the presence or absence of sliced pork and green onions on top of the ramen.\n\nWrite a program that, when S is given, prints the price of the corresponding bowl of ramen.\n\nConstraints\n\nS is a string of length 3.\n\nEach character in S is o or x.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the price of the bowl of ramen corresponding to S.\n\nSample Input 1\n\noxo\n\nSample Output 1\n\n900\n\nThe price of a ramen topped with two kinds of toppings, boiled egg and green onions, is 700 + 100 \\times 2 = 900 yen.\n\nSample Input 2\n\nooo\n\nSample Output 2\n\n1000\n\nThe price of a ramen topped with all three kinds of toppings is 700 + 100 \\times 3 = 1000 yen.\n\nSample Input 3\n\nxxx\n\nSample Output 3\n\n700\n\nThe price of a ramen without any toppings is 700 yen.", "sample_input": "oxo\n"}, "reference_outputs": ["900\n"], "source_document_id": "p03369", "source_text": "Score : 100 points\n\nProblem Statement\n\nIn \"Takahashi-ya\", a ramen restaurant, a bowl of ramen costs 700 yen (the currency of Japan), plus 100 yen for each kind of topping (boiled egg, sliced pork, green onions).\n\nA customer ordered a bowl of ramen and told which toppings to put on his ramen to a clerk. The clerk took a memo of the order as a string S. S is three characters long, and if the first character in S is o, it means the ramen should be topped with boiled egg; if that character is x, it means the ramen should not be topped with boiled egg. Similarly, the second and third characters in S mean the presence or absence of sliced pork and green onions on top of the ramen.\n\nWrite a program that, when S is given, prints the price of the corresponding bowl of ramen.\n\nConstraints\n\nS is a string of length 3.\n\nEach character in S is o or x.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the price of the bowl of ramen corresponding to S.\n\nSample Input 1\n\noxo\n\nSample Output 1\n\n900\n\nThe price of a ramen topped with two kinds of toppings, boiled egg and green onions, is 700 + 100 \\times 2 = 900 yen.\n\nSample Input 2\n\nooo\n\nSample Output 2\n\n1000\n\nThe price of a ramen topped with all three kinds of toppings is 700 + 100 \\times 3 = 1000 yen.\n\nSample Input 3\n\nxxx\n\nSample Output 3\n\n700\n\nThe price of a ramen without any toppings is 700 yen.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 110, "cpu_time_ms": 8, "memory_kb": 888}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s911668213", "group_id": "codeNet:p03369", "input_text": "s = io.read()\nif s == \"ooo\" then\n print(1000)\nelseif s == \"xoo\" then\n print(900)\nelseif s == \"oxo\" then\n print(900)\nelseif s == \"oox\" then\n print(800)\nelseif s == \"xxo\" then\n print(800)\nelseif s == \"oxx\" then\n print(800)\nelseif s == \"xox\" then\n print(800)\nelse\n print(700)\nend", "language": "Lua", "metadata": {"date": 1528914383, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03369.html", "problem_id": "p03369", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03369/input.txt", "sample_output_relpath": "derived/input_output/data/p03369/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03369/Lua/s911668213.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s911668213", "user_id": "u544732702"}, "prompt_components": {"gold_output": "900\n", "input_to_evaluate": "s = io.read()\nif s == \"ooo\" then\n print(1000)\nelseif s == \"xoo\" then\n print(900)\nelseif s == \"oxo\" then\n print(900)\nelseif s == \"oox\" then\n print(800)\nelseif s == \"xxo\" then\n print(800)\nelseif s == \"oxx\" then\n print(800)\nelseif s == \"xox\" then\n print(800)\nelse\n print(700)\nend", "problem_context": "Score : 100 points\n\nProblem Statement\n\nIn \"Takahashi-ya\", a ramen restaurant, a bowl of ramen costs 700 yen (the currency of Japan), plus 100 yen for each kind of topping (boiled egg, sliced pork, green onions).\n\nA customer ordered a bowl of ramen and told which toppings to put on his ramen to a clerk. The clerk took a memo of the order as a string S. S is three characters long, and if the first character in S is o, it means the ramen should be topped with boiled egg; if that character is x, it means the ramen should not be topped with boiled egg. Similarly, the second and third characters in S mean the presence or absence of sliced pork and green onions on top of the ramen.\n\nWrite a program that, when S is given, prints the price of the corresponding bowl of ramen.\n\nConstraints\n\nS is a string of length 3.\n\nEach character in S is o or x.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the price of the bowl of ramen corresponding to S.\n\nSample Input 1\n\noxo\n\nSample Output 1\n\n900\n\nThe price of a ramen topped with two kinds of toppings, boiled egg and green onions, is 700 + 100 \\times 2 = 900 yen.\n\nSample Input 2\n\nooo\n\nSample Output 2\n\n1000\n\nThe price of a ramen topped with all three kinds of toppings is 700 + 100 \\times 3 = 1000 yen.\n\nSample Input 3\n\nxxx\n\nSample Output 3\n\n700\n\nThe price of a ramen without any toppings is 700 yen.", "sample_input": "oxo\n"}, "reference_outputs": ["900\n"], "source_document_id": "p03369", "source_text": "Score : 100 points\n\nProblem Statement\n\nIn \"Takahashi-ya\", a ramen restaurant, a bowl of ramen costs 700 yen (the currency of Japan), plus 100 yen for each kind of topping (boiled egg, sliced pork, green onions).\n\nA customer ordered a bowl of ramen and told which toppings to put on his ramen to a clerk. The clerk took a memo of the order as a string S. S is three characters long, and if the first character in S is o, it means the ramen should be topped with boiled egg; if that character is x, it means the ramen should not be topped with boiled egg. Similarly, the second and third characters in S mean the presence or absence of sliced pork and green onions on top of the ramen.\n\nWrite a program that, when S is given, prints the price of the corresponding bowl of ramen.\n\nConstraints\n\nS is a string of length 3.\n\nEach character in S is o or x.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the price of the bowl of ramen corresponding to S.\n\nSample Input 1\n\noxo\n\nSample Output 1\n\n900\n\nThe price of a ramen topped with two kinds of toppings, boiled egg and green onions, is 700 + 100 \\times 2 = 900 yen.\n\nSample Input 2\n\nooo\n\nSample Output 2\n\n1000\n\nThe price of a ramen topped with all three kinds of toppings is 700 + 100 \\times 3 = 1000 yen.\n\nSample Input 3\n\nxxx\n\nSample Output 3\n\n700\n\nThe price of a ramen without any toppings is 700 yen.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 284, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s180112702", "group_id": "codeNet:p03370", "input_text": "n,x=io.read(\"*n\",\"*n\")\nMin=200000\nfor i=1,n do\n\tm=io.read(\"*n\")\n\tif Min>m then Min=m end\n\tx=x-m\nend\nprint(n+math.floor(x/Min))", "language": "Lua", "metadata": {"date": 1524406680, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p03370.html", "problem_id": "p03370", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03370/input.txt", "sample_output_relpath": "derived/input_output/data/p03370/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03370/Lua/s180112702.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s180112702", "user_id": "u781091740"}, "prompt_components": {"gold_output": "9\n", "input_to_evaluate": "n,x=io.read(\"*n\",\"*n\")\nMin=200000\nfor i=1,n do\n\tm=io.read(\"*n\")\n\tif Min>m then Min=m end\n\tx=x-m\nend\nprint(n+math.floor(x/Min))", "problem_context": "Score : 200 points\n\nProblem Statement\n\nAkaki, a patissier, can make N kinds of doughnut using only a certain powder called \"Okashi no Moto\" (literally \"material of pastry\", simply called Moto below) as ingredient. These doughnuts are called Doughnut 1, Doughnut 2, ..., Doughnut N. In order to make one Doughnut i (1 ≤ i ≤ N), she needs to consume m_i grams of Moto. She cannot make a non-integer number of doughnuts, such as 0.5 doughnuts.\n\nNow, she has X grams of Moto. She decides to make as many doughnuts as possible for a party tonight. However, since the tastes of the guests differ, she will obey the following condition:\n\nFor each of the N kinds of doughnuts, make at least one doughnut of that kind.\n\nAt most how many doughnuts can be made here? She does not necessarily need to consume all of her Moto. Also, under the constraints of this problem, it is always possible to obey the condition.\n\nConstraints\n\n2 ≤ N ≤ 100\n\n1 ≤ m_i ≤ 1000\n\nm_1 + m_2 + ... + m_N ≤ X ≤ 10^5\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN X\nm_1\nm_2\n:\nm_N\n\nOutput\n\nPrint the maximum number of doughnuts that can be made under the condition.\n\nSample Input 1\n\n3 1000\n120\n100\n140\n\nSample Output 1\n\n9\n\nShe has 1000 grams of Moto and can make three kinds of doughnuts. If she makes one doughnut for each of the three kinds, she consumes 120 + 100 + 140 = 360 grams of Moto. From the 640 grams of Moto that remains here, she can make additional six Doughnuts 2. This is how she can made a total of nine doughnuts, which is the maximum.\n\nSample Input 2\n\n4 360\n90\n90\n90\n90\n\nSample Output 2\n\n4\n\nMaking one doughnut for each of the four kinds consumes all of her Moto.\n\nSample Input 3\n\n5 3000\n150\n130\n150\n130\n110\n\nSample Output 3\n\n26", "sample_input": "3 1000\n120\n100\n140\n"}, "reference_outputs": ["9\n"], "source_document_id": "p03370", "source_text": "Score : 200 points\n\nProblem Statement\n\nAkaki, a patissier, can make N kinds of doughnut using only a certain powder called \"Okashi no Moto\" (literally \"material of pastry\", simply called Moto below) as ingredient. These doughnuts are called Doughnut 1, Doughnut 2, ..., Doughnut N. In order to make one Doughnut i (1 ≤ i ≤ N), she needs to consume m_i grams of Moto. She cannot make a non-integer number of doughnuts, such as 0.5 doughnuts.\n\nNow, she has X grams of Moto. She decides to make as many doughnuts as possible for a party tonight. However, since the tastes of the guests differ, she will obey the following condition:\n\nFor each of the N kinds of doughnuts, make at least one doughnut of that kind.\n\nAt most how many doughnuts can be made here? She does not necessarily need to consume all of her Moto. Also, under the constraints of this problem, it is always possible to obey the condition.\n\nConstraints\n\n2 ≤ N ≤ 100\n\n1 ≤ m_i ≤ 1000\n\nm_1 + m_2 + ... + m_N ≤ X ≤ 10^5\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN X\nm_1\nm_2\n:\nm_N\n\nOutput\n\nPrint the maximum number of doughnuts that can be made under the condition.\n\nSample Input 1\n\n3 1000\n120\n100\n140\n\nSample Output 1\n\n9\n\nShe has 1000 grams of Moto and can make three kinds of doughnuts. If she makes one doughnut for each of the three kinds, she consumes 120 + 100 + 140 = 360 grams of Moto. From the 640 grams of Moto that remains here, she can make additional six Doughnuts 2. This is how she can made a total of nine doughnuts, which is the maximum.\n\nSample Input 2\n\n4 360\n90\n90\n90\n90\n\nSample Output 2\n\n4\n\nMaking one doughnut for each of the four kinds consumes all of her Moto.\n\nSample Input 3\n\n5 3000\n150\n130\n150\n130\n110\n\nSample Output 3\n\n26", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 126, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s469779341", "group_id": "codeNet:p03377", "input_text": "local a, b, x = io.read(\"*n\", \"*n\", \"*n\")\nif a <= x and x <= a + b then\n print(\"YES\")\nelse\n print(\"NO\")\nend\n", "language": "Lua", "metadata": {"date": 1563112308, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03377.html", "problem_id": "p03377", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03377/input.txt", "sample_output_relpath": "derived/input_output/data/p03377/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03377/Lua/s469779341.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s469779341", "user_id": "u120582723"}, "prompt_components": {"gold_output": "YES\n", "input_to_evaluate": "local a, b, x = io.read(\"*n\", \"*n\", \"*n\")\nif a <= x and x <= a + b then\n print(\"YES\")\nelse\n print(\"NO\")\nend\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nThere are a total of A + B cats and dogs.\nAmong them, A are known to be cats, but the remaining B are not known to be either cats or dogs.\n\nDetermine if it is possible that there are exactly X cats among these A + B animals.\n\nConstraints\n\n1 \\leq A \\leq 100\n\n1 \\leq B \\leq 100\n\n1 \\leq X \\leq 200\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B X\n\nOutput\n\nIf it is possible that there are exactly X cats, print YES; if it is impossible, print NO.\n\nSample Input 1\n\n3 5 4\n\nSample Output 1\n\nYES\n\nIf there are one cat and four dogs among the B = 5 animals, there are X = 4 cats in total.\n\nSample Input 2\n\n2 2 6\n\nSample Output 2\n\nNO\n\nEven if all of the B = 2 animals are cats, there are less than X = 6 cats in total.\n\nSample Input 3\n\n5 3 2\n\nSample Output 3\n\nNO\n\nEven if all of the B = 3 animals are dogs, there are more than X = 2 cats in total.", "sample_input": "3 5 4\n"}, "reference_outputs": ["YES\n"], "source_document_id": "p03377", "source_text": "Score : 100 points\n\nProblem Statement\n\nThere are a total of A + B cats and dogs.\nAmong them, A are known to be cats, but the remaining B are not known to be either cats or dogs.\n\nDetermine if it is possible that there are exactly X cats among these A + B animals.\n\nConstraints\n\n1 \\leq A \\leq 100\n\n1 \\leq B \\leq 100\n\n1 \\leq X \\leq 200\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B X\n\nOutput\n\nIf it is possible that there are exactly X cats, print YES; if it is impossible, print NO.\n\nSample Input 1\n\n3 5 4\n\nSample Output 1\n\nYES\n\nIf there are one cat and four dogs among the B = 5 animals, there are X = 4 cats in total.\n\nSample Input 2\n\n2 2 6\n\nSample Output 2\n\nNO\n\nEven if all of the B = 2 animals are cats, there are less than X = 6 cats in total.\n\nSample Input 3\n\n5 3 2\n\nSample Output 3\n\nNO\n\nEven if all of the B = 3 animals are dogs, there are more than X = 2 cats in total.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 110, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s744750626", "group_id": "codeNet:p03377", "input_text": "a,b,c=io.read():match(\"(.+)%s(.+)%s(.+)\")\nprint(a*1<=c*1 and c*1<=a+b and\"YES\"or\"N\")", "language": "Lua", "metadata": {"date": 1551840721, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03377.html", "problem_id": "p03377", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03377/input.txt", "sample_output_relpath": "derived/input_output/data/p03377/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03377/Lua/s744750626.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s744750626", "user_id": "u837412668"}, "prompt_components": {"gold_output": "YES\n", "input_to_evaluate": "a,b,c=io.read():match(\"(.+)%s(.+)%s(.+)\")\nprint(a*1<=c*1 and c*1<=a+b and\"YES\"or\"N\")", "problem_context": "Score : 100 points\n\nProblem Statement\n\nThere are a total of A + B cats and dogs.\nAmong them, A are known to be cats, but the remaining B are not known to be either cats or dogs.\n\nDetermine if it is possible that there are exactly X cats among these A + B animals.\n\nConstraints\n\n1 \\leq A \\leq 100\n\n1 \\leq B \\leq 100\n\n1 \\leq X \\leq 200\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B X\n\nOutput\n\nIf it is possible that there are exactly X cats, print YES; if it is impossible, print NO.\n\nSample Input 1\n\n3 5 4\n\nSample Output 1\n\nYES\n\nIf there are one cat and four dogs among the B = 5 animals, there are X = 4 cats in total.\n\nSample Input 2\n\n2 2 6\n\nSample Output 2\n\nNO\n\nEven if all of the B = 2 animals are cats, there are less than X = 6 cats in total.\n\nSample Input 3\n\n5 3 2\n\nSample Output 3\n\nNO\n\nEven if all of the B = 3 animals are dogs, there are more than X = 2 cats in total.", "sample_input": "3 5 4\n"}, "reference_outputs": ["YES\n"], "source_document_id": "p03377", "source_text": "Score : 100 points\n\nProblem Statement\n\nThere are a total of A + B cats and dogs.\nAmong them, A are known to be cats, but the remaining B are not known to be either cats or dogs.\n\nDetermine if it is possible that there are exactly X cats among these A + B animals.\n\nConstraints\n\n1 \\leq A \\leq 100\n\n1 \\leq B \\leq 100\n\n1 \\leq X \\leq 200\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B X\n\nOutput\n\nIf it is possible that there are exactly X cats, print YES; if it is impossible, print NO.\n\nSample Input 1\n\n3 5 4\n\nSample Output 1\n\nYES\n\nIf there are one cat and four dogs among the B = 5 animals, there are X = 4 cats in total.\n\nSample Input 2\n\n2 2 6\n\nSample Output 2\n\nNO\n\nEven if all of the B = 2 animals are cats, there are less than X = 6 cats in total.\n\nSample Input 3\n\n5 3 2\n\nSample Output 3\n\nNO\n\nEven if all of the B = 3 animals are dogs, there are more than X = 2 cats in total.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 84, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s168194517", "group_id": "codeNet:p03378", "input_text": "local N, M, X = io.read(\"*n\", \"*n\", \"*n\")\nlocal A = {}\nfor i = 1, M do\n A[i] = io.read(\"*n\")\nend\n\nlocal left = 0\nlocal right = 0\nfor i = 1, N+1 do\n for j = 1, M do\n if i == A[j] and X < i then\n right = right + 1\n elseif i == A[j] and X > i then\n left = left + 1\n end\n end\nend\n\nprint(math.min(left, right))", "language": "Lua", "metadata": {"date": 1586929068, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03378.html", "problem_id": "p03378", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03378/input.txt", "sample_output_relpath": "derived/input_output/data/p03378/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03378/Lua/s168194517.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s168194517", "user_id": "u045238009"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "local N, M, X = io.read(\"*n\", \"*n\", \"*n\")\nlocal A = {}\nfor i = 1, M do\n A[i] = io.read(\"*n\")\nend\n\nlocal left = 0\nlocal right = 0\nfor i = 1, N+1 do\n for j = 1, M do\n if i == A[j] and X < i then\n right = right + 1\n elseif i == A[j] and X > i then\n left = left + 1\n end\n end\nend\n\nprint(math.min(left, right))", "problem_context": "Score : 200 points\n\nProblem Statement\n\nThere are N + 1 squares arranged in a row, numbered 0, 1, ..., N from left to right.\n\nInitially, you are in Square X.\nYou can freely travel between adjacent squares. Your goal is to reach Square 0 or Square N.\nHowever, for each i = 1, 2, ..., M, there is a toll gate in Square A_i, and traveling to Square A_i incurs a cost of 1.\nIt is guaranteed that there is no toll gate in Square 0, Square X and Square N.\n\nFind the minimum cost incurred before reaching the goal.\n\nConstraints\n\n1 \\leq N \\leq 100\n\n1 \\leq M \\leq 100\n\n1 \\leq X \\leq N - 1\n\n1 \\leq A_1 < A_2 < ... < A_M \\leq N\n\nA_i \\neq X\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M X\nA_1 A_2 ... A_M\n\nOutput\n\nPrint the minimum cost incurred before reaching the goal.\n\nSample Input 1\n\n5 3 3\n1 2 4\n\nSample Output 1\n\n1\n\nThe optimal solution is as follows:\n\nFirst, travel from Square 3 to Square 4. Here, there is a toll gate in Square 4, so the cost of 1 is incurred.\n\nThen, travel from Square 4 to Square 5. This time, no cost is incurred.\n\nNow, we are in Square 5 and we have reached the goal.\n\nIn this case, the total cost incurred is 1.\n\nSample Input 2\n\n7 3 2\n4 5 6\n\nSample Output 2\n\n0\n\nWe may be able to reach the goal at no cost.\n\nSample Input 3\n\n10 7 5\n1 2 3 4 6 8 9\n\nSample Output 3\n\n3", "sample_input": "5 3 3\n1 2 4\n"}, "reference_outputs": ["1\n"], "source_document_id": "p03378", "source_text": "Score : 200 points\n\nProblem Statement\n\nThere are N + 1 squares arranged in a row, numbered 0, 1, ..., N from left to right.\n\nInitially, you are in Square X.\nYou can freely travel between adjacent squares. Your goal is to reach Square 0 or Square N.\nHowever, for each i = 1, 2, ..., M, there is a toll gate in Square A_i, and traveling to Square A_i incurs a cost of 1.\nIt is guaranteed that there is no toll gate in Square 0, Square X and Square N.\n\nFind the minimum cost incurred before reaching the goal.\n\nConstraints\n\n1 \\leq N \\leq 100\n\n1 \\leq M \\leq 100\n\n1 \\leq X \\leq N - 1\n\n1 \\leq A_1 < A_2 < ... < A_M \\leq N\n\nA_i \\neq X\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M X\nA_1 A_2 ... A_M\n\nOutput\n\nPrint the minimum cost incurred before reaching the goal.\n\nSample Input 1\n\n5 3 3\n1 2 4\n\nSample Output 1\n\n1\n\nThe optimal solution is as follows:\n\nFirst, travel from Square 3 to Square 4. Here, there is a toll gate in Square 4, so the cost of 1 is incurred.\n\nThen, travel from Square 4 to Square 5. This time, no cost is incurred.\n\nNow, we are in Square 5 and we have reached the goal.\n\nIn this case, the total cost incurred is 1.\n\nSample Input 2\n\n7 3 2\n4 5 6\n\nSample Output 2\n\n0\n\nWe may be able to reach the goal at no cost.\n\nSample Input 3\n\n10 7 5\n1 2 3 4 6 8 9\n\nSample Output 3\n\n3", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 357, "cpu_time_ms": 8, "memory_kb": 888}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s701410661", "group_id": "codeNet:p03378", "input_text": "local N=io.read(\"n\")\nlocal M=io.read(\"n\")\nlocal X=io.read(\"n\")\nlocal A={}\nlocal left=0\nfor i=1,M do\n A[i]=io.read(\"n\")\n if A[i]=right then\n print(left)\n end\nend\n", "language": "Lua", "metadata": {"date": 1550801619, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03379.html", "problem_id": "p03379", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03379/input.txt", "sample_output_relpath": "derived/input_output/data/p03379/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03379/Lua/s042755379.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s042755379", "user_id": "u015229643"}, "prompt_components": {"gold_output": "4\n3\n3\n4\n", "input_to_evaluate": "N=io.read(\"n\")\nX={}\nB={}\nfor i=1,N do\n X[i]=io.read(\"n\")\n B[i]=X[i]\nend\ntable.sort(B)\nleft=B[N//2]\nright=B[N//2+1]\nfor i=1,N do\n if X[i]<=left then\n print(right)\n \telseif X[i]>=right then\n print(left)\n end\nend\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nWhen l is an odd number, the median of l numbers a_1, a_2, ..., a_l is the (\\frac{l+1}{2})-th largest value among a_1, a_2, ..., a_l.\n\nYou are given N numbers X_1, X_2, ..., X_N, where N is an even number.\nFor each i = 1, 2, ..., N, let the median of X_1, X_2, ..., X_N excluding X_i, that is, the median of X_1, X_2, ..., X_{i-1}, X_{i+1}, ..., X_N be B_i.\n\nFind B_i for each i = 1, 2, ..., N.\n\nConstraints\n\n2 \\leq N \\leq 200000\n\nN is even.\n\n1 \\leq X_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nX_1 X_2 ... X_N\n\nOutput\n\nPrint N lines.\nThe i-th line should contain B_i.\n\nSample Input 1\n\n4\n2 4 4 3\n\nSample Output 1\n\n4\n3\n3\n4\n\nSince the median of X_2, X_3, X_4 is 4, B_1 = 4.\n\nSince the median of X_1, X_3, X_4 is 3, B_2 = 3.\n\nSince the median of X_1, X_2, X_4 is 3, B_3 = 3.\n\nSince the median of X_1, X_2, X_3 is 4, B_4 = 4.\n\nSample Input 2\n\n2\n1 2\n\nSample Output 2\n\n2\n1\n\nSample Input 3\n\n6\n5 5 4 4 3 3\n\nSample Output 3\n\n4\n4\n4\n4\n4\n4", "sample_input": "4\n2 4 4 3\n"}, "reference_outputs": ["4\n3\n3\n4\n"], "source_document_id": "p03379", "source_text": "Score : 300 points\n\nProblem Statement\n\nWhen l is an odd number, the median of l numbers a_1, a_2, ..., a_l is the (\\frac{l+1}{2})-th largest value among a_1, a_2, ..., a_l.\n\nYou are given N numbers X_1, X_2, ..., X_N, where N is an even number.\nFor each i = 1, 2, ..., N, let the median of X_1, X_2, ..., X_N excluding X_i, that is, the median of X_1, X_2, ..., X_{i-1}, X_{i+1}, ..., X_N be B_i.\n\nFind B_i for each i = 1, 2, ..., N.\n\nConstraints\n\n2 \\leq N \\leq 200000\n\nN is even.\n\n1 \\leq X_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nX_1 X_2 ... X_N\n\nOutput\n\nPrint N lines.\nThe i-th line should contain B_i.\n\nSample Input 1\n\n4\n2 4 4 3\n\nSample Output 1\n\n4\n3\n3\n4\n\nSince the median of X_2, X_3, X_4 is 4, B_1 = 4.\n\nSince the median of X_1, X_3, X_4 is 3, B_2 = 3.\n\nSince the median of X_1, X_2, X_4 is 3, B_3 = 3.\n\nSince the median of X_1, X_2, X_3 is 4, B_4 = 4.\n\nSample Input 2\n\n2\n1 2\n\nSample Output 2\n\n2\n1\n\nSample Input 3\n\n6\n5 5 4 4 3 3\n\nSample Output 3\n\n4\n4\n4\n4\n4\n4", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 221, "cpu_time_ms": 697, "memory_kb": 10588}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s967883860", "group_id": "codeNet:p03380", "input_text": "N=io.read(\"n\")\nlocal a={}\nfor i=1,N do\n\ta[i]=io.read(\"n\")\nend\nfunction c(n,m)\n\tlocal res=0\n\tif m<=n//2 then\n\t\tlocal s=1\n\t\tlocal k=1\n\t\tfor i=n,n-m+1,-1 do\n\t\t\ts=s*i\n\t\tend\n\t\tfor i=1,m do\n\t\t\tk=k*i\n\t\tend\n\t\tres=s//k\n\t\telse res=c(n,n-m)\n\tend\n\treturn res\nend\ntable.sort(a)\nlocal a1=a[1]\nlocal b1=a[2]\nlocal total=c(a1,b1)\nfor i=1,N-1 do\n\tfor j=i+1,N do\n\t\tif c(a[i],a[j])>total then\n\t\t\ttotal=c(a[i],a[j])\n\t\t\ta1=a[i]\n\t\t\tb1=a[j]\n\t\tend\n\tend\nend\nprint(a1,b1)\n", "language": "Lua", "metadata": {"date": 1550807151, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03380.html", "problem_id": "p03380", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03380/input.txt", "sample_output_relpath": "derived/input_output/data/p03380/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03380/Lua/s967883860.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s967883860", "user_id": "u015229643"}, "prompt_components": {"gold_output": "11 6\n", "input_to_evaluate": "N=io.read(\"n\")\nlocal a={}\nfor i=1,N do\n\ta[i]=io.read(\"n\")\nend\nfunction c(n,m)\n\tlocal res=0\n\tif m<=n//2 then\n\t\tlocal s=1\n\t\tlocal k=1\n\t\tfor i=n,n-m+1,-1 do\n\t\t\ts=s*i\n\t\tend\n\t\tfor i=1,m do\n\t\t\tk=k*i\n\t\tend\n\t\tres=s//k\n\t\telse res=c(n,n-m)\n\tend\n\treturn res\nend\ntable.sort(a)\nlocal a1=a[1]\nlocal b1=a[2]\nlocal total=c(a1,b1)\nfor i=1,N-1 do\n\tfor j=i+1,N do\n\t\tif c(a[i],a[j])>total then\n\t\t\ttotal=c(a[i],a[j])\n\t\t\ta1=a[i]\n\t\t\tb1=a[j]\n\t\tend\n\tend\nend\nprint(a1,b1)\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nLet {\\rm comb}(n,r) be the number of ways to choose r objects from among n objects, disregarding order.\nFrom n non-negative integers a_1, a_2, ..., a_n, select two numbers a_i > a_j so that {\\rm comb}(a_i,a_j) is maximized.\nIf there are multiple pairs that maximize the value, any of them is accepted.\n\nConstraints\n\n2 \\leq n \\leq 10^5\n\n0 \\leq a_i \\leq 10^9\n\na_1,a_2,...,a_n are pairwise distinct.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nn\na_1 a_2 ... a_n\n\nOutput\n\nPrint a_i and a_j that you selected, with a space in between.\n\nSample Input 1\n\n5\n6 9 4 2 11\n\nSample Output 1\n\n11 6\n\n\\rm{comb}(a_i,a_j) for each possible selection is as follows:\n\n\\rm{comb}(4,2)=6\n\n\\rm{comb}(6,2)=15\n\n\\rm{comb}(6,4)=15\n\n\\rm{comb}(9,2)=36\n\n\\rm{comb}(9,4)=126\n\n\\rm{comb}(9,6)=84\n\n\\rm{comb}(11,2)=55\n\n\\rm{comb}(11,4)=330\n\n\\rm{comb}(11,6)=462\n\n\\rm{comb}(11,9)=55\n\nThus, we should print 11 and 6.\n\nSample Input 2\n\n2\n100 0\n\nSample Output 2\n\n100 0", "sample_input": "5\n6 9 4 2 11\n"}, "reference_outputs": ["11 6\n"], "source_document_id": "p03380", "source_text": "Score : 400 points\n\nProblem Statement\n\nLet {\\rm comb}(n,r) be the number of ways to choose r objects from among n objects, disregarding order.\nFrom n non-negative integers a_1, a_2, ..., a_n, select two numbers a_i > a_j so that {\\rm comb}(a_i,a_j) is maximized.\nIf there are multiple pairs that maximize the value, any of them is accepted.\n\nConstraints\n\n2 \\leq n \\leq 10^5\n\n0 \\leq a_i \\leq 10^9\n\na_1,a_2,...,a_n are pairwise distinct.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nn\na_1 a_2 ... a_n\n\nOutput\n\nPrint a_i and a_j that you selected, with a space in between.\n\nSample Input 1\n\n5\n6 9 4 2 11\n\nSample Output 1\n\n11 6\n\n\\rm{comb}(a_i,a_j) for each possible selection is as follows:\n\n\\rm{comb}(4,2)=6\n\n\\rm{comb}(6,2)=15\n\n\\rm{comb}(6,4)=15\n\n\\rm{comb}(9,2)=36\n\n\\rm{comb}(9,4)=126\n\n\\rm{comb}(9,6)=84\n\n\\rm{comb}(11,2)=55\n\n\\rm{comb}(11,4)=330\n\n\\rm{comb}(11,6)=462\n\n\\rm{comb}(11,9)=55\n\nThus, we should print 11 and 6.\n\nSample Input 2\n\n2\n100 0\n\nSample Output 2\n\n100 0", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 446, "cpu_time_ms": 2103, "memory_kb": 2424}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s329964637", "group_id": "codeNet:p03380", "input_text": "N=io.read(\"n\")\nlocal a={}\nfor i=1,N do\n\ta[i]=io.read(\"n\")\nend\nfunction c(n,m)\n\tlocal res=0\n\tif m<=n//2 then\n\t\tlocal s=1\n\t\tlocal k=1\n\t\tfor i=n,n-m+1,-1 do\n\t\t\ts=s*i\n\t\tend\n\t\tfor i=1,m do\n\t\t\tk=k*i\n\t\tend\n\t\tres=s//k\n\t\telse res=c(n,n-m)\n\tend\n\treturn res\nend\ntable.sort(a)\nlocal a1=a[1]\nlocal b1=a[2]\nlocal total=c(a1,b1)\nfor i=1,N-1 do\n\tfor j=i,N do\n\t\tif c(a[i],a[j])>total then\n\t\t\ttotal=c(a[i],a[j])\n\t\t\ta1=a[i]\n\t\t\tb1=a[j]\n\t\tend\n\tend\nend\nprint(a1,b1)\n", "language": "Lua", "metadata": {"date": 1550806932, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03380.html", "problem_id": "p03380", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03380/input.txt", "sample_output_relpath": "derived/input_output/data/p03380/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03380/Lua/s329964637.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s329964637", "user_id": "u015229643"}, "prompt_components": {"gold_output": "11 6\n", "input_to_evaluate": "N=io.read(\"n\")\nlocal a={}\nfor i=1,N do\n\ta[i]=io.read(\"n\")\nend\nfunction c(n,m)\n\tlocal res=0\n\tif m<=n//2 then\n\t\tlocal s=1\n\t\tlocal k=1\n\t\tfor i=n,n-m+1,-1 do\n\t\t\ts=s*i\n\t\tend\n\t\tfor i=1,m do\n\t\t\tk=k*i\n\t\tend\n\t\tres=s//k\n\t\telse res=c(n,n-m)\n\tend\n\treturn res\nend\ntable.sort(a)\nlocal a1=a[1]\nlocal b1=a[2]\nlocal total=c(a1,b1)\nfor i=1,N-1 do\n\tfor j=i,N do\n\t\tif c(a[i],a[j])>total then\n\t\t\ttotal=c(a[i],a[j])\n\t\t\ta1=a[i]\n\t\t\tb1=a[j]\n\t\tend\n\tend\nend\nprint(a1,b1)\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nLet {\\rm comb}(n,r) be the number of ways to choose r objects from among n objects, disregarding order.\nFrom n non-negative integers a_1, a_2, ..., a_n, select two numbers a_i > a_j so that {\\rm comb}(a_i,a_j) is maximized.\nIf there are multiple pairs that maximize the value, any of them is accepted.\n\nConstraints\n\n2 \\leq n \\leq 10^5\n\n0 \\leq a_i \\leq 10^9\n\na_1,a_2,...,a_n are pairwise distinct.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nn\na_1 a_2 ... a_n\n\nOutput\n\nPrint a_i and a_j that you selected, with a space in between.\n\nSample Input 1\n\n5\n6 9 4 2 11\n\nSample Output 1\n\n11 6\n\n\\rm{comb}(a_i,a_j) for each possible selection is as follows:\n\n\\rm{comb}(4,2)=6\n\n\\rm{comb}(6,2)=15\n\n\\rm{comb}(6,4)=15\n\n\\rm{comb}(9,2)=36\n\n\\rm{comb}(9,4)=126\n\n\\rm{comb}(9,6)=84\n\n\\rm{comb}(11,2)=55\n\n\\rm{comb}(11,4)=330\n\n\\rm{comb}(11,6)=462\n\n\\rm{comb}(11,9)=55\n\nThus, we should print 11 and 6.\n\nSample Input 2\n\n2\n100 0\n\nSample Output 2\n\n100 0", "sample_input": "5\n6 9 4 2 11\n"}, "reference_outputs": ["11 6\n"], "source_document_id": "p03380", "source_text": "Score : 400 points\n\nProblem Statement\n\nLet {\\rm comb}(n,r) be the number of ways to choose r objects from among n objects, disregarding order.\nFrom n non-negative integers a_1, a_2, ..., a_n, select two numbers a_i > a_j so that {\\rm comb}(a_i,a_j) is maximized.\nIf there are multiple pairs that maximize the value, any of them is accepted.\n\nConstraints\n\n2 \\leq n \\leq 10^5\n\n0 \\leq a_i \\leq 10^9\n\na_1,a_2,...,a_n are pairwise distinct.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nn\na_1 a_2 ... a_n\n\nOutput\n\nPrint a_i and a_j that you selected, with a space in between.\n\nSample Input 1\n\n5\n6 9 4 2 11\n\nSample Output 1\n\n11 6\n\n\\rm{comb}(a_i,a_j) for each possible selection is as follows:\n\n\\rm{comb}(4,2)=6\n\n\\rm{comb}(6,2)=15\n\n\\rm{comb}(6,4)=15\n\n\\rm{comb}(9,2)=36\n\n\\rm{comb}(9,4)=126\n\n\\rm{comb}(9,6)=84\n\n\\rm{comb}(11,2)=55\n\n\\rm{comb}(11,4)=330\n\n\\rm{comb}(11,6)=462\n\n\\rm{comb}(11,9)=55\n\nThus, we should print 11 and 6.\n\nSample Input 2\n\n2\n100 0\n\nSample Output 2\n\n100 0", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 444, "cpu_time_ms": 2103, "memory_kb": 2424}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s024616700", "group_id": "codeNet:p03383", "input_text": "local h, w = io.read(\"*n\", \"*n\", \"*l\")\nlocal map = {}\nfor i = 1, h do\n local str = io.read()\n for j = 1, w do\n map[(i - 1) * w + j] = str:sub(j, j)\n end\nend\nlocal vertical = {}\nlocal vmap = {}\nfor i = 1, w do\n vertical[i] = {}\n for j = 1, h do\n vertical[i][j] = map[(j - 1) * w + i]\n end\n table.sort(vertical[i])\n vertical[i] = table.concat(vertical[i], \"\")\n local v = vertical[i]\n if vmap[v] then\n vmap[v] = nil\n else\n vmap[v] = true\n end\nend\nlocal vrem = 0\nfor k, v in pairs(vmap) do\n vrem = vrem + 1\nend\n\nlocal horizontal = {}\nlocal hmap = {}\nfor i = 1, h do\n horizontal[i] = {}\n for j = 1, w do\n horizontal[i][j] = map[(i - 1) * w + j]\n end\n table.sort(horizontal[i])\n horizontal[i] = table.concat(horizontal[i], \"\")\n local v = vertical[i]\n if hmap[v] then\n hmap[v] = nil\n else\n hmap[v] = true\n end\nend\nlocal hrem = 0\nfor k, v in pairs(vmap) do\n hrem = hrem + 1\nend\nlocal f = vrem <= 1 and hrem <= 1\nprint(f and \"YES\" or \"NO\")\n", "language": "Lua", "metadata": {"date": 1582591612, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03383.html", "problem_id": "p03383", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03383/input.txt", "sample_output_relpath": "derived/input_output/data/p03383/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03383/Lua/s024616700.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s024616700", "user_id": "u120582723"}, "prompt_components": {"gold_output": "YES\n", "input_to_evaluate": "local h, w = io.read(\"*n\", \"*n\", \"*l\")\nlocal map = {}\nfor i = 1, h do\n local str = io.read()\n for j = 1, w do\n map[(i - 1) * w + j] = str:sub(j, j)\n end\nend\nlocal vertical = {}\nlocal vmap = {}\nfor i = 1, w do\n vertical[i] = {}\n for j = 1, h do\n vertical[i][j] = map[(j - 1) * w + i]\n end\n table.sort(vertical[i])\n vertical[i] = table.concat(vertical[i], \"\")\n local v = vertical[i]\n if vmap[v] then\n vmap[v] = nil\n else\n vmap[v] = true\n end\nend\nlocal vrem = 0\nfor k, v in pairs(vmap) do\n vrem = vrem + 1\nend\n\nlocal horizontal = {}\nlocal hmap = {}\nfor i = 1, h do\n horizontal[i] = {}\n for j = 1, w do\n horizontal[i][j] = map[(i - 1) * w + j]\n end\n table.sort(horizontal[i])\n horizontal[i] = table.concat(horizontal[i], \"\")\n local v = vertical[i]\n if hmap[v] then\n hmap[v] = nil\n else\n hmap[v] = true\n end\nend\nlocal hrem = 0\nfor k, v in pairs(vmap) do\n hrem = hrem + 1\nend\nlocal f = vrem <= 1 and hrem <= 1\nprint(f and \"YES\" or \"NO\")\n", "problem_context": "Score : 700 points\n\nProblem Statement\n\nThere is an H \\times W grid (H vertical, W horizontal), where each square contains a lowercase English letter.\nSpecifically, the letter in the square at the i-th row and j-th column is equal to the j-th character in the string S_i.\n\nSnuke can apply the following operation to this grid any number of times:\n\nChoose two different rows and swap them. Or, choose two different columns and swap them.\n\nSnuke wants this grid to be symmetric.\nThat is, for any 1 \\leq i \\leq H and 1 \\leq j \\leq W, the letter in the square at the i-th row and j-th column and the letter in the square at the (H + 1 - i)-th row and (W + 1 - j)-th column should be equal.\n\nDetermine if Snuke can achieve this objective.\n\nConstraints\n\n1 \\leq H \\leq 12\n\n1 \\leq W \\leq 12\n\n|S_i| = W\n\nS_i consists of lowercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\nS_1\nS_2\n:\nS_H\n\nOutput\n\nIf Snuke can make the grid symmetric, print YES; if he cannot, print NO.\n\nSample Input 1\n\n2 3\narc\nrac\n\nSample Output 1\n\nYES\n\nIf the second and third columns from the left are swapped, the grid becomes symmetric, as shown in the image below:\n\nSample Input 2\n\n3 7\natcoder\nregular\ncontest\n\nSample Output 2\n\nNO\n\nSample Input 3\n\n12 12\nbimonigaloaf\nfaurwlkbleht\ndexwimqxzxbb\nlxdgyoifcxid\nydxiliocfdgx\nnfoabgilamoi\nibxbdqmzxxwe\npqirylfrcrnf\nwtehfkllbura\nyfrnpflcrirq\nwvcclwgiubrk\nlkbrwgwuiccv\n\nSample Output 3\n\nYES", "sample_input": "2 3\narc\nrac\n"}, "reference_outputs": ["YES\n"], "source_document_id": "p03383", "source_text": "Score : 700 points\n\nProblem Statement\n\nThere is an H \\times W grid (H vertical, W horizontal), where each square contains a lowercase English letter.\nSpecifically, the letter in the square at the i-th row and j-th column is equal to the j-th character in the string S_i.\n\nSnuke can apply the following operation to this grid any number of times:\n\nChoose two different rows and swap them. Or, choose two different columns and swap them.\n\nSnuke wants this grid to be symmetric.\nThat is, for any 1 \\leq i \\leq H and 1 \\leq j \\leq W, the letter in the square at the i-th row and j-th column and the letter in the square at the (H + 1 - i)-th row and (W + 1 - j)-th column should be equal.\n\nDetermine if Snuke can achieve this objective.\n\nConstraints\n\n1 \\leq H \\leq 12\n\n1 \\leq W \\leq 12\n\n|S_i| = W\n\nS_i consists of lowercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\nS_1\nS_2\n:\nS_H\n\nOutput\n\nIf Snuke can make the grid symmetric, print YES; if he cannot, print NO.\n\nSample Input 1\n\n2 3\narc\nrac\n\nSample Output 1\n\nYES\n\nIf the second and third columns from the left are swapped, the grid becomes symmetric, as shown in the image below:\n\nSample Input 2\n\n3 7\natcoder\nregular\ncontest\n\nSample Output 2\n\nNO\n\nSample Input 3\n\n12 12\nbimonigaloaf\nfaurwlkbleht\ndexwimqxzxbb\nlxdgyoifcxid\nydxiliocfdgx\nnfoabgilamoi\nibxbdqmzxxwe\npqirylfrcrnf\nwtehfkllbura\nyfrnpflcrirq\nwvcclwgiubrk\nlkbrwgwuiccv\n\nSample Output 3\n\nYES", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 975, "cpu_time_ms": 4, "memory_kb": 508}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s029262758", "group_id": "codeNet:p03385", "input_text": "a=io.read()\nb,x=a:gsub(\"a\",\"\")\nb,y=a:gsub(\"b\",\"\")\nb,z=a:gsub(\"c\",\"\")\nprint(x==1 and y==1 and z==1 and \"Yes\"or \"No\")", "language": "Lua", "metadata": {"date": 1551840559, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p03385.html", "problem_id": "p03385", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03385/input.txt", "sample_output_relpath": "derived/input_output/data/p03385/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03385/Lua/s029262758.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s029262758", "user_id": "u837412668"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "a=io.read()\nb,x=a:gsub(\"a\",\"\")\nb,y=a:gsub(\"b\",\"\")\nb,z=a:gsub(\"c\",\"\")\nprint(x==1 and y==1 and z==1 and \"Yes\"or \"No\")", "problem_context": "Score : 100 points\n\nProblem Statement\n\nYou are given a string S of length 3 consisting of a, b and c. Determine if S can be obtained by permuting abc.\n\nConstraints\n\n|S|=3\n\nS consists of a, b and c.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nIf S can be obtained by permuting abc, print Yes; otherwise, print No.\n\nSample Input 1\n\nbac\n\nSample Output 1\n\nYes\n\nSwapping the first and second characters in bac results in abc.\n\nSample Input 2\n\nbab\n\nSample Output 2\n\nNo\n\nSample Input 3\n\nabc\n\nSample Output 3\n\nYes\n\nSample Input 4\n\naaa\n\nSample Output 4\n\nNo", "sample_input": "bac\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03385", "source_text": "Score : 100 points\n\nProblem Statement\n\nYou are given a string S of length 3 consisting of a, b and c. Determine if S can be obtained by permuting abc.\n\nConstraints\n\n|S|=3\n\nS consists of a, b and c.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nIf S can be obtained by permuting abc, print Yes; otherwise, print No.\n\nSample Input 1\n\nbac\n\nSample Output 1\n\nYes\n\nSwapping the first and second characters in bac results in abc.\n\nSample Input 2\n\nbab\n\nSample Output 2\n\nNo\n\nSample Input 3\n\nabc\n\nSample Output 3\n\nYes\n\nSample Input 4\n\naaa\n\nSample Output 4\n\nNo", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 115, "cpu_time_ms": 2, "memory_kb": 256}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s730848498", "group_id": "codeNet:p03385", "input_text": "a=io.read()\nb,x=a:gsub(\"a\",\"\")\nb,y=a:gsub(\"b\",\"\")\nb,z=a:gsub(\"c\",\"\")\nprint(x==1 and y==1 and z==1 and \"Yes\"or \"No\")", "language": "Lua", "metadata": {"date": 1551840542, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03385.html", "problem_id": "p03385", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03385/input.txt", "sample_output_relpath": "derived/input_output/data/p03385/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03385/Lua/s730848498.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s730848498", "user_id": "u837412668"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "a=io.read()\nb,x=a:gsub(\"a\",\"\")\nb,y=a:gsub(\"b\",\"\")\nb,z=a:gsub(\"c\",\"\")\nprint(x==1 and y==1 and z==1 and \"Yes\"or \"No\")", "problem_context": "Score : 100 points\n\nProblem Statement\n\nYou are given a string S of length 3 consisting of a, b and c. Determine if S can be obtained by permuting abc.\n\nConstraints\n\n|S|=3\n\nS consists of a, b and c.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nIf S can be obtained by permuting abc, print Yes; otherwise, print No.\n\nSample Input 1\n\nbac\n\nSample Output 1\n\nYes\n\nSwapping the first and second characters in bac results in abc.\n\nSample Input 2\n\nbab\n\nSample Output 2\n\nNo\n\nSample Input 3\n\nabc\n\nSample Output 3\n\nYes\n\nSample Input 4\n\naaa\n\nSample Output 4\n\nNo", "sample_input": "bac\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03385", "source_text": "Score : 100 points\n\nProblem Statement\n\nYou are given a string S of length 3 consisting of a, b and c. Determine if S can be obtained by permuting abc.\n\nConstraints\n\n|S|=3\n\nS consists of a, b and c.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nIf S can be obtained by permuting abc, print Yes; otherwise, print No.\n\nSample Input 1\n\nbac\n\nSample Output 1\n\nYes\n\nSwapping the first and second characters in bac results in abc.\n\nSample Input 2\n\nbab\n\nSample Output 2\n\nNo\n\nSample Input 3\n\nabc\n\nSample Output 3\n\nYes\n\nSample Input 4\n\naaa\n\nSample Output 4\n\nNo", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 115, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s173073724", "group_id": "codeNet:p03386", "input_text": "local a, b, k = io.read(\"*n\", \"*n\", \"*n\")\nfor i = a, b do\n if i < a + k or b < i + k then\n print(i)\n end\nend", "language": "Lua", "metadata": {"date": 1584710487, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03386.html", "problem_id": "p03386", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03386/input.txt", "sample_output_relpath": "derived/input_output/data/p03386/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03386/Lua/s173073724.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s173073724", "user_id": "u120582723"}, "prompt_components": {"gold_output": "3\n4\n7\n8\n", "input_to_evaluate": "local a, b, k = io.read(\"*n\", \"*n\", \"*n\")\nfor i = a, b do\n if i < a + k or b < i + k then\n print(i)\n end\nend", "problem_context": "Score : 200 points\n\nProblem Statement\n\nPrint all the integers that satisfies the following in ascending order:\n\nAmong the integers between A and B (inclusive), it is either within the K smallest integers or within the K largest integers.\n\nConstraints\n\n1 \\leq A \\leq B \\leq 10^9\n\n1 \\leq K \\leq 100\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B K\n\nOutput\n\nPrint all the integers that satisfies the condition above in ascending order.\n\nSample Input 1\n\n3 8 2\n\nSample Output 1\n\n3\n4\n7\n8\n\n3 is the first smallest integer among the integers between 3 and 8.\n\n4 is the second smallest integer among the integers between 3 and 8.\n\n7 is the second largest integer among the integers between 3 and 8.\n\n8 is the first largest integer among the integers between 3 and 8.\n\nSample Input 2\n\n4 8 3\n\nSample Output 2\n\n4\n5\n6\n7\n8\n\nSample Input 3\n\n2 9 100\n\nSample Output 3\n\n2\n3\n4\n5\n6\n7\n8\n9", "sample_input": "3 8 2\n"}, "reference_outputs": ["3\n4\n7\n8\n"], "source_document_id": "p03386", "source_text": "Score : 200 points\n\nProblem Statement\n\nPrint all the integers that satisfies the following in ascending order:\n\nAmong the integers between A and B (inclusive), it is either within the K smallest integers or within the K largest integers.\n\nConstraints\n\n1 \\leq A \\leq B \\leq 10^9\n\n1 \\leq K \\leq 100\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B K\n\nOutput\n\nPrint all the integers that satisfies the condition above in ascending order.\n\nSample Input 1\n\n3 8 2\n\nSample Output 1\n\n3\n4\n7\n8\n\n3 is the first smallest integer among the integers between 3 and 8.\n\n4 is the second smallest integer among the integers between 3 and 8.\n\n7 is the second largest integer among the integers between 3 and 8.\n\n8 is the first largest integer among the integers between 3 and 8.\n\nSample Input 2\n\n4 8 3\n\nSample Output 2\n\n4\n5\n6\n7\n8\n\nSample Input 3\n\n2 9 100\n\nSample Output 3\n\n2\n3\n4\n5\n6\n7\n8\n9", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 113, "cpu_time_ms": 2103, "memory_kb": 256}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s461836184", "group_id": "codeNet:p03388", "input_text": "Q=io.read(\"n\")\nfor i=1,Q do\n A=io.read(\"n\")\n B=io.read(\"n\")\n if A>b then\n A,B=B,A\n end\n local count=0\n local k=1\n for i=B-1,A,-1 do\n if i*(A+k)b then\n A,B=B,A\n end\n local count=0\n local k=1\n for i=B-1,A,-1 do\n if i*(A+k)s:sub(i-1,i-1) then\n s=s:sub(1,i-1)\n break\n end\n end\n if #s==26 then\n print(-1)\n return\n else\n for i=97,122 do\n local c=string.char(i)\n if not s:find(c) and s:sub(#s,#s)s:sub(i-1,i-1) then\n s=s:sub(1,i-1)\n break\n end\n end\n if #s==26 then\n print(-1)\n return\n else\n for i=97,122 do\n local c=string.char(i)\n if not s:find(c) and s:sub(#s,#s) y_{j} where j is the smallest integer such that x_{j} \\neq y_{j}.\n\nConstraints\n\n1 \\leq |S| \\leq 26\n\nS is a diverse word.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the next word that appears after S in the dictionary, or -1 if it doesn't exist.\n\nSample Input 1\n\natcoder\n\nSample Output 1\n\natcoderb\n\natcoderb is the lexicographically smallest diverse word that is lexicographically larger than atcoder. Note that atcoderb is lexicographically smaller than b.\n\nSample Input 2\n\nabc\n\nSample Output 2\n\nabcd\n\nSample Input 3\n\nzyxwvutsrqponmlkjihgfedcba\n\nSample Output 3\n\n-1\n\nThis is the lexicographically largest diverse word, so the answer is -1.\n\nSample Input 4\n\nabcdefghijklmnopqrstuvwzyx\n\nSample Output 4\n\nabcdefghijklmnopqrstuvx", "sample_input": "atcoder\n"}, "reference_outputs": ["atcoderb\n"], "source_document_id": "p03393", "source_text": "Score : 300 points\n\nProblem Statement\n\nGotou just received a dictionary. However, he doesn't recognize the language used in the dictionary. He did some analysis on the dictionary and realizes that the dictionary contains all possible diverse words in lexicographical order.\n\nA word is called diverse if and only if it is a nonempty string of English lowercase letters and all letters in the word are distinct. For example, atcoder, zscoder and agc are diverse words while gotou and connect aren't diverse words.\n\nGiven a diverse word S, determine the next word that appears after S in the dictionary, i.e. the lexicographically smallest diverse word that is lexicographically larger than S, or determine that it doesn't exist.\n\nLet X = x_{1}x_{2}...x_{n} and Y = y_{1}y_{2}...y_{m} be two distinct strings. X is lexicographically larger than Y if and only if Y is a prefix of X or x_{j} > y_{j} where j is the smallest integer such that x_{j} \\neq y_{j}.\n\nConstraints\n\n1 \\leq |S| \\leq 26\n\nS is a diverse word.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the next word that appears after S in the dictionary, or -1 if it doesn't exist.\n\nSample Input 1\n\natcoder\n\nSample Output 1\n\natcoderb\n\natcoderb is the lexicographically smallest diverse word that is lexicographically larger than atcoder. Note that atcoderb is lexicographically smaller than b.\n\nSample Input 2\n\nabc\n\nSample Output 2\n\nabcd\n\nSample Input 3\n\nzyxwvutsrqponmlkjihgfedcba\n\nSample Output 3\n\n-1\n\nThis is the lexicographically largest diverse word, so the answer is -1.\n\nSample Input 4\n\nabcdefghijklmnopqrstuvwzyx\n\nSample Output 4\n\nabcdefghijklmnopqrstuvx", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 732, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s820608801", "group_id": "codeNet:p03394", "input_text": "local n = io.read(\"*n\")\nif n == 3 then\n print(\"2 3 25\")\nelseif n % 4 == 1 then\n local rep = (n - 1) // 4\n for i = 0, rep - 1 do\n io.write(2 + 6 * i .. \" \" .. 3 + 6 * i .. \" \" .. 4 + 6 * i .. \" \" .. 6 + 6 * i .. \" \")\n end\n if n % 8 == 1 then\n print(rep * 6 + 6)\n else\n print(rep * 6 + 3)\n end\nelseif n % 4 == 0 then\n local rep = n // 4 - 1\n for i = 0, rep - 1 do\n io.write(2 + 6 * i .. \" \" .. 3 + 6 * i .. \" \" .. 4 + 6 * i .. \" \" .. 6 + 6 * i .. \" \")\n end\n io.write(2 + 6 * rep .. \" \" .. 3 + 6 * rep .. \" \" .. 4 + 6 * rep .. \" \")\n if n % 8 == 0 then\n print(rep * 6 + 6)\n else\n print(rep * 6 + 9)\n end\nelseif n % 4 == 2 then\n local rep = (n - 2) // 4\n for i = 0, rep - 1 do\n io.write(2 + 6 * i .. \" \" .. 3 + 6 * i .. \" \" .. 4 + 6 * i .. \" \" .. 6 + 6 * i .. \" \")\n end\n if n % 8 == 2 then\n print(2 + 6 * rep .. \" \" .. 4 + rep * 6)\n else\n print(3 + 6 * rep .. \" \" .. 6 + rep * 6)\n end\nelse\n local rep = (n - 3) // 4\n for i = 0, rep - 1 do\n io.write(2 + 6 * i .. \" \" .. 3 + 6 * i .. \" \" .. 4 + 6 * i .. \" \" .. 6 + 6 * i .. \" \")\n end\n if n % 8 == 3 then\n print(2 + 6 * rep .. \" \" .. 4 + rep * 6 .. \" \" .. 6 + rep * 6)\n else\n print(2 + 6 * rep .. \" \" .. 3 + rep * 6 .. \" \" .. 4 + rep * 6)\n end\nend\n", "language": "Lua", "metadata": {"date": 1565734906, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03394.html", "problem_id": "p03394", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03394/input.txt", "sample_output_relpath": "derived/input_output/data/p03394/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03394/Lua/s820608801.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s820608801", "user_id": "u120582723"}, "prompt_components": {"gold_output": "2 5 63\n", "input_to_evaluate": "local n = io.read(\"*n\")\nif n == 3 then\n print(\"2 3 25\")\nelseif n % 4 == 1 then\n local rep = (n - 1) // 4\n for i = 0, rep - 1 do\n io.write(2 + 6 * i .. \" \" .. 3 + 6 * i .. \" \" .. 4 + 6 * i .. \" \" .. 6 + 6 * i .. \" \")\n end\n if n % 8 == 1 then\n print(rep * 6 + 6)\n else\n print(rep * 6 + 3)\n end\nelseif n % 4 == 0 then\n local rep = n // 4 - 1\n for i = 0, rep - 1 do\n io.write(2 + 6 * i .. \" \" .. 3 + 6 * i .. \" \" .. 4 + 6 * i .. \" \" .. 6 + 6 * i .. \" \")\n end\n io.write(2 + 6 * rep .. \" \" .. 3 + 6 * rep .. \" \" .. 4 + 6 * rep .. \" \")\n if n % 8 == 0 then\n print(rep * 6 + 6)\n else\n print(rep * 6 + 9)\n end\nelseif n % 4 == 2 then\n local rep = (n - 2) // 4\n for i = 0, rep - 1 do\n io.write(2 + 6 * i .. \" \" .. 3 + 6 * i .. \" \" .. 4 + 6 * i .. \" \" .. 6 + 6 * i .. \" \")\n end\n if n % 8 == 2 then\n print(2 + 6 * rep .. \" \" .. 4 + rep * 6)\n else\n print(3 + 6 * rep .. \" \" .. 6 + rep * 6)\n end\nelse\n local rep = (n - 3) // 4\n for i = 0, rep - 1 do\n io.write(2 + 6 * i .. \" \" .. 3 + 6 * i .. \" \" .. 4 + 6 * i .. \" \" .. 6 + 6 * i .. \" \")\n end\n if n % 8 == 3 then\n print(2 + 6 * rep .. \" \" .. 4 + rep * 6 .. \" \" .. 6 + rep * 6)\n else\n print(2 + 6 * rep .. \" \" .. 3 + rep * 6 .. \" \" .. 4 + rep * 6)\n end\nend\n", "problem_context": "Score : 600 points\n\nProblem Statement\n\nNagase is a top student in high school. One day, she's analyzing some properties of special sets of positive integers.\n\nShe thinks that a set S = \\{a_{1}, a_{2}, ..., a_{N}\\} of distinct positive integers is called special if for all 1 \\leq i \\leq N, the gcd (greatest common divisor) of a_{i} and the sum of the remaining elements of S is not 1.\n\nNagase wants to find a special set of size N. However, this task is too easy, so she decided to ramp up the difficulty. Nagase challenges you to find a special set of size N such that the gcd of all elements are 1 and the elements of the set does not exceed 30000.\n\nConstraints\n\n3 \\leq N \\leq 20000\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nOutput N space-separated integers, denoting the elements of the set S. S must satisfy the following conditions :\n\nThe elements must be distinct positive integers not exceeding 30000.\n\nThe gcd of all elements of S is 1, i.e. there does not exist an integer d > 1 that divides all elements of S.\n\nS is a special set.\n\nIf there are multiple solutions, you may output any of them. The elements of S may be printed in any order. It is guaranteed that at least one solution exist under the given contraints.\n\nSample Input 1\n\n3\n\nSample Output 1\n\n2 5 63\n\n\\{2, 5, 63\\} is special because gcd(2, 5 + 63) = 2, gcd(5, 2 + 63) = 5, gcd(63, 2 + 5) = 7. Also, gcd(2, 5, 63) = 1. Thus, this set satisfies all the criteria.\n\nNote that \\{2, 4, 6\\} is not a valid solution because gcd(2, 4, 6) = 2 > 1.\n\nSample Input 2\n\n4\n\nSample Output 2\n\n2 5 20 63\n\n\\{2, 5, 20, 63\\} is special because gcd(2, 5 + 20 + 63) = 2, gcd(5, 2 + 20 + 63) = 5, gcd(20, 2 + 5 + 63) = 10, gcd(63, 2 + 5 + 20) = 9. Also, gcd(2, 5, 20, 63) = 1. Thus, this set satisfies all the criteria.", "sample_input": "3\n"}, "reference_outputs": ["2 5 63\n"], "source_document_id": "p03394", "source_text": "Score : 600 points\n\nProblem Statement\n\nNagase is a top student in high school. One day, she's analyzing some properties of special sets of positive integers.\n\nShe thinks that a set S = \\{a_{1}, a_{2}, ..., a_{N}\\} of distinct positive integers is called special if for all 1 \\leq i \\leq N, the gcd (greatest common divisor) of a_{i} and the sum of the remaining elements of S is not 1.\n\nNagase wants to find a special set of size N. However, this task is too easy, so she decided to ramp up the difficulty. Nagase challenges you to find a special set of size N such that the gcd of all elements are 1 and the elements of the set does not exceed 30000.\n\nConstraints\n\n3 \\leq N \\leq 20000\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nOutput N space-separated integers, denoting the elements of the set S. S must satisfy the following conditions :\n\nThe elements must be distinct positive integers not exceeding 30000.\n\nThe gcd of all elements of S is 1, i.e. there does not exist an integer d > 1 that divides all elements of S.\n\nS is a special set.\n\nIf there are multiple solutions, you may output any of them. The elements of S may be printed in any order. It is guaranteed that at least one solution exist under the given contraints.\n\nSample Input 1\n\n3\n\nSample Output 1\n\n2 5 63\n\n\\{2, 5, 63\\} is special because gcd(2, 5 + 63) = 2, gcd(5, 2 + 63) = 5, gcd(63, 2 + 5) = 7. Also, gcd(2, 5, 63) = 1. Thus, this set satisfies all the criteria.\n\nNote that \\{2, 4, 6\\} is not a valid solution because gcd(2, 4, 6) = 2 > 1.\n\nSample Input 2\n\n4\n\nSample Output 2\n\n2 5 20 63\n\n\\{2, 5, 20, 63\\} is special because gcd(2, 5 + 20 + 63) = 2, gcd(5, 2 + 20 + 63) = 5, gcd(20, 2 + 5 + 63) = 10, gcd(63, 2 + 5 + 20) = 9. Also, gcd(2, 5, 20, 63) = 1. Thus, this set satisfies all the criteria.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1252, "cpu_time_ms": 14, "memory_kb": 1008}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s120308144", "group_id": "codeNet:p03399", "input_text": "local a = io.read()\nlocal b = io.read()\nlocal c = io.read()\nlocal d = io.read()\n\nlocal aa = 0\nlocal bb = 0\n\nif a < b then\n aa = tonumber(a)\nelseif a == b then\n aa = tonumber(a)\nelse\n aa = tonumber(b)\nend\n\nif c < d then\n bb = tonumber(c)\nelseif c == d then\n bb = tonumber(c)\nelse\n bb = tonumber(d)\nend\n\nprint(aa+bb)\n", "language": "Lua", "metadata": {"date": 1522028428, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p03399.html", "problem_id": "p03399", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03399/input.txt", "sample_output_relpath": "derived/input_output/data/p03399/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03399/Lua/s120308144.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s120308144", "user_id": "u751668935"}, "prompt_components": {"gold_output": "520\n", "input_to_evaluate": "local a = io.read()\nlocal b = io.read()\nlocal c = io.read()\nlocal d = io.read()\n\nlocal aa = 0\nlocal bb = 0\n\nif a < b then\n aa = tonumber(a)\nelseif a == b then\n aa = tonumber(a)\nelse\n aa = tonumber(b)\nend\n\nif c < d then\n bb = tonumber(c)\nelseif c == d then\n bb = tonumber(c)\nelse\n bb = tonumber(d)\nend\n\nprint(aa+bb)\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nYou planned a trip using trains and buses.\nThe train fare will be A yen (the currency of Japan) if you buy ordinary tickets along the way, and B yen if you buy an unlimited ticket.\nSimilarly, the bus fare will be C yen if you buy ordinary tickets along the way, and D yen if you buy an unlimited ticket.\n\nFind the minimum total fare when the optimal choices are made for trains and buses.\n\nConstraints\n\n1 \\leq A \\leq 1 000\n\n1 \\leq B \\leq 1 000\n\n1 \\leq C \\leq 1 000\n\n1 \\leq D \\leq 1 000\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA\nB\nC\nD\n\nOutput\n\nPrint the minimum total fare.\n\nSample Input 1\n\n600\n300\n220\n420\n\nSample Output 1\n\n520\n\nThe train fare will be 600 yen if you buy ordinary tickets, and 300 yen if you buy an unlimited ticket.\nThus, the optimal choice for trains is to buy an unlimited ticket for 300 yen.\nOn the other hand, the optimal choice for buses is to buy ordinary tickets for 220 yen.\n\nTherefore, the minimum total fare is 300 + 220 = 520 yen.\n\nSample Input 2\n\n555\n555\n400\n200\n\nSample Output 2\n\n755\n\nSample Input 3\n\n549\n817\n715\n603\n\nSample Output 3\n\n1152", "sample_input": "600\n300\n220\n420\n"}, "reference_outputs": ["520\n"], "source_document_id": "p03399", "source_text": "Score : 100 points\n\nProblem Statement\n\nYou planned a trip using trains and buses.\nThe train fare will be A yen (the currency of Japan) if you buy ordinary tickets along the way, and B yen if you buy an unlimited ticket.\nSimilarly, the bus fare will be C yen if you buy ordinary tickets along the way, and D yen if you buy an unlimited ticket.\n\nFind the minimum total fare when the optimal choices are made for trains and buses.\n\nConstraints\n\n1 \\leq A \\leq 1 000\n\n1 \\leq B \\leq 1 000\n\n1 \\leq C \\leq 1 000\n\n1 \\leq D \\leq 1 000\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA\nB\nC\nD\n\nOutput\n\nPrint the minimum total fare.\n\nSample Input 1\n\n600\n300\n220\n420\n\nSample Output 1\n\n520\n\nThe train fare will be 600 yen if you buy ordinary tickets, and 300 yen if you buy an unlimited ticket.\nThus, the optimal choice for trains is to buy an unlimited ticket for 300 yen.\nOn the other hand, the optimal choice for buses is to buy ordinary tickets for 220 yen.\n\nTherefore, the minimum total fare is 300 + 220 = 520 yen.\n\nSample Input 2\n\n555\n555\n400\n200\n\nSample Output 2\n\n755\n\nSample Input 3\n\n549\n817\n715\n603\n\nSample Output 3\n\n1152", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 333, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s656503274", "group_id": "codeNet:p03399", "input_text": "local a = io.read()\nlocal b = io.read()\nlocal c = io.read()\nlocal d = io.read()\n\nlocal aa = 0 \nlocal bb = 0 \n\nif a <= b then\n aa = tonumber(a)\nelse\n aa = tonumber(b)\nend\n\nif c <= d then\n bb = tonumber(c)\nelse\n bb = tonumber(d)\nend\n\nprint(aa+bb)", "language": "Lua", "metadata": {"date": 1522026850, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p03399.html", "problem_id": "p03399", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03399/input.txt", "sample_output_relpath": "derived/input_output/data/p03399/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03399/Lua/s656503274.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s656503274", "user_id": "u751668935"}, "prompt_components": {"gold_output": "520\n", "input_to_evaluate": "local a = io.read()\nlocal b = io.read()\nlocal c = io.read()\nlocal d = io.read()\n\nlocal aa = 0 \nlocal bb = 0 \n\nif a <= b then\n aa = tonumber(a)\nelse\n aa = tonumber(b)\nend\n\nif c <= d then\n bb = tonumber(c)\nelse\n bb = tonumber(d)\nend\n\nprint(aa+bb)", "problem_context": "Score : 100 points\n\nProblem Statement\n\nYou planned a trip using trains and buses.\nThe train fare will be A yen (the currency of Japan) if you buy ordinary tickets along the way, and B yen if you buy an unlimited ticket.\nSimilarly, the bus fare will be C yen if you buy ordinary tickets along the way, and D yen if you buy an unlimited ticket.\n\nFind the minimum total fare when the optimal choices are made for trains and buses.\n\nConstraints\n\n1 \\leq A \\leq 1 000\n\n1 \\leq B \\leq 1 000\n\n1 \\leq C \\leq 1 000\n\n1 \\leq D \\leq 1 000\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA\nB\nC\nD\n\nOutput\n\nPrint the minimum total fare.\n\nSample Input 1\n\n600\n300\n220\n420\n\nSample Output 1\n\n520\n\nThe train fare will be 600 yen if you buy ordinary tickets, and 300 yen if you buy an unlimited ticket.\nThus, the optimal choice for trains is to buy an unlimited ticket for 300 yen.\nOn the other hand, the optimal choice for buses is to buy ordinary tickets for 220 yen.\n\nTherefore, the minimum total fare is 300 + 220 = 520 yen.\n\nSample Input 2\n\n555\n555\n400\n200\n\nSample Output 2\n\n755\n\nSample Input 3\n\n549\n817\n715\n603\n\nSample Output 3\n\n1152", "sample_input": "600\n300\n220\n420\n"}, "reference_outputs": ["520\n"], "source_document_id": "p03399", "source_text": "Score : 100 points\n\nProblem Statement\n\nYou planned a trip using trains and buses.\nThe train fare will be A yen (the currency of Japan) if you buy ordinary tickets along the way, and B yen if you buy an unlimited ticket.\nSimilarly, the bus fare will be C yen if you buy ordinary tickets along the way, and D yen if you buy an unlimited ticket.\n\nFind the minimum total fare when the optimal choices are made for trains and buses.\n\nConstraints\n\n1 \\leq A \\leq 1 000\n\n1 \\leq B \\leq 1 000\n\n1 \\leq C \\leq 1 000\n\n1 \\leq D \\leq 1 000\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA\nB\nC\nD\n\nOutput\n\nPrint the minimum total fare.\n\nSample Input 1\n\n600\n300\n220\n420\n\nSample Output 1\n\n520\n\nThe train fare will be 600 yen if you buy ordinary tickets, and 300 yen if you buy an unlimited ticket.\nThus, the optimal choice for trains is to buy an unlimited ticket for 300 yen.\nOn the other hand, the optimal choice for buses is to buy ordinary tickets for 220 yen.\n\nTherefore, the minimum total fare is 300 + 220 = 520 yen.\n\nSample Input 2\n\n555\n555\n400\n200\n\nSample Output 2\n\n755\n\nSample Input 3\n\n549\n817\n715\n603\n\nSample Output 3\n\n1152", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 256, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s140354732", "group_id": "codeNet:p03400", "input_text": "local N, D, X = io.read(\"*n\", \"*n\", \"*n\")\nlocal A = {}\nlocal counter = N\nfor i = 1, N do\n A[i] = io.read(\"*n\")\n counter = counter + (D-1)//A[i]\nend\nprint(counter+X)", "language": "Lua", "metadata": {"date": 1586938029, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03400.html", "problem_id": "p03400", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03400/input.txt", "sample_output_relpath": "derived/input_output/data/p03400/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03400/Lua/s140354732.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s140354732", "user_id": "u045238009"}, "prompt_components": {"gold_output": "8\n", "input_to_evaluate": "local N, D, X = io.read(\"*n\", \"*n\", \"*n\")\nlocal A = {}\nlocal counter = N\nfor i = 1, N do\n A[i] = io.read(\"*n\")\n counter = counter + (D-1)//A[i]\nend\nprint(counter+X)", "problem_context": "Score : 200 points\n\nProblem Statement\n\nSome number of chocolate pieces were prepared for a training camp.\nThe camp had N participants and lasted for D days.\nThe i-th participant (1 \\leq i \\leq N) ate one chocolate piece on each of the following days in the camp: the 1-st day, the (A_i + 1)-th day, the (2A_i + 1)-th day, and so on.\nAs a result, there were X chocolate pieces remaining at the end of the camp. During the camp, nobody except the participants ate chocolate pieces.\n\nFind the number of chocolate pieces prepared at the beginning of the camp.\n\nConstraints\n\n1 \\leq N \\leq 100\n\n1 \\leq D \\leq 100\n\n1 \\leq X \\leq 100\n\n1 \\leq A_i \\leq 100 (1 \\leq i \\leq N)\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nD X\nA_1\nA_2\n:\nA_N\n\nOutput\n\nFind the number of chocolate pieces prepared at the beginning of the camp.\n\nSample Input 1\n\n3\n7 1\n2\n5\n10\n\nSample Output 1\n\n8\n\nThe camp has 3 participants and lasts for 7 days.\nEach participant eats chocolate pieces as follows:\n\nThe first participant eats one chocolate piece on Day 1, 3, 5 and 7, for a total of four.\n\nThe second participant eats one chocolate piece on Day 1 and 6, for a total of two.\n\nThe third participant eats one chocolate piece only on Day 1, for a total of one.\n\nSince the number of pieces remaining at the end of the camp is one, the number of pieces prepared at the beginning of the camp is 1 + 4 + 2 + 1 = 8.\n\nSample Input 2\n\n2\n8 20\n1\n10\n\nSample Output 2\n\n29\n\nSample Input 3\n\n5\n30 44\n26\n18\n81\n18\n6\n\nSample Output 3\n\n56", "sample_input": "3\n7 1\n2\n5\n10\n"}, "reference_outputs": ["8\n"], "source_document_id": "p03400", "source_text": "Score : 200 points\n\nProblem Statement\n\nSome number of chocolate pieces were prepared for a training camp.\nThe camp had N participants and lasted for D days.\nThe i-th participant (1 \\leq i \\leq N) ate one chocolate piece on each of the following days in the camp: the 1-st day, the (A_i + 1)-th day, the (2A_i + 1)-th day, and so on.\nAs a result, there were X chocolate pieces remaining at the end of the camp. During the camp, nobody except the participants ate chocolate pieces.\n\nFind the number of chocolate pieces prepared at the beginning of the camp.\n\nConstraints\n\n1 \\leq N \\leq 100\n\n1 \\leq D \\leq 100\n\n1 \\leq X \\leq 100\n\n1 \\leq A_i \\leq 100 (1 \\leq i \\leq N)\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nD X\nA_1\nA_2\n:\nA_N\n\nOutput\n\nFind the number of chocolate pieces prepared at the beginning of the camp.\n\nSample Input 1\n\n3\n7 1\n2\n5\n10\n\nSample Output 1\n\n8\n\nThe camp has 3 participants and lasts for 7 days.\nEach participant eats chocolate pieces as follows:\n\nThe first participant eats one chocolate piece on Day 1, 3, 5 and 7, for a total of four.\n\nThe second participant eats one chocolate piece on Day 1 and 6, for a total of two.\n\nThe third participant eats one chocolate piece only on Day 1, for a total of one.\n\nSince the number of pieces remaining at the end of the camp is one, the number of pieces prepared at the beginning of the camp is 1 + 4 + 2 + 1 = 8.\n\nSample Input 2\n\n2\n8 20\n1\n10\n\nSample Output 2\n\n29\n\nSample Input 3\n\n5\n30 44\n26\n18\n81\n18\n6\n\nSample Output 3\n\n56", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 170, "cpu_time_ms": 20, "memory_kb": 760}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s231045131", "group_id": "codeNet:p03400", "input_text": "local N, D, X = io.read(\"*n\", \"*n\", \"*n\")\nlocal A = {}\nfor i = 1, N do\n A[i] = io.read(\"*n\")\nend\ntable.sort(A)\n\nlocal counter = N\nfor i = 1, N do\n counter = counter + (D-1)//A[i]\nend\nprint(counter+X)", "language": "Lua", "metadata": {"date": 1586937837, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03400.html", "problem_id": "p03400", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03400/input.txt", "sample_output_relpath": "derived/input_output/data/p03400/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03400/Lua/s231045131.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s231045131", "user_id": "u045238009"}, "prompt_components": {"gold_output": "8\n", "input_to_evaluate": "local N, D, X = io.read(\"*n\", \"*n\", \"*n\")\nlocal A = {}\nfor i = 1, N do\n A[i] = io.read(\"*n\")\nend\ntable.sort(A)\n\nlocal counter = N\nfor i = 1, N do\n counter = counter + (D-1)//A[i]\nend\nprint(counter+X)", "problem_context": "Score : 200 points\n\nProblem Statement\n\nSome number of chocolate pieces were prepared for a training camp.\nThe camp had N participants and lasted for D days.\nThe i-th participant (1 \\leq i \\leq N) ate one chocolate piece on each of the following days in the camp: the 1-st day, the (A_i + 1)-th day, the (2A_i + 1)-th day, and so on.\nAs a result, there were X chocolate pieces remaining at the end of the camp. During the camp, nobody except the participants ate chocolate pieces.\n\nFind the number of chocolate pieces prepared at the beginning of the camp.\n\nConstraints\n\n1 \\leq N \\leq 100\n\n1 \\leq D \\leq 100\n\n1 \\leq X \\leq 100\n\n1 \\leq A_i \\leq 100 (1 \\leq i \\leq N)\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nD X\nA_1\nA_2\n:\nA_N\n\nOutput\n\nFind the number of chocolate pieces prepared at the beginning of the camp.\n\nSample Input 1\n\n3\n7 1\n2\n5\n10\n\nSample Output 1\n\n8\n\nThe camp has 3 participants and lasts for 7 days.\nEach participant eats chocolate pieces as follows:\n\nThe first participant eats one chocolate piece on Day 1, 3, 5 and 7, for a total of four.\n\nThe second participant eats one chocolate piece on Day 1 and 6, for a total of two.\n\nThe third participant eats one chocolate piece only on Day 1, for a total of one.\n\nSince the number of pieces remaining at the end of the camp is one, the number of pieces prepared at the beginning of the camp is 1 + 4 + 2 + 1 = 8.\n\nSample Input 2\n\n2\n8 20\n1\n10\n\nSample Output 2\n\n29\n\nSample Input 3\n\n5\n30 44\n26\n18\n81\n18\n6\n\nSample Output 3\n\n56", "sample_input": "3\n7 1\n2\n5\n10\n"}, "reference_outputs": ["8\n"], "source_document_id": "p03400", "source_text": "Score : 200 points\n\nProblem Statement\n\nSome number of chocolate pieces were prepared for a training camp.\nThe camp had N participants and lasted for D days.\nThe i-th participant (1 \\leq i \\leq N) ate one chocolate piece on each of the following days in the camp: the 1-st day, the (A_i + 1)-th day, the (2A_i + 1)-th day, and so on.\nAs a result, there were X chocolate pieces remaining at the end of the camp. During the camp, nobody except the participants ate chocolate pieces.\n\nFind the number of chocolate pieces prepared at the beginning of the camp.\n\nConstraints\n\n1 \\leq N \\leq 100\n\n1 \\leq D \\leq 100\n\n1 \\leq X \\leq 100\n\n1 \\leq A_i \\leq 100 (1 \\leq i \\leq N)\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nD X\nA_1\nA_2\n:\nA_N\n\nOutput\n\nFind the number of chocolate pieces prepared at the beginning of the camp.\n\nSample Input 1\n\n3\n7 1\n2\n5\n10\n\nSample Output 1\n\n8\n\nThe camp has 3 participants and lasts for 7 days.\nEach participant eats chocolate pieces as follows:\n\nThe first participant eats one chocolate piece on Day 1, 3, 5 and 7, for a total of four.\n\nThe second participant eats one chocolate piece on Day 1 and 6, for a total of two.\n\nThe third participant eats one chocolate piece only on Day 1, for a total of one.\n\nSince the number of pieces remaining at the end of the camp is one, the number of pieces prepared at the beginning of the camp is 1 + 4 + 2 + 1 = 8.\n\nSample Input 2\n\n2\n8 20\n1\n10\n\nSample Output 2\n\n29\n\nSample Input 3\n\n5\n30 44\n26\n18\n81\n18\n6\n\nSample Output 3\n\n56", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 205, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s736604892", "group_id": "codeNet:p03403", "input_text": "local n=io.read(\"*n\")\nlocal a={}\na[1],a[n+2]=0,0\nfor i=2,n+1 do\n a[i]=io.read(\"*n\")\nend\n\nlocal total=0\nfor i=1,n+1 do\n total=total+math.abs(a[i]-a[i+1])\nend\n\nfor i=2,n+1 do\n local x=math.abs(a[i-1]-a[i+1])\n local y=math.abs(a[i-1]-a[i])\n local z=math.abs(a[i]-a[i+1])\n print(total+x-y-z)\nend", "language": "Lua", "metadata": {"date": 1589898637, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p03403.html", "problem_id": "p03403", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03403/input.txt", "sample_output_relpath": "derived/input_output/data/p03403/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03403/Lua/s736604892.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s736604892", "user_id": "u045238009"}, "prompt_components": {"gold_output": "12\n8\n10\n", "input_to_evaluate": "local n=io.read(\"*n\")\nlocal a={}\na[1],a[n+2]=0,0\nfor i=2,n+1 do\n a[i]=io.read(\"*n\")\nend\n\nlocal total=0\nfor i=1,n+1 do\n total=total+math.abs(a[i]-a[i+1])\nend\n\nfor i=2,n+1 do\n local x=math.abs(a[i-1]-a[i+1])\n local y=math.abs(a[i-1]-a[i])\n local z=math.abs(a[i]-a[i+1])\n print(total+x-y-z)\nend", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere are N sightseeing spots on the x-axis, numbered 1, 2, ..., N.\nSpot i is at the point with coordinate A_i.\nIt costs |a - b| yen (the currency of Japan) to travel from a point with coordinate a to another point with coordinate b along the axis.\n\nYou planned a trip along the axis.\nIn this plan, you first depart from the point with coordinate 0, then visit the N spots in the order they are numbered, and finally return to the point with coordinate 0.\n\nHowever, something came up just before the trip, and you no longer have enough time to visit all the N spots, so you decided to choose some i and cancel the visit to Spot i.\nYou will visit the remaining spots as planned in the order they are numbered.\nYou will also depart from and return to the point with coordinate 0 at the beginning and the end, as planned.\n\nFor each i = 1, 2, ..., N, find the total cost of travel during the trip when the visit to Spot i is canceled.\n\nConstraints\n\n2 \\leq N \\leq 10^5\n\n-5000 \\leq A_i \\leq 5000 (1 \\leq i \\leq N)\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nPrint N lines.\nIn the i-th line, print the total cost of travel during the trip when the visit to Spot i is canceled.\n\nSample Input 1\n\n3\n3 5 -1\n\nSample Output 1\n\n12\n8\n10\n\nSpot 1, 2 and 3 are at the points with coordinates 3, 5 and -1, respectively.\nFor each i, the course of the trip and the total cost of travel when the visit to Spot i is canceled, are as follows:\n\nFor i = 1, the course of the trip is 0 \\rightarrow 5 \\rightarrow -1 \\rightarrow 0 and the total cost of travel is 5 + 6 + 1 = 12 yen.\n\nFor i = 2, the course of the trip is 0 \\rightarrow 3 \\rightarrow -1 \\rightarrow 0 and the total cost of travel is 3 + 4 + 1 = 8 yen.\n\nFor i = 3, the course of the trip is 0 \\rightarrow 3 \\rightarrow 5 \\rightarrow 0 and the total cost of travel is 3 + 2 + 5 = 10 yen.\n\nSample Input 2\n\n5\n1 1 1 2 0\n\nSample Output 2\n\n4\n4\n4\n2\n4\n\nSample Input 3\n\n6\n-679 -2409 -3258 3095 -3291 -4462\n\nSample Output 3\n\n21630\n21630\n19932\n8924\n21630\n19288", "sample_input": "3\n3 5 -1\n"}, "reference_outputs": ["12\n8\n10\n"], "source_document_id": "p03403", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere are N sightseeing spots on the x-axis, numbered 1, 2, ..., N.\nSpot i is at the point with coordinate A_i.\nIt costs |a - b| yen (the currency of Japan) to travel from a point with coordinate a to another point with coordinate b along the axis.\n\nYou planned a trip along the axis.\nIn this plan, you first depart from the point with coordinate 0, then visit the N spots in the order they are numbered, and finally return to the point with coordinate 0.\n\nHowever, something came up just before the trip, and you no longer have enough time to visit all the N spots, so you decided to choose some i and cancel the visit to Spot i.\nYou will visit the remaining spots as planned in the order they are numbered.\nYou will also depart from and return to the point with coordinate 0 at the beginning and the end, as planned.\n\nFor each i = 1, 2, ..., N, find the total cost of travel during the trip when the visit to Spot i is canceled.\n\nConstraints\n\n2 \\leq N \\leq 10^5\n\n-5000 \\leq A_i \\leq 5000 (1 \\leq i \\leq N)\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nPrint N lines.\nIn the i-th line, print the total cost of travel during the trip when the visit to Spot i is canceled.\n\nSample Input 1\n\n3\n3 5 -1\n\nSample Output 1\n\n12\n8\n10\n\nSpot 1, 2 and 3 are at the points with coordinates 3, 5 and -1, respectively.\nFor each i, the course of the trip and the total cost of travel when the visit to Spot i is canceled, are as follows:\n\nFor i = 1, the course of the trip is 0 \\rightarrow 5 \\rightarrow -1 \\rightarrow 0 and the total cost of travel is 5 + 6 + 1 = 12 yen.\n\nFor i = 2, the course of the trip is 0 \\rightarrow 3 \\rightarrow -1 \\rightarrow 0 and the total cost of travel is 3 + 4 + 1 = 8 yen.\n\nFor i = 3, the course of the trip is 0 \\rightarrow 3 \\rightarrow 5 \\rightarrow 0 and the total cost of travel is 3 + 2 + 5 = 10 yen.\n\nSample Input 2\n\n5\n1 1 1 2 0\n\nSample Output 2\n\n4\n4\n4\n2\n4\n\nSample Input 3\n\n6\n-679 -2409 -3258 3095 -3291 -4462\n\nSample Output 3\n\n21630\n21630\n19932\n8924\n21630\n19288", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 309, "cpu_time_ms": 106, "memory_kb": 2304}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s181349497", "group_id": "codeNet:p03407", "input_text": "a=io.read(\"n\")+io.read(\"n\")\nprint(a>=io.read(\"n\")and'Yes'or'No')", "language": "Lua", "metadata": {"date": 1570163027, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03407.html", "problem_id": "p03407", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03407/input.txt", "sample_output_relpath": "derived/input_output/data/p03407/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03407/Lua/s181349497.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s181349497", "user_id": "u162773977"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "a=io.read(\"n\")+io.read(\"n\")\nprint(a>=io.read(\"n\")and'Yes'or'No')", "problem_context": "Score : 100 points\n\nProblem Statement\n\nAn elementary school student Takahashi has come to a variety store.\n\nHe has two coins, A-yen and B-yen coins (yen is the currency of Japan), and wants to buy a toy that costs C yen. Can he buy it?\n\nNote that he lives in Takahashi Kingdom, and may have coins that do not exist in Japan.\n\nConstraints\n\nAll input values are integers.\n\n1 \\leq A, B \\leq 500\n\n1 \\leq C \\leq 1000\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C\n\nOutput\n\nIf Takahashi can buy the toy, print Yes; if he cannot, print No.\n\nSample Input 1\n\n50 100 120\n\nSample Output 1\n\nYes\n\nHe has 50 + 100 = 150 yen, so he can buy the 120-yen toy.\n\nSample Input 2\n\n500 100 1000\n\nSample Output 2\n\nNo\n\nHe has 500 + 100 = 600 yen, but he cannot buy the 1000-yen toy.\n\nSample Input 3\n\n19 123 143\n\nSample Output 3\n\nNo\n\nThere are 19-yen and 123-yen coins in Takahashi Kingdom, which are rather hard to use.\n\nSample Input 4\n\n19 123 142\n\nSample Output 4\n\nYes", "sample_input": "50 100 120\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03407", "source_text": "Score : 100 points\n\nProblem Statement\n\nAn elementary school student Takahashi has come to a variety store.\n\nHe has two coins, A-yen and B-yen coins (yen is the currency of Japan), and wants to buy a toy that costs C yen. Can he buy it?\n\nNote that he lives in Takahashi Kingdom, and may have coins that do not exist in Japan.\n\nConstraints\n\nAll input values are integers.\n\n1 \\leq A, B \\leq 500\n\n1 \\leq C \\leq 1000\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C\n\nOutput\n\nIf Takahashi can buy the toy, print Yes; if he cannot, print No.\n\nSample Input 1\n\n50 100 120\n\nSample Output 1\n\nYes\n\nHe has 50 + 100 = 150 yen, so he can buy the 120-yen toy.\n\nSample Input 2\n\n500 100 1000\n\nSample Output 2\n\nNo\n\nHe has 500 + 100 = 600 yen, but he cannot buy the 1000-yen toy.\n\nSample Input 3\n\n19 123 143\n\nSample Output 3\n\nNo\n\nThere are 19-yen and 123-yen coins in Takahashi Kingdom, which are rather hard to use.\n\nSample Input 4\n\n19 123 142\n\nSample Output 4\n\nYes", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 64, "cpu_time_ms": 8, "memory_kb": 888}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s778232703", "group_id": "codeNet:p03408", "input_text": "n=io.read(\"*n\",\"*l\")\ns={}\nfor i=1,n do\n x=io.read()\n if not s[x] then\n s[x]=1\n else\n s[x]=s[x]+1\n end\nend\nm=io.read(\"*n\",\"*l\")\nt={}\nfor i=1,m do\n x=io.read()\n if not t[x] then\n t[x]=1\n else\n t[x]=t[x]+1\n end\nend\n\nyen=0\nfor k,v in pairs(s) do\n if t[k] then\n x=t[k]\n else\n x=0\n end\n yen=math.max(yen,s[k]-x)\nend\nprint(yen)", "language": "Lua", "metadata": {"date": 1588280530, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03408.html", "problem_id": "p03408", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03408/input.txt", "sample_output_relpath": "derived/input_output/data/p03408/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03408/Lua/s778232703.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s778232703", "user_id": "u045238009"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "n=io.read(\"*n\",\"*l\")\ns={}\nfor i=1,n do\n x=io.read()\n if not s[x] then\n s[x]=1\n else\n s[x]=s[x]+1\n end\nend\nm=io.read(\"*n\",\"*l\")\nt={}\nfor i=1,m do\n x=io.read()\n if not t[x] then\n t[x]=1\n else\n t[x]=t[x]+1\n end\nend\n\nyen=0\nfor k,v in pairs(s) do\n if t[k] then\n x=t[k]\n else\n x=0\n end\n yen=math.max(yen,s[k]-x)\nend\nprint(yen)", "problem_context": "Score : 200 points\n\nProblem Statement\n\nTakahashi has N blue cards and M red cards.\nA string is written on each card. The string written on the i-th blue card is s_i, and the string written on the i-th red card is t_i.\n\nTakahashi will now announce a string, and then check every card. Each time he finds a blue card with the string announced by him, he will earn 1 yen (the currency of Japan); each time he finds a red card with that string, he will lose 1 yen.\n\nHere, we only consider the case where the string announced by Takahashi and the string on the card are exactly the same. For example, if he announces atcoder, he will not earn money even if there are blue cards with atcoderr, atcode, btcoder, and so on. (On the other hand, he will not lose money even if there are red cards with such strings, either.)\n\nAt most how much can he earn on balance?\n\nNote that the same string may be written on multiple cards.\n\nConstraints\n\nN and M are integers.\n\n1 \\leq N, M \\leq 100\n\ns_1, s_2, ..., s_N, t_1, t_2, ..., t_M are all strings of lengths between 1 and 10 (inclusive) consisting of lowercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\ns_1\ns_2\n:\ns_N\nM\nt_1\nt_2\n:\nt_M\n\nOutput\n\nIf Takahashi can earn at most X yen on balance, print X.\n\nSample Input 1\n\n3\napple\norange\napple\n1\ngrape\n\nSample Output 1\n\n2\n\nHe can earn 2 yen by announcing apple.\n\nSample Input 2\n\n3\napple\norange\napple\n5\napple\napple\napple\napple\napple\n\nSample Output 2\n\n1\n\nIf he announces apple, he will lose 3 yen. If he announces orange, he can earn 1 yen.\n\nSample Input 3\n\n1\nvoldemort\n10\nvoldemort\nvoldemort\nvoldemort\nvoldemort\nvoldemort\nvoldemort\nvoldemort\nvoldemort\nvoldemort\nvoldemort\n\nSample Output 3\n\n0\n\nIf he announces voldemort, he will lose 9 yen. If he announces orange, for example, he can avoid losing a yen.\n\nSample Input 4\n\n6\nred\nred\nblue\nyellow\nyellow\nred\n5\nred\nred\nyellow\ngreen\nblue\n\nSample Output 4\n\n1", "sample_input": "3\napple\norange\napple\n1\ngrape\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03408", "source_text": "Score : 200 points\n\nProblem Statement\n\nTakahashi has N blue cards and M red cards.\nA string is written on each card. The string written on the i-th blue card is s_i, and the string written on the i-th red card is t_i.\n\nTakahashi will now announce a string, and then check every card. Each time he finds a blue card with the string announced by him, he will earn 1 yen (the currency of Japan); each time he finds a red card with that string, he will lose 1 yen.\n\nHere, we only consider the case where the string announced by Takahashi and the string on the card are exactly the same. For example, if he announces atcoder, he will not earn money even if there are blue cards with atcoderr, atcode, btcoder, and so on. (On the other hand, he will not lose money even if there are red cards with such strings, either.)\n\nAt most how much can he earn on balance?\n\nNote that the same string may be written on multiple cards.\n\nConstraints\n\nN and M are integers.\n\n1 \\leq N, M \\leq 100\n\ns_1, s_2, ..., s_N, t_1, t_2, ..., t_M are all strings of lengths between 1 and 10 (inclusive) consisting of lowercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\ns_1\ns_2\n:\ns_N\nM\nt_1\nt_2\n:\nt_M\n\nOutput\n\nIf Takahashi can earn at most X yen on balance, print X.\n\nSample Input 1\n\n3\napple\norange\napple\n1\ngrape\n\nSample Output 1\n\n2\n\nHe can earn 2 yen by announcing apple.\n\nSample Input 2\n\n3\napple\norange\napple\n5\napple\napple\napple\napple\napple\n\nSample Output 2\n\n1\n\nIf he announces apple, he will lose 3 yen. If he announces orange, he can earn 1 yen.\n\nSample Input 3\n\n1\nvoldemort\n10\nvoldemort\nvoldemort\nvoldemort\nvoldemort\nvoldemort\nvoldemort\nvoldemort\nvoldemort\nvoldemort\nvoldemort\n\nSample Output 3\n\n0\n\nIf he announces voldemort, he will lose 9 yen. If he announces orange, for example, he can avoid losing a yen.\n\nSample Input 4\n\n6\nred\nred\nblue\nyellow\nyellow\nred\n5\nred\nred\nyellow\ngreen\nblue\n\nSample Output 4\n\n1", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 398, "cpu_time_ms": 9, "memory_kb": 888}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s353916254", "group_id": "codeNet:p03408", "input_text": "N=io.read(\"n\")\ns={}\ncount={}\nfor i=1,N do\n s[i]=io.read()\n count[s[i]]=count[s[i]] or 0 +1\nend\nM=io.read(\"n\")\nt={}\nfor i=1,M do\n t[i]=io.read()\n count[t[i]]=count[t[i]] or 0 -1\nend\nlocal earn=0\nfor i,v in pairs(count) do\n if v>0 then\n earn=earn+v\n end\nend\nprint(earn)\n", "language": "Lua", "metadata": {"date": 1550884655, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03408.html", "problem_id": "p03408", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03408/input.txt", "sample_output_relpath": "derived/input_output/data/p03408/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03408/Lua/s353916254.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s353916254", "user_id": "u015229643"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "N=io.read(\"n\")\ns={}\ncount={}\nfor i=1,N do\n s[i]=io.read()\n count[s[i]]=count[s[i]] or 0 +1\nend\nM=io.read(\"n\")\nt={}\nfor i=1,M do\n t[i]=io.read()\n count[t[i]]=count[t[i]] or 0 -1\nend\nlocal earn=0\nfor i,v in pairs(count) do\n if v>0 then\n earn=earn+v\n end\nend\nprint(earn)\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nTakahashi has N blue cards and M red cards.\nA string is written on each card. The string written on the i-th blue card is s_i, and the string written on the i-th red card is t_i.\n\nTakahashi will now announce a string, and then check every card. Each time he finds a blue card with the string announced by him, he will earn 1 yen (the currency of Japan); each time he finds a red card with that string, he will lose 1 yen.\n\nHere, we only consider the case where the string announced by Takahashi and the string on the card are exactly the same. For example, if he announces atcoder, he will not earn money even if there are blue cards with atcoderr, atcode, btcoder, and so on. (On the other hand, he will not lose money even if there are red cards with such strings, either.)\n\nAt most how much can he earn on balance?\n\nNote that the same string may be written on multiple cards.\n\nConstraints\n\nN and M are integers.\n\n1 \\leq N, M \\leq 100\n\ns_1, s_2, ..., s_N, t_1, t_2, ..., t_M are all strings of lengths between 1 and 10 (inclusive) consisting of lowercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\ns_1\ns_2\n:\ns_N\nM\nt_1\nt_2\n:\nt_M\n\nOutput\n\nIf Takahashi can earn at most X yen on balance, print X.\n\nSample Input 1\n\n3\napple\norange\napple\n1\ngrape\n\nSample Output 1\n\n2\n\nHe can earn 2 yen by announcing apple.\n\nSample Input 2\n\n3\napple\norange\napple\n5\napple\napple\napple\napple\napple\n\nSample Output 2\n\n1\n\nIf he announces apple, he will lose 3 yen. If he announces orange, he can earn 1 yen.\n\nSample Input 3\n\n1\nvoldemort\n10\nvoldemort\nvoldemort\nvoldemort\nvoldemort\nvoldemort\nvoldemort\nvoldemort\nvoldemort\nvoldemort\nvoldemort\n\nSample Output 3\n\n0\n\nIf he announces voldemort, he will lose 9 yen. If he announces orange, for example, he can avoid losing a yen.\n\nSample Input 4\n\n6\nred\nred\nblue\nyellow\nyellow\nred\n5\nred\nred\nyellow\ngreen\nblue\n\nSample Output 4\n\n1", "sample_input": "3\napple\norange\napple\n1\ngrape\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03408", "source_text": "Score : 200 points\n\nProblem Statement\n\nTakahashi has N blue cards and M red cards.\nA string is written on each card. The string written on the i-th blue card is s_i, and the string written on the i-th red card is t_i.\n\nTakahashi will now announce a string, and then check every card. Each time he finds a blue card with the string announced by him, he will earn 1 yen (the currency of Japan); each time he finds a red card with that string, he will lose 1 yen.\n\nHere, we only consider the case where the string announced by Takahashi and the string on the card are exactly the same. For example, if he announces atcoder, he will not earn money even if there are blue cards with atcoderr, atcode, btcoder, and so on. (On the other hand, he will not lose money even if there are red cards with such strings, either.)\n\nAt most how much can he earn on balance?\n\nNote that the same string may be written on multiple cards.\n\nConstraints\n\nN and M are integers.\n\n1 \\leq N, M \\leq 100\n\ns_1, s_2, ..., s_N, t_1, t_2, ..., t_M are all strings of lengths between 1 and 10 (inclusive) consisting of lowercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\ns_1\ns_2\n:\ns_N\nM\nt_1\nt_2\n:\nt_M\n\nOutput\n\nIf Takahashi can earn at most X yen on balance, print X.\n\nSample Input 1\n\n3\napple\norange\napple\n1\ngrape\n\nSample Output 1\n\n2\n\nHe can earn 2 yen by announcing apple.\n\nSample Input 2\n\n3\napple\norange\napple\n5\napple\napple\napple\napple\napple\n\nSample Output 2\n\n1\n\nIf he announces apple, he will lose 3 yen. If he announces orange, he can earn 1 yen.\n\nSample Input 3\n\n1\nvoldemort\n10\nvoldemort\nvoldemort\nvoldemort\nvoldemort\nvoldemort\nvoldemort\nvoldemort\nvoldemort\nvoldemort\nvoldemort\n\nSample Output 3\n\n0\n\nIf he announces voldemort, he will lose 9 yen. If he announces orange, for example, he can avoid losing a yen.\n\nSample Input 4\n\n6\nred\nred\nblue\nyellow\nyellow\nred\n5\nred\nred\nyellow\ngreen\nblue\n\nSample Output 4\n\n1", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 277, "cpu_time_ms": 6, "memory_kb": 632}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s916765341", "group_id": "codeNet:p03415", "input_text": "A=io.read()\nB=io.read()\nC=io.read()\nprint(string.sub(A,1,1)..string.sub(B,2,2)..string.sub(C,3,3))", "language": "Lua", "metadata": {"date": 1550947457, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03415.html", "problem_id": "p03415", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03415/input.txt", "sample_output_relpath": "derived/input_output/data/p03415/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03415/Lua/s916765341.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s916765341", "user_id": "u015229643"}, "prompt_components": {"gold_output": "abc\n", "input_to_evaluate": "A=io.read()\nB=io.read()\nC=io.read()\nprint(string.sub(A,1,1)..string.sub(B,2,2)..string.sub(C,3,3))", "problem_context": "Score : 100 points\n\nProblem Statement\n\nWe have a 3×3 square grid, where each square contains a lowercase English letters.\nThe letter in the square at the i-th row from the top and j-th column from the left is c_{ij}.\n\nPrint the string of length 3 that can be obtained by concatenating the letters in the squares on the diagonal connecting the top-left and bottom-right corner of the grid, from the top-left to bottom-right.\n\nConstraints\n\nInput consists of lowercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nc_{11}c_{12}c_{13}\nc_{21}c_{22}c_{23}\nc_{31}c_{32}c_{33}\n\nOutput\n\nPrint the string of length 3 that can be obtained by concatenating the letters on the diagonal connecting the top-left and bottom-right corner of the grid, from the top-left to bottom-right.\n\nSample Input 1\n\nant\nobe\nrec\n\nSample Output 1\n\nabc\n\nThe letters in the squares on the diagonal connecting the top-left and bottom-right corner of the grid are a, b and c from top-right to bottom-left. Concatenate these letters and print abc.\n\nSample Input 2\n\nedu\ncat\nion\n\nSample Output 2\n\nean", "sample_input": "ant\nobe\nrec\n"}, "reference_outputs": ["abc\n"], "source_document_id": "p03415", "source_text": "Score : 100 points\n\nProblem Statement\n\nWe have a 3×3 square grid, where each square contains a lowercase English letters.\nThe letter in the square at the i-th row from the top and j-th column from the left is c_{ij}.\n\nPrint the string of length 3 that can be obtained by concatenating the letters in the squares on the diagonal connecting the top-left and bottom-right corner of the grid, from the top-left to bottom-right.\n\nConstraints\n\nInput consists of lowercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nc_{11}c_{12}c_{13}\nc_{21}c_{22}c_{23}\nc_{31}c_{32}c_{33}\n\nOutput\n\nPrint the string of length 3 that can be obtained by concatenating the letters on the diagonal connecting the top-left and bottom-right corner of the grid, from the top-left to bottom-right.\n\nSample Input 1\n\nant\nobe\nrec\n\nSample Output 1\n\nabc\n\nThe letters in the squares on the diagonal connecting the top-left and bottom-right corner of the grid are a, b and c from top-right to bottom-left. Concatenate these letters and print abc.\n\nSample Input 2\n\nedu\ncat\nion\n\nSample Output 2\n\nean", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 98, "cpu_time_ms": 79, "memory_kb": 760}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s980112215", "group_id": "codeNet:p03416", "input_text": "local str1 = io.read()\nlocal str2 = io.read()\n\nlocal count = 0\nfor i = tonumber(str1), tonumber(str2) do\n if(tonumber(i) == tonumber(string.reverse(i))) then\n count = count + 1\n end\nend\nprint(count)", "language": "Lua", "metadata": {"date": 1520818132, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03416.html", "problem_id": "p03416", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03416/input.txt", "sample_output_relpath": "derived/input_output/data/p03416/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03416/Lua/s980112215.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s980112215", "user_id": "u751668935"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "local str1 = io.read()\nlocal str2 = io.read()\n\nlocal count = 0\nfor i = tonumber(str1), tonumber(str2) do\n if(tonumber(i) == tonumber(string.reverse(i))) then\n count = count + 1\n end\nend\nprint(count)", "problem_context": "Score : 200 points\n\nProblem Statement\n\nFind the number of palindromic numbers among the integers between A and B (inclusive).\nHere, a palindromic number is a positive integer whose string representation in base 10 (without leading zeros) reads the same forward and backward.\n\nConstraints\n\n10000 \\leq A \\leq B \\leq 99999\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nPrint the number of palindromic numbers among the integers between A and B (inclusive).\n\nSample Input 1\n\n11009 11332\n\nSample Output 1\n\n4\n\nThere are four integers that satisfy the conditions: 11011, 11111, 11211 and 11311.\n\nSample Input 2\n\n31415 92653\n\nSample Output 2\n\n612", "sample_input": "11009 11332\n"}, "reference_outputs": ["4\n"], "source_document_id": "p03416", "source_text": "Score : 200 points\n\nProblem Statement\n\nFind the number of palindromic numbers among the integers between A and B (inclusive).\nHere, a palindromic number is a positive integer whose string representation in base 10 (without leading zeros) reads the same forward and backward.\n\nConstraints\n\n10000 \\leq A \\leq B \\leq 99999\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nPrint the number of palindromic numbers among the integers between A and B (inclusive).\n\nSample Input 1\n\n11009 11332\n\nSample Output 1\n\n4\n\nThere are four integers that satisfy the conditions: 11011, 11111, 11211 and 11311.\n\nSample Input 2\n\n31415 92653\n\nSample Output 2\n\n612", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 211, "cpu_time_ms": 6, "memory_kb": 888}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s118845039", "group_id": "codeNet:p03417", "input_text": "N=io.read(\"n\")\nM=io.read(\"n\")\nlocal count=0\nif N==1 and M==1 then\n count=1\n elseif N==1 and M>=3 then\n count=M-2\n elseif M==1 and N>=3 then\n count=N-2\n elseif N==2 or M==2 then\n count=0\n elseif N>=3 and M>=3 then\n count=(N-2)*(M-2)\nend\nprint(count)\n\n", "language": "Lua", "metadata": {"date": 1550952961, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03417.html", "problem_id": "p03417", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03417/input.txt", "sample_output_relpath": "derived/input_output/data/p03417/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03417/Lua/s118845039.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s118845039", "user_id": "u015229643"}, "prompt_components": {"gold_output": "0\n", "input_to_evaluate": "N=io.read(\"n\")\nM=io.read(\"n\")\nlocal count=0\nif N==1 and M==1 then\n count=1\n elseif N==1 and M>=3 then\n count=M-2\n elseif M==1 and N>=3 then\n count=N-2\n elseif N==2 or M==2 then\n count=0\n elseif N>=3 and M>=3 then\n count=(N-2)*(M-2)\nend\nprint(count)\n\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere is 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.\nThe front and back sides of these cards can be distinguished, and initially every card faces up.\n\nWe will perform the following operation once for each square contains a card:\n\nFor each of the following nine squares, flip the card in it if it exists: the target square itself and the eight squares that shares a corner or a side with the target square.\n\nIt can be proved that, whether each card faces up or down after all the operations does not depend on the order the operations are performed.\nFind the number of cards that face down after all the operations.\n\nConstraints\n\n1 \\leq N,M \\leq 10^9\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\n\nOutput\n\nPrint the number of cards that face down after all the operations.\n\nSample Input 1\n\n2 2\n\nSample Output 1\n\n0\n\nWe will flip every card in any of the four operations. Thus, after all the operations, all cards face up.\n\nSample Input 2\n\n1 7\n\nSample Output 2\n\n5\n\nAfter all the operations, all cards except at both ends face down.\n\nSample Input 3\n\n314 1592\n\nSample Output 3\n\n496080", "sample_input": "2 2\n"}, "reference_outputs": ["0\n"], "source_document_id": "p03417", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere is 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.\nThe front and back sides of these cards can be distinguished, and initially every card faces up.\n\nWe will perform the following operation once for each square contains a card:\n\nFor each of the following nine squares, flip the card in it if it exists: the target square itself and the eight squares that shares a corner or a side with the target square.\n\nIt can be proved that, whether each card faces up or down after all the operations does not depend on the order the operations are performed.\nFind the number of cards that face down after all the operations.\n\nConstraints\n\n1 \\leq N,M \\leq 10^9\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\n\nOutput\n\nPrint the number of cards that face down after all the operations.\n\nSample Input 1\n\n2 2\n\nSample Output 1\n\n0\n\nWe will flip every card in any of the four operations. Thus, after all the operations, all cards face up.\n\nSample Input 2\n\n1 7\n\nSample Output 2\n\n5\n\nAfter all the operations, all cards except at both ends face down.\n\nSample Input 3\n\n314 1592\n\nSample Output 3\n\n496080", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 259, "cpu_time_ms": 7, "memory_kb": 760}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s127903207", "group_id": "codeNet:p03418", "input_text": "N=io.read(\"n\")\nK=io.read(\"n\")\nlocal count=0\nfor i=K+1,N do\n for j=1,N do\n while(j%i<=k) do\n count=count+1\n end\n end\nend\nprint(count)", "language": "Lua", "metadata": {"date": 1550953536, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03418.html", "problem_id": "p03418", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03418/input.txt", "sample_output_relpath": "derived/input_output/data/p03418/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03418/Lua/s127903207.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s127903207", "user_id": "u015229643"}, "prompt_components": {"gold_output": "7\n", "input_to_evaluate": "N=io.read(\"n\")\nK=io.read(\"n\")\nlocal count=0\nfor i=K+1,N do\n for j=1,N do\n while(j%i<=k) do\n count=count+1\n end\n end\nend\nprint(count)", "problem_context": "Score : 400 points\n\nProblem Statement\n\nTakahashi had a pair of two positive integers not exceeding N, (a,b), which he has forgotten.\nHe remembers that the remainder of a divided by b was greater than or equal to K.\nFind the number of possible pairs that he may have had.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n0 \\leq K \\leq N-1\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\n\nOutput\n\nPrint the number of possible pairs that he may have had.\n\nSample Input 1\n\n5 2\n\nSample Output 1\n\n7\n\nThere are seven possible pairs: (2,3),(5,3),(2,4),(3,4),(2,5),(3,5) and (4,5).\n\nSample Input 2\n\n10 0\n\nSample Output 2\n\n100\n\nSample Input 3\n\n31415 9265\n\nSample Output 3\n\n287927211", "sample_input": "5 2\n"}, "reference_outputs": ["7\n"], "source_document_id": "p03418", "source_text": "Score : 400 points\n\nProblem Statement\n\nTakahashi had a pair of two positive integers not exceeding N, (a,b), which he has forgotten.\nHe remembers that the remainder of a divided by b was greater than or equal to K.\nFind the number of possible pairs that he may have had.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n0 \\leq K \\leq N-1\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\n\nOutput\n\nPrint the number of possible pairs that he may have had.\n\nSample Input 1\n\n5 2\n\nSample Output 1\n\n7\n\nThere are seven possible pairs: (2,3),(5,3),(2,4),(3,4),(2,5),(3,5) and (4,5).\n\nSample Input 2\n\n10 0\n\nSample Output 2\n\n100\n\nSample Input 3\n\n31415 9265\n\nSample Output 3\n\n287927211", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 145, "cpu_time_ms": 92, "memory_kb": 888}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s788962920", "group_id": "codeNet:p03419", "input_text": "n,m=io.read(\"*n\",\"*n\")\nif n>4 and m>4 then\n print(n*m-(2*n+2*m-4))\n return\nelse\n grid={}\n for i=1,n+2 do\n grid[i]={}\n for j=1,m+2 do\n grid[i][j]=\"x\"\n end\n end\n for i=2,n+1 do\n for j=2,m+1 do\n for k=-1,1 do\n for l=-1,1 do\n if grid[i-k][j-l]==\"x\" then\n grid[i-k][j-l]=\"o\"\n else\n grid[i-k][j-l]=\"x\"\n end\n end\n end\n end\n end\n\n counter=0\n for i=2,n+1 do\n for j=2,m+1 do\n if grid[i][j]==\"o\" then\n counter=counter+1\n end\n end\n end\n print(counter)\nend", "language": "Lua", "metadata": {"date": 1589256839, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p03419.html", "problem_id": "p03419", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03419/input.txt", "sample_output_relpath": "derived/input_output/data/p03419/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03419/Lua/s788962920.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s788962920", "user_id": "u045238009"}, "prompt_components": {"gold_output": "0\n", "input_to_evaluate": "n,m=io.read(\"*n\",\"*n\")\nif n>4 and m>4 then\n print(n*m-(2*n+2*m-4))\n return\nelse\n grid={}\n for i=1,n+2 do\n grid[i]={}\n for j=1,m+2 do\n grid[i][j]=\"x\"\n end\n end\n for i=2,n+1 do\n for j=2,m+1 do\n for k=-1,1 do\n for l=-1,1 do\n if grid[i-k][j-l]==\"x\" then\n grid[i-k][j-l]=\"o\"\n else\n grid[i-k][j-l]=\"x\"\n end\n end\n end\n end\n end\n\n counter=0\n for i=2,n+1 do\n for j=2,m+1 do\n if grid[i][j]==\"o\" then\n counter=counter+1\n end\n end\n end\n print(counter)\nend", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere is 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.\nThe front and back sides of these cards can be distinguished, and initially every card faces up.\n\nWe will perform the following operation once for each square contains a card:\n\nFor each of the following nine squares, flip the card in it if it exists: the target square itself and the eight squares that shares a corner or a side with the target square.\n\nIt can be proved that, whether each card faces up or down after all the operations does not depend on the order the operations are performed.\nFind the number of cards that face down after all the operations.\n\nConstraints\n\n1 \\leq N,M \\leq 10^9\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\n\nOutput\n\nPrint the number of cards that face down after all the operations.\n\nSample Input 1\n\n2 2\n\nSample Output 1\n\n0\n\nWe will flip every card in any of the four operations. Thus, after all the operations, all cards face up.\n\nSample Input 2\n\n1 7\n\nSample Output 2\n\n5\n\nAfter all the operations, all cards except at both ends face down.\n\nSample Input 3\n\n314 1592\n\nSample Output 3\n\n496080", "sample_input": "2 2\n"}, "reference_outputs": ["0\n"], "source_document_id": "p03419", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere is 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.\nThe front and back sides of these cards can be distinguished, and initially every card faces up.\n\nWe will perform the following operation once for each square contains a card:\n\nFor each of the following nine squares, flip the card in it if it exists: the target square itself and the eight squares that shares a corner or a side with the target square.\n\nIt can be proved that, whether each card faces up or down after all the operations does not depend on the order the operations are performed.\nFind the number of cards that face down after all the operations.\n\nConstraints\n\n1 \\leq N,M \\leq 10^9\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\n\nOutput\n\nPrint the number of cards that face down after all the operations.\n\nSample Input 1\n\n2 2\n\nSample Output 1\n\n0\n\nWe will flip every card in any of the four operations. Thus, after all the operations, all cards face up.\n\nSample Input 2\n\n1 7\n\nSample Output 2\n\n5\n\nAfter all the operations, all cards except at both ends face down.\n\nSample Input 3\n\n314 1592\n\nSample Output 3\n\n496080", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 728, "cpu_time_ms": 2143, "memory_kb": 1049088}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s839536366", "group_id": "codeNet:p03420", "input_text": "local n,k=io.read(\"n\",\"n\")\nif k==0 then\n print(n*n)\nelse\n local sum=0\n for i=1,n do\n sum=sum+math.max(0,i-k)*(n//i)+math.max(0,n%i-k+1)\n end\n print(sum)\nend", "language": "Lua", "metadata": {"date": 1595211758, "filename_ext": "lua", "original_language": "Lua (Lua 5.3.5)", "problem_description_relpath": "problem_descriptions/p03420.html", "problem_id": "p03420", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03420/input.txt", "sample_output_relpath": "derived/input_output/data/p03420/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03420/Lua/s839536366.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s839536366", "user_id": "u045238009"}, "prompt_components": {"gold_output": "7\n", "input_to_evaluate": "local n,k=io.read(\"n\",\"n\")\nif k==0 then\n print(n*n)\nelse\n local sum=0\n for i=1,n do\n sum=sum+math.max(0,i-k)*(n//i)+math.max(0,n%i-k+1)\n end\n print(sum)\nend", "problem_context": "Score : 400 points\n\nProblem Statement\n\nTakahashi had a pair of two positive integers not exceeding N, (a,b), which he has forgotten.\nHe remembers that the remainder of a divided by b was greater than or equal to K.\nFind the number of possible pairs that he may have had.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n0 \\leq K \\leq N-1\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\n\nOutput\n\nPrint the number of possible pairs that he may have had.\n\nSample Input 1\n\n5 2\n\nSample Output 1\n\n7\n\nThere are seven possible pairs: (2,3),(5,3),(2,4),(3,4),(2,5),(3,5) and (4,5).\n\nSample Input 2\n\n10 0\n\nSample Output 2\n\n100\n\nSample Input 3\n\n31415 9265\n\nSample Output 3\n\n287927211", "sample_input": "5 2\n"}, "reference_outputs": ["7\n"], "source_document_id": "p03420", "source_text": "Score : 400 points\n\nProblem Statement\n\nTakahashi had a pair of two positive integers not exceeding N, (a,b), which he has forgotten.\nHe remembers that the remainder of a divided by b was greater than or equal to K.\nFind the number of possible pairs that he may have had.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n0 \\leq K \\leq N-1\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\n\nOutput\n\nPrint the number of possible pairs that he may have had.\n\nSample Input 1\n\n5 2\n\nSample Output 1\n\n7\n\nThere are seven possible pairs: (2,3),(5,3),(2,4),(3,4),(2,5),(3,5) and (4,5).\n\nSample Input 2\n\n10 0\n\nSample Output 2\n\n100\n\nSample Input 3\n\n31415 9265\n\nSample Output 3\n\n287927211", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 178, "cpu_time_ms": 30, "memory_kb": 2756}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s993095098", "group_id": "codeNet:p03421", "input_text": "local n, a, b = io.read(\"*n\", \"*n\", \"*n\")\nlocal bmax = n + 1 - a\nlocal bmin = math.ceil(n / a)\nif n < a or b < bmin or bmax < b then\n print(-1)\nelse\n local t = {}\n for i = 1, a do\n t[i] = n - a + i\n end\n local curmax = n - a\n local rem = n + 1 - a - b\n while 0 < rem do\n if a - 1 <= rem then\n for i = 1, a do\n table.insert(t, curmax - a + i)\n end\n curmax = curmax - a\n rem = rem - a + 1\n else\n for i = 1, rem + 1 do\n table.insert(t, curmax - rem - 1 + i)\n end\n curmax = curmax - rem - 1\n rem = 0\n end\n end\n for i = curmax, 1, -1 do\n table.insert(t, i)\n end\n print(table.concat(t, \" \"))\nend\n", "language": "Lua", "metadata": {"date": 1569213117, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03421.html", "problem_id": "p03421", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03421/input.txt", "sample_output_relpath": "derived/input_output/data/p03421/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03421/Lua/s993095098.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s993095098", "user_id": "u120582723"}, "prompt_components": {"gold_output": "2 4 1 5 3\n", "input_to_evaluate": "local n, a, b = io.read(\"*n\", \"*n\", \"*n\")\nlocal bmax = n + 1 - a\nlocal bmin = math.ceil(n / a)\nif n < a or b < bmin or bmax < b then\n print(-1)\nelse\n local t = {}\n for i = 1, a do\n t[i] = n - a + i\n end\n local curmax = n - a\n local rem = n + 1 - a - b\n while 0 < rem do\n if a - 1 <= rem then\n for i = 1, a do\n table.insert(t, curmax - a + i)\n end\n curmax = curmax - a\n rem = rem - a + 1\n else\n for i = 1, rem + 1 do\n table.insert(t, curmax - rem - 1 + i)\n end\n curmax = curmax - rem - 1\n rem = 0\n end\n end\n for i = curmax, 1, -1 do\n table.insert(t, i)\n end\n print(table.concat(t, \" \"))\nend\n", "problem_context": "Score : 700 points\n\nProblem Statement\n\nDetermine if there exists a sequence obtained by permuting 1,2,...,N that satisfies the following conditions:\n\nThe length of its longest increasing subsequence is A.\n\nThe length of its longest decreasing subsequence is B.\n\nIf it exists, construct one such sequence.\n\nNotes\n\nA subsequence of a sequence P is a sequence that can be obtained by extracting some of the elements in P without changing the order.\n\nA longest increasing subsequence of a sequence P is a sequence with the maximum length among the subsequences of P that are monotonically increasing.\n\nSimilarly, a longest decreasing subsequence of a sequence P is a sequence with the maximum length among the subsequences of P that are monotonically decreasing.\n\nConstraints\n\n1 \\leq N,A,B \\leq 3\\times 10^5\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN A B\n\nOutput\n\nIf there are no sequences that satisfy the conditions, print -1.\n\nOtherwise, print N integers. The i-th integer should be the i-th element of the sequence that you constructed.\n\nSample Input 1\n\n5 3 2\n\nSample Output 1\n\n2 4 1 5 3\n\nOne longest increasing subsequence of this sequence is {2,4,5}, and one longest decreasing subsequence of it is {4,3}.\n\nSample Input 2\n\n7 7 1\n\nSample Output 2\n\n1 2 3 4 5 6 7\n\nSample Input 3\n\n300000 300000 300000\n\nSample Output 3\n\n-1", "sample_input": "5 3 2\n"}, "reference_outputs": ["2 4 1 5 3\n"], "source_document_id": "p03421", "source_text": "Score : 700 points\n\nProblem Statement\n\nDetermine if there exists a sequence obtained by permuting 1,2,...,N that satisfies the following conditions:\n\nThe length of its longest increasing subsequence is A.\n\nThe length of its longest decreasing subsequence is B.\n\nIf it exists, construct one such sequence.\n\nNotes\n\nA subsequence of a sequence P is a sequence that can be obtained by extracting some of the elements in P without changing the order.\n\nA longest increasing subsequence of a sequence P is a sequence with the maximum length among the subsequences of P that are monotonically increasing.\n\nSimilarly, a longest decreasing subsequence of a sequence P is a sequence with the maximum length among the subsequences of P that are monotonically decreasing.\n\nConstraints\n\n1 \\leq N,A,B \\leq 3\\times 10^5\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN A B\n\nOutput\n\nIf there are no sequences that satisfy the conditions, print -1.\n\nOtherwise, print N integers. The i-th integer should be the i-th element of the sequence that you constructed.\n\nSample Input 1\n\n5 3 2\n\nSample Output 1\n\n2 4 1 5 3\n\nOne longest increasing subsequence of this sequence is {2,4,5}, and one longest decreasing subsequence of it is {4,3}.\n\nSample Input 2\n\n7 7 1\n\nSample Output 2\n\n1 2 3 4 5 6 7\n\nSample Input 3\n\n300000 300000 300000\n\nSample Output 3\n\n-1", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 670, "cpu_time_ms": 187, "memory_kb": 30456}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s215199569", "group_id": "codeNet:p03423", "input_text": "print(math.floor(io.read()/3))", "language": "Lua", "metadata": {"date": 1551839339, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p03423.html", "problem_id": "p03423", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03423/input.txt", "sample_output_relpath": "derived/input_output/data/p03423/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03423/Lua/s215199569.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s215199569", "user_id": "u837412668"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "print(math.floor(io.read()/3))", "problem_context": "Score : 100 points\n\nProblem Statement\n\nThere are N students in a school.\n\nWe will divide these students into some groups, and in each group they will discuss some themes.\n\nYou think that groups consisting of two or less students cannot have an effective discussion, so you want to have as many groups consisting of three or more students as possible.\n\nDivide the students so that the number of groups consisting of three or more students is maximized.\n\nConstraints\n\n1 \\leq N \\leq 1000\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nIf you can form at most x groups consisting of three or more students, print x.\n\nSample Input 1\n\n8\n\nSample Output 1\n\n2\n\nFor example, you can form a group of three students and another of five students.\n\nSample Input 2\n\n2\n\nSample Output 2\n\n0\n\nSometimes you cannot form any group consisting of three or more students, regardless of how you divide the students.\n\nSample Input 3\n\n9\n\nSample Output 3\n\n3", "sample_input": "8\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03423", "source_text": "Score : 100 points\n\nProblem Statement\n\nThere are N students in a school.\n\nWe will divide these students into some groups, and in each group they will discuss some themes.\n\nYou think that groups consisting of two or less students cannot have an effective discussion, so you want to have as many groups consisting of three or more students as possible.\n\nDivide the students so that the number of groups consisting of three or more students is maximized.\n\nConstraints\n\n1 \\leq N \\leq 1000\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nIf you can form at most x groups consisting of three or more students, print x.\n\nSample Input 1\n\n8\n\nSample Output 1\n\n2\n\nFor example, you can form a group of three students and another of five students.\n\nSample Input 2\n\n2\n\nSample Output 2\n\n0\n\nSometimes you cannot form any group consisting of three or more students, regardless of how you divide the students.\n\nSample Input 3\n\n9\n\nSample Output 3\n\n3", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 30, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s031869484", "group_id": "codeNet:p03423", "input_text": "print(io.read()//3)", "language": "Lua", "metadata": {"date": 1551839277, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03423.html", "problem_id": "p03423", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03423/input.txt", "sample_output_relpath": "derived/input_output/data/p03423/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03423/Lua/s031869484.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s031869484", "user_id": "u837412668"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "print(io.read()//3)", "problem_context": "Score : 100 points\n\nProblem Statement\n\nThere are N students in a school.\n\nWe will divide these students into some groups, and in each group they will discuss some themes.\n\nYou think that groups consisting of two or less students cannot have an effective discussion, so you want to have as many groups consisting of three or more students as possible.\n\nDivide the students so that the number of groups consisting of three or more students is maximized.\n\nConstraints\n\n1 \\leq N \\leq 1000\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nIf you can form at most x groups consisting of three or more students, print x.\n\nSample Input 1\n\n8\n\nSample Output 1\n\n2\n\nFor example, you can form a group of three students and another of five students.\n\nSample Input 2\n\n2\n\nSample Output 2\n\n0\n\nSometimes you cannot form any group consisting of three or more students, regardless of how you divide the students.\n\nSample Input 3\n\n9\n\nSample Output 3\n\n3", "sample_input": "8\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03423", "source_text": "Score : 100 points\n\nProblem Statement\n\nThere are N students in a school.\n\nWe will divide these students into some groups, and in each group they will discuss some themes.\n\nYou think that groups consisting of two or less students cannot have an effective discussion, so you want to have as many groups consisting of three or more students as possible.\n\nDivide the students so that the number of groups consisting of three or more students is maximized.\n\nConstraints\n\n1 \\leq N \\leq 1000\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nIf you can form at most x groups consisting of three or more students, print x.\n\nSample Input 1\n\n8\n\nSample Output 1\n\n2\n\nFor example, you can form a group of three students and another of five students.\n\nSample Input 2\n\n2\n\nSample Output 2\n\n0\n\nSometimes you cannot form any group consisting of three or more students, regardless of how you divide the students.\n\nSample Input 3\n\n9\n\nSample Output 3\n\n3", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 19, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s519954967", "group_id": "codeNet:p03423", "input_text": "N=io.read(\"n\")\nprint(N//3)", "language": "Lua", "metadata": {"date": 1550960785, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03423.html", "problem_id": "p03423", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03423/input.txt", "sample_output_relpath": "derived/input_output/data/p03423/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03423/Lua/s519954967.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s519954967", "user_id": "u015229643"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "N=io.read(\"n\")\nprint(N//3)", "problem_context": "Score : 100 points\n\nProblem Statement\n\nThere are N students in a school.\n\nWe will divide these students into some groups, and in each group they will discuss some themes.\n\nYou think that groups consisting of two or less students cannot have an effective discussion, so you want to have as many groups consisting of three or more students as possible.\n\nDivide the students so that the number of groups consisting of three or more students is maximized.\n\nConstraints\n\n1 \\leq N \\leq 1000\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nIf you can form at most x groups consisting of three or more students, print x.\n\nSample Input 1\n\n8\n\nSample Output 1\n\n2\n\nFor example, you can form a group of three students and another of five students.\n\nSample Input 2\n\n2\n\nSample Output 2\n\n0\n\nSometimes you cannot form any group consisting of three or more students, regardless of how you divide the students.\n\nSample Input 3\n\n9\n\nSample Output 3\n\n3", "sample_input": "8\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03423", "source_text": "Score : 100 points\n\nProblem Statement\n\nThere are N students in a school.\n\nWe will divide these students into some groups, and in each group they will discuss some themes.\n\nYou think that groups consisting of two or less students cannot have an effective discussion, so you want to have as many groups consisting of three or more students as possible.\n\nDivide the students so that the number of groups consisting of three or more students is maximized.\n\nConstraints\n\n1 \\leq N \\leq 1000\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nIf you can form at most x groups consisting of three or more students, print x.\n\nSample Input 1\n\n8\n\nSample Output 1\n\n2\n\nFor example, you can form a group of three students and another of five students.\n\nSample Input 2\n\n2\n\nSample Output 2\n\n0\n\nSometimes you cannot form any group consisting of three or more students, regardless of how you divide the students.\n\nSample Input 3\n\n9\n\nSample Output 3\n\n3", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 26, "cpu_time_ms": 8, "memory_kb": 760}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s806649202", "group_id": "codeNet:p03425", "input_text": "N=io.read(\"n\")\nlocal t={M=0,A=0,R=0,C=0,H=0}\nfor i=1,N do\n local s=io.read()\n local f=string.sub(s,1,1)\n t[f]=t[f]+1 or nil\nend\na1 =t[M]*t[A]*t[R]\na2 =t[M]*t[A]*t[C]\na3 =t[M]*t[A]*t[H]\na4 =t[M]*t[R]*t[C]\na5 =t[M]*t[R]*t[H]\na6 =t[M]*t[C]*t[H]\na7 =t[A]*t[R]*t[C]\na8 =t[A]*t[R]*t[H]\na9 =t[A]*t[C]*t[H]\na10=t[R]*t[C]*t[H]\nprint(a1+a2+a3+a4+a5+a6+a7+a8+a9+a10)", "language": "Lua", "metadata": {"date": 1550964514, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03425.html", "problem_id": "p03425", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03425/input.txt", "sample_output_relpath": "derived/input_output/data/p03425/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03425/Lua/s806649202.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s806649202", "user_id": "u015229643"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "N=io.read(\"n\")\nlocal t={M=0,A=0,R=0,C=0,H=0}\nfor i=1,N do\n local s=io.read()\n local f=string.sub(s,1,1)\n t[f]=t[f]+1 or nil\nend\na1 =t[M]*t[A]*t[R]\na2 =t[M]*t[A]*t[C]\na3 =t[M]*t[A]*t[H]\na4 =t[M]*t[R]*t[C]\na5 =t[M]*t[R]*t[H]\na6 =t[M]*t[C]*t[H]\na7 =t[A]*t[R]*t[C]\na8 =t[A]*t[R]*t[H]\na9 =t[A]*t[C]*t[H]\na10=t[R]*t[C]*t[H]\nprint(a1+a2+a3+a4+a5+a6+a7+a8+a9+a10)", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere are N people. The name of the i-th person is S_i.\n\nWe would like to choose three people so that the following conditions are met:\n\nThe name of every chosen person begins with M, A, R, C or H.\n\nThere are no multiple people whose names begin with the same letter.\n\nHow many such ways are there to choose three people, disregarding order?\n\nNote that the answer may not fit into a 32-bit integer type.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\nS_i consists of uppercase English letters.\n\n1 \\leq |S_i| \\leq 10\n\nS_i \\neq S_j (i \\neq j)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS_1\n:\nS_N\n\nOutput\n\nIf there are x ways to choose three people so that the given conditions are met, print x.\n\nSample Input 1\n\n5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI\n\nSample Output 1\n\n2\n\nWe can choose three people with the following names:\n\nMASHIKE, RUMOI, HABORO\n\nMASHIKE, RUMOI, HOROKANAI\n\nThus, we have two ways.\n\nSample Input 2\n\n4\nZZ\nZZZ\nZ\nZZZZZZZZZZ\n\nSample Output 2\n\n0\n\nNote that there may be no ways to choose three people so that the given conditions are met.\n\nSample Input 3\n\n5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO\n\nSample Output 3\n\n7", "sample_input": "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03425", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere are N people. The name of the i-th person is S_i.\n\nWe would like to choose three people so that the following conditions are met:\n\nThe name of every chosen person begins with M, A, R, C or H.\n\nThere are no multiple people whose names begin with the same letter.\n\nHow many such ways are there to choose three people, disregarding order?\n\nNote that the answer may not fit into a 32-bit integer type.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\nS_i consists of uppercase English letters.\n\n1 \\leq |S_i| \\leq 10\n\nS_i \\neq S_j (i \\neq j)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS_1\n:\nS_N\n\nOutput\n\nIf there are x ways to choose three people so that the given conditions are met, print x.\n\nSample Input 1\n\n5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI\n\nSample Output 1\n\n2\n\nWe can choose three people with the following names:\n\nMASHIKE, RUMOI, HABORO\n\nMASHIKE, RUMOI, HOROKANAI\n\nThus, we have two ways.\n\nSample Input 2\n\n4\nZZ\nZZZ\nZ\nZZZZZZZZZZ\n\nSample Output 2\n\n0\n\nNote that there may be no ways to choose three people so that the given conditions are met.\n\nSample Input 3\n\n5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO\n\nSample Output 3\n\n7", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 358, "cpu_time_ms": 7, "memory_kb": 760}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s789289197", "group_id": "codeNet:p03426", "input_text": "local mfl, mab = math.floor, math.abs\nlocal h, w, d = io.read(\"*n\", \"*n\", \"*n\")\nlocal n = h * w\nlocal map = {}\nlocal cost = {}\nfor i = 1, n do\n map[i] = io.read(\"*n\")\n cost[i] = 0\nend\nfor t_i_d = 1, d do\n local src_x, src_y = 0, 0\n local costsum = 0\n local i_d = t_i_d\n while i_d <= n do\n for i = 1, n do\n if map[i] == i_d then\n local dst_x, dst_y = 1 + (i - 1) % w, 1 + mfl((i - 1) / w)\n costsum = costsum + mab(dst_x - src_x) + mab(dst_y - src_y)\n cost[i_d] = costsum\n src_x, src_y = dst_x, dst_y\n break\n end\n end\n i_d = i_d + d\n end\nend\nlocal q = io.read(\"*n\")\nfor i = 1, q do\n local l, r = io.read(\"*n\", \"*n\")\n print(cost[r] - cost[l])\nend\n", "language": "Lua", "metadata": {"date": 1558664924, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p03426.html", "problem_id": "p03426", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03426/input.txt", "sample_output_relpath": "derived/input_output/data/p03426/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03426/Lua/s789289197.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s789289197", "user_id": "u120582723"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "local mfl, mab = math.floor, math.abs\nlocal h, w, d = io.read(\"*n\", \"*n\", \"*n\")\nlocal n = h * w\nlocal map = {}\nlocal cost = {}\nfor i = 1, n do\n map[i] = io.read(\"*n\")\n cost[i] = 0\nend\nfor t_i_d = 1, d do\n local src_x, src_y = 0, 0\n local costsum = 0\n local i_d = t_i_d\n while i_d <= n do\n for i = 1, n do\n if map[i] == i_d then\n local dst_x, dst_y = 1 + (i - 1) % w, 1 + mfl((i - 1) / w)\n costsum = costsum + mab(dst_x - src_x) + mab(dst_y - src_y)\n cost[i_d] = costsum\n src_x, src_y = dst_x, dst_y\n break\n end\n end\n i_d = i_d + d\n end\nend\nlocal q = io.read(\"*n\")\nfor i = 1, q do\n local l, r = io.read(\"*n\", \"*n\")\n print(cost[r] - cost[l])\nend\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nWe have a grid with H rows and W columns. The square at the i-th row and the j-th column will be called Square (i,j).\n\nThe integers from 1 through H×W are written throughout the grid, and the integer written in Square (i,j) is A_{i,j}.\n\nYou, a magical girl, can teleport a piece placed on Square (i,j) to Square (x,y) by consuming |x-i|+|y-j| magic points.\n\nYou now have to take Q practical tests of your ability as a magical girl.\n\nThe i-th test will be conducted as follows:\n\nInitially, a piece is placed on the square where the integer L_i is written.\n\nLet x be the integer written in the square occupied by the piece. Repeatedly move the piece to the square where the integer x+D is written, as long as x is not R_i. The test ends when x=R_i.\n\nHere, it is guaranteed that R_i-L_i is a multiple of D.\n\nFor each test, find the sum of magic points consumed during that test.\n\nConstraints\n\n1 \\leq H,W \\leq 300\n\n1 \\leq D \\leq H×W\n\n1 \\leq A_{i,j} \\leq H×W\n\nA_{i,j} \\neq A_{x,y} ((i,j) \\neq (x,y))\n\n1 \\leq Q \\leq 10^5\n\n1 \\leq L_i \\leq R_i \\leq H×W\n\n(R_i-L_i) is a multiple of D.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W D\nA_{1,1} A_{1,2} ... A_{1,W}\n:\nA_{H,1} A_{H,2} ... A_{H,W}\nQ\nL_1 R_1\n:\nL_Q R_Q\n\nOutput\n\nFor each test, print the sum of magic points consumed during that test.\n\nOutput should be in the order the tests are conducted.\n\nSample Input 1\n\n3 3 2\n1 4 3\n2 5 7\n8 9 6\n1\n4 8\n\nSample Output 1\n\n5\n\n4 is written in Square (1,2).\n\n6 is written in Square (3,3).\n\n8 is written in Square (3,1).\n\nThus, the sum of magic points consumed during the first test is (|3-1|+|3-2|)+(|3-3|+|1-3|)=5.\n\nSample Input 2\n\n4 2 3\n3 7\n1 4\n5 2\n6 8\n2\n2 2\n2 2\n\nSample Output 2\n\n0\n0\n\nNote that there may be a test where the piece is not moved at all, and there may be multiple identical tests.\n\nSample Input 3\n\n5 5 4\n13 25 7 15 17\n16 22 20 2 9\n14 11 12 1 19\n10 6 23 8 18\n3 21 5 24 4\n3\n13 13\n2 10\n13 13\n\nSample Output 3\n\n0\n5\n0", "sample_input": "3 3 2\n1 4 3\n2 5 7\n8 9 6\n1\n4 8\n"}, "reference_outputs": ["5\n"], "source_document_id": "p03426", "source_text": "Score : 400 points\n\nProblem Statement\n\nWe have a grid with H rows and W columns. The square at the i-th row and the j-th column will be called Square (i,j).\n\nThe integers from 1 through H×W are written throughout the grid, and the integer written in Square (i,j) is A_{i,j}.\n\nYou, a magical girl, can teleport a piece placed on Square (i,j) to Square (x,y) by consuming |x-i|+|y-j| magic points.\n\nYou now have to take Q practical tests of your ability as a magical girl.\n\nThe i-th test will be conducted as follows:\n\nInitially, a piece is placed on the square where the integer L_i is written.\n\nLet x be the integer written in the square occupied by the piece. Repeatedly move the piece to the square where the integer x+D is written, as long as x is not R_i. The test ends when x=R_i.\n\nHere, it is guaranteed that R_i-L_i is a multiple of D.\n\nFor each test, find the sum of magic points consumed during that test.\n\nConstraints\n\n1 \\leq H,W \\leq 300\n\n1 \\leq D \\leq H×W\n\n1 \\leq A_{i,j} \\leq H×W\n\nA_{i,j} \\neq A_{x,y} ((i,j) \\neq (x,y))\n\n1 \\leq Q \\leq 10^5\n\n1 \\leq L_i \\leq R_i \\leq H×W\n\n(R_i-L_i) is a multiple of D.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W D\nA_{1,1} A_{1,2} ... A_{1,W}\n:\nA_{H,1} A_{H,2} ... A_{H,W}\nQ\nL_1 R_1\n:\nL_Q R_Q\n\nOutput\n\nFor each test, print the sum of magic points consumed during that test.\n\nOutput should be in the order the tests are conducted.\n\nSample Input 1\n\n3 3 2\n1 4 3\n2 5 7\n8 9 6\n1\n4 8\n\nSample Output 1\n\n5\n\n4 is written in Square (1,2).\n\n6 is written in Square (3,3).\n\n8 is written in Square (3,1).\n\nThus, the sum of magic points consumed during the first test is (|3-1|+|3-2|)+(|3-3|+|1-3|)=5.\n\nSample Input 2\n\n4 2 3\n3 7\n1 4\n5 2\n6 8\n2\n2 2\n2 2\n\nSample Output 2\n\n0\n0\n\nNote that there may be a test where the piece is not moved at all, and there may be multiple identical tests.\n\nSample Input 3\n\n5 5 4\n13 25 7 15 17\n16 22 20 2 9\n14 11 12 1 19\n10 6 23 8 18\n3 21 5 24 4\n3\n13 13\n2 10\n13 13\n\nSample Output 3\n\n0\n5\n0", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 707, "cpu_time_ms": 2103, "memory_kb": 2560}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s536084326", "group_id": "codeNet:p03427", "input_text": "local s = io.read()\nlocal all9 = true\nfor i = 2, #s do\n if s:sub(i, i) ~= \"9\" then\n all9 = false\n end\nend\nlocal n = tonumber(s:sub(1, 1))\nn = n + 9 * (#s - 1)\nif not all9 then n = n - 1 end\nprint(n)\n", "language": "Lua", "metadata": {"date": 1563248041, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03427.html", "problem_id": "p03427", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03427/input.txt", "sample_output_relpath": "derived/input_output/data/p03427/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03427/Lua/s536084326.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s536084326", "user_id": "u120582723"}, "prompt_components": {"gold_output": "18\n", "input_to_evaluate": "local s = io.read()\nlocal all9 = true\nfor i = 2, #s do\n if s:sub(i, i) ~= \"9\" then\n all9 = false\n end\nend\nlocal n = tonumber(s:sub(1, 1))\nn = n + 9 * (#s - 1)\nif not all9 then n = n - 1 end\nprint(n)\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nFind the maximum possible sum of the digits (in base 10) of a positive integer not greater than N.\n\nConstraints\n\n1\\leq N \\leq 10^{16}\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the maximum possible sum of the digits (in base 10) of a positive integer not greater than N.\n\nSample Input 1\n\n100\n\nSample Output 1\n\n18\n\nFor example, the sum of the digits in 99 is 18, which turns out to be the maximum value.\n\nSample Input 2\n\n9995\n\nSample Output 2\n\n35\n\nFor example, the sum of the digits in 9989 is 35, which turns out to be the maximum value.\n\nSample Input 3\n\n3141592653589793\n\nSample Output 3\n\n137", "sample_input": "100\n"}, "reference_outputs": ["18\n"], "source_document_id": "p03427", "source_text": "Score : 300 points\n\nProblem Statement\n\nFind the maximum possible sum of the digits (in base 10) of a positive integer not greater than N.\n\nConstraints\n\n1\\leq N \\leq 10^{16}\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the maximum possible sum of the digits (in base 10) of a positive integer not greater than N.\n\nSample Input 1\n\n100\n\nSample Output 1\n\n18\n\nFor example, the sum of the digits in 99 is 18, which turns out to be the maximum value.\n\nSample Input 2\n\n9995\n\nSample Output 2\n\n35\n\nFor example, the sum of the digits in 9989 is 35, which turns out to be the maximum value.\n\nSample Input 3\n\n3141592653589793\n\nSample Output 3\n\n137", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 204, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s276549208", "group_id": "codeNet:p03433", "input_text": "print(io.read()%500>1*io.read()and\"No\"or\"Yes\")", "language": "Lua", "metadata": {"date": 1551839206, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03433.html", "problem_id": "p03433", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03433/input.txt", "sample_output_relpath": "derived/input_output/data/p03433/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03433/Lua/s276549208.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s276549208", "user_id": "u837412668"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "print(io.read()%500>1*io.read()and\"No\"or\"Yes\")", "problem_context": "Score: 100 points\n\nProblem Statement\n\nE869120 has A 1-yen coins and infinitely many 500-yen coins.\n\nDetermine if he can pay exactly N yen using only these coins.\n\nConstraints\n\nN is an integer between 1 and 10000 (inclusive).\n\nA is an integer between 0 and 1000 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA\n\nOutput\n\nIf E869120 can pay exactly N yen using only his 1-yen and 500-yen coins, print Yes; otherwise, print No.\n\nSample Input 1\n\n2018\n218\n\nSample Output 1\n\nYes\n\nWe can pay 2018 yen with four 500-yen coins and 18 1-yen coins, so the answer is Yes.\n\nSample Input 2\n\n2763\n0\n\nSample Output 2\n\nNo\n\nWhen we have no 1-yen coins, we can only pay a multiple of 500 yen using only 500-yen coins. Since 2763 is not a multiple of 500, we cannot pay this amount.\n\nSample Input 3\n\n37\n514\n\nSample Output 3\n\nYes", "sample_input": "2018\n218\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03433", "source_text": "Score: 100 points\n\nProblem Statement\n\nE869120 has A 1-yen coins and infinitely many 500-yen coins.\n\nDetermine if he can pay exactly N yen using only these coins.\n\nConstraints\n\nN is an integer between 1 and 10000 (inclusive).\n\nA is an integer between 0 and 1000 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA\n\nOutput\n\nIf E869120 can pay exactly N yen using only his 1-yen and 500-yen coins, print Yes; otherwise, print No.\n\nSample Input 1\n\n2018\n218\n\nSample Output 1\n\nYes\n\nWe can pay 2018 yen with four 500-yen coins and 18 1-yen coins, so the answer is Yes.\n\nSample Input 2\n\n2763\n0\n\nSample Output 2\n\nNo\n\nWhen we have no 1-yen coins, we can only pay a multiple of 500 yen using only 500-yen coins. Since 2763 is not a multiple of 500, we cannot pay this amount.\n\nSample Input 3\n\n37\n514\n\nSample Output 3\n\nYes", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 46, "cpu_time_ms": 3, "memory_kb": 376}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s965088735", "group_id": "codeNet:p03435", "input_text": "a={}\nfor i=1,9 do \n a[i]=io.read(\"n\")\nend\nlocal res=\"No\"\nif a[1]-a[2]==a[4]-a[5] and a[4]-a[5]==a[7]-a[8] then\n if a[2]-a[3]==a[5]-a[6] and a[5]-a[6]==a[8]-a[9] then\n if a[1]-a[4]==a[2]-a[5] and a[2]-a[5]==a[3]-a[6] then\n if a[4]-a[7]==a[5]-a[8] and a[5]-a[8]==a[6]-a[9] then\n res=\"Yes\"\n end\n end\n end\nend\nprint(res)", "language": "Lua", "metadata": {"date": 1550970987, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03435.html", "problem_id": "p03435", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03435/input.txt", "sample_output_relpath": "derived/input_output/data/p03435/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03435/Lua/s965088735.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s965088735", "user_id": "u015229643"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "a={}\nfor i=1,9 do \n a[i]=io.read(\"n\")\nend\nlocal res=\"No\"\nif a[1]-a[2]==a[4]-a[5] and a[4]-a[5]==a[7]-a[8] then\n if a[2]-a[3]==a[5]-a[6] and a[5]-a[6]==a[8]-a[9] then\n if a[1]-a[4]==a[2]-a[5] and a[2]-a[5]==a[3]-a[6] then\n if a[4]-a[7]==a[5]-a[8] and a[5]-a[8]==a[6]-a[9] then\n res=\"Yes\"\n end\n end\n end\nend\nprint(res)", "problem_context": "Score: 300 points\n\nProblem Statement\n\nWe have a 3 \\times 3 grid. A number c_{i, j} is written in the square (i, j), where (i, j) denotes the square at the i-th row from the top and the j-th column from the left.\n\nAccording to Takahashi, there are six integers a_1, a_2, a_3, b_1, b_2, b_3 whose values are fixed, and the number written in the square (i, j) is equal to a_i + b_j.\n\nDetermine if he is correct.\n\nConstraints\n\nc_{i, j} \\ (1 \\leq i \\leq 3, 1 \\leq j \\leq 3) is an integer between 0 and 100 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nc_{1,1} c_{1,2} c_{1,3}\nc_{2,1} c_{2,2} c_{2,3}\nc_{3,1} c_{3,2} c_{3,3}\n\nOutput\n\nIf Takahashi's statement is correct, print Yes; otherwise, print No.\n\nSample Input 1\n\n1 0 1\n2 1 2\n1 0 1\n\nSample Output 1\n\nYes\n\nTakahashi is correct, since there are possible sets of integers such as: a_1=0,a_2=1,a_3=0,b_1=1,b_2=0,b_3=1.\n\nSample Input 2\n\n2 2 2\n2 1 2\n2 2 2\n\nSample Output 2\n\nNo\n\nTakahashi is incorrect in this case.\n\nSample Input 3\n\n0 8 8\n0 8 8\n0 8 8\n\nSample Output 3\n\nYes\n\nSample Input 4\n\n1 8 6\n2 9 7\n0 7 7\n\nSample Output 4\n\nNo", "sample_input": "1 0 1\n2 1 2\n1 0 1\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03435", "source_text": "Score: 300 points\n\nProblem Statement\n\nWe have a 3 \\times 3 grid. A number c_{i, j} is written in the square (i, j), where (i, j) denotes the square at the i-th row from the top and the j-th column from the left.\n\nAccording to Takahashi, there are six integers a_1, a_2, a_3, b_1, b_2, b_3 whose values are fixed, and the number written in the square (i, j) is equal to a_i + b_j.\n\nDetermine if he is correct.\n\nConstraints\n\nc_{i, j} \\ (1 \\leq i \\leq 3, 1 \\leq j \\leq 3) is an integer between 0 and 100 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nc_{1,1} c_{1,2} c_{1,3}\nc_{2,1} c_{2,2} c_{2,3}\nc_{3,1} c_{3,2} c_{3,3}\n\nOutput\n\nIf Takahashi's statement is correct, print Yes; otherwise, print No.\n\nSample Input 1\n\n1 0 1\n2 1 2\n1 0 1\n\nSample Output 1\n\nYes\n\nTakahashi is correct, since there are possible sets of integers such as: a_1=0,a_2=1,a_3=0,b_1=1,b_2=0,b_3=1.\n\nSample Input 2\n\n2 2 2\n2 1 2\n2 2 2\n\nSample Output 2\n\nNo\n\nTakahashi is incorrect in this case.\n\nSample Input 3\n\n0 8 8\n0 8 8\n0 8 8\n\nSample Output 3\n\nYes\n\nSample Input 4\n\n1 8 6\n2 9 7\n0 7 7\n\nSample Output 4\n\nNo", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 342, "cpu_time_ms": 7, "memory_kb": 760}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s436584686", "group_id": "codeNet:p03436", "input_text": "-- capture\nlocal h, w = io.read(\"*n\", \"*n\", \"*l\")\nlocal s = h * w\nlocal str = \"\"\nlocal t = {}\nlocal white = 0\nfor i = 1, h do\n str = io.read()\n for j = 1, w do\n if(string.sub(str, j, j) == \".\") then\n t[(i - 1) * w + j] = 0\n white = white + 1\n else\n t[(i - 1) * w + j] = -1\n end\n end\nend\nt[1] = 1\nlocal check_pos = {1}\nlocal rem_count, task_idx, step = 1, 1, 1\nwhile(0 < rem_count) do\n local idx = check_pos[task_idx]\n rem_count, task_idx = rem_count - 1, task_idx + 1\n -- left\n if(idx % w ~= 1) then\n if(t[idx - 1] == 0) then t[idx - 1] = t[idx] + 1; rem_count = rem_count + 1; table.insert(check_pos, idx - 1) end\n end\n -- right\n if(idx % w ~= 0) then\n if(t[idx + 1] == 0) then t[idx + 1] = t[idx] + 1; rem_count = rem_count + 1; table.insert(check_pos, idx + 1) end\n end\n -- up\n if(w < idx) then\n if(t[idx - w] == 0) then t[idx - w] = t[idx] + 1; rem_count = rem_count + 1; table.insert(check_pos, idx - w) end\n end\n -- down\n if(idx <= s - w) then\n if(t[idx + w] == 0) then t[idx + w] = t[idx] + 1; rem_count = rem_count + 1; table.insert(check_pos, idx + w) end\n end\nend\nif(0 < t[s]) then print(white - t[s]) else print(-1) end\n\n", "language": "Lua", "metadata": {"date": 1555364576, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p03436.html", "problem_id": "p03436", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03436/input.txt", "sample_output_relpath": "derived/input_output/data/p03436/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03436/Lua/s436584686.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s436584686", "user_id": "u120582723"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "-- capture\nlocal h, w = io.read(\"*n\", \"*n\", \"*l\")\nlocal s = h * w\nlocal str = \"\"\nlocal t = {}\nlocal white = 0\nfor i = 1, h do\n str = io.read()\n for j = 1, w do\n if(string.sub(str, j, j) == \".\") then\n t[(i - 1) * w + j] = 0\n white = white + 1\n else\n t[(i - 1) * w + j] = -1\n end\n end\nend\nt[1] = 1\nlocal check_pos = {1}\nlocal rem_count, task_idx, step = 1, 1, 1\nwhile(0 < rem_count) do\n local idx = check_pos[task_idx]\n rem_count, task_idx = rem_count - 1, task_idx + 1\n -- left\n if(idx % w ~= 1) then\n if(t[idx - 1] == 0) then t[idx - 1] = t[idx] + 1; rem_count = rem_count + 1; table.insert(check_pos, idx - 1) end\n end\n -- right\n if(idx % w ~= 0) then\n if(t[idx + 1] == 0) then t[idx + 1] = t[idx] + 1; rem_count = rem_count + 1; table.insert(check_pos, idx + 1) end\n end\n -- up\n if(w < idx) then\n if(t[idx - w] == 0) then t[idx - w] = t[idx] + 1; rem_count = rem_count + 1; table.insert(check_pos, idx - w) end\n end\n -- down\n if(idx <= s - w) then\n if(t[idx + w] == 0) then t[idx + w] = t[idx] + 1; rem_count = rem_count + 1; table.insert(check_pos, idx + w) end\n end\nend\nif(0 < t[s]) then print(white - t[s]) else print(-1) end\n\n", "problem_context": "Score: 400 points\n\nProblem statement\n\nWe have an H \\times W grid whose squares are painted black or white. The square at the i-th row from the top and the j-th column from the left is denoted as (i, j).\n\nSnuke would like to play the following game on this grid. At the beginning of the game, there is a character called Kenus at square (1, 1). The player repeatedly moves Kenus up, down, left or right by one square. The game is completed when Kenus reaches square (H, W) passing only white squares.\n\nBefore Snuke starts the game, he can change the color of some of the white squares to black. However, he cannot change the color of square (1, 1) and (H, W). Also, changes of color must all be carried out before the beginning of the game.\n\nWhen the game is completed, Snuke's score will be the number of times he changed the color of a square before the beginning of the game. Find the maximum possible score that Snuke can achieve, or print -1 if the game cannot be completed, that is, Kenus can never reach square (H, W) regardless of how Snuke changes the color of the squares.\n\nThe color of the squares are given to you as characters s_{i, j}. If square (i, j) is initially painted by white, s_{i, j} is .; if square (i, j) is initially painted by black, s_{i, j} is #.\n\nConstraints\n\nH is an integer between 2 and 50 (inclusive).\n\nW is an integer between 2 and 50 (inclusive).\n\ns_{i, j} is . or # (1 \\leq i \\leq H, 1 \\leq j \\leq W).\n\ns_{1, 1} and s_{H, W} are ..\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\ns_{1, 1}s_{1, 2}s_{1, 3} ... s_{1, W}\ns_{2, 1}s_{2, 2}s_{2, 3} ... s_{2, W}\n: :\ns_{H, 1}s_{H, 2}s_{H, 3} ... s_{H, W}\n\nOutput\n\nPrint the maximum possible score that Snuke can achieve, or print -1 if the game cannot be completed.\n\nSample Input 1\n\n3 3\n..#\n#..\n...\n\nSample Output 1\n\n2\n\nThe score 2 can be achieved by changing the color of squares as follows:\n\nSample Input 2\n\n10 37\n.....................................\n...#...####...####..###...###...###..\n..#.#..#...#.##....#...#.#...#.#...#.\n..#.#..#...#.#.....#...#.#...#.#...#.\n.#...#.#..##.#.....#...#.#.###.#.###.\n.#####.####..#.....#...#..##....##...\n.#...#.#...#.#.....#...#.#...#.#...#.\n.#...#.#...#.##....#...#.#...#.#...#.\n.#...#.####...####..###...###...###..\n.....................................\n\nSample Output 2\n\n209", "sample_input": "3 3\n..#\n#..\n...\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03436", "source_text": "Score: 400 points\n\nProblem statement\n\nWe have an H \\times W grid whose squares are painted black or white. The square at the i-th row from the top and the j-th column from the left is denoted as (i, j).\n\nSnuke would like to play the following game on this grid. At the beginning of the game, there is a character called Kenus at square (1, 1). The player repeatedly moves Kenus up, down, left or right by one square. The game is completed when Kenus reaches square (H, W) passing only white squares.\n\nBefore Snuke starts the game, he can change the color of some of the white squares to black. However, he cannot change the color of square (1, 1) and (H, W). Also, changes of color must all be carried out before the beginning of the game.\n\nWhen the game is completed, Snuke's score will be the number of times he changed the color of a square before the beginning of the game. Find the maximum possible score that Snuke can achieve, or print -1 if the game cannot be completed, that is, Kenus can never reach square (H, W) regardless of how Snuke changes the color of the squares.\n\nThe color of the squares are given to you as characters s_{i, j}. If square (i, j) is initially painted by white, s_{i, j} is .; if square (i, j) is initially painted by black, s_{i, j} is #.\n\nConstraints\n\nH is an integer between 2 and 50 (inclusive).\n\nW is an integer between 2 and 50 (inclusive).\n\ns_{i, j} is . or # (1 \\leq i \\leq H, 1 \\leq j \\leq W).\n\ns_{1, 1} and s_{H, W} are ..\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\ns_{1, 1}s_{1, 2}s_{1, 3} ... s_{1, W}\ns_{2, 1}s_{2, 2}s_{2, 3} ... s_{2, W}\n: :\ns_{H, 1}s_{H, 2}s_{H, 3} ... s_{H, W}\n\nOutput\n\nPrint the maximum possible score that Snuke can achieve, or print -1 if the game cannot be completed.\n\nSample Input 1\n\n3 3\n..#\n#..\n...\n\nSample Output 1\n\n2\n\nThe score 2 can be achieved by changing the color of squares as follows:\n\nSample Input 2\n\n10 37\n.....................................\n...#...####...####..###...###...###..\n..#.#..#...#.##....#...#.#...#.#...#.\n..#.#..#...#.#.....#...#.#...#.#...#.\n.#...#.#..##.#.....#...#.#.###.#.###.\n.#####.####..#.....#...#..##....##...\n.#...#.#...#.#.....#...#.#...#.#...#.\n.#...#.#...#.##....#...#.#...#.#...#.\n.#...#.####...####..###...###...###..\n.....................................\n\nSample Output 2\n\n209", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1185, "cpu_time_ms": 2, "memory_kb": 384}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s851405963", "group_id": "codeNet:p03438", "input_text": "local n = io.read(\"*n\")\nlocal a, b = {}, {}\nfor i = 1, n do a[i] = io.read(\"*n\") end\nfor i = 1, n do b[i] = io.read(\"*n\") end\nlocal asum, bsum = 0, 0\nlocal c = {}\nfor i = 1, n do\n c[i] = b[i] - a[i]\n asum, bsum = asum + a[i], bsum + b[i]\nend\ntable.sort(c)\nlocal cnt = bsum - asum\nfor i = 1, n do\n if c[i] < 0 then\n cnt = cnt + c[i]\n elseif 0 < c[i] then\n if c[i] % 2 == 1 then cnt = cnt - 1 end\n end\nend\nprint(0 <= cnt and \"Yes\" or \"No\")\n", "language": "Lua", "metadata": {"date": 1563655003, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03438.html", "problem_id": "p03438", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03438/input.txt", "sample_output_relpath": "derived/input_output/data/p03438/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03438/Lua/s851405963.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s851405963", "user_id": "u120582723"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "local n = io.read(\"*n\")\nlocal a, b = {}, {}\nfor i = 1, n do a[i] = io.read(\"*n\") end\nfor i = 1, n do b[i] = io.read(\"*n\") end\nlocal asum, bsum = 0, 0\nlocal c = {}\nfor i = 1, n do\n c[i] = b[i] - a[i]\n asum, bsum = asum + a[i], bsum + b[i]\nend\ntable.sort(c)\nlocal cnt = bsum - asum\nfor i = 1, n do\n if c[i] < 0 then\n cnt = cnt + c[i]\n elseif 0 < c[i] then\n if c[i] % 2 == 1 then cnt = cnt - 1 end\n end\nend\nprint(0 <= cnt and \"Yes\" or \"No\")\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nYou are given two integer sequences of length N: a_1,a_2,..,a_N and b_1,b_2,..,b_N.\nDetermine if we can repeat the following operation zero or more times so that the sequences a and b become equal.\n\nOperation: Choose two integers i and j (possibly the same) between 1 and N (inclusive), then perform the following two actions simultaneously:\n\nAdd 2 to a_i.\n\nAdd 1 to b_j.\n\nConstraints\n\n1 ≤ N ≤ 10 000\n\n0 �� a_i,b_i ≤ 10^9 (1 ≤ i ≤ N)\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 .. a_N\nb_1 b_2 .. b_N\n\nOutput\n\nIf we can repeat the operation zero or more times so that the sequences a and b become equal, print Yes; otherwise, print No.\n\nSample Input 1\n\n3\n1 2 3\n5 2 2\n\nSample Output 1\n\nYes\n\nFor example, we can perform three operations as follows to do our job:\n\nFirst operation: i=1 and j=2. Now we have a = \\{3,2,3\\}, b = \\{5,3,2\\}.\n\nSecond operation: i=1 and j=2. Now we have a = \\{5,2,3\\}, b = \\{5,4,2\\}.\n\nThird operation: i=2 and j=3. Now we have a = \\{5,4,3\\}, b = \\{5,4,3\\}.\n\nSample Input 2\n\n5\n3 1 4 1 5\n2 7 1 8 2\n\nSample Output 2\n\nNo\n\nSample Input 3\n\n5\n2 7 1 8 2\n3 1 4 1 5\n\nSample Output 3\n\nNo", "sample_input": "3\n1 2 3\n5 2 2\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03438", "source_text": "Score : 300 points\n\nProblem Statement\n\nYou are given two integer sequences of length N: a_1,a_2,..,a_N and b_1,b_2,..,b_N.\nDetermine if we can repeat the following operation zero or more times so that the sequences a and b become equal.\n\nOperation: Choose two integers i and j (possibly the same) between 1 and N (inclusive), then perform the following two actions simultaneously:\n\nAdd 2 to a_i.\n\nAdd 1 to b_j.\n\nConstraints\n\n1 ≤ N ≤ 10 000\n\n0 ≤ a_i,b_i ≤ 10^9 (1 ≤ i ≤ N)\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 .. a_N\nb_1 b_2 .. b_N\n\nOutput\n\nIf we can repeat the operation zero or more times so that the sequences a and b become equal, print Yes; otherwise, print No.\n\nSample Input 1\n\n3\n1 2 3\n5 2 2\n\nSample Output 1\n\nYes\n\nFor example, we can perform three operations as follows to do our job:\n\nFirst operation: i=1 and j=2. Now we have a = \\{3,2,3\\}, b = \\{5,3,2\\}.\n\nSecond operation: i=1 and j=2. Now we have a = \\{5,2,3\\}, b = \\{5,4,2\\}.\n\nThird operation: i=2 and j=3. Now we have a = \\{5,4,3\\}, b = \\{5,4,3\\}.\n\nSample Input 2\n\n5\n3 1 4 1 5\n2 7 1 8 2\n\nSample Output 2\n\nNo\n\nSample Input 3\n\n5\n2 7 1 8 2\n3 1 4 1 5\n\nSample Output 3\n\nNo", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 449, "cpu_time_ms": 14, "memory_kb": 1144}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s683614317", "group_id": "codeNet:p03441", "input_text": "local n = io.read(\"*n\")\nlocal edge = {}\nfor i = 1, n do\n edge[i] = {}\nend\nfor i = 1, n - 1 do\n local a, b = io.read(\"*n\", \"*n\")\n a = a + 1\n b = b + 1\n table.insert(edge[a], b)\n table.insert(edge[b], a)\nend\nlocal parent = {}\nlocal asked = {}\nlocal asked_child_cnt = {}\nlocal root = nil\nlocal tasks = {}\nlocal required = {}\nfor i = 1, n do\n required[i] = false\n parent[i] = 0\n asked[i] = false\n asked_child_cnt[i] = 0\n if #edge[i] == 1 then\n if root then\n table.insert(tasks, i)\n else\n root = i\n end\n end\nend\nlocal done = 0\nwhile done < #tasks do\n done = done + 1\n local child = tasks[done]\n asked[child] = true\n if child == root then break end\n if 3 <= #edge[child] then\n required[child] = true\n end\n for i = 1, #edge[child] do\n local pcand = edge[child][i]\n if not asked[pcand] then\n parent[child] = pcand\n asked_child_cnt[pcand] = asked_child_cnt[pcand] + 1\n if asked_child_cnt[pcand] == #edge[pcand] - 1 then\n table.insert(tasks, pcand)\n end\n end\n end\nend\n-- for i = 1, n do\n-- asked[i] = false\n-- end\n-- asked[root] = true\ntasks[1] = edge[root][1]\ntasknum = 1\ndone = 0\nlocal ret = 1\nwhile done < tasknum do\n done = done + 1\n local p = tasks[done]\n local required_cnt = #edge[p] - 2\n if 0 < required_cnt then\n for i = 1, #edge[p] do\n local c = edge[p][i]\n if c ~= parent[p] then\n if required[c] then\n tasknum = tasknum + 1\n tasks[tasknum] = c\n required_cnt = required_cnt - 1\n end\n end\n end\n if 0 < required_cnt then\n ret = ret + required_cnt\n end\n end\nend\nprint(ret)\n", "language": "Lua", "metadata": {"date": 1595691447, "filename_ext": "lua", "original_language": "Lua (LuaJIT 2.1.0)", "problem_description_relpath": "problem_descriptions/p03441.html", "problem_id": "p03441", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03441/input.txt", "sample_output_relpath": "derived/input_output/data/p03441/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03441/Lua/s683614317.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s683614317", "user_id": "u120582723"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "local n = io.read(\"*n\")\nlocal edge = {}\nfor i = 1, n do\n edge[i] = {}\nend\nfor i = 1, n - 1 do\n local a, b = io.read(\"*n\", \"*n\")\n a = a + 1\n b = b + 1\n table.insert(edge[a], b)\n table.insert(edge[b], a)\nend\nlocal parent = {}\nlocal asked = {}\nlocal asked_child_cnt = {}\nlocal root = nil\nlocal tasks = {}\nlocal required = {}\nfor i = 1, n do\n required[i] = false\n parent[i] = 0\n asked[i] = false\n asked_child_cnt[i] = 0\n if #edge[i] == 1 then\n if root then\n table.insert(tasks, i)\n else\n root = i\n end\n end\nend\nlocal done = 0\nwhile done < #tasks do\n done = done + 1\n local child = tasks[done]\n asked[child] = true\n if child == root then break end\n if 3 <= #edge[child] then\n required[child] = true\n end\n for i = 1, #edge[child] do\n local pcand = edge[child][i]\n if not asked[pcand] then\n parent[child] = pcand\n asked_child_cnt[pcand] = asked_child_cnt[pcand] + 1\n if asked_child_cnt[pcand] == #edge[pcand] - 1 then\n table.insert(tasks, pcand)\n end\n end\n end\nend\n-- for i = 1, n do\n-- asked[i] = false\n-- end\n-- asked[root] = true\ntasks[1] = edge[root][1]\ntasknum = 1\ndone = 0\nlocal ret = 1\nwhile done < tasknum do\n done = done + 1\n local p = tasks[done]\n local required_cnt = #edge[p] - 2\n if 0 < required_cnt then\n for i = 1, #edge[p] do\n local c = edge[p][i]\n if c ~= parent[p] then\n if required[c] then\n tasknum = tasknum + 1\n tasks[tasknum] = c\n required_cnt = required_cnt - 1\n end\n end\n end\n if 0 < required_cnt then\n ret = ret + required_cnt\n end\n end\nend\nprint(ret)\n", "problem_context": "Score : 900 points\n\nProblem Statement\n\nWe have a tree with N vertices.\nThe vertices are numbered 0 through N - 1, and the i-th edge (0 ≤ i < N - 1) comnnects Vertex a_i and b_i.\nFor each pair of vertices u and v (0 ≤ u, v < N), we define the distance d(u, v) as the number of edges in the path u-v.\n\nIt is expected that one of the vertices will be invaded by aliens from outer space.\nSnuke wants to immediately identify that vertex when the invasion happens.\nTo do so, he has decided to install an antenna on some vertices.\n\nFirst, he decides the number of antennas, K (1 ≤ K ≤ N).\nThen, he chooses K different vertices, x_0, x_1, ..., x_{K - 1}, on which he installs Antenna 0, 1, ..., K - 1, respectively.\nIf Vertex v is invaded by aliens, Antenna k (0 ≤ k < K) will output the distance d(x_k, v).\nBased on these K outputs, Snuke will identify the vertex that is invaded.\nThus, in order to identify the invaded vertex no matter which one is invaded, the following condition must hold:\n\nFor each vertex u (0 ≤ u < N), consider the vector (d(x_0, u), ..., d(x_{K - 1}, u)). These N vectors are distinct.\n\nFind the minumum value of K, the number of antennas, when the condition is satisfied.\n\nConstraints\n\n2 ≤ N ≤ 10^5\n\n0 ≤ a_i, b_i < N\n\nThe given graph is a tree.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_0 b_0\na_1 b_1\n:\na_{N - 2} b_{N - 2}\n\nOutput\n\nPrint the minumum value of K, the number of antennas, when the condition is satisfied.\n\nSample Input 1\n\n5\n0 1\n0 2\n0 3\n3 4\n\nSample Output 1\n\n2\n\nFor example, install an antenna on Vertex 1 and 3.\nThen, the following five vectors are distinct:\n\n(d(1, 0), d(3, 0)) = (1, 1)\n\n(d(1, 1), d(3, 1)) = (0, 2)\n\n(d(1, 2), d(3, 2)) = (2, 2)\n\n(d(1, 3), d(3, 3)) = (2, 0)\n\n(d(1, 4), d(3, 4)) = (3, 1)\n\nSample Input 2\n\n2\n0 1\n\nSample Output 2\n\n1\n\nFor example, install an antenna on Vertex 0.\n\nSample Input 3\n\n10\n2 8\n6 0\n4 1\n7 6\n2 3\n8 6\n6 9\n2 4\n5 8\n\nSample Output 3\n\n3\n\nFor example, install an antenna on Vertex 0, 4, 9.", "sample_input": "5\n0 1\n0 2\n0 3\n3 4\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03441", "source_text": "Score : 900 points\n\nProblem Statement\n\nWe have a tree with N vertices.\nThe vertices are numbered 0 through N - 1, and the i-th edge (0 ≤ i < N - 1) comnnects Vertex a_i and b_i.\nFor each pair of vertices u and v (0 ≤ u, v < N), we define the distance d(u, v) as the number of edges in the path u-v.\n\nIt is expected that one of the vertices will be invaded by aliens from outer space.\nSnuke wants to immediately identify that vertex when the invasion happens.\nTo do so, he has decided to install an antenna on some vertices.\n\nFirst, he decides the number of antennas, K (1 ≤ K ≤ N).\nThen, he chooses K different vertices, x_0, x_1, ..., x_{K - 1}, on which he installs Antenna 0, 1, ..., K - 1, respectively.\nIf Vertex v is invaded by aliens, Antenna k (0 ≤ k < K) will output the distance d(x_k, v).\nBased on these K outputs, Snuke will identify the vertex that is invaded.\nThus, in order to identify the invaded vertex no matter which one is invaded, the following condition must hold:\n\nFor each vertex u (0 ≤ u < N), consider the vector (d(x_0, u), ..., d(x_{K - 1}, u)). These N vectors are distinct.\n\nFind the minumum value of K, the number of antennas, when the condition is satisfied.\n\nConstraints\n\n2 ≤ N ≤ 10^5\n\n0 ≤ a_i, b_i < N\n\nThe given graph is a tree.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_0 b_0\na_1 b_1\n:\na_{N - 2} b_{N - 2}\n\nOutput\n\nPrint the minumum value of K, the number of antennas, when the condition is satisfied.\n\nSample Input 1\n\n5\n0 1\n0 2\n0 3\n3 4\n\nSample Output 1\n\n2\n\nFor example, install an antenna on Vertex 1 and 3.\nThen, the following five vectors are distinct:\n\n(d(1, 0), d(3, 0)) = (1, 1)\n\n(d(1, 1), d(3, 1)) = (0, 2)\n\n(d(1, 2), d(3, 2)) = (2, 2)\n\n(d(1, 3), d(3, 3)) = (2, 0)\n\n(d(1, 4), d(3, 4)) = (3, 1)\n\nSample Input 2\n\n2\n0 1\n\nSample Output 2\n\n1\n\nFor example, install an antenna on Vertex 0.\n\nSample Input 3\n\n10\n2 8\n6 0\n4 1\n7 6\n2 3\n8 6\n6 9\n2 4\n5 8\n\nSample Output 3\n\n3\n\nFor example, install an antenna on Vertex 0, 4, 9.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1628, "cpu_time_ms": 119, "memory_kb": 17444}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s392831996", "group_id": "codeNet:p03447", "input_text": "m = io.read(\"*number\")-io.read(\"*number\")\ny = io.read(\"*number\")\nprint(m-math.floor(m/y)*y)", "language": "Lua", "metadata": {"date": 1517985102, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03447.html", "problem_id": "p03447", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03447/input.txt", "sample_output_relpath": "derived/input_output/data/p03447/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03447/Lua/s392831996.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s392831996", "user_id": "u079330987"}, "prompt_components": {"gold_output": "84\n", "input_to_evaluate": "m = io.read(\"*number\")-io.read(\"*number\")\ny = io.read(\"*number\")\nprint(m-math.floor(m/y)*y)", "problem_context": "Score : 100 points\n\nProblem Statement\n\nYou went shopping to buy cakes and donuts with X yen (the currency of Japan).\n\nFirst, you bought one cake for A yen at a cake shop.\nThen, you bought as many donuts as possible for B yen each, at a donut shop.\n\nHow much do you have left after shopping?\n\nConstraints\n\n1 \\leq A, B \\leq 1 000\n\nA + B \\leq X \\leq 10 000\n\nX, A and B are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX\nA\nB\n\nOutput\n\nPrint the amount you have left after shopping.\n\nSample Input 1\n\n1234\n150\n100\n\nSample Output 1\n\n84\n\nYou have 1234 - 150 = 1084 yen left after buying a cake.\nWith this amount, you can buy 10 donuts, after which you have 84 yen left.\n\nSample Input 2\n\n1000\n108\n108\n\nSample Output 2\n\n28\n\nSample Input 3\n\n579\n123\n456\n\nSample Output 3\n\n0\n\nSample Input 4\n\n7477\n549\n593\n\nSample Output 4\n\n405", "sample_input": "1234\n150\n100\n"}, "reference_outputs": ["84\n"], "source_document_id": "p03447", "source_text": "Score : 100 points\n\nProblem Statement\n\nYou went shopping to buy cakes and donuts with X yen (the currency of Japan).\n\nFirst, you bought one cake for A yen at a cake shop.\nThen, you bought as many donuts as possible for B yen each, at a donut shop.\n\nHow much do you have left after shopping?\n\nConstraints\n\n1 \\leq A, B \\leq 1 000\n\nA + B \\leq X \\leq 10 000\n\nX, A and B are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX\nA\nB\n\nOutput\n\nPrint the amount you have left after shopping.\n\nSample Input 1\n\n1234\n150\n100\n\nSample Output 1\n\n84\n\nYou have 1234 - 150 = 1084 yen left after buying a cake.\nWith this amount, you can buy 10 donuts, after which you have 84 yen left.\n\nSample Input 2\n\n1000\n108\n108\n\nSample Output 2\n\n28\n\nSample Input 3\n\n579\n123\n456\n\nSample Output 3\n\n0\n\nSample Input 4\n\n7477\n549\n593\n\nSample Output 4\n\n405", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 91, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s261932000", "group_id": "codeNet:p03449", "input_text": "n=io.read(\"*n\",\"*l\")\na={}\nfor i=1,2 do\n for j=1,n do\n a[i][j]=io.read(\"*n\")\n end\nend\n\ntotal=0\nfor i=1,n do\n count=0\n for j=1,i do\n count=count+a[1][j]\n end\n for k=i,n do\n count=count+a[2][k]\n end\n total=math.max(count,total)\nend\nprint(total)", "language": "Lua", "metadata": {"date": 1588198487, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03449.html", "problem_id": "p03449", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03449/input.txt", "sample_output_relpath": "derived/input_output/data/p03449/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03449/Lua/s261932000.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s261932000", "user_id": "u045238009"}, "prompt_components": {"gold_output": "14\n", "input_to_evaluate": "n=io.read(\"*n\",\"*l\")\na={}\nfor i=1,2 do\n for j=1,n do\n a[i][j]=io.read(\"*n\")\n end\nend\n\ntotal=0\nfor i=1,n do\n count=0\n for j=1,i do\n count=count+a[1][j]\n end\n for k=i,n do\n count=count+a[2][k]\n end\n total=math.max(count,total)\nend\nprint(total)", "problem_context": "Score : 300 points\n\nProblem Statement\n\nWe have a 2 \\times N grid. We will denote the square at the i-th row and j-th column (1 \\leq i \\leq 2, 1 \\leq j \\leq N) as (i, j).\n\nYou are initially in the top-left square, (1, 1).\nYou will travel to the bottom-right square, (2, N), by repeatedly moving right or down.\n\nThe square (i, j) contains A_{i, j} candies.\nYou will collect all the candies you visit during the travel.\nThe top-left and bottom-right squares also contain candies, and you will also collect them.\n\nAt most how many candies can you collect when you choose the best way to travel?\n\nConstraints\n\n1 \\leq N \\leq 100\n\n1 \\leq A_{i, j} \\leq 100 (1 \\leq i \\leq 2, 1 \\leq j \\leq N)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_{1, 1} A_{1, 2} ... A_{1, N}\nA_{2, 1} A_{2, 2} ... A_{2, N}\n\nOutput\n\nPrint the maximum number of candies that can be collected.\n\nSample Input 1\n\n5\n3 2 2 4 1\n1 2 2 2 1\n\nSample Output 1\n\n14\n\nThe number of collected candies will be maximized when you:\n\nmove right three times, then move down once, then move right once.\n\nSample Input 2\n\n4\n1 1 1 1\n1 1 1 1\n\nSample Output 2\n\n5\n\nYou will always collect the same number of candies, regardless of how you travel.\n\nSample Input 3\n\n7\n3 3 4 5 4 5 3\n5 3 4 4 2 3 2\n\nSample Output 3\n\n29\n\nSample Input 4\n\n1\n2\n3\n\nSample Output 4\n\n5", "sample_input": "5\n3 2 2 4 1\n1 2 2 2 1\n"}, "reference_outputs": ["14\n"], "source_document_id": "p03449", "source_text": "Score : 300 points\n\nProblem Statement\n\nWe have a 2 \\times N grid. We will denote the square at the i-th row and j-th column (1 \\leq i \\leq 2, 1 \\leq j \\leq N) as (i, j).\n\nYou are initially in the top-left square, (1, 1).\nYou will travel to the bottom-right square, (2, N), by repeatedly moving right or down.\n\nThe square (i, j) contains A_{i, j} candies.\nYou will collect all the candies you visit during the travel.\nThe top-left and bottom-right squares also contain candies, and you will also collect them.\n\nAt most how many candies can you collect when you choose the best way to travel?\n\nConstraints\n\n1 \\leq N \\leq 100\n\n1 \\leq A_{i, j} \\leq 100 (1 \\leq i \\leq 2, 1 \\leq j \\leq N)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_{1, 1} A_{1, 2} ... A_{1, N}\nA_{2, 1} A_{2, 2} ... A_{2, N}\n\nOutput\n\nPrint the maximum number of candies that can be collected.\n\nSample Input 1\n\n5\n3 2 2 4 1\n1 2 2 2 1\n\nSample Output 1\n\n14\n\nThe number of collected candies will be maximized when you:\n\nmove right three times, then move down once, then move right once.\n\nSample Input 2\n\n4\n1 1 1 1\n1 1 1 1\n\nSample Output 2\n\n5\n\nYou will always collect the same number of candies, regardless of how you travel.\n\nSample Input 3\n\n7\n3 3 4 5 4 5 3\n5 3 4 4 2 3 2\n\nSample Output 3\n\n29\n\nSample Input 4\n\n1\n2\n3\n\nSample Output 4\n\n5", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 286, "cpu_time_ms": 8, "memory_kb": 760}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s279677978", "group_id": "codeNet:p03449", "input_text": "local N = io.read(\"n\")\nlocal A1, A2 = {}, {}\nfor i=1,N do A1[i]=io.read(\"n\") end\nfor i=1,N do A2[i]=io.read(\"n\") end\nlocal ans = 0\nfor sw=1,N do\n local c=0\n for i=1,sw do\n c=c+A1[i]\n end\n for i=sw,N do\n c=c+A2[i]\n end\n ans=math.max(ans,c)\nend\nprint(ans)\n", "language": "Lua", "metadata": {"date": 1570248953, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03449.html", "problem_id": "p03449", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03449/input.txt", "sample_output_relpath": "derived/input_output/data/p03449/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03449/Lua/s279677978.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s279677978", "user_id": "u162773977"}, "prompt_components": {"gold_output": "14\n", "input_to_evaluate": "local N = io.read(\"n\")\nlocal A1, A2 = {}, {}\nfor i=1,N do A1[i]=io.read(\"n\") end\nfor i=1,N do A2[i]=io.read(\"n\") end\nlocal ans = 0\nfor sw=1,N do\n local c=0\n for i=1,sw do\n c=c+A1[i]\n end\n for i=sw,N do\n c=c+A2[i]\n end\n ans=math.max(ans,c)\nend\nprint(ans)\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nWe have a 2 \\times N grid. We will denote the square at the i-th row and j-th column (1 \\leq i \\leq 2, 1 \\leq j \\leq N) as (i, j).\n\nYou are initially in the top-left square, (1, 1).\nYou will travel to the bottom-right square, (2, N), by repeatedly moving right or down.\n\nThe square (i, j) contains A_{i, j} candies.\nYou will collect all the candies you visit during the travel.\nThe top-left and bottom-right squares also contain candies, and you will also collect them.\n\nAt most how many candies can you collect when you choose the best way to travel?\n\nConstraints\n\n1 \\leq N \\leq 100\n\n1 \\leq A_{i, j} \\leq 100 (1 \\leq i \\leq 2, 1 \\leq j \\leq N)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_{1, 1} A_{1, 2} ... A_{1, N}\nA_{2, 1} A_{2, 2} ... A_{2, N}\n\nOutput\n\nPrint the maximum number of candies that can be collected.\n\nSample Input 1\n\n5\n3 2 2 4 1\n1 2 2 2 1\n\nSample Output 1\n\n14\n\nThe number of collected candies will be maximized when you:\n\nmove right three times, then move down once, then move right once.\n\nSample Input 2\n\n4\n1 1 1 1\n1 1 1 1\n\nSample Output 2\n\n5\n\nYou will always collect the same number of candies, regardless of how you travel.\n\nSample Input 3\n\n7\n3 3 4 5 4 5 3\n5 3 4 4 2 3 2\n\nSample Output 3\n\n29\n\nSample Input 4\n\n1\n2\n3\n\nSample Output 4\n\n5", "sample_input": "5\n3 2 2 4 1\n1 2 2 2 1\n"}, "reference_outputs": ["14\n"], "source_document_id": "p03449", "source_text": "Score : 300 points\n\nProblem Statement\n\nWe have a 2 \\times N grid. We will denote the square at the i-th row and j-th column (1 \\leq i \\leq 2, 1 \\leq j \\leq N) as (i, j).\n\nYou are initially in the top-left square, (1, 1).\nYou will travel to the bottom-right square, (2, N), by repeatedly moving right or down.\n\nThe square (i, j) contains A_{i, j} candies.\nYou will collect all the candies you visit during the travel.\nThe top-left and bottom-right squares also contain candies, and you will also collect them.\n\nAt most how many candies can you collect when you choose the best way to travel?\n\nConstraints\n\n1 \\leq N \\leq 100\n\n1 \\leq A_{i, j} \\leq 100 (1 \\leq i \\leq 2, 1 \\leq j \\leq N)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_{1, 1} A_{1, 2} ... A_{1, N}\nA_{2, 1} A_{2, 2} ... A_{2, N}\n\nOutput\n\nPrint the maximum number of candies that can be collected.\n\nSample Input 1\n\n5\n3 2 2 4 1\n1 2 2 2 1\n\nSample Output 1\n\n14\n\nThe number of collected candies will be maximized when you:\n\nmove right three times, then move down once, then move right once.\n\nSample Input 2\n\n4\n1 1 1 1\n1 1 1 1\n\nSample Output 2\n\n5\n\nYou will always collect the same number of candies, regardless of how you travel.\n\nSample Input 3\n\n7\n3 3 4 5 4 5 3\n5 3 4 4 2 3 2\n\nSample Output 3\n\n29\n\nSample Input 4\n\n1\n2\n3\n\nSample Output 4\n\n5", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 266, "cpu_time_ms": 7, "memory_kb": 760}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s668004573", "group_id": "codeNet:p03449", "input_text": "local n = io.read(\"*n\")\nlocal a, b = {}, {}\na[1], b[1] = 0, 0\nfor i = 2, n+1 do a[i] = a[i-1] + io.read(\"*n\") end\nfor i = 2, n+1 do b[i] = b[i-1] + io.read(\"*n\") end\nlocal max = 0\nlocal bm = b[n+1]\nfor i = 2, n+1 do\n max = math.max(max, a[i]+bm-b[i-1])\nend\nprint(max)\n", "language": "Lua", "metadata": {"date": 1555617279, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p03449.html", "problem_id": "p03449", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03449/input.txt", "sample_output_relpath": "derived/input_output/data/p03449/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03449/Lua/s668004573.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s668004573", "user_id": "u120582723"}, "prompt_components": {"gold_output": "14\n", "input_to_evaluate": "local n = io.read(\"*n\")\nlocal a, b = {}, {}\na[1], b[1] = 0, 0\nfor i = 2, n+1 do a[i] = a[i-1] + io.read(\"*n\") end\nfor i = 2, n+1 do b[i] = b[i-1] + io.read(\"*n\") end\nlocal max = 0\nlocal bm = b[n+1]\nfor i = 2, n+1 do\n max = math.max(max, a[i]+bm-b[i-1])\nend\nprint(max)\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nWe have a 2 \\times N grid. We will denote the square at the i-th row and j-th column (1 \\leq i \\leq 2, 1 \\leq j \\leq N) as (i, j).\n\nYou are initially in the top-left square, (1, 1).\nYou will travel to the bottom-right square, (2, N), by repeatedly moving right or down.\n\nThe square (i, j) contains A_{i, j} candies.\nYou will collect all the candies you visit during the travel.\nThe top-left and bottom-right squares also contain candies, and you will also collect them.\n\nAt most how many candies can you collect when you choose the best way to travel?\n\nConstraints\n\n1 \\leq N \\leq 100\n\n1 \\leq A_{i, j} \\leq 100 (1 \\leq i \\leq 2, 1 \\leq j \\leq N)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_{1, 1} A_{1, 2} ... A_{1, N}\nA_{2, 1} A_{2, 2} ... A_{2, N}\n\nOutput\n\nPrint the maximum number of candies that can be collected.\n\nSample Input 1\n\n5\n3 2 2 4 1\n1 2 2 2 1\n\nSample Output 1\n\n14\n\nThe number of collected candies will be maximized when you:\n\nmove right three times, then move down once, then move right once.\n\nSample Input 2\n\n4\n1 1 1 1\n1 1 1 1\n\nSample Output 2\n\n5\n\nYou will always collect the same number of candies, regardless of how you travel.\n\nSample Input 3\n\n7\n3 3 4 5 4 5 3\n5 3 4 4 2 3 2\n\nSample Output 3\n\n29\n\nSample Input 4\n\n1\n2\n3\n\nSample Output 4\n\n5", "sample_input": "5\n3 2 2 4 1\n1 2 2 2 1\n"}, "reference_outputs": ["14\n"], "source_document_id": "p03449", "source_text": "Score : 300 points\n\nProblem Statement\n\nWe have a 2 \\times N grid. We will denote the square at the i-th row and j-th column (1 \\leq i \\leq 2, 1 \\leq j \\leq N) as (i, j).\n\nYou are initially in the top-left square, (1, 1).\nYou will travel to the bottom-right square, (2, N), by repeatedly moving right or down.\n\nThe square (i, j) contains A_{i, j} candies.\nYou will collect all the candies you visit during the travel.\nThe top-left and bottom-right squares also contain candies, and you will also collect them.\n\nAt most how many candies can you collect when you choose the best way to travel?\n\nConstraints\n\n1 \\leq N \\leq 100\n\n1 \\leq A_{i, j} \\leq 100 (1 \\leq i \\leq 2, 1 \\leq j \\leq N)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_{1, 1} A_{1, 2} ... A_{1, N}\nA_{2, 1} A_{2, 2} ... A_{2, N}\n\nOutput\n\nPrint the maximum number of candies that can be collected.\n\nSample Input 1\n\n5\n3 2 2 4 1\n1 2 2 2 1\n\nSample Output 1\n\n14\n\nThe number of collected candies will be maximized when you:\n\nmove right three times, then move down once, then move right once.\n\nSample Input 2\n\n4\n1 1 1 1\n1 1 1 1\n\nSample Output 2\n\n5\n\nYou will always collect the same number of candies, regardless of how you travel.\n\nSample Input 3\n\n7\n3 3 4 5 4 5 3\n5 3 4 4 2 3 2\n\nSample Output 3\n\n29\n\nSample Input 4\n\n1\n2\n3\n\nSample Output 4\n\n5", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 269, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s977449038", "group_id": "codeNet:p03450", "input_text": "local ior = io.input()\nlocal n, m = ior:read(\"*n\", \"*n\")\nlocal hasinfo = {}\nlocal pos = {}\nlocal parent = {}\nlocal grouplen = {}\nlocal groupidxes = {}\nfor i = 1, n do parent[i], grouplen[i], groupidxes[i] = i, 1, {i} end\nfor i = 1, n do hasinfo[i], pos[i] = false, 0 end\nlocal isok = true\n\nfunction getroot(idx)\n while(parent[idx] ~= idx) do\n idx = parent[idx]\n end\n return idx\nend\n\nfor i = 1, m do\n local l, r, d = ior:read(\"*n\", \"*n\", \"*n\")\n if(isok) then\n local lr, rr = getroot(l), getroot(r)\n if(hasinfo[l] and hasinfo[r]) then\n if(lr ~= rr) then\n local diff = pos[r] - (pos[l] + d)\n if(grouplen[lr] < grouplen[rr]) then\n for j = 1, #groupidxes[lr] do\n local tmpidx = groupidxes[lr][j]\n table.insert(groupidxes[rr], tmpidx)\n pos[tmpidx] = pos[tmpidx] + diff\n end\n grouplen[rr] = grouplen[rr] + grouplen[lr]\n grouplen[lr] = 0\n parent[l], parent[r], parent[lr] = rr, rr, rr\n else\n for j = 1, #groupidxes[rr] do\n local tmpidx = groupidxes[rr][j]\n table.insert(groupidxes[lr], tmpidx)\n pos[tmpidx] = pos[tmpidx] - diff\n end\n grouplen[lr] = grouplen[rr] + grouplen[lr]\n grouplen[rr] = 0\n parent[l], parent[r], parent[rr] = lr, lr, lr\n end\n else\n parent[l], parent[r], parent[lr] = rr, rr, rr\n isok = (d == pos[r] - pos[l])\n end\n elseif(hasinfo[r]) then\n parent[l], parent[r], parent[lr] = rr, rr, rr\n grouplen[l] = 0\n grouplen[rr] = grouplen[rr] + 1\n table.insert(groupidxes[rr], l)\n hasinfo[l] = true\n pos[l] = pos[r] - d\n elseif(hasinfo[l]) then\n parent[l], parent[r], parent[rr] = lr, lr, lr\n grouplen[lr] = grouplen[lr] + 1\n grouplen[r] = 0\n table.insert(groupidxes[lr], r)\n hasinfo[r] = true\n pos[r] = pos[l] + d\n else\n parent[l], parent[r], parent[rr] = lr, lr, lr\n grouplen[l] = 2\n grouplen[r] = 0\n table.insert(groupidxes[l], r)\n hasinfo[l], hasinfo[r] = true, true\n pos[l] = 0\n pos[r] = d\n end\n end\nend\nprint(isok and \"Yes\" or \"No\")\n", "language": "Lua", "metadata": {"date": 1557194099, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p03450.html", "problem_id": "p03450", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03450/input.txt", "sample_output_relpath": "derived/input_output/data/p03450/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03450/Lua/s977449038.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s977449038", "user_id": "u120582723"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "local ior = io.input()\nlocal n, m = ior:read(\"*n\", \"*n\")\nlocal hasinfo = {}\nlocal pos = {}\nlocal parent = {}\nlocal grouplen = {}\nlocal groupidxes = {}\nfor i = 1, n do parent[i], grouplen[i], groupidxes[i] = i, 1, {i} end\nfor i = 1, n do hasinfo[i], pos[i] = false, 0 end\nlocal isok = true\n\nfunction getroot(idx)\n while(parent[idx] ~= idx) do\n idx = parent[idx]\n end\n return idx\nend\n\nfor i = 1, m do\n local l, r, d = ior:read(\"*n\", \"*n\", \"*n\")\n if(isok) then\n local lr, rr = getroot(l), getroot(r)\n if(hasinfo[l] and hasinfo[r]) then\n if(lr ~= rr) then\n local diff = pos[r] - (pos[l] + d)\n if(grouplen[lr] < grouplen[rr]) then\n for j = 1, #groupidxes[lr] do\n local tmpidx = groupidxes[lr][j]\n table.insert(groupidxes[rr], tmpidx)\n pos[tmpidx] = pos[tmpidx] + diff\n end\n grouplen[rr] = grouplen[rr] + grouplen[lr]\n grouplen[lr] = 0\n parent[l], parent[r], parent[lr] = rr, rr, rr\n else\n for j = 1, #groupidxes[rr] do\n local tmpidx = groupidxes[rr][j]\n table.insert(groupidxes[lr], tmpidx)\n pos[tmpidx] = pos[tmpidx] - diff\n end\n grouplen[lr] = grouplen[rr] + grouplen[lr]\n grouplen[rr] = 0\n parent[l], parent[r], parent[rr] = lr, lr, lr\n end\n else\n parent[l], parent[r], parent[lr] = rr, rr, rr\n isok = (d == pos[r] - pos[l])\n end\n elseif(hasinfo[r]) then\n parent[l], parent[r], parent[lr] = rr, rr, rr\n grouplen[l] = 0\n grouplen[rr] = grouplen[rr] + 1\n table.insert(groupidxes[rr], l)\n hasinfo[l] = true\n pos[l] = pos[r] - d\n elseif(hasinfo[l]) then\n parent[l], parent[r], parent[rr] = lr, lr, lr\n grouplen[lr] = grouplen[lr] + 1\n grouplen[r] = 0\n table.insert(groupidxes[lr], r)\n hasinfo[r] = true\n pos[r] = pos[l] + d\n else\n parent[l], parent[r], parent[rr] = lr, lr, lr\n grouplen[l] = 2\n grouplen[r] = 0\n table.insert(groupidxes[l], r)\n hasinfo[l], hasinfo[r] = true, true\n pos[l] = 0\n pos[r] = d\n end\n end\nend\nprint(isok and \"Yes\" or \"No\")\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nThere are N people standing on the x-axis.\nLet the coordinate of Person i be x_i.\nFor every i, x_i is an integer between 0 and 10^9 (inclusive).\nIt is possible that more than one person is standing at the same coordinate.\n\nYou will given M pieces of information regarding the positions of these people.\nThe i-th piece of information has the form (L_i, R_i, D_i).\nThis means that Person R_i is to the right of Person L_i by D_i units of distance, that is, x_{R_i} - x_{L_i} = D_i holds.\n\nIt turns out that some of these M pieces of information may be incorrect.\nDetermine if there exists a set of values (x_1, x_2, ..., x_N) that is consistent with the given pieces of information.\n\nConstraints\n\n1 \\leq N \\leq 100 000\n\n0 \\leq M \\leq 200 000\n\n1 \\leq L_i, R_i \\leq N (1 \\leq i \\leq M)\n\n0 \\leq D_i \\leq 10 000 (1 \\leq i \\leq M)\n\nL_i \\neq R_i (1 \\leq i \\leq M)\n\nIf i \\neq j, then (L_i, R_i) \\neq (L_j, R_j) and (L_i, R_i) \\neq (R_j, L_j).\n\nD_i are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nL_1 R_1 D_1\nL_2 R_2 D_2\n:\nL_M R_M D_M\n\nOutput\n\nIf there exists a set of values (x_1, x_2, ..., x_N) that is consistent with all given pieces of information, print Yes; if it does not exist, print No.\n\nSample Input 1\n\n3 3\n1 2 1\n2 3 1\n1 3 2\n\nSample Output 1\n\nYes\n\nSome possible sets of values (x_1, x_2, x_3) are (0, 1, 2) and (101, 102, 103).\n\nSample Input 2\n\n3 3\n1 2 1\n2 3 1\n1 3 5\n\nSample Output 2\n\nNo\n\nIf the first two pieces of information are correct, x_3 - x_1 = 2 holds, which is contradictory to the last piece of information.\n\nSample Input 3\n\n4 3\n2 1 1\n2 3 5\n3 4 2\n\nSample Output 3\n\nYes\n\nSample Input 4\n\n10 3\n8 7 100\n7 9 100\n9 8 100\n\nSample Output 4\n\nNo\n\nSample Input 5\n\n100 0\n\nSample Output 5\n\nYes", "sample_input": "3 3\n1 2 1\n2 3 1\n1 3 2\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03450", "source_text": "Score : 400 points\n\nProblem Statement\n\nThere are N people standing on the x-axis.\nLet the coordinate of Person i be x_i.\nFor every i, x_i is an integer between 0 and 10^9 (inclusive).\nIt is possible that more than one person is standing at the same coordinate.\n\nYou will given M pieces of information regarding the positions of these people.\nThe i-th piece of information has the form (L_i, R_i, D_i).\nThis means that Person R_i is to the right of Person L_i by D_i units of distance, that is, x_{R_i} - x_{L_i} = D_i holds.\n\nIt turns out that some of these M pieces of information may be incorrect.\nDetermine if there exists a set of values (x_1, x_2, ..., x_N) that is consistent with the given pieces of information.\n\nConstraints\n\n1 \\leq N \\leq 100 000\n\n0 \\leq M \\leq 200 000\n\n1 \\leq L_i, R_i \\leq N (1 \\leq i \\leq M)\n\n0 \\leq D_i \\leq 10 000 (1 \\leq i \\leq M)\n\nL_i \\neq R_i (1 \\leq i \\leq M)\n\nIf i \\neq j, then (L_i, R_i) \\neq (L_j, R_j) and (L_i, R_i) \\neq (R_j, L_j).\n\nD_i are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nL_1 R_1 D_1\nL_2 R_2 D_2\n:\nL_M R_M D_M\n\nOutput\n\nIf there exists a set of values (x_1, x_2, ..., x_N) that is consistent with all given pieces of information, print Yes; if it does not exist, print No.\n\nSample Input 1\n\n3 3\n1 2 1\n2 3 1\n1 3 2\n\nSample Output 1\n\nYes\n\nSome possible sets of values (x_1, x_2, x_3) are (0, 1, 2) and (101, 102, 103).\n\nSample Input 2\n\n3 3\n1 2 1\n2 3 1\n1 3 5\n\nSample Output 2\n\nNo\n\nIf the first two pieces of information are correct, x_3 - x_1 = 2 holds, which is contradictory to the last piece of information.\n\nSample Input 3\n\n4 3\n2 1 1\n2 3 5\n3 4 2\n\nSample Output 3\n\nYes\n\nSample Input 4\n\n10 3\n8 7 100\n7 9 100\n9 8 100\n\nSample Output 4\n\nNo\n\nSample Input 5\n\n100 0\n\nSample Output 5\n\nYes", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2177, "cpu_time_ms": 188, "memory_kb": 19812}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s314478195", "group_id": "codeNet:p03453", "input_text": "local mfl, mce = math.floor, math.ceil\nlocal mmi, mma = math.min, math.max\nlocal mod = 1000000007\nlocal function bmul(x, y)\n local x1, y1 = mfl(x / 31623), mfl(y / 31623)\n local x0, y0 = x - x1 * 31623, y - y1 * 31623\n return (x1 * y1 * 14122 + (x1 * y0 + x0 * y1) * 31623 + x0 * y0) % mod\nend\n\nlocal function badd(x, y)\n return (x + y) % mod\nend\n\nlocal function bsub(x, y)\n return x < y and x - y + mod or x - y\nend\n\nlocal pow2 = {1}\nfor i = 2, 28 do pow2[i] = pow2[i - 1] * 2 end\nlocal SegTree = {}\nSegTree.updateAll = function(self)\n for i = self.stagenum - 1, 1, -1 do\n local cnt = pow2[i]\n for j = 0, cnt - 1 do\n self.stage[cnt + j] = self.func(self.stage[(cnt + j) * 2], self.stage[(cnt + j) * 2 + 1])\n end\n end\nend\nSegTree.create = function(self, n, func, emptyvalue)\n self.func, self.emptyvalue = func, emptyvalue\n local stagenum, mul = 1, 1\n self.stage = {}\n while mul < n do\n mul, stagenum = mul * 2, stagenum + 1\n end\n self.stagenum = stagenum\n for i = 1, mul * 2 - 1 do self.stage[i] = emptyvalue end\n for i = 1, n do self.stage[mul + i - 1] = i end\n self:updateAll()\nend\nSegTree.update = function(self, idx)\n idx = idx + pow2[self.stagenum] - 1\n for i = self.stagenum - 1, 1, -1 do\n local dst = mfl(idx / 2)\n local rem = dst * 4 + 1 - idx\n self.stage[dst] = self.func(self.stage[idx], self.stage[rem])\n idx = dst\n end\nend\nSegTree.new = function(n, func, emptyvalue)\n local obj = {}\n setmetatable(obj, {__index = SegTree})\n obj:create(n, func, emptyvalue)\n return obj\nend\n\nlocal n, m = io.read(\"*n\", \"*n\")\nlocal s, t = io.read(\"*n\", \"*n\")\nlocal edge = {}\nfor i = 1, n do\n edge[i] = {}\nend\nfor i = 1, m do\n local a, b, d = io.read(\"*n\", \"*n\", \"*n\")\n edge[a][b], edge[b][a] = d, d\nend\n\nlocal inf = 1000000000 * 99999 + 1\nlocal slen, tlen = {}, {}\nlocal sway = {}\nlocal asked = {}\nfor i = 1, n do\n slen[i], tlen[i] = inf, inf\n asked[i] = false\n sway[i] = 0\nend\nslen[s] = 0\nsway[s] = 1\nasked[n + 1] = true\n\nlocal function mergefunc(x, y)\n if asked[x] then return y\n elseif asked[y] then return x\n else\n return slen[x] < slen[y] and x or y\n end\nend\n\nlocal st = SegTree.new(n, mergefunc, n + 1)\n\nfor i = 1, n do\n local src = st.stage[1]\n if asked[src] then break end\n asked[src] = true\n st:update(src)\n for dst, cost in pairs(edge[src]) do\n if slen[src] + cost < slen[dst] then\n slen[dst] = slen[src] + cost\n sway[dst] = sway[src]\n st:update(dst)\n elseif slen[src] + cost == slen[dst] then\n sway[dst] = badd(sway[dst], sway[src])\n end\n end\nend\n\nlocal stlen = slen[t]\nlocal ret = bmul(sway[t], sway[t])\nif inf <= stlen then\n print(0)\n os.exit()\nend\n\nlocal function mergefunc2(x, y)\n if asked[x] then return y\n elseif asked[y] then return x\n else\n return tlen[x] < tlen[y] and x or y\n end\nend\nst.func = mergefunc2\nlocal tway = {}\nfor i = 1, n do\n asked[i] = false\n tway[i] = 0\nend\ntlen[t] = 0\ntway[t] = 1\nst:updateAll()\n\nfor i = 1, n do\n local src = st.stage[1]\n if asked[src] then break end\n asked[src] = true\n if tlen[src] * 2 == stlen then\n local z = bmul(sway[src], tway[src])\n z = bmul(z, z)\n ret = bsub(ret, z)\n end\n st:update(src)\n for dst, cost in pairs(edge[src]) do\n local tlsrc = tlen[src]\n if tlsrc * 2 < stlen and stlen < (tlsrc + cost) * 2\n and tlsrc + cost + slen[dst] == stlen then\n local z = bmul(tway[src], sway[dst])\n z = bmul(z, z)\n ret = bsub(ret, z)\n end\n if tlen[src] + cost < tlen[dst] then\n tlen[dst] = tlen[src] + cost\n tway[dst] = tway[src]\n st:update(dst)\n elseif tlen[src] + cost == tlen[dst] then\n tway[dst] = badd(tway[dst], tway[src])\n end\n end\nend\nprint(ret)\n", "language": "Lua", "metadata": {"date": 1597723457, "filename_ext": "lua", "original_language": "Lua (LuaJIT 2.1.0)", "problem_description_relpath": "problem_descriptions/p03453.html", "problem_id": "p03453", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03453/input.txt", "sample_output_relpath": "derived/input_output/data/p03453/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03453/Lua/s314478195.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s314478195", "user_id": "u120582723"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "local mfl, mce = math.floor, math.ceil\nlocal mmi, mma = math.min, math.max\nlocal mod = 1000000007\nlocal function bmul(x, y)\n local x1, y1 = mfl(x / 31623), mfl(y / 31623)\n local x0, y0 = x - x1 * 31623, y - y1 * 31623\n return (x1 * y1 * 14122 + (x1 * y0 + x0 * y1) * 31623 + x0 * y0) % mod\nend\n\nlocal function badd(x, y)\n return (x + y) % mod\nend\n\nlocal function bsub(x, y)\n return x < y and x - y + mod or x - y\nend\n\nlocal pow2 = {1}\nfor i = 2, 28 do pow2[i] = pow2[i - 1] * 2 end\nlocal SegTree = {}\nSegTree.updateAll = function(self)\n for i = self.stagenum - 1, 1, -1 do\n local cnt = pow2[i]\n for j = 0, cnt - 1 do\n self.stage[cnt + j] = self.func(self.stage[(cnt + j) * 2], self.stage[(cnt + j) * 2 + 1])\n end\n end\nend\nSegTree.create = function(self, n, func, emptyvalue)\n self.func, self.emptyvalue = func, emptyvalue\n local stagenum, mul = 1, 1\n self.stage = {}\n while mul < n do\n mul, stagenum = mul * 2, stagenum + 1\n end\n self.stagenum = stagenum\n for i = 1, mul * 2 - 1 do self.stage[i] = emptyvalue end\n for i = 1, n do self.stage[mul + i - 1] = i end\n self:updateAll()\nend\nSegTree.update = function(self, idx)\n idx = idx + pow2[self.stagenum] - 1\n for i = self.stagenum - 1, 1, -1 do\n local dst = mfl(idx / 2)\n local rem = dst * 4 + 1 - idx\n self.stage[dst] = self.func(self.stage[idx], self.stage[rem])\n idx = dst\n end\nend\nSegTree.new = function(n, func, emptyvalue)\n local obj = {}\n setmetatable(obj, {__index = SegTree})\n obj:create(n, func, emptyvalue)\n return obj\nend\n\nlocal n, m = io.read(\"*n\", \"*n\")\nlocal s, t = io.read(\"*n\", \"*n\")\nlocal edge = {}\nfor i = 1, n do\n edge[i] = {}\nend\nfor i = 1, m do\n local a, b, d = io.read(\"*n\", \"*n\", \"*n\")\n edge[a][b], edge[b][a] = d, d\nend\n\nlocal inf = 1000000000 * 99999 + 1\nlocal slen, tlen = {}, {}\nlocal sway = {}\nlocal asked = {}\nfor i = 1, n do\n slen[i], tlen[i] = inf, inf\n asked[i] = false\n sway[i] = 0\nend\nslen[s] = 0\nsway[s] = 1\nasked[n + 1] = true\n\nlocal function mergefunc(x, y)\n if asked[x] then return y\n elseif asked[y] then return x\n else\n return slen[x] < slen[y] and x or y\n end\nend\n\nlocal st = SegTree.new(n, mergefunc, n + 1)\n\nfor i = 1, n do\n local src = st.stage[1]\n if asked[src] then break end\n asked[src] = true\n st:update(src)\n for dst, cost in pairs(edge[src]) do\n if slen[src] + cost < slen[dst] then\n slen[dst] = slen[src] + cost\n sway[dst] = sway[src]\n st:update(dst)\n elseif slen[src] + cost == slen[dst] then\n sway[dst] = badd(sway[dst], sway[src])\n end\n end\nend\n\nlocal stlen = slen[t]\nlocal ret = bmul(sway[t], sway[t])\nif inf <= stlen then\n print(0)\n os.exit()\nend\n\nlocal function mergefunc2(x, y)\n if asked[x] then return y\n elseif asked[y] then return x\n else\n return tlen[x] < tlen[y] and x or y\n end\nend\nst.func = mergefunc2\nlocal tway = {}\nfor i = 1, n do\n asked[i] = false\n tway[i] = 0\nend\ntlen[t] = 0\ntway[t] = 1\nst:updateAll()\n\nfor i = 1, n do\n local src = st.stage[1]\n if asked[src] then break end\n asked[src] = true\n if tlen[src] * 2 == stlen then\n local z = bmul(sway[src], tway[src])\n z = bmul(z, z)\n ret = bsub(ret, z)\n end\n st:update(src)\n for dst, cost in pairs(edge[src]) do\n local tlsrc = tlen[src]\n if tlsrc * 2 < stlen and stlen < (tlsrc + cost) * 2\n and tlsrc + cost + slen[dst] == stlen then\n local z = bmul(tway[src], sway[dst])\n z = bmul(z, z)\n ret = bsub(ret, z)\n end\n if tlen[src] + cost < tlen[dst] then\n tlen[dst] = tlen[src] + cost\n tway[dst] = tway[src]\n st:update(dst)\n elseif tlen[src] + cost == tlen[dst] then\n tway[dst] = badd(tway[dst], tway[src])\n end\n end\nend\nprint(ret)\n", "problem_context": "Score : 700 points\n\nProblem Statement\n\nWe have a graph with N vertices and M edges, and there are two people on the graph: Takahashi and Aoki.\n\nThe i-th edge connects Vertex U_i and Vertex V_i.\nThe time it takes to traverse this edge is D_i minutes, regardless of direction and who traverses the edge (Takahashi or Aoki).\n\nTakahashi departs Vertex S and Aoki departs Vertex T at the same time. Takahashi travels to Vertex T and Aoki travels to Vertex S, both in the shortest time possible.\nFind the number of the pairs of ways for Takahashi and Aoki to choose their shortest paths such that they never meet (at a vertex or on an edge) during the travel, modulo 10^9 + 7.\n\nConstraints\n\n1 \\leq N \\leq 100 000\n\n1 \\leq M \\leq 200 000\n\n1 \\leq S, T \\leq N\n\nS \\neq T\n\n1 \\leq U_i, V_i \\leq N (1 \\leq i \\leq M)\n\n1 \\leq D_i \\leq 10^9 (1 \\leq i \\leq M)\n\nIf i \\neq j, then (U_i, V_i) \\neq (U_j, V_j) and (U_i, V_i) \\neq (V_j, U_j).\n\nU_i \\neq V_i (1 \\leq i \\leq M)\n\nD_i are integers.\n\nThe given graph is connected.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nS T\nU_1 V_1 D_1\nU_2 V_2 D_2\n:\nU_M V_M D_M\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n4 4\n1 3\n1 2 1\n2 3 1\n3 4 1\n4 1 1\n\nSample Output 1\n\n2\n\nThere are two ways to choose shortest paths that satisfies the condition:\n\nTakahashi chooses the path 1 \\rightarrow 2 \\rightarrow 3, and Aoki chooses the path 3 \\rightarrow 4 \\rightarrow 1.\n\nTakahashi chooses the path 1 \\rightarrow 4 \\rightarrow 3, and Aoki chooses the path 3 \\rightarrow 2 \\rightarrow 1.\n\nSample Input 2\n\n3 3\n1 3\n1 2 1\n2 3 1\n3 1 2\n\nSample Output 2\n\n2\n\nSample Input 3\n\n3 3\n1 3\n1 2 1\n2 3 1\n3 1 2\n\nSample Output 3\n\n2\n\nSample Input 4\n\n8 13\n4 2\n7 3 9\n6 2 3\n1 6 4\n7 6 9\n3 8 9\n1 2 2\n2 8 12\n8 6 9\n2 5 5\n4 2 18\n5 3 7\n5 1 515371567\n4 8 6\n\nSample Output 4\n\n6", "sample_input": "4 4\n1 3\n1 2 1\n2 3 1\n3 4 1\n4 1 1\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03453", "source_text": "Score : 700 points\n\nProblem Statement\n\nWe have a graph with N vertices and M edges, and there are two people on the graph: Takahashi and Aoki.\n\nThe i-th edge connects Vertex U_i and Vertex V_i.\nThe time it takes to traverse this edge is D_i minutes, regardless of direction and who traverses the edge (Takahashi or Aoki).\n\nTakahashi departs Vertex S and Aoki departs Vertex T at the same time. Takahashi travels to Vertex T and Aoki travels to Vertex S, both in the shortest time possible.\nFind the number of the pairs of ways for Takahashi and Aoki to choose their shortest paths such that they never meet (at a vertex or on an edge) during the travel, modulo 10^9 + 7.\n\nConstraints\n\n1 \\leq N \\leq 100 000\n\n1 \\leq M \\leq 200 000\n\n1 \\leq S, T \\leq N\n\nS \\neq T\n\n1 \\leq U_i, V_i \\leq N (1 \\leq i \\leq M)\n\n1 \\leq D_i \\leq 10^9 (1 \\leq i \\leq M)\n\nIf i \\neq j, then (U_i, V_i) \\neq (U_j, V_j) and (U_i, V_i) \\neq (V_j, U_j).\n\nU_i \\neq V_i (1 \\leq i \\leq M)\n\nD_i are integers.\n\nThe given graph is connected.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nS T\nU_1 V_1 D_1\nU_2 V_2 D_2\n:\nU_M V_M D_M\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n4 4\n1 3\n1 2 1\n2 3 1\n3 4 1\n4 1 1\n\nSample Output 1\n\n2\n\nThere are two ways to choose shortest paths that satisfies the condition:\n\nTakahashi chooses the path 1 \\rightarrow 2 \\rightarrow 3, and Aoki chooses the path 3 \\rightarrow 4 \\rightarrow 1.\n\nTakahashi chooses the path 1 \\rightarrow 4 \\rightarrow 3, and Aoki chooses the path 3 \\rightarrow 2 \\rightarrow 1.\n\nSample Input 2\n\n3 3\n1 3\n1 2 1\n2 3 1\n3 1 2\n\nSample Output 2\n\n2\n\nSample Input 3\n\n3 3\n1 3\n1 2 1\n2 3 1\n3 1 2\n\nSample Output 3\n\n2\n\nSample Input 4\n\n8 13\n4 2\n7 3 9\n6 2 3\n1 6 4\n7 6 9\n3 8 9\n1 2 2\n2 8 12\n8 6 9\n2 5 5\n4 2 18\n5 3 7\n5 1 515371567\n4 8 6\n\nSample Output 4\n\n6", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 3680, "cpu_time_ms": 541, "memory_kb": 28944}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s792873126", "group_id": "codeNet:p03456", "input_text": "s = io.read()\ns = s:gsub(\" \", \"\")\ns = tonumber(s)\nf = false\nfor i = 1, 400 do\n if i * i == s then f = true break end\nend\nprint(f and \"Yes\" or \"No\")\n", "language": "Lua", "metadata": {"date": 1594094293, "filename_ext": "lua", "original_language": "Lua (Lua 5.3.5)", "problem_description_relpath": "problem_descriptions/p03456.html", "problem_id": "p03456", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03456/input.txt", "sample_output_relpath": "derived/input_output/data/p03456/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03456/Lua/s792873126.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s792873126", "user_id": "u120582723"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "s = io.read()\ns = s:gsub(\" \", \"\")\ns = tonumber(s)\nf = false\nfor i = 1, 400 do\n if i * i == s then f = true break end\nend\nprint(f and \"Yes\" or \"No\")\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nAtCoDeer the deer has found two positive integers, a and b.\nDetermine whether the concatenation of a and b in this order is a square number.\n\nConstraints\n\n1 ≤ a,b ≤ 100\n\na and b are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\na b\n\nOutput\n\nIf the concatenation of a and b in this order is a square number, print Yes; otherwise, print No.\n\nSample Input 1\n\n1 21\n\nSample Output 1\n\nYes\n\nAs 121 = 11 × 11, it is a square number.\n\nSample Input 2\n\n100 100\n\nSample Output 2\n\nNo\n\n100100 is not a square number.\n\nSample Input 3\n\n12 10\n\nSample Output 3\n\nNo", "sample_input": "1 21\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03456", "source_text": "Score : 200 points\n\nProblem Statement\n\nAtCoDeer the deer has found two positive integers, a and b.\nDetermine whether the concatenation of a and b in this order is a square number.\n\nConstraints\n\n1 ≤ a,b ≤ 100\n\na and b are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\na b\n\nOutput\n\nIf the concatenation of a and b in this order is a square number, print Yes; otherwise, print No.\n\nSample Input 1\n\n1 21\n\nSample Output 1\n\nYes\n\nAs 121 = 11 × 11, it is a square number.\n\nSample Input 2\n\n100 100\n\nSample Output 2\n\nNo\n\n100100 is not a square number.\n\nSample Input 3\n\n12 10\n\nSample Output 3\n\nNo", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 149, "cpu_time_ms": 4, "memory_kb": 2548}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s588526480", "group_id": "codeNet:p03456", "input_text": "a=io.read(\"n\")\nb=io.read(\"n\")\nlocal res=0\nif b==100 then\n res=a*1000+b\n elseif b>=10 and b<=99 then\n res=a*100+b\n else\n res=a*10+b\nend\nlocal _,k=math.modf(math.sqrt(res))\nif k==0 then\n print(\"Yes\")\nelse\n print(\"No\")\nend", "language": "Lua", "metadata": {"date": 1551127714, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03456.html", "problem_id": "p03456", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03456/input.txt", "sample_output_relpath": "derived/input_output/data/p03456/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03456/Lua/s588526480.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s588526480", "user_id": "u015229643"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "a=io.read(\"n\")\nb=io.read(\"n\")\nlocal res=0\nif b==100 then\n res=a*1000+b\n elseif b>=10 and b<=99 then\n res=a*100+b\n else\n res=a*10+b\nend\nlocal _,k=math.modf(math.sqrt(res))\nif k==0 then\n print(\"Yes\")\nelse\n print(\"No\")\nend", "problem_context": "Score : 200 points\n\nProblem Statement\n\nAtCoDeer the deer has found two positive integers, a and b.\nDetermine whether the concatenation of a and b in this order is a square number.\n\nConstraints\n\n1 ≤ a,b ≤ 100\n\na and b are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\na b\n\nOutput\n\nIf the concatenation of a and b in this order is a square number, print Yes; otherwise, print No.\n\nSample Input 1\n\n1 21\n\nSample Output 1\n\nYes\n\nAs 121 = 11 × 11, it is a square number.\n\nSample Input 2\n\n100 100\n\nSample Output 2\n\nNo\n\n100100 is not a square number.\n\nSample Input 3\n\n12 10\n\nSample Output 3\n\nNo", "sample_input": "1 21\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03456", "source_text": "Score : 200 points\n\nProblem Statement\n\nAtCoDeer the deer has found two positive integers, a and b.\nDetermine whether the concatenation of a and b in this order is a square number.\n\nConstraints\n\n1 ≤ a,b ≤ 100\n\na and b are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\na b\n\nOutput\n\nIf the concatenation of a and b in this order is a square number, print Yes; otherwise, print No.\n\nSample Input 1\n\n1 21\n\nSample Output 1\n\nYes\n\nAs 121 = 11 × 11, it is a square number.\n\nSample Input 2\n\n100 100\n\nSample Output 2\n\nNo\n\n100100 is not a square number.\n\nSample Input 3\n\n12 10\n\nSample Output 3\n\nNo", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 230, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s399248626", "group_id": "codeNet:p03457", "input_text": "local n = io.read(\"*n\")\nlocal t = 0\nlocal x = 0\nlocal y = 0\nfor i = 1, n do\n local t0, x0, y0 = io.read(\"*n\", \"*n\", \"*n\")\n local dt = t0 - t\n local dx = x0 - x\n local dy = y0 - y\n if dx + dy > dt or (dt - dx - dy) % 2 > 0 then\n print(\"No\")\n return \n end\n t = t0\n x = x0\n y = y0\nend\nreturn print(\"Yes\")\n", "language": "Lua", "metadata": {"date": 1529109589, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p03457.html", "problem_id": "p03457", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03457/input.txt", "sample_output_relpath": "derived/input_output/data/p03457/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03457/Lua/s399248626.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s399248626", "user_id": "u280667879"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "local n = io.read(\"*n\")\nlocal t = 0\nlocal x = 0\nlocal y = 0\nfor i = 1, n do\n local t0, x0, y0 = io.read(\"*n\", \"*n\", \"*n\")\n local dt = t0 - t\n local dx = x0 - x\n local dy = y0 - y\n if dx + dy > dt or (dt - dx - dy) % 2 > 0 then\n print(\"No\")\n return \n end\n t = t0\n x = x0\n y = y0\nend\nreturn print(\"Yes\")\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nAtCoDeer the deer is going on a trip in a two-dimensional plane.\nIn his plan, he will depart from point (0, 0) at time 0, then for each i between 1 and N (inclusive), he will visit point (x_i,y_i) at time t_i.\n\nIf AtCoDeer is at point (x, y) at time t, he can be at one of the following points at time t+1: (x+1,y), (x-1,y), (x,y+1) and (x,y-1).\nNote that he cannot stay at his place.\nDetermine whether he can carry out his plan.\n\nConstraints\n\n1 ≤ N ≤ 10^5\n\n0 ≤ x_i ≤ 10^5\n\n0 ≤ y_i ≤ 10^5\n\n1 ≤ t_i ≤ 10^5\n\nt_i < t_{i+1} (1 ≤ i ≤ N-1)\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nt_1 x_1 y_1\nt_2 x_2 y_2\n:\nt_N x_N y_N\n\nOutput\n\nIf AtCoDeer can carry out his plan, print Yes; if he cannot, print No.\n\nSample Input 1\n\n2\n3 1 2\n6 1 1\n\nSample Output 1\n\nYes\n\nFor example, he can travel as follows: (0,0), (0,1), (1,1), (1,2), (1,1), (1,0), then (1,1).\n\nSample Input 2\n\n1\n2 100 100\n\nSample Output 2\n\nNo\n\nIt is impossible to be at (100,100) two seconds after being at (0,0).\n\nSample Input 3\n\n2\n5 1 1\n100 1 1\n\nSample Output 3\n\nNo", "sample_input": "2\n3 1 2\n6 1 1\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03457", "source_text": "Score : 300 points\n\nProblem Statement\n\nAtCoDeer the deer is going on a trip in a two-dimensional plane.\nIn his plan, he will depart from point (0, 0) at time 0, then for each i between 1 and N (inclusive), he will visit point (x_i,y_i) at time t_i.\n\nIf AtCoDeer is at point (x, y) at time t, he can be at one of the following points at time t+1: (x+1,y), (x-1,y), (x,y+1) and (x,y-1).\nNote that he cannot stay at his place.\nDetermine whether he can carry out his plan.\n\nConstraints\n\n1 ≤ N ≤ 10^5\n\n0 ≤ x_i ≤ 10^5\n\n0 ≤ y_i ≤ 10^5\n\n1 ≤ t_i ≤ 10^5\n\nt_i < t_{i+1} (1 ≤ i ≤ N-1)\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nt_1 x_1 y_1\nt_2 x_2 y_2\n:\nt_N x_N y_N\n\nOutput\n\nIf AtCoDeer can carry out his plan, print Yes; if he cannot, print No.\n\nSample Input 1\n\n2\n3 1 2\n6 1 1\n\nSample Output 1\n\nYes\n\nFor example, he can travel as follows: (0,0), (0,1), (1,1), (1,2), (1,1), (1,0), then (1,1).\n\nSample Input 2\n\n1\n2 100 100\n\nSample Output 2\n\nNo\n\nIt is impossible to be at (100,100) two seconds after being at (0,0).\n\nSample Input 3\n\n2\n5 1 1\n100 1 1\n\nSample Output 3\n\nNo", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 317, "cpu_time_ms": 48, "memory_kb": 256}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s378349291", "group_id": "codeNet:p03459", "input_text": "local n = io.read('*n')\nio.read('*l')\nlocal ret = true\nfor i = 1, n do\n\tlocal t = io.read('*n')\n\tlocal x = io.read('*n')\n\tlocal y = io.read('*n')\n\tif (t - (x + y)) < 0 then\n\t\tret = false\n\tend\n\tif (t - (x + y)) % 2 > 0 then\n\t\tret = false\n\tend\nend\nprint(ret and 'Yes' or 'No')", "language": "Lua", "metadata": {"date": 1553565747, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03459.html", "problem_id": "p03459", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03459/input.txt", "sample_output_relpath": "derived/input_output/data/p03459/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03459/Lua/s378349291.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s378349291", "user_id": "u863370423"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "local n = io.read('*n')\nio.read('*l')\nlocal ret = true\nfor i = 1, n do\n\tlocal t = io.read('*n')\n\tlocal x = io.read('*n')\n\tlocal y = io.read('*n')\n\tif (t - (x + y)) < 0 then\n\t\tret = false\n\tend\n\tif (t - (x + y)) % 2 > 0 then\n\t\tret = false\n\tend\nend\nprint(ret and 'Yes' or 'No')", "problem_context": "Score : 300 points\n\nProblem Statement\n\nAtCoDeer the deer is going on a trip in a two-dimensional plane.\nIn his plan, he will depart from point (0, 0) at time 0, then for each i between 1 and N (inclusive), he will visit point (x_i,y_i) at time t_i.\n\nIf AtCoDeer is at point (x, y) at time t, he can be at one of the following points at time t+1: (x+1,y), (x-1,y), (x,y+1) and (x,y-1).\nNote that he cannot stay at his place.\nDetermine whether he can carry out his plan.\n\nConstraints\n\n1 ≤ N ≤ 10^5\n\n0 ≤ x_i ≤ 10^5\n\n0 ≤ y_i ≤ 10^5\n\n1 ≤ t_i ≤ 10^5\n\nt_i < t_{i+1} (1 ≤ i ≤ N-1)\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nt_1 x_1 y_1\nt_2 x_2 y_2\n:\nt_N x_N y_N\n\nOutput\n\nIf AtCoDeer can carry out his plan, print Yes; if he cannot, print No.\n\nSample Input 1\n\n2\n3 1 2\n6 1 1\n\nSample Output 1\n\nYes\n\nFor example, he can travel as follows: (0,0), (0,1), (1,1), (1,2), (1,1), (1,0), then (1,1).\n\nSample Input 2\n\n1\n2 100 100\n\nSample Output 2\n\nNo\n\nIt is impossible to be at (100,100) two seconds after being at (0,0).\n\nSample Input 3\n\n2\n5 1 1\n100 1 1\n\nSample Output 3\n\nNo", "sample_input": "2\n3 1 2\n6 1 1\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03459", "source_text": "Score : 300 points\n\nProblem Statement\n\nAtCoDeer the deer is going on a trip in a two-dimensional plane.\nIn his plan, he will depart from point (0, 0) at time 0, then for each i between 1 and N (inclusive), he will visit point (x_i,y_i) at time t_i.\n\nIf AtCoDeer is at point (x, y) at time t, he can be at one of the following points at time t+1: (x+1,y), (x-1,y), (x,y+1) and (x,y-1).\nNote that he cannot stay at his place.\nDetermine whether he can carry out his plan.\n\nConstraints\n\n1 ≤ N ≤ 10^5\n\n0 ≤ x_i ≤ 10^5\n\n0 ≤ y_i ≤ 10^5\n\n1 ≤ t_i ≤ 10^5\n\nt_i < t_{i+1} (1 ≤ i ≤ N-1)\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nt_1 x_1 y_1\nt_2 x_2 y_2\n:\nt_N x_N y_N\n\nOutput\n\nIf AtCoDeer can carry out his plan, print Yes; if he cannot, print No.\n\nSample Input 1\n\n2\n3 1 2\n6 1 1\n\nSample Output 1\n\nYes\n\nFor example, he can travel as follows: (0,0), (0,1), (1,1), (1,2), (1,1), (1,0), then (1,1).\n\nSample Input 2\n\n1\n2 100 100\n\nSample Output 2\n\nNo\n\nIt is impossible to be at (100,100) two seconds after being at (0,0).\n\nSample Input 3\n\n2\n5 1 1\n100 1 1\n\nSample Output 3\n\nNo", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 274, "cpu_time_ms": 84, "memory_kb": 256}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s859759566", "group_id": "codeNet:p03459", "input_text": "local a = io.read(\"*number\")\n\nlocal function getABC()\n\tlocal tb = {false, false}\n\tfor i=1, a do\n\t\tlocal s = io.read(\"*number\")\n\t\tlocal x = io.read(\"*number\")\n\t\tlocal y = io.read(\"*number\")\n\t\tfor j=0, s do\n\t\t\tlocal r = x + y + 2*j\n\t\t\tif s == r then\n\t\t\t\ttb[i] = true\n\t\t\t\tbreak\n\t\t\tend\n\t\tend\n\tend\n\treturn tb\nend\n\nlocal r = getABC()\nif r[1] and r[2] then\n\tprint(\"YES\")\nelse\n\tprint(\"NO\")\nend\n", "language": "Lua", "metadata": {"date": 1553561151, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03459.html", "problem_id": "p03459", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03459/input.txt", "sample_output_relpath": "derived/input_output/data/p03459/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03459/Lua/s859759566.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s859759566", "user_id": "u089230684"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "local a = io.read(\"*number\")\n\nlocal function getABC()\n\tlocal tb = {false, false}\n\tfor i=1, a do\n\t\tlocal s = io.read(\"*number\")\n\t\tlocal x = io.read(\"*number\")\n\t\tlocal y = io.read(\"*number\")\n\t\tfor j=0, s do\n\t\t\tlocal r = x + y + 2*j\n\t\t\tif s == r then\n\t\t\t\ttb[i] = true\n\t\t\t\tbreak\n\t\t\tend\n\t\tend\n\tend\n\treturn tb\nend\n\nlocal r = getABC()\nif r[1] and r[2] then\n\tprint(\"YES\")\nelse\n\tprint(\"NO\")\nend\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nAtCoDeer the deer is going on a trip in a two-dimensional plane.\nIn his plan, he will depart from point (0, 0) at time 0, then for each i between 1 and N (inclusive), he will visit point (x_i,y_i) at time t_i.\n\nIf AtCoDeer is at point (x, y) at time t, he can be at one of the following points at time t+1: (x+1,y), (x-1,y), (x,y+1) and (x,y-1).\nNote that he cannot stay at his place.\nDetermine whether he can carry out his plan.\n\nConstraints\n\n1 ≤ N ≤ 10^5\n\n0 ≤ x_i ≤ 10^5\n\n0 ≤ y_i ≤ 10^5\n\n1 ≤ t_i ≤ 10^5\n\nt_i < t_{i+1} (1 ≤ i ≤ N-1)\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nt_1 x_1 y_1\nt_2 x_2 y_2\n:\nt_N x_N y_N\n\nOutput\n\nIf AtCoDeer can carry out his plan, print Yes; if he cannot, print No.\n\nSample Input 1\n\n2\n3 1 2\n6 1 1\n\nSample Output 1\n\nYes\n\nFor example, he can travel as follows: (0,0), (0,1), (1,1), (1,2), (1,1), (1,0), then (1,1).\n\nSample Input 2\n\n1\n2 100 100\n\nSample Output 2\n\nNo\n\nIt is impossible to be at (100,100) two seconds after being at (0,0).\n\nSample Input 3\n\n2\n5 1 1\n100 1 1\n\nSample Output 3\n\nNo", "sample_input": "2\n3 1 2\n6 1 1\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03459", "source_text": "Score : 300 points\n\nProblem Statement\n\nAtCoDeer the deer is going on a trip in a two-dimensional plane.\nIn his plan, he will depart from point (0, 0) at time 0, then for each i between 1 and N (inclusive), he will visit point (x_i,y_i) at time t_i.\n\nIf AtCoDeer is at point (x, y) at time t, he can be at one of the following points at time t+1: (x+1,y), (x-1,y), (x,y+1) and (x,y-1).\nNote that he cannot stay at his place.\nDetermine whether he can carry out his plan.\n\nConstraints\n\n1 ≤ N ≤ 10^5\n\n0 ≤ x_i ≤ 10^5\n\n0 ≤ y_i ≤ 10^5\n\n1 ≤ t_i ≤ 10^5\n\nt_i < t_{i+1} (1 ≤ i ≤ N-1)\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nt_1 x_1 y_1\nt_2 x_2 y_2\n:\nt_N x_N y_N\n\nOutput\n\nIf AtCoDeer can carry out his plan, print Yes; if he cannot, print No.\n\nSample Input 1\n\n2\n3 1 2\n6 1 1\n\nSample Output 1\n\nYes\n\nFor example, he can travel as follows: (0,0), (0,1), (1,1), (1,2), (1,1), (1,0), then (1,1).\n\nSample Input 2\n\n1\n2 100 100\n\nSample Output 2\n\nNo\n\nIt is impossible to be at (100,100) two seconds after being at (0,0).\n\nSample Input 3\n\n2\n5 1 1\n100 1 1\n\nSample Output 3\n\nNo", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 386, "cpu_time_ms": 2103, "memory_kb": 2424}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s701203271", "group_id": "codeNet:p03463", "input_text": "local n, a, b = io.read(\"*n\", \"*n\", \"*n\")\nif (b - a) % 2 == 0 then\n print(\"Alice\")\nelse\n print(\"Borys\")\nend\n", "language": "Lua", "metadata": {"date": 1563306971, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03463.html", "problem_id": "p03463", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03463/input.txt", "sample_output_relpath": "derived/input_output/data/p03463/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03463/Lua/s701203271.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s701203271", "user_id": "u120582723"}, "prompt_components": {"gold_output": "Alice\n", "input_to_evaluate": "local n, a, b = io.read(\"*n\", \"*n\", \"*n\")\nif (b - a) % 2 == 0 then\n print(\"Alice\")\nelse\n print(\"Borys\")\nend\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nA game is played on a strip consisting of N cells consecutively numbered from 1 to N.\n\nAlice has her token on cell A. Borys has his token on a different cell B.\n\nPlayers take turns, Alice moves first.\nThe moving player must shift his or her token from its current cell X to the neighboring cell on the left, cell X-1, or on the right, cell X+1.\nNote that it's disallowed to move the token outside the strip or to the cell with the other player's token.\nIn one turn, the token of the moving player must be shifted exactly once.\n\nThe player who can't make a move loses, and the other player wins.\n\nBoth players want to win. Who wins if they play optimally?\n\nConstraints\n\n2 \\leq N \\leq 100\n\n1 \\leq A < B \\leq N\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN A B\n\nOutput\n\nPrint Alice if Alice wins, Borys if Borys wins, and Draw if nobody wins.\n\nSample Input 1\n\n5 2 4\n\nSample Output 1\n\nAlice\n\nAlice can move her token to cell 3.\nAfter that, Borys will be unable to move his token to cell 3, so he will have to move his token to cell 5.\nThen, Alice moves her token to cell 4. Borys can't make a move and loses.\n\nSample Input 2\n\n2 1 2\n\nSample Output 2\n\nBorys\n\nAlice can't make the very first move and loses.\n\nSample Input 3\n\n58 23 42\n\nSample Output 3\n\nBorys", "sample_input": "5 2 4\n"}, "reference_outputs": ["Alice\n"], "source_document_id": "p03463", "source_text": "Score : 300 points\n\nProblem Statement\n\nA game is played on a strip consisting of N cells consecutively numbered from 1 to N.\n\nAlice has her token on cell A. Borys has his token on a different cell B.\n\nPlayers take turns, Alice moves first.\nThe moving player must shift his or her token from its current cell X to the neighboring cell on the left, cell X-1, or on the right, cell X+1.\nNote that it's disallowed to move the token outside the strip or to the cell with the other player's token.\nIn one turn, the token of the moving player must be shifted exactly once.\n\nThe player who can't make a move loses, and the other player wins.\n\nBoth players want to win. Who wins if they play optimally?\n\nConstraints\n\n2 \\leq N \\leq 100\n\n1 \\leq A < B \\leq N\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN A B\n\nOutput\n\nPrint Alice if Alice wins, Borys if Borys wins, and Draw if nobody wins.\n\nSample Input 1\n\n5 2 4\n\nSample Output 1\n\nAlice\n\nAlice can move her token to cell 3.\nAfter that, Borys will be unable to move his token to cell 3, so he will have to move his token to cell 5.\nThen, Alice moves her token to cell 4. Borys can't make a move and loses.\n\nSample Input 2\n\n2 1 2\n\nSample Output 2\n\nBorys\n\nAlice can't make the very first move and loses.\n\nSample Input 3\n\n58 23 42\n\nSample Output 3\n\nBorys", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 110, "cpu_time_ms": 7, "memory_kb": 888}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s758448700", "group_id": "codeNet:p03464", "input_text": "local mfl, mce = math.floor, math.ceil\nlocal n = io.read(\"*n\")\nlocal t = {}\nfor i = 1, n do\n t[i] = io.read(\"*n\")\nend\nlocal curmin, curmax = 2, 2\n-- a[n] = k * t[n] + l (0 <= k, 0 <= l < t[n])\n-- a[n+1] = k * t[n]\nfor i = n, 1, -1 do\n local a = curmin\n local b = curmax + t[i] - 1\n if 1 < i then\n curmin = t[i - 1] * mce(a / t[i - 1])\n curmax = t[i - 1] * mfl(b / t[i - 1])\n else\n curmin, curmax = a, b\n end\n if curmax < curmin then break end\nend\nif curmax < curmin then\n print(-1)\nelse\n print(curmin .. \" \" .. curmax)\nend\n", "language": "Lua", "metadata": {"date": 1568234814, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03464.html", "problem_id": "p03464", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03464/input.txt", "sample_output_relpath": "derived/input_output/data/p03464/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03464/Lua/s758448700.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s758448700", "user_id": "u120582723"}, "prompt_components": {"gold_output": "6 8\n", "input_to_evaluate": "local mfl, mce = math.floor, math.ceil\nlocal n = io.read(\"*n\")\nlocal t = {}\nfor i = 1, n do\n t[i] = io.read(\"*n\")\nend\nlocal curmin, curmax = 2, 2\n-- a[n] = k * t[n] + l (0 <= k, 0 <= l < t[n])\n-- a[n+1] = k * t[n]\nfor i = n, 1, -1 do\n local a = curmin\n local b = curmax + t[i] - 1\n if 1 < i then\n curmin = t[i - 1] * mce(a / t[i - 1])\n curmax = t[i - 1] * mfl(b / t[i - 1])\n else\n curmin, curmax = a, b\n end\n if curmax < curmin then break end\nend\nif curmax < curmin then\n print(-1)\nelse\n print(curmin .. \" \" .. curmax)\nend\n", "problem_context": "Score : 500 points\n\nProblem Statement\n\nAn adult game master and N children are playing a game on an ice rink.\nThe game consists of K rounds.\nIn the i-th round, the game master announces:\n\nForm groups consisting of A_i children each!\n\nThen the children who are still in the game form as many groups of A_i children as possible.\nOne child may belong to at most one group.\nThose who are left without a group leave the game. The others proceed to the next round.\nNote that it's possible that nobody leaves the game in some round.\n\nIn the end, after the K-th round, there are exactly two children left, and they are declared the winners.\n\nYou have heard the values of A_1, A_2, ..., A_K. You don't know N, but you want to estimate it.\n\nFind the smallest and the largest possible number of children in the game before the start, or determine that no valid values of N exist.\n\nConstraints\n\n1 \\leq K \\leq 10^5\n\n2 \\leq A_i \\leq 10^9\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nK\nA_1 A_2 ... A_K\n\nOutput\n\nPrint two integers representing the smallest and the largest possible value of N, respectively,\nor a single integer -1 if the described situation is impossible.\n\nSample Input 1\n\n4\n3 4 3 2\n\nSample Output 1\n\n6 8\n\nFor example, if the game starts with 6 children, then it proceeds as follows:\n\nIn the first round, 6 children form 2 groups of 3 children, and nobody leaves the game.\n\nIn the second round, 6 children form 1 group of 4 children, and 2 children leave the game.\n\nIn the third round, 4 children form 1 group of 3 children, and 1 child leaves the game.\n\nIn the fourth round, 3 children form 1 group of 2 children, and 1 child leaves the game.\n\nThe last 2 children are declared the winners.\n\nSample Input 2\n\n5\n3 4 100 3 2\n\nSample Output 2\n\n-1\n\nThis situation is impossible.\nIn particular, if the game starts with less than 100 children, everyone leaves after the third round.\n\nSample Input 3\n\n10\n2 2 2 2 2 2 2 2 2 2\n\nSample Output 3\n\n2 3", "sample_input": "4\n3 4 3 2\n"}, "reference_outputs": ["6 8\n"], "source_document_id": "p03464", "source_text": "Score : 500 points\n\nProblem Statement\n\nAn adult game master and N children are playing a game on an ice rink.\nThe game consists of K rounds.\nIn the i-th round, the game master announces:\n\nForm groups consisting of A_i children each!\n\nThen the children who are still in the game form as many groups of A_i children as possible.\nOne child may belong to at most one group.\nThose who are left without a group leave the game. The others proceed to the next round.\nNote that it's possible that nobody leaves the game in some round.\n\nIn the end, after the K-th round, there are exactly two children left, and they are declared the winners.\n\nYou have heard the values of A_1, A_2, ..., A_K. You don't know N, but you want to estimate it.\n\nFind the smallest and the largest possible number of children in the game before the start, or determine that no valid values of N exist.\n\nConstraints\n\n1 \\leq K \\leq 10^5\n\n2 \\leq A_i \\leq 10^9\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nK\nA_1 A_2 ... A_K\n\nOutput\n\nPrint two integers representing the smallest and the largest possible value of N, respectively,\nor a single integer -1 if the described situation is impossible.\n\nSample Input 1\n\n4\n3 4 3 2\n\nSample Output 1\n\n6 8\n\nFor example, if the game starts with 6 children, then it proceeds as follows:\n\nIn the first round, 6 children form 2 groups of 3 children, and nobody leaves the game.\n\nIn the second round, 6 children form 1 group of 4 children, and 2 children leave the game.\n\nIn the third round, 4 children form 1 group of 3 children, and 1 child leaves the game.\n\nIn the fourth round, 3 children form 1 group of 2 children, and 1 child leaves the game.\n\nThe last 2 children are declared the winners.\n\nSample Input 2\n\n5\n3 4 100 3 2\n\nSample Output 2\n\n-1\n\nThis situation is impossible.\nIn particular, if the game starts with less than 100 children, everyone leaves after the third round.\n\nSample Input 3\n\n10\n2 2 2 2 2 2 2 2 2 2\n\nSample Output 3\n\n2 3", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 541, "cpu_time_ms": 63, "memory_kb": 2424}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s761462992", "group_id": "codeNet:p03464", "input_text": "local mfl, mce = math.floor, math.ceil\nlocal n = io.read(\"*n\")\nlocal t = {}\nfor i = 1, n do\n t[i] = io.read(\"*n\")\nend\nlocal curmin, curmax = 2, 2\n-- a[n] = k * t[n] + l (0 <= k, 0 <= l < t[n])\n-- a[n+1] = k * t[n]\nfor i = n, 1, -1 do\n local a = curmin\n local b = curmax + t[i] - 1\n if 1 < i then\n curmin = t[i - 1] * mce(a / t[i - 1])\n curmax = t[i - 1] * mfl(b / t[i - 1])\n else\n curmin, curmax = a, b\n end\nend\nif curmax < curmin then\n print(-1)\nelse\n print(curmin .. \" \" .. curmax)\nend\n", "language": "Lua", "metadata": {"date": 1568234526, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p03464.html", "problem_id": "p03464", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03464/input.txt", "sample_output_relpath": "derived/input_output/data/p03464/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03464/Lua/s761462992.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s761462992", "user_id": "u120582723"}, "prompt_components": {"gold_output": "6 8\n", "input_to_evaluate": "local mfl, mce = math.floor, math.ceil\nlocal n = io.read(\"*n\")\nlocal t = {}\nfor i = 1, n do\n t[i] = io.read(\"*n\")\nend\nlocal curmin, curmax = 2, 2\n-- a[n] = k * t[n] + l (0 <= k, 0 <= l < t[n])\n-- a[n+1] = k * t[n]\nfor i = n, 1, -1 do\n local a = curmin\n local b = curmax + t[i] - 1\n if 1 < i then\n curmin = t[i - 1] * mce(a / t[i - 1])\n curmax = t[i - 1] * mfl(b / t[i - 1])\n else\n curmin, curmax = a, b\n end\nend\nif curmax < curmin then\n print(-1)\nelse\n print(curmin .. \" \" .. curmax)\nend\n", "problem_context": "Score : 500 points\n\nProblem Statement\n\nAn adult game master and N children are playing a game on an ice rink.\nThe game consists of K rounds.\nIn the i-th round, the game master announces:\n\nForm groups consisting of A_i children each!\n\nThen the children who are still in the game form as many groups of A_i children as possible.\nOne child may belong to at most one group.\nThose who are left without a group leave the game. The others proceed to the next round.\nNote that it's possible that nobody leaves the game in some round.\n\nIn the end, after the K-th round, there are exactly two children left, and they are declared the winners.\n\nYou have heard the values of A_1, A_2, ..., A_K. You don't know N, but you want to estimate it.\n\nFind the smallest and the largest possible number of children in the game before the start, or determine that no valid values of N exist.\n\nConstraints\n\n1 \\leq K \\leq 10^5\n\n2 \\leq A_i \\leq 10^9\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nK\nA_1 A_2 ... A_K\n\nOutput\n\nPrint two integers representing the smallest and the largest possible value of N, respectively,\nor a single integer -1 if the described situation is impossible.\n\nSample Input 1\n\n4\n3 4 3 2\n\nSample Output 1\n\n6 8\n\nFor example, if the game starts with 6 children, then it proceeds as follows:\n\nIn the first round, 6 children form 2 groups of 3 children, and nobody leaves the game.\n\nIn the second round, 6 children form 1 group of 4 children, and 2 children leave the game.\n\nIn the third round, 4 children form 1 group of 3 children, and 1 child leaves the game.\n\nIn the fourth round, 3 children form 1 group of 2 children, and 1 child leaves the game.\n\nThe last 2 children are declared the winners.\n\nSample Input 2\n\n5\n3 4 100 3 2\n\nSample Output 2\n\n-1\n\nThis situation is impossible.\nIn particular, if the game starts with less than 100 children, everyone leaves after the third round.\n\nSample Input 3\n\n10\n2 2 2 2 2 2 2 2 2 2\n\nSample Output 3\n\n2 3", "sample_input": "4\n3 4 3 2\n"}, "reference_outputs": ["6 8\n"], "source_document_id": "p03464", "source_text": "Score : 500 points\n\nProblem Statement\n\nAn adult game master and N children are playing a game on an ice rink.\nThe game consists of K rounds.\nIn the i-th round, the game master announces:\n\nForm groups consisting of A_i children each!\n\nThen the children who are still in the game form as many groups of A_i children as possible.\nOne child may belong to at most one group.\nThose who are left without a group leave the game. The others proceed to the next round.\nNote that it's possible that nobody leaves the game in some round.\n\nIn the end, after the K-th round, there are exactly two children left, and they are declared the winners.\n\nYou have heard the values of A_1, A_2, ..., A_K. You don't know N, but you want to estimate it.\n\nFind the smallest and the largest possible number of children in the game before the start, or determine that no valid values of N exist.\n\nConstraints\n\n1 \\leq K \\leq 10^5\n\n2 \\leq A_i \\leq 10^9\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nK\nA_1 A_2 ... A_K\n\nOutput\n\nPrint two integers representing the smallest and the largest possible value of N, respectively,\nor a single integer -1 if the described situation is impossible.\n\nSample Input 1\n\n4\n3 4 3 2\n\nSample Output 1\n\n6 8\n\nFor example, if the game starts with 6 children, then it proceeds as follows:\n\nIn the first round, 6 children form 2 groups of 3 children, and nobody leaves the game.\n\nIn the second round, 6 children form 1 group of 4 children, and 2 children leave the game.\n\nIn the third round, 4 children form 1 group of 3 children, and 1 child leaves the game.\n\nIn the fourth round, 3 children form 1 group of 2 children, and 1 child leaves the game.\n\nThe last 2 children are declared the winners.\n\nSample Input 2\n\n5\n3 4 100 3 2\n\nSample Output 2\n\n-1\n\nThis situation is impossible.\nIn particular, if the game starts with less than 100 children, everyone leaves after the third round.\n\nSample Input 3\n\n10\n2 2 2 2 2 2 2 2 2 2\n\nSample Output 3\n\n2 3", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 505, "cpu_time_ms": 26, "memory_kb": 1280}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s896129057", "group_id": "codeNet:p03469", "input_text": "local S = io.read(\"*l\")\nlocal new_S = S:gsub(\"7\", \"8\", 1)\nprint(new_S)", "language": "Lua", "metadata": {"date": 1586653292, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p03469.html", "problem_id": "p03469", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03469/input.txt", "sample_output_relpath": "derived/input_output/data/p03469/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03469/Lua/s896129057.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s896129057", "user_id": "u793881115"}, "prompt_components": {"gold_output": "2018/01/07\n", "input_to_evaluate": "local S = io.read(\"*l\")\nlocal new_S = S:gsub(\"7\", \"8\", 1)\nprint(new_S)", "problem_context": "Score : 100 points\n\nProblem Statement\n\nOn some day in January 2018, Takaki is writing a document. The document has a column where the current date is written in yyyy/mm/dd format. For example, January 23, 2018 should be written as 2018/01/23.\n\nAfter finishing the document, she noticed that she had mistakenly wrote 2017 at the beginning of the date column. Write a program that, when the string that Takaki wrote in the date column, S, is given as input, modifies the first four characters in S to 2018 and prints it.\n\nConstraints\n\nS is a string of length 10.\n\nThe first eight characters in S are 2017/01/.\n\nThe last two characters in S are digits and represent an integer between 1 and 31 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nReplace the first four characters in S with 2018 and print it.\n\nSample Input 1\n\n2017/01/07\n\nSample Output 1\n\n2018/01/07\n\nSample Input 2\n\n2017/01/31\n\nSample Output 2\n\n2018/01/31", "sample_input": "2017/01/07\n"}, "reference_outputs": ["2018/01/07\n"], "source_document_id": "p03469", "source_text": "Score : 100 points\n\nProblem Statement\n\nOn some day in January 2018, Takaki is writing a document. The document has a column where the current date is written in yyyy/mm/dd format. For example, January 23, 2018 should be written as 2018/01/23.\n\nAfter finishing the document, she noticed that she had mistakenly wrote 2017 at the beginning of the date column. Write a program that, when the string that Takaki wrote in the date column, S, is given as input, modifies the first four characters in S to 2018 and prints it.\n\nConstraints\n\nS is a string of length 10.\n\nThe first eight characters in S are 2017/01/.\n\nThe last two characters in S are digits and represent an integer between 1 and 31 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nReplace the first four characters in S with 2018 and print it.\n\nSample Input 1\n\n2017/01/07\n\nSample Output 1\n\n2018/01/07\n\nSample Input 2\n\n2017/01/31\n\nSample Output 2\n\n2018/01/31", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 70, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s375212687", "group_id": "codeNet:p03469", "input_text": "print(io.read():gsub(\"2017\",\"2018\"))", "language": "Lua", "metadata": {"date": 1551838586, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03469.html", "problem_id": "p03469", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03469/input.txt", "sample_output_relpath": "derived/input_output/data/p03469/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03469/Lua/s375212687.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s375212687", "user_id": "u837412668"}, "prompt_components": {"gold_output": "2018/01/07\n", "input_to_evaluate": "print(io.read():gsub(\"2017\",\"2018\"))", "problem_context": "Score : 100 points\n\nProblem Statement\n\nOn some day in January 2018, Takaki is writing a document. The document has a column where the current date is written in yyyy/mm/dd format. For example, January 23, 2018 should be written as 2018/01/23.\n\nAfter finishing the document, she noticed that she had mistakenly wrote 2017 at the beginning of the date column. Write a program that, when the string that Takaki wrote in the date column, S, is given as input, modifies the first four characters in S to 2018 and prints it.\n\nConstraints\n\nS is a string of length 10.\n\nThe first eight characters in S are 2017/01/.\n\nThe last two characters in S are digits and represent an integer between 1 and 31 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nReplace the first four characters in S with 2018 and print it.\n\nSample Input 1\n\n2017/01/07\n\nSample Output 1\n\n2018/01/07\n\nSample Input 2\n\n2017/01/31\n\nSample Output 2\n\n2018/01/31", "sample_input": "2017/01/07\n"}, "reference_outputs": ["2018/01/07\n"], "source_document_id": "p03469", "source_text": "Score : 100 points\n\nProblem Statement\n\nOn some day in January 2018, Takaki is writing a document. The document has a column where the current date is written in yyyy/mm/dd format. For example, January 23, 2018 should be written as 2018/01/23.\n\nAfter finishing the document, she noticed that she had mistakenly wrote 2017 at the beginning of the date column. Write a program that, when the string that Takaki wrote in the date column, S, is given as input, modifies the first four characters in S to 2018 and prints it.\n\nConstraints\n\nS is a string of length 10.\n\nThe first eight characters in S are 2017/01/.\n\nThe last two characters in S are digits and represent an integer between 1 and 31 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nReplace the first four characters in S with 2018 and print it.\n\nSample Input 1\n\n2017/01/07\n\nSample Output 1\n\n2018/01/07\n\nSample Input 2\n\n2017/01/31\n\nSample Output 2\n\n2018/01/31", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 36, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s539963392", "group_id": "codeNet:p03470", "input_text": "n = io.read(\"*n\")\nt = {}\nfor i = 1, n do\n a = io.read(\"*n\")\n t[a] = true\nend\nc = 0\nfor k, v in pairs(t) do c = c + 1 end\nprint(c)\n", "language": "Lua", "metadata": {"date": 1594178895, "filename_ext": "lua", "original_language": "Lua (Lua 5.3.5)", "problem_description_relpath": "problem_descriptions/p03470.html", "problem_id": "p03470", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03470/input.txt", "sample_output_relpath": "derived/input_output/data/p03470/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03470/Lua/s539963392.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s539963392", "user_id": "u120582723"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "n = io.read(\"*n\")\nt = {}\nfor i = 1, n do\n a = io.read(\"*n\")\n t[a] = true\nend\nc = 0\nfor k, v in pairs(t) do c = c + 1 end\nprint(c)\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nAn X-layered kagami mochi (X ≥ 1) is a pile of X round mochi (rice cake) stacked vertically where each mochi (except the bottom one) has a smaller diameter than that of the mochi directly below it. For example, if you stack three mochi with diameters of 10, 8 and 6 centimeters from bottom to top in this order, you have a 3-layered kagami mochi; if you put just one mochi, you have a 1-layered kagami mochi.\n\nLunlun the dachshund has N round mochi, and the diameter of the i-th mochi is d_i centimeters. When we make a kagami mochi using some or all of them, at most how many layers can our kagami mochi have?\n\nConstraints\n\n1 ≤ N ≤ 100\n\n1 ≤ d_i ≤ 100\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nd_1\n:\nd_N\n\nOutput\n\nPrint the maximum number of layers in a kagami mochi that can be made.\n\nSample Input 1\n\n4\n10\n8\n8\n6\n\nSample Output 1\n\n3\n\nIf we stack the mochi with diameters of 10, 8 and 6 centimeters from bottom to top in this order, we have a 3-layered kagami mochi, which is the maximum number of layers.\n\nSample Input 2\n\n3\n15\n15\n15\n\nSample Output 2\n\n1\n\nWhen all the mochi have the same diameter, we can only have a 1-layered kagami mochi.\n\nSample Input 3\n\n7\n50\n30\n50\n100\n50\n80\n30\n\nSample Output 3\n\n4", "sample_input": "4\n10\n8\n8\n6\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03470", "source_text": "Score : 200 points\n\nProblem Statement\n\nAn X-layered kagami mochi (X ≥ 1) is a pile of X round mochi (rice cake) stacked vertically where each mochi (except the bottom one) has a smaller diameter than that of the mochi directly below it. For example, if you stack three mochi with diameters of 10, 8 and 6 centimeters from bottom to top in this order, you have a 3-layered kagami mochi; if you put just one mochi, you have a 1-layered kagami mochi.\n\nLunlun the dachshund has N round mochi, and the diameter of the i-th mochi is d_i centimeters. When we make a kagami mochi using some or all of them, at most how many layers can our kagami mochi have?\n\nConstraints\n\n1 ≤ N ≤ 100\n\n1 ≤ d_i ≤ 100\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nd_1\n:\nd_N\n\nOutput\n\nPrint the maximum number of layers in a kagami mochi that can be made.\n\nSample Input 1\n\n4\n10\n8\n8\n6\n\nSample Output 1\n\n3\n\nIf we stack the mochi with diameters of 10, 8 and 6 centimeters from bottom to top in this order, we have a 3-layered kagami mochi, which is the maximum number of layers.\n\nSample Input 2\n\n3\n15\n15\n15\n\nSample Output 2\n\n1\n\nWhen all the mochi have the same diameter, we can only have a 1-layered kagami mochi.\n\nSample Input 3\n\n7\n50\n30\n50\n100\n50\n80\n30\n\nSample Output 3\n\n4", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 132, "cpu_time_ms": 3, "memory_kb": 2776}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s163119628", "group_id": "codeNet:p03470", "input_text": "local n = io.read(\"*n\")\nlocal d = {}\nfor i = 1, n do\n local num = io.read(\"*n\")\n if d[num] == nil then\n d[num] = true\n end\nend\n\nlocal count = 0\nfor key, value in pairs(d) do\n count = count + 1\nend\nprint(count)", "language": "Lua", "metadata": {"date": 1586526724, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p03470.html", "problem_id": "p03470", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03470/input.txt", "sample_output_relpath": "derived/input_output/data/p03470/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03470/Lua/s163119628.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s163119628", "user_id": "u793881115"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "local n = io.read(\"*n\")\nlocal d = {}\nfor i = 1, n do\n local num = io.read(\"*n\")\n if d[num] == nil then\n d[num] = true\n end\nend\n\nlocal count = 0\nfor key, value in pairs(d) do\n count = count + 1\nend\nprint(count)", "problem_context": "Score : 200 points\n\nProblem Statement\n\nAn X-layered kagami mochi (X ≥ 1) is a pile of X round mochi (rice cake) stacked vertically where each mochi (except the bottom one) has a smaller diameter than that of the mochi directly below it. For example, if you stack three mochi with diameters of 10, 8 and 6 centimeters from bottom to top in this order, you have a 3-layered kagami mochi; if you put just one mochi, you have a 1-layered kagami mochi.\n\nLunlun the dachshund has N round mochi, and the diameter of the i-th mochi is d_i centimeters. When we make a kagami mochi using some or all of them, at most how many layers can our kagami mochi have?\n\nConstraints\n\n1 ≤ N ≤ 100\n\n1 ≤ d_i ≤ 100\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nd_1\n:\nd_N\n\nOutput\n\nPrint the maximum number of layers in a kagami mochi that can be made.\n\nSample Input 1\n\n4\n10\n8\n8\n6\n\nSample Output 1\n\n3\n\nIf we stack the mochi with diameters of 10, 8 and 6 centimeters from bottom to top in this order, we have a 3-layered kagami mochi, which is the maximum number of layers.\n\nSample Input 2\n\n3\n15\n15\n15\n\nSample Output 2\n\n1\n\nWhen all the mochi have the same diameter, we can only have a 1-layered kagami mochi.\n\nSample Input 3\n\n7\n50\n30\n50\n100\n50\n80\n30\n\nSample Output 3\n\n4", "sample_input": "4\n10\n8\n8\n6\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03470", "source_text": "Score : 200 points\n\nProblem Statement\n\nAn X-layered kagami mochi (X ≥ 1) is a pile of X round mochi (rice cake) stacked vertically where each mochi (except the bottom one) has a smaller diameter than that of the mochi directly below it. For example, if you stack three mochi with diameters of 10, 8 and 6 centimeters from bottom to top in this order, you have a 3-layered kagami mochi; if you put just one mochi, you have a 1-layered kagami mochi.\n\nLunlun the dachshund has N round mochi, and the diameter of the i-th mochi is d_i centimeters. When we make a kagami mochi using some or all of them, at most how many layers can our kagami mochi have?\n\nConstraints\n\n1 ≤ N ≤ 100\n\n1 ≤ d_i ≤ 100\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nd_1\n:\nd_N\n\nOutput\n\nPrint the maximum number of layers in a kagami mochi that can be made.\n\nSample Input 1\n\n4\n10\n8\n8\n6\n\nSample Output 1\n\n3\n\nIf we stack the mochi with diameters of 10, 8 and 6 centimeters from bottom to top in this order, we have a 3-layered kagami mochi, which is the maximum number of layers.\n\nSample Input 2\n\n3\n15\n15\n15\n\nSample Output 2\n\n1\n\nWhen all the mochi have the same diameter, we can only have a 1-layered kagami mochi.\n\nSample Input 3\n\n7\n50\n30\n50\n100\n50\n80\n30\n\nSample Output 3\n\n4", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 228, "cpu_time_ms": 2, "memory_kb": 256}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s737452428", "group_id": "codeNet:p03470", "input_text": "t = {}\nn = io.read(\"*n\")\ncnt = 0\nfor i = 1, n do\n a = io.read(\"*n\")\n if(t[a] == nil) then t[a], cnt = true, cnt + 1 end\nend\nprint(cnt)", "language": "Lua", "metadata": {"date": 1555248470, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p03470.html", "problem_id": "p03470", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03470/input.txt", "sample_output_relpath": "derived/input_output/data/p03470/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03470/Lua/s737452428.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s737452428", "user_id": "u120582723"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "t = {}\nn = io.read(\"*n\")\ncnt = 0\nfor i = 1, n do\n a = io.read(\"*n\")\n if(t[a] == nil) then t[a], cnt = true, cnt + 1 end\nend\nprint(cnt)", "problem_context": "Score : 200 points\n\nProblem Statement\n\nAn X-layered kagami mochi (X ≥ 1) is a pile of X round mochi (rice cake) stacked vertically where each mochi (except the bottom one) has a smaller diameter than that of the mochi directly below it. For example, if you stack three mochi with diameters of 10, 8 and 6 centimeters from bottom to top in this order, you have a 3-layered kagami mochi; if you put just one mochi, you have a 1-layered kagami mochi.\n\nLunlun the dachshund has N round mochi, and the diameter of the i-th mochi is d_i centimeters. When we make a kagami mochi using some or all of them, at most how many layers can our kagami mochi have?\n\nConstraints\n\n1 ≤ N ≤ 100\n\n1 ≤ d_i ≤ 100\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nd_1\n:\nd_N\n\nOutput\n\nPrint the maximum number of layers in a kagami mochi that can be made.\n\nSample Input 1\n\n4\n10\n8\n8\n6\n\nSample Output 1\n\n3\n\nIf we stack the mochi with diameters of 10, 8 and 6 centimeters from bottom to top in this order, we have a 3-layered kagami mochi, which is the maximum number of layers.\n\nSample Input 2\n\n3\n15\n15\n15\n\nSample Output 2\n\n1\n\nWhen all the mochi have the same diameter, we can only have a 1-layered kagami mochi.\n\nSample Input 3\n\n7\n50\n30\n50\n100\n50\n80\n30\n\nSample Output 3\n\n4", "sample_input": "4\n10\n8\n8\n6\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03470", "source_text": "Score : 200 points\n\nProblem Statement\n\nAn X-layered kagami mochi (X ≥ 1) is a pile of X round mochi (rice cake) stacked vertically where each mochi (except the bottom one) has a smaller diameter than that of the mochi directly below it. For example, if you stack three mochi with diameters of 10, 8 and 6 centimeters from bottom to top in this order, you have a 3-layered kagami mochi; if you put just one mochi, you have a 1-layered kagami mochi.\n\nLunlun the dachshund has N round mochi, and the diameter of the i-th mochi is d_i centimeters. When we make a kagami mochi using some or all of them, at most how many layers can our kagami mochi have?\n\nConstraints\n\n1 ≤ N ≤ 100\n\n1 ≤ d_i ≤ 100\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nd_1\n:\nd_N\n\nOutput\n\nPrint the maximum number of layers in a kagami mochi that can be made.\n\nSample Input 1\n\n4\n10\n8\n8\n6\n\nSample Output 1\n\n3\n\nIf we stack the mochi with diameters of 10, 8 and 6 centimeters from bottom to top in this order, we have a 3-layered kagami mochi, which is the maximum number of layers.\n\nSample Input 2\n\n3\n15\n15\n15\n\nSample Output 2\n\n1\n\nWhen all the mochi have the same diameter, we can only have a 1-layered kagami mochi.\n\nSample Input 3\n\n7\n50\n30\n50\n100\n50\n80\n30\n\nSample Output 3\n\n4", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 140, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s011795525", "group_id": "codeNet:p03470", "input_text": "local n = io.read(\"*n\")\nlocal arr\ndo\n local _accum_0 = { }\n local _len_0 = 1\n for i = 1, n do\n _accum_0[_len_0] = io.read(\"*n\")\n _len_0 = _len_0 + 1\n end\n arr = _accum_0\nend\ntable.sort(arr)\nlocal r = 1\nfor i = 2, n do\n if arr[i - 1] ~= arr[i] then\n r = r + 1\n end\nend\nreturn print(r)", "language": "Lua", "metadata": {"date": 1529109502, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p03470.html", "problem_id": "p03470", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03470/input.txt", "sample_output_relpath": "derived/input_output/data/p03470/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03470/Lua/s011795525.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s011795525", "user_id": "u280667879"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "local n = io.read(\"*n\")\nlocal arr\ndo\n local _accum_0 = { }\n local _len_0 = 1\n for i = 1, n do\n _accum_0[_len_0] = io.read(\"*n\")\n _len_0 = _len_0 + 1\n end\n arr = _accum_0\nend\ntable.sort(arr)\nlocal r = 1\nfor i = 2, n do\n if arr[i - 1] ~= arr[i] then\n r = r + 1\n end\nend\nreturn print(r)", "problem_context": "Score : 200 points\n\nProblem Statement\n\nAn X-layered kagami mochi (X ≥ 1) is a pile of X round mochi (rice cake) stacked vertically where each mochi (except the bottom one) has a smaller diameter than that of the mochi directly below it. For example, if you stack three mochi with diameters of 10, 8 and 6 centimeters from bottom to top in this order, you have a 3-layered kagami mochi; if you put just one mochi, you have a 1-layered kagami mochi.\n\nLunlun the dachshund has N round mochi, and the diameter of the i-th mochi is d_i centimeters. When we make a kagami mochi using some or all of them, at most how many layers can our kagami mochi have?\n\nConstraints\n\n1 ≤ N ≤ 100\n\n1 ≤ d_i ≤ 100\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nd_1\n:\nd_N\n\nOutput\n\nPrint the maximum number of layers in a kagami mochi that can be made.\n\nSample Input 1\n\n4\n10\n8\n8\n6\n\nSample Output 1\n\n3\n\nIf we stack the mochi with diameters of 10, 8 and 6 centimeters from bottom to top in this order, we have a 3-layered kagami mochi, which is the maximum number of layers.\n\nSample Input 2\n\n3\n15\n15\n15\n\nSample Output 2\n\n1\n\nWhen all the mochi have the same diameter, we can only have a 1-layered kagami mochi.\n\nSample Input 3\n\n7\n50\n30\n50\n100\n50\n80\n30\n\nSample Output 3\n\n4", "sample_input": "4\n10\n8\n8\n6\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03470", "source_text": "Score : 200 points\n\nProblem Statement\n\nAn X-layered kagami mochi (X ≥ 1) is a pile of X round mochi (rice cake) stacked vertically where each mochi (except the bottom one) has a smaller diameter than that of the mochi directly below it. For example, if you stack three mochi with diameters of 10, 8 and 6 centimeters from bottom to top in this order, you have a 3-layered kagami mochi; if you put just one mochi, you have a 1-layered kagami mochi.\n\nLunlun the dachshund has N round mochi, and the diameter of the i-th mochi is d_i centimeters. When we make a kagami mochi using some or all of them, at most how many layers can our kagami mochi have?\n\nConstraints\n\n1 ≤ N ≤ 100\n\n1 ≤ d_i ≤ 100\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nd_1\n:\nd_N\n\nOutput\n\nPrint the maximum number of layers in a kagami mochi that can be made.\n\nSample Input 1\n\n4\n10\n8\n8\n6\n\nSample Output 1\n\n3\n\nIf we stack the mochi with diameters of 10, 8 and 6 centimeters from bottom to top in this order, we have a 3-layered kagami mochi, which is the maximum number of layers.\n\nSample Input 2\n\n3\n15\n15\n15\n\nSample Output 2\n\n1\n\nWhen all the mochi have the same diameter, we can only have a 1-layered kagami mochi.\n\nSample Input 3\n\n7\n50\n30\n50\n100\n50\n80\n30\n\nSample Output 3\n\n4", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 299, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s121092919", "group_id": "codeNet:p03473", "input_text": "M = io.read(\"*n\")\nprint(M%24 + 24)", "language": "Lua", "metadata": {"date": 1565526362, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03473.html", "problem_id": "p03473", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03473/input.txt", "sample_output_relpath": "derived/input_output/data/p03473/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03473/Lua/s121092919.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s121092919", "user_id": "u318027064"}, "prompt_components": {"gold_output": "27\n", "input_to_evaluate": "M = io.read(\"*n\")\nprint(M%24 + 24)", "problem_context": "Score : 100 points\n\nProblem Statement\n\nHow many hours do we have until New Year at M o'clock (24-hour notation) on 30th, December?\n\nConstraints\n\n1≤M≤23\n\nM is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nM\n\nOutput\n\nIf we have x hours until New Year at M o'clock on 30th, December, print x.\n\nSample Input 1\n\n21\n\nSample Output 1\n\n27\n\nWe have 27 hours until New Year at 21 o'clock on 30th, December.\n\nSample Input 2\n\n12\n\nSample Output 2\n\n36", "sample_input": "21\n"}, "reference_outputs": ["27\n"], "source_document_id": "p03473", "source_text": "Score : 100 points\n\nProblem Statement\n\nHow many hours do we have until New Year at M o'clock (24-hour notation) on 30th, December?\n\nConstraints\n\n1≤M≤23\n\nM is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nM\n\nOutput\n\nIf we have x hours until New Year at M o'clock on 30th, December, print x.\n\nSample Input 1\n\n21\n\nSample Output 1\n\n27\n\nWe have 27 hours until New Year at 21 o'clock on 30th, December.\n\nSample Input 2\n\n12\n\nSample Output 2\n\n36", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 34, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s126330065", "group_id": "codeNet:p03473", "input_text": "M = io.read(\"*n\")\nprint(M + 24)", "language": "Lua", "metadata": {"date": 1565526324, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03473.html", "problem_id": "p03473", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03473/input.txt", "sample_output_relpath": "derived/input_output/data/p03473/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03473/Lua/s126330065.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s126330065", "user_id": "u318027064"}, "prompt_components": {"gold_output": "27\n", "input_to_evaluate": "M = io.read(\"*n\")\nprint(M + 24)", "problem_context": "Score : 100 points\n\nProblem Statement\n\nHow many hours do we have until New Year at M o'clock (24-hour notation) on 30th, December?\n\nConstraints\n\n1≤M≤23\n\nM is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nM\n\nOutput\n\nIf we have x hours until New Year at M o'clock on 30th, December, print x.\n\nSample Input 1\n\n21\n\nSample Output 1\n\n27\n\nWe have 27 hours until New Year at 21 o'clock on 30th, December.\n\nSample Input 2\n\n12\n\nSample Output 2\n\n36", "sample_input": "21\n"}, "reference_outputs": ["27\n"], "source_document_id": "p03473", "source_text": "Score : 100 points\n\nProblem Statement\n\nHow many hours do we have until New Year at M o'clock (24-hour notation) on 30th, December?\n\nConstraints\n\n1≤M≤23\n\nM is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nM\n\nOutput\n\nIf we have x hours until New Year at M o'clock on 30th, December, print x.\n\nSample Input 1\n\n21\n\nSample Output 1\n\n27\n\nWe have 27 hours until New Year at 21 o'clock on 30th, December.\n\nSample Input 2\n\n12\n\nSample Output 2\n\n36", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 31, "cpu_time_ms": 7, "memory_kb": 760}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s942142044", "group_id": "codeNet:p03474", "input_text": "A, B = io.read(\"*n\", \"*n\", \"*l\")\nS = io.read()\nif S == string.rep(\"%d\", A)..\"-\"..string.rep(\"%d\", B) and string.sub(S, A+1, A+1) == \"-\" and #S == A+B+1 then\n print(\"Yes\")\nelse\n print(\"No\")\nend", "language": "Lua", "metadata": {"date": 1587081377, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03474.html", "problem_id": "p03474", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03474/input.txt", "sample_output_relpath": "derived/input_output/data/p03474/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03474/Lua/s942142044.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s942142044", "user_id": "u045238009"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "A, B = io.read(\"*n\", \"*n\", \"*l\")\nS = io.read()\nif S == string.rep(\"%d\", A)..\"-\"..string.rep(\"%d\", B) and string.sub(S, A+1, A+1) == \"-\" and #S == A+B+1 then\n print(\"Yes\")\nelse\n print(\"No\")\nend", "problem_context": "Score : 200 points\n\nProblem Statement\n\nThe postal code in Atcoder Kingdom is A+B+1 characters long, its (A+1)-th character is a hyphen -, and the other characters are digits from 0 through 9.\n\nYou are given a string S. Determine whether it follows the postal code format in Atcoder Kingdom.\n\nConstraints\n\n1≤A,B≤5\n\n|S|=A+B+1\n\nS consists of - and digits from 0 through 9.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\nS\n\nOutput\n\nPrint Yes if S follows the postal code format in AtCoder Kingdom; print No otherwise.\n\nSample Input 1\n\n3 4\n269-6650\n\nSample Output 1\n\nYes\n\nThe (A+1)-th character of S is -, and the other characters are digits from 0 through 9, so it follows the format.\n\nSample Input 2\n\n1 1\n---\n\nSample Output 2\n\nNo\n\nS contains unnecessary -s other than the (A+1)-th character, so it does not follow the format.\n\nSample Input 3\n\n1 2\n7444\n\nSample Output 3\n\nNo", "sample_input": "3 4\n269-6650\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03474", "source_text": "Score : 200 points\n\nProblem Statement\n\nThe postal code in Atcoder Kingdom is A+B+1 characters long, its (A+1)-th character is a hyphen -, and the other characters are digits from 0 through 9.\n\nYou are given a string S. Determine whether it follows the postal code format in Atcoder Kingdom.\n\nConstraints\n\n1≤A,B≤5\n\n|S|=A+B+1\n\nS consists of - and digits from 0 through 9.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\nS\n\nOutput\n\nPrint Yes if S follows the postal code format in AtCoder Kingdom; print No otherwise.\n\nSample Input 1\n\n3 4\n269-6650\n\nSample Output 1\n\nYes\n\nThe (A+1)-th character of S is -, and the other characters are digits from 0 through 9, so it follows the format.\n\nSample Input 2\n\n1 1\n---\n\nSample Output 2\n\nNo\n\nS contains unnecessary -s other than the (A+1)-th character, so it does not follow the format.\n\nSample Input 3\n\n1 2\n7444\n\nSample Output 3\n\nNo", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 198, "cpu_time_ms": 10, "memory_kb": 1132}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s474971784", "group_id": "codeNet:p03474", "input_text": "A=io.read(\"n\")\nB=io.read(\"n\")\nS=io.read()\nlocal res=\"Yes\"\nfor i=1,#S do\n if i==A+1 then\n if string.sub(S,i,i)~=\"-\" then\n res=\"No\"\n end\n elseif string.sub(S,i,i)<\"0\" or string.sub(S,i,i)>\"9\" then\n res=\"No\"\n end\nend\nprint(res)\n\n", "language": "Lua", "metadata": {"date": 1551143493, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03474.html", "problem_id": "p03474", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03474/input.txt", "sample_output_relpath": "derived/input_output/data/p03474/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03474/Lua/s474971784.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s474971784", "user_id": "u015229643"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "A=io.read(\"n\")\nB=io.read(\"n\")\nS=io.read()\nlocal res=\"Yes\"\nfor i=1,#S do\n if i==A+1 then\n if string.sub(S,i,i)~=\"-\" then\n res=\"No\"\n end\n elseif string.sub(S,i,i)<\"0\" or string.sub(S,i,i)>\"9\" then\n res=\"No\"\n end\nend\nprint(res)\n\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nThe postal code in Atcoder Kingdom is A+B+1 characters long, its (A+1)-th character is a hyphen -, and the other characters are digits from 0 through 9.\n\nYou are given a string S. Determine whether it follows the postal code format in Atcoder Kingdom.\n\nConstraints\n\n1≤A,B≤5\n\n|S|=A+B+1\n\nS consists of - and digits from 0 through 9.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\nS\n\nOutput\n\nPrint Yes if S follows the postal code format in AtCoder Kingdom; print No otherwise.\n\nSample Input 1\n\n3 4\n269-6650\n\nSample Output 1\n\nYes\n\nThe (A+1)-th character of S is -, and the other characters are digits from 0 through 9, so it follows the format.\n\nSample Input 2\n\n1 1\n---\n\nSample Output 2\n\nNo\n\nS contains unnecessary -s other than the (A+1)-th character, so it does not follow the format.\n\nSample Input 3\n\n1 2\n7444\n\nSample Output 3\n\nNo", "sample_input": "3 4\n269-6650\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03474", "source_text": "Score : 200 points\n\nProblem Statement\n\nThe postal code in Atcoder Kingdom is A+B+1 characters long, its (A+1)-th character is a hyphen -, and the other characters are digits from 0 through 9.\n\nYou are given a string S. Determine whether it follows the postal code format in Atcoder Kingdom.\n\nConstraints\n\n1≤A,B≤5\n\n|S|=A+B+1\n\nS consists of - and digits from 0 through 9.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\nS\n\nOutput\n\nPrint Yes if S follows the postal code format in AtCoder Kingdom; print No otherwise.\n\nSample Input 1\n\n3 4\n269-6650\n\nSample Output 1\n\nYes\n\nThe (A+1)-th character of S is -, and the other characters are digits from 0 through 9, so it follows the format.\n\nSample Input 2\n\n1 1\n---\n\nSample Output 2\n\nNo\n\nS contains unnecessary -s other than the (A+1)-th character, so it does not follow the format.\n\nSample Input 3\n\n1 2\n7444\n\nSample Output 3\n\nNo", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 245, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s927804931", "group_id": "codeNet:p03475", "input_text": "local n = io.read(\"*n\")\nlocal c, s, f = {}, {}, {}\nfor i = 1, n - 1 do\n c[i], s[i], f[i] = io.read(\"*n\", \"*n\", \"*n\")\nend\nlocal mma = math.max\nfor i = 1, n - 1 do\n local cur = 0\n for j = i, n - 1 do\n cur = mma(s[j], (cur // f[j]) * f[j])\n cur = cur + c[j]\n end\n print(cur)\nend\nprint(0)", "language": "Lua", "metadata": {"date": 1597606734, "filename_ext": "lua", "original_language": "Lua (Lua 5.3.5)", "problem_description_relpath": "problem_descriptions/p03475.html", "problem_id": "p03475", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03475/input.txt", "sample_output_relpath": "derived/input_output/data/p03475/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03475/Lua/s927804931.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s927804931", "user_id": "u120582723"}, "prompt_components": {"gold_output": "12\n11\n0\n", "input_to_evaluate": "local n = io.read(\"*n\")\nlocal c, s, f = {}, {}, {}\nfor i = 1, n - 1 do\n c[i], s[i], f[i] = io.read(\"*n\", \"*n\", \"*n\")\nend\nlocal mma = math.max\nfor i = 1, n - 1 do\n local cur = 0\n for j = i, n - 1 do\n cur = mma(s[j], (cur // f[j]) * f[j])\n cur = cur + c[j]\n end\n print(cur)\nend\nprint(0)", "problem_context": "Score : 300 points\n\nProblem Statement\n\nA railroad running from west to east in Atcoder Kingdom is now complete.\n\nThere are N stations on the railroad, numbered 1 through N from west to east.\n\nTomorrow, the opening ceremony of the railroad will take place.\n\nOn this railroad, for each integer i such that 1≤i≤N-1, there will be trains that run from Station i to Station i+1 in C_i seconds. No other trains will be operated.\n\nThe first train from Station i to Station i+1 will depart Station i S_i seconds after the ceremony begins. Thereafter, there will be a train that departs Station i every F_i seconds.\n\nHere, it is guaranteed that F_i divides S_i.\n\nThat is, for each Time t satisfying S_i≤t and t%F_i=0, there will be a train that departs Station i t seconds after the ceremony begins and arrives at Station i+1 t+C_i seconds after the ceremony begins, where A%B denotes A modulo B, and there will be no other trains.\n\nFor each i, find the earliest possible time we can reach Station N if we are at Station i when the ceremony begins, ignoring the time needed to change trains.\n\nConstraints\n\n1≤N≤500\n\n1≤C_i≤100\n\n1≤S_i≤10^5\n\n1≤F_i≤10\n\nS_i%F_i=0\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nC_1 S_1 F_1\n:\nC_{N-1} S_{N-1} F_{N-1}\n\nOutput\n\nPrint N lines. Assuming that we are at Station i (1≤i≤N) when the ceremony begins, if the earliest possible time we can reach Station N is x seconds after the ceremony begins, the i-th line should contain x.\n\nSample Input 1\n\n3\n6 5 1\n1 10 1\n\nSample Output 1\n\n12\n11\n0\n\nWe will travel from Station 1 as follows:\n\n5 seconds after the beginning: take the train to Station 2.\n\n11 seconds: arrive at Station 2.\n\n11 seconds: take the train to Station 3.\n\n12 seconds: arrive at Station 3.\n\nWe will travel from Station 2 as follows:\n\n10 seconds: take the train to Station 3.\n\n11 seconds: arrive at Station 3.\n\nNote that we should print 0 for Station 3.\n\nSample Input 2\n\n4\n12 24 6\n52 16 4\n99 2 2\n\nSample Output 2\n\n187\n167\n101\n0\n\nSample Input 3\n\n4\n12 13 1\n44 17 17\n66 4096 64\n\nSample Output 3\n\n4162\n4162\n4162\n0", "sample_input": "3\n6 5 1\n1 10 1\n"}, "reference_outputs": ["12\n11\n0\n"], "source_document_id": "p03475", "source_text": "Score : 300 points\n\nProblem Statement\n\nA railroad running from west to east in Atcoder Kingdom is now complete.\n\nThere are N stations on the railroad, numbered 1 through N from west to east.\n\nTomorrow, the opening ceremony of the railroad will take place.\n\nOn this railroad, for each integer i such that 1≤i≤N-1, there will be trains that run from Station i to Station i+1 in C_i seconds. No other trains will be operated.\n\nThe first train from Station i to Station i+1 will depart Station i S_i seconds after the ceremony begins. Thereafter, there will be a train that departs Station i every F_i seconds.\n\nHere, it is guaranteed that F_i divides S_i.\n\nThat is, for each Time t satisfying S_i≤t and t%F_i=0, there will be a train that departs Station i t seconds after the ceremony begins and arrives at Station i+1 t+C_i seconds after the ceremony begins, where A%B denotes A modulo B, and there will be no other trains.\n\nFor each i, find the earliest possible time we can reach Station N if we are at Station i when the ceremony begins, ignoring the time needed to change trains.\n\nConstraints\n\n1≤N≤500\n\n1≤C_i≤100\n\n1≤S_i≤10^5\n\n1≤F_i≤10\n\nS_i%F_i=0\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nC_1 S_1 F_1\n:\nC_{N-1} S_{N-1} F_{N-1}\n\nOutput\n\nPrint N lines. Assuming that we are at Station i (1≤i≤N) when the ceremony begins, if the earliest possible time we can reach Station N is x seconds after the ceremony begins, the i-th line should contain x.\n\nSample Input 1\n\n3\n6 5 1\n1 10 1\n\nSample Output 1\n\n12\n11\n0\n\nWe will travel from Station 1 as follows:\n\n5 seconds after the beginning: take the train to Station 2.\n\n11 seconds: arrive at Station 2.\n\n11 seconds: take the train to Station 3.\n\n12 seconds: arrive at Station 3.\n\nWe will travel from Station 2 as follows:\n\n10 seconds: take the train to Station 3.\n\n11 seconds: arrive at Station 3.\n\nNote that we should print 0 for Station 3.\n\nSample Input 2\n\n4\n12 24 6\n52 16 4\n99 2 2\n\nSample Output 2\n\n187\n167\n101\n0\n\nSample Input 3\n\n4\n12 13 1\n44 17 17\n66 4096 64\n\nSample Output 3\n\n4162\n4162\n4162\n0", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 295, "cpu_time_ms": 28, "memory_kb": 2728}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s068251103", "group_id": "codeNet:p03476", "input_text": "Q=io.read(\"n\")\nl={}\nr={}\nfor i=1,Q do\n l[i]=io.read(\"n\")\n r[i]=io.read(\"n\")\nend\nfunction prime(o)\n local res=true\n if o>2 then\n for i=2,o/2 do\n if o%i==0 then\n res=false\n end\n end\n end\n return res\nend\nfor i=1,Q do\n local count=0\n for j=l[i],r[i],2 do\n if prime(j) and prime((j+1)//2) then\n count=count+1\n end\n end\n print(count)\nend", "language": "Lua", "metadata": {"date": 1551146958, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03476.html", "problem_id": "p03476", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03476/input.txt", "sample_output_relpath": "derived/input_output/data/p03476/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03476/Lua/s068251103.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s068251103", "user_id": "u015229643"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "Q=io.read(\"n\")\nl={}\nr={}\nfor i=1,Q do\n l[i]=io.read(\"n\")\n r[i]=io.read(\"n\")\nend\nfunction prime(o)\n local res=true\n if o>2 then\n for i=2,o/2 do\n if o%i==0 then\n res=false\n end\n end\n end\n return res\nend\nfor i=1,Q do\n local count=0\n for j=l[i],r[i],2 do\n if prime(j) and prime((j+1)//2) then\n count=count+1\n end\n end\n print(count)\nend", "problem_context": "Score : 400 points\n\nProblem Statement\n\nWe say that a odd number N is similar to 2017 when both N and (N+1)/2 are prime.\n\nYou are given Q queries.\n\nIn the i-th query, given two odd numbers l_i and r_i, find the number of odd numbers x similar to 2017 such that l_i ≤ x ≤ r_i.\n\nConstraints\n\n1≤Q≤10^5\n\n1≤l_i≤r_i≤10^5\n\nl_i and r_i are odd.\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nQ\nl_1 r_1\n:\nl_Q r_Q\n\nOutput\n\nPrint Q lines. The i-th line (1≤i≤Q) should contain the response to the i-th query.\n\nSample Input 1\n\n1\n3 7\n\nSample Output 1\n\n2\n\n3 is similar to 2017, since both 3 and (3+1)/2=2 are prime.\n\n5 is similar to 2017, since both 5 and (5+1)/2=3 are prime.\n\n7 is not similar to 2017, since (7+1)/2=4 is not prime, although 7 is prime.\n\nThus, the response to the first query should be 2.\n\nSample Input 2\n\n4\n13 13\n7 11\n7 11\n2017 2017\n\nSample Output 2\n\n1\n0\n0\n1\n\nNote that 2017 is also similar to 2017.\n\nSample Input 3\n\n6\n1 53\n13 91\n37 55\n19 51\n73 91\n13 49\n\nSample Output 3\n\n4\n4\n1\n1\n1\n2", "sample_input": "1\n3 7\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03476", "source_text": "Score : 400 points\n\nProblem Statement\n\nWe say that a odd number N is similar to 2017 when both N and (N+1)/2 are prime.\n\nYou are given Q queries.\n\nIn the i-th query, given two odd numbers l_i and r_i, find the number of odd numbers x similar to 2017 such that l_i ≤ x ≤ r_i.\n\nConstraints\n\n1≤Q≤10^5\n\n1≤l_i≤r_i≤10^5\n\nl_i and r_i are odd.\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nQ\nl_1 r_1\n:\nl_Q r_Q\n\nOutput\n\nPrint Q lines. The i-th line (1≤i≤Q) should contain the response to the i-th query.\n\nSample Input 1\n\n1\n3 7\n\nSample Output 1\n\n2\n\n3 is similar to 2017, since both 3 and (3+1)/2=2 are prime.\n\n5 is similar to 2017, since both 5 and (5+1)/2=3 are prime.\n\n7 is not similar to 2017, since (7+1)/2=4 is not prime, although 7 is prime.\n\nThus, the response to the first query should be 2.\n\nSample Input 2\n\n4\n13 13\n7 11\n7 11\n2017 2017\n\nSample Output 2\n\n1\n0\n0\n1\n\nNote that 2017 is also similar to 2017.\n\nSample Input 3\n\n6\n1 53\n13 91\n37 55\n19 51\n73 91\n13 49\n\nSample Output 3\n\n4\n4\n1\n1\n1\n2", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 376, "cpu_time_ms": 2103, "memory_kb": 4444}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s263765851", "group_id": "codeNet:p03476", "input_text": "Q=io.read(\"n\")\nl={}\nr={}\nfor i=1,Q do\n l[i]=io.read(\"n\")\n r[i]=io.read(\"n\")\nend\nfunction prime(o)\n local res=true\n if o==1 or o==2 then\n return res\n elseif o>2 then\n for i=2,o-1 do\n if o%i==0 then\n res=false\n end\n end\n return res\n end\nend\nfor i=1,Q do\n local count=0\n for j=l[i],r[i] do\n if prime(j) and prime((j+1)//2) then\n count=count+1\n end\n end\n print(count)\nend", "language": "Lua", "metadata": {"date": 1551146145, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03476.html", "problem_id": "p03476", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03476/input.txt", "sample_output_relpath": "derived/input_output/data/p03476/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03476/Lua/s263765851.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s263765851", "user_id": "u015229643"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "Q=io.read(\"n\")\nl={}\nr={}\nfor i=1,Q do\n l[i]=io.read(\"n\")\n r[i]=io.read(\"n\")\nend\nfunction prime(o)\n local res=true\n if o==1 or o==2 then\n return res\n elseif o>2 then\n for i=2,o-1 do\n if o%i==0 then\n res=false\n end\n end\n return res\n end\nend\nfor i=1,Q do\n local count=0\n for j=l[i],r[i] do\n if prime(j) and prime((j+1)//2) then\n count=count+1\n end\n end\n print(count)\nend", "problem_context": "Score : 400 points\n\nProblem Statement\n\nWe say that a odd number N is similar to 2017 when both N and (N+1)/2 are prime.\n\nYou are given Q queries.\n\nIn the i-th query, given two odd numbers l_i and r_i, find the number of odd numbers x similar to 2017 such that l_i ≤ x ≤ r_i.\n\nConstraints\n\n1≤Q≤10^5\n\n1≤l_i≤r_i≤10^5\n\nl_i and r_i are odd.\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nQ\nl_1 r_1\n:\nl_Q r_Q\n\nOutput\n\nPrint Q lines. The i-th line (1≤i≤Q) should contain the response to the i-th query.\n\nSample Input 1\n\n1\n3 7\n\nSample Output 1\n\n2\n\n3 is similar to 2017, since both 3 and (3+1)/2=2 are prime.\n\n5 is similar to 2017, since both 5 and (5+1)/2=3 are prime.\n\n7 is not similar to 2017, since (7+1)/2=4 is not prime, although 7 is prime.\n\nThus, the response to the first query should be 2.\n\nSample Input 2\n\n4\n13 13\n7 11\n7 11\n2017 2017\n\nSample Output 2\n\n1\n0\n0\n1\n\nNote that 2017 is also similar to 2017.\n\nSample Input 3\n\n6\n1 53\n13 91\n37 55\n19 51\n73 91\n13 49\n\nSample Output 3\n\n4\n4\n1\n1\n1\n2", "sample_input": "1\n3 7\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03476", "source_text": "Score : 400 points\n\nProblem Statement\n\nWe say that a odd number N is similar to 2017 when both N and (N+1)/2 are prime.\n\nYou are given Q queries.\n\nIn the i-th query, given two odd numbers l_i and r_i, find the number of odd numbers x similar to 2017 such that l_i ≤ x ≤ r_i.\n\nConstraints\n\n1≤Q≤10^5\n\n1≤l_i≤r_i≤10^5\n\nl_i and r_i are odd.\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nQ\nl_1 r_1\n:\nl_Q r_Q\n\nOutput\n\nPrint Q lines. The i-th line (1≤i≤Q) should contain the response to the i-th query.\n\nSample Input 1\n\n1\n3 7\n\nSample Output 1\n\n2\n\n3 is similar to 2017, since both 3 and (3+1)/2=2 are prime.\n\n5 is similar to 2017, since both 5 and (5+1)/2=3 are prime.\n\n7 is not similar to 2017, since (7+1)/2=4 is not prime, although 7 is prime.\n\nThus, the response to the first query should be 2.\n\nSample Input 2\n\n4\n13 13\n7 11\n7 11\n2017 2017\n\nSample Output 2\n\n1\n0\n0\n1\n\nNote that 2017 is also similar to 2017.\n\nSample Input 3\n\n6\n1 53\n13 91\n37 55\n19 51\n73 91\n13 49\n\nSample Output 3\n\n4\n4\n1\n1\n1\n2", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 417, "cpu_time_ms": 2104, "memory_kb": 4444}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s002404843", "group_id": "codeNet:p03477", "input_text": "a,b,c,d=io.read():match(\"(.+)%s(.+)%s(.+)%s(.+)\")\nprint(a+b==c+d and\"Balanced\"or a+b>c+d and\"Left\"or\"Right\")", "language": "Lua", "metadata": {"date": 1551838390, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p03477.html", "problem_id": "p03477", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03477/input.txt", "sample_output_relpath": "derived/input_output/data/p03477/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03477/Lua/s002404843.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s002404843", "user_id": "u837412668"}, "prompt_components": {"gold_output": "Left\n", "input_to_evaluate": "a,b,c,d=io.read():match(\"(.+)%s(.+)%s(.+)%s(.+)\")\nprint(a+b==c+d and\"Balanced\"or a+b>c+d and\"Left\"or\"Right\")", "problem_context": "Score : 100 points\n\nProblem Statement\n\nA balance scale tips to the left if L>R, where L is the total weight of the masses on the left pan and R is the total weight of the masses on the right pan. Similarly, it balances if L=R, and tips to the right if L8, we should print Left.\n\nSample Input 2\n\n3 4 5 2\n\nSample Output 2\n\nBalanced\n\nThe total weight of the masses on the left pan is 7, and the total weight of the masses on the right pan is 7. Since 7=7, we should print Balanced.\n\nSample Input 3\n\n1 7 6 4\n\nSample Output 3\n\nRight\n\nThe total weight of the masses on the left pan is 8, and the total weight of the masses on the right pan is 10. Since 8<10, we should print Right.", "sample_input": "3 8 7 1\n"}, "reference_outputs": ["Left\n"], "source_document_id": "p03477", "source_text": "Score : 100 points\n\nProblem Statement\n\nA balance scale tips to the left if L>R, where L is the total weight of the masses on the left pan and R is the total weight of the masses on the right pan. Similarly, it balances if L=R, and tips to the right if L8, we should print Left.\n\nSample Input 2\n\n3 4 5 2\n\nSample Output 2\n\nBalanced\n\nThe total weight of the masses on the left pan is 7, and the total weight of the masses on the right pan is 7. Since 7=7, we should print Balanced.\n\nSample Input 3\n\n1 7 6 4\n\nSample Output 3\n\nRight\n\nThe total weight of the masses on the left pan is 8, and the total weight of the masses on the right pan is 10. Since 8<10, we should print Right.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 108, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s879910103", "group_id": "codeNet:p03477", "input_text": "a,b,c,d=io.read():match(\"(.+)%s(.+)%s(.+)%s(.+)\")\nprint(a+b==c+d and\"Balanced\"or a+b>c+d and\"Left\"or\"Right\")", "language": "Lua", "metadata": {"date": 1551838371, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03477.html", "problem_id": "p03477", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03477/input.txt", "sample_output_relpath": "derived/input_output/data/p03477/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03477/Lua/s879910103.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s879910103", "user_id": "u837412668"}, "prompt_components": {"gold_output": "Left\n", "input_to_evaluate": "a,b,c,d=io.read():match(\"(.+)%s(.+)%s(.+)%s(.+)\")\nprint(a+b==c+d and\"Balanced\"or a+b>c+d and\"Left\"or\"Right\")", "problem_context": "Score : 100 points\n\nProblem Statement\n\nA balance scale tips to the left if L>R, where L is the total weight of the masses on the left pan and R is the total weight of the masses on the right pan. Similarly, it balances if L=R, and tips to the right if L8, we should print Left.\n\nSample Input 2\n\n3 4 5 2\n\nSample Output 2\n\nBalanced\n\nThe total weight of the masses on the left pan is 7, and the total weight of the masses on the right pan is 7. Since 7=7, we should print Balanced.\n\nSample Input 3\n\n1 7 6 4\n\nSample Output 3\n\nRight\n\nThe total weight of the masses on the left pan is 8, and the total weight of the masses on the right pan is 10. Since 8<10, we should print Right.", "sample_input": "3 8 7 1\n"}, "reference_outputs": ["Left\n"], "source_document_id": "p03477", "source_text": "Score : 100 points\n\nProblem Statement\n\nA balance scale tips to the left if L>R, where L is the total weight of the masses on the left pan and R is the total weight of the masses on the right pan. Similarly, it balances if L=R, and tips to the right if L8, we should print Left.\n\nSample Input 2\n\n3 4 5 2\n\nSample Output 2\n\nBalanced\n\nThe total weight of the masses on the left pan is 7, and the total weight of the masses on the right pan is 7. Since 7=7, we should print Balanced.\n\nSample Input 3\n\n1 7 6 4\n\nSample Output 3\n\nRight\n\nThe total weight of the masses on the left pan is 8, and the total weight of the masses on the right pan is 10. Since 8<10, we should print Right.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 108, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s902947652", "group_id": "codeNet:p03477", "input_text": "A,B,C,D=io.read(\"n\",\"n\",\"n\",\"n\")\nif A+B>C+D then\n print(\"Left\")\n elseif A+B==C+D then\n print(\"Balanced\")\n else \n print(\"Right\")\nend", "language": "Lua", "metadata": {"date": 1551147983, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03477.html", "problem_id": "p03477", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03477/input.txt", "sample_output_relpath": "derived/input_output/data/p03477/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03477/Lua/s902947652.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s902947652", "user_id": "u015229643"}, "prompt_components": {"gold_output": "Left\n", "input_to_evaluate": "A,B,C,D=io.read(\"n\",\"n\",\"n\",\"n\")\nif A+B>C+D then\n print(\"Left\")\n elseif A+B==C+D then\n print(\"Balanced\")\n else \n print(\"Right\")\nend", "problem_context": "Score : 100 points\n\nProblem Statement\n\nA balance scale tips to the left if L>R, where L is the total weight of the masses on the left pan and R is the total weight of the masses on the right pan. Similarly, it balances if L=R, and tips to the right if L8, we should print Left.\n\nSample Input 2\n\n3 4 5 2\n\nSample Output 2\n\nBalanced\n\nThe total weight of the masses on the left pan is 7, and the total weight of the masses on the right pan is 7. Since 7=7, we should print Balanced.\n\nSample Input 3\n\n1 7 6 4\n\nSample Output 3\n\nRight\n\nThe total weight of the masses on the left pan is 8, and the total weight of the masses on the right pan is 10. Since 8<10, we should print Right.", "sample_input": "3 8 7 1\n"}, "reference_outputs": ["Left\n"], "source_document_id": "p03477", "source_text": "Score : 100 points\n\nProblem Statement\n\nA balance scale tips to the left if L>R, where L is the total weight of the masses on the left pan and R is the total weight of the masses on the right pan. Similarly, it balances if L=R, and tips to the right if L8, we should print Left.\n\nSample Input 2\n\n3 4 5 2\n\nSample Output 2\n\nBalanced\n\nThe total weight of the masses on the left pan is 7, and the total weight of the masses on the right pan is 7. Since 7=7, we should print Balanced.\n\nSample Input 3\n\n1 7 6 4\n\nSample Output 3\n\nRight\n\nThe total weight of the masses on the left pan is 8, and the total weight of the masses on the right pan is 10. Since 8<10, we should print Right.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 136, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s168208838", "group_id": "codeNet:p03480", "input_text": "local s = io.read()\nlocal n = #s\nlocal prv = s:sub(1, 1)\nlocal nxt = \"\"\nlocal from = 1\nlocal ret = 1\nlocal mma, mmi = math.max, math.min\nfor i = 2, n do\n nxt = s:sub(i, i)\n if prv ~= nxt then\n ret = mma(ret, mmi(i - 1, n + 1 - from))\n prv = nxt\n from = i\n end\nend\nret = mma(ret, mmi(n, n + 1 - from))\nprint(ret)\n", "language": "Lua", "metadata": {"date": 1568170596, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03480.html", "problem_id": "p03480", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03480/input.txt", "sample_output_relpath": "derived/input_output/data/p03480/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03480/Lua/s168208838.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s168208838", "user_id": "u120582723"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "local s = io.read()\nlocal n = #s\nlocal prv = s:sub(1, 1)\nlocal nxt = \"\"\nlocal from = 1\nlocal ret = 1\nlocal mma, mmi = math.max, math.min\nfor i = 2, n do\n nxt = s:sub(i, i)\n if prv ~= nxt then\n ret = mma(ret, mmi(i - 1, n + 1 - from))\n prv = nxt\n from = i\n end\nend\nret = mma(ret, mmi(n, n + 1 - from))\nprint(ret)\n", "problem_context": "Score : 500 points\n\nProblem Statement\n\nYou are given a string S consisting of 0 and 1.\nFind the maximum integer K not greater than |S| such that we can turn all the characters of S into 0 by repeating the following operation some number of times.\n\nChoose a contiguous segment [l,r] in S whose length is at least K (that is, r-l+1\\geq K must be satisfied). For each integer i such that l\\leq i\\leq r, do the following: if S_i is 0, replace it with 1; if S_i is 1, replace it with 0.\n\nConstraints\n\n1\\leq |S|\\leq 10^5\n\nS_i(1\\leq i\\leq N) is either 0 or 1.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the maximum integer K such that we can turn all the characters of S into 0 by repeating the operation some number of times.\n\nSample Input 1\n\n010\n\nSample Output 1\n\n2\n\nWe can turn all the characters of S into 0 by the following operations:\n\nPerform the operation on the segment S[1,3] with length 3. S is now 101.\n\nPerform the operation on the segment S[1,2] with length 2. S is now 011.\n\nPerform the operation on the segment S[2,3] with length 2. S is now 000.\n\nSample Input 2\n\n100000000\n\nSample Output 2\n\n8\n\nSample Input 3\n\n00001111\n\nSample Output 3\n\n4", "sample_input": "010\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03480", "source_text": "Score : 500 points\n\nProblem Statement\n\nYou are given a string S consisting of 0 and 1.\nFind the maximum integer K not greater than |S| such that we can turn all the characters of S into 0 by repeating the following operation some number of times.\n\nChoose a contiguous segment [l,r] in S whose length is at least K (that is, r-l+1\\geq K must be satisfied). For each integer i such that l\\leq i\\leq r, do the following: if S_i is 0, replace it with 1; if S_i is 1, replace it with 0.\n\nConstraints\n\n1\\leq |S|\\leq 10^5\n\nS_i(1\\leq i\\leq N) is either 0 or 1.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the maximum integer K such that we can turn all the characters of S into 0 by repeating the operation some number of times.\n\nSample Input 1\n\n010\n\nSample Output 1\n\n2\n\nWe can turn all the characters of S into 0 by the following operations:\n\nPerform the operation on the segment S[1,3] with length 3. S is now 101.\n\nPerform the operation on the segment S[1,2] with length 2. S is now 011.\n\nPerform the operation on the segment S[2,3] with length 2. S is now 000.\n\nSample Input 2\n\n100000000\n\nSample Output 2\n\n8\n\nSample Input 3\n\n00001111\n\nSample Output 3\n\n4", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 324, "cpu_time_ms": 25, "memory_kb": 1008}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s275078773", "group_id": "codeNet:p03481", "input_text": "x,y=io.read(\"*n\",\"*n\")\nprint(math.floor(math.log(math.floor(y/x),2)+1))", "language": "Lua", "metadata": {"date": 1587420031, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03481.html", "problem_id": "p03481", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03481/input.txt", "sample_output_relpath": "derived/input_output/data/p03481/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03481/Lua/s275078773.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s275078773", "user_id": "u045238009"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "x,y=io.read(\"*n\",\"*n\")\nprint(math.floor(math.log(math.floor(y/x),2)+1))", "problem_context": "Score : 300 points\n\nProblem Statement\n\nAs a token of his gratitude, Takahashi has decided to give his mother an integer sequence.\nThe sequence A needs to satisfy the conditions below:\n\nA consists of integers between X and Y (inclusive).\n\nFor each 1\\leq i \\leq |A|-1, A_{i+1} is a multiple of A_i and strictly greater than A_i.\n\nFind the maximum possible length of the sequence.\n\nConstraints\n\n1 \\leq X \\leq Y \\leq 10^{18}\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX Y\n\nOutput\n\nPrint the maximum possible length of the sequence.\n\nSample Input 1\n\n3 20\n\nSample Output 1\n\n3\n\nThe sequence 3,6,18 satisfies the conditions.\n\nSample Input 2\n\n25 100\n\nSample Output 2\n\n3\n\nSample Input 3\n\n314159265 358979323846264338\n\nSample Output 3\n\n31", "sample_input": "3 20\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03481", "source_text": "Score : 300 points\n\nProblem Statement\n\nAs a token of his gratitude, Takahashi has decided to give his mother an integer sequence.\nThe sequence A needs to satisfy the conditions below:\n\nA consists of integers between X and Y (inclusive).\n\nFor each 1\\leq i \\leq |A|-1, A_{i+1} is a multiple of A_i and strictly greater than A_i.\n\nFind the maximum possible length of the sequence.\n\nConstraints\n\n1 \\leq X \\leq Y \\leq 10^{18}\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX Y\n\nOutput\n\nPrint the maximum possible length of the sequence.\n\nSample Input 1\n\n3 20\n\nSample Output 1\n\n3\n\nThe sequence 3,6,18 satisfies the conditions.\n\nSample Input 2\n\n25 100\n\nSample Output 2\n\n3\n\nSample Input 3\n\n314159265 358979323846264338\n\nSample Output 3\n\n31", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 71, "cpu_time_ms": 8, "memory_kb": 756}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s915587259", "group_id": "codeNet:p03481", "input_text": "x,y=io.read(\"*n\",\"*n\")\nprint(math.log(y/x,2)+1)", "language": "Lua", "metadata": {"date": 1587419794, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03481.html", "problem_id": "p03481", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03481/input.txt", "sample_output_relpath": "derived/input_output/data/p03481/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03481/Lua/s915587259.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s915587259", "user_id": "u045238009"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "x,y=io.read(\"*n\",\"*n\")\nprint(math.log(y/x,2)+1)", "problem_context": "Score : 300 points\n\nProblem Statement\n\nAs a token of his gratitude, Takahashi has decided to give his mother an integer sequence.\nThe sequence A needs to satisfy the conditions below:\n\nA consists of integers between X and Y (inclusive).\n\nFor each 1\\leq i \\leq |A|-1, A_{i+1} is a multiple of A_i and strictly greater than A_i.\n\nFind the maximum possible length of the sequence.\n\nConstraints\n\n1 \\leq X \\leq Y \\leq 10^{18}\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX Y\n\nOutput\n\nPrint the maximum possible length of the sequence.\n\nSample Input 1\n\n3 20\n\nSample Output 1\n\n3\n\nThe sequence 3,6,18 satisfies the conditions.\n\nSample Input 2\n\n25 100\n\nSample Output 2\n\n3\n\nSample Input 3\n\n314159265 358979323846264338\n\nSample Output 3\n\n31", "sample_input": "3 20\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03481", "source_text": "Score : 300 points\n\nProblem Statement\n\nAs a token of his gratitude, Takahashi has decided to give his mother an integer sequence.\nThe sequence A needs to satisfy the conditions below:\n\nA consists of integers between X and Y (inclusive).\n\nFor each 1\\leq i \\leq |A|-1, A_{i+1} is a multiple of A_i and strictly greater than A_i.\n\nFind the maximum possible length of the sequence.\n\nConstraints\n\n1 \\leq X \\leq Y \\leq 10^{18}\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX Y\n\nOutput\n\nPrint the maximum possible length of the sequence.\n\nSample Input 1\n\n3 20\n\nSample Output 1\n\n3\n\nThe sequence 3,6,18 satisfies the conditions.\n\nSample Input 2\n\n25 100\n\nSample Output 2\n\n3\n\nSample Input 3\n\n314159265 358979323846264338\n\nSample Output 3\n\n31", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 47, "cpu_time_ms": 9, "memory_kb": 880}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s093047938", "group_id": "codeNet:p03481", "input_text": "x,y=io.read(\"*n\",\"*n\")\ncounter=0\nwhile x<=y do\n x=x*2\n counter=counter+1\nend\nprint(counter)", "language": "Lua", "metadata": {"date": 1587419586, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03481.html", "problem_id": "p03481", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03481/input.txt", "sample_output_relpath": "derived/input_output/data/p03481/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03481/Lua/s093047938.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s093047938", "user_id": "u045238009"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "x,y=io.read(\"*n\",\"*n\")\ncounter=0\nwhile x<=y do\n x=x*2\n counter=counter+1\nend\nprint(counter)", "problem_context": "Score : 300 points\n\nProblem Statement\n\nAs a token of his gratitude, Takahashi has decided to give his mother an integer sequence.\nThe sequence A needs to satisfy the conditions below:\n\nA consists of integers between X and Y (inclusive).\n\nFor each 1\\leq i \\leq |A|-1, A_{i+1} is a multiple of A_i and strictly greater than A_i.\n\nFind the maximum possible length of the sequence.\n\nConstraints\n\n1 \\leq X \\leq Y \\leq 10^{18}\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX Y\n\nOutput\n\nPrint the maximum possible length of the sequence.\n\nSample Input 1\n\n3 20\n\nSample Output 1\n\n3\n\nThe sequence 3,6,18 satisfies the conditions.\n\nSample Input 2\n\n25 100\n\nSample Output 2\n\n3\n\nSample Input 3\n\n314159265 358979323846264338\n\nSample Output 3\n\n31", "sample_input": "3 20\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03481", "source_text": "Score : 300 points\n\nProblem Statement\n\nAs a token of his gratitude, Takahashi has decided to give his mother an integer sequence.\nThe sequence A needs to satisfy the conditions below:\n\nA consists of integers between X and Y (inclusive).\n\nFor each 1\\leq i \\leq |A|-1, A_{i+1} is a multiple of A_i and strictly greater than A_i.\n\nFind the maximum possible length of the sequence.\n\nConstraints\n\n1 \\leq X \\leq Y \\leq 10^{18}\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX Y\n\nOutput\n\nPrint the maximum possible length of the sequence.\n\nSample Input 1\n\n3 20\n\nSample Output 1\n\n3\n\nThe sequence 3,6,18 satisfies the conditions.\n\nSample Input 2\n\n25 100\n\nSample Output 2\n\n3\n\nSample Input 3\n\n314159265 358979323846264338\n\nSample Output 3\n\n31", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 97, "cpu_time_ms": 6, "memory_kb": 888}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s485844783", "group_id": "codeNet:p03481", "input_text": "x,y=io.read(\"*n\",\"*n\")\ncounter=0\nwhile x <\n\nx, y = io.read('n'), io.read('n')\n\nans = 0\nwhile x <= y do\n ans = ans + 1\n x = x * 2\nend\n\nprint(ans)\n", "language": "Lua", "metadata": {"date": 1514140913, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03481.html", "problem_id": "p03481", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03481/input.txt", "sample_output_relpath": "derived/input_output/data/p03481/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03481/Lua/s682032646.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s682032646", "user_id": "u785421275"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "-- > <\n\nx, y = io.read('n'), io.read('n')\n\nans = 0\nwhile x <= y do\n ans = ans + 1\n x = x * 2\nend\n\nprint(ans)\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nAs a token of his gratitude, Takahashi has decided to give his mother an integer sequence.\nThe sequence A needs to satisfy the conditions below:\n\nA consists of integers between X and Y (inclusive).\n\nFor each 1\\leq i \\leq |A|-1, A_{i+1} is a multiple of A_i and strictly greater than A_i.\n\nFind the maximum possible length of the sequence.\n\nConstraints\n\n1 \\leq X \\leq Y \\leq 10^{18}\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX Y\n\nOutput\n\nPrint the maximum possible length of the sequence.\n\nSample Input 1\n\n3 20\n\nSample Output 1\n\n3\n\nThe sequence 3,6,18 satisfies the conditions.\n\nSample Input 2\n\n25 100\n\nSample Output 2\n\n3\n\nSample Input 3\n\n314159265 358979323846264338\n\nSample Output 3\n\n31", "sample_input": "3 20\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03481", "source_text": "Score : 300 points\n\nProblem Statement\n\nAs a token of his gratitude, Takahashi has decided to give his mother an integer sequence.\nThe sequence A needs to satisfy the conditions below:\n\nA consists of integers between X and Y (inclusive).\n\nFor each 1\\leq i \\leq |A|-1, A_{i+1} is a multiple of A_i and strictly greater than A_i.\n\nFind the maximum possible length of the sequence.\n\nConstraints\n\n1 \\leq X \\leq Y \\leq 10^{18}\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX Y\n\nOutput\n\nPrint the maximum possible length of the sequence.\n\nSample Input 1\n\n3 20\n\nSample Output 1\n\n3\n\nThe sequence 3,6,18 satisfies the conditions.\n\nSample Input 2\n\n25 100\n\nSample Output 2\n\n3\n\nSample Input 3\n\n314159265 358979323846264338\n\nSample Output 3\n\n31", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 115, "cpu_time_ms": 8, "memory_kb": 760}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s913101462", "group_id": "codeNet:p03485", "input_text": "a, b = io.read(\"*n\", \"*n\")\nprint(math.ceil((a + b) / 2))\n", "language": "Lua", "metadata": {"date": 1594178712, "filename_ext": "lua", "original_language": "Lua (Lua 5.3.5)", "problem_description_relpath": "problem_descriptions/p03485.html", "problem_id": "p03485", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03485/input.txt", "sample_output_relpath": "derived/input_output/data/p03485/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03485/Lua/s913101462.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s913101462", "user_id": "u120582723"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "a, b = io.read(\"*n\", \"*n\")\nprint(math.ceil((a + b) / 2))\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nYou are given two positive integers a and b.\nLet x be the average of a and b.\nPrint x rounded up to the nearest integer.\n\nConstraints\n\na and b are integers.\n\n1 \\leq a, b \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\na b\n\nOutput\n\nPrint x rounded up to the nearest integer.\n\nSample Input 1\n\n1 3\n\nSample Output 1\n\n2\n\nThe average of 1 and 3 is 2.0, and it will be rounded up to the nearest integer, 2.\n\nSample Input 2\n\n7 4\n\nSample Output 2\n\n6\n\nThe average of 7 and 4 is 5.5, and it will be rounded up to the nearest integer, 6.\n\nSample Input 3\n\n5 5\n\nSample Output 3\n\n5", "sample_input": "1 3\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03485", "source_text": "Score : 100 points\n\nProblem Statement\n\nYou are given two positive integers a and b.\nLet x be the average of a and b.\nPrint x rounded up to the nearest integer.\n\nConstraints\n\na and b are integers.\n\n1 \\leq a, b \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\na b\n\nOutput\n\nPrint x rounded up to the nearest integer.\n\nSample Input 1\n\n1 3\n\nSample Output 1\n\n2\n\nThe average of 1 and 3 is 2.0, and it will be rounded up to the nearest integer, 2.\n\nSample Input 2\n\n7 4\n\nSample Output 2\n\n6\n\nThe average of 7 and 4 is 5.5, and it will be rounded up to the nearest integer, 6.\n\nSample Input 3\n\n5 5\n\nSample Output 3\n\n5", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 57, "cpu_time_ms": 5, "memory_kb": 2648}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s228700507", "group_id": "codeNet:p03485", "input_text": "a=io.read(\"n\")\nb=io.read(\"n\")\nprint(math.ceil((a+b)/2))", "language": "Lua", "metadata": {"date": 1551212814, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03485.html", "problem_id": "p03485", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03485/input.txt", "sample_output_relpath": "derived/input_output/data/p03485/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03485/Lua/s228700507.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s228700507", "user_id": "u015229643"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "a=io.read(\"n\")\nb=io.read(\"n\")\nprint(math.ceil((a+b)/2))", "problem_context": "Score : 100 points\n\nProblem Statement\n\nYou are given two positive integers a and b.\nLet x be the average of a and b.\nPrint x rounded up to the nearest integer.\n\nConstraints\n\na and b are integers.\n\n1 \\leq a, b \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\na b\n\nOutput\n\nPrint x rounded up to the nearest integer.\n\nSample Input 1\n\n1 3\n\nSample Output 1\n\n2\n\nThe average of 1 and 3 is 2.0, and it will be rounded up to the nearest integer, 2.\n\nSample Input 2\n\n7 4\n\nSample Output 2\n\n6\n\nThe average of 7 and 4 is 5.5, and it will be rounded up to the nearest integer, 6.\n\nSample Input 3\n\n5 5\n\nSample Output 3\n\n5", "sample_input": "1 3\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03485", "source_text": "Score : 100 points\n\nProblem Statement\n\nYou are given two positive integers a and b.\nLet x be the average of a and b.\nPrint x rounded up to the nearest integer.\n\nConstraints\n\na and b are integers.\n\n1 \\leq a, b \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\na b\n\nOutput\n\nPrint x rounded up to the nearest integer.\n\nSample Input 1\n\n1 3\n\nSample Output 1\n\n2\n\nThe average of 1 and 3 is 2.0, and it will be rounded up to the nearest integer, 2.\n\nSample Input 2\n\n7 4\n\nSample Output 2\n\n6\n\nThe average of 7 and 4 is 5.5, and it will be rounded up to the nearest integer, 6.\n\nSample Input 3\n\n5 5\n\nSample Output 3\n\n5", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 55, "cpu_time_ms": 8, "memory_kb": 888}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s802817913", "group_id": "codeNet:p03487", "input_text": "n = io.read(\"*n\")\nrem = 0\nt = {}\ns = {}\nfor i = 1, n do\n a = io.read(\"*n\")\n if(n < a) then\n rem = rem + 1\n elseif(s[a] ~= nil) then\n rem = rem + 1\n else\n if(t[a] == nil) then\n t[a] = 1\n else\n t[a] = t[a] + 1\n end\n if(t[a] == a) then\n s[a] = true\n t[a] = 0\n end\n end\nend\nfor k, v in pairs(t) do\n rem = rem + v\nend\nprint(rem)", "language": "Lua", "metadata": {"date": 1554695241, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p03487.html", "problem_id": "p03487", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03487/input.txt", "sample_output_relpath": "derived/input_output/data/p03487/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03487/Lua/s802817913.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s802817913", "user_id": "u120582723"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "n = io.read(\"*n\")\nrem = 0\nt = {}\ns = {}\nfor i = 1, n do\n a = io.read(\"*n\")\n if(n < a) then\n rem = rem + 1\n elseif(s[a] ~= nil) then\n rem = rem + 1\n else\n if(t[a] == nil) then\n t[a] = 1\n else\n t[a] = t[a] + 1\n end\n if(t[a] == a) then\n s[a] = true\n t[a] = 0\n end\n end\nend\nfor k, v in pairs(t) do\n rem = rem + v\nend\nprint(rem)", "problem_context": "Score : 300 points\n\nProblem Statement\n\nYou are given a sequence of positive integers of length N, a = (a_1, a_2, ..., a_N).\nYour objective is to remove some of the elements in a so that a will be a good sequence.\n\nHere, an sequence b is a good sequence when the following condition holds true:\n\nFor each element x in b, the value x occurs exactly x times in b.\n\nFor example, (3, 3, 3), (4, 2, 4, 1, 4, 2, 4) and () (an empty sequence) are good sequences, while (3, 3, 3, 3) and (2, 4, 1, 4, 2) are not.\n\nFind the minimum number of elements that needs to be removed so that a will be a good sequence.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\na_i is an integer.\n\n1 \\leq a_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 ... a_N\n\nOutput\n\nPrint the minimum number of elements that needs to be removed so that a will be a good sequence.\n\nSample Input 1\n\n4\n3 3 3 3\n\nSample Output 1\n\n1\n\nWe can, for example, remove one occurrence of 3. Then, (3, 3, 3) is a good sequence.\n\nSample Input 2\n\n5\n2 4 1 4 2\n\nSample Output 2\n\n2\n\nWe can, for example, remove two occurrences of 4. Then, (2, 1, 2) is a good sequence.\n\nSample Input 3\n\n6\n1 2 2 3 3 3\n\nSample Output 3\n\n0\n\nSample Input 4\n\n1\n1000000000\n\nSample Output 4\n\n1\n\nRemove one occurrence of 10^9. Then, () is a good sequence.\n\nSample Input 5\n\n8\n2 7 1 8 2 8 1 8\n\nSample Output 5\n\n5", "sample_input": "4\n3 3 3 3\n"}, "reference_outputs": ["1\n"], "source_document_id": "p03487", "source_text": "Score : 300 points\n\nProblem Statement\n\nYou are given a sequence of positive integers of length N, a = (a_1, a_2, ..., a_N).\nYour objective is to remove some of the elements in a so that a will be a good sequence.\n\nHere, an sequence b is a good sequence when the following condition holds true:\n\nFor each element x in b, the value x occurs exactly x times in b.\n\nFor example, (3, 3, 3), (4, 2, 4, 1, 4, 2, 4) and () (an empty sequence) are good sequences, while (3, 3, 3, 3) and (2, 4, 1, 4, 2) are not.\n\nFind the minimum number of elements that needs to be removed so that a will be a good sequence.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\na_i is an integer.\n\n1 \\leq a_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 ... a_N\n\nOutput\n\nPrint the minimum number of elements that needs to be removed so that a will be a good sequence.\n\nSample Input 1\n\n4\n3 3 3 3\n\nSample Output 1\n\n1\n\nWe can, for example, remove one occurrence of 3. Then, (3, 3, 3) is a good sequence.\n\nSample Input 2\n\n5\n2 4 1 4 2\n\nSample Output 2\n\n2\n\nWe can, for example, remove two occurrences of 4. Then, (2, 1, 2) is a good sequence.\n\nSample Input 3\n\n6\n1 2 2 3 3 3\n\nSample Output 3\n\n0\n\nSample Input 4\n\n1\n1000000000\n\nSample Output 4\n\n1\n\nRemove one occurrence of 10^9. Then, () is a good sequence.\n\nSample Input 5\n\n8\n2 7 1 8 2 8 1 8\n\nSample Output 5\n\n5", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 434, "cpu_time_ms": 40, "memory_kb": 256}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s891514207", "group_id": "codeNet:p03487", "input_text": "N=io.read(\"n\")\nlocal a={}\nlocal t={}\nfor i=1,N do\n a[i]=io.read(\"n\")\n t[a[i]]=(t[a[i]] or 0)+1\nend\nlocal count=0\nfor i,v in pairs(t) do\n if iv then\n count=count+v\n end\nend\nprint(count)", "language": "Lua", "metadata": {"date": 1551216414, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03487.html", "problem_id": "p03487", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03487/input.txt", "sample_output_relpath": "derived/input_output/data/p03487/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03487/Lua/s891514207.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s891514207", "user_id": "u015229643"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "N=io.read(\"n\")\nlocal a={}\nlocal t={}\nfor i=1,N do\n a[i]=io.read(\"n\")\n t[a[i]]=(t[a[i]] or 0)+1\nend\nlocal count=0\nfor i,v in pairs(t) do\n if iv then\n count=count+v\n end\nend\nprint(count)", "problem_context": "Score : 300 points\n\nProblem Statement\n\nYou are given a sequence of positive integers of length N, a = (a_1, a_2, ..., a_N).\nYour objective is to remove some of the elements in a so that a will be a good sequence.\n\nHere, an sequence b is a good sequence when the following condition holds true:\n\nFor each element x in b, the value x occurs exactly x times in b.\n\nFor example, (3, 3, 3), (4, 2, 4, 1, 4, 2, 4) and () (an empty sequence) are good sequences, while (3, 3, 3, 3) and (2, 4, 1, 4, 2) are not.\n\nFind the minimum number of elements that needs to be removed so that a will be a good sequence.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\na_i is an integer.\n\n1 \\leq a_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 ... a_N\n\nOutput\n\nPrint the minimum number of elements that needs to be removed so that a will be a good sequence.\n\nSample Input 1\n\n4\n3 3 3 3\n\nSample Output 1\n\n1\n\nWe can, for example, remove one occurrence of 3. Then, (3, 3, 3) is a good sequence.\n\nSample Input 2\n\n5\n2 4 1 4 2\n\nSample Output 2\n\n2\n\nWe can, for example, remove two occurrences of 4. Then, (2, 1, 2) is a good sequence.\n\nSample Input 3\n\n6\n1 2 2 3 3 3\n\nSample Output 3\n\n0\n\nSample Input 4\n\n1\n1000000000\n\nSample Output 4\n\n1\n\nRemove one occurrence of 10^9. Then, () is a good sequence.\n\nSample Input 5\n\n8\n2 7 1 8 2 8 1 8\n\nSample Output 5\n\n5", "sample_input": "4\n3 3 3 3\n"}, "reference_outputs": ["1\n"], "source_document_id": "p03487", "source_text": "Score : 300 points\n\nProblem Statement\n\nYou are given a sequence of positive integers of length N, a = (a_1, a_2, ..., a_N).\nYour objective is to remove some of the elements in a so that a will be a good sequence.\n\nHere, an sequence b is a good sequence when the following condition holds true:\n\nFor each element x in b, the value x occurs exactly x times in b.\n\nFor example, (3, 3, 3), (4, 2, 4, 1, 4, 2, 4) and () (an empty sequence) are good sequences, while (3, 3, 3, 3) and (2, 4, 1, 4, 2) are not.\n\nFind the minimum number of elements that needs to be removed so that a will be a good sequence.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\na_i is an integer.\n\n1 \\leq a_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 ... a_N\n\nOutput\n\nPrint the minimum number of elements that needs to be removed so that a will be a good sequence.\n\nSample Input 1\n\n4\n3 3 3 3\n\nSample Output 1\n\n1\n\nWe can, for example, remove one occurrence of 3. Then, (3, 3, 3) is a good sequence.\n\nSample Input 2\n\n5\n2 4 1 4 2\n\nSample Output 2\n\n2\n\nWe can, for example, remove two occurrences of 4. Then, (2, 1, 2) is a good sequence.\n\nSample Input 3\n\n6\n1 2 2 3 3 3\n\nSample Output 3\n\n0\n\nSample Input 4\n\n1\n1000000000\n\nSample Output 4\n\n1\n\nRemove one occurrence of 10^9. Then, () is a good sequence.\n\nSample Input 5\n\n8\n2 7 1 8 2 8 1 8\n\nSample Output 5\n\n5", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 234, "cpu_time_ms": 54, "memory_kb": 8808}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s937001588", "group_id": "codeNet:p03488", "input_text": "S=io.read()\nx=io.read()\ny=io.read()\nlocal xcount=0\nlocal ycount=0\nlocal swap=0\nfor i=1,#S do\n if string.sub(S,i,i)==\"F\" then\n xcount=xcount+1\n end\n if string.sub(S,i,i)==\"T\" then\n xcount,ycount=ycount,xcount\n swap=swap+1\n end\nend\nif swap%2==1 then \n xcount,ycount=ycount,xcount\nend\nif xcount>math.abs(x) and (xcount-math.abs(x))%2==0 and ycount>math.abs(y) and (ycount-math.abs(y))%2==0 then\n print(\"Yes\")\n else\n print(\"No\")\nend ", "language": "Lua", "metadata": {"date": 1551219342, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03488.html", "problem_id": "p03488", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03488/input.txt", "sample_output_relpath": "derived/input_output/data/p03488/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03488/Lua/s937001588.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s937001588", "user_id": "u015229643"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "S=io.read()\nx=io.read()\ny=io.read()\nlocal xcount=0\nlocal ycount=0\nlocal swap=0\nfor i=1,#S do\n if string.sub(S,i,i)==\"F\" then\n xcount=xcount+1\n end\n if string.sub(S,i,i)==\"T\" then\n xcount,ycount=ycount,xcount\n swap=swap+1\n end\nend\nif swap%2==1 then \n xcount,ycount=ycount,xcount\nend\nif xcount>math.abs(x) and (xcount-math.abs(x))%2==0 and ycount>math.abs(y) and (ycount-math.abs(y))%2==0 then\n print(\"Yes\")\n else\n print(\"No\")\nend ", "problem_context": "Score : 500 points\n\nProblem Statement\n\nA robot is put at the origin in a two-dimensional plane.\nInitially, the robot is facing in the positive x-axis direction.\n\nThis robot will be given an instruction sequence s.\ns consists of the following two kinds of letters, and will be executed in order from front to back.\n\nF : Move in the current direction by distance 1.\n\nT : Turn 90 degrees, either clockwise or counterclockwise.\n\nThe objective of the robot is to be at coordinates (x, y) after all the instructions are executed.\nDetermine whether this objective is achievable.\n\nConstraints\n\ns consists of F and T.\n\n1 \\leq |s| \\leq 8 000\n\nx and y are integers.\n\n|x|, |y| \\leq |s|\n\nInput\n\nInput is given from Standard Input in the following format:\n\ns\nx y\n\nOutput\n\nIf the objective is achievable, print Yes; if it is not, print No.\n\nSample Input 1\n\nFTFFTFFF\n4 2\n\nSample Output 1\n\nYes\n\nThe objective can be achieved by, for example, turning counterclockwise in the first T and turning clockwise in the second T.\n\nSample Input 2\n\nFTFFTFFF\n-2 -2\n\nSample Output 2\n\nYes\n\nThe objective can be achieved by, for example, turning clockwise in the first T and turning clockwise in the second T.\n\nSample Input 3\n\nFF\n1 0\n\nSample Output 3\n\nNo\n\nSample Input 4\n\nTF\n1 0\n\nSample Output 4\n\nNo\n\nSample Input 5\n\nFFTTFF\n0 0\n\nSample Output 5\n\nYes\n\nThe objective can be achieved by, for example, turning counterclockwise in the first T and turning counterclockwise in the second T.\n\nSample Input 6\n\nTTTT\n1 0\n\nSample Output 6\n\nNo", "sample_input": "FTFFTFFF\n4 2\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03488", "source_text": "Score : 500 points\n\nProblem Statement\n\nA robot is put at the origin in a two-dimensional plane.\nInitially, the robot is facing in the positive x-axis direction.\n\nThis robot will be given an instruction sequence s.\ns consists of the following two kinds of letters, and will be executed in order from front to back.\n\nF : Move in the current direction by distance 1.\n\nT : Turn 90 degrees, either clockwise or counterclockwise.\n\nThe objective of the robot is to be at coordinates (x, y) after all the instructions are executed.\nDetermine whether this objective is achievable.\n\nConstraints\n\ns consists of F and T.\n\n1 \\leq |s| \\leq 8 000\n\nx and y are integers.\n\n|x|, |y| \\leq |s|\n\nInput\n\nInput is given from Standard Input in the following format:\n\ns\nx y\n\nOutput\n\nIf the objective is achievable, print Yes; if it is not, print No.\n\nSample Input 1\n\nFTFFTFFF\n4 2\n\nSample Output 1\n\nYes\n\nThe objective can be achieved by, for example, turning counterclockwise in the first T and turning clockwise in the second T.\n\nSample Input 2\n\nFTFFTFFF\n-2 -2\n\nSample Output 2\n\nYes\n\nThe objective can be achieved by, for example, turning clockwise in the first T and turning clockwise in the second T.\n\nSample Input 3\n\nFF\n1 0\n\nSample Output 3\n\nNo\n\nSample Input 4\n\nTF\n1 0\n\nSample Output 4\n\nNo\n\nSample Input 5\n\nFFTTFF\n0 0\n\nSample Output 5\n\nYes\n\nThe objective can be achieved by, for example, turning counterclockwise in the first T and turning counterclockwise in the second T.\n\nSample Input 6\n\nTTTT\n1 0\n\nSample Output 6\n\nNo", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 448, "cpu_time_ms": 4, "memory_kb": 256}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s369397057", "group_id": "codeNet:p03490", "input_text": "local str = io.read()\nlocal finalA = io.read(\"*n\")\nlocal finalB = io.read(\"*n\")\n\nlocal tb = {}\nlocal numT = 0\nfor i = 1, string.len(str) do\n if string.sub(str,i,i) == \"F\" then\n numT = numT + 1\n end\n table.insert(tb,string.sub(str,i,i))\nend\n\nif finalA + finalB > numT then\n print(\"No\")\n return\nend\n\nlocal dirTb = {\n {0,1},\n {0,-1},\n {-1,0},\n {1,0}\n}\n\nlocal turnTb = {\n {3,4},\n {3,4},\n {1,2},\n {1,2}\n}\nlocal function digui( a,b,idx,curDir )\n if a == finalA and b == finalB and idx == #tb + 1 then\n return true\n end\n\n if idx > #tb then\n return false\n end\n\n if math.abs(a) > #tb or math.abs(b) > #tb then\n return false\n end\n\n if tb[idx] == 'F' then\n return digui(a+dirTb[curDir][1],b+dirTb[curDir][2],idx+1,curDir)\n else\n return digui(a,b,idx+1,turnTb[curDir][1]) or digui(a,b,idx+1,turnTb[curDir][2]) \n end\n\nend\n\nlocal f = digui(0,0,1,4)\nprint(f and \"Yes\" or \"No\")", "language": "Lua", "metadata": {"date": 1594181061, "filename_ext": "lua", "original_language": "Lua (Lua 5.3.5)", "problem_description_relpath": "problem_descriptions/p03490.html", "problem_id": "p03490", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03490/input.txt", "sample_output_relpath": "derived/input_output/data/p03490/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03490/Lua/s369397057.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s369397057", "user_id": "u089230684"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "local str = io.read()\nlocal finalA = io.read(\"*n\")\nlocal finalB = io.read(\"*n\")\n\nlocal tb = {}\nlocal numT = 0\nfor i = 1, string.len(str) do\n if string.sub(str,i,i) == \"F\" then\n numT = numT + 1\n end\n table.insert(tb,string.sub(str,i,i))\nend\n\nif finalA + finalB > numT then\n print(\"No\")\n return\nend\n\nlocal dirTb = {\n {0,1},\n {0,-1},\n {-1,0},\n {1,0}\n}\n\nlocal turnTb = {\n {3,4},\n {3,4},\n {1,2},\n {1,2}\n}\nlocal function digui( a,b,idx,curDir )\n if a == finalA and b == finalB and idx == #tb + 1 then\n return true\n end\n\n if idx > #tb then\n return false\n end\n\n if math.abs(a) > #tb or math.abs(b) > #tb then\n return false\n end\n\n if tb[idx] == 'F' then\n return digui(a+dirTb[curDir][1],b+dirTb[curDir][2],idx+1,curDir)\n else\n return digui(a,b,idx+1,turnTb[curDir][1]) or digui(a,b,idx+1,turnTb[curDir][2]) \n end\n\nend\n\nlocal f = digui(0,0,1,4)\nprint(f and \"Yes\" or \"No\")", "problem_context": "Score : 500 points\n\nProblem Statement\n\nA robot is put at the origin in a two-dimensional plane.\nInitially, the robot is facing in the positive x-axis direction.\n\nThis robot will be given an instruction sequence s.\ns consists of the following two kinds of letters, and will be executed in order from front to back.\n\nF : Move in the current direction by distance 1.\n\nT : Turn 90 degrees, either clockwise or counterclockwise.\n\nThe objective of the robot is to be at coordinates (x, y) after all the instructions are executed.\nDetermine whether this objective is achievable.\n\nConstraints\n\ns consists of F and T.\n\n1 \\leq |s| \\leq 8 000\n\nx and y are integers.\n\n|x|, |y| \\leq |s|\n\nInput\n\nInput is given from Standard Input in the following format:\n\ns\nx y\n\nOutput\n\nIf the objective is achievable, print Yes; if it is not, print No.\n\nSample Input 1\n\nFTFFTFFF\n4 2\n\nSample Output 1\n\nYes\n\nThe objective can be achieved by, for example, turning counterclockwise in the first T and turning clockwise in the second T.\n\nSample Input 2\n\nFTFFTFFF\n-2 -2\n\nSample Output 2\n\nYes\n\nThe objective can be achieved by, for example, turning clockwise in the first T and turning clockwise in the second T.\n\nSample Input 3\n\nFF\n1 0\n\nSample Output 3\n\nNo\n\nSample Input 4\n\nTF\n1 0\n\nSample Output 4\n\nNo\n\nSample Input 5\n\nFFTTFF\n0 0\n\nSample Output 5\n\nYes\n\nThe objective can be achieved by, for example, turning counterclockwise in the first T and turning counterclockwise in the second T.\n\nSample Input 6\n\nTTTT\n1 0\n\nSample Output 6\n\nNo", "sample_input": "FTFFTFFF\n4 2\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03490", "source_text": "Score : 500 points\n\nProblem Statement\n\nA robot is put at the origin in a two-dimensional plane.\nInitially, the robot is facing in the positive x-axis direction.\n\nThis robot will be given an instruction sequence s.\ns consists of the following two kinds of letters, and will be executed in order from front to back.\n\nF : Move in the current direction by distance 1.\n\nT : Turn 90 degrees, either clockwise or counterclockwise.\n\nThe objective of the robot is to be at coordinates (x, y) after all the instructions are executed.\nDetermine whether this objective is achievable.\n\nConstraints\n\ns consists of F and T.\n\n1 \\leq |s| \\leq 8 000\n\nx and y are integers.\n\n|x|, |y| \\leq |s|\n\nInput\n\nInput is given from Standard Input in the following format:\n\ns\nx y\n\nOutput\n\nIf the objective is achievable, print Yes; if it is not, print No.\n\nSample Input 1\n\nFTFFTFFF\n4 2\n\nSample Output 1\n\nYes\n\nThe objective can be achieved by, for example, turning counterclockwise in the first T and turning clockwise in the second T.\n\nSample Input 2\n\nFTFFTFFF\n-2 -2\n\nSample Output 2\n\nYes\n\nThe objective can be achieved by, for example, turning clockwise in the first T and turning clockwise in the second T.\n\nSample Input 3\n\nFF\n1 0\n\nSample Output 3\n\nNo\n\nSample Input 4\n\nTF\n1 0\n\nSample Output 4\n\nNo\n\nSample Input 5\n\nFFTTFF\n0 0\n\nSample Output 5\n\nYes\n\nThe objective can be achieved by, for example, turning counterclockwise in the first T and turning counterclockwise in the second T.\n\nSample Input 6\n\nTTTT\n1 0\n\nSample Output 6\n\nNo", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 969, "cpu_time_ms": 2205, "memory_kb": 3752}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s382637318", "group_id": "codeNet:p03490", "input_text": "local str = io.read()\nio.read(\"*l\")\nlocal finalA = io.read(\"*n\")\nlocal finalB = io.read(\"*n\")\n\nlocal tb = {}\nfor i = 1, string.len(str) do\n table.insert(tb,string.sub(str,i,i))\nend\n\nlocal dirTb = {\n {0,1},\n {0,-1},\n {-1,0},\n {1,0}\n}\n\nlocal turnTb = {\n {3,4},\n {3,4},\n {1,2},\n {1,2}\n}\nlocal function digui( a,b,idx,curDir )\n -- print(a..\" \"..b)\n if a == finalA and b == finalB and idx == #tb + 1 then\n return true\n end\n\n if idx > #tb then\n return false\n end\n\n if math.abs(a) > 8000 or math.abs(b) > 8000 then\n return false\n end\n -- print(a..\" \"..b)\n\n if tb[idx] == 'F' then\n return digui(a+dirTb[curDir][1],b+dirTb[curDir][2],idx+1,curDir)\n else\n return digui(a,b,idx+1,turnTb[curDir][1]) or digui(a,b,idx+1,turnTb[curDir][2]) \n end\n\nend\n\nlocal f = digui(0,0,1,4)\nprint(f and \"yes\" or \"no\")", "language": "Lua", "metadata": {"date": 1594178655, "filename_ext": "lua", "original_language": "Lua (Lua 5.3.5)", "problem_description_relpath": "problem_descriptions/p03490.html", "problem_id": "p03490", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03490/input.txt", "sample_output_relpath": "derived/input_output/data/p03490/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03490/Lua/s382637318.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s382637318", "user_id": "u018679195"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "local str = io.read()\nio.read(\"*l\")\nlocal finalA = io.read(\"*n\")\nlocal finalB = io.read(\"*n\")\n\nlocal tb = {}\nfor i = 1, string.len(str) do\n table.insert(tb,string.sub(str,i,i))\nend\n\nlocal dirTb = {\n {0,1},\n {0,-1},\n {-1,0},\n {1,0}\n}\n\nlocal turnTb = {\n {3,4},\n {3,4},\n {1,2},\n {1,2}\n}\nlocal function digui( a,b,idx,curDir )\n -- print(a..\" \"..b)\n if a == finalA and b == finalB and idx == #tb + 1 then\n return true\n end\n\n if idx > #tb then\n return false\n end\n\n if math.abs(a) > 8000 or math.abs(b) > 8000 then\n return false\n end\n -- print(a..\" \"..b)\n\n if tb[idx] == 'F' then\n return digui(a+dirTb[curDir][1],b+dirTb[curDir][2],idx+1,curDir)\n else\n return digui(a,b,idx+1,turnTb[curDir][1]) or digui(a,b,idx+1,turnTb[curDir][2]) \n end\n\nend\n\nlocal f = digui(0,0,1,4)\nprint(f and \"yes\" or \"no\")", "problem_context": "Score : 500 points\n\nProblem Statement\n\nA robot is put at the origin in a two-dimensional plane.\nInitially, the robot is facing in the positive x-axis direction.\n\nThis robot will be given an instruction sequence s.\ns consists of the following two kinds of letters, and will be executed in order from front to back.\n\nF : Move in the current direction by distance 1.\n\nT : Turn 90 degrees, either clockwise or counterclockwise.\n\nThe objective of the robot is to be at coordinates (x, y) after all the instructions are executed.\nDetermine whether this objective is achievable.\n\nConstraints\n\ns consists of F and T.\n\n1 \\leq |s| \\leq 8 000\n\nx and y are integers.\n\n|x|, |y| \\leq |s|\n\nInput\n\nInput is given from Standard Input in the following format:\n\ns\nx y\n\nOutput\n\nIf the objective is achievable, print Yes; if it is not, print No.\n\nSample Input 1\n\nFTFFTFFF\n4 2\n\nSample Output 1\n\nYes\n\nThe objective can be achieved by, for example, turning counterclockwise in the first T and turning clockwise in the second T.\n\nSample Input 2\n\nFTFFTFFF\n-2 -2\n\nSample Output 2\n\nYes\n\nThe objective can be achieved by, for example, turning clockwise in the first T and turning clockwise in the second T.\n\nSample Input 3\n\nFF\n1 0\n\nSample Output 3\n\nNo\n\nSample Input 4\n\nTF\n1 0\n\nSample Output 4\n\nNo\n\nSample Input 5\n\nFFTTFF\n0 0\n\nSample Output 5\n\nYes\n\nThe objective can be achieved by, for example, turning counterclockwise in the first T and turning counterclockwise in the second T.\n\nSample Input 6\n\nTTTT\n1 0\n\nSample Output 6\n\nNo", "sample_input": "FTFFTFFF\n4 2\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03490", "source_text": "Score : 500 points\n\nProblem Statement\n\nA robot is put at the origin in a two-dimensional plane.\nInitially, the robot is facing in the positive x-axis direction.\n\nThis robot will be given an instruction sequence s.\ns consists of the following two kinds of letters, and will be executed in order from front to back.\n\nF : Move in the current direction by distance 1.\n\nT : Turn 90 degrees, either clockwise or counterclockwise.\n\nThe objective of the robot is to be at coordinates (x, y) after all the instructions are executed.\nDetermine whether this objective is achievable.\n\nConstraints\n\ns consists of F and T.\n\n1 \\leq |s| \\leq 8 000\n\nx and y are integers.\n\n|x|, |y| \\leq |s|\n\nInput\n\nInput is given from Standard Input in the following format:\n\ns\nx y\n\nOutput\n\nIf the objective is achievable, print Yes; if it is not, print No.\n\nSample Input 1\n\nFTFFTFFF\n4 2\n\nSample Output 1\n\nYes\n\nThe objective can be achieved by, for example, turning counterclockwise in the first T and turning clockwise in the second T.\n\nSample Input 2\n\nFTFFTFFF\n-2 -2\n\nSample Output 2\n\nYes\n\nThe objective can be achieved by, for example, turning clockwise in the first T and turning clockwise in the second T.\n\nSample Input 3\n\nFF\n1 0\n\nSample Output 3\n\nNo\n\nSample Input 4\n\nTF\n1 0\n\nSample Output 4\n\nNo\n\nSample Input 5\n\nFFTTFF\n0 0\n\nSample Output 5\n\nYes\n\nThe objective can be achieved by, for example, turning counterclockwise in the first T and turning counterclockwise in the second T.\n\nSample Input 6\n\nTTTT\n1 0\n\nSample Output 6\n\nNo", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 884, "cpu_time_ms": 2205, "memory_kb": 4008}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s638882661", "group_id": "codeNet:p03490", "input_text": "local str,finalA,finalB = io.read(\"*l\",\"*n\",\"*n\")\nio.read(\"*l\")\n\nlocal tb = {}\nfor i = 1, string.len(str) do\n table.insert(tb,string.sub(str,i,i))\nend\n\nlocal dirTb = {\n {0,1},\n {0,-1},\n {-1,0},\n {1,0}\n}\n\nlocal turnTb = {\n {3,4},\n {3,4},\n {1,2},\n {1,2}\n}\nlocal function digui( a,b,idx,curDir )\n -- print(a..\" \"..b)\n if a == finalA and b == finalB and idx == #tb + 1 then\n return true\n end\n\n if idx > #tb then\n return false\n end\n\n if math.abs(a) > 8000 or math.abs(b) > 8000 then\n return false\n end\n -- print(a..\" \"..b)\n\n if tb[idx] == 'F' then\n return digui(a+dirTb[curDir][1],b+dirTb[curDir][2],idx+1,curDir)\n else\n return digui(a,b,idx+1,turnTb[curDir][1]) or digui(a,b,idx+1,turnTb[curDir][2]) \n end\n\nend\n\nlocal f = digui(0,0,1,4)\nprint(f and \"yes\" or \"no\")", "language": "Lua", "metadata": {"date": 1594177417, "filename_ext": "lua", "original_language": "Lua (Lua 5.3.5)", "problem_description_relpath": "problem_descriptions/p03490.html", "problem_id": "p03490", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03490/input.txt", "sample_output_relpath": "derived/input_output/data/p03490/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03490/Lua/s638882661.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s638882661", "user_id": "u816631826"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "local str,finalA,finalB = io.read(\"*l\",\"*n\",\"*n\")\nio.read(\"*l\")\n\nlocal tb = {}\nfor i = 1, string.len(str) do\n table.insert(tb,string.sub(str,i,i))\nend\n\nlocal dirTb = {\n {0,1},\n {0,-1},\n {-1,0},\n {1,0}\n}\n\nlocal turnTb = {\n {3,4},\n {3,4},\n {1,2},\n {1,2}\n}\nlocal function digui( a,b,idx,curDir )\n -- print(a..\" \"..b)\n if a == finalA and b == finalB and idx == #tb + 1 then\n return true\n end\n\n if idx > #tb then\n return false\n end\n\n if math.abs(a) > 8000 or math.abs(b) > 8000 then\n return false\n end\n -- print(a..\" \"..b)\n\n if tb[idx] == 'F' then\n return digui(a+dirTb[curDir][1],b+dirTb[curDir][2],idx+1,curDir)\n else\n return digui(a,b,idx+1,turnTb[curDir][1]) or digui(a,b,idx+1,turnTb[curDir][2]) \n end\n\nend\n\nlocal f = digui(0,0,1,4)\nprint(f and \"yes\" or \"no\")", "problem_context": "Score : 500 points\n\nProblem Statement\n\nA robot is put at the origin in a two-dimensional plane.\nInitially, the robot is facing in the positive x-axis direction.\n\nThis robot will be given an instruction sequence s.\ns consists of the following two kinds of letters, and will be executed in order from front to back.\n\nF : Move in the current direction by distance 1.\n\nT : Turn 90 degrees, either clockwise or counterclockwise.\n\nThe objective of the robot is to be at coordinates (x, y) after all the instructions are executed.\nDetermine whether this objective is achievable.\n\nConstraints\n\ns consists of F and T.\n\n1 \\leq |s| \\leq 8 000\n\nx and y are integers.\n\n|x|, |y| \\leq |s|\n\nInput\n\nInput is given from Standard Input in the following format:\n\ns\nx y\n\nOutput\n\nIf the objective is achievable, print Yes; if it is not, print No.\n\nSample Input 1\n\nFTFFTFFF\n4 2\n\nSample Output 1\n\nYes\n\nThe objective can be achieved by, for example, turning counterclockwise in the first T and turning clockwise in the second T.\n\nSample Input 2\n\nFTFFTFFF\n-2 -2\n\nSample Output 2\n\nYes\n\nThe objective can be achieved by, for example, turning clockwise in the first T and turning clockwise in the second T.\n\nSample Input 3\n\nFF\n1 0\n\nSample Output 3\n\nNo\n\nSample Input 4\n\nTF\n1 0\n\nSample Output 4\n\nNo\n\nSample Input 5\n\nFFTTFF\n0 0\n\nSample Output 5\n\nYes\n\nThe objective can be achieved by, for example, turning counterclockwise in the first T and turning counterclockwise in the second T.\n\nSample Input 6\n\nTTTT\n1 0\n\nSample Output 6\n\nNo", "sample_input": "FTFFTFFF\n4 2\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03490", "source_text": "Score : 500 points\n\nProblem Statement\n\nA robot is put at the origin in a two-dimensional plane.\nInitially, the robot is facing in the positive x-axis direction.\n\nThis robot will be given an instruction sequence s.\ns consists of the following two kinds of letters, and will be executed in order from front to back.\n\nF : Move in the current direction by distance 1.\n\nT : Turn 90 degrees, either clockwise or counterclockwise.\n\nThe objective of the robot is to be at coordinates (x, y) after all the instructions are executed.\nDetermine whether this objective is achievable.\n\nConstraints\n\ns consists of F and T.\n\n1 \\leq |s| \\leq 8 000\n\nx and y are integers.\n\n|x|, |y| \\leq |s|\n\nInput\n\nInput is given from Standard Input in the following format:\n\ns\nx y\n\nOutput\n\nIf the objective is achievable, print Yes; if it is not, print No.\n\nSample Input 1\n\nFTFFTFFF\n4 2\n\nSample Output 1\n\nYes\n\nThe objective can be achieved by, for example, turning counterclockwise in the first T and turning clockwise in the second T.\n\nSample Input 2\n\nFTFFTFFF\n-2 -2\n\nSample Output 2\n\nYes\n\nThe objective can be achieved by, for example, turning clockwise in the first T and turning clockwise in the second T.\n\nSample Input 3\n\nFF\n1 0\n\nSample Output 3\n\nNo\n\nSample Input 4\n\nTF\n1 0\n\nSample Output 4\n\nNo\n\nSample Input 5\n\nFFTTFF\n0 0\n\nSample Output 5\n\nYes\n\nThe objective can be achieved by, for example, turning counterclockwise in the first T and turning counterclockwise in the second T.\n\nSample Input 6\n\nTTTT\n1 0\n\nSample Output 6\n\nNo", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 855, "cpu_time_ms": 2205, "memory_kb": 3972}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s147190133", "group_id": "codeNet:p03494", "input_text": "N=io.read(\"n\")\nA={}\nfor i=1,N do\n A[i]=io.read(\"n\")\nend\nlocal count=0\nlocal t=A[#A]\nlocal sign=0\nwhile true do\n for i=1,N do\n if A[i]%2==1 then\n sign=1\n break\n end\n A[i]=A[i]//2\n end\n if A[#A]==t//2 then\n count=count+1\n t=A[#A]\n end\n if sign==1 then\n break\n end\nend\nprint(count)\n ", "language": "Lua", "metadata": {"date": 1551222868, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03494.html", "problem_id": "p03494", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03494/input.txt", "sample_output_relpath": "derived/input_output/data/p03494/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03494/Lua/s147190133.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s147190133", "user_id": "u015229643"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "N=io.read(\"n\")\nA={}\nfor i=1,N do\n A[i]=io.read(\"n\")\nend\nlocal count=0\nlocal t=A[#A]\nlocal sign=0\nwhile true do\n for i=1,N do\n if A[i]%2==1 then\n sign=1\n break\n end\n A[i]=A[i]//2\n end\n if A[#A]==t//2 then\n count=count+1\n t=A[#A]\n end\n if sign==1 then\n break\n end\nend\nprint(count)\n ", "problem_context": "Score : 200 points\n\nProblem Statement\n\nThere are N positive integers written on a blackboard: A_1, ..., A_N.\n\nSnuke can perform the following operation when all integers on the blackboard are even:\n\nReplace each integer X on the blackboard by X divided by 2.\n\nFind the maximum possible number of operations that Snuke can perform.\n\nConstraints\n\n1 \\leq N \\leq 200\n\n1 \\leq A_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the maximum possible number of operations that Snuke can perform.\n\nSample Input 1\n\n3\n8 12 40\n\nSample Output 1\n\n2\n\nInitially, [8, 12, 40] are written on the blackboard.\nSince all those integers are even, Snuke can perform the operation.\n\nAfter the operation is performed once, [4, 6, 20] are written on the blackboard.\nSince all those integers are again even, he can perform the operation.\n\nAfter the operation is performed twice, [2, 3, 10] are written on the blackboard.\nNow, there is an odd number 3 on the blackboard, so he cannot perform the operation any more.\n\nThus, Snuke can perform the operation at most twice.\n\nSample Input 2\n\n4\n5 6 8 10\n\nSample Output 2\n\n0\n\nSince there is an odd number 5 on the blackboard already in the beginning, Snuke cannot perform the operation at all.\n\nSample Input 3\n\n6\n382253568 723152896 37802240 379425024 404894720 471526144\n\nSample Output 3\n\n8", "sample_input": "3\n8 12 40\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03494", "source_text": "Score : 200 points\n\nProblem Statement\n\nThere are N positive integers written on a blackboard: A_1, ..., A_N.\n\nSnuke can perform the following operation when all integers on the blackboard are even:\n\nReplace each integer X on the blackboard by X divided by 2.\n\nFind the maximum possible number of operations that Snuke can perform.\n\nConstraints\n\n1 \\leq N \\leq 200\n\n1 \\leq A_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the maximum possible number of operations that Snuke can perform.\n\nSample Input 1\n\n3\n8 12 40\n\nSample Output 1\n\n2\n\nInitially, [8, 12, 40] are written on the blackboard.\nSince all those integers are even, Snuke can perform the operation.\n\nAfter the operation is performed once, [4, 6, 20] are written on the blackboard.\nSince all those integers are again even, he can perform the operation.\n\nAfter the operation is performed twice, [2, 3, 10] are written on the blackboard.\nNow, there is an odd number 3 on the blackboard, so he cannot perform the operation any more.\n\nThus, Snuke can perform the operation at most twice.\n\nSample Input 2\n\n4\n5 6 8 10\n\nSample Output 2\n\n0\n\nSince there is an odd number 5 on the blackboard already in the beginning, Snuke cannot perform the operation at all.\n\nSample Input 3\n\n6\n382253568 723152896 37802240 379425024 404894720 471526144\n\nSample Output 3\n\n8", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 316, "cpu_time_ms": 2, "memory_kb": 256}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s721688563", "group_id": "codeNet:p03494", "input_text": "local r = 99999999\nlocal n = tonumber(io.read(\"*l\"))\nfor _ in io.read(\"*l\"):gmatch(\"%d+\") do\n local r0 = 0\n local k = tonumber(_)\n while k % 2 < 1 do\n r0 = r0 + 1\n k = k // 2\n end\n if r > r0 then\n r = r0\n end\nend\nreturn print(r)\n", "language": "Lua", "metadata": {"date": 1529109277, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03494.html", "problem_id": "p03494", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03494/input.txt", "sample_output_relpath": "derived/input_output/data/p03494/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03494/Lua/s721688563.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s721688563", "user_id": "u280667879"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "local r = 99999999\nlocal n = tonumber(io.read(\"*l\"))\nfor _ in io.read(\"*l\"):gmatch(\"%d+\") do\n local r0 = 0\n local k = tonumber(_)\n while k % 2 < 1 do\n r0 = r0 + 1\n k = k // 2\n end\n if r > r0 then\n r = r0\n end\nend\nreturn print(r)\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nThere are N positive integers written on a blackboard: A_1, ..., A_N.\n\nSnuke can perform the following operation when all integers on the blackboard are even:\n\nReplace each integer X on the blackboard by X divided by 2.\n\nFind the maximum possible number of operations that Snuke can perform.\n\nConstraints\n\n1 \\leq N \\leq 200\n\n1 \\leq A_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the maximum possible number of operations that Snuke can perform.\n\nSample Input 1\n\n3\n8 12 40\n\nSample Output 1\n\n2\n\nInitially, [8, 12, 40] are written on the blackboard.\nSince all those integers are even, Snuke can perform the operation.\n\nAfter the operation is performed once, [4, 6, 20] are written on the blackboard.\nSince all those integers are again even, he can perform the operation.\n\nAfter the operation is performed twice, [2, 3, 10] are written on the blackboard.\nNow, there is an odd number 3 on the blackboard, so he cannot perform the operation any more.\n\nThus, Snuke can perform the operation at most twice.\n\nSample Input 2\n\n4\n5 6 8 10\n\nSample Output 2\n\n0\n\nSince there is an odd number 5 on the blackboard already in the beginning, Snuke cannot perform the operation at all.\n\nSample Input 3\n\n6\n382253568 723152896 37802240 379425024 404894720 471526144\n\nSample Output 3\n\n8", "sample_input": "3\n8 12 40\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03494", "source_text": "Score : 200 points\n\nProblem Statement\n\nThere are N positive integers written on a blackboard: A_1, ..., A_N.\n\nSnuke can perform the following operation when all integers on the blackboard are even:\n\nReplace each integer X on the blackboard by X divided by 2.\n\nFind the maximum possible number of operations that Snuke can perform.\n\nConstraints\n\n1 \\leq N \\leq 200\n\n1 \\leq A_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the maximum possible number of operations that Snuke can perform.\n\nSample Input 1\n\n3\n8 12 40\n\nSample Output 1\n\n2\n\nInitially, [8, 12, 40] are written on the blackboard.\nSince all those integers are even, Snuke can perform the operation.\n\nAfter the operation is performed once, [4, 6, 20] are written on the blackboard.\nSince all those integers are again even, he can perform the operation.\n\nAfter the operation is performed twice, [2, 3, 10] are written on the blackboard.\nNow, there is an odd number 3 on the blackboard, so he cannot perform the operation any more.\n\nThus, Snuke can perform the operation at most twice.\n\nSample Input 2\n\n4\n5 6 8 10\n\nSample Output 2\n\n0\n\nSince there is an odd number 5 on the blackboard already in the beginning, Snuke cannot perform the operation at all.\n\nSample Input 3\n\n6\n382253568 723152896 37802240 379425024 404894720 471526144\n\nSample Output 3\n\n8", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 244, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s961725042", "group_id": "codeNet:p03497", "input_text": "n,k=io.read(\"*n\",\"*n\",\"*l\")\na={}\nfor i=1,n do\n x=io.read(\"*n\")\n if not a[x] then\n a[x]=1\n else\n a[x]=a[x]+1\n end\nend\n\nb={}\nfor _,j in pairs(a) do\n table.insert(b,j)\nend\ntable.sort(b)\n\nball=0\nif #b-k>0 then\n for i=1,#b-k do\n ball=ball+b[i]\n end\nend\nprint(ball)", "language": "Lua", "metadata": {"date": 1589247718, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03497.html", "problem_id": "p03497", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03497/input.txt", "sample_output_relpath": "derived/input_output/data/p03497/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03497/Lua/s961725042.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s961725042", "user_id": "u045238009"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "n,k=io.read(\"*n\",\"*n\",\"*l\")\na={}\nfor i=1,n do\n x=io.read(\"*n\")\n if not a[x] then\n a[x]=1\n else\n a[x]=a[x]+1\n end\nend\n\nb={}\nfor _,j in pairs(a) do\n table.insert(b,j)\nend\ntable.sort(b)\n\nball=0\nif #b-k>0 then\n for i=1,#b-k do\n ball=ball+b[i]\n end\nend\nprint(ball)", "problem_context": "Score : 300 points\n\nProblem Statement\n\nTakahashi has N balls. Initially, an integer A_i is written on the i-th ball.\n\nHe would like to rewrite the integer on some balls so that there are at most K different integers written on the N balls.\n\nFind the minimum number of balls that Takahashi needs to rewrite the integers on them.\n\nConstraints\n\n1 \\leq K \\leq N \\leq 200000\n\n1 \\leq A_i \\leq N\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the minimum number of balls that Takahashi needs to rewrite the integers on them.\n\nSample Input 1\n\n5 2\n1 1 2 2 5\n\nSample Output 1\n\n1\n\nFor example, if we rewrite the integer on the fifth ball to 2, there are two different integers written on the balls: 1 and 2.\nOn the other hand, it is not possible to rewrite the integers on zero balls so that there are at most two different integers written on the balls, so we should print 1.\n\nSample Input 2\n\n4 4\n1 1 2 2\n\nSample Output 2\n\n0\n\nAlready in the beginning, there are two different integers written on the balls, so we do not need to rewrite anything.\n\nSample Input 3\n\n10 3\n5 1 3 2 4 1 1 2 3 4\n\nSample Output 3\n\n3", "sample_input": "5 2\n1 1 2 2 5\n"}, "reference_outputs": ["1\n"], "source_document_id": "p03497", "source_text": "Score : 300 points\n\nProblem Statement\n\nTakahashi has N balls. Initially, an integer A_i is written on the i-th ball.\n\nHe would like to rewrite the integer on some balls so that there are at most K different integers written on the N balls.\n\nFind the minimum number of balls that Takahashi needs to rewrite the integers on them.\n\nConstraints\n\n1 \\leq K \\leq N \\leq 200000\n\n1 \\leq A_i \\leq N\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the minimum number of balls that Takahashi needs to rewrite the integers on them.\n\nSample Input 1\n\n5 2\n1 1 2 2 5\n\nSample Output 1\n\n1\n\nFor example, if we rewrite the integer on the fifth ball to 2, there are two different integers written on the balls: 1 and 2.\nOn the other hand, it is not possible to rewrite the integers on zero balls so that there are at most two different integers written on the balls, so we should print 1.\n\nSample Input 2\n\n4 4\n1 1 2 2\n\nSample Output 2\n\n0\n\nAlready in the beginning, there are two different integers written on the balls, so we do not need to rewrite anything.\n\nSample Input 3\n\n10 3\n5 1 3 2 4 1 1 2 3 4\n\nSample Output 3\n\n3", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 301, "cpu_time_ms": 270, "memory_kb": 10208}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s039870235", "group_id": "codeNet:p03497", "input_text": "n, k = io.read('n'), io.read('n')\nbucket = {}\ncoll = {}\n\nfor i = 1, n do\n local a_i = io.read('n')\n bucket[a_i] = (bucket[a_i] or 0) + 1\nend\n\nfor _, v in pairs(bucket) do -- > <\n coll[#coll + 1] = v\nend\n\ntable.sort(coll)\n\nans = n\nfor i = 1, math.min(k, #coll) do\n ans = ans - coll[#coll - i + 1]\nend\n\nprint(ans)\n", "language": "Lua", "metadata": {"date": 1513211060, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03497.html", "problem_id": "p03497", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03497/input.txt", "sample_output_relpath": "derived/input_output/data/p03497/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03497/Lua/s039870235.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s039870235", "user_id": "u785421275"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "n, k = io.read('n'), io.read('n')\nbucket = {}\ncoll = {}\n\nfor i = 1, n do\n local a_i = io.read('n')\n bucket[a_i] = (bucket[a_i] or 0) + 1\nend\n\nfor _, v in pairs(bucket) do -- > <\n coll[#coll + 1] = v\nend\n\ntable.sort(coll)\n\nans = n\nfor i = 1, math.min(k, #coll) do\n ans = ans - coll[#coll - i + 1]\nend\n\nprint(ans)\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nTakahashi has N balls. Initially, an integer A_i is written on the i-th ball.\n\nHe would like to rewrite the integer on some balls so that there are at most K different integers written on the N balls.\n\nFind the minimum number of balls that Takahashi needs to rewrite the integers on them.\n\nConstraints\n\n1 \\leq K \\leq N \\leq 200000\n\n1 \\leq A_i \\leq N\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the minimum number of balls that Takahashi needs to rewrite the integers on them.\n\nSample Input 1\n\n5 2\n1 1 2 2 5\n\nSample Output 1\n\n1\n\nFor example, if we rewrite the integer on the fifth ball to 2, there are two different integers written on the balls: 1 and 2.\nOn the other hand, it is not possible to rewrite the integers on zero balls so that there are at most two different integers written on the balls, so we should print 1.\n\nSample Input 2\n\n4 4\n1 1 2 2\n\nSample Output 2\n\n0\n\nAlready in the beginning, there are two different integers written on the balls, so we do not need to rewrite anything.\n\nSample Input 3\n\n10 3\n5 1 3 2 4 1 1 2 3 4\n\nSample Output 3\n\n3", "sample_input": "5 2\n1 1 2 2 5\n"}, "reference_outputs": ["1\n"], "source_document_id": "p03497", "source_text": "Score : 300 points\n\nProblem Statement\n\nTakahashi has N balls. Initially, an integer A_i is written on the i-th ball.\n\nHe would like to rewrite the integer on some balls so that there are at most K different integers written on the N balls.\n\nFind the minimum number of balls that Takahashi needs to rewrite the integers on them.\n\nConstraints\n\n1 \\leq K \\leq N \\leq 200000\n\n1 \\leq A_i \\leq N\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the minimum number of balls that Takahashi needs to rewrite the integers on them.\n\nSample Input 1\n\n5 2\n1 1 2 2 5\n\nSample Output 1\n\n1\n\nFor example, if we rewrite the integer on the fifth ball to 2, there are two different integers written on the balls: 1 and 2.\nOn the other hand, it is not possible to rewrite the integers on zero balls so that there are at most two different integers written on the balls, so we should print 1.\n\nSample Input 2\n\n4 4\n1 1 2 2\n\nSample Output 2\n\n0\n\nAlready in the beginning, there are two different integers written on the balls, so we do not need to rewrite anything.\n\nSample Input 3\n\n10 3\n5 1 3 2 4 1 1 2 3 4\n\nSample Output 3\n\n3", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 327, "cpu_time_ms": 239, "memory_kb": 10208}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s830659356", "group_id": "codeNet:p03501", "input_text": "a,b,c=io.read():match(\"(.+)%s(.+)%s(.+)\")\nprint(math.floor(math.min(a*b,c*1)))", "language": "Lua", "metadata": {"date": 1551837964, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p03501.html", "problem_id": "p03501", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03501/input.txt", "sample_output_relpath": "derived/input_output/data/p03501/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03501/Lua/s830659356.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s830659356", "user_id": "u837412668"}, "prompt_components": {"gold_output": "119\n", "input_to_evaluate": "a,b,c=io.read():match(\"(.+)%s(.+)%s(.+)\")\nprint(math.floor(math.min(a*b,c*1)))", "problem_context": "Score : 100 points\n\nProblem Statement\n\nYou are parking at a parking lot. You can choose from the following two fee plans:\n\nPlan 1: The fee will be A×T yen (the currency of Japan) when you park for T hours.\n\nPlan 2: The fee will be B yen, regardless of the duration.\n\nFind the minimum fee when you park for N hours.\n\nConstraints\n\n1≤N≤20\n\n1≤A≤100\n\n1≤B≤2000\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN A B\n\nOutput\n\nWhen the minimum fee is x yen, print the value of x.\n\nSample Input 1\n\n7 17 120\n\nSample Output 1\n\n119\n\nIf you choose Plan 1, the fee will be 7×17=119 yen.\n\nIf you choose Plan 2, the fee will be 120 yen.\n\nThus, the minimum fee is 119 yen.\n\nSample Input 2\n\n5 20 100\n\nSample Output 2\n\n100\n\nThe fee might be the same in the two plans.\n\nSample Input 3\n\n6 18 100\n\nSample Output 3\n\n100", "sample_input": "7 17 120\n"}, "reference_outputs": ["119\n"], "source_document_id": "p03501", "source_text": "Score : 100 points\n\nProblem Statement\n\nYou are parking at a parking lot. You can choose from the following two fee plans:\n\nPlan 1: The fee will be A×T yen (the currency of Japan) when you park for T hours.\n\nPlan 2: The fee will be B yen, regardless of the duration.\n\nFind the minimum fee when you park for N hours.\n\nConstraints\n\n1≤N≤20\n\n1≤A≤100\n\n1≤B≤2000\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN A B\n\nOutput\n\nWhen the minimum fee is x yen, print the value of x.\n\nSample Input 1\n\n7 17 120\n\nSample Output 1\n\n119\n\nIf you choose Plan 1, the fee will be 7×17=119 yen.\n\nIf you choose Plan 2, the fee will be 120 yen.\n\nThus, the minimum fee is 119 yen.\n\nSample Input 2\n\n5 20 100\n\nSample Output 2\n\n100\n\nThe fee might be the same in the two plans.\n\nSample Input 3\n\n6 18 100\n\nSample Output 3\n\n100", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 78, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s289547271", "group_id": "codeNet:p03502", "input_text": "N=io.read()\nlocal sum=0\nlocal mark=N\nwhile N>0 do\n sum=sum+N%10\n N=N//10\nend\nif mark%sum==0 then\n print(\"Yes\")\n else\n print(\"No\")\nend\n", "language": "Lua", "metadata": {"date": 1551289789, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03502.html", "problem_id": "p03502", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03502/input.txt", "sample_output_relpath": "derived/input_output/data/p03502/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03502/Lua/s289547271.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s289547271", "user_id": "u015229643"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "N=io.read()\nlocal sum=0\nlocal mark=N\nwhile N>0 do\n sum=sum+N%10\n N=N//10\nend\nif mark%sum==0 then\n print(\"Yes\")\n else\n print(\"No\")\nend\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nAn integer X is called a Harshad number if X is divisible by f(X), where f(X) is the sum of the digits in X when written in base 10.\n\nGiven an integer N, determine whether it is a Harshad number.\n\nConstraints\n\n1?N?10^8\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint Yes if N is a Harshad number; print No otherwise.\n\nSample Input 1\n\n12\n\nSample Output 1\n\nYes\n\nf(12)=1+2=3. Since 12 is divisible by 3, 12 is a Harshad number.\n\nSample Input 2\n\n57\n\nSample Output 2\n\nNo\n\nf(57)=5+7=12. Since 57 is not divisible by 12, 12 is not a Harshad number.\n\nSample Input 3\n\n148\n\nSample Output 3\n\nNo", "sample_input": "12\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03502", "source_text": "Score : 200 points\n\nProblem Statement\n\nAn integer X is called a Harshad number if X is divisible by f(X), where f(X) is the sum of the digits in X when written in base 10.\n\nGiven an integer N, determine whether it is a Harshad number.\n\nConstraints\n\n1?N?10^8\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint Yes if N is a Harshad number; print No otherwise.\n\nSample Input 1\n\n12\n\nSample Output 1\n\nYes\n\nf(12)=1+2=3. Since 12 is divisible by 3, 12 is a Harshad number.\n\nSample Input 2\n\n57\n\nSample Output 2\n\nNo\n\nf(57)=5+7=12. Since 57 is not divisible by 12, 12 is not a Harshad number.\n\nSample Input 3\n\n148\n\nSample Output 3\n\nNo", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 139, "cpu_time_ms": 8, "memory_kb": 760}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s071941430", "group_id": "codeNet:p03503", "input_text": "local mfl, mma = math.floor, math.max\nlocal n = io.read(\"*n\")\nlocal f = {}\nfor i = 1, n * 10 do\n f[i] = (io.read(\"*n\") == 1)\nend\nlocal p = {}\nfor i = 1, n * 11 do\n p[i] = io.read(\"*n\")\nend\n\nlocal score = {}\nfor i = 1, 1023 do\n local cnt = {}\n local ti = i\n for k = 1, n do cnt[k] = 1 end\n for j = 1, 10 do\n local flg = ti % 2\n ti = mfl(ti / 2)\n if flg == 1 then\n for k = 1, n do\n if f[(k - 1) * 10 + j] then\n cnt[k] = cnt[k] + 1\n end\n end\n end\n end\n score[i] = 0\n for k = 1, n do\n score[i] = score[i] + p[(k - 1) * 11 + cnt[k]]\n end\nend\nlocal ret = score[1]\nfor i = 2, 1023 do\n ret = mma(ret, score[i])\nend\nprint(ret)\n", "language": "Lua", "metadata": {"date": 1560892590, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p03503.html", "problem_id": "p03503", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03503/input.txt", "sample_output_relpath": "derived/input_output/data/p03503/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03503/Lua/s071941430.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s071941430", "user_id": "u120582723"}, "prompt_components": {"gold_output": "8\n", "input_to_evaluate": "local mfl, mma = math.floor, math.max\nlocal n = io.read(\"*n\")\nlocal f = {}\nfor i = 1, n * 10 do\n f[i] = (io.read(\"*n\") == 1)\nend\nlocal p = {}\nfor i = 1, n * 11 do\n p[i] = io.read(\"*n\")\nend\n\nlocal score = {}\nfor i = 1, 1023 do\n local cnt = {}\n local ti = i\n for k = 1, n do cnt[k] = 1 end\n for j = 1, 10 do\n local flg = ti % 2\n ti = mfl(ti / 2)\n if flg == 1 then\n for k = 1, n do\n if f[(k - 1) * 10 + j] then\n cnt[k] = cnt[k] + 1\n end\n end\n end\n end\n score[i] = 0\n for k = 1, n do\n score[i] = score[i] + p[(k - 1) * 11 + cnt[k]]\n end\nend\nlocal ret = score[1]\nfor i = 2, 1023 do\n ret = mma(ret, score[i])\nend\nprint(ret)\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nJoisino is planning to open a shop in a shopping street.\n\nEach of the five weekdays is divided into two periods, the morning and the evening. For each of those ten periods, a shop must be either open during the whole period, or closed during the whole period. Naturally, a shop must be open during at least one of those periods.\n\nThere are already N stores in the street, numbered 1 through N.\n\nYou are given information of the business hours of those shops, F_{i,j,k}. If F_{i,j,k}=1, Shop i is open during Period k on Day j (this notation is explained below); if F_{i,j,k}=0, Shop i is closed during that period. Here, the days of the week are denoted as follows. Monday: Day 1, Tuesday: Day 2, Wednesday: Day 3, Thursday: Day 4, Friday: Day 5. Also, the morning is denoted as Period 1, and the afternoon is denoted as Period 2.\n\nLet c_i be the number of periods during which both Shop i and Joisino's shop are open. Then, the profit of Joisino's shop will be P_{1,c_1}+P_{2,c_2}+...+P_{N,c_N}.\n\nFind the maximum possible profit of Joisino's shop when she decides whether her shop is open during each period, making sure that it is open during at least one period.\n\nConstraints\n\n1≤N≤100\n\n0≤F_{i,j,k}≤1\n\nFor every integer i such that 1≤i≤N, there exists at least one pair (j,k) such that F_{i,j,k}=1.\n\n-10^7≤P_{i,j}≤10^7\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nF_{1,1,1} F_{1,1,2} ... F_{1,5,1} F_{1,5,2}\n:\nF_{N,1,1} F_{N,1,2} ... F_{N,5,1} F_{N,5,2}\nP_{1,0} ... P_{1,10}\n:\nP_{N,0} ... P_{N,10}\n\nOutput\n\nPrint the maximum possible profit of Joisino's shop.\n\nSample Input 1\n\n1\n1 1 0 1 0 0 0 1 0 1\n3 4 5 6 7 8 9 -2 -3 4 -2\n\nSample Output 1\n\n8\n\nIf her shop is open only during the periods when Shop 1 is opened, the profit will be 8, which is the maximum possible profit.\n\nSample Input 2\n\n2\n1 1 1 1 1 0 0 0 0 0\n0 0 0 0 0 1 1 1 1 1\n0 -2 -2 -2 -2 -2 -1 -1 -1 -1 -1\n0 -2 -2 -2 -2 -2 -1 -1 -1 -1 -1\n\nSample Output 2\n\n-2\n\nNote that a shop must be open during at least one period, and the profit may be negative.\n\nSample Input 3\n\n3\n1 1 1 1 1 1 0 0 1 1\n0 1 0 1 1 1 1 0 1 0\n1 0 1 1 0 1 0 1 0 1\n-8 6 -2 -8 -8 4 8 7 -6 2 2\n-9 2 0 1 7 -5 0 -2 -6 5 5\n6 -6 7 -9 6 -5 8 0 -9 -7 -7\n\nSample Output 3\n\n23", "sample_input": "1\n1 1 0 1 0 0 0 1 0 1\n3 4 5 6 7 8 9 -2 -3 4 -2\n"}, "reference_outputs": ["8\n"], "source_document_id": "p03503", "source_text": "Score : 300 points\n\nProblem Statement\n\nJoisino is planning to open a shop in a shopping street.\n\nEach of the five weekdays is divided into two periods, the morning and the evening. For each of those ten periods, a shop must be either open during the whole period, or closed during the whole period. Naturally, a shop must be open during at least one of those periods.\n\nThere are already N stores in the street, numbered 1 through N.\n\nYou are given information of the business hours of those shops, F_{i,j,k}. If F_{i,j,k}=1, Shop i is open during Period k on Day j (this notation is explained below); if F_{i,j,k}=0, Shop i is closed during that period. Here, the days of the week are denoted as follows. Monday: Day 1, Tuesday: Day 2, Wednesday: Day 3, Thursday: Day 4, Friday: Day 5. Also, the morning is denoted as Period 1, and the afternoon is denoted as Period 2.\n\nLet c_i be the number of periods during which both Shop i and Joisino's shop are open. Then, the profit of Joisino's shop will be P_{1,c_1}+P_{2,c_2}+...+P_{N,c_N}.\n\nFind the maximum possible profit of Joisino's shop when she decides whether her shop is open during each period, making sure that it is open during at least one period.\n\nConstraints\n\n1≤N≤100\n\n0≤F_{i,j,k}≤1\n\nFor every integer i such that 1≤i≤N, there exists at least one pair (j,k) such that F_{i,j,k}=1.\n\n-10^7≤P_{i,j}≤10^7\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nF_{1,1,1} F_{1,1,2} ... F_{1,5,1} F_{1,5,2}\n:\nF_{N,1,1} F_{N,1,2} ... F_{N,5,1} F_{N,5,2}\nP_{1,0} ... P_{1,10}\n:\nP_{N,0} ... P_{N,10}\n\nOutput\n\nPrint the maximum possible profit of Joisino's shop.\n\nSample Input 1\n\n1\n1 1 0 1 0 0 0 1 0 1\n3 4 5 6 7 8 9 -2 -3 4 -2\n\nSample Output 1\n\n8\n\nIf her shop is open only during the periods when Shop 1 is opened, the profit will be 8, which is the maximum possible profit.\n\nSample Input 2\n\n2\n1 1 1 1 1 0 0 0 0 0\n0 0 0 0 0 1 1 1 1 1\n0 -2 -2 -2 -2 -2 -1 -1 -1 -1 -1\n0 -2 -2 -2 -2 -2 -1 -1 -1 -1 -1\n\nSample Output 2\n\n-2\n\nNote that a shop must be open during at least one period, and the profit may be negative.\n\nSample Input 3\n\n3\n1 1 1 1 1 1 0 0 1 1\n0 1 0 1 1 1 1 0 1 0\n1 0 1 1 0 1 0 1 0 1\n-8 6 -2 -8 -8 4 8 7 -6 2 2\n-9 2 0 1 7 -5 0 -2 -6 5 5\n6 -6 7 -9 6 -5 8 0 -9 -7 -7\n\nSample Output 3\n\n23", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 677, "cpu_time_ms": 7, "memory_kb": 384}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s595822544", "group_id": "codeNet:p03504", "input_text": "local n, c = io.read(\"*n\", \"*n\")\nlocal tbl = {}\nfor i = 1, n do\n local tmp = {}\n tmp.s, tmp.t, tmp.c = io.read(\"*n\", \"*n\", \"*n\")\n tbl[i] = tmp\nend\ntable.sort(tbl, function(a, b) return a.s < b.s end)\nlocal rec_end = {tbl[1].t}\nlocal rec_ch = {tbl[1].c}\n\nfor i = 2, n do\n local fpos = nil\n for ir = 1, #rec_end do\n if rec_end[ir] == tbl[i].s and rec_ch[ir] == tbl[i].c then\n rec_end[ir] = tbl[i].t\n fpos = ir\n break\n elseif rec_end[ir] < tbl[i].s then\n if not fpos then\n fpos = ir\n else\n if rec_end[ir] < rec_end[fpos] then\n fpos = ir\n end\n end\n end\n end\n if fpos then\n rec_end[fpos] = tbl[i].t\n rec_ch[fpos] = tbl[i].c\n else\n table.insert(rec_end, tbl[i].t)\n table.insert(rec_ch, tbl[i].c)\n end\nend\nprint(#rec_end)\n", "language": "Lua", "metadata": {"date": 1563727744, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p03504.html", "problem_id": "p03504", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03504/input.txt", "sample_output_relpath": "derived/input_output/data/p03504/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03504/Lua/s595822544.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s595822544", "user_id": "u120582723"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "local n, c = io.read(\"*n\", \"*n\")\nlocal tbl = {}\nfor i = 1, n do\n local tmp = {}\n tmp.s, tmp.t, tmp.c = io.read(\"*n\", \"*n\", \"*n\")\n tbl[i] = tmp\nend\ntable.sort(tbl, function(a, b) return a.s < b.s end)\nlocal rec_end = {tbl[1].t}\nlocal rec_ch = {tbl[1].c}\n\nfor i = 2, n do\n local fpos = nil\n for ir = 1, #rec_end do\n if rec_end[ir] == tbl[i].s and rec_ch[ir] == tbl[i].c then\n rec_end[ir] = tbl[i].t\n fpos = ir\n break\n elseif rec_end[ir] < tbl[i].s then\n if not fpos then\n fpos = ir\n else\n if rec_end[ir] < rec_end[fpos] then\n fpos = ir\n end\n end\n end\n end\n if fpos then\n rec_end[fpos] = tbl[i].t\n rec_ch[fpos] = tbl[i].c\n else\n table.insert(rec_end, tbl[i].t)\n table.insert(rec_ch, tbl[i].c)\n end\nend\nprint(#rec_end)\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nJoisino is planning to record N TV programs with recorders.\n\nThe TV can receive C channels numbered 1 through C.\n\nThe i-th program that she wants to record will be broadcast from time s_i to time t_i (including time s_i but not t_i) on Channel c_i.\n\nHere, there will never be more than one program that are broadcast on the same channel at the same time.\n\nWhen the recorder is recording a channel from time S to time T (including time S but not T), it cannot record other channels from time S-0.5 to time T (including time S-0.5 but not T).\n\nFind the minimum number of recorders required to record the channels so that all the N programs are completely recorded.\n\nConstraints\n\n1≤N≤10^5\n\n1≤C≤30\n\n1≤s_i=2 then\n for i=2,N do\n L[i]=L[i-1]+L[i-2]\n end\nend\nprint(L[N])\n ", "language": "Lua", "metadata": {"date": 1551306184, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03544.html", "problem_id": "p03544", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03544/input.txt", "sample_output_relpath": "derived/input_output/data/p03544/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03544/Lua/s884318435.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s884318435", "user_id": "u015229643"}, "prompt_components": {"gold_output": "11\n", "input_to_evaluate": "N=io.read(\"n\")\nL={}\nL[0]=2\nL[1]=1\nif N>=2 then\n for i=2,N do\n L[i]=L[i-1]+L[i-2]\n end\nend\nprint(L[N])\n ", "problem_context": "Score : 200 points\n\nProblem Statement\n\nIt is November 18 now in Japan. By the way, 11 and 18 are adjacent Lucas numbers.\n\nYou are given an integer N. Find the N-th Lucas number.\n\nHere, the i-th Lucas number L_i is defined as follows:\n\nL_0=2\n\nL_1=1\n\nL_i=L_{i-1}+L_{i-2} (i≥2)\n\nConstraints\n\n1≤N≤86\n\nIt is guaranteed that the answer is less than 10^{18}.\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the N-th Lucas number.\n\nSample Input 1\n\n5\n\nSample Output 1\n\n11\n\nL_0=2\n\nL_1=1\n\nL_2=L_0+L_1=3\n\nL_3=L_1+L_2=4\n\nL_4=L_2+L_3=7\n\nL_5=L_3+L_4=11\n\nThus, the 5-th Lucas number is 11.\n\nSample Input 2\n\n86\n\nSample Output 2\n\n939587134549734843", "sample_input": "5\n"}, "reference_outputs": ["11\n"], "source_document_id": "p03544", "source_text": "Score : 200 points\n\nProblem Statement\n\nIt is November 18 now in Japan. By the way, 11 and 18 are adjacent Lucas numbers.\n\nYou are given an integer N. Find the N-th Lucas number.\n\nHere, the i-th Lucas number L_i is defined as follows:\n\nL_0=2\n\nL_1=1\n\nL_i=L_{i-1}+L_{i-2} (i≥2)\n\nConstraints\n\n1≤N≤86\n\nIt is guaranteed that the answer is less than 10^{18}.\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the N-th Lucas number.\n\nSample Input 1\n\n5\n\nSample Output 1\n\n11\n\nL_0=2\n\nL_1=1\n\nL_2=L_0+L_1=3\n\nL_3=L_1+L_2=4\n\nL_4=L_2+L_3=7\n\nL_5=L_3+L_4=11\n\nThus, the 5-th Lucas number is 11.\n\nSample Input 2\n\n86\n\nSample Output 2\n\n939587134549734843", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 109, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s911183814", "group_id": "codeNet:p03545", "input_text": "local function ston(x,i)\n return tonumber(x:sub(i,i))\nend\nlocal function eo(i)\n if i%2==0 then\n return 1\n else\n return -1\n end\nend\nlocal function pm(i)\n if i%2==0 then\n return \"+\"\n else\n return \"-\"\n end\nend\n\nx=io.read()\na=ston(x,1)\nb=ston(x,2)\nc=ston(x,3)\nd=ston(x,4)\n\nfor i=1,2 do\n for j=1,2 do\n for k=1,2 do\n if a+b*eo(i)+c*eo(j)+d*eo(k)==7 then\n print(a..pm(i)..b..pm(j)..c..pm(k)..d..\"=7\")\n return\n end\n end\n end\nend", "language": "Lua", "metadata": {"date": 1588390676, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03545.html", "problem_id": "p03545", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03545/input.txt", "sample_output_relpath": "derived/input_output/data/p03545/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03545/Lua/s911183814.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s911183814", "user_id": "u045238009"}, "prompt_components": {"gold_output": "1+2+2+2=7\n", "input_to_evaluate": "local function ston(x,i)\n return tonumber(x:sub(i,i))\nend\nlocal function eo(i)\n if i%2==0 then\n return 1\n else\n return -1\n end\nend\nlocal function pm(i)\n if i%2==0 then\n return \"+\"\n else\n return \"-\"\n end\nend\n\nx=io.read()\na=ston(x,1)\nb=ston(x,2)\nc=ston(x,3)\nd=ston(x,4)\n\nfor i=1,2 do\n for j=1,2 do\n for k=1,2 do\n if a+b*eo(i)+c*eo(j)+d*eo(k)==7 then\n print(a..pm(i)..b..pm(j)..c..pm(k)..d..\"=7\")\n return\n end\n end\n end\nend", "problem_context": "Score : 300 points\n\nProblem Statement\n\nSitting in a station waiting room, Joisino is gazing at her train ticket.\n\nThe ticket is numbered with four digits A, B, C and D in this order, each between 0 and 9 (inclusive).\n\nIn the formula A op1 B op2 C op3 D = 7, replace each of the symbols op1, op2 and op3 with + or - so that the formula holds.\n\nThe given input guarantees that there is a solution. If there are multiple solutions, any of them will be accepted.\n\nConstraints\n\n0≤A,B,C,D≤9\n\nAll input values are integers.\n\nIt is guaranteed that there is a solution.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nABCD\n\nOutput\n\nPrint the formula you made, including the part =7.\n\nUse the signs + and -.\n\nDo not print a space between a digit and a sign.\n\nSample Input 1\n\n1222\n\nSample Output 1\n\n1+2+2+2=7\n\nThis is the only valid solution.\n\nSample Input 2\n\n0290\n\nSample Output 2\n\n0-2+9+0=7\n\n0 - 2 + 9 - 0 = 7 is also a valid solution.\n\nSample Input 3\n\n3242\n\nSample Output 3\n\n3+2+4-2=7", "sample_input": "1222\n"}, "reference_outputs": ["1+2+2+2=7\n"], "source_document_id": "p03545", "source_text": "Score : 300 points\n\nProblem Statement\n\nSitting in a station waiting room, Joisino is gazing at her train ticket.\n\nThe ticket is numbered with four digits A, B, C and D in this order, each between 0 and 9 (inclusive).\n\nIn the formula A op1 B op2 C op3 D = 7, replace each of the symbols op1, op2 and op3 with + or - so that the formula holds.\n\nThe given input guarantees that there is a solution. If there are multiple solutions, any of them will be accepted.\n\nConstraints\n\n0≤A,B,C,D≤9\n\nAll input values are integers.\n\nIt is guaranteed that there is a solution.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nABCD\n\nOutput\n\nPrint the formula you made, including the part =7.\n\nUse the signs + and -.\n\nDo not print a space between a digit and a sign.\n\nSample Input 1\n\n1222\n\nSample Output 1\n\n1+2+2+2=7\n\nThis is the only valid solution.\n\nSample Input 2\n\n0290\n\nSample Output 2\n\n0-2+9+0=7\n\n0 - 2 + 9 - 0 = 7 is also a valid solution.\n\nSample Input 3\n\n3242\n\nSample Output 3\n\n3+2+4-2=7", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 541, "cpu_time_ms": 8, "memory_kb": 888}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s711486137", "group_id": "codeNet:p03545", "input_text": "local s = io.read()\nlocal a = {}\nfor i = 1, 4 do\n a[i] = tonumber(s:sub(i, i))\nend\nfor i = 0, 7 do\n local sum = a[1]\n local ti = i\n sum = sum + a[2] * (2 * (ti % 2) - 1)\n ti = ti // 2\n sum = sum + a[3] * (2 * (ti % 2) - 1)\n ti = ti // 2\n sum = sum + a[4] * (2 * (ti % 2) - 1)\n if sum == 7 then\n io.write(a[1])\n local z = i\n for k = 2, 4 do\n io.write(z % 2 == 0 and \"-\" or \"+\")\n io.write(a[k])\n z = z // 2\n end\n io.write(\"=7\\n\")\n break\n end\nend\n", "language": "Lua", "metadata": {"date": 1559521857, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03545.html", "problem_id": "p03545", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03545/input.txt", "sample_output_relpath": "derived/input_output/data/p03545/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03545/Lua/s711486137.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s711486137", "user_id": "u120582723"}, "prompt_components": {"gold_output": "1+2+2+2=7\n", "input_to_evaluate": "local s = io.read()\nlocal a = {}\nfor i = 1, 4 do\n a[i] = tonumber(s:sub(i, i))\nend\nfor i = 0, 7 do\n local sum = a[1]\n local ti = i\n sum = sum + a[2] * (2 * (ti % 2) - 1)\n ti = ti // 2\n sum = sum + a[3] * (2 * (ti % 2) - 1)\n ti = ti // 2\n sum = sum + a[4] * (2 * (ti % 2) - 1)\n if sum == 7 then\n io.write(a[1])\n local z = i\n for k = 2, 4 do\n io.write(z % 2 == 0 and \"-\" or \"+\")\n io.write(a[k])\n z = z // 2\n end\n io.write(\"=7\\n\")\n break\n end\nend\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nSitting in a station waiting room, Joisino is gazing at her train ticket.\n\nThe ticket is numbered with four digits A, B, C and D in this order, each between 0 and 9 (inclusive).\n\nIn the formula A op1 B op2 C op3 D = 7, replace each of the symbols op1, op2 and op3 with + or - so that the formula holds.\n\nThe given input guarantees that there is a solution. If there are multiple solutions, any of them will be accepted.\n\nConstraints\n\n0≤A,B,C,D≤9\n\nAll input values are integers.\n\nIt is guaranteed that there is a solution.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nABCD\n\nOutput\n\nPrint the formula you made, including the part =7.\n\nUse the signs + and -.\n\nDo not print a space between a digit and a sign.\n\nSample Input 1\n\n1222\n\nSample Output 1\n\n1+2+2+2=7\n\nThis is the only valid solution.\n\nSample Input 2\n\n0290\n\nSample Output 2\n\n0-2+9+0=7\n\n0 - 2 + 9 - 0 = 7 is also a valid solution.\n\nSample Input 3\n\n3242\n\nSample Output 3\n\n3+2+4-2=7", "sample_input": "1222\n"}, "reference_outputs": ["1+2+2+2=7\n"], "source_document_id": "p03545", "source_text": "Score : 300 points\n\nProblem Statement\n\nSitting in a station waiting room, Joisino is gazing at her train ticket.\n\nThe ticket is numbered with four digits A, B, C and D in this order, each between 0 and 9 (inclusive).\n\nIn the formula A op1 B op2 C op3 D = 7, replace each of the symbols op1, op2 and op3 with + or - so that the formula holds.\n\nThe given input guarantees that there is a solution. If there are multiple solutions, any of them will be accepted.\n\nConstraints\n\n0≤A,B,C,D≤9\n\nAll input values are integers.\n\nIt is guaranteed that there is a solution.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nABCD\n\nOutput\n\nPrint the formula you made, including the part =7.\n\nUse the signs + and -.\n\nDo not print a space between a digit and a sign.\n\nSample Input 1\n\n1222\n\nSample Output 1\n\n1+2+2+2=7\n\nThis is the only valid solution.\n\nSample Input 2\n\n0290\n\nSample Output 2\n\n0-2+9+0=7\n\n0 - 2 + 9 - 0 = 7 is also a valid solution.\n\nSample Input 3\n\n3242\n\nSample Output 3\n\n3+2+4-2=7", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 487, "cpu_time_ms": 17, "memory_kb": 760}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s252604254", "group_id": "codeNet:p03545", "input_text": "A=io.read(\"n\")\nB=io.read(\"n\")\nC=io.read(\"n\")\nD=io.read(\"n\")\nif A+B+C+D==7 then \n print(string.format(\"%d+%d+%d+%d=7\",A,B,C,D))\nelseif A+B+C-D==7 then\n print(string.format(\"%d+%d+%d-%d=7\",A,B,C,D))\n elseif A+B-C+D==7 then\n print(string.format(\"%d+%d-%d+%d=7\",A,B,C,D))\n elseif A+B-C-D==7 then\n print(string.format(\"%d+%d-%d-%d=7\",A,B,C,D))\n elseif A-B+C+D==7 then\n print(string.format(\"%d-%d+%d+%d=7\",A,B,C,D))\n elseif A-B+C-D==7 then\n print(string.format(\"%d-%d+%d-%d=7\",A,B,C,D))\n elseif A-B-C+D==7 then\n print(string.format(\"%d-%d-%d+%d=7\",A,B,C,D))\n elseif A-B-C-D==7 then\n print(string.format(\"%d-%d-%d-%d=7\",A,B,C,D))\nend", "language": "Lua", "metadata": {"date": 1551311383, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03545.html", "problem_id": "p03545", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03545/input.txt", "sample_output_relpath": "derived/input_output/data/p03545/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03545/Lua/s252604254.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s252604254", "user_id": "u015229643"}, "prompt_components": {"gold_output": "1+2+2+2=7\n", "input_to_evaluate": "A=io.read(\"n\")\nB=io.read(\"n\")\nC=io.read(\"n\")\nD=io.read(\"n\")\nif A+B+C+D==7 then \n print(string.format(\"%d+%d+%d+%d=7\",A,B,C,D))\nelseif A+B+C-D==7 then\n print(string.format(\"%d+%d+%d-%d=7\",A,B,C,D))\n elseif A+B-C+D==7 then\n print(string.format(\"%d+%d-%d+%d=7\",A,B,C,D))\n elseif A+B-C-D==7 then\n print(string.format(\"%d+%d-%d-%d=7\",A,B,C,D))\n elseif A-B+C+D==7 then\n print(string.format(\"%d-%d+%d+%d=7\",A,B,C,D))\n elseif A-B+C-D==7 then\n print(string.format(\"%d-%d+%d-%d=7\",A,B,C,D))\n elseif A-B-C+D==7 then\n print(string.format(\"%d-%d-%d+%d=7\",A,B,C,D))\n elseif A-B-C-D==7 then\n print(string.format(\"%d-%d-%d-%d=7\",A,B,C,D))\nend", "problem_context": "Score : 300 points\n\nProblem Statement\n\nSitting in a station waiting room, Joisino is gazing at her train ticket.\n\nThe ticket is numbered with four digits A, B, C and D in this order, each between 0 and 9 (inclusive).\n\nIn the formula A op1 B op2 C op3 D = 7, replace each of the symbols op1, op2 and op3 with + or - so that the formula holds.\n\nThe given input guarantees that there is a solution. If there are multiple solutions, any of them will be accepted.\n\nConstraints\n\n0≤A,B,C,D≤9\n\nAll input values are integers.\n\nIt is guaranteed that there is a solution.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nABCD\n\nOutput\n\nPrint the formula you made, including the part =7.\n\nUse the signs + and -.\n\nDo not print a space between a digit and a sign.\n\nSample Input 1\n\n1222\n\nSample Output 1\n\n1+2+2+2=7\n\nThis is the only valid solution.\n\nSample Input 2\n\n0290\n\nSample Output 2\n\n0-2+9+0=7\n\n0 - 2 + 9 - 0 = 7 is also a valid solution.\n\nSample Input 3\n\n3242\n\nSample Output 3\n\n3+2+4-2=7", "sample_input": "1222\n"}, "reference_outputs": ["1+2+2+2=7\n"], "source_document_id": "p03545", "source_text": "Score : 300 points\n\nProblem Statement\n\nSitting in a station waiting room, Joisino is gazing at her train ticket.\n\nThe ticket is numbered with four digits A, B, C and D in this order, each between 0 and 9 (inclusive).\n\nIn the formula A op1 B op2 C op3 D = 7, replace each of the symbols op1, op2 and op3 with + or - so that the formula holds.\n\nThe given input guarantees that there is a solution. If there are multiple solutions, any of them will be accepted.\n\nConstraints\n\n0≤A,B,C,D≤9\n\nAll input values are integers.\n\nIt is guaranteed that there is a solution.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nABCD\n\nOutput\n\nPrint the formula you made, including the part =7.\n\nUse the signs + and -.\n\nDo not print a space between a digit and a sign.\n\nSample Input 1\n\n1222\n\nSample Output 1\n\n1+2+2+2=7\n\nThis is the only valid solution.\n\nSample Input 2\n\n0290\n\nSample Output 2\n\n0-2+9+0=7\n\n0 - 2 + 9 - 0 = 7 is also a valid solution.\n\nSample Input 3\n\n3242\n\nSample Output 3\n\n3+2+4-2=7", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 715, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s667491545", "group_id": "codeNet:p03546", "input_text": "local h,w=io.read(\"n\",\"n\")\nlocal c={}\nfor i=0,9 do\n c[i]={}\n for j=0,9 do\n c[i][j]=io.read(\"n\")\n end\nend\n\n--Warshall-Floyd法\nfor k=0,9 do\n for i=0,9 do\n for j=0,9 do\n c[i][j]=math.min(c[i][j],c[i][k]+c[k][j])\n end\n end\nend\n\nlocal counter=0\nfor i=1,h do\n for j=1,w do\n local input=io.read(\"n\")\n if input>=0 then\n counter=counter+c[input][1]\n end\n end\nend\nprint(counter)", "language": "Lua", "metadata": {"date": 1593110347, "filename_ext": "lua", "original_language": "Lua (LuaJIT 2.1.0)", "problem_description_relpath": "problem_descriptions/p03546.html", "problem_id": "p03546", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03546/input.txt", "sample_output_relpath": "derived/input_output/data/p03546/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03546/Lua/s667491545.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s667491545", "user_id": "u045238009"}, "prompt_components": {"gold_output": "12\n", "input_to_evaluate": "local h,w=io.read(\"n\",\"n\")\nlocal c={}\nfor i=0,9 do\n c[i]={}\n for j=0,9 do\n c[i][j]=io.read(\"n\")\n end\nend\n\n--Warshall-Floyd法\nfor k=0,9 do\n for i=0,9 do\n for j=0,9 do\n c[i][j]=math.min(c[i][j],c[i][k]+c[k][j])\n end\n end\nend\n\nlocal counter=0\nfor i=1,h do\n for j=1,w do\n local input=io.read(\"n\")\n if input>=0 then\n counter=counter+c[input][1]\n end\n end\nend\nprint(counter)", "problem_context": "Score : 400 points\n\nProblem Statement\n\nJoisino the magical girl has decided to turn every single digit that exists on this world into 1.\n\nRewriting a digit i with j (0≤i,j≤9) costs c_{i,j} MP (Magic Points).\n\nShe is now standing before a wall. The wall is divided into HW squares in H rows and W columns, and at least one square contains a digit between 0 and 9 (inclusive).\n\nYou are given A_{i,j} that describes the square at the i-th row from the top and j-th column from the left, as follows:\n\nIf A_{i,j}≠-1, the square contains a digit A_{i,j}.\n\nIf A_{i,j}=-1, the square does not contain a digit.\n\nFind the minimum total amount of MP required to turn every digit on this wall into 1 in the end.\n\nConstraints\n\n1≤H,W≤200\n\n1≤c_{i,j}≤10^3 (i≠j)\n\nc_{i,j}=0 (i=j)\n\n-1≤A_{i,j}≤9\n\nAll input values are integers.\n\nThere is at least one digit on the wall.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\nc_{0,0} ... c_{0,9}\n:\nc_{9,0} ... c_{9,9}\nA_{1,1} ... A_{1,W}\n:\nA_{H,1} ... A_{H,W}\n\nOutput\n\nPrint the minimum total amount of MP required to turn every digit on the wall into 1 in the end.\n\nSample Input 1\n\n2 4\n0 9 9 9 9 9 9 9 9 9\n9 0 9 9 9 9 9 9 9 9\n9 9 0 9 9 9 9 9 9 9\n9 9 9 0 9 9 9 9 9 9\n9 9 9 9 0 9 9 9 9 2\n9 9 9 9 9 0 9 9 9 9\n9 9 9 9 9 9 0 9 9 9\n9 9 9 9 9 9 9 0 9 9\n9 9 9 9 2 9 9 9 0 9\n9 2 9 9 9 9 9 9 9 0\n-1 -1 -1 -1\n8 1 1 8\n\nSample Output 1\n\n12\n\nTo turn a single 8 into 1, it is optimal to first turn 8 into 4, then turn 4 into 9, and finally turn 9 into 1, costing 6 MP.\n\nThe wall contains two 8s, so the minimum total MP required is 6×2=12.\n\nSample Input 2\n\n5 5\n0 999 999 999 999 999 999 999 999 999\n999 0 999 999 999 999 999 999 999 999\n999 999 0 999 999 999 999 999 999 999\n999 999 999 0 999 999 999 999 999 999\n999 999 999 999 0 999 999 999 999 999\n999 999 999 999 999 0 999 999 999 999\n999 999 999 999 999 999 0 999 999 999\n999 999 999 999 999 999 999 0 999 999\n999 999 999 999 999 999 999 999 0 999\n999 999 999 999 999 999 999 999 999 0\n1 1 1 1 1\n1 1 1 1 1\n1 1 1 1 1\n1 1 1 1 1\n1 1 1 1 1\n\nSample Output 2\n\n0\n\nNote that she may not need to change any digit.\n\nSample Input 3\n\n3 5\n0 4 3 6 2 7 2 5 3 3\n4 0 5 3 7 5 3 7 2 7\n5 7 0 7 2 9 3 2 9 1\n3 6 2 0 2 4 6 4 2 3\n3 5 7 4 0 6 9 7 6 7\n9 8 5 2 2 0 4 7 6 5\n5 4 6 3 2 3 0 5 4 3\n3 6 2 3 4 2 4 0 8 9\n4 6 5 4 3 5 3 2 0 8\n2 1 3 4 5 7 8 6 4 0\n3 5 2 6 1\n2 5 3 2 1\n6 9 2 5 6\n\nSample Output 3\n\n47", "sample_input": "2 4\n0 9 9 9 9 9 9 9 9 9\n9 0 9 9 9 9 9 9 9 9\n9 9 0 9 9 9 9 9 9 9\n9 9 9 0 9 9 9 9 9 9\n9 9 9 9 0 9 9 9 9 2\n9 9 9 9 9 0 9 9 9 9\n9 9 9 9 9 9 0 9 9 9\n9 9 9 9 9 9 9 0 9 9\n9 9 9 9 2 9 9 9 0 9\n9 2 9 9 9 9 9 9 9 0\n-1 -1 -1 -1\n8 1 1 8\n"}, "reference_outputs": ["12\n"], "source_document_id": "p03546", "source_text": "Score : 400 points\n\nProblem Statement\n\nJoisino the magical girl has decided to turn every single digit that exists on this world into 1.\n\nRewriting a digit i with j (0≤i,j≤9) costs c_{i,j} MP (Magic Points).\n\nShe is now standing before a wall. The wall is divided into HW squares in H rows and W columns, and at least one square contains a digit between 0 and 9 (inclusive).\n\nYou are given A_{i,j} that describes the square at the i-th row from the top and j-th column from the left, as follows:\n\nIf A_{i,j}≠-1, the square contains a digit A_{i,j}.\n\nIf A_{i,j}=-1, the square does not contain a digit.\n\nFind the minimum total amount of MP required to turn every digit on this wall into 1 in the end.\n\nConstraints\n\n1≤H,W≤200\n\n1≤c_{i,j}≤10^3 (i≠j)\n\nc_{i,j}=0 (i=j)\n\n-1≤A_{i,j}≤9\n\nAll input values are integers.\n\nThere is at least one digit on the wall.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\nc_{0,0} ... c_{0,9}\n:\nc_{9,0} ... c_{9,9}\nA_{1,1} ... A_{1,W}\n:\nA_{H,1} ... A_{H,W}\n\nOutput\n\nPrint the minimum total amount of MP required to turn every digit on the wall into 1 in the end.\n\nSample Input 1\n\n2 4\n0 9 9 9 9 9 9 9 9 9\n9 0 9 9 9 9 9 9 9 9\n9 9 0 9 9 9 9 9 9 9\n9 9 9 0 9 9 9 9 9 9\n9 9 9 9 0 9 9 9 9 2\n9 9 9 9 9 0 9 9 9 9\n9 9 9 9 9 9 0 9 9 9\n9 9 9 9 9 9 9 0 9 9\n9 9 9 9 2 9 9 9 0 9\n9 2 9 9 9 9 9 9 9 0\n-1 -1 -1 -1\n8 1 1 8\n\nSample Output 1\n\n12\n\nTo turn a single 8 into 1, it is optimal to first turn 8 into 4, then turn 4 into 9, and finally turn 9 into 1, costing 6 MP.\n\nThe wall contains two 8s, so the minimum total MP required is 6×2=12.\n\nSample Input 2\n\n5 5\n0 999 999 999 999 999 999 999 999 999\n999 0 999 999 999 999 999 999 999 999\n999 999 0 999 999 999 999 999 999 999\n999 999 999 0 999 999 999 999 999 999\n999 999 999 999 0 999 999 999 999 999\n999 999 999 999 999 0 999 999 999 999\n999 999 999 999 999 999 0 999 999 999\n999 999 999 999 999 999 999 0 999 999\n999 999 999 999 999 999 999 999 0 999\n999 999 999 999 999 999 999 999 999 0\n1 1 1 1 1\n1 1 1 1 1\n1 1 1 1 1\n1 1 1 1 1\n1 1 1 1 1\n\nSample Output 2\n\n0\n\nNote that she may not need to change any digit.\n\nSample Input 3\n\n3 5\n0 4 3 6 2 7 2 5 3 3\n4 0 5 3 7 5 3 7 2 7\n5 7 0 7 2 9 3 2 9 1\n3 6 2 0 2 4 6 4 2 3\n3 5 7 4 0 6 9 7 6 7\n9 8 5 2 2 0 4 7 6 5\n5 4 6 3 2 3 0 5 4 3\n3 6 2 3 4 2 4 0 8 9\n4 6 5 4 3 5 3 2 0 8\n2 1 3 4 5 7 8 6 4 0\n3 5 2 6 1\n2 5 3 2 1\n6 9 2 5 6\n\nSample Output 3\n\n47", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 454, "cpu_time_ms": 19, "memory_kb": 2704}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s050085590", "group_id": "codeNet:p03547", "input_text": "x = io.read()\na, b = x:match(\"(%w) (%w)\")\nif a < b then\n print(\"<\")\nelseif a == b then\n print(\"=\")\nelse\n print(\">\")\nend", "language": "Lua", "metadata": {"date": 1568805773, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03547.html", "problem_id": "p03547", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03547/input.txt", "sample_output_relpath": "derived/input_output/data/p03547/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03547/Lua/s050085590.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s050085590", "user_id": "u120582723"}, "prompt_components": {"gold_output": "<\n", "input_to_evaluate": "x = io.read()\na, b = x:match(\"(%w) (%w)\")\nif a < b then\n print(\"<\")\nelseif a == b then\n print(\"=\")\nelse\n print(\">\")\nend", "problem_context": "Score : 100 points\n\nProblem Statement\n\nIn programming, hexadecimal notation is often used.\n\nIn hexadecimal notation, besides the ten digits 0, 1, ..., 9, the six letters A, B, C, D, E and F are used to represent the values 10, 11, 12, 13, 14 and 15, respectively.\n\nIn this problem, you are given two letters X and Y. Each X and Y is A, B, C, D, E or F.\n\nWhen X and Y are seen as hexadecimal numbers, which is larger?\n\nConstraints\n\nEach X and Y is A, B, C, D, E or F.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX Y\n\nOutput\n\nIf X is smaller, print <; if Y is smaller, print >; if they are equal, print =.\n\nSample Input 1\n\nA B\n\nSample Output 1\n\n<\n\n10 < 11.\n\nSample Input 2\n\nE C\n\nSample Output 2\n\n>\n\n14 > 12.\n\nSample Input 3\n\nF F\n\nSample Output 3\n\n=\n\n15 = 15.", "sample_input": "A B\n"}, "reference_outputs": ["<\n"], "source_document_id": "p03547", "source_text": "Score : 100 points\n\nProblem Statement\n\nIn programming, hexadecimal notation is often used.\n\nIn hexadecimal notation, besides the ten digits 0, 1, ..., 9, the six letters A, B, C, D, E and F are used to represent the values 10, 11, 12, 13, 14 and 15, respectively.\n\nIn this problem, you are given two letters X and Y. Each X and Y is A, B, C, D, E or F.\n\nWhen X and Y are seen as hexadecimal numbers, which is larger?\n\nConstraints\n\nEach X and Y is A, B, C, D, E or F.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX Y\n\nOutput\n\nIf X is smaller, print <; if Y is smaller, print >; if they are equal, print =.\n\nSample Input 1\n\nA B\n\nSample Output 1\n\n<\n\n10 < 11.\n\nSample Input 2\n\nE C\n\nSample Output 2\n\n>\n\n14 > 12.\n\nSample Input 3\n\nF F\n\nSample Output 3\n\n=\n\n15 = 15.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 122, "cpu_time_ms": 7, "memory_kb": 888}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s159486936", "group_id": "codeNet:p03548", "input_text": "local x, y, z = io.read(\"*n\", \"*n\", \"*n\")\nx = x - z\nprint(x // (y + z))\n", "language": "Lua", "metadata": {"date": 1568520278, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03548.html", "problem_id": "p03548", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03548/input.txt", "sample_output_relpath": "derived/input_output/data/p03548/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03548/Lua/s159486936.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s159486936", "user_id": "u120582723"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "local x, y, z = io.read(\"*n\", \"*n\", \"*n\")\nx = x - z\nprint(x // (y + z))\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nWe have a long seat of width X centimeters.\nThere are many people who wants to sit here. A person sitting on the seat will always occupy an interval of length Y centimeters.\n\nWe would like to seat as many people as possible, but they are all very shy, and there must be a gap of length at least Z centimeters between two people, and between the end of the seat and a person.\n\nAt most how many people can sit on the seat?\n\nConstraints\n\nAll input values are integers.\n\n1 \\leq X, Y, Z \\leq 10^5\n\nY+2Z \\leq X\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX Y Z\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n13 3 1\n\nSample Output 1\n\n3\n\nThere is just enough room for three, as shown below:\n\nFigure\n\nSample Input 2\n\n12 3 1\n\nSample Output 2\n\n2\n\nSample Input 3\n\n100000 1 1\n\nSample Output 3\n\n49999\n\nSample Input 4\n\n64146 123 456\n\nSample Output 4\n\n110\n\nSample Input 5\n\n64145 123 456\n\nSample Output 5\n\n109", "sample_input": "13 3 1\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03548", "source_text": "Score : 200 points\n\nProblem Statement\n\nWe have a long seat of width X centimeters.\nThere are many people who wants to sit here. A person sitting on the seat will always occupy an interval of length Y centimeters.\n\nWe would like to seat as many people as possible, but they are all very shy, and there must be a gap of length at least Z centimeters between two people, and between the end of the seat and a person.\n\nAt most how many people can sit on the seat?\n\nConstraints\n\nAll input values are integers.\n\n1 \\leq X, Y, Z \\leq 10^5\n\nY+2Z \\leq X\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX Y Z\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n13 3 1\n\nSample Output 1\n\n3\n\nThere is just enough room for three, as shown below:\n\nFigure\n\nSample Input 2\n\n12 3 1\n\nSample Output 2\n\n2\n\nSample Input 3\n\n100000 1 1\n\nSample Output 3\n\n49999\n\nSample Input 4\n\n64146 123 456\n\nSample Output 4\n\n110\n\nSample Input 5\n\n64145 123 456\n\nSample Output 5\n\n109", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 72, "cpu_time_ms": 8, "memory_kb": 888}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s540078766", "group_id": "codeNet:p03549", "input_text": "local a, b = io.read(\"*n\", \"*n\")\nprint(((a - b) * 100 + b * 1900) * 2^b)\n", "language": "Lua", "metadata": {"date": 1558917701, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p03549.html", "problem_id": "p03549", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03549/input.txt", "sample_output_relpath": "derived/input_output/data/p03549/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03549/Lua/s540078766.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s540078766", "user_id": "u120582723"}, "prompt_components": {"gold_output": "3800\n", "input_to_evaluate": "local a, b = io.read(\"*n\", \"*n\")\nprint(((a - b) * 100 + b * 1900) * 2^b)\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nTakahashi is now competing in a programming contest, but he received TLE in a problem where the answer is YES or NO.\n\nWhen he checked the detailed status of the submission, there were N test cases in the problem, and the code received TLE in M of those cases.\n\nThen, he rewrote the code to correctly solve each of those M cases with 1/2 probability in 1900 milliseconds, and correctly solve each of the other N-M cases without fail in 100 milliseconds.\n\nNow, he goes through the following process:\n\nSubmit the code.\n\nWait until the code finishes execution on all the cases.\n\nIf the code fails to correctly solve some of the M cases, submit it again.\n\nRepeat until the code correctly solve all the cases in one submission.\n\nLet the expected value of the total execution time of the code be X milliseconds. Print X (as an integer).\n\nConstraints\n\nAll input values are integers.\n\n1 \\leq N \\leq 100\n\n1 \\leq M \\leq {\\rm min}(N, 5)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\n\nOutput\n\nPrint X, the expected value of the total execution time of the code, as an integer. It can be proved that, under the constraints in this problem, X is an integer not exceeding 10^9.\n\nSample Input 1\n\n1 1\n\nSample Output 1\n\n3800\n\nIn this input, there is only one case. Takahashi will repeatedly submit the code that correctly solves this case with 1/2 probability in 1900 milliseconds.\n\nThe code will succeed in one attempt with 1/2 probability, in two attempts with 1/4 probability, and in three attempts with 1/8 probability, and so on.\n\nThus, the answer is 1900 \\times 1/2 + (2 \\times 1900) \\times 1/4 + (3 \\times 1900) \\times 1/8 + ... = 3800.\n\nSample Input 2\n\n10 2\n\nSample Output 2\n\n18400\n\nThe code will take 1900 milliseconds in each of the 2 cases, and 100 milliseconds in each of the 10-2=8 cases. The probability of the code correctly solving all the cases is 1/2 \\times 1/2 = 1/4.\n\nSample Input 3\n\n100 5\n\nSample Output 3\n\n608000", "sample_input": "1 1\n"}, "reference_outputs": ["3800\n"], "source_document_id": "p03549", "source_text": "Score : 300 points\n\nProblem Statement\n\nTakahashi is now competing in a programming contest, but he received TLE in a problem where the answer is YES or NO.\n\nWhen he checked the detailed status of the submission, there were N test cases in the problem, and the code received TLE in M of those cases.\n\nThen, he rewrote the code to correctly solve each of those M cases with 1/2 probability in 1900 milliseconds, and correctly solve each of the other N-M cases without fail in 100 milliseconds.\n\nNow, he goes through the following process:\n\nSubmit the code.\n\nWait until the code finishes execution on all the cases.\n\nIf the code fails to correctly solve some of the M cases, submit it again.\n\nRepeat until the code correctly solve all the cases in one submission.\n\nLet the expected value of the total execution time of the code be X milliseconds. Print X (as an integer).\n\nConstraints\n\nAll input values are integers.\n\n1 \\leq N \\leq 100\n\n1 \\leq M \\leq {\\rm min}(N, 5)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\n\nOutput\n\nPrint X, the expected value of the total execution time of the code, as an integer. It can be proved that, under the constraints in this problem, X is an integer not exceeding 10^9.\n\nSample Input 1\n\n1 1\n\nSample Output 1\n\n3800\n\nIn this input, there is only one case. Takahashi will repeatedly submit the code that correctly solves this case with 1/2 probability in 1900 milliseconds.\n\nThe code will succeed in one attempt with 1/2 probability, in two attempts with 1/4 probability, and in three attempts with 1/8 probability, and so on.\n\nThus, the answer is 1900 \\times 1/2 + (2 \\times 1900) \\times 1/4 + (3 \\times 1900) \\times 1/8 + ... = 3800.\n\nSample Input 2\n\n10 2\n\nSample Output 2\n\n18400\n\nThe code will take 1900 milliseconds in each of the 2 cases, and 100 milliseconds in each of the 10-2=8 cases. The probability of the code correctly solving all the cases is 1/2 \\times 1/2 = 1/4.\n\nSample Input 3\n\n100 5\n\nSample Output 3\n\n608000", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 74, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s216175021", "group_id": "codeNet:p03550", "input_text": "N=io.read(\"n\")\nZ=io.read(\"n\")\nW=io.read(\"n\")\na={}\nb={}\nfor i=1,N do\n a[i]=io.read(\"n\")\n b[i]=a[i]\nend\ntable.sort(b)\nt={}\nt[1]=math.abs(a[N]-W)\nt[2]=math.abs(b[1]-a[N])\nt[3]=math.abs(b[N]-a[N])\nt[4]=math.abs(a[N]-Z)\ntable.sort(t)\nprint(t[4])", "language": "Lua", "metadata": {"date": 1551320485, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03550.html", "problem_id": "p03550", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03550/input.txt", "sample_output_relpath": "derived/input_output/data/p03550/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03550/Lua/s216175021.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s216175021", "user_id": "u015229643"}, "prompt_components": {"gold_output": "900\n", "input_to_evaluate": "N=io.read(\"n\")\nZ=io.read(\"n\")\nW=io.read(\"n\")\na={}\nb={}\nfor i=1,N do\n a[i]=io.read(\"n\")\n b[i]=a[i]\nend\ntable.sort(b)\nt={}\nt[1]=math.abs(a[N]-W)\nt[2]=math.abs(b[1]-a[N])\nt[3]=math.abs(b[N]-a[N])\nt[4]=math.abs(a[N]-Z)\ntable.sort(t)\nprint(t[4])", "problem_context": "Score : 500 points\n\nProblem Statement\n\nWe have a deck consisting of N cards. Each card has an integer written on it. The integer on the i-th card from the top is a_i.\n\nTwo people X and Y will play a game using this deck. Initially, X has a card with Z written on it in his hand, and Y has a card with W written on it in his hand. Then, starting from X, they will alternately perform the following action:\n\nDraw some number of cards from the top of the deck. Then, discard the card in his hand and keep the last drawn card instead. Here, at least one card must be drawn.\n\nThe game ends when there is no more card in the deck. The score of the game is the absolute difference of the integers written on the cards in the two players' hand.\n\nX will play the game so that the score will be maximized, and Y will play the game so that the score will be minimized. What will be the score of the game?\n\nConstraints\n\nAll input values are integers.\n\n1 \\leq N \\leq 2000\n\n1 \\leq Z, W, a_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN Z W\na_1 a_2 ... a_N\n\nOutput\n\nPrint the score.\n\nSample Input 1\n\n3 100 100\n10 1000 100\n\nSample Output 1\n\n900\n\nIf X draws two cards first, Y will draw the last card, and the score will be |1000 - 100| = 900.\n\nSample Input 2\n\n3 100 1000\n10 100 100\n\nSample Output 2\n\n900\n\nIf X draws all the cards first, the score will be |1000 - 100| = 900.\n\nSample Input 3\n\n5 1 1\n1 1 1 1 1\n\nSample Output 3\n\n0\n\nSample Input 4\n\n1 1 1\n1000000000\n\nSample Output 4\n\n999999999", "sample_input": "3 100 100\n10 1000 100\n"}, "reference_outputs": ["900\n"], "source_document_id": "p03550", "source_text": "Score : 500 points\n\nProblem Statement\n\nWe have a deck consisting of N cards. Each card has an integer written on it. The integer on the i-th card from the top is a_i.\n\nTwo people X and Y will play a game using this deck. Initially, X has a card with Z written on it in his hand, and Y has a card with W written on it in his hand. Then, starting from X, they will alternately perform the following action:\n\nDraw some number of cards from the top of the deck. Then, discard the card in his hand and keep the last drawn card instead. Here, at least one card must be drawn.\n\nThe game ends when there is no more card in the deck. The score of the game is the absolute difference of the integers written on the cards in the two players' hand.\n\nX will play the game so that the score will be maximized, and Y will play the game so that the score will be minimized. What will be the score of the game?\n\nConstraints\n\nAll input values are integers.\n\n1 \\leq N \\leq 2000\n\n1 \\leq Z, W, a_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN Z W\na_1 a_2 ... a_N\n\nOutput\n\nPrint the score.\n\nSample Input 1\n\n3 100 100\n10 1000 100\n\nSample Output 1\n\n900\n\nIf X draws two cards first, Y will draw the last card, and the score will be |1000 - 100| = 900.\n\nSample Input 2\n\n3 100 1000\n10 100 100\n\nSample Output 2\n\n900\n\nIf X draws all the cards first, the score will be |1000 - 100| = 900.\n\nSample Input 3\n\n5 1 1\n1 1 1 1 1\n\nSample Output 3\n\n0\n\nSample Input 4\n\n1 1 1\n1000000000\n\nSample Output 4\n\n999999999", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 242, "cpu_time_ms": 7, "memory_kb": 888}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s633257929", "group_id": "codeNet:p03550", "input_text": "function binary_search(tbl, key, imin, imax)\n if imax < imin then\n return imin\n end\n \n local imid = imin + math.floor((imax - imin)/2)\n if tbl[imid] > key then\n return binary_search(tbl, key, imin, imid - 1)\n elseif tbl[imid] < key then\n return binary_search(tbl, key, imid + 1, imax)\n else\n return imid\n end\nend\n\nfunction main()\n local input_nzw = string.gmatch(io.read(), \"%d+\")\n local n = tonumber(input_nzw())\n local z = tonumber(input_nzw())\n local w = tonumber(input_nzw())\n local a = {}\n for i in string.gmatch(io.read(), \"%d+\") do\n table.insert(a, tonumber(i))\n end\n \n if #a == 0 then\n return math.abs(z - w)\n end\n \n local sorted_nums = {a[#a]}\n local max_diff = math.abs(a[#a] - w)\n for i = #a - 1, 1, -1 do\n local idx = binary_search(sorted_nums, a[i], 1, #sorted_nums)\n local min_diff = 1000000000\n if idx <= #sorted_nums then\n min_diff = math.abs(sorted_nums[idx] - a[i])\n end\n if idx >= 2 then\n local diff = math.abs(sorted_nums[idx-1] - a[i])\n if diff < min_diff then\n min_diff = diff\n end\n end\n if min_diff > max_diff then\n max_diff = min_diff\n end\n table.insert(sorted_nums, idx, a[i])\n end\n return max_diff\nend\n\nprint(main())", "language": "Lua", "metadata": {"date": 1510552539, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p03550.html", "problem_id": "p03550", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03550/input.txt", "sample_output_relpath": "derived/input_output/data/p03550/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03550/Lua/s633257929.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s633257929", "user_id": "u940915899"}, "prompt_components": {"gold_output": "900\n", "input_to_evaluate": "function binary_search(tbl, key, imin, imax)\n if imax < imin then\n return imin\n end\n \n local imid = imin + math.floor((imax - imin)/2)\n if tbl[imid] > key then\n return binary_search(tbl, key, imin, imid - 1)\n elseif tbl[imid] < key then\n return binary_search(tbl, key, imid + 1, imax)\n else\n return imid\n end\nend\n\nfunction main()\n local input_nzw = string.gmatch(io.read(), \"%d+\")\n local n = tonumber(input_nzw())\n local z = tonumber(input_nzw())\n local w = tonumber(input_nzw())\n local a = {}\n for i in string.gmatch(io.read(), \"%d+\") do\n table.insert(a, tonumber(i))\n end\n \n if #a == 0 then\n return math.abs(z - w)\n end\n \n local sorted_nums = {a[#a]}\n local max_diff = math.abs(a[#a] - w)\n for i = #a - 1, 1, -1 do\n local idx = binary_search(sorted_nums, a[i], 1, #sorted_nums)\n local min_diff = 1000000000\n if idx <= #sorted_nums then\n min_diff = math.abs(sorted_nums[idx] - a[i])\n end\n if idx >= 2 then\n local diff = math.abs(sorted_nums[idx-1] - a[i])\n if diff < min_diff then\n min_diff = diff\n end\n end\n if min_diff > max_diff then\n max_diff = min_diff\n end\n table.insert(sorted_nums, idx, a[i])\n end\n return max_diff\nend\n\nprint(main())", "problem_context": "Score : 500 points\n\nProblem Statement\n\nWe have a deck consisting of N cards. Each card has an integer written on it. The integer on the i-th card from the top is a_i.\n\nTwo people X and Y will play a game using this deck. Initially, X has a card with Z written on it in his hand, and Y has a card with W written on it in his hand. Then, starting from X, they will alternately perform the following action:\n\nDraw some number of cards from the top of the deck. Then, discard the card in his hand and keep the last drawn card instead. Here, at least one card must be drawn.\n\nThe game ends when there is no more card in the deck. The score of the game is the absolute difference of the integers written on the cards in the two players' hand.\n\nX will play the game so that the score will be maximized, and Y will play the game so that the score will be minimized. What will be the score of the game?\n\nConstraints\n\nAll input values are integers.\n\n1 \\leq N \\leq 2000\n\n1 \\leq Z, W, a_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN Z W\na_1 a_2 ... a_N\n\nOutput\n\nPrint the score.\n\nSample Input 1\n\n3 100 100\n10 1000 100\n\nSample Output 1\n\n900\n\nIf X draws two cards first, Y will draw the last card, and the score will be |1000 - 100| = 900.\n\nSample Input 2\n\n3 100 1000\n10 100 100\n\nSample Output 2\n\n900\n\nIf X draws all the cards first, the score will be |1000 - 100| = 900.\n\nSample Input 3\n\n5 1 1\n1 1 1 1 1\n\nSample Output 3\n\n0\n\nSample Input 4\n\n1 1 1\n1000000000\n\nSample Output 4\n\n999999999", "sample_input": "3 100 100\n10 1000 100\n"}, "reference_outputs": ["900\n"], "source_document_id": "p03550", "source_text": "Score : 500 points\n\nProblem Statement\n\nWe have a deck consisting of N cards. Each card has an integer written on it. The integer on the i-th card from the top is a_i.\n\nTwo people X and Y will play a game using this deck. Initially, X has a card with Z written on it in his hand, and Y has a card with W written on it in his hand. Then, starting from X, they will alternately perform the following action:\n\nDraw some number of cards from the top of the deck. Then, discard the card in his hand and keep the last drawn card instead. Here, at least one card must be drawn.\n\nThe game ends when there is no more card in the deck. The score of the game is the absolute difference of the integers written on the cards in the two players' hand.\n\nX will play the game so that the score will be maximized, and Y will play the game so that the score will be minimized. What will be the score of the game?\n\nConstraints\n\nAll input values are integers.\n\n1 \\leq N \\leq 2000\n\n1 \\leq Z, W, a_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN Z W\na_1 a_2 ... a_N\n\nOutput\n\nPrint the score.\n\nSample Input 1\n\n3 100 100\n10 1000 100\n\nSample Output 1\n\n900\n\nIf X draws two cards first, Y will draw the last card, and the score will be |1000 - 100| = 900.\n\nSample Input 2\n\n3 100 1000\n10 100 100\n\nSample Output 2\n\n900\n\nIf X draws all the cards first, the score will be |1000 - 100| = 900.\n\nSample Input 3\n\n5 1 1\n1 1 1 1 1\n\nSample Output 3\n\n0\n\nSample Input 4\n\n1 1 1\n1000000000\n\nSample Output 4\n\n999999999", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1389, "cpu_time_ms": 5, "memory_kb": 384}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s856781246", "group_id": "codeNet:p03553", "input_text": "n = io.read('*n')\na = {}\nfor i = 1, n do\n a[i] = io.read('*n')\nend\n\nfor i = n, 1, -1 do\n local sum = 0\n for j = i, n, i do\n sum = sum + a[j]\n end\n if sum < 0 then\n for j = i, n, i do\n a[j] = 0\n end\n end\nend\n\ntotal = 0\nfor i = 1, n do\n total = total + a[i]\nend\nio.write(total, '\\n')\n", "language": "Lua", "metadata": {"date": 1550895095, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p03553.html", "problem_id": "p03553", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03553/input.txt", "sample_output_relpath": "derived/input_output/data/p03553/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03553/Lua/s856781246.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s856781246", "user_id": "u390181802"}, "prompt_components": {"gold_output": "12\n", "input_to_evaluate": "n = io.read('*n')\na = {}\nfor i = 1, n do\n a[i] = io.read('*n')\nend\n\nfor i = n, 1, -1 do\n local sum = 0\n for j = i, n, i do\n sum = sum + a[j]\n end\n if sum < 0 then\n for j = i, n, i do\n a[j] = 0\n end\n end\nend\n\ntotal = 0\nfor i = 1, n do\n total = total + a[i]\nend\nio.write(total, '\\n')\n", "problem_context": "Score : 700 points\n\nProblem Statement\n\nWe have N gemstones labeled 1 through N.\n\nYou can perform the following operation any number of times (possibly zero).\n\nSelect a positive integer x, and smash all the gems labeled with multiples of x.\n\nThen, for each i, if the gem labeled i remains without getting smashed, you will receive a_i yen (the currency of Japan).\nHowever, a_i may be negative, in which case you will be charged money.\n\nBy optimally performing the operation, how much yen can you earn?\n\nConstraints\n\nAll input values are integers.\n\n1 \\leq N \\leq 100\n\n|a_i| \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 ... a_N\n\nOutput\n\nPrint the maximum amount of money that can be earned.\n\nSample Input 1\n\n6\n1 2 -6 4 5 3\n\nSample Output 1\n\n12\n\nIt is optimal to smash Gem 3 and 6.\n\nSample Input 2\n\n6\n100 -100 -100 -100 100 -100\n\nSample Output 2\n\n200\n\nSample Input 3\n\n5\n-1 -2 -3 -4 -5\n\nSample Output 3\n\n0\n\nIt is optimal to smash all the gems.\n\nSample Input 4\n\n2\n-1000 100000\n\nSample Output 4\n\n99000", "sample_input": "6\n1 2 -6 4 5 3\n"}, "reference_outputs": ["12\n"], "source_document_id": "p03553", "source_text": "Score : 700 points\n\nProblem Statement\n\nWe have N gemstones labeled 1 through N.\n\nYou can perform the following operation any number of times (possibly zero).\n\nSelect a positive integer x, and smash all the gems labeled with multiples of x.\n\nThen, for each i, if the gem labeled i remains without getting smashed, you will receive a_i yen (the currency of Japan).\nHowever, a_i may be negative, in which case you will be charged money.\n\nBy optimally performing the operation, how much yen can you earn?\n\nConstraints\n\nAll input values are integers.\n\n1 \\leq N \\leq 100\n\n|a_i| \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 ... a_N\n\nOutput\n\nPrint the maximum amount of money that can be earned.\n\nSample Input 1\n\n6\n1 2 -6 4 5 3\n\nSample Output 1\n\n12\n\nIt is optimal to smash Gem 3 and 6.\n\nSample Input 2\n\n6\n100 -100 -100 -100 100 -100\n\nSample Output 2\n\n200\n\nSample Input 3\n\n5\n-1 -2 -3 -4 -5\n\nSample Output 3\n\n0\n\nIt is optimal to smash all the gems.\n\nSample Input 4\n\n2\n-1000 100000\n\nSample Output 4\n\n99000", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 303, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s738919306", "group_id": "codeNet:p03553", "input_text": "n = io.read('n')\na = {}\nfor i = 1, n do\n a[i] = io.read('n')\nend\n\nfor i = n, 1, -1 do\n local sum = 0\n for j = i, n, i do\n sum = sum + a[j]\n end\n if sum < 0 then\n for j = i, n, i do\n a[j] = 0\n end\n end\nend\n\ntotal = 0\nfor i = 1, n do\n total = total + a[i]\nend\nio.write(total, '\\n')\n", "language": "Lua", "metadata": {"date": 1550895041, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p03553.html", "problem_id": "p03553", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03553/input.txt", "sample_output_relpath": "derived/input_output/data/p03553/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03553/Lua/s738919306.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s738919306", "user_id": "u390181802"}, "prompt_components": {"gold_output": "12\n", "input_to_evaluate": "n = io.read('n')\na = {}\nfor i = 1, n do\n a[i] = io.read('n')\nend\n\nfor i = n, 1, -1 do\n local sum = 0\n for j = i, n, i do\n sum = sum + a[j]\n end\n if sum < 0 then\n for j = i, n, i do\n a[j] = 0\n end\n end\nend\n\ntotal = 0\nfor i = 1, n do\n total = total + a[i]\nend\nio.write(total, '\\n')\n", "problem_context": "Score : 700 points\n\nProblem Statement\n\nWe have N gemstones labeled 1 through N.\n\nYou can perform the following operation any number of times (possibly zero).\n\nSelect a positive integer x, and smash all the gems labeled with multiples of x.\n\nThen, for each i, if the gem labeled i remains without getting smashed, you will receive a_i yen (the currency of Japan).\nHowever, a_i may be negative, in which case you will be charged money.\n\nBy optimally performing the operation, how much yen can you earn?\n\nConstraints\n\nAll input values are integers.\n\n1 \\leq N \\leq 100\n\n|a_i| \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 ... a_N\n\nOutput\n\nPrint the maximum amount of money that can be earned.\n\nSample Input 1\n\n6\n1 2 -6 4 5 3\n\nSample Output 1\n\n12\n\nIt is optimal to smash Gem 3 and 6.\n\nSample Input 2\n\n6\n100 -100 -100 -100 100 -100\n\nSample Output 2\n\n200\n\nSample Input 3\n\n5\n-1 -2 -3 -4 -5\n\nSample Output 3\n\n0\n\nIt is optimal to smash all the gems.\n\nSample Input 4\n\n2\n-1000 100000\n\nSample Output 4\n\n99000", "sample_input": "6\n1 2 -6 4 5 3\n"}, "reference_outputs": ["12\n"], "source_document_id": "p03553", "source_text": "Score : 700 points\n\nProblem Statement\n\nWe have N gemstones labeled 1 through N.\n\nYou can perform the following operation any number of times (possibly zero).\n\nSelect a positive integer x, and smash all the gems labeled with multiples of x.\n\nThen, for each i, if the gem labeled i remains without getting smashed, you will receive a_i yen (the currency of Japan).\nHowever, a_i may be negative, in which case you will be charged money.\n\nBy optimally performing the operation, how much yen can you earn?\n\nConstraints\n\nAll input values are integers.\n\n1 \\leq N \\leq 100\n\n|a_i| \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 ... a_N\n\nOutput\n\nPrint the maximum amount of money that can be earned.\n\nSample Input 1\n\n6\n1 2 -6 4 5 3\n\nSample Output 1\n\n12\n\nIt is optimal to smash Gem 3 and 6.\n\nSample Input 2\n\n6\n100 -100 -100 -100 100 -100\n\nSample Output 2\n\n200\n\nSample Input 3\n\n5\n-1 -2 -3 -4 -5\n\nSample Output 3\n\n0\n\nIt is optimal to smash all the gems.\n\nSample Input 4\n\n2\n-1000 100000\n\nSample Output 4\n\n99000", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 301, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s545544792", "group_id": "codeNet:p03555", "input_text": "a = io.read()\nb = io.read()\nif a:sub(1, 1) == b:sub(3, 3) and a:sub(2, 2) == b:sub(2, 2) and a:sub(3, 3) == b:sub(1, 1) then\n print(\"YES\")\nelse\n print(\"NO\")\nend\n", "language": "Lua", "metadata": {"date": 1569933361, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03555.html", "problem_id": "p03555", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03555/input.txt", "sample_output_relpath": "derived/input_output/data/p03555/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03555/Lua/s545544792.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s545544792", "user_id": "u120582723"}, "prompt_components": {"gold_output": "YES\n", "input_to_evaluate": "a = io.read()\nb = io.read()\nif a:sub(1, 1) == b:sub(3, 3) and a:sub(2, 2) == b:sub(2, 2) and a:sub(3, 3) == b:sub(1, 1) then\n print(\"YES\")\nelse\n print(\"NO\")\nend\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nYou are given a grid with 2 rows and 3 columns of squares.\nThe color of the square at the i-th row and j-th column is represented by the character C_{ij}.\n\nWrite a program that prints YES if this grid remains the same when rotated 180 degrees, and prints NO otherwise.\n\nConstraints\n\nC_{i,j}(1 \\leq i \\leq 2, 1 \\leq j \\leq 3) is a lowercase English letter.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nC_{11}C_{12}C_{13}\nC_{21}C_{22}C_{23}\n\nOutput\n\nPrint YES if this grid remains the same when rotated 180 degrees; print NO otherwise.\n\nSample Input 1\n\npot\ntop\n\nSample Output 1\n\nYES\n\nThis grid remains the same when rotated 180 degrees.\n\nSample Input 2\n\ntab\nbet\n\nSample Output 2\n\nNO\n\nThis grid does not remain the same when rotated 180 degrees.\n\nSample Input 3\n\neye\neel\n\nSample Output 3\n\nNO", "sample_input": "pot\ntop\n"}, "reference_outputs": ["YES\n"], "source_document_id": "p03555", "source_text": "Score : 100 points\n\nProblem Statement\n\nYou are given a grid with 2 rows and 3 columns of squares.\nThe color of the square at the i-th row and j-th column is represented by the character C_{ij}.\n\nWrite a program that prints YES if this grid remains the same when rotated 180 degrees, and prints NO otherwise.\n\nConstraints\n\nC_{i,j}(1 \\leq i \\leq 2, 1 \\leq j \\leq 3) is a lowercase English letter.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nC_{11}C_{12}C_{13}\nC_{21}C_{22}C_{23}\n\nOutput\n\nPrint YES if this grid remains the same when rotated 180 degrees; print NO otherwise.\n\nSample Input 1\n\npot\ntop\n\nSample Output 1\n\nYES\n\nThis grid remains the same when rotated 180 degrees.\n\nSample Input 2\n\ntab\nbet\n\nSample Output 2\n\nNO\n\nThis grid does not remain the same when rotated 180 degrees.\n\nSample Input 3\n\neye\neel\n\nSample Output 3\n\nNO", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 163, "cpu_time_ms": 5, "memory_kb": 508}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s052217709", "group_id": "codeNet:p03556", "input_text": "local n = io.read(\"*n\")\nlocal z = math.ceil(math.sqrt(n))\nif z * z <= n then\n print(z * z)\nelse\n print((z - 1) * (z - 1))\nend\n", "language": "Lua", "metadata": {"date": 1569816130, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03556.html", "problem_id": "p03556", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03556/input.txt", "sample_output_relpath": "derived/input_output/data/p03556/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03556/Lua/s052217709.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s052217709", "user_id": "u120582723"}, "prompt_components": {"gold_output": "9\n", "input_to_evaluate": "local n = io.read(\"*n\")\nlocal z = math.ceil(math.sqrt(n))\nif z * z <= n then\n print(z * z)\nelse\n print((z - 1) * (z - 1))\nend\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nFind the largest square number not exceeding N. Here, a square number is an integer that can be represented as the square of an integer.\n\nConstraints\n\n1 \\leq N \\leq 10^9\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the largest square number not exceeding N.\n\nSample Input 1\n\n10\n\nSample Output 1\n\n9\n\n10 is not square, but 9 = 3 × 3 is. Thus, we print 9.\n\nSample Input 2\n\n81\n\nSample Output 2\n\n81\n\nSample Input 3\n\n271828182\n\nSample Output 3\n\n271821169", "sample_input": "10\n"}, "reference_outputs": ["9\n"], "source_document_id": "p03556", "source_text": "Score : 200 points\n\nProblem Statement\n\nFind the largest square number not exceeding N. Here, a square number is an integer that can be represented as the square of an integer.\n\nConstraints\n\n1 \\leq N \\leq 10^9\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the largest square number not exceeding N.\n\nSample Input 1\n\n10\n\nSample Output 1\n\n9\n\n10 is not square, but 9 = 3 × 3 is. Thus, we print 9.\n\nSample Input 2\n\n81\n\nSample Output 2\n\n81\n\nSample Input 3\n\n271828182\n\nSample Output 3\n\n271821169", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 128, "cpu_time_ms": 5, "memory_kb": 508}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s262439543", "group_id": "codeNet:p03559", "input_text": "local n = io.read(\"*n\", \"*l\")\nlocal a, b, c = {}, {}, {}\nlocal str = io.read()\nlocal i = 1\nlocal tn = tonumber\nfor val in string.gmatch(str, \"%d+\") do\n a[i] = tn(val)\n i = i + 1\nend\nstr = io.read()\ni = 1\nfor val in string.gmatch(str, \"%d+\") do\n b[i] = tn(val)\n i = i + 1\nend\nstr = io.read()\ni = 1\nfor val in string.gmatch(str, \"%d+\") do\n c[i] = tn(val)\n i = i + 1\nend\ntable.sort(a)\ntable.sort(b)\ntable.sort(c)\nlocal ab, bc = {}, {}\nlocal bpos, cpos = 1, 1\nlocal alast, blast = n, n\nfor j = 1, n do\n local tgt = a[j]\n local found = false\n for k = bpos, n do\n if(tgt < b[k]) then\n ab[j], bpos, found = k, k, true\n break\n end\n end\n if(not found) then\n alast = j - 1\n break\n end\nend\nfor j = 1, n do\n local tgt = b[j]\n local found = false\n for k = cpos, n do\n if(tgt < c[k]) then\n bc[j], cpos, found = (n - k + 1), k, true\n break\n end\n end\n if(not found) then\n blast = j - 1\n break\n end\nend\nfor i = blast + 1, n do\n bc[i] = 0\nend\nfor i = blast - 1, 1, -1 do\n bc[i] = bc[i] + bc[i + 1]\nend\nlocal sum = 0\nfor i = 1, alast do\n sum = sum + bc[ab[i]]\nend\nprint(sum)\n", "language": "Lua", "metadata": {"date": 1555472515, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03559.html", "problem_id": "p03559", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03559/input.txt", "sample_output_relpath": "derived/input_output/data/p03559/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03559/Lua/s262439543.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s262439543", "user_id": "u120582723"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "local n = io.read(\"*n\", \"*l\")\nlocal a, b, c = {}, {}, {}\nlocal str = io.read()\nlocal i = 1\nlocal tn = tonumber\nfor val in string.gmatch(str, \"%d+\") do\n a[i] = tn(val)\n i = i + 1\nend\nstr = io.read()\ni = 1\nfor val in string.gmatch(str, \"%d+\") do\n b[i] = tn(val)\n i = i + 1\nend\nstr = io.read()\ni = 1\nfor val in string.gmatch(str, \"%d+\") do\n c[i] = tn(val)\n i = i + 1\nend\ntable.sort(a)\ntable.sort(b)\ntable.sort(c)\nlocal ab, bc = {}, {}\nlocal bpos, cpos = 1, 1\nlocal alast, blast = n, n\nfor j = 1, n do\n local tgt = a[j]\n local found = false\n for k = bpos, n do\n if(tgt < b[k]) then\n ab[j], bpos, found = k, k, true\n break\n end\n end\n if(not found) then\n alast = j - 1\n break\n end\nend\nfor j = 1, n do\n local tgt = b[j]\n local found = false\n for k = cpos, n do\n if(tgt < c[k]) then\n bc[j], cpos, found = (n - k + 1), k, true\n break\n end\n end\n if(not found) then\n blast = j - 1\n break\n end\nend\nfor i = blast + 1, n do\n bc[i] = 0\nend\nfor i = blast - 1, 1, -1 do\n bc[i] = bc[i] + bc[i + 1]\nend\nlocal sum = 0\nfor i = 1, alast do\n sum = sum + bc[ab[i]]\nend\nprint(sum)\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThe season for Snuke Festival has come again this year. First of all, Ringo will perform a ritual to summon Snuke. For the ritual, he needs an altar, which consists of three parts, one in each of the three categories: upper, middle and lower.\n\nHe has N parts for each of the three categories. The size of the i-th upper part is A_i, the size of the i-th middle part is B_i, and the size of the i-th lower part is C_i.\n\nTo build an altar, the size of the middle part must be strictly greater than that of the upper part, and the size of the lower part must be strictly greater than that of the middle part. On the other hand, any three parts that satisfy these conditions can be combined to form an altar.\n\nHow many different altars can Ringo build? Here, two altars are considered different when at least one of the three parts used is different.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n1 \\leq A_i \\leq 10^9(1\\leq i\\leq N)\n\n1 \\leq B_i \\leq 10^9(1\\leq i\\leq N)\n\n1 \\leq C_i \\leq 10^9(1\\leq i\\leq N)\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 ... A_N\nB_1 ... B_N\nC_1 ... C_N\n\nOutput\n\nPrint the number of different altars that Ringo can build.\n\nSample Input 1\n\n2\n1 5\n2 4\n3 6\n\nSample Output 1\n\n3\n\nThe following three altars can be built:\n\nUpper: 1-st part, Middle: 1-st part, Lower: 1-st part\n\nUpper: 1-st part, Middle: 1-st part, Lower: 2-nd part\n\nUpper: 1-st part, Middle: 2-nd part, Lower: 2-nd part\n\nSample Input 2\n\n3\n1 1 1\n2 2 2\n3 3 3\n\nSample Output 2\n\n27\n\nSample Input 3\n\n6\n3 14 159 2 6 53\n58 9 79 323 84 6\n2643 383 2 79 50 288\n\nSample Output 3\n\n87", "sample_input": "2\n1 5\n2 4\n3 6\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03559", "source_text": "Score : 300 points\n\nProblem Statement\n\nThe season for Snuke Festival has come again this year. First of all, Ringo will perform a ritual to summon Snuke. For the ritual, he needs an altar, which consists of three parts, one in each of the three categories: upper, middle and lower.\n\nHe has N parts for each of the three categories. The size of the i-th upper part is A_i, the size of the i-th middle part is B_i, and the size of the i-th lower part is C_i.\n\nTo build an altar, the size of the middle part must be strictly greater than that of the upper part, and the size of the lower part must be strictly greater than that of the middle part. On the other hand, any three parts that satisfy these conditions can be combined to form an altar.\n\nHow many different altars can Ringo build? Here, two altars are considered different when at least one of the three parts used is different.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n1 \\leq A_i \\leq 10^9(1\\leq i\\leq N)\n\n1 \\leq B_i \\leq 10^9(1\\leq i\\leq N)\n\n1 \\leq C_i \\leq 10^9(1\\leq i\\leq N)\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 ... A_N\nB_1 ... B_N\nC_1 ... C_N\n\nOutput\n\nPrint the number of different altars that Ringo can build.\n\nSample Input 1\n\n2\n1 5\n2 4\n3 6\n\nSample Output 1\n\n3\n\nThe following three altars can be built:\n\nUpper: 1-st part, Middle: 1-st part, Lower: 1-st part\n\nUpper: 1-st part, Middle: 1-st part, Lower: 2-nd part\n\nUpper: 1-st part, Middle: 2-nd part, Lower: 2-nd part\n\nSample Input 2\n\n3\n1 1 1\n2 2 2\n3 3 3\n\nSample Output 2\n\n27\n\nSample Input 3\n\n6\n3 14 159 2 6 53\n58 9 79 323 84 6\n2643 383 2 79 50 288\n\nSample Output 3\n\n87", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1121, "cpu_time_ms": 388, "memory_kb": 25260}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s698551715", "group_id": "codeNet:p03559", "input_text": "do -- Library\n table.map = function(t, f)\n local ret = {}\n for i = 1, #t do\n table.insert(ret, f(t[i]))\n end\n return ret\n end\n \n table.each = function(t, f)\n for i = 1, #t do\n f(t[i])\n end\n end\n \n table.sum = function(t)\n local sum = 0\n for i = 1, #t do\n sum = sum + t[i]\n end\n return sum\n end\n \n table.slice = function(t, b, e)\n local ret = {}\n for i = b, e do\n table.insert(ret, t[i])\n end\n return ret\n end\n \n string.split = function(str, sep)\n local ret = {}\n for i in string.gmatch(str, \"[^\"..sep..\"]+\") do\n table.insert(ret, i)\n end\n return ret\n end\nend\n\ncalculate = nil\ndo\n local memo = {}\n local stages_to_str = function(stages)\n return table.concat(table.map(stages, tostring), \",\")\n end\n \n function calculate(top_num, under_stages)\n local str_under_stages = stages_to_str(under_stages)\n if not memo[top_num] then\n memo[top_num] = {}\n elseif memo[top_num][str_under_stages] then\n return memo[top_num][str_under_stages]\n end\n \n if #under_stages == 0 then\n return 1\n end\n \n memo[top_num][str_under_stages] = table.sum(table.map(under_stages[1], function(size)\n if size <= top_num then\n return 0\n end\n \n return calculate(size, table.slice(under_stages, 2, #under_stages))\n end))\n return memo[top_num][str_under_stages]\n end\nend\n\nfunction main()\n local n = tonumber(io.read())\n local stages = {}\n for i = 1, 3 do\n table.insert(stages, table.map(string.split(io.read(), \" \"), tonumber))\n end\n \n table.each(stages, function(t)\n table.sort(t, function(a, b) return b < a end)\n end)\n \n print(calculate(0, stages))\nend\n\nmain()", "language": "Lua", "metadata": {"date": 1510446155, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p03559.html", "problem_id": "p03559", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03559/input.txt", "sample_output_relpath": "derived/input_output/data/p03559/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03559/Lua/s698551715.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s698551715", "user_id": "u940915899"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "do -- Library\n table.map = function(t, f)\n local ret = {}\n for i = 1, #t do\n table.insert(ret, f(t[i]))\n end\n return ret\n end\n \n table.each = function(t, f)\n for i = 1, #t do\n f(t[i])\n end\n end\n \n table.sum = function(t)\n local sum = 0\n for i = 1, #t do\n sum = sum + t[i]\n end\n return sum\n end\n \n table.slice = function(t, b, e)\n local ret = {}\n for i = b, e do\n table.insert(ret, t[i])\n end\n return ret\n end\n \n string.split = function(str, sep)\n local ret = {}\n for i in string.gmatch(str, \"[^\"..sep..\"]+\") do\n table.insert(ret, i)\n end\n return ret\n end\nend\n\ncalculate = nil\ndo\n local memo = {}\n local stages_to_str = function(stages)\n return table.concat(table.map(stages, tostring), \",\")\n end\n \n function calculate(top_num, under_stages)\n local str_under_stages = stages_to_str(under_stages)\n if not memo[top_num] then\n memo[top_num] = {}\n elseif memo[top_num][str_under_stages] then\n return memo[top_num][str_under_stages]\n end\n \n if #under_stages == 0 then\n return 1\n end\n \n memo[top_num][str_under_stages] = table.sum(table.map(under_stages[1], function(size)\n if size <= top_num then\n return 0\n end\n \n return calculate(size, table.slice(under_stages, 2, #under_stages))\n end))\n return memo[top_num][str_under_stages]\n end\nend\n\nfunction main()\n local n = tonumber(io.read())\n local stages = {}\n for i = 1, 3 do\n table.insert(stages, table.map(string.split(io.read(), \" \"), tonumber))\n end\n \n table.each(stages, function(t)\n table.sort(t, function(a, b) return b < a end)\n end)\n \n print(calculate(0, stages))\nend\n\nmain()", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThe season for Snuke Festival has come again this year. First of all, Ringo will perform a ritual to summon Snuke. For the ritual, he needs an altar, which consists of three parts, one in each of the three categories: upper, middle and lower.\n\nHe has N parts for each of the three categories. The size of the i-th upper part is A_i, the size of the i-th middle part is B_i, and the size of the i-th lower part is C_i.\n\nTo build an altar, the size of the middle part must be strictly greater than that of the upper part, and the size of the lower part must be strictly greater than that of the middle part. On the other hand, any three parts that satisfy these conditions can be combined to form an altar.\n\nHow many different altars can Ringo build? Here, two altars are considered different when at least one of the three parts used is different.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n1 \\leq A_i \\leq 10^9(1\\leq i\\leq N)\n\n1 \\leq B_i \\leq 10^9(1\\leq i\\leq N)\n\n1 \\leq C_i \\leq 10^9(1\\leq i\\leq N)\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 ... A_N\nB_1 ... B_N\nC_1 ... C_N\n\nOutput\n\nPrint the number of different altars that Ringo can build.\n\nSample Input 1\n\n2\n1 5\n2 4\n3 6\n\nSample Output 1\n\n3\n\nThe following three altars can be built:\n\nUpper: 1-st part, Middle: 1-st part, Lower: 1-st part\n\nUpper: 1-st part, Middle: 1-st part, Lower: 2-nd part\n\nUpper: 1-st part, Middle: 2-nd part, Lower: 2-nd part\n\nSample Input 2\n\n3\n1 1 1\n2 2 2\n3 3 3\n\nSample Output 2\n\n27\n\nSample Input 3\n\n6\n3 14 159 2 6 53\n58 9 79 323 84 6\n2643 383 2 79 50 288\n\nSample Output 3\n\n87", "sample_input": "2\n1 5\n2 4\n3 6\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03559", "source_text": "Score : 300 points\n\nProblem Statement\n\nThe season for Snuke Festival has come again this year. First of all, Ringo will perform a ritual to summon Snuke. For the ritual, he needs an altar, which consists of three parts, one in each of the three categories: upper, middle and lower.\n\nHe has N parts for each of the three categories. The size of the i-th upper part is A_i, the size of the i-th middle part is B_i, and the size of the i-th lower part is C_i.\n\nTo build an altar, the size of the middle part must be strictly greater than that of the upper part, and the size of the lower part must be strictly greater than that of the middle part. On the other hand, any three parts that satisfy these conditions can be combined to form an altar.\n\nHow many different altars can Ringo build? Here, two altars are considered different when at least one of the three parts used is different.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n1 \\leq A_i \\leq 10^9(1\\leq i\\leq N)\n\n1 \\leq B_i \\leq 10^9(1\\leq i\\leq N)\n\n1 \\leq C_i \\leq 10^9(1\\leq i\\leq N)\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 ... A_N\nB_1 ... B_N\nC_1 ... C_N\n\nOutput\n\nPrint the number of different altars that Ringo can build.\n\nSample Input 1\n\n2\n1 5\n2 4\n3 6\n\nSample Output 1\n\n3\n\nThe following three altars can be built:\n\nUpper: 1-st part, Middle: 1-st part, Lower: 1-st part\n\nUpper: 1-st part, Middle: 1-st part, Lower: 2-nd part\n\nUpper: 1-st part, Middle: 2-nd part, Lower: 2-nd part\n\nSample Input 2\n\n3\n1 1 1\n2 2 2\n3 3 3\n\nSample Output 2\n\n27\n\nSample Input 3\n\n6\n3 14 159 2 6 53\n58 9 79 323 84 6\n2643 383 2 79 50 288\n\nSample Output 3\n\n87", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1985, "cpu_time_ms": 2110, "memory_kb": 137764}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s819227889", "group_id": "codeNet:p03561", "input_text": "local k, n = io.read(\"*n\", \"*n\")\nlocal t = {}\n\nif k % 2 == 0 then\n table.insert(t, k / 2)\n for i = 1, n - 1 do table.insert(t, k) end\nelse\n local hk = (k + 1) / 2\n for i = 1, n do t[i] = hk end\n local decnum = math.ceil((n - 1) / 2)\n for i = 1, decnum do\n for j = n, 1, -1 do\n if 0 < t[j] then\n t[j] = t[j] - 1\n for s = j + 1, n do\n t[s] = k\n end\n break\n end\n end\n end\n for i = 1, n do\n if t[i] == 0 then\n for j = i, n do\n table.remove(t)\n end\n break\n end\n end\nend\n\nprint(table.concat(t, \" \"))\n", "language": "Lua", "metadata": {"date": 1565976285, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p03561.html", "problem_id": "p03561", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03561/input.txt", "sample_output_relpath": "derived/input_output/data/p03561/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03561/Lua/s819227889.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s819227889", "user_id": "u120582723"}, "prompt_components": {"gold_output": "2 1\n", "input_to_evaluate": "local k, n = io.read(\"*n\", \"*n\")\nlocal t = {}\n\nif k % 2 == 0 then\n table.insert(t, k / 2)\n for i = 1, n - 1 do table.insert(t, k) end\nelse\n local hk = (k + 1) / 2\n for i = 1, n do t[i] = hk end\n local decnum = math.ceil((n - 1) / 2)\n for i = 1, decnum do\n for j = n, 1, -1 do\n if 0 < t[j] then\n t[j] = t[j] - 1\n for s = j + 1, n do\n t[s] = k\n end\n break\n end\n end\n end\n for i = 1, n do\n if t[i] == 0 then\n for j = i, n do\n table.remove(t)\n end\n break\n end\n end\nend\n\nprint(table.concat(t, \" \"))\n", "problem_context": "Score : 800 points\n\nProblem Statement\n\nIn Finite Encyclopedia of Integer Sequences (FEIS), all integer sequences of lengths between 1 and N (inclusive) consisting of integers between 1 and K (inclusive) are listed.\n\nLet the total number of sequences listed in FEIS be X. Among those sequences, find the (X/2)-th (rounded up to the nearest integer) lexicographically smallest one.\n\nConstraints\n\n1 \\leq N,K \\leq 3 × 10^5\n\nN and K are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nK N\n\nOutput\n\nPrint the (X/2)-th (rounded up to the nearest integer) lexicographically smallest sequence listed in FEIS, with spaces in between, where X is the total number of sequences listed in FEIS.\n\nSample Input 1\n\n3 2\n\nSample Output 1\n\n2 1\n\nThere are 12 sequences listed in FEIS: (1),(1,1),(1,2),(1,3),(2),(2,1),(2,2),(2,3),(3),(3,1),(3,2),(3,3).\nThe (12/2 = 6)-th lexicographically smallest one among them is (2,1).\n\nSample Input 2\n\n2 4\n\nSample Output 2\n\n1 2 2 2\n\nSample Input 3\n\n5 14\n\nSample Output 3\n\n3 3 3 3 3 3 3 3 3 3 3 3 2 2", "sample_input": "3 2\n"}, "reference_outputs": ["2 1\n"], "source_document_id": "p03561", "source_text": "Score : 800 points\n\nProblem Statement\n\nIn Finite Encyclopedia of Integer Sequences (FEIS), all integer sequences of lengths between 1 and N (inclusive) consisting of integers between 1 and K (inclusive) are listed.\n\nLet the total number of sequences listed in FEIS be X. Among those sequences, find the (X/2)-th (rounded up to the nearest integer) lexicographically smallest one.\n\nConstraints\n\n1 \\leq N,K \\leq 3 × 10^5\n\nN and K are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nK N\n\nOutput\n\nPrint the (X/2)-th (rounded up to the nearest integer) lexicographically smallest sequence listed in FEIS, with spaces in between, where X is the total number of sequences listed in FEIS.\n\nSample Input 1\n\n3 2\n\nSample Output 1\n\n2 1\n\nThere are 12 sequences listed in FEIS: (1),(1,1),(1,2),(1,3),(2),(2,1),(2,2),(2,3),(3),(3,1),(3,2),(3,3).\nThe (12/2 = 6)-th lexicographically smallest one among them is (2,1).\n\nSample Input 2\n\n2 4\n\nSample Output 2\n\n1 2 2 2\n\nSample Input 3\n\n5 14\n\nSample Output 3\n\n3 3 3 3 3 3 3 3 3 3 3 3 2 2", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 584, "cpu_time_ms": 152, "memory_kb": 12956}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s218745651", "group_id": "codeNet:p03563", "input_text": "R=io.read(\"n\")\nG=io.read(\"n\")\nprint(G*2-R)", "language": "Lua", "metadata": {"date": 1551823696, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03563.html", "problem_id": "p03563", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03563/input.txt", "sample_output_relpath": "derived/input_output/data/p03563/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03563/Lua/s218745651.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s218745651", "user_id": "u015229643"}, "prompt_components": {"gold_output": "2032\n", "input_to_evaluate": "R=io.read(\"n\")\nG=io.read(\"n\")\nprint(G*2-R)", "problem_context": "Score : 100 points\n\nProblem Statement\n\nTakahashi is a user of a site that hosts programming contests.\n\nWhen a user competes in a contest, the rating of the user (not necessarily an integer) changes according to the performance of the user, as follows:\n\nLet the current rating of the user be a.\n\nSuppose that the performance of the user in the contest is b.\n\nThen, the new rating of the user will be the avarage of a and b.\n\nFor example, if a user with rating 1 competes in a contest and gives performance 1000, his/her new rating will be 500.5, the average of 1 and 1000.\n\nTakahashi's current rating is R, and he wants his rating to be exactly G after the next contest.\n\nFind the performance required to achieve it.\n\nConstraints\n\n0 \\leq R, G \\leq 4500\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nR\nG\n\nOutput\n\nPrint the performance required to achieve the objective.\n\nSample Input 1\n\n2002\n2017\n\nSample Output 1\n\n2032\n\nTakahashi's current rating is 2002.\n\nIf his performance in the contest is 2032, his rating will be the average of 2002 and 2032, which is equal to the desired rating, 2017.\n\nSample Input 2\n\n4500\n0\n\nSample Output 2\n\n-4500\n\nAlthough the current and desired ratings are between 0 and 4500, the performance of a user can be below 0.", "sample_input": "2002\n2017\n"}, "reference_outputs": ["2032\n"], "source_document_id": "p03563", "source_text": "Score : 100 points\n\nProblem Statement\n\nTakahashi is a user of a site that hosts programming contests.\n\nWhen a user competes in a contest, the rating of the user (not necessarily an integer) changes according to the performance of the user, as follows:\n\nLet the current rating of the user be a.\n\nSuppose that the performance of the user in the contest is b.\n\nThen, the new rating of the user will be the avarage of a and b.\n\nFor example, if a user with rating 1 competes in a contest and gives performance 1000, his/her new rating will be 500.5, the average of 1 and 1000.\n\nTakahashi's current rating is R, and he wants his rating to be exactly G after the next contest.\n\nFind the performance required to achieve it.\n\nConstraints\n\n0 \\leq R, G \\leq 4500\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nR\nG\n\nOutput\n\nPrint the performance required to achieve the objective.\n\nSample Input 1\n\n2002\n2017\n\nSample Output 1\n\n2032\n\nTakahashi's current rating is 2002.\n\nIf his performance in the contest is 2032, his rating will be the average of 2002 and 2032, which is equal to the desired rating, 2017.\n\nSample Input 2\n\n4500\n0\n\nSample Output 2\n\n-4500\n\nAlthough the current and desired ratings are between 0 and 4500, the performance of a user can be below 0.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 42, "cpu_time_ms": 7, "memory_kb": 888}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s819482413", "group_id": "codeNet:p03564", "input_text": "N=io.read(\"n\")\nK=io.read(\"n\")\nlocal int=1\nfor i=1,N do\n if int<=K then\n int=int*2\n else\n int=int+K\n end\nend\nprint(int)\n", "language": "Lua", "metadata": {"date": 1551824519, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03564.html", "problem_id": "p03564", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03564/input.txt", "sample_output_relpath": "derived/input_output/data/p03564/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03564/Lua/s819482413.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s819482413", "user_id": "u015229643"}, "prompt_components": {"gold_output": "10\n", "input_to_evaluate": "N=io.read(\"n\")\nK=io.read(\"n\")\nlocal int=1\nfor i=1,N do\n if int<=K then\n int=int*2\n else\n int=int+K\n end\nend\nprint(int)\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nSquare1001 has seen an electric bulletin board displaying the integer 1.\nHe can perform the following operations A and B to change this value:\n\nOperation A: The displayed value is doubled.\n\nOperation B: The displayed value increases by K.\n\nSquare1001 needs to perform these operations N times in total.\nFind the minimum possible value displayed in the board after N operations.\n\nConstraints\n\n1 \\leq N, K \\leq 10\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nK\n\nOutput\n\nPrint the minimum possible value displayed in the board after N operations.\n\nSample Input 1\n\n4\n3\n\nSample Output 1\n\n10\n\nThe value will be minimized when the operations are performed in the following order: A, A, B, B.\n\nIn this case, the value will change as follows: 1 → 2 → 4 → 7 → 10.\n\nSample Input 2\n\n10\n10\n\nSample Output 2\n\n76\n\nThe value will be minimized when the operations are performed in the following order: A, A, A, A, B, B, B, B, B, B.\n\nIn this case, the value will change as follows: 1 → 2 → 4 → 8 → 16 → 26 → 36 → 46 → 56 → 66 → 76.\n\nBy the way, this contest is AtCoder Beginner Contest 076.", "sample_input": "4\n3\n"}, "reference_outputs": ["10\n"], "source_document_id": "p03564", "source_text": "Score : 200 points\n\nProblem Statement\n\nSquare1001 has seen an electric bulletin board displaying the integer 1.\nHe can perform the following operations A and B to change this value:\n\nOperation A: The displayed value is doubled.\n\nOperation B: The displayed value increases by K.\n\nSquare1001 needs to perform these operations N times in total.\nFind the minimum possible value displayed in the board after N operations.\n\nConstraints\n\n1 \\leq N, K \\leq 10\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nK\n\nOutput\n\nPrint the minimum possible value displayed in the board after N operations.\n\nSample Input 1\n\n4\n3\n\nSample Output 1\n\n10\n\nThe value will be minimized when the operations are performed in the following order: A, A, B, B.\n\nIn this case, the value will change as follows: 1 → 2 → 4 → 7 → 10.\n\nSample Input 2\n\n10\n10\n\nSample Output 2\n\n76\n\nThe value will be minimized when the operations are performed in the following order: A, A, A, A, B, B, B, B, B, B.\n\nIn this case, the value will change as follows: 1 → 2 → 4 → 8 → 16 → 26 → 36 → 46 → 56 → 66 → 76.\n\nBy the way, this contest is AtCoder Beginner Contest 076.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 130, "cpu_time_ms": 8, "memory_kb": 888}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s726783198", "group_id": "codeNet:p03566", "input_text": "local n = io.read(\"*n\")\nlocal tsum = 0\nlocal t = {}\nlocal vmax = {}\nfor i = 1, n do\n t[i] = 2 * io.read(\"*n\")\n tsum = tsum + t[i]\nend\nlocal mmi, mma = math.min, math.max\nfor i = 1, tsum do\n vmax[i] = mmi(i / 2, (tsum - i) / 2)\nend\nlocal tprev = 0\nfor i = 1, n do\n local v = io.read(\"*n\")\n for j = 1, tprev - 1 do\n vmax[j] = mmi(vmax[j], v + (tprev - j) / 2)\n end\n for j = mma(1, tprev), tprev + t[i] do\n vmax[j] = mmi(vmax[j], v)\n end\n tprev = tprev + t[i]\n for j = tprev + 1, tsum do\n vmax[j] = mmi(vmax[j], v + (j - tprev) / 2)\n end\nend\nlocal dist = vmax[1]\nfor i = 2, tsum do\n dist = dist + vmax[i] + vmax[i - 1]\nend\nprint(dist / 4)\n", "language": "Lua", "metadata": {"date": 1563750358, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03566.html", "problem_id": "p03566", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03566/input.txt", "sample_output_relpath": "derived/input_output/data/p03566/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03566/Lua/s726783198.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s726783198", "user_id": "u120582723"}, "prompt_components": {"gold_output": "2100.000000000000000\n", "input_to_evaluate": "local n = io.read(\"*n\")\nlocal tsum = 0\nlocal t = {}\nlocal vmax = {}\nfor i = 1, n do\n t[i] = 2 * io.read(\"*n\")\n tsum = tsum + t[i]\nend\nlocal mmi, mma = math.min, math.max\nfor i = 1, tsum do\n vmax[i] = mmi(i / 2, (tsum - i) / 2)\nend\nlocal tprev = 0\nfor i = 1, n do\n local v = io.read(\"*n\")\n for j = 1, tprev - 1 do\n vmax[j] = mmi(vmax[j], v + (tprev - j) / 2)\n end\n for j = mma(1, tprev), tprev + t[i] do\n vmax[j] = mmi(vmax[j], v)\n end\n tprev = tprev + t[i]\n for j = tprev + 1, tsum do\n vmax[j] = mmi(vmax[j], v + (j - tprev) / 2)\n end\nend\nlocal dist = vmax[1]\nfor i = 2, tsum do\n dist = dist + vmax[i] + vmax[i - 1]\nend\nprint(dist / 4)\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nIn the year 2168, AtCoder Inc., which is much larger than now, is starting a limited express train service called AtCoder Express.\n\nIn the plan developed by the president Takahashi, the trains will run as follows:\n\nA train will run for (t_1 + t_2 + t_3 + ... + t_N) seconds.\n\nIn the first t_1 seconds, a train must run at a speed of at most v_1 m/s (meters per second). Similarly, in the subsequent t_2 seconds, a train must run at a speed of at most v_2 m/s, and so on.\n\nAccording to the specifications of the trains, the acceleration of a train must be always within ±1m/s^2. Additionally, a train must stop at the beginning and the end of the run.\n\nFind the maximum possible distance that a train can cover in the run.\n\nConstraints\n\n1 \\leq N \\leq 100\n\n1 \\leq t_i \\leq 200\n\n1 \\leq v_i \\leq 100\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nt_1 t_2 t_3 … t_N\nv_1 v_2 v_3 … v_N\n\nOutput\n\nPrint the maximum possible that a train can cover in the run.\n\nOutput is considered correct if its absolute difference from the judge's output is at most 10^{-3}.\n\nSample Input 1\n\n1\n100\n30\n\nSample Output 1\n\n2100.000000000000000\n\nThe maximum distance is achieved when a train runs as follows:\n\nIn the first 30 seconds, it accelerates at a rate of 1m/s^2, covering 450 meters.\n\nIn the subsequent 40 seconds, it maintains the velocity of 30m/s, covering 1200 meters.\n\nIn the last 30 seconds, it decelerates at the acceleration of -1m/s^2, covering 450 meters.\n\nThe total distance covered is 450 + 1200 + 450 = 2100 meters.\n\nSample Input 2\n\n2\n60 50\n34 38\n\nSample Output 2\n\n2632.000000000000000\n\nThe maximum distance is achieved when a train runs as follows:\n\nIn the first 34 seconds, it accelerates at a rate of 1m/s^2, covering 578 meters.\n\nIn the subsequent 26 seconds, it maintains the velocity of 34m/s, covering 884 meters.\n\nIn the subsequent 4 seconds, it accelerates at a rate of 1m/s^2, covering 144 meters.\n\nIn the subsequent 8 seconds, it maintains the velocity of 38m/s, covering 304 meters.\n\nIn the last 38 seconds, it decelerates at the acceleration of -1m/s^2, covering 722 meters.\n\nThe total distance covered is 578 + 884 + 144 + 304 + 722 = 2632 meters.\n\nSample Input 3\n\n3\n12 14 2\n6 2 7\n\nSample Output 3\n\n76.000000000000000\n\nThe maximum distance is achieved when a train runs as follows:\n\nIn the first 6 seconds, it accelerates at a rate of 1m/s^2, covering 18 meters.\n\nIn the subsequent 2 seconds, it maintains the velocity of 6m/s, covering 12 meters.\n\nIn the subsequent 4 seconds, it decelerates at the acceleration of -1m/s^2, covering 16 meters.\n\nIn the subsequent 14 seconds, it maintains the velocity of 2m/s, covering 28 meters.\n\nIn the last 2 seconds, it decelerates at the acceleration of -1m/s^2, covering 2 meters.\n\nThe total distance covered is 18 + 12 + 16 + 28 + 2 = 76 meters.\n\nSample Input 4\n\n1\n9\n10\n\nSample Output 4\n\n20.250000000000000000\n\nThe maximum distance is achieved when a train runs as follows:\n\nIn the first 4.5 seconds, it accelerates at a rate of 1m/s^2, covering 10.125 meters.\n\nIn the last 4.5 seconds, it decelerates at the acceleration of -1m/s^2, covering 10.125 meters.\n\nThe total distance covered is 10.125 + 10.125 = 20.25 meters.\n\nSample Input 5\n\n10\n64 55 27 35 76 119 7 18 49 100\n29 19 31 39 27 48 41 87 55 70\n\nSample Output 5\n\n20291.000000000000", "sample_input": "1\n100\n30\n"}, "reference_outputs": ["2100.000000000000000\n"], "source_document_id": "p03566", "source_text": "Score : 400 points\n\nProblem Statement\n\nIn the year 2168, AtCoder Inc., which is much larger than now, is starting a limited express train service called AtCoder Express.\n\nIn the plan developed by the president Takahashi, the trains will run as follows:\n\nA train will run for (t_1 + t_2 + t_3 + ... + t_N) seconds.\n\nIn the first t_1 seconds, a train must run at a speed of at most v_1 m/s (meters per second). Similarly, in the subsequent t_2 seconds, a train must run at a speed of at most v_2 m/s, and so on.\n\nAccording to the specifications of the trains, the acceleration of a train must be always within ±1m/s^2. Additionally, a train must stop at the beginning and the end of the run.\n\nFind the maximum possible distance that a train can cover in the run.\n\nConstraints\n\n1 \\leq N \\leq 100\n\n1 \\leq t_i \\leq 200\n\n1 \\leq v_i \\leq 100\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nt_1 t_2 t_3 … t_N\nv_1 v_2 v_3 … v_N\n\nOutput\n\nPrint the maximum possible that a train can cover in the run.\n\nOutput is considered correct if its absolute difference from the judge's output is at most 10^{-3}.\n\nSample Input 1\n\n1\n100\n30\n\nSample Output 1\n\n2100.000000000000000\n\nThe maximum distance is achieved when a train runs as follows:\n\nIn the first 30 seconds, it accelerates at a rate of 1m/s^2, covering 450 meters.\n\nIn the subsequent 40 seconds, it maintains the velocity of 30m/s, covering 1200 meters.\n\nIn the last 30 seconds, it decelerates at the acceleration of -1m/s^2, covering 450 meters.\n\nThe total distance covered is 450 + 1200 + 450 = 2100 meters.\n\nSample Input 2\n\n2\n60 50\n34 38\n\nSample Output 2\n\n2632.000000000000000\n\nThe maximum distance is achieved when a train runs as follows:\n\nIn the first 34 seconds, it accelerates at a rate of 1m/s^2, covering 578 meters.\n\nIn the subsequent 26 seconds, it maintains the velocity of 34m/s, covering 884 meters.\n\nIn the subsequent 4 seconds, it accelerates at a rate of 1m/s^2, covering 144 meters.\n\nIn the subsequent 8 seconds, it maintains the velocity of 38m/s, covering 304 meters.\n\nIn the last 38 seconds, it decelerates at the acceleration of -1m/s^2, covering 722 meters.\n\nThe total distance covered is 578 + 884 + 144 + 304 + 722 = 2632 meters.\n\nSample Input 3\n\n3\n12 14 2\n6 2 7\n\nSample Output 3\n\n76.000000000000000\n\nThe maximum distance is achieved when a train runs as follows:\n\nIn the first 6 seconds, it accelerates at a rate of 1m/s^2, covering 18 meters.\n\nIn the subsequent 2 seconds, it maintains the velocity of 6m/s, covering 12 meters.\n\nIn the subsequent 4 seconds, it decelerates at the acceleration of -1m/s^2, covering 16 meters.\n\nIn the subsequent 14 seconds, it maintains the velocity of 2m/s, covering 28 meters.\n\nIn the last 2 seconds, it decelerates at the acceleration of -1m/s^2, covering 2 meters.\n\nThe total distance covered is 18 + 12 + 16 + 28 + 2 = 76 meters.\n\nSample Input 4\n\n1\n9\n10\n\nSample Output 4\n\n20.250000000000000000\n\nThe maximum distance is achieved when a train runs as follows:\n\nIn the first 4.5 seconds, it accelerates at a rate of 1m/s^2, covering 10.125 meters.\n\nIn the last 4.5 seconds, it decelerates at the acceleration of -1m/s^2, covering 10.125 meters.\n\nThe total distance covered is 10.125 + 10.125 = 20.25 meters.\n\nSample Input 5\n\n10\n64 55 27 35 76 119 7 18 49 100\n29 19 31 39 27 48 41 87 55 70\n\nSample Output 5\n\n20291.000000000000", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 657, "cpu_time_ms": 328, "memory_kb": 1400}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s470799269", "group_id": "codeNet:p03569", "input_text": "local s = io.read()\nlocal n = #s\nlocal cnt = 0\nlocal t = {}\nfor i = 1, n do\n local sstr = s:sub(i, i)\n if sstr == \"x\" then\n cnt = cnt + 1\n else\n local tmp = {}\n tmp.c = cnt\n tmp.s = sstr\n table.insert(t, tmp)\n cnt = 0\n end\nend\nlocal ret = 0\nlocal mab = math.abs\nlocal nt = #t\nlocal isok = true\n\nlocal half = nt // 2\nfor i = 1, half do\n if t[i].s ~= t[nt + 1 - i].s then\n isok = false\n break\n else\n if i == 1 then\n ret = ret + mab(t[i].c - cnt)\n else\n ret = ret + mab(t[i].c - t[nt + 2 - i].c)\n end\n end\nend\nif nt % 2 == 1 then\n if nt == 1 then\n ret = ret + mab(t[1].c - cnt)\n else\n ret = ret + mab(t[half + 1].c - t[half + 2].c)\n end\nend\nprint(isok and ret or -1)\n", "language": "Lua", "metadata": {"date": 1563854193, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03569.html", "problem_id": "p03569", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03569/input.txt", "sample_output_relpath": "derived/input_output/data/p03569/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03569/Lua/s470799269.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s470799269", "user_id": "u120582723"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "local s = io.read()\nlocal n = #s\nlocal cnt = 0\nlocal t = {}\nfor i = 1, n do\n local sstr = s:sub(i, i)\n if sstr == \"x\" then\n cnt = cnt + 1\n else\n local tmp = {}\n tmp.c = cnt\n tmp.s = sstr\n table.insert(t, tmp)\n cnt = 0\n end\nend\nlocal ret = 0\nlocal mab = math.abs\nlocal nt = #t\nlocal isok = true\n\nlocal half = nt // 2\nfor i = 1, half do\n if t[i].s ~= t[nt + 1 - i].s then\n isok = false\n break\n else\n if i == 1 then\n ret = ret + mab(t[i].c - cnt)\n else\n ret = ret + mab(t[i].c - t[nt + 2 - i].c)\n end\n end\nend\nif nt % 2 == 1 then\n if nt == 1 then\n ret = ret + mab(t[1].c - cnt)\n else\n ret = ret + mab(t[half + 1].c - t[half + 2].c)\n end\nend\nprint(isok and ret or -1)\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nWe have a string s consisting of lowercase English letters.\nSnuke can perform the following operation repeatedly:\n\nInsert a letter x to any position in s of his choice, including the beginning and end of s.\n\nSnuke's objective is to turn s into a palindrome.\nDetermine whether the objective is achievable. If it is achievable, find the minimum number of operations required.\n\nNotes\n\nA palindrome is a string that reads the same forward and backward.\nFor example, a, aa, abba and abcba are palindromes, while ab, abab and abcda are not.\n\nConstraints\n\n1 \\leq |s| \\leq 10^5\n\ns consists of lowercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\ns\n\nOutput\n\nIf the objective is achievable, print the number of operations required.\nIf it is not, print -1 instead.\n\nSample Input 1\n\nxabxa\n\nSample Output 1\n\n2\n\nOne solution is as follows (newly inserted x are shown in bold):\n\nxabxa → xaxbxa → xaxbxax\n\nSample Input 2\n\nab\n\nSample Output 2\n\n-1\n\nNo sequence of operations can turn s into a palindrome.\n\nSample Input 3\n\na\n\nSample Output 3\n\n0\n\ns is a palindrome already at the beginning.\n\nSample Input 4\n\noxxx\n\nSample Output 4\n\n3\n\nOne solution is as follows:\n\noxxx → xoxxx → xxoxxx → xxxoxxx", "sample_input": "xabxa\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03569", "source_text": "Score : 400 points\n\nProblem Statement\n\nWe have a string s consisting of lowercase English letters.\nSnuke can perform the following operation repeatedly:\n\nInsert a letter x to any position in s of his choice, including the beginning and end of s.\n\nSnuke's objective is to turn s into a palindrome.\nDetermine whether the objective is achievable. If it is achievable, find the minimum number of operations required.\n\nNotes\n\nA palindrome is a string that reads the same forward and backward.\nFor example, a, aa, abba and abcba are palindromes, while ab, abab and abcda are not.\n\nConstraints\n\n1 \\leq |s| \\leq 10^5\n\ns consists of lowercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\ns\n\nOutput\n\nIf the objective is achievable, print the number of operations required.\nIf it is not, print -1 instead.\n\nSample Input 1\n\nxabxa\n\nSample Output 1\n\n2\n\nOne solution is as follows (newly inserted x are shown in bold):\n\nxabxa → xaxbxa → xaxbxax\n\nSample Input 2\n\nab\n\nSample Output 2\n\n-1\n\nNo sequence of operations can turn s into a palindrome.\n\nSample Input 3\n\na\n\nSample Output 3\n\n0\n\ns is a palindrome already at the beginning.\n\nSample Input 4\n\noxxx\n\nSample Output 4\n\n3\n\nOne solution is as follows:\n\noxxx → xoxxx → xxoxxx → xxxoxxx", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 723, "cpu_time_ms": 99, "memory_kb": 16532}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s504345169", "group_id": "codeNet:p03573", "input_text": "a,b,c=io.read():match(\"(.+)%s(.+)%s(.+)\")\nprint(a==b and c or b==c and a or b)", "language": "Lua", "metadata": {"date": 1551836684, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p03573.html", "problem_id": "p03573", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03573/input.txt", "sample_output_relpath": "derived/input_output/data/p03573/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03573/Lua/s504345169.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s504345169", "user_id": "u837412668"}, "prompt_components": {"gold_output": "7\n", "input_to_evaluate": "a,b,c=io.read():match(\"(.+)%s(.+)%s(.+)\")\nprint(a==b and c or b==c and a or b)", "problem_context": "Score : 100 points\n\nProblem Statement\n\nYou are given three integers, A, B and C.\n\nAmong them, two are the same, but the remaining one is different from the rest.\n\nFor example, when A=5,B=7,C=5, A and C are the same, but B is different.\n\nFind the one that is different from the rest among the given three integers.\n\nConstraints\n\n-100 \\leq A,B,C \\leq 100\n\nA, B and C are integers.\n\nThe input satisfies the condition in the statement.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C\n\nOutput\n\nAmong A, B and C, print the integer that is different from the rest.\n\nSample Input 1\n\n5 7 5\n\nSample Output 1\n\n7\n\nThis is the same case as the one in the statement.\n\nSample Input 2\n\n1 1 7\n\nSample Output 2\n\n7\n\nIn this case, C is the one we seek.\n\nSample Input 3\n\n-100 100 100\n\nSample Output 3\n\n-100", "sample_input": "5 7 5\n"}, "reference_outputs": ["7\n"], "source_document_id": "p03573", "source_text": "Score : 100 points\n\nProblem Statement\n\nYou are given three integers, A, B and C.\n\nAmong them, two are the same, but the remaining one is different from the rest.\n\nFor example, when A=5,B=7,C=5, A and C are the same, but B is different.\n\nFind the one that is different from the rest among the given three integers.\n\nConstraints\n\n-100 \\leq A,B,C \\leq 100\n\nA, B and C are integers.\n\nThe input satisfies the condition in the statement.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C\n\nOutput\n\nAmong A, B and C, print the integer that is different from the rest.\n\nSample Input 1\n\n5 7 5\n\nSample Output 1\n\n7\n\nThis is the same case as the one in the statement.\n\nSample Input 2\n\n1 1 7\n\nSample Output 2\n\n7\n\nIn this case, C is the one we seek.\n\nSample Input 3\n\n-100 100 100\n\nSample Output 3\n\n-100", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 78, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s679855078", "group_id": "codeNet:p03575", "input_text": "local n, m = io.read(\"*n\", \"*n\")\nlocal t = {}\nlocal as, bs = {}, {}\nfor i = 1, n do t[i] = {} end\nfor i = 1, m do\n local a, b = io.read(\"*n\", \"*n\")\n as[i], bs[i] = a, b\n t[a][b], t[b][a] = true, true\nend\n\nlocal function check(tbl)\n local reached = {true}\n for i = 2, n do reached[i] = false end\n local reachnum = 1\n local tasks = {1}\n local tasknum, done = 1, 0\n while done < tasknum do\n done = done + 1\n local idx = tasks[done]\n for k, v in pairs(tbl[idx]) do\n if v and not reached[k] then\n table.insert(tasks, k)\n reached[k] = true\n reachnum = reachnum + 1\n tasknum = tasknum + 1\n end\n end\n end\n return n == reachnum\nend\nlocal ret = 0\nfor i = 1, m do\n t[as[i]][bs[i]], t[bs[i]][as[i]] = false, false\n if not check(t) then ret = ret + 1 end\n t[as[i]][bs[i]], t[bs[i]][as[i]] = true, true\nend\nprint(ret)\n", "language": "Lua", "metadata": {"date": 1561265214, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03575.html", "problem_id": "p03575", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03575/input.txt", "sample_output_relpath": "derived/input_output/data/p03575/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03575/Lua/s679855078.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s679855078", "user_id": "u120582723"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "local n, m = io.read(\"*n\", \"*n\")\nlocal t = {}\nlocal as, bs = {}, {}\nfor i = 1, n do t[i] = {} end\nfor i = 1, m do\n local a, b = io.read(\"*n\", \"*n\")\n as[i], bs[i] = a, b\n t[a][b], t[b][a] = true, true\nend\n\nlocal function check(tbl)\n local reached = {true}\n for i = 2, n do reached[i] = false end\n local reachnum = 1\n local tasks = {1}\n local tasknum, done = 1, 0\n while done < tasknum do\n done = done + 1\n local idx = tasks[done]\n for k, v in pairs(tbl[idx]) do\n if v and not reached[k] then\n table.insert(tasks, k)\n reached[k] = true\n reachnum = reachnum + 1\n tasknum = tasknum + 1\n end\n end\n end\n return n == reachnum\nend\nlocal ret = 0\nfor i = 1, m do\n t[as[i]][bs[i]], t[bs[i]][as[i]] = false, false\n if not check(t) then ret = ret + 1 end\n t[as[i]][bs[i]], t[bs[i]][as[i]] = true, true\nend\nprint(ret)\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nYou are given an undirected connected graph with N vertices and M edges that does not contain self-loops and double edges.\n\nThe i-th edge (1 \\leq i \\leq M) connects Vertex a_i and Vertex b_i.\n\nAn edge whose removal disconnects the graph is called a bridge.\n\nFind the number of the edges that are bridges among the M edges.\n\nNotes\n\nA self-loop is an edge i such that a_i=b_i (1 \\leq i \\leq M).\n\nDouble edges are a pair of edges i,j such that a_i=a_j and b_i=b_j (1 \\leq id[i] then\n checker=false\n end\n else\n checker=false\n end\nend\nprint(checker and \"YES\" or \"NO\")", "language": "Lua", "metadata": {"date": 1589334490, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03578.html", "problem_id": "p03578", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03578/input.txt", "sample_output_relpath": "derived/input_output/data/p03578/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03578/Lua/s474757189.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s474757189", "user_id": "u045238009"}, "prompt_components": {"gold_output": "YES\n", "input_to_evaluate": "local n=io.read(\"*n\",\"*l\")\nlocal d={}\nfor i=1,n do\n local x=io.read(\"*n\")\n if not d[x] then\n d[x]=1\n else\n d[x]=d[x]+1\n end\nend\nlocal m=io.read(\"*n\",\"*l\")\nlocal t={}\nfor i=1,m do\n local y=io.read(\"*n\")\n if not t[y] then\n t[y]=1\n else\n t[y]=t[y]+1\n end\nend\n\nchecker=true\nfor i,_ in pairs(t) do\n if d[i] then\n if t[i]>d[i] then\n checker=false\n end\n else\n checker=false\n end\nend\nprint(checker and \"YES\" or \"NO\")", "problem_context": "Score : 200 points\n\nProblem Statement\n\nRng is preparing a problem set for a qualification round of CODEFESTIVAL.\n\nHe has N candidates of problems. The difficulty of the i-th candidate is D_i.\n\nThere must be M problems in the problem set, and the difficulty of the i-th problem must be T_i. Here, one candidate of a problem cannot be used as multiple problems.\n\nDetermine whether Rng can complete the problem set without creating new candidates of problems.\n\nConstraints\n\n1 \\leq N \\leq 200,000\n\n1 \\leq D_i \\leq 10^9\n\n1 \\leq M \\leq 200,000\n\n1 \\leq T_i \\leq 10^9\n\nAll numbers in the input are integers.\n\nPartial Score\n\n100 points will be awarded for passing the test set satisfying N \\leq 100 and M \\leq 100.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nD_1 D_2 ... D_N\nM\nT_1 T_2 ... T_M\n\nOutput\n\nPrint YES if Rng can complete the problem set without creating new candidates of problems; print NO if he cannot.\n\nSample Input 1\n\n5\n3 1 4 1 5\n3\n5 4 3\n\nSample Output 1\n\nYES\n\nSample Input 2\n\n7\n100 200 500 700 1200 1600 2000\n6\n100 200 500 700 1600 1600\n\nSample Output 2\n\nNO\n\nNot enough 1600s.\n\nSample Input 3\n\n1\n800\n5\n100 100 100 100 100\n\nSample Output 3\n\nNO\n\nSample Input 4\n\n15\n1 2 2 3 3 3 4 4 4 4 5 5 5 5 5\n9\n5 4 3 2 1 2 3 4 5\n\nSample Output 4\n\nYES", "sample_input": "5\n3 1 4 1 5\n3\n5 4 3\n"}, "reference_outputs": ["YES\n"], "source_document_id": "p03578", "source_text": "Score : 200 points\n\nProblem Statement\n\nRng is preparing a problem set for a qualification round of CODEFESTIVAL.\n\nHe has N candidates of problems. The difficulty of the i-th candidate is D_i.\n\nThere must be M problems in the problem set, and the difficulty of the i-th problem must be T_i. Here, one candidate of a problem cannot be used as multiple problems.\n\nDetermine whether Rng can complete the problem set without creating new candidates of problems.\n\nConstraints\n\n1 \\leq N \\leq 200,000\n\n1 \\leq D_i \\leq 10^9\n\n1 \\leq M \\leq 200,000\n\n1 \\leq T_i \\leq 10^9\n\nAll numbers in the input are integers.\n\nPartial Score\n\n100 points will be awarded for passing the test set satisfying N \\leq 100 and M \\leq 100.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nD_1 D_2 ... D_N\nM\nT_1 T_2 ... T_M\n\nOutput\n\nPrint YES if Rng can complete the problem set without creating new candidates of problems; print NO if he cannot.\n\nSample Input 1\n\n5\n3 1 4 1 5\n3\n5 4 3\n\nSample Output 1\n\nYES\n\nSample Input 2\n\n7\n100 200 500 700 1200 1600 2000\n6\n100 200 500 700 1600 1600\n\nSample Output 2\n\nNO\n\nNot enough 1600s.\n\nSample Input 3\n\n1\n800\n5\n100 100 100 100 100\n\nSample Output 3\n\nNO\n\nSample Input 4\n\n15\n1 2 2 3 3 3 4 4 4 4 5 5 5 5 5\n9\n5 4 3 2 1 2 3 4 5\n\nSample Output 4\n\nYES", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 501, "cpu_time_ms": 208, "memory_kb": 24804}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s471318974", "group_id": "codeNet:p03578", "input_text": "local n=io.read(\"*n\",\"*l\")\nlocal d={}\nfor i=1,n do\n local x=io.read(\"*n\")\n if not d[x] then\n d[x]=1\n else\n d[x]=d[x]+1\n end\nend\nlocal m=io.read(\"*n\",\"*l\")\nlocal t={}\nfor i=1,m do\n local y=io.read(\"*n\")\n if not t[y] then\n t[y]=1\n else\n t[y]=t[y]+1\n end\nend\n\nfor i,_ in pairs(t) do\n if t[i]>d[i] then\n print(\"NO\")\n return \n end\nend\nprint(\"YES\")", "language": "Lua", "metadata": {"date": 1589334315, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03578.html", "problem_id": "p03578", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03578/input.txt", "sample_output_relpath": "derived/input_output/data/p03578/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03578/Lua/s471318974.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s471318974", "user_id": "u045238009"}, "prompt_components": {"gold_output": "YES\n", "input_to_evaluate": "local n=io.read(\"*n\",\"*l\")\nlocal d={}\nfor i=1,n do\n local x=io.read(\"*n\")\n if not d[x] then\n d[x]=1\n else\n d[x]=d[x]+1\n end\nend\nlocal m=io.read(\"*n\",\"*l\")\nlocal t={}\nfor i=1,m do\n local y=io.read(\"*n\")\n if not t[y] then\n t[y]=1\n else\n t[y]=t[y]+1\n end\nend\n\nfor i,_ in pairs(t) do\n if t[i]>d[i] then\n print(\"NO\")\n return \n end\nend\nprint(\"YES\")", "problem_context": "Score : 200 points\n\nProblem Statement\n\nRng is preparing a problem set for a qualification round of CODEFESTIVAL.\n\nHe has N candidates of problems. The difficulty of the i-th candidate is D_i.\n\nThere must be M problems in the problem set, and the difficulty of the i-th problem must be T_i. Here, one candidate of a problem cannot be used as multiple problems.\n\nDetermine whether Rng can complete the problem set without creating new candidates of problems.\n\nConstraints\n\n1 \\leq N \\leq 200,000\n\n1 \\leq D_i \\leq 10^9\n\n1 \\leq M \\leq 200,000\n\n1 \\leq T_i \\leq 10^9\n\nAll numbers in the input are integers.\n\nPartial Score\n\n100 points will be awarded for passing the test set satisfying N \\leq 100 and M \\leq 100.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nD_1 D_2 ... D_N\nM\nT_1 T_2 ... T_M\n\nOutput\n\nPrint YES if Rng can complete the problem set without creating new candidates of problems; print NO if he cannot.\n\nSample Input 1\n\n5\n3 1 4 1 5\n3\n5 4 3\n\nSample Output 1\n\nYES\n\nSample Input 2\n\n7\n100 200 500 700 1200 1600 2000\n6\n100 200 500 700 1600 1600\n\nSample Output 2\n\nNO\n\nNot enough 1600s.\n\nSample Input 3\n\n1\n800\n5\n100 100 100 100 100\n\nSample Output 3\n\nNO\n\nSample Input 4\n\n15\n1 2 2 3 3 3 4 4 4 4 5 5 5 5 5\n9\n5 4 3 2 1 2 3 4 5\n\nSample Output 4\n\nYES", "sample_input": "5\n3 1 4 1 5\n3\n5 4 3\n"}, "reference_outputs": ["YES\n"], "source_document_id": "p03578", "source_text": "Score : 200 points\n\nProblem Statement\n\nRng is preparing a problem set for a qualification round of CODEFESTIVAL.\n\nHe has N candidates of problems. The difficulty of the i-th candidate is D_i.\n\nThere must be M problems in the problem set, and the difficulty of the i-th problem must be T_i. Here, one candidate of a problem cannot be used as multiple problems.\n\nDetermine whether Rng can complete the problem set without creating new candidates of problems.\n\nConstraints\n\n1 \\leq N \\leq 200,000\n\n1 \\leq D_i \\leq 10^9\n\n1 \\leq M \\leq 200,000\n\n1 \\leq T_i \\leq 10^9\n\nAll numbers in the input are integers.\n\nPartial Score\n\n100 points will be awarded for passing the test set satisfying N \\leq 100 and M \\leq 100.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nD_1 D_2 ... D_N\nM\nT_1 T_2 ... T_M\n\nOutput\n\nPrint YES if Rng can complete the problem set without creating new candidates of problems; print NO if he cannot.\n\nSample Input 1\n\n5\n3 1 4 1 5\n3\n5 4 3\n\nSample Output 1\n\nYES\n\nSample Input 2\n\n7\n100 200 500 700 1200 1600 2000\n6\n100 200 500 700 1600 1600\n\nSample Output 2\n\nNO\n\nNot enough 1600s.\n\nSample Input 3\n\n1\n800\n5\n100 100 100 100 100\n\nSample Output 3\n\nNO\n\nSample Input 4\n\n15\n1 2 2 3 3 3 4 4 4 4 5 5 5 5 5\n9\n5 4 3 2 1 2 3 4 5\n\nSample Output 4\n\nYES", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 417, "cpu_time_ms": 188, "memory_kb": 24804}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s170425444", "group_id": "codeNet:p03578", "input_text": "n = io.read('*n')\na = {}\nfor i = 1, n do\n local u = io.read('*n')\n if not a[u] then a[u] = 0 end\n a[u] = a[u] + 1\nend\n\nm = io.read('*n')\nans = true\nfor i = 1, m do\n local u = io.read('*n')\n if not a[u] or a[u] == 0 then\n ans = false\n break\n end\n a[u] = a[u] - 1\nend\nif ans then print('YES') else print('NO') end", "language": "Lua", "metadata": {"date": 1507511125, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03578.html", "problem_id": "p03578", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03578/input.txt", "sample_output_relpath": "derived/input_output/data/p03578/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03578/Lua/s170425444.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s170425444", "user_id": "u402685795"}, "prompt_components": {"gold_output": "YES\n", "input_to_evaluate": "n = io.read('*n')\na = {}\nfor i = 1, n do\n local u = io.read('*n')\n if not a[u] then a[u] = 0 end\n a[u] = a[u] + 1\nend\n\nm = io.read('*n')\nans = true\nfor i = 1, m do\n local u = io.read('*n')\n if not a[u] or a[u] == 0 then\n ans = false\n break\n end\n a[u] = a[u] - 1\nend\nif ans then print('YES') else print('NO') end", "problem_context": "Score : 200 points\n\nProblem Statement\n\nRng is preparing a problem set for a qualification round of CODEFESTIVAL.\n\nHe has N candidates of problems. The difficulty of the i-th candidate is D_i.\n\nThere must be M problems in the problem set, and the difficulty of the i-th problem must be T_i. Here, one candidate of a problem cannot be used as multiple problems.\n\nDetermine whether Rng can complete the problem set without creating new candidates of problems.\n\nConstraints\n\n1 \\leq N \\leq 200,000\n\n1 \\leq D_i \\leq 10^9\n\n1 \\leq M \\leq 200,000\n\n1 \\leq T_i \\leq 10^9\n\nAll numbers in the input are integers.\n\nPartial Score\n\n100 points will be awarded for passing the test set satisfying N \\leq 100 and M \\leq 100.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nD_1 D_2 ... D_N\nM\nT_1 T_2 ... T_M\n\nOutput\n\nPrint YES if Rng can complete the problem set without creating new candidates of problems; print NO if he cannot.\n\nSample Input 1\n\n5\n3 1 4 1 5\n3\n5 4 3\n\nSample Output 1\n\nYES\n\nSample Input 2\n\n7\n100 200 500 700 1200 1600 2000\n6\n100 200 500 700 1600 1600\n\nSample Output 2\n\nNO\n\nNot enough 1600s.\n\nSample Input 3\n\n1\n800\n5\n100 100 100 100 100\n\nSample Output 3\n\nNO\n\nSample Input 4\n\n15\n1 2 2 3 3 3 4 4 4 4 5 5 5 5 5\n9\n5 4 3 2 1 2 3 4 5\n\nSample Output 4\n\nYES", "sample_input": "5\n3 1 4 1 5\n3\n5 4 3\n"}, "reference_outputs": ["YES\n"], "source_document_id": "p03578", "source_text": "Score : 200 points\n\nProblem Statement\n\nRng is preparing a problem set for a qualification round of CODEFESTIVAL.\n\nHe has N candidates of problems. The difficulty of the i-th candidate is D_i.\n\nThere must be M problems in the problem set, and the difficulty of the i-th problem must be T_i. Here, one candidate of a problem cannot be used as multiple problems.\n\nDetermine whether Rng can complete the problem set without creating new candidates of problems.\n\nConstraints\n\n1 \\leq N \\leq 200,000\n\n1 \\leq D_i \\leq 10^9\n\n1 \\leq M \\leq 200,000\n\n1 \\leq T_i \\leq 10^9\n\nAll numbers in the input are integers.\n\nPartial Score\n\n100 points will be awarded for passing the test set satisfying N \\leq 100 and M \\leq 100.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nD_1 D_2 ... D_N\nM\nT_1 T_2 ... T_M\n\nOutput\n\nPrint YES if Rng can complete the problem set without creating new candidates of problems; print NO if he cannot.\n\nSample Input 1\n\n5\n3 1 4 1 5\n3\n5 4 3\n\nSample Output 1\n\nYES\n\nSample Input 2\n\n7\n100 200 500 700 1200 1600 2000\n6\n100 200 500 700 1600 1600\n\nSample Output 2\n\nNO\n\nNot enough 1600s.\n\nSample Input 3\n\n1\n800\n5\n100 100 100 100 100\n\nSample Output 3\n\nNO\n\nSample Input 4\n\n15\n1 2 2 3 3 3 4 4 4 4 5 5 5 5 5\n9\n5 4 3 2 1 2 3 4 5\n\nSample Output 4\n\nYES", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 324, "cpu_time_ms": 196, "memory_kb": 12648}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s980238967", "group_id": "codeNet:p03583", "input_text": "local n=io.read(\"n\")\nfor i=1,3500 do\n for j=1,3500 do\n local a=n*i*j\n local b=(4*i*j-n*j-n*i)\n if b>0 and a%b==0 then\n print(i..\" \"..j..\" \"..a//b)\n return\n end\n end\nend", "language": "Lua", "metadata": {"date": 1594522129, "filename_ext": "lua", "original_language": "Lua (Lua 5.3.5)", "problem_description_relpath": "problem_descriptions/p03583.html", "problem_id": "p03583", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03583/input.txt", "sample_output_relpath": "derived/input_output/data/p03583/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03583/Lua/s980238967.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s980238967", "user_id": "u045238009"}, "prompt_components": {"gold_output": "1 2 2\n", "input_to_evaluate": "local n=io.read(\"n\")\nfor i=1,3500 do\n for j=1,3500 do\n local a=n*i*j\n local b=(4*i*j-n*j-n*i)\n if b>0 and a%b==0 then\n print(i..\" \"..j..\" \"..a//b)\n return\n end\n end\nend", "problem_context": "Score : 300 points\n\nProblem Statement\n\nYou are given an integer N.\n\nFind a triple of positive integers h, n and w such that 4/N = 1/h + 1/n + 1/w.\n\nIf there are multiple solutions, any of them will be accepted.\n\nConstraints\n\nIt is guaranteed that, for the given integer N, there exists a solution such that h,n,w \\leq 3500.\n\nInputs\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutputs\n\nPrint a triple of positive integers h, n and w that satisfies the condition, in the following format:\n\nh n w\n\nSample Input 1\n\n2\n\nSample Output 1\n\n1 2 2\n\n4/2 = 1/1 + 1/2 + 1/2.\n\nSample Input 2\n\n3485\n\nSample Output 2\n\n872 1012974 1539173474040\n\nIt is allowed to use an integer exceeding 3500 in a solution.\n\nSample Input 3\n\n4664\n\nSample Output 3\n\n3498 3498 3498", "sample_input": "2\n"}, "reference_outputs": ["1 2 2\n"], "source_document_id": "p03583", "source_text": "Score : 300 points\n\nProblem Statement\n\nYou are given an integer N.\n\nFind a triple of positive integers h, n and w such that 4/N = 1/h + 1/n + 1/w.\n\nIf there are multiple solutions, any of them will be accepted.\n\nConstraints\n\nIt is guaranteed that, for the given integer N, there exists a solution such that h,n,w \\leq 3500.\n\nInputs\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutputs\n\nPrint a triple of positive integers h, n and w that satisfies the condition, in the following format:\n\nh n w\n\nSample Input 1\n\n2\n\nSample Output 1\n\n1 2 2\n\n4/2 = 1/1 + 1/2 + 1/2.\n\nSample Input 2\n\n3485\n\nSample Output 2\n\n872 1012974 1539173474040\n\nIt is allowed to use an integer exceeding 3500 in a solution.\n\nSample Input 3\n\n4664\n\nSample Output 3\n\n3498 3498 3498", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 224, "cpu_time_ms": 298, "memory_kb": 2788}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s433228537", "group_id": "codeNet:p03583", "input_text": "local n=io.read(\"n\")\nfor i=1,3500 do\n for j=1,3500 do\n local k=n*i*j/(4*i*j-n*j-n*i)\n if math.fmod(k,1)==0 and k>=0 then\n print(i..\" \"..j..\" \"..string.format(\"%d\",k))\n return\n end\n end\nend", "language": "Lua", "metadata": {"date": 1594521630, "filename_ext": "lua", "original_language": "Lua (LuaJIT 2.1.0)", "problem_description_relpath": "problem_descriptions/p03583.html", "problem_id": "p03583", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03583/input.txt", "sample_output_relpath": "derived/input_output/data/p03583/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03583/Lua/s433228537.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s433228537", "user_id": "u045238009"}, "prompt_components": {"gold_output": "1 2 2\n", "input_to_evaluate": "local n=io.read(\"n\")\nfor i=1,3500 do\n for j=1,3500 do\n local k=n*i*j/(4*i*j-n*j-n*i)\n if math.fmod(k,1)==0 and k>=0 then\n print(i..\" \"..j..\" \"..string.format(\"%d\",k))\n return\n end\n end\nend", "problem_context": "Score : 300 points\n\nProblem Statement\n\nYou are given an integer N.\n\nFind a triple of positive integers h, n and w such that 4/N = 1/h + 1/n + 1/w.\n\nIf there are multiple solutions, any of them will be accepted.\n\nConstraints\n\nIt is guaranteed that, for the given integer N, there exists a solution such that h,n,w \\leq 3500.\n\nInputs\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutputs\n\nPrint a triple of positive integers h, n and w that satisfies the condition, in the following format:\n\nh n w\n\nSample Input 1\n\n2\n\nSample Output 1\n\n1 2 2\n\n4/2 = 1/1 + 1/2 + 1/2.\n\nSample Input 2\n\n3485\n\nSample Output 2\n\n872 1012974 1539173474040\n\nIt is allowed to use an integer exceeding 3500 in a solution.\n\nSample Input 3\n\n4664\n\nSample Output 3\n\n3498 3498 3498", "sample_input": "2\n"}, "reference_outputs": ["1 2 2\n"], "source_document_id": "p03583", "source_text": "Score : 300 points\n\nProblem Statement\n\nYou are given an integer N.\n\nFind a triple of positive integers h, n and w such that 4/N = 1/h + 1/n + 1/w.\n\nIf there are multiple solutions, any of them will be accepted.\n\nConstraints\n\nIt is guaranteed that, for the given integer N, there exists a solution such that h,n,w \\leq 3500.\n\nInputs\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutputs\n\nPrint a triple of positive integers h, n and w that satisfies the condition, in the following format:\n\nh n w\n\nSample Input 1\n\n2\n\nSample Output 1\n\n1 2 2\n\n4/2 = 1/1 + 1/2 + 1/2.\n\nSample Input 2\n\n3485\n\nSample Output 2\n\n872 1012974 1539173474040\n\nIt is allowed to use an integer exceeding 3500 in a solution.\n\nSample Input 3\n\n4664\n\nSample Output 3\n\n3498 3498 3498", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 237, "cpu_time_ms": 349, "memory_kb": 2848}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s935347758", "group_id": "codeNet:p03583", "input_text": "local n = io.read(\"*n\")\nfor i = 1, 3500 do\n for j = i, 3500 do\n --[[\n 4ijk = Njk + Nik + Nij\n k(4ij - Nj - Ni) = Nij\n ]]\n local a = n * i * j\n local b = 4 * i * j - n * (i + j)\n if 0 < b and a % b == 0 then\n local k = a // b\n print(i ..\" \" .. j .. \" \" .. k)\n os.exit()\n end\n end\nend\n", "language": "Lua", "metadata": {"date": 1594092837, "filename_ext": "lua", "original_language": "Lua (Lua 5.3.5)", "problem_description_relpath": "problem_descriptions/p03583.html", "problem_id": "p03583", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03583/input.txt", "sample_output_relpath": "derived/input_output/data/p03583/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03583/Lua/s935347758.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s935347758", "user_id": "u120582723"}, "prompt_components": {"gold_output": "1 2 2\n", "input_to_evaluate": "local n = io.read(\"*n\")\nfor i = 1, 3500 do\n for j = i, 3500 do\n --[[\n 4ijk = Njk + Nik + Nij\n k(4ij - Nj - Ni) = Nij\n ]]\n local a = n * i * j\n local b = 4 * i * j - n * (i + j)\n if 0 < b and a % b == 0 then\n local k = a // b\n print(i ..\" \" .. j .. \" \" .. k)\n os.exit()\n end\n end\nend\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nYou are given an integer N.\n\nFind a triple of positive integers h, n and w such that 4/N = 1/h + 1/n + 1/w.\n\nIf there are multiple solutions, any of them will be accepted.\n\nConstraints\n\nIt is guaranteed that, for the given integer N, there exists a solution such that h,n,w \\leq 3500.\n\nInputs\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutputs\n\nPrint a triple of positive integers h, n and w that satisfies the condition, in the following format:\n\nh n w\n\nSample Input 1\n\n2\n\nSample Output 1\n\n1 2 2\n\n4/2 = 1/1 + 1/2 + 1/2.\n\nSample Input 2\n\n3485\n\nSample Output 2\n\n872 1012974 1539173474040\n\nIt is allowed to use an integer exceeding 3500 in a solution.\n\nSample Input 3\n\n4664\n\nSample Output 3\n\n3498 3498 3498", "sample_input": "2\n"}, "reference_outputs": ["1 2 2\n"], "source_document_id": "p03583", "source_text": "Score : 300 points\n\nProblem Statement\n\nYou are given an integer N.\n\nFind a triple of positive integers h, n and w such that 4/N = 1/h + 1/n + 1/w.\n\nIf there are multiple solutions, any of them will be accepted.\n\nConstraints\n\nIt is guaranteed that, for the given integer N, there exists a solution such that h,n,w \\leq 3500.\n\nInputs\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutputs\n\nPrint a triple of positive integers h, n and w that satisfies the condition, in the following format:\n\nh n w\n\nSample Input 1\n\n2\n\nSample Output 1\n\n1 2 2\n\n4/2 = 1/1 + 1/2 + 1/2.\n\nSample Input 2\n\n3485\n\nSample Output 2\n\n872 1012974 1539173474040\n\nIt is allowed to use an integer exceeding 3500 in a solution.\n\nSample Input 3\n\n4664\n\nSample Output 3\n\n3498 3498 3498", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 324, "cpu_time_ms": 209, "memory_kb": 2748}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s635719672", "group_id": "codeNet:p03591", "input_text": "if io.read():sub(1,4)=='YAKI'then print('Yes')else print('No')end", "language": "Lua", "metadata": {"date": 1506229909, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03591.html", "problem_id": "p03591", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03591/input.txt", "sample_output_relpath": "derived/input_output/data/p03591/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03591/Lua/s635719672.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s635719672", "user_id": "u785421275"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "if io.read():sub(1,4)=='YAKI'then print('Yes')else print('No')end", "problem_context": "Score : 100 points\n\nProblem Statement\n\nRingo is giving a present to Snuke.\n\nRingo has found out that Snuke loves yakiniku (a Japanese term meaning grilled meat. yaki: grilled, niku: meat). He supposes that Snuke likes grilled things starting with YAKI in Japanese, and does not like other things.\n\nYou are given a string S representing the Japanese name of Ringo's present to Snuke. Determine whether S starts with YAKI.\n\nConstraints\n\n1 \\leq |S| \\leq 10\n\nS consists of uppercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nIf S starts with YAKI, print Yes; otherwise, print No.\n\nSample Input 1\n\nYAKINIKU\n\nSample Output 1\n\nYes\n\nYAKINIKU starts with YAKI.\n\nSample Input 2\n\nTAKOYAKI\n\nSample Output 2\n\nNo\n\nTAKOYAKI (a Japanese snack. tako: octopus) does not start with YAKI.\n\nSample Input 3\n\nYAK\n\nSample Output 3\n\nNo", "sample_input": "YAKINIKU\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03591", "source_text": "Score : 100 points\n\nProblem Statement\n\nRingo is giving a present to Snuke.\n\nRingo has found out that Snuke loves yakiniku (a Japanese term meaning grilled meat. yaki: grilled, niku: meat). He supposes that Snuke likes grilled things starting with YAKI in Japanese, and does not like other things.\n\nYou are given a string S representing the Japanese name of Ringo's present to Snuke. Determine whether S starts with YAKI.\n\nConstraints\n\n1 \\leq |S| \\leq 10\n\nS consists of uppercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nIf S starts with YAKI, print Yes; otherwise, print No.\n\nSample Input 1\n\nYAKINIKU\n\nSample Output 1\n\nYes\n\nYAKINIKU starts with YAKI.\n\nSample Input 2\n\nTAKOYAKI\n\nSample Output 2\n\nNo\n\nTAKOYAKI (a Japanese snack. tako: octopus) does not start with YAKI.\n\nSample Input 3\n\nYAK\n\nSample Output 3\n\nNo", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 65, "cpu_time_ms": 5, "memory_kb": 752}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s099921785", "group_id": "codeNet:p03592", "input_text": "local h, w, k = io.read(\"*n\", \"*n\", \"*n\")\nlocal f = false\nfor i_h = 0, h do\n for i_w = 0, w do\n if(k == w * i_h + h * i_w - 2 * i_h * i_w) then\n f = true\n break\n end\n end\n if f then break end\nend\nprint(f and \"Yes\" or \"No\")\n", "language": "Lua", "metadata": {"date": 1558285748, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p03592.html", "problem_id": "p03592", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03592/input.txt", "sample_output_relpath": "derived/input_output/data/p03592/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03592/Lua/s099921785.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s099921785", "user_id": "u120582723"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "local h, w, k = io.read(\"*n\", \"*n\", \"*n\")\nlocal f = false\nfor i_h = 0, h do\n for i_w = 0, w do\n if(k == w * i_h + h * i_w - 2 * i_h * i_w) then\n f = true\n break\n end\n end\n if f then break end\nend\nprint(f and \"Yes\" or \"No\")\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nWe have a grid with N rows and M columns of squares. Initially, all the squares are white.\n\nThere is a button attached to each row and each column.\nWhen a button attached to a row is pressed, the colors of all the squares in that row are inverted; that is, white squares become black and vice versa.\nWhen a button attached to a column is pressed, the colors of all the squares in that column are inverted.\n\nTakahashi can freely press the buttons any number of times. Determine whether he can have exactly K black squares in the grid.\n\nConstraints\n\n1 \\leq N,M \\leq 1000\n\n0 \\leq K \\leq NM\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M K\n\nOutput\n\nIf Takahashi can have exactly K black squares in the grid, print Yes; otherwise, print No.\n\nSample Input 1\n\n2 2 2\n\nSample Output 1\n\nYes\n\nPress the buttons in the order of the first row, the first column.\n\nSample Input 2\n\n2 2 1\n\nSample Output 2\n\nNo\n\nSample Input 3\n\n3 5 8\n\nSample Output 3\n\nYes\n\nPress the buttons in the order of the first column, third column, second row, fifth column.\n\nSample Input 4\n\n7 9 20\n\nSample Output 4\n\nNo", "sample_input": "2 2 2\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03592", "source_text": "Score : 200 points\n\nProblem Statement\n\nWe have a grid with N rows and M columns of squares. Initially, all the squares are white.\n\nThere is a button attached to each row and each column.\nWhen a button attached to a row is pressed, the colors of all the squares in that row are inverted; that is, white squares become black and vice versa.\nWhen a button attached to a column is pressed, the colors of all the squares in that column are inverted.\n\nTakahashi can freely press the buttons any number of times. Determine whether he can have exactly K black squares in the grid.\n\nConstraints\n\n1 \\leq N,M \\leq 1000\n\n0 \\leq K \\leq NM\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M K\n\nOutput\n\nIf Takahashi can have exactly K black squares in the grid, print Yes; otherwise, print No.\n\nSample Input 1\n\n2 2 2\n\nSample Output 1\n\nYes\n\nPress the buttons in the order of the first row, the first column.\n\nSample Input 2\n\n2 2 1\n\nSample Output 2\n\nNo\n\nSample Input 3\n\n3 5 8\n\nSample Output 3\n\nYes\n\nPress the buttons in the order of the first column, third column, second row, fifth column.\n\nSample Input 4\n\n7 9 20\n\nSample Output 4\n\nNo", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 242, "cpu_time_ms": 3, "memory_kb": 256}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s370039345", "group_id": "codeNet:p03593", "input_text": "local h,w=io.read(\"n\",\"n\",\"l\")\nlocal map={}\nfor i=1,h do\n local s=io.read()\n for j=1,w do\n local a=s:sub(j,j)\n map[a]=(map[a] or 0)+1\n end\nend\n\nlocal count={}\nfor k,v in pairs(map) do\n count[v]=(count[v] or 0)+1\nend\n\nlocal g1=(h%2)*(w%2)\nlocal g2=(h%2)*(w//2)+(w%2)*(h//2)\nlocal g4=(h//2)*(w//2)\n\nwhile g1>0 do\n local checker=false\n for i=1,10000 do\n if i%4==1 or i%4==3 then\n if count[i] and count[i]>0 then\n count[i]=count[i]-1\n count[i-1]=(count[i-1] or 0)+1\n checker=true\n g1=g1-1\n end\n end\n end\n if not checker then\n print(\"No\")\n return\n end\nend\n\nwhile g2>0 do\n local checker=false\n for i=1,10000 do\n if i%4==2 then\n if count[i] and count[i]>0 then\n count[i]=count[i]-1\n count[i-2]=(count[i-2] or 0)+1\n checker=true\n g2=g2-1\n end\n end\n end\n if not checker then\n print(\"No\")\n return\n end\nend\n\nwhile g4>0 do\n local checker=false\n for i=1,10000 do\n if i%4==0 then\n if count[i] and count[i]>0 then\n count[i]=count[i]-1\n count[i-4]=(count[i-4] or 0)+1\n checker=true\n g4=g4-1\n end\n end\n end\n if not checker then\n print(\"No\")\n return\n end\nend\n\nprint(\"Yes\")", "language": "Lua", "metadata": {"date": 1596865183, "filename_ext": "lua", "original_language": "Lua (Lua 5.3.5)", "problem_description_relpath": "problem_descriptions/p03593.html", "problem_id": "p03593", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03593/input.txt", "sample_output_relpath": "derived/input_output/data/p03593/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03593/Lua/s370039345.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s370039345", "user_id": "u045238009"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "local h,w=io.read(\"n\",\"n\",\"l\")\nlocal map={}\nfor i=1,h do\n local s=io.read()\n for j=1,w do\n local a=s:sub(j,j)\n map[a]=(map[a] or 0)+1\n end\nend\n\nlocal count={}\nfor k,v in pairs(map) do\n count[v]=(count[v] or 0)+1\nend\n\nlocal g1=(h%2)*(w%2)\nlocal g2=(h%2)*(w//2)+(w%2)*(h//2)\nlocal g4=(h//2)*(w//2)\n\nwhile g1>0 do\n local checker=false\n for i=1,10000 do\n if i%4==1 or i%4==3 then\n if count[i] and count[i]>0 then\n count[i]=count[i]-1\n count[i-1]=(count[i-1] or 0)+1\n checker=true\n g1=g1-1\n end\n end\n end\n if not checker then\n print(\"No\")\n return\n end\nend\n\nwhile g2>0 do\n local checker=false\n for i=1,10000 do\n if i%4==2 then\n if count[i] and count[i]>0 then\n count[i]=count[i]-1\n count[i-2]=(count[i-2] or 0)+1\n checker=true\n g2=g2-1\n end\n end\n end\n if not checker then\n print(\"No\")\n return\n end\nend\n\nwhile g4>0 do\n local checker=false\n for i=1,10000 do\n if i%4==0 then\n if count[i] and count[i]>0 then\n count[i]=count[i]-1\n count[i-4]=(count[i-4] or 0)+1\n checker=true\n g4=g4-1\n end\n end\n end\n if not checker then\n print(\"No\")\n return\n end\nend\n\nprint(\"Yes\")", "problem_context": "Score : 400 points\n\nProblem Statement\n\nWe have an H-by-W matrix.\nLet a_{ij} be the element at the i-th row from the top and j-th column from the left.\nIn this matrix, each a_{ij} is a lowercase English letter.\n\nSnuke is creating another H-by-W matrix, A', by freely rearranging the elements in A.\nHere, he wants to satisfy the following condition:\n\nEvery row and column in A' can be read as a palindrome.\n\nDetermine whether he can create a matrix satisfying the condition.\n\nNote\n\nA palindrome is a string that reads the same forward and backward.\nFor example, a, aa, abba and abcba are all palindromes, while ab, abab and abcda are not.\n\nConstraints\n\n1 ≤ H, W ≤ 100\n\na_{ij} is a lowercase English letter.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\na_{11}a_{12}...a_{1W}\n:\na_{H1}a_{H2}...a_{HW}\n\nOutput\n\nIf Snuke can create a matrix satisfying the condition, print Yes; otherwise, print No.\n\nSample Input 1\n\n3 4\naabb\naabb\naacc\n\nSample Output 1\n\nYes\n\nFor example, the following matrix satisfies the condition.\n\nabba\nacca\nabba\n\nSample Input 2\n\n2 2\naa\nbb\n\nSample Output 2\n\nNo\n\nIt is not possible to create a matrix satisfying the condition, no matter how we rearrange the elements in A.\n\nSample Input 3\n\n5 1\nt\nw\ne\ne\nt\n\nSample Output 3\n\nYes\n\nFor example, the following matrix satisfies the condition.\n\nt\ne\nw\ne\nt\n\nSample Input 4\n\n2 5\nabxba\nabyba\n\nSample Output 4\n\nNo\n\nSample Input 5\n\n1 1\nz\n\nSample Output 5\n\nYes", "sample_input": "3 4\naabb\naabb\naacc\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03593", "source_text": "Score : 400 points\n\nProblem Statement\n\nWe have an H-by-W matrix.\nLet a_{ij} be the element at the i-th row from the top and j-th column from the left.\nIn this matrix, each a_{ij} is a lowercase English letter.\n\nSnuke is creating another H-by-W matrix, A', by freely rearranging the elements in A.\nHere, he wants to satisfy the following condition:\n\nEvery row and column in A' can be read as a palindrome.\n\nDetermine whether he can create a matrix satisfying the condition.\n\nNote\n\nA palindrome is a string that reads the same forward and backward.\nFor example, a, aa, abba and abcba are all palindromes, while ab, abab and abcda are not.\n\nConstraints\n\n1 ≤ H, W ≤ 100\n\na_{ij} is a lowercase English letter.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\na_{11}a_{12}...a_{1W}\n:\na_{H1}a_{H2}...a_{HW}\n\nOutput\n\nIf Snuke can create a matrix satisfying the condition, print Yes; otherwise, print No.\n\nSample Input 1\n\n3 4\naabb\naabb\naacc\n\nSample Output 1\n\nYes\n\nFor example, the following matrix satisfies the condition.\n\nabba\nacca\nabba\n\nSample Input 2\n\n2 2\naa\nbb\n\nSample Output 2\n\nNo\n\nIt is not possible to create a matrix satisfying the condition, no matter how we rearrange the elements in A.\n\nSample Input 3\n\n5 1\nt\nw\ne\ne\nt\n\nSample Output 3\n\nYes\n\nFor example, the following matrix satisfies the condition.\n\nt\ne\nw\ne\nt\n\nSample Input 4\n\n2 5\nabxba\nabyba\n\nSample Output 4\n\nNo\n\nSample Input 5\n\n1 1\nz\n\nSample Output 5\n\nYes", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1455, "cpu_time_ms": 144, "memory_kb": 2692}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s212175151", "group_id": "codeNet:p03593", "input_text": "local h,w=io.read(\"n\",\"n\",\"l\")\nlocal map={}\nfor i=1,h do\n local s=io.read()\n for j=1,w do\n local a=s:sub(j,j)\n map[a]=(map[a] or 0)+1\n end\nend\n\nlocal g1=(h%2)*(w%2)\nlocal g2=(h%2)*(w//2)+(w%2)*(h//2)\nlocal g4=(h//2)*(w//2)\n\nwhile g1>0 do\n local checker=false\n for k,v in pairs(map) do\n if v%4==1 or v%4==3 then\n map[k]=map[k]-1\n g1=g1-1\n checker=true\n end\n end\n if not checker then\n print(\"No\")\n return\n end\nend\n\nwhile g2>0 do\n local checker=false\n for k,v in pairs(map) do\n if v%4==2 then\n map[k]=map[k]-2\n g2=g2-1\n checker=true\n end\n end\n if not checker then\n print(\"No\")\n return\n end\nend\n\nwhile g4>0 do\n local checker=false\n for k,v in pairs(map) do\n if v%4==0 then\n map[k]=map[k]-4\n g4=g4-1\n checker=true\n end\n end\n if not checker then\n print(\"No\")\n return\n end\nend\n\nprint(\"Yes\")", "language": "Lua", "metadata": {"date": 1596864767, "filename_ext": "lua", "original_language": "Lua (Lua 5.3.5)", "problem_description_relpath": "problem_descriptions/p03593.html", "problem_id": "p03593", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03593/input.txt", "sample_output_relpath": "derived/input_output/data/p03593/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03593/Lua/s212175151.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s212175151", "user_id": "u045238009"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "local h,w=io.read(\"n\",\"n\",\"l\")\nlocal map={}\nfor i=1,h do\n local s=io.read()\n for j=1,w do\n local a=s:sub(j,j)\n map[a]=(map[a] or 0)+1\n end\nend\n\nlocal g1=(h%2)*(w%2)\nlocal g2=(h%2)*(w//2)+(w%2)*(h//2)\nlocal g4=(h//2)*(w//2)\n\nwhile g1>0 do\n local checker=false\n for k,v in pairs(map) do\n if v%4==1 or v%4==3 then\n map[k]=map[k]-1\n g1=g1-1\n checker=true\n end\n end\n if not checker then\n print(\"No\")\n return\n end\nend\n\nwhile g2>0 do\n local checker=false\n for k,v in pairs(map) do\n if v%4==2 then\n map[k]=map[k]-2\n g2=g2-1\n checker=true\n end\n end\n if not checker then\n print(\"No\")\n return\n end\nend\n\nwhile g4>0 do\n local checker=false\n for k,v in pairs(map) do\n if v%4==0 then\n map[k]=map[k]-4\n g4=g4-1\n checker=true\n end\n end\n if not checker then\n print(\"No\")\n return\n end\nend\n\nprint(\"Yes\")", "problem_context": "Score : 400 points\n\nProblem Statement\n\nWe have an H-by-W matrix.\nLet a_{ij} be the element at the i-th row from the top and j-th column from the left.\nIn this matrix, each a_{ij} is a lowercase English letter.\n\nSnuke is creating another H-by-W matrix, A', by freely rearranging the elements in A.\nHere, he wants to satisfy the following condition:\n\nEvery row and column in A' can be read as a palindrome.\n\nDetermine whether he can create a matrix satisfying the condition.\n\nNote\n\nA palindrome is a string that reads the same forward and backward.\nFor example, a, aa, abba and abcba are all palindromes, while ab, abab and abcda are not.\n\nConstraints\n\n1 ≤ H, W ≤ 100\n\na_{ij} is a lowercase English letter.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\na_{11}a_{12}...a_{1W}\n:\na_{H1}a_{H2}...a_{HW}\n\nOutput\n\nIf Snuke can create a matrix satisfying the condition, print Yes; otherwise, print No.\n\nSample Input 1\n\n3 4\naabb\naabb\naacc\n\nSample Output 1\n\nYes\n\nFor example, the following matrix satisfies the condition.\n\nabba\nacca\nabba\n\nSample Input 2\n\n2 2\naa\nbb\n\nSample Output 2\n\nNo\n\nIt is not possible to create a matrix satisfying the condition, no matter how we rearrange the elements in A.\n\nSample Input 3\n\n5 1\nt\nw\ne\ne\nt\n\nSample Output 3\n\nYes\n\nFor example, the following matrix satisfies the condition.\n\nt\ne\nw\ne\nt\n\nSample Input 4\n\n2 5\nabxba\nabyba\n\nSample Output 4\n\nNo\n\nSample Input 5\n\n1 1\nz\n\nSample Output 5\n\nYes", "sample_input": "3 4\naabb\naabb\naacc\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03593", "source_text": "Score : 400 points\n\nProblem Statement\n\nWe have an H-by-W matrix.\nLet a_{ij} be the element at the i-th row from the top and j-th column from the left.\nIn this matrix, each a_{ij} is a lowercase English letter.\n\nSnuke is creating another H-by-W matrix, A', by freely rearranging the elements in A.\nHere, he wants to satisfy the following condition:\n\nEvery row and column in A' can be read as a palindrome.\n\nDetermine whether he can create a matrix satisfying the condition.\n\nNote\n\nA palindrome is a string that reads the same forward and backward.\nFor example, a, aa, abba and abcba are all palindromes, while ab, abab and abcda are not.\n\nConstraints\n\n1 ≤ H, W ≤ 100\n\na_{ij} is a lowercase English letter.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\na_{11}a_{12}...a_{1W}\n:\na_{H1}a_{H2}...a_{HW}\n\nOutput\n\nIf Snuke can create a matrix satisfying the condition, print Yes; otherwise, print No.\n\nSample Input 1\n\n3 4\naabb\naabb\naacc\n\nSample Output 1\n\nYes\n\nFor example, the following matrix satisfies the condition.\n\nabba\nacca\nabba\n\nSample Input 2\n\n2 2\naa\nbb\n\nSample Output 2\n\nNo\n\nIt is not possible to create a matrix satisfying the condition, no matter how we rearrange the elements in A.\n\nSample Input 3\n\n5 1\nt\nw\ne\ne\nt\n\nSample Output 3\n\nYes\n\nFor example, the following matrix satisfies the condition.\n\nt\ne\nw\ne\nt\n\nSample Input 4\n\n2 5\nabxba\nabyba\n\nSample Output 4\n\nNo\n\nSample Input 5\n\n1 1\nz\n\nSample Output 5\n\nYes", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1034, "cpu_time_ms": 6, "memory_kb": 2588}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s797538912", "group_id": "codeNet:p03599", "input_text": "local mfl = math.floor\nlocal a, b, c, d, e, f = io.read(\"*n\", \"*n\", \"*n\", \"*n\", \"*n\", \"*n\")\nlocal alim = mfl(f / (100 * a))\nlocal ret = {0, 100 * a}\nfor i_a = 0, alim do\n local rem = f - i_a * 100 * a\n local blim = mfl(rem / (100 * b))\n for i_b = 0, blim do\n local rem2 = rem - i_b * 100 * b\n local clim = mfl(rem2 / c)\n for i_c = 0, clim do\n local rem3 = rem2 - i_c * c\n local dlim = mfl(rem3 / d)\n for i_d = 0, dlim do\n local t1, t2 = i_c * c + i_d * d, (i_a * a + i_b * b) * 100 + i_c * c + i_d * d\n if (100 + e) * t1 <= t2 * e then\n if ret[1] * t2 < ret[2] * t1 then\n ret[1], ret[2] = t1, t2\n end\n end\n end\n end\n end\nend\nprint(ret[2] .. \" \" .. ret[1])\n", "language": "Lua", "metadata": {"date": 1558915518, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p03599.html", "problem_id": "p03599", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03599/input.txt", "sample_output_relpath": "derived/input_output/data/p03599/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03599/Lua/s797538912.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s797538912", "user_id": "u120582723"}, "prompt_components": {"gold_output": "110 10\n", "input_to_evaluate": "local mfl = math.floor\nlocal a, b, c, d, e, f = io.read(\"*n\", \"*n\", \"*n\", \"*n\", \"*n\", \"*n\")\nlocal alim = mfl(f / (100 * a))\nlocal ret = {0, 100 * a}\nfor i_a = 0, alim do\n local rem = f - i_a * 100 * a\n local blim = mfl(rem / (100 * b))\n for i_b = 0, blim do\n local rem2 = rem - i_b * 100 * b\n local clim = mfl(rem2 / c)\n for i_c = 0, clim do\n local rem3 = rem2 - i_c * c\n local dlim = mfl(rem3 / d)\n for i_d = 0, dlim do\n local t1, t2 = i_c * c + i_d * d, (i_a * a + i_b * b) * 100 + i_c * c + i_d * d\n if (100 + e) * t1 <= t2 * e then\n if ret[1] * t2 < ret[2] * t1 then\n ret[1], ret[2] = t1, t2\n end\n end\n end\n end\n end\nend\nprint(ret[2] .. \" \" .. ret[1])\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nSnuke is making sugar water in a beaker.\nInitially, the beaker is empty. Snuke can perform the following four types of operations any number of times. He may choose not to perform some types of operations.\n\nOperation 1: Pour 100A grams of water into the beaker.\n\nOperation 2: Pour 100B grams of water into the beaker.\n\nOperation 3: Put C grams of sugar into the beaker.\n\nOperation 4: Put D grams of sugar into the beaker.\n\nIn our experimental environment, E grams of sugar can dissolve into 100 grams of water.\n\nSnuke will make sugar water with the highest possible density.\n\nThe beaker can contain at most F grams of substances (water and sugar combined), and there must not be any undissolved sugar in the beaker.\nFind the mass of the sugar water Snuke will make, and the mass of sugar dissolved in it.\nIf there is more than one candidate, any of them will be accepted.\n\nWe remind you that the sugar water that contains a grams of water and b grams of sugar is \\frac{100b}{a + b} percent.\nAlso, in this problem, pure water that does not contain any sugar is regarded as 0 percent density sugar water.\n\nConstraints\n\n1 \\leq A < B \\leq 30\n\n1 \\leq C < D \\leq 30\n\n1 \\leq E \\leq 100\n\n100A \\leq F \\leq 3 000\n\nA, B, C, D, E and F are all integers.\n\nInputs\n\nInput is given from Standard Input in the following format:\n\nA B C D E F\n\nOutputs\n\nPrint two integers separated by a space.\nThe first integer should be the mass of the desired sugar water, and the second should be the mass of the sugar dissolved in it.\n\nSample Input 1\n\n1 2 10 20 15 200\n\nSample Output 1\n\n110 10\n\nIn this environment, 15 grams of sugar can dissolve into 100 grams of water, and the beaker can contain at most 200 grams of substances.\n\nWe can make 110 grams of sugar water by performing Operation 1 once and Operation 3 once.\nIt is not possible to make sugar water with higher density.\nFor example, the following sequences of operations are infeasible:\n\nIf we perform Operation 1 once and Operation 4 once, there will be undissolved sugar in the beaker.\n\nIf we perform Operation 2 once and Operation 3 three times, the mass of substances in the beaker will exceed 200 grams.\n\nSample Input 2\n\n1 2 1 2 100 1000\n\nSample Output 2\n\n200 100\n\nThere are other acceptable outputs, such as:\n\n400 200\n\nHowever, the output below is not acceptable:\n\n300 150\n\nThis is because, in order to make 300 grams of sugar water containing 150 grams of sugar, we need to pour exactly 150 grams of water into the beaker, which is impossible.\n\nSample Input 3\n\n17 19 22 26 55 2802\n\nSample Output 3\n\n2634 934", "sample_input": "1 2 10 20 15 200\n"}, "reference_outputs": ["110 10\n"], "source_document_id": "p03599", "source_text": "Score : 300 points\n\nProblem Statement\n\nSnuke is making sugar water in a beaker.\nInitially, the beaker is empty. Snuke can perform the following four types of operations any number of times. He may choose not to perform some types of operations.\n\nOperation 1: Pour 100A grams of water into the beaker.\n\nOperation 2: Pour 100B grams of water into the beaker.\n\nOperation 3: Put C grams of sugar into the beaker.\n\nOperation 4: Put D grams of sugar into the beaker.\n\nIn our experimental environment, E grams of sugar can dissolve into 100 grams of water.\n\nSnuke will make sugar water with the highest possible density.\n\nThe beaker can contain at most F grams of substances (water and sugar combined), and there must not be any undissolved sugar in the beaker.\nFind the mass of the sugar water Snuke will make, and the mass of sugar dissolved in it.\nIf there is more than one candidate, any of them will be accepted.\n\nWe remind you that the sugar water that contains a grams of water and b grams of sugar is \\frac{100b}{a + b} percent.\nAlso, in this problem, pure water that does not contain any sugar is regarded as 0 percent density sugar water.\n\nConstraints\n\n1 \\leq A < B \\leq 30\n\n1 \\leq C < D \\leq 30\n\n1 \\leq E \\leq 100\n\n100A \\leq F \\leq 3 000\n\nA, B, C, D, E and F are all integers.\n\nInputs\n\nInput is given from Standard Input in the following format:\n\nA B C D E F\n\nOutputs\n\nPrint two integers separated by a space.\nThe first integer should be the mass of the desired sugar water, and the second should be the mass of the sugar dissolved in it.\n\nSample Input 1\n\n1 2 10 20 15 200\n\nSample Output 1\n\n110 10\n\nIn this environment, 15 grams of sugar can dissolve into 100 grams of water, and the beaker can contain at most 200 grams of substances.\n\nWe can make 110 grams of sugar water by performing Operation 1 once and Operation 3 once.\nIt is not possible to make sugar water with higher density.\nFor example, the following sequences of operations are infeasible:\n\nIf we perform Operation 1 once and Operation 4 once, there will be undissolved sugar in the beaker.\n\nIf we perform Operation 2 once and Operation 3 three times, the mass of substances in the beaker will exceed 200 grams.\n\nSample Input 2\n\n1 2 1 2 100 1000\n\nSample Output 2\n\n200 100\n\nThere are other acceptable outputs, such as:\n\n400 200\n\nHowever, the output below is not acceptable:\n\n300 150\n\nThis is because, in order to make 300 grams of sugar water containing 150 grams of sugar, we need to pour exactly 150 grams of water into the beaker, which is impossible.\n\nSample Input 3\n\n17 19 22 26 55 2802\n\nSample Output 3\n\n2634 934", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 742, "cpu_time_ms": 10, "memory_kb": 256}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s658302983", "group_id": "codeNet:p03600", "input_text": "local function uf_initialize(n)\n local parent = {}\n for i = 1, n do parent[i] = i end\n return parent\nend\n\nlocal function uf_findroot(idx, parent)\n local idx_update = idx\n while parent[idx] ~= idx do\n idx = parent[idx]\n end\n while parent[idx_update] ~= idx do\n parent[idx_update], idx_update = idx, parent[idx_update]\n end\n return idx\nend\n\nlocal n = io.read(\"*n\")\nlocal edge = {}\nfor i = 1, n do\n for j = 1, n do\n local c = io.read(\"*n\")\n if i < j then\n local tmp = {}\n tmp.c, tmp.i1, tmp.i2 = c, i, j\n table.insert(edge, tmp)\n end\n end\nend\n\nlocal e = {}\nfor i = 1, n do e[i] = {} end\n\nlocal function getlen(start_idx, dst_idx)\n local taskstate = {}\n for i = 1, n do taskstate[i] = false end\n local tasks = {}\n local tasknum = 0\n local done = 0\n\n local len = {}\n for i = 1, n do len[i] = 300000000000 end\n len[start_idx] = 0\n\n local function addtask(idx)\n if not taskstate[idx] then\n taskstate[idx] = true\n tasknum = tasknum + 1\n tasks[tasknum] = idx\n end\n end\n addtask(start_idx)\n\n while done < tasknum do\n done = done + 1\n local src = tasks[done]\n taskstate[src] = false\n for dst, cost in pairs(e[src]) do\n if len[src] + cost < len[dst] then\n len[dst] = len[src] + cost\n addtask(dst)\n end\n end\n end\n return len[dst_idx]\nend\n\ntable.sort(edge, function(a, b) return a.c < b.c end)\nlocal parent = uf_initialize(n)\nlocal totalcost = 0\nlocal flg = true\nlocal linenum = #edge\nfor i = 1, linenum do\n local c, i1, i2 = edge[i].c, edge[i].i1, edge[i].i2\n local r1, r2 = uf_findroot(i1, parent), uf_findroot(i2, parent)\n parent[i1], parent[i2] = r1, r2\n if r1 ~= r2 then\n parent[r2] = r1\n parent[i2] = r1\n totalcost = totalcost + c\n else\n local len = getlen(i1, i2)\n if c < len then\n totalcost = totalcost + c\n elseif len < c then\n flg = false\n end\n end\n e[i1][i2], e[i2][i1] = c, c\nend\nprint(flg and totalcost or -1)\n", "language": "Lua", "metadata": {"date": 1565754463, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p03600.html", "problem_id": "p03600", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03600/input.txt", "sample_output_relpath": "derived/input_output/data/p03600/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03600/Lua/s658302983.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s658302983", "user_id": "u120582723"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "local function uf_initialize(n)\n local parent = {}\n for i = 1, n do parent[i] = i end\n return parent\nend\n\nlocal function uf_findroot(idx, parent)\n local idx_update = idx\n while parent[idx] ~= idx do\n idx = parent[idx]\n end\n while parent[idx_update] ~= idx do\n parent[idx_update], idx_update = idx, parent[idx_update]\n end\n return idx\nend\n\nlocal n = io.read(\"*n\")\nlocal edge = {}\nfor i = 1, n do\n for j = 1, n do\n local c = io.read(\"*n\")\n if i < j then\n local tmp = {}\n tmp.c, tmp.i1, tmp.i2 = c, i, j\n table.insert(edge, tmp)\n end\n end\nend\n\nlocal e = {}\nfor i = 1, n do e[i] = {} end\n\nlocal function getlen(start_idx, dst_idx)\n local taskstate = {}\n for i = 1, n do taskstate[i] = false end\n local tasks = {}\n local tasknum = 0\n local done = 0\n\n local len = {}\n for i = 1, n do len[i] = 300000000000 end\n len[start_idx] = 0\n\n local function addtask(idx)\n if not taskstate[idx] then\n taskstate[idx] = true\n tasknum = tasknum + 1\n tasks[tasknum] = idx\n end\n end\n addtask(start_idx)\n\n while done < tasknum do\n done = done + 1\n local src = tasks[done]\n taskstate[src] = false\n for dst, cost in pairs(e[src]) do\n if len[src] + cost < len[dst] then\n len[dst] = len[src] + cost\n addtask(dst)\n end\n end\n end\n return len[dst_idx]\nend\n\ntable.sort(edge, function(a, b) return a.c < b.c end)\nlocal parent = uf_initialize(n)\nlocal totalcost = 0\nlocal flg = true\nlocal linenum = #edge\nfor i = 1, linenum do\n local c, i1, i2 = edge[i].c, edge[i].i1, edge[i].i2\n local r1, r2 = uf_findroot(i1, parent), uf_findroot(i2, parent)\n parent[i1], parent[i2] = r1, r2\n if r1 ~= r2 then\n parent[r2] = r1\n parent[i2] = r1\n totalcost = totalcost + c\n else\n local len = getlen(i1, i2)\n if c < len then\n totalcost = totalcost + c\n elseif len < c then\n flg = false\n end\n end\n e[i1][i2], e[i2][i1] = c, c\nend\nprint(flg and totalcost or -1)\n", "problem_context": "Score : 500 points\n\nProblem Statement\n\nIn Takahashi Kingdom, which once existed, there are N cities, and some pairs of cities are connected bidirectionally by roads.\nThe following are known about the road network:\n\nPeople traveled between cities only through roads. It was possible to reach any city from any other city, via intermediate cities if necessary.\n\nDifferent roads may have had different lengths, but all the lengths were positive integers.\n\nSnuke the archeologist found a table with N rows and N columns, A, in the ruin of Takahashi Kingdom.\nHe thought that it represented the shortest distances between the cities along the roads in the kingdom.\n\nDetermine whether there exists a road network such that for each u and v, the integer A_{u, v} at the u-th row and v-th column of A is equal to the length of the shortest path from City u to City v.\nIf such a network exist, find the shortest possible total length of the roads.\n\nConstraints\n\n1 \\leq N \\leq 300\n\nIf i ≠ j, 1 \\leq A_{i, j} = A_{j, i} \\leq 10^9.\n\nA_{i, i} = 0\n\nInputs\n\nInput is given from Standard Input in the following format:\n\nN\nA_{1, 1} A_{1, 2} ... A_{1, N}\nA_{2, 1} A_{2, 2} ... A_{2, N}\n...\nA_{N, 1} A_{N, 2} ... A_{N, N}\n\nOutputs\n\nIf there exists no network that satisfies the condition, print -1.\nIf it exists, print the shortest possible total length of the roads.\n\nSample Input 1\n\n3\n0 1 3\n1 0 2\n3 2 0\n\nSample Output 1\n\n3\n\nThe network below satisfies the condition:\n\nCity 1 and City 2 is connected by a road of length 1.\n\nCity 2 and City 3 is connected by a road of length 2.\n\nCity 3 and City 1 is not connected by a road.\n\nSample Input 2\n\n3\n0 1 3\n1 0 1\n3 1 0\n\nSample Output 2\n\n-1\n\nAs there is a path of length 1 from City 1 to City 2 and City 2 to City 3, there is a path of length 2 from City 1 to City 3.\nHowever, according to the table, the shortest distance between City 1 and City 3 must be 3.\n\nThus, we conclude that there exists no network that satisfies the condition.\n\nSample Input 3\n\n5\n0 21 18 11 28\n21 0 13 10 26\n18 13 0 23 13\n11 10 23 0 17\n28 26 13 17 0\n\nSample Output 3\n\n82\n\nSample Input 4\n\n3\n0 1000000000 1000000000\n1000000000 0 1000000000\n1000000000 1000000000 0\n\nSample Output 4\n\n3000000000", "sample_input": "3\n0 1 3\n1 0 2\n3 2 0\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03600", "source_text": "Score : 500 points\n\nProblem Statement\n\nIn Takahashi Kingdom, which once existed, there are N cities, and some pairs of cities are connected bidirectionally by roads.\nThe following are known about the road network:\n\nPeople traveled between cities only through roads. It was possible to reach any city from any other city, via intermediate cities if necessary.\n\nDifferent roads may have had different lengths, but all the lengths were positive integers.\n\nSnuke the archeologist found a table with N rows and N columns, A, in the ruin of Takahashi Kingdom.\nHe thought that it represented the shortest distances between the cities along the roads in the kingdom.\n\nDetermine whether there exists a road network such that for each u and v, the integer A_{u, v} at the u-th row and v-th column of A is equal to the length of the shortest path from City u to City v.\nIf such a network exist, find the shortest possible total length of the roads.\n\nConstraints\n\n1 \\leq N \\leq 300\n\nIf i ≠ j, 1 \\leq A_{i, j} = A_{j, i} \\leq 10^9.\n\nA_{i, i} = 0\n\nInputs\n\nInput is given from Standard Input in the following format:\n\nN\nA_{1, 1} A_{1, 2} ... A_{1, N}\nA_{2, 1} A_{2, 2} ... A_{2, N}\n...\nA_{N, 1} A_{N, 2} ... A_{N, N}\n\nOutputs\n\nIf there exists no network that satisfies the condition, print -1.\nIf it exists, print the shortest possible total length of the roads.\n\nSample Input 1\n\n3\n0 1 3\n1 0 2\n3 2 0\n\nSample Output 1\n\n3\n\nThe network below satisfies the condition:\n\nCity 1 and City 2 is connected by a road of length 1.\n\nCity 2 and City 3 is connected by a road of length 2.\n\nCity 3 and City 1 is not connected by a road.\n\nSample Input 2\n\n3\n0 1 3\n1 0 1\n3 1 0\n\nSample Output 2\n\n-1\n\nAs there is a path of length 1 from City 1 to City 2 and City 2 to City 3, there is a path of length 2 from City 1 to City 3.\nHowever, according to the table, the shortest distance between City 1 and City 3 must be 3.\n\nThus, we conclude that there exists no network that satisfies the condition.\n\nSample Input 3\n\n5\n0 21 18 11 28\n21 0 13 10 26\n18 13 0 23 13\n11 10 23 0 17\n28 26 13 17 0\n\nSample Output 3\n\n82\n\nSample Input 4\n\n3\n0 1000000000 1000000000\n1000000000 0 1000000000\n1000000000 1000000000 0\n\nSample Output 4\n\n3000000000", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1962, "cpu_time_ms": 2105, "memory_kb": 26624}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s707796414", "group_id": "codeNet:p03605", "input_text": "print(io.read(1)=='9'and'Yes'or io.read(1)=='9'and'Yes'or'No')", "language": "Lua", "metadata": {"date": 1570075358, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03605.html", "problem_id": "p03605", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03605/input.txt", "sample_output_relpath": "derived/input_output/data/p03605/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03605/Lua/s707796414.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s707796414", "user_id": "u162773977"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "print(io.read(1)=='9'and'Yes'or io.read(1)=='9'and'Yes'or'No')", "problem_context": "Score : 100 points\n\nProblem Statement\n\nIt is September 9 in Japan now.\n\nYou are given a two-digit integer N. Answer the question: Is 9 contained in the decimal notation of N?\n\nConstraints\n\n10≤N≤99\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nIf 9 is contained in the decimal notation of N, print Yes; if not, print No.\n\nSample Input 1\n\n29\n\nSample Output 1\n\nYes\n\nThe one's digit of 29 is 9.\n\nSample Input 2\n\n72\n\nSample Output 2\n\nNo\n\n72 does not contain 9.\n\nSample Input 3\n\n91\n\nSample Output 3\n\nYes", "sample_input": "29\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03605", "source_text": "Score : 100 points\n\nProblem Statement\n\nIt is September 9 in Japan now.\n\nYou are given a two-digit integer N. Answer the question: Is 9 contained in the decimal notation of N?\n\nConstraints\n\n10≤N≤99\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nIf 9 is contained in the decimal notation of N, print Yes; if not, print No.\n\nSample Input 1\n\n29\n\nSample Output 1\n\nYes\n\nThe one's digit of 29 is 9.\n\nSample Input 2\n\n72\n\nSample Output 2\n\nNo\n\n72 does not contain 9.\n\nSample Input 3\n\n91\n\nSample Output 3\n\nYes", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 62, "cpu_time_ms": 11, "memory_kb": 760}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s906052415", "group_id": "codeNet:p03607", "input_text": "n=io.read(\"*n\")\na={}\nfor i=1,n do\n number=io.read(\"*n\")\n if a[number] then\n a[number]=0\n else\n a[number]=1\n end\nend\n\ncounter=0\nfor _,v in pairs(a) do\n counter=counter+v\nend\nprint(counter)", "language": "Lua", "metadata": {"date": 1589151984, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03607.html", "problem_id": "p03607", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03607/input.txt", "sample_output_relpath": "derived/input_output/data/p03607/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03607/Lua/s906052415.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s906052415", "user_id": "u045238009"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "n=io.read(\"*n\")\na={}\nfor i=1,n do\n number=io.read(\"*n\")\n if a[number] then\n a[number]=0\n else\n a[number]=1\n end\nend\n\ncounter=0\nfor _,v in pairs(a) do\n counter=counter+v\nend\nprint(counter)", "problem_context": "Score : 300 points\n\nProblem Statement\n\nYou are playing the following game with Joisino.\n\nInitially, you have a blank sheet of paper.\n\nJoisino announces a number. If that number is written on the sheet, erase the number from the sheet; if not, write the number on the sheet. This process is repeated N times.\n\nThen, you are asked a question: How many numbers are written on the sheet now?\n\nThe numbers announced by Joisino are given as A_1, ... ,A_N in the order she announces them. How many numbers will be written on the sheet at the end of the game?\n\nConstraints\n\n1≤N≤100000\n\n1≤A_i≤1000000000(=10^9)\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1\n:\nA_N\n\nOutput\n\nPrint how many numbers will be written on the sheet at the end of the game.\n\nSample Input 1\n\n3\n6\n2\n6\n\nSample Output 1\n\n1\n\nThe game proceeds as follows:\n\n6 is not written on the sheet, so write 6.\n\n2 is not written on the sheet, so write 2.\n\n6 is written on the sheet, so erase 6.\n\nThus, the sheet contains only 2 in the end. The answer is 1.\n\nSample Input 2\n\n4\n2\n5\n5\n2\n\nSample Output 2\n\n0\n\nIt is possible that no number is written on the sheet in the end.\n\nSample Input 3\n\n6\n12\n22\n16\n22\n18\n12\n\nSample Output 3\n\n2", "sample_input": "3\n6\n2\n6\n"}, "reference_outputs": ["1\n"], "source_document_id": "p03607", "source_text": "Score : 300 points\n\nProblem Statement\n\nYou are playing the following game with Joisino.\n\nInitially, you have a blank sheet of paper.\n\nJoisino announces a number. If that number is written on the sheet, erase the number from the sheet; if not, write the number on the sheet. This process is repeated N times.\n\nThen, you are asked a question: How many numbers are written on the sheet now?\n\nThe numbers announced by Joisino are given as A_1, ... ,A_N in the order she announces them. How many numbers will be written on the sheet at the end of the game?\n\nConstraints\n\n1≤N≤100000\n\n1≤A_i≤1000000000(=10^9)\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1\n:\nA_N\n\nOutput\n\nPrint how many numbers will be written on the sheet at the end of the game.\n\nSample Input 1\n\n3\n6\n2\n6\n\nSample Output 1\n\n1\n\nThe game proceeds as follows:\n\n6 is not written on the sheet, so write 6.\n\n2 is not written on the sheet, so write 2.\n\n6 is written on the sheet, so erase 6.\n\nThus, the sheet contains only 2 in the end. The answer is 1.\n\nSample Input 2\n\n4\n2\n5\n5\n2\n\nSample Output 2\n\n0\n\nIt is possible that no number is written on the sheet in the end.\n\nSample Input 3\n\n6\n12\n22\n16\n22\n18\n12\n\nSample Output 3\n\n2", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 216, "cpu_time_ms": 75, "memory_kb": 6508}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s848808335", "group_id": "codeNet:p03607", "input_text": "n,a=io.read('n'),{}for i=1,n do b=io.read('n')a[b]=not a[b]end b=0 for _,v in pairs(a)do if v then b=b+1 end end print(b)", "language": "Lua", "metadata": {"date": 1505011506, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03607.html", "problem_id": "p03607", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03607/input.txt", "sample_output_relpath": "derived/input_output/data/p03607/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03607/Lua/s848808335.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s848808335", "user_id": "u785421275"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "n,a=io.read('n'),{}for i=1,n do b=io.read('n')a[b]=not a[b]end b=0 for _,v in pairs(a)do if v then b=b+1 end end print(b)", "problem_context": "Score : 300 points\n\nProblem Statement\n\nYou are playing the following game with Joisino.\n\nInitially, you have a blank sheet of paper.\n\nJoisino announces a number. If that number is written on the sheet, erase the number from the sheet; if not, write the number on the sheet. This process is repeated N times.\n\nThen, you are asked a question: How many numbers are written on the sheet now?\n\nThe numbers announced by Joisino are given as A_1, ... ,A_N in the order she announces them. How many numbers will be written on the sheet at the end of the game?\n\nConstraints\n\n1≤N≤100000\n\n1≤A_i≤1000000000(=10^9)\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1\n:\nA_N\n\nOutput\n\nPrint how many numbers will be written on the sheet at the end of the game.\n\nSample Input 1\n\n3\n6\n2\n6\n\nSample Output 1\n\n1\n\nThe game proceeds as follows:\n\n6 is not written on the sheet, so write 6.\n\n2 is not written on the sheet, so write 2.\n\n6 is written on the sheet, so erase 6.\n\nThus, the sheet contains only 2 in the end. The answer is 1.\n\nSample Input 2\n\n4\n2\n5\n5\n2\n\nSample Output 2\n\n0\n\nIt is possible that no number is written on the sheet in the end.\n\nSample Input 3\n\n6\n12\n22\n16\n22\n18\n12\n\nSample Output 3\n\n2", "sample_input": "3\n6\n2\n6\n"}, "reference_outputs": ["1\n"], "source_document_id": "p03607", "source_text": "Score : 300 points\n\nProblem Statement\n\nYou are playing the following game with Joisino.\n\nInitially, you have a blank sheet of paper.\n\nJoisino announces a number. If that number is written on the sheet, erase the number from the sheet; if not, write the number on the sheet. This process is repeated N times.\n\nThen, you are asked a question: How many numbers are written on the sheet now?\n\nThe numbers announced by Joisino are given as A_1, ... ,A_N in the order she announces them. How many numbers will be written on the sheet at the end of the game?\n\nConstraints\n\n1≤N≤100000\n\n1≤A_i≤1000000000(=10^9)\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1\n:\nA_N\n\nOutput\n\nPrint how many numbers will be written on the sheet at the end of the game.\n\nSample Input 1\n\n3\n6\n2\n6\n\nSample Output 1\n\n1\n\nThe game proceeds as follows:\n\n6 is not written on the sheet, so write 6.\n\n2 is not written on the sheet, so write 2.\n\n6 is written on the sheet, so erase 6.\n\nThus, the sheet contains only 2 in the end. The answer is 1.\n\nSample Input 2\n\n4\n2\n5\n5\n2\n\nSample Output 2\n\n0\n\nIt is possible that no number is written on the sheet in the end.\n\nSample Input 3\n\n6\n12\n22\n16\n22\n18\n12\n\nSample Output 3\n\n2", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 121, "cpu_time_ms": 159, "memory_kb": 6508}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s200279679", "group_id": "codeNet:p03608", "input_text": "local mmi, mma = math.min, math.max\nlocal mfl, mce = math.floor, math.ceil\nlocal n, m, r = io.read(\"*n\", \"*n\", \"*n\")\nlocal t = {}\nfor i = 1, r do\n t[i] = io.read(\"*n\")\nend\nlocal inf = 1000000007 * 1000\nlocal len = {}\nfor i = 1, n do\n len[i] = {}\n for j = 1, n do\n len[i][j] = i == j and 0 or inf\n end\nend\nfor i = 1, m do\n local a, b, c = io.read(\"*n\", \"*n\", \"*n\")\n len[a][b], len[b][a] = c, c\nend\nfor k = 1, n do\n for i = 1, n do\n for j = 1, n do\n len[i][j] = mmi(len[i][j], len[i][k] + len[k][j])\n end\n end\nend\n\nlocal function getpattern(n, patall, idx)\n local used = {}\n local retary = {}\n local div = patall\n for i = 1, n do used[i] = false end\n for i = n, 1, -1 do\n div = mfl(div / i)\n local v_idx = mfl(idx / div)\n idx = idx % div\n local tmp_idx = 0\n for j = 1, n do\n if not used[j] then\n if tmp_idx == v_idx then\n table.insert(retary, j)\n used[j] = true\n break\n else\n tmp_idx = tmp_idx + 1\n end\n end\n end\n end\n return retary\nend\n\nlocal function heldkarp_prepare(n)\n local tot = 1\n local alltask = {}\n local stagetask = {}\n for i = 1, n do\n tot = tot * 2\n alltask[i] = {}\n stagetask[i] = {}\n end\n for i = 1, n do\n for j = 1, tot - 1 do\n -- set inf value\n alltask[i][j] = 100000 * 200 * 8\n end\n end\n for i = 1, tot - 1 do\n local ti = i\n local cnt = 0\n for j = 1, n do\n if ti % 2 == 1 then\n cnt = cnt + 1\n ti = ti - 1\n end\n ti = ti / 2\n end\n table.insert(stagetask[cnt], i)\n end\n -- set first state\n local tmp = 1\n for i = 1, n do\n alltask[i][tmp] = 0\n tmp = tmp * 2\n end\n return tot, alltask, stagetask\nend\n\nlocal function heldkarp_doall(n, alltask, stagetask)\n for stage = 1, n - 1 do\n local stlen = #stagetask[stage]\n for i_stagetask = 1, stlen do\n local used = stagetask[stage][i_stagetask]\n local t_used = used\n for i = 1, n do\n if t_used % 2 == 1 then\n local val = alltask[i][used]\n local mul = 1\n local tmp = used\n for j = 1, n do\n if tmp % 2 == 0 then\n alltask[j][used + mul] = mmi(alltask[j][used + mul], val + len[t[i]][t[j]])\n else\n tmp = tmp - 1\n end\n tmp = tmp / 2\n mul = mul * 2\n end\n t_used = t_used - 1\n end\n t_used = t_used / 2\n end\n end\n end\nend\n\nlocal function heldkarp_getresult(n, tot, alltask)\n local ret = 100000 * 200 * 8\n for i = 1, n do\n ret = mmi(ret, alltask[i][tot - 1])\n end\n return ret\nend\nlocal tot, alltask, stagetask = heldkarp_prepare(r)\nheldkarp_doall(r, alltask, stagetask)\nprint(heldkarp_getresult(r, tot, alltask))\n", "language": "Lua", "metadata": {"date": 1601348764, "filename_ext": "lua", "original_language": "Lua (LuaJIT 2.1.0)", "problem_description_relpath": "problem_descriptions/p03608.html", "problem_id": "p03608", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03608/input.txt", "sample_output_relpath": "derived/input_output/data/p03608/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03608/Lua/s200279679.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s200279679", "user_id": "u120582723"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "local mmi, mma = math.min, math.max\nlocal mfl, mce = math.floor, math.ceil\nlocal n, m, r = io.read(\"*n\", \"*n\", \"*n\")\nlocal t = {}\nfor i = 1, r do\n t[i] = io.read(\"*n\")\nend\nlocal inf = 1000000007 * 1000\nlocal len = {}\nfor i = 1, n do\n len[i] = {}\n for j = 1, n do\n len[i][j] = i == j and 0 or inf\n end\nend\nfor i = 1, m do\n local a, b, c = io.read(\"*n\", \"*n\", \"*n\")\n len[a][b], len[b][a] = c, c\nend\nfor k = 1, n do\n for i = 1, n do\n for j = 1, n do\n len[i][j] = mmi(len[i][j], len[i][k] + len[k][j])\n end\n end\nend\n\nlocal function getpattern(n, patall, idx)\n local used = {}\n local retary = {}\n local div = patall\n for i = 1, n do used[i] = false end\n for i = n, 1, -1 do\n div = mfl(div / i)\n local v_idx = mfl(idx / div)\n idx = idx % div\n local tmp_idx = 0\n for j = 1, n do\n if not used[j] then\n if tmp_idx == v_idx then\n table.insert(retary, j)\n used[j] = true\n break\n else\n tmp_idx = tmp_idx + 1\n end\n end\n end\n end\n return retary\nend\n\nlocal function heldkarp_prepare(n)\n local tot = 1\n local alltask = {}\n local stagetask = {}\n for i = 1, n do\n tot = tot * 2\n alltask[i] = {}\n stagetask[i] = {}\n end\n for i = 1, n do\n for j = 1, tot - 1 do\n -- set inf value\n alltask[i][j] = 100000 * 200 * 8\n end\n end\n for i = 1, tot - 1 do\n local ti = i\n local cnt = 0\n for j = 1, n do\n if ti % 2 == 1 then\n cnt = cnt + 1\n ti = ti - 1\n end\n ti = ti / 2\n end\n table.insert(stagetask[cnt], i)\n end\n -- set first state\n local tmp = 1\n for i = 1, n do\n alltask[i][tmp] = 0\n tmp = tmp * 2\n end\n return tot, alltask, stagetask\nend\n\nlocal function heldkarp_doall(n, alltask, stagetask)\n for stage = 1, n - 1 do\n local stlen = #stagetask[stage]\n for i_stagetask = 1, stlen do\n local used = stagetask[stage][i_stagetask]\n local t_used = used\n for i = 1, n do\n if t_used % 2 == 1 then\n local val = alltask[i][used]\n local mul = 1\n local tmp = used\n for j = 1, n do\n if tmp % 2 == 0 then\n alltask[j][used + mul] = mmi(alltask[j][used + mul], val + len[t[i]][t[j]])\n else\n tmp = tmp - 1\n end\n tmp = tmp / 2\n mul = mul * 2\n end\n t_used = t_used - 1\n end\n t_used = t_used / 2\n end\n end\n end\nend\n\nlocal function heldkarp_getresult(n, tot, alltask)\n local ret = 100000 * 200 * 8\n for i = 1, n do\n ret = mmi(ret, alltask[i][tot - 1])\n end\n return ret\nend\nlocal tot, alltask, stagetask = heldkarp_prepare(r)\nheldkarp_doall(r, alltask, stagetask)\nprint(heldkarp_getresult(r, tot, alltask))\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nThere are N towns in the State of Atcoder, connected by M bidirectional roads.\n\nThe i-th road connects Town A_i and B_i and has a length of C_i.\n\nJoisino is visiting R towns in the state, r_1,r_2,..,r_R (not necessarily in this order).\n\nShe will fly to the first town she visits, and fly back from the last town she visits, but for the rest of the trip she will have to travel by road.\n\nIf she visits the towns in the order that minimizes the distance traveled by road, what will that distance be?\n\nConstraints\n\n2≤N≤200\n\n1≤M≤N×(N-1)/2\n\n2≤R≤min(8,N) (min(8,N) is the smaller of 8 and N.)\n\nr_i≠r_j (i≠j)\n\n1≤A_i,B_i≤N, A_i≠B_i\n\n(A_i,B_i)≠(A_j,B_j),(A_i,B_i)≠(B_j,A_j) (i≠j)\n\n1≤C_i≤100000\n\nEvery town can be reached from every town by road.\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M R\nr_1 ... r_R\nA_1 B_1 C_1\n:\nA_M B_M C_M\n\nOutput\n\nPrint the distance traveled by road if Joisino visits the towns in the order that minimizes it.\n\nSample Input 1\n\n3 3 3\n1 2 3\n1 2 1\n2 3 1\n3 1 4\n\nSample Output 1\n\n2\n\nFor example, if she visits the towns in the order of 1, 2, 3, the distance traveled will be 2, which is the minimum possible.\n\nSample Input 2\n\n3 3 2\n1 3\n2 3 2\n1 3 6\n1 2 2\n\nSample Output 2\n\n4\n\nThe shortest distance between Towns 1 and 3 is 4. Thus, whether she visits Town 1 or 3 first, the distance traveled will be 4.\n\nSample Input 3\n\n4 6 3\n2 3 4\n1 2 4\n2 3 3\n4 3 1\n1 4 1\n4 2 2\n3 1 6\n\nSample Output 3\n\n3", "sample_input": "3 3 3\n1 2 3\n1 2 1\n2 3 1\n3 1 4\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03608", "source_text": "Score : 400 points\n\nProblem Statement\n\nThere are N towns in the State of Atcoder, connected by M bidirectional roads.\n\nThe i-th road connects Town A_i and B_i and has a length of C_i.\n\nJoisino is visiting R towns in the state, r_1,r_2,..,r_R (not necessarily in this order).\n\nShe will fly to the first town she visits, and fly back from the last town she visits, but for the rest of the trip she will have to travel by road.\n\nIf she visits the towns in the order that minimizes the distance traveled by road, what will that distance be?\n\nConstraints\n\n2≤N≤200\n\n1≤M≤N×(N-1)/2\n\n2≤R≤min(8,N) (min(8,N) is the smaller of 8 and N.)\n\nr_i≠r_j (i≠j)\n\n1≤A_i,B_i≤N, A_i≠B_i\n\n(A_i,B_i)≠(A_j,B_j),(A_i,B_i)≠(B_j,A_j) (i≠j)\n\n1≤C_i≤100000\n\nEvery town can be reached from every town by road.\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M R\nr_1 ... r_R\nA_1 B_1 C_1\n:\nA_M B_M C_M\n\nOutput\n\nPrint the distance traveled by road if Joisino visits the towns in the order that minimizes it.\n\nSample Input 1\n\n3 3 3\n1 2 3\n1 2 1\n2 3 1\n3 1 4\n\nSample Output 1\n\n2\n\nFor example, if she visits the towns in the order of 1, 2, 3, the distance traveled will be 2, which is the minimum possible.\n\nSample Input 2\n\n3 3 2\n1 3\n2 3 2\n1 3 6\n1 2 2\n\nSample Output 2\n\n4\n\nThe shortest distance between Towns 1 and 3 is 4. Thus, whether she visits Town 1 or 3 first, the distance traveled will be 4.\n\nSample Input 3\n\n4 6 3\n2 3 4\n1 2 4\n2 3 3\n4 3 1\n1 4 1\n4 2 2\n3 1 6\n\nSample Output 3\n\n3", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2754, "cpu_time_ms": 46, "memory_kb": 2912}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s464122032", "group_id": "codeNet:p03609", "input_text": "a,b=io.read():match(\"(.+)%s(.+)\")\nprint(math.max(0,math.floor(a-b)))", "language": "Lua", "metadata": {"date": 1551836172, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p03609.html", "problem_id": "p03609", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03609/input.txt", "sample_output_relpath": "derived/input_output/data/p03609/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03609/Lua/s464122032.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s464122032", "user_id": "u837412668"}, "prompt_components": {"gold_output": "83\n", "input_to_evaluate": "a,b=io.read():match(\"(.+)%s(.+)\")\nprint(math.max(0,math.floor(a-b)))", "problem_context": "Score : 100 points\n\nProblem Statement\n\nWe have a sandglass that runs for X seconds. The sand drops from the upper bulb at a rate of 1 gram per second. That is, the upper bulb initially contains X grams of sand.\n\nHow many grams of sand will the upper bulb contains after t seconds?\n\nConstraints\n\n1≤X≤10^9\n\n1≤t≤10^9\n\nX and t are integers.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nX t\n\nOutput\n\nPrint the number of sand in the upper bulb after t second.\n\nSample Input 1\n\n100 17\n\nSample Output 1\n\n83\n\n17 out of the initial 100 grams of sand will be consumed, resulting in 83 grams.\n\nSample Input 2\n\n48 58\n\nSample Output 2\n\n0\n\nAll 48 grams of sand will be gone, resulting in 0 grams.\n\nSample Input 3\n\n1000000000 1000000000\n\nSample Output 3\n\n0", "sample_input": "100 17\n"}, "reference_outputs": ["83\n"], "source_document_id": "p03609", "source_text": "Score : 100 points\n\nProblem Statement\n\nWe have a sandglass that runs for X seconds. The sand drops from the upper bulb at a rate of 1 gram per second. That is, the upper bulb initially contains X grams of sand.\n\nHow many grams of sand will the upper bulb contains after t seconds?\n\nConstraints\n\n1≤X≤10^9\n\n1≤t≤10^9\n\nX and t are integers.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nX t\n\nOutput\n\nPrint the number of sand in the upper bulb after t second.\n\nSample Input 1\n\n100 17\n\nSample Output 1\n\n83\n\n17 out of the initial 100 grams of sand will be consumed, resulting in 83 grams.\n\nSample Input 2\n\n48 58\n\nSample Output 2\n\n0\n\nAll 48 grams of sand will be gone, resulting in 0 grams.\n\nSample Input 3\n\n1000000000 1000000000\n\nSample Output 3\n\n0", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 68, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s923818309", "group_id": "codeNet:p03610", "input_text": "local s = io.read(\"*l\")\n\nlocal out_s = \"\"\nfor i = 1, s:len() do\n if i % 2 == 1 then\n out_s = out_s..s:sub(i, i)\n end\nend\n\nprint(out_s)", "language": "Lua", "metadata": {"date": 1587077142, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p03610.html", "problem_id": "p03610", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03610/input.txt", "sample_output_relpath": "derived/input_output/data/p03610/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03610/Lua/s923818309.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s923818309", "user_id": "u793881115"}, "prompt_components": {"gold_output": "acdr\n", "input_to_evaluate": "local s = io.read(\"*l\")\n\nlocal out_s = \"\"\nfor i = 1, s:len() do\n if i % 2 == 1 then\n out_s = out_s..s:sub(i, i)\n end\nend\n\nprint(out_s)", "problem_context": "Score : 200 points\n\nProblem Statement\n\nYou are given a string s consisting of lowercase English letters. Extract all the characters in the odd-indexed positions and print the string obtained by concatenating them. Here, the leftmost character is assigned the index 1.\n\nConstraints\n\nEach character in s is a lowercase English letter.\n\n1≤|s|≤10^5\n\nInput\n\nThe input is given from Standard Input in the following format:\n\ns\n\nOutput\n\nPrint the string obtained by concatenating all the characters in the odd-numbered positions.\n\nSample Input 1\n\natcoder\n\nSample Output 1\n\nacdr\n\nExtract the first character a, the third character c, the fifth character d and the seventh character r to obtain acdr.\n\nSample Input 2\n\naaaa\n\nSample Output 2\n\naa\n\nSample Input 3\n\nz\n\nSample Output 3\n\nz\n\nSample Input 4\n\nfukuokayamaguchi\n\nSample Output 4\n\nfkoaaauh", "sample_input": "atcoder\n"}, "reference_outputs": ["acdr\n"], "source_document_id": "p03610", "source_text": "Score : 200 points\n\nProblem Statement\n\nYou are given a string s consisting of lowercase English letters. Extract all the characters in the odd-indexed positions and print the string obtained by concatenating them. Here, the leftmost character is assigned the index 1.\n\nConstraints\n\nEach character in s is a lowercase English letter.\n\n1≤|s|≤10^5\n\nInput\n\nThe input is given from Standard Input in the following format:\n\ns\n\nOutput\n\nPrint the string obtained by concatenating all the characters in the odd-numbered positions.\n\nSample Input 1\n\natcoder\n\nSample Output 1\n\nacdr\n\nExtract the first character a, the third character c, the fifth character d and the seventh character r to obtain acdr.\n\nSample Input 2\n\naaaa\n\nSample Output 2\n\naa\n\nSample Input 3\n\nz\n\nSample Output 3\n\nz\n\nSample Input 4\n\nfukuokayamaguchi\n\nSample Output 4\n\nfkoaaauh", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 147, "cpu_time_ms": 222, "memory_kb": 1340}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s856436094", "group_id": "codeNet:p03611", "input_text": "n=io.read(\"*n\")\na={}\nfor i=1,n do\n x=io.read(\"*n\")\n if not a[x] then\n a[x]=1\n else\n a[x]=a[x]+1\n end\nend\n\nmax=0\nfor integer,_ in pairs(a) do\n counter=a[integer]\n if a[integer-1] then\n counter=counter+a[integer-1]\n end\n if a[integer+1] then\n counter=counter+a[integer+1]\n end\n max=math.max(counter,max)\nend\nprint(max)", "language": "Lua", "metadata": {"date": 1589064969, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03611.html", "problem_id": "p03611", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03611/input.txt", "sample_output_relpath": "derived/input_output/data/p03611/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03611/Lua/s856436094.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s856436094", "user_id": "u045238009"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "n=io.read(\"*n\")\na={}\nfor i=1,n do\n x=io.read(\"*n\")\n if not a[x] then\n a[x]=1\n else\n a[x]=a[x]+1\n end\nend\n\nmax=0\nfor integer,_ in pairs(a) do\n counter=a[integer]\n if a[integer-1] then\n counter=counter+a[integer-1]\n end\n if a[integer+1] then\n counter=counter+a[integer+1]\n end\n max=math.max(counter,max)\nend\nprint(max)", "problem_context": "Score : 300 points\n\nProblem Statement\n\nYou are given an integer sequence of length N, a_1,a_2,...,a_N.\n\nFor each 1≤i≤N, you have three choices: add 1 to a_i, subtract 1 from a_i or do nothing.\n\nAfter these operations, you select an integer X and count the number of i such that a_i=X.\n\nMaximize this count by making optimal choices.\n\nConstraints\n\n1≤N≤10^5\n\n0≤a_i<10^5 (1≤i≤N)\n\na_i is an integer.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\na_1 a_2 .. a_N\n\nOutput\n\nPrint the maximum possible number of i such that a_i=X.\n\nSample Input 1\n\n7\n3 1 4 1 5 9 2\n\nSample Output 1\n\n4\n\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\n\n10\n0 1 2 3 4 5 6 7 8 9\n\nSample Output 2\n\n3\n\nSample Input 3\n\n1\n99999\n\nSample Output 3\n\n1", "sample_input": "7\n3 1 4 1 5 9 2\n"}, "reference_outputs": ["4\n"], "source_document_id": "p03611", "source_text": "Score : 300 points\n\nProblem Statement\n\nYou are given an integer sequence of length N, a_1,a_2,...,a_N.\n\nFor each 1≤i≤N, you have three choices: add 1 to a_i, subtract 1 from a_i or do nothing.\n\nAfter these operations, you select an integer X and count the number of i such that a_i=X.\n\nMaximize this count by making optimal choices.\n\nConstraints\n\n1≤N≤10^5\n\n0≤a_i<10^5 (1≤i≤N)\n\na_i is an integer.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\na_1 a_2 .. a_N\n\nOutput\n\nPrint the maximum possible number of i such that a_i=X.\n\nSample Input 1\n\n7\n3 1 4 1 5 9 2\n\nSample Output 1\n\n4\n\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\n\n10\n0 1 2 3 4 5 6 7 8 9\n\nSample Output 2\n\n3\n\nSample Input 3\n\n1\n99999\n\nSample Output 3\n\n1", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 374, "cpu_time_ms": 74, "memory_kb": 3440}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s198490070", "group_id": "codeNet:p03611", "input_text": "local ior = io.input()\nlocal t = {}\nfor i = 1, 100000 do t[i] = 0 end\nlocal n = ior:read(\"*n\")\nfor i = 1, n do\n local a = ior:read(\"*n\")\n if 1 < a then t[a - 1] = t[a - 1] + 1 end\n if 0 < a then t[a] = t[a] + 1 end\n t[a + 1] = t[a + 1] + 1\nend\nlocal ret = 0\nfor i = 1, 100000 do\n ret = math.max(ret, t[i])\nend\nprint(ret)\n", "language": "Lua", "metadata": {"date": 1558930234, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p03611.html", "problem_id": "p03611", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03611/input.txt", "sample_output_relpath": "derived/input_output/data/p03611/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03611/Lua/s198490070.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s198490070", "user_id": "u120582723"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "local ior = io.input()\nlocal t = {}\nfor i = 1, 100000 do t[i] = 0 end\nlocal n = ior:read(\"*n\")\nfor i = 1, n do\n local a = ior:read(\"*n\")\n if 1 < a then t[a - 1] = t[a - 1] + 1 end\n if 0 < a then t[a] = t[a] + 1 end\n t[a + 1] = t[a + 1] + 1\nend\nlocal ret = 0\nfor i = 1, 100000 do\n ret = math.max(ret, t[i])\nend\nprint(ret)\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nYou are given an integer sequence of length N, a_1,a_2,...,a_N.\n\nFor each 1≤i≤N, you have three choices: add 1 to a_i, subtract 1 from a_i or do nothing.\n\nAfter these operations, you select an integer X and count the number of i such that a_i=X.\n\nMaximize this count by making optimal choices.\n\nConstraints\n\n1≤N≤10^5\n\n0≤a_i<10^5 (1≤i≤N)\n\na_i is an integer.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\na_1 a_2 .. a_N\n\nOutput\n\nPrint the maximum possible number of i such that a_i=X.\n\nSample Input 1\n\n7\n3 1 4 1 5 9 2\n\nSample Output 1\n\n4\n\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\n\n10\n0 1 2 3 4 5 6 7 8 9\n\nSample Output 2\n\n3\n\nSample Input 3\n\n1\n99999\n\nSample Output 3\n\n1", "sample_input": "7\n3 1 4 1 5 9 2\n"}, "reference_outputs": ["4\n"], "source_document_id": "p03611", "source_text": "Score : 300 points\n\nProblem Statement\n\nYou are given an integer sequence of length N, a_1,a_2,...,a_N.\n\nFor each 1≤i≤N, you have three choices: add 1 to a_i, subtract 1 from a_i or do nothing.\n\nAfter these operations, you select an integer X and count the number of i such that a_i=X.\n\nMaximize this count by making optimal choices.\n\nConstraints\n\n1≤N≤10^5\n\n0≤a_i<10^5 (1≤i≤N)\n\na_i is an integer.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\na_1 a_2 .. a_N\n\nOutput\n\nPrint the maximum possible number of i such that a_i=X.\n\nSample Input 1\n\n7\n3 1 4 1 5 9 2\n\nSample Output 1\n\n4\n\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\n\n10\n0 1 2 3 4 5 6 7 8 9\n\nSample Output 2\n\n3\n\nSample Input 3\n\n1\n99999\n\nSample Output 3\n\n1", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 326, "cpu_time_ms": 30, "memory_kb": 1280}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s002963542", "group_id": "codeNet:p03612", "input_text": "n = io.read(\"*n\")\nt = {}\nfor i = 1, n do\n t[i] = io.read(\"*n\")\nend\nr = 0\nc = 1\nwhile c <= n do\n if t[c] == c then\n r, c = r + 1, c + 2\n else\n c = c + 1\n end\nend\nprint(r)", "language": "Lua", "metadata": {"date": 1601346666, "filename_ext": "lua", "original_language": "Lua (Lua 5.3.5)", "problem_description_relpath": "problem_descriptions/p03612.html", "problem_id": "p03612", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03612/input.txt", "sample_output_relpath": "derived/input_output/data/p03612/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03612/Lua/s002963542.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s002963542", "user_id": "u120582723"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "n = io.read(\"*n\")\nt = {}\nfor i = 1, n do\n t[i] = io.read(\"*n\")\nend\nr = 0\nc = 1\nwhile c <= n do\n if t[c] == c then\n r, c = r + 1, c + 2\n else\n c = c + 1\n end\nend\nprint(r)", "problem_context": "Score : 400 points\n\nProblem Statement\n\nYou are given a permutation p_1,p_2,...,p_N consisting of 1,2,..,N.\nYou can perform the following operation any number of times (possibly zero):\n\nOperation: Swap two adjacent elements in the permutation.\n\nYou want to have p_i ≠ i for all 1≤i≤N.\nFind the minimum required number of operations to achieve this.\n\nConstraints\n\n2≤N≤10^5\n\np_1,p_2,..,p_N is a permutation of 1,2,..,N.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\np_1 p_2 .. p_N\n\nOutput\n\nPrint the minimum required number of operations\n\nSample Input 1\n\n5\n1 4 3 5 2\n\nSample Output 1\n\n2\n\nSwap 1 and 4, then swap 1 and 3. p is now 4,3,1,5,2 and satisfies the condition.\nThis is the minimum possible number, so the answer is 2.\n\nSample Input 2\n\n2\n1 2\n\nSample Output 2\n\n1\n\nSwapping 1 and 2 satisfies the condition.\n\nSample Input 3\n\n2\n2 1\n\nSample Output 3\n\n0\n\nThe condition is already satisfied initially.\n\nSample Input 4\n\n9\n1 2 4 9 5 8 7 3 6\n\nSample Output 4\n\n3", "sample_input": "5\n1 4 3 5 2\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03612", "source_text": "Score : 400 points\n\nProblem Statement\n\nYou are given a permutation p_1,p_2,...,p_N consisting of 1,2,..,N.\nYou can perform the following operation any number of times (possibly zero):\n\nOperation: Swap two adjacent elements in the permutation.\n\nYou want to have p_i ≠ i for all 1≤i≤N.\nFind the minimum required number of operations to achieve this.\n\nConstraints\n\n2≤N≤10^5\n\np_1,p_2,..,p_N is a permutation of 1,2,..,N.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\np_1 p_2 .. p_N\n\nOutput\n\nPrint the minimum required number of operations\n\nSample Input 1\n\n5\n1 4 3 5 2\n\nSample Output 1\n\n2\n\nSwap 1 and 4, then swap 1 and 3. p is now 4,3,1,5,2 and satisfies the condition.\nThis is the minimum possible number, so the answer is 2.\n\nSample Input 2\n\n2\n1 2\n\nSample Output 2\n\n1\n\nSwapping 1 and 2 satisfies the condition.\n\nSample Input 3\n\n2\n2 1\n\nSample Output 3\n\n0\n\nThe condition is already satisfied initially.\n\nSample Input 4\n\n9\n1 2 4 9 5 8 7 3 6\n\nSample Output 4\n\n3", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 179, "cpu_time_ms": 39, "memory_kb": 4288}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s006665825", "group_id": "codeNet:p03612", "input_text": "n=io.read(\"*n\",\"*l\")\np={}\nfor i=1,n do\n p[i]=io.read(\"*n\")\nend\n\ncounter=0\nfor i=1,n-1 do\n if p[i]==i or p[i+1]==i+1 then\n p[i],p[i+1]=p[i+1],p[i]\n counter=counter+1\n end\nend\n\nprint(counter)", "language": "Lua", "metadata": {"date": 1587356145, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03612.html", "problem_id": "p03612", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03612/input.txt", "sample_output_relpath": "derived/input_output/data/p03612/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03612/Lua/s006665825.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s006665825", "user_id": "u045238009"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "n=io.read(\"*n\",\"*l\")\np={}\nfor i=1,n do\n p[i]=io.read(\"*n\")\nend\n\ncounter=0\nfor i=1,n-1 do\n if p[i]==i or p[i+1]==i+1 then\n p[i],p[i+1]=p[i+1],p[i]\n counter=counter+1\n end\nend\n\nprint(counter)", "problem_context": "Score : 400 points\n\nProblem Statement\n\nYou are given a permutation p_1,p_2,...,p_N consisting of 1,2,..,N.\nYou can perform the following operation any number of times (possibly zero):\n\nOperation: Swap two adjacent elements in the permutation.\n\nYou want to have p_i ≠ i for all 1≤i≤N.\nFind the minimum required number of operations to achieve this.\n\nConstraints\n\n2≤N≤10^5\n\np_1,p_2,..,p_N is a permutation of 1,2,..,N.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\np_1 p_2 .. p_N\n\nOutput\n\nPrint the minimum required number of operations\n\nSample Input 1\n\n5\n1 4 3 5 2\n\nSample Output 1\n\n2\n\nSwap 1 and 4, then swap 1 and 3. p is now 4,3,1,5,2 and satisfies the condition.\nThis is the minimum possible number, so the answer is 2.\n\nSample Input 2\n\n2\n1 2\n\nSample Output 2\n\n1\n\nSwapping 1 and 2 satisfies the condition.\n\nSample Input 3\n\n2\n2 1\n\nSample Output 3\n\n0\n\nThe condition is already satisfied initially.\n\nSample Input 4\n\n9\n1 2 4 9 5 8 7 3 6\n\nSample Output 4\n\n3", "sample_input": "5\n1 4 3 5 2\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03612", "source_text": "Score : 400 points\n\nProblem Statement\n\nYou are given a permutation p_1,p_2,...,p_N consisting of 1,2,..,N.\nYou can perform the following operation any number of times (possibly zero):\n\nOperation: Swap two adjacent elements in the permutation.\n\nYou want to have p_i ≠ i for all 1≤i≤N.\nFind the minimum required number of operations to achieve this.\n\nConstraints\n\n2≤N≤10^5\n\np_1,p_2,..,p_N is a permutation of 1,2,..,N.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\np_1 p_2 .. p_N\n\nOutput\n\nPrint the minimum required number of operations\n\nSample Input 1\n\n5\n1 4 3 5 2\n\nSample Output 1\n\n2\n\nSwap 1 and 4, then swap 1 and 3. p is now 4,3,1,5,2 and satisfies the condition.\nThis is the minimum possible number, so the answer is 2.\n\nSample Input 2\n\n2\n1 2\n\nSample Output 2\n\n1\n\nSwapping 1 and 2 satisfies the condition.\n\nSample Input 3\n\n2\n2 1\n\nSample Output 3\n\n0\n\nThe condition is already satisfied initially.\n\nSample Input 4\n\n9\n1 2 4 9 5 8 7 3 6\n\nSample Output 4\n\n3", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 212, "cpu_time_ms": 65, "memory_kb": 2424}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s303349661", "group_id": "codeNet:p03617", "input_text": "t={}\nfor i=1,4 do\n t[i]=io.read(\"*n\")\nend\nn=io.read(\"*n\")\n\nx=math.min(4*t[1],2*t[2],t[3])\nif 2*x1 then\n barmax=math.max(length,barmax)\n end\nend\nif a[barmax]>=4 then\n print(barmax*barmax)\nelse\n local barmax2=0\n for length,number in pairs(a) do\n if length1 then\n barmax2=math.max(length,barmax2)\n end\n end\n print(barmax*barmax2)\nend", "language": "Lua", "metadata": {"date": 1589730188, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03627.html", "problem_id": "p03627", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03627/input.txt", "sample_output_relpath": "derived/input_output/data/p03627/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03627/Lua/s317570464.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s317570464", "user_id": "u045238009"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "local n=io.read(\"*n\",\"*l\")\nlocal a={}\nfor i=1,n do\n local bar=io.read(\"*n\")\n if not a[bar] then\n a[bar]=1\n else\n a[bar]=a[bar]+1\n end\nend\n\nlocal barmax=0\nfor length,number in pairs(a) do\n if number>1 then\n barmax=math.max(length,barmax)\n end\nend\nif a[barmax]>=4 then\n print(barmax*barmax)\nelse\n local barmax2=0\n for length,number in pairs(a) do\n if length1 then\n barmax2=math.max(length,barmax2)\n end\n end\n print(barmax*barmax2)\nend", "problem_context": "Score : 300 points\n\nProblem Statement\n\nWe have N sticks with negligible thickness.\nThe length of the i-th stick is A_i.\n\nSnuke wants to select four different sticks from these sticks and form a rectangle (including a square), using the sticks as its sides.\nFind the maximum possible area of the rectangle.\n\nConstraints\n\n4 \\leq N \\leq 10^5\n\n1 \\leq A_i \\leq 10^9\n\nA_i is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the maximum possible area of the rectangle.\nIf no rectangle can be formed, print 0.\n\nSample Input 1\n\n6\n3 1 2 4 2 1\n\nSample Output 1\n\n2\n\n1 \\times 2 rectangle can be formed.\n\nSample Input 2\n\n4\n1 2 3 4\n\nSample Output 2\n\n0\n\nNo rectangle can be formed.\n\nSample Input 3\n\n10\n3 3 3 3 4 4 4 5 5 5\n\nSample Output 3\n\n20", "sample_input": "6\n3 1 2 4 2 1\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03627", "source_text": "Score : 300 points\n\nProblem Statement\n\nWe have N sticks with negligible thickness.\nThe length of the i-th stick is A_i.\n\nSnuke wants to select four different sticks from these sticks and form a rectangle (including a square), using the sticks as its sides.\nFind the maximum possible area of the rectangle.\n\nConstraints\n\n4 \\leq N \\leq 10^5\n\n1 \\leq A_i \\leq 10^9\n\nA_i is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the maximum possible area of the rectangle.\nIf no rectangle can be formed, print 0.\n\nSample Input 1\n\n6\n3 1 2 4 2 1\n\nSample Output 1\n\n2\n\n1 \\times 2 rectangle can be formed.\n\nSample Input 2\n\n4\n1 2 3 4\n\nSample Output 2\n\n0\n\nNo rectangle can be formed.\n\nSample Input 3\n\n10\n3 3 3 3 4 4 4 5 5 5\n\nSample Output 3\n\n20", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 530, "cpu_time_ms": 59, "memory_kb": 6508}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s045029473", "group_id": "codeNet:p03628", "input_text": "local n=io.read(\"n\",\"l\")\nlocal s={}\nfor i=1,2 do\n s[i]={io.read():byte(1,n)}\nend\n\nlocal mod=1000000007\nlocal combination\nlocal i\nif s[1][1]==s[2][1] then\n combination=3\n i=2\nelse\n combination=6\n i=3\nend\nwhile i<=n do\n if s[1][i-1]~=s[2][i-1] and s[1][i]~=s[2][i] then\n combination=combination*3\n i=i+2\n elseif s[1][i-1]==s[2][i-1] and s[1][i]~=s[2][i] then\n combination=combination*2\n i=i+2\n else\n if s[1][i-1]==s[2][i-1] then\n combination=combination*2\n end\n i=i+1\n end\n combination=combination%mod\nend\nprint(combination)", "language": "Lua", "metadata": {"date": 1595903242, "filename_ext": "lua", "original_language": "Lua (LuaJIT 2.1.0)", "problem_description_relpath": "problem_descriptions/p03628.html", "problem_id": "p03628", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03628/input.txt", "sample_output_relpath": "derived/input_output/data/p03628/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03628/Lua/s045029473.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s045029473", "user_id": "u045238009"}, "prompt_components": {"gold_output": "6\n", "input_to_evaluate": "local n=io.read(\"n\",\"l\")\nlocal s={}\nfor i=1,2 do\n s[i]={io.read():byte(1,n)}\nend\n\nlocal mod=1000000007\nlocal combination\nlocal i\nif s[1][1]==s[2][1] then\n combination=3\n i=2\nelse\n combination=6\n i=3\nend\nwhile i<=n do\n if s[1][i-1]~=s[2][i-1] and s[1][i]~=s[2][i] then\n combination=combination*3\n i=i+2\n elseif s[1][i-1]==s[2][i-1] and s[1][i]~=s[2][i] then\n combination=combination*2\n i=i+2\n else\n if s[1][i-1]==s[2][i-1] then\n combination=combination*2\n end\n i=i+1\n end\n combination=combination%mod\nend\nprint(combination)", "problem_context": "Score : 400 points\n\nProblem Statement\n\nWe have a board with a 2 \\times N grid.\nSnuke covered the board with N dominoes without overlaps.\nHere, a domino can cover a 1 \\times 2 or 2 \\times 1 square.\n\nThen, Snuke decided to paint these dominoes using three colors: red, cyan and green.\nTwo dominoes that are adjacent by side should be painted by different colors.\nHere, it is not always necessary to use all three colors.\n\nFind the number of such ways to paint the dominoes, modulo 1000000007.\n\nThe arrangement of the dominoes is given to you as two strings S_1 and S_2 in the following manner:\n\nEach domino is represented by a different English letter (lowercase or uppercase).\n\nThe j-th character in S_i represents the domino that occupies the square at the i-th row from the top and j-th column from the left.\n\nConstraints\n\n1 \\leq N \\leq 52\n\n|S_1| = |S_2| = N\n\nS_1 and S_2 consist of lowercase and uppercase English letters.\n\nS_1 and S_2 represent a valid arrangement of dominoes.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS_1\nS_2\n\nOutput\n\nPrint the number of such ways to paint the dominoes, modulo 1000000007.\n\nSample Input 1\n\n3\naab\nccb\n\nSample Output 1\n\n6\n\nThere are six ways as shown below:\n\nSample Input 2\n\n1\nZ\nZ\n\nSample Output 2\n\n3\n\nNote that it is not always necessary to use all the colors.\n\nSample Input 3\n\n52\nRvvttdWIyyPPQFFZZssffEEkkaSSDKqcibbeYrhAljCCGGJppHHn\nRLLwwdWIxxNNQUUXXVVMMooBBaggDKqcimmeYrhAljOOTTJuuzzn\n\nSample Output 3\n\n958681902", "sample_input": "3\naab\nccb\n"}, "reference_outputs": ["6\n"], "source_document_id": "p03628", "source_text": "Score : 400 points\n\nProblem Statement\n\nWe have a board with a 2 \\times N grid.\nSnuke covered the board with N dominoes without overlaps.\nHere, a domino can cover a 1 \\times 2 or 2 \\times 1 square.\n\nThen, Snuke decided to paint these dominoes using three colors: red, cyan and green.\nTwo dominoes that are adjacent by side should be painted by different colors.\nHere, it is not always necessary to use all three colors.\n\nFind the number of such ways to paint the dominoes, modulo 1000000007.\n\nThe arrangement of the dominoes is given to you as two strings S_1 and S_2 in the following manner:\n\nEach domino is represented by a different English letter (lowercase or uppercase).\n\nThe j-th character in S_i represents the domino that occupies the square at the i-th row from the top and j-th column from the left.\n\nConstraints\n\n1 \\leq N \\leq 52\n\n|S_1| = |S_2| = N\n\nS_1 and S_2 consist of lowercase and uppercase English letters.\n\nS_1 and S_2 represent a valid arrangement of dominoes.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS_1\nS_2\n\nOutput\n\nPrint the number of such ways to paint the dominoes, modulo 1000000007.\n\nSample Input 1\n\n3\naab\nccb\n\nSample Output 1\n\n6\n\nThere are six ways as shown below:\n\nSample Input 2\n\n1\nZ\nZ\n\nSample Output 2\n\n3\n\nNote that it is not always necessary to use all the colors.\n\nSample Input 3\n\n52\nRvvttdWIyyPPQFFZZssffEEkkaSSDKqcibbeYrhAljCCGGJppHHn\nRLLwwdWIxxNNQUUXXVVMMooBBaggDKqcimmeYrhAljOOTTJuuzzn\n\nSample Output 3\n\n958681902", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 612, "cpu_time_ms": 3, "memory_kb": 2776}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s724375109", "group_id": "codeNet:p03629", "input_text": "local s = io.read()\nlocal n = #s\nlocal cycle_end_pos = {}\nlocal box = {}\nfor i = 1, 26 do\n box[i] = false\nend\nlocal t = {}\nfor i = 1, n do\n t[i] = s:sub(i, i):byte() - 96\nend\nlocal boxcnt = 0\nfor i = 1, n do\n local v = t[i]\n if not box[v] then\n box[v] = true\n boxcnt = boxcnt + 1\n if boxcnt == 26 then\n table.insert(cycle_end_pos, i)\n boxcnt = 0\n for j = 1, 26 do box[j] = false end\n end\n end\nend\n-- node = (#cycles + 1) * 26\nlocal edge = {}\nlocal invedge = {}\nlocal canuse = {}\n\nfor i = 1, (#cycle_end_pos + 1) * 26 do\n edge[i] = {}\n invedge[i] = {}\n canuse[i] = false\nend\n\nlocal first_pos = {}\nlocal last_pos = {}\nfor ic = 1, #cycle_end_pos do\n local spos = ic == 1 and 1 or cycle_end_pos[ic - 1] + 1\n local epos = cycle_end_pos[ic]\n for i = 1, 26 do\n box[i] = false\n first_pos[i] = 0\n last_pos[i] = 0\n end\n boxcnt = 0\n for i = spos, epos do\n local v = t[i]\n if first_pos[v] == 0 then\n first_pos[v] = i\n end\n last_pos[v] = i\n end\n for i = 1, 26 do\n local src = (ic - 1) * 26 + i\n for j = 1, 26 do\n if last_pos[j] <= first_pos[i] then\n local dst = ic * 26 + j\n table.insert(edge[src], dst)\n table.insert(invedge[dst], src)\n end\n end\n end\nend\nfor i = 1, 26 do\n local idx = #cycle_end_pos * 26 + i\n canuse[idx] = true\nend\nif #cycle_end_pos == 0 then\n for i = 1, n do\n local v = t[i]\n local idx = #cycle_end_pos * 26 + v\n canuse[idx] = false\n end\nelse\n for i = cycle_end_pos[#cycle_end_pos] + 1, n do\n local v = t[i]\n local idx = #cycle_end_pos * 26 + v\n canuse[idx] = false\n end\nend\nlocal tasks = {}\nfor i = 1, 26 do\n local idx = #cycle_end_pos * 26 + i\n if canuse[idx] then\n table.insert(tasks, idx)\n end\nend\nlocal done = 0\nwhile done < #tasks do\n done = done + 1\n local invsrc = tasks[done]\n for i = 1, #invedge[invsrc] do\n local invdst = invedge[invsrc][i]\n if not canuse[invdst] then\n canuse[invdst] = true\n table.insert(tasks, invdst)\n end\n end\nend\nlocal ret = {}\nlocal curpos = 0\nfor i = 1, 26 do\n if canuse[i] then\n curpos = i\n table.insert(ret, string.char(96 + i))\n break\n end\nend\nfor ic = 1, #cycle_end_pos do\n for i = 1, #edge[curpos] do\n local dst = edge[curpos][i]\n if canuse[dst] then\n curpos = dst\n table.insert(ret, string.char(96 + dst - 26 * ic))\n break\n end\n end\nend\nprint(table.concat(ret))\n", "language": "Lua", "metadata": {"date": 1590028238, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03629.html", "problem_id": "p03629", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03629/input.txt", "sample_output_relpath": "derived/input_output/data/p03629/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03629/Lua/s724375109.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s724375109", "user_id": "u120582723"}, "prompt_components": {"gold_output": "b\n", "input_to_evaluate": "local s = io.read()\nlocal n = #s\nlocal cycle_end_pos = {}\nlocal box = {}\nfor i = 1, 26 do\n box[i] = false\nend\nlocal t = {}\nfor i = 1, n do\n t[i] = s:sub(i, i):byte() - 96\nend\nlocal boxcnt = 0\nfor i = 1, n do\n local v = t[i]\n if not box[v] then\n box[v] = true\n boxcnt = boxcnt + 1\n if boxcnt == 26 then\n table.insert(cycle_end_pos, i)\n boxcnt = 0\n for j = 1, 26 do box[j] = false end\n end\n end\nend\n-- node = (#cycles + 1) * 26\nlocal edge = {}\nlocal invedge = {}\nlocal canuse = {}\n\nfor i = 1, (#cycle_end_pos + 1) * 26 do\n edge[i] = {}\n invedge[i] = {}\n canuse[i] = false\nend\n\nlocal first_pos = {}\nlocal last_pos = {}\nfor ic = 1, #cycle_end_pos do\n local spos = ic == 1 and 1 or cycle_end_pos[ic - 1] + 1\n local epos = cycle_end_pos[ic]\n for i = 1, 26 do\n box[i] = false\n first_pos[i] = 0\n last_pos[i] = 0\n end\n boxcnt = 0\n for i = spos, epos do\n local v = t[i]\n if first_pos[v] == 0 then\n first_pos[v] = i\n end\n last_pos[v] = i\n end\n for i = 1, 26 do\n local src = (ic - 1) * 26 + i\n for j = 1, 26 do\n if last_pos[j] <= first_pos[i] then\n local dst = ic * 26 + j\n table.insert(edge[src], dst)\n table.insert(invedge[dst], src)\n end\n end\n end\nend\nfor i = 1, 26 do\n local idx = #cycle_end_pos * 26 + i\n canuse[idx] = true\nend\nif #cycle_end_pos == 0 then\n for i = 1, n do\n local v = t[i]\n local idx = #cycle_end_pos * 26 + v\n canuse[idx] = false\n end\nelse\n for i = cycle_end_pos[#cycle_end_pos] + 1, n do\n local v = t[i]\n local idx = #cycle_end_pos * 26 + v\n canuse[idx] = false\n end\nend\nlocal tasks = {}\nfor i = 1, 26 do\n local idx = #cycle_end_pos * 26 + i\n if canuse[idx] then\n table.insert(tasks, idx)\n end\nend\nlocal done = 0\nwhile done < #tasks do\n done = done + 1\n local invsrc = tasks[done]\n for i = 1, #invedge[invsrc] do\n local invdst = invedge[invsrc][i]\n if not canuse[invdst] then\n canuse[invdst] = true\n table.insert(tasks, invdst)\n end\n end\nend\nlocal ret = {}\nlocal curpos = 0\nfor i = 1, 26 do\n if canuse[i] then\n curpos = i\n table.insert(ret, string.char(96 + i))\n break\n end\nend\nfor ic = 1, #cycle_end_pos do\n for i = 1, #edge[curpos] do\n local dst = edge[curpos][i]\n if canuse[dst] then\n curpos = dst\n table.insert(ret, string.char(96 + dst - 26 * ic))\n break\n end\n end\nend\nprint(table.concat(ret))\n", "problem_context": "Score : 600 points\n\nProblem Statement\n\nA subsequence of a string S is a string that can be obtained by deleting zero or more characters from S without changing the order of the remaining characters.\nFor example, arc, artistic and (an empty string) are all subsequences of artistic; abc and ci are not.\n\nYou are given a string A consisting of lowercase English letters.\nFind the shortest string among the strings consisting of lowercase English letters that are not subsequences of A.\nIf there are more than one such string, find the lexicographically smallest one among them.\n\nConstraints\n\n1 \\leq |A| \\leq 2 \\times 10^5\n\nA consists of lowercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA\n\nOutput\n\nPrint the lexicographically smallest string among the shortest strings consisting of lowercase English letters that are not subsequences of A.\n\nSample Input 1\n\natcoderregularcontest\n\nSample Output 1\n\nb\n\nThe string atcoderregularcontest contains a as a subsequence, but not b.\n\nSample Input 2\n\nabcdefghijklmnopqrstuvwxyz\n\nSample Output 2\n\naa\n\nSample Input 3\n\nfrqnvhydscshfcgdemurlfrutcpzhopfotpifgepnqjxupnskapziurswqazdwnwbgdhyktfyhqqxpoidfhjdakoxraiedxskywuepzfniuyskxiyjpjlxuqnfgmnjcvtlpnclfkpervxmdbvrbrdn\n\nSample Output 3\n\naca", "sample_input": "atcoderregularcontest\n"}, "reference_outputs": ["b\n"], "source_document_id": "p03629", "source_text": "Score : 600 points\n\nProblem Statement\n\nA subsequence of a string S is a string that can be obtained by deleting zero or more characters from S without changing the order of the remaining characters.\nFor example, arc, artistic and (an empty string) are all subsequences of artistic; abc and ci are not.\n\nYou are given a string A consisting of lowercase English letters.\nFind the shortest string among the strings consisting of lowercase English letters that are not subsequences of A.\nIf there are more than one such string, find the lexicographically smallest one among them.\n\nConstraints\n\n1 \\leq |A| \\leq 2 \\times 10^5\n\nA consists of lowercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA\n\nOutput\n\nPrint the lexicographically smallest string among the shortest strings consisting of lowercase English letters that are not subsequences of A.\n\nSample Input 1\n\natcoderregularcontest\n\nSample Output 1\n\nb\n\nThe string atcoderregularcontest contains a as a subsequence, but not b.\n\nSample Input 2\n\nabcdefghijklmnopqrstuvwxyz\n\nSample Output 2\n\naa\n\nSample Input 3\n\nfrqnvhydscshfcgdemurlfrutcpzhopfotpifgepnqjxupnskapziurswqazdwnwbgdhyktfyhqqxpoidfhjdakoxraiedxskywuepzfniuyskxiyjpjlxuqnfgmnjcvtlpnclfkpervxmdbvrbrdn\n\nSample Output 3\n\naca", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2410, "cpu_time_ms": 1836, "memory_kb": 171060}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s146852694", "group_id": "codeNet:p03631", "input_text": "a=io.read()\nprint(a==a:reverse()and\"Yes\"or\"No\")", "language": "Lua", "metadata": {"date": 1551835903, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p03631.html", "problem_id": "p03631", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03631/input.txt", "sample_output_relpath": "derived/input_output/data/p03631/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03631/Lua/s146852694.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s146852694", "user_id": "u837412668"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "a=io.read()\nprint(a==a:reverse()and\"Yes\"or\"No\")", "problem_context": "Score : 100 points\n\nProblem Statement\n\nYou are given a three-digit positive integer N.\n\nDetermine whether N is a palindromic number.\n\nHere, a palindromic number is an integer that reads the same backward as forward in decimal notation.\n\nConstraints\n\n100≤N≤999\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nIf N is a palindromic number, print Yes; otherwise, print No.\n\nSample Input 1\n\n575\n\nSample Output 1\n\nYes\n\nN=575 is also 575 when read backward, so it is a palindromic number. You should print Yes.\n\nSample Input 2\n\n123\n\nSample Output 2\n\nNo\n\nN=123 becomes 321 when read backward, so it is not a palindromic number. You should print No.\n\nSample Input 3\n\n812\n\nSample Output 3\n\nNo", "sample_input": "575\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03631", "source_text": "Score : 100 points\n\nProblem Statement\n\nYou are given a three-digit positive integer N.\n\nDetermine whether N is a palindromic number.\n\nHere, a palindromic number is an integer that reads the same backward as forward in decimal notation.\n\nConstraints\n\n100≤N≤999\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nIf N is a palindromic number, print Yes; otherwise, print No.\n\nSample Input 1\n\n575\n\nSample Output 1\n\nYes\n\nN=575 is also 575 when read backward, so it is a palindromic number. You should print Yes.\n\nSample Input 2\n\n123\n\nSample Output 2\n\nNo\n\nN=123 becomes 321 when read backward, so it is not a palindromic number. You should print No.\n\nSample Input 3\n\n812\n\nSample Output 3\n\nNo", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 47, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s827778669", "group_id": "codeNet:p03632", "input_text": "a, b, c, d = io.read('*n'), io.read('*n'), io.read('*n'), io.read('*n')\nprint(math.max(0, math.min(b, d) - math.max(a, c)))\n", "language": "Lua", "metadata": {"date": 1502591995, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03632.html", "problem_id": "p03632", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03632/input.txt", "sample_output_relpath": "derived/input_output/data/p03632/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03632/Lua/s827778669.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s827778669", "user_id": "u785421275"}, "prompt_components": {"gold_output": "50\n", "input_to_evaluate": "a, b, c, d = io.read('*n'), io.read('*n'), io.read('*n'), io.read('*n')\nprint(math.max(0, math.min(b, d) - math.max(a, c)))\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nAlice and Bob are controlling a robot. They each have one switch that controls the robot.\n\nAlice started holding down her button A second after the start-up of the robot, and released her button B second after the start-up.\n\nBob started holding down his button C second after the start-up, and released his button D second after the start-up.\n\nFor how many seconds both Alice and Bob were holding down their buttons?\n\nConstraints\n\n0≤A Island 4 -> Island 5.", "sample_input": "3 2\n1 2\n2 3\n"}, "reference_outputs": ["POSSIBLE\n"], "source_document_id": "p03645", "source_text": "Score : 300 points\n\nProblem Statement\n\nIn Takahashi Kingdom, there is an archipelago of N islands, called Takahashi Islands.\nFor convenience, we will call them Island 1, Island 2, ..., Island N.\n\nThere are M kinds of regular boat services between these islands.\nEach service connects two islands. The i-th service connects Island a_i and Island b_i.\n\nCat Snuke is on Island 1 now, and wants to go to Island N.\nHowever, it turned out that there is no boat service from Island 1 to Island N, so he wants to know whether it is possible to go to Island N by using two boat services.\n\nHelp him.\n\nConstraints\n\n3 ≤ N ≤ 200 000\n\n1 ≤ M ≤ 200 000\n\n1 ≤ a_i < b_i ≤ N\n\n(a_i, b_i) \\neq (1, N)\n\nIf i \\neq j, (a_i, b_i) \\neq (a_j, b_j).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\na_1 b_1\na_2 b_2\n:\na_M b_M\n\nOutput\n\nIf it is possible to go to Island N by using two boat services, print POSSIBLE; otherwise, print IMPOSSIBLE.\n\nSample Input 1\n\n3 2\n1 2\n2 3\n\nSample Output 1\n\nPOSSIBLE\n\nSample Input 2\n\n4 3\n1 2\n2 3\n3 4\n\nSample Output 2\n\nIMPOSSIBLE\n\nYou have to use three boat services to get to Island 4.\n\nSample Input 3\n\n100000 1\n1 99999\n\nSample Output 3\n\nIMPOSSIBLE\n\nSample Input 4\n\n5 5\n1 3\n4 5\n2 3\n2 4\n1 4\n\nSample Output 4\n\nPOSSIBLE\n\nYou can get to Island 5 by using two boat services: Island 1 -> Island 4 -> Island 5.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 319, "cpu_time_ms": 106, "memory_kb": 11228}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s618494680", "group_id": "codeNet:p03647", "input_text": "n,m=io.read(\"*n\",\"*n\")\nf=io.read(\"*a\")\nc,d={},{}\nfor a,b in f:gmatch(\"(%d+) (%d+)\") do\n\ta=tonumber(a);b=tonumber(b)\n\tif a==1 then c[#c+1]=b end\n\tif b==n then d[a]=true end\nend\nfor _,i in ipairs(c)do\n\tif d[i] then\n\t\tprint(\"POSSIBLE\")\n\t\tos.exit()\n\tend\nend\nprint(\"IMPOSSIBLE\")", "language": "Lua", "metadata": {"date": 1525646203, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p03647.html", "problem_id": "p03647", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03647/input.txt", "sample_output_relpath": "derived/input_output/data/p03647/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03647/Lua/s618494680.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s618494680", "user_id": "u781091740"}, "prompt_components": {"gold_output": "POSSIBLE\n", "input_to_evaluate": "n,m=io.read(\"*n\",\"*n\")\nf=io.read(\"*a\")\nc,d={},{}\nfor a,b in f:gmatch(\"(%d+) (%d+)\") do\n\ta=tonumber(a);b=tonumber(b)\n\tif a==1 then c[#c+1]=b end\n\tif b==n then d[a]=true end\nend\nfor _,i in ipairs(c)do\n\tif d[i] then\n\t\tprint(\"POSSIBLE\")\n\t\tos.exit()\n\tend\nend\nprint(\"IMPOSSIBLE\")", "problem_context": "Score : 300 points\n\nProblem Statement\n\nIn Takahashi Kingdom, there is an archipelago of N islands, called Takahashi Islands.\nFor convenience, we will call them Island 1, Island 2, ..., Island N.\n\nThere are M kinds of regular boat services between these islands.\nEach service connects two islands. The i-th service connects Island a_i and Island b_i.\n\nCat Snuke is on Island 1 now, and wants to go to Island N.\nHowever, it turned out that there is no boat service from Island 1 to Island N, so he wants to know whether it is possible to go to Island N by using two boat services.\n\nHelp him.\n\nConstraints\n\n3 ≤ N ≤ 200 000\n\n1 ≤ M ≤ 200 000\n\n1 ≤ a_i < b_i ≤ N\n\n(a_i, b_i) \\neq (1, N)\n\nIf i \\neq j, (a_i, b_i) \\neq (a_j, b_j).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\na_1 b_1\na_2 b_2\n:\na_M b_M\n\nOutput\n\nIf it is possible to go to Island N by using two boat services, print POSSIBLE; otherwise, print IMPOSSIBLE.\n\nSample Input 1\n\n3 2\n1 2\n2 3\n\nSample Output 1\n\nPOSSIBLE\n\nSample Input 2\n\n4 3\n1 2\n2 3\n3 4\n\nSample Output 2\n\nIMPOSSIBLE\n\nYou have to use three boat services to get to Island 4.\n\nSample Input 3\n\n100000 1\n1 99999\n\nSample Output 3\n\nIMPOSSIBLE\n\nSample Input 4\n\n5 5\n1 3\n4 5\n2 3\n2 4\n1 4\n\nSample Output 4\n\nPOSSIBLE\n\nYou can get to Island 5 by using two boat services: Island 1 -> Island 4 -> Island 5.", "sample_input": "3 2\n1 2\n2 3\n"}, "reference_outputs": ["POSSIBLE\n"], "source_document_id": "p03647", "source_text": "Score : 300 points\n\nProblem Statement\n\nIn Takahashi Kingdom, there is an archipelago of N islands, called Takahashi Islands.\nFor convenience, we will call them Island 1, Island 2, ..., Island N.\n\nThere are M kinds of regular boat services between these islands.\nEach service connects two islands. The i-th service connects Island a_i and Island b_i.\n\nCat Snuke is on Island 1 now, and wants to go to Island N.\nHowever, it turned out that there is no boat service from Island 1 to Island N, so he wants to know whether it is possible to go to Island N by using two boat services.\n\nHelp him.\n\nConstraints\n\n3 ≤ N ≤ 200 000\n\n1 ≤ M ≤ 200 000\n\n1 ≤ a_i < b_i ≤ N\n\n(a_i, b_i) \\neq (1, N)\n\nIf i \\neq j, (a_i, b_i) \\neq (a_j, b_j).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\na_1 b_1\na_2 b_2\n:\na_M b_M\n\nOutput\n\nIf it is possible to go to Island N by using two boat services, print POSSIBLE; otherwise, print IMPOSSIBLE.\n\nSample Input 1\n\n3 2\n1 2\n2 3\n\nSample Output 1\n\nPOSSIBLE\n\nSample Input 2\n\n4 3\n1 2\n2 3\n3 4\n\nSample Output 2\n\nIMPOSSIBLE\n\nYou have to use three boat services to get to Island 4.\n\nSample Input 3\n\n100000 1\n1 99999\n\nSample Output 3\n\nIMPOSSIBLE\n\nSample Input 4\n\n5 5\n1 3\n4 5\n2 3\n2 4\n1 4\n\nSample Output 4\n\nPOSSIBLE\n\nYou can get to Island 5 by using two boat services: Island 1 -> Island 4 -> Island 5.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 273, "cpu_time_ms": 119, "memory_kb": 14536}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s541425706", "group_id": "codeNet:p03649", "input_text": "local n = io.read(\"*n\")\nlocal a = {}\nfor i = 1, n do a[i] = io.read(\"*n\") end\nlocal cnt = 0\n\nlocal function getminmax()\n local min, max, maxp = a[1], a[1], 1\n for i = 2, n do\n if max < a[i] then\n max, maxp = a[i], i\n end\n if a[i] < min then\n min = a[i]\n end\n end\n return min, max, maxp\nend\nwhile true do\n local min, max, maxp = getminmax()\n if max - min <= n then break end\n local rep = (max - min) // (n + 1)\n cnt = cnt + rep\n for i = 1, n do\n if i == maxp then\n a[i] = a[i] - rep * n\n else\n a[i] = a[i] + rep\n end\n end\nend\ndo\n local min = getminmax()\n while n <= min do\n local rep = min // n\n cnt = cnt + rep * n * (n - 1)\n for i = 1, n do\n a[i] = a[i] - rep * (n - 1)\n end\n min = getminmax()\n end\nend\nwhile true do\n local min, max, maxp = getminmax()\n if max < n then break\n else\n cnt = cnt + 1\n for i = 1, n do\n if i == maxp then a[i] = a[i] - n\n else a[i] = a[i] + 1\n end\n end\n end\nend\n\nprint(cnt)\n", "language": "Lua", "metadata": {"date": 1582262430, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03649.html", "problem_id": "p03649", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03649/input.txt", "sample_output_relpath": "derived/input_output/data/p03649/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03649/Lua/s541425706.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s541425706", "user_id": "u120582723"}, "prompt_components": {"gold_output": "0\n", "input_to_evaluate": "local n = io.read(\"*n\")\nlocal a = {}\nfor i = 1, n do a[i] = io.read(\"*n\") end\nlocal cnt = 0\n\nlocal function getminmax()\n local min, max, maxp = a[1], a[1], 1\n for i = 2, n do\n if max < a[i] then\n max, maxp = a[i], i\n end\n if a[i] < min then\n min = a[i]\n end\n end\n return min, max, maxp\nend\nwhile true do\n local min, max, maxp = getminmax()\n if max - min <= n then break end\n local rep = (max - min) // (n + 1)\n cnt = cnt + rep\n for i = 1, n do\n if i == maxp then\n a[i] = a[i] - rep * n\n else\n a[i] = a[i] + rep\n end\n end\nend\ndo\n local min = getminmax()\n while n <= min do\n local rep = min // n\n cnt = cnt + rep * n * (n - 1)\n for i = 1, n do\n a[i] = a[i] - rep * (n - 1)\n end\n min = getminmax()\n end\nend\nwhile true do\n local min, max, maxp = getminmax()\n if max < n then break\n else\n cnt = cnt + 1\n for i = 1, n do\n if i == maxp then a[i] = a[i] - n\n else a[i] = a[i] + 1\n end\n end\n end\nend\n\nprint(cnt)\n", "problem_context": "Score : 600 points\n\nProblem Statement\n\nWe have a sequence of length N consisting of non-negative integers. Consider performing the following operation on this sequence until the largest element in this sequence becomes N-1 or smaller. (The operation is the same as the one in Problem D.)\n\nDetermine the largest element in the sequence (if there is more than one, choose one). Decrease the value of this element by N, and increase each of the other elements by 1.\n\nIt can be proved that the largest element in the sequence becomes N-1 or smaller after a finite number of operations.\n\nYou are given the sequence a_i. Find the number of times we will perform the above operation.\n\nConstraints\n\n2 ≤ N ≤ 50\n\n0 ≤ a_i ≤ 10^{16} + 1000\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 ... a_N\n\nOutput\n\nPrint the number of times the operation will be performed.\n\nSample Input 1\n\n4\n3 3 3 3\n\nSample Output 1\n\n0\n\nSample Input 2\n\n3\n1 0 3\n\nSample Output 2\n\n1\n\nSample Input 3\n\n2\n2 2\n\nSample Output 3\n\n2\n\nSample Input 4\n\n7\n27 0 0 0 0 0 0\n\nSample Output 4\n\n3\n\nSample Input 5\n\n10\n1000 193 256 777 0 1 1192 1234567891011 48 425\n\nSample Output 5\n\n1234567894848", "sample_input": "4\n3 3 3 3\n"}, "reference_outputs": ["0\n"], "source_document_id": "p03649", "source_text": "Score : 600 points\n\nProblem Statement\n\nWe have a sequence of length N consisting of non-negative integers. Consider performing the following operation on this sequence until the largest element in this sequence becomes N-1 or smaller. (The operation is the same as the one in Problem D.)\n\nDetermine the largest element in the sequence (if there is more than one, choose one). Decrease the value of this element by N, and increase each of the other elements by 1.\n\nIt can be proved that the largest element in the sequence becomes N-1 or smaller after a finite number of operations.\n\nYou are given the sequence a_i. Find the number of times we will perform the above operation.\n\nConstraints\n\n2 ≤ N ≤ 50\n\n0 ≤ a_i ≤ 10^{16} + 1000\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 ... a_N\n\nOutput\n\nPrint the number of times the operation will be performed.\n\nSample Input 1\n\n4\n3 3 3 3\n\nSample Output 1\n\n0\n\nSample Input 2\n\n3\n1 0 3\n\nSample Output 2\n\n1\n\nSample Input 3\n\n2\n2 2\n\nSample Output 3\n\n2\n\nSample Input 4\n\n7\n27 0 0 0 0 0 0\n\nSample Output 4\n\n3\n\nSample Input 5\n\n10\n1000 193 256 777 0 1 1192 1234567891011 48 425\n\nSample Output 5\n\n1234567894848", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1005, "cpu_time_ms": 11, "memory_kb": 760}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s418047844", "group_id": "codeNet:p03657", "input_text": "a,b=io.read():match(\"(.+)%s(.+)\")\nprint((a%3==0 or b%3==0 or (a+b)%3==0)and \"Possible\"or\"Impossible\")", "language": "Lua", "metadata": {"date": 1551835462, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p03657.html", "problem_id": "p03657", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03657/input.txt", "sample_output_relpath": "derived/input_output/data/p03657/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03657/Lua/s418047844.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s418047844", "user_id": "u837412668"}, "prompt_components": {"gold_output": "Possible\n", "input_to_evaluate": "a,b=io.read():match(\"(.+)%s(.+)\")\nprint((a%3==0 or b%3==0 or (a+b)%3==0)and \"Possible\"or\"Impossible\")", "problem_context": "Score : 100 points\n\nProblem Statement\n\nSnuke is giving cookies to his three goats.\n\nHe has two cookie tins. One contains A cookies, and the other contains B cookies. He can thus give A cookies, B cookies or A+B cookies to his goats (he cannot open the tins).\n\nYour task is to determine whether Snuke can give cookies to his three goats so that each of them can have the same number of cookies.\n\nConstraints\n\n1 \\leq A,B \\leq 100\n\nBoth A and B are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nIf it is possible to give cookies so that each of the three goats can have the same number of cookies, print Possible; otherwise, print Impossible.\n\nSample Input 1\n\n4 5\n\nSample Output 1\n\nPossible\n\nIf Snuke gives nine cookies, each of the three goats can have three cookies.\n\nSample Input 2\n\n1 1\n\nSample Output 2\n\nImpossible\n\nSince there are only two cookies, the three goats cannot have the same number of cookies no matter what Snuke gives to them.", "sample_input": "4 5\n"}, "reference_outputs": ["Possible\n"], "source_document_id": "p03657", "source_text": "Score : 100 points\n\nProblem Statement\n\nSnuke is giving cookies to his three goats.\n\nHe has two cookie tins. One contains A cookies, and the other contains B cookies. He can thus give A cookies, B cookies or A+B cookies to his goats (he cannot open the tins).\n\nYour task is to determine whether Snuke can give cookies to his three goats so that each of them can have the same number of cookies.\n\nConstraints\n\n1 \\leq A,B \\leq 100\n\nBoth A and B are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nIf it is possible to give cookies so that each of the three goats can have the same number of cookies, print Possible; otherwise, print Impossible.\n\nSample Input 1\n\n4 5\n\nSample Output 1\n\nPossible\n\nIf Snuke gives nine cookies, each of the three goats can have three cookies.\n\nSample Input 2\n\n1 1\n\nSample Output 2\n\nImpossible\n\nSince there are only two cookies, the three goats cannot have the same number of cookies no matter what Snuke gives to them.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 101, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s764830642", "group_id": "codeNet:p03657", "input_text": "a = io.read(\"*line\")\nnlist = {}\nj = 1\n\nfor i in a:gmatch(\"%S+\") do\n nlist[j] = tonumber(i)\n j = j + 1\nend\narg1 = nlist[1]\narg2 = nlist[2]\n \nif (arg1+arg2) % 3 == 0.0 then\n print('Possible')\nelse\n print('Impossible')\nend", "language": "Lua", "metadata": {"date": 1501027075, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03657.html", "problem_id": "p03657", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03657/input.txt", "sample_output_relpath": "derived/input_output/data/p03657/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03657/Lua/s764830642.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s764830642", "user_id": "u678875535"}, "prompt_components": {"gold_output": "Possible\n", "input_to_evaluate": "a = io.read(\"*line\")\nnlist = {}\nj = 1\n\nfor i in a:gmatch(\"%S+\") do\n nlist[j] = tonumber(i)\n j = j + 1\nend\narg1 = nlist[1]\narg2 = nlist[2]\n \nif (arg1+arg2) % 3 == 0.0 then\n print('Possible')\nelse\n print('Impossible')\nend", "problem_context": "Score : 100 points\n\nProblem Statement\n\nSnuke is giving cookies to his three goats.\n\nHe has two cookie tins. One contains A cookies, and the other contains B cookies. He can thus give A cookies, B cookies or A+B cookies to his goats (he cannot open the tins).\n\nYour task is to determine whether Snuke can give cookies to his three goats so that each of them can have the same number of cookies.\n\nConstraints\n\n1 \\leq A,B \\leq 100\n\nBoth A and B are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nIf it is possible to give cookies so that each of the three goats can have the same number of cookies, print Possible; otherwise, print Impossible.\n\nSample Input 1\n\n4 5\n\nSample Output 1\n\nPossible\n\nIf Snuke gives nine cookies, each of the three goats can have three cookies.\n\nSample Input 2\n\n1 1\n\nSample Output 2\n\nImpossible\n\nSince there are only two cookies, the three goats cannot have the same number of cookies no matter what Snuke gives to them.", "sample_input": "4 5\n"}, "reference_outputs": ["Possible\n"], "source_document_id": "p03657", "source_text": "Score : 100 points\n\nProblem Statement\n\nSnuke is giving cookies to his three goats.\n\nHe has two cookie tins. One contains A cookies, and the other contains B cookies. He can thus give A cookies, B cookies or A+B cookies to his goats (he cannot open the tins).\n\nYour task is to determine whether Snuke can give cookies to his three goats so that each of them can have the same number of cookies.\n\nConstraints\n\n1 \\leq A,B \\leq 100\n\nBoth A and B are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nIf it is possible to give cookies so that each of the three goats can have the same number of cookies, print Possible; otherwise, print Impossible.\n\nSample Input 1\n\n4 5\n\nSample Output 1\n\nPossible\n\nIf Snuke gives nine cookies, each of the three goats can have three cookies.\n\nSample Input 2\n\n1 1\n\nSample Output 2\n\nImpossible\n\nSince there are only two cookies, the three goats cannot have the same number of cookies no matter what Snuke gives to them.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 235, "cpu_time_ms": 8, "memory_kb": 888}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s722540705", "group_id": "codeNet:p03659", "input_text": "local n=io.read(\"*n\")\nlocal a={}\nlocal total=0\nfor i=1,n do\n a[i]=io.read(\"*n\")\n total=total+a[i]\nend\n\nlocal total_i=0\nlocal diff=10^9\nfor i=1,n-1 do\n total_i=total_i+a[i]\n diff=math.min(diff,math.abs(total-2*total_i))\nend\nprint(diff)", "language": "Lua", "metadata": {"date": 1590372362, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03659.html", "problem_id": "p03659", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03659/input.txt", "sample_output_relpath": "derived/input_output/data/p03659/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03659/Lua/s722540705.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s722540705", "user_id": "u045238009"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "local n=io.read(\"*n\")\nlocal a={}\nlocal total=0\nfor i=1,n do\n a[i]=io.read(\"*n\")\n total=total+a[i]\nend\n\nlocal total_i=0\nlocal diff=10^9\nfor i=1,n-1 do\n total_i=total_i+a[i]\n diff=math.min(diff,math.abs(total-2*total_i))\nend\nprint(diff)", "problem_context": "Score : 300 points\n\nProblem Statement\n\nSnuke and Raccoon have a heap of N cards. The i-th card from the top has the integer a_i written on it.\n\nThey will share these cards.\nFirst, Snuke will take some number of cards from the top of the heap, then Raccoon will take all the remaining cards.\nHere, both Snuke and Raccoon have to take at least one card.\n\nLet the sum of the integers on Snuke's cards and Raccoon's cards be x and y, respectively.\nThey would like to minimize |x-y|.\nFind the minimum possible value of |x-y|.\n\nConstraints\n\n2 \\leq N \\leq 2 \\times 10^5\n\n-10^{9} \\leq a_i \\leq 10^{9}\n\na_i is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 ... a_{N}\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n6\n1 2 3 4 5 6\n\nSample Output 1\n\n1\n\nIf Snuke takes four cards from the top, and Raccoon takes the remaining two cards, x=10, y=11, and thus |x-y|=1. This is the minimum possible value.\n\nSample Input 2\n\n2\n10 -10\n\nSample Output 2\n\n20\n\nSnuke can only take one card from the top, and Raccoon can only take the remaining one card. In this case, x=10, y=-10, and thus |x-y|=20.", "sample_input": "6\n1 2 3 4 5 6\n"}, "reference_outputs": ["1\n"], "source_document_id": "p03659", "source_text": "Score : 300 points\n\nProblem Statement\n\nSnuke and Raccoon have a heap of N cards. The i-th card from the top has the integer a_i written on it.\n\nThey will share these cards.\nFirst, Snuke will take some number of cards from the top of the heap, then Raccoon will take all the remaining cards.\nHere, both Snuke and Raccoon have to take at least one card.\n\nLet the sum of the integers on Snuke's cards and Raccoon's cards be x and y, respectively.\nThey would like to minimize |x-y|.\nFind the minimum possible value of |x-y|.\n\nConstraints\n\n2 \\leq N \\leq 2 \\times 10^5\n\n-10^{9} \\leq a_i \\leq 10^{9}\n\na_i is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 ... a_{N}\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n6\n1 2 3 4 5 6\n\nSample Output 1\n\n1\n\nIf Snuke takes four cards from the top, and Raccoon takes the remaining two cards, x=10, y=11, and thus |x-y|=1. This is the minimum possible value.\n\nSample Input 2\n\n2\n10 -10\n\nSample Output 2\n\n20\n\nSnuke can only take one card from the top, and Raccoon can only take the remaining one card. In this case, x=10, y=-10, and thus |x-y|=20.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 246, "cpu_time_ms": 93, "memory_kb": 4472}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s009669029", "group_id": "codeNet:p03659", "input_text": "local n = io.read(\"*n\", \"*l\")\nlocal str = io.read()\nlocal nums = {}\nlocal ti = table.insert\nlocal tn = tonumber\nlocal diff = 0\nfor numstr in string.gmatch(str, \"%-?%d+\") do\n local a = tn(numstr)\n diff = diff + a\n ti(nums, a)\nend\ndiff = diff - nums[1] * 2\nlocal ma = math.abs\nlocal mm = math.min\nlocal diffmax = ma(diff)\nfor i = 2, n - 1 do\n diff = diff - nums[i] * 2\n diffmax = mm(diffmax, ma(diff))\nend\nprint(diffmax)\n", "language": "Lua", "metadata": {"date": 1555473263, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03659.html", "problem_id": "p03659", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03659/input.txt", "sample_output_relpath": "derived/input_output/data/p03659/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03659/Lua/s009669029.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s009669029", "user_id": "u120582723"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "local n = io.read(\"*n\", \"*l\")\nlocal str = io.read()\nlocal nums = {}\nlocal ti = table.insert\nlocal tn = tonumber\nlocal diff = 0\nfor numstr in string.gmatch(str, \"%-?%d+\") do\n local a = tn(numstr)\n diff = diff + a\n ti(nums, a)\nend\ndiff = diff - nums[1] * 2\nlocal ma = math.abs\nlocal mm = math.min\nlocal diffmax = ma(diff)\nfor i = 2, n - 1 do\n diff = diff - nums[i] * 2\n diffmax = mm(diffmax, ma(diff))\nend\nprint(diffmax)\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nSnuke and Raccoon have a heap of N cards. The i-th card from the top has the integer a_i written on it.\n\nThey will share these cards.\nFirst, Snuke will take some number of cards from the top of the heap, then Raccoon will take all the remaining cards.\nHere, both Snuke and Raccoon have to take at least one card.\n\nLet the sum of the integers on Snuke's cards and Raccoon's cards be x and y, respectively.\nThey would like to minimize |x-y|.\nFind the minimum possible value of |x-y|.\n\nConstraints\n\n2 \\leq N \\leq 2 \\times 10^5\n\n-10^{9} \\leq a_i \\leq 10^{9}\n\na_i is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 ... a_{N}\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n6\n1 2 3 4 5 6\n\nSample Output 1\n\n1\n\nIf Snuke takes four cards from the top, and Raccoon takes the remaining two cards, x=10, y=11, and thus |x-y|=1. This is the minimum possible value.\n\nSample Input 2\n\n2\n10 -10\n\nSample Output 2\n\n20\n\nSnuke can only take one card from the top, and Raccoon can only take the remaining one card. In this case, x=10, y=-10, and thus |x-y|=20.", "sample_input": "6\n1 2 3 4 5 6\n"}, "reference_outputs": ["1\n"], "source_document_id": "p03659", "source_text": "Score : 300 points\n\nProblem Statement\n\nSnuke and Raccoon have a heap of N cards. The i-th card from the top has the integer a_i written on it.\n\nThey will share these cards.\nFirst, Snuke will take some number of cards from the top of the heap, then Raccoon will take all the remaining cards.\nHere, both Snuke and Raccoon have to take at least one card.\n\nLet the sum of the integers on Snuke's cards and Raccoon's cards be x and y, respectively.\nThey would like to minimize |x-y|.\nFind the minimum possible value of |x-y|.\n\nConstraints\n\n2 \\leq N \\leq 2 \\times 10^5\n\n-10^{9} \\leq a_i \\leq 10^{9}\n\na_i is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 ... a_{N}\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n6\n1 2 3 4 5 6\n\nSample Output 1\n\n1\n\nIf Snuke takes four cards from the top, and Raccoon takes the remaining two cards, x=10, y=11, and thus |x-y|=1. This is the minimum possible value.\n\nSample Input 2\n\n2\n10 -10\n\nSample Output 2\n\n20\n\nSnuke can only take one card from the top, and Raccoon can only take the remaining one card. In this case, x=10, y=-10, and thus |x-y|=20.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 424, "cpu_time_ms": 136, "memory_kb": 11264}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s979837822", "group_id": "codeNet:p03665", "input_text": "local function combination(x,y)\n if y==0 then\n return 1\n else\n return x*combination(x-1,y-1)//y\n end\nend\n\nn,p=io.read(\"*n\",\"*n\")\nlocal co=0\nlocal ce=n\nfor i=1,n do\n if io.read(\"*n\")%2==1 then\n co=co+1\n ce=ce-1\n end\nend\n\nlocal cootal=0\nlocal ceotal=0\nfor i=p,co,2 do\n cootal=cootal+combination(co,i)\nend\nfor i=0,ce do\n ceotal=ceotal+combination(ce,i)\nend\nprint(cootal*ceotal)", "language": "Lua", "metadata": {"date": 1589633699, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03665.html", "problem_id": "p03665", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03665/input.txt", "sample_output_relpath": "derived/input_output/data/p03665/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03665/Lua/s979837822.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s979837822", "user_id": "u045238009"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "local function combination(x,y)\n if y==0 then\n return 1\n else\n return x*combination(x-1,y-1)//y\n end\nend\n\nn,p=io.read(\"*n\",\"*n\")\nlocal co=0\nlocal ce=n\nfor i=1,n do\n if io.read(\"*n\")%2==1 then\n co=co+1\n ce=ce-1\n end\nend\n\nlocal cootal=0\nlocal ceotal=0\nfor i=p,co,2 do\n cootal=cootal+combination(co,i)\nend\nfor i=0,ce do\n ceotal=ceotal+combination(ce,i)\nend\nprint(cootal*ceotal)", "problem_context": "Score : 200 points\n\nProblem Statement\n\nThere are N bags of biscuits. The i-th bag contains A_i biscuits.\n\nTakaki will select some of these bags and eat all of the biscuits inside.\nHere, it is also possible to select all or none of the bags.\n\nHe would like to select bags so that the total number of biscuits inside is congruent to P modulo 2.\nHow many such ways to select bags there are?\n\nConstraints\n\n1 \\leq N \\leq 50\n\nP = 0 or 1\n\n1 \\leq A_i \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN P\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the number of ways to select bags so that the total number of biscuits inside is congruent to P modulo 2.\n\nSample Input 1\n\n2 0\n1 3\n\nSample Output 1\n\n2\n\nThere are two ways to select bags so that the total number of biscuits inside is congruent to 0 modulo 2:\n\nSelect neither bag. The total number of biscuits is 0.\n\nSelect both bags. The total number of biscuits is 4.\n\nSample Input 2\n\n1 1\n50\n\nSample Output 2\n\n0\n\nSample Input 3\n\n3 0\n1 1 1\n\nSample Output 3\n\n4\n\nTwo bags are distinguished even if they contain the same number of biscuits.\n\nSample Input 4\n\n45 1\n17 55 85 55 74 20 90 67 40 70 39 89 91 50 16 24 14 43 24 66 25 9 89 71 41 16 53 13 61 15 85 72 62 67 42 26 36 66 4 87 59 91 4 25 26\n\nSample Output 4\n\n17592186044416", "sample_input": "2 0\n1 3\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03665", "source_text": "Score : 200 points\n\nProblem Statement\n\nThere are N bags of biscuits. The i-th bag contains A_i biscuits.\n\nTakaki will select some of these bags and eat all of the biscuits inside.\nHere, it is also possible to select all or none of the bags.\n\nHe would like to select bags so that the total number of biscuits inside is congruent to P modulo 2.\nHow many such ways to select bags there are?\n\nConstraints\n\n1 \\leq N \\leq 50\n\nP = 0 or 1\n\n1 \\leq A_i \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN P\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the number of ways to select bags so that the total number of biscuits inside is congruent to P modulo 2.\n\nSample Input 1\n\n2 0\n1 3\n\nSample Output 1\n\n2\n\nThere are two ways to select bags so that the total number of biscuits inside is congruent to 0 modulo 2:\n\nSelect neither bag. The total number of biscuits is 0.\n\nSelect both bags. The total number of biscuits is 4.\n\nSample Input 2\n\n1 1\n50\n\nSample Output 2\n\n0\n\nSample Input 3\n\n3 0\n1 1 1\n\nSample Output 3\n\n4\n\nTwo bags are distinguished even if they contain the same number of biscuits.\n\nSample Input 4\n\n45 1\n17 55 85 55 74 20 90 67 40 70 39 89 91 50 16 24 14 43 24 66 25 9 89 71 41 16 53 13 61 15 85 72 62 67 42 26 36 66 4 87 59 91 4 25 26\n\nSample Output 4\n\n17592186044416", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 423, "cpu_time_ms": 10, "memory_kb": 760}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s375524790", "group_id": "codeNet:p03665", "input_text": "local function combination(x,y)\n if y==0 then\n return 1\n else\n return x*combination(x-1,y-1)//y\n end\nend\n\nn,p=io.read(\"*n\",\"*n\")\nlocal co=0\nlocal ce=0\nfor i=1,n do\n if io.read(\"*n\")%2==1 then\n co=co+1\n else\n ce=n-co\n end\nend\n\nlocal cootal=0\nlocal ceotal=0\nif p==0 then\n for i=0,co,2 do\n cootal=cootal+combination(co,i)\n end\n for i=0,ce do\n ceotal=ceotal+combination(ce,i)\n end\nelse\n for i=1,co,2 do\n cootal=cootal+combination(co,i)\n end\n for i=0,ce do\n ceotal=ceotal+combination(ce,i)\n end\nend\nprint(cootal*ceotal)", "language": "Lua", "metadata": {"date": 1589585711, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03665.html", "problem_id": "p03665", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03665/input.txt", "sample_output_relpath": "derived/input_output/data/p03665/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03665/Lua/s375524790.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s375524790", "user_id": "u045238009"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "local function combination(x,y)\n if y==0 then\n return 1\n else\n return x*combination(x-1,y-1)//y\n end\nend\n\nn,p=io.read(\"*n\",\"*n\")\nlocal co=0\nlocal ce=0\nfor i=1,n do\n if io.read(\"*n\")%2==1 then\n co=co+1\n else\n ce=n-co\n end\nend\n\nlocal cootal=0\nlocal ceotal=0\nif p==0 then\n for i=0,co,2 do\n cootal=cootal+combination(co,i)\n end\n for i=0,ce do\n ceotal=ceotal+combination(ce,i)\n end\nelse\n for i=1,co,2 do\n cootal=cootal+combination(co,i)\n end\n for i=0,ce do\n ceotal=ceotal+combination(ce,i)\n end\nend\nprint(cootal*ceotal)", "problem_context": "Score : 200 points\n\nProblem Statement\n\nThere are N bags of biscuits. The i-th bag contains A_i biscuits.\n\nTakaki will select some of these bags and eat all of the biscuits inside.\nHere, it is also possible to select all or none of the bags.\n\nHe would like to select bags so that the total number of biscuits inside is congruent to P modulo 2.\nHow many such ways to select bags there are?\n\nConstraints\n\n1 \\leq N \\leq 50\n\nP = 0 or 1\n\n1 \\leq A_i \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN P\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the number of ways to select bags so that the total number of biscuits inside is congruent to P modulo 2.\n\nSample Input 1\n\n2 0\n1 3\n\nSample Output 1\n\n2\n\nThere are two ways to select bags so that the total number of biscuits inside is congruent to 0 modulo 2:\n\nSelect neither bag. The total number of biscuits is 0.\n\nSelect both bags. The total number of biscuits is 4.\n\nSample Input 2\n\n1 1\n50\n\nSample Output 2\n\n0\n\nSample Input 3\n\n3 0\n1 1 1\n\nSample Output 3\n\n4\n\nTwo bags are distinguished even if they contain the same number of biscuits.\n\nSample Input 4\n\n45 1\n17 55 85 55 74 20 90 67 40 70 39 89 91 50 16 24 14 43 24 66 25 9 89 71 41 16 53 13 61 15 85 72 62 67 42 26 36 66 4 87 59 91 4 25 26\n\nSample Output 4\n\n17592186044416", "sample_input": "2 0\n1 3\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03665", "source_text": "Score : 200 points\n\nProblem Statement\n\nThere are N bags of biscuits. The i-th bag contains A_i biscuits.\n\nTakaki will select some of these bags and eat all of the biscuits inside.\nHere, it is also possible to select all or none of the bags.\n\nHe would like to select bags so that the total number of biscuits inside is congruent to P modulo 2.\nHow many such ways to select bags there are?\n\nConstraints\n\n1 \\leq N \\leq 50\n\nP = 0 or 1\n\n1 \\leq A_i \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN P\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the number of ways to select bags so that the total number of biscuits inside is congruent to P modulo 2.\n\nSample Input 1\n\n2 0\n1 3\n\nSample Output 1\n\n2\n\nThere are two ways to select bags so that the total number of biscuits inside is congruent to 0 modulo 2:\n\nSelect neither bag. The total number of biscuits is 0.\n\nSelect both bags. The total number of biscuits is 4.\n\nSample Input 2\n\n1 1\n50\n\nSample Output 2\n\n0\n\nSample Input 3\n\n3 0\n1 1 1\n\nSample Output 3\n\n4\n\nTwo bags are distinguished even if they contain the same number of biscuits.\n\nSample Input 4\n\n45 1\n17 55 85 55 74 20 90 67 40 70 39 89 91 50 16 24 14 43 24 66 25 9 89 71 41 16 53 13 61 15 85 72 62 67 42 26 36 66 4 87 59 91 4 25 26\n\nSample Output 4\n\n17592186044416", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 612, "cpu_time_ms": 7, "memory_kb": 888}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s698157878", "group_id": "codeNet:p03666", "input_text": "local n, a, b, c, d = io.read(\"*n\", \"*n\", \"*n\", \"*n\", \"*n\")\nlocal len, n1 = math.abs(a - b), n - 1\nlocal isok = false\nfor i = 0, n1 do\n local l, r = i * c - (n1 - i) * d, i * d - (n1 - i) * c\n if l <= len and len <= r then isok = true break end\nend\nprint(isok and \"YES\" or \"NO\")\n", "language": "Lua", "metadata": {"date": 1566070717, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03666.html", "problem_id": "p03666", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03666/input.txt", "sample_output_relpath": "derived/input_output/data/p03666/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03666/Lua/s698157878.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s698157878", "user_id": "u120582723"}, "prompt_components": {"gold_output": "YES\n", "input_to_evaluate": "local n, a, b, c, d = io.read(\"*n\", \"*n\", \"*n\", \"*n\", \"*n\")\nlocal len, n1 = math.abs(a - b), n - 1\nlocal isok = false\nfor i = 0, n1 do\n local l, r = i * c - (n1 - i) * d, i * d - (n1 - i) * c\n if l <= len and len <= r then isok = true break end\nend\nprint(isok and \"YES\" or \"NO\")\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nThere are N squares in a row.\nThe leftmost square contains the integer A, and the rightmost contains the integer B. The other squares are empty.\n\nAohashi would like to fill the empty squares with integers so that the following condition is satisfied:\n\nFor any two adjacent squares, the (absolute) difference of the two integers in those squares is between C and D (inclusive).\n\nAs long as the condition is satisfied, it is allowed to use arbitrarily large or small integers to fill the squares.\nDetermine whether it is possible to fill the squares under the condition.\n\nConstraints\n\n3 \\leq N \\leq 500000\n\n0 \\leq A \\leq 10^9\n\n0 \\leq B \\leq 10^9\n\n0 \\leq C \\leq D \\leq 10^9\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN A B C D\n\nOutput\n\nPrint YES if it is possible to fill the squares under the condition; print NO otherwise.\n\nSample Input 1\n\n5 1 5 2 4\n\nSample Output 1\n\nYES\n\nFor example, fill the squares with the following integers: 1, -1, 3, 7, 5, from left to right.\n\nSample Input 2\n\n4 7 6 4 5\n\nSample Output 2\n\nNO\n\nSample Input 3\n\n48792 105960835 681218449 90629745 90632170\n\nSample Output 3\n\nNO\n\nSample Input 4\n\n491995 412925347 825318103 59999126 59999339\n\nSample Output 4\n\nYES", "sample_input": "5 1 5 2 4\n"}, "reference_outputs": ["YES\n"], "source_document_id": "p03666", "source_text": "Score : 400 points\n\nProblem Statement\n\nThere are N squares in a row.\nThe leftmost square contains the integer A, and the rightmost contains the integer B. The other squares are empty.\n\nAohashi would like to fill the empty squares with integers so that the following condition is satisfied:\n\nFor any two adjacent squares, the (absolute) difference of the two integers in those squares is between C and D (inclusive).\n\nAs long as the condition is satisfied, it is allowed to use arbitrarily large or small integers to fill the squares.\nDetermine whether it is possible to fill the squares under the condition.\n\nConstraints\n\n3 \\leq N \\leq 500000\n\n0 \\leq A \\leq 10^9\n\n0 \\leq B \\leq 10^9\n\n0 \\leq C \\leq D \\leq 10^9\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN A B C D\n\nOutput\n\nPrint YES if it is possible to fill the squares under the condition; print NO otherwise.\n\nSample Input 1\n\n5 1 5 2 4\n\nSample Output 1\n\nYES\n\nFor example, fill the squares with the following integers: 1, -1, 3, 7, 5, from left to right.\n\nSample Input 2\n\n4 7 6 4 5\n\nSample Output 2\n\nNO\n\nSample Input 3\n\n48792 105960835 681218449 90629745 90632170\n\nSample Output 3\n\nNO\n\nSample Input 4\n\n491995 412925347 825318103 59999126 59999339\n\nSample Output 4\n\nYES", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 281, "cpu_time_ms": 45, "memory_kb": 376}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s350572870", "group_id": "codeNet:p03671", "input_text": "x={}\nfor i in io.read():gmatch(\"%d+\")do\n table.insert(x,i*1)\nend\ntable.sort(x)\nprint(math.floor(x[1]+x[2]))", "language": "Lua", "metadata": {"date": 1551752862, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03671.html", "problem_id": "p03671", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03671/input.txt", "sample_output_relpath": "derived/input_output/data/p03671/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03671/Lua/s350572870.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s350572870", "user_id": "u837412668"}, "prompt_components": {"gold_output": "1300\n", "input_to_evaluate": "x={}\nfor i in io.read():gmatch(\"%d+\")do\n table.insert(x,i*1)\nend\ntable.sort(x)\nprint(math.floor(x[1]+x[2]))", "problem_context": "Score : 100 points\n\nProblem Statement\n\nSnuke is buying a bicycle.\nThe bicycle of his choice does not come with a bell, so he has to buy one separately.\n\nHe has very high awareness of safety, and decides to buy two bells, one for each hand.\n\nThe store sells three kinds of bells for the price of a, b and c yen (the currency of Japan), respectively.\nFind the minimum total price of two different bells.\n\nConstraints\n\n1 \\leq a,b,c \\leq 10000\n\na, b and c are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\na b c\n\nOutput\n\nPrint the minimum total price of two different bells.\n\nSample Input 1\n\n700 600 780\n\nSample Output 1\n\n1300\n\nBuying a 700-yen bell and a 600-yen bell costs 1300 yen.\n\nBuying a 700-yen bell and a 780-yen bell costs 1480 yen.\n\nBuying a 600-yen bell and a 780-yen bell costs 1380 yen.\n\nThe minimum among these is 1300 yen.\n\nSample Input 2\n\n10000 10000 10000\n\nSample Output 2\n\n20000\n\nBuying any two bells costs 20000 yen.", "sample_input": "700 600 780\n"}, "reference_outputs": ["1300\n"], "source_document_id": "p03671", "source_text": "Score : 100 points\n\nProblem Statement\n\nSnuke is buying a bicycle.\nThe bicycle of his choice does not come with a bell, so he has to buy one separately.\n\nHe has very high awareness of safety, and decides to buy two bells, one for each hand.\n\nThe store sells three kinds of bells for the price of a, b and c yen (the currency of Japan), respectively.\nFind the minimum total price of two different bells.\n\nConstraints\n\n1 \\leq a,b,c \\leq 10000\n\na, b and c are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\na b c\n\nOutput\n\nPrint the minimum total price of two different bells.\n\nSample Input 1\n\n700 600 780\n\nSample Output 1\n\n1300\n\nBuying a 700-yen bell and a 600-yen bell costs 1300 yen.\n\nBuying a 700-yen bell and a 780-yen bell costs 1480 yen.\n\nBuying a 600-yen bell and a 780-yen bell costs 1380 yen.\n\nThe minimum among these is 1300 yen.\n\nSample Input 2\n\n10000 10000 10000\n\nSample Output 2\n\n20000\n\nBuying any two bells costs 20000 yen.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 108, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s865413832", "group_id": "codeNet:p03673", "input_text": "local n=io.read(\"*n\")\nlocal b={}\nfor i=1,n do\n if i%2==1 then\n table.insert(b,io.read(\"*n\"))\n else\n table.insert(b,1,io.read(\"*n\"))\n end\nend\nif n%2==0 then\n print(table.concat(b,\" \"))\nelse\n local c={}\n for i=n,1,-1 do\n table.insert(c,b[i])\n end\n print(table.concat(c,\" \"))\nend", "language": "Lua", "metadata": {"date": 1589507937, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p03673.html", "problem_id": "p03673", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03673/input.txt", "sample_output_relpath": "derived/input_output/data/p03673/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03673/Lua/s865413832.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s865413832", "user_id": "u045238009"}, "prompt_components": {"gold_output": "4 2 1 3\n", "input_to_evaluate": "local n=io.read(\"*n\")\nlocal b={}\nfor i=1,n do\n if i%2==1 then\n table.insert(b,io.read(\"*n\"))\n else\n table.insert(b,1,io.read(\"*n\"))\n end\nend\nif n%2==0 then\n print(table.concat(b,\" \"))\nelse\n local c={}\n for i=n,1,-1 do\n table.insert(c,b[i])\n end\n print(table.concat(c,\" \"))\nend", "problem_context": "Score : 300 points\n\nProblem Statement\n\nYou are given an integer sequence of length n, a_1, ..., a_n.\nLet us consider performing the following n operations on an empty sequence b.\n\nThe i-th operation is as follows:\n\nAppend a_i to the end of b.\n\nReverse the order of the elements in b.\n\nFind the sequence b obtained after these n operations.\n\nConstraints\n\n1 \\leq n \\leq 2\\times 10^5\n\n0 \\leq a_i \\leq 10^9\n\nn and a_i are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nn\na_1 a_2 ... a_n\n\nOutput\n\nPrint n integers in a line with spaces in between.\nThe i-th integer should be b_i.\n\nSample Input 1\n\n4\n1 2 3 4\n\nSample Output 1\n\n4 2 1 3\n\nAfter step 1 of the first operation, b becomes: 1.\n\nAfter step 2 of the first operation, b becomes: 1.\n\nAfter step 1 of the second operation, b becomes: 1, 2.\n\nAfter step 2 of the second operation, b becomes: 2, 1.\n\nAfter step 1 of the third operation, b becomes: 2, 1, 3.\n\nAfter step 2 of the third operation, b becomes: 3, 1, 2.\n\nAfter step 1 of the fourth operation, b becomes: 3, 1, 2, 4.\n\nAfter step 2 of the fourth operation, b becomes: 4, 2, 1, 3.\n\nThus, the answer is 4 2 1 3.\n\nSample Input 2\n\n3\n1 2 3\n\nSample Output 2\n\n3 1 2\n\nAs shown above in Sample Output 1, b becomes 3, 1, 2 after step 2 of the third operation. Thus, the answer is 3 1 2.\n\nSample Input 3\n\n1\n1000000000\n\nSample Output 3\n\n1000000000\n\nSample Input 4\n\n6\n0 6 7 6 7 0\n\nSample Output 4\n\n0 6 6 0 7 7", "sample_input": "4\n1 2 3 4\n"}, "reference_outputs": ["4 2 1 3\n"], "source_document_id": "p03673", "source_text": "Score : 300 points\n\nProblem Statement\n\nYou are given an integer sequence of length n, a_1, ..., a_n.\nLet us consider performing the following n operations on an empty sequence b.\n\nThe i-th operation is as follows:\n\nAppend a_i to the end of b.\n\nReverse the order of the elements in b.\n\nFind the sequence b obtained after these n operations.\n\nConstraints\n\n1 \\leq n \\leq 2\\times 10^5\n\n0 \\leq a_i \\leq 10^9\n\nn and a_i are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nn\na_1 a_2 ... a_n\n\nOutput\n\nPrint n integers in a line with spaces in between.\nThe i-th integer should be b_i.\n\nSample Input 1\n\n4\n1 2 3 4\n\nSample Output 1\n\n4 2 1 3\n\nAfter step 1 of the first operation, b becomes: 1.\n\nAfter step 2 of the first operation, b becomes: 1.\n\nAfter step 1 of the second operation, b becomes: 1, 2.\n\nAfter step 2 of the second operation, b becomes: 2, 1.\n\nAfter step 1 of the third operation, b becomes: 2, 1, 3.\n\nAfter step 2 of the third operation, b becomes: 3, 1, 2.\n\nAfter step 1 of the fourth operation, b becomes: 3, 1, 2, 4.\n\nAfter step 2 of the fourth operation, b becomes: 4, 2, 1, 3.\n\nThus, the answer is 4 2 1 3.\n\nSample Input 2\n\n3\n1 2 3\n\nSample Output 2\n\n3 1 2\n\nAs shown above in Sample Output 1, b becomes 3, 1, 2 after step 2 of the third operation. Thus, the answer is 3 1 2.\n\nSample Input 3\n\n1\n1000000000\n\nSample Output 3\n\n1000000000\n\nSample Input 4\n\n6\n0 6 7 6 7 0\n\nSample Output 4\n\n0 6 6 0 7 7", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 321, "cpu_time_ms": 2103, "memory_kb": 1280}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s976035141", "group_id": "codeNet:p03674", "input_text": "local mod = 1000000007\nlocal mfl = math.floor\nlocal function bmul(x, y) return(x * y) % mod end\n\nlocal function badd(x, y)\n return (x + y) % mod\nend\n\nlocal function bsub(x, y)\n return x < y and x - y + mod or x - y\nend\n\nlocal function modpow(src, pow)\n local res = 1\n while 0 < pow do\n if pow % 2 == 1 then\n res = bmul(res, src)\n pow = pow - 1\n end\n src = bmul(src, src)\n pow = mfl(pow / 2)\n end\n return res\nend\n\nlocal function modinv(src)\n return modpow(src, mod - 2)\nend\n\nlocal fact = {1}\nlocal invs = {1}\nlocal invfact = {1}\nfor i = 2, 100000 do\n fact[i] = bmul(fact[i - 1], i)\n invs[i] = bmul(mfl(mod / i), mod - invs[mod % i])\n invfact[i] = bmul(invfact[i - 1], invs[i])\nend\n\nlocal function getComb(n, k)\n if k == 0 or k == n then return 1 end\n return bmul(fact[n], bmul(invfact[k], invfact[n - k]))\nend\n\nlocal n = io.read(\"*n\")\nlocal t = {}\nfor i = 1, n + 1 do\n t[i] = io.read(\"*n\")\nend\nlocal spos, epos = 0, 0\ndo\n local map = {}\n for i = 1, n + 1 do\n if not map[t[i]] then\n map[t[i]] = i\n else\n spos, epos = map[t[i]], i\n break\n end\n end\nend\nfor k = 1, n + 1 do\n local use_zero = 0\n if k <= n - 1 then\n use_zero = getComb(n - 1, k)\n end\n local use_two = 0\n if 2 <= k then\n use_two = getComb(n - 1, k - 2)\n end\n local use_one = 0\n if k <= n then\n use_one = bmul(2, getComb(n - 1, k - 1))\n end\n local use_one_dup = 0\n local mid_range = epos - spos - 1\n if k - 1 <= n - 1 - mid_range then\n use_one_dup = getComb(n - 1 - mid_range, k - 1)\n end\n local ret = badd(use_zero, badd(use_two, bsub(use_one, use_one_dup)))\n print(ret)\nend\n", "language": "Lua", "metadata": {"date": 1589642101, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03674.html", "problem_id": "p03674", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03674/input.txt", "sample_output_relpath": "derived/input_output/data/p03674/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03674/Lua/s976035141.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s976035141", "user_id": "u120582723"}, "prompt_components": {"gold_output": "3\n5\n4\n1\n", "input_to_evaluate": "local mod = 1000000007\nlocal mfl = math.floor\nlocal function bmul(x, y) return(x * y) % mod end\n\nlocal function badd(x, y)\n return (x + y) % mod\nend\n\nlocal function bsub(x, y)\n return x < y and x - y + mod or x - y\nend\n\nlocal function modpow(src, pow)\n local res = 1\n while 0 < pow do\n if pow % 2 == 1 then\n res = bmul(res, src)\n pow = pow - 1\n end\n src = bmul(src, src)\n pow = mfl(pow / 2)\n end\n return res\nend\n\nlocal function modinv(src)\n return modpow(src, mod - 2)\nend\n\nlocal fact = {1}\nlocal invs = {1}\nlocal invfact = {1}\nfor i = 2, 100000 do\n fact[i] = bmul(fact[i - 1], i)\n invs[i] = bmul(mfl(mod / i), mod - invs[mod % i])\n invfact[i] = bmul(invfact[i - 1], invs[i])\nend\n\nlocal function getComb(n, k)\n if k == 0 or k == n then return 1 end\n return bmul(fact[n], bmul(invfact[k], invfact[n - k]))\nend\n\nlocal n = io.read(\"*n\")\nlocal t = {}\nfor i = 1, n + 1 do\n t[i] = io.read(\"*n\")\nend\nlocal spos, epos = 0, 0\ndo\n local map = {}\n for i = 1, n + 1 do\n if not map[t[i]] then\n map[t[i]] = i\n else\n spos, epos = map[t[i]], i\n break\n end\n end\nend\nfor k = 1, n + 1 do\n local use_zero = 0\n if k <= n - 1 then\n use_zero = getComb(n - 1, k)\n end\n local use_two = 0\n if 2 <= k then\n use_two = getComb(n - 1, k - 2)\n end\n local use_one = 0\n if k <= n then\n use_one = bmul(2, getComb(n - 1, k - 1))\n end\n local use_one_dup = 0\n local mid_range = epos - spos - 1\n if k - 1 <= n - 1 - mid_range then\n use_one_dup = getComb(n - 1 - mid_range, k - 1)\n end\n local ret = badd(use_zero, badd(use_two, bsub(use_one, use_one_dup)))\n print(ret)\nend\n", "problem_context": "Score : 600 points\n\nProblem Statement\n\nYou are given an integer sequence of length n+1, a_1,a_2,...,a_{n+1}, which consists of the n integers 1,...,n.\nIt is known that each of the n integers 1,...,n appears at least once in this sequence.\n\nFor each integer k=1,...,n+1, find the number of the different subsequences (not necessarily contiguous) of the given sequence with length k, modulo 10^9+7.\n\nNotes\n\nIf the contents of two subsequences are the same, they are not separately counted even if they originate from different positions in the original sequence.\n\nA 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. For example, the sequences 1,3,5 and 1,2,3 are subsequences of 1,2,3,4,5, while 3,1,2 and 1,10,100 are not.\n\nConstraints\n\n1 \\leq n \\leq 10^5\n\n1 \\leq a_i \\leq n\n\nEach of the integers 1,...,n appears in the sequence.\n\nn and a_i are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nn\na_1 a_2 ... a_{n+1}\n\nOutput\n\nPrint n+1 lines.\nThe k-th line should contain the number of the different subsequences of the given sequence with length k, modulo 10^9+7.\n\nSample Input 1\n\n3\n1 2 1 3\n\nSample Output 1\n\n3\n5\n4\n1\n\nThere are three subsequences with length 1: 1 and 2 and 3.\n\nThere are five subsequences with length 2: 1,1 and 1,2 and 1,3 and 2,1 and 2,3.\n\nThere are four subsequences with length 3: 1,1,3 and 1,2,1 and 1,2,3 and 2,1,3.\n\nThere is one subsequence with length 4: 1,2,1,3.\n\nSample Input 2\n\n1\n1 1\n\nSample Output 2\n\n1\n1\n\nThere is one subsequence with length 1: 1.\n\nThere is one subsequence with length 2: 1,1.\n\nSample Input 3\n\n32\n29 19 7 10 26 32 27 4 11 20 2 8 16 23 5 14 6 12 17 22 18 30 28 24 15 1 25 3 13 21 19 31 9\n\nSample Output 3\n\n32\n525\n5453\n40919\n237336\n1107568\n4272048\n13884156\n38567100\n92561040\n193536720\n354817320\n573166440\n818809200\n37158313\n166803103\n166803103\n37158313\n818809200\n573166440\n354817320\n193536720\n92561040\n38567100\n13884156\n4272048\n1107568\n237336\n40920\n5456\n528\n33\n1\n\nBe sure to print the numbers modulo 10^9+7.", "sample_input": "3\n1 2 1 3\n"}, "reference_outputs": ["3\n5\n4\n1\n"], "source_document_id": "p03674", "source_text": "Score : 600 points\n\nProblem Statement\n\nYou are given an integer sequence of length n+1, a_1,a_2,...,a_{n+1}, which consists of the n integers 1,...,n.\nIt is known that each of the n integers 1,...,n appears at least once in this sequence.\n\nFor each integer k=1,...,n+1, find the number of the different subsequences (not necessarily contiguous) of the given sequence with length k, modulo 10^9+7.\n\nNotes\n\nIf the contents of two subsequences are the same, they are not separately counted even if they originate from different positions in the original sequence.\n\nA 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. For example, the sequences 1,3,5 and 1,2,3 are subsequences of 1,2,3,4,5, while 3,1,2 and 1,10,100 are not.\n\nConstraints\n\n1 \\leq n \\leq 10^5\n\n1 \\leq a_i \\leq n\n\nEach of the integers 1,...,n appears in the sequence.\n\nn and a_i are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nn\na_1 a_2 ... a_{n+1}\n\nOutput\n\nPrint n+1 lines.\nThe k-th line should contain the number of the different subsequences of the given sequence with length k, modulo 10^9+7.\n\nSample Input 1\n\n3\n1 2 1 3\n\nSample Output 1\n\n3\n5\n4\n1\n\nThere are three subsequences with length 1: 1 and 2 and 3.\n\nThere are five subsequences with length 2: 1,1 and 1,2 and 1,3 and 2,1 and 2,3.\n\nThere are four subsequences with length 3: 1,1,3 and 1,2,1 and 1,2,3 and 2,1,3.\n\nThere is one subsequence with length 4: 1,2,1,3.\n\nSample Input 2\n\n1\n1 1\n\nSample Output 2\n\n1\n1\n\nThere is one subsequence with length 1: 1.\n\nThere is one subsequence with length 2: 1,1.\n\nSample Input 3\n\n32\n29 19 7 10 26 32 27 4 11 20 2 8 16 23 5 14 6 12 17 22 18 30 28 24 15 1 25 3 13 21 19 31 9\n\nSample Output 3\n\n32\n525\n5453\n40919\n237336\n1107568\n4272048\n13884156\n38567100\n92561040\n193536720\n354817320\n573166440\n818809200\n37158313\n166803103\n166803103\n37158313\n818809200\n573166440\n354817320\n193536720\n92561040\n38567100\n13884156\n4272048\n1107568\n237336\n40920\n5456\n528\n33\n1\n\nBe sure to print the numbers modulo 10^9+7.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1623, "cpu_time_ms": 528, "memory_kb": 16220}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s281550715", "group_id": "codeNet:p03674", "input_text": "local mod = 1000000007\nlocal mfl = math.floor\n\nlocal function bmul(x, y)\n local x0, y0 = x % 31623, y % 31623\n local x1, y1 = mfl(x / 31623), mfl(y / 31623)\n return (x1 * y1 * 14122 + (x1 * y0 + x0 * y1) * 31623 + x0 * y0) % mod\nend\n\nlocal function badd(x, y)\n return (x + y) % mod\nend\nlocal function bsub(x, y)\n return x < y and x - y + mod or x - y\nend\n\nlocal function modpow(src, pow)\n local res = 1\n while (0 < pow) do\n if (pow % 2 == 1) then\n res = bmul(res, src)\n pow = pow - 1\n end\n src = bmul(src, src)\n pow = mfl(pow / 2)\n end\n return res\nend\n\nlocal function modinv(src)\n return modpow(src, mod - 2)\nend\nlocal n = io.read(\"*n\")\nlocal invval = {}\nfor i = 1, n + 1 do\n invval[i] = modinv(i)\nend\n\nlocal function getComb(n, k)\n local ret = 1\n for i = 1, k do\n ret = bmul(ret, n + 1 - i)\n ret = bmul(ret, invval[i])\n end\n return ret\nend\n\nlocal a = {}\nfor i = 1, n + 1 do a[i] = io.read(\"*n\") end\nlocal t = {}\nlocal midcnt = 0\nfor i = 1, n + 1 do\n if t[a[i]] then\n midcnt = i - t[a[i]] - 1\n break\n else\n t[a[i]] = i\n end\nend\n\nif n == 1 then\n print(\"1\\n1\")\nelse\n for i = 1, n + 1 do\n local ret = 0\n -- case 0\n if i < n then\n ret = badd(ret, getComb(n - 1, i))\n end\n -- case 1\n if i <= n then\n local all = getComb(n - 1, i - 1)\n local without_mid = 0\n if i <= n - midcnt then\n without_mid = getComb(n - 1 - midcnt, i - 1)\n end\n local with_mid = bsub(all, without_mid)\n ret = badd(ret, without_mid)\n ret = badd(ret, (with_mid * 2) % mod)\n end\n -- case 2\n if 1 < i then\n ret = badd(ret, getComb(n - 1, i - 2))\n end\n print(ret)\n end\nend\n", "language": "Lua", "metadata": {"date": 1567221196, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p03674.html", "problem_id": "p03674", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03674/input.txt", "sample_output_relpath": "derived/input_output/data/p03674/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03674/Lua/s281550715.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s281550715", "user_id": "u120582723"}, "prompt_components": {"gold_output": "3\n5\n4\n1\n", "input_to_evaluate": "local mod = 1000000007\nlocal mfl = math.floor\n\nlocal function bmul(x, y)\n local x0, y0 = x % 31623, y % 31623\n local x1, y1 = mfl(x / 31623), mfl(y / 31623)\n return (x1 * y1 * 14122 + (x1 * y0 + x0 * y1) * 31623 + x0 * y0) % mod\nend\n\nlocal function badd(x, y)\n return (x + y) % mod\nend\nlocal function bsub(x, y)\n return x < y and x - y + mod or x - y\nend\n\nlocal function modpow(src, pow)\n local res = 1\n while (0 < pow) do\n if (pow % 2 == 1) then\n res = bmul(res, src)\n pow = pow - 1\n end\n src = bmul(src, src)\n pow = mfl(pow / 2)\n end\n return res\nend\n\nlocal function modinv(src)\n return modpow(src, mod - 2)\nend\nlocal n = io.read(\"*n\")\nlocal invval = {}\nfor i = 1, n + 1 do\n invval[i] = modinv(i)\nend\n\nlocal function getComb(n, k)\n local ret = 1\n for i = 1, k do\n ret = bmul(ret, n + 1 - i)\n ret = bmul(ret, invval[i])\n end\n return ret\nend\n\nlocal a = {}\nfor i = 1, n + 1 do a[i] = io.read(\"*n\") end\nlocal t = {}\nlocal midcnt = 0\nfor i = 1, n + 1 do\n if t[a[i]] then\n midcnt = i - t[a[i]] - 1\n break\n else\n t[a[i]] = i\n end\nend\n\nif n == 1 then\n print(\"1\\n1\")\nelse\n for i = 1, n + 1 do\n local ret = 0\n -- case 0\n if i < n then\n ret = badd(ret, getComb(n - 1, i))\n end\n -- case 1\n if i <= n then\n local all = getComb(n - 1, i - 1)\n local without_mid = 0\n if i <= n - midcnt then\n without_mid = getComb(n - 1 - midcnt, i - 1)\n end\n local with_mid = bsub(all, without_mid)\n ret = badd(ret, without_mid)\n ret = badd(ret, (with_mid * 2) % mod)\n end\n -- case 2\n if 1 < i then\n ret = badd(ret, getComb(n - 1, i - 2))\n end\n print(ret)\n end\nend\n", "problem_context": "Score : 600 points\n\nProblem Statement\n\nYou are given an integer sequence of length n+1, a_1,a_2,...,a_{n+1}, which consists of the n integers 1,...,n.\nIt is known that each of the n integers 1,...,n appears at least once in this sequence.\n\nFor each integer k=1,...,n+1, find the number of the different subsequences (not necessarily contiguous) of the given sequence with length k, modulo 10^9+7.\n\nNotes\n\nIf the contents of two subsequences are the same, they are not separately counted even if they originate from different positions in the original sequence.\n\nA 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. For example, the sequences 1,3,5 and 1,2,3 are subsequences of 1,2,3,4,5, while 3,1,2 and 1,10,100 are not.\n\nConstraints\n\n1 \\leq n \\leq 10^5\n\n1 \\leq a_i \\leq n\n\nEach of the integers 1,...,n appears in the sequence.\n\nn and a_i are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nn\na_1 a_2 ... a_{n+1}\n\nOutput\n\nPrint n+1 lines.\nThe k-th line should contain the number of the different subsequences of the given sequence with length k, modulo 10^9+7.\n\nSample Input 1\n\n3\n1 2 1 3\n\nSample Output 1\n\n3\n5\n4\n1\n\nThere are three subsequences with length 1: 1 and 2 and 3.\n\nThere are five subsequences with length 2: 1,1 and 1,2 and 1,3 and 2,1 and 2,3.\n\nThere are four subsequences with length 3: 1,1,3 and 1,2,1 and 1,2,3 and 2,1,3.\n\nThere is one subsequence with length 4: 1,2,1,3.\n\nSample Input 2\n\n1\n1 1\n\nSample Output 2\n\n1\n1\n\nThere is one subsequence with length 1: 1.\n\nThere is one subsequence with length 2: 1,1.\n\nSample Input 3\n\n32\n29 19 7 10 26 32 27 4 11 20 2 8 16 23 5 14 6 12 17 22 18 30 28 24 15 1 25 3 13 21 19 31 9\n\nSample Output 3\n\n32\n525\n5453\n40919\n237336\n1107568\n4272048\n13884156\n38567100\n92561040\n193536720\n354817320\n573166440\n818809200\n37158313\n166803103\n166803103\n37158313\n818809200\n573166440\n354817320\n193536720\n92561040\n38567100\n13884156\n4272048\n1107568\n237336\n40920\n5456\n528\n33\n1\n\nBe sure to print the numbers modulo 10^9+7.", "sample_input": "3\n1 2 1 3\n"}, "reference_outputs": ["3\n5\n4\n1\n"], "source_document_id": "p03674", "source_text": "Score : 600 points\n\nProblem Statement\n\nYou are given an integer sequence of length n+1, a_1,a_2,...,a_{n+1}, which consists of the n integers 1,...,n.\nIt is known that each of the n integers 1,...,n appears at least once in this sequence.\n\nFor each integer k=1,...,n+1, find the number of the different subsequences (not necessarily contiguous) of the given sequence with length k, modulo 10^9+7.\n\nNotes\n\nIf the contents of two subsequences are the same, they are not separately counted even if they originate from different positions in the original sequence.\n\nA 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. For example, the sequences 1,3,5 and 1,2,3 are subsequences of 1,2,3,4,5, while 3,1,2 and 1,10,100 are not.\n\nConstraints\n\n1 \\leq n \\leq 10^5\n\n1 \\leq a_i \\leq n\n\nEach of the integers 1,...,n appears in the sequence.\n\nn and a_i are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nn\na_1 a_2 ... a_{n+1}\n\nOutput\n\nPrint n+1 lines.\nThe k-th line should contain the number of the different subsequences of the given sequence with length k, modulo 10^9+7.\n\nSample Input 1\n\n3\n1 2 1 3\n\nSample Output 1\n\n3\n5\n4\n1\n\nThere are three subsequences with length 1: 1 and 2 and 3.\n\nThere are five subsequences with length 2: 1,1 and 1,2 and 1,3 and 2,1 and 2,3.\n\nThere are four subsequences with length 3: 1,1,3 and 1,2,1 and 1,2,3 and 2,1,3.\n\nThere is one subsequence with length 4: 1,2,1,3.\n\nSample Input 2\n\n1\n1 1\n\nSample Output 2\n\n1\n1\n\nThere is one subsequence with length 1: 1.\n\nThere is one subsequence with length 2: 1,1.\n\nSample Input 3\n\n32\n29 19 7 10 26 32 27 4 11 20 2 8 16 23 5 14 6 12 17 22 18 30 28 24 15 1 25 3 13 21 19 31 9\n\nSample Output 3\n\n32\n525\n5453\n40919\n237336\n1107568\n4272048\n13884156\n38567100\n92561040\n193536720\n354817320\n573166440\n818809200\n37158313\n166803103\n166803103\n37158313\n818809200\n573166440\n354817320\n193536720\n92561040\n38567100\n13884156\n4272048\n1107568\n237336\n40920\n5456\n528\n33\n1\n\nBe sure to print the numbers modulo 10^9+7.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1678, "cpu_time_ms": 2103, "memory_kb": 4340}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s398273046", "group_id": "codeNet:p03679", "input_text": "x,a,b=io.read():match(\"(.+)%s(.+)%s(.+)\")\nif b-a<=0 then\n print(\"delicious\")\nelseif b-a <=x*1 then\n print(\"safe\")\nelse\n print(\"dangerous\")\nend", "language": "Lua", "metadata": {"date": 1551751723, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03679.html", "problem_id": "p03679", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03679/input.txt", "sample_output_relpath": "derived/input_output/data/p03679/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03679/Lua/s398273046.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s398273046", "user_id": "u837412668"}, "prompt_components": {"gold_output": "safe\n", "input_to_evaluate": "x,a,b=io.read():match(\"(.+)%s(.+)%s(.+)\")\nif b-a<=0 then\n print(\"delicious\")\nelseif b-a <=x*1 then\n print(\"safe\")\nelse\n print(\"dangerous\")\nend", "problem_context": "Score : 100 points\n\nProblem Statement\n\nTakahashi has a strong stomach. He never gets a stomachache from eating something whose \"best-by\" date is at most X days earlier.\nHe gets a stomachache if the \"best-by\" date of the food is X+1 or more days earlier, though.\n\nOther than that, he finds the food delicious if he eats it not later than the \"best-by\" date. Otherwise, he does not find it delicious.\n\nTakahashi bought some food A days before the \"best-by\" date, and ate it B days after he bought it.\n\nWrite a program that outputs delicious if he found it delicious, safe if he did not found it delicious but did not get a stomachache either, and dangerous if he got a stomachache.\n\nConstraints\n\n1 ≤ X,A,B ≤ 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX A B\n\nOutput\n\nPrint delicious if Takahashi found the food delicious; print safe if he neither found it delicious nor got a stomachache; print dangerous if he got a stomachache.\n\nSample Input 1\n\n4 3 6\n\nSample Output 1\n\nsafe\n\nHe ate the food three days after the \"best-by\" date. It was not delicious or harmful for him.\n\nSample Input 2\n\n6 5 1\n\nSample Output 2\n\ndelicious\n\nHe ate the food by the \"best-by\" date. It was delicious for him.\n\nSample Input 3\n\n3 7 12\n\nSample Output 3\n\ndangerous\n\nHe ate the food five days after the \"best-by\" date. It was harmful for him.", "sample_input": "4 3 6\n"}, "reference_outputs": ["safe\n"], "source_document_id": "p03679", "source_text": "Score : 100 points\n\nProblem Statement\n\nTakahashi has a strong stomach. He never gets a stomachache from eating something whose \"best-by\" date is at most X days earlier.\nHe gets a stomachache if the \"best-by\" date of the food is X+1 or more days earlier, though.\n\nOther than that, he finds the food delicious if he eats it not later than the \"best-by\" date. Otherwise, he does not find it delicious.\n\nTakahashi bought some food A days before the \"best-by\" date, and ate it B days after he bought it.\n\nWrite a program that outputs delicious if he found it delicious, safe if he did not found it delicious but did not get a stomachache either, and dangerous if he got a stomachache.\n\nConstraints\n\n1 ≤ X,A,B ≤ 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX A B\n\nOutput\n\nPrint delicious if Takahashi found the food delicious; print safe if he neither found it delicious nor got a stomachache; print dangerous if he got a stomachache.\n\nSample Input 1\n\n4 3 6\n\nSample Output 1\n\nsafe\n\nHe ate the food three days after the \"best-by\" date. It was not delicious or harmful for him.\n\nSample Input 2\n\n6 5 1\n\nSample Output 2\n\ndelicious\n\nHe ate the food by the \"best-by\" date. It was delicious for him.\n\nSample Input 3\n\n3 7 12\n\nSample Output 3\n\ndangerous\n\nHe ate the food five days after the \"best-by\" date. It was harmful for him.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 145, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s217565052", "group_id": "codeNet:p03680", "input_text": "local read = io.read\nlocal n = read(\"n\")\nlocal a = {}\nfor i = 1, n do\n\ta[i] = read(\"n\")\nend\n\nlocal has_shined = {}\nlocal function push_switch(light_num, push_times)\n\tif light_num == 2 then\n\t\treturn push_times\n\telseif has_shined[light_num] then\n\t\treturn -1\n\telse\n\t\thas_shined[light_num] = true\n\t\tpush_times = push_times + 1\n\t\treturn push_switch(a[light_num], push_times)\n\tend\nend\n\nprint(push_switch(1, 0))\n", "language": "Lua", "metadata": {"date": 1598491629, "filename_ext": "lua", "original_language": "Lua (Lua 5.3.5)", "problem_description_relpath": "problem_descriptions/p03680.html", "problem_id": "p03680", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03680/input.txt", "sample_output_relpath": "derived/input_output/data/p03680/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03680/Lua/s217565052.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s217565052", "user_id": "u793881115"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "local read = io.read\nlocal n = read(\"n\")\nlocal a = {}\nfor i = 1, n do\n\ta[i] = read(\"n\")\nend\n\nlocal has_shined = {}\nlocal function push_switch(light_num, push_times)\n\tif light_num == 2 then\n\t\treturn push_times\n\telseif has_shined[light_num] then\n\t\treturn -1\n\telse\n\t\thas_shined[light_num] = true\n\t\tpush_times = push_times + 1\n\t\treturn push_switch(a[light_num], push_times)\n\tend\nend\n\nprint(push_switch(1, 0))\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nTakahashi wants to gain muscle, and decides to work out at AtCoder Gym.\n\nThe exercise machine at the gym has N buttons, and exactly one of the buttons is lighten up.\nThese buttons are numbered 1 through N.\nWhen Button i is lighten up and you press it, the light is turned off, and then Button a_i will be lighten up. It is possible that i=a_i.\nWhen Button i is not lighten up, nothing will happen by pressing it.\n\nInitially, Button 1 is lighten up. Takahashi wants to quit pressing buttons when Button 2 is lighten up.\n\nDetermine whether this is possible. If the answer is positive, find the minimum number of times he needs to press buttons.\n\nConstraints\n\n2 ≤ N ≤ 10^5\n\n1 ≤ a_i ≤ N\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1\na_2\n:\na_N\n\nOutput\n\nPrint -1 if it is impossible to lighten up Button 2.\nOtherwise, print the minimum number of times we need to press buttons in order to lighten up Button 2.\n\nSample Input 1\n\n3\n3\n1\n2\n\nSample Output 1\n\n2\n\nPress Button 1, then Button 3.\n\nSample Input 2\n\n4\n3\n4\n1\n2\n\nSample Output 2\n\n-1\n\nPressing Button 1 lightens up Button 3, and vice versa, so Button 2 will never be lighten up.\n\nSample Input 3\n\n5\n3\n3\n4\n2\n4\n\nSample Output 3\n\n3", "sample_input": "3\n3\n1\n2\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03680", "source_text": "Score : 200 points\n\nProblem Statement\n\nTakahashi wants to gain muscle, and decides to work out at AtCoder Gym.\n\nThe exercise machine at the gym has N buttons, and exactly one of the buttons is lighten up.\nThese buttons are numbered 1 through N.\nWhen Button i is lighten up and you press it, the light is turned off, and then Button a_i will be lighten up. It is possible that i=a_i.\nWhen Button i is not lighten up, nothing will happen by pressing it.\n\nInitially, Button 1 is lighten up. Takahashi wants to quit pressing buttons when Button 2 is lighten up.\n\nDetermine whether this is possible. If the answer is positive, find the minimum number of times he needs to press buttons.\n\nConstraints\n\n2 ≤ N ≤ 10^5\n\n1 ≤ a_i ≤ N\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1\na_2\n:\na_N\n\nOutput\n\nPrint -1 if it is impossible to lighten up Button 2.\nOtherwise, print the minimum number of times we need to press buttons in order to lighten up Button 2.\n\nSample Input 1\n\n3\n3\n1\n2\n\nSample Output 1\n\n2\n\nPress Button 1, then Button 3.\n\nSample Input 2\n\n4\n3\n4\n1\n2\n\nSample Output 2\n\n-1\n\nPressing Button 1 lightens up Button 3, and vice versa, so Button 2 will never be lighten up.\n\nSample Input 3\n\n5\n3\n3\n4\n2\n4\n\nSample Output 3\n\n3", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 405, "cpu_time_ms": 49, "memory_kb": 8452}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s955358127", "group_id": "codeNet:p03681", "input_text": "local n,m=io.read(\"n\",\"n\")\nif math.abs(n-m)>=2 then\n print(0)\nelse\n local dog=1\n for i=1,n do\n dog=dog*i%1000000007\n end\n local ape=1\n for i=1,m do\n ape=ape*i%1000000007\n end\n print(n==m and 2*dog*ape%1000000007 or dog*ape%1000000007)\nend", "language": "Lua", "metadata": {"date": 1590497395, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03681.html", "problem_id": "p03681", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03681/input.txt", "sample_output_relpath": "derived/input_output/data/p03681/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03681/Lua/s955358127.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s955358127", "user_id": "u045238009"}, "prompt_components": {"gold_output": "8\n", "input_to_evaluate": "local n,m=io.read(\"n\",\"n\")\nif math.abs(n-m)>=2 then\n print(0)\nelse\n local dog=1\n for i=1,n do\n dog=dog*i%1000000007\n end\n local ape=1\n for i=1,m do\n ape=ape*i%1000000007\n end\n print(n==m and 2*dog*ape%1000000007 or dog*ape%1000000007)\nend", "problem_context": "Score : 300 points\n\nProblem Statement\n\nSnuke has N dogs and M monkeys. He wants them to line up in a row.\n\nAs a Japanese saying goes, these dogs and monkeys are on bad terms. (\"ken'en no naka\", literally \"the relationship of dogs and monkeys\", means a relationship of mutual hatred.) Snuke is trying to reconsile them, by arranging the animals so that there are neither two adjacent dogs nor two adjacent monkeys.\n\nHow many such arrangements there are? Find the count modulo 10^9+7 (since animals cannot understand numbers larger than that).\nHere, dogs and monkeys are both distinguishable. Also, two arrangements that result from reversing each other are distinguished.\n\nConstraints\n\n1 ≤ N,M ≤ 10^5\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\n\nOutput\n\nPrint the number of possible arrangements, modulo 10^9+7.\n\nSample Input 1\n\n2 2\n\nSample Output 1\n\n8\n\nWe will denote the dogs by A and B, and the monkeys by C and D. There are eight possible arrangements: ACBD, ADBC, BCAD, BDAC, CADB, CBDA, DACB and DBCA.\n\nSample Input 2\n\n3 2\n\nSample Output 2\n\n12\n\nSample Input 3\n\n1 8\n\nSample Output 3\n\n0\n\nSample Input 4\n\n100000 100000\n\nSample Output 4\n\n530123477", "sample_input": "2 2\n"}, "reference_outputs": ["8\n"], "source_document_id": "p03681", "source_text": "Score : 300 points\n\nProblem Statement\n\nSnuke has N dogs and M monkeys. He wants them to line up in a row.\n\nAs a Japanese saying goes, these dogs and monkeys are on bad terms. (\"ken'en no naka\", literally \"the relationship of dogs and monkeys\", means a relationship of mutual hatred.) Snuke is trying to reconsile them, by arranging the animals so that there are neither two adjacent dogs nor two adjacent monkeys.\n\nHow many such arrangements there are? Find the count modulo 10^9+7 (since animals cannot understand numbers larger than that).\nHere, dogs and monkeys are both distinguishable. Also, two arrangements that result from reversing each other are distinguished.\n\nConstraints\n\n1 ≤ N,M ≤ 10^5\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\n\nOutput\n\nPrint the number of possible arrangements, modulo 10^9+7.\n\nSample Input 1\n\n2 2\n\nSample Output 1\n\n8\n\nWe will denote the dogs by A and B, and the monkeys by C and D. There are eight possible arrangements: ACBD, ADBC, BCAD, BDAC, CADB, CBDA, DACB and DBCA.\n\nSample Input 2\n\n3 2\n\nSample Output 2\n\n12\n\nSample Input 3\n\n1 8\n\nSample Output 3\n\n0\n\nSample Input 4\n\n100000 100000\n\nSample Output 4\n\n530123477", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 276, "cpu_time_ms": 8, "memory_kb": 888}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s093925252", "group_id": "codeNet:p03682", "input_text": "local mmi, mab = math.min, math.abs\n\nlocal function uf_initialize(n)\n local parent = {}\n for i = 1, n do parent[i] = i end\n return parent\nend\n\nlocal function uf_findroot(idx, parent)\n while parent[idx] ~= idx do\n idx = parent[idx]\n end\n return idx\nend\n\nlocal function kruskal(n, line)\n -- line.c, line.i1, line.i2\n table.sort(line, function(a, b) return a.c < b.c end)\n local parent = uf_initialize(n)\n local totalcost = 0\n local used = 0\n local linenum = #line\n for i = 1, linenum do\n local c, i1, i2 = line[i].c, line[i].i1, line[i].i2\n local r1, r2 = uf_findroot(i1, parent), uf_findroot(i2, parent)\n parent[i1], parent[i2] = r1, r2\n if r1 ~= r2 then\n parent[r2] = r1\n parent[i2] = r1\n totalcost = totalcost + c\n used = used + 1\n if used == n - 1 then break end\n end\n end\n return totalcost\nend\n\nlocal n = io.read(\"*n\")\nlocal t = {}\nfor i = 1, n do\n local tbl = {}\n tbl.i, tbl.x , tbl.y = i, io.read(\"*n\", \"*n\")\n t[i] = tbl\nend\n\nlocal line = {}\n\ntable.sort(t, function(a, b) return a.x > b.x end)\nfor i = 1, n - 1 do\n local tmp = {}\n tmp.c = t[i].x - t[i + 1].x\n tmp.i1, tmp.i2 = t[i].i, t[i + 1].i\n table.insert(line, tmp)\nend\n\ntable.sort(t, function(a, b) return a.y > b.y end)\nfor i = 1, n - 1 do\n if t[i].y - t[i + 1].y < mab(t[i].x - t[i + 1].x) then\n local tmp = {}\n tmp.c = t[i].y - t[i + 1].y\n tmp.i1, tmp.i2 = t[i].i, t[i + 1].i\n table.insert(line, tmp)\n end\nend\n\nprint(kruskal(n, line))\n", "language": "Lua", "metadata": {"date": 1563159703, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p03682.html", "problem_id": "p03682", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03682/input.txt", "sample_output_relpath": "derived/input_output/data/p03682/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03682/Lua/s093925252.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s093925252", "user_id": "u120582723"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "local mmi, mab = math.min, math.abs\n\nlocal function uf_initialize(n)\n local parent = {}\n for i = 1, n do parent[i] = i end\n return parent\nend\n\nlocal function uf_findroot(idx, parent)\n while parent[idx] ~= idx do\n idx = parent[idx]\n end\n return idx\nend\n\nlocal function kruskal(n, line)\n -- line.c, line.i1, line.i2\n table.sort(line, function(a, b) return a.c < b.c end)\n local parent = uf_initialize(n)\n local totalcost = 0\n local used = 0\n local linenum = #line\n for i = 1, linenum do\n local c, i1, i2 = line[i].c, line[i].i1, line[i].i2\n local r1, r2 = uf_findroot(i1, parent), uf_findroot(i2, parent)\n parent[i1], parent[i2] = r1, r2\n if r1 ~= r2 then\n parent[r2] = r1\n parent[i2] = r1\n totalcost = totalcost + c\n used = used + 1\n if used == n - 1 then break end\n end\n end\n return totalcost\nend\n\nlocal n = io.read(\"*n\")\nlocal t = {}\nfor i = 1, n do\n local tbl = {}\n tbl.i, tbl.x , tbl.y = i, io.read(\"*n\", \"*n\")\n t[i] = tbl\nend\n\nlocal line = {}\n\ntable.sort(t, function(a, b) return a.x > b.x end)\nfor i = 1, n - 1 do\n local tmp = {}\n tmp.c = t[i].x - t[i + 1].x\n tmp.i1, tmp.i2 = t[i].i, t[i + 1].i\n table.insert(line, tmp)\nend\n\ntable.sort(t, function(a, b) return a.y > b.y end)\nfor i = 1, n - 1 do\n if t[i].y - t[i + 1].y < mab(t[i].x - t[i + 1].x) then\n local tmp = {}\n tmp.c = t[i].y - t[i + 1].y\n tmp.i1, tmp.i2 = t[i].i, t[i + 1].i\n table.insert(line, tmp)\n end\nend\n\nprint(kruskal(n, line))\n", "problem_context": "Score : 500 points\n\nProblem Statement\n\nThere are N towns on a plane. The i-th town is located at the coordinates (x_i,y_i). There may be more than one town at the same coordinates.\n\nYou can build a road between two towns at coordinates (a,b) and (c,d) for a cost of min(|a-c|,|b-d|) yen (the currency of Japan). It is not possible to build other types of roads.\n\nYour objective is to build roads so that it will be possible to travel between every pair of towns by traversing roads. At least how much money is necessary to achieve this?\n\nConstraints\n\n2 ≤ N ≤ 10^5\n\n0 ≤ x_i,y_i ≤ 10^9\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nx_1 y_1\nx_2 y_2\n:\nx_N y_N\n\nOutput\n\nPrint the minimum necessary amount of money in order to build roads so that it will be possible to travel between every pair of towns by traversing roads.\n\nSample Input 1\n\n3\n1 5\n3 9\n7 8\n\nSample Output 1\n\n3\n\nBuild a road between Towns 1 and 2, and another between Towns 2 and 3. The total cost is 2+1=3 yen.\n\nSample Input 2\n\n6\n8 3\n4 9\n12 19\n18 1\n13 5\n7 6\n\nSample Output 2\n\n8", "sample_input": "3\n1 5\n3 9\n7 8\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03682", "source_text": "Score : 500 points\n\nProblem Statement\n\nThere are N towns on a plane. The i-th town is located at the coordinates (x_i,y_i). There may be more than one town at the same coordinates.\n\nYou can build a road between two towns at coordinates (a,b) and (c,d) for a cost of min(|a-c|,|b-d|) yen (the currency of Japan). It is not possible to build other types of roads.\n\nYour objective is to build roads so that it will be possible to travel between every pair of towns by traversing roads. At least how much money is necessary to achieve this?\n\nConstraints\n\n2 ≤ N ≤ 10^5\n\n0 ≤ x_i,y_i ≤ 10^9\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nx_1 y_1\nx_2 y_2\n:\nx_N y_N\n\nOutput\n\nPrint the minimum necessary amount of money in order to build roads so that it will be possible to travel between every pair of towns by traversing roads.\n\nSample Input 1\n\n3\n1 5\n3 9\n7 8\n\nSample Output 1\n\n3\n\nBuild a road between Towns 1 and 2, and another between Towns 2 and 3. The total cost is 2+1=3 yen.\n\nSample Input 2\n\n6\n8 3\n4 9\n12 19\n18 1\n13 5\n7 6\n\nSample Output 2\n\n8", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1478, "cpu_time_ms": 889, "memory_kb": 51436}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s599416241", "group_id": "codeNet:p03686", "input_text": "local mma = math.max\nlocal mfl, mce, mmi = math.floor, math.ceil, math.min\n\nlocal AvlTree = {}\nAvlTree.makenode = function(self, val, parent)\n local i = self.box[#self.box]\n if not i then i = #self.v + 1\n else table.remove(self.box)\n end\n self.v[i], self.p[i] = val, parent\n self.lc[i], self.rc[i], self.l[i], self.r[i] = 0, 0, 1, 1\n return i\nend\nAvlTree.create = function(self, lessthan, n)\n self.lessthan = lessthan\n self.root = 1\n self.box = {}\n for i = n + 1, 2, -1 do table.insert(self.box, i) end\n -- value, leftCount, rightCount, left, right, parent\n self.v, self.lc, self.rc, self.l, self.r, self.p = {}, {}, {}, {}, {}, {}\n for i = 1, n + 1 do\n self.v[i], self.p[i] = 0, 1\n self.lc[i], self.rc[i], self.l[i], self.r[i] = 0, 0, 1, 1\n end\nend\n\nAvlTree.recalc = function(self, i)\n local kl, kr = self.l[i], self.r[i]\n if 1 < kl then self.lc[i] = 1 + mma(self.lc[kl], self.rc[kl])\n else self.lc[i] = 0\n end\n if 1 < kr then self.rc[i] = 1 + mma(self.lc[kr], self.rc[kr])\n else self.rc[i] = 0\n end\nend\nAvlTree.recalcAll = function(self, i)\n while 1 < i do\n self:recalc(i)\n i = self.p[i]\n end\nend\n\nAvlTree.rotR = function(self, parent)\n local granp, child = self.p[parent], self.l[parent]\n self.r[child], self.l[parent] = parent, self.r[child]\n self.p[child], self.p[parent] = granp, child\n self.p[self.l[parent]] = parent\n if 1 < granp then\n if self.l[granp] == parent then\n self.l[granp] = child\n else\n self.r[granp] = child\n end\n else\n self.root = child\n end\nend\n\nAvlTree.rotL = function(self, parent)\n local granp, child = self.p[parent], self.r[parent]\n self.l[child], self.r[parent] = parent, self.l[child]\n self.p[child], self.p[parent] = granp, child\n self.p[self.r[parent]] = parent\n if 1 < granp then\n if self.r[granp] == parent then\n self.r[granp] = child\n else\n self.l[granp] = child\n end\n else\n self.root = child\n end\nend\n\nAvlTree.rotLR = function(self, lparent, rparent)\n local sp, sl, sr = self.p, self.l, self.r\n local granp, d = sp[rparent], sr[lparent]\n sp[lparent], sr[lparent] = d, sl[d]\n sp[rparent], sl[rparent] = d, sr[d]\n sp[sl[d]], sp[sr[d]] = lparent, rparent\n sp[d], sl[d], sr[d] = granp, lparent, rparent\n if 1 < granp then\n if sr[granp] == rparent then sr[granp] = d\n else sl[granp] = d\n end\n else self.root = d\n end\nend\n\nAvlTree.rotRL = function(self, rparent, lparent)\n local sp, sl, sr = self.p, self.l, self.r\n local granp, d = sp[lparent], sl[rparent]\n sp[rparent], sl[rparent] = d, sr[d]\n sp[lparent], sr[lparent] = d, sl[d]\n sp[sr[d]], sp[sl[d]] = rparent, lparent\n sp[d], sr[d], sl[d] = granp, rparent, lparent\n if 1 < granp then\n if sl[granp] == lparent then sl[granp] = d\n else sr[granp] = d\n end\n else self.root = d\n end\nend\n\nAvlTree.empty = function(self) return self.root <= 1 end\n\nAvlTree.push = function(self, val)\n if self.root <= 1 then self.root = self:makenode(val, 1) return end\n local pos = self.root\n while true do\n if self.lessthan(val, self.v[pos]) then\n if 1 < self.l[pos] then\n pos = self.l[pos]\n else\n self.l[pos] = self:makenode(val, pos)\n pos = self.l[pos]\n break\n end\n else\n if 1 < self.r[pos] then\n pos = self.r[pos]\n else\n self.r[pos] = self:makenode(val, pos)\n pos = self.r[pos]\n break\n end\n end\n end\n while 1 < pos do\n local child, parent = pos, self.p[pos]\n if parent <= 1 then\n break\n end\n self:recalc(parent)\n local lcp_m_rcp = self.lc[parent] - self.rc[parent]\n if lcp_m_rcp % 2 ~= 0 then -- 1 or -1\n pos = parent\n elseif lcp_m_rcp == 2 then\n if self.lc[child] - 1 == self.rc[child] then\n self:rotR(parent)\n self:recalcAll(parent)\n else\n self:rotLR(child, parent)\n self:recalc(child)\n self:recalcAll(parent)\n end\n break\n elseif lcp_m_rcp == -2 then\n if self.rc[child] - 1 == self.lc[child] then\n self:rotL(parent)\n self:recalcAll(parent)\n else\n self:rotRL(child, parent)\n self:recalc(child)\n self:recalcAll(parent)\n end\n break\n else\n break\n end\n end\nend\n\nAvlTree.rmsub = function(self, node)\n while 1 < node do\n self:recalc(node)\n if self.lc[node] == self.rc[node] then\n node = self.p[node]\n elseif self.lc[node] + 1 == self.rc[node] then\n self:recalcAll(self.p[node])\n break\n else\n if self.lc[self.r[node]] == self.rc[self.r[node]] then\n self:rotL(node)\n self:recalcAll(node)\n break\n elseif self.lc[self.r[node]] + 1 == self.rc[self.r[node]] then\n local nr = self.r[node]\n self:rotL(node)\n self:recalc(node)\n node = nr\n else\n local nr = self.r[node]\n local nrl = self.l[nr]\n self:rotRL(nr, node)\n self:recalc(nr)\n self:recalc(node)\n node = nrl\n end\n end\n end\nend\n\nAvlTree.pop = function(self)\n local node = self.root\n while 1 < self.l[node] do\n node = self.l[node]\n end\n local v = self.v[node]\n local kp = self.p[node]\n self.p[self.r[node]] = kp\n if 1 < kp then\n self.l[kp] = self.r[node]\n self:rmsub(kp)\n else\n self.root = self.r[node]\n end\n table.insert(self.box, node)\n return v\nend\n\nAvlTree.new = function(lessthan, n)\n local obj = {}\n setmetatable(obj, {__index = AvlTree})\n obj:create(lessthan, n)\n return obj\nend\n\nlocal n, m = io.read(\"*n\", \"*n\")\nlocal ls, rs = {}, {}\nlocal used = {}\nlocal r_list = {}\nlocal l_list = {}\nfor i = 1, m do\n r_list[i] = {}\n l_list[i] = {}\nend\nfor i = 1, n do\n ls[i], rs[i] = io.read(\"*n\", \"*n\")\n used[i] = false\n if rs[i] <= m then\n table.insert(r_list[rs[i]], i)\n end\n if 0 < ls[i] then\n table.insert(l_list[ls[i]], i)\n end\nend\nlocal function small_l_is_fast(a, b)\n return ls[a] < ls[b]\nend\nlocal avl1 = AvlTree.new(small_l_is_fast, 1)\nlocal sit = 0\nlocal chair_used = {}\nfor i = 1, m do\n for j = 1, #r_list[i] do\n avl1:push(r_list[i][j])\n end\n if not avl1:empty() then\n local top = avl1:pop()\n sit = sit + 1\n used[top] = true\n chair_used[i] = true\n else\n chair_used[i] = false\n end\nend\nlocal rem = 0\nfor i = m, 1, -1 do\n for j = 1, #l_list[i] do\n local v = l_list[i][j]\n if not used[v] then\n rem = rem + 1\n end\n end\n if 0 < rem and not chair_used[i] then\n sit = sit + 1\n rem = rem - 1\n end\nend\nprint(n - sit)\n", "language": "Lua", "metadata": {"date": 1600616174, "filename_ext": "lua", "original_language": "Lua (LuaJIT 2.1.0)", "problem_description_relpath": "problem_descriptions/p03686.html", "problem_id": "p03686", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03686/input.txt", "sample_output_relpath": "derived/input_output/data/p03686/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03686/Lua/s599416241.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s599416241", "user_id": "u120582723"}, "prompt_components": {"gold_output": "0\n", "input_to_evaluate": "local mma = math.max\nlocal mfl, mce, mmi = math.floor, math.ceil, math.min\n\nlocal AvlTree = {}\nAvlTree.makenode = function(self, val, parent)\n local i = self.box[#self.box]\n if not i then i = #self.v + 1\n else table.remove(self.box)\n end\n self.v[i], self.p[i] = val, parent\n self.lc[i], self.rc[i], self.l[i], self.r[i] = 0, 0, 1, 1\n return i\nend\nAvlTree.create = function(self, lessthan, n)\n self.lessthan = lessthan\n self.root = 1\n self.box = {}\n for i = n + 1, 2, -1 do table.insert(self.box, i) end\n -- value, leftCount, rightCount, left, right, parent\n self.v, self.lc, self.rc, self.l, self.r, self.p = {}, {}, {}, {}, {}, {}\n for i = 1, n + 1 do\n self.v[i], self.p[i] = 0, 1\n self.lc[i], self.rc[i], self.l[i], self.r[i] = 0, 0, 1, 1\n end\nend\n\nAvlTree.recalc = function(self, i)\n local kl, kr = self.l[i], self.r[i]\n if 1 < kl then self.lc[i] = 1 + mma(self.lc[kl], self.rc[kl])\n else self.lc[i] = 0\n end\n if 1 < kr then self.rc[i] = 1 + mma(self.lc[kr], self.rc[kr])\n else self.rc[i] = 0\n end\nend\nAvlTree.recalcAll = function(self, i)\n while 1 < i do\n self:recalc(i)\n i = self.p[i]\n end\nend\n\nAvlTree.rotR = function(self, parent)\n local granp, child = self.p[parent], self.l[parent]\n self.r[child], self.l[parent] = parent, self.r[child]\n self.p[child], self.p[parent] = granp, child\n self.p[self.l[parent]] = parent\n if 1 < granp then\n if self.l[granp] == parent then\n self.l[granp] = child\n else\n self.r[granp] = child\n end\n else\n self.root = child\n end\nend\n\nAvlTree.rotL = function(self, parent)\n local granp, child = self.p[parent], self.r[parent]\n self.l[child], self.r[parent] = parent, self.l[child]\n self.p[child], self.p[parent] = granp, child\n self.p[self.r[parent]] = parent\n if 1 < granp then\n if self.r[granp] == parent then\n self.r[granp] = child\n else\n self.l[granp] = child\n end\n else\n self.root = child\n end\nend\n\nAvlTree.rotLR = function(self, lparent, rparent)\n local sp, sl, sr = self.p, self.l, self.r\n local granp, d = sp[rparent], sr[lparent]\n sp[lparent], sr[lparent] = d, sl[d]\n sp[rparent], sl[rparent] = d, sr[d]\n sp[sl[d]], sp[sr[d]] = lparent, rparent\n sp[d], sl[d], sr[d] = granp, lparent, rparent\n if 1 < granp then\n if sr[granp] == rparent then sr[granp] = d\n else sl[granp] = d\n end\n else self.root = d\n end\nend\n\nAvlTree.rotRL = function(self, rparent, lparent)\n local sp, sl, sr = self.p, self.l, self.r\n local granp, d = sp[lparent], sl[rparent]\n sp[rparent], sl[rparent] = d, sr[d]\n sp[lparent], sr[lparent] = d, sl[d]\n sp[sr[d]], sp[sl[d]] = rparent, lparent\n sp[d], sr[d], sl[d] = granp, rparent, lparent\n if 1 < granp then\n if sl[granp] == lparent then sl[granp] = d\n else sr[granp] = d\n end\n else self.root = d\n end\nend\n\nAvlTree.empty = function(self) return self.root <= 1 end\n\nAvlTree.push = function(self, val)\n if self.root <= 1 then self.root = self:makenode(val, 1) return end\n local pos = self.root\n while true do\n if self.lessthan(val, self.v[pos]) then\n if 1 < self.l[pos] then\n pos = self.l[pos]\n else\n self.l[pos] = self:makenode(val, pos)\n pos = self.l[pos]\n break\n end\n else\n if 1 < self.r[pos] then\n pos = self.r[pos]\n else\n self.r[pos] = self:makenode(val, pos)\n pos = self.r[pos]\n break\n end\n end\n end\n while 1 < pos do\n local child, parent = pos, self.p[pos]\n if parent <= 1 then\n break\n end\n self:recalc(parent)\n local lcp_m_rcp = self.lc[parent] - self.rc[parent]\n if lcp_m_rcp % 2 ~= 0 then -- 1 or -1\n pos = parent\n elseif lcp_m_rcp == 2 then\n if self.lc[child] - 1 == self.rc[child] then\n self:rotR(parent)\n self:recalcAll(parent)\n else\n self:rotLR(child, parent)\n self:recalc(child)\n self:recalcAll(parent)\n end\n break\n elseif lcp_m_rcp == -2 then\n if self.rc[child] - 1 == self.lc[child] then\n self:rotL(parent)\n self:recalcAll(parent)\n else\n self:rotRL(child, parent)\n self:recalc(child)\n self:recalcAll(parent)\n end\n break\n else\n break\n end\n end\nend\n\nAvlTree.rmsub = function(self, node)\n while 1 < node do\n self:recalc(node)\n if self.lc[node] == self.rc[node] then\n node = self.p[node]\n elseif self.lc[node] + 1 == self.rc[node] then\n self:recalcAll(self.p[node])\n break\n else\n if self.lc[self.r[node]] == self.rc[self.r[node]] then\n self:rotL(node)\n self:recalcAll(node)\n break\n elseif self.lc[self.r[node]] + 1 == self.rc[self.r[node]] then\n local nr = self.r[node]\n self:rotL(node)\n self:recalc(node)\n node = nr\n else\n local nr = self.r[node]\n local nrl = self.l[nr]\n self:rotRL(nr, node)\n self:recalc(nr)\n self:recalc(node)\n node = nrl\n end\n end\n end\nend\n\nAvlTree.pop = function(self)\n local node = self.root\n while 1 < self.l[node] do\n node = self.l[node]\n end\n local v = self.v[node]\n local kp = self.p[node]\n self.p[self.r[node]] = kp\n if 1 < kp then\n self.l[kp] = self.r[node]\n self:rmsub(kp)\n else\n self.root = self.r[node]\n end\n table.insert(self.box, node)\n return v\nend\n\nAvlTree.new = function(lessthan, n)\n local obj = {}\n setmetatable(obj, {__index = AvlTree})\n obj:create(lessthan, n)\n return obj\nend\n\nlocal n, m = io.read(\"*n\", \"*n\")\nlocal ls, rs = {}, {}\nlocal used = {}\nlocal r_list = {}\nlocal l_list = {}\nfor i = 1, m do\n r_list[i] = {}\n l_list[i] = {}\nend\nfor i = 1, n do\n ls[i], rs[i] = io.read(\"*n\", \"*n\")\n used[i] = false\n if rs[i] <= m then\n table.insert(r_list[rs[i]], i)\n end\n if 0 < ls[i] then\n table.insert(l_list[ls[i]], i)\n end\nend\nlocal function small_l_is_fast(a, b)\n return ls[a] < ls[b]\nend\nlocal avl1 = AvlTree.new(small_l_is_fast, 1)\nlocal sit = 0\nlocal chair_used = {}\nfor i = 1, m do\n for j = 1, #r_list[i] do\n avl1:push(r_list[i][j])\n end\n if not avl1:empty() then\n local top = avl1:pop()\n sit = sit + 1\n used[top] = true\n chair_used[i] = true\n else\n chair_used[i] = false\n end\nend\nlocal rem = 0\nfor i = m, 1, -1 do\n for j = 1, #l_list[i] do\n local v = l_list[i][j]\n if not used[v] then\n rem = rem + 1\n end\n end\n if 0 < rem and not chair_used[i] then\n sit = sit + 1\n rem = rem - 1\n end\nend\nprint(n - sit)\n", "problem_context": "Score : 1000 points\n\nProblem Statement\n\nThere are M chairs arranged in a line. The coordinate of the i-th chair (1 ≤ i ≤ M) is i.\n\nN people of the Takahashi clan played too much games, and they are all suffering from backaches. They need to sit in chairs and rest, but they are particular about which chairs they sit in. Specifically, the i-th person wishes to sit in a chair whose coordinate is not greater than L_i, or not less than R_i. Naturally, only one person can sit in the same chair.\n\nIt may not be possible for all of them to sit in their favorite chairs, if nothing is done.\nAoki, who cares for the health of the people of the Takahashi clan, decides to provide additional chairs so that all of them can sit in chairs at their favorite positions.\n\nAdditional chairs can be placed at arbitrary real coordinates. Find the minimum required number of additional chairs.\n\nConstraints\n\n1 ≤ N,M ≤ 2 × 10^5\n\n0 ≤ L_i < R_i ≤ M + 1(1 ≤ i ≤ N)\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nL_1 R_1\n:\nL_N R_N\n\nOutput\n\nPrint the minimum required number of additional chairs.\n\nSample Input 1\n\n4 4\n0 3\n2 3\n1 3\n3 4\n\nSample Output 1\n\n0\n\nThe four people can sit in chairs at the coordinates 3, 2, 1 and 4, respectively, and no more chair is needed.\n\nSample Input 2\n\n7 6\n0 7\n1 5\n3 6\n2 7\n1 6\n2 6\n3 7\n\nSample Output 2\n\n2\n\nIf we place additional chairs at the coordinates 0 and 2.5, the seven people can sit at coordinates 0, 5, 3, 2, 6, 1 and 2.5, respectively.\n\nSample Input 3\n\n3 1\n1 2\n1 2\n1 2\n\nSample Output 3\n\n2\n\nSample Input 4\n\n6 6\n1 6\n1 6\n1 5\n1 5\n2 6\n2 6\n\nSample Output 4\n\n2", "sample_input": "4 4\n0 3\n2 3\n1 3\n3 4\n"}, "reference_outputs": ["0\n"], "source_document_id": "p03686", "source_text": "Score : 1000 points\n\nProblem Statement\n\nThere are M chairs arranged in a line. The coordinate of the i-th chair (1 ≤ i ≤ M) is i.\n\nN people of the Takahashi clan played too much games, and they are all suffering from backaches. They need to sit in chairs and rest, but they are particular about which chairs they sit in. Specifically, the i-th person wishes to sit in a chair whose coordinate is not greater than L_i, or not less than R_i. Naturally, only one person can sit in the same chair.\n\nIt may not be possible for all of them to sit in their favorite chairs, if nothing is done.\nAoki, who cares for the health of the people of the Takahashi clan, decides to provide additional chairs so that all of them can sit in chairs at their favorite positions.\n\nAdditional chairs can be placed at arbitrary real coordinates. Find the minimum required number of additional chairs.\n\nConstraints\n\n1 ≤ N,M ≤ 2 × 10^5\n\n0 ≤ L_i < R_i ≤ M + 1(1 ≤ i ≤ N)\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nL_1 R_1\n:\nL_N R_N\n\nOutput\n\nPrint the minimum required number of additional chairs.\n\nSample Input 1\n\n4 4\n0 3\n2 3\n1 3\n3 4\n\nSample Output 1\n\n0\n\nThe four people can sit in chairs at the coordinates 3, 2, 1 and 4, respectively, and no more chair is needed.\n\nSample Input 2\n\n7 6\n0 7\n1 5\n3 6\n2 7\n1 6\n2 6\n3 7\n\nSample Output 2\n\n2\n\nIf we place additional chairs at the coordinates 0 and 2.5, the seven people can sit at coordinates 0, 5, 3, 2, 6, 1 and 2.5, respectively.\n\nSample Input 3\n\n3 1\n1 2\n1 2\n1 2\n\nSample Output 3\n\n2\n\nSample Input 4\n\n6 6\n1 6\n1 6\n1 5\n1 5\n2 6\n2 6\n\nSample Output 4\n\n2", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 6436, "cpu_time_ms": 436, "memory_kb": 47908}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s846859449", "group_id": "codeNet:p03693", "input_text": "r,_,g,_,b=io.read(1,1,1,1,1)\nprint(tonumber(r..g..b)%4==0 and\"YES\"or\"NO\")", "language": "Lua", "metadata": {"date": 1570836446, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03693.html", "problem_id": "p03693", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03693/input.txt", "sample_output_relpath": "derived/input_output/data/p03693/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03693/Lua/s846859449.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s846859449", "user_id": "u162773977"}, "prompt_components": {"gold_output": "YES\n", "input_to_evaluate": "r,_,g,_,b=io.read(1,1,1,1,1)\nprint(tonumber(r..g..b)%4==0 and\"YES\"or\"NO\")", "problem_context": "Score : 100 points\n\nProblem Statement\n\nAtCoDeer has three cards, one red, one green and one blue.\n\nAn integer between 1 and 9 (inclusive) is written on each card: r on the red card, g on the green card and b on the blue card.\n\nWe will arrange the cards in the order red, green and blue from left to right, and read them as a three-digit integer.\n\nIs this integer a multiple of 4?\n\nConstraints\n\n1 ≤ r, g, b ≤ 9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nr g b\n\nOutput\n\nIf the three-digit integer is a multiple of 4, print YES (case-sensitive); otherwise, print NO.\n\nSample Input 1\n\n4 3 2\n\nSample Output 1\n\nYES\n\n432 is a multiple of 4, and thus YES should be printed.\n\nSample Input 2\n\n2 3 4\n\nSample Output 2\n\nNO\n\n234 is not a multiple of 4, and thus NO should be printed.", "sample_input": "4 3 2\n"}, "reference_outputs": ["YES\n"], "source_document_id": "p03693", "source_text": "Score : 100 points\n\nProblem Statement\n\nAtCoDeer has three cards, one red, one green and one blue.\n\nAn integer between 1 and 9 (inclusive) is written on each card: r on the red card, g on the green card and b on the blue card.\n\nWe will arrange the cards in the order red, green and blue from left to right, and read them as a three-digit integer.\n\nIs this integer a multiple of 4?\n\nConstraints\n\n1 ≤ r, g, b ≤ 9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nr g b\n\nOutput\n\nIf the three-digit integer is a multiple of 4, print YES (case-sensitive); otherwise, print NO.\n\nSample Input 1\n\n4 3 2\n\nSample Output 1\n\nYES\n\n432 is a multiple of 4, and thus YES should be printed.\n\nSample Input 2\n\n2 3 4\n\nSample Output 2\n\nNO\n\n234 is not a multiple of 4, and thus NO should be printed.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 73, "cpu_time_ms": 4, "memory_kb": 636}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s361895928", "group_id": "codeNet:p03695", "input_text": "n=io.read(\"*n\",\"*l\")\nt={0,0,0,0,0,0,0,0,0}\nfor i=1,n do\n rate=io.read(\"*n\")//400\n if rate>=8 then\n rate=8\n t[rate]=t[rate]+1\n else\n t[rate]=1\n end\nend\n\ncolormin=1\ncolormax=0\nfor rate,v in pairs(t) do\n if rate~=8 then\n colormin=colormin+v\n end\n colormax=colormax+v\nend\nprint(colormin,colormax)", "language": "Lua", "metadata": {"date": 1589057686, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03695.html", "problem_id": "p03695", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03695/input.txt", "sample_output_relpath": "derived/input_output/data/p03695/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03695/Lua/s361895928.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s361895928", "user_id": "u045238009"}, "prompt_components": {"gold_output": "2 2\n", "input_to_evaluate": "n=io.read(\"*n\",\"*l\")\nt={0,0,0,0,0,0,0,0,0}\nfor i=1,n do\n rate=io.read(\"*n\")//400\n if rate>=8 then\n rate=8\n t[rate]=t[rate]+1\n else\n t[rate]=1\n end\nend\n\ncolormin=1\ncolormax=0\nfor rate,v in pairs(t) do\n if rate~=8 then\n colormin=colormin+v\n end\n colormax=colormax+v\nend\nprint(colormin,colormax)", "problem_context": "Score : 300 points\n\nProblem Statement\n\nIn AtCoder, a person who has participated in a contest receives a color, which corresponds to the person's rating as follows:\n\nRating 1-399 : gray\n\nRating 400-799 : brown\n\nRating 800-1199 : green\n\nRating 1200-1599 : cyan\n\nRating 1600-1999 : blue\n\nRating 2000-2399 : yellow\n\nRating 2400-2799 : orange\n\nRating 2800-3199 : red\n\nOther than the above, a person whose rating is 3200 or higher can freely pick his/her color, which can be one of the eight colors above or not.\n\nCurrently, there are N users who have participated in a contest in AtCoder, and the i-th user has a rating of a_i.\n\nFind the minimum and maximum possible numbers of different colors of the users.\n\nConstraints\n\n1 ≤ N ≤ 100\n\n1 ≤ a_i ≤ 4800\n\na_i is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 ... a_N\n\nOutput\n\nPrint the minimum possible number of different colors of the users, and the maximum possible number of different colors, with a space in between.\n\nSample Input 1\n\n4\n2100 2500 2700 2700\n\nSample Output 1\n\n2 2\n\nThe user with rating 2100 is \"yellow\", and the others are \"orange\". There are two different colors.\n\nSample Input 2\n\n5\n1100 1900 2800 3200 3200\n\nSample Output 2\n\n3 5\n\nThe user with rating 1100 is \"green\", the user with rating 1900 is blue and the user with rating 2800 is \"red\".\n\nIf the fourth user picks \"red\", and the fifth user picks \"blue\", there are three different colors. This is one possible scenario for the minimum number of colors.\n\nIf the fourth user picks \"purple\", and the fifth user picks \"black\", there are five different colors. This is one possible scenario for the maximum number of colors.\n\nSample Input 3\n\n20\n800 810 820 830 840 850 860 870 880 890 900 910 920 930 940 950 960 970 980 990\n\nSample Output 3\n\n1 1\n\nAll the users are \"green\", and thus there is one color.", "sample_input": "4\n2100 2500 2700 2700\n"}, "reference_outputs": ["2 2\n"], "source_document_id": "p03695", "source_text": "Score : 300 points\n\nProblem Statement\n\nIn AtCoder, a person who has participated in a contest receives a color, which corresponds to the person's rating as follows:\n\nRating 1-399 : gray\n\nRating 400-799 : brown\n\nRating 800-1199 : green\n\nRating 1200-1599 : cyan\n\nRating 1600-1999 : blue\n\nRating 2000-2399 : yellow\n\nRating 2400-2799 : orange\n\nRating 2800-3199 : red\n\nOther than the above, a person whose rating is 3200 or higher can freely pick his/her color, which can be one of the eight colors above or not.\n\nCurrently, there are N users who have participated in a contest in AtCoder, and the i-th user has a rating of a_i.\n\nFind the minimum and maximum possible numbers of different colors of the users.\n\nConstraints\n\n1 ≤ N ≤ 100\n\n1 ≤ a_i ≤ 4800\n\na_i is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 ... a_N\n\nOutput\n\nPrint the minimum possible number of different colors of the users, and the maximum possible number of different colors, with a space in between.\n\nSample Input 1\n\n4\n2100 2500 2700 2700\n\nSample Output 1\n\n2 2\n\nThe user with rating 2100 is \"yellow\", and the others are \"orange\". There are two different colors.\n\nSample Input 2\n\n5\n1100 1900 2800 3200 3200\n\nSample Output 2\n\n3 5\n\nThe user with rating 1100 is \"green\", the user with rating 1900 is blue and the user with rating 2800 is \"red\".\n\nIf the fourth user picks \"red\", and the fifth user picks \"blue\", there are three different colors. This is one possible scenario for the minimum number of colors.\n\nIf the fourth user picks \"purple\", and the fifth user picks \"black\", there are five different colors. This is one possible scenario for the maximum number of colors.\n\nSample Input 3\n\n20\n800 810 820 830 840 850 860 870 880 890 900 910 920 930 940 950 960 970 980 990\n\nSample Output 3\n\n1 1\n\nAll the users are \"green\", and thus there is one color.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 341, "cpu_time_ms": 7, "memory_kb": 760}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s947059577", "group_id": "codeNet:p03696", "input_text": "local n=io.read(\"n\",\"l\")\nlocal s=io.read()\nlocal t=s:gsub(\"%b()\",\"\")\nlocal l,r=0,0\nfor i=1,#t do\n if t:sub(i,i)==\")\" then\n l=l+1\n else\n r=r+1\n end\nend\nprint(string.rep(\"(\",l)..s..string.rep(\")\",r))\n", "language": "Lua", "metadata": {"date": 1593098684, "filename_ext": "lua", "original_language": "Lua (LuaJIT 2.1.0)", "problem_description_relpath": "problem_descriptions/p03696.html", "problem_id": "p03696", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03696/input.txt", "sample_output_relpath": "derived/input_output/data/p03696/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03696/Lua/s947059577.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s947059577", "user_id": "u045238009"}, "prompt_components": {"gold_output": "(())\n", "input_to_evaluate": "local n=io.read(\"n\",\"l\")\nlocal s=io.read()\nlocal t=s:gsub(\"%b()\",\"\")\nlocal l,r=0,0\nfor i=1,#t do\n if t:sub(i,i)==\")\" then\n l=l+1\n else\n r=r+1\n end\nend\nprint(string.rep(\"(\",l)..s..string.rep(\")\",r))\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nYou are given a string S of length N consisting of ( and ). Your task is to insert some number of ( and ) into S to obtain a correct bracket sequence.\n\nHere, a correct bracket sequence is defined as follows:\n\n() is a correct bracket sequence.\n\nIf X is a correct bracket sequence, the concatenation of (, X and ) in this order is also a correct bracket sequence.\n\nIf X and Y are correct bracket sequences, the concatenation of X and Y in this order is also a correct bracket sequence.\n\nEvery correct bracket sequence can be derived from the rules above.\n\nFind the shortest correct bracket sequence that can be obtained. If there is more than one such sequence, find the lexicographically smallest one.\n\nConstraints\n\nThe length of S is N.\n\n1 ≤ N ≤ 100\n\nS consists of ( and ).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS\n\nOutput\n\nPrint the lexicographically smallest string among the shortest correct bracket sequences that can be obtained by inserting some number of ( and ) into S.\n\nSample Input 1\n\n3\n())\n\nSample Output 1\n\n(())\n\nSample Input 2\n\n6\n)))())\n\nSample Output 2\n\n(((()))())\n\nSample Input 3\n\n8\n))))((((\n\nSample Output 3\n\n(((())))(((())))", "sample_input": "3\n())\n"}, "reference_outputs": ["(())\n"], "source_document_id": "p03696", "source_text": "Score : 400 points\n\nProblem Statement\n\nYou are given a string S of length N consisting of ( and ). Your task is to insert some number of ( and ) into S to obtain a correct bracket sequence.\n\nHere, a correct bracket sequence is defined as follows:\n\n() is a correct bracket sequence.\n\nIf X is a correct bracket sequence, the concatenation of (, X and ) in this order is also a correct bracket sequence.\n\nIf X and Y are correct bracket sequences, the concatenation of X and Y in this order is also a correct bracket sequence.\n\nEvery correct bracket sequence can be derived from the rules above.\n\nFind the shortest correct bracket sequence that can be obtained. If there is more than one such sequence, find the lexicographically smallest one.\n\nConstraints\n\nThe length of S is N.\n\n1 ≤ N ≤ 100\n\nS consists of ( and ).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS\n\nOutput\n\nPrint the lexicographically smallest string among the shortest correct bracket sequences that can be obtained by inserting some number of ( and ) into S.\n\nSample Input 1\n\n3\n())\n\nSample Output 1\n\n(())\n\nSample Input 2\n\n6\n)))())\n\nSample Output 2\n\n(((()))())\n\nSample Input 3\n\n8\n))))((((\n\nSample Output 3\n\n(((())))(((())))", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 221, "cpu_time_ms": 3, "memory_kb": 2776}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s264408051", "group_id": "codeNet:p03697", "input_text": "a, b = io.read(\"*n\", \"*n\")\nprint(a + b < 10 and a + b or \"error\")", "language": "Lua", "metadata": {"date": 1570793158, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03697.html", "problem_id": "p03697", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03697/input.txt", "sample_output_relpath": "derived/input_output/data/p03697/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03697/Lua/s264408051.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s264408051", "user_id": "u120582723"}, "prompt_components": {"gold_output": "9\n", "input_to_evaluate": "a, b = io.read(\"*n\", \"*n\")\nprint(a + b < 10 and a + b or \"error\")", "problem_context": "Score : 100 points\n\nProblem Statement\n\nYou are given two integers A and B as the input. Output the value of A + B.\n\nHowever, if A + B is 10 or greater, output error instead.\n\nConstraints\n\nA and B are integers.\n\n1 ≤ A, B ≤ 9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nIf A + B is 10 or greater, print the string error (case-sensitive); otherwise, print the value of A + B.\n\nSample Input 1\n\n6 3\n\nSample Output 1\n\n9\n\nSample Input 2\n\n6 4\n\nSample Output 2\n\nerror", "sample_input": "6 3\n"}, "reference_outputs": ["9\n"], "source_document_id": "p03697", "source_text": "Score : 100 points\n\nProblem Statement\n\nYou are given two integers A and B as the input. Output the value of A + B.\n\nHowever, if A + B is 10 or greater, output error instead.\n\nConstraints\n\nA and B are integers.\n\n1 ≤ A, B ≤ 9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nIf A + B is 10 or greater, print the string error (case-sensitive); otherwise, print the value of A + B.\n\nSample Input 1\n\n6 3\n\nSample Output 1\n\n9\n\nSample Input 2\n\n6 4\n\nSample Output 2\n\nerror", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 65, "cpu_time_ms": 9, "memory_kb": 760}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s368691321", "group_id": "codeNet:p03698", "input_text": "S = io.read()\nset = {}\nbool = false\nfor i = 1, #S do\n seq = string.sub(S, i, i)\n if set[seq] then\n bool = true\n break\n end\n set[seq] = true\nend\nprint(bool and \"no\" or \"yes\")", "language": "Lua", "metadata": {"date": 1587078944, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03698.html", "problem_id": "p03698", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03698/input.txt", "sample_output_relpath": "derived/input_output/data/p03698/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03698/Lua/s368691321.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s368691321", "user_id": "u045238009"}, "prompt_components": {"gold_output": "yes\n", "input_to_evaluate": "S = io.read()\nset = {}\nbool = false\nfor i = 1, #S do\n seq = string.sub(S, i, i)\n if set[seq] then\n bool = true\n break\n end\n set[seq] = true\nend\nprint(bool and \"no\" or \"yes\")", "problem_context": "Score : 200 points\n\nProblem Statement\n\nYou are given a string S consisting of lowercase English letters. Determine whether all the characters in S are different.\n\nConstraints\n\n2 ≤ |S| ≤ 26, where |S| denotes the length of S.\n\nS consists of lowercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nIf all the characters in S are different, print yes (case-sensitive); otherwise, print no.\n\nSample Input 1\n\nuncopyrightable\n\nSample Output 1\n\nyes\n\nSample Input 2\n\ndifferent\n\nSample Output 2\n\nno\n\nSample Input 3\n\nno\n\nSample Output 3\n\nyes", "sample_input": "uncopyrightable\n"}, "reference_outputs": ["yes\n"], "source_document_id": "p03698", "source_text": "Score : 200 points\n\nProblem Statement\n\nYou are given a string S consisting of lowercase English letters. Determine whether all the characters in S are different.\n\nConstraints\n\n2 ≤ |S| ≤ 26, where |S| denotes the length of S.\n\nS consists of lowercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nIf all the characters in S are different, print yes (case-sensitive); otherwise, print no.\n\nSample Input 1\n\nuncopyrightable\n\nSample Output 1\n\nyes\n\nSample Input 2\n\ndifferent\n\nSample Output 2\n\nno\n\nSample Input 3\n\nno\n\nSample Output 3\n\nyes", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 199, "cpu_time_ms": 8, "memory_kb": 760}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s311648126", "group_id": "codeNet:p03699", "input_text": "local min = 100\nlocal sum = 0\nlocal n = io.read(\"*n\")\nfor i = 1, n do\n local a = io.read(\"*n\")\n sum = sum + a\n if a % 10 ~= 0 then\n min = math.min(a, min)\n end\nend\nif sum % 10 ~= 0 then\n print(sum)\nelse\n if min == 100 then\n print(0)\n else\n print(sum - min)\n end\nend\n", "language": "Lua", "metadata": {"date": 1558982969, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p03699.html", "problem_id": "p03699", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03699/input.txt", "sample_output_relpath": "derived/input_output/data/p03699/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03699/Lua/s311648126.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s311648126", "user_id": "u120582723"}, "prompt_components": {"gold_output": "25\n", "input_to_evaluate": "local min = 100\nlocal sum = 0\nlocal n = io.read(\"*n\")\nfor i = 1, n do\n local a = io.read(\"*n\")\n sum = sum + a\n if a % 10 ~= 0 then\n min = math.min(a, min)\n end\nend\nif sum % 10 ~= 0 then\n print(sum)\nelse\n if min == 100 then\n print(0)\n else\n print(sum - min)\n end\nend\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nYou are taking a computer-based examination. The examination consists of N questions, and the score allocated to the i-th question is s_i. Your answer to each question will be judged as either \"correct\" or \"incorrect\", and your grade will be the sum of the points allocated to questions that are answered correctly. When you finish answering the questions, your answers will be immediately judged and your grade will be displayed... if everything goes well.\n\nHowever, the examination system is actually flawed, and if your grade is a multiple of 10, the system displays 0 as your grade. Otherwise, your grade is displayed correctly. In this situation, what is the maximum value that can be displayed as your grade?\n\nConstraints\n\nAll input values are integers.\n\n1 ≤ N ≤ 100\n\n1 ≤ s_i ≤ 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\ns_1\ns_2\n:\ns_N\n\nOutput\n\nPrint the maximum value that can be displayed as your grade.\n\nSample Input 1\n\n3\n5\n10\n15\n\nSample Output 1\n\n25\n\nYour grade will be 25 if the 10-point and 15-point questions are answered correctly and the 5-point question is not, and this grade will be displayed correctly. Your grade will become 30 if the 5-point question is also answered correctly, but this grade will be incorrectly displayed as 0.\n\nSample Input 2\n\n3\n10\n10\n15\n\nSample Output 2\n\n35\n\nYour grade will be 35 if all the questions are answered correctly, and this grade will be displayed correctly.\n\nSample Input 3\n\n3\n10\n20\n30\n\nSample Output 3\n\n0\n\nRegardless of whether each question is answered correctly or not, your grade will be a multiple of 10 and displayed as 0.", "sample_input": "3\n5\n10\n15\n"}, "reference_outputs": ["25\n"], "source_document_id": "p03699", "source_text": "Score : 300 points\n\nProblem Statement\n\nYou are taking a computer-based examination. The examination consists of N questions, and the score allocated to the i-th question is s_i. Your answer to each question will be judged as either \"correct\" or \"incorrect\", and your grade will be the sum of the points allocated to questions that are answered correctly. When you finish answering the questions, your answers will be immediately judged and your grade will be displayed... if everything goes well.\n\nHowever, the examination system is actually flawed, and if your grade is a multiple of 10, the system displays 0 as your grade. Otherwise, your grade is displayed correctly. In this situation, what is the maximum value that can be displayed as your grade?\n\nConstraints\n\nAll input values are integers.\n\n1 ≤ N ≤ 100\n\n1 ≤ s_i ≤ 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\ns_1\ns_2\n:\ns_N\n\nOutput\n\nPrint the maximum value that can be displayed as your grade.\n\nSample Input 1\n\n3\n5\n10\n15\n\nSample Output 1\n\n25\n\nYour grade will be 25 if the 10-point and 15-point questions are answered correctly and the 5-point question is not, and this grade will be displayed correctly. Your grade will become 30 if the 5-point question is also answered correctly, but this grade will be incorrectly displayed as 0.\n\nSample Input 2\n\n3\n10\n10\n15\n\nSample Output 2\n\n35\n\nYour grade will be 35 if all the questions are answered correctly, and this grade will be displayed correctly.\n\nSample Input 3\n\n3\n10\n20\n30\n\nSample Output 3\n\n0\n\nRegardless of whether each question is answered correctly or not, your grade will be a multiple of 10 and displayed as 0.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 283, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s410808003", "group_id": "codeNet:p03699", "input_text": "#!/usr/bin/env lua\n\nN = io.read(\"*num\")\n\ns = {}\nfor i=1, N do\n s[i] = io.read(\"*num\")\nend\n\nun = {}\ndata = {}\nfor i=1, N do\n un[i] = 0\n data[i] = 0\nend\n\nfor i=1, N do\n if s[i] % 10 == 0 then\n un[i] = s[i]\n else\n data[i] = s[i]\n end\nend\n\ndata_cnt = 0\nfor i = 1, N do\n if data[i] > 0 then\n data_cnt = data_cnt + 1\n end\nend\n\nsum = 0\nfor i = 1, N do\n sum = sum + s[i]\nend\n\nmin = 100\nfor i = 1, N do\n if min >= data[i] and data[i] >= 1 then\n min = data[i]\n end\nend\n\nif data_cnt == 0 then\n print(0)\nelse\n if sum % 10 ~= 0 then\n print(sum)\n else\n print(sum-min)\n end\nend", "language": "Lua", "metadata": {"date": 1496717036, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03699.html", "problem_id": "p03699", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03699/input.txt", "sample_output_relpath": "derived/input_output/data/p03699/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03699/Lua/s410808003.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s410808003", "user_id": "u678875535"}, "prompt_components": {"gold_output": "25\n", "input_to_evaluate": "#!/usr/bin/env lua\n\nN = io.read(\"*num\")\n\ns = {}\nfor i=1, N do\n s[i] = io.read(\"*num\")\nend\n\nun = {}\ndata = {}\nfor i=1, N do\n un[i] = 0\n data[i] = 0\nend\n\nfor i=1, N do\n if s[i] % 10 == 0 then\n un[i] = s[i]\n else\n data[i] = s[i]\n end\nend\n\ndata_cnt = 0\nfor i = 1, N do\n if data[i] > 0 then\n data_cnt = data_cnt + 1\n end\nend\n\nsum = 0\nfor i = 1, N do\n sum = sum + s[i]\nend\n\nmin = 100\nfor i = 1, N do\n if min >= data[i] and data[i] >= 1 then\n min = data[i]\n end\nend\n\nif data_cnt == 0 then\n print(0)\nelse\n if sum % 10 ~= 0 then\n print(sum)\n else\n print(sum-min)\n end\nend", "problem_context": "Score : 300 points\n\nProblem Statement\n\nYou are taking a computer-based examination. The examination consists of N questions, and the score allocated to the i-th question is s_i. Your answer to each question will be judged as either \"correct\" or \"incorrect\", and your grade will be the sum of the points allocated to questions that are answered correctly. When you finish answering the questions, your answers will be immediately judged and your grade will be displayed... if everything goes well.\n\nHowever, the examination system is actually flawed, and if your grade is a multiple of 10, the system displays 0 as your grade. Otherwise, your grade is displayed correctly. In this situation, what is the maximum value that can be displayed as your grade?\n\nConstraints\n\nAll input values are integers.\n\n1 ≤ N ≤ 100\n\n1 ≤ s_i ≤ 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\ns_1\ns_2\n:\ns_N\n\nOutput\n\nPrint the maximum value that can be displayed as your grade.\n\nSample Input 1\n\n3\n5\n10\n15\n\nSample Output 1\n\n25\n\nYour grade will be 25 if the 10-point and 15-point questions are answered correctly and the 5-point question is not, and this grade will be displayed correctly. Your grade will become 30 if the 5-point question is also answered correctly, but this grade will be incorrectly displayed as 0.\n\nSample Input 2\n\n3\n10\n10\n15\n\nSample Output 2\n\n35\n\nYour grade will be 35 if all the questions are answered correctly, and this grade will be displayed correctly.\n\nSample Input 3\n\n3\n10\n20\n30\n\nSample Output 3\n\n0\n\nRegardless of whether each question is answered correctly or not, your grade will be a multiple of 10 and displayed as 0.", "sample_input": "3\n5\n10\n15\n"}, "reference_outputs": ["25\n"], "source_document_id": "p03699", "source_text": "Score : 300 points\n\nProblem Statement\n\nYou are taking a computer-based examination. The examination consists of N questions, and the score allocated to the i-th question is s_i. Your answer to each question will be judged as either \"correct\" or \"incorrect\", and your grade will be the sum of the points allocated to questions that are answered correctly. When you finish answering the questions, your answers will be immediately judged and your grade will be displayed... if everything goes well.\n\nHowever, the examination system is actually flawed, and if your grade is a multiple of 10, the system displays 0 as your grade. Otherwise, your grade is displayed correctly. In this situation, what is the maximum value that can be displayed as your grade?\n\nConstraints\n\nAll input values are integers.\n\n1 ≤ N ≤ 100\n\n1 ≤ s_i ≤ 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\ns_1\ns_2\n:\ns_N\n\nOutput\n\nPrint the maximum value that can be displayed as your grade.\n\nSample Input 1\n\n3\n5\n10\n15\n\nSample Output 1\n\n25\n\nYour grade will be 25 if the 10-point and 15-point questions are answered correctly and the 5-point question is not, and this grade will be displayed correctly. Your grade will become 30 if the 5-point question is also answered correctly, but this grade will be incorrectly displayed as 0.\n\nSample Input 2\n\n3\n10\n10\n15\n\nSample Output 2\n\n35\n\nYour grade will be 35 if all the questions are answered correctly, and this grade will be displayed correctly.\n\nSample Input 3\n\n3\n10\n20\n30\n\nSample Output 3\n\n0\n\nRegardless of whether each question is answered correctly or not, your grade will be a multiple of 10 and displayed as 0.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 649, "cpu_time_ms": 11, "memory_kb": 1012}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s463168083", "group_id": "codeNet:p03703", "input_text": "local mfl, mce, mmi = math.floor, math.ceil, math.min\nlocal SegTree = {}\nSegTree.updateAll = function(self)\n for i = self.stagenum - 1, 1, -1 do\n for j = 1, self.cnt[i] do\n self.stage[i][j] = self.stage[i + 1][j * 2 - 1] + self.stage[i + 1][j * 2]\n end\n end\nend\nSegTree.create = function(self, n)\n self.emptyvalue = 0\n local stagenum, mul = 1, 1\n self.cnt, self.stage, self.size = {1}, {{}}, {}\n while mul < n do\n mul, stagenum = mul * 2, stagenum + 1\n self.cnt[stagenum], self.stage[stagenum] = mul, {}\n end\n for i = 1, stagenum do self.size[i] = self.cnt[stagenum + 1 - i] end\n self.stagenum = stagenum\n for i = 1, mul do self.stage[stagenum][i] = 0 end\n self:updateAll()\nend\nSegTree.getRange = function(self, left, right)\n if left == right then return self.stage[self.stagenum][left] end\n local start_stage = 1\n while right - left + 1 < self.size[start_stage] do\n start_stage = start_stage + 1\n end\n local ret = self.emptyvalue\n local tasks = {{start_stage, left, right}}\n while 0 < #tasks do\n local task = tasks[#tasks]\n table.remove(tasks)\n local stage, l, r = task[1], task[2], task[3]\n if (l - 1) % self.size[stage] ~= 0 then\n local newr = mce((l - 1) / self.size[stage]) * self.size[stage]\n table.insert(tasks, {stage + 1, l, mmi(r, newr)})\n l = newr + 1\n end\n if self.size[stage] <= r + 1 - l then\n local pos = mce(l / self.size[stage])\n ret = ret + self.stage[stage][pos]\n l = l + self.size[stage]\n end\n if l <= r then\n table.insert(tasks, {stage + 1, l, r})\n end\n end\n return ret\nend\nSegTree.decValue = function(self, idx)\n self.stage[self.stagenum][idx] = self.stage[self.stagenum][idx] - 1\n for i = self.stagenum - 1, 1, -1 do\n local dst = mce(idx / 2)\n local rem = dst * 4 - 1 - idx\n self.stage[i][dst] = self.stage[i + 1][idx] + self.stage[i + 1][rem]\n idx = dst\n end\nend\nSegTree.inc = function(self, idx)\n self.stage[self.stagenum][idx] = 1 + self.stage[self.stagenum][idx]\nend\nSegTree.new = function(n)\n local obj = {}\n setmetatable(obj, {__index = SegTree})\n obj:create(n)\n return obj\nend\n\nlocal n, k = io.read(\"*n\", \"*n\")\nlocal sum, conv = {}, {}\nsum[1] = {1, io.read(\"*n\") - k}\nfor i = 2, n do\n sum[i] = {i, sum[i - 1][2] + io.read(\"*n\") - k}\nend\nsum[n + 1] = {n + 1, 0}\ntable.sort(sum, function(x, y) return x[2] < y[2] end)\nlocal sumTypeCount = 1\nlocal sumTypeList = {}\nconv[sum[1][2]] = 1\nsumTypeList[1] = sum[1][2]\nfor i = 2, n + 1 do\n if sum[i][2] ~= sumTypeList[sumTypeCount] then\n sumTypeCount = sumTypeCount + 1\n conv[sum[i][2]] = sumTypeCount\n sumTypeList[sumTypeCount] = sum[i][2]\n end\nend\ntable.sort(sum, function(x, y) return x[1] < y[1] end)\nlocal segtree = SegTree.new(sumTypeCount)\nfor i = 1, n do\n sum[i] = sum[i][2]\n segtree:inc(conv[sum[i]])\nend\nsegtree:updateAll()\n\nlocal bias = 0\nlocal cnt = 0\nfor i = 1, n do\n local treeleft = conv[bias]\n if treeleft <= sumTypeCount then\n cnt = cnt + segtree:getRange(treeleft, sumTypeCount)\n end\n segtree:decValue(conv[sum[i]])\n bias = sum[i]\nend\nprint(cnt)\n", "language": "Lua", "metadata": {"date": 1564624706, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p03703.html", "problem_id": "p03703", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03703/input.txt", "sample_output_relpath": "derived/input_output/data/p03703/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03703/Lua/s463168083.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s463168083", "user_id": "u120582723"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "local mfl, mce, mmi = math.floor, math.ceil, math.min\nlocal SegTree = {}\nSegTree.updateAll = function(self)\n for i = self.stagenum - 1, 1, -1 do\n for j = 1, self.cnt[i] do\n self.stage[i][j] = self.stage[i + 1][j * 2 - 1] + self.stage[i + 1][j * 2]\n end\n end\nend\nSegTree.create = function(self, n)\n self.emptyvalue = 0\n local stagenum, mul = 1, 1\n self.cnt, self.stage, self.size = {1}, {{}}, {}\n while mul < n do\n mul, stagenum = mul * 2, stagenum + 1\n self.cnt[stagenum], self.stage[stagenum] = mul, {}\n end\n for i = 1, stagenum do self.size[i] = self.cnt[stagenum + 1 - i] end\n self.stagenum = stagenum\n for i = 1, mul do self.stage[stagenum][i] = 0 end\n self:updateAll()\nend\nSegTree.getRange = function(self, left, right)\n if left == right then return self.stage[self.stagenum][left] end\n local start_stage = 1\n while right - left + 1 < self.size[start_stage] do\n start_stage = start_stage + 1\n end\n local ret = self.emptyvalue\n local tasks = {{start_stage, left, right}}\n while 0 < #tasks do\n local task = tasks[#tasks]\n table.remove(tasks)\n local stage, l, r = task[1], task[2], task[3]\n if (l - 1) % self.size[stage] ~= 0 then\n local newr = mce((l - 1) / self.size[stage]) * self.size[stage]\n table.insert(tasks, {stage + 1, l, mmi(r, newr)})\n l = newr + 1\n end\n if self.size[stage] <= r + 1 - l then\n local pos = mce(l / self.size[stage])\n ret = ret + self.stage[stage][pos]\n l = l + self.size[stage]\n end\n if l <= r then\n table.insert(tasks, {stage + 1, l, r})\n end\n end\n return ret\nend\nSegTree.decValue = function(self, idx)\n self.stage[self.stagenum][idx] = self.stage[self.stagenum][idx] - 1\n for i = self.stagenum - 1, 1, -1 do\n local dst = mce(idx / 2)\n local rem = dst * 4 - 1 - idx\n self.stage[i][dst] = self.stage[i + 1][idx] + self.stage[i + 1][rem]\n idx = dst\n end\nend\nSegTree.inc = function(self, idx)\n self.stage[self.stagenum][idx] = 1 + self.stage[self.stagenum][idx]\nend\nSegTree.new = function(n)\n local obj = {}\n setmetatable(obj, {__index = SegTree})\n obj:create(n)\n return obj\nend\n\nlocal n, k = io.read(\"*n\", \"*n\")\nlocal sum, conv = {}, {}\nsum[1] = {1, io.read(\"*n\") - k}\nfor i = 2, n do\n sum[i] = {i, sum[i - 1][2] + io.read(\"*n\") - k}\nend\nsum[n + 1] = {n + 1, 0}\ntable.sort(sum, function(x, y) return x[2] < y[2] end)\nlocal sumTypeCount = 1\nlocal sumTypeList = {}\nconv[sum[1][2]] = 1\nsumTypeList[1] = sum[1][2]\nfor i = 2, n + 1 do\n if sum[i][2] ~= sumTypeList[sumTypeCount] then\n sumTypeCount = sumTypeCount + 1\n conv[sum[i][2]] = sumTypeCount\n sumTypeList[sumTypeCount] = sum[i][2]\n end\nend\ntable.sort(sum, function(x, y) return x[1] < y[1] end)\nlocal segtree = SegTree.new(sumTypeCount)\nfor i = 1, n do\n sum[i] = sum[i][2]\n segtree:inc(conv[sum[i]])\nend\nsegtree:updateAll()\n\nlocal bias = 0\nlocal cnt = 0\nfor i = 1, n do\n local treeleft = conv[bias]\n if treeleft <= sumTypeCount then\n cnt = cnt + segtree:getRange(treeleft, sumTypeCount)\n end\n segtree:decValue(conv[sum[i]])\n bias = sum[i]\nend\nprint(cnt)\n", "problem_context": "Score : 600 points\n\nProblem Statement\n\nYou are given an integer sequence of length N, a = {a_1, a_2, …, a_N}, and an integer K.\n\na has N(N+1)/2 non-empty contiguous subsequences, {a_l, a_{l+1}, …, a_r} (1 ≤ l ≤ r ≤ N). Among them, how many have an arithmetic mean that is greater than or equal to K?\n\nConstraints\n\nAll input values are integers.\n\n1 ≤ N ≤ 2 \\times 10^5\n\n1 ≤ K ≤ 10^9\n\n1 ≤ a_i ≤ 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\na_1\na_2\n:\na_N\n\nOutput\n\nPrint the number of the non-empty contiguous subsequences with an arithmetic mean that is greater than or equal to K.\n\nSample Input 1\n\n3 6\n7\n5\n7\n\nSample Output 1\n\n5\n\nAll the non-empty contiguous subsequences of a are listed below:\n\n{a_1} = {7}\n\n{a_1, a_2} = {7, 5}\n\n{a_1, a_2, a_3} = {7, 5, 7}\n\n{a_2} = {5}\n\n{a_2, a_3} = {5, 7}\n\n{a_3} = {7}\n\nTheir means are 7, 6, 19/3, 5, 6 and 7, respectively, and five among them are 6 or greater. Note that {a_1} and {a_3} are indistinguishable by the values of their elements, but we count them individually.\n\nSample Input 2\n\n1 2\n1\n\nSample Output 2\n\n0\n\nSample Input 3\n\n7 26\n10\n20\n30\n40\n30\n20\n10\n\nSample Output 3\n\n13", "sample_input": "3 6\n7\n5\n7\n"}, "reference_outputs": ["5\n"], "source_document_id": "p03703", "source_text": "Score : 600 points\n\nProblem Statement\n\nYou are given an integer sequence of length N, a = {a_1, a_2, …, a_N}, and an integer K.\n\na has N(N+1)/2 non-empty contiguous subsequences, {a_l, a_{l+1}, …, a_r} (1 ≤ l ≤ r ≤ N). Among them, how many have an arithmetic mean that is greater than or equal to K?\n\nConstraints\n\nAll input values are integers.\n\n1 ≤ N ≤ 2 \\times 10^5\n\n1 ≤ K ≤ 10^9\n\n1 ≤ a_i ≤ 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\na_1\na_2\n:\na_N\n\nOutput\n\nPrint the number of the non-empty contiguous subsequences with an arithmetic mean that is greater than or equal to K.\n\nSample Input 1\n\n3 6\n7\n5\n7\n\nSample Output 1\n\n5\n\nAll the non-empty contiguous subsequences of a are listed below:\n\n{a_1} = {7}\n\n{a_1, a_2} = {7, 5}\n\n{a_1, a_2, a_3} = {7, 5, 7}\n\n{a_2} = {5}\n\n{a_2, a_3} = {5, 7}\n\n{a_3} = {7}\n\nTheir means are 7, 6, 19/3, 5, 6 and 7, respectively, and five among them are 6 or greater. Note that {a_1} and {a_3} are indistinguishable by the values of their elements, but we count them individually.\n\nSample Input 2\n\n1 2\n1\n\nSample Output 2\n\n0\n\nSample Input 3\n\n7 26\n10\n20\n30\n40\n30\n20\n10\n\nSample Output 3\n\n13", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 3078, "cpu_time_ms": 1892, "memory_kb": 55816}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s713123361", "group_id": "codeNet:p03703", "input_text": "local mfl, mce, mmi = math.floor, math.ceil, math.min\nlocal SegTree = {}\nSegTree.updateAll = function(self)\n for i = self.stagenum - 1, 1, -1 do\n for j = 1, self.cnt[i] do\n self.stage[i][j] = self.func(self.stage[i + 1][j * 2 - 1], self.stage[i + 1][j * 2])\n end\n end\nend\nSegTree.create = function(self, ary, func, emptyvalue)\n self.func, self.emptyvalue = func, emptyvalue\n local stagenum, mul = 1, 1\n self.cnt, self.stage, self.size = {1}, {{}}, {}\n while mul < #ary do\n mul, stagenum = mul * 2, stagenum + 1\n self.cnt[stagenum], self.stage[stagenum] = mul, {}\n end\n for i = 1, stagenum do self.size[i] = self.cnt[stagenum + 1 - i] end\n self.stagenum = stagenum\n for i = 1, #ary do self.stage[stagenum][i] = ary[i] end\n for i = #ary + 1, mul do self.stage[stagenum][i] = emptyvalue end\n self:updateAll()\nend\nSegTree.getRange = function(self, left, right)\n if left == right then return self.stage[self.stagenum][left] end\n local start_stage = 1\n while right - left + 1 < self.size[start_stage] do\n start_stage = start_stage + 1\n end\n local ret = self.emptyvalue\n local tasks = {{start_stage, left, right}}\n while 0 < #tasks do\n local task = tasks[#tasks]\n table.remove(tasks)\n local stage, l, r = task[1], task[2], task[3]\n if (l - 1) % self.size[stage] ~= 0 then\n local newr = mce((l - 1) / self.size[stage]) * self.size[stage]\n table.insert(tasks, {stage + 1, l, mmi(r, newr)})\n l = newr + 1\n end\n if self.size[stage] <= r + 1 - l then\n local pos = mce(l / self.size[stage])\n ret = self.func(ret, self.stage[stage][pos])\n l = l + self.size[stage]\n end\n if l <= r then\n table.insert(tasks, {stage + 1, l, r})\n end\n end\n return ret\nend\nSegTree.decValue = function(self, idx, silent)\n self.stage[self.stagenum][idx] = self.stage[self.stagenum][idx] - 1\n if not silent then\n for i = self.stagenum - 1, 1, -1 do\n local dst = mce(idx / 2)\n local rem = dst * 4 - 1 - idx\n self.stage[i][dst] = self.func(self.stage[i + 1][idx], self.stage[i + 1][rem])\n idx = dst\n end\n end\nend\nSegTree.new = function(ary, func, emptyvalue)\n local obj = {}\n setmetatable(obj, {__index = SegTree})\n obj:create(ary, func, emptyvalue)\n return obj\nend\n\nlocal n, k = io.read(\"*n\", \"*n\")\nlocal sum, conv = {}, {}\nsum[1] = {1, io.read(\"*n\") - k}\nfor i = 2, n do\n sum[i] = {i, sum[i - 1][2] + io.read(\"*n\") - k}\nend\ntable.sort(sum, function(x, y) return x[2] < y[2] end)\nlocal sumTypeCount = 1\nlocal sumTypeList = {}\ndo\n conv[sum[1][2]] = 1\n sumTypeList[1] = sum[1][2]\n for i = 2, n do\n if sum[i][2] ~= sumTypeList[sumTypeCount] then\n sumTypeCount = sumTypeCount + 1\n conv[sum[i][2]] = sumTypeCount\n sumTypeList[sumTypeCount] = sum[i][2]\n end\n end\nend\ntable.sort(sum, function(x, y) return x[1] < y[1] end)\nlocal sumArrayForTree = {}\nfor i = 1, sumTypeCount do sumArrayForTree[i] = 0 end\nfor i = 1, n do\n sum[i] = sum[i][2]\n local idx = conv[sum[i]]\n sumArrayForTree[idx] = sumArrayForTree[idx] + 1\nend\n\nlocal segtree = SegTree.new(sumArrayForTree, function(a, b) return a + b end, 0)\n\nlocal function lower_bound(ary, x)\n local num = #ary\n if num == 0 then return 1 end\n if(x <= ary[1]) then return 1 end\n if(ary[num] < x) then return num + 1 end\n local min, max = 1, num\n while(1 < max - min) do\n local mid = mfl((min + max) / 2)\n if(ary[mid] < x) then\n min = mid\n else\n max = mid\n end\n end\n return max\nend\n\nlocal bias = 0\nlocal cnt = 0\nfor i = 1, n do\n local treeleft = i == 1 and lower_bound(sumTypeList, bias) or conv[bias]\n if treeleft <= sumTypeCount then\n cnt = cnt + segtree:getRange(treeleft, sumTypeCount)\n end\n segtree:decValue(conv[sum[i]])\n bias = sum[i]\nend\nprint(cnt)\n", "language": "Lua", "metadata": {"date": 1564614940, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p03703.html", "problem_id": "p03703", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03703/input.txt", "sample_output_relpath": "derived/input_output/data/p03703/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03703/Lua/s713123361.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s713123361", "user_id": "u120582723"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "local mfl, mce, mmi = math.floor, math.ceil, math.min\nlocal SegTree = {}\nSegTree.updateAll = function(self)\n for i = self.stagenum - 1, 1, -1 do\n for j = 1, self.cnt[i] do\n self.stage[i][j] = self.func(self.stage[i + 1][j * 2 - 1], self.stage[i + 1][j * 2])\n end\n end\nend\nSegTree.create = function(self, ary, func, emptyvalue)\n self.func, self.emptyvalue = func, emptyvalue\n local stagenum, mul = 1, 1\n self.cnt, self.stage, self.size = {1}, {{}}, {}\n while mul < #ary do\n mul, stagenum = mul * 2, stagenum + 1\n self.cnt[stagenum], self.stage[stagenum] = mul, {}\n end\n for i = 1, stagenum do self.size[i] = self.cnt[stagenum + 1 - i] end\n self.stagenum = stagenum\n for i = 1, #ary do self.stage[stagenum][i] = ary[i] end\n for i = #ary + 1, mul do self.stage[stagenum][i] = emptyvalue end\n self:updateAll()\nend\nSegTree.getRange = function(self, left, right)\n if left == right then return self.stage[self.stagenum][left] end\n local start_stage = 1\n while right - left + 1 < self.size[start_stage] do\n start_stage = start_stage + 1\n end\n local ret = self.emptyvalue\n local tasks = {{start_stage, left, right}}\n while 0 < #tasks do\n local task = tasks[#tasks]\n table.remove(tasks)\n local stage, l, r = task[1], task[2], task[3]\n if (l - 1) % self.size[stage] ~= 0 then\n local newr = mce((l - 1) / self.size[stage]) * self.size[stage]\n table.insert(tasks, {stage + 1, l, mmi(r, newr)})\n l = newr + 1\n end\n if self.size[stage] <= r + 1 - l then\n local pos = mce(l / self.size[stage])\n ret = self.func(ret, self.stage[stage][pos])\n l = l + self.size[stage]\n end\n if l <= r then\n table.insert(tasks, {stage + 1, l, r})\n end\n end\n return ret\nend\nSegTree.decValue = function(self, idx, silent)\n self.stage[self.stagenum][idx] = self.stage[self.stagenum][idx] - 1\n if not silent then\n for i = self.stagenum - 1, 1, -1 do\n local dst = mce(idx / 2)\n local rem = dst * 4 - 1 - idx\n self.stage[i][dst] = self.func(self.stage[i + 1][idx], self.stage[i + 1][rem])\n idx = dst\n end\n end\nend\nSegTree.new = function(ary, func, emptyvalue)\n local obj = {}\n setmetatable(obj, {__index = SegTree})\n obj:create(ary, func, emptyvalue)\n return obj\nend\n\nlocal n, k = io.read(\"*n\", \"*n\")\nlocal sum, conv = {}, {}\nsum[1] = {1, io.read(\"*n\") - k}\nfor i = 2, n do\n sum[i] = {i, sum[i - 1][2] + io.read(\"*n\") - k}\nend\ntable.sort(sum, function(x, y) return x[2] < y[2] end)\nlocal sumTypeCount = 1\nlocal sumTypeList = {}\ndo\n conv[sum[1][2]] = 1\n sumTypeList[1] = sum[1][2]\n for i = 2, n do\n if sum[i][2] ~= sumTypeList[sumTypeCount] then\n sumTypeCount = sumTypeCount + 1\n conv[sum[i][2]] = sumTypeCount\n sumTypeList[sumTypeCount] = sum[i][2]\n end\n end\nend\ntable.sort(sum, function(x, y) return x[1] < y[1] end)\nlocal sumArrayForTree = {}\nfor i = 1, sumTypeCount do sumArrayForTree[i] = 0 end\nfor i = 1, n do\n sum[i] = sum[i][2]\n local idx = conv[sum[i]]\n sumArrayForTree[idx] = sumArrayForTree[idx] + 1\nend\n\nlocal segtree = SegTree.new(sumArrayForTree, function(a, b) return a + b end, 0)\n\nlocal function lower_bound(ary, x)\n local num = #ary\n if num == 0 then return 1 end\n if(x <= ary[1]) then return 1 end\n if(ary[num] < x) then return num + 1 end\n local min, max = 1, num\n while(1 < max - min) do\n local mid = mfl((min + max) / 2)\n if(ary[mid] < x) then\n min = mid\n else\n max = mid\n end\n end\n return max\nend\n\nlocal bias = 0\nlocal cnt = 0\nfor i = 1, n do\n local treeleft = i == 1 and lower_bound(sumTypeList, bias) or conv[bias]\n if treeleft <= sumTypeCount then\n cnt = cnt + segtree:getRange(treeleft, sumTypeCount)\n end\n segtree:decValue(conv[sum[i]])\n bias = sum[i]\nend\nprint(cnt)\n", "problem_context": "Score : 600 points\n\nProblem Statement\n\nYou are given an integer sequence of length N, a = {a_1, a_2, …, a_N}, and an integer K.\n\na has N(N+1)/2 non-empty contiguous subsequences, {a_l, a_{l+1}, …, a_r} (1 ≤ l ≤ r ≤ N). Among them, how many have an arithmetic mean that is greater than or equal to K?\n\nConstraints\n\nAll input values are integers.\n\n1 ≤ N ≤ 2 \\times 10^5\n\n1 ≤ K ≤ 10^9\n\n1 ≤ a_i ≤ 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\na_1\na_2\n:\na_N\n\nOutput\n\nPrint the number of the non-empty contiguous subsequences with an arithmetic mean that is greater than or equal to K.\n\nSample Input 1\n\n3 6\n7\n5\n7\n\nSample Output 1\n\n5\n\nAll the non-empty contiguous subsequences of a are listed below:\n\n{a_1} = {7}\n\n{a_1, a_2} = {7, 5}\n\n{a_1, a_2, a_3} = {7, 5, 7}\n\n{a_2} = {5}\n\n{a_2, a_3} = {5, 7}\n\n{a_3} = {7}\n\nTheir means are 7, 6, 19/3, 5, 6 and 7, respectively, and five among them are 6 or greater. Note that {a_1} and {a_3} are indistinguishable by the values of their elements, but we count them individually.\n\nSample Input 2\n\n1 2\n1\n\nSample Output 2\n\n0\n\nSample Input 3\n\n7 26\n10\n20\n30\n40\n30\n20\n10\n\nSample Output 3\n\n13", "sample_input": "3 6\n7\n5\n7\n"}, "reference_outputs": ["5\n"], "source_document_id": "p03703", "source_text": "Score : 600 points\n\nProblem Statement\n\nYou are given an integer sequence of length N, a = {a_1, a_2, …, a_N}, and an integer K.\n\na has N(N+1)/2 non-empty contiguous subsequences, {a_l, a_{l+1}, …, a_r} (1 ≤ l ≤ r ≤ N). Among them, how many have an arithmetic mean that is greater than or equal to K?\n\nConstraints\n\nAll input values are integers.\n\n1 ≤ N ≤ 2 \\times 10^5\n\n1 ≤ K ≤ 10^9\n\n1 ≤ a_i ≤ 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\na_1\na_2\n:\na_N\n\nOutput\n\nPrint the number of the non-empty contiguous subsequences with an arithmetic mean that is greater than or equal to K.\n\nSample Input 1\n\n3 6\n7\n5\n7\n\nSample Output 1\n\n5\n\nAll the non-empty contiguous subsequences of a are listed below:\n\n{a_1} = {7}\n\n{a_1, a_2} = {7, 5}\n\n{a_1, a_2, a_3} = {7, 5, 7}\n\n{a_2} = {5}\n\n{a_2, a_3} = {5, 7}\n\n{a_3} = {7}\n\nTheir means are 7, 6, 19/3, 5, 6 and 7, respectively, and five among them are 6 or greater. Note that {a_1} and {a_3} are indistinguishable by the values of their elements, but we count them individually.\n\nSample Input 2\n\n1 2\n1\n\nSample Output 2\n\n0\n\nSample Input 3\n\n7 26\n10\n20\n30\n40\n30\n20\n10\n\nSample Output 3\n\n13", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 3755, "cpu_time_ms": 1896, "memory_kb": 35336}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s735615221", "group_id": "codeNet:p03711", "input_text": "local x, y = io.read(\"n\", \"n\")\nlocal g1 = {1,3,5,7,8,10,12}\nlocal g2 = {4,6,9,11}\nlocal g3 = {2}\nlocal function get(i)\n local groups = {g1,g2,g3}\n for k,v in ipairs(groups) do\n for kk,vv in ipairs(v) do\n if i == vv then\n return k\n end\n end\n end\n return -1\nend\nif get(x) == get(y) then print('Yes')\nelse print('No') end", "language": "Lua", "metadata": {"date": 1567954909, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03711.html", "problem_id": "p03711", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03711/input.txt", "sample_output_relpath": "derived/input_output/data/p03711/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03711/Lua/s735615221.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s735615221", "user_id": "u162773977"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "local x, y = io.read(\"n\", \"n\")\nlocal g1 = {1,3,5,7,8,10,12}\nlocal g2 = {4,6,9,11}\nlocal g3 = {2}\nlocal function get(i)\n local groups = {g1,g2,g3}\n for k,v in ipairs(groups) do\n for kk,vv in ipairs(v) do\n if i == vv then\n return k\n end\n end\n end\n return -1\nend\nif get(x) == get(y) then print('Yes')\nelse print('No') end", "problem_context": "Score : 100 points\n\nProblem Statement\n\nBased on some criterion, Snuke divided the integers from 1 through 12 into three groups as shown in the figure below.\nGiven two integers x and y (1 ≤ x < y ≤ 12), determine whether they belong to the same group.\n\nConstraints\n\nx and y are integers.\n\n1 ≤ x < y ≤ 12\n\nInput\n\nInput is given from Standard Input in the following format:\n\nx y\n\nOutput\n\nIf x and y belong to the same group, print Yes; otherwise, print No.\n\nSample Input 1\n\n1 3\n\nSample Output 1\n\nYes\n\nSample Input 2\n\n2 4\n\nSample Output 2\n\nNo", "sample_input": "1 3\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03711", "source_text": "Score : 100 points\n\nProblem Statement\n\nBased on some criterion, Snuke divided the integers from 1 through 12 into three groups as shown in the figure below.\nGiven two integers x and y (1 ≤ x < y ≤ 12), determine whether they belong to the same group.\n\nConstraints\n\nx and y are integers.\n\n1 ≤ x < y ≤ 12\n\nInput\n\nInput is given from Standard Input in the following format:\n\nx y\n\nOutput\n\nIf x and y belong to the same group, print Yes; otherwise, print No.\n\nSample Input 1\n\n1 3\n\nSample Output 1\n\nYes\n\nSample Input 2\n\n2 4\n\nSample Output 2\n\nNo", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 381, "cpu_time_ms": 7, "memory_kb": 888}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s873890513", "group_id": "codeNet:p03713", "input_text": "local DBG = true\nlocal function dbgpr(...)\n if DBG then\n io.write(\"[dbg]\")\n print(...)\n end\nend\nlocal function dbgpr_t(tbl, use_pairs)\n if DBG then\n local enum = ipairs\n if use_pairs then\n enum = pairs\n end\n dbgpr(tbl)\n io.write(\"[dbg]\")\n for i,v in enum(tbl) do\n io.write(i)\n io.write(\":\")\n io.write(tostring(v))\n io.write(\" \")\n end\n print(\"\")\n end\nend\nlocal H, W = io.read(\"n\", \"n\")\nlocal INF = 99999999999\nlocal function vert(H, W)\n local m = W % 3\n if m == 0 then\n return 0\n else\n return H\n end\nend\n\nlocal function horiz(H, W)\n return vert(W, H)\nend\n\nlocal function maxmindiff(a,b,c)\n local max = math.max(a,b,c)\n local min = math.min(a,b,c)\n return max - min\nend\n\nlocal function vh(H, W)\n local d = W // 3\n local h = H // 2\n local ans = INF\n for w=math.max(d,0),math.min(d+2,W) do\n local area1 = w * H\n local area2 = (W - w) * h\n local area3 = (W - w) * (H - h)\n ans = math.min(ans, maxmindiff(area1,area2,area3))\n end\n return ans\nend\n\n\nlocal function hv(H, W)\n return vh(W, H)\nend\n\nlocal answers = {vert(H, W), horiz(H, W), vh(H, W), hv(H, W)}\n--dbgpr_t(answers)\nprint(math.min(table.unpack(answers)))\n\n", "language": "Lua", "metadata": {"date": 1566693610, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03713.html", "problem_id": "p03713", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03713/input.txt", "sample_output_relpath": "derived/input_output/data/p03713/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03713/Lua/s873890513.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s873890513", "user_id": "u162773977"}, "prompt_components": {"gold_output": "0\n", "input_to_evaluate": "local DBG = true\nlocal function dbgpr(...)\n if DBG then\n io.write(\"[dbg]\")\n print(...)\n end\nend\nlocal function dbgpr_t(tbl, use_pairs)\n if DBG then\n local enum = ipairs\n if use_pairs then\n enum = pairs\n end\n dbgpr(tbl)\n io.write(\"[dbg]\")\n for i,v in enum(tbl) do\n io.write(i)\n io.write(\":\")\n io.write(tostring(v))\n io.write(\" \")\n end\n print(\"\")\n end\nend\nlocal H, W = io.read(\"n\", \"n\")\nlocal INF = 99999999999\nlocal function vert(H, W)\n local m = W % 3\n if m == 0 then\n return 0\n else\n return H\n end\nend\n\nlocal function horiz(H, W)\n return vert(W, H)\nend\n\nlocal function maxmindiff(a,b,c)\n local max = math.max(a,b,c)\n local min = math.min(a,b,c)\n return max - min\nend\n\nlocal function vh(H, W)\n local d = W // 3\n local h = H // 2\n local ans = INF\n for w=math.max(d,0),math.min(d+2,W) do\n local area1 = w * H\n local area2 = (W - w) * h\n local area3 = (W - w) * (H - h)\n ans = math.min(ans, maxmindiff(area1,area2,area3))\n end\n return ans\nend\n\n\nlocal function hv(H, W)\n return vh(W, H)\nend\n\nlocal answers = {vert(H, W), horiz(H, W), vh(H, W), hv(H, W)}\n--dbgpr_t(answers)\nprint(math.min(table.unpack(answers)))\n\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nThere is a bar of chocolate with a height of H blocks and a width of W blocks.\nSnuke is dividing this bar into exactly three pieces.\nHe can only cut the bar along borders of blocks, and the shape of each piece must be a rectangle.\n\nSnuke is trying to divide the bar as evenly as possible.\nMore specifically, he is trying to minimize S_{max} - S_{min}, where S_{max} is the area (the number of blocks contained) of the largest piece, and S_{min} is the area of the smallest piece.\nFind the minimum possible value of S_{max} - S_{min}.\n\nConstraints\n\n2 ≤ H, W ≤ 10^5\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\n\nOutput\n\nPrint the minimum possible value of S_{max} - S_{min}.\n\nSample Input 1\n\n3 5\n\nSample Output 1\n\n0\n\nIn the division below, S_{max} - S_{min} = 5 - 5 = 0.\n\nSample Input 2\n\n4 5\n\nSample Output 2\n\n2\n\nIn the division below, S_{max} - S_{min} = 8 - 6 = 2.\n\nSample Input 3\n\n5 5\n\nSample Output 3\n\n4\n\nIn the division below, S_{max} - S_{min} = 10 - 6 = 4.\n\nSample Input 4\n\n100000 2\n\nSample Output 4\n\n1\n\nSample Input 5\n\n100000 100000\n\nSample Output 5\n\n50000", "sample_input": "3 5\n"}, "reference_outputs": ["0\n"], "source_document_id": "p03713", "source_text": "Score : 400 points\n\nProblem Statement\n\nThere is a bar of chocolate with a height of H blocks and a width of W blocks.\nSnuke is dividing this bar into exactly three pieces.\nHe can only cut the bar along borders of blocks, and the shape of each piece must be a rectangle.\n\nSnuke is trying to divide the bar as evenly as possible.\nMore specifically, he is trying to minimize S_{max} - S_{min}, where S_{max} is the area (the number of blocks contained) of the largest piece, and S_{min} is the area of the smallest piece.\nFind the minimum possible value of S_{max} - S_{min}.\n\nConstraints\n\n2 ≤ H, W ≤ 10^5\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\n\nOutput\n\nPrint the minimum possible value of S_{max} - S_{min}.\n\nSample Input 1\n\n3 5\n\nSample Output 1\n\n0\n\nIn the division below, S_{max} - S_{min} = 5 - 5 = 0.\n\nSample Input 2\n\n4 5\n\nSample Output 2\n\n2\n\nIn the division below, S_{max} - S_{min} = 8 - 6 = 2.\n\nSample Input 3\n\n5 5\n\nSample Output 3\n\n4\n\nIn the division below, S_{max} - S_{min} = 10 - 6 = 4.\n\nSample Input 4\n\n100000 2\n\nSample Output 4\n\n1\n\nSample Input 5\n\n100000 100000\n\nSample Output 5\n\n50000", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1333, "cpu_time_ms": 219, "memory_kb": 1012}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s858271247", "group_id": "codeNet:p03713", "input_text": "local DBG = true\nlocal function dbgpr(...)\n if DBG then\n io.write(\"[dbg]\")\n print(...)\n end\nend\nlocal function dbgpr_t(tbl, use_pairs)\n if DBG then\n local enum = ipairs\n if use_pairs then\n enum = pairs\n end\n dbgpr(tbl)\n io.write(\"[dbg]\")\n for i,v in enum(tbl) do\n io.write(i)\n io.write(\":\")\n io.write(tostring(v))\n io.write(\" \")\n end\n print(\"\")\n end\nend\nlocal H, W = io.read(\"n\", \"n\")\nlocal INF = 99999999999\nlocal function vert()\n local m = W % 3\n if m == 0 then\n return 0\n else\n return H\n end\nend\n\nlocal function horiz()\n local m = H % 3\n if m == 0 then\n return 0\n else\n return W\n end\nend\n\nlocal function maxmindiff(a,b,c)\n local max = math.max(a,b,c)\n local min = math.min(a,b,c)\n return max - min\nend\n\nlocal function vh()\n local d = W // 3\n local dd = H // 2\n local ans = INF\n for w=math.max(d-3,0),math.min(d+3,W) do\n local area1 = w * H\n for h=math.max(dd-3,0),math.min(dd+3,H) do\n local area2 = (W - w) * h\n local area3 = (W - w) * (H - h)\n ans = math.min(ans, maxmindiff(area1,area2,area3))\n end\n end\n return ans\nend\n\n\nlocal function hv()\n local d = H // 3\n local dd = W // 2\n local ans = INF\n for h=math.max(d-3,0),math.min(d+3,H) do\n local area1 = h * W\n for w=math.max(dd-3,0),math.min(dd+3,W) do\n local area2 = (H - h) * w\n local area3 = (H - h) * (W - w)\n ans = math.min(ans, maxmindiff(area1,area2,area3))\n end\n end\n return ans\nend\n\nlocal answers = {vert(), horiz(), vh(), hv()}\n--dbgpr_t(answers)\nprint(math.min(table.unpack(answers)))\n\n", "language": "Lua", "metadata": {"date": 1566692833, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03713.html", "problem_id": "p03713", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03713/input.txt", "sample_output_relpath": "derived/input_output/data/p03713/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03713/Lua/s858271247.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s858271247", "user_id": "u162773977"}, "prompt_components": {"gold_output": "0\n", "input_to_evaluate": "local DBG = true\nlocal function dbgpr(...)\n if DBG then\n io.write(\"[dbg]\")\n print(...)\n end\nend\nlocal function dbgpr_t(tbl, use_pairs)\n if DBG then\n local enum = ipairs\n if use_pairs then\n enum = pairs\n end\n dbgpr(tbl)\n io.write(\"[dbg]\")\n for i,v in enum(tbl) do\n io.write(i)\n io.write(\":\")\n io.write(tostring(v))\n io.write(\" \")\n end\n print(\"\")\n end\nend\nlocal H, W = io.read(\"n\", \"n\")\nlocal INF = 99999999999\nlocal function vert()\n local m = W % 3\n if m == 0 then\n return 0\n else\n return H\n end\nend\n\nlocal function horiz()\n local m = H % 3\n if m == 0 then\n return 0\n else\n return W\n end\nend\n\nlocal function maxmindiff(a,b,c)\n local max = math.max(a,b,c)\n local min = math.min(a,b,c)\n return max - min\nend\n\nlocal function vh()\n local d = W // 3\n local dd = H // 2\n local ans = INF\n for w=math.max(d-3,0),math.min(d+3,W) do\n local area1 = w * H\n for h=math.max(dd-3,0),math.min(dd+3,H) do\n local area2 = (W - w) * h\n local area3 = (W - w) * (H - h)\n ans = math.min(ans, maxmindiff(area1,area2,area3))\n end\n end\n return ans\nend\n\n\nlocal function hv()\n local d = H // 3\n local dd = W // 2\n local ans = INF\n for h=math.max(d-3,0),math.min(d+3,H) do\n local area1 = h * W\n for w=math.max(dd-3,0),math.min(dd+3,W) do\n local area2 = (H - h) * w\n local area3 = (H - h) * (W - w)\n ans = math.min(ans, maxmindiff(area1,area2,area3))\n end\n end\n return ans\nend\n\nlocal answers = {vert(), horiz(), vh(), hv()}\n--dbgpr_t(answers)\nprint(math.min(table.unpack(answers)))\n\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nThere is a bar of chocolate with a height of H blocks and a width of W blocks.\nSnuke is dividing this bar into exactly three pieces.\nHe can only cut the bar along borders of blocks, and the shape of each piece must be a rectangle.\n\nSnuke is trying to divide the bar as evenly as possible.\nMore specifically, he is trying to minimize S_{max} - S_{min}, where S_{max} is the area (the number of blocks contained) of the largest piece, and S_{min} is the area of the smallest piece.\nFind the minimum possible value of S_{max} - S_{min}.\n\nConstraints\n\n2 ≤ H, W ≤ 10^5\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\n\nOutput\n\nPrint the minimum possible value of S_{max} - S_{min}.\n\nSample Input 1\n\n3 5\n\nSample Output 1\n\n0\n\nIn the division below, S_{max} - S_{min} = 5 - 5 = 0.\n\nSample Input 2\n\n4 5\n\nSample Output 2\n\n2\n\nIn the division below, S_{max} - S_{min} = 8 - 6 = 2.\n\nSample Input 3\n\n5 5\n\nSample Output 3\n\n4\n\nIn the division below, S_{max} - S_{min} = 10 - 6 = 4.\n\nSample Input 4\n\n100000 2\n\nSample Output 4\n\n1\n\nSample Input 5\n\n100000 100000\n\nSample Output 5\n\n50000", "sample_input": "3 5\n"}, "reference_outputs": ["0\n"], "source_document_id": "p03713", "source_text": "Score : 400 points\n\nProblem Statement\n\nThere is a bar of chocolate with a height of H blocks and a width of W blocks.\nSnuke is dividing this bar into exactly three pieces.\nHe can only cut the bar along borders of blocks, and the shape of each piece must be a rectangle.\n\nSnuke is trying to divide the bar as evenly as possible.\nMore specifically, he is trying to minimize S_{max} - S_{min}, where S_{max} is the area (the number of blocks contained) of the largest piece, and S_{min} is the area of the smallest piece.\nFind the minimum possible value of S_{max} - S_{min}.\n\nConstraints\n\n2 ≤ H, W ≤ 10^5\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\n\nOutput\n\nPrint the minimum possible value of S_{max} - S_{min}.\n\nSample Input 1\n\n3 5\n\nSample Output 1\n\n0\n\nIn the division below, S_{max} - S_{min} = 5 - 5 = 0.\n\nSample Input 2\n\n4 5\n\nSample Output 2\n\n2\n\nIn the division below, S_{max} - S_{min} = 8 - 6 = 2.\n\nSample Input 3\n\n5 5\n\nSample Output 3\n\n4\n\nIn the division below, S_{max} - S_{min} = 10 - 6 = 4.\n\nSample Input 4\n\n100000 2\n\nSample Output 4\n\n1\n\nSample Input 5\n\n100000 100000\n\nSample Output 5\n\n50000", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1794, "cpu_time_ms": 341, "memory_kb": 760}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s726960791", "group_id": "codeNet:p03716", "input_text": "local PairingHeap={}\n\nPairingHeap.meld=function(self,a,b)\n if not a then\n return b\n elseif not b then\n return a\n elseif a[1]P then\n lsum[i]=lsum[i-1]+A-P\n minq:push(A,A)\n minq:pop()\n else\n lsum[i]=lsum[i-1]\n end\nend\n\nlocal rsum={[0]=0}\nlocal maxq=PairingHeap:new()\nfor i=1,n do\n local A=a[3*n-i+1]\n rsum[i]=rsum[i-1]+A\n maxq:push(-A,A)\nend\nfor i=n+1,2*n do\n local P=maxq:top()\n local A=a[3*n-i+1]\n if A

P then\n lsum[i]=lsum[i-1]+A-P\n minq:push(A,A)\n minq:pop()\n else\n lsum[i]=lsum[i-1]\n end\nend\n\nlocal rsum={[0]=0}\nlocal maxq=PairingHeap:new()\nfor i=1,n do\n local A=a[3*n-i+1]\n rsum[i]=rsum[i-1]+A\n maxq:push(-A,A)\nend\nfor i=n+1,2*n do\n local P=maxq:top()\n local A=a[3*n-i+1]\n if A

0 and X or 0)\nend\n\nlocal rsum={[0]=0}\nlocal maxq=PairingHeap:new()\nfor i=1,n do\n local A=a[3*n-i+1]\n rsum[i]=rsum[i-1]+A\n maxq:push(-A,A)\nend\nfor i=n+1,2*n do\n local X=a[3*n-i+1]-maxq:pop()\n rsum[i]=rsum[i-1]+(X<0 and X or 0)\nend\nlocal max=math.mininteger\nfor i=n+1,2*n do\n max=math.max(max,lsum[i]-rsum[3*n-i])\nend\nprint(max)", "language": "Lua", "metadata": {"date": 1600084447, "filename_ext": "lua", "original_language": "Lua (Lua 5.3.5)", "problem_description_relpath": "problem_descriptions/p03716.html", "problem_id": "p03716", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03716/input.txt", "sample_output_relpath": "derived/input_output/data/p03716/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03716/Lua/s957623319.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s957623319", "user_id": "u045238009"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "local PairingHeap={}\n\nPairingHeap.meld=function(self,a,b)\n if not a then\n return b\n elseif not b then\n return a\n elseif a[1]0 and X or 0)\nend\n\nlocal rsum={[0]=0}\nlocal maxq=PairingHeap:new()\nfor i=1,n do\n local A=a[3*n-i+1]\n rsum[i]=rsum[i-1]+A\n maxq:push(-A,A)\nend\nfor i=n+1,2*n do\n local X=a[3*n-i+1]-maxq:pop()\n rsum[i]=rsum[i-1]+(X<0 and X or 0)\nend\nlocal max=math.mininteger\nfor i=n+1,2*n do\n max=math.max(max,lsum[i]-rsum[3*n-i])\nend\nprint(max)", "problem_context": "Score : 500 points\n\nProblem Statement\n\nLet N be a positive integer.\n\nThere is a numerical sequence of length 3N, a = (a_1, a_2, ..., a_{3N}).\nSnuke is constructing a new sequence of length 2N, a', by removing exactly N elements from a without changing the order of the remaining elements.\nHere, the score of a' is defined as follows: (the sum of the elements in the first half of a') - (the sum of the elements in the second half of a').\n\nFind the maximum possible score of a'.\n\nConstraints\n\n1 ≤ N ≤ 10^5\n\na_i is an integer.\n\n1 ≤ a_i ≤ 10^9\n\nPartial Score\n\nIn the test set worth 300 points, N ≤ 1000.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 ... a_{3N}\n\nOutput\n\nPrint the maximum possible score of a'.\n\nSample Input 1\n\n2\n3 1 4 1 5 9\n\nSample Output 1\n\n1\n\nWhen a_2 and a_6 are removed, a' will be (3, 4, 1, 5), which has a score of (3 + 4) - (1 + 5) = 1.\n\nSample Input 2\n\n1\n1 2 3\n\nSample Output 2\n\n-1\n\nFor example, when a_1 are removed, a' will be (2, 3), which has a score of 2 - 3 = -1.\n\nSample Input 3\n\n3\n8 2 2 7 4 6 5 3 8\n\nSample Output 3\n\n5\n\nFor example, when a_2, a_3 and a_9 are removed, a' will be (8, 7, 4, 6, 5, 3), which has a score of (8 + 7 + 4) - (6 + 5 + 3) = 5.", "sample_input": "2\n3 1 4 1 5 9\n"}, "reference_outputs": ["1\n"], "source_document_id": "p03716", "source_text": "Score : 500 points\n\nProblem Statement\n\nLet N be a positive integer.\n\nThere is a numerical sequence of length 3N, a = (a_1, a_2, ..., a_{3N}).\nSnuke is constructing a new sequence of length 2N, a', by removing exactly N elements from a without changing the order of the remaining elements.\nHere, the score of a' is defined as follows: (the sum of the elements in the first half of a') - (the sum of the elements in the second half of a').\n\nFind the maximum possible score of a'.\n\nConstraints\n\n1 ≤ N ≤ 10^5\n\na_i is an integer.\n\n1 ≤ a_i ≤ 10^9\n\nPartial Score\n\nIn the test set worth 300 points, N ≤ 1000.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 ... a_{3N}\n\nOutput\n\nPrint the maximum possible score of a'.\n\nSample Input 1\n\n2\n3 1 4 1 5 9\n\nSample Output 1\n\n1\n\nWhen a_2 and a_6 are removed, a' will be (3, 4, 1, 5), which has a score of (3 + 4) - (1 + 5) = 1.\n\nSample Input 2\n\n1\n1 2 3\n\nSample Output 2\n\n-1\n\nFor example, when a_1 are removed, a' will be (2, 3), which has a score of 2 - 3 = -1.\n\nSample Input 3\n\n3\n8 2 2 7 4 6 5 3 8\n\nSample Output 3\n\n5\n\nFor example, when a_2, a_3 and a_9 are removed, a' will be (8, 7, 4, 6, 5, 3), which has a score of (8 + 7 + 4) - (6 + 5 + 3) = 5.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2220, "cpu_time_ms": 861, "memory_kb": 50924}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s649217429", "group_id": "codeNet:p03718", "input_text": "local mma = math.max\nlocal mfl, mce, mmi = math.floor, math.ceil, math.min\nlocal SegTree = {}\nSegTree.updateAll = function(self)\n for i = self.stagenum - 1, 1, -1 do\n for j = 1, self.cnt[i] do\n self.stage[i][j] = self.func(self.stage[i + 1][j * 2 - 1], self.stage[i + 1][j * 2])\n end\n end\nend\nSegTree.create = function(self, n, func)\n self.func = func\n local stagenum, mul = 1, 1\n self.cnt, self.stage, self.size = {1}, {{}}, {}\n while mul < n do\n mul, stagenum = mul * 2, stagenum + 1\n self.cnt[stagenum], self.stage[stagenum] = mul, {}\n end\n for i = 1, stagenum do self.size[i] = self.cnt[stagenum + 1 - i] end\n self.stagenum = stagenum\n for i = 1, n do self.stage[stagenum][i] = i end\n for i = n + 1, mul do self.stage[stagenum][i] = n + 1 end\n self:updateAll()\nend\nSegTree.update = function(self, idx)\n for i = self.stagenum - 1, 1, -1 do\n local dst = mce(idx / 2)\n local rem = dst * 4 - 1 - idx\n self.stage[i][dst] = self.func(self.stage[i + 1][idx], self.stage[i + 1][rem])\n idx = dst\n end\nend\nSegTree.new = function(n, func)\n local obj = {}\n setmetatable(obj, {__index = SegTree})\n obj:create(n, func)\n return obj\nend\n\nlocal h, w = io.read(\"*n\", \"*n\", \"*l\")\nlocal idxedges = {}\nlocal sidx, gidx = 0, 0\n\n--[[\n1, ..., w: column i\nw + 1, ..., w + h: row i\nw + h + 1: startpos\nw + h + 2: goalpos\n]]\nlocal snode = w + h + 1\nlocal gnode = w + h + 2\nlocal edge = {}\nfor i = 1, gnode do\n edge[i] = {}\nend\n\nfor i = 1, h do\n local str = io.read()\n for j = 1, w do\n local idx = (i - 1) * w + j\n local s = str:sub(j, j)\n if s == \"S\" then\n sidx = idx\n elseif s == \"T\" then\n gidx = idx\n elseif s == \"o\" then\n table.insert(idxedges, idx)\n end\n end\nend\nlocal function getrowcol(idx)\n local r = 1 + mfl((idx - 1) / w)\n local c = idx % w\n if c == 0 then c = w end\n return r, c\nend\n\nlocal len, stlen = {}, {}\nfor i = 1, gnode + 1 do\n len[i] = gnode\n stlen[i] = gnode\nend\nlocal seg = SegTree.new(gnode, function(x, y) return stlen[x] < stlen[y] and x or y end)\n\nlocal function runDijkstra()\n for i = 1, gnode + 1 do\n len[i] = gnode\n stlen[i] = gnode\n end\n len[snode] = 0\n stlen[snode] = 0\n seg:updateAll()\n for i = 1, gnode do\n local node = seg.stage[1][1]\n if gnode <= stlen[node] then\n break\n end\n for dst, v in pairs(edge[node]) do\n if len[node] + 1 < len[dst] then\n len[dst] = len[node] + 1\n stlen[dst] = stlen[node] + 1\n seg:update(dst)\n end\n end\n stlen[node] = gnode\n seg:update(node)\n end\n if gnode <= len[gnode] then\n return false\n else\n -- reverse walk\n local cur = gnode\n while cur ~= snode do\n for dst, v in pairs(edge[cur]) do\n if v and len[dst] + 1 == len[cur] then\n edge[cur][dst] = edge[cur][dst] - 1\n edge[dst][cur] = edge[dst][cur] - 1\n if edge[cur][dst] == 0 then\n edge[cur][dst] = nil\n edge[dst][cur] = nil\n end\n cur = dst\n break\n end\n end\n end\n return true\n end\nend\n\nlocal function solve()\n local sr, sc = getrowcol(sidx)\n local gr, gc = getrowcol(gidx)\n if sr == gr or sc == gc then\n return -1\n end\n local idxedgenum = #idxedges\n local function addedge(a, b)\n if not edge[a][b] then edge[a][b] = 1\n else edge[a][b] = edge[a][b] + 1 end\n if not edge[b][a] then edge[b][a] = 1\n else edge[b][a] = edge[b][a] + 1 end\n end\n for i = 1, idxedgenum do\n local r, c = getrowcol(idxedges[i])\n if r == sr then\n if c == gc then\n addedge(snode, gnode)\n else\n addedge(snode, c)\n end\n elseif r == gr then\n if c == sc then\n addedge(snode, gnode)\n else\n addedge(gnode, c)\n end\n else\n if c == sc then\n addedge(snode, r + w)\n elseif c == gc then\n addedge(gnode, r + w)\n else\n addedge(c, r + w)\n end\n end\n end\n local cnt = 0\n while true do\n if runDijkstra() then\n cnt = cnt + 1\n else\n break\n end\n end\n return cnt\nend\nprint(solve())\n", "language": "Lua", "metadata": {"date": 1574317598, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p03718.html", "problem_id": "p03718", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03718/input.txt", "sample_output_relpath": "derived/input_output/data/p03718/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03718/Lua/s649217429.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s649217429", "user_id": "u120582723"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "local mma = math.max\nlocal mfl, mce, mmi = math.floor, math.ceil, math.min\nlocal SegTree = {}\nSegTree.updateAll = function(self)\n for i = self.stagenum - 1, 1, -1 do\n for j = 1, self.cnt[i] do\n self.stage[i][j] = self.func(self.stage[i + 1][j * 2 - 1], self.stage[i + 1][j * 2])\n end\n end\nend\nSegTree.create = function(self, n, func)\n self.func = func\n local stagenum, mul = 1, 1\n self.cnt, self.stage, self.size = {1}, {{}}, {}\n while mul < n do\n mul, stagenum = mul * 2, stagenum + 1\n self.cnt[stagenum], self.stage[stagenum] = mul, {}\n end\n for i = 1, stagenum do self.size[i] = self.cnt[stagenum + 1 - i] end\n self.stagenum = stagenum\n for i = 1, n do self.stage[stagenum][i] = i end\n for i = n + 1, mul do self.stage[stagenum][i] = n + 1 end\n self:updateAll()\nend\nSegTree.update = function(self, idx)\n for i = self.stagenum - 1, 1, -1 do\n local dst = mce(idx / 2)\n local rem = dst * 4 - 1 - idx\n self.stage[i][dst] = self.func(self.stage[i + 1][idx], self.stage[i + 1][rem])\n idx = dst\n end\nend\nSegTree.new = function(n, func)\n local obj = {}\n setmetatable(obj, {__index = SegTree})\n obj:create(n, func)\n return obj\nend\n\nlocal h, w = io.read(\"*n\", \"*n\", \"*l\")\nlocal idxedges = {}\nlocal sidx, gidx = 0, 0\n\n--[[\n1, ..., w: column i\nw + 1, ..., w + h: row i\nw + h + 1: startpos\nw + h + 2: goalpos\n]]\nlocal snode = w + h + 1\nlocal gnode = w + h + 2\nlocal edge = {}\nfor i = 1, gnode do\n edge[i] = {}\nend\n\nfor i = 1, h do\n local str = io.read()\n for j = 1, w do\n local idx = (i - 1) * w + j\n local s = str:sub(j, j)\n if s == \"S\" then\n sidx = idx\n elseif s == \"T\" then\n gidx = idx\n elseif s == \"o\" then\n table.insert(idxedges, idx)\n end\n end\nend\nlocal function getrowcol(idx)\n local r = 1 + mfl((idx - 1) / w)\n local c = idx % w\n if c == 0 then c = w end\n return r, c\nend\n\nlocal len, stlen = {}, {}\nfor i = 1, gnode + 1 do\n len[i] = gnode\n stlen[i] = gnode\nend\nlocal seg = SegTree.new(gnode, function(x, y) return stlen[x] < stlen[y] and x or y end)\n\nlocal function runDijkstra()\n for i = 1, gnode + 1 do\n len[i] = gnode\n stlen[i] = gnode\n end\n len[snode] = 0\n stlen[snode] = 0\n seg:updateAll()\n for i = 1, gnode do\n local node = seg.stage[1][1]\n if gnode <= stlen[node] then\n break\n end\n for dst, v in pairs(edge[node]) do\n if len[node] + 1 < len[dst] then\n len[dst] = len[node] + 1\n stlen[dst] = stlen[node] + 1\n seg:update(dst)\n end\n end\n stlen[node] = gnode\n seg:update(node)\n end\n if gnode <= len[gnode] then\n return false\n else\n -- reverse walk\n local cur = gnode\n while cur ~= snode do\n for dst, v in pairs(edge[cur]) do\n if v and len[dst] + 1 == len[cur] then\n edge[cur][dst] = edge[cur][dst] - 1\n edge[dst][cur] = edge[dst][cur] - 1\n if edge[cur][dst] == 0 then\n edge[cur][dst] = nil\n edge[dst][cur] = nil\n end\n cur = dst\n break\n end\n end\n end\n return true\n end\nend\n\nlocal function solve()\n local sr, sc = getrowcol(sidx)\n local gr, gc = getrowcol(gidx)\n if sr == gr or sc == gc then\n return -1\n end\n local idxedgenum = #idxedges\n local function addedge(a, b)\n if not edge[a][b] then edge[a][b] = 1\n else edge[a][b] = edge[a][b] + 1 end\n if not edge[b][a] then edge[b][a] = 1\n else edge[b][a] = edge[b][a] + 1 end\n end\n for i = 1, idxedgenum do\n local r, c = getrowcol(idxedges[i])\n if r == sr then\n if c == gc then\n addedge(snode, gnode)\n else\n addedge(snode, c)\n end\n elseif r == gr then\n if c == sc then\n addedge(snode, gnode)\n else\n addedge(gnode, c)\n end\n else\n if c == sc then\n addedge(snode, r + w)\n elseif c == gc then\n addedge(gnode, r + w)\n else\n addedge(c, r + w)\n end\n end\n end\n local cnt = 0\n while true do\n if runDijkstra() then\n cnt = cnt + 1\n else\n break\n end\n end\n return cnt\nend\nprint(solve())\n", "problem_context": "Score : 800 points\n\nProblem Statement\n\nThere is a pond with a rectangular shape.\nThe pond is divided into a grid with H rows and W columns of squares.\nWe will denote the square at the i-th row from the top and j-th column from the left by (i,\\ j).\n\nSome of the squares in the pond contains a lotus leaf floating on the water.\nOn one of those leaves, S, there is a frog trying to get to another leaf T.\nThe state of square (i,\\ j) is given to you by a character a_{ij}, as follows:\n\n. : A square without a leaf.\n\no : A square with a leaf floating on the water.\n\nS : A square with the leaf S.\n\nT : A square with the leaf T.\n\nThe frog will repeatedly perform the following action to get to the leaf T: \"jump to a leaf that is in the same row or the same column as the leaf where the frog is currently located.\"\n\nSnuke is trying to remove some of the leaves, other than S and T, so that the frog cannot get to the leaf T.\nDetermine whether this objective is achievable. If it is achievable, find the minimum necessary number of leaves to remove.\n\nConstraints\n\n2 ≤ H, W ≤ 100\n\na_{ij} is ., o, S or T.\n\nThere is exactly one S among a_{ij}.\n\nThere is exactly one T among a_{ij}.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\na_{11} ... a_{1W}\n:\na_{H1} ... a_{HW}\n\nOutput\n\nIf the objective is achievable, print the minimum necessary number of leaves to remove.\nOtherwise, print -1 instead.\n\nSample Input 1\n\n3 3\nS.o\n.o.\no.T\n\nSample Output 1\n\n2\n\nRemove the upper-right and lower-left leaves.\n\nSample Input 2\n\n3 4\nS...\n.oo.\n...T\n\nSample Output 2\n\n0\n\nSample Input 3\n\n4 3\n.S.\n.o.\n.o.\n.T.\n\nSample Output 3\n\n-1\n\nSample Input 4\n\n10 10\n.o...o..o.\n....o.....\n....oo.oo.\n..oooo..o.\n....oo....\n..o..o....\no..o....So\no....T....\n....o.....\n........oo\n\nSample Output 4\n\n5", "sample_input": "3 3\nS.o\n.o.\no.T\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03718", "source_text": "Score : 800 points\n\nProblem Statement\n\nThere is a pond with a rectangular shape.\nThe pond is divided into a grid with H rows and W columns of squares.\nWe will denote the square at the i-th row from the top and j-th column from the left by (i,\\ j).\n\nSome of the squares in the pond contains a lotus leaf floating on the water.\nOn one of those leaves, S, there is a frog trying to get to another leaf T.\nThe state of square (i,\\ j) is given to you by a character a_{ij}, as follows:\n\n. : A square without a leaf.\n\no : A square with a leaf floating on the water.\n\nS : A square with the leaf S.\n\nT : A square with the leaf T.\n\nThe frog will repeatedly perform the following action to get to the leaf T: \"jump to a leaf that is in the same row or the same column as the leaf where the frog is currently located.\"\n\nSnuke is trying to remove some of the leaves, other than S and T, so that the frog cannot get to the leaf T.\nDetermine whether this objective is achievable. If it is achievable, find the minimum necessary number of leaves to remove.\n\nConstraints\n\n2 ≤ H, W ≤ 100\n\na_{ij} is ., o, S or T.\n\nThere is exactly one S among a_{ij}.\n\nThere is exactly one T among a_{ij}.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\na_{11} ... a_{1W}\n:\na_{H1} ... a_{HW}\n\nOutput\n\nIf the objective is achievable, print the minimum necessary number of leaves to remove.\nOtherwise, print -1 instead.\n\nSample Input 1\n\n3 3\nS.o\n.o.\no.T\n\nSample Output 1\n\n2\n\nRemove the upper-right and lower-left leaves.\n\nSample Input 2\n\n3 4\nS...\n.oo.\n...T\n\nSample Output 2\n\n0\n\nSample Input 3\n\n4 3\n.S.\n.o.\n.o.\n.T.\n\nSample Output 3\n\n-1\n\nSample Input 4\n\n10 10\n.o...o..o.\n....o.....\n....oo.oo.\n..oooo..o.\n....oo....\n..o..o....\no..o....So\no....T....\n....o.....\n........oo\n\nSample Output 4\n\n5", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 4061, "cpu_time_ms": 111, "memory_kb": 896}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s856696318", "group_id": "codeNet:p03719", "input_text": "a, b, c = io.read(\"*n\", \"*n\", \"*n\")\nif a <= c and c <= b then\n print(\"Yes\")\nelse\n print(\"No\")\nend", "language": "Lua", "metadata": {"date": 1568435029, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03719.html", "problem_id": "p03719", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03719/input.txt", "sample_output_relpath": "derived/input_output/data/p03719/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03719/Lua/s856696318.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s856696318", "user_id": "u120582723"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "a, b, c = io.read(\"*n\", \"*n\", \"*n\")\nif a <= c and c <= b then\n print(\"Yes\")\nelse\n print(\"No\")\nend", "problem_context": "Score : 100 points\n\nProblem Statement\n\nYou are given three integers A, B and C.\nDetermine whether C is not less than A and not greater than B.\n\nConstraints\n\n-100≤A,B,C≤100\n\nA, B and C are all integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C\n\nOutput\n\nIf the condition is satisfied, print Yes; otherwise, print No.\n\nSample Input 1\n\n1 3 2\n\nSample Output 1\n\nYes\n\nC=2 is not less than A=1 and not greater than B=3, and thus the output should be Yes.\n\nSample Input 2\n\n6 5 4\n\nSample Output 2\n\nNo\n\nC=4 is less than A=6, and thus the output should be No.\n\nSample Input 3\n\n2 2 2\n\nSample Output 3\n\nYes", "sample_input": "1 3 2\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03719", "source_text": "Score : 100 points\n\nProblem Statement\n\nYou are given three integers A, B and C.\nDetermine whether C is not less than A and not greater than B.\n\nConstraints\n\n-100≤A,B,C≤100\n\nA, B and C are all integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C\n\nOutput\n\nIf the condition is satisfied, print Yes; otherwise, print No.\n\nSample Input 1\n\n1 3 2\n\nSample Output 1\n\nYes\n\nC=2 is not less than A=1 and not greater than B=3, and thus the output should be Yes.\n\nSample Input 2\n\n6 5 4\n\nSample Output 2\n\nNo\n\nC=4 is less than A=6, and thus the output should be No.\n\nSample Input 3\n\n2 2 2\n\nSample Output 3\n\nYes", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 99, "cpu_time_ms": 7, "memory_kb": 760}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s433052885", "group_id": "codeNet:p03720", "input_text": "local n, m = io.read(\"*n\", \"*n\")\nlocal t = {}\nfor i = 1, n do\n t[i] = 0\nend\nfor i = 1, m * 2 do\n local a = io.read(\"*n\")\n t[a] = t[a] + 1\nend\nfor i = 1, n do print(t[i]) end\n", "language": "Lua", "metadata": {"date": 1568380622, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03720.html", "problem_id": "p03720", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03720/input.txt", "sample_output_relpath": "derived/input_output/data/p03720/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03720/Lua/s433052885.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s433052885", "user_id": "u120582723"}, "prompt_components": {"gold_output": "2\n2\n1\n1\n", "input_to_evaluate": "local n, m = io.read(\"*n\", \"*n\")\nlocal t = {}\nfor i = 1, n do\n t[i] = 0\nend\nfor i = 1, m * 2 do\n local a = io.read(\"*n\")\n t[a] = t[a] + 1\nend\nfor i = 1, n do print(t[i]) end\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nThere are N cities and M roads.\nThe i-th road (1≤i≤M) connects two cities a_i and b_i (1≤a_i,b_i≤N) bidirectionally.\nThere may be more than one road that connects the same pair of two cities.\nFor each city, how many roads are connected to the city?\n\nConstraints\n\n2≤N,M≤50\n\n1≤a_i,b_i≤N\n\na_i ≠ b_i\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\na_1 b_1\n:\na_M b_M\n\nOutput\n\nPrint the answer in N lines.\nIn the i-th line (1≤i≤N), print the number of roads connected to city i.\n\nSample Input 1\n\n4 3\n1 2\n2 3\n1 4\n\nSample Output 1\n\n2\n2\n1\n1\n\nCity 1 is connected to the 1-st and 3-rd roads.\n\nCity 2 is connected to the 1-st and 2-nd roads.\n\nCity 3 is connected to the 2-nd road.\n\nCity 4 is connected to the 3-rd road.\n\nSample Input 2\n\n2 5\n1 2\n2 1\n1 2\n2 1\n1 2\n\nSample Output 2\n\n5\n5\n\nSample Input 3\n\n8 8\n1 2\n3 4\n1 5\n2 8\n3 7\n5 2\n4 1\n6 8\n\nSample Output 3\n\n3\n3\n2\n2\n2\n1\n1\n2", "sample_input": "4 3\n1 2\n2 3\n1 4\n"}, "reference_outputs": ["2\n2\n1\n1\n"], "source_document_id": "p03720", "source_text": "Score : 200 points\n\nProblem Statement\n\nThere are N cities and M roads.\nThe i-th road (1≤i≤M) connects two cities a_i and b_i (1≤a_i,b_i≤N) bidirectionally.\nThere may be more than one road that connects the same pair of two cities.\nFor each city, how many roads are connected to the city?\n\nConstraints\n\n2≤N,M≤50\n\n1≤a_i,b_i≤N\n\na_i ≠ b_i\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\na_1 b_1\n:\na_M b_M\n\nOutput\n\nPrint the answer in N lines.\nIn the i-th line (1≤i≤N), print the number of roads connected to city i.\n\nSample Input 1\n\n4 3\n1 2\n2 3\n1 4\n\nSample Output 1\n\n2\n2\n1\n1\n\nCity 1 is connected to the 1-st and 3-rd roads.\n\nCity 2 is connected to the 1-st and 2-nd roads.\n\nCity 3 is connected to the 2-nd road.\n\nCity 4 is connected to the 3-rd road.\n\nSample Input 2\n\n2 5\n1 2\n2 1\n1 2\n2 1\n1 2\n\nSample Output 2\n\n5\n5\n\nSample Input 3\n\n8 8\n1 2\n3 4\n1 5\n2 8\n3 7\n5 2\n4 1\n6 8\n\nSample Output 3\n\n3\n3\n2\n2\n2\n1\n1\n2", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 177, "cpu_time_ms": 7, "memory_kb": 760}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s124369342", "group_id": "codeNet:p03721", "input_text": "local n,k=io.read(\"n\",\"n\")\nlocal t={}\nfor i=1,n do\n local a,b=io.read(\"n\",\"n\")\n t[i]={a,b}\nend\ntable.sort(t,function(x,y)\n return x[1]=k then\n print(t[i][1])\n return\n end\nend", "language": "Lua", "metadata": {"date": 1591017141, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03721.html", "problem_id": "p03721", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03721/input.txt", "sample_output_relpath": "derived/input_output/data/p03721/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03721/Lua/s124369342.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s124369342", "user_id": "u045238009"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "local n,k=io.read(\"n\",\"n\")\nlocal t={}\nfor i=1,n do\n local a,b=io.read(\"n\",\"n\")\n t[i]={a,b}\nend\ntable.sort(t,function(x,y)\n return x[1]=k then\n print(t[i][1])\n return\n end\nend", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere is an empty array.\nThe following N operations will be performed to insert integers into the array.\nIn the i-th operation (1≤i≤N), b_i copies of an integer a_i are inserted into the array.\nFind the K-th smallest integer in the array after the N operations.\nFor example, the 4-th smallest integer in the array \\{1,2,2,3,3,3\\} is 3.\n\nConstraints\n\n1≤N≤10^5\n\n1≤a_i,b_i≤10^5\n\n1≤K≤b_1…+…b_n\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\na_1 b_1\n:\na_N b_N\n\nOutput\n\nPrint the K-th smallest integer in the array after the N operations.\n\nSample Input 1\n\n3 4\n1 1\n2 2\n3 3\n\nSample Output 1\n\n3\n\nThe resulting array is the same as the one in the problem statement.\n\nSample Input 2\n\n10 500000\n1 100000\n1 100000\n1 100000\n1 100000\n1 100000\n100000 100000\n100000 100000\n100000 100000\n100000 100000\n100000 100000\n\nSample Output 2\n\n1", "sample_input": "3 4\n1 1\n2 2\n3 3\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03721", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere is an empty array.\nThe following N operations will be performed to insert integers into the array.\nIn the i-th operation (1≤i≤N), b_i copies of an integer a_i are inserted into the array.\nFind the K-th smallest integer in the array after the N operations.\nFor example, the 4-th smallest integer in the array \\{1,2,2,3,3,3\\} is 3.\n\nConstraints\n\n1≤N≤10^5\n\n1≤a_i,b_i≤10^5\n\n1≤K≤b_1…+…b_n\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\na_1 b_1\n:\na_N b_N\n\nOutput\n\nPrint the K-th smallest integer in the array after the N operations.\n\nSample Input 1\n\n3 4\n1 1\n2 2\n3 3\n\nSample Output 1\n\n3\n\nThe resulting array is the same as the one in the problem statement.\n\nSample Input 2\n\n10 500000\n1 100000\n1 100000\n1 100000\n1 100000\n1 100000\n100000 100000\n100000 100000\n100000 100000\n100000 100000\n100000 100000\n\nSample Output 2\n\n1", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 284, "cpu_time_ms": 300, "memory_kb": 13304}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s821829358", "group_id": "codeNet:p03722", "input_text": "local n, m = io.read(\"*n\", \"*n\")\nlocal edge = {}\nfor i = 1, n do edge[i] = {} end\nfor i = 1, m do\n local a, b, c = io.read(\"*n\", \"*n\", \"*n\")\n edge[a][b] = c\nend\n\nlocal taskstate = {}\nfor i = 1, n do taskstate[i] = false end\nlocal tasks = {}\nlocal tasknum = 0\nlocal done = 0\nlocal tasklim = n + 1\nlocal updatecount = 0\nlocal len = {}\nfor i = 1, n do len[i] = -1000000000000 end\nlen[1] = 0\nlocal function addtask(idx)\n if(not taskstate[idx]) then\n taskstate[idx] = true\n tasknum = tasknum + 1\n local taskidx = tasknum % tasklim\n if taskidx == 0 then taskidx = tasklim end\n tasks[taskidx] = idx\n if idx == n then\n updatecount = updatecount + 1\n if n + 2 < updatecount then\n return false\n end\n end\n end\n return true\nend\naddtask(1)\n\nlocal ret = true\nwhile(done < tasknum) do\n done = done + 1\n local taskidx = done % tasklim\n if(taskidx == 0) then taskidx = tasklim end\n local src = tasks[taskidx]\n taskstate[src] = false\n\n for dst, cost in pairs(edge[src]) do\n if len[dst] < len[src] + cost then\n len[dst] = len[src] + cost\n ret = addtask(dst)\n end\n end\n if not ret then break end\n if 10000000 < done then break end\nend\nif ret then\n print(len[n])\nelse\n print(\"inf\")\nend\n", "language": "Lua", "metadata": {"date": 1565052379, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p03722.html", "problem_id": "p03722", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03722/input.txt", "sample_output_relpath": "derived/input_output/data/p03722/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03722/Lua/s821829358.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s821829358", "user_id": "u120582723"}, "prompt_components": {"gold_output": "7\n", "input_to_evaluate": "local n, m = io.read(\"*n\", \"*n\")\nlocal edge = {}\nfor i = 1, n do edge[i] = {} end\nfor i = 1, m do\n local a, b, c = io.read(\"*n\", \"*n\", \"*n\")\n edge[a][b] = c\nend\n\nlocal taskstate = {}\nfor i = 1, n do taskstate[i] = false end\nlocal tasks = {}\nlocal tasknum = 0\nlocal done = 0\nlocal tasklim = n + 1\nlocal updatecount = 0\nlocal len = {}\nfor i = 1, n do len[i] = -1000000000000 end\nlen[1] = 0\nlocal function addtask(idx)\n if(not taskstate[idx]) then\n taskstate[idx] = true\n tasknum = tasknum + 1\n local taskidx = tasknum % tasklim\n if taskidx == 0 then taskidx = tasklim end\n tasks[taskidx] = idx\n if idx == n then\n updatecount = updatecount + 1\n if n + 2 < updatecount then\n return false\n end\n end\n end\n return true\nend\naddtask(1)\n\nlocal ret = true\nwhile(done < tasknum) do\n done = done + 1\n local taskidx = done % tasklim\n if(taskidx == 0) then taskidx = tasklim end\n local src = tasks[taskidx]\n taskstate[src] = false\n\n for dst, cost in pairs(edge[src]) do\n if len[dst] < len[src] + cost then\n len[dst] = len[src] + cost\n ret = addtask(dst)\n end\n end\n if not ret then break end\n if 10000000 < done then break end\nend\nif ret then\n print(len[n])\nelse\n print(\"inf\")\nend\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nThere is a directed graph with N vertices and M edges.\nThe i-th edge (1≤i≤M) points from vertex a_i to vertex b_i, and has a weight c_i.\nWe will play the following single-player game using this graph and a piece.\n\nInitially, the piece is placed at vertex 1, and the score of the player is set to 0.\nThe player can move the piece as follows:\n\nWhen the piece is placed at vertex a_i, move the piece along the i-th edge to vertex b_i. After this move, the score of the player is increased by c_i.\n\nThe player can end the game only when the piece is placed at vertex N.\nThe given graph guarantees that it is possible to traverse from vertex 1 to vertex N.\n\nWhen the player acts optimally to maximize the score at the end of the game, what will the score be?\nIf it is possible to increase the score indefinitely, print inf.\n\nConstraints\n\n2≤N≤1000\n\n1≤M≤min(N(N-1),2000)\n\n1≤a_i,b_i≤N (1≤i≤M)\n\na_i≠b_i (1≤i≤M)\n\na_i≠a_j or b_i≠b_j (1≤i0 and\"inf\"or d[1][n])", "language": "Lua", "metadata": {"date": 1524449098, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p03722.html", "problem_id": "p03722", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03722/input.txt", "sample_output_relpath": "derived/input_output/data/p03722/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03722/Lua/s189837628.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s189837628", "user_id": "u781091740"}, "prompt_components": {"gold_output": "7\n", "input_to_evaluate": "n,m=io.read(\"*n\",\"*n\")\nd={}\ne=-1e15\nfor i=1,n do\n\td[i]={}\n\tfor j=1,n do\n\t\td[i][j]=(i==j and 0 or e)\n\tend\nend\n\nfor i=1,m do\n\ta,b,c=io.read(\"*n\",\"*n\",\"*n\")\n\td[a][b]=c\nend\n\nfor k=n,1,-1 do\n\tfor i=1,n do\n\t\tc=d[i][k]\n\t\tif c~=e then\n\t\t\tfor j=1,n do\n\t\t\t\ta=c+d[k][j]\n\t\t\t\tb=d[i][j]\n\t\t\t\tif b0 and\"inf\"or d[1][n])", "problem_context": "Score : 400 points\n\nProblem Statement\n\nThere is a directed graph with N vertices and M edges.\nThe i-th edge (1≤i≤M) points from vertex a_i to vertex b_i, and has a weight c_i.\nWe will play the following single-player game using this graph and a piece.\n\nInitially, the piece is placed at vertex 1, and the score of the player is set to 0.\nThe player can move the piece as follows:\n\nWhen the piece is placed at vertex a_i, move the piece along the i-th edge to vertex b_i. After this move, the score of the player is increased by c_i.\n\nThe player can end the game only when the piece is placed at vertex N.\nThe given graph guarantees that it is possible to traverse from vertex 1 to vertex N.\n\nWhen the player acts optimally to maximize the score at the end of the game, what will the score be?\nIf it is possible to increase the score indefinitely, print inf.\n\nConstraints\n\n2≤N≤1000\n\n1≤M≤min(N(N-1),2000)\n\n1≤a_i,b_i≤N (1≤i≤M)\n\na_i≠b_i (1≤i≤M)\n\na_i≠a_j or b_i≠b_j (1≤i0 and \"NO\" or \"YES\")", "language": "Lua", "metadata": {"date": 1599618551, "filename_ext": "lua", "original_language": "Lua (Lua 5.3.5)", "problem_description_relpath": "problem_descriptions/p03724.html", "problem_id": "p03724", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03724/input.txt", "sample_output_relpath": "derived/input_output/data/p03724/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03724/Lua/s121053201.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s121053201", "user_id": "u045238009"}, "prompt_components": {"gold_output": "YES\n", "input_to_evaluate": "local n,m=io.read(\"n\",\"n\")\nlocal t={}\nfor i=1,m do\n\tlocal a,b=io.read(\"n\",\"n\")\n\tt[a]=((t[a] or 0)+1)%2\n\tt[b]=((t[b] or 0)+1)%2\nend\nlocal checker=0\nfor i=1,n do\n\tchecker=checker+(t[i] or 0)\nend\nprint(checker>0 and \"NO\" or \"YES\")", "problem_context": "Score : 500 points\n\nProblem Statement\n\nTakahashi is not good at problems about trees in programming contests, and Aoki is helping him practice.\n\nFirst, Takahashi created a tree with N vertices numbered 1 through N, and wrote 0 at each edge.\n\nThen, Aoki gave him M queries. The i-th of them is as follows:\n\nIncrement the number written at each edge along the path connecting vertices a_i and b_i, by one.\n\nAfter Takahashi executed all of the queries, he told Aoki that, for every edge, the written number became an even number.\nHowever, Aoki forgot to confirm that the graph Takahashi created was actually a tree, and it is possible that Takahashi made a mistake in creating a tree or executing queries.\n\nDetermine whether there exists a tree that has the property mentioned by Takahashi.\n\nConstraints\n\n2 ≤ N ≤ 10^5\n\n1 ≤ M ≤ 10^5\n\n1 ≤ a_i,b_i ≤ N\n\na_i ≠ b_i\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\na_1 b_1\n:\na_M b_M\n\nOutput\n\nPrint YES if there exists a tree that has the property mentioned by Takahashi; print NO otherwise.\n\nSample Input 1\n\n4 4\n1 2\n2 4\n1 3\n3 4\n\nSample Output 1\n\nYES\n\nFor example, Takahashi's graph has the property mentioned by him if it has the following edges: 1-2, 1-3 and 1-4.\nIn this case, the number written at every edge will become 2.\n\nSample Input 2\n\n5 5\n1 2\n3 5\n5 1\n3 4\n2 3\n\nSample Output 2\n\nNO", "sample_input": "4 4\n1 2\n2 4\n1 3\n3 4\n"}, "reference_outputs": ["YES\n"], "source_document_id": "p03724", "source_text": "Score : 500 points\n\nProblem Statement\n\nTakahashi is not good at problems about trees in programming contests, and Aoki is helping him practice.\n\nFirst, Takahashi created a tree with N vertices numbered 1 through N, and wrote 0 at each edge.\n\nThen, Aoki gave him M queries. The i-th of them is as follows:\n\nIncrement the number written at each edge along the path connecting vertices a_i and b_i, by one.\n\nAfter Takahashi executed all of the queries, he told Aoki that, for every edge, the written number became an even number.\nHowever, Aoki forgot to confirm that the graph Takahashi created was actually a tree, and it is possible that Takahashi made a mistake in creating a tree or executing queries.\n\nDetermine whether there exists a tree that has the property mentioned by Takahashi.\n\nConstraints\n\n2 ≤ N ≤ 10^5\n\n1 ≤ M ≤ 10^5\n\n1 ≤ a_i,b_i ≤ N\n\na_i ≠ b_i\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\na_1 b_1\n:\na_M b_M\n\nOutput\n\nPrint YES if there exists a tree that has the property mentioned by Takahashi; print NO otherwise.\n\nSample Input 1\n\n4 4\n1 2\n2 4\n1 3\n3 4\n\nSample Output 1\n\nYES\n\nFor example, Takahashi's graph has the property mentioned by him if it has the following edges: 1-2, 1-3 and 1-4.\nIn this case, the number written at every edge will become 2.\n\nSample Input 2\n\n5 5\n1 2\n3 5\n5 1\n3 4\n2 3\n\nSample Output 2\n\nNO", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 227, "cpu_time_ms": 61, "memory_kb": 6420}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s096974652", "group_id": "codeNet:p03725", "input_text": "local mmi = math.min\nlocal h, w, k = io.read(\"*n\", \"*n\", \"*n\", \"*l\")\nlocal t = {}\nlocal inf = 1000000007\nlocal spos = 0\nlocal len = {}\nfor i = 1, h do\n local str = io.read()\n for j = 1, w do\n local idx = (i - 1) * w + j\n local ss = str:sub(j, j)\n t[idx] = not (ss == \"#\")\n len[idx] = inf\n if ss == \"S\" then\n spos = idx\n end\n end\nend\n\nlocal taskstate = {}\nfor i = 1, h * w do taskstate[i] = false end\nlocal tasks = {}\nlocal tasknum = 0\nlocal done = 0\nlocal tasklim = h * w\n\nlocal function addtask(idx)\n if not taskstate[idx] then\n taskstate[idx] = true\n tasknum = tasknum + 1\n local taskidx = tasknum % tasklim\n if taskidx == 0 then taskidx = tasklim end\n tasks[taskidx] = idx\n end\nend\n\nlocal function walk(src, dst)\n if t[dst] and len[src] < k and len[src] + 1 < len[dst] then\n len[dst] = len[src] + 1\n addtask(dst)\n end\nend\n\nlen[spos] = 0\naddtask(spos)\n\nwhile done < tasknum do\n done = done + 1\n local taskidx = done % tasklim\n if taskidx == 0 then taskidx = tasklim end\n local idx = tasks[taskidx]\n taskstate[idx] = false\n\n if w < idx then walk(idx, idx - w) end\n if idx <= (h - 1) * w then walk(idx, idx + w) end\n if idx % w ~= 0 then walk(idx, idx + 1) end\n if idx % w ~= 1 then walk(idx, idx - 1) end\nend\n\nlocal ret = inf\n\nfor i = 1, h do\n for j = 1, w do\n local idx = (i - 1) * w + j\n if len[idx] <= k then\n local cand = mmi(i - 1, h - i)\n cand = mmi(cand, j - 1)\n cand = mmi(cand, w - j)\n ret = mmi(ret, 1 + math.ceil(cand / k))\n end\n end\nend\nprint(ret)\n", "language": "Lua", "metadata": {"date": 1583844757, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p03725.html", "problem_id": "p03725", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03725/input.txt", "sample_output_relpath": "derived/input_output/data/p03725/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03725/Lua/s096974652.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s096974652", "user_id": "u120582723"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "local mmi = math.min\nlocal h, w, k = io.read(\"*n\", \"*n\", \"*n\", \"*l\")\nlocal t = {}\nlocal inf = 1000000007\nlocal spos = 0\nlocal len = {}\nfor i = 1, h do\n local str = io.read()\n for j = 1, w do\n local idx = (i - 1) * w + j\n local ss = str:sub(j, j)\n t[idx] = not (ss == \"#\")\n len[idx] = inf\n if ss == \"S\" then\n spos = idx\n end\n end\nend\n\nlocal taskstate = {}\nfor i = 1, h * w do taskstate[i] = false end\nlocal tasks = {}\nlocal tasknum = 0\nlocal done = 0\nlocal tasklim = h * w\n\nlocal function addtask(idx)\n if not taskstate[idx] then\n taskstate[idx] = true\n tasknum = tasknum + 1\n local taskidx = tasknum % tasklim\n if taskidx == 0 then taskidx = tasklim end\n tasks[taskidx] = idx\n end\nend\n\nlocal function walk(src, dst)\n if t[dst] and len[src] < k and len[src] + 1 < len[dst] then\n len[dst] = len[src] + 1\n addtask(dst)\n end\nend\n\nlen[spos] = 0\naddtask(spos)\n\nwhile done < tasknum do\n done = done + 1\n local taskidx = done % tasklim\n if taskidx == 0 then taskidx = tasklim end\n local idx = tasks[taskidx]\n taskstate[idx] = false\n\n if w < idx then walk(idx, idx - w) end\n if idx <= (h - 1) * w then walk(idx, idx + w) end\n if idx % w ~= 0 then walk(idx, idx + 1) end\n if idx % w ~= 1 then walk(idx, idx - 1) end\nend\n\nlocal ret = inf\n\nfor i = 1, h do\n for j = 1, w do\n local idx = (i - 1) * w + j\n if len[idx] <= k then\n local cand = mmi(i - 1, h - i)\n cand = mmi(cand, j - 1)\n cand = mmi(cand, w - j)\n ret = mmi(ret, 1 + math.ceil(cand / k))\n end\n end\nend\nprint(ret)\n", "problem_context": "Score : 700 points\n\nProblem Statement\n\nTakahashi is locked within a building.\n\nThis building consists of H×W rooms, arranged in H rows and W columns.\nWe will denote the room at the i-th row and j-th column as (i,j). The state of this room is represented by a character A_{i,j}. If A_{i,j}= #, the room is locked and cannot be entered; if A_{i,j}= ., the room is not locked and can be freely entered.\nTakahashi is currently at the room where A_{i,j}= S, which can also be freely entered.\n\nEach room in the 1-st row, 1-st column, H-th row or W-th column, has an exit.\nEach of the other rooms (i,j) is connected to four rooms: (i-1,j), (i+1,j), (i,j-1) and (i,j+1).\n\nTakahashi will use his magic to get out of the building. In one cast, he can do the following:\n\nMove to an adjacent room at most K times, possibly zero. Here, locked rooms cannot be entered.\n\nThen, select and unlock at most K locked rooms, possibly zero. Those rooms will remain unlocked from then on.\n\nHis objective is to reach a room with an exit. Find the minimum necessary number of casts to do so.\n\nIt is guaranteed that Takahashi is initially at a room without an exit.\n\nConstraints\n\n3 ≤ H ≤ 800\n\n3 ≤ W ≤ 800\n\n1 ≤ K ≤ H×W\n\nEach A_{i,j} is # , . or S.\n\nThere uniquely exists (i,j) such that A_{i,j}= S, and it satisfies 2 ≤ i ≤ H-1 and 2 ≤ j ≤ W-1.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W K\nA_{1,1}A_{1,2}...A_{1,W}\n:\nA_{H,1}A_{H,2}...A_{H,W}\n\nOutput\n\nPrint the minimum necessary number of casts.\n\nSample Input 1\n\n3 3 3\n#.#\n#S.\n###\n\nSample Output 1\n\n1\n\nTakahashi can move to room (1,2) in one cast.\n\nSample Input 2\n\n3 3 3\n###\n#S#\n###\n\nSample Output 2\n\n2\n\nTakahashi cannot move in the first cast, but can unlock room (1,2).\nThen, he can move to room (1,2) in the next cast, achieving the objective in two casts.\n\nSample Input 3\n\n7 7 2\n#######\n#######\n##...##\n###S###\n##.#.##\n###.###\n#######\n\nSample Output 3\n\n2", "sample_input": "3 3 3\n#.#\n#S.\n###\n"}, "reference_outputs": ["1\n"], "source_document_id": "p03725", "source_text": "Score : 700 points\n\nProblem Statement\n\nTakahashi is locked within a building.\n\nThis building consists of H×W rooms, arranged in H rows and W columns.\nWe will denote the room at the i-th row and j-th column as (i,j). The state of this room is represented by a character A_{i,j}. If A_{i,j}= #, the room is locked and cannot be entered; if A_{i,j}= ., the room is not locked and can be freely entered.\nTakahashi is currently at the room where A_{i,j}= S, which can also be freely entered.\n\nEach room in the 1-st row, 1-st column, H-th row or W-th column, has an exit.\nEach of the other rooms (i,j) is connected to four rooms: (i-1,j), (i+1,j), (i,j-1) and (i,j+1).\n\nTakahashi will use his magic to get out of the building. In one cast, he can do the following:\n\nMove to an adjacent room at most K times, possibly zero. Here, locked rooms cannot be entered.\n\nThen, select and unlock at most K locked rooms, possibly zero. Those rooms will remain unlocked from then on.\n\nHis objective is to reach a room with an exit. Find the minimum necessary number of casts to do so.\n\nIt is guaranteed that Takahashi is initially at a room without an exit.\n\nConstraints\n\n3 ≤ H ≤ 800\n\n3 ≤ W ≤ 800\n\n1 ≤ K ≤ H×W\n\nEach A_{i,j} is # , . or S.\n\nThere uniquely exists (i,j) such that A_{i,j}= S, and it satisfies 2 ≤ i ≤ H-1 and 2 ≤ j ≤ W-1.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W K\nA_{1,1}A_{1,2}...A_{1,W}\n:\nA_{H,1}A_{H,2}...A_{H,W}\n\nOutput\n\nPrint the minimum necessary number of casts.\n\nSample Input 1\n\n3 3 3\n#.#\n#S.\n###\n\nSample Output 1\n\n1\n\nTakahashi can move to room (1,2) in one cast.\n\nSample Input 2\n\n3 3 3\n###\n#S#\n###\n\nSample Output 2\n\n2\n\nTakahashi cannot move in the first cast, but can unlock room (1,2).\nThen, he can move to room (1,2) in the next cast, achieving the objective in two casts.\n\nSample Input 3\n\n7 7 2\n#######\n#######\n##...##\n###S###\n##.#.##\n###.###\n#######\n\nSample Output 3\n\n2", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1552, "cpu_time_ms": 76, "memory_kb": 33652}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s609232279", "group_id": "codeNet:p03729", "input_text": "a,b,c=io.read():match(\"(%l+)%s(%l+)%s(%l+)\")\nprint((a:match(\".$\")==b:match(\"^.\")and b:match(\".$\")==c:match(\"^.\"))and \"YES\"or\"NO\" )", "language": "Lua", "metadata": {"date": 1551750361, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03729.html", "problem_id": "p03729", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03729/input.txt", "sample_output_relpath": "derived/input_output/data/p03729/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03729/Lua/s609232279.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s609232279", "user_id": "u837412668"}, "prompt_components": {"gold_output": "YES\n", "input_to_evaluate": "a,b,c=io.read():match(\"(%l+)%s(%l+)%s(%l+)\")\nprint((a:match(\".$\")==b:match(\"^.\")and b:match(\".$\")==c:match(\"^.\"))and \"YES\"or\"NO\" )", "problem_context": "Score : 100 points\n\nProblem Statement\n\nYou are given three strings A, B and C. Check whether they form a word chain.\n\nMore formally, determine whether both of the following are true:\n\nThe last character in A and the initial character in B are the same.\n\nThe last character in B and the initial character in C are the same.\n\nIf both are true, print YES. Otherwise, print NO.\n\nConstraints\n\nA, B and C are all composed of lowercase English letters (a - z).\n\n1 ≤ |A|, |B|, |C| ≤ 10, where |A|, |B| and |C| are the lengths of A, B and C, respectively.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C\n\nOutput\n\nPrint YES or NO.\n\nSample Input 1\n\nrng gorilla apple\n\nSample Output 1\n\nYES\n\nThey form a word chain.\n\nSample Input 2\n\nyakiniku unagi sushi\n\nSample Output 2\n\nNO\n\nA and B form a word chain, but B and C do not.\n\nSample Input 3\n\na a a\n\nSample Output 3\n\nYES\n\nSample Input 4\n\naaaaaaaaab aaaaaaaaaa aaaaaaaaab\n\nSample Output 4\n\nNO", "sample_input": "rng gorilla apple\n"}, "reference_outputs": ["YES\n"], "source_document_id": "p03729", "source_text": "Score : 100 points\n\nProblem Statement\n\nYou are given three strings A, B and C. Check whether they form a word chain.\n\nMore formally, determine whether both of the following are true:\n\nThe last character in A and the initial character in B are the same.\n\nThe last character in B and the initial character in C are the same.\n\nIf both are true, print YES. Otherwise, print NO.\n\nConstraints\n\nA, B and C are all composed of lowercase English letters (a - z).\n\n1 ≤ |A|, |B|, |C| ≤ 10, where |A|, |B| and |C| are the lengths of A, B and C, respectively.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C\n\nOutput\n\nPrint YES or NO.\n\nSample Input 1\n\nrng gorilla apple\n\nSample Output 1\n\nYES\n\nThey form a word chain.\n\nSample Input 2\n\nyakiniku unagi sushi\n\nSample Output 2\n\nNO\n\nA and B form a word chain, but B and C do not.\n\nSample Input 3\n\na a a\n\nSample Output 3\n\nYES\n\nSample Input 4\n\naaaaaaaaab aaaaaaaaaa aaaaaaaaab\n\nSample Output 4\n\nNO", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 131, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s092312808", "group_id": "codeNet:p03731", "input_text": "N,T=io.read(\"n\",\"n\")\nt1=io.read(\"n\")\nans=0\nprev=0\nfor i=2,N do\n ti = io.read(\"n\")\n dur = ti - prev\n ans = ans + (dur > T and T or dur)\n prev = ti\nend\nans = ans + T\nprint(ans)", "language": "Lua", "metadata": {"date": 1566879635, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03731.html", "problem_id": "p03731", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03731/input.txt", "sample_output_relpath": "derived/input_output/data/p03731/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03731/Lua/s092312808.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s092312808", "user_id": "u162773977"}, "prompt_components": {"gold_output": "7\n", "input_to_evaluate": "N,T=io.read(\"n\",\"n\")\nt1=io.read(\"n\")\nans=0\nprev=0\nfor i=2,N do\n ti = io.read(\"n\")\n dur = ti - prev\n ans = ans + (dur > T and T or dur)\n prev = ti\nend\nans = ans + T\nprint(ans)", "problem_context": "Score : 300 points\n\nProblem Statement\n\nIn a public bath, there is a shower which emits water for T seconds when the switch is pushed.\n\nIf the switch is pushed when the shower is already emitting water, from that moment it will be emitting water for T seconds.\nNote that it does not mean that the shower emits water for T additional seconds.\n\nN people will push the switch while passing by the shower.\nThe i-th person will push the switch t_i seconds after the first person pushes it.\n\nHow long will the shower emit water in total?\n\nConstraints\n\n1 ≤ N ≤ 200,000\n\n1 ≤ T ≤ 10^9\n\n0 = t_1 < t_2 < t_3 < , ..., < t_{N-1} < t_N ≤ 10^9\n\nT and each t_i are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN T\nt_1 t_2 ... t_N\n\nOutput\n\nAssume that the shower will emit water for a total of X seconds. Print X.\n\nSample Input 1\n\n2 4\n0 3\n\nSample Output 1\n\n7\n\nThree seconds after the first person pushes the water, the switch is pushed again and the shower emits water for four more seconds, for a total of seven seconds.\n\nSample Input 2\n\n2 4\n0 5\n\nSample Output 2\n\n8\n\nOne second after the shower stops emission of water triggered by the first person, the switch is pushed again.\n\nSample Input 3\n\n4 1000000000\n0 1000 1000000 1000000000\n\nSample Output 3\n\n2000000000\n\nSample Input 4\n\n1 1\n0\n\nSample Output 4\n\n1\n\nSample Input 5\n\n9 10\n0 3 5 7 100 110 200 300 311\n\nSample Output 5\n\n67", "sample_input": "2 4\n0 3\n"}, "reference_outputs": ["7\n"], "source_document_id": "p03731", "source_text": "Score : 300 points\n\nProblem Statement\n\nIn a public bath, there is a shower which emits water for T seconds when the switch is pushed.\n\nIf the switch is pushed when the shower is already emitting water, from that moment it will be emitting water for T seconds.\nNote that it does not mean that the shower emits water for T additional seconds.\n\nN people will push the switch while passing by the shower.\nThe i-th person will push the switch t_i seconds after the first person pushes it.\n\nHow long will the shower emit water in total?\n\nConstraints\n\n1 ≤ N ≤ 200,000\n\n1 ≤ T ≤ 10^9\n\n0 = t_1 < t_2 < t_3 < , ..., < t_{N-1} < t_N ≤ 10^9\n\nT and each t_i are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN T\nt_1 t_2 ... t_N\n\nOutput\n\nAssume that the shower will emit water for a total of X seconds. Print X.\n\nSample Input 1\n\n2 4\n0 3\n\nSample Output 1\n\n7\n\nThree seconds after the first person pushes the water, the switch is pushed again and the shower emits water for four more seconds, for a total of seven seconds.\n\nSample Input 2\n\n2 4\n0 5\n\nSample Output 2\n\n8\n\nOne second after the shower stops emission of water triggered by the first person, the switch is pushed again.\n\nSample Input 3\n\n4 1000000000\n0 1000 1000000 1000000000\n\nSample Output 3\n\n2000000000\n\nSample Input 4\n\n1 1\n0\n\nSample Output 4\n\n1\n\nSample Input 5\n\n9 10\n0 3 5 7 100 110 200 300 311\n\nSample Output 5\n\n67", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 178, "cpu_time_ms": 100, "memory_kb": 760}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s520340837", "group_id": "codeNet:p03731", "input_text": "N,T=io.read(\"n\",\"n\")\nt1=io.read(\"n\")\nans=0\nfor i=2,N do\n ti = io.read(\"n\")\n ans = ans + (ti > T and T or ti)\nend\nans = ans + T\nprint(ans)", "language": "Lua", "metadata": {"date": 1566878976, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03731.html", "problem_id": "p03731", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03731/input.txt", "sample_output_relpath": "derived/input_output/data/p03731/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03731/Lua/s520340837.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s520340837", "user_id": "u162773977"}, "prompt_components": {"gold_output": "7\n", "input_to_evaluate": "N,T=io.read(\"n\",\"n\")\nt1=io.read(\"n\")\nans=0\nfor i=2,N do\n ti = io.read(\"n\")\n ans = ans + (ti > T and T or ti)\nend\nans = ans + T\nprint(ans)", "problem_context": "Score : 300 points\n\nProblem Statement\n\nIn a public bath, there is a shower which emits water for T seconds when the switch is pushed.\n\nIf the switch is pushed when the shower is already emitting water, from that moment it will be emitting water for T seconds.\nNote that it does not mean that the shower emits water for T additional seconds.\n\nN people will push the switch while passing by the shower.\nThe i-th person will push the switch t_i seconds after the first person pushes it.\n\nHow long will the shower emit water in total?\n\nConstraints\n\n1 ≤ N ≤ 200,000\n\n1 ≤ T ≤ 10^9\n\n0 = t_1 < t_2 < t_3 < , ..., < t_{N-1} < t_N ≤ 10^9\n\nT and each t_i are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN T\nt_1 t_2 ... t_N\n\nOutput\n\nAssume that the shower will emit water for a total of X seconds. Print X.\n\nSample Input 1\n\n2 4\n0 3\n\nSample Output 1\n\n7\n\nThree seconds after the first person pushes the water, the switch is pushed again and the shower emits water for four more seconds, for a total of seven seconds.\n\nSample Input 2\n\n2 4\n0 5\n\nSample Output 2\n\n8\n\nOne second after the shower stops emission of water triggered by the first person, the switch is pushed again.\n\nSample Input 3\n\n4 1000000000\n0 1000 1000000 1000000000\n\nSample Output 3\n\n2000000000\n\nSample Input 4\n\n1 1\n0\n\nSample Output 4\n\n1\n\nSample Input 5\n\n9 10\n0 3 5 7 100 110 200 300 311\n\nSample Output 5\n\n67", "sample_input": "2 4\n0 3\n"}, "reference_outputs": ["7\n"], "source_document_id": "p03731", "source_text": "Score : 300 points\n\nProblem Statement\n\nIn a public bath, there is a shower which emits water for T seconds when the switch is pushed.\n\nIf the switch is pushed when the shower is already emitting water, from that moment it will be emitting water for T seconds.\nNote that it does not mean that the shower emits water for T additional seconds.\n\nN people will push the switch while passing by the shower.\nThe i-th person will push the switch t_i seconds after the first person pushes it.\n\nHow long will the shower emit water in total?\n\nConstraints\n\n1 ≤ N ≤ 200,000\n\n1 ≤ T ≤ 10^9\n\n0 = t_1 < t_2 < t_3 < , ..., < t_{N-1} < t_N ≤ 10^9\n\nT and each t_i are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN T\nt_1 t_2 ... t_N\n\nOutput\n\nAssume that the shower will emit water for a total of X seconds. Print X.\n\nSample Input 1\n\n2 4\n0 3\n\nSample Output 1\n\n7\n\nThree seconds after the first person pushes the water, the switch is pushed again and the shower emits water for four more seconds, for a total of seven seconds.\n\nSample Input 2\n\n2 4\n0 5\n\nSample Output 2\n\n8\n\nOne second after the shower stops emission of water triggered by the first person, the switch is pushed again.\n\nSample Input 3\n\n4 1000000000\n0 1000 1000000 1000000000\n\nSample Output 3\n\n2000000000\n\nSample Input 4\n\n1 1\n0\n\nSample Output 4\n\n1\n\nSample Input 5\n\n9 10\n0 3 5 7 100 110 200 300 311\n\nSample Output 5\n\n67", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 139, "cpu_time_ms": 78, "memory_kb": 760}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s089190309", "group_id": "codeNet:p03733", "input_text": "local n, t = io.read(\"*n\", \"*n\", \"*l\")\nlocal str = io.read()\nlocal a = {}\nfor numstr in string.gmatch(str, \"%d+\") do\n table.insert(a, tonumber(numstr))\nend\nlocal totlen = a[#a] + t\nfor i = 2, n do\n totlen = totlen - math.max(0, a[i] - a[i - 1] - t)\nend\nprint(totlen)\n", "language": "Lua", "metadata": {"date": 1555594657, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p03733.html", "problem_id": "p03733", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03733/input.txt", "sample_output_relpath": "derived/input_output/data/p03733/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03733/Lua/s089190309.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s089190309", "user_id": "u120582723"}, "prompt_components": {"gold_output": "7\n", "input_to_evaluate": "local n, t = io.read(\"*n\", \"*n\", \"*l\")\nlocal str = io.read()\nlocal a = {}\nfor numstr in string.gmatch(str, \"%d+\") do\n table.insert(a, tonumber(numstr))\nend\nlocal totlen = a[#a] + t\nfor i = 2, n do\n totlen = totlen - math.max(0, a[i] - a[i - 1] - t)\nend\nprint(totlen)\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nIn a public bath, there is a shower which emits water for T seconds when the switch is pushed.\n\nIf the switch is pushed when the shower is already emitting water, from that moment it will be emitting water for T seconds.\nNote that it does not mean that the shower emits water for T additional seconds.\n\nN people will push the switch while passing by the shower.\nThe i-th person will push the switch t_i seconds after the first person pushes it.\n\nHow long will the shower emit water in total?\n\nConstraints\n\n1 ≤ N ≤ 200,000\n\n1 ≤ T ≤ 10^9\n\n0 = t_1 < t_2 < t_3 < , ..., < t_{N-1} < t_N ≤ 10^9\n\nT and each t_i are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN T\nt_1 t_2 ... t_N\n\nOutput\n\nAssume that the shower will emit water for a total of X seconds. Print X.\n\nSample Input 1\n\n2 4\n0 3\n\nSample Output 1\n\n7\n\nThree seconds after the first person pushes the water, the switch is pushed again and the shower emits water for four more seconds, for a total of seven seconds.\n\nSample Input 2\n\n2 4\n0 5\n\nSample Output 2\n\n8\n\nOne second after the shower stops emission of water triggered by the first person, the switch is pushed again.\n\nSample Input 3\n\n4 1000000000\n0 1000 1000000 1000000000\n\nSample Output 3\n\n2000000000\n\nSample Input 4\n\n1 1\n0\n\nSample Output 4\n\n1\n\nSample Input 5\n\n9 10\n0 3 5 7 100 110 200 300 311\n\nSample Output 5\n\n67", "sample_input": "2 4\n0 3\n"}, "reference_outputs": ["7\n"], "source_document_id": "p03733", "source_text": "Score : 300 points\n\nProblem Statement\n\nIn a public bath, there is a shower which emits water for T seconds when the switch is pushed.\n\nIf the switch is pushed when the shower is already emitting water, from that moment it will be emitting water for T seconds.\nNote that it does not mean that the shower emits water for T additional seconds.\n\nN people will push the switch while passing by the shower.\nThe i-th person will push the switch t_i seconds after the first person pushes it.\n\nHow long will the shower emit water in total?\n\nConstraints\n\n1 ≤ N ≤ 200,000\n\n1 ≤ T ≤ 10^9\n\n0 = t_1 < t_2 < t_3 < , ..., < t_{N-1} < t_N ≤ 10^9\n\nT and each t_i are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN T\nt_1 t_2 ... t_N\n\nOutput\n\nAssume that the shower will emit water for a total of X seconds. Print X.\n\nSample Input 1\n\n2 4\n0 3\n\nSample Output 1\n\n7\n\nThree seconds after the first person pushes the water, the switch is pushed again and the shower emits water for four more seconds, for a total of seven seconds.\n\nSample Input 2\n\n2 4\n0 5\n\nSample Output 2\n\n8\n\nOne second after the shower stops emission of water triggered by the first person, the switch is pushed again.\n\nSample Input 3\n\n4 1000000000\n0 1000 1000000 1000000000\n\nSample Output 3\n\n2000000000\n\nSample Input 4\n\n1 1\n0\n\nSample Output 4\n\n1\n\nSample Input 5\n\n9 10\n0 3 5 7 100 110 200 300 311\n\nSample Output 5\n\n67", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 269, "cpu_time_ms": 92, "memory_kb": 11980}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s032628437", "group_id": "codeNet:p03735", "input_text": "local mmi, mma = math.min, math.max\nlocal n = io.read(\"*n\")\nlocal a, b = {}, {}\nlocal ta, tb = io.read(\"*n\"), io.read(\"*n\")\nif tb < ta then ta, tb = tb, ta end\nlocal a, b = {ta}, {tb}\nlocal minv, minp, maxv, maxp = ta, 1, tb, 1\nfor i = 2, n do\n ta, tb= io.read(\"*n\", \"*n\")\n if tb < ta then ta, tb = tb, ta end\n a[i], b[i] = ta, tb\n if ta < minv then\n minv = ta\n minp = i\n end\n if maxv < tb then\n maxv = tb\n maxp = i\n end\nend\nlocal ret = nil\nif minv == maxv then\n -- (A) all same\n ret = 0\nelse\n -- (B) R has min, B has max value\n local redmax, bluemin = a[1], b[1]\n for i = 2, n do\n redmax = mma(redmax, a[i])\n bluemin = mmi(bluemin, b[i])\n end\n ret = (redmax - minv) * (maxv - bluemin)\nend\n\n-- (C) R has both of min and max values\ndo\n local t = {}\n for i = 1, n do t[i] = i end\n table.sort(t, function(x, y) return a[x] < a[y] end)\n local bmin = nil\n local bmax = nil\n local minlen = a[t[n]] - a[t[1]]\n for i = 1, n do\n if i == 1 then\n bmin, bmax = b[t[1]], b[t[1]]\n else\n bmin = mmi(bmin, b[t[i]])\n bmax = mma(bmax, b[t[i]])\n end\n local l = i == n and bmin or mmi(a[t[i + 1]], bmin)\n local r = i == n and bmax or mma(a[t[n]], bmax)\n minlen = mmi(minlen, r - l)\n end\n ret = mmi(ret, minlen * (maxv - minv))\nend\nprint(ret)\n", "language": "Lua", "metadata": {"date": 1570921007, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03735.html", "problem_id": "p03735", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03735/input.txt", "sample_output_relpath": "derived/input_output/data/p03735/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03735/Lua/s032628437.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s032628437", "user_id": "u120582723"}, "prompt_components": {"gold_output": "15\n", "input_to_evaluate": "local mmi, mma = math.min, math.max\nlocal n = io.read(\"*n\")\nlocal a, b = {}, {}\nlocal ta, tb = io.read(\"*n\"), io.read(\"*n\")\nif tb < ta then ta, tb = tb, ta end\nlocal a, b = {ta}, {tb}\nlocal minv, minp, maxv, maxp = ta, 1, tb, 1\nfor i = 2, n do\n ta, tb= io.read(\"*n\", \"*n\")\n if tb < ta then ta, tb = tb, ta end\n a[i], b[i] = ta, tb\n if ta < minv then\n minv = ta\n minp = i\n end\n if maxv < tb then\n maxv = tb\n maxp = i\n end\nend\nlocal ret = nil\nif minv == maxv then\n -- (A) all same\n ret = 0\nelse\n -- (B) R has min, B has max value\n local redmax, bluemin = a[1], b[1]\n for i = 2, n do\n redmax = mma(redmax, a[i])\n bluemin = mmi(bluemin, b[i])\n end\n ret = (redmax - minv) * (maxv - bluemin)\nend\n\n-- (C) R has both of min and max values\ndo\n local t = {}\n for i = 1, n do t[i] = i end\n table.sort(t, function(x, y) return a[x] < a[y] end)\n local bmin = nil\n local bmax = nil\n local minlen = a[t[n]] - a[t[1]]\n for i = 1, n do\n if i == 1 then\n bmin, bmax = b[t[1]], b[t[1]]\n else\n bmin = mmi(bmin, b[t[i]])\n bmax = mma(bmax, b[t[i]])\n end\n local l = i == n and bmin or mmi(a[t[i + 1]], bmin)\n local r = i == n and bmax or mma(a[t[n]], bmax)\n minlen = mmi(minlen, r - l)\n end\n ret = mmi(ret, minlen * (maxv - minv))\nend\nprint(ret)\n", "problem_context": "Score : 700 points\n\nProblem Statement\n\nThere are N bags, each containing two white balls. The i-th box contains two balls with integers x_i and y_i written on them, respectively.\n\nFor each of these bags, you will paint one of the balls red, and paint the other blue.\n\nAfterwards, the 2N balls will be classified according to color.\n\nThen, we will define the following:\n\nR_{max}: the maximum integer written on a ball painted in red\n\nR_{min}: the minimum integer written on a ball painted in red\n\nB_{max}: the maximum integer written on a ball painted in blue\n\nB_{min}: the minimum integer written on a ball painted in blue\n\nFind the minimum possible value of (R_{max} - R_{min}) \\times (B_{max} - B_{min}).\n\nConstraints\n\n1 ≤ N ≤ 200,000\n\n1 ≤ x_i, y_i ≤ 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nx_1 y_1\nx_2 y_2\n:\nx_N y_N\n\nOutput\n\nPrint the minimum possible value.\n\nSample Input 1\n\n3\n1 2\n3 4\n5 6\n\nSample Output 1\n\n15\n\nThe optimal solution is to paint the balls with x_1, x_2, y_3 red, and paint the balls with y_1, y_2, x_3 blue.\n\nSample Input 2\n\n3\n1010 10\n1000 1\n20 1020\n\nSample Output 2\n\n380\n\nSample Input 3\n\n2\n1 1\n1000000000 1000000000\n\nSample Output 3\n\n999999998000000001", "sample_input": "3\n1 2\n3 4\n5 6\n"}, "reference_outputs": ["15\n"], "source_document_id": "p03735", "source_text": "Score : 700 points\n\nProblem Statement\n\nThere are N bags, each containing two white balls. The i-th box contains two balls with integers x_i and y_i written on them, respectively.\n\nFor each of these bags, you will paint one of the balls red, and paint the other blue.\n\nAfterwards, the 2N balls will be classified according to color.\n\nThen, we will define the following:\n\nR_{max}: the maximum integer written on a ball painted in red\n\nR_{min}: the minimum integer written on a ball painted in red\n\nB_{max}: the maximum integer written on a ball painted in blue\n\nB_{min}: the minimum integer written on a ball painted in blue\n\nFind the minimum possible value of (R_{max} - R_{min}) \\times (B_{max} - B_{min}).\n\nConstraints\n\n1 ≤ N ≤ 200,000\n\n1 ≤ x_i, y_i ≤ 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nx_1 y_1\nx_2 y_2\n:\nx_N y_N\n\nOutput\n\nPrint the minimum possible value.\n\nSample Input 1\n\n3\n1 2\n3 4\n5 6\n\nSample Output 1\n\n15\n\nThe optimal solution is to paint the balls with x_1, x_2, y_3 red, and paint the balls with y_1, y_2, x_3 blue.\n\nSample Input 2\n\n3\n1010 10\n1000 1\n20 1020\n\nSample Output 2\n\n380\n\nSample Input 3\n\n2\n1 1\n1000000000 1000000000\n\nSample Output 3\n\n999999998000000001", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1296, "cpu_time_ms": 735, "memory_kb": 13180}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s692874057", "group_id": "codeNet:p03737", "input_text": "function f(x)\n return(x:match(\"^.\"))\nend\na=io.read()\nprint(string.upper(a:gsub(\"%l+\",f):gsub(\"%s\",\"\")))", "language": "Lua", "metadata": {"date": 1551749514, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p03737.html", "problem_id": "p03737", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03737/input.txt", "sample_output_relpath": "derived/input_output/data/p03737/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03737/Lua/s692874057.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s692874057", "user_id": "u837412668"}, "prompt_components": {"gold_output": "ABC\n", "input_to_evaluate": "function f(x)\n return(x:match(\"^.\"))\nend\na=io.read()\nprint(string.upper(a:gsub(\"%l+\",f):gsub(\"%s\",\"\")))", "problem_context": "Score : 100 points\n\nProblem Statement\n\nYou are given three words s_1, s_2 and s_3, each composed of lowercase English letters, with spaces in between.\nPrint the acronym formed from the uppercased initial letters of the words.\n\nConstraints\n\ns_1, s_2 and s_3 are composed of lowercase English letters.\n\n1 ≤ |s_i| ≤ 10 (1≤i≤3)\n\nInput\n\nInput is given from Standard Input in the following format:\n\ns_1 s_2 s_3\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\natcoder beginner contest\n\nSample Output 1\n\nABC\n\nThe initial letters of atcoder, beginner and contest are a, b and c. Uppercase and concatenate them to obtain ABC.\n\nSample Input 2\n\nresident register number\n\nSample Output 2\n\nRRN\n\nSample Input 3\n\nk nearest neighbor\n\nSample Output 3\n\nKNN\n\nSample Input 4\n\nasync layered coding\n\nSample Output 4\n\nALC", "sample_input": "atcoder beginner contest\n"}, "reference_outputs": ["ABC\n"], "source_document_id": "p03737", "source_text": "Score : 100 points\n\nProblem Statement\n\nYou are given three words s_1, s_2 and s_3, each composed of lowercase English letters, with spaces in between.\nPrint the acronym formed from the uppercased initial letters of the words.\n\nConstraints\n\ns_1, s_2 and s_3 are composed of lowercase English letters.\n\n1 ≤ |s_i| ≤ 10 (1≤i≤3)\n\nInput\n\nInput is given from Standard Input in the following format:\n\ns_1 s_2 s_3\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\natcoder beginner contest\n\nSample Output 1\n\nABC\n\nThe initial letters of atcoder, beginner and contest are a, b and c. Uppercase and concatenate them to obtain ABC.\n\nSample Input 2\n\nresident register number\n\nSample Output 2\n\nRRN\n\nSample Input 3\n\nk nearest neighbor\n\nSample Output 3\n\nKNN\n\nSample Input 4\n\nasync layered coding\n\nSample Output 4\n\nALC", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 104, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s920235426", "group_id": "codeNet:p03737", "input_text": "function f(x)\n return(x:match(\"^.\"))\nend\na=io.read()\nprint(string.upper(a:gsub(\"%l+\",f):gsub(\"%s\",\"\")))", "language": "Lua", "metadata": {"date": 1551749503, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03737.html", "problem_id": "p03737", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03737/input.txt", "sample_output_relpath": "derived/input_output/data/p03737/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03737/Lua/s920235426.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s920235426", "user_id": "u837412668"}, "prompt_components": {"gold_output": "ABC\n", "input_to_evaluate": "function f(x)\n return(x:match(\"^.\"))\nend\na=io.read()\nprint(string.upper(a:gsub(\"%l+\",f):gsub(\"%s\",\"\")))", "problem_context": "Score : 100 points\n\nProblem Statement\n\nYou are given three words s_1, s_2 and s_3, each composed of lowercase English letters, with spaces in between.\nPrint the acronym formed from the uppercased initial letters of the words.\n\nConstraints\n\ns_1, s_2 and s_3 are composed of lowercase English letters.\n\n1 ≤ |s_i| ≤ 10 (1≤i≤3)\n\nInput\n\nInput is given from Standard Input in the following format:\n\ns_1 s_2 s_3\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\natcoder beginner contest\n\nSample Output 1\n\nABC\n\nThe initial letters of atcoder, beginner and contest are a, b and c. Uppercase and concatenate them to obtain ABC.\n\nSample Input 2\n\nresident register number\n\nSample Output 2\n\nRRN\n\nSample Input 3\n\nk nearest neighbor\n\nSample Output 3\n\nKNN\n\nSample Input 4\n\nasync layered coding\n\nSample Output 4\n\nALC", "sample_input": "atcoder beginner contest\n"}, "reference_outputs": ["ABC\n"], "source_document_id": "p03737", "source_text": "Score : 100 points\n\nProblem Statement\n\nYou are given three words s_1, s_2 and s_3, each composed of lowercase English letters, with spaces in between.\nPrint the acronym formed from the uppercased initial letters of the words.\n\nConstraints\n\ns_1, s_2 and s_3 are composed of lowercase English letters.\n\n1 ≤ |s_i| ≤ 10 (1≤i≤3)\n\nInput\n\nInput is given from Standard Input in the following format:\n\ns_1 s_2 s_3\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\natcoder beginner contest\n\nSample Output 1\n\nABC\n\nThe initial letters of atcoder, beginner and contest are a, b and c. Uppercase and concatenate them to obtain ABC.\n\nSample Input 2\n\nresident register number\n\nSample Output 2\n\nRRN\n\nSample Input 3\n\nk nearest neighbor\n\nSample Output 3\n\nKNN\n\nSample Input 4\n\nasync layered coding\n\nSample Output 4\n\nALC", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 104, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s426055661", "group_id": "codeNet:p03738", "input_text": "A = tostring(io.read())\nB = tostring(io.read())\nif #A>#B then\n print(\"GREATER\")\nelseif #A<#B then\n print(\"LESS\") \nelseif #A==#B then\n i = 1\n while A:sub(i,i) == B:sub(i,i) and i<#A do\n i = i+1\n end\n if A:sub(i,i) > B:sub(i,i) then\n print(\"GREATER\")\n elseif A:sub(i,i) < B:sub(i,i) then\n print(\"LESS\")\n elseif A:sub(i,i) == B:sub(i,i) then\n print(\"EQUAL\")\n end\nend", "language": "Lua", "metadata": {"date": 1587144940, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03738.html", "problem_id": "p03738", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03738/input.txt", "sample_output_relpath": "derived/input_output/data/p03738/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03738/Lua/s426055661.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s426055661", "user_id": "u045238009"}, "prompt_components": {"gold_output": "GREATER\n", "input_to_evaluate": "A = tostring(io.read())\nB = tostring(io.read())\nif #A>#B then\n print(\"GREATER\")\nelseif #A<#B then\n print(\"LESS\") \nelseif #A==#B then\n i = 1\n while A:sub(i,i) == B:sub(i,i) and i<#A do\n i = i+1\n end\n if A:sub(i,i) > B:sub(i,i) then\n print(\"GREATER\")\n elseif A:sub(i,i) < B:sub(i,i) then\n print(\"LESS\")\n elseif A:sub(i,i) == B:sub(i,i) then\n print(\"EQUAL\")\n end\nend", "problem_context": "Score : 200 points\n\nProblem Statement\n\nYou are given two positive integers A and B. Compare the magnitudes of these numbers.\n\nConstraints\n\n1 ≤ A, B ≤ 10^{100}\n\nNeither A nor B begins with a 0.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA\nB\n\nOutput\n\nPrint GREATER if A>B, LESS if A24, print GREATER.\n\nSample Input 2\n\n850\n3777\n\nSample Output 2\n\nLESS\n\nSample Input 3\n\n9720246\n22516266\n\nSample Output 3\n\nLESS\n\nSample Input 4\n\n123456789012345678901234567890\n234567890123456789012345678901\n\nSample Output 4\n\nLESS", "sample_input": "36\n24\n"}, "reference_outputs": ["GREATER\n"], "source_document_id": "p03738", "source_text": "Score : 200 points\n\nProblem Statement\n\nYou are given two positive integers A and B. Compare the magnitudes of these numbers.\n\nConstraints\n\n1 ≤ A, B ≤ 10^{100}\n\nNeither A nor B begins with a 0.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA\nB\n\nOutput\n\nPrint GREATER if A>B, LESS if A24, print GREATER.\n\nSample Input 2\n\n850\n3777\n\nSample Output 2\n\nLESS\n\nSample Input 3\n\n9720246\n22516266\n\nSample Output 3\n\nLESS\n\nSample Input 4\n\n123456789012345678901234567890\n234567890123456789012345678901\n\nSample Output 4\n\nLESS", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 421, "cpu_time_ms": 5, "memory_kb": 496}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s554325900", "group_id": "codeNet:p03738", "input_text": "a=io.read()\nb=io.read()\na=string.rep(\"0\",101-#a)..a\nb=string.rep(\"0\",101-#b)..b\nprint(a==b and \"EQUAL\" or a>b and \"GREATER\" or \"LESS\")", "language": "Lua", "metadata": {"date": 1551750057, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03738.html", "problem_id": "p03738", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03738/input.txt", "sample_output_relpath": "derived/input_output/data/p03738/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03738/Lua/s554325900.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s554325900", "user_id": "u837412668"}, "prompt_components": {"gold_output": "GREATER\n", "input_to_evaluate": "a=io.read()\nb=io.read()\na=string.rep(\"0\",101-#a)..a\nb=string.rep(\"0\",101-#b)..b\nprint(a==b and \"EQUAL\" or a>b and \"GREATER\" or \"LESS\")", "problem_context": "Score : 200 points\n\nProblem Statement\n\nYou are given two positive integers A and B. Compare the magnitudes of these numbers.\n\nConstraints\n\n1 ≤ A, B ≤ 10^{100}\n\nNeither A nor B begins with a 0.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA\nB\n\nOutput\n\nPrint GREATER if A>B, LESS if A24, print GREATER.\n\nSample Input 2\n\n850\n3777\n\nSample Output 2\n\nLESS\n\nSample Input 3\n\n9720246\n22516266\n\nSample Output 3\n\nLESS\n\nSample Input 4\n\n123456789012345678901234567890\n234567890123456789012345678901\n\nSample Output 4\n\nLESS", "sample_input": "36\n24\n"}, "reference_outputs": ["GREATER\n"], "source_document_id": "p03738", "source_text": "Score : 200 points\n\nProblem Statement\n\nYou are given two positive integers A and B. Compare the magnitudes of these numbers.\n\nConstraints\n\n1 ≤ A, B ≤ 10^{100}\n\nNeither A nor B begins with a 0.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA\nB\n\nOutput\n\nPrint GREATER if A>B, LESS if A24, print GREATER.\n\nSample Input 2\n\n850\n3777\n\nSample Output 2\n\nLESS\n\nSample Input 3\n\n9720246\n22516266\n\nSample Output 3\n\nLESS\n\nSample Input 4\n\n123456789012345678901234567890\n234567890123456789012345678901\n\nSample Output 4\n\nLESS", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 134, "cpu_time_ms": 2, "memory_kb": 372}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s505723120", "group_id": "codeNet:p03739", "input_text": "local n = io.read(\"*n\", \"*l\")\nlocal str = io.read()\nlocal a = {}\nfor v in str:gmatch(\"(%-?%d+)\") do\n table.insert(a, tonumber(v))\nend\nlocal stepmin = nil\nfor type = -1, 1, 2 do\n local step = 0\n local sum = 0\n local flag = type\n for i = 1, n do\n sum = sum + a[i]\n if flag == 1 then\n if sum <= 0 then\n step = step + 1 - sum\n sum = 1\n end\n else\n if 0 <= sum then\n step = step + 1 + sum\n sum = -1\n end\n end\n flag = -flag\n end\n if type == -1 then stepmin = step else stepmin = math.min(stepmin, step) end\nend\nprint(stepmin)\n", "language": "Lua", "metadata": {"date": 1559006912, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p03739.html", "problem_id": "p03739", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03739/input.txt", "sample_output_relpath": "derived/input_output/data/p03739/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03739/Lua/s505723120.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s505723120", "user_id": "u120582723"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "local n = io.read(\"*n\", \"*l\")\nlocal str = io.read()\nlocal a = {}\nfor v in str:gmatch(\"(%-?%d+)\") do\n table.insert(a, tonumber(v))\nend\nlocal stepmin = nil\nfor type = -1, 1, 2 do\n local step = 0\n local sum = 0\n local flag = type\n for i = 1, n do\n sum = sum + a[i]\n if flag == 1 then\n if sum <= 0 then\n step = step + 1 - sum\n sum = 1\n end\n else\n if 0 <= sum then\n step = step + 1 + sum\n sum = -1\n end\n end\n flag = -flag\n end\n if type == -1 then stepmin = step else stepmin = math.min(stepmin, step) end\nend\nprint(stepmin)\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nYou are given an integer sequence of length N. The i-th term in the sequence is a_i.\nIn one operation, you can select a term and either increment or decrement it by one.\n\nAt least how many operations are necessary to satisfy the following conditions?\n\nFor every i (1≤i≤n), the sum of the terms from the 1-st through i-th term is not zero.\n\nFor every i (1≤i≤n-1), the sign of the sum of the terms from the 1-st through i-th term, is different from the sign of the sum of the terms from the 1-st through (i+1)-th term.\n\nConstraints\n\n2 ≤ n ≤ 10^5\n\n|a_i| ≤ 10^9\n\nEach a_i is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nn\na_1 a_2 ... a_n\n\nOutput\n\nPrint the minimum necessary count of operations.\n\nSample Input 1\n\n4\n1 -3 1 0\n\nSample Output 1\n\n4\n\nFor example, the given sequence can be transformed into 1, -2, 2, -2 by four operations. The sums of the first one, two, three and four terms are 1, -1, 1 and -1, respectively, which satisfy the conditions.\n\nSample Input 2\n\n5\n3 -6 4 -5 7\n\nSample Output 2\n\n0\n\nThe given sequence already satisfies the conditions.\n\nSample Input 3\n\n6\n-1 4 3 2 -5 4\n\nSample Output 3\n\n8", "sample_input": "4\n1 -3 1 0\n"}, "reference_outputs": ["4\n"], "source_document_id": "p03739", "source_text": "Score : 300 points\n\nProblem Statement\n\nYou are given an integer sequence of length N. The i-th term in the sequence is a_i.\nIn one operation, you can select a term and either increment or decrement it by one.\n\nAt least how many operations are necessary to satisfy the following conditions?\n\nFor every i (1≤i≤n), the sum of the terms from the 1-st through i-th term is not zero.\n\nFor every i (1≤i≤n-1), the sign of the sum of the terms from the 1-st through i-th term, is different from the sign of the sum of the terms from the 1-st through (i+1)-th term.\n\nConstraints\n\n2 ≤ n ≤ 10^5\n\n|a_i| ≤ 10^9\n\nEach a_i is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nn\na_1 a_2 ... a_n\n\nOutput\n\nPrint the minimum necessary count of operations.\n\nSample Input 1\n\n4\n1 -3 1 0\n\nSample Output 1\n\n4\n\nFor example, the given sequence can be transformed into 1, -2, 2, -2 by four operations. The sums of the first one, two, three and four terms are 1, -1, 1 and -1, respectively, which satisfy the conditions.\n\nSample Input 2\n\n5\n3 -6 4 -5 7\n\nSample Output 2\n\n0\n\nThe given sequence already satisfies the conditions.\n\nSample Input 3\n\n6\n-1 4 3 2 -5 4\n\nSample Output 3\n\n8", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 589, "cpu_time_ms": 51, "memory_kb": 6144}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s001782777", "group_id": "codeNet:p03740", "input_text": "a, b = io.read(\"*n\", \"*n\")\nprint(math.abs(a-b) <= 1 and \"Brown\" or \"Alice\")", "language": "Lua", "metadata": {"date": 1565655489, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03740.html", "problem_id": "p03740", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03740/input.txt", "sample_output_relpath": "derived/input_output/data/p03740/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03740/Lua/s001782777.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s001782777", "user_id": "u120582723"}, "prompt_components": {"gold_output": "Brown\n", "input_to_evaluate": "a, b = io.read(\"*n\", \"*n\")\nprint(math.abs(a-b) <= 1 and \"Brown\" or \"Alice\")", "problem_context": "Score : 500 points\n\nProblem Statement\n\nAlice and Brown loves games. Today, they will play the following game.\n\nIn this game, there are two piles initially consisting of X and Y stones, respectively.\nAlice and Bob alternately perform the following operation, starting from Alice:\n\nTake 2i stones from one of the piles. Then, throw away i of them, and put the remaining i in the other pile. Here, the integer i (1≤i) can be freely chosen as long as there is a sufficient number of stones in the pile.\n\nThe player who becomes unable to perform the operation, loses the game.\n\nGiven X and Y, determine the winner of the game, assuming that both players play optimally.\n\nConstraints\n\n0 ≤ X, Y ≤ 10^{18}\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX Y\n\nOutput\n\nPrint the winner: either Alice or Brown.\n\nSample Input 1\n\n2 1\n\nSample Output 1\n\nBrown\n\nAlice can do nothing but taking two stones from the pile containing two stones. As a result, the piles consist of zero and two stones, respectively. Then, Brown will take the two stones, and the piles will consist of one and zero stones, respectively. Alice will be unable to perform the operation anymore, which means Brown's victory.\n\nSample Input 2\n\n5 0\n\nSample Output 2\n\nAlice\n\nSample Input 3\n\n0 0\n\nSample Output 3\n\nBrown\n\nSample Input 4\n\n4 8\n\nSample Output 4\n\nAlice", "sample_input": "2 1\n"}, "reference_outputs": ["Brown\n"], "source_document_id": "p03740", "source_text": "Score : 500 points\n\nProblem Statement\n\nAlice and Brown loves games. Today, they will play the following game.\n\nIn this game, there are two piles initially consisting of X and Y stones, respectively.\nAlice and Bob alternately perform the following operation, starting from Alice:\n\nTake 2i stones from one of the piles. Then, throw away i of them, and put the remaining i in the other pile. Here, the integer i (1≤i) can be freely chosen as long as there is a sufficient number of stones in the pile.\n\nThe player who becomes unable to perform the operation, loses the game.\n\nGiven X and Y, determine the winner of the game, assuming that both players play optimally.\n\nConstraints\n\n0 ≤ X, Y ≤ 10^{18}\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX Y\n\nOutput\n\nPrint the winner: either Alice or Brown.\n\nSample Input 1\n\n2 1\n\nSample Output 1\n\nBrown\n\nAlice can do nothing but taking two stones from the pile containing two stones. As a result, the piles consist of zero and two stones, respectively. Then, Brown will take the two stones, and the piles will consist of one and zero stones, respectively. Alice will be unable to perform the operation anymore, which means Brown's victory.\n\nSample Input 2\n\n5 0\n\nSample Output 2\n\nAlice\n\nSample Input 3\n\n0 0\n\nSample Output 3\n\nBrown\n\nSample Input 4\n\n4 8\n\nSample Output 4\n\nAlice", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 75, "cpu_time_ms": 9, "memory_kb": 760}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s741203119", "group_id": "codeNet:p03741", "input_text": "N = io.read \"l\"\nsum = 0\nop = 0\nfor a in io.read \"l\":gmatch \"%-?%d+\" do\n a = tonumber(a)\n if sum > 0 then\n if a >= -sum then\n aNew = -sum - 1\n op = op + math.abs(a - aNew)\n a = aNew\n end\n elseif sum < 0 then\n if a <= -sum then\n aNew = -sum + 1\n op = op + math.abs(a - aNew)\n a = aNew\n end\n end\n sum = sum + a\nend\nprint((\"%d\"):format(op))\n", "language": "Lua", "metadata": {"date": 1492988746, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03741.html", "problem_id": "p03741", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03741/input.txt", "sample_output_relpath": "derived/input_output/data/p03741/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03741/Lua/s741203119.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s741203119", "user_id": "u224680588"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "N = io.read \"l\"\nsum = 0\nop = 0\nfor a in io.read \"l\":gmatch \"%-?%d+\" do\n a = tonumber(a)\n if sum > 0 then\n if a >= -sum then\n aNew = -sum - 1\n op = op + math.abs(a - aNew)\n a = aNew\n end\n elseif sum < 0 then\n if a <= -sum then\n aNew = -sum + 1\n op = op + math.abs(a - aNew)\n a = aNew\n end\n end\n sum = sum + a\nend\nprint((\"%d\"):format(op))\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nYou are given an integer sequence of length N. The i-th term in the sequence is a_i.\nIn one operation, you can select a term and either increment or decrement it by one.\n\nAt least how many operations are necessary to satisfy the following conditions?\n\nFor every i (1≤i≤n), the sum of the terms from the 1-st through i-th term is not zero.\n\nFor every i (1≤i≤n-1), the sign of the sum of the terms from the 1-st through i-th term, is different from the sign of the sum of the terms from the 1-st through (i+1)-th term.\n\nConstraints\n\n2 ≤ n ≤ 10^5\n\n|a_i| ≤ 10^9\n\nEach a_i is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nn\na_1 a_2 ... a_n\n\nOutput\n\nPrint the minimum necessary count of operations.\n\nSample Input 1\n\n4\n1 -3 1 0\n\nSample Output 1\n\n4\n\nFor example, the given sequence can be transformed into 1, -2, 2, -2 by four operations. The sums of the first one, two, three and four terms are 1, -1, 1 and -1, respectively, which satisfy the conditions.\n\nSample Input 2\n\n5\n3 -6 4 -5 7\n\nSample Output 2\n\n0\n\nThe given sequence already satisfies the conditions.\n\nSample Input 3\n\n6\n-1 4 3 2 -5 4\n\nSample Output 3\n\n8", "sample_input": "4\n1 -3 1 0\n"}, "reference_outputs": ["4\n"], "source_document_id": "p03741", "source_text": "Score : 300 points\n\nProblem Statement\n\nYou are given an integer sequence of length N. The i-th term in the sequence is a_i.\nIn one operation, you can select a term and either increment or decrement it by one.\n\nAt least how many operations are necessary to satisfy the following conditions?\n\nFor every i (1≤i≤n), the sum of the terms from the 1-st through i-th term is not zero.\n\nFor every i (1≤i≤n-1), the sign of the sum of the terms from the 1-st through i-th term, is different from the sign of the sum of the terms from the 1-st through (i+1)-th term.\n\nConstraints\n\n2 ≤ n ≤ 10^5\n\n|a_i| ≤ 10^9\n\nEach a_i is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nn\na_1 a_2 ... a_n\n\nOutput\n\nPrint the minimum necessary count of operations.\n\nSample Input 1\n\n4\n1 -3 1 0\n\nSample Output 1\n\n4\n\nFor example, the given sequence can be transformed into 1, -2, 2, -2 by four operations. The sums of the first one, two, three and four terms are 1, -1, 1 and -1, respectively, which satisfy the conditions.\n\nSample Input 2\n\n5\n3 -6 4 -5 7\n\nSample Output 2\n\n0\n\nThe given sequence already satisfies the conditions.\n\nSample Input 3\n\n6\n-1 4 3 2 -5 4\n\nSample Output 3\n\n8", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 446, "cpu_time_ms": 80, "memory_kb": 4352}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s094716956", "group_id": "codeNet:p03741", "input_text": "N = io.read \"l\"\nsum = 0\nop = 0\nfor a in io.read \"l\":gmatch \"%-?%d+\" do\n a = tonumber(a)\n if sum > 0 then\n if a >= -sum then\n aNew = -sum - 1\n op = op + math.abs(a - aNew)\n a = aNew\n end\n elseif sum < 0 then\n if a <= -sum then\n aNew = -sum + 1\n op = op + math.abs(a - aNew)\n a = aNew\n end\n end\n sum = sum + a\nend\nprint(op)\n", "language": "Lua", "metadata": {"date": 1492987536, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03741.html", "problem_id": "p03741", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03741/input.txt", "sample_output_relpath": "derived/input_output/data/p03741/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03741/Lua/s094716956.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s094716956", "user_id": "u224680588"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "N = io.read \"l\"\nsum = 0\nop = 0\nfor a in io.read \"l\":gmatch \"%-?%d+\" do\n a = tonumber(a)\n if sum > 0 then\n if a >= -sum then\n aNew = -sum - 1\n op = op + math.abs(a - aNew)\n a = aNew\n end\n elseif sum < 0 then\n if a <= -sum then\n aNew = -sum + 1\n op = op + math.abs(a - aNew)\n a = aNew\n end\n end\n sum = sum + a\nend\nprint(op)\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nYou are given an integer sequence of length N. The i-th term in the sequence is a_i.\nIn one operation, you can select a term and either increment or decrement it by one.\n\nAt least how many operations are necessary to satisfy the following conditions?\n\nFor every i (1≤i≤n), the sum of the terms from the 1-st through i-th term is not zero.\n\nFor every i (1≤i≤n-1), the sign of the sum of the terms from the 1-st through i-th term, is different from the sign of the sum of the terms from the 1-st through (i+1)-th term.\n\nConstraints\n\n2 ≤ n ≤ 10^5\n\n|a_i| ≤ 10^9\n\nEach a_i is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nn\na_1 a_2 ... a_n\n\nOutput\n\nPrint the minimum necessary count of operations.\n\nSample Input 1\n\n4\n1 -3 1 0\n\nSample Output 1\n\n4\n\nFor example, the given sequence can be transformed into 1, -2, 2, -2 by four operations. The sums of the first one, two, three and four terms are 1, -1, 1 and -1, respectively, which satisfy the conditions.\n\nSample Input 2\n\n5\n3 -6 4 -5 7\n\nSample Output 2\n\n0\n\nThe given sequence already satisfies the conditions.\n\nSample Input 3\n\n6\n-1 4 3 2 -5 4\n\nSample Output 3\n\n8", "sample_input": "4\n1 -3 1 0\n"}, "reference_outputs": ["4\n"], "source_document_id": "p03741", "source_text": "Score : 300 points\n\nProblem Statement\n\nYou are given an integer sequence of length N. The i-th term in the sequence is a_i.\nIn one operation, you can select a term and either increment or decrement it by one.\n\nAt least how many operations are necessary to satisfy the following conditions?\n\nFor every i (1≤i≤n), the sum of the terms from the 1-st through i-th term is not zero.\n\nFor every i (1≤i≤n-1), the sign of the sum of the terms from the 1-st through i-th term, is different from the sign of the sum of the terms from the 1-st through (i+1)-th term.\n\nConstraints\n\n2 ≤ n ≤ 10^5\n\n|a_i| ≤ 10^9\n\nEach a_i is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nn\na_1 a_2 ... a_n\n\nOutput\n\nPrint the minimum necessary count of operations.\n\nSample Input 1\n\n4\n1 -3 1 0\n\nSample Output 1\n\n4\n\nFor example, the given sequence can be transformed into 1, -2, 2, -2 by four operations. The sums of the first one, two, three and four terms are 1, -1, 1 and -1, respectively, which satisfy the conditions.\n\nSample Input 2\n\n5\n3 -6 4 -5 7\n\nSample Output 2\n\n0\n\nThe given sequence already satisfies the conditions.\n\nSample Input 3\n\n6\n-1 4 3 2 -5 4\n\nSample Output 3\n\n8", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 431, "cpu_time_ms": 80, "memory_kb": 4352}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s172924215", "group_id": "codeNet:p03745", "input_text": "status=0\nsplit=0\nn=io.read(\"*n\")\na=io.read(\"*n\")\nfor i=1,n-1 do\n b=io.read(\"*n\")\n if a>b then\n if status==1 then\n split=split+1\n status=0\n elseif status==0 then\n status=-1\n end\n elseif ab then\n if status==1 then\n split=split+1\n status=0\n elseif status==0 then\n status=-1\n end\n elseif a= 2 * x then\n\t\tout = i\n\t\tbreak\n\tend\nend\n\nprint(out)\n", "language": "Lua", "metadata": {"date": 1600360094, "filename_ext": "lua", "original_language": "Lua (Lua 5.3.5)", "problem_description_relpath": "problem_descriptions/p03779.html", "problem_id": "p03779", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03779/input.txt", "sample_output_relpath": "derived/input_output/data/p03779/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03779/Lua/s295454597.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s295454597", "user_id": "u793881115"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "local x = io.read(\"n\")\n\nlocal out\nfor i = 1, x do\n\tif i*i + i >= 2 * x then\n\t\tout = i\n\t\tbreak\n\tend\nend\n\nprint(out)\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nThere is a kangaroo at coordinate 0 on an infinite number line that runs from left to right, at time 0.\nDuring the period between time i-1 and time i, the kangaroo can either stay at his position, or perform a jump of length exactly i to the left or to the right.\nThat is, if his coordinate at time i-1 is x, he can be at coordinate x-i, x or x+i at time i.\nThe kangaroo's nest is at coordinate X, and he wants to travel to coordinate X as fast as possible.\nFind the earliest possible time to reach coordinate X.\n\nConstraints\n\nX is an integer.\n\n1≤X≤10^9\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nX\n\nOutput\n\nPrint the earliest possible time for the kangaroo to reach coordinate X.\n\nSample Input 1\n\n6\n\nSample Output 1\n\n3\n\nThe kangaroo can reach his nest at time 3 by jumping to the right three times, which is the earliest possible time.\n\nSample Input 2\n\n2\n\nSample Output 2\n\n2\n\nHe can reach his nest at time 2 by staying at his position during the first second, and jumping to the right at the next second.\n\nSample Input 3\n\n11\n\nSample Output 3\n\n5", "sample_input": "6\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03779", "source_text": "Score : 200 points\n\nProblem Statement\n\nThere is a kangaroo at coordinate 0 on an infinite number line that runs from left to right, at time 0.\nDuring the period between time i-1 and time i, the kangaroo can either stay at his position, or perform a jump of length exactly i to the left or to the right.\nThat is, if his coordinate at time i-1 is x, he can be at coordinate x-i, x or x+i at time i.\nThe kangaroo's nest is at coordinate X, and he wants to travel to coordinate X as fast as possible.\nFind the earliest possible time to reach coordinate X.\n\nConstraints\n\nX is an integer.\n\n1≤X≤10^9\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nX\n\nOutput\n\nPrint the earliest possible time for the kangaroo to reach coordinate X.\n\nSample Input 1\n\n6\n\nSample Output 1\n\n3\n\nThe kangaroo can reach his nest at time 3 by jumping to the right three times, which is the earliest possible time.\n\nSample Input 2\n\n2\n\nSample Output 2\n\n2\n\nHe can reach his nest at time 2 by staying at his position during the first second, and jumping to the right at the next second.\n\nSample Input 3\n\n11\n\nSample Output 3\n\n5", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 115, "cpu_time_ms": 10, "memory_kb": 2728}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s357136988", "group_id": "codeNet:p03780", "input_text": "local mmi = math.min\nlocal mma = math.max\nlocal n, k = io.read(\"*n\", \"*n\")\nlocal a = {}\nfor i = 1, n do\n local at = io.read(\"*n\")\n if at < k then\n table.insert(a, at)\n end\nend\nn = #a\ntable.sort(a, function(x, y) return x > y end)\nlocal function solve()\n if n == 0 then return 0 end\n local tail = {}\n for i = 1, n do\n tail[i] = {}\n -- for j = 1, k - 1 do\n -- tail[i][j] = false\n -- end\n end\n tail[n][a[n]] = true\n local curmax = a[n]\n for i = n - 1, 1, -1 do\n for j = 1, curmax do\n if tail[i + 1][j] then\n tail[i][j] = true\n if j + a[i] < k then\n tail[i][j + a[i]] = true\n curmax = mma(curmax, j + a[i])\n end\n end\n end\n tail[i][a[i]] = true\n curmax = mma(curmax, a[i])\n end\n local head = {}\n for i = 1, k - 1 do\n head[i] = false\n end\n local cnt = 0\n curmax = 0\n for i = 1, n - 1 do\n local ai = a[i]\n local need = false\n for j = k - ai, k - 1 do\n for p = 1, j - 1 do\n local q = j - p\n if head[p] and tail[i + 1][q] then\n need = true\n break\n end\n end\n if head[j] or tail[i + 1][j] then\n need = true\n end\n if need then break end\n end\n if not need then cnt = cnt + 1 end\n for j = mmi(curmax, k - 1 - ai), 1, -1 do\n if head[j] then head[j + ai] = true end\n end\n head[ai] = true\n curmax = mmi(curmax + ai, k - 1)\n end\n do -- i == n\n local ai = a[n]\n local need = false\n for j = k - ai, k - 1 do\n if head[j] then\n need = true\n break\n end\n end\n if not need then cnt = cnt + 1 end\n end\n return cnt\nend\nprint(solve())\n", "language": "Lua", "metadata": {"date": 1573189801, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p03780.html", "problem_id": "p03780", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03780/input.txt", "sample_output_relpath": "derived/input_output/data/p03780/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03780/Lua/s357136988.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Memory Limit Exceeded", "submission_id": "s357136988", "user_id": "u120582723"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "local mmi = math.min\nlocal mma = math.max\nlocal n, k = io.read(\"*n\", \"*n\")\nlocal a = {}\nfor i = 1, n do\n local at = io.read(\"*n\")\n if at < k then\n table.insert(a, at)\n end\nend\nn = #a\ntable.sort(a, function(x, y) return x > y end)\nlocal function solve()\n if n == 0 then return 0 end\n local tail = {}\n for i = 1, n do\n tail[i] = {}\n -- for j = 1, k - 1 do\n -- tail[i][j] = false\n -- end\n end\n tail[n][a[n]] = true\n local curmax = a[n]\n for i = n - 1, 1, -1 do\n for j = 1, curmax do\n if tail[i + 1][j] then\n tail[i][j] = true\n if j + a[i] < k then\n tail[i][j + a[i]] = true\n curmax = mma(curmax, j + a[i])\n end\n end\n end\n tail[i][a[i]] = true\n curmax = mma(curmax, a[i])\n end\n local head = {}\n for i = 1, k - 1 do\n head[i] = false\n end\n local cnt = 0\n curmax = 0\n for i = 1, n - 1 do\n local ai = a[i]\n local need = false\n for j = k - ai, k - 1 do\n for p = 1, j - 1 do\n local q = j - p\n if head[p] and tail[i + 1][q] then\n need = true\n break\n end\n end\n if head[j] or tail[i + 1][j] then\n need = true\n end\n if need then break end\n end\n if not need then cnt = cnt + 1 end\n for j = mmi(curmax, k - 1 - ai), 1, -1 do\n if head[j] then head[j + ai] = true end\n end\n head[ai] = true\n curmax = mmi(curmax + ai, k - 1)\n end\n do -- i == n\n local ai = a[n]\n local need = false\n for j = k - ai, k - 1 do\n if head[j] then\n need = true\n break\n end\n end\n if not need then cnt = cnt + 1 end\n end\n return cnt\nend\nprint(solve())\n", "problem_context": "Score : 600 points\n\nProblem Statement\n\nAtCoDeer the deer has N cards with positive integers written on them. The number on the i-th card (1≤i≤N) is a_i.\nBecause he loves big numbers, he calls a subset of the cards good when the sum of the numbers written on the cards in the subset, is K or greater.\n\nThen, for each card i, he judges whether it is unnecessary or not, as follows:\n\nIf, for any good subset of the cards containing card i, the set that can be obtained by eliminating card i from the subset is also good, card i is unnecessary.\n\nOtherwise, card i is NOT unnecessary.\n\nFind the number of the unnecessary cards. Here, he judges each card independently, and he does not throw away cards that turn out to be unnecessary.\n\nConstraints\n\nAll input values are integers.\n\n1≤N≤5000\n\n1≤K≤5000\n\n1≤a_i≤10^9 (1≤i≤N)\n\nPartial Score\n\n300 points will be awarded for passing the test set satisfying N,K≤400.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN K\na_1 a_2 ... a_N\n\nOutput\n\nPrint the number of the unnecessary cards.\n\nSample Input 1\n\n3 6\n1 4 3\n\nSample Output 1\n\n1\n\nThere are two good sets: {2,3} and {1,2,3}.\n\nCard 1 is only contained in {1,2,3}, and this set without card 1, {2,3}, is also good. Thus, card 1 is unnecessary.\n\nFor card 2, a good set {2,3} without card 2, {3}, is not good. Thus, card 2 is NOT unnecessary.\n\nNeither is card 3 for a similar reason, hence the answer is 1.\n\nSample Input 2\n\n5 400\n3 1 4 1 5\n\nSample Output 2\n\n5\n\nIn this case, there is no good set. Therefore, all the cards are unnecessary.\n\nSample Input 3\n\n6 20\n10 4 3 10 25 2\n\nSample Output 3\n\n3", "sample_input": "3 6\n1 4 3\n"}, "reference_outputs": ["1\n"], "source_document_id": "p03780", "source_text": "Score : 600 points\n\nProblem Statement\n\nAtCoDeer the deer has N cards with positive integers written on them. The number on the i-th card (1≤i≤N) is a_i.\nBecause he loves big numbers, he calls a subset of the cards good when the sum of the numbers written on the cards in the subset, is K or greater.\n\nThen, for each card i, he judges whether it is unnecessary or not, as follows:\n\nIf, for any good subset of the cards containing card i, the set that can be obtained by eliminating card i from the subset is also good, card i is unnecessary.\n\nOtherwise, card i is NOT unnecessary.\n\nFind the number of the unnecessary cards. Here, he judges each card independently, and he does not throw away cards that turn out to be unnecessary.\n\nConstraints\n\nAll input values are integers.\n\n1≤N≤5000\n\n1≤K≤5000\n\n1≤a_i≤10^9 (1≤i≤N)\n\nPartial Score\n\n300 points will be awarded for passing the test set satisfying N,K≤400.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN K\na_1 a_2 ... a_N\n\nOutput\n\nPrint the number of the unnecessary cards.\n\nSample Input 1\n\n3 6\n1 4 3\n\nSample Output 1\n\n1\n\nThere are two good sets: {2,3} and {1,2,3}.\n\nCard 1 is only contained in {1,2,3}, and this set without card 1, {2,3}, is also good. Thus, card 1 is unnecessary.\n\nFor card 2, a good set {2,3} without card 2, {3}, is not good. Thus, card 2 is NOT unnecessary.\n\nNeither is card 3 for a similar reason, hence the answer is 1.\n\nSample Input 2\n\n5 400\n3 1 4 1 5\n\nSample Output 2\n\n5\n\nIn this case, there is no good set. Therefore, all the cards are unnecessary.\n\nSample Input 3\n\n6 20\n10 4 3 10 25 2\n\nSample Output 3\n\n3", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1651, "cpu_time_ms": 728, "memory_kb": 320896}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s416909569", "group_id": "codeNet:p03785", "input_text": "local n,c,k=io.read(\"*n\",\"*n\",\"*n\")\nlocal t={}\nfor i=1,n do\n t[i]=io.read(\"*n\")\nend\ntable.sort(t)\n\nlocal bus=0\nlocal capacity=0\nlocal tadius=t[1]+k\nfor i=1,n do\n if capacity==c or tadius0 then\n print(n+(m-2*n)//4)\nelse\n print(m//2)\nend", "language": "Lua", "metadata": {"date": 1589510608, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03799.html", "problem_id": "p03799", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03799/input.txt", "sample_output_relpath": "derived/input_output/data/p03799/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03799/Lua/s850631094.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s850631094", "user_id": "u045238009"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "local n,m=io.read(\"*n\",\"*n\")\nif m-2*n>0 then\n print(n+(m-2*n)//4)\nelse\n print(m//2)\nend", "problem_context": "Score : 300 points\n\nProblem Statement\n\nSnuke loves puzzles.\n\nToday, he is working on a puzzle using S- and c-shaped pieces.\nIn this puzzle, you can combine two c-shaped pieces into one S-shaped piece, as shown in the figure below:\n\nSnuke decided to create as many Scc groups as possible by putting together one S-shaped piece and two c-shaped pieces.\n\nFind the maximum number of Scc groups that can be created when Snuke has N S-shaped pieces and M c-shaped pieces.\n\nConstraints\n\n1 ≤ N,M ≤ 10^{12}\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN M\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n1 6\n\nSample Output 1\n\n2\n\nTwo Scc groups can be created as follows:\n\nCombine two c-shaped pieces into one S-shaped piece\n\nCreate two Scc groups, each from one S-shaped piece and two c-shaped pieces\n\nSample Input 2\n\n12345 678901\n\nSample Output 2\n\n175897", "sample_input": "1 6\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03799", "source_text": "Score : 300 points\n\nProblem Statement\n\nSnuke loves puzzles.\n\nToday, he is working on a puzzle using S- and c-shaped pieces.\nIn this puzzle, you can combine two c-shaped pieces into one S-shaped piece, as shown in the figure below:\n\nSnuke decided to create as many Scc groups as possible by putting together one S-shaped piece and two c-shaped pieces.\n\nFind the maximum number of Scc groups that can be created when Snuke has N S-shaped pieces and M c-shaped pieces.\n\nConstraints\n\n1 ≤ N,M ≤ 10^{12}\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN M\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n1 6\n\nSample Output 1\n\n2\n\nTwo Scc groups can be created as follows:\n\nCombine two c-shaped pieces into one S-shaped piece\n\nCreate two Scc groups, each from one S-shaped piece and two c-shaped pieces\n\nSample Input 2\n\n12345 678901\n\nSample Output 2\n\n175897", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 93, "cpu_time_ms": 7, "memory_kb": 760}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s590335662", "group_id": "codeNet:p03799", "input_text": "local n,m=io.read(\"*n\",\"*n\")\nprint((2*n+m)//4)", "language": "Lua", "metadata": {"date": 1589510018, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03799.html", "problem_id": "p03799", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03799/input.txt", "sample_output_relpath": "derived/input_output/data/p03799/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03799/Lua/s590335662.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s590335662", "user_id": "u045238009"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "local n,m=io.read(\"*n\",\"*n\")\nprint((2*n+m)//4)", "problem_context": "Score : 300 points\n\nProblem Statement\n\nSnuke loves puzzles.\n\nToday, he is working on a puzzle using S- and c-shaped pieces.\nIn this puzzle, you can combine two c-shaped pieces into one S-shaped piece, as shown in the figure below:\n\nSnuke decided to create as many Scc groups as possible by putting together one S-shaped piece and two c-shaped pieces.\n\nFind the maximum number of Scc groups that can be created when Snuke has N S-shaped pieces and M c-shaped pieces.\n\nConstraints\n\n1 ≤ N,M ≤ 10^{12}\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN M\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n1 6\n\nSample Output 1\n\n2\n\nTwo Scc groups can be created as follows:\n\nCombine two c-shaped pieces into one S-shaped piece\n\nCreate two Scc groups, each from one S-shaped piece and two c-shaped pieces\n\nSample Input 2\n\n12345 678901\n\nSample Output 2\n\n175897", "sample_input": "1 6\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03799", "source_text": "Score : 300 points\n\nProblem Statement\n\nSnuke loves puzzles.\n\nToday, he is working on a puzzle using S- and c-shaped pieces.\nIn this puzzle, you can combine two c-shaped pieces into one S-shaped piece, as shown in the figure below:\n\nSnuke decided to create as many Scc groups as possible by putting together one S-shaped piece and two c-shaped pieces.\n\nFind the maximum number of Scc groups that can be created when Snuke has N S-shaped pieces and M c-shaped pieces.\n\nConstraints\n\n1 ≤ N,M ≤ 10^{12}\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN M\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n1 6\n\nSample Output 1\n\n2\n\nTwo Scc groups can be created as follows:\n\nCombine two c-shaped pieces into one S-shaped piece\n\nCreate two Scc groups, each from one S-shaped piece and two c-shaped pieces\n\nSample Input 2\n\n12345 678901\n\nSample Output 2\n\n175897", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 46, "cpu_time_ms": 14, "memory_kb": 888}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s395333723", "group_id": "codeNet:p03800", "input_text": "-- C\nlocal sub = string.sub\nlocal n = io.read('*n', '*l')\nlocal s = io.read('*l')\nss = {}\nfor i = 1, n do\n\tss[i] = sub(s, i, i)\nend\nlocal ret = nil\nif ss[1] == 'o' then\n\tret = {\n\t\t{[1] = 1, [2] = 1, [n] = 1},\n\t\t{[1] = 1, [2] = 0, [n] = 0},\n\t\t{[1] = 0, [2] = 0, [n] = 1},\n\t\t{[1] = 0, [2] = 1, [n] = 0},\n\t}\nelse\n\tret = {\n\t\t{[1] = 1, [2] = 1, [n] = 0},\n\t\t{[1] = 1, [2] = 0, [n] = 1},\n\t\t{[1] = 0, [2] = 0, [n] = 0},\n\t\t{[1] = 0, [2] = 1, [n] = 1},\n\t}\nend\nfor i = 2, n-2 do\n\tfor j = 1, 4 do\n\t\tlocal ans = ret[j]\n\t\tif ss[i] == 'o' then\n\t\t\tif ans[i] == 1 then\n\t\t\t\tans[i + 1] = ans[i - 1]\n\t\t\telse\n\t\t\t\tans[i + 1] = 1 - ans[i - 1]\n\t\t\tend\n\t\telse\n\t\t\tif ans[i] == 1 then\n\t\t\t\tans[i + 1] = 1 - ans[i - 1]\n\t\t\telse\n\t\t\t\tans[i + 1] = ans[i - 1]\n\t\t\tend\n\t\tend\n\tend\nend\n\nlocal function isOK(a, b, c, ch)\n\tif ch == \"o\" then\n\t\tif b == 1 then\n\t\t\treturn a == c\n\t\telse\n\t\t\treturn a ~= c\n\t\tend\n\telse\n\t\tif b == 1 then\n\t\t\treturn a ~= c\n\t\telse\n\t\t\treturn a == c\n\t\tend\n\tend\nend\n\nlocal sum = 0\nlocal result = nil\nfor j = 1, 4 do\n\tlocal ans = ret[j]\n\tif isOK(ans[n-2], ans[n-1], ans[n], ss[n-1]) and isOK(ans[n-1], ans[n], ans[1], ss[n]) then\n\t\tsum = sum + 1\n\t\tresult = ans\n\t\tbreak\n\tend\nend\n\nif sum == 1 then\n\tfor i = 1, n do\n\t\tresult[i] = result[i] == 1 and \"S\" or \"W\"\n\tend\n\tprint(table.concat(result))\nelse\n\tprint(-1)\nend", "language": "Lua", "metadata": {"date": 1553572726, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03800.html", "problem_id": "p03800", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03800/input.txt", "sample_output_relpath": "derived/input_output/data/p03800/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03800/Lua/s395333723.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s395333723", "user_id": "u018679195"}, "prompt_components": {"gold_output": "SSSWWS\n", "input_to_evaluate": "-- C\nlocal sub = string.sub\nlocal n = io.read('*n', '*l')\nlocal s = io.read('*l')\nss = {}\nfor i = 1, n do\n\tss[i] = sub(s, i, i)\nend\nlocal ret = nil\nif ss[1] == 'o' then\n\tret = {\n\t\t{[1] = 1, [2] = 1, [n] = 1},\n\t\t{[1] = 1, [2] = 0, [n] = 0},\n\t\t{[1] = 0, [2] = 0, [n] = 1},\n\t\t{[1] = 0, [2] = 1, [n] = 0},\n\t}\nelse\n\tret = {\n\t\t{[1] = 1, [2] = 1, [n] = 0},\n\t\t{[1] = 1, [2] = 0, [n] = 1},\n\t\t{[1] = 0, [2] = 0, [n] = 0},\n\t\t{[1] = 0, [2] = 1, [n] = 1},\n\t}\nend\nfor i = 2, n-2 do\n\tfor j = 1, 4 do\n\t\tlocal ans = ret[j]\n\t\tif ss[i] == 'o' then\n\t\t\tif ans[i] == 1 then\n\t\t\t\tans[i + 1] = ans[i - 1]\n\t\t\telse\n\t\t\t\tans[i + 1] = 1 - ans[i - 1]\n\t\t\tend\n\t\telse\n\t\t\tif ans[i] == 1 then\n\t\t\t\tans[i + 1] = 1 - ans[i - 1]\n\t\t\telse\n\t\t\t\tans[i + 1] = ans[i - 1]\n\t\t\tend\n\t\tend\n\tend\nend\n\nlocal function isOK(a, b, c, ch)\n\tif ch == \"o\" then\n\t\tif b == 1 then\n\t\t\treturn a == c\n\t\telse\n\t\t\treturn a ~= c\n\t\tend\n\telse\n\t\tif b == 1 then\n\t\t\treturn a ~= c\n\t\telse\n\t\t\treturn a == c\n\t\tend\n\tend\nend\n\nlocal sum = 0\nlocal result = nil\nfor j = 1, 4 do\n\tlocal ans = ret[j]\n\tif isOK(ans[n-2], ans[n-1], ans[n], ss[n-1]) and isOK(ans[n-1], ans[n], ans[1], ss[n]) then\n\t\tsum = sum + 1\n\t\tresult = ans\n\t\tbreak\n\tend\nend\n\nif sum == 1 then\n\tfor i = 1, n do\n\t\tresult[i] = result[i] == 1 and \"S\" or \"W\"\n\tend\n\tprint(table.concat(result))\nelse\n\tprint(-1)\nend", "problem_context": "Score : 500 points\n\nProblem Statement\n\nSnuke, who loves animals, built a zoo.\n\nThere are N animals in this zoo. They are conveniently numbered 1 through N, and arranged in a circle.\nThe animal numbered i (2≤i≤N-1) is adjacent to the animals numbered i-1 and i+1. Also, the animal numbered 1 is adjacent to the animals numbered 2 and N, and the animal numbered N is adjacent to the animals numbered N-1 and 1.\n\nThere are two kinds of animals in this zoo: honest sheep that only speak the truth, and lying wolves that only tell lies.\n\nSnuke cannot tell the difference between these two species, and asked each animal the following question: \"Are your neighbors of the same species?\" The animal numbered i answered s_i. Here, if s_i is o, the animal said that the two neighboring animals are of the same species, and if s_i is x, the animal said that the two neighboring animals are of different species.\n\nMore formally, a sheep answered o if the two neighboring animals are both sheep or both wolves, and answered x otherwise.\nSimilarly, a wolf answered x if the two neighboring animals are both sheep or both wolves, and answered o otherwise.\n\nSnuke is wondering whether there is a valid assignment of species to the animals that is consistent with these responses. If there is such an assignment, show one such assignment. Otherwise, print -1.\n\nConstraints\n\n3 ≤ N ≤ 10^{5}\n\ns is a string of length N consisting of o and x.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\ns\n\nOutput\n\nIf there does not exist an valid assignment that is consistent with s, print -1.\nOtherwise, print an string t in the following format. The output is considered correct if the assignment described by t is consistent with s.\n\nt is a string of length N consisting of S and W.\n\nIf t_i is S, it indicates that the animal numbered i is a sheep. If t_i is W, it indicates that the animal numbered i is a wolf.\n\nSample Input 1\n\n6\nooxoox\n\nSample Output 1\n\nSSSWWS\n\nFor example, if the animals numbered 1, 2, 3, 4, 5 and 6 are respectively a sheep, sheep, sheep, wolf, wolf, and sheep, it is consistent with their responses. Besides, there is another valid assignment of species: a wolf, sheep, wolf, sheep, wolf and wolf.\n\nLet us remind you: if the neiboring animals are of the same species, a sheep answers o and a wolf answers x. If the neiboring animals are of different species, a sheep answers x and a wolf answers o.\n\nSample Input 2\n\n3\noox\n\nSample Output 2\n\n-1\n\nPrint -1 if there is no valid assignment of species.\n\nSample Input 3\n\n10\noxooxoxoox\n\nSample Output 3\n\nSSWWSSSWWS", "sample_input": "6\nooxoox\n"}, "reference_outputs": ["SSSWWS\n"], "source_document_id": "p03800", "source_text": "Score : 500 points\n\nProblem Statement\n\nSnuke, who loves animals, built a zoo.\n\nThere are N animals in this zoo. They are conveniently numbered 1 through N, and arranged in a circle.\nThe animal numbered i (2≤i≤N-1) is adjacent to the animals numbered i-1 and i+1. Also, the animal numbered 1 is adjacent to the animals numbered 2 and N, and the animal numbered N is adjacent to the animals numbered N-1 and 1.\n\nThere are two kinds of animals in this zoo: honest sheep that only speak the truth, and lying wolves that only tell lies.\n\nSnuke cannot tell the difference between these two species, and asked each animal the following question: \"Are your neighbors of the same species?\" The animal numbered i answered s_i. Here, if s_i is o, the animal said that the two neighboring animals are of the same species, and if s_i is x, the animal said that the two neighboring animals are of different species.\n\nMore formally, a sheep answered o if the two neighboring animals are both sheep or both wolves, and answered x otherwise.\nSimilarly, a wolf answered x if the two neighboring animals are both sheep or both wolves, and answered o otherwise.\n\nSnuke is wondering whether there is a valid assignment of species to the animals that is consistent with these responses. If there is such an assignment, show one such assignment. Otherwise, print -1.\n\nConstraints\n\n3 ≤ N ≤ 10^{5}\n\ns is a string of length N consisting of o and x.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\ns\n\nOutput\n\nIf there does not exist an valid assignment that is consistent with s, print -1.\nOtherwise, print an string t in the following format. The output is considered correct if the assignment described by t is consistent with s.\n\nt is a string of length N consisting of S and W.\n\nIf t_i is S, it indicates that the animal numbered i is a sheep. If t_i is W, it indicates that the animal numbered i is a wolf.\n\nSample Input 1\n\n6\nooxoox\n\nSample Output 1\n\nSSSWWS\n\nFor example, if the animals numbered 1, 2, 3, 4, 5 and 6 are respectively a sheep, sheep, sheep, wolf, wolf, and sheep, it is consistent with their responses. Besides, there is another valid assignment of species: a wolf, sheep, wolf, sheep, wolf and wolf.\n\nLet us remind you: if the neiboring animals are of the same species, a sheep answers o and a wolf answers x. If the neiboring animals are of different species, a sheep answers x and a wolf answers o.\n\nSample Input 2\n\n3\noox\n\nSample Output 2\n\n-1\n\nPrint -1 if there is no valid assignment of species.\n\nSample Input 3\n\n10\noxooxoxoox\n\nSample Output 3\n\nSSWWSSSWWS", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1287, "cpu_time_ms": 91, "memory_kb": 10920}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s498300041", "group_id": "codeNet:p03801", "input_text": "local function comp(a, b)\n return a < b\nend\n\nlocal function lower_bound(ary, x)\n local num = #ary\n if num == 0 then return 1 end\n if not comp(ary[1], x) then return 1 end\n if comp(ary[num], x) then return num + 1 end\n local min, max = 1, num\n while 1 < max - min do\n local mid = (min + max) // 2\n if comp(ary[mid], x) then\n min = mid\n else\n max = mid\n end\n end\n return max\nend\n\nlocal n = io.read(\"*n\")\nlocal stage = {1}\nlocal stagenum = {io.read(\"*n\")}\nlocal stagesum = {stagenum[1]}\nlocal stageaddcnt = {1}\nfor i = 2, n do\n local a = io.read(\"*n\")\n local pos = lower_bound(stagenum, a)\n if #stagenum < pos then\n table.insert(stage, i)\n table.insert(stagenum, a)\n table.insert(stagesum, a)\n table.insert(stageaddcnt, 1)\n else\n stagesum[pos] = stagesum[pos] + a\n stageaddcnt[pos] = stageaddcnt[pos] + 1\n end\nend\nlocal ret = {}\nfor i = 1, n do\n ret[i] = 0\nend\n\nfor i = #stagesum, 2, -1 do\n local dst_i = stage[i]\n local num = stagenum[i]\n local sum = stagesum[i]\n local addcnt = stageaddcnt[i]\n ret[dst_i] = sum - addcnt * stagenum[i - 1]\n stageaddcnt[i - 1] = stageaddcnt[i - 1] + addcnt\n stagesum[i - 1] = stagesum[i- 1] + stagenum[i - 1] * addcnt\nend\nret[1] = stagesum[1]\n\nprint(table.concat(ret, \"\\n\"))\n", "language": "Lua", "metadata": {"date": 1570109310, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03801.html", "problem_id": "p03801", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03801/input.txt", "sample_output_relpath": "derived/input_output/data/p03801/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03801/Lua/s498300041.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s498300041", "user_id": "u120582723"}, "prompt_components": {"gold_output": "2\n1\n", "input_to_evaluate": "local function comp(a, b)\n return a < b\nend\n\nlocal function lower_bound(ary, x)\n local num = #ary\n if num == 0 then return 1 end\n if not comp(ary[1], x) then return 1 end\n if comp(ary[num], x) then return num + 1 end\n local min, max = 1, num\n while 1 < max - min do\n local mid = (min + max) // 2\n if comp(ary[mid], x) then\n min = mid\n else\n max = mid\n end\n end\n return max\nend\n\nlocal n = io.read(\"*n\")\nlocal stage = {1}\nlocal stagenum = {io.read(\"*n\")}\nlocal stagesum = {stagenum[1]}\nlocal stageaddcnt = {1}\nfor i = 2, n do\n local a = io.read(\"*n\")\n local pos = lower_bound(stagenum, a)\n if #stagenum < pos then\n table.insert(stage, i)\n table.insert(stagenum, a)\n table.insert(stagesum, a)\n table.insert(stageaddcnt, 1)\n else\n stagesum[pos] = stagesum[pos] + a\n stageaddcnt[pos] = stageaddcnt[pos] + 1\n end\nend\nlocal ret = {}\nfor i = 1, n do\n ret[i] = 0\nend\n\nfor i = #stagesum, 2, -1 do\n local dst_i = stage[i]\n local num = stagenum[i]\n local sum = stagesum[i]\n local addcnt = stageaddcnt[i]\n ret[dst_i] = sum - addcnt * stagenum[i - 1]\n stageaddcnt[i - 1] = stageaddcnt[i - 1] + addcnt\n stagesum[i - 1] = stagesum[i- 1] + stagenum[i - 1] * addcnt\nend\nret[1] = stagesum[1]\n\nprint(table.concat(ret, \"\\n\"))\n", "problem_context": "Score : 700 points\n\nProblem Statement\n\nSnuke loves constructing integer sequences.\n\nThere are N piles of stones, numbered 1 through N.\nThe pile numbered i consists of a_i stones.\n\nSnuke will construct an integer sequence s of length Σa_i, as follows:\n\nAmong the piles with the largest number of stones remaining, let x be the index of the pile with the smallest index. Append x to the end of s.\n\nSelect a pile with one or more stones remaining, and remove a stone from that pile.\n\nIf there is a pile with one or more stones remaining, go back to step 1. Otherwise, terminate the process.\n\nWe are interested in the lexicographically smallest sequence that can be constructed. For each of the integers 1,2,3,...,N, how many times does it occur in the lexicographically smallest sequence?\n\nConstraints\n\n1 ≤ N ≤ 10^{5}\n\n1 ≤ a_i ≤ 10^{9}\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\na_1 a_2 ... a_{N}\n\nOutput\n\nPrint N lines. The i-th line should contain the number of the occurrences of the integer i in the lexicographically smallest sequence that can be constructed.\n\nSample Input 1\n\n2\n1 2\n\nSample Output 1\n\n2\n1\n\nThe lexicographically smallest sequence is constructed as follows:\n\nSince the pile with the largest number of stones remaining is pile 2, append 2 to the end of s. Then, remove a stone from pile 2.\n\nSince the piles with the largest number of stones remaining are pile 1 and 2, append 1 to the end of s (we take the smallest index). Then, remove a stone from pile 2.\n\nSince the pile with the largest number of stones remaining is pile 1, append 1 to the end of s. Then, remove a stone from pile 1.\n\nThe resulting sequence is (2,1,1). In this sequence, 1 occurs twice, and 2 occurs once.\n\nSample Input 2\n\n10\n1 2 1 3 2 4 2 5 8 1\n\nSample Output 2\n\n10\n7\n0\n4\n0\n3\n0\n2\n3\n0", "sample_input": "2\n1 2\n"}, "reference_outputs": ["2\n1\n"], "source_document_id": "p03801", "source_text": "Score : 700 points\n\nProblem Statement\n\nSnuke loves constructing integer sequences.\n\nThere are N piles of stones, numbered 1 through N.\nThe pile numbered i consists of a_i stones.\n\nSnuke will construct an integer sequence s of length Σa_i, as follows:\n\nAmong the piles with the largest number of stones remaining, let x be the index of the pile with the smallest index. Append x to the end of s.\n\nSelect a pile with one or more stones remaining, and remove a stone from that pile.\n\nIf there is a pile with one or more stones remaining, go back to step 1. Otherwise, terminate the process.\n\nWe are interested in the lexicographically smallest sequence that can be constructed. For each of the integers 1,2,3,...,N, how many times does it occur in the lexicographically smallest sequence?\n\nConstraints\n\n1 ≤ N ≤ 10^{5}\n\n1 ≤ a_i ≤ 10^{9}\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\na_1 a_2 ... a_{N}\n\nOutput\n\nPrint N lines. The i-th line should contain the number of the occurrences of the integer i in the lexicographically smallest sequence that can be constructed.\n\nSample Input 1\n\n2\n1 2\n\nSample Output 1\n\n2\n1\n\nThe lexicographically smallest sequence is constructed as follows:\n\nSince the pile with the largest number of stones remaining is pile 2, append 2 to the end of s. Then, remove a stone from pile 2.\n\nSince the piles with the largest number of stones remaining are pile 1 and 2, append 1 to the end of s (we take the smallest index). Then, remove a stone from pile 2.\n\nSince the pile with the largest number of stones remaining is pile 1, append 1 to the end of s. Then, remove a stone from pile 1.\n\nThe resulting sequence is (2,1,1). In this sequence, 1 occurs twice, and 2 occurs once.\n\nSample Input 2\n\n10\n1 2 1 3 2 4 2 5 8 1\n\nSample Output 2\n\n10\n7\n0\n4\n0\n3\n0\n2\n3\n0", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1267, "cpu_time_ms": 249, "memory_kb": 17888}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s869639894", "group_id": "codeNet:p03804", "input_text": "local n,m=io.read(\"n\",\"n\",\"l\")\nlocal a={}\nfor i=1,n do\n a[i]=io.read()\nend\nlocal b={}\nfor i=1,m do\n b[i]=io.read()\nend\n\nfor i=1,n-m+1 do\n for j=1,n-m+1 do\n local flag=true\n for k=i,i+m-1 do\n if a[k]:sub(j,j+m-1)~=b[k-m+1] then\n flag=false\n end\n end\n if flag then\n print(\"Yes\")\n return\n end\n end\nend\nprint(\"No\")", "language": "Lua", "metadata": {"date": 1591496258, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03804.html", "problem_id": "p03804", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03804/input.txt", "sample_output_relpath": "derived/input_output/data/p03804/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03804/Lua/s869639894.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s869639894", "user_id": "u045238009"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "local n,m=io.read(\"n\",\"n\",\"l\")\nlocal a={}\nfor i=1,n do\n a[i]=io.read()\nend\nlocal b={}\nfor i=1,m do\n b[i]=io.read()\nend\n\nfor i=1,n-m+1 do\n for j=1,n-m+1 do\n local flag=true\n for k=i,i+m-1 do\n if a[k]:sub(j,j+m-1)~=b[k-m+1] then\n flag=false\n end\n end\n if flag then\n print(\"Yes\")\n return\n end\n end\nend\nprint(\"No\")", "problem_context": "Score : 200 points\n\nProblem Statement\n\nYou are given an image A composed of N rows and N columns of pixels, and a template image B composed of M rows and M columns of pixels.\n\nA pixel is the smallest element of an image, and in this problem it is a square of size 1×1.\n\nAlso, the given images are binary images, and the color of each pixel is either white or black.\n\nIn the input, every pixel is represented by a character: . corresponds to a white pixel, and # corresponds to a black pixel.\n\nThe image A is given as N strings A_1,...,A_N.\n\nThe j-th character in the string A_i corresponds to the pixel at the i-th row and j-th column of the image A (1≦i,j≦N).\n\nSimilarly, the template image B is given as M strings B_1,...,B_M.\n\nThe j-th character in the string B_i corresponds to the pixel at the i-th row and j-th column of the template image B (1≦i,j≦M).\n\nDetermine whether the template image B is contained in the image A when only parallel shifts can be applied to the images.\n\nConstraints\n\n1≦M≦N≦50\n\nA_i is a string of length N consisting of # and ..\n\nB_i is a string of length M consisting of # and ..\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN M\nA_1\nA_2\n:\nA_N\nB_1\nB_2\n:\nB_M\n\nOutput\n\nPrint Yes if the template image B is contained in the image A. Print No otherwise.\n\nSample Input 1\n\n3 2\n#.#\n.#.\n#.#\n#.\n.#\n\nSample Output 1\n\nYes\n\nThe template image B is identical to the upper-left 2 × 2 subimage and the lower-right 2 × 2 subimage of A. Thus, the output should be Yes.\n\nSample Input 2\n\n4 1\n....\n....\n....\n....\n#\n\nSample Output 2\n\nNo\n\nThe template image B, composed of a black pixel, is not contained in the image A composed of white pixels.", "sample_input": "3 2\n#.#\n.#.\n#.#\n#.\n.#\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03804", "source_text": "Score : 200 points\n\nProblem Statement\n\nYou are given an image A composed of N rows and N columns of pixels, and a template image B composed of M rows and M columns of pixels.\n\nA pixel is the smallest element of an image, and in this problem it is a square of size 1×1.\n\nAlso, the given images are binary images, and the color of each pixel is either white or black.\n\nIn the input, every pixel is represented by a character: . corresponds to a white pixel, and # corresponds to a black pixel.\n\nThe image A is given as N strings A_1,...,A_N.\n\nThe j-th character in the string A_i corresponds to the pixel at the i-th row and j-th column of the image A (1≦i,j≦N).\n\nSimilarly, the template image B is given as M strings B_1,...,B_M.\n\nThe j-th character in the string B_i corresponds to the pixel at the i-th row and j-th column of the template image B (1≦i,j≦M).\n\nDetermine whether the template image B is contained in the image A when only parallel shifts can be applied to the images.\n\nConstraints\n\n1≦M≦N≦50\n\nA_i is a string of length N consisting of # and ..\n\nB_i is a string of length M consisting of # and ..\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN M\nA_1\nA_2\n:\nA_N\nB_1\nB_2\n:\nB_M\n\nOutput\n\nPrint Yes if the template image B is contained in the image A. Print No otherwise.\n\nSample Input 1\n\n3 2\n#.#\n.#.\n#.#\n#.\n.#\n\nSample Output 1\n\nYes\n\nThe template image B is identical to the upper-left 2 × 2 subimage and the lower-right 2 × 2 subimage of A. Thus, the output should be Yes.\n\nSample Input 2\n\n4 1\n....\n....\n....\n....\n#\n\nSample Output 2\n\nNo\n\nThe template image B, composed of a black pixel, is not contained in the image A composed of white pixels.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 416, "cpu_time_ms": 7, "memory_kb": 888}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s040075242", "group_id": "codeNet:p03804", "input_text": "local n, m = io.read(\"*n\", \"*n\", \"*l\")\nlocal a, b = {}, {}\nfor i = 1, n do\n local s = io.read()\n for j = 1, n do\n table.insert(a, s:sub(j, j))\n end\nend\nfor i = 1, m do\n local s = io.read()\n for j = 1, m do\n table.insert(b, s:sub(j, j))\n end\nend\n\nlocal function check(x, y)\n for i = 1, m do\n for j = 1, m do\n local i_b = (i - 1) * m + j\n local i_a = (x + i - 2) * n + y + j - 1\n if b[i_b] ~= a[i_a] then return false end\n end\n end\n return true\nend\n\nlocal f = false\nfor i = 1, n + 1 - m do\n for j = 1, n + 1 - m do\n if check(i, j) then f = true break end\n end\n if f then break end\nend\nprint(f and \"Yes\" or \"No\")\n", "language": "Lua", "metadata": {"date": 1563417969, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03804.html", "problem_id": "p03804", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03804/input.txt", "sample_output_relpath": "derived/input_output/data/p03804/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03804/Lua/s040075242.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s040075242", "user_id": "u120582723"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "local n, m = io.read(\"*n\", \"*n\", \"*l\")\nlocal a, b = {}, {}\nfor i = 1, n do\n local s = io.read()\n for j = 1, n do\n table.insert(a, s:sub(j, j))\n end\nend\nfor i = 1, m do\n local s = io.read()\n for j = 1, m do\n table.insert(b, s:sub(j, j))\n end\nend\n\nlocal function check(x, y)\n for i = 1, m do\n for j = 1, m do\n local i_b = (i - 1) * m + j\n local i_a = (x + i - 2) * n + y + j - 1\n if b[i_b] ~= a[i_a] then return false end\n end\n end\n return true\nend\n\nlocal f = false\nfor i = 1, n + 1 - m do\n for j = 1, n + 1 - m do\n if check(i, j) then f = true break end\n end\n if f then break end\nend\nprint(f and \"Yes\" or \"No\")\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nYou are given an image A composed of N rows and N columns of pixels, and a template image B composed of M rows and M columns of pixels.\n\nA pixel is the smallest element of an image, and in this problem it is a square of size 1×1.\n\nAlso, the given images are binary images, and the color of each pixel is either white or black.\n\nIn the input, every pixel is represented by a character: . corresponds to a white pixel, and # corresponds to a black pixel.\n\nThe image A is given as N strings A_1,...,A_N.\n\nThe j-th character in the string A_i corresponds to the pixel at the i-th row and j-th column of the image A (1≦i,j≦N).\n\nSimilarly, the template image B is given as M strings B_1,...,B_M.\n\nThe j-th character in the string B_i corresponds to the pixel at the i-th row and j-th column of the template image B (1≦i,j≦M).\n\nDetermine whether the template image B is contained in the image A when only parallel shifts can be applied to the images.\n\nConstraints\n\n1≦M≦N≦50\n\nA_i is a string of length N consisting of # and ..\n\nB_i is a string of length M consisting of # and ..\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN M\nA_1\nA_2\n:\nA_N\nB_1\nB_2\n:\nB_M\n\nOutput\n\nPrint Yes if the template image B is contained in the image A. Print No otherwise.\n\nSample Input 1\n\n3 2\n#.#\n.#.\n#.#\n#.\n.#\n\nSample Output 1\n\nYes\n\nThe template image B is identical to the upper-left 2 × 2 subimage and the lower-right 2 × 2 subimage of A. Thus, the output should be Yes.\n\nSample Input 2\n\n4 1\n....\n....\n....\n....\n#\n\nSample Output 2\n\nNo\n\nThe template image B, composed of a black pixel, is not contained in the image A composed of white pixels.", "sample_input": "3 2\n#.#\n.#.\n#.#\n#.\n.#\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03804", "source_text": "Score : 200 points\n\nProblem Statement\n\nYou are given an image A composed of N rows and N columns of pixels, and a template image B composed of M rows and M columns of pixels.\n\nA pixel is the smallest element of an image, and in this problem it is a square of size 1×1.\n\nAlso, the given images are binary images, and the color of each pixel is either white or black.\n\nIn the input, every pixel is represented by a character: . corresponds to a white pixel, and # corresponds to a black pixel.\n\nThe image A is given as N strings A_1,...,A_N.\n\nThe j-th character in the string A_i corresponds to the pixel at the i-th row and j-th column of the image A (1≦i,j≦N).\n\nSimilarly, the template image B is given as M strings B_1,...,B_M.\n\nThe j-th character in the string B_i corresponds to the pixel at the i-th row and j-th column of the template image B (1≦i,j≦M).\n\nDetermine whether the template image B is contained in the image A when only parallel shifts can be applied to the images.\n\nConstraints\n\n1≦M≦N≦50\n\nA_i is a string of length N consisting of # and ..\n\nB_i is a string of length M consisting of # and ..\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN M\nA_1\nA_2\n:\nA_N\nB_1\nB_2\n:\nB_M\n\nOutput\n\nPrint Yes if the template image B is contained in the image A. Print No otherwise.\n\nSample Input 1\n\n3 2\n#.#\n.#.\n#.#\n#.\n.#\n\nSample Output 1\n\nYes\n\nThe template image B is identical to the upper-left 2 × 2 subimage and the lower-right 2 × 2 subimage of A. Thus, the output should be Yes.\n\nSample Input 2\n\n4 1\n....\n....\n....\n....\n#\n\nSample Output 2\n\nNo\n\nThe template image B, composed of a black pixel, is not contained in the image A composed of white pixels.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 652, "cpu_time_ms": 7, "memory_kb": 760}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s786444329", "group_id": "codeNet:p03805", "input_text": "local n, m = io.read(\"*n\", \"*n\")\nlocal t = {}\nfor i = 1, n do t[i] = {} end\nfor i = 1, m do\n local a, b = io.read(\"*n\", \"*n\")\n t[a][b], t[b][a] = true, true\nend\nlocal mult = 1\nfor i = 2, n - 1 do\n mult = mult * i\nend\nlocal cnt = 0\nfor i = 0, mult - 1 do\n local rem = {}\n local resarray = {1}\n for j = 2, n do rem[j - 1] = j end\n local it = i\n\n local tmpmult = mult\n for j = n - 1, 1, -1 do \n local divfactor = tmpmult / j\n local pos = 1 + math.floor(it / divfactor)\n table.insert(resarray, rem[pos])\n table.remove(rem, pos)\n tmpmult = divfactor\n it = it % divfactor\n end\n local isok = true\n for j = 1, n - 1 do\n if(not t[resarray[j]][resarray[j+1]]) then\n isok = false\n break\n end\n end\n if(isok) then cnt = cnt + 1 end\nend\nprint(cnt)\n", "language": "Lua", "metadata": {"date": 1555421780, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p03805.html", "problem_id": "p03805", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03805/input.txt", "sample_output_relpath": "derived/input_output/data/p03805/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03805/Lua/s786444329.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s786444329", "user_id": "u120582723"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "local n, m = io.read(\"*n\", \"*n\")\nlocal t = {}\nfor i = 1, n do t[i] = {} end\nfor i = 1, m do\n local a, b = io.read(\"*n\", \"*n\")\n t[a][b], t[b][a] = true, true\nend\nlocal mult = 1\nfor i = 2, n - 1 do\n mult = mult * i\nend\nlocal cnt = 0\nfor i = 0, mult - 1 do\n local rem = {}\n local resarray = {1}\n for j = 2, n do rem[j - 1] = j end\n local it = i\n\n local tmpmult = mult\n for j = n - 1, 1, -1 do \n local divfactor = tmpmult / j\n local pos = 1 + math.floor(it / divfactor)\n table.insert(resarray, rem[pos])\n table.remove(rem, pos)\n tmpmult = divfactor\n it = it % divfactor\n end\n local isok = true\n for j = 1, n - 1 do\n if(not t[resarray[j]][resarray[j+1]]) then\n isok = false\n break\n end\n end\n if(isok) then cnt = cnt + 1 end\nend\nprint(cnt)\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nYou are given an undirected unweighted graph with N vertices and M edges that contains neither self-loops nor double edges.\n\nHere, a self-loop is an edge where a_i = b_i (1≤i≤M), and double edges are two edges where (a_i,b_i)=(a_j,b_j) or (a_i,b_i)=(b_j,a_j) (1≤i depth[y]\nend\nlocal mma = math.max\nwhile 0 < #tasks do\n local c = tasks[#tasks]\n table.remove(tasks)\n local p = parent[c]\n childpush[p] = childpush[p] + 1\n if childpush[p] == #child[p] then\n table.sort(child[p], sortfunc)\n local d = 0\n for i = 1, #child[p] do\n d = mma(d, i + depth[child[p][i]])\n end\n depth[p] = d\n if 1 < p then\n table.insert(tasks, p)\n end\n end\nend\nprint(depth[1])\n", "language": "Lua", "metadata": {"date": 1569763002, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p03822.html", "problem_id": "p03822", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03822/input.txt", "sample_output_relpath": "derived/input_output/data/p03822/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03822/Lua/s870624591.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s870624591", "user_id": "u120582723"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "local n = io.read(\"*n\")\nlocal parent, child, childpush = {}, {}, {}\nlocal depth = {}\nfor i = 1, n do\n child[i] = {}\n depth[i] = 0\n childpush[i] = 0\nend\nparent[1] = 0\nfor i = 2, n do\n local a = io.read(\"*n\")\n parent[i] = a\n table.insert(child[a], i)\nend\nlocal tasks = {}\nfor i = 1, n do\n if #child[i] == 0 then\n table.insert(tasks, i)\n end\nend\nlocal function sortfunc(x, y)\n return depth[x] > depth[y]\nend\nlocal mma = math.max\nwhile 0 < #tasks do\n local c = tasks[#tasks]\n table.remove(tasks)\n local p = parent[c]\n childpush[p] = childpush[p] + 1\n if childpush[p] == #child[p] then\n table.sort(child[p], sortfunc)\n local d = 0\n for i = 1, #child[p] do\n d = mma(d, i + depth[child[p][i]])\n end\n depth[p] = d\n if 1 < p then\n table.insert(tasks, p)\n end\n end\nend\nprint(depth[1])\n", "problem_context": "Score : 800 points\n\nProblem Statement\n\nN contestants participated in a competition. The total of N-1 matches were played in a knockout tournament.\nFor some reasons, the tournament may not be \"fair\" for all the contestants.\nThat is, the number of the matches that must be played in order to win the championship may be different for each contestant. The structure of the tournament is formally described at the end of this statement.\n\nAfter each match, there were always one winner and one loser. The last contestant standing was declared the champion.\n\nFigure: an example of a tournament\n\nFor convenience, the contestants were numbered 1 through N. The contestant numbered 1 was the champion, and the contestant numbered i(2 ≦ i ≦ N) was defeated in a match against the contestant numbered a_i.\n\nWe will define the depth of the tournament as the maximum number of the matches that must be played in order to win the championship over all the contestants.\n\nFind the minimum possible depth of the tournament.\n\nThe formal description of the structure of the tournament is as follows. In the i-th match, one of the following played against each other:\n\nTwo predetermined contestants\n\nOne predetermined contestant and the winner of the j-th match, where j(j 0 and self.lower(ku, k) do\n self:_swap(ku, k)\n k = k//2\n ku = ku//2\n end\nend\n\nfunction Heap:insertq(e)\n table.insert(self.a, e)\n self:upheap(#self.a)\nend\n\nfunction Heap:downheap(newk)\n local k = newk\n while k <= #self.a//2 do\n local kdl = k*2\n local kdr = kdl + 1\n local kd\n if kdr <= #self.a and self.lower(kdl, kdr) then\n kd = kdr\n else\n kd = kdl\n end\n if self.upper(k, kd) then\n break\n end\n self:_swap(k, kd)\n k = kd\n end\nend\n\nfunction Heap:top()\n assert(#self.a >= 1)\n return self.a[1]\nend\n\nfunction Heap:remove_top()\n assert(#self.a >= 1)\n local v = self.a[1]\n self:_swap(1, #self.a)\n table.remove(self.a)\n self:downheap(1)\n return v\nend\n\nfunction Heap:replace_top(e)\n assert(#self.a >= 1)\n local old_v = self.a[1]\n local swapped = false\n if self.upper_func(old_v, e) then\n self.a[1] = e\n self:downheap(1)\n swapped = true\n end\n return swapped, old_v\nend\n\n-- dijkstra's algorithm\nlocal function find_shortest_path_all(adj_list, src)\n local INF = math.maxinteger\n local from1 = {}\n local prevs = {}\n from1[src] = 0\n local q = Heap.new(function (v1, v2)\n return from1[v1] < from1[v2]\n end)\n local proved = {}\n q:insertq(src)\n while q:count() > 0 do\n local cur_v = q:remove_top()\n if not proved[cur_v] then\n proved[cur_v] = true\n local cur_cost = from1[cur_v]\n --[[\n if cur_v == dst then\n return cur_cost\n end\n ]]\n for _, link in ipairs(adj_list[cur_v]) do\n local to, cost = table.unpack(link)\n if not proved[to] then\n -- compare costs\n local before = from1[to]\n local candidate = cur_cost + cost\n if not before or candidate < before then\n from1[to] = candidate\n prevs[to] = cur_v\n q:insertq(to)\n end\n end\n end\n end\n end\n return from1, prevs\nend\n\nlocal function make_path(prevs, src, dst)\n local path = {}\n path[#path+1] = dst\n local cur = dst\n while cur ~= src do\n local next = prevs[cur]\n path[#path+1] = next\n cur = next\n end\n -- reverse\n for i=1, #path//2 do\n path[i], path[#path-i+1] = path[#path-i+1], path[i]\n end\n return path\nend\n\n-- main\nlocal N, M = io.read(\"n\", \"n\")\n\nlocal edges = {}\nfor i=1,M do\n local a, b, cost = io.read(\"n\", \"n\", \"n\")\n edges[#edges+1] = {a, b, cost}\nend\n\nlocal adj_list = {}\nfor i=1,N do\n adj_list[i] = {}\nend\n\nlocal edge_check = {}\nfor s=1,N do\n edge_check[s] = {}\nend\n\nfor i=1,M do\n local a, b, cost = table.unpack(edges[i])\n local list = adj_list[a]\n list[#list+1] = {b, cost}\n local list2 = adj_list[b]\n list2[#list2+1] = {a, cost}\n local small = math.min(a, b)\n local big = math.max(a, b)\n edge_check[small][big] = 0\nend\n\n\nfor s=1,N do\n local c, prevs = find_shortest_path_all(adj_list, s)\n for dd=1,N do\n if dd ~= s then\n local ss = prevs[dd]\n local small = math.min(ss, dd)\n local big = math.max(ss, dd)\n edge_check[small][big] = edge_check[small][big] + 1\n end\n end\nend\n\nlocal ans = 0\nfor s=1,N do\n for d=s+1,N do\n local count = edge_check[s][d]\n if count and count == 0 then\n ans = ans + 1\n end\n end\nend\nprint(ans)\n", "language": "Lua", "metadata": {"date": 1558588935, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03837.html", "problem_id": "p03837", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03837/input.txt", "sample_output_relpath": "derived/input_output/data/p03837/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03837/Lua/s075628511.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s075628511", "user_id": "u162773977"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "-- heap\nlocal Heap = {}\nfunction Heap.new(upper_func)\n local self = setmetatable({}, {__index = Heap})\n self.a = {}\n self.upper_func = upper_func\n self.upper = function(k1, k2)\n assert(k1 < k2)\n if k1 == 0 then\n return false\n else\n return upper_func(self.a[k1], self.a[k2])\n end\n end\n self.lower = function(k1, k2)\n return not self.upper(k1, k2)\n end\n return self\nend\n\nfunction Heap:count()\n return #self.a\nend\n\nfunction Heap:_swap(k1, k2)\n local old_k1 = self.a[k1]\n self.a[k1] = self.a[k2]\n self.a[k2] = old_k1\nend\n\nfunction Heap:upheap(newk)\n local ku = newk // 2\n local k = newk\n while ku > 0 and self.lower(ku, k) do\n self:_swap(ku, k)\n k = k//2\n ku = ku//2\n end\nend\n\nfunction Heap:insertq(e)\n table.insert(self.a, e)\n self:upheap(#self.a)\nend\n\nfunction Heap:downheap(newk)\n local k = newk\n while k <= #self.a//2 do\n local kdl = k*2\n local kdr = kdl + 1\n local kd\n if kdr <= #self.a and self.lower(kdl, kdr) then\n kd = kdr\n else\n kd = kdl\n end\n if self.upper(k, kd) then\n break\n end\n self:_swap(k, kd)\n k = kd\n end\nend\n\nfunction Heap:top()\n assert(#self.a >= 1)\n return self.a[1]\nend\n\nfunction Heap:remove_top()\n assert(#self.a >= 1)\n local v = self.a[1]\n self:_swap(1, #self.a)\n table.remove(self.a)\n self:downheap(1)\n return v\nend\n\nfunction Heap:replace_top(e)\n assert(#self.a >= 1)\n local old_v = self.a[1]\n local swapped = false\n if self.upper_func(old_v, e) then\n self.a[1] = e\n self:downheap(1)\n swapped = true\n end\n return swapped, old_v\nend\n\n-- dijkstra's algorithm\nlocal function find_shortest_path_all(adj_list, src)\n local INF = math.maxinteger\n local from1 = {}\n local prevs = {}\n from1[src] = 0\n local q = Heap.new(function (v1, v2)\n return from1[v1] < from1[v2]\n end)\n local proved = {}\n q:insertq(src)\n while q:count() > 0 do\n local cur_v = q:remove_top()\n if not proved[cur_v] then\n proved[cur_v] = true\n local cur_cost = from1[cur_v]\n --[[\n if cur_v == dst then\n return cur_cost\n end\n ]]\n for _, link in ipairs(adj_list[cur_v]) do\n local to, cost = table.unpack(link)\n if not proved[to] then\n -- compare costs\n local before = from1[to]\n local candidate = cur_cost + cost\n if not before or candidate < before then\n from1[to] = candidate\n prevs[to] = cur_v\n q:insertq(to)\n end\n end\n end\n end\n end\n return from1, prevs\nend\n\nlocal function make_path(prevs, src, dst)\n local path = {}\n path[#path+1] = dst\n local cur = dst\n while cur ~= src do\n local next = prevs[cur]\n path[#path+1] = next\n cur = next\n end\n -- reverse\n for i=1, #path//2 do\n path[i], path[#path-i+1] = path[#path-i+1], path[i]\n end\n return path\nend\n\n-- main\nlocal N, M = io.read(\"n\", \"n\")\n\nlocal edges = {}\nfor i=1,M do\n local a, b, cost = io.read(\"n\", \"n\", \"n\")\n edges[#edges+1] = {a, b, cost}\nend\n\nlocal adj_list = {}\nfor i=1,N do\n adj_list[i] = {}\nend\n\nlocal edge_check = {}\nfor s=1,N do\n edge_check[s] = {}\nend\n\nfor i=1,M do\n local a, b, cost = table.unpack(edges[i])\n local list = adj_list[a]\n list[#list+1] = {b, cost}\n local list2 = adj_list[b]\n list2[#list2+1] = {a, cost}\n local small = math.min(a, b)\n local big = math.max(a, b)\n edge_check[small][big] = 0\nend\n\n\nfor s=1,N do\n local c, prevs = find_shortest_path_all(adj_list, s)\n for dd=1,N do\n if dd ~= s then\n local ss = prevs[dd]\n local small = math.min(ss, dd)\n local big = math.max(ss, dd)\n edge_check[small][big] = edge_check[small][big] + 1\n end\n end\nend\n\nlocal ans = 0\nfor s=1,N do\n for d=s+1,N do\n local count = edge_check[s][d]\n if count and count == 0 then\n ans = ans + 1\n end\n end\nend\nprint(ans)\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nYou are given an undirected connected weighted graph with N vertices and M edges that contains neither self-loops nor double edges.\n\nThe i-th (1≤i≤M) edge connects vertex a_i and vertex b_i with a distance of c_i.\n\nHere, a self-loop is an edge where a_i = b_i (1≤i≤M), and double edges are two edges where (a_i,b_i)=(a_j,b_j) or (a_i,b_i)=(b_j,a_j) (1≤isize[y] then\n x,y=y,x\n end\n list[x]=y\n size[y]=size[y]+size[x]\nend\n\nlocal function getsize(x)\n return size[root(x,list)]\nend\n\n----------\n\nlocal n,k,l=io.read(\"n\",\"n\",\"n\")\ninit(n)\n\nfor i=1,k do\n local p,q=io.read(\"n\",\"n\")\n unite(p,q,road)\nend\n\nfor i=1,l do\n local r,s=io.read(\"n\",\"n\")\n unite(r,s,rail)\nend\n\nlocal counter={}\nfor i=1,n do\n local key=root(i,road)..\" \"..root(i,rail)\n counter[key]=(counter[key] or 0)+1\nend\n\nfor i=1,n do\n local key=root(i,road)..\" \"..root(i,rail)\n io.write(counter[key]..\" \")\nend\nprint()", "language": "Lua", "metadata": {"date": 1598248016, "filename_ext": "lua", "original_language": "Lua (LuaJIT 2.1.0)", "problem_description_relpath": "problem_descriptions/p03855.html", "problem_id": "p03855", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03855/input.txt", "sample_output_relpath": "derived/input_output/data/p03855/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03855/Lua/s249965896.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s249965896", "user_id": "u045238009"}, "prompt_components": {"gold_output": "1 2 2 1\n", "input_to_evaluate": "local road={}\nlocal rail={}\nlocal size={}\n\nlocal function init(n)\n for i=1,n do\n road[i]=i\n rail[i]=i\n size[i]=1\n end\nend\n\nlocal function root(x,list)\n return list[x]==x and x or root(list[x],list)\nend\n\nlocal function same(x,y,list)\n return root(x,list)==root(y,list)\nend\n\nlocal function unite(x,y,list)\n x=root(x,list)\n y=root(y,list)\n if x==y then\n return\n end\n if size[x]>size[y] then\n x,y=y,x\n end\n list[x]=y\n size[y]=size[y]+size[x]\nend\n\nlocal function getsize(x)\n return size[root(x,list)]\nend\n\n----------\n\nlocal n,k,l=io.read(\"n\",\"n\",\"n\")\ninit(n)\n\nfor i=1,k do\n local p,q=io.read(\"n\",\"n\")\n unite(p,q,road)\nend\n\nfor i=1,l do\n local r,s=io.read(\"n\",\"n\")\n unite(r,s,rail)\nend\n\nlocal counter={}\nfor i=1,n do\n local key=root(i,road)..\" \"..root(i,rail)\n counter[key]=(counter[key] or 0)+1\nend\n\nfor i=1,n do\n local key=root(i,road)..\" \"..root(i,rail)\n io.write(counter[key]..\" \")\nend\nprint()", "problem_context": "Score : 400 points\n\nProblem Statement\n\nThere are N cities. There are also K roads and L railways, extending between the cities.\nThe i-th road bidirectionally connects the p_i-th and q_i-th cities, and the i-th railway bidirectionally connects the r_i-th and s_i-th cities.\nNo two roads connect the same pair of cities. Similarly, no two railways connect the same pair of cities.\n\nWe will say city A and B are connected by roads if city B is reachable from city A by traversing some number of roads. Here, any city is considered to be connected to itself by roads.\nWe will also define connectivity by railways similarly.\n\nFor each city, find the number of the cities connected to that city by both roads and railways.\n\nConstraints\n\n2 ≦ N ≦ 2*10^5\n\n1 ≦ K, L≦ 10^5\n\n1 ≦ p_i, q_i, r_i, s_i ≦ N\n\np_i < q_i\n\nr_i < s_i\n\nWhen i ≠ j, (p_i, q_i) ≠ (p_j, q_j)\n\nWhen i ≠ j, (r_i, s_i) ≠ (r_j, s_j)\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN K L\np_1 q_1\n:\np_K q_K\nr_1 s_1\n:\nr_L s_L\n\nOutput\n\nPrint N integers. The i-th of them should represent the number of the cities connected to the i-th city by both roads and railways.\n\nSample Input 1\n\n4 3 1\n1 2\n2 3\n3 4\n2 3\n\nSample Output 1\n\n1 2 2 1\n\nAll the four cities are connected to each other by roads.\n\nBy railways, only the second and third cities are connected. Thus, the answers for the cities are 1, 2, 2 and 1, respectively.\n\nSample Input 2\n\n4 2 2\n1 2\n2 3\n1 4\n2 3\n\nSample Output 2\n\n1 2 2 1\n\nSample Input 3\n\n7 4 4\n1 2\n2 3\n2 5\n6 7\n3 5\n4 5\n3 4\n6 7\n\nSample Output 3\n\n1 1 2 1 2 2 2", "sample_input": "4 3 1\n1 2\n2 3\n3 4\n2 3\n"}, "reference_outputs": ["1 2 2 1\n"], "source_document_id": "p03855", "source_text": "Score : 400 points\n\nProblem Statement\n\nThere are N cities. There are also K roads and L railways, extending between the cities.\nThe i-th road bidirectionally connects the p_i-th and q_i-th cities, and the i-th railway bidirectionally connects the r_i-th and s_i-th cities.\nNo two roads connect the same pair of cities. Similarly, no two railways connect the same pair of cities.\n\nWe will say city A and B are connected by roads if city B is reachable from city A by traversing some number of roads. Here, any city is considered to be connected to itself by roads.\nWe will also define connectivity by railways similarly.\n\nFor each city, find the number of the cities connected to that city by both roads and railways.\n\nConstraints\n\n2 ≦ N ≦ 2*10^5\n\n1 ≦ K, L≦ 10^5\n\n1 ≦ p_i, q_i, r_i, s_i ≦ N\n\np_i < q_i\n\nr_i < s_i\n\nWhen i ≠ j, (p_i, q_i) ≠ (p_j, q_j)\n\nWhen i ≠ j, (r_i, s_i) ≠ (r_j, s_j)\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN K L\np_1 q_1\n:\np_K q_K\nr_1 s_1\n:\nr_L s_L\n\nOutput\n\nPrint N integers. The i-th of them should represent the number of the cities connected to the i-th city by both roads and railways.\n\nSample Input 1\n\n4 3 1\n1 2\n2 3\n3 4\n2 3\n\nSample Output 1\n\n1 2 2 1\n\nAll the four cities are connected to each other by roads.\n\nBy railways, only the second and third cities are connected. Thus, the answers for the cities are 1, 2, 2 and 1, respectively.\n\nSample Input 2\n\n4 2 2\n1 2\n2 3\n1 4\n2 3\n\nSample Output 2\n\n1 2 2 1\n\nSample Input 3\n\n7 4 4\n1 2\n2 3\n2 5\n6 7\n3 5\n4 5\n3 4\n6 7\n\nSample Output 3\n\n1 1 2 1 2 2 2", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 989, "cpu_time_ms": 222, "memory_kb": 24148}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s576539885", "group_id": "codeNet:p03855", "input_text": "local n, k, l = io.read(\"*n\", \"*n\", \"*n\")\n\nlocal function uf_initialize(n)\n local parent = {}\n for i = 1, n do parent[i] = i end\n return parent\nend\n\nlocal function uf_findroot(idx, parent)\n local idx_update = idx\n while parent[idx] ~= idx do\n idx = parent[idx]\n end\n while parent[idx_update] ~= idx do\n parent[idx_update], idx_update = idx, parent[idx_update]\n end\n return idx\nend\n\nlocal p1, p2 = uf_initialize(n), uf_initialize(n)\n\nfor i = 1, k do\n local a, b = io.read(\"*n\", \"*n\")\n local ra, rb = uf_findroot(a, p1), uf_findroot(b, p1)\n p1[b], p1[rb] = ra, ra\nend\n\nfor i = 1, l do\n local a, b = io.read(\"*n\", \"*n\")\n local ra, rb = uf_findroot(a, p2), uf_findroot(b, p2)\n p2[b], p2[rb] = ra, ra\nend\n\nlocal function getidx(r1, r2)\n return r1 - 1 + r2 * n\nend\nlocal groups = {}\nfor i = 1, n do\n local idx = getidx(uf_findroot(i, p1), uf_findroot(i, p2))\n if not groups[idx] then\n groups[idx] = 1\n else\n groups[idx] = groups[idx] + 1\n end\nend\nfor i = 1, n do\n local idx = getidx(uf_findroot(i, p1), uf_findroot(i, p2))\n io.write(groups[idx])\n io.write(i == n and \"\\n\" or \" \")\nend\n", "language": "Lua", "metadata": {"date": 1563848315, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p03855.html", "problem_id": "p03855", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03855/input.txt", "sample_output_relpath": "derived/input_output/data/p03855/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03855/Lua/s576539885.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s576539885", "user_id": "u120582723"}, "prompt_components": {"gold_output": "1 2 2 1\n", "input_to_evaluate": "local n, k, l = io.read(\"*n\", \"*n\", \"*n\")\n\nlocal function uf_initialize(n)\n local parent = {}\n for i = 1, n do parent[i] = i end\n return parent\nend\n\nlocal function uf_findroot(idx, parent)\n local idx_update = idx\n while parent[idx] ~= idx do\n idx = parent[idx]\n end\n while parent[idx_update] ~= idx do\n parent[idx_update], idx_update = idx, parent[idx_update]\n end\n return idx\nend\n\nlocal p1, p2 = uf_initialize(n), uf_initialize(n)\n\nfor i = 1, k do\n local a, b = io.read(\"*n\", \"*n\")\n local ra, rb = uf_findroot(a, p1), uf_findroot(b, p1)\n p1[b], p1[rb] = ra, ra\nend\n\nfor i = 1, l do\n local a, b = io.read(\"*n\", \"*n\")\n local ra, rb = uf_findroot(a, p2), uf_findroot(b, p2)\n p2[b], p2[rb] = ra, ra\nend\n\nlocal function getidx(r1, r2)\n return r1 - 1 + r2 * n\nend\nlocal groups = {}\nfor i = 1, n do\n local idx = getidx(uf_findroot(i, p1), uf_findroot(i, p2))\n if not groups[idx] then\n groups[idx] = 1\n else\n groups[idx] = groups[idx] + 1\n end\nend\nfor i = 1, n do\n local idx = getidx(uf_findroot(i, p1), uf_findroot(i, p2))\n io.write(groups[idx])\n io.write(i == n and \"\\n\" or \" \")\nend\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nThere are N cities. There are also K roads and L railways, extending between the cities.\nThe i-th road bidirectionally connects the p_i-th and q_i-th cities, and the i-th railway bidirectionally connects the r_i-th and s_i-th cities.\nNo two roads connect the same pair of cities. Similarly, no two railways connect the same pair of cities.\n\nWe will say city A and B are connected by roads if city B is reachable from city A by traversing some number of roads. Here, any city is considered to be connected to itself by roads.\nWe will also define connectivity by railways similarly.\n\nFor each city, find the number of the cities connected to that city by both roads and railways.\n\nConstraints\n\n2 ≦ N ≦ 2*10^5\n\n1 ≦ K, L≦ 10^5\n\n1 ≦ p_i, q_i, r_i, s_i ≦ N\n\np_i < q_i\n\nr_i < s_i\n\nWhen i ≠ j, (p_i, q_i) ≠ (p_j, q_j)\n\nWhen i ≠ j, (r_i, s_i) ≠ (r_j, s_j)\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN K L\np_1 q_1\n:\np_K q_K\nr_1 s_1\n:\nr_L s_L\n\nOutput\n\nPrint N integers. The i-th of them should represent the number of the cities connected to the i-th city by both roads and railways.\n\nSample Input 1\n\n4 3 1\n1 2\n2 3\n3 4\n2 3\n\nSample Output 1\n\n1 2 2 1\n\nAll the four cities are connected to each other by roads.\n\nBy railways, only the second and third cities are connected. Thus, the answers for the cities are 1, 2, 2 and 1, respectively.\n\nSample Input 2\n\n4 2 2\n1 2\n2 3\n1 4\n2 3\n\nSample Output 2\n\n1 2 2 1\n\nSample Input 3\n\n7 4 4\n1 2\n2 3\n2 5\n6 7\n3 5\n4 5\n3 4\n6 7\n\nSample Output 3\n\n1 1 2 1 2 2 2", "sample_input": "4 3 1\n1 2\n2 3\n3 4\n2 3\n"}, "reference_outputs": ["1 2 2 1\n"], "source_document_id": "p03855", "source_text": "Score : 400 points\n\nProblem Statement\n\nThere are N cities. There are also K roads and L railways, extending between the cities.\nThe i-th road bidirectionally connects the p_i-th and q_i-th cities, and the i-th railway bidirectionally connects the r_i-th and s_i-th cities.\nNo two roads connect the same pair of cities. Similarly, no two railways connect the same pair of cities.\n\nWe will say city A and B are connected by roads if city B is reachable from city A by traversing some number of roads. Here, any city is considered to be connected to itself by roads.\nWe will also define connectivity by railways similarly.\n\nFor each city, find the number of the cities connected to that city by both roads and railways.\n\nConstraints\n\n2 ≦ N ≦ 2*10^5\n\n1 ≦ K, L≦ 10^5\n\n1 ≦ p_i, q_i, r_i, s_i ≦ N\n\np_i < q_i\n\nr_i < s_i\n\nWhen i ≠ j, (p_i, q_i) ≠ (p_j, q_j)\n\nWhen i ≠ j, (r_i, s_i) ≠ (r_j, s_j)\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN K L\np_1 q_1\n:\np_K q_K\nr_1 s_1\n:\nr_L s_L\n\nOutput\n\nPrint N integers. The i-th of them should represent the number of the cities connected to the i-th city by both roads and railways.\n\nSample Input 1\n\n4 3 1\n1 2\n2 3\n3 4\n2 3\n\nSample Output 1\n\n1 2 2 1\n\nAll the four cities are connected to each other by roads.\n\nBy railways, only the second and third cities are connected. Thus, the answers for the cities are 1, 2, 2 and 1, respectively.\n\nSample Input 2\n\n4 2 2\n1 2\n2 3\n1 4\n2 3\n\nSample Output 2\n\n1 2 2 1\n\nSample Input 3\n\n7 4 4\n1 2\n2 3\n2 5\n6 7\n3 5\n4 5\n3 4\n6 7\n\nSample Output 3\n\n1 1 2 1 2 2 2", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1113, "cpu_time_ms": 235, "memory_kb": 13744}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s455462459", "group_id": "codeNet:p03860", "input_text": "print(\"A\"..io.read():match(\"%s(.).*%s\")..\"C\")", "language": "Lua", "metadata": {"date": 1551656915, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p03860.html", "problem_id": "p03860", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03860/input.txt", "sample_output_relpath": "derived/input_output/data/p03860/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03860/Lua/s455462459.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s455462459", "user_id": "u837412668"}, "prompt_components": {"gold_output": "ABC\n", "input_to_evaluate": "print(\"A\"..io.read():match(\"%s(.).*%s\")..\"C\")", "problem_context": "Score : 100 points\n\nProblem Statement\n\nSnuke is going to open a contest named \"AtCoder s Contest\".\nHere, s is a string of length 1 or greater, where the first character is an uppercase English letter, and the second and subsequent characters are lowercase English letters.\n\nSnuke has decided to abbreviate the name of the contest as \"AxC\".\nHere, x is the uppercase English letter at the beginning of s.\n\nGiven the name of the contest, print the abbreviation of the name.\n\nConstraints\n\nThe length of s is between 1 and 100, inclusive.\n\nThe first character in s is an uppercase English letter.\n\nThe second and subsequent characters in s are lowercase English letters.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nAtCoder s Contest\n\nOutput\n\nPrint the abbreviation of the name of the contest.\n\nSample Input 1\n\nAtCoder Beginner Contest\n\nSample Output 1\n\nABC\n\nThe contest in which you are participating now.\n\nSample Input 2\n\nAtCoder Snuke Contest\n\nSample Output 2\n\nASC\n\nThis contest does not actually exist.\n\nSample Input 3\n\nAtCoder X Contest\n\nSample Output 3\n\nAXC", "sample_input": "AtCoder Beginner Contest\n"}, "reference_outputs": ["ABC\n"], "source_document_id": "p03860", "source_text": "Score : 100 points\n\nProblem Statement\n\nSnuke is going to open a contest named \"AtCoder s Contest\".\nHere, s is a string of length 1 or greater, where the first character is an uppercase English letter, and the second and subsequent characters are lowercase English letters.\n\nSnuke has decided to abbreviate the name of the contest as \"AxC\".\nHere, x is the uppercase English letter at the beginning of s.\n\nGiven the name of the contest, print the abbreviation of the name.\n\nConstraints\n\nThe length of s is between 1 and 100, inclusive.\n\nThe first character in s is an uppercase English letter.\n\nThe second and subsequent characters in s are lowercase English letters.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nAtCoder s Contest\n\nOutput\n\nPrint the abbreviation of the name of the contest.\n\nSample Input 1\n\nAtCoder Beginner Contest\n\nSample Output 1\n\nABC\n\nThe contest in which you are participating now.\n\nSample Input 2\n\nAtCoder Snuke Contest\n\nSample Output 2\n\nASC\n\nThis contest does not actually exist.\n\nSample Input 3\n\nAtCoder X Contest\n\nSample Output 3\n\nAXC", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 45, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s758824263", "group_id": "codeNet:p03861", "input_text": "a,b,x=io.read(\"n\",\"n\",\"n\")\nprint((b//x)-((a-1)//x))", "language": "Lua", "metadata": {"date": 1591144799, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03861.html", "problem_id": "p03861", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03861/input.txt", "sample_output_relpath": "derived/input_output/data/p03861/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03861/Lua/s758824263.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s758824263", "user_id": "u045238009"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "a,b,x=io.read(\"n\",\"n\",\"n\")\nprint((b//x)-((a-1)//x))", "problem_context": "Score : 200 points\n\nProblem Statement\n\nYou are given nonnegative integers a and b (a ≤ b), and a positive integer x.\nAmong the integers between a and b, inclusive, how many are divisible by x?\n\nConstraints\n\n0 ≤ a ≤ b ≤ 10^{18}\n\n1 ≤ x ≤ 10^{18}\n\nInput\n\nThe input is given from Standard Input in the following format:\n\na b x\n\nOutput\n\nPrint the number of the integers between a and b, inclusive, that are divisible by x.\n\nSample Input 1\n\n4 8 2\n\nSample Output 1\n\n3\n\nThere are three integers between 4 and 8, inclusive, that are divisible by 2: 4, 6 and 8.\n\nSample Input 2\n\n0 5 1\n\nSample Output 2\n\n6\n\nThere are six integers between 0 and 5, inclusive, that are divisible by 1: 0, 1, 2, 3, 4 and 5.\n\nSample Input 3\n\n9 9 2\n\nSample Output 3\n\n0\n\nThere are no integer between 9 and 9, inclusive, that is divisible by 2.\n\nSample Input 4\n\n1 1000000000000000000 3\n\nSample Output 4\n\n333333333333333333\n\nWatch out for integer overflows.", "sample_input": "4 8 2\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03861", "source_text": "Score : 200 points\n\nProblem Statement\n\nYou are given nonnegative integers a and b (a ≤ b), and a positive integer x.\nAmong the integers between a and b, inclusive, how many are divisible by x?\n\nConstraints\n\n0 ≤ a ≤ b ≤ 10^{18}\n\n1 ≤ x ≤ 10^{18}\n\nInput\n\nThe input is given from Standard Input in the following format:\n\na b x\n\nOutput\n\nPrint the number of the integers between a and b, inclusive, that are divisible by x.\n\nSample Input 1\n\n4 8 2\n\nSample Output 1\n\n3\n\nThere are three integers between 4 and 8, inclusive, that are divisible by 2: 4, 6 and 8.\n\nSample Input 2\n\n0 5 1\n\nSample Output 2\n\n6\n\nThere are six integers between 0 and 5, inclusive, that are divisible by 1: 0, 1, 2, 3, 4 and 5.\n\nSample Input 3\n\n9 9 2\n\nSample Output 3\n\n0\n\nThere are no integer between 9 and 9, inclusive, that is divisible by 2.\n\nSample Input 4\n\n1 1000000000000000000 3\n\nSample Output 4\n\n333333333333333333\n\nWatch out for integer overflows.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 51, "cpu_time_ms": 5, "memory_kb": 632}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s257948296", "group_id": "codeNet:p03862", "input_text": "local n,x=io.read(\"n\",\"n\")\nlocal a={}\nfor i=1,n do\n a[i]=io.read(\"n\")\nend\n\nlocal counter=0\nfor i=1,n-1 do\n local sum=a[i]+a[i+1]\n if sum>x then\n local diff=sum-x\n counter=counter+diff\n if diffx then\n local diff=sum-x\n counter=counter+diff\n if diff=n then\n max=mid\n else\n min=mid\n end\n end\n return max\nend\n\nlocal x=upper_bound(n)\nfor i=1,x do\n if i~=x*(x+1)//2-n then\n print(i)\n end\nend", "language": "Lua", "metadata": {"date": 1591020825, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03910.html", "problem_id": "p03910", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03910/input.txt", "sample_output_relpath": "derived/input_output/data/p03910/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03910/Lua/s753466684.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s753466684", "user_id": "u045238009"}, "prompt_components": {"gold_output": "1\n3\n", "input_to_evaluate": "local n=io.read(\"n\")\n\nlocal function upper_bound(x)\n local max=n+1\n local min=0\n while 1=n then\n max=mid\n else\n min=mid\n end\n end\n return max\nend\n\nlocal x=upper_bound(n)\nfor i=1,x do\n if i~=x*(x+1)//2-n then\n print(i)\n end\nend", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThe problem set at CODE FESTIVAL 20XX Finals consists of N problems.\n\nThe score allocated to the i-th (1≦i≦N) problem is i points.\n\nTakahashi, a contestant, is trying to score exactly N points. For that, he is deciding which problems to solve.\n\nAs problems with higher scores are harder, he wants to minimize the highest score of a problem among the ones solved by him.\n\nDetermine the set of problems that should be solved.\n\nConstraints\n\n1≦N≦10^7\n\nPartial Score\n\n200 points will be awarded for passing the test set satisfying 1≦N≦1000.\n\nAdditional 100 points will be awarded for passing the test set without additional constraints.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\n\nOutput\n\nAmong the sets of problems with the total score of N, find a set in which the highest score of a problem is minimum, then print the indices of the problems in the set in any order, one per line.\n\nIf there exists more than one such set, any of them will be accepted.\n\nSample Input 1\n\n4\n\nSample Output 1\n\n1\n3\n\nSolving only the 4-th problem will also result in the total score of 4 points, but solving the 1-st and 3-rd problems will lower the highest score of a solved problem.\n\nSample Input 2\n\n7\n\nSample Output 2\n\n1\n2\n4\n\nThe set \\{3,4\\} will also be accepted.\n\nSample Input 3\n\n1\n\nSample Output 3\n\n1", "sample_input": "4\n"}, "reference_outputs": ["1\n3\n"], "source_document_id": "p03910", "source_text": "Score : 300 points\n\nProblem Statement\n\nThe problem set at CODE FESTIVAL 20XX Finals consists of N problems.\n\nThe score allocated to the i-th (1≦i≦N) problem is i points.\n\nTakahashi, a contestant, is trying to score exactly N points. For that, he is deciding which problems to solve.\n\nAs problems with higher scores are harder, he wants to minimize the highest score of a problem among the ones solved by him.\n\nDetermine the set of problems that should be solved.\n\nConstraints\n\n1≦N≦10^7\n\nPartial Score\n\n200 points will be awarded for passing the test set satisfying 1≦N≦1000.\n\nAdditional 100 points will be awarded for passing the test set without additional constraints.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\n\nOutput\n\nAmong the sets of problems with the total score of N, find a set in which the highest score of a problem is minimum, then print the indices of the problems in the set in any order, one per line.\n\nIf there exists more than one such set, any of them will be accepted.\n\nSample Input 1\n\n4\n\nSample Output 1\n\n1\n3\n\nSolving only the 4-th problem will also result in the total score of 4 points, but solving the 1-st and 3-rd problems will lower the highest score of a solved problem.\n\nSample Input 2\n\n7\n\nSample Output 2\n\n1\n2\n4\n\nThe set \\{3,4\\} will also be accepted.\n\nSample Input 3\n\n1\n\nSample Output 3\n\n1", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 353, "cpu_time_ms": 13, "memory_kb": 760}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s354386956", "group_id": "codeNet:p03911", "input_text": "local function uf_initialize(n)\n local parent = {}\n for i = 1, n do parent[i] = i end\n return parent\nend\n\nlocal function uf_findroot(idx, parent)\n local idx_update = idx\n while parent[idx] ~= idx do\n idx = parent[idx]\n end\n while parent[idx_update] ~= idx do\n parent[idx_update], idx_update = idx, parent[idx_update]\n end\n return idx\nend\n\nlocal n, m = io.read(\"*n\", \"*n\")\nlocal lang = {}\nfor i = 1, m do\n lang[i] = {}\nend\nfor i = 1, n do\n local k = io.read(\"*n\")\n for j = 1, k do\n local l = io.read(\"*n\")\n table.insert(lang[l], i)\n end\nend\n\nlocal parent = uf_initialize(n)\nfor i = 1, m do\n if 0 < #lang[i] then\n local r = uf_findroot(lang[i][1], parent)\n for j = 2, #lang[i] do\n local tgt = lang[i][j]\n local tr = uf_findroot(tgt, parent)\n parent[tr], parent[tgt] = r, r\n end\n end\nend\nlocal cand = uf_findroot(1, parent)\nfor i = 2, n do\n local z = uf_findroot(i, parent)\n if z ~= cand then print(\"NO\") os.exit() end\nend\nprint(\"YES\")\n", "language": "Lua", "metadata": {"date": 1600814330, "filename_ext": "lua", "original_language": "Lua (Lua 5.3.5)", "problem_description_relpath": "problem_descriptions/p03911.html", "problem_id": "p03911", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03911/input.txt", "sample_output_relpath": "derived/input_output/data/p03911/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03911/Lua/s354386956.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s354386956", "user_id": "u120582723"}, "prompt_components": {"gold_output": "YES\n", "input_to_evaluate": "local function uf_initialize(n)\n local parent = {}\n for i = 1, n do parent[i] = i end\n return parent\nend\n\nlocal function uf_findroot(idx, parent)\n local idx_update = idx\n while parent[idx] ~= idx do\n idx = parent[idx]\n end\n while parent[idx_update] ~= idx do\n parent[idx_update], idx_update = idx, parent[idx_update]\n end\n return idx\nend\n\nlocal n, m = io.read(\"*n\", \"*n\")\nlocal lang = {}\nfor i = 1, m do\n lang[i] = {}\nend\nfor i = 1, n do\n local k = io.read(\"*n\")\n for j = 1, k do\n local l = io.read(\"*n\")\n table.insert(lang[l], i)\n end\nend\n\nlocal parent = uf_initialize(n)\nfor i = 1, m do\n if 0 < #lang[i] then\n local r = uf_findroot(lang[i][1], parent)\n for j = 2, #lang[i] do\n local tgt = lang[i][j]\n local tr = uf_findroot(tgt, parent)\n parent[tr], parent[tgt] = r, r\n end\n end\nend\nlocal cand = uf_findroot(1, parent)\nfor i = 2, n do\n local z = uf_findroot(i, parent)\n if z ~= cand then print(\"NO\") os.exit() end\nend\nprint(\"YES\")\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nOn a planet far, far away, M languages are spoken. They are conveniently numbered 1 through M.\n\nFor CODE FESTIVAL 20XX held on this planet, N participants gathered from all over the planet.\n\nThe i-th (1≦i≦N) participant can speak K_i languages numbered L_{i,1}, L_{i,2}, ..., L_{i,{}K_i}.\n\nTwo participants A and B can communicate with each other if and only if one of the following conditions is satisfied:\n\nThere exists a language that both A and B can speak.\n\nThere exists a participant X that both A and B can communicate with.\n\nDetermine whether all N participants can communicate with all other participants.\n\nConstraints\n\n2≦N≦10^5\n\n1≦M≦10^5\n\n1≦K_i≦M\n\n(The sum of all K_i)≦10^5\n\n1≦L_{i,j}≦M\n\nL_{i,1}, L_{i,2}, ..., L_{i,{}K_i} are pairwise distinct.\n\nPartial Score\n\n200 points will be awarded for passing the test set satisfying the following: N≦1000, M≦1000 and (The sum of all K_i)≦1000.\n\nAdditional 200 points will be awarded for passing the test set without additional constraints.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN M\nK_1 L_{1,1} L_{1,2} ... L_{1,{}K_1}\nK_2 L_{2,1} L_{2,2} ... L_{2,{}K_2}\n:\nK_N L_{N,1} L_{N,2} ... L_{N,{}K_N}\n\nOutput\n\nIf all N participants can communicate with all other participants, print YES. Otherwise, print NO.\n\nSample Input 1\n\n4 6\n3 1 2 3\n2 4 2\n2 4 6\n1 6\n\nSample Output 1\n\nYES\n\nAny two participants can communicate with each other, as follows:\n\nParticipants 1 and 2: both can speak language 2.\n\nParticipants 2 and 3: both can speak language 4.\n\nParticipants 1 and 3: both can communicate with participant 2.\n\nParticipants 3 and 4: both can speak language 6.\n\nParticipants 2 and 4: both can communicate with participant 3.\n\nParticipants 1 and 4: both can communicate with participant 2.\n\nNote that there can be languages spoken by no participant.\n\nSample Input 2\n\n4 4\n2 1 2\n2 1 2\n1 3\n2 4 3\n\nSample Output 2\n\nNO\n\nFor example, participants 1 and 3 cannot communicate with each other.", "sample_input": "4 6\n3 1 2 3\n2 4 2\n2 4 6\n1 6\n"}, "reference_outputs": ["YES\n"], "source_document_id": "p03911", "source_text": "Score : 400 points\n\nProblem Statement\n\nOn a planet far, far away, M languages are spoken. They are conveniently numbered 1 through M.\n\nFor CODE FESTIVAL 20XX held on this planet, N participants gathered from all over the planet.\n\nThe i-th (1≦i≦N) participant can speak K_i languages numbered L_{i,1}, L_{i,2}, ..., L_{i,{}K_i}.\n\nTwo participants A and B can communicate with each other if and only if one of the following conditions is satisfied:\n\nThere exists a language that both A and B can speak.\n\nThere exists a participant X that both A and B can communicate with.\n\nDetermine whether all N participants can communicate with all other participants.\n\nConstraints\n\n2≦N≦10^5\n\n1≦M≦10^5\n\n1≦K_i≦M\n\n(The sum of all K_i)≦10^5\n\n1≦L_{i,j}≦M\n\nL_{i,1}, L_{i,2}, ..., L_{i,{}K_i} are pairwise distinct.\n\nPartial Score\n\n200 points will be awarded for passing the test set satisfying the following: N≦1000, M≦1000 and (The sum of all K_i)≦1000.\n\nAdditional 200 points will be awarded for passing the test set without additional constraints.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN M\nK_1 L_{1,1} L_{1,2} ... L_{1,{}K_1}\nK_2 L_{2,1} L_{2,2} ... L_{2,{}K_2}\n:\nK_N L_{N,1} L_{N,2} ... L_{N,{}K_N}\n\nOutput\n\nIf all N participants can communicate with all other participants, print YES. Otherwise, print NO.\n\nSample Input 1\n\n4 6\n3 1 2 3\n2 4 2\n2 4 6\n1 6\n\nSample Output 1\n\nYES\n\nAny two participants can communicate with each other, as follows:\n\nParticipants 1 and 2: both can speak language 2.\n\nParticipants 2 and 3: both can speak language 4.\n\nParticipants 1 and 3: both can communicate with participant 2.\n\nParticipants 3 and 4: both can speak language 6.\n\nParticipants 2 and 4: both can communicate with participant 3.\n\nParticipants 1 and 4: both can communicate with participant 2.\n\nNote that there can be languages spoken by no participant.\n\nSample Input 2\n\n4 4\n2 1 2\n2 1 2\n1 3\n2 4 3\n\nSample Output 2\n\nNO\n\nFor example, participants 1 and 3 cannot communicate with each other.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 986, "cpu_time_ms": 105, "memory_kb": 14632}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s546125438", "group_id": "codeNet:p03912", "input_text": "local n, m = io.read(\"*n\", \"*n\")\nlocal t = {}\nlocal mod = {}\nlocal pr = {}\nfor i = 1, m do mod[i] = 0 pr[i] = 0 end\nfor i = 1, n do\n local a = io.read(\"*n\")\n local v = a % m\n if v == 0 then v = m end\n mod[v] = mod[v] + 1\n t[i] = a\nend\ntable.sort(t)\nlocal pos = 1\nwhile pos <= n - 1 do\n if t[pos] == t[pos + 1] then\n local v = t[pos] % m\n if v == 0 then v = m end\n pr[v] = pr[v] + 1\n pos = pos + 2\n else\n pos = pos + 1\n end\nend\nlocal mmi, mfl = math.min, math.floor\nlocal ret = 0\nlocal hm = mfl((m - 1) / 2)\nfor i = 1, hm do\n local v = mmi(mod[i], mod[m - i])\n ret = ret + v\n mod[i] = mod[i] - v\n mod[m - i] = mod[m - i] - v\nend\ndo\n local v = mfl(mod[m] / 2)\n ret = ret + v\n mod[m] = mod[m] - v * 2\nend\nif m % 2 == 0 then\n local z = mfl(m / 2)\n local v = mfl(mod[z] / 2)\n ret = ret + v\n mod[z] = mod[z] - v * 2\nend\nfor i = 1, m do\n local v = mmi(pr[i], mfl(mod[i] / 2))\n ret = ret + v\nend\nprint(ret)\n", "language": "Lua", "metadata": {"date": 1569714259, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p03912.html", "problem_id": "p03912", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03912/input.txt", "sample_output_relpath": "derived/input_output/data/p03912/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03912/Lua/s546125438.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s546125438", "user_id": "u120582723"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "local n, m = io.read(\"*n\", \"*n\")\nlocal t = {}\nlocal mod = {}\nlocal pr = {}\nfor i = 1, m do mod[i] = 0 pr[i] = 0 end\nfor i = 1, n do\n local a = io.read(\"*n\")\n local v = a % m\n if v == 0 then v = m end\n mod[v] = mod[v] + 1\n t[i] = a\nend\ntable.sort(t)\nlocal pos = 1\nwhile pos <= n - 1 do\n if t[pos] == t[pos + 1] then\n local v = t[pos] % m\n if v == 0 then v = m end\n pr[v] = pr[v] + 1\n pos = pos + 2\n else\n pos = pos + 1\n end\nend\nlocal mmi, mfl = math.min, math.floor\nlocal ret = 0\nlocal hm = mfl((m - 1) / 2)\nfor i = 1, hm do\n local v = mmi(mod[i], mod[m - i])\n ret = ret + v\n mod[i] = mod[i] - v\n mod[m - i] = mod[m - i] - v\nend\ndo\n local v = mfl(mod[m] / 2)\n ret = ret + v\n mod[m] = mod[m] - v * 2\nend\nif m % 2 == 0 then\n local z = mfl(m / 2)\n local v = mfl(mod[z] / 2)\n ret = ret + v\n mod[z] = mod[z] - v * 2\nend\nfor i = 1, m do\n local v = mmi(pr[i], mfl(mod[i] / 2))\n ret = ret + v\nend\nprint(ret)\n", "problem_context": "Score : 700 points\n\nProblem Statement\n\nTakahashi is playing with N cards.\n\nThe i-th card has an integer X_i on it.\n\nTakahashi is trying to create as many pairs of cards as possible satisfying one of the following conditions:\n\nThe integers on the two cards are the same.\n\nThe sum of the integers on the two cards is a multiple of M.\n\nFind the maximum number of pairs that can be created.\n\nNote that a card cannot be used in more than one pair.\n\nConstraints\n\n2≦N≦10^5\n\n1≦M≦10^5\n\n1≦X_i≦10^5\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN M\nX_1 X_2 ... X_N\n\nOutput\n\nPrint the maximum number of pairs that can be created.\n\nSample Input 1\n\n7 5\n3 1 4 1 5 9 2\n\nSample Output 1\n\n3\n\nThree pairs (3,2), (1,4) and (1,9) can be created.\n\nIt is possible to create pairs (3,2) and (1,1), but the number of pairs is not maximized with this.\n\nSample Input 2\n\n15 10\n1 5 6 10 11 11 11 20 21 25 25 26 99 99 99\n\nSample Output 2\n\n6", "sample_input": "7 5\n3 1 4 1 5 9 2\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03912", "source_text": "Score : 700 points\n\nProblem Statement\n\nTakahashi is playing with N cards.\n\nThe i-th card has an integer X_i on it.\n\nTakahashi is trying to create as many pairs of cards as possible satisfying one of the following conditions:\n\nThe integers on the two cards are the same.\n\nThe sum of the integers on the two cards is a multiple of M.\n\nFind the maximum number of pairs that can be created.\n\nNote that a card cannot be used in more than one pair.\n\nConstraints\n\n2≦N≦10^5\n\n1≦M≦10^5\n\n1≦X_i≦10^5\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN M\nX_1 X_2 ... X_N\n\nOutput\n\nPrint the maximum number of pairs that can be created.\n\nSample Input 1\n\n7 5\n3 1 4 1 5 9 2\n\nSample Output 1\n\n3\n\nThree pairs (3,2), (1,4) and (1,9) can be created.\n\nIt is possible to create pairs (3,2) and (1,1), but the number of pairs is not maximized with this.\n\nSample Input 2\n\n15 10\n1 5 6 10 11 11 11 20 21 25 25 26 99 99 99\n\nSample Output 2\n\n6", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 936, "cpu_time_ms": 76, "memory_kb": 3584}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s722930163", "group_id": "codeNet:p03932", "input_text": "local mmi, mma = math.min, math.max\nlocal MinCostFlow = {}\n\nMinCostFlow.initialize = function(self, n, spos, tpos, inf)\n self.n = n\n self.spos, self.tpos = spos, tpos\n self.inf = inf\n -- edge_dst[src][i] := dst\n self.edge_dst = {}\n -- edge_cost[src][i] := cost from src to edge_dst[src][i]\n self.edge_cost = {}\n -- edge_cap[src][i] := capacity from src to edge_dst[src][i]\n self.edge_cap = {}\n -- initial capacity. corresponding to edge_cap\n self.edge_initialcap = {}\n -- edge_dst_invedge_idx[src][i] := \"j\" where edge_dst[dst][j] == src\n -- in this case, edge_dst_invedge_idx[dst][j] should be \"i\".\n self.edge_dst_invedge_idx = {}\n -- len[v] := length from spos. len[spos] := 0\n self.len = {}\n -- sub_graph_flag[v] := whether to contains the vertex v in the sub-graph or not\n self.sub_graph_flag = {}\n -- sub_graph_v[i] := list of vertexes that are contained in the sub-graph. from tpos to spos.\n self.sub_graph_v = {}\n -- sub_graph_edgeidx[i] := edge index from sub_graph_v[i + 1] to sub_graph_v[i]\n self.sub_graph_edgeidx = {}\n -- sub_graph_size := the size of sub_graph_v.\n -- may not equal to #sub_graph_v (because not cleared).\n self.sub_graph_size = 0\n for i = 1, n do\n self.edge_dst[i] = {}\n self.edge_cost[i] = {}\n self.edge_cap[i] = {}\n self.edge_initialcap[i] = {}\n self.edge_dst_invedge_idx[i] = {}\n self.len[i] = 0\n self.sub_graph_flag[i] = false\n end\nend\n\nMinCostFlow.addEdge = function(self, src, dst, cost, cap)\n table.insert(self.edge_dst[src], dst)\n table.insert(self.edge_cost[src], cost)\n table.insert(self.edge_cap[src], cap)\n table.insert(self.edge_initialcap[src], cap)\n table.insert(self.edge_dst_invedge_idx[src], 1 + #self.edge_dst[dst])\n table.insert(self.edge_dst[dst], src)\n table.insert(self.edge_cost[dst], -cost)\n table.insert(self.edge_cap[dst], 0)--invcap\n table.insert(self.edge_initialcap[dst], 0)--invcap\n table.insert(self.edge_dst_invedge_idx[dst], #self.edge_dst[src])\nend\nMinCostFlow.invwalk_recursive = function(self, invsrc)\n if invsrc == self.spos then return true end\n local edge_dst, edge_cap, edge_cost = self.edge_dst, self.edge_cap, self.edge_cost\n local edge_dst_invedge_idx = self.edge_dst_invedge_idx\n local len = self.len\n local sub_graph_flag = self.sub_graph_flag\n local sub_graph_v = self.sub_graph_v\n local sub_graph_edgeidx = self.sub_graph_edgeidx\n for i = 1, #edge_dst[invsrc] do\n local invdst = edge_dst[invsrc][i]\n local j = edge_dst_invedge_idx[invsrc][i]\n if 0 < edge_cap[invdst][j]\n and len[invdst] + edge_cost[invdst][j] == len[invsrc]\n and not sub_graph_flag[invdst] then\n self.sub_graph_size = self.sub_graph_size + 1\n sub_graph_v[self.sub_graph_size] = invdst\n sub_graph_edgeidx[self.sub_graph_size - 1] = j\n sub_graph_flag[invdst] = true\n if self:invwalk_recursive(invdst) then\n return true\n else\n self.sub_graph_flag[invdst] = false\n self.sub_graph_size = self.sub_graph_size - 1\n end\n end\n end\n return false\nend\n\nMinCostFlow.makeSubGraph = function(self)\n local inf = self.inf\n local len = self.len\n local n = self.n\n local edge_dst, edge_cap = self.edge_dst, self.edge_cap\n local edge_dst_invedge_idx = self.edge_dst_invedge_idx\n local edge_cost = self.edge_cost\n local sub_graph_v = self.sub_graph_v\n local sub_graph_edgeidx = self.sub_graph_edgeidx\n local sub_graph_flag = self.sub_graph_flag\n for i = 1, self.n do\n len[i] = inf\n sub_graph_flag[i] = false\n end\n -- Bellman-Ford\n local updated1, updated2 = {}, {}\n for i = 1, n do\n updated1[i] = true\n end\n len[self.spos] = 0\n for irp = 1, n do\n local updsrc = irp % 2 == 1 and updated1 or updated2\n local upddst = irp % 2 == 1 and updated2 or updated1\n for i = 1, n do\n upddst[i] = false\n end\n for src = 1, n do\n if updsrc[src] then\n local eddst, edcap, edcost = edge_dst[src], edge_cap[src], edge_cost[src]\n for i = 1, #eddst do\n if 0 < edcap[i] then\n local dst = eddst[i]\n local cost = edcost[i]\n if len[src] + cost < len[dst] then\n len[dst] = len[src] + cost\n upddst[dst] = true\n end\n end\n end\n end\n end\n end\n self.sub_graph_size = 0\n if inf <= len[self.tpos] then\n return 0\n end\n -- restore route (from tpos to spos)\n self.sub_graph_size = 1\n sub_graph_v[1] = self.tpos\n self:invwalk_recursive(self.tpos)\n local min_capacity = inf\n for i = self.sub_graph_size, 2, -1 do\n local src = sub_graph_v[i]\n local j = sub_graph_edgeidx[i - 1]\n min_capacity = mmi(min_capacity, edge_cap[src][j])\n end\n return min_capacity\nend\n\nMinCostFlow.flow = function(self, capacity)\n local edge_dst, edge_cap = self.edge_dst, self.edge_cap\n local edge_dst_invedge_idx = self.edge_dst_invedge_idx\n local sub_graph_v = self.sub_graph_v\n local sub_graph_edgeidx = self.sub_graph_edgeidx\n for i = self.sub_graph_size, 2, -1 do\n local src = sub_graph_v[i]\n local dst = sub_graph_v[i - 1]\n local j = sub_graph_edgeidx[i - 1]\n edge_cap[src][j] = edge_cap[src][j] - capacity\n local k = edge_dst_invedge_idx[src][j]\n edge_cap[dst][k] = edge_cap[dst][k] + capacity\n end\nend\n\nMinCostFlow.getMinCostFlow = function(self, amount, invalid)\n local ret = 0\n local cap = self:makeSubGraph()\n while 0 < cap do\n cap = mmi(amount, cap)\n ret = ret + self.len[self.tpos] * cap\n self:flow(cap)\n amount = amount - cap\n if 0 < amount then\n cap = self:makeSubGraph()\n else\n break\n end\n end\n if 0 < amount then return invalid end\n return ret\nend\n\nlocal h, w = io.read(\"*n\", \"*n\")\nlocal s = 2 * h * w + 1\nlocal t = 2 * h * w + 2\nMinCostFlow:initialize(t, s, t, 1000000007 * 100)\nMinCostFlow:addEdge(s, 1, 0, 2)\nMinCostFlow:addEdge(2 * h * w, t, 0, 2)\nfor i = 1, h do\n for j = 1, w - 1 do\n local idx = (i - 1) * w + j\n MinCostFlow:addEdge(idx + h * w, idx + 1, 0, 2)\n end\nend\nfor i = 1, h - 1 do\n for j = 1, w do\n local idx = (i - 1) * w + j\n MinCostFlow:addEdge(idx + h * w, idx + w, 0, 2)\n end\nend\nfor i = 1, h do\n for j = 1, w do\n local idx = (i - 1) * w + j\n local a = io.read(\"*n\")\n MinCostFlow:addEdge(idx, idx + h * w, 0, 1)\n MinCostFlow:addEdge(idx, idx + h * w, -a, 1)\n end\nend\nprint(math.abs(MinCostFlow:getMinCostFlow(2)))\n", "language": "Lua", "metadata": {"date": 1599968057, "filename_ext": "lua", "original_language": "Lua (LuaJIT 2.1.0)", "problem_description_relpath": "problem_descriptions/p03932.html", "problem_id": "p03932", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03932/input.txt", "sample_output_relpath": "derived/input_output/data/p03932/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03932/Lua/s722930163.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s722930163", "user_id": "u120582723"}, "prompt_components": {"gold_output": "21\n", "input_to_evaluate": "local mmi, mma = math.min, math.max\nlocal MinCostFlow = {}\n\nMinCostFlow.initialize = function(self, n, spos, tpos, inf)\n self.n = n\n self.spos, self.tpos = spos, tpos\n self.inf = inf\n -- edge_dst[src][i] := dst\n self.edge_dst = {}\n -- edge_cost[src][i] := cost from src to edge_dst[src][i]\n self.edge_cost = {}\n -- edge_cap[src][i] := capacity from src to edge_dst[src][i]\n self.edge_cap = {}\n -- initial capacity. corresponding to edge_cap\n self.edge_initialcap = {}\n -- edge_dst_invedge_idx[src][i] := \"j\" where edge_dst[dst][j] == src\n -- in this case, edge_dst_invedge_idx[dst][j] should be \"i\".\n self.edge_dst_invedge_idx = {}\n -- len[v] := length from spos. len[spos] := 0\n self.len = {}\n -- sub_graph_flag[v] := whether to contains the vertex v in the sub-graph or not\n self.sub_graph_flag = {}\n -- sub_graph_v[i] := list of vertexes that are contained in the sub-graph. from tpos to spos.\n self.sub_graph_v = {}\n -- sub_graph_edgeidx[i] := edge index from sub_graph_v[i + 1] to sub_graph_v[i]\n self.sub_graph_edgeidx = {}\n -- sub_graph_size := the size of sub_graph_v.\n -- may not equal to #sub_graph_v (because not cleared).\n self.sub_graph_size = 0\n for i = 1, n do\n self.edge_dst[i] = {}\n self.edge_cost[i] = {}\n self.edge_cap[i] = {}\n self.edge_initialcap[i] = {}\n self.edge_dst_invedge_idx[i] = {}\n self.len[i] = 0\n self.sub_graph_flag[i] = false\n end\nend\n\nMinCostFlow.addEdge = function(self, src, dst, cost, cap)\n table.insert(self.edge_dst[src], dst)\n table.insert(self.edge_cost[src], cost)\n table.insert(self.edge_cap[src], cap)\n table.insert(self.edge_initialcap[src], cap)\n table.insert(self.edge_dst_invedge_idx[src], 1 + #self.edge_dst[dst])\n table.insert(self.edge_dst[dst], src)\n table.insert(self.edge_cost[dst], -cost)\n table.insert(self.edge_cap[dst], 0)--invcap\n table.insert(self.edge_initialcap[dst], 0)--invcap\n table.insert(self.edge_dst_invedge_idx[dst], #self.edge_dst[src])\nend\nMinCostFlow.invwalk_recursive = function(self, invsrc)\n if invsrc == self.spos then return true end\n local edge_dst, edge_cap, edge_cost = self.edge_dst, self.edge_cap, self.edge_cost\n local edge_dst_invedge_idx = self.edge_dst_invedge_idx\n local len = self.len\n local sub_graph_flag = self.sub_graph_flag\n local sub_graph_v = self.sub_graph_v\n local sub_graph_edgeidx = self.sub_graph_edgeidx\n for i = 1, #edge_dst[invsrc] do\n local invdst = edge_dst[invsrc][i]\n local j = edge_dst_invedge_idx[invsrc][i]\n if 0 < edge_cap[invdst][j]\n and len[invdst] + edge_cost[invdst][j] == len[invsrc]\n and not sub_graph_flag[invdst] then\n self.sub_graph_size = self.sub_graph_size + 1\n sub_graph_v[self.sub_graph_size] = invdst\n sub_graph_edgeidx[self.sub_graph_size - 1] = j\n sub_graph_flag[invdst] = true\n if self:invwalk_recursive(invdst) then\n return true\n else\n self.sub_graph_flag[invdst] = false\n self.sub_graph_size = self.sub_graph_size - 1\n end\n end\n end\n return false\nend\n\nMinCostFlow.makeSubGraph = function(self)\n local inf = self.inf\n local len = self.len\n local n = self.n\n local edge_dst, edge_cap = self.edge_dst, self.edge_cap\n local edge_dst_invedge_idx = self.edge_dst_invedge_idx\n local edge_cost = self.edge_cost\n local sub_graph_v = self.sub_graph_v\n local sub_graph_edgeidx = self.sub_graph_edgeidx\n local sub_graph_flag = self.sub_graph_flag\n for i = 1, self.n do\n len[i] = inf\n sub_graph_flag[i] = false\n end\n -- Bellman-Ford\n local updated1, updated2 = {}, {}\n for i = 1, n do\n updated1[i] = true\n end\n len[self.spos] = 0\n for irp = 1, n do\n local updsrc = irp % 2 == 1 and updated1 or updated2\n local upddst = irp % 2 == 1 and updated2 or updated1\n for i = 1, n do\n upddst[i] = false\n end\n for src = 1, n do\n if updsrc[src] then\n local eddst, edcap, edcost = edge_dst[src], edge_cap[src], edge_cost[src]\n for i = 1, #eddst do\n if 0 < edcap[i] then\n local dst = eddst[i]\n local cost = edcost[i]\n if len[src] + cost < len[dst] then\n len[dst] = len[src] + cost\n upddst[dst] = true\n end\n end\n end\n end\n end\n end\n self.sub_graph_size = 0\n if inf <= len[self.tpos] then\n return 0\n end\n -- restore route (from tpos to spos)\n self.sub_graph_size = 1\n sub_graph_v[1] = self.tpos\n self:invwalk_recursive(self.tpos)\n local min_capacity = inf\n for i = self.sub_graph_size, 2, -1 do\n local src = sub_graph_v[i]\n local j = sub_graph_edgeidx[i - 1]\n min_capacity = mmi(min_capacity, edge_cap[src][j])\n end\n return min_capacity\nend\n\nMinCostFlow.flow = function(self, capacity)\n local edge_dst, edge_cap = self.edge_dst, self.edge_cap\n local edge_dst_invedge_idx = self.edge_dst_invedge_idx\n local sub_graph_v = self.sub_graph_v\n local sub_graph_edgeidx = self.sub_graph_edgeidx\n for i = self.sub_graph_size, 2, -1 do\n local src = sub_graph_v[i]\n local dst = sub_graph_v[i - 1]\n local j = sub_graph_edgeidx[i - 1]\n edge_cap[src][j] = edge_cap[src][j] - capacity\n local k = edge_dst_invedge_idx[src][j]\n edge_cap[dst][k] = edge_cap[dst][k] + capacity\n end\nend\n\nMinCostFlow.getMinCostFlow = function(self, amount, invalid)\n local ret = 0\n local cap = self:makeSubGraph()\n while 0 < cap do\n cap = mmi(amount, cap)\n ret = ret + self.len[self.tpos] * cap\n self:flow(cap)\n amount = amount - cap\n if 0 < amount then\n cap = self:makeSubGraph()\n else\n break\n end\n end\n if 0 < amount then return invalid end\n return ret\nend\n\nlocal h, w = io.read(\"*n\", \"*n\")\nlocal s = 2 * h * w + 1\nlocal t = 2 * h * w + 2\nMinCostFlow:initialize(t, s, t, 1000000007 * 100)\nMinCostFlow:addEdge(s, 1, 0, 2)\nMinCostFlow:addEdge(2 * h * w, t, 0, 2)\nfor i = 1, h do\n for j = 1, w - 1 do\n local idx = (i - 1) * w + j\n MinCostFlow:addEdge(idx + h * w, idx + 1, 0, 2)\n end\nend\nfor i = 1, h - 1 do\n for j = 1, w do\n local idx = (i - 1) * w + j\n MinCostFlow:addEdge(idx + h * w, idx + w, 0, 2)\n end\nend\nfor i = 1, h do\n for j = 1, w do\n local idx = (i - 1) * w + j\n local a = io.read(\"*n\")\n MinCostFlow:addEdge(idx, idx + h * w, 0, 1)\n MinCostFlow:addEdge(idx, idx + h * w, -a, 1)\n end\nend\nprint(math.abs(MinCostFlow:getMinCostFlow(2)))\n", "problem_context": "Max Score: $600$ Points\n\nProblem Statement\n\nSigma and his brother Sugim are in the $H \\times W$ grid. They wants to buy some souvenirs.\n\nTheir start position is upper-left cell, and the goal position is lower-right cell.\n\nSome cells has a souvenir shop. At $i$-th row and $j$-th column, there is $a_{i, j}$ souvenirs.\n\nIn one move, they can go left, right, down, and up cell.\n\nBut they have little time, so they can move only $H+W-2$ times.\n\nThey wanted to buy souvenirs as many as possible, but they had no computer, so they couldn't get the maximal numbers of souvenirs.\n\nWrite a program and calculate the maximum souvenirs they can get, and help them.\n\nInput\n\nThe input is given from standard input in the following format.\n\n$H \\ W$\n$a_{1, 1} \\ a_{1, 2} \\ \\cdots \\ a_{1, W}$\n$a_{2, 1} \\ a_{2, 2} \\ \\cdots \\ a_{2, W}$\n$\\vdots \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\vdots \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\vdots$\n$a_{H, 1} \\ a_{H, 2} \\ \\cdots \\ a_{H, W}$\n\nOutput\n\nPrint the maximum number of souvenirs they can get.\n\nConstraints\n\n$1 \\le H, W \\le 200$\n\n$0 \\le a_{i, j} \\le 10^5$\n\nSubtasks\n\nSubtask 1 [ 50 points ]\n\nThe testcase in the subtask satisfies $1 \\le H \\le 2$.\n\nSubtask 2 [ 80 points ]\n\nThe testcase in the subtask satisfies $1 \\le H \\le 3$.\n\nSubtask 3 [ 120 points ]\n\nThe testcase in the subtask satisfies $1 \\le H, W \\le 7$.\n\nSubtask 4 [ 150 points ]\n\nThe testcase in the subtask satisfies $1 \\le H, W \\le 30$.\n\nSubtask 5 [ 200 points ]\n\nThere are no additional constraints.\n\nSample Input 1\n\n3 3\n1 0 5\n2 2 3\n4 2 4\n\nSample Output 1\n\n21\n\nThe cell at $i$-th row and $j$-th column is denoted $(i, j)$.\n\nIn this case, one of the optimal solution is this:\n\nSigma moves $(1, 1) -> (1, 2) -> (1, 3) -> (2, 3) -> (3, 3)$.\n\nSugim moves $(1, 1) -> (2, 1) -> (3, 1) -> (3, 2) -> (3, 3)$.\n\nThen, they can get $21$ souvernirs.\n\nSample Input 2\n\n6 6\n1 2 3 4 5 6\n8 6 9 1 2 0\n3 1 4 1 5 9\n2 6 5 3 5 8\n1 4 1 4 2 1\n2 7 1 8 2 8\n\nSample Output 2\n\n97\n\nWriter : square1001", "sample_input": "3 3\n1 0 5\n2 2 3\n4 2 4\n"}, "reference_outputs": ["21\n"], "source_document_id": "p03932", "source_text": "Max Score: $600$ Points\n\nProblem Statement\n\nSigma and his brother Sugim are in the $H \\times W$ grid. They wants to buy some souvenirs.\n\nTheir start position is upper-left cell, and the goal position is lower-right cell.\n\nSome cells has a souvenir shop. At $i$-th row and $j$-th column, there is $a_{i, j}$ souvenirs.\n\nIn one move, they can go left, right, down, and up cell.\n\nBut they have little time, so they can move only $H+W-2$ times.\n\nThey wanted to buy souvenirs as many as possible, but they had no computer, so they couldn't get the maximal numbers of souvenirs.\n\nWrite a program and calculate the maximum souvenirs they can get, and help them.\n\nInput\n\nThe input is given from standard input in the following format.\n\n$H \\ W$\n$a_{1, 1} \\ a_{1, 2} \\ \\cdots \\ a_{1, W}$\n$a_{2, 1} \\ a_{2, 2} \\ \\cdots \\ a_{2, W}$\n$\\vdots \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\vdots \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\vdots$\n$a_{H, 1} \\ a_{H, 2} \\ \\cdots \\ a_{H, W}$\n\nOutput\n\nPrint the maximum number of souvenirs they can get.\n\nConstraints\n\n$1 \\le H, W \\le 200$\n\n$0 \\le a_{i, j} \\le 10^5$\n\nSubtasks\n\nSubtask 1 [ 50 points ]\n\nThe testcase in the subtask satisfies $1 \\le H \\le 2$.\n\nSubtask 2 [ 80 points ]\n\nThe testcase in the subtask satisfies $1 \\le H \\le 3$.\n\nSubtask 3 [ 120 points ]\n\nThe testcase in the subtask satisfies $1 \\le H, W \\le 7$.\n\nSubtask 4 [ 150 points ]\n\nThe testcase in the subtask satisfies $1 \\le H, W \\le 30$.\n\nSubtask 5 [ 200 points ]\n\nThere are no additional constraints.\n\nSample Input 1\n\n3 3\n1 0 5\n2 2 3\n4 2 4\n\nSample Output 1\n\n21\n\nThe cell at $i$-th row and $j$-th column is denoted $(i, j)$.\n\nIn this case, one of the optimal solution is this:\n\nSigma moves $(1, 1) -> (1, 2) -> (1, 3) -> (2, 3) -> (3, 3)$.\n\nSugim moves $(1, 1) -> (2, 1) -> (3, 1) -> (3, 2) -> (3, 3)$.\n\nThen, they can get $21$ souvernirs.\n\nSample Input 2\n\n6 6\n1 2 3 4 5 6\n8 6 9 1 2 0\n3 1 4 1 5 9\n2 6 5 3 5 8\n1 4 1 4 2 1\n2 7 1 8 2 8\n\nSample Output 2\n\n97\n\nWriter : square1001", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 6337, "cpu_time_ms": 2207, "memory_kb": 49980}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s345347493", "group_id": "codeNet:p03937", "input_text": "local h,w=io.read(\"*n\",\"*n\",\"*l\")\nlocal counter=0\nfor i=1,h do\n local a=#io.read():gsub(\"%.\",\"\")\n counter=counter+a\nend\nprint(counter==h+w-1 and \"Possible\" or \"Impossible\")", "language": "Lua", "metadata": {"date": 1590325797, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p03937.html", "problem_id": "p03937", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03937/input.txt", "sample_output_relpath": "derived/input_output/data/p03937/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03937/Lua/s345347493.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s345347493", "user_id": "u045238009"}, "prompt_components": {"gold_output": "Possible\n", "input_to_evaluate": "local h,w=io.read(\"*n\",\"*n\",\"*l\")\nlocal counter=0\nfor i=1,h do\n local a=#io.read():gsub(\"%.\",\"\")\n counter=counter+a\nend\nprint(counter==h+w-1 and \"Possible\" or \"Impossible\")", "problem_context": "Score : 200 points\n\nProblem Statement\n\n#nck {\nwidth: 30px;\nheight: auto;\n}\n\nWe have a grid of H rows and W columns. Initially, there is a stone in the top left cell. Shik is trying to move the stone to the bottom right cell. In each step, he can move the stone one cell to its left, up, right, or down (if such cell exists). It is possible that the stone visits a cell multiple times (including the bottom right and the top left cell).\n\nYou are given a matrix of characters a_{ij} (1 \\leq i \\leq H, 1 \\leq j \\leq W). After Shik completes all moving actions, a_{ij} is # if the stone had ever located at the i-th row and the j-th column during the process of moving. Otherwise, a_{ij} is .. Please determine whether it is possible that Shik only uses right and down moves in all steps.\n\nConstraints\n\n2 \\leq H, W \\leq 8\n\na_{i,j} is either # or ..\n\nThere exists a valid sequence of moves for Shik to generate the map a.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nH W\na_{11}a_{12}...a_{1W}\n:\na_{H1}a_{H2}...a_{HW}\n\nOutput\n\nIf it is possible that Shik only uses right and down moves, print Possible. Otherwise, print Impossible.\n\nSample Input 1\n\n4 5\n##...\n.##..\n..##.\n...##\n\nSample Output 1\n\nPossible\n\nThe matrix can be generated by a 7-move sequence: right, down, right, down, right, down, and right.\n\nSample Input 2\n\n5 3\n###\n..#\n###\n#..\n###\n\nSample Output 2\n\nImpossible\n\nSample Input 3\n\n4 5\n##...\n.###.\n.###.\n...##\n\nSample Output 3\n\nImpossible", "sample_input": "4 5\n##...\n.##..\n..##.\n...##\n"}, "reference_outputs": ["Possible\n"], "source_document_id": "p03937", "source_text": "Score : 200 points\n\nProblem Statement\n\n#nck {\nwidth: 30px;\nheight: auto;\n}\n\nWe have a grid of H rows and W columns. Initially, there is a stone in the top left cell. Shik is trying to move the stone to the bottom right cell. In each step, he can move the stone one cell to its left, up, right, or down (if such cell exists). It is possible that the stone visits a cell multiple times (including the bottom right and the top left cell).\n\nYou are given a matrix of characters a_{ij} (1 \\leq i \\leq H, 1 \\leq j \\leq W). After Shik completes all moving actions, a_{ij} is # if the stone had ever located at the i-th row and the j-th column during the process of moving. Otherwise, a_{ij} is .. Please determine whether it is possible that Shik only uses right and down moves in all steps.\n\nConstraints\n\n2 \\leq H, W \\leq 8\n\na_{i,j} is either # or ..\n\nThere exists a valid sequence of moves for Shik to generate the map a.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nH W\na_{11}a_{12}...a_{1W}\n:\na_{H1}a_{H2}...a_{HW}\n\nOutput\n\nIf it is possible that Shik only uses right and down moves, print Possible. Otherwise, print Impossible.\n\nSample Input 1\n\n4 5\n##...\n.##..\n..##.\n...##\n\nSample Output 1\n\nPossible\n\nThe matrix can be generated by a 7-move sequence: right, down, right, down, right, down, and right.\n\nSample Input 2\n\n5 3\n###\n..#\n###\n#..\n###\n\nSample Output 2\n\nImpossible\n\nSample Input 3\n\n4 5\n##...\n.###.\n.###.\n...##\n\nSample Output 3\n\nImpossible", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 178, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s254356745", "group_id": "codeNet:p03937", "input_text": "local h,w=io.read(\"*n\",\"*n\",\"*l\")\nlocal counter=0\nfor i=1,h do\n local a=#io.read():gsub(\"%.\",\"\")\n counter=counter+a\nend\nprint(counter==h+w-1 and \"Possible\" or \"Impossible\")", "language": "Lua", "metadata": {"date": 1590325731, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03937.html", "problem_id": "p03937", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03937/input.txt", "sample_output_relpath": "derived/input_output/data/p03937/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03937/Lua/s254356745.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s254356745", "user_id": "u045238009"}, "prompt_components": {"gold_output": "Possible\n", "input_to_evaluate": "local h,w=io.read(\"*n\",\"*n\",\"*l\")\nlocal counter=0\nfor i=1,h do\n local a=#io.read():gsub(\"%.\",\"\")\n counter=counter+a\nend\nprint(counter==h+w-1 and \"Possible\" or \"Impossible\")", "problem_context": "Score : 200 points\n\nProblem Statement\n\n#nck {\nwidth: 30px;\nheight: auto;\n}\n\nWe have a grid of H rows and W columns. Initially, there is a stone in the top left cell. Shik is trying to move the stone to the bottom right cell. In each step, he can move the stone one cell to its left, up, right, or down (if such cell exists). It is possible that the stone visits a cell multiple times (including the bottom right and the top left cell).\n\nYou are given a matrix of characters a_{ij} (1 \\leq i \\leq H, 1 \\leq j \\leq W). After Shik completes all moving actions, a_{ij} is # if the stone had ever located at the i-th row and the j-th column during the process of moving. Otherwise, a_{ij} is .. Please determine whether it is possible that Shik only uses right and down moves in all steps.\n\nConstraints\n\n2 \\leq H, W \\leq 8\n\na_{i,j} is either # or ..\n\nThere exists a valid sequence of moves for Shik to generate the map a.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nH W\na_{11}a_{12}...a_{1W}\n:\na_{H1}a_{H2}...a_{HW}\n\nOutput\n\nIf it is possible that Shik only uses right and down moves, print Possible. Otherwise, print Impossible.\n\nSample Input 1\n\n4 5\n##...\n.##..\n..##.\n...##\n\nSample Output 1\n\nPossible\n\nThe matrix can be generated by a 7-move sequence: right, down, right, down, right, down, and right.\n\nSample Input 2\n\n5 3\n###\n..#\n###\n#..\n###\n\nSample Output 2\n\nImpossible\n\nSample Input 3\n\n4 5\n##...\n.###.\n.###.\n...##\n\nSample Output 3\n\nImpossible", "sample_input": "4 5\n##...\n.##..\n..##.\n...##\n"}, "reference_outputs": ["Possible\n"], "source_document_id": "p03937", "source_text": "Score : 200 points\n\nProblem Statement\n\n#nck {\nwidth: 30px;\nheight: auto;\n}\n\nWe have a grid of H rows and W columns. Initially, there is a stone in the top left cell. Shik is trying to move the stone to the bottom right cell. In each step, he can move the stone one cell to its left, up, right, or down (if such cell exists). It is possible that the stone visits a cell multiple times (including the bottom right and the top left cell).\n\nYou are given a matrix of characters a_{ij} (1 \\leq i \\leq H, 1 \\leq j \\leq W). After Shik completes all moving actions, a_{ij} is # if the stone had ever located at the i-th row and the j-th column during the process of moving. Otherwise, a_{ij} is .. Please determine whether it is possible that Shik only uses right and down moves in all steps.\n\nConstraints\n\n2 \\leq H, W \\leq 8\n\na_{i,j} is either # or ..\n\nThere exists a valid sequence of moves for Shik to generate the map a.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nH W\na_{11}a_{12}...a_{1W}\n:\na_{H1}a_{H2}...a_{HW}\n\nOutput\n\nIf it is possible that Shik only uses right and down moves, print Possible. Otherwise, print Impossible.\n\nSample Input 1\n\n4 5\n##...\n.##..\n..##.\n...##\n\nSample Output 1\n\nPossible\n\nThe matrix can be generated by a 7-move sequence: right, down, right, down, right, down, and right.\n\nSample Input 2\n\n5 3\n###\n..#\n###\n#..\n###\n\nSample Output 2\n\nImpossible\n\nSample Input 3\n\n4 5\n##...\n.###.\n.###.\n...##\n\nSample Output 3\n\nImpossible", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 178, "cpu_time_ms": 3, "memory_kb": 376}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s579041687", "group_id": "codeNet:p03938", "input_text": "local n = io.read(\"*n\")\nlocal a, b = {}, {}\nfor i = 1, n do\n a[i] = 30000 * i\n b[i] = 30000 * (n + 1 - i)\nend\nfor i = 1, n do\n local p = io.read(\"*n\")\n a[p] = a[p] + i\nend\nprint(table.concat(a, \" \"))\nprint(table.concat(b, \" \"))\n", "language": "Lua", "metadata": {"date": 1564109628, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03938.html", "problem_id": "p03938", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03938/input.txt", "sample_output_relpath": "derived/input_output/data/p03938/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03938/Lua/s579041687.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s579041687", "user_id": "u120582723"}, "prompt_components": {"gold_output": "1 4\n5 4\n", "input_to_evaluate": "local n = io.read(\"*n\")\nlocal a, b = {}, {}\nfor i = 1, n do\n a[i] = 30000 * i\n b[i] = 30000 * (n + 1 - i)\nend\nfor i = 1, n do\n local p = io.read(\"*n\")\n a[p] = a[p] + i\nend\nprint(table.concat(a, \" \"))\nprint(table.concat(b, \" \"))\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\n#nck {\nwidth: 30px;\nheight: auto;\n}\n\nYou are given a permutation p of the set {1, 2, ..., N}. Please construct two sequences of positive integers a_1, a_2, ..., a_N and b_1, b_2, ..., b_N satisfying the following conditions:\n\n1 \\leq a_i, b_i \\leq 10^9 for all i\n\na_1 < a_2 < ... < a_N\n\nb_1 > b_2 > ... > b_N\n\na_{p_1}+b_{p_1} < a_{p_2}+b_{p_2} < ... < a_{p_N}+b_{p_N}\n\nConstraints\n\n2 \\leq N \\leq 20,000\n\np is a permutation of the set {1, 2, ..., N}\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\np_1 p_2 ... p_N\n\nOutput\n\nThe output consists of two lines. The first line contains a_1, a_2, ..., a_N seperated by a space. The second line contains b_1, b_2, ..., b_N seperated by a space.\n\nIt can be shown that there always exists a solution for any input satisfying the constraints.\n\nSample Input 1\n\n2\n1 2\n\nSample Output 1\n\n1 4\n5 4\n\na_1 + b_1 = 6 and a_2 + b_2 = 8. So this output satisfies all conditions.\n\nSample Input 2\n\n3\n3 2 1\n\nSample Output 2\n\n1 2 3\n5 3 1\n\nSample Input 3\n\n3\n2 3 1\n\nSample Output 3\n\n5 10 100\n100 10 1", "sample_input": "2\n1 2\n"}, "reference_outputs": ["1 4\n5 4\n"], "source_document_id": "p03938", "source_text": "Score : 400 points\n\nProblem Statement\n\n#nck {\nwidth: 30px;\nheight: auto;\n}\n\nYou are given a permutation p of the set {1, 2, ..., N}. Please construct two sequences of positive integers a_1, a_2, ..., a_N and b_1, b_2, ..., b_N satisfying the following conditions:\n\n1 \\leq a_i, b_i \\leq 10^9 for all i\n\na_1 < a_2 < ... < a_N\n\nb_1 > b_2 > ... > b_N\n\na_{p_1}+b_{p_1} < a_{p_2}+b_{p_2} < ... < a_{p_N}+b_{p_N}\n\nConstraints\n\n2 \\leq N \\leq 20,000\n\np is a permutation of the set {1, 2, ..., N}\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\np_1 p_2 ... p_N\n\nOutput\n\nThe output consists of two lines. The first line contains a_1, a_2, ..., a_N seperated by a space. The second line contains b_1, b_2, ..., b_N seperated by a space.\n\nIt can be shown that there always exists a solution for any input satisfying the constraints.\n\nSample Input 1\n\n2\n1 2\n\nSample Output 1\n\n1 4\n5 4\n\na_1 + b_1 = 6 and a_2 + b_2 = 8. So this output satisfies all conditions.\n\nSample Input 2\n\n3\n3 2 1\n\nSample Output 2\n\n1 2 3\n5 3 1\n\nSample Input 3\n\n3\n2 3 1\n\nSample Output 3\n\n5 10 100\n100 10 1", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 232, "cpu_time_ms": 24, "memory_kb": 4636}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s819572930", "group_id": "codeNet:p03943", "input_text": "a,b,c=io.read():match(\"(.+)%s(.+)%s(.+)\")\nn={a*1,b*1,c*1}\ntable.sort(n)\nprint(n[1]+n[2]==n[3]and\"Yes\"or\"No\")", "language": "Lua", "metadata": {"date": 1551656634, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p03943.html", "problem_id": "p03943", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03943/input.txt", "sample_output_relpath": "derived/input_output/data/p03943/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03943/Lua/s819572930.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s819572930", "user_id": "u837412668"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "a,b,c=io.read():match(\"(.+)%s(.+)%s(.+)\")\nn={a*1,b*1,c*1}\ntable.sort(n)\nprint(n[1]+n[2]==n[3]and\"Yes\"or\"No\")", "problem_context": "Score : 100 points\n\nProblem Statement\n\nTwo students of AtCoder Kindergarten are fighting over candy packs.\n\nThere are three candy packs, each of which contains a, b, and c candies, respectively.\n\nTeacher Evi is trying to distribute the packs between the two students so that each student gets the same number of candies. Determine whether it is possible.\n\nNote that Evi cannot take candies out of the packs, and the whole contents of each pack must be given to one of the students.\n\nConstraints\n\n1 ≦ a, b, c ≦ 100\n\nInput\n\nThe input is given from Standard Input in the following format:\n\na b c\n\nOutput\n\nIf it is possible to distribute the packs so that each student gets the same number of candies, print Yes. Otherwise, print No.\n\nSample Input 1\n\n10 30 20\n\nSample Output 1\n\nYes\n\nGive the pack with 30 candies to one student, and give the two packs with 10 and 20 candies to the other. Then, each gets 30 candies.\n\nSample Input 2\n\n30 30 100\n\nSample Output 2\n\nNo\n\nIn this case, the student who gets the pack with 100 candies always has more candies than the other.\n\nNote that every pack must be given to one of them.\n\nSample Input 3\n\n56 25 31\n\nSample Output 3\n\nYes", "sample_input": "10 30 20\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03943", "source_text": "Score : 100 points\n\nProblem Statement\n\nTwo students of AtCoder Kindergarten are fighting over candy packs.\n\nThere are three candy packs, each of which contains a, b, and c candies, respectively.\n\nTeacher Evi is trying to distribute the packs between the two students so that each student gets the same number of candies. Determine whether it is possible.\n\nNote that Evi cannot take candies out of the packs, and the whole contents of each pack must be given to one of the students.\n\nConstraints\n\n1 ≦ a, b, c ≦ 100\n\nInput\n\nThe input is given from Standard Input in the following format:\n\na b c\n\nOutput\n\nIf it is possible to distribute the packs so that each student gets the same number of candies, print Yes. Otherwise, print No.\n\nSample Input 1\n\n10 30 20\n\nSample Output 1\n\nYes\n\nGive the pack with 30 candies to one student, and give the two packs with 10 and 20 candies to the other. Then, each gets 30 candies.\n\nSample Input 2\n\n30 30 100\n\nSample Output 2\n\nNo\n\nIn this case, the student who gets the pack with 100 candies always has more candies than the other.\n\nNote that every pack must be given to one of them.\n\nSample Input 3\n\n56 25 31\n\nSample Output 3\n\nYes", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 108, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s352199013", "group_id": "codeNet:p03943", "input_text": "local max = math.max(arg[1], arg[2], arg[3])\nlocal sum = arg[1] + arg[2] + arg[3]\n\nif sum - max == max then\n\tprint(\"Yes\")\nelse\n\tprint(\"No\")\nend", "language": "Lua", "metadata": {"date": 1478558799, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03943.html", "problem_id": "p03943", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03943/input.txt", "sample_output_relpath": "derived/input_output/data/p03943/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03943/Lua/s352199013.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s352199013", "user_id": "u899855470"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "local max = math.max(arg[1], arg[2], arg[3])\nlocal sum = arg[1] + arg[2] + arg[3]\n\nif sum - max == max then\n\tprint(\"Yes\")\nelse\n\tprint(\"No\")\nend", "problem_context": "Score : 100 points\n\nProblem Statement\n\nTwo students of AtCoder Kindergarten are fighting over candy packs.\n\nThere are three candy packs, each of which contains a, b, and c candies, respectively.\n\nTeacher Evi is trying to distribute the packs between the two students so that each student gets the same number of candies. Determine whether it is possible.\n\nNote that Evi cannot take candies out of the packs, and the whole contents of each pack must be given to one of the students.\n\nConstraints\n\n1 ≦ a, b, c ≦ 100\n\nInput\n\nThe input is given from Standard Input in the following format:\n\na b c\n\nOutput\n\nIf it is possible to distribute the packs so that each student gets the same number of candies, print Yes. Otherwise, print No.\n\nSample Input 1\n\n10 30 20\n\nSample Output 1\n\nYes\n\nGive the pack with 30 candies to one student, and give the two packs with 10 and 20 candies to the other. Then, each gets 30 candies.\n\nSample Input 2\n\n30 30 100\n\nSample Output 2\n\nNo\n\nIn this case, the student who gets the pack with 100 candies always has more candies than the other.\n\nNote that every pack must be given to one of them.\n\nSample Input 3\n\n56 25 31\n\nSample Output 3\n\nYes", "sample_input": "10 30 20\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03943", "source_text": "Score : 100 points\n\nProblem Statement\n\nTwo students of AtCoder Kindergarten are fighting over candy packs.\n\nThere are three candy packs, each of which contains a, b, and c candies, respectively.\n\nTeacher Evi is trying to distribute the packs between the two students so that each student gets the same number of candies. Determine whether it is possible.\n\nNote that Evi cannot take candies out of the packs, and the whole contents of each pack must be given to one of the students.\n\nConstraints\n\n1 ≦ a, b, c ≦ 100\n\nInput\n\nThe input is given from Standard Input in the following format:\n\na b c\n\nOutput\n\nIf it is possible to distribute the packs so that each student gets the same number of candies, print Yes. Otherwise, print No.\n\nSample Input 1\n\n10 30 20\n\nSample Output 1\n\nYes\n\nGive the pack with 30 candies to one student, and give the two packs with 10 and 20 candies to the other. Then, each gets 30 candies.\n\nSample Input 2\n\n30 30 100\n\nSample Output 2\n\nNo\n\nIn this case, the student who gets the pack with 100 candies always has more candies than the other.\n\nNote that every pack must be given to one of them.\n\nSample Input 3\n\n56 25 31\n\nSample Output 3\n\nYes", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 143, "cpu_time_ms": 8, "memory_kb": 888}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s164895673", "group_id": "codeNet:p03944", "input_text": "local read = io.read\n\nlocal W, H, N = read(\"*n\", \"*n\", \"*n\")\nlocal rectangle = {}\nfor x = 1, W do\n\trectangle[x] = {}\n\tfor y = 1, H do\n\t\trectangle[x][y] = true\n\tend\nend\n\nlocal function paint(x_i, y_i, a_i)\n\tif a_i == 1 then\n\t\tfor x = 1, x_i do\n\t\t\tfor y = 1, H do\n\t\t\t\trectangle[x][y] = false\n\t\t\tend\n\t\tend\n\telseif a_i == 2 then\n\t\tfor x = x_i + 1, W do\n\t\t\tfor y = 1, H do\n\t\t\t\trectangle[x][y] = false\n\t\t\tend\n\t\tend\n\telseif a_i == 3 then\n\t\tfor x = 1, W do\n\t\t\tfor y = 1, y_i do\n\t\t\t\trectangle[x][y] = false\n\t\t\tend\n\t\tend\n\telse\n\t\tfor x = 1, W do\n\t\t\tfor y = y_i + 1, H do\n\t\t\t\trectangle[x][y] = false\n\t\t\tend\n\t\tend\n\tend\nend\n\nfor i = 1, N do\n\tpaint(read(\"*n\", \"*n\", \"*n\"))\nend\n\nlocal out = 0\nfor x = 1, W do\n\tfor y = 1, H do\n\t\tif rectangle[x][y] then\n\t\t\tout = out + 1\n\t\tend\n\tend\nend\n\nprint(out)\n", "language": "Lua", "metadata": {"date": 1595002672, "filename_ext": "lua", "original_language": "Lua (LuaJIT 2.1.0)", "problem_description_relpath": "problem_descriptions/p03944.html", "problem_id": "p03944", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03944/input.txt", "sample_output_relpath": "derived/input_output/data/p03944/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03944/Lua/s164895673.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s164895673", "user_id": "u793881115"}, "prompt_components": {"gold_output": "9\n", "input_to_evaluate": "local read = io.read\n\nlocal W, H, N = read(\"*n\", \"*n\", \"*n\")\nlocal rectangle = {}\nfor x = 1, W do\n\trectangle[x] = {}\n\tfor y = 1, H do\n\t\trectangle[x][y] = true\n\tend\nend\n\nlocal function paint(x_i, y_i, a_i)\n\tif a_i == 1 then\n\t\tfor x = 1, x_i do\n\t\t\tfor y = 1, H do\n\t\t\t\trectangle[x][y] = false\n\t\t\tend\n\t\tend\n\telseif a_i == 2 then\n\t\tfor x = x_i + 1, W do\n\t\t\tfor y = 1, H do\n\t\t\t\trectangle[x][y] = false\n\t\t\tend\n\t\tend\n\telseif a_i == 3 then\n\t\tfor x = 1, W do\n\t\t\tfor y = 1, y_i do\n\t\t\t\trectangle[x][y] = false\n\t\t\tend\n\t\tend\n\telse\n\t\tfor x = 1, W do\n\t\t\tfor y = y_i + 1, H do\n\t\t\t\trectangle[x][y] = false\n\t\t\tend\n\t\tend\n\tend\nend\n\nfor i = 1, N do\n\tpaint(read(\"*n\", \"*n\", \"*n\"))\nend\n\nlocal out = 0\nfor x = 1, W do\n\tfor y = 1, H do\n\t\tif rectangle[x][y] then\n\t\t\tout = out + 1\n\t\tend\n\tend\nend\n\nprint(out)\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nThere is a rectangle in the xy-plane, with its lower left corner at (0, 0) and its upper right corner at (W, H). Each of its sides is parallel to the x-axis or y-axis. Initially, the whole region within the rectangle is painted white.\n\nSnuke plotted N points into the rectangle. The coordinate of the i-th (1 ≦ i ≦ N) point was (x_i, y_i).\n\nThen, he created an integer sequence a of length N, and for each 1 ≦ i ≦ N, he painted some region within the rectangle black, as follows:\n\nIf a_i = 1, he painted the region satisfying x < x_i within the rectangle.\n\nIf a_i = 2, he painted the region satisfying x > x_i within the rectangle.\n\nIf a_i = 3, he painted the region satisfying y < y_i within the rectangle.\n\nIf a_i = 4, he painted the region satisfying y > y_i within the rectangle.\n\nFind the area of the white region within the rectangle after he finished painting.\n\nConstraints\n\n1 ≦ W, H ≦ 100\n\n1 ≦ N ≦ 100\n\n0 ≦ x_i ≦ W (1 ≦ i ≦ N)\n\n0 ≦ y_i ≦ H (1 ≦ i ≦ N)\n\nW, H (21:32, added), x_i and y_i are integers.\n\na_i (1 ≦ i ≦ N) is 1, 2, 3 or 4.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nW H N\nx_1 y_1 a_1\nx_2 y_2 a_2\n:\nx_N y_N a_N\n\nOutput\n\nPrint the area of the white region within the rectangle after Snuke finished painting.\n\nSample Input 1\n\n5 4 2\n2 1 1\n3 3 4\n\nSample Output 1\n\n9\n\nThe figure below shows the rectangle before Snuke starts painting.\n\nFirst, as (x_1, y_1) = (2, 1) and a_1 = 1, he paints the region satisfying x < 2 within the rectangle:\n\nThen, as (x_2, y_2) = (3, 3) and a_2 = 4, he paints the region satisfying y > 3 within the rectangle:\n\nNow, the area of the white region within the rectangle is 9.\n\nSample Input 2\n\n5 4 3\n2 1 1\n3 3 4\n1 4 2\n\nSample Output 2\n\n0\n\nIt is possible that the whole region within the rectangle is painted black.\n\nSample Input 3\n\n10 10 5\n1 6 1\n4 1 3\n6 9 4\n9 4 2\n3 1 3\n\nSample Output 3\n\n64", "sample_input": "5 4 2\n2 1 1\n3 3 4\n"}, "reference_outputs": ["9\n"], "source_document_id": "p03944", "source_text": "Score : 200 points\n\nProblem Statement\n\nThere is a rectangle in the xy-plane, with its lower left corner at (0, 0) and its upper right corner at (W, H). Each of its sides is parallel to the x-axis or y-axis. Initially, the whole region within the rectangle is painted white.\n\nSnuke plotted N points into the rectangle. The coordinate of the i-th (1 ≦ i ≦ N) point was (x_i, y_i).\n\nThen, he created an integer sequence a of length N, and for each 1 ≦ i ≦ N, he painted some region within the rectangle black, as follows:\n\nIf a_i = 1, he painted the region satisfying x < x_i within the rectangle.\n\nIf a_i = 2, he painted the region satisfying x > x_i within the rectangle.\n\nIf a_i = 3, he painted the region satisfying y < y_i within the rectangle.\n\nIf a_i = 4, he painted the region satisfying y > y_i within the rectangle.\n\nFind the area of the white region within the rectangle after he finished painting.\n\nConstraints\n\n1 ≦ W, H ≦ 100\n\n1 ≦ N ≦ 100\n\n0 ≦ x_i ≦ W (1 ≦ i ≦ N)\n\n0 ≦ y_i ≦ H (1 ≦ i ≦ N)\n\nW, H (21:32, added), x_i and y_i are integers.\n\na_i (1 ≦ i ≦ N) is 1, 2, 3 or 4.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nW H N\nx_1 y_1 a_1\nx_2 y_2 a_2\n:\nx_N y_N a_N\n\nOutput\n\nPrint the area of the white region within the rectangle after Snuke finished painting.\n\nSample Input 1\n\n5 4 2\n2 1 1\n3 3 4\n\nSample Output 1\n\n9\n\nThe figure below shows the rectangle before Snuke starts painting.\n\nFirst, as (x_1, y_1) = (2, 1) and a_1 = 1, he paints the region satisfying x < 2 within the rectangle:\n\nThen, as (x_2, y_2) = (3, 3) and a_2 = 4, he paints the region satisfying y > 3 within the rectangle:\n\nNow, the area of the white region within the rectangle is 9.\n\nSample Input 2\n\n5 4 3\n2 1 1\n3 3 4\n1 4 2\n\nSample Output 2\n\n0\n\nIt is possible that the whole region within the rectangle is painted black.\n\nSample Input 3\n\n10 10 5\n1 6 1\n4 1 3\n6 9 4\n9 4 2\n3 1 3\n\nSample Output 3\n\n64", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 780, "cpu_time_ms": 5, "memory_kb": 2772}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s092808191", "group_id": "codeNet:p03946", "input_text": "local n, t = io.read(\"*n\", \"*n\")\nlocal a = {}\nfor i = 1, n do a[i] = io.read(\"*n\") end\nlocal mmi, mma = math.min, math.max\nlocal min = {}\nmin[1] = {}\nmin[1].c, min[1].v = 1, a[1]\n\nfor i = 2, n do\n min[i] = {}\n if a[i] < min[i - 1].v then\n min[i].c, min[i].v = 1, a[i]\n elseif min[i - 1].v == a[i] then\n min[i].c = min[i - 1].c + 1\n min[i].v = min[i - 1].v\n else\n min[i].c = min[i - 1].c\n min[i].v = min[i - 1].v\n end\nend\nlocal maxrate = 0\nfor i = 2, n do\n maxrate = mma(maxrate, a[i] - min[i].v)\nend\nlocal totcnt = 0\nlocal mincnt = min[1].c\nlocal maxcnt = 0\nfor i = 2, n do\n if min[i].v < min[i - 1].v then\n totcnt = totcnt + mmi(mincnt, maxcnt)\n mincnt = min[i].c\n maxcnt = 0\n else\n if maxrate == a[i] - min[i].v then\n maxcnt = maxcnt + 1\n end\n end\nend\ntotcnt = totcnt + mmi(mincnt, maxcnt)\nprint(totcnt)\n", "language": "Lua", "metadata": {"date": 1564201702, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p03946.html", "problem_id": "p03946", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03946/input.txt", "sample_output_relpath": "derived/input_output/data/p03946/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03946/Lua/s092808191.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s092808191", "user_id": "u120582723"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "local n, t = io.read(\"*n\", \"*n\")\nlocal a = {}\nfor i = 1, n do a[i] = io.read(\"*n\") end\nlocal mmi, mma = math.min, math.max\nlocal min = {}\nmin[1] = {}\nmin[1].c, min[1].v = 1, a[1]\n\nfor i = 2, n do\n min[i] = {}\n if a[i] < min[i - 1].v then\n min[i].c, min[i].v = 1, a[i]\n elseif min[i - 1].v == a[i] then\n min[i].c = min[i - 1].c + 1\n min[i].v = min[i - 1].v\n else\n min[i].c = min[i - 1].c\n min[i].v = min[i - 1].v\n end\nend\nlocal maxrate = 0\nfor i = 2, n do\n maxrate = mma(maxrate, a[i] - min[i].v)\nend\nlocal totcnt = 0\nlocal mincnt = min[1].c\nlocal maxcnt = 0\nfor i = 2, n do\n if min[i].v < min[i - 1].v then\n totcnt = totcnt + mmi(mincnt, maxcnt)\n mincnt = min[i].c\n maxcnt = 0\n else\n if maxrate == a[i] - min[i].v then\n maxcnt = maxcnt + 1\n end\n end\nend\ntotcnt = totcnt + mmi(mincnt, maxcnt)\nprint(totcnt)\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nThere are N towns located in a line, conveniently numbered 1 through N. Takahashi the merchant is going on a travel from town 1 to town N, buying and selling apples.\n\nTakahashi will begin the travel at town 1, with no apple in his possession. The actions that can be performed during the travel are as follows:\n\nMove: When at town i (i < N), move to town i + 1.\n\nMerchandise: Buy or sell an arbitrary number of apples at the current town. Here, it is assumed that one apple can always be bought and sold for A_i yen (the currency of Japan) at town i (1 ≦ i ≦ N), where A_i are distinct integers. Also, you can assume that he has an infinite supply of money.\n\nFor some reason, there is a constraint on merchandising apple during the travel: the sum of the number of apples bought and the number of apples sold during the whole travel, must be at most T. (Note that a single apple can be counted in both.)\n\nDuring the travel, Takahashi will perform actions so that the profit of the travel is maximized. Here, the profit of the travel is the amount of money that is gained by selling apples, minus the amount of money that is spent on buying apples. Note that we are not interested in apples in his possession at the end of the travel.\n\nAoki, a business rival of Takahashi, wants to trouble Takahashi by manipulating the market price of apples. Prior to the beginning of Takahashi's travel, Aoki can change A_i into another arbitrary non-negative integer A_i' for any town i, any number of times. The cost of performing this operation is |A_i - A_i'|. After performing this operation, different towns may have equal values of A_i.\n\nAoki's objective is to decrease Takahashi's expected profit by at least 1 yen. Find the minimum total cost to achieve it. You may assume that Takahashi's expected profit is initially at least 1 yen.\n\nConstraints\n\n1 ≦ N ≦ 10^5\n\n1 ≦ A_i ≦ 10^9 (1 ≦ i ≦ N)\n\nA_i are distinct.\n\n2 ≦ T ≦ 10^9\n\nIn the initial state, Takahashi's expected profit is at least 1 yen.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN T\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the minimum total cost to decrease Takahashi's expected profit by at least 1 yen.\n\nSample Input 1\n\n3 2\n100 50 200\n\nSample Output 1\n\n1\n\nIn the initial state, Takahashi can achieve the maximum profit of 150 yen as follows:\n\nMove from town 1 to town 2.\n\nBuy one apple for 50 yen at town 2.\n\nMove from town 2 to town 3.\n\nSell one apple for 200 yen at town 3.\n\nIf, for example, Aoki changes the price of an apple at town 2 from 50 yen to 51 yen, Takahashi will not be able to achieve the profit of 150 yen. The cost of performing this operation is 1, thus the answer is 1.\n\nThere are other ways to decrease Takahashi's expected profit, such as changing the price of an apple at town 3 from 200 yen to 199 yen.\n\nSample Input 2\n\n5 8\n50 30 40 10 20\n\nSample Output 2\n\n2\n\nSample Input 3\n\n10 100\n7 10 4 5 9 3 6 8 2 1\n\nSample Output 3\n\n2", "sample_input": "3 2\n100 50 200\n"}, "reference_outputs": ["1\n"], "source_document_id": "p03946", "source_text": "Score : 400 points\n\nProblem Statement\n\nThere are N towns located in a line, conveniently numbered 1 through N. Takahashi the merchant is going on a travel from town 1 to town N, buying and selling apples.\n\nTakahashi will begin the travel at town 1, with no apple in his possession. The actions that can be performed during the travel are as follows:\n\nMove: When at town i (i < N), move to town i + 1.\n\nMerchandise: Buy or sell an arbitrary number of apples at the current town. Here, it is assumed that one apple can always be bought and sold for A_i yen (the currency of Japan) at town i (1 ≦ i ≦ N), where A_i are distinct integers. Also, you can assume that he has an infinite supply of money.\n\nFor some reason, there is a constraint on merchandising apple during the travel: the sum of the number of apples bought and the number of apples sold during the whole travel, must be at most T. (Note that a single apple can be counted in both.)\n\nDuring the travel, Takahashi will perform actions so that the profit of the travel is maximized. Here, the profit of the travel is the amount of money that is gained by selling apples, minus the amount of money that is spent on buying apples. Note that we are not interested in apples in his possession at the end of the travel.\n\nAoki, a business rival of Takahashi, wants to trouble Takahashi by manipulating the market price of apples. Prior to the beginning of Takahashi's travel, Aoki can change A_i into another arbitrary non-negative integer A_i' for any town i, any number of times. The cost of performing this operation is |A_i - A_i'|. After performing this operation, different towns may have equal values of A_i.\n\nAoki's objective is to decrease Takahashi's expected profit by at least 1 yen. Find the minimum total cost to achieve it. You may assume that Takahashi's expected profit is initially at least 1 yen.\n\nConstraints\n\n1 ≦ N ≦ 10^5\n\n1 ≦ A_i ≦ 10^9 (1 ≦ i ≦ N)\n\nA_i are distinct.\n\n2 ≦ T ≦ 10^9\n\nIn the initial state, Takahashi's expected profit is at least 1 yen.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN T\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the minimum total cost to decrease Takahashi's expected profit by at least 1 yen.\n\nSample Input 1\n\n3 2\n100 50 200\n\nSample Output 1\n\n1\n\nIn the initial state, Takahashi can achieve the maximum profit of 150 yen as follows:\n\nMove from town 1 to town 2.\n\nBuy one apple for 50 yen at town 2.\n\nMove from town 2 to town 3.\n\nSell one apple for 200 yen at town 3.\n\nIf, for example, Aoki changes the price of an apple at town 2 from 50 yen to 51 yen, Takahashi will not be able to achieve the profit of 150 yen. The cost of performing this operation is 1, thus the answer is 1.\n\nThere are other ways to decrease Takahashi's expected profit, such as changing the price of an apple at town 3 from 200 yen to 199 yen.\n\nSample Input 2\n\n5 8\n50 30 40 10 20\n\nSample Output 2\n\n2\n\nSample Input 3\n\n10 100\n7 10 4 5 9 3 6 8 2 1\n\nSample Output 3\n\n2", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 850, "cpu_time_ms": 48, "memory_kb": 11648}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s496817839", "group_id": "codeNet:p03949", "input_text": "local mmi, mma = math.min, math.max\nlocal n = io.read(\"*n\")\nlocal edge = {}\nlocal len = {}\nlocal parent = {}\nlocal childcnt = {}\nlocal valmin, valmax = {}, {}\nfor i = 1, n do\n edge[i] = {}\n len[i] = -1\n parent[i] = 0\n childcnt[i] = 0\n valmin[i], valmax[i] = false, false\nend\nfor i = 1, n - 1 do\n local a, b = io.read(\"*n\", \"*n\")\n edge[a][b], edge[b][a] = true, true\nend\nlocal k = io.read(\"*n\")\nlocal startpos, startval = 0, 0\nfor i = 1, k do\n local pos, val = io.read(\"*n\", \"*n\")\n valmin[pos], valmax[pos] = val, val\n if i == 1 or val < startval then\n startpos, startval = pos, val\n end\nend\nlocal valid = true\nlen[startpos] = 0\nlocal tasks = {startpos}\nfor i = 1, n do\n local src = tasks[i]\n for dst, _u in pairs(edge[src]) do\n if len[dst] < 0 then\n childcnt[src] = childcnt[src] + 1\n parent[dst] = src\n len[dst] = len[src] + 1\n if valmax[dst] then\n if (valmax[dst] + valmax[startpos] + len[dst]) % 2 == 1 then\n valid = false break\n end\n if valmax[startpos] + len[dst] < valmax[dst] then\n valid = false break\n end\n else\n valmax[dst] = valmax[startpos] + len[dst]\n valmin[dst] = valmax[startpos] + (len[dst] % 2)\n end\n table.insert(tasks, dst)\n end\n end\n if not valid then break end\nend\nif not valid then print(\"No\")\nelse\n tasks = {}\n for i = 1, n do\n if childcnt[i] == 0 then\n table.insert(tasks, i)\n end\n end\n for i = 1, n - 1 do\n local c = tasks[i]\n local p = parent[c]\n local newp_min = mma(valmin[p], valmin[c] - 1)\n local newp_max = mmi(valmax[p], valmax[c] + 1)\n if newp_max < newp_min then\n valid = false\n break\n end\n valmin[p] = newp_min\n valmax[p] = newp_max\n childcnt[p] = childcnt[p] - 1\n if childcnt[p] == 0 then\n table.insert(tasks, p)\n end\n end\n if not valid then print(\"No\")\n else\n local val = {}\n for i = 1, n do val[i] = 0 end\n val[startpos] = valmin[startpos]\n tasks = {startpos}\n for i = 1, n do\n local src = tasks[i]\n for dst, _u in pairs(edge[src]) do\n if len[src] < len[dst] then\n if valmin[dst] <= val[src] - 1 then\n val[dst] = val[src] - 1\n else\n val[dst] = val[src] + 1\n end\n table.insert(tasks, dst)\n end\n end\n end\n print(\"Yes\")\n for i = 1, n do\n print(val[i])\n end\n end\nend\n", "language": "Lua", "metadata": {"date": 1582481645, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p03949.html", "problem_id": "p03949", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03949/input.txt", "sample_output_relpath": "derived/input_output/data/p03949/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03949/Lua/s496817839.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s496817839", "user_id": "u120582723"}, "prompt_components": {"gold_output": "Yes\n5\n6\n6\n5\n7\n", "input_to_evaluate": "local mmi, mma = math.min, math.max\nlocal n = io.read(\"*n\")\nlocal edge = {}\nlocal len = {}\nlocal parent = {}\nlocal childcnt = {}\nlocal valmin, valmax = {}, {}\nfor i = 1, n do\n edge[i] = {}\n len[i] = -1\n parent[i] = 0\n childcnt[i] = 0\n valmin[i], valmax[i] = false, false\nend\nfor i = 1, n - 1 do\n local a, b = io.read(\"*n\", \"*n\")\n edge[a][b], edge[b][a] = true, true\nend\nlocal k = io.read(\"*n\")\nlocal startpos, startval = 0, 0\nfor i = 1, k do\n local pos, val = io.read(\"*n\", \"*n\")\n valmin[pos], valmax[pos] = val, val\n if i == 1 or val < startval then\n startpos, startval = pos, val\n end\nend\nlocal valid = true\nlen[startpos] = 0\nlocal tasks = {startpos}\nfor i = 1, n do\n local src = tasks[i]\n for dst, _u in pairs(edge[src]) do\n if len[dst] < 0 then\n childcnt[src] = childcnt[src] + 1\n parent[dst] = src\n len[dst] = len[src] + 1\n if valmax[dst] then\n if (valmax[dst] + valmax[startpos] + len[dst]) % 2 == 1 then\n valid = false break\n end\n if valmax[startpos] + len[dst] < valmax[dst] then\n valid = false break\n end\n else\n valmax[dst] = valmax[startpos] + len[dst]\n valmin[dst] = valmax[startpos] + (len[dst] % 2)\n end\n table.insert(tasks, dst)\n end\n end\n if not valid then break end\nend\nif not valid then print(\"No\")\nelse\n tasks = {}\n for i = 1, n do\n if childcnt[i] == 0 then\n table.insert(tasks, i)\n end\n end\n for i = 1, n - 1 do\n local c = tasks[i]\n local p = parent[c]\n local newp_min = mma(valmin[p], valmin[c] - 1)\n local newp_max = mmi(valmax[p], valmax[c] + 1)\n if newp_max < newp_min then\n valid = false\n break\n end\n valmin[p] = newp_min\n valmax[p] = newp_max\n childcnt[p] = childcnt[p] - 1\n if childcnt[p] == 0 then\n table.insert(tasks, p)\n end\n end\n if not valid then print(\"No\")\n else\n local val = {}\n for i = 1, n do val[i] = 0 end\n val[startpos] = valmin[startpos]\n tasks = {startpos}\n for i = 1, n do\n local src = tasks[i]\n for dst, _u in pairs(edge[src]) do\n if len[src] < len[dst] then\n if valmin[dst] <= val[src] - 1 then\n val[dst] = val[src] - 1\n else\n val[dst] = val[src] + 1\n end\n table.insert(tasks, dst)\n end\n end\n end\n print(\"Yes\")\n for i = 1, n do\n print(val[i])\n end\n end\nend\n", "problem_context": "Score : 800 points\n\nProblem Statement\n\nWe have a tree with N vertices. The vertices are numbered 1, 2, ..., N. The i-th (1 ≦ i ≦ N - 1) edge connects the two vertices A_i and B_i.\n\nTakahashi wrote integers into K of the vertices. Specifically, for each 1 ≦ j ≦ K, he wrote the integer P_j into vertex V_j. The remaining vertices are left empty. After that, he got tired and fell asleep.\n\nThen, Aoki appeared. He is trying to surprise Takahashi by writing integers into all empty vertices so that the following condition is satisfied:\n\nCondition: For any two vertices directly connected by an edge, the integers written into these vertices differ by exactly 1.\n\nDetermine if it is possible to write integers into all empty vertices so that the condition is satisfied. If the answer is positive, find one specific way to satisfy the condition.\n\nConstraints\n\n1 ≦ N ≦ 10^5\n\n1 ≦ K ≦ N\n\n1 ≦ A_i, B_i ≦ N (1 ≦ i ≦ N - 1)\n\n1 ≦ V_j ≦ N (1 ≦ j ≦ K) (21:18, a mistake in this constraint was corrected)\n\n0 ≦ P_j ≦ 10^5 (1 ≦ j ≦ K)\n\nThe given graph is a tree.\n\nAll v_j are distinct.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\nA_1 B_1\nA_2 B_2\n:\nA_{N-1} B_{N-1}\nK\nV_1 P_1\nV_2 P_2\n:\nV_K P_K\n\nOutput\n\nIf it is possible to write integers into all empty vertices so that the condition is satisfied, print Yes. Otherwise, print No.\n\nIf it is possible to satisfy the condition, print N lines in addition. The v-th (1 ≦ v ≦ N) of these N lines should contain the integer that should be written into vertex v. If there are multiple ways to satisfy the condition, any of those is accepted.\n\nSample Input 1\n\n5\n1 2\n3 1\n4 3\n3 5\n2\n2 6\n5 7\n\nSample Output 1\n\nYes\n5\n6\n6\n5\n7\n\nThe figure below shows the tree when Takahashi fell asleep. For each vertex, the integer written beside it represents the index of the vertex, and the integer written into the vertex is the integer written by Takahashi.\n\nAoki can, for example, satisfy the condition by writing integers into the remaining vertices as follows:\n\nThis corresponds to Sample Output 1. Note that other outputs that satisfy the condition will also be accepted, such as:\n\nYes\n7\n6\n8\n7\n7\n\nSample Input 2\n\n5\n1 2\n3 1\n4 3\n3 5\n3\n2 6\n4 3\n5 7\n\nSample Output 2\n\nNo\n\nSample Input 3\n\n4\n1 2\n2 3\n3 4\n1\n1 0\n\nSample Output 3\n\nYes\n0\n-1\n-2\n-3\n\nThe integers written by Aoki may be negative or exceed 10^6.", "sample_input": "5\n1 2\n3 1\n4 3\n3 5\n2\n2 6\n5 7\n"}, "reference_outputs": ["Yes\n5\n6\n6\n5\n7\n"], "source_document_id": "p03949", "source_text": "Score : 800 points\n\nProblem Statement\n\nWe have a tree with N vertices. The vertices are numbered 1, 2, ..., N. The i-th (1 ≦ i ≦ N - 1) edge connects the two vertices A_i and B_i.\n\nTakahashi wrote integers into K of the vertices. Specifically, for each 1 ≦ j ≦ K, he wrote the integer P_j into vertex V_j. The remaining vertices are left empty. After that, he got tired and fell asleep.\n\nThen, Aoki appeared. He is trying to surprise Takahashi by writing integers into all empty vertices so that the following condition is satisfied:\n\nCondition: For any two vertices directly connected by an edge, the integers written into these vertices differ by exactly 1.\n\nDetermine if it is possible to write integers into all empty vertices so that the condition is satisfied. If the answer is positive, find one specific way to satisfy the condition.\n\nConstraints\n\n1 ≦ N ≦ 10^5\n\n1 ≦ K ≦ N\n\n1 ≦ A_i, B_i ≦ N (1 ≦ i ≦ N - 1)\n\n1 ≦ V_j ≦ N (1 ≦ j ≦ K) (21:18, a mistake in this constraint was corrected)\n\n0 ≦ P_j ≦ 10^5 (1 ≦ j ≦ K)\n\nThe given graph is a tree.\n\nAll v_j are distinct.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\nA_1 B_1\nA_2 B_2\n:\nA_{N-1} B_{N-1}\nK\nV_1 P_1\nV_2 P_2\n:\nV_K P_K\n\nOutput\n\nIf it is possible to write integers into all empty vertices so that the condition is satisfied, print Yes. Otherwise, print No.\n\nIf it is possible to satisfy the condition, print N lines in addition. The v-th (1 ≦ v ≦ N) of these N lines should contain the integer that should be written into vertex v. If there are multiple ways to satisfy the condition, any of those is accepted.\n\nSample Input 1\n\n5\n1 2\n3 1\n4 3\n3 5\n2\n2 6\n5 7\n\nSample Output 1\n\nYes\n5\n6\n6\n5\n7\n\nThe figure below shows the tree when Takahashi fell asleep. For each vertex, the integer written beside it represents the index of the vertex, and the integer written into the vertex is the integer written by Takahashi.\n\nAoki can, for example, satisfy the condition by writing integers into the remaining vertices as follows:\n\nThis corresponds to Sample Output 1. Note that other outputs that satisfy the condition will also be accepted, such as:\n\nYes\n7\n6\n8\n7\n7\n\nSample Input 2\n\n5\n1 2\n3 1\n4 3\n3 5\n3\n2 6\n4 3\n5 7\n\nSample Output 2\n\nNo\n\nSample Input 3\n\n4\n1 2\n2 3\n3 4\n1\n1 0\n\nSample Output 3\n\nYes\n0\n-1\n-2\n-3\n\nThe integers written by Aoki may be negative or exceed 10^6.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2406, "cpu_time_ms": 274, "memory_kb": 22964}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s187031225", "group_id": "codeNet:p03958", "input_text": "local mma = math.max\nlocal mfl, mce, mmi = math.floor, math.ceil, math.min\n\nlocal AvlTree = {}\nAvlTree.makenode = function(self, val, parent)\n local i = self.box[#self.box]\n if not i then i = #self.v + 1\n else table.remove(self.box)\n end\n self.v[i], self.p[i] = val, parent\n self.lc[i], self.rc[i], self.l[i], self.r[i] = 0, 0, 1, 1\n return i\nend\nAvlTree.create = function(self, lessthan, n)\n self.lessthan = lessthan\n self.root = 1\n self.box = {}\n for i = n + 1, 2, -1 do table.insert(self.box, i) end\n -- value, leftCount, rightCount, left, right, parent\n self.v, self.lc, self.rc, self.l, self.r, self.p = {}, {}, {}, {}, {}, {}\n for i = 1, n + 1 do\n self.v[i], self.p[i] = 0, 1\n self.lc[i], self.rc[i], self.l[i], self.r[i] = 0, 0, 1, 1\n end\nend\n\nAvlTree.recalc = function(self, i)\n local kl, kr = self.l[i], self.r[i]\n if 1 < kl then self.lc[i] = 1 + mma(self.lc[kl], self.rc[kl])\n else self.lc[i] = 0\n end\n if 1 < kr then self.rc[i] = 1 + mma(self.lc[kr], self.rc[kr])\n else self.rc[i] = 0\n end\nend\nAvlTree.recalcAll = function(self, i)\n while 1 < i do\n self:recalc(i)\n i = self.p[i]\n end\nend\n\nAvlTree.rotR = function(self, parent)\n local granp, child = self.p[parent], self.l[parent]\n self.r[child], self.l[parent] = parent, self.r[child]\n self.p[child], self.p[parent] = granp, child\n self.p[self.l[parent]] = parent\n if 1 < granp then\n if self.l[granp] == parent then\n self.l[granp] = child\n else\n self.r[granp] = child\n end\n else\n self.root = child\n end\nend\n\nAvlTree.rotL = function(self, parent)\n local granp, child = self.p[parent], self.r[parent]\n self.l[child], self.r[parent] = parent, self.l[child]\n self.p[child], self.p[parent] = granp, child\n self.p[self.r[parent]] = parent\n if 1 < granp then\n if self.r[granp] == parent then\n self.r[granp] = child\n else\n self.l[granp] = child\n end\n else\n self.root = child\n end\nend\n\nAvlTree.rotLR = function(self, lparent, rparent)\n local sp, sl, sr = self.p, self.l, self.r\n local granp, d = sp[rparent], sr[lparent]\n sp[lparent], sr[lparent] = d, sl[d]\n sp[rparent], sl[rparent] = d, sr[d]\n sp[sl[d]], sp[sr[d]] = lparent, rparent\n sp[d], sl[d], sr[d] = granp, lparent, rparent\n if 1 < granp then\n if sr[granp] == rparent then sr[granp] = d\n else sl[granp] = d\n end\n else self.root = d\n end\nend\n\nAvlTree.rotRL = function(self, rparent, lparent)\n local sp, sl, sr = self.p, self.l, self.r\n local granp, d = sp[lparent], sl[rparent]\n sp[rparent], sl[rparent] = d, sr[d]\n sp[lparent], sr[lparent] = d, sl[d]\n sp[sr[d]], sp[sl[d]] = rparent, lparent\n sp[d], sr[d], sl[d] = granp, rparent, lparent\n if 1 < granp then\n if sl[granp] == lparent then sl[granp] = d\n else sr[granp] = d\n end\n else self.root = d\n end\nend\n\nAvlTree.empty = function(self) return self.root <= 1 end\n\nAvlTree.push = function(self, val)\n if self.root <= 1 then self.root = self:makenode(val, 1) return end\n local pos = self.root\n while true do\n if self.lessthan(val, self.v[pos]) then\n if 1 < self.l[pos] then\n pos = self.l[pos]\n else\n self.l[pos] = self:makenode(val, pos)\n pos = self.l[pos]\n break\n end\n else\n if 1 < self.r[pos] then\n pos = self.r[pos]\n else\n self.r[pos] = self:makenode(val, pos)\n pos = self.r[pos]\n break\n end\n end\n end\n while 1 < pos do\n local child, parent = pos, self.p[pos]\n if parent <= 1 then\n break\n end\n self:recalc(parent)\n local lcp_m_rcp = self.lc[parent] - self.rc[parent]\n if lcp_m_rcp % 2 ~= 0 then -- 1 or -1\n pos = parent\n elseif lcp_m_rcp == 2 then\n if self.lc[child] - 1 == self.rc[child] then\n self:rotR(parent)\n self:recalcAll(parent)\n else\n self:rotLR(child, parent)\n self:recalc(child)\n self:recalcAll(parent)\n end\n break\n elseif lcp_m_rcp == -2 then\n if self.rc[child] - 1 == self.lc[child] then\n self:rotL(parent)\n self:recalcAll(parent)\n else\n self:rotRL(child, parent)\n self:recalc(child)\n self:recalcAll(parent)\n end\n break\n else\n break\n end\n end\nend\n\nAvlTree.rmsub = function(self, node)\n while 1 < node do\n self:recalc(node)\n if self.lc[node] == self.rc[node] then\n node = self.p[node]\n elseif self.lc[node] + 1 == self.rc[node] then\n self:recalcAll(self.p[node])\n break\n else\n if self.lc[self.r[node]] == self.rc[self.r[node]] then\n self:rotL(node)\n self:recalcAll(node)\n break\n elseif self.lc[self.r[node]] + 1 == self.rc[self.r[node]] then\n local nr = self.r[node]\n self:rotL(node)\n self:recalc(node)\n node = nr\n else\n local nr = self.r[node]\n local nrl = self.l[nr]\n self:rotRL(nr, node)\n self:recalc(nr)\n self:recalc(node)\n node = nrl\n end\n end\n end\nend\n\nAvlTree.pop = function(self)\n local node = self.root\n while 1 < self.l[node] do\n node = self.l[node]\n end\n local v = self.v[node]\n local kp = self.p[node]\n self.p[self.r[node]] = kp\n if 1 < kp then\n self.l[kp] = self.r[node]\n self:rmsub(kp)\n else\n self.root = self.r[node]\n end\n table.insert(self.box, node)\n return v\nend\n\nAvlTree.new = function(lessthan, n)\n local obj = {}\n setmetatable(obj, {__index = AvlTree})\n obj:create(lessthan, n)\n return obj\nend\n\nlocal n, m = io.read(\"*n\", \"*n\")\nlocal a = {}\nfor i = 1, m do\n a[i] = io.read(\"*n\")\nend\n\nlocal function lt(p, q)\n return a[p] > a[q]\nend\nlocal avl = AvlTree.new(lt, m)\nfor i = 1, m do avl:push(i) end\nwhile true do\n local top = avl:pop()\n if avl:empty() then\n print(a[top] - 1)\n break\n else\n local nxt = avl:pop()\n a[top] = a[top] - 1\n a[nxt] = a[nxt] - 1\n if 0 < a[nxt] then\n avl:push(nxt)\n avl:push(top)\n elseif 0 < a[top] then\n avl:push(top)\n end\n if avl:empty() then print(0) break end\n end\nend\n", "language": "Lua", "metadata": {"date": 1600811204, "filename_ext": "lua", "original_language": "Lua (Lua 5.3.5)", "problem_description_relpath": "problem_descriptions/p03958.html", "problem_id": "p03958", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03958/input.txt", "sample_output_relpath": "derived/input_output/data/p03958/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03958/Lua/s187031225.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s187031225", "user_id": "u120582723"}, "prompt_components": {"gold_output": "0\n", "input_to_evaluate": "local mma = math.max\nlocal mfl, mce, mmi = math.floor, math.ceil, math.min\n\nlocal AvlTree = {}\nAvlTree.makenode = function(self, val, parent)\n local i = self.box[#self.box]\n if not i then i = #self.v + 1\n else table.remove(self.box)\n end\n self.v[i], self.p[i] = val, parent\n self.lc[i], self.rc[i], self.l[i], self.r[i] = 0, 0, 1, 1\n return i\nend\nAvlTree.create = function(self, lessthan, n)\n self.lessthan = lessthan\n self.root = 1\n self.box = {}\n for i = n + 1, 2, -1 do table.insert(self.box, i) end\n -- value, leftCount, rightCount, left, right, parent\n self.v, self.lc, self.rc, self.l, self.r, self.p = {}, {}, {}, {}, {}, {}\n for i = 1, n + 1 do\n self.v[i], self.p[i] = 0, 1\n self.lc[i], self.rc[i], self.l[i], self.r[i] = 0, 0, 1, 1\n end\nend\n\nAvlTree.recalc = function(self, i)\n local kl, kr = self.l[i], self.r[i]\n if 1 < kl then self.lc[i] = 1 + mma(self.lc[kl], self.rc[kl])\n else self.lc[i] = 0\n end\n if 1 < kr then self.rc[i] = 1 + mma(self.lc[kr], self.rc[kr])\n else self.rc[i] = 0\n end\nend\nAvlTree.recalcAll = function(self, i)\n while 1 < i do\n self:recalc(i)\n i = self.p[i]\n end\nend\n\nAvlTree.rotR = function(self, parent)\n local granp, child = self.p[parent], self.l[parent]\n self.r[child], self.l[parent] = parent, self.r[child]\n self.p[child], self.p[parent] = granp, child\n self.p[self.l[parent]] = parent\n if 1 < granp then\n if self.l[granp] == parent then\n self.l[granp] = child\n else\n self.r[granp] = child\n end\n else\n self.root = child\n end\nend\n\nAvlTree.rotL = function(self, parent)\n local granp, child = self.p[parent], self.r[parent]\n self.l[child], self.r[parent] = parent, self.l[child]\n self.p[child], self.p[parent] = granp, child\n self.p[self.r[parent]] = parent\n if 1 < granp then\n if self.r[granp] == parent then\n self.r[granp] = child\n else\n self.l[granp] = child\n end\n else\n self.root = child\n end\nend\n\nAvlTree.rotLR = function(self, lparent, rparent)\n local sp, sl, sr = self.p, self.l, self.r\n local granp, d = sp[rparent], sr[lparent]\n sp[lparent], sr[lparent] = d, sl[d]\n sp[rparent], sl[rparent] = d, sr[d]\n sp[sl[d]], sp[sr[d]] = lparent, rparent\n sp[d], sl[d], sr[d] = granp, lparent, rparent\n if 1 < granp then\n if sr[granp] == rparent then sr[granp] = d\n else sl[granp] = d\n end\n else self.root = d\n end\nend\n\nAvlTree.rotRL = function(self, rparent, lparent)\n local sp, sl, sr = self.p, self.l, self.r\n local granp, d = sp[lparent], sl[rparent]\n sp[rparent], sl[rparent] = d, sr[d]\n sp[lparent], sr[lparent] = d, sl[d]\n sp[sr[d]], sp[sl[d]] = rparent, lparent\n sp[d], sr[d], sl[d] = granp, rparent, lparent\n if 1 < granp then\n if sl[granp] == lparent then sl[granp] = d\n else sr[granp] = d\n end\n else self.root = d\n end\nend\n\nAvlTree.empty = function(self) return self.root <= 1 end\n\nAvlTree.push = function(self, val)\n if self.root <= 1 then self.root = self:makenode(val, 1) return end\n local pos = self.root\n while true do\n if self.lessthan(val, self.v[pos]) then\n if 1 < self.l[pos] then\n pos = self.l[pos]\n else\n self.l[pos] = self:makenode(val, pos)\n pos = self.l[pos]\n break\n end\n else\n if 1 < self.r[pos] then\n pos = self.r[pos]\n else\n self.r[pos] = self:makenode(val, pos)\n pos = self.r[pos]\n break\n end\n end\n end\n while 1 < pos do\n local child, parent = pos, self.p[pos]\n if parent <= 1 then\n break\n end\n self:recalc(parent)\n local lcp_m_rcp = self.lc[parent] - self.rc[parent]\n if lcp_m_rcp % 2 ~= 0 then -- 1 or -1\n pos = parent\n elseif lcp_m_rcp == 2 then\n if self.lc[child] - 1 == self.rc[child] then\n self:rotR(parent)\n self:recalcAll(parent)\n else\n self:rotLR(child, parent)\n self:recalc(child)\n self:recalcAll(parent)\n end\n break\n elseif lcp_m_rcp == -2 then\n if self.rc[child] - 1 == self.lc[child] then\n self:rotL(parent)\n self:recalcAll(parent)\n else\n self:rotRL(child, parent)\n self:recalc(child)\n self:recalcAll(parent)\n end\n break\n else\n break\n end\n end\nend\n\nAvlTree.rmsub = function(self, node)\n while 1 < node do\n self:recalc(node)\n if self.lc[node] == self.rc[node] then\n node = self.p[node]\n elseif self.lc[node] + 1 == self.rc[node] then\n self:recalcAll(self.p[node])\n break\n else\n if self.lc[self.r[node]] == self.rc[self.r[node]] then\n self:rotL(node)\n self:recalcAll(node)\n break\n elseif self.lc[self.r[node]] + 1 == self.rc[self.r[node]] then\n local nr = self.r[node]\n self:rotL(node)\n self:recalc(node)\n node = nr\n else\n local nr = self.r[node]\n local nrl = self.l[nr]\n self:rotRL(nr, node)\n self:recalc(nr)\n self:recalc(node)\n node = nrl\n end\n end\n end\nend\n\nAvlTree.pop = function(self)\n local node = self.root\n while 1 < self.l[node] do\n node = self.l[node]\n end\n local v = self.v[node]\n local kp = self.p[node]\n self.p[self.r[node]] = kp\n if 1 < kp then\n self.l[kp] = self.r[node]\n self:rmsub(kp)\n else\n self.root = self.r[node]\n end\n table.insert(self.box, node)\n return v\nend\n\nAvlTree.new = function(lessthan, n)\n local obj = {}\n setmetatable(obj, {__index = AvlTree})\n obj:create(lessthan, n)\n return obj\nend\n\nlocal n, m = io.read(\"*n\", \"*n\")\nlocal a = {}\nfor i = 1, m do\n a[i] = io.read(\"*n\")\nend\n\nlocal function lt(p, q)\n return a[p] > a[q]\nend\nlocal avl = AvlTree.new(lt, m)\nfor i = 1, m do avl:push(i) end\nwhile true do\n local top = avl:pop()\n if avl:empty() then\n print(a[top] - 1)\n break\n else\n local nxt = avl:pop()\n a[top] = a[top] - 1\n a[nxt] = a[nxt] - 1\n if 0 < a[nxt] then\n avl:push(nxt)\n avl:push(top)\n elseif 0 < a[top] then\n avl:push(top)\n end\n if avl:empty() then print(0) break end\n end\nend\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nThere are K pieces of cakes.\nMr. Takahashi would like to eat one cake per day, taking K days to eat them all.\n\nThere are T types of cake, and the number of the cakes of type i (1 ≤ i ≤ T) is a_i.\n\nEating the same type of cake two days in a row would be no fun,\nso Mr. Takahashi would like to decide the order for eating cakes that minimizes the number of days on which he has to eat the same type of cake as the day before.\n\nCompute the minimum number of days on which the same type of cake as the previous day will be eaten.\n\nConstraints\n\n1 ≤ K ≤ 10000\n\n1 ≤ T ≤ 100\n\n1 ≤ a_i ≤ 100\n\na_1 + a_2 + ... + a_T = K\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nK T\na_1 a_2 ... a_T\n\nOutput\n\nPrint the minimum number of days on which the same type of cake as the previous day will be eaten.\n\nSample Input 1\n\n7 3\n3 2 2\n\nSample Output 1\n\n0\n\nFor example, if Mr. Takahashi eats cakes in the order of 2, 1, 2, 3, 1, 3, 1, he can avoid eating the same type of cake as the previous day.\n\nSample Input 2\n\n6 3\n1 4 1\n\nSample Output 2\n\n1\n\nThere are 6 cakes.\nFor example, if Mr. Takahashi eats cakes in the order of 2, 3, 2, 2, 1, 2, he has to eat the same type of cake (i.e., type 2) as the previous day only on the fourth day.\nSince this is the minimum number, the answer is 1.\n\nSample Input 3\n\n100 1\n100\n\nSample Output 3\n\n99\n\nSince Mr. Takahashi has only one type of cake, he has no choice but to eat the same type of cake as the previous day from the second day and after.", "sample_input": "7 3\n3 2 2\n"}, "reference_outputs": ["0\n"], "source_document_id": "p03958", "source_text": "Score : 200 points\n\nProblem Statement\n\nThere are K pieces of cakes.\nMr. Takahashi would like to eat one cake per day, taking K days to eat them all.\n\nThere are T types of cake, and the number of the cakes of type i (1 ≤ i ≤ T) is a_i.\n\nEating the same type of cake two days in a row would be no fun,\nso Mr. Takahashi would like to decide the order for eating cakes that minimizes the number of days on which he has to eat the same type of cake as the day before.\n\nCompute the minimum number of days on which the same type of cake as the previous day will be eaten.\n\nConstraints\n\n1 ≤ K ≤ 10000\n\n1 ≤ T ≤ 100\n\n1 ≤ a_i ≤ 100\n\na_1 + a_2 + ... + a_T = K\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nK T\na_1 a_2 ... a_T\n\nOutput\n\nPrint the minimum number of days on which the same type of cake as the previous day will be eaten.\n\nSample Input 1\n\n7 3\n3 2 2\n\nSample Output 1\n\n0\n\nFor example, if Mr. Takahashi eats cakes in the order of 2, 1, 2, 3, 1, 3, 1, he can avoid eating the same type of cake as the previous day.\n\nSample Input 2\n\n6 3\n1 4 1\n\nSample Output 2\n\n1\n\nThere are 6 cakes.\nFor example, if Mr. Takahashi eats cakes in the order of 2, 3, 2, 2, 1, 2, he has to eat the same type of cake (i.e., type 2) as the previous day only on the fourth day.\nSince this is the minimum number, the answer is 1.\n\nSample Input 3\n\n100 1\n100\n\nSample Output 3\n\n99\n\nSince Mr. Takahashi has only one type of cake, he has no choice but to eat the same type of cake as the previous day from the second day and after.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 5993, "cpu_time_ms": 76, "memory_kb": 2760}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s009274100", "group_id": "codeNet:p03958", "input_text": "local mma = math.max\nlocal mfl, mce, mmi = math.floor, math.ceil, math.min\n\nlocal AvlTree = {}\nAvlTree.makenode = function(self, val, parent)\n local i = self.box[#self.box]\n if not i then i = #self.v + 1\n else table.remove(self.box)\n end\n self.v[i], self.p[i] = val, parent\n self.lc[i], self.rc[i], self.l[i], self.r[i] = 0, 0, 1, 1\n return i\nend\nAvlTree.create = function(self, lessthan, n)\n self.lessthan = lessthan\n self.root = 1\n self.box = {}\n for i = n + 1, 2, -1 do table.insert(self.box, i) end\n -- value, leftCount, rightCount, left, right, parent\n self.v, self.lc, self.rc, self.l, self.r, self.p = {}, {}, {}, {}, {}, {}\n for i = 1, n + 1 do\n self.v[i], self.p[i] = 0, 1\n self.lc[i], self.rc[i], self.l[i], self.r[i] = 0, 0, 1, 1\n end\nend\n\nAvlTree.recalc = function(self, i)\n local kl, kr = self.l[i], self.r[i]\n if 1 < kl then self.lc[i] = 1 + mma(self.lc[kl], self.rc[kl])\n else self.lc[i] = 0\n end\n if 1 < kr then self.rc[i] = 1 + mma(self.lc[kr], self.rc[kr])\n else self.rc[i] = 0\n end\nend\nAvlTree.recalcAll = function(self, i)\n while 1 < i do\n self:recalc(i)\n i = self.p[i]\n end\nend\n\nAvlTree.rotR = function(self, parent)\n local granp, child = self.p[parent], self.l[parent]\n self.r[child], self.l[parent] = parent, self.r[child]\n self.p[child], self.p[parent] = granp, child\n self.p[self.l[parent]] = parent\n if 1 < granp then\n if self.l[granp] == parent then\n self.l[granp] = child\n else\n self.r[granp] = child\n end\n else\n self.root = child\n end\nend\n\nAvlTree.rotL = function(self, parent)\n local granp, child = self.p[parent], self.r[parent]\n self.l[child], self.r[parent] = parent, self.l[child]\n self.p[child], self.p[parent] = granp, child\n self.p[self.r[parent]] = parent\n if 1 < granp then\n if self.r[granp] == parent then\n self.r[granp] = child\n else\n self.l[granp] = child\n end\n else\n self.root = child\n end\nend\n\nAvlTree.rotLR = function(self, lparent, rparent)\n local sp, sl, sr = self.p, self.l, self.r\n local granp, d = sp[rparent], sr[lparent]\n sp[lparent], sr[lparent] = d, sl[d]\n sp[rparent], sl[rparent] = d, sr[d]\n sp[sl[d]], sp[sr[d]] = lparent, rparent\n sp[d], sl[d], sr[d] = granp, lparent, rparent\n if 1 < granp then\n if sr[granp] == rparent then sr[granp] = d\n else sl[granp] = d\n end\n else self.root = d\n end\nend\n\nAvlTree.rotRL = function(self, rparent, lparent)\n local sp, sl, sr = self.p, self.l, self.r\n local granp, d = sp[lparent], sl[rparent]\n sp[rparent], sl[rparent] = d, sr[d]\n sp[lparent], sr[lparent] = d, sl[d]\n sp[sr[d]], sp[sl[d]] = rparent, lparent\n sp[d], sr[d], sl[d] = granp, rparent, lparent\n if 1 < granp then\n if sl[granp] == lparent then sl[granp] = d\n else sr[granp] = d\n end\n else self.root = d\n end\nend\n\nAvlTree.empty = function(self) return self.root <= 1 end\n\nAvlTree.push = function(self, val)\n if self.root <= 1 then self.root = self:makenode(val, 1) return end\n local pos = self.root\n while true do\n if self.lessthan(val, self.v[pos]) then\n if 1 < self.l[pos] then\n pos = self.l[pos]\n else\n self.l[pos] = self:makenode(val, pos)\n pos = self.l[pos]\n break\n end\n else\n if 1 < self.r[pos] then\n pos = self.r[pos]\n else\n self.r[pos] = self:makenode(val, pos)\n pos = self.r[pos]\n break\n end\n end\n end\n while 1 < pos do\n local child, parent = pos, self.p[pos]\n if parent <= 1 then\n break\n end\n self:recalc(parent)\n local lcp_m_rcp = self.lc[parent] - self.rc[parent]\n if lcp_m_rcp % 2 ~= 0 then -- 1 or -1\n pos = parent\n elseif lcp_m_rcp == 2 then\n if self.lc[child] - 1 == self.rc[child] then\n self:rotR(parent)\n self:recalcAll(parent)\n else\n self:rotLR(child, parent)\n self:recalc(child)\n self:recalcAll(parent)\n end\n break\n elseif lcp_m_rcp == -2 then\n if self.rc[child] - 1 == self.lc[child] then\n self:rotL(parent)\n self:recalcAll(parent)\n else\n self:rotRL(child, parent)\n self:recalc(child)\n self:recalcAll(parent)\n end\n break\n else\n break\n end\n end\nend\n\nAvlTree.rmsub = function(self, node)\n while 1 < node do\n self:recalc(node)\n if self.lc[node] == self.rc[node] then\n node = self.p[node]\n elseif self.lc[node] + 1 == self.rc[node] then\n self:recalcAll(self.p[node])\n break\n else\n if self.lc[self.r[node]] == self.rc[self.r[node]] then\n self:rotL(node)\n self:recalcAll(node)\n break\n elseif self.lc[self.r[node]] + 1 == self.rc[self.r[node]] then\n local nr = self.r[node]\n self:rotL(node)\n self:recalc(node)\n node = nr\n else\n local nr = self.r[node]\n local nrl = self.l[nr]\n self:rotRL(nr, node)\n self:recalc(nr)\n self:recalc(node)\n node = nrl\n end\n end\n end\nend\n\nAvlTree.pop = function(self)\n local node = self.root\n while 1 < self.l[node] do\n node = self.l[node]\n end\n local v = self.v[node]\n local kp = self.p[node]\n self.p[self.r[node]] = kp\n if 1 < kp then\n self.l[kp] = self.r[node]\n self:rmsub(kp)\n else\n self.root = self.r[node]\n end\n table.insert(self.box, node)\n return v\nend\n\nAvlTree.new = function(lessthan, n)\n local obj = {}\n setmetatable(obj, {__index = AvlTree})\n obj:create(lessthan, n)\n return obj\nend\n\nlocal n, m = io.read(\"*n\", \"*n\")\nlocal a = {}\nfor i = 1, m do\n a[i] = io.read(\"*n\")\nend\n\nlocal function lt(p, q)\n return a[p] > a[q]\nend\nlocal avl = AvlTree.new(lt, m)\nfor i = 1, m do avl:push(i) end\nwhile true do\n local top = avl:pop()\n if avl:empty() then\n print(a[top] - 1)\n break\n else\n local nxt = avl:pop()\n a[top] = a[top] - 1\n a[nxt] = a[nxt] - 1\n if 0 < a[nxt] then\n avl:push(nxt)\n avl:push(top)\n elseif 0 < a[top] then\n avl:push(top)\n end\n if avl:empty() then break end\n end\nend\n", "language": "Lua", "metadata": {"date": 1600811144, "filename_ext": "lua", "original_language": "Lua (LuaJIT 2.1.0)", "problem_description_relpath": "problem_descriptions/p03958.html", "problem_id": "p03958", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03958/input.txt", "sample_output_relpath": "derived/input_output/data/p03958/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03958/Lua/s009274100.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s009274100", "user_id": "u120582723"}, "prompt_components": {"gold_output": "0\n", "input_to_evaluate": "local mma = math.max\nlocal mfl, mce, mmi = math.floor, math.ceil, math.min\n\nlocal AvlTree = {}\nAvlTree.makenode = function(self, val, parent)\n local i = self.box[#self.box]\n if not i then i = #self.v + 1\n else table.remove(self.box)\n end\n self.v[i], self.p[i] = val, parent\n self.lc[i], self.rc[i], self.l[i], self.r[i] = 0, 0, 1, 1\n return i\nend\nAvlTree.create = function(self, lessthan, n)\n self.lessthan = lessthan\n self.root = 1\n self.box = {}\n for i = n + 1, 2, -1 do table.insert(self.box, i) end\n -- value, leftCount, rightCount, left, right, parent\n self.v, self.lc, self.rc, self.l, self.r, self.p = {}, {}, {}, {}, {}, {}\n for i = 1, n + 1 do\n self.v[i], self.p[i] = 0, 1\n self.lc[i], self.rc[i], self.l[i], self.r[i] = 0, 0, 1, 1\n end\nend\n\nAvlTree.recalc = function(self, i)\n local kl, kr = self.l[i], self.r[i]\n if 1 < kl then self.lc[i] = 1 + mma(self.lc[kl], self.rc[kl])\n else self.lc[i] = 0\n end\n if 1 < kr then self.rc[i] = 1 + mma(self.lc[kr], self.rc[kr])\n else self.rc[i] = 0\n end\nend\nAvlTree.recalcAll = function(self, i)\n while 1 < i do\n self:recalc(i)\n i = self.p[i]\n end\nend\n\nAvlTree.rotR = function(self, parent)\n local granp, child = self.p[parent], self.l[parent]\n self.r[child], self.l[parent] = parent, self.r[child]\n self.p[child], self.p[parent] = granp, child\n self.p[self.l[parent]] = parent\n if 1 < granp then\n if self.l[granp] == parent then\n self.l[granp] = child\n else\n self.r[granp] = child\n end\n else\n self.root = child\n end\nend\n\nAvlTree.rotL = function(self, parent)\n local granp, child = self.p[parent], self.r[parent]\n self.l[child], self.r[parent] = parent, self.l[child]\n self.p[child], self.p[parent] = granp, child\n self.p[self.r[parent]] = parent\n if 1 < granp then\n if self.r[granp] == parent then\n self.r[granp] = child\n else\n self.l[granp] = child\n end\n else\n self.root = child\n end\nend\n\nAvlTree.rotLR = function(self, lparent, rparent)\n local sp, sl, sr = self.p, self.l, self.r\n local granp, d = sp[rparent], sr[lparent]\n sp[lparent], sr[lparent] = d, sl[d]\n sp[rparent], sl[rparent] = d, sr[d]\n sp[sl[d]], sp[sr[d]] = lparent, rparent\n sp[d], sl[d], sr[d] = granp, lparent, rparent\n if 1 < granp then\n if sr[granp] == rparent then sr[granp] = d\n else sl[granp] = d\n end\n else self.root = d\n end\nend\n\nAvlTree.rotRL = function(self, rparent, lparent)\n local sp, sl, sr = self.p, self.l, self.r\n local granp, d = sp[lparent], sl[rparent]\n sp[rparent], sl[rparent] = d, sr[d]\n sp[lparent], sr[lparent] = d, sl[d]\n sp[sr[d]], sp[sl[d]] = rparent, lparent\n sp[d], sr[d], sl[d] = granp, rparent, lparent\n if 1 < granp then\n if sl[granp] == lparent then sl[granp] = d\n else sr[granp] = d\n end\n else self.root = d\n end\nend\n\nAvlTree.empty = function(self) return self.root <= 1 end\n\nAvlTree.push = function(self, val)\n if self.root <= 1 then self.root = self:makenode(val, 1) return end\n local pos = self.root\n while true do\n if self.lessthan(val, self.v[pos]) then\n if 1 < self.l[pos] then\n pos = self.l[pos]\n else\n self.l[pos] = self:makenode(val, pos)\n pos = self.l[pos]\n break\n end\n else\n if 1 < self.r[pos] then\n pos = self.r[pos]\n else\n self.r[pos] = self:makenode(val, pos)\n pos = self.r[pos]\n break\n end\n end\n end\n while 1 < pos do\n local child, parent = pos, self.p[pos]\n if parent <= 1 then\n break\n end\n self:recalc(parent)\n local lcp_m_rcp = self.lc[parent] - self.rc[parent]\n if lcp_m_rcp % 2 ~= 0 then -- 1 or -1\n pos = parent\n elseif lcp_m_rcp == 2 then\n if self.lc[child] - 1 == self.rc[child] then\n self:rotR(parent)\n self:recalcAll(parent)\n else\n self:rotLR(child, parent)\n self:recalc(child)\n self:recalcAll(parent)\n end\n break\n elseif lcp_m_rcp == -2 then\n if self.rc[child] - 1 == self.lc[child] then\n self:rotL(parent)\n self:recalcAll(parent)\n else\n self:rotRL(child, parent)\n self:recalc(child)\n self:recalcAll(parent)\n end\n break\n else\n break\n end\n end\nend\n\nAvlTree.rmsub = function(self, node)\n while 1 < node do\n self:recalc(node)\n if self.lc[node] == self.rc[node] then\n node = self.p[node]\n elseif self.lc[node] + 1 == self.rc[node] then\n self:recalcAll(self.p[node])\n break\n else\n if self.lc[self.r[node]] == self.rc[self.r[node]] then\n self:rotL(node)\n self:recalcAll(node)\n break\n elseif self.lc[self.r[node]] + 1 == self.rc[self.r[node]] then\n local nr = self.r[node]\n self:rotL(node)\n self:recalc(node)\n node = nr\n else\n local nr = self.r[node]\n local nrl = self.l[nr]\n self:rotRL(nr, node)\n self:recalc(nr)\n self:recalc(node)\n node = nrl\n end\n end\n end\nend\n\nAvlTree.pop = function(self)\n local node = self.root\n while 1 < self.l[node] do\n node = self.l[node]\n end\n local v = self.v[node]\n local kp = self.p[node]\n self.p[self.r[node]] = kp\n if 1 < kp then\n self.l[kp] = self.r[node]\n self:rmsub(kp)\n else\n self.root = self.r[node]\n end\n table.insert(self.box, node)\n return v\nend\n\nAvlTree.new = function(lessthan, n)\n local obj = {}\n setmetatable(obj, {__index = AvlTree})\n obj:create(lessthan, n)\n return obj\nend\n\nlocal n, m = io.read(\"*n\", \"*n\")\nlocal a = {}\nfor i = 1, m do\n a[i] = io.read(\"*n\")\nend\n\nlocal function lt(p, q)\n return a[p] > a[q]\nend\nlocal avl = AvlTree.new(lt, m)\nfor i = 1, m do avl:push(i) end\nwhile true do\n local top = avl:pop()\n if avl:empty() then\n print(a[top] - 1)\n break\n else\n local nxt = avl:pop()\n a[top] = a[top] - 1\n a[nxt] = a[nxt] - 1\n if 0 < a[nxt] then\n avl:push(nxt)\n avl:push(top)\n elseif 0 < a[top] then\n avl:push(top)\n end\n if avl:empty() then break end\n end\nend\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nThere are K pieces of cakes.\nMr. Takahashi would like to eat one cake per day, taking K days to eat them all.\n\nThere are T types of cake, and the number of the cakes of type i (1 ≤ i ≤ T) is a_i.\n\nEating the same type of cake two days in a row would be no fun,\nso Mr. Takahashi would like to decide the order for eating cakes that minimizes the number of days on which he has to eat the same type of cake as the day before.\n\nCompute the minimum number of days on which the same type of cake as the previous day will be eaten.\n\nConstraints\n\n1 ≤ K ≤ 10000\n\n1 ≤ T ≤ 100\n\n1 ≤ a_i ≤ 100\n\na_1 + a_2 + ... + a_T = K\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nK T\na_1 a_2 ... a_T\n\nOutput\n\nPrint the minimum number of days on which the same type of cake as the previous day will be eaten.\n\nSample Input 1\n\n7 3\n3 2 2\n\nSample Output 1\n\n0\n\nFor example, if Mr. Takahashi eats cakes in the order of 2, 1, 2, 3, 1, 3, 1, he can avoid eating the same type of cake as the previous day.\n\nSample Input 2\n\n6 3\n1 4 1\n\nSample Output 2\n\n1\n\nThere are 6 cakes.\nFor example, if Mr. Takahashi eats cakes in the order of 2, 3, 2, 2, 1, 2, he has to eat the same type of cake (i.e., type 2) as the previous day only on the fourth day.\nSince this is the minimum number, the answer is 1.\n\nSample Input 3\n\n100 1\n100\n\nSample Output 3\n\n99\n\nSince Mr. Takahashi has only one type of cake, he has no choice but to eat the same type of cake as the previous day from the second day and after.", "sample_input": "7 3\n3 2 2\n"}, "reference_outputs": ["0\n"], "source_document_id": "p03958", "source_text": "Score : 200 points\n\nProblem Statement\n\nThere are K pieces of cakes.\nMr. Takahashi would like to eat one cake per day, taking K days to eat them all.\n\nThere are T types of cake, and the number of the cakes of type i (1 ≤ i ≤ T) is a_i.\n\nEating the same type of cake two days in a row would be no fun,\nso Mr. Takahashi would like to decide the order for eating cakes that minimizes the number of days on which he has to eat the same type of cake as the day before.\n\nCompute the minimum number of days on which the same type of cake as the previous day will be eaten.\n\nConstraints\n\n1 ≤ K ≤ 10000\n\n1 ≤ T ≤ 100\n\n1 ≤ a_i ≤ 100\n\na_1 + a_2 + ... + a_T = K\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nK T\na_1 a_2 ... a_T\n\nOutput\n\nPrint the minimum number of days on which the same type of cake as the previous day will be eaten.\n\nSample Input 1\n\n7 3\n3 2 2\n\nSample Output 1\n\n0\n\nFor example, if Mr. Takahashi eats cakes in the order of 2, 1, 2, 3, 1, 3, 1, he can avoid eating the same type of cake as the previous day.\n\nSample Input 2\n\n6 3\n1 4 1\n\nSample Output 2\n\n1\n\nThere are 6 cakes.\nFor example, if Mr. Takahashi eats cakes in the order of 2, 3, 2, 2, 1, 2, he has to eat the same type of cake (i.e., type 2) as the previous day only on the fourth day.\nSince this is the minimum number, the answer is 1.\n\nSample Input 3\n\n100 1\n100\n\nSample Output 3\n\n99\n\nSince Mr. Takahashi has only one type of cake, he has no choice but to eat the same type of cake as the previous day from the second day and after.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 5984, "cpu_time_ms": 12, "memory_kb": 2764}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s594733747", "group_id": "codeNet:p03960", "input_text": "local mma, mmi = math.max, math.min\nlocal h, w = io.read(\"*n\", \"*n\", \"*l\")\nlocal map = {}\nfor j = 1, w do map[j] = {} end\nfor i = 1, h do\n local str = io.read()\n for j = 1, w do\n map[j][i] = str:sub(j, j):byte()\n end\nend\nlocal function solve(col)\n local mapl, mapr = map[col], map[col + 1]\n local cost = {}\n do\n cost[1] = {}\n local lv = mapl[1]\n for right = 1, h do\n local z = lv == mapr[right] and 1 or 0\n cost[1][right] = z\n end\n end\n for left = 2, h do\n cost[left] = {}\n local lv = mapl[left]\n do\n local z = lv == mapr[1] and 1 or 0\n cost[left][1] = z\n end\n for right = 2, h do\n local z = lv == mapr[right] and 1 or 0\n z = z + cost[left - 1][right - 1]\n cost[left][right] = z\n end\n end\n for sum = h * 2 - 1, 2, -1 do\n local dst_l_min, dst_l_max = mma(1, sum - h), mmi(h, sum - 1)\n for dst_l = dst_l_min, dst_l_max do\n local dst_r = sum - dst_l\n if dst_l == h then\n cost[h][dst_r] = cost[h][dst_r] + cost[h][dst_r + 1]\n elseif dst_r == h then\n cost[dst_l][h] = cost[dst_l][h] + cost[dst_l + 1][h]\n else\n cost[dst_l][dst_r] = cost[dst_l][dst_r] + mmi(cost[dst_l + 1][dst_r], cost[dst_l][dst_r + 1])\n end\n end\n end\n local res = cost[1][1]\n for i = 1, h do\n res = mmi(res, cost[i][1])\n res = mmi(res, cost[1][i])\n end\n return res\nend\n\nlocal ret = 0\nfor i = 1, w - 1 do\n ret = ret + solve(i)\nend\nprint(ret)\n", "language": "Lua", "metadata": {"date": 1582385194, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p03960.html", "problem_id": "p03960", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03960/input.txt", "sample_output_relpath": "derived/input_output/data/p03960/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03960/Lua/s594733747.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s594733747", "user_id": "u120582723"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "local mma, mmi = math.max, math.min\nlocal h, w = io.read(\"*n\", \"*n\", \"*l\")\nlocal map = {}\nfor j = 1, w do map[j] = {} end\nfor i = 1, h do\n local str = io.read()\n for j = 1, w do\n map[j][i] = str:sub(j, j):byte()\n end\nend\nlocal function solve(col)\n local mapl, mapr = map[col], map[col + 1]\n local cost = {}\n do\n cost[1] = {}\n local lv = mapl[1]\n for right = 1, h do\n local z = lv == mapr[right] and 1 or 0\n cost[1][right] = z\n end\n end\n for left = 2, h do\n cost[left] = {}\n local lv = mapl[left]\n do\n local z = lv == mapr[1] and 1 or 0\n cost[left][1] = z\n end\n for right = 2, h do\n local z = lv == mapr[right] and 1 or 0\n z = z + cost[left - 1][right - 1]\n cost[left][right] = z\n end\n end\n for sum = h * 2 - 1, 2, -1 do\n local dst_l_min, dst_l_max = mma(1, sum - h), mmi(h, sum - 1)\n for dst_l = dst_l_min, dst_l_max do\n local dst_r = sum - dst_l\n if dst_l == h then\n cost[h][dst_r] = cost[h][dst_r] + cost[h][dst_r + 1]\n elseif dst_r == h then\n cost[dst_l][h] = cost[dst_l][h] + cost[dst_l + 1][h]\n else\n cost[dst_l][dst_r] = cost[dst_l][dst_r] + mmi(cost[dst_l + 1][dst_r], cost[dst_l][dst_r + 1])\n end\n end\n end\n local res = cost[1][1]\n for i = 1, h do\n res = mmi(res, cost[i][1])\n res = mmi(res, cost[1][i])\n end\n return res\nend\n\nlocal ret = 0\nfor i = 1, w - 1 do\n ret = ret + solve(i)\nend\nprint(ret)\n", "problem_context": "Score : 800 points\n\nProblem Statement\n\nMr. Takahashi has in his room an art object with H rows and W columns, made up of H \\times W blocks.\nEach block has a color represented by a lowercase English letter (a-z).\nThe color of the block at the i-th row and j-th column is c_{i,j}.\n\nMr. Takahashi would like to dismantle the object, finding it a bit kitschy for his tastes.\nThe dismantling is processed by repeating the following operation:\n\nChoose one of the W columns and push down that column one row.\nThe block at the bottom of that column disappears.\n\nEach time the operation is performed, a cost is incurred.\nSince blocks of the same color have a property to draw each other together, the cost of the operation is the number of the pairs of blocks (p, q) such that:\n\nThe block p is in the selected column.\n\nThe two blocks p and q are horizontally adjacent (before pushing down the column).\n\nThe two blocks p and q have the same color.\n\nMr. Takahashi dismantles the object by repeating the operation H \\times W times to get rid of all the blocks.\nCompute the minimum total cost to dismantle the object.\n\nConstraints\n\n1 ≤ H ≤ 300\n\n2 ≤ W ≤ 300\n\nAll characters c_{i,j} are lowercase English letters (a-z).\n\nPartial Score\n\nIn test cases worth 300 points, W = 3.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nH W\nc_{1,1}c_{1,2}..c_{1,W}\nc_{2,1}c_{2,2}..c_{2,W}\n:\nc_{H,1}c_{H,2}..c_{H,W}\n\nOutput\n\nPrint the minimum total cost to dismantle the object.\n\nSample Input 1\n\n2 3\nrrr\nbrg\n\nSample Output 1\n\n2\n\nFor example, the total cost of 2 can be achieved by performing the operation as follows and this is the minimum value.\n\nSample Input 2\n\n6 3\nxya\nxya\nayz\nayz\nxaz\nxaz\n\nSample Output 2\n\n0\n\nThe total cost of 0 can be achieved by first pushing down all blocks of the middle column, then all of the left column, and all of the right column.\n\nSample Input 3\n\n4 2\nay\nxa\nxy\nay\n\nSample Output 3\n\n0\n\nThe total cost of 0 can be achieved by the following operations:\n\npushing down the right column one row;\n\npushing down the left column one row;\n\npushing down all of the right column;\n\nand pushing down all of the left column.\n\nSample Input 4\n\n5 5\naaaaa\nabbba\nababa\nabbba\naaaaa\n\nSample Output 4\n\n24\n\nSample Input 5\n\n7 10\nxxxxxxxxxx\nccccxxffff\ncxxcxxfxxx\ncxxxxxffff\ncxxcxxfxxx\nccccxxfxxx\nxxxxxxxxxx\n\nSample Output 5\n\n130", "sample_input": "2 3\nrrr\nbrg\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03960", "source_text": "Score : 800 points\n\nProblem Statement\n\nMr. Takahashi has in his room an art object with H rows and W columns, made up of H \\times W blocks.\nEach block has a color represented by a lowercase English letter (a-z).\nThe color of the block at the i-th row and j-th column is c_{i,j}.\n\nMr. Takahashi would like to dismantle the object, finding it a bit kitschy for his tastes.\nThe dismantling is processed by repeating the following operation:\n\nChoose one of the W columns and push down that column one row.\nThe block at the bottom of that column disappears.\n\nEach time the operation is performed, a cost is incurred.\nSince blocks of the same color have a property to draw each other together, the cost of the operation is the number of the pairs of blocks (p, q) such that:\n\nThe block p is in the selected column.\n\nThe two blocks p and q are horizontally adjacent (before pushing down the column).\n\nThe two blocks p and q have the same color.\n\nMr. Takahashi dismantles the object by repeating the operation H \\times W times to get rid of all the blocks.\nCompute the minimum total cost to dismantle the object.\n\nConstraints\n\n1 ≤ H ≤ 300\n\n2 ≤ W ≤ 300\n\nAll characters c_{i,j} are lowercase English letters (a-z).\n\nPartial Score\n\nIn test cases worth 300 points, W = 3.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nH W\nc_{1,1}c_{1,2}..c_{1,W}\nc_{2,1}c_{2,2}..c_{2,W}\n:\nc_{H,1}c_{H,2}..c_{H,W}\n\nOutput\n\nPrint the minimum total cost to dismantle the object.\n\nSample Input 1\n\n2 3\nrrr\nbrg\n\nSample Output 1\n\n2\n\nFor example, the total cost of 2 can be achieved by performing the operation as follows and this is the minimum value.\n\nSample Input 2\n\n6 3\nxya\nxya\nayz\nayz\nxaz\nxaz\n\nSample Output 2\n\n0\n\nThe total cost of 0 can be achieved by first pushing down all blocks of the middle column, then all of the left column, and all of the right column.\n\nSample Input 3\n\n4 2\nay\nxa\nxy\nay\n\nSample Output 3\n\n0\n\nThe total cost of 0 can be achieved by the following operations:\n\npushing down the right column one row;\n\npushing down the left column one row;\n\npushing down all of the right column;\n\nand pushing down all of the left column.\n\nSample Input 4\n\n5 5\naaaaa\nabbba\nababa\nabbba\naaaaa\n\nSample Output 4\n\n24\n\nSample Input 5\n\n7 10\nxxxxxxxxxx\nccccxxffff\ncxxcxxfxxx\ncxxxxxffff\ncxxcxxfxxx\nccccxxfxxx\nxxxxxxxxxx\n\nSample Output 5\n\n130", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1450, "cpu_time_ms": 730, "memory_kb": 10240}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s310207860", "group_id": "codeNet:p03962", "input_text": "a, b, c = io.read(\"*n\", \"*n\", \"*n\")\nr = 0\nif a ~= b and b ~= c and c ~= a then\n\tr = 3\nelseif a == b and c ~= a then\n\tr = 2\nelseif b == c and a ~= b then\n\tr = 2\nelseif c == a and b ~= c then\n\tr = 2\nelse\n\tr = 1\nend\nprint(r)\n", "language": "Lua", "metadata": {"date": 1478589284, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p03962.html", "problem_id": "p03962", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03962/input.txt", "sample_output_relpath": "derived/input_output/data/p03962/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03962/Lua/s310207860.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s310207860", "user_id": "u899855470"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "a, b, c = io.read(\"*n\", \"*n\", \"*n\")\nr = 0\nif a ~= b and b ~= c and c ~= a then\n\tr = 3\nelseif a == b and c ~= a then\n\tr = 2\nelseif b == c and a ~= b then\n\tr = 2\nelseif c == a and b ~= c then\n\tr = 2\nelse\n\tr = 1\nend\nprint(r)\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nAtCoDeer the deer recently bought three paint cans.\nThe color of the one he bought two days ago is a, the color of the one he bought yesterday is b, and the color of the one he bought today is c.\nHere, the color of each paint can is represented by an integer between 1 and 100, inclusive.\n\nSince he is forgetful, he might have bought more than one paint can in the same color.\nCount the number of different kinds of colors of these paint cans and tell him.\n\nConstraints\n\n1≦a,b,c≦100\n\nInput\n\nThe input is given from Standard Input in the following format:\n\na b c\n\nOutput\n\nPrint the number of different kinds of colors of the paint cans.\n\nSample Input 1\n\n3 1 4\n\nSample Output 1\n\n3\n\nThree different colors: 1, 3, and 4.\n\nSample Input 2\n\n3 3 33\n\nSample Output 2\n\n2\n\nTwo different colors: 3 and 33.", "sample_input": "3 1 4\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03962", "source_text": "Score : 100 points\n\nProblem Statement\n\nAtCoDeer the deer recently bought three paint cans.\nThe color of the one he bought two days ago is a, the color of the one he bought yesterday is b, and the color of the one he bought today is c.\nHere, the color of each paint can is represented by an integer between 1 and 100, inclusive.\n\nSince he is forgetful, he might have bought more than one paint can in the same color.\nCount the number of different kinds of colors of these paint cans and tell him.\n\nConstraints\n\n1≦a,b,c≦100\n\nInput\n\nThe input is given from Standard Input in the following format:\n\na b c\n\nOutput\n\nPrint the number of different kinds of colors of the paint cans.\n\nSample Input 1\n\n3 1 4\n\nSample Output 1\n\n3\n\nThree different colors: 1, 3, and 4.\n\nSample Input 2\n\n3 3 33\n\nSample Output 2\n\n2\n\nTwo different colors: 3 and 33.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 222, "cpu_time_ms": 3, "memory_kb": 256}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s597156382", "group_id": "codeNet:p03963", "input_text": "a, b = io.read(\"*n\", \"*n\")\nr = b\nfor i = 2, a do\n r = r * (b - 1)\nend\nprint(r)\n", "language": "Lua", "metadata": {"date": 1589460707, "filename_ext": "lua", "original_language": "Lua (Lua 5.3.5)", "problem_description_relpath": "problem_descriptions/p03963.html", "problem_id": "p03963", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03963/input.txt", "sample_output_relpath": "derived/input_output/data/p03963/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03963/Lua/s597156382.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s597156382", "user_id": "u120582723"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "a, b = io.read(\"*n\", \"*n\")\nr = b\nfor i = 2, a do\n r = r * (b - 1)\nend\nprint(r)\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nThere are N balls placed in a row.\nAtCoDeer the deer is painting each of these in one of the K colors of his paint cans.\nFor aesthetic reasons, any two adjacent balls must be painted in different colors.\n\nFind the number of the possible ways to paint the balls.\n\nConstraints\n\n1≦N≦1000\n\n2≦K≦1000\n\nThe correct answer is at most 2^{31}-1.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN K\n\nOutput\n\nPrint the number of the possible ways to paint the balls.\n\nSample Input 1\n\n2 2\n\nSample Output 1\n\n2\n\nWe will denote the colors by 0 and 1. There are two possible ways: we can either paint the left ball in color 0 and the right ball in color 1, or paint the left in color 1 and the right in color 0.\n\nSample Input 2\n\n1 10\n\nSample Output 2\n\n10\n\nSince there is only one ball, we can use any of the ten colors to paint it. Thus, the answer is ten.", "sample_input": "2 2\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03963", "source_text": "Score : 200 points\n\nProblem Statement\n\nThere are N balls placed in a row.\nAtCoDeer the deer is painting each of these in one of the K colors of his paint cans.\nFor aesthetic reasons, any two adjacent balls must be painted in different colors.\n\nFind the number of the possible ways to paint the balls.\n\nConstraints\n\n1≦N≦1000\n\n2≦K≦1000\n\nThe correct answer is at most 2^{31}-1.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN K\n\nOutput\n\nPrint the number of the possible ways to paint the balls.\n\nSample Input 1\n\n2 2\n\nSample Output 1\n\n2\n\nWe will denote the colors by 0 and 1. There are two possible ways: we can either paint the left ball in color 0 and the right ball in color 1, or paint the left in color 1 and the right in color 0.\n\nSample Input 2\n\n1 10\n\nSample Output 2\n\n10\n\nSince there is only one ball, we can use any of the ten colors to paint it. Thus, the answer is ten.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 80, "cpu_time_ms": 5, "memory_kb": 2740}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s143432877", "group_id": "codeNet:p03963", "input_text": "local n, k = io.read(\"*n\", \"*n\")\nlocal r = k\nfor i = 1, n - 1 do\n r = r * (k - 1)\nend\nprint(r)\n", "language": "Lua", "metadata": {"date": 1565585404, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p03963.html", "problem_id": "p03963", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03963/input.txt", "sample_output_relpath": "derived/input_output/data/p03963/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03963/Lua/s143432877.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s143432877", "user_id": "u120582723"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "local n, k = io.read(\"*n\", \"*n\")\nlocal r = k\nfor i = 1, n - 1 do\n r = r * (k - 1)\nend\nprint(r)\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nThere are N balls placed in a row.\nAtCoDeer the deer is painting each of these in one of the K colors of his paint cans.\nFor aesthetic reasons, any two adjacent balls must be painted in different colors.\n\nFind the number of the possible ways to paint the balls.\n\nConstraints\n\n1≦N≦1000\n\n2≦K≦1000\n\nThe correct answer is at most 2^{31}-1.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN K\n\nOutput\n\nPrint the number of the possible ways to paint the balls.\n\nSample Input 1\n\n2 2\n\nSample Output 1\n\n2\n\nWe will denote the colors by 0 and 1. There are two possible ways: we can either paint the left ball in color 0 and the right ball in color 1, or paint the left in color 1 and the right in color 0.\n\nSample Input 2\n\n1 10\n\nSample Output 2\n\n10\n\nSince there is only one ball, we can use any of the ten colors to paint it. Thus, the answer is ten.", "sample_input": "2 2\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03963", "source_text": "Score : 200 points\n\nProblem Statement\n\nThere are N balls placed in a row.\nAtCoDeer the deer is painting each of these in one of the K colors of his paint cans.\nFor aesthetic reasons, any two adjacent balls must be painted in different colors.\n\nFind the number of the possible ways to paint the balls.\n\nConstraints\n\n1≦N≦1000\n\n2≦K≦1000\n\nThe correct answer is at most 2^{31}-1.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN K\n\nOutput\n\nPrint the number of the possible ways to paint the balls.\n\nSample Input 1\n\n2 2\n\nSample Output 1\n\n2\n\nWe will denote the colors by 0 and 1. There are two possible ways: we can either paint the left ball in color 0 and the right ball in color 1, or paint the left in color 1 and the right in color 0.\n\nSample Input 2\n\n1 10\n\nSample Output 2\n\n10\n\nSince there is only one ball, we can use any of the ten colors to paint it. Thus, the answer is ten.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 96, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s354382142", "group_id": "codeNet:p03972", "input_text": "local w, h = io.read(\"*n\", \"*n\")\nlocal lim = (w + 1) * (h + 1) - 1\nlocal cost = {}\nlocal idxs = {}\nfor i = 1, w + h do\n cost[i] = io.read(\"*n\")\n idxs[i] = i\nend\ntable.sort(idxs, function(a, b) return cost[a] > cost[b] end)\n\nlocal wuse, huse = 0, 0\nlocal cnt = 0\nlocal ret = 0LL\nwhile cnt < lim do\n local idx = idxs[#idxs]\n table.remove(idxs)\n local u = 0\n if idx <= w then\n wuse = wuse + 1\n u = h + 1 - huse\n else\n huse = huse + 1\n u = w + 1 - wuse\n end\n cnt = cnt + u\n ret = ret + cost[idx] * u\nend\nlocal str = tostring(ret):gsub(\"LL\", \"\")\nprint(str)\n", "language": "Lua", "metadata": {"date": 1568900753, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p03972.html", "problem_id": "p03972", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03972/input.txt", "sample_output_relpath": "derived/input_output/data/p03972/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03972/Lua/s354382142.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s354382142", "user_id": "u120582723"}, "prompt_components": {"gold_output": "29\n", "input_to_evaluate": "local w, h = io.read(\"*n\", \"*n\")\nlocal lim = (w + 1) * (h + 1) - 1\nlocal cost = {}\nlocal idxs = {}\nfor i = 1, w + h do\n cost[i] = io.read(\"*n\")\n idxs[i] = i\nend\ntable.sort(idxs, function(a, b) return cost[a] > cost[b] end)\n\nlocal wuse, huse = 0, 0\nlocal cnt = 0\nlocal ret = 0LL\nwhile cnt < lim do\n local idx = idxs[#idxs]\n table.remove(idxs)\n local u = 0\n if idx <= w then\n wuse = wuse + 1\n u = h + 1 - huse\n else\n huse = huse + 1\n u = w + 1 - wuse\n end\n cnt = cnt + u\n ret = ret + cost[idx] * u\nend\nlocal str = tostring(ret):gsub(\"LL\", \"\")\nprint(str)\n", "problem_context": "Score : 500 points\n\nProblem Statement\n\nOn an xy plane, in an area satisfying 0 ≤ x ≤ W, 0 ≤ y ≤ H, there is one house at each and every point where both x and y are integers.\n\nThere are unpaved roads between every pair of points for which either the x coordinates are equal and the difference between the y coordinates is 1, or the y coordinates are equal and the difference between the x coordinates is 1.\n\nThe cost of paving a road between houses on coordinates (i,j) and (i+1,j) is p_i for any value of j, while the cost of paving a road between houses on coordinates (i,j) and (i,j+1) is q_j for any value of i.\n\nMr. Takahashi wants to pave some of these roads and be able to travel between any two houses on paved roads only. Find the solution with the minimum total cost.\n\nConstraints\n\n1 ≦ W,H ≦ 10^5\n\n1 ≦ p_i ≦ 10^8(0 ≦ i ≦ W-1)\n\n1 ≦ q_j ≦ 10^8(0 ≦ j ≦ H-1)\n\np_i (0 ≦ i ≦ W−1) is an integer.\n\nq_j (0 ≦ j ≦ H−1) is an integer.\n\nInput\n\nInputs are provided from Standard Input in the following form.\n\nW H\np_0\n:\np_{W-1}\nq_0\n:\nq_{H-1}\n\nOutput\n\nOutput an integer representing the minimum total cost.\n\nSample Input 1\n\n2 2\n3\n5\n2\n7\n\nSample Output 1\n\n29\n\nIt is enough to pave the following eight roads.\n\nRoad connecting houses at (0,0) and (0,1)\n\nRoad connecting houses at (0,1) and (1,1)\n\nRoad connecting houses at (0,2) and (1,2)\n\nRoad connecting houses at (1,0) and (1,1)\n\nRoad connecting houses at (1,0) and (2,0)\n\nRoad connecting houses at (1,1) and (1,2)\n\nRoad connecting houses at (1,2) and (2,2)\n\nRoad connecting houses at (2,0) and (2,1)\n\nSample Input 2\n\n4 3\n2\n4\n8\n1\n2\n9\n3\n\nSample Output 2\n\n60", "sample_input": "2 2\n3\n5\n2\n7\n"}, "reference_outputs": ["29\n"], "source_document_id": "p03972", "source_text": "Score : 500 points\n\nProblem Statement\n\nOn an xy plane, in an area satisfying 0 ≤ x ≤ W, 0 ≤ y ≤ H, there is one house at each and every point where both x and y are integers.\n\nThere are unpaved roads between every pair of points for which either the x coordinates are equal and the difference between the y coordinates is 1, or the y coordinates are equal and the difference between the x coordinates is 1.\n\nThe cost of paving a road between houses on coordinates (i,j) and (i+1,j) is p_i for any value of j, while the cost of paving a road between houses on coordinates (i,j) and (i,j+1) is q_j for any value of i.\n\nMr. Takahashi wants to pave some of these roads and be able to travel between any two houses on paved roads only. Find the solution with the minimum total cost.\n\nConstraints\n\n1 ≦ W,H ≦ 10^5\n\n1 ≦ p_i ≦ 10^8(0 ≦ i ≦ W-1)\n\n1 ≦ q_j ≦ 10^8(0 ≦ j ≦ H-1)\n\np_i (0 ≦ i ≦ W−1) is an integer.\n\nq_j (0 ≦ j ≦ H−1) is an integer.\n\nInput\n\nInputs are provided from Standard Input in the following form.\n\nW H\np_0\n:\np_{W-1}\nq_0\n:\nq_{H-1}\n\nOutput\n\nOutput an integer representing the minimum total cost.\n\nSample Input 1\n\n2 2\n3\n5\n2\n7\n\nSample Output 1\n\n29\n\nIt is enough to pave the following eight roads.\n\nRoad connecting houses at (0,0) and (0,1)\n\nRoad connecting houses at (0,1) and (1,1)\n\nRoad connecting houses at (0,2) and (1,2)\n\nRoad connecting houses at (1,0) and (1,1)\n\nRoad connecting houses at (1,0) and (2,0)\n\nRoad connecting houses at (1,1) and (1,2)\n\nRoad connecting houses at (1,2) and (2,2)\n\nRoad connecting houses at (2,0) and (2,1)\n\nSample Input 2\n\n4 3\n2\n4\n8\n1\n2\n9\n3\n\nSample Output 2\n\n60", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 574, "cpu_time_ms": 672, "memory_kb": 9852}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s618769465", "group_id": "codeNet:p03973", "input_text": "local n = io.read(\"*n\")\nlocal a = io.read(\"*n\")\nlocal ret = a - 1\nlocal cur = 1\nfor i = 2, n do\n a = io.read(\"*n\")\n if a <= cur then\n -- nothing\n elseif a == cur + 1 then\n cur = cur + 1\n else\n ret = ret + (a - 1) // (cur + 1)\n end\nend\nprint(ret)\n", "language": "Lua", "metadata": {"date": 1569785306, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03973.html", "problem_id": "p03973", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03973/input.txt", "sample_output_relpath": "derived/input_output/data/p03973/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03973/Lua/s618769465.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s618769465", "user_id": "u120582723"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "local n = io.read(\"*n\")\nlocal a = io.read(\"*n\")\nlocal ret = a - 1\nlocal cur = 1\nfor i = 2, n do\n a = io.read(\"*n\")\n if a <= cur then\n -- nothing\n elseif a == cur + 1 then\n cur = cur + 1\n else\n ret = ret + (a - 1) // (cur + 1)\n end\nend\nprint(ret)\n", "problem_context": "Score : 700 points\n\nProblem Statement\n\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.\n\nMr. 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.\n\nAt 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.\n\nMr. Takahashi can set the value of positive integer P independently at each step.\n\nHe 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.\n\nHelp 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.\n\nConstraints\n\n1 ≦ | N | ≦ 100000\n\n1 ≦ A_i ≦ 10^9(1 ≦ i ≦ N)\n\nAll inputs are integers.\n\nInput\n\nInputs are provided from Standard Inputs in the following form.\n\nN\nA_1\n:\nA_N\n\nOutput\n\nOutput an integer representing the maximum number of products Mr. Takahashi can sell.\n\nSample Input 1\n\n3\n3\n2\n5\n\nSample Output 1\n\n3\n\nAs values of P, select in order 1, 4, 1.\n\nSample Input 2\n\n15\n3\n1\n4\n1\n5\n9\n2\n6\n5\n3\n5\n8\n9\n7\n9\n\nSample Output 2\n\n18", "sample_input": "3\n3\n2\n5\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03973", "source_text": "Score : 700 points\n\nProblem Statement\n\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.\n\nMr. 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.\n\nAt 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.\n\nMr. Takahashi can set the value of positive integer P independently at each step.\n\nHe 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.\n\nHelp 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.\n\nConstraints\n\n1 ≦ | N | ≦ 100000\n\n1 ≦ A_i ≦ 10^9(1 ≦ i ≦ N)\n\nAll inputs are integers.\n\nInput\n\nInputs are provided from Standard Inputs in the following form.\n\nN\nA_1\n:\nA_N\n\nOutput\n\nOutput an integer representing the maximum number of products Mr. Takahashi can sell.\n\nSample Input 1\n\n3\n3\n2\n5\n\nSample Output 1\n\n3\n\nAs values of P, select in order 1, 4, 1.\n\nSample Input 2\n\n15\n3\n1\n4\n1\n5\n9\n2\n6\n5\n3\n5\n8\n9\n7\n9\n\nSample Output 2\n\n18", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 260, "cpu_time_ms": 40, "memory_kb": 760}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s429326920", "group_id": "codeNet:p03975", "input_text": "n, a, b = io.read(\"*n\", \"*n\", \"*n\")\nc = 0\nfor i = 1, n do\n z = io.read(\"*n\")\n if z < a or b <= z then c = c + 1 end\nend\nprint(c)", "language": "Lua", "metadata": {"date": 1595855546, "filename_ext": "lua", "original_language": "Lua (Lua 5.3.5)", "problem_description_relpath": "problem_descriptions/p03975.html", "problem_id": "p03975", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03975/input.txt", "sample_output_relpath": "derived/input_output/data/p03975/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03975/Lua/s429326920.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s429326920", "user_id": "u120582723"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "n, a, b = io.read(\"*n\", \"*n\", \"*n\")\nc = 0\nfor i = 1, n do\n z = io.read(\"*n\")\n if z < a or b <= z then c = c + 1 end\nend\nprint(c)", "problem_context": "Score : 66 points\n\nProblem Statement\n\nSummer vacation ended at last and the second semester has begun.\nYou, a Kyoto University student, came to university and heard a rumor that somebody will barricade the entrance of your classroom.\nThe barricade will be built just before the start of the A-th class and removed by Kyoto University students just before the start of the B-th class.\nAll the classes conducted when the barricade is blocking the entrance will be cancelled and you will not be able to attend them.\nToday you take N classes and class i is conducted in the t_i-th period.\nYou take at most one class in each period.\nFind the number of classes you can attend.\n\nConstraints\n\n1 \\leq N \\leq 1000\n\n1 \\leq A < B \\leq 10^9\n\n1 \\leq t_i \\leq 10^9\n\nAll t_i values are distinct.\n\nInput\n\nN, A and B are given on the first line and t_i is given on the (i+1)-th line.\n\nN A B\nt1\n:\ntN\n\nOutput\n\nPrint the number of classes you can attend.\n\nSample Input 1\n\n5 5 9\n4\n3\n6\n9\n1\n\nSample Output 1\n\n4\n\nYou can not only attend the third class.\n\nSample Input 2\n\n5 4 9\n5\n6\n7\n8\n9\n\nSample Output 2\n\n1\n\nYou can only attend the fifth class.\n\nSample Input 3\n\n4 3 6\n9\n6\n8\n1\n\nSample Output 3\n\n4\n\nYou can attend all the classes.\n\nSample Input 4\n\n2 1 2\n1\n2\n\nSample Output 4\n\n1\n\nYou can not attend the first class, but can attend the second.", "sample_input": "5 5 9\n4\n3\n6\n9\n1\n"}, "reference_outputs": ["4\n"], "source_document_id": "p03975", "source_text": "Score : 66 points\n\nProblem Statement\n\nSummer vacation ended at last and the second semester has begun.\nYou, a Kyoto University student, came to university and heard a rumor that somebody will barricade the entrance of your classroom.\nThe barricade will be built just before the start of the A-th class and removed by Kyoto University students just before the start of the B-th class.\nAll the classes conducted when the barricade is blocking the entrance will be cancelled and you will not be able to attend them.\nToday you take N classes and class i is conducted in the t_i-th period.\nYou take at most one class in each period.\nFind the number of classes you can attend.\n\nConstraints\n\n1 \\leq N \\leq 1000\n\n1 \\leq A < B \\leq 10^9\n\n1 \\leq t_i \\leq 10^9\n\nAll t_i values are distinct.\n\nInput\n\nN, A and B are given on the first line and t_i is given on the (i+1)-th line.\n\nN A B\nt1\n:\ntN\n\nOutput\n\nPrint the number of classes you can attend.\n\nSample Input 1\n\n5 5 9\n4\n3\n6\n9\n1\n\nSample Output 1\n\n4\n\nYou can not only attend the third class.\n\nSample Input 2\n\n5 4 9\n5\n6\n7\n8\n9\n\nSample Output 2\n\n1\n\nYou can only attend the fifth class.\n\nSample Input 3\n\n4 3 6\n9\n6\n8\n1\n\nSample Output 3\n\n4\n\nYou can attend all the classes.\n\nSample Input 4\n\n2 1 2\n1\n2\n\nSample Output 4\n\n1\n\nYou can not attend the first class, but can attend the second.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 130, "cpu_time_ms": 4, "memory_kb": 2752}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s456906529", "group_id": "codeNet:p03976", "input_text": "local mma = math.max\nlocal mfl, mce, mmi = math.floor, math.ceil, math.min\n\nlocal AvlTree = {}\nAvlTree.makenode = function(self, val, parent)\n local i = self.box[#self.box]\n if not i then i = #self.v + 1\n else table.remove(self.box)\n end\n self.v[i], self.p[i] = val, parent\n self.lc[i], self.rc[i], self.l[i], self.r[i] = 0, 0, 1, 1\n return i\nend\nAvlTree.create = function(self, lessthan, n)\n self.lessthan = lessthan\n self.root = 1\n self.box = {}\n for i = n + 1, 2, -1 do table.insert(self.box, i) end\n -- value, leftCount, rightCount, left, right, parent\n self.v, self.lc, self.rc, self.l, self.r, self.p = {}, {}, {}, {}, {}, {}\n for i = 1, n + 1 do\n self.v[i], self.p[i] = 0, 1\n self.lc[i], self.rc[i], self.l[i], self.r[i] = 0, 0, 1, 1\n end\nend\n\nAvlTree.recalc = function(self, i)\n local kl, kr = self.l[i], self.r[i]\n if 1 < kl then self.lc[i] = 1 + mma(self.lc[kl], self.rc[kl])\n else self.lc[i] = 0\n end\n if 1 < kr then self.rc[i] = 1 + mma(self.lc[kr], self.rc[kr])\n else self.rc[i] = 0\n end\nend\nAvlTree.recalcAll = function(self, i)\n while 1 < i do\n self:recalc(i)\n i = self.p[i]\n end\nend\n\nAvlTree.rotR = function(self, parent)\n local granp, child = self.p[parent], self.l[parent]\n self.r[child], self.l[parent] = parent, self.r[child]\n self.p[child], self.p[parent] = granp, child\n self.p[self.l[parent]] = parent\n if 1 < granp then\n if self.l[granp] == parent then\n self.l[granp] = child\n else\n self.r[granp] = child\n end\n else\n self.root = child\n end\nend\n\nAvlTree.rotL = function(self, parent)\n local granp, child = self.p[parent], self.r[parent]\n self.l[child], self.r[parent] = parent, self.l[child]\n self.p[child], self.p[parent] = granp, child\n self.p[self.r[parent]] = parent\n if 1 < granp then\n if self.r[granp] == parent then\n self.r[granp] = child\n else\n self.l[granp] = child\n end\n else\n self.root = child\n end\nend\n\nAvlTree.rotLR = function(self, lparent, rparent)\n local sp, sl, sr = self.p, self.l, self.r\n local granp, d = sp[rparent], sr[lparent]\n sp[lparent], sr[lparent] = d, sl[d]\n sp[rparent], sl[rparent] = d, sr[d]\n sp[sl[d]], sp[sr[d]] = lparent, rparent\n sp[d], sl[d], sr[d] = granp, lparent, rparent\n if 1 < granp then\n if sr[granp] == rparent then sr[granp] = d\n else sl[granp] = d\n end\n else self.root = d\n end\nend\n\nAvlTree.rotRL = function(self, rparent, lparent)\n local sp, sl, sr = self.p, self.l, self.r\n local granp, d = sp[lparent], sl[rparent]\n sp[rparent], sl[rparent] = d, sr[d]\n sp[lparent], sr[lparent] = d, sl[d]\n sp[sr[d]], sp[sl[d]] = rparent, lparent\n sp[d], sr[d], sl[d] = granp, rparent, lparent\n if 1 < granp then\n if sl[granp] == lparent then sl[granp] = d\n else sr[granp] = d\n end\n else self.root = d\n end\nend\n\nAvlTree.empty = function(self) return self.root <= 1 end\n\nAvlTree.push = function(self, val)\n if self.root <= 1 then self.root = self:makenode(val, 1) return end\n local pos = self.root\n while true do\n if self.lessthan(val, self.v[pos]) then\n if 1 < self.l[pos] then\n pos = self.l[pos]\n else\n self.l[pos] = self:makenode(val, pos)\n pos = self.l[pos]\n break\n end\n else\n if 1 < self.r[pos] then\n pos = self.r[pos]\n else\n self.r[pos] = self:makenode(val, pos)\n pos = self.r[pos]\n break\n end\n end\n end\n while 1 < pos do\n local child, parent = pos, self.p[pos]\n if parent <= 1 then\n break\n end\n self:recalc(parent)\n local lcp_m_rcp = self.lc[parent] - self.rc[parent]\n if lcp_m_rcp % 2 ~= 0 then -- 1 or -1\n pos = parent\n elseif lcp_m_rcp == 2 then\n if self.lc[child] - 1 == self.rc[child] then\n self:rotR(parent)\n self:recalcAll(parent)\n else\n self:rotLR(child, parent)\n self:recalc(child)\n self:recalcAll(parent)\n end\n break\n elseif lcp_m_rcp == -2 then\n if self.rc[child] - 1 == self.lc[child] then\n self:rotL(parent)\n self:recalcAll(parent)\n else\n self:rotRL(child, parent)\n self:recalc(child)\n self:recalcAll(parent)\n end\n break\n else\n break\n end\n end\nend\n\nAvlTree.rmsub = function(self, node)\n while 1 < node do\n self:recalc(node)\n if self.lc[node] == self.rc[node] then\n node = self.p[node]\n elseif self.lc[node] + 1 == self.rc[node] then\n self:recalcAll(self.p[node])\n break\n else\n if self.lc[self.r[node]] == self.rc[self.r[node]] then\n self:rotL(node)\n self:recalcAll(node)\n break\n elseif self.lc[self.r[node]] + 1 == self.rc[self.r[node]] then\n local nr = self.r[node]\n self:rotL(node)\n self:recalc(node)\n node = nr\n else\n local nr = self.r[node]\n local nrl = self.l[nr]\n self:rotRL(nr, node)\n self:recalc(nr)\n self:recalc(node)\n node = nrl\n end\n end\n end\nend\n\nAvlTree.pop = function(self)\n local node = self.root\n while 1 < self.l[node] do\n node = self.l[node]\n end\n local v = self.v[node]\n local kp = self.p[node]\n self.p[self.r[node]] = kp\n if 1 < kp then\n self.l[kp] = self.r[node]\n self:rmsub(kp)\n else\n self.root = self.r[node]\n end\n table.insert(self.box, node)\n return v\nend\n\nAvlTree.new = function(lessthan, n)\n local obj = {}\n setmetatable(obj, {__index = AvlTree})\n obj:create(lessthan, n)\n return obj\nend\n\nlocal n, k = io.read(\"*n\", \"*n\", \"*l\")\nlocal t = {}\nfor i = 1, 26 do\n t[i] = 0\nend\nfor i = 1, n do\n local s = io.read():byte(1) - 64\n t[s] = t[s] + 1\nend\nlocal avl = AvlTree.new(function(a, b) return t[a] > t[b] end, 1)\nfor i = 1, 26 do\n if 0 < t[i] then\n avl:push(i)\n end\nend\nlocal ret = 0\nlocal z = {}\nwhile true do\n local valid = true\n for i = 1, k do\n if avl:empty() then valid = false break end\n z[i] = avl:pop()\n end\n if not valid then break end\n ret = ret + 1\n for i = 1, k do\n t[z[i]] = t[z[i]] - 1\n if 0 < t[z[i]] then\n avl:push(z[i])\n end\n end\nend\nprint(ret)\n", "language": "Lua", "metadata": {"date": 1599744958, "filename_ext": "lua", "original_language": "Lua (LuaJIT 2.1.0)", "problem_description_relpath": "problem_descriptions/p03976.html", "problem_id": "p03976", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03976/input.txt", "sample_output_relpath": "derived/input_output/data/p03976/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03976/Lua/s456906529.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s456906529", "user_id": "u120582723"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "local mma = math.max\nlocal mfl, mce, mmi = math.floor, math.ceil, math.min\n\nlocal AvlTree = {}\nAvlTree.makenode = function(self, val, parent)\n local i = self.box[#self.box]\n if not i then i = #self.v + 1\n else table.remove(self.box)\n end\n self.v[i], self.p[i] = val, parent\n self.lc[i], self.rc[i], self.l[i], self.r[i] = 0, 0, 1, 1\n return i\nend\nAvlTree.create = function(self, lessthan, n)\n self.lessthan = lessthan\n self.root = 1\n self.box = {}\n for i = n + 1, 2, -1 do table.insert(self.box, i) end\n -- value, leftCount, rightCount, left, right, parent\n self.v, self.lc, self.rc, self.l, self.r, self.p = {}, {}, {}, {}, {}, {}\n for i = 1, n + 1 do\n self.v[i], self.p[i] = 0, 1\n self.lc[i], self.rc[i], self.l[i], self.r[i] = 0, 0, 1, 1\n end\nend\n\nAvlTree.recalc = function(self, i)\n local kl, kr = self.l[i], self.r[i]\n if 1 < kl then self.lc[i] = 1 + mma(self.lc[kl], self.rc[kl])\n else self.lc[i] = 0\n end\n if 1 < kr then self.rc[i] = 1 + mma(self.lc[kr], self.rc[kr])\n else self.rc[i] = 0\n end\nend\nAvlTree.recalcAll = function(self, i)\n while 1 < i do\n self:recalc(i)\n i = self.p[i]\n end\nend\n\nAvlTree.rotR = function(self, parent)\n local granp, child = self.p[parent], self.l[parent]\n self.r[child], self.l[parent] = parent, self.r[child]\n self.p[child], self.p[parent] = granp, child\n self.p[self.l[parent]] = parent\n if 1 < granp then\n if self.l[granp] == parent then\n self.l[granp] = child\n else\n self.r[granp] = child\n end\n else\n self.root = child\n end\nend\n\nAvlTree.rotL = function(self, parent)\n local granp, child = self.p[parent], self.r[parent]\n self.l[child], self.r[parent] = parent, self.l[child]\n self.p[child], self.p[parent] = granp, child\n self.p[self.r[parent]] = parent\n if 1 < granp then\n if self.r[granp] == parent then\n self.r[granp] = child\n else\n self.l[granp] = child\n end\n else\n self.root = child\n end\nend\n\nAvlTree.rotLR = function(self, lparent, rparent)\n local sp, sl, sr = self.p, self.l, self.r\n local granp, d = sp[rparent], sr[lparent]\n sp[lparent], sr[lparent] = d, sl[d]\n sp[rparent], sl[rparent] = d, sr[d]\n sp[sl[d]], sp[sr[d]] = lparent, rparent\n sp[d], sl[d], sr[d] = granp, lparent, rparent\n if 1 < granp then\n if sr[granp] == rparent then sr[granp] = d\n else sl[granp] = d\n end\n else self.root = d\n end\nend\n\nAvlTree.rotRL = function(self, rparent, lparent)\n local sp, sl, sr = self.p, self.l, self.r\n local granp, d = sp[lparent], sl[rparent]\n sp[rparent], sl[rparent] = d, sr[d]\n sp[lparent], sr[lparent] = d, sl[d]\n sp[sr[d]], sp[sl[d]] = rparent, lparent\n sp[d], sr[d], sl[d] = granp, rparent, lparent\n if 1 < granp then\n if sl[granp] == lparent then sl[granp] = d\n else sr[granp] = d\n end\n else self.root = d\n end\nend\n\nAvlTree.empty = function(self) return self.root <= 1 end\n\nAvlTree.push = function(self, val)\n if self.root <= 1 then self.root = self:makenode(val, 1) return end\n local pos = self.root\n while true do\n if self.lessthan(val, self.v[pos]) then\n if 1 < self.l[pos] then\n pos = self.l[pos]\n else\n self.l[pos] = self:makenode(val, pos)\n pos = self.l[pos]\n break\n end\n else\n if 1 < self.r[pos] then\n pos = self.r[pos]\n else\n self.r[pos] = self:makenode(val, pos)\n pos = self.r[pos]\n break\n end\n end\n end\n while 1 < pos do\n local child, parent = pos, self.p[pos]\n if parent <= 1 then\n break\n end\n self:recalc(parent)\n local lcp_m_rcp = self.lc[parent] - self.rc[parent]\n if lcp_m_rcp % 2 ~= 0 then -- 1 or -1\n pos = parent\n elseif lcp_m_rcp == 2 then\n if self.lc[child] - 1 == self.rc[child] then\n self:rotR(parent)\n self:recalcAll(parent)\n else\n self:rotLR(child, parent)\n self:recalc(child)\n self:recalcAll(parent)\n end\n break\n elseif lcp_m_rcp == -2 then\n if self.rc[child] - 1 == self.lc[child] then\n self:rotL(parent)\n self:recalcAll(parent)\n else\n self:rotRL(child, parent)\n self:recalc(child)\n self:recalcAll(parent)\n end\n break\n else\n break\n end\n end\nend\n\nAvlTree.rmsub = function(self, node)\n while 1 < node do\n self:recalc(node)\n if self.lc[node] == self.rc[node] then\n node = self.p[node]\n elseif self.lc[node] + 1 == self.rc[node] then\n self:recalcAll(self.p[node])\n break\n else\n if self.lc[self.r[node]] == self.rc[self.r[node]] then\n self:rotL(node)\n self:recalcAll(node)\n break\n elseif self.lc[self.r[node]] + 1 == self.rc[self.r[node]] then\n local nr = self.r[node]\n self:rotL(node)\n self:recalc(node)\n node = nr\n else\n local nr = self.r[node]\n local nrl = self.l[nr]\n self:rotRL(nr, node)\n self:recalc(nr)\n self:recalc(node)\n node = nrl\n end\n end\n end\nend\n\nAvlTree.pop = function(self)\n local node = self.root\n while 1 < self.l[node] do\n node = self.l[node]\n end\n local v = self.v[node]\n local kp = self.p[node]\n self.p[self.r[node]] = kp\n if 1 < kp then\n self.l[kp] = self.r[node]\n self:rmsub(kp)\n else\n self.root = self.r[node]\n end\n table.insert(self.box, node)\n return v\nend\n\nAvlTree.new = function(lessthan, n)\n local obj = {}\n setmetatable(obj, {__index = AvlTree})\n obj:create(lessthan, n)\n return obj\nend\n\nlocal n, k = io.read(\"*n\", \"*n\", \"*l\")\nlocal t = {}\nfor i = 1, 26 do\n t[i] = 0\nend\nfor i = 1, n do\n local s = io.read():byte(1) - 64\n t[s] = t[s] + 1\nend\nlocal avl = AvlTree.new(function(a, b) return t[a] > t[b] end, 1)\nfor i = 1, 26 do\n if 0 < t[i] then\n avl:push(i)\n end\nend\nlocal ret = 0\nlocal z = {}\nwhile true do\n local valid = true\n for i = 1, k do\n if avl:empty() then valid = false break end\n z[i] = avl:pop()\n end\n if not valid then break end\n ret = ret + 1\n for i = 1, k do\n t[z[i]] = t[z[i]] - 1\n if 0 < t[z[i]] then\n avl:push(z[i])\n end\n end\nend\nprint(ret)\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nKyoto University Programming Contest is a programming contest voluntarily held by some Kyoto University students.\nThis contest is abbreviated as Kyoto University Programming Contest and called KUPC.\n\nsource: Kyoto University Programming Contest Information\n\nThe problem-preparing committee met to hold this year's KUPC and N problems were proposed there.\nThe problems are numbered from 1 to N and the name of i-th problem is P_i.\nHowever, since they proposed too many problems, they decided to divide them into some sets for several contests.\n\nThey decided to divide this year's KUPC into several KUPCs by dividing problems under the following conditions.\n\nOne KUPC provides K problems.\n\nEach problem appears at most once among all the KUPCs.\n\nAll the first letters of the problem names in one KUPC must be different.\n\nYou, one of the committee members, want to hold as many KUPCs as possible.\nWrite a program to find the maximum number of KUPCs that can be held this year.\n\nConstraints\n\n1 \\leq N \\leq 10^4\n\n1 \\leq K \\leq 26\n\n1 \\leq |P_i| \\leq 10\n\nAll characters in P_i are capital letters.\n\nNote that, for each i and j (1 \\leq i < j \\leq N),\nP_i \\neq P_j are not necessarily satisfied.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN K\nP_1\n:\nP_N\n\nOutput\n\nPrint the maximum number of KUPCs that can be held on one line.\n\nSample Input 1\n\n9 3\nAPPLE\nANT\nATCODER\nBLOCK\nBULL\nBOSS\nCAT\nDOG\nEGG\n\nFor example, three KUPCs can be held by dividing the problems as follows.\n\nFirst: APPLE, BLOCK, CAT\n\nSecond: ANT, BULL, DOG\n\nThird: ATCODER, BOSS, EGG\n\nSample Output 1\n\n3\n\nSample Input 2\n\n3 2\nKU\nKYOUDAI\nKYOTOUNIV\n\nSample Output 2\n\n0\n\nNo KUPC can be held.", "sample_input": "9 3\nAPPLE\nANT\nATCODER\nBLOCK\nBULL\nBOSS\nCAT\nDOG\nEGG\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03976", "source_text": "Score : 100 points\n\nProblem Statement\n\nKyoto University Programming Contest is a programming contest voluntarily held by some Kyoto University students.\nThis contest is abbreviated as Kyoto University Programming Contest and called KUPC.\n\nsource: Kyoto University Programming Contest Information\n\nThe problem-preparing committee met to hold this year's KUPC and N problems were proposed there.\nThe problems are numbered from 1 to N and the name of i-th problem is P_i.\nHowever, since they proposed too many problems, they decided to divide them into some sets for several contests.\n\nThey decided to divide this year's KUPC into several KUPCs by dividing problems under the following conditions.\n\nOne KUPC provides K problems.\n\nEach problem appears at most once among all the KUPCs.\n\nAll the first letters of the problem names in one KUPC must be different.\n\nYou, one of the committee members, want to hold as many KUPCs as possible.\nWrite a program to find the maximum number of KUPCs that can be held this year.\n\nConstraints\n\n1 \\leq N \\leq 10^4\n\n1 \\leq K \\leq 26\n\n1 \\leq |P_i| \\leq 10\n\nAll characters in P_i are capital letters.\n\nNote that, for each i and j (1 \\leq i < j \\leq N),\nP_i \\neq P_j are not necessarily satisfied.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN K\nP_1\n:\nP_N\n\nOutput\n\nPrint the maximum number of KUPCs that can be held on one line.\n\nSample Input 1\n\n9 3\nAPPLE\nANT\nATCODER\nBLOCK\nBULL\nBOSS\nCAT\nDOG\nEGG\n\nFor example, three KUPCs can be held by dividing the problems as follows.\n\nFirst: APPLE, BLOCK, CAT\n\nSecond: ANT, BULL, DOG\n\nThird: ATCODER, BOSS, EGG\n\nSample Output 1\n\n3\n\nSample Input 2\n\n3 2\nKU\nKYOUDAI\nKYOTOUNIV\n\nSample Output 2\n\n0\n\nNo KUPC can be held.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 6051, "cpu_time_ms": 20, "memory_kb": 2984}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s201883144", "group_id": "codeNet:p03986", "input_text": "local x=io.read()\nlocal s,st=0,0\nfor i=1,#x do\n if x:sub(i,i)==\"S\" then\n s=s+1\n else\n if 0=27-a and a>1 then\n sable[i]=string.char(97)\n k=k-(27-a)\n elseif i==#s then\n sable[i]=string.char((sable[i]+k)%27+96)\n else\n sable[i]=string.char(sable[i]+96)\n end\nend\nprint(table.concat(sable,\"\"))", "language": "Lua", "metadata": {"date": 1593659417, "filename_ext": "lua", "original_language": "Lua (LuaJIT 2.1.0)", "problem_description_relpath": "problem_descriptions/p03994.html", "problem_id": "p03994", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03994/input.txt", "sample_output_relpath": "derived/input_output/data/p03994/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03994/Lua/s681354990.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s681354990", "user_id": "u045238009"}, "prompt_components": {"gold_output": "aya\n", "input_to_evaluate": "local s=io.read()\nlocal sable={}\nfor i=1,#s do\n sable[i]=s:byte(i)-96\nend\nlocal k=io.read(\"n\")\nfor i=1,#s do\n local a=sable[i]\n if k>=27-a and a>1 then\n sable[i]=string.char(97)\n k=k-(27-a)\n elseif i==#s then\n sable[i]=string.char((sable[i]+k)%27+96)\n else\n sable[i]=string.char(sable[i]+96)\n end\nend\nprint(table.concat(sable,\"\"))", "problem_context": "Score : 400 points\n\nProblem Statement\n\nMr. Takahashi has a string s consisting of lowercase English letters.\nHe repeats the following operation on s exactly K times.\n\nChoose an arbitrary letter on s and change that letter to the next alphabet. Note that the next letter of z is a.\n\nFor example, if you perform an operation for the second letter on aaz, aaz becomes abz.\nIf you then perform an operation for the third letter on abz, abz becomes aba.\n\nMr. Takahashi wants to have the lexicographically smallest string after performing exactly K operations on s.\nFind the such string.\n\nConstraints\n\n1≤|s|≤10^5\n\nAll letters in s are lowercase English letters.\n\n1≤K≤10^9\n\nInput\n\nThe input is given from Standard Input in the following format:\n\ns\nK\n\nOutput\n\nPrint the lexicographically smallest string after performing exactly K operations on s.\n\nSample Input 1\n\nxyz\n4\n\nSample Output 1\n\naya\n\nFor example, you can perform the following operations: xyz, yyz, zyz, ayz, aya.\n\nSample Input 2\n\na\n25\n\nSample Output 2\n\nz\n\nYou have to perform exactly K operations.\n\nSample Input 3\n\ncodefestival\n100\n\nSample Output 3\n\naaaafeaaivap", "sample_input": "xyz\n4\n"}, "reference_outputs": ["aya\n"], "source_document_id": "p03994", "source_text": "Score : 400 points\n\nProblem Statement\n\nMr. Takahashi has a string s consisting of lowercase English letters.\nHe repeats the following operation on s exactly K times.\n\nChoose an arbitrary letter on s and change that letter to the next alphabet. Note that the next letter of z is a.\n\nFor example, if you perform an operation for the second letter on aaz, aaz becomes abz.\nIf you then perform an operation for the third letter on abz, abz becomes aba.\n\nMr. Takahashi wants to have the lexicographically smallest string after performing exactly K operations on s.\nFind the such string.\n\nConstraints\n\n1≤|s|≤10^5\n\nAll letters in s are lowercase English letters.\n\n1≤K≤10^9\n\nInput\n\nThe input is given from Standard Input in the following format:\n\ns\nK\n\nOutput\n\nPrint the lexicographically smallest string after performing exactly K operations on s.\n\nSample Input 1\n\nxyz\n4\n\nSample Output 1\n\naya\n\nFor example, you can perform the following operations: xyz, yyz, zyz, ayz, aya.\n\nSample Input 2\n\na\n25\n\nSample Output 2\n\nz\n\nYou have to perform exactly K operations.\n\nSample Input 3\n\ncodefestival\n100\n\nSample Output 3\n\naaaafeaaivap", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 376, "cpu_time_ms": 16, "memory_kb": 3932}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s161175509", "group_id": "codeNet:p03997", "input_text": "a = io.read(\"*n\")\nb, c = io.read(\"*n\", \"*n\")\nprint((a + b) * c // 2)", "language": "Lua", "metadata": {"date": 1560227278, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03997.html", "problem_id": "p03997", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03997/input.txt", "sample_output_relpath": "derived/input_output/data/p03997/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03997/Lua/s161175509.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s161175509", "user_id": "u120582723"}, "prompt_components": {"gold_output": "7\n", "input_to_evaluate": "a = io.read(\"*n\")\nb, c = io.read(\"*n\", \"*n\")\nprint((a + b) * c // 2)", "problem_context": "Score : 100 points\n\nProblem Statement\n\nYou are given a trapezoid. The lengths of its upper base, lower base, and height are a, b, and h, respectively.\n\nAn example of a trapezoid\n\nFind the area of this trapezoid.\n\nConstraints\n\n1≦a≦100\n\n1≦b≦100\n\n1≦h≦100\n\nAll input values are integers.\n\nh is even.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\na\nb\nh\n\nOutput\n\nPrint the area of the given trapezoid. It is guaranteed that the area is an integer.\n\nSample Input 1\n\n3\n4\n2\n\nSample Output 1\n\n7\n\nWhen the lengths of the upper base, lower base, and height are 3, 4, and 2, respectively, the area of the trapezoid is (3+4)×2/2 = 7.\n\nSample Input 2\n\n4\n4\n4\n\nSample Output 2\n\n16\n\nIn this case, a parallelogram is given, which is also a trapezoid.", "sample_input": "3\n4\n2\n"}, "reference_outputs": ["7\n"], "source_document_id": "p03997", "source_text": "Score : 100 points\n\nProblem Statement\n\nYou are given a trapezoid. The lengths of its upper base, lower base, and height are a, b, and h, respectively.\n\nAn example of a trapezoid\n\nFind the area of this trapezoid.\n\nConstraints\n\n1≦a≦100\n\n1≦b≦100\n\n1≦h≦100\n\nAll input values are integers.\n\nh is even.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\na\nb\nh\n\nOutput\n\nPrint the area of the given trapezoid. It is guaranteed that the area is an integer.\n\nSample Input 1\n\n3\n4\n2\n\nSample Output 1\n\n7\n\nWhen the lengths of the upper base, lower base, and height are 3, 4, and 2, respectively, the area of the trapezoid is (3+4)×2/2 = 7.\n\nSample Input 2\n\n4\n4\n4\n\nSample Output 2\n\n16\n\nIn this case, a parallelogram is given, which is also a trapezoid.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 68, "cpu_time_ms": 8, "memory_kb": 888}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s052023994", "group_id": "codeNet:p03998", "input_text": "local S={}\nS[\"a\"]=io.read()\nS[\"b\"]=io.read()\nS[\"c\"]=io.read()\n\nlocal discard=\"a\"\nwhile S[\"a\"]~=\"\" and S[\"b\"]~=\"\" and S[\"c\"]~=\"\" do\n discard=S[discard]:sub(1,1)\n S[discard]=S[discard]:sub(2,#S[discard])\n if S[discard]==\"\" then\n print(discard:upper())\n break\n end\nend", "language": "Lua", "metadata": {"date": 1590288749, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03998.html", "problem_id": "p03998", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03998/input.txt", "sample_output_relpath": "derived/input_output/data/p03998/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03998/Lua/s052023994.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s052023994", "user_id": "u045238009"}, "prompt_components": {"gold_output": "A\n", "input_to_evaluate": "local S={}\nS[\"a\"]=io.read()\nS[\"b\"]=io.read()\nS[\"c\"]=io.read()\n\nlocal discard=\"a\"\nwhile S[\"a\"]~=\"\" and S[\"b\"]~=\"\" and S[\"c\"]~=\"\" do\n discard=S[discard]:sub(1,1)\n S[discard]=S[discard]:sub(2,#S[discard])\n if S[discard]==\"\" then\n print(discard:upper())\n break\n end\nend", "problem_context": "Score : 200 points\n\nProblem Statement\n\nAlice, Bob and Charlie are playing Card Game for Three, as below:\n\nAt first, each of the three players has a deck consisting of some number of cards. Each card has a letter a, b or c written on it. The orders of the cards in the decks cannot be rearranged.\n\nThe players take turns. Alice goes first.\n\nIf the current player's deck contains at least one card, discard the top card in the deck. Then, the player whose name begins with the letter on the discarded card, takes the next turn. (For example, if the card says a, Alice takes the next turn.)\n\nIf the current player's deck is empty, the game ends and the current player wins the game.\n\nYou are given the initial decks of the players.\nMore specifically, you are given three strings S_A, S_B and S_C. The i-th (1≦i≦|S_A|) letter in S_A is the letter on the i-th card in Alice's initial deck. S_B and S_C describes Bob's and Charlie's initial decks in the same way.\n\nDetermine the winner of the game.\n\nConstraints\n\n1≦|S_A|≦100\n\n1≦|S_B|≦100\n\n1≦|S_C|≦100\n\nEach letter in S_A, S_B, S_C is a, b or c.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nS_A\nS_B\nS_C\n\nOutput\n\nIf Alice will win, print A. If Bob will win, print B. If Charlie will win, print C.\n\nSample Input 1\n\naca\naccc\nca\n\nSample Output 1\n\nA\n\nThe game will progress as below:\n\nAlice discards the top card in her deck, a. Alice takes the next turn.\n\nAlice discards the top card in her deck, c. Charlie takes the next turn.\n\nCharlie discards the top card in his deck, c. Charlie takes the next turn.\n\nCharlie discards the top card in his deck, a. Alice takes the next turn.\n\nAlice discards the top card in her deck, a. Alice takes the next turn.\n\nAlice's deck is empty. The game ends and Alice wins the game.\n\nSample Input 2\n\nabcb\naacb\nbccc\n\nSample Output 2\n\nC", "sample_input": "aca\naccc\nca\n"}, "reference_outputs": ["A\n"], "source_document_id": "p03998", "source_text": "Score : 200 points\n\nProblem Statement\n\nAlice, Bob and Charlie are playing Card Game for Three, as below:\n\nAt first, each of the three players has a deck consisting of some number of cards. Each card has a letter a, b or c written on it. The orders of the cards in the decks cannot be rearranged.\n\nThe players take turns. Alice goes first.\n\nIf the current player's deck contains at least one card, discard the top card in the deck. Then, the player whose name begins with the letter on the discarded card, takes the next turn. (For example, if the card says a, Alice takes the next turn.)\n\nIf the current player's deck is empty, the game ends and the current player wins the game.\n\nYou are given the initial decks of the players.\nMore specifically, you are given three strings S_A, S_B and S_C. The i-th (1≦i≦|S_A|) letter in S_A is the letter on the i-th card in Alice's initial deck. S_B and S_C describes Bob's and Charlie's initial decks in the same way.\n\nDetermine the winner of the game.\n\nConstraints\n\n1≦|S_A|≦100\n\n1≦|S_B|≦100\n\n1≦|S_C|≦100\n\nEach letter in S_A, S_B, S_C is a, b or c.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nS_A\nS_B\nS_C\n\nOutput\n\nIf Alice will win, print A. If Bob will win, print B. If Charlie will win, print C.\n\nSample Input 1\n\naca\naccc\nca\n\nSample Output 1\n\nA\n\nThe game will progress as below:\n\nAlice discards the top card in her deck, a. Alice takes the next turn.\n\nAlice discards the top card in her deck, c. Charlie takes the next turn.\n\nCharlie discards the top card in his deck, c. Charlie takes the next turn.\n\nCharlie discards the top card in his deck, a. Alice takes the next turn.\n\nAlice discards the top card in her deck, a. Alice takes the next turn.\n\nAlice's deck is empty. The game ends and Alice wins the game.\n\nSample Input 2\n\nabcb\naacb\nbccc\n\nSample Output 2\n\nC", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 291, "cpu_time_ms": 8, "memory_kb": 880}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s430700603", "group_id": "codeNet:p03998", "input_text": "sa = io.read()\nsb = io.read()\nsc = io.read()\nlocal ta, tb, tc = 1, 1, 1\ncur = \"a\"\nwhile true do\n if cur == \"a\" then\n if #sa < ta then\n print(\"A\") os.exit()\n end\n cur = sa:sub(ta, ta)\n ta = ta + 1\n elseif cur == \"b\" then\n if #sb < tb then\n print(\"B\") os.exit()\n end\n cur = sb:sub(tb, tb)\n tb = tb + 1\n else\n if #sc < tc then\n print(\"C\") os.exit()\n end\n cur = sc:sub(tc, tc)\n tc = tc + 1\n end\nend\n", "language": "Lua", "metadata": {"date": 1589597545, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p03998.html", "problem_id": "p03998", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03998/input.txt", "sample_output_relpath": "derived/input_output/data/p03998/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03998/Lua/s430700603.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s430700603", "user_id": "u120582723"}, "prompt_components": {"gold_output": "A\n", "input_to_evaluate": "sa = io.read()\nsb = io.read()\nsc = io.read()\nlocal ta, tb, tc = 1, 1, 1\ncur = \"a\"\nwhile true do\n if cur == \"a\" then\n if #sa < ta then\n print(\"A\") os.exit()\n end\n cur = sa:sub(ta, ta)\n ta = ta + 1\n elseif cur == \"b\" then\n if #sb < tb then\n print(\"B\") os.exit()\n end\n cur = sb:sub(tb, tb)\n tb = tb + 1\n else\n if #sc < tc then\n print(\"C\") os.exit()\n end\n cur = sc:sub(tc, tc)\n tc = tc + 1\n end\nend\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nAlice, Bob and Charlie are playing Card Game for Three, as below:\n\nAt first, each of the three players has a deck consisting of some number of cards. Each card has a letter a, b or c written on it. The orders of the cards in the decks cannot be rearranged.\n\nThe players take turns. Alice goes first.\n\nIf the current player's deck contains at least one card, discard the top card in the deck. Then, the player whose name begins with the letter on the discarded card, takes the next turn. (For example, if the card says a, Alice takes the next turn.)\n\nIf the current player's deck is empty, the game ends and the current player wins the game.\n\nYou are given the initial decks of the players.\nMore specifically, you are given three strings S_A, S_B and S_C. The i-th (1≦i≦|S_A|) letter in S_A is the letter on the i-th card in Alice's initial deck. S_B and S_C describes Bob's and Charlie's initial decks in the same way.\n\nDetermine the winner of the game.\n\nConstraints\n\n1≦|S_A|≦100\n\n1≦|S_B|≦100\n\n1≦|S_C|≦100\n\nEach letter in S_A, S_B, S_C is a, b or c.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nS_A\nS_B\nS_C\n\nOutput\n\nIf Alice will win, print A. If Bob will win, print B. If Charlie will win, print C.\n\nSample Input 1\n\naca\naccc\nca\n\nSample Output 1\n\nA\n\nThe game will progress as below:\n\nAlice discards the top card in her deck, a. Alice takes the next turn.\n\nAlice discards the top card in her deck, c. Charlie takes the next turn.\n\nCharlie discards the top card in his deck, c. Charlie takes the next turn.\n\nCharlie discards the top card in his deck, a. Alice takes the next turn.\n\nAlice discards the top card in her deck, a. Alice takes the next turn.\n\nAlice's deck is empty. The game ends and Alice wins the game.\n\nSample Input 2\n\nabcb\naacb\nbccc\n\nSample Output 2\n\nC", "sample_input": "aca\naccc\nca\n"}, "reference_outputs": ["A\n"], "source_document_id": "p03998", "source_text": "Score : 200 points\n\nProblem Statement\n\nAlice, Bob and Charlie are playing Card Game for Three, as below:\n\nAt first, each of the three players has a deck consisting of some number of cards. Each card has a letter a, b or c written on it. The orders of the cards in the decks cannot be rearranged.\n\nThe players take turns. Alice goes first.\n\nIf the current player's deck contains at least one card, discard the top card in the deck. Then, the player whose name begins with the letter on the discarded card, takes the next turn. (For example, if the card says a, Alice takes the next turn.)\n\nIf the current player's deck is empty, the game ends and the current player wins the game.\n\nYou are given the initial decks of the players.\nMore specifically, you are given three strings S_A, S_B and S_C. The i-th (1≦i≦|S_A|) letter in S_A is the letter on the i-th card in Alice's initial deck. S_B and S_C describes Bob's and Charlie's initial decks in the same way.\n\nDetermine the winner of the game.\n\nConstraints\n\n1≦|S_A|≦100\n\n1≦|S_B|≦100\n\n1≦|S_C|≦100\n\nEach letter in S_A, S_B, S_C is a, b or c.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nS_A\nS_B\nS_C\n\nOutput\n\nIf Alice will win, print A. If Bob will win, print B. If Charlie will win, print C.\n\nSample Input 1\n\naca\naccc\nca\n\nSample Output 1\n\nA\n\nThe game will progress as below:\n\nAlice discards the top card in her deck, a. Alice takes the next turn.\n\nAlice discards the top card in her deck, c. Charlie takes the next turn.\n\nCharlie discards the top card in his deck, c. Charlie takes the next turn.\n\nCharlie discards the top card in his deck, a. Alice takes the next turn.\n\nAlice discards the top card in her deck, a. Alice takes the next turn.\n\nAlice's deck is empty. The game ends and Alice wins the game.\n\nSample Input 2\n\nabcb\naacb\nbccc\n\nSample Output 2\n\nC", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 450, "cpu_time_ms": 8, "memory_kb": 888}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s067919194", "group_id": "codeNet:p03998", "input_text": "local tgt = 1\nlocal strs = {}\nlocal pos = {1, 1, 1}\nlocal tmp = \"\"\nfor i = 1, 3 do strs[i] = io.read() end\nwhile pos[tgt] <= #(strs[tgt]) do\n tmp = strs[tgt]:sub(pos[tgt], pos[tgt])\n pos[tgt] = pos[tgt] + 1\n tgt = string.byte(tmp) - 96\nend\nprint(string.char(tgt + 64))\n", "language": "Lua", "metadata": {"date": 1558665812, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p03998.html", "problem_id": "p03998", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03998/input.txt", "sample_output_relpath": "derived/input_output/data/p03998/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03998/Lua/s067919194.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s067919194", "user_id": "u120582723"}, "prompt_components": {"gold_output": "A\n", "input_to_evaluate": "local tgt = 1\nlocal strs = {}\nlocal pos = {1, 1, 1}\nlocal tmp = \"\"\nfor i = 1, 3 do strs[i] = io.read() end\nwhile pos[tgt] <= #(strs[tgt]) do\n tmp = strs[tgt]:sub(pos[tgt], pos[tgt])\n pos[tgt] = pos[tgt] + 1\n tgt = string.byte(tmp) - 96\nend\nprint(string.char(tgt + 64))\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nAlice, Bob and Charlie are playing Card Game for Three, as below:\n\nAt first, each of the three players has a deck consisting of some number of cards. Each card has a letter a, b or c written on it. The orders of the cards in the decks cannot be rearranged.\n\nThe players take turns. Alice goes first.\n\nIf the current player's deck contains at least one card, discard the top card in the deck. Then, the player whose name begins with the letter on the discarded card, takes the next turn. (For example, if the card says a, Alice takes the next turn.)\n\nIf the current player's deck is empty, the game ends and the current player wins the game.\n\nYou are given the initial decks of the players.\nMore specifically, you are given three strings S_A, S_B and S_C. The i-th (1≦i≦|S_A|) letter in S_A is the letter on the i-th card in Alice's initial deck. S_B and S_C describes Bob's and Charlie's initial decks in the same way.\n\nDetermine the winner of the game.\n\nConstraints\n\n1≦|S_A|≦100\n\n1≦|S_B|≦100\n\n1≦|S_C|≦100\n\nEach letter in S_A, S_B, S_C is a, b or c.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nS_A\nS_B\nS_C\n\nOutput\n\nIf Alice will win, print A. If Bob will win, print B. If Charlie will win, print C.\n\nSample Input 1\n\naca\naccc\nca\n\nSample Output 1\n\nA\n\nThe game will progress as below:\n\nAlice discards the top card in her deck, a. Alice takes the next turn.\n\nAlice discards the top card in her deck, c. Charlie takes the next turn.\n\nCharlie discards the top card in his deck, c. Charlie takes the next turn.\n\nCharlie discards the top card in his deck, a. Alice takes the next turn.\n\nAlice discards the top card in her deck, a. Alice takes the next turn.\n\nAlice's deck is empty. The game ends and Alice wins the game.\n\nSample Input 2\n\nabcb\naacb\nbccc\n\nSample Output 2\n\nC", "sample_input": "aca\naccc\nca\n"}, "reference_outputs": ["A\n"], "source_document_id": "p03998", "source_text": "Score : 200 points\n\nProblem Statement\n\nAlice, Bob and Charlie are playing Card Game for Three, as below:\n\nAt first, each of the three players has a deck consisting of some number of cards. Each card has a letter a, b or c written on it. The orders of the cards in the decks cannot be rearranged.\n\nThe players take turns. Alice goes first.\n\nIf the current player's deck contains at least one card, discard the top card in the deck. Then, the player whose name begins with the letter on the discarded card, takes the next turn. (For example, if the card says a, Alice takes the next turn.)\n\nIf the current player's deck is empty, the game ends and the current player wins the game.\n\nYou are given the initial decks of the players.\nMore specifically, you are given three strings S_A, S_B and S_C. The i-th (1≦i≦|S_A|) letter in S_A is the letter on the i-th card in Alice's initial deck. S_B and S_C describes Bob's and Charlie's initial decks in the same way.\n\nDetermine the winner of the game.\n\nConstraints\n\n1≦|S_A|≦100\n\n1≦|S_B|≦100\n\n1≦|S_C|≦100\n\nEach letter in S_A, S_B, S_C is a, b or c.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nS_A\nS_B\nS_C\n\nOutput\n\nIf Alice will win, print A. If Bob will win, print B. If Charlie will win, print C.\n\nSample Input 1\n\naca\naccc\nca\n\nSample Output 1\n\nA\n\nThe game will progress as below:\n\nAlice discards the top card in her deck, a. Alice takes the next turn.\n\nAlice discards the top card in her deck, c. Charlie takes the next turn.\n\nCharlie discards the top card in his deck, c. Charlie takes the next turn.\n\nCharlie discards the top card in his deck, a. Alice takes the next turn.\n\nAlice discards the top card in her deck, a. Alice takes the next turn.\n\nAlice's deck is empty. The game ends and Alice wins the game.\n\nSample Input 2\n\nabcb\naacb\nbccc\n\nSample Output 2\n\nC", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 272, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s365782329", "group_id": "codeNet:p03999", "input_text": "local ior = io.read\nlocal str = ior()\nlocal ppos = #str - 1\nlocal tot = (1< max then\n max = cur\n max_i = i\n end\nend\nif max < L then\n print(\"Impossible\")\n return\nelse\n print(\"Possible\")\n for i=1,max_i-1 do\n print(i)\n end\n for i=N-1,max_i,-1 do\n print(i)\n end\nend", "language": "Lua", "metadata": {"date": 1570494738, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p04035.html", "problem_id": "p04035", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p04035/input.txt", "sample_output_relpath": "derived/input_output/data/p04035/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p04035/Lua/s405422275.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s405422275", "user_id": "u162773977"}, "prompt_components": {"gold_output": "Possible\n2\n1\n", "input_to_evaluate": "local read = setmetatable({}, {__index = function(t, k) local a = {} for i=1,#k do table.insert(a, '*'..string.sub(k, i, i)) end local r = io.read local u = table.unpack or unpack return function() return r(u(a)) end end})\nread.N = function(N) local t={} for i=1,N do t[i]=read.n() end return t end\n--\nlocal N, L = read.nn()\nlocal A = read.N(N)\n\nlocal max = 0\nlocal max_i = 0\nfor i=1,N-1 do\n local cur = A[i] + A[i+1]\n if cur > max then\n max = cur\n max_i = i\n end\nend\nif max < L then\n print(\"Impossible\")\n return\nelse\n print(\"Possible\")\n for i=1,max_i-1 do\n print(i)\n end\n for i=N-1,max_i,-1 do\n print(i)\n end\nend", "problem_context": "Problem Statement\n\nWe have N pieces of ropes, numbered 1 through N. The length of piece i is a_i.\n\nAt first, for each i (1≤i≤N-1), piece i and piece i+1 are tied at the ends, forming one long rope with N-1 knots. Snuke will try to untie all of the knots by performing the following operation repeatedly:\n\nChoose a (connected) rope with a total length of at least L, then untie one of its knots.\n\nIs it possible to untie all of the N-1 knots by properly applying this operation? If the answer is positive, find one possible order to untie the knots.\n\nConstraints\n\n2≤N≤10^5\n\n1≤L≤10^9\n\n1≤a_i≤10^9\n\nAll input values are integers.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN L\na_1 a_2 ... a_n\n\nOutput\n\nIf it is not possible to untie all of the N-1 knots, print Impossible.\n\nIf it is possible to untie all of the knots, print Possible, then print another N-1 lines that describe a possible order to untie the knots. The j-th of those N-1 lines should contain the index of the knot that is untied in the j-th operation. Here, the index of the knot connecting piece i and piece i+1 is i.\n\nIf there is more than one solution, output any.\n\nSample Input 1\n\n3 50\n30 20 10\n\nSample Output 1\n\nPossible\n2\n1\n\nIf the knot 1 is untied first, the knot 2 will become impossible to untie.\n\nSample Input 2\n\n2 21\n10 10\n\nSample Output 2\n\nImpossible\n\nSample Input 3\n\n5 50\n10 20 30 40 50\n\nSample Output 3\n\nPossible\n1\n2\n3\n4\n\nAnother example of a possible solution is 3, 4, 1, 2.", "sample_input": "3 50\n30 20 10\n"}, "reference_outputs": ["Possible\n2\n1\n"], "source_document_id": "p04035", "source_text": "Problem Statement\n\nWe have N pieces of ropes, numbered 1 through N. The length of piece i is a_i.\n\nAt first, for each i (1≤i≤N-1), piece i and piece i+1 are tied at the ends, forming one long rope with N-1 knots. Snuke will try to untie all of the knots by performing the following operation repeatedly:\n\nChoose a (connected) rope with a total length of at least L, then untie one of its knots.\n\nIs it possible to untie all of the N-1 knots by properly applying this operation? If the answer is positive, find one possible order to untie the knots.\n\nConstraints\n\n2≤N≤10^5\n\n1≤L≤10^9\n\n1≤a_i≤10^9\n\nAll input values are integers.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN L\na_1 a_2 ... a_n\n\nOutput\n\nIf it is not possible to untie all of the N-1 knots, print Impossible.\n\nIf it is possible to untie all of the knots, print Possible, then print another N-1 lines that describe a possible order to untie the knots. The j-th of those N-1 lines should contain the index of the knot that is untied in the j-th operation. Here, the index of the knot connecting piece i and piece i+1 is i.\n\nIf there is more than one solution, output any.\n\nSample Input 1\n\n3 50\n30 20 10\n\nSample Output 1\n\nPossible\n2\n1\n\nIf the knot 1 is untied first, the knot 2 will become impossible to untie.\n\nSample Input 2\n\n2 21\n10 10\n\nSample Output 2\n\nImpossible\n\nSample Input 3\n\n5 50\n10 20 30 40 50\n\nSample Output 3\n\nPossible\n1\n2\n3\n4\n\nAnother example of a possible solution is 3, 4, 1, 2.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 671, "cpu_time_ms": 402, "memory_kb": 12792}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s797170177", "group_id": "codeNet:p04035", "input_text": "local n, l = io.read(\"*n\", \"*n\")\nlocal a = {}\nfor i = 1, n do\n a[i] = io.read(\"*n\")\nend\nlocal pos = 0\nfor i = 1, n - 1 do\n if l <= a[i] + a[i + 1] then\n pos = i\n break\n end\nend\nif pos == 0 then\n print(\"Impossible\")\nelse\n print(\"Possible\")\n for i = 1, pos - 1 do\n print(i)\n end\n for i = n - 1, pos + 1, -1 do\n print(i)\n end\n print(pos)\nend\n", "language": "Lua", "metadata": {"date": 1564147312, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p04035.html", "problem_id": "p04035", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p04035/input.txt", "sample_output_relpath": "derived/input_output/data/p04035/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p04035/Lua/s797170177.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s797170177", "user_id": "u120582723"}, "prompt_components": {"gold_output": "Possible\n2\n1\n", "input_to_evaluate": "local n, l = io.read(\"*n\", \"*n\")\nlocal a = {}\nfor i = 1, n do\n a[i] = io.read(\"*n\")\nend\nlocal pos = 0\nfor i = 1, n - 1 do\n if l <= a[i] + a[i + 1] then\n pos = i\n break\n end\nend\nif pos == 0 then\n print(\"Impossible\")\nelse\n print(\"Possible\")\n for i = 1, pos - 1 do\n print(i)\n end\n for i = n - 1, pos + 1, -1 do\n print(i)\n end\n print(pos)\nend\n", "problem_context": "Problem Statement\n\nWe have N pieces of ropes, numbered 1 through N. The length of piece i is a_i.\n\nAt first, for each i (1≤i≤N-1), piece i and piece i+1 are tied at the ends, forming one long rope with N-1 knots. Snuke will try to untie all of the knots by performing the following operation repeatedly:\n\nChoose a (connected) rope with a total length of at least L, then untie one of its knots.\n\nIs it possible to untie all of the N-1 knots by properly applying this operation? If the answer is positive, find one possible order to untie the knots.\n\nConstraints\n\n2≤N≤10^5\n\n1≤L≤10^9\n\n1≤a_i≤10^9\n\nAll input values are integers.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN L\na_1 a_2 ... a_n\n\nOutput\n\nIf it is not possible to untie all of the N-1 knots, print Impossible.\n\nIf it is possible to untie all of the knots, print Possible, then print another N-1 lines that describe a possible order to untie the knots. The j-th of those N-1 lines should contain the index of the knot that is untied in the j-th operation. Here, the index of the knot connecting piece i and piece i+1 is i.\n\nIf there is more than one solution, output any.\n\nSample Input 1\n\n3 50\n30 20 10\n\nSample Output 1\n\nPossible\n2\n1\n\nIf the knot 1 is untied first, the knot 2 will become impossible to untie.\n\nSample Input 2\n\n2 21\n10 10\n\nSample Output 2\n\nImpossible\n\nSample Input 3\n\n5 50\n10 20 30 40 50\n\nSample Output 3\n\nPossible\n1\n2\n3\n4\n\nAnother example of a possible solution is 3, 4, 1, 2.", "sample_input": "3 50\n30 20 10\n"}, "reference_outputs": ["Possible\n2\n1\n"], "source_document_id": "p04035", "source_text": "Problem Statement\n\nWe have N pieces of ropes, numbered 1 through N. The length of piece i is a_i.\n\nAt first, for each i (1≤i≤N-1), piece i and piece i+1 are tied at the ends, forming one long rope with N-1 knots. Snuke will try to untie all of the knots by performing the following operation repeatedly:\n\nChoose a (connected) rope with a total length of at least L, then untie one of its knots.\n\nIs it possible to untie all of the N-1 knots by properly applying this operation? If the answer is positive, find one possible order to untie the knots.\n\nConstraints\n\n2≤N≤10^5\n\n1≤L≤10^9\n\n1≤a_i≤10^9\n\nAll input values are integers.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN L\na_1 a_2 ... a_n\n\nOutput\n\nIf it is not possible to untie all of the N-1 knots, print Impossible.\n\nIf it is possible to untie all of the knots, print Possible, then print another N-1 lines that describe a possible order to untie the knots. The j-th of those N-1 lines should contain the index of the knot that is untied in the j-th operation. Here, the index of the knot connecting piece i and piece i+1 is i.\n\nIf there is more than one solution, output any.\n\nSample Input 1\n\n3 50\n30 20 10\n\nSample Output 1\n\nPossible\n2\n1\n\nIf the knot 1 is untied first, the knot 2 will become impossible to untie.\n\nSample Input 2\n\n2 21\n10 10\n\nSample Output 2\n\nImpossible\n\nSample Input 3\n\n5 50\n10 20 30 40 50\n\nSample Output 3\n\nPossible\n1\n2\n3\n4\n\nAnother example of a possible solution is 3, 4, 1, 2.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 361, "cpu_time_ms": 285, "memory_kb": 8568}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s490016749", "group_id": "codeNet:p04043", "input_text": "local t = {}\nfor i = 1, 3 do\n table.insert(t, io.read(\"*n\", \"*n\", \"*n\"))\nend\ntable.sort(t)\nif t[1] == 5 and t[2] == 5 and t[3] == 7 then\n print(\"YES\")\nelse\n print(\"NO\")\nend", "language": "Lua", "metadata": {"date": 1571952680, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p04043.html", "problem_id": "p04043", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p04043/input.txt", "sample_output_relpath": "derived/input_output/data/p04043/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p04043/Lua/s490016749.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s490016749", "user_id": "u413686817"}, "prompt_components": {"gold_output": "YES\n", "input_to_evaluate": "local t = {}\nfor i = 1, 3 do\n table.insert(t, io.read(\"*n\", \"*n\", \"*n\"))\nend\ntable.sort(t)\nif t[1] == 5 and t[2] == 5 and t[3] == 7 then\n print(\"YES\")\nelse\n print(\"NO\")\nend", "problem_context": "Score : 100 points\n\nProblem Statement\n\nIroha loves Haiku. Haiku is a short form of Japanese poetry. A Haiku consists of three phrases with 5, 7 and 5 syllables, in this order.\n\nTo create a Haiku, Iroha has come up with three different phrases. These phrases have A, B and C syllables, respectively. Determine whether she can construct a Haiku by using each of the phrases once, in some order.\n\nConstraints\n\n1≦A,B,C≦10\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nA B C\n\nOutput\n\nIf it is possible to construct a Haiku by using each of the phrases once, print YES (case-sensitive). Otherwise, print NO.\n\nSample Input 1\n\n5 5 7\n\nSample Output 1\n\nYES\n\nUsing three phrases of length 5, 5 and 7, it is possible to construct a Haiku.\n\nSample Input 2\n\n7 7 5\n\nSample Output 2\n\nNO", "sample_input": "5 5 7\n"}, "reference_outputs": ["YES\n"], "source_document_id": "p04043", "source_text": "Score : 100 points\n\nProblem Statement\n\nIroha loves Haiku. Haiku is a short form of Japanese poetry. A Haiku consists of three phrases with 5, 7 and 5 syllables, in this order.\n\nTo create a Haiku, Iroha has come up with three different phrases. These phrases have A, B and C syllables, respectively. Determine whether she can construct a Haiku by using each of the phrases once, in some order.\n\nConstraints\n\n1≦A,B,C≦10\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nA B C\n\nOutput\n\nIf it is possible to construct a Haiku by using each of the phrases once, print YES (case-sensitive). Otherwise, print NO.\n\nSample Input 1\n\n5 5 7\n\nSample Output 1\n\nYES\n\nUsing three phrases of length 5, 5 and 7, it is possible to construct a Haiku.\n\nSample Input 2\n\n7 7 5\n\nSample Output 2\n\nNO", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 175, "cpu_time_ms": 8, "memory_kb": 760}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s103620863", "group_id": "codeNet:p04045", "input_text": "local n, k = io.read(\"*n\", \"*n\")\nlocal t = {}\nfor i = 1, k do\n local z = io.read(\"*n\")\n t[z] = true\nend\nwhile true do\n local len = #(tostring(n))\n local valid = true\n local v = n\n for i = 1, len do\n local tmp = v % 10\n if t[tmp] then valid = false break end\n v = v // 10\n end\n if valid then print(n) break end\n n = n + 1\nend\n", "language": "Lua", "metadata": {"date": 1597756388, "filename_ext": "lua", "original_language": "Lua (Lua 5.3.5)", "problem_description_relpath": "problem_descriptions/p04045.html", "problem_id": "p04045", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p04045/input.txt", "sample_output_relpath": "derived/input_output/data/p04045/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p04045/Lua/s103620863.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s103620863", "user_id": "u120582723"}, "prompt_components": {"gold_output": "2000\n", "input_to_evaluate": "local n, k = io.read(\"*n\", \"*n\")\nlocal t = {}\nfor i = 1, k do\n local z = io.read(\"*n\")\n t[z] = true\nend\nwhile true do\n local len = #(tostring(n))\n local valid = true\n local v = n\n for i = 1, len do\n local tmp = v % 10\n if t[tmp] then valid = false break end\n v = v // 10\n end\n if valid then print(n) break end\n n = n + 1\nend\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nIroha is very particular about numbers. There are K digits that she dislikes: D_1, D_2, ..., D_K.\n\nShe is shopping, and now paying at the cashier.\nHer total is N yen (the currency of Japan), thus she has to hand at least N yen to the cashier (and possibly receive the change).\n\nHowever, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.\n\nFind the amount of money that she will hand to the cashier.\n\nConstraints\n\n1 ≦ N < 10000\n\n1 ≦ K < 10\n\n0 ≦ D_1 < D_2 < … < D_K≦9\n\n\\{D_1,D_2,...,D_K\\} ≠ \\{1,2,3,4,5,6,7,8,9\\}\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN K\nD_1 D_2 … D_K\n\nOutput\n\nPrint the amount of money that Iroha will hand to the cashier.\n\nSample Input 1\n\n1000 8\n1 3 4 5 6 7 8 9\n\nSample Output 1\n\n2000\n\nShe dislikes all digits except 0 and 2.\n\nThe smallest integer equal to or greater than N=1000 whose decimal notation contains only 0 and 2, is 2000.\n\nSample Input 2\n\n9999 1\n0\n\nSample Output 2\n\n9999", "sample_input": "1000 8\n1 3 4 5 6 7 8 9\n"}, "reference_outputs": ["2000\n"], "source_document_id": "p04045", "source_text": "Score : 300 points\n\nProblem Statement\n\nIroha is very particular about numbers. There are K digits that she dislikes: D_1, D_2, ..., D_K.\n\nShe is shopping, and now paying at the cashier.\nHer total is N yen (the currency of Japan), thus she has to hand at least N yen to the cashier (and possibly receive the change).\n\nHowever, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.\n\nFind the amount of money that she will hand to the cashier.\n\nConstraints\n\n1 ≦ N < 10000\n\n1 ≦ K < 10\n\n0 ≦ D_1 < D_2 < … < D_K≦9\n\n\\{D_1,D_2,...,D_K\\} ≠ \\{1,2,3,4,5,6,7,8,9\\}\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN K\nD_1 D_2 … D_K\n\nOutput\n\nPrint the amount of money that Iroha will hand to the cashier.\n\nSample Input 1\n\n1000 8\n1 3 4 5 6 7 8 9\n\nSample Output 1\n\n2000\n\nShe dislikes all digits except 0 and 2.\n\nThe smallest integer equal to or greater than N=1000 whose decimal notation contains only 0 and 2, is 2000.\n\nSample Input 2\n\n9999 1\n0\n\nSample Output 2\n\n9999", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 343, "cpu_time_ms": 49, "memory_kb": 2848}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s845412283", "group_id": "codeNet:p04045", "input_text": "n, k = io.read(\"*n\", \"*n\")\nds = {}\nfor i = 1, k do ds[io.read(\"*n\")] = true end\ndigits = {}\nwhile(0 < n) do\n a = n % 10\n table.insert(digits, a)\n n = math.floor(n / 10)\nend\nneedrestart = true\nwhile(needrestart) do\n needrestart = false\n len = #digits\n for i = 1, len + 1 do\n val = digits[i]\n if(val == nil) then break end\n isok = (ds[val % 10] == nil)\n while(not isok)do\n needrestart = true\n for j = 1, i - 1 do digits[j] = 0 end\n val = val + 1\n isok = (ds[val % 10] == nil)\n end\n if(10 <= val) then\n needrestart = true\n for j = 1, i - 1 do digits[j] = 0 end\n val = val - 10\n if(i ~= len) then digits[i + 1] = digits[i + 1] + 1 else digits[i + 1] = 1 end\n end\n digits[i] = val\n if(needrestart) then break end\n end\nend\nlen = #digits\nfor i = len , 1, -1 do\n io.write(digits[i])\nend\nio.write(\"\\n\")", "language": "Lua", "metadata": {"date": 1554688620, "filename_ext": "lua", "original_language": "LuaJIT (2.0.4)", "problem_description_relpath": "problem_descriptions/p04045.html", "problem_id": "p04045", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p04045/input.txt", "sample_output_relpath": "derived/input_output/data/p04045/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p04045/Lua/s845412283.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s845412283", "user_id": "u120582723"}, "prompt_components": {"gold_output": "2000\n", "input_to_evaluate": "n, k = io.read(\"*n\", \"*n\")\nds = {}\nfor i = 1, k do ds[io.read(\"*n\")] = true end\ndigits = {}\nwhile(0 < n) do\n a = n % 10\n table.insert(digits, a)\n n = math.floor(n / 10)\nend\nneedrestart = true\nwhile(needrestart) do\n needrestart = false\n len = #digits\n for i = 1, len + 1 do\n val = digits[i]\n if(val == nil) then break end\n isok = (ds[val % 10] == nil)\n while(not isok)do\n needrestart = true\n for j = 1, i - 1 do digits[j] = 0 end\n val = val + 1\n isok = (ds[val % 10] == nil)\n end\n if(10 <= val) then\n needrestart = true\n for j = 1, i - 1 do digits[j] = 0 end\n val = val - 10\n if(i ~= len) then digits[i + 1] = digits[i + 1] + 1 else digits[i + 1] = 1 end\n end\n digits[i] = val\n if(needrestart) then break end\n end\nend\nlen = #digits\nfor i = len , 1, -1 do\n io.write(digits[i])\nend\nio.write(\"\\n\")", "problem_context": "Score : 300 points\n\nProblem Statement\n\nIroha is very particular about numbers. There are K digits that she dislikes: D_1, D_2, ..., D_K.\n\nShe is shopping, and now paying at the cashier.\nHer total is N yen (the currency of Japan), thus she has to hand at least N yen to the cashier (and possibly receive the change).\n\nHowever, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.\n\nFind the amount of money that she will hand to the cashier.\n\nConstraints\n\n1 ≦ N < 10000\n\n1 ≦ K < 10\n\n0 ≦ D_1 < D_2 < … < D_K≦9\n\n\\{D_1,D_2,...,D_K\\} ≠ \\{1,2,3,4,5,6,7,8,9\\}\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN K\nD_1 D_2 … D_K\n\nOutput\n\nPrint the amount of money that Iroha will hand to the cashier.\n\nSample Input 1\n\n1000 8\n1 3 4 5 6 7 8 9\n\nSample Output 1\n\n2000\n\nShe dislikes all digits except 0 and 2.\n\nThe smallest integer equal to or greater than N=1000 whose decimal notation contains only 0 and 2, is 2000.\n\nSample Input 2\n\n9999 1\n0\n\nSample Output 2\n\n9999", "sample_input": "1000 8\n1 3 4 5 6 7 8 9\n"}, "reference_outputs": ["2000\n"], "source_document_id": "p04045", "source_text": "Score : 300 points\n\nProblem Statement\n\nIroha is very particular about numbers. There are K digits that she dislikes: D_1, D_2, ..., D_K.\n\nShe is shopping, and now paying at the cashier.\nHer total is N yen (the currency of Japan), thus she has to hand at least N yen to the cashier (and possibly receive the change).\n\nHowever, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.\n\nFind the amount of money that she will hand to the cashier.\n\nConstraints\n\n1 ≦ N < 10000\n\n1 ≦ K < 10\n\n0 ≦ D_1 < D_2 < … < D_K≦9\n\n\\{D_1,D_2,...,D_K\\} ≠ \\{1,2,3,4,5,6,7,8,9\\}\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN K\nD_1 D_2 … D_K\n\nOutput\n\nPrint the amount of money that Iroha will hand to the cashier.\n\nSample Input 1\n\n1000 8\n1 3 4 5 6 7 8 9\n\nSample Output 1\n\n2000\n\nShe dislikes all digits except 0 and 2.\n\nThe smallest integer equal to or greater than N=1000 whose decimal notation contains only 0 and 2, is 2000.\n\nSample Input 2\n\n9999 1\n0\n\nSample Output 2\n\n9999", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 968, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s412413833", "group_id": "codeNet:p04047", "input_text": "local ior = io.input()\nlocal n = ior:read(\"*n\")\nlocal t = {}\nfor i = 1, 2 * n do t[i] = ior:read(\"*n\") end\ntable.sort(t)\nlocal sum = 0\nfor i = 1, 2 * n, 2 do\n sum = sum + t[i]\nend\nprint(sum)\n", "language": "Lua", "metadata": {"date": 1556583158, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p04047.html", "problem_id": "p04047", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p04047/input.txt", "sample_output_relpath": "derived/input_output/data/p04047/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p04047/Lua/s412413833.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s412413833", "user_id": "u120582723"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "local ior = io.input()\nlocal n = ior:read(\"*n\")\nlocal t = {}\nfor i = 1, 2 * n do t[i] = ior:read(\"*n\") end\ntable.sort(t)\nlocal sum = 0\nfor i = 1, 2 * n, 2 do\n sum = sum + t[i]\nend\nprint(sum)\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nSnuke is having a barbeque party.\n\nAt the party, he will make N servings of Skewer Meal.\n\nExample of a serving of Skewer Meal\n\nHe has a stock of 2N skewers, all of which will be used in Skewer Meal. The length of the i-th skewer is L_i.\nAlso, he has an infinite supply of ingredients.\n\nTo make a serving of Skewer Meal, he picks 2 skewers and threads ingredients onto those skewers.\nLet the length of the shorter skewer be x, then the serving can hold the maximum of x ingredients.\n\nWhat is the maximum total number of ingredients that his N servings of Skewer Meal can hold, if he uses the skewers optimally?\n\nConstraints\n\n1≦N≦100\n\n1≦L_i≦100\n\nFor each i, L_i is an integer.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\nL_1 L_2 ... L_{2N}\n\nOutput\n\nPrint the maximum total number of ingredients that Snuke's N servings of Skewer Meal can hold.\n\nSample Input 1\n\n2\n1 3 1 2\n\nSample Output 1\n\n3\n\nIf he makes a serving using the first and third skewers, and another using the second and fourth skewers, each serving will hold 1 and 2 ingredients, for the total of 3.\n\nSample Input 2\n\n5\n100 1 2 3 14 15 58 58 58 29\n\nSample Output 2\n\n135", "sample_input": "2\n1 3 1 2\n"}, "reference_outputs": ["3\n"], "source_document_id": "p04047", "source_text": "Score : 200 points\n\nProblem Statement\n\nSnuke is having a barbeque party.\n\nAt the party, he will make N servings of Skewer Meal.\n\nExample of a serving of Skewer Meal\n\nHe has a stock of 2N skewers, all of which will be used in Skewer Meal. The length of the i-th skewer is L_i.\nAlso, he has an infinite supply of ingredients.\n\nTo make a serving of Skewer Meal, he picks 2 skewers and threads ingredients onto those skewers.\nLet the length of the shorter skewer be x, then the serving can hold the maximum of x ingredients.\n\nWhat is the maximum total number of ingredients that his N servings of Skewer Meal can hold, if he uses the skewers optimally?\n\nConstraints\n\n1≦N≦100\n\n1≦L_i≦100\n\nFor each i, L_i is an integer.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\nL_1 L_2 ... L_{2N}\n\nOutput\n\nPrint the maximum total number of ingredients that Snuke's N servings of Skewer Meal can hold.\n\nSample Input 1\n\n2\n1 3 1 2\n\nSample Output 1\n\n3\n\nIf he makes a serving using the first and third skewers, and another using the second and fourth skewers, each serving will hold 1 and 2 ingredients, for the total of 3.\n\nSample Input 2\n\n5\n100 1 2 3 14 15 58 58 58 29\n\nSample Output 2\n\n135", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 192, "cpu_time_ms": 4, "memory_kb": 508}, "variant": "low_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Lua:s652025361", "group_id": "codeNet:p04048", "input_text": "local ior = io.input()\nlocal n, x = ior:read(\"*n\", \"*n\")\nlocal sum = n\nlocal a, b = x, n - x\nif(a < b) then a, b = b, a end\nwhile(true) do\n if(a % b == 0) then\n sum = sum + b * (2 * (a // b) - 1)\n break\n else\n local rem = a % b\n sum = sum + 2 * (a - rem)\n a, b = b, rem\n end\nend\nprint(sum)\n", "language": "Lua", "metadata": {"date": 1556586083, "filename_ext": "lua", "original_language": "Lua (5.3.2)", "problem_description_relpath": "problem_descriptions/p04048.html", "problem_id": "p04048", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p04048/input.txt", "sample_output_relpath": "derived/input_output/data/p04048/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p04048/Lua/s652025361.lua", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s652025361", "user_id": "u120582723"}, "prompt_components": {"gold_output": "12\n", "input_to_evaluate": "local ior = io.input()\nlocal n, x = ior:read(\"*n\", \"*n\")\nlocal sum = n\nlocal a, b = x, n - x\nif(a < b) then a, b = b, a end\nwhile(true) do\n if(a % b == 0) then\n sum = sum + b * (2 * (a // b) - 1)\n break\n else\n local rem = a % b\n sum = sum + 2 * (a - rem)\n a, b = b, rem\n end\nend\nprint(sum)\n", "problem_context": "Score : 500 points\n\nProblem Statement\n\nSnuke is conducting an optical experiment using mirrors and his new invention, the rifle of Mysterious Light.\n\nThree mirrors of length N are set so that they form an equilateral triangle.\nLet the vertices of the triangle be a, b and c.\n\nInside the triangle, the rifle is placed at the point p on segment ab such that ap = X.\n(The size of the rifle is negligible.)\nNow, the rifle is about to fire a ray of Mysterious Light in the direction of bc.\n\nThe ray of Mysterious Light will travel in a straight line, and will be reflected by mirrors, in the same ways as \"ordinary\" light.\nThere is one major difference, though: it will be also reflected by its own trajectory as if it is a mirror!\nWhen the ray comes back to the rifle, the ray will be absorbed.\n\nThe following image shows the ray's trajectory where N = 5 and X = 2.\n\nIt can be shown that the ray eventually comes back to the rifle and is absorbed, regardless of the values of N and X.\nFind the total length of the ray's trajectory.\n\nConstraints\n\n2≦N≦10^{12}\n\n1≦X≦N-1\n\nN and X are integers.\n\nPartial Points\n\n300 points will be awarded for passing the test set satisfying N≦1000.\n\nAnother 200 points will be awarded for passing the test set without additional constraints.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN X\n\nOutput\n\nPrint the total length of the ray's trajectory.\n\nSample Input 1\n\n5 2\n\nSample Output 1\n\n12\n\nRefer to the image in the Problem Statement section.\nThe total length of the trajectory is 2+3+2+2+1+1+1 = 12.", "sample_input": "5 2\n"}, "reference_outputs": ["12\n"], "source_document_id": "p04048", "source_text": "Score : 500 points\n\nProblem Statement\n\nSnuke is conducting an optical experiment using mirrors and his new invention, the rifle of Mysterious Light.\n\nThree mirrors of length N are set so that they form an equilateral triangle.\nLet the vertices of the triangle be a, b and c.\n\nInside the triangle, the rifle is placed at the point p on segment ab such that ap = X.\n(The size of the rifle is negligible.)\nNow, the rifle is about to fire a ray of Mysterious Light in the direction of bc.\n\nThe ray of Mysterious Light will travel in a straight line, and will be reflected by mirrors, in the same ways as \"ordinary\" light.\nThere is one major difference, though: it will be also reflected by its own trajectory as if it is a mirror!\nWhen the ray comes back to the rifle, the ray will be absorbed.\n\nThe following image shows the ray's trajectory where N = 5 and X = 2.\n\nIt can be shown that the ray eventually comes back to the rifle and is absorbed, regardless of the values of N and X.\nFind the total length of the ray's trajectory.\n\nConstraints\n\n2≦N≦10^{12}\n\n1≦X≦N-1\n\nN and X are integers.\n\nPartial Points\n\n300 points will be awarded for passing the test set satisfying N≦1000.\n\nAnother 200 points will be awarded for passing the test set without additional constraints.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN X\n\nOutput\n\nPrint the total length of the ray's trajectory.\n\nSample Input 1\n\n5 2\n\nSample Output 1\n\n12\n\nRefer to the image in the Problem Statement section.\nThe total length of the trajectory is 2+3+2+2+1+1+1 = 12.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 308, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "low_resource"}