diff --git "a/languages/kotlin/validation.jsonl" "b/languages/kotlin/validation.jsonl" new file mode 100644--- /dev/null +++ "b/languages/kotlin/validation.jsonl" @@ -0,0 +1,1000 @@ +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s170257636", "group_id": "codeNet:p00357", "input_text": "import java.lang.Math.max\n\nfun main(args: Array) {\n val n = readLine()!!.toInt()\n val d = Array(n) {\n readLine()!!.toInt() / 10\n }\n\n fun isPossibleToReach(): Boolean {\n var current = 0\n for (i in d.indices) {\n if (current < i) return false\n current = max(current, i + d[i])\n }\n return current >= d.size\n }\n\n if (!isPossibleToReach()) {\n println(\"no\")\n return\n }\n d.reverse()\n if (!isPossibleToReach()) {\n println(\"no\")\n return\n }\n println(\"yes\")\n}\n", "language": "Kotlin", "metadata": {"date": 1568361614, "filename_ext": "kt", "original_language": "Kotlin", "problem_description_relpath": "problem_descriptions/p00357.html", "problem_id": "p00357", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p00357/input.txt", "sample_output_relpath": "derived/input_output/data/p00357/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00357/Kotlin/s170257636.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s170257636", "user_id": "u561121048"}, "prompt_components": {"gold_output": "no\n", "input_to_evaluate": "import java.lang.Math.max\n\nfun main(args: Array) {\n val n = readLine()!!.toInt()\n val d = Array(n) {\n readLine()!!.toInt() / 10\n }\n\n fun isPossibleToReach(): Boolean {\n var current = 0\n for (i in d.indices) {\n if (current < i) return false\n current = max(current, i + d[i])\n }\n return current >= d.size\n }\n\n if (!isPossibleToReach()) {\n println(\"no\")\n return\n }\n d.reverse()\n if (!isPossibleToReach()) {\n println(\"no\")\n return\n }\n println(\"yes\")\n}\n", "problem_context": "Trampoline\n\nA plurality of trampolines are arranged in a line at 10 m intervals. Each trampoline has its own maximum horizontal distance within which the jumper can jump safely. Starting from the left-most trampoline, the jumper jumps to another trampoline within the allowed jumping range. The jumper wants to repeat jumping until he/she reaches the right-most trampoline, and then tries to return to the left-most trampoline only through jumping. Can the jumper complete the roundtrip without a single stepping-down from a trampoline?\n\nWrite a program to report if the jumper can complete the journey using the list of maximum horizontal reaches of these trampolines. Assume that the trampolines are points without spatial extent.\n\nInput\n\nThe input is given in the following format.\n\nN\nd_1\nd_2\n:\nd_N\n\nThe first line provides the number of trampolines N (2 ≤ N ≤ 3 × 105). Each of the subsequent N lines gives the maximum allowable jumping distance in integer meters for the i-th trampoline d_i (1 ≤ d_i ≤ 106).\n\nOutput\n\nOutput \"yes\" if the jumper can complete the roundtrip, or \"no\" if he/she cannot.\n\nSample Input 1\n\n4\n20\n5\n10\n1\n\nSample Output 1\n\nno\n\nSample Input 2\n\n3\n10\n5\n10\n\nSample Output 2\n\nno\n\nSample Input 3\n\n4\n20\n30\n1\n20\n\nSample Output 3\n\nyes", "sample_input": "4\n20\n5\n10\n1\n"}, "reference_outputs": ["no\n"], "source_document_id": "p00357", "source_text": "Trampoline\n\nA plurality of trampolines are arranged in a line at 10 m intervals. Each trampoline has its own maximum horizontal distance within which the jumper can jump safely. Starting from the left-most trampoline, the jumper jumps to another trampoline within the allowed jumping range. The jumper wants to repeat jumping until he/she reaches the right-most trampoline, and then tries to return to the left-most trampoline only through jumping. Can the jumper complete the roundtrip without a single stepping-down from a trampoline?\n\nWrite a program to report if the jumper can complete the journey using the list of maximum horizontal reaches of these trampolines. Assume that the trampolines are points without spatial extent.\n\nInput\n\nThe input is given in the following format.\n\nN\nd_1\nd_2\n:\nd_N\n\nThe first line provides the number of trampolines N (2 ≤ N ≤ 3 × 105). Each of the subsequent N lines gives the maximum allowable jumping distance in integer meters for the i-th trampoline d_i (1 ≤ d_i ≤ 106).\n\nOutput\n\nOutput \"yes\" if the jumper can complete the roundtrip, or \"no\" if he/she cannot.\n\nSample Input 1\n\n4\n20\n5\n10\n1\n\nSample Output 1\n\nno\n\nSample Input 2\n\n3\n10\n5\n10\n\nSample Output 2\n\nno\n\nSample Input 3\n\n4\n20\n30\n1\n20\n\nSample Output 3\n\nyes", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 240, "memory_kb": 56808}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s745646801", "group_id": "codeNet:p00510", "input_text": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val n = sc.nextInt()\n var m = sc.nextInt()\n var ans = m\n\n for (i in 1..n) {\n m += sc.nextInt() - sc.nextInt()\n if (m < 0) { ans = 0; break }\n ans = Math.max(ans, m)\n }\n println(ans)\n}\n", "language": "Kotlin", "metadata": {"date": 1528627221, "filename_ext": "kt", "original_language": "Kotlin", "problem_description_relpath": "problem_descriptions/p00510.html", "problem_id": "p00510", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p00510/input.txt", "sample_output_relpath": "derived/input_output/data/p00510/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00510/Kotlin/s745646801.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s745646801", "user_id": "u197615397"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val n = sc.nextInt()\n var m = sc.nextInt()\n var ans = m\n\n for (i in 1..n) {\n m += sc.nextInt() - sc.nextInt()\n if (m < 0) { ans = 0; break }\n ans = Math.max(ans, m)\n }\n println(ans)\n}\n", "problem_context": "問題 1\n\n n 分間にわたり,\nトンネルの入口と出口で,\n1分間に通過する車の数を数えたデータがある.\nそのデータは,\n全部で n+2 行からなり,\n各行には次の内容が書かれている.\n\n第1行目には,正整数 n が書かれており,\n調査時間が n 分間であったことを表している.\n\n第2行目には,正整数 m が書かれており,\n調査開始時におけるトンネル内の車の台数が m であったことを表している.\n\n第(2+i)行目( i = 1, 2, ... , n ) には,\n調査開始後 (i-1) 分経過した時点から i 分経過するまでの1分間に,\n入口を通過した車の台数と出口を通過した車の台数が\n1つの空白で区切られて書かれている.\n\n調査開始後 j 分経過した時点 ( j=0, 1, 2, ... , n )\nにおけるトンネル内の車の台数を Sj とする.\nSj の最大値を出力しなさい.\nまた,\nトンネル内の車の台数が負になることは考えられないので,\nSj が一度でも負になった場合は,\n「エラー」の意味で 0 を出力しなさい.\nただし,\nn は 10000 以下で,\nトンネルの入口および出口を1分間に通過する車の台数は 100 以下である.\n\n 出力ファイルにおいては,\n出力の最後の行にも改行コードを入れること.\n\n入出力例\n\n入力例1\n\n3\n2\n2 3\n2 3\n4 1\n\n出力例1\n\n3\n\n入力例2\n\n3\n2\n2 3\n2 4\n4 1\n\n出力例2\n\n0\n\n入力例3\n\n3\n2\n2 3\n2 3\n1 0\n\n出力例3\n\n2\n\n問題文と自動審判に使われるデータは、情報オリンピック日本委員会が作成し公開している問題文と採点用テストデータです。", "sample_input": "3\n2\n2 3\n2 3\n4 1\n"}, "reference_outputs": ["3\n"], "source_document_id": "p00510", "source_text": "問題 1\n\n n 分間にわたり,\nトンネルの入口と出口で,\n1分間に通過する車の数を数えたデータがある.\nそのデータは,\n全部で n+2 行からなり,\n各行には次の内容が書かれている.\n\n第1行目には,正整数 n が書かれており,\n調査時間が n 分間であったことを表している.\n\n第2行目には,正整数 m が書かれており,\n調査開始時におけるトンネル内の車の台数が m であったことを表している.\n\n第(2+i)行目( i = 1, 2, ... , n ) には,\n調査開始後 (i-1) 分経過した時点から i 分経過するまでの1分間に,\n入口を通過した車の台数と出口を通過した車の台数が\n1つの空白で区切られて書かれている.\n\n調査開始後 j 分経過した時点 ( j=0, 1, 2, ... , n )\nにおけるトンネル内の車の台数を Sj とする.\nSj の最大値を出力しなさい.\nまた,\nトンネル内の車の台数が負になることは考えられないので,\nSj が一度でも負になった場合は,\n「エラー」の意味で 0 を出力しなさい.\nただし,\nn は 10000 以下で,\nトンネルの入口および出口を1分間に通過する車の台数は 100 以下である.\n\n 出力ファイルにおいては,\n出力の最後の行にも改行コードを入れること.\n\n入出力例\n\n入力例1\n\n3\n2\n2 3\n2 3\n4 1\n\n出力例1\n\n3\n\n入力例2\n\n3\n2\n2 3\n2 4\n4 1\n\n出力例2\n\n0\n\n入力例3\n\n3\n2\n2 3\n2 3\n1 0\n\n出力例3\n\n2\n\n問題文と自動審判に使われるデータは、情報オリンピック日本委員会が作成し公開している問題文と採点用テストデータです。", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 310, "cpu_time_ms": 210, "memory_kb": 48392}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s202775407", "group_id": "codeNet:p00962", "input_text": "import java.util.*\nfun main(args: Array?): Unit {\n val (n, m) = readLine()!!.trim().split(' ').map(String::toInt)\n val edges = Array(m){\n val (a, b, c) = readLine()!!.trim().split( ' ').map(String::toInt)\n Edge(it, a - 1, b - 1, c)\n }\n solve(n, m, edges)\n}\nfun solve(n: Int, m: Int, edges: Array) {\n val nodes = Array(n){ arrayListOf()}\n for (e in edges){\n nodes[e.from].add(e)\n }\n val minFromStart = LongArray(n){Long.MAX_VALUE shr 2}.also{it[0] = 0}\n val queue = PriorityQueue>(compareBy(Pair<*, Long>::second)).also{it.add(Pair(0, 0))}\n while (queue.isNotEmpty()) {\n val (current, cost) = queue.poll()\n if (minFromStart[current] == cost) {\n for (e in nodes[current]) if (minFromStart[e.to] > e.cost + cost) {\n minFromStart[e.to] = e.cost + cost\n queue.add(Pair(e.to, e.cost + cost))\n }\n }\n }\n for (i in nodes.indices) nodes[i] = arrayListOf()\n for (e in edges){\n nodes[e.to].add(e)\n }\n val minToGoal = LongArray(n){Long.MAX_VALUE shr 2}.also{it[1] = 0}\n queue.add(Pair(1, 0))\n while(queue.isNotEmpty()) {\n val (current, cost) = queue.poll()\n if (minToGoal[current] == cost) {\n for (e in nodes[current]) if (minToGoal[e.from] > e.cost + cost) {\n minToGoal[e.from] = e.cost + cost\n queue.add((Pair(e.from, e.cost + cost)))\n }\n }\n }\n val isBottleNeck = markBottleNeckEdge(n, m, edges, minFromStart, minToGoal)\n for (e in edges) {\n if (isBottleNeck[e.id]) {\n println(\"SAD\")\n }else if (minFromStart[e.to] + minToGoal[e.from] + e.cost < minFromStart[1]){\n println(\"HAPPY\")\n }else {\n println(\"SOSO\")\n }\n }\n}\nfun markBottleNeckEdge(n: Int, m: Int, edges: Array, minCostFromStart: LongArray, minCostToGoal: LongArray): BooleanArray {\n val nodes = Array(n){arrayListOf()}\n val minCost = minCostFromStart[1]\n for (e in edges) if (minCostFromStart[e.from] + e.cost + minCostToGoal[e.to] == minCost) {\n nodes[e.from].add(FlowEdge(e.id, e.to, nodes[e.to].size, true))\n nodes[e.to].add(FlowEdge(e.id, e.from, nodes[e.from].size - 1, false))\n }\n val prevEdge = Array(n){null as FlowEdge?}\n val queue: Queue = ArrayDeque()\n queue.add(0)\n while(queue.isNotEmpty() && queue.peek() != 1) {\n for (e in nodes[queue.poll()]) if (e.hasFlow && prevEdge[e.to] == null) {\n prevEdge[e.to] = e\n queue.add(e.to)\n }\n }\n var last = 1\n while (last != 0) {\n val e = prevEdge[last]!!\n val r = nodes[e.to][e.pair]\n e.hasFlow = false\n r.hasFlow = true\n last = r.to\n }\n queue.clear()\n queue.add(0)\n prevEdge.fill(null)\n prevEdge[0] = nodes.first().first()\n val visited = ArrayDeque().also{it.add(0)}\n while(queue.isNotEmpty() && queue.peek() != 1) {\n for (e in nodes[queue.poll()]) if (e.hasFlow && prevEdge[e.to] == null) {\n prevEdge[e.to] = e\n queue.add(e.to)\n visited.add(e.to)\n }\n }\n if (queue.isNotEmpty()) {\n return BooleanArray(m){false}\n }\n val result = BooleanArray(m){false}\n var bottleNeck = -1\n for (v in visited) {\n for (e in nodes[v]) {\n if (!e.hasFlow && prevEdge[e.to] == null) {\n bottleNeck = e.id\n }\n }\n }\n while(bottleNeck != -1) {\n visited.clear()\n queue.clear()\n result[bottleNeck] = true\n prevEdge[edges[bottleNeck].to] = nodes.first().first()\n queue.add(edges[bottleNeck].to)\n visited.add(edges[bottleNeck].to)\n bottleNeck = -1\n while(queue.isNotEmpty()) {\n for (e in nodes[queue.poll()]) if (e.hasFlow && prevEdge[e.to] == null) {\n prevEdge[e.to] = e\n queue.add(e.to)\n visited.add(e.to)\n }\n }\n for (v in visited) {\n for (e in nodes[v]) {\n if (!e.hasFlow && prevEdge[e.to] == null && edges[e.id].to == e.to) {\n bottleNeck = e.id\n }\n }\n }\n }\n return result\n}\nclass Edge(val id: Int, val from: Int, val to: Int, val cost: Int)\nclass FlowEdge(val id: Int, val to: Int, val pair: Int, var hasFlow: Boolean)\n", "language": "Kotlin", "metadata": {"date": 1558026734, "filename_ext": "kt", "original_language": "Kotlin", "problem_description_relpath": "problem_descriptions/p00962.html", "problem_id": "p00962", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p00962/input.txt", "sample_output_relpath": "derived/input_output/data/p00962/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00962/Kotlin/s202775407.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s202775407", "user_id": "u514597327"}, "prompt_components": {"gold_output": "SAD\nSAD\nSAD\nSOSO\nHAPPY\n", "input_to_evaluate": "import java.util.*\nfun main(args: Array?): Unit {\n val (n, m) = readLine()!!.trim().split(' ').map(String::toInt)\n val edges = Array(m){\n val (a, b, c) = readLine()!!.trim().split( ' ').map(String::toInt)\n Edge(it, a - 1, b - 1, c)\n }\n solve(n, m, edges)\n}\nfun solve(n: Int, m: Int, edges: Array) {\n val nodes = Array(n){ arrayListOf()}\n for (e in edges){\n nodes[e.from].add(e)\n }\n val minFromStart = LongArray(n){Long.MAX_VALUE shr 2}.also{it[0] = 0}\n val queue = PriorityQueue>(compareBy(Pair<*, Long>::second)).also{it.add(Pair(0, 0))}\n while (queue.isNotEmpty()) {\n val (current, cost) = queue.poll()\n if (minFromStart[current] == cost) {\n for (e in nodes[current]) if (minFromStart[e.to] > e.cost + cost) {\n minFromStart[e.to] = e.cost + cost\n queue.add(Pair(e.to, e.cost + cost))\n }\n }\n }\n for (i in nodes.indices) nodes[i] = arrayListOf()\n for (e in edges){\n nodes[e.to].add(e)\n }\n val minToGoal = LongArray(n){Long.MAX_VALUE shr 2}.also{it[1] = 0}\n queue.add(Pair(1, 0))\n while(queue.isNotEmpty()) {\n val (current, cost) = queue.poll()\n if (minToGoal[current] == cost) {\n for (e in nodes[current]) if (minToGoal[e.from] > e.cost + cost) {\n minToGoal[e.from] = e.cost + cost\n queue.add((Pair(e.from, e.cost + cost)))\n }\n }\n }\n val isBottleNeck = markBottleNeckEdge(n, m, edges, minFromStart, minToGoal)\n for (e in edges) {\n if (isBottleNeck[e.id]) {\n println(\"SAD\")\n }else if (minFromStart[e.to] + minToGoal[e.from] + e.cost < minFromStart[1]){\n println(\"HAPPY\")\n }else {\n println(\"SOSO\")\n }\n }\n}\nfun markBottleNeckEdge(n: Int, m: Int, edges: Array, minCostFromStart: LongArray, minCostToGoal: LongArray): BooleanArray {\n val nodes = Array(n){arrayListOf()}\n val minCost = minCostFromStart[1]\n for (e in edges) if (minCostFromStart[e.from] + e.cost + minCostToGoal[e.to] == minCost) {\n nodes[e.from].add(FlowEdge(e.id, e.to, nodes[e.to].size, true))\n nodes[e.to].add(FlowEdge(e.id, e.from, nodes[e.from].size - 1, false))\n }\n val prevEdge = Array(n){null as FlowEdge?}\n val queue: Queue = ArrayDeque()\n queue.add(0)\n while(queue.isNotEmpty() && queue.peek() != 1) {\n for (e in nodes[queue.poll()]) if (e.hasFlow && prevEdge[e.to] == null) {\n prevEdge[e.to] = e\n queue.add(e.to)\n }\n }\n var last = 1\n while (last != 0) {\n val e = prevEdge[last]!!\n val r = nodes[e.to][e.pair]\n e.hasFlow = false\n r.hasFlow = true\n last = r.to\n }\n queue.clear()\n queue.add(0)\n prevEdge.fill(null)\n prevEdge[0] = nodes.first().first()\n val visited = ArrayDeque().also{it.add(0)}\n while(queue.isNotEmpty() && queue.peek() != 1) {\n for (e in nodes[queue.poll()]) if (e.hasFlow && prevEdge[e.to] == null) {\n prevEdge[e.to] = e\n queue.add(e.to)\n visited.add(e.to)\n }\n }\n if (queue.isNotEmpty()) {\n return BooleanArray(m){false}\n }\n val result = BooleanArray(m){false}\n var bottleNeck = -1\n for (v in visited) {\n for (e in nodes[v]) {\n if (!e.hasFlow && prevEdge[e.to] == null) {\n bottleNeck = e.id\n }\n }\n }\n while(bottleNeck != -1) {\n visited.clear()\n queue.clear()\n result[bottleNeck] = true\n prevEdge[edges[bottleNeck].to] = nodes.first().first()\n queue.add(edges[bottleNeck].to)\n visited.add(edges[bottleNeck].to)\n bottleNeck = -1\n while(queue.isNotEmpty()) {\n for (e in nodes[queue.poll()]) if (e.hasFlow && prevEdge[e.to] == null) {\n prevEdge[e.to] = e\n queue.add(e.to)\n visited.add(e.to)\n }\n }\n for (v in visited) {\n for (e in nodes[v]) {\n if (!e.hasFlow && prevEdge[e.to] == null && edges[e.id].to == e.to) {\n bottleNeck = e.id\n }\n }\n }\n }\n return result\n}\nclass Edge(val id: Int, val from: Int, val to: Int, val cost: Int)\nclass FlowEdge(val id: Int, val to: Int, val pair: Int, var hasFlow: Boolean)\n", "problem_context": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], skipTags: [\"script\",\"noscript\",\"style\",\"textarea\",\"code\"], processEscapes: true }});\n\nProblem F\nPizza Delivery\n\nAlyssa is a college student, living in New Tsukuba City. All the streets in the city are one-way. A new social experiment starting tomorrow is on alternative traffic regulation reversing the one-way directions of street sections. Reversals will be on one single street section between two adjacent intersections for each day; the directions of all the other sections will not change, and the reversal will be canceled on the next day.\n\nAlyssa orders a piece of pizza everyday from the same pizzeria. The pizza is delivered along the shortest route from the intersection with the pizzeria to the intersection with Alyssa's house.\n\nAltering the traffic regulation may change the shortest route. Please tell Alyssa how the social experiment will affect the pizza delivery route.\n\nInput\n\nThe input consists of a single test case in the following format.\n\n$n$ $m$\n$a_1$ $b_1$ $c_1$\n...\n$a_m$ $b_m$ $c_m$\n\nThe first line contains two integers, $n$, the number of intersections, and $m$, the number of street sections in New Tsukuba City ($2 \\leq n \\leq 100 000, 1 \\leq m \\leq 100 000$). The intersections are numbered $1$ through $n$ and the street sections are numbered $1$ through $m$.\n\nThe following $m$ lines contain the information about the street sections, each with three integers $a_i$, $b_i$, and $c_i$ ($1 \\leq a_i n, 1 \\leq b_i \\leq n, a_i \\ne b_i, 1 \\leq c_i \\leq 100 000$). They mean that the street section numbered $i$ connects two intersections with the one-way direction from $a_i$ to $b_i$, which will be reversed on the $i$-th day. The street section has the length of $c_i$. Note that there may be more than one street section connecting the same pair of intersections.\n\nThe pizzeria is on the intersection 1 and Alyssa's house is on the intersection 2. It is guaranteed that at least one route exists from the pizzeria to Alyssa's before the social experiment starts.\n\nOutput\n\nThe output should contain $m$ lines. The $i$-th line should be\n\nHAPPY if the shortest route on the $i$-th day will become shorter,\n\nSOSO if the length of the shortest route on the $i$-th day will not change, and\n\nSAD if the shortest route on the $i$-th day will be longer or if there will be no route from the pizzeria to Alyssa's house.\n\nAlyssa doesn't mind whether the delivery bike can go back to the pizzeria or not.\n\nSample Input 1\n\n4 5\n1 3 5\n3 4 6\n4 2 7\n2 1 18\n2 3 12\n\nSample Output 1\n\nSAD\nSAD\nSAD\nSOSO\nHAPPY\n\nSample Input 2\n\n7 5\n1 3 2\n1 6 3\n4 2 4\n6 2 5\n7 5 6\n\nSample Output 2\n\nSOSO\nSAD\nSOSO\nSAD\nSOSO\n\nSample Input 3\n\n10 14\n1 7 9\n1 8 3\n2 8 4\n2 6 11\n3 7 8\n3 4 4\n3 2 1\n3 2 7\n4 8 4\n5 6 11\n5 8 12\n6 10 6\n7 10 8\n8 3 6\n\nSample Output 3\n\nSOSO\nSAD\nHAPPY\nSOSO\nSOSO\nSOSO\nSAD\nSOSO\nSOSO\nSOSO\nSOSO\nSOSO\nSOSO\nSAD", "sample_input": "4 5\n1 3 5\n3 4 6\n4 2 7\n2 1 18\n2 3 12\n"}, "reference_outputs": ["SAD\nSAD\nSAD\nSOSO\nHAPPY\n"], "source_document_id": "p00962", "source_text": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], skipTags: [\"script\",\"noscript\",\"style\",\"textarea\",\"code\"], processEscapes: true }});\n\nProblem F\nPizza Delivery\n\nAlyssa is a college student, living in New Tsukuba City. All the streets in the city are one-way. A new social experiment starting tomorrow is on alternative traffic regulation reversing the one-way directions of street sections. Reversals will be on one single street section between two adjacent intersections for each day; the directions of all the other sections will not change, and the reversal will be canceled on the next day.\n\nAlyssa orders a piece of pizza everyday from the same pizzeria. The pizza is delivered along the shortest route from the intersection with the pizzeria to the intersection with Alyssa's house.\n\nAltering the traffic regulation may change the shortest route. Please tell Alyssa how the social experiment will affect the pizza delivery route.\n\nInput\n\nThe input consists of a single test case in the following format.\n\n$n$ $m$\n$a_1$ $b_1$ $c_1$\n...\n$a_m$ $b_m$ $c_m$\n\nThe first line contains two integers, $n$, the number of intersections, and $m$, the number of street sections in New Tsukuba City ($2 \\leq n \\leq 100 000, 1 \\leq m \\leq 100 000$). The intersections are numbered $1$ through $n$ and the street sections are numbered $1$ through $m$.\n\nThe following $m$ lines contain the information about the street sections, each with three integers $a_i$, $b_i$, and $c_i$ ($1 \\leq a_i n, 1 \\leq b_i \\leq n, a_i \\ne b_i, 1 \\leq c_i \\leq 100 000$). They mean that the street section numbered $i$ connects two intersections with the one-way direction from $a_i$ to $b_i$, which will be reversed on the $i$-th day. The street section has the length of $c_i$. Note that there may be more than one street section connecting the same pair of intersections.\n\nThe pizzeria is on the intersection 1 and Alyssa's house is on the intersection 2. It is guaranteed that at least one route exists from the pizzeria to Alyssa's before the social experiment starts.\n\nOutput\n\nThe output should contain $m$ lines. The $i$-th line should be\n\nHAPPY if the shortest route on the $i$-th day will become shorter,\n\nSOSO if the length of the shortest route on the $i$-th day will not change, and\n\nSAD if the shortest route on the $i$-th day will be longer or if there will be no route from the pizzeria to Alyssa's house.\n\nAlyssa doesn't mind whether the delivery bike can go back to the pizzeria or not.\n\nSample Input 1\n\n4 5\n1 3 5\n3 4 6\n4 2 7\n2 1 18\n2 3 12\n\nSample Output 1\n\nSAD\nSAD\nSAD\nSOSO\nHAPPY\n\nSample Input 2\n\n7 5\n1 3 2\n1 6 3\n4 2 4\n6 2 5\n7 5 6\n\nSample Output 2\n\nSOSO\nSAD\nSOSO\nSAD\nSOSO\n\nSample Input 3\n\n10 14\n1 7 9\n1 8 3\n2 8 4\n2 6 11\n3 7 8\n3 4 4\n3 2 1\n3 2 7\n4 8 4\n5 6 11\n5 8 12\n6 10 6\n7 10 8\n8 3 6\n\nSample Output 3\n\nSOSO\nSAD\nHAPPY\nSOSO\nSOSO\nSOSO\nSAD\nSOSO\nSOSO\nSOSO\nSOSO\nSOSO\nSOSO\nSAD", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 4440, "cpu_time_ms": 1980, "memory_kb": 134868}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s563751964", "group_id": "codeNet:p01012", "input_text": "\nimport java.math.BigDecimal\n\n\ndata class CutParams(val m:Int, val n:Int) {\n val left:BigDecimal = BigDecimal(m).divide(BigDecimal(m).add(BigDecimal(n)), 30, BigDecimal.ROUND_HALF_UP)\n val right:BigDecimal = BigDecimal(n).divide(BigDecimal(m).add(BigDecimal(n)), 30, BigDecimal.ROUND_HALF_UP)\n}\nfun main(args:Array):Unit{\n val (m, n, x) = readLine()!!.split(' ').map(String::toInt)\n val (k, l, y) = readLine()!!.split(' ').map(String::toInt)\n val vertical = CutParams(m, n)\n val horizontal = CutParams(k, l)\n var ver = BigDecimal.ONE\n repeat(x) {\n ver = with(vertical){ver * (left * left + right * right) + left * right}\n }\n var hor = BigDecimal.ONE\n repeat(y){\n hor = with(horizontal){hor * (left * left + right * right) + left * right}\n }\n println(ver * hor)\n}\n", "language": "Kotlin", "metadata": {"date": 1528095836, "filename_ext": "kt", "original_language": "Kotlin", "problem_description_relpath": "problem_descriptions/p01012.html", "problem_id": "p01012", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p01012/input.txt", "sample_output_relpath": "derived/input_output/data/p01012/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p01012/Kotlin/s563751964.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s563751964", "user_id": "u514597327"}, "prompt_components": {"gold_output": "0.562500\n", "input_to_evaluate": "\nimport java.math.BigDecimal\n\n\ndata class CutParams(val m:Int, val n:Int) {\n val left:BigDecimal = BigDecimal(m).divide(BigDecimal(m).add(BigDecimal(n)), 30, BigDecimal.ROUND_HALF_UP)\n val right:BigDecimal = BigDecimal(n).divide(BigDecimal(m).add(BigDecimal(n)), 30, BigDecimal.ROUND_HALF_UP)\n}\nfun main(args:Array):Unit{\n val (m, n, x) = readLine()!!.split(' ').map(String::toInt)\n val (k, l, y) = readLine()!!.split(' ').map(String::toInt)\n val vertical = CutParams(m, n)\n val horizontal = CutParams(k, l)\n var ver = BigDecimal.ONE\n repeat(x) {\n ver = with(vertical){ver * (left * left + right * right) + left * right}\n }\n var hor = BigDecimal.ONE\n repeat(y){\n hor = with(horizontal){hor * (left * left + right * right) + left * right}\n }\n println(ver * hor)\n}\n", "problem_context": "Planarian Regeneration\n\nProblem\n\n皆さん、「プラナリア」って知っていますか?\n\nプラナリアとは、日本では川の上流の石や枯葉などの裏に張り付いて生息している水生生物です。\n\nプラナリアの最も優れた能力はその「再生能力」です。プラナリアの再生能力は著しく、例えば、三等分するとそれぞれが再生し、数週間後に��元の完全な状態のプラナリアが3匹できあがります。\n\nこの度、会津の山奥の上流にて発見された新種のプラナリアの姿は長方形をしていて、プラナリアはある法則により再生します。\nこのとき、プラナリアは下の図のように配置し、2つの手段でプラナリアの切断実験を行います。\n\nまず1つ目の手段として、垂直方向に切ることを考えます。一度の切断では、すべての断片を水平方向の長さが(断片の頭に近い部分):(断片の頭に遠い部分)=m :n になるように切断します。この動作をx 回繰り返します。\n\n次に2つ目の手段として、水平方向に切ることを考えます。一度の切断では、すべての断片を垂直方向の長さが(断片の右端に近い部分):(断片の左端に近い部分)=k :l に切断します。この動作をy 回繰り返します。これらの切断によって断片が移動することはありません。\n\n数週間後に、各断片が元の完全なプラナリアの状態に再生している確率は以下の式により求まります。\n\n上の図は、垂直方向に1:2で2回、水平方向に1:1で1回切断した状態です。\n\n以上の操作で切断した時の、数週間後に元の姿に再生しているプラナリアの数の期待値を求めてください。元のプラナリアの垂直方向の長さと水平方向の長さはともに1とします。\n\nInput\n\nm n x\nk l y\n\n入力では、6つの整数m , n , x , k , l , y が上記の入力フォーマットで与えられます。\n\nこれら6つの整数は問題文中のものと対応しており、水平方向にm :n で切断する動作をx 回、垂直方向にk :l で切断する動作をy 回繰り返します。\n\n1 ≤ m , n , k , l ≤ 100、 0 ≤ x , y ≤ 40 であり、 m , n と l , k はそれぞれ互いに素です。\n\nOutput\n\n一行に数週間後に元の姿に再生しているプラナリアの数の期待値を出力してください。\n\n出力は 10-6 以下の誤差ならば許容されます。\n\nSample Input 1\n\n1 1 1\n1 1 1\n\nSample Output 1\n\n0.562500\n\nSample Input 2\n\n1 2 2\n1 1 1\n\nSample Output 2\n\n0.490741\n\nSample Input 3\n\n1 2 0\n3 4 0\n\nSample Output 3\n\n1.000000\n\nNotes\n\nこの問題では、doubleよりも精度の高い浮動小数を使用することを推奨します。", "sample_input": "1 1 1\n1 1 1\n"}, "reference_outputs": ["0.562500\n"], "source_document_id": "p01012", "source_text": "Planarian Regeneration\n\nProblem\n\n皆さん、「プラナリア」って知っていますか?\n\nプラナリアとは、日本では川の上流の石や枯葉などの裏に張り付いて生息している水生生物です。\n\nプラナリアの最も優れた能力はその「再生能力」です。プラナリアの再生能力は著しく、例えば、三等分するとそれぞれが再生し、数週間後には元の完全な状態のプラナリアが3匹できあがります。\n\nこの度、会津の山奥の上流にて発見された新種のプラナリアの姿は長方形をしていて、プラナリアはある法則により再生します。\nこのとき、プラナリアは下の図のように配置し、2つの手段でプラナリアの切断実験を行います。\n\nまず1つ目の手段として、垂直方向に切ることを考えます。一度の切断では、すべての断片を水平方向の長さが(断片の頭に近い部分):(断片の頭に遠い部分)=m :n になるように切断します。この動作をx 回繰り返します。\n\n次に2つ目の手段として、水平方向に切ることを考えます。一度の切断では、すべての断片を垂直方向の長さが(断片の右端に近い部分):(断片の左端に近い部分)=k :l に切断します。この動作をy 回繰り返します。これらの切断によって断片が移動することはありません。\n\n数週間後に、各断片が元の完全なプラナリアの状態に再生している確率は以下の式により求まります。\n\n上の図は、垂直方向に1:2で2回、水平方向に1:1で1回切断した状態です。\n\n以上の操作で切断した時の、数週間後に元の姿に再生しているプラナリアの数の期待値を求めてください。元のプラナリアの垂直方向の長さと水平方向の長さはともに1とします。\n\nInput\n\nm n x\nk l y\n\n入力では、6つの整数m , n , x , k , l , y が上記の入力フォーマットで与えられます。\n\nこれら6つの整数は問題文中のものと対応しており、水平方向にm :n で切断する動作をx 回、垂直方向にk :l で切断する動作をy 回繰り返します。\n\n1 ≤ m , n , k , l ≤ 100、 0 ≤ x , y ≤ 40 であり、 m , n と l , k はそれぞれ互いに素です。\n\nOutput\n\n一行に数週間後に元の姿に再生しているプラナリアの���の期待値を出力してください。\n\n出力は 10-6 以下の誤差ならば許容されます。\n\nSample Input 1\n\n1 1 1\n1 1 1\n\nSample Output 1\n\n0.562500\n\nSample Input 2\n\n1 2 2\n1 1 1\n\nSample Output 2\n\n0.490741\n\nSample Input 3\n\n1 2 0\n3 4 0\n\nSample Output 3\n\n1.000000\n\nNotes\n\nこの問題では、doubleよりも精度の高い浮動小数を使用することを推奨します。", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 824, "cpu_time_ms": 200, "memory_kb": 35100}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s667927236", "group_id": "codeNet:p01094", "input_text": "import java.util.Scanner;\n\nfun main(args: Array) {\n\tval scanner = Scanner(System.`in`)\n\tval ans = mutableListOf()\n\twhile (true) {\n\t\tval n = scanner.nextInt()\n\t\tif (n==0) break\n\t\tval map = mutableMapOf()\n\t\tvar max = Pair('-', 0)\n\t\tvar second = 0\n\t\tvar win: Pair? = null\n\t\tfor (i in 1..n) {\n\t\t\tval c = scanner.next().toCharArray()[0]\n\t\t\tmap[c] = map.getOrElse(c){0} + 1\n\t\t\tif (map[c]!! > max.second) max = Pair(c, map[c]!!)\n\t\t\telse if (map[c]!! > second) second = map[c]!!\n\t\t\tval r = n-i\n\t\t\tif (max.second > second+r) {\n\t\t\t\twin = Pair(max.first, i)\n\t\t\t\trepeat(r) {scanner.next()}\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t\tif (win!=null) ans.add(\"${win.first} ${win.second}\")\n\t\telse ans.add(\"TIE\")\n\t}\n\tans.forEach { println(it) }\n}\n", "language": "Kotlin", "metadata": {"date": 1569765130, "filename_ext": "kt", "original_language": "Kotlin", "problem_description_relpath": "problem_descriptions/p01094.html", "problem_id": "p01094", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p01094/input.txt", "sample_output_relpath": "derived/input_output/data/p01094/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p01094/Kotlin/s667927236.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s667927236", "user_id": "u335407822"}, "prompt_components": {"gold_output": "A 1\nTIE\nTIE\nK 4\nX 5\nA 7\nU 8\n", "input_to_evaluate": "import java.util.Scanner;\n\nfun main(args: Array) {\n\tval scanner = Scanner(System.`in`)\n\tval ans = mutableListOf()\n\twhile (true) {\n\t\tval n = scanner.nextInt()\n\t\tif (n==0) break\n\t\tval map = mutableMapOf()\n\t\tvar max = Pair('-', 0)\n\t\tvar second = 0\n\t\tvar win: Pair? = null\n\t\tfor (i in 1..n) {\n\t\t\tval c = scanner.next().toCharArray()[0]\n\t\t\tmap[c] = map.getOrElse(c){0} + 1\n\t\t\tif (map[c]!! > max.second) max = Pair(c, map[c]!!)\n\t\t\telse if (map[c]!! > second) second = map[c]!!\n\t\t\tval r = n-i\n\t\t\tif (max.second > second+r) {\n\t\t\t\twin = Pair(max.first, i)\n\t\t\t\trepeat(r) {scanner.next()}\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t\tif (win!=null) ans.add(\"${win.first} ${win.second}\")\n\t\telse ans.add(\"TIE\")\n\t}\n\tans.forEach { println(it) }\n}\n", "problem_context": "Look for the Winner!\n\nThe citizens of TKB City are famous for their deep love in elections and vote counting.\nToday they hold an election for the next chairperson of the electoral commission.\nNow the voting has just been closed and the counting is going to start.\nThe TKB citizens have strong desire to know the winner as early as possible during vote counting.\n\nThe election candidate receiving the most votes shall be the next chairperson.\nSuppose for instance that we have three candidates A, B, and C and ten votes.\nSuppose also that we have already counted six of the ten votes and the vote counts of A, B, and C are four, one, and one, respectively.\nAt this moment, every candidate has a chance to receive four more votes and so everyone can still be the winner.\nHowever, if the next vote counted is cast for A, A is ensured to be the winner since A already has five votes and B or C can have at most four votes at the end.\nIn this example, therefore, the TKB citizens can know the winner just when the seventh vote is counted.\n\nYour mission is to write a program that receives every vote counted, one by one, identifies the winner, and determines when the winner gets ensured.\n\nInput\n\nThe input consists of at most 1500 datasets, each consisting of two lines in the following format.\n\nn\n\nc1 c2 … cn\n\nn in the first line represents the number of votes, and is a positive integer no greater than 100.\nThe second line represents the n votes, separated by a space.\nEach ci (1 ≤ i ≤ n) is a single uppercase letter, i.e. one of 'A' through 'Z'.\nThis represents the election candidate for which the i-th vote was cast.\nCounting shall be done in the given order from c1 to cn.\n\nYou should assume that at least two stand as candidates even when all the votes are cast for one candidate.\n\nThe end of the input is indicated by a line containing a zero.\n\nOutput\n\nFor each dataset, unless the election ends in a tie, output a single line containing an uppercase letter c and an integer d separated by a space:\nc should represent the election winner and d should represent after counting how many votes the winner is identified.\nOtherwise, that is, if the election ends in a tie, output a single line containing `TIE'.\n\nSample Input\n\n1\nA\n4\nA A B B\n5\nL M N L N\n6\nK K K K K K\n6\nX X X Y Z X\n10\nA A A B A C A C C B\n10\nU U U U U V V W W W\n0\n\nOutput for the Sample Input\n\nA 1\nTIE\nTIE\nK 4\nX 5\nA 7\nU 8", "sample_input": "1\nA\n4\nA A B B\n5\nL M N L N\n6\nK K K K K K\n6\nX X X Y Z X\n10\nA A A B A C A C C B\n10\nU U U U U V V W W W\n0\n"}, "reference_outputs": ["A 1\nTIE\nTIE\nK 4\nX 5\nA 7\nU 8\n"], "source_document_id": "p01094", "source_text": "Look for the Winner!\n\nThe citizens of TKB City are famous for their deep love in elections and vote counting.\nToday they hold an election for the next chairperson of the electoral commission.\nNow the voting has just been closed and the counting is going to start.\nThe TKB citizens have strong desire to know the winner as early as possible during vote counting.\n\nThe election candidate receiving the most votes shall be the next chairperson.\nSuppose for instance that we have three candidates A, B, and C and ten votes.\nSuppose also that we have already counted six of the ten votes and the vote counts of A, B, and C are four, one, and one, respectively.\nAt this moment, every candidate has a chance to receive four more votes and so everyone can still be the winner.\nHowever, if the next vote counted is cast for A, A is ensured to be the winner since A already has five votes and B or C can have at most four votes at the end.\nIn this example, therefore, the TKB citizens can know the winner just when the seventh vote is counted.\n\nYour mission is to write a program that receives every vote counted, one by one, identifies the winner, and determines when the winner gets ensured.\n\nInput\n\nThe input consists of at most 1500 datasets, each consisting of two lines in the following format.\n\nn\n\nc1 c2 … cn\n\nn in the first line represents the number of votes, and is a positive integer no greater than 100.\nThe second line represents the n votes, separated by a space.\nEach ci (1 ≤ i ≤ n) is a single uppercase letter, i.e. one of 'A' through 'Z'.\nThis represents the election candidate for which the i-th vote was cast.\nCounting shall be done in the given order from c1 to cn.\n\nYou should assume that at least two stand as candidates even when all the votes are cast for one candidate.\n\nThe end of the input is indicated by a line containing a zero.\n\nOutput\n\nFor each dataset, unless the election ends in a tie, output a single line containing an uppercase letter c and an integer d separated by a space:\nc should represent the election winner and d should represent after counting how many votes the winner is identified.\nOtherwise, that is, if the election ends in a tie, output a single line containing `TIE'.\n\nSample Input\n\n1\nA\n4\nA A B B\n5\nL M N L N\n6\nK K K K K K\n6\nX X X Y Z X\n10\nA A A B A C A C C B\n10\nU U U U U V V W W W\n0\n\nOutput for the Sample Input\n\nA 1\nTIE\nTIE\nK 4\nX 5\nA 7\nU 8", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 746, "cpu_time_ms": 430, "memory_kb": 48016}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s776257110", "group_id": "codeNet:p02233", "input_text": "fun main(args: Array) {\n val n = readLine()?.toInt() ?: return\n val fibonacci = Fibonacci()\n println(fibonacci.getFibonacci(n))\n}\n\nclass Fibonacci {\n private val fibonacciMemo = mutableMapOf(0 to 1, 1 to 1)\n\n fun getFibonacci(n: Int): Int {\n return if (fibonacciMemo[n] != null) {\n fibonacciMemo[n]!!\n } else {\n fibonacciMemo[n] = getFibonacci(n - 2) + getFibonacci(n - 1)\n fibonacciMemo[n]!!\n }\n }\n}\n", "language": "Kotlin", "metadata": {"date": 1547520319, "filename_ext": "kt", "original_language": "Kotlin", "problem_description_relpath": "problem_descriptions/p02233.html", "problem_id": "p02233", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02233/input.txt", "sample_output_relpath": "derived/input_output/data/p02233/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02233/Kotlin/s776257110.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s776257110", "user_id": "u462634153"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "fun main(args: Array) {\n val n = readLine()?.toInt() ?: return\n val fibonacci = Fibonacci()\n println(fibonacci.getFibonacci(n))\n}\n\nclass Fibonacci {\n private val fibonacciMemo = mutableMapOf(0 to 1, 1 to 1)\n\n fun getFibonacci(n: Int): Int {\n return if (fibonacciMemo[n] != null) {\n fibonacciMemo[n]!!\n } else {\n fibonacciMemo[n] = getFibonacci(n - 2) + getFibonacci(n - 1)\n fibonacciMemo[n]!!\n }\n }\n}\n", "problem_context": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nFibonacci Number\n\nWrite a program which prints $n$-th fibonacci number for a given integer $n$. The $n$-th fibonacci number is defined by the following recursive formula:\n\n\\begin{equation*}\nfib(n)= \\left \\{\n\\begin{array}{ll}\n1  & (n = 0) \\\\\n1  & (n = 1) \\\\\nfib(n - 1) + fib(n - 2) & \\\\\n\\end{array}\n\\right.\n\\end{equation*}\n\nInput\n\nAn integer $n$ is given.\n\noutput\n\nPrint the $n$-th fibonacci number in a line.\n\nConstraints\n\n$0 \\leq n \\leq 44$\n\nSample Input 1\n\n3\n\nSample Output 1\n\n3", "sample_input": "3\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02233", "source_text": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nFibonacci Number\n\nWrite a program which prints $n$-th fibonacci number for a given integer $n$. The $n$-th fibonacci number is defined by the following recursive formula:\n\n\\begin{equation*}\nfib(n)= \\left \\{\n\\begin{array}{ll}\n1  & (n = 0) \\\\\n1  & (n = 1) \\\\\nfib(n - 1) + fib(n - 2) & \\\\\n\\end{array}\n\\right.\n\\end{equation*}\n\nInput\n\nAn integer $n$ is given.\n\noutput\n\nPrint the $n$-th fibonacci number in a line.\n\nConstraints\n\n$0 \\leq n \\leq 44$\n\nSample Input 1\n\n3\n\nSample Output 1\n\n3", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 481, "cpu_time_ms": 100, "memory_kb": 26360}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s105489217", "group_id": "codeNet:p02255", "input_text": "import java.util.Scanner\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val n = sc.nextInt()\n val array = IntArray(n){sc.nextInt()}\n for (i in 1 until array.size) {\n println(array.joinToString(\" \"))\n val v = array[i]\n var j = i - 1\n while (j >= 0 && array[j] > v) {\n array[j+1] = array[j]\n j--\n }\n array[j+1] = v\n }\n println(array.joinToString(\" \"))\n}\n", "language": "Kotlin", "metadata": {"date": 1544068861, "filename_ext": "kt", "original_language": "Kotlin", "problem_description_relpath": "problem_descriptions/p02255.html", "problem_id": "p02255", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02255/input.txt", "sample_output_relpath": "derived/input_output/data/p02255/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02255/Kotlin/s105489217.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s105489217", "user_id": "u462634153"}, "prompt_components": {"gold_output": "5 2 4 6 1 3\n2 5 4 6 1 3\n2 4 5 6 1 3\n2 4 5 6 1 3\n1 2 4 5 6 3\n1 2 3 4 5 6\n", "input_to_evaluate": "import java.util.Scanner\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val n = sc.nextInt()\n val array = IntArray(n){sc.nextInt()}\n for (i in 1 until array.size) {\n println(array.joinToString(\" \"))\n val v = array[i]\n var j = i - 1\n while (j >= 0 && array[j] > v) {\n array[j+1] = array[j]\n j--\n }\n array[j+1] = v\n }\n println(array.joinToString(\" \"))\n}\n", "problem_context": "Insertion Sort\n\nWrite a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:\n\nfor i = 1 to A.length-1\nkey = A[i]\n/* insert A[i] into the sorted sequence A[0,...,j-1] */\nj = i - 1\nwhile j >= 0 and A[j] > key\nA[j+1] = A[j]\nj--\nA[j+1] = key\n\nNote that, indices for array elements are based on 0-origin.\n\nTo illustrate the algorithms, your program should trace intermediate result for each step.\n\nInput\n\nThe first line of the input includes an integer N, the number of elements in the sequence.\n\nIn the second line, N elements of the sequence are given separated by a single space.\n\nOutput\n\nThe output consists of N lines. Please output the intermediate sequence in a line for each step. Elements of the sequence should be separated by single space.\n\nConstraints\n\n1 ≤ N ≤ 100\n\nSample Input 1\n\n6\n5 2 4 6 1 3\n\nSample Output 1\n\n5 2 4 6 1 3\n2 5 4 6 1 3\n2 4 5 6 1 3\n2 4 5 6 1 3\n1 2 4 5 6 3\n1 2 3 4 5 6\n\nSample Input 2\n\n3\n1 2 3\n\nSample Output 2\n\n1 2 3\n1 2 3\n1 2 3\n\nHint\n\nTemplate in C", "sample_input": "6\n5 2 4 6 1 3\n"}, "reference_outputs": ["5 2 4 6 1 3\n2 5 4 6 1 3\n2 4 5 6 1 3\n2 4 5 6 1 3\n1 2 4 5 6 3\n1 2 3 4 5 6\n"], "source_document_id": "p02255", "source_text": "Insertion Sort\n\nWrite a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:\n\nfor i = 1 to A.length-1\nkey = A[i]\n/* insert A[i] into the sorted sequence A[0,...,j-1] */\nj = i - 1\nwhile j >= 0 and A[j] > key\nA[j+1] = A[j]\nj--\nA[j+1] = key\n\nNote that, indices for array elements are based on 0-origin.\n\nTo illustrate the algorithms, your program should trace intermediate result for each step.\n\nInput\n\nThe first line of the input includes an integer N, the number of elements in the sequence.\n\nIn the second line, N elements of the sequence are given separated by a single space.\n\nOutput\n\nThe output consists of N lines. Please output the intermediate sequence in a line for each step. Elements of the sequence should be separated by single space.\n\nConstraints\n\n1 ≤ N ≤ 100\n\nSample Input 1\n\n6\n5 2 4 6 1 3\n\nSample Output 1\n\n5 2 4 6 1 3\n2 5 4 6 1 3\n2 4 5 6 1 3\n2 4 5 6 1 3\n1 2 4 5 6 3\n1 2 3 4 5 6\n\nSample Input 2\n\n3\n1 2 3\n\nSample Output 2\n\n1 2 3\n1 2 3\n1 2 3\n\nHint\n\nTemplate in C", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 404, "cpu_time_ms": 130, "memory_kb": 30832}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s207292112", "group_id": "codeNet:p02257", "input_text": "fun main(args: Array) {\n val n = readLine()!!.toInt()\n val array = (1..n).map {\n readLine()!!.toInt()\n }\n\n println(array.asSequence().filter { isPrime(it) }.count())\n}\n\nfun isPrime(n: Int): Boolean {\n when (n) {\n 0 -> return false\n 1 -> return false\n else -> {\n for (i in 2..Math.sqrt(n.toDouble()).toInt())\n if (n % i == 0)\n return false\n return true\n }\n }\n}\n", "language": "Kotlin", "metadata": {"date": 1562401012, "filename_ext": "kt", "original_language": "Kotlin", "problem_description_relpath": "problem_descriptions/p02257.html", "problem_id": "p02257", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02257/input.txt", "sample_output_relpath": "derived/input_output/data/p02257/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02257/Kotlin/s207292112.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s207292112", "user_id": "u208877383"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "fun main(args: Array) {\n val n = readLine()!!.toInt()\n val array = (1..n).map {\n readLine()!!.toInt()\n }\n\n println(array.asSequence().filter { isPrime(it) }.count())\n}\n\nfun isPrime(n: Int): Boolean {\n when (n) {\n 0 -> return false\n 1 -> return false\n else -> {\n for (i in 2..Math.sqrt(n.toDouble()).toInt())\n if (n % i == 0)\n return false\n return true\n }\n }\n}\n", "problem_context": "Prime Numbers\n\nA prime number is a natural number which has exactly two distinct natural number divisors: 1 and itself. For example, the first four prime numbers are: 2, 3, 5 and 7.\n\nWrite a program which reads a list of N integers and prints the number of prime numbers in the list.\n\nInput\n\nThe first line contains an integer N, the number of elements in the list.\n\nN numbers are given in the following lines.\n\nOutput\n\nPrint the number of prime numbers in the given list.\n\nConstraints\n\n1 ≤ N ≤ 10000\n\n2 ≤ an element of the list ≤ 108\n\nSample Input 1\n\n5\n2\n3\n4\n5\n6\n\nSample Output 1\n\n3\n\nSample Input 2\n\n11\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n\nSample Output 2\n\n4", "sample_input": "5\n2\n3\n4\n5\n6\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02257", "source_text": "Prime Numbers\n\nA prime number is a natural number which has exactly two distinct natural number divisors: 1 and itself. For example, the first four prime numbers are: 2, 3, 5 and 7.\n\nWrite a program which reads a list of N integers and prints the number of prime numbers in the list.\n\nInput\n\nThe first line contains an integer N, the number of elements in the list.\n\nN numbers are given in the following lines.\n\nOutput\n\nPrint the number of prime numbers in the given list.\n\nConstraints\n\n1 ≤ N ≤ 10000\n\n2 ≤ an element of the list ≤ 108\n\nSample Input 1\n\n5\n2\n3\n4\n5\n6\n\nSample Output 1\n\n3\n\nSample Input 2\n\n11\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n\nSample Output 2\n\n4", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 190, "memory_kb": 32868}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s498338282", "group_id": "codeNet:p02259", "input_text": "fun main(args: Array) {\n val n = readLine()!!.toInt()\n val xs = readLine()!!.split(' ').map { it.toInt() }.toMutableList()\n var cnt = 0\n for (i in 0 until n) {\n for (j in n - 1 downTo i + 1) {\n if (xs[j] < xs[j - 1]) {\n val t = xs[j]\n xs[j] = xs[j - 1]\n xs[j- 1] = t\n cnt++\n }\n }\n }\n println(xs.joinToString(\" \"))\n println(cnt)\n}\n", "language": "Kotlin", "metadata": {"date": 1565051481, "filename_ext": "kt", "original_language": "Kotlin", "problem_description_relpath": "problem_descriptions/p02259.html", "problem_id": "p02259", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02259/input.txt", "sample_output_relpath": "derived/input_output/data/p02259/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02259/Kotlin/s498338282.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s498338282", "user_id": "u079779562"}, "prompt_components": {"gold_output": "1 2 3 4 5\n8\n", "input_to_evaluate": "fun main(args: Array) {\n val n = readLine()!!.toInt()\n val xs = readLine()!!.split(' ').map { it.toInt() }.toMutableList()\n var cnt = 0\n for (i in 0 until n) {\n for (j in n - 1 downTo i + 1) {\n if (xs[j] < xs[j - 1]) {\n val t = xs[j]\n xs[j] = xs[j - 1]\n xs[j- 1] = t\n cnt++\n }\n }\n }\n println(xs.joinToString(\" \"))\n println(cnt)\n}\n", "problem_context": "Bubble Sort\n\nWrite a program of the Bubble Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:\n\nBubbleSort(A)\n1 for i = 0 to A.length-1\n2 for j = A.length-1 downto i+1\n3 if A[j] < A[j-1]\n4 swap A[j] and A[j-1]\n\nNote that, indices for array elements are based on 0-origin.\n\nYour program should also print the number of swap operations defined in line 4 of the pseudocode.\n\nInput\n\nThe first line of the input includes an integer N, the number of elements in the sequence.\n\nIn the second line, N elements of the sequence are given separated by spaces characters.\n\nOutput\n\nThe output consists of 2 lines.\n\nIn the first line, please print the sorted sequence. Two contiguous elements of the sequence should be separated by a space character.\n\nIn the second line, please print the number of swap operations.\n\nConstraints\n\n1 ≤ N ≤ 100\n\nSample Input 1\n\n5\n5 3 2 4 1\n\nSample Output 1\n\n1 2 3 4 5\n8\n\nSample Input 2\n\n6\n5 2 4 6 1 3\n\nSample Output 2\n\n1 2 3 4 5 6\n9", "sample_input": "5\n5 3 2 4 1\n"}, "reference_outputs": ["1 2 3 4 5\n8\n"], "source_document_id": "p02259", "source_text": "Bubble Sort\n\nWrite a program of the Bubble Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:\n\nBubbleSort(A)\n1 for i = 0 to A.length-1\n2 for j = A.length-1 downto i+1\n3 if A[j] < A[j-1]\n4 swap A[j] and A[j-1]\n\nNote that, indices for array elements are based on 0-origin.\n\nYour program should also print the number of swap operations defined in line 4 of the pseudocode.\n\nInput\n\nThe first line of the input includes an integer N, the number of elements in the sequence.\n\nIn the second line, N elements of the sequence are given separated by spaces characters.\n\nOutput\n\nThe output consists of 2 lines.\n\nIn the first line, please print the sorted sequence. Two contiguous elements of the sequence should be separated by a space character.\n\nIn the second line, please print the number of swap operations.\n\nConstraints\n\n1 ≤ N ≤ 100\n\nSample Input 1\n\n5\n5 3 2 4 1\n\nSample Output 1\n\n1 2 3 4 5\n8\n\nSample Input 2\n\n6\n5 2 4 6 1 3\n\nSample Output 2\n\n1 2 3 4 5 6\n9", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 140, "memory_kb": 34452}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s841975891", "group_id": "codeNet:p02263", "input_text": "class Stack(size: Int) {\n\n private val elements = arrayOfNulls(size)\n\n private var top = 0\n\n private fun isEmpty() = top == 0\n\n private fun isFull() = elements.size == top\n\n fun push(element: T) {\n if (isFull()) throw Exception(\"error\")\n elements[top] = element\n top++\n }\n\n @Suppress(\"UNCHECKED_CAST\")\n fun pop() : T {\n if (isEmpty()) throw Exception(\"error\")\n val element = elements[top - 1]\n elements[top - 1] = null\n top--\n return element as T\n }\n}\n\nfun isNumber(num: String): Boolean {\n try {\n num.toInt()\n } catch (e: NumberFormatException) {\n return false\n }\n return true\n}\n\nfun calc(firstNumber: Int, secondNumber: Int, operator: String): Int {\n when (operator) {\n \"+\" -> return firstNumber + secondNumber\n \"-\" -> return firstNumber - secondNumber\n \"*\" -> return firstNumber * secondNumber\n }\n return 0\n}\n\nfun main(args: Array) {\n val array = readLine()!!.split(\" \")\n val stack = Stack(array.size)\n\n array.forEach { item ->\n if (isNumber(item)) {\n stack.push(item)\n } else {\n val secondNumber = stack.pop()\n val firstNumber = stack.pop()\n val result = calc(firstNumber.toInt(), secondNumber.toInt(), item)\n stack.push(result.toString())\n }\n }\n println(stack.pop())\n}\n", "language": "Kotlin", "metadata": {"date": 1562461081, "filename_ext": "kt", "original_language": "Kotlin", "problem_description_relpath": "problem_descriptions/p02263.html", "problem_id": "p02263", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02263/input.txt", "sample_output_relpath": "derived/input_output/data/p02263/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02263/Kotlin/s841975891.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s841975891", "user_id": "u208877383"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "class Stack(size: Int) {\n\n private val elements = arrayOfNulls(size)\n\n private var top = 0\n\n private fun isEmpty() = top == 0\n\n private fun isFull() = elements.size == top\n\n fun push(element: T) {\n if (isFull()) throw Exception(\"error\")\n elements[top] = element\n top++\n }\n\n @Suppress(\"UNCHECKED_CAST\")\n fun pop() : T {\n if (isEmpty()) throw Exception(\"error\")\n val element = elements[top - 1]\n elements[top - 1] = null\n top--\n return element as T\n }\n}\n\nfun isNumber(num: String): Boolean {\n try {\n num.toInt()\n } catch (e: NumberFormatException) {\n return false\n }\n return true\n}\n\nfun calc(firstNumber: Int, secondNumber: Int, operator: String): Int {\n when (operator) {\n \"+\" -> return firstNumber + secondNumber\n \"-\" -> return firstNumber - secondNumber\n \"*\" -> return firstNumber * secondNumber\n }\n return 0\n}\n\nfun main(args: Array) {\n val array = readLine()!!.split(\" \")\n val stack = Stack(array.size)\n\n array.forEach { item ->\n if (isNumber(item)) {\n stack.push(item)\n } else {\n val secondNumber = stack.pop()\n val firstNumber = stack.pop()\n val result = calc(firstNumber.toInt(), secondNumber.toInt(), item)\n stack.push(result.toString())\n }\n }\n println(stack.pop())\n}\n", "problem_context": "Reverse Polish notation is a notation where every operator follows all of its operands. For example, an expression (1+2)*(5+4) in the conventional Polish notation can be represented as 1 2 + 5 4 + * in the Reverse Polish notation. One of advantages of the Reverse Polish notation is that it is parenthesis-free.\n\nWrite a program which reads an expression in the Reverse Polish notation and prints the computational result.\n\nAn expression in the Reverse Polish notation is calculated using a stack. To evaluate the expression, the program should read symbols in order. If the symbol is an operand, the corresponding value should be pushed into the stack. On the other hand, if the symbols is an operator, the program should pop two elements from the stack, perform the corresponding operations, then push the result in to the stack. The program should repeat this operations.\n\nInput\n\nAn expression is given in a line. Two consequtive symbols (operand or operator) are separated by a space character.\n\nYou can assume that +, - and * are given as the operator and an operand is a positive integer less than 106\n\nOutput\n\nPrint the computational result in a line.\n\nConstraints\n\n2 ≤ the number of operands in the expression ≤ 100\n\n1 ≤ the number of operators in the expression ≤ 99\n\n-1 × 109 ≤ values in the stack ≤ 109\n\nSample Input 1\n\n1 2 +\n\nSample Output 1\n\n3\n\nSample Input 2\n\n1 2 + 3 4 - *\n\nSample Output 2\n\n-3\n\nNotes\n\nTemplate in C", "sample_input": "1 2 +\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02263", "source_text": "Reverse Polish notation is a notation where every operator follows all of its operands. For example, an expression (1+2)*(5+4) in the conventional Polish notation can be represented as 1 2 + 5 4 + * in the Reverse Polish notation. One of advantages of the Reverse Polish notation is that it is parenthesis-free.\n\nWrite a program which reads an expression in the Reverse Polish notation and prints the computational result.\n\nAn expression in the Reverse Polish notation is calculated using a stack. To evaluate the expression, the program should read symbols in order. If the symbol is an operand, the corresponding value should be pushed into the stack. On the other hand, if the symbols is an operator, the program should pop two elements from the stack, perform the corresponding operations, then push the result in to the stack. The program should repeat this operations.\n\nInput\n\nAn expression is given in a line. Two consequtive symbols (operand or operator) are separated by a space character.\n\nYou can assume that +, - and * are given as the operator and an operand is a positive integer less than 106\n\nOutput\n\nPrint the computational result in a line.\n\nConstraints\n\n2 ≤ the number of operands in the expression ≤ 100\n\n1 ≤ the number of operators in the expression ≤ 99\n\n-1 × 109 ≤ values in the stack ≤ 109\n\nSample Input 1\n\n1 2 +\n\nSample Output 1\n\n3\n\nSample Input 2\n\n1 2 + 3 4 - *\n\nSample Output 2\n\n-3\n\nNotes\n\nTemplate in C", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1429, "cpu_time_ms": 150, "memory_kb": 33596}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s619104388", "group_id": "codeNet:p02302", "input_text": "import java.lang.Math.*\nimport java.util.*\n\ndata class Point(val x:Double, val y:Double)\nclass Line private constructor (private val a:Double, private val b:Double, private val c:Double){ // ay = bx + c\n fun crossPoint(other:Line):Point?{\n return when{\n isPallarel(other) -> null\n else -> {\n val newy = (c * other.b - other.c * b) / (a * other.b - other.a * b) // ab'y - a'by = bb'x - bb'x + cb' - c'b\n val newx = (c * other.a - other.c * a) / (a * other.b - other.a * b) // aa'y - aa'y = a'bx - ab'x + ca' - c'a\n Point(newx, newy)\n }\n }\n }\n fun isPallarel(other:Line):Boolean {\n return a * other.b == b * other.a\n }\n fun x(y:Double):Double? {\n return when{\n isHorizontal() -> null\n else -> (a * y - c) / b\n }\n }\n fun x(y:Int):Double? = x(y.toDouble())\n fun y(x:Double):Double? {\n return when{\n isVertical() -> null\n else -> (b * x + c) / a\n }\n }\n fun y(x:Int):Double? = y(x.toDouble())\n fun isHorizontal():Boolean = b == 0e0\n fun isVertical():Boolean = a == 0e0\n companion object {\n fun lineOnTwoPoint(a:Point, b:Point):Line {\n return Line(a.x - b.x, a.y - b.y, b.y * (a.x - b.x) - b.x * (a.y - b.y))\n }\n }\n}\ndata class Vector(val x:Double, val y:Double){\n fun cross(other:Vector):Double = x * other.y - y * other.x\n fun length():Double = sqrt(x * x + y * y)\n companion object {\n fun fromToPoint(from:Point, to:Point):Vector = Vector(to.x - from.x, to.y - from.y)\n }\n}\ndata class Edge(val from:Point, val to:Point)\nfun area(a:Point, b:Point):Double {\n return (a.y + b.y) * (a.x - b.x) / 2\n}\nfun Double.between(a:Double, b:Double):Boolean {\n return (a - this) * (b - this) <= 0\n}\nfun crossPoint(line:Line, edge:Edge):Point? {\n return line.crossPoint(Line.lineOnTwoPoint(edge.from, edge.to))?.let{\n when{\n it.x.between(edge.from.x, edge.to.x) && it.y.between(edge.from.y, edge.to.y) -> it\n else -> null\n }\n }\n}\nfun convexArea(points:Array):Double {\n var res:Double = 0.0\n for (i in 1 until points.size){\n res += area(points[i], points[i - 1])\n }\n return (res + area(points[0], points[points.size - 1])).let{if (it < 0) -it else it}\n}\nfun cutConvex(points:Array, from:Point, to:Point):Array {\n val line = Line.lineOnTwoPoint(from, to)\n val isLeft = Vector.fromToPoint(from, to).cross(Vector.fromToPoint(from, points[0])) > 0\n val (a, b) = points.indices.filter{i ->\n crossPoint(line, Edge(points[i], points[(i + 1) % points.size]))?.let{\n when {\n points[i].x == it.x && points[i].y == it.y -> null\n else -> it\n }\n } != null\n }\n //println(\"${points[a]}, ${points[a + 1]}, ${crossPoint(line, Edge(points[a], points[a + 1]))}\")\n //println(\"${points[b]}, ${points[(b + 1) % points.size]}, ${crossPoint(line, Edge(points[b], points[(b + 1) % points.size]))}\")\n val res = LinkedList()\n if (isLeft){\n for (i in 0 .. a){\n res.push(points[i])\n }\n res.push(crossPoint(line, Edge(points[a], points[(a + 1) % points.size]))!!)\n res.push(crossPoint(line, Edge(points[b], points[(b + 1) % points.size]))!!)\n for (i in (b + 1) until points.size){\n res.push(points[i])\n }\n }else{\n res.push(crossPoint(line, Edge(points[a], points[(a + 1) % points.size]))!!)\n for (i in (a + 1) .. b){\n res.push(points[i])\n }\n res.push(crossPoint(line, Edge(points[b], points[(b + 1) % points.size]))!!)\n }\n return res.toTypedArray()\n}\nfun main(args:Array):Unit{\n val n = readLine()!!.toInt()\n val points = Array(n){\n val (x, y) = readLine()!!.split(' ').map(String::toDouble)\n Point(x, y)\n }\n val q = readLine()!!.toInt()\n for (i in 0 until q){\n val (x1, y1, x2, y2) = readLine()!!.split(' ').map(String::toDouble)\n val cut = cutConvex(points, Point(x1, y1), Point(x2, y2))\n println(convexArea(cut))\n }\n}\n", "language": "Kotlin", "metadata": {"date": 1527853887, "filename_ext": "kt", "original_language": "Kotlin", "problem_description_relpath": "problem_descriptions/p02302.html", "problem_id": "p02302", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02302/input.txt", "sample_output_relpath": "derived/input_output/data/p02302/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02302/Kotlin/s619104388.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s619104388", "user_id": "u514597327"}, "prompt_components": {"gold_output": "2.00000000\n4.00000000\n", "input_to_evaluate": "import java.lang.Math.*\nimport java.util.*\n\ndata class Point(val x:Double, val y:Double)\nclass Line private constructor (private val a:Double, private val b:Double, private val c:Double){ // ay = bx + c\n fun crossPoint(other:Line):Point?{\n return when{\n isPallarel(other) -> null\n else -> {\n val newy = (c * other.b - other.c * b) / (a * other.b - other.a * b) // ab'y - a'by = bb'x - bb'x + cb' - c'b\n val newx = (c * other.a - other.c * a) / (a * other.b - other.a * b) // aa'y - aa'y = a'bx - ab'x + ca' - c'a\n Point(newx, newy)\n }\n }\n }\n fun isPallarel(other:Line):Boolean {\n return a * other.b == b * other.a\n }\n fun x(y:Double):Double? {\n return when{\n isHorizontal() -> null\n else -> (a * y - c) / b\n }\n }\n fun x(y:Int):Double? = x(y.toDouble())\n fun y(x:Double):Double? {\n return when{\n isVertical() -> null\n else -> (b * x + c) / a\n }\n }\n fun y(x:Int):Double? = y(x.toDouble())\n fun isHorizontal():Boolean = b == 0e0\n fun isVertical():Boolean = a == 0e0\n companion object {\n fun lineOnTwoPoint(a:Point, b:Point):Line {\n return Line(a.x - b.x, a.y - b.y, b.y * (a.x - b.x) - b.x * (a.y - b.y))\n }\n }\n}\ndata class Vector(val x:Double, val y:Double){\n fun cross(other:Vector):Double = x * other.y - y * other.x\n fun length():Double = sqrt(x * x + y * y)\n companion object {\n fun fromToPoint(from:Point, to:Point):Vector = Vector(to.x - from.x, to.y - from.y)\n }\n}\ndata class Edge(val from:Point, val to:Point)\nfun area(a:Point, b:Point):Double {\n return (a.y + b.y) * (a.x - b.x) / 2\n}\nfun Double.between(a:Double, b:Double):Boolean {\n return (a - this) * (b - this) <= 0\n}\nfun crossPoint(line:Line, edge:Edge):Point? {\n return line.crossPoint(Line.lineOnTwoPoint(edge.from, edge.to))?.let{\n when{\n it.x.between(edge.from.x, edge.to.x) && it.y.between(edge.from.y, edge.to.y) -> it\n else -> null\n }\n }\n}\nfun convexArea(points:Array):Double {\n var res:Double = 0.0\n for (i in 1 until points.size){\n res += area(points[i], points[i - 1])\n }\n return (res + area(points[0], points[points.size - 1])).let{if (it < 0) -it else it}\n}\nfun cutConvex(points:Array, from:Point, to:Point):Array {\n val line = Line.lineOnTwoPoint(from, to)\n val isLeft = Vector.fromToPoint(from, to).cross(Vector.fromToPoint(from, points[0])) > 0\n val (a, b) = points.indices.filter{i ->\n crossPoint(line, Edge(points[i], points[(i + 1) % points.size]))?.let{\n when {\n points[i].x == it.x && points[i].y == it.y -> null\n else -> it\n }\n } != null\n }\n //println(\"${points[a]}, ${points[a + 1]}, ${crossPoint(line, Edge(points[a], points[a + 1]))}\")\n //println(\"${points[b]}, ${points[(b + 1) % points.size]}, ${crossPoint(line, Edge(points[b], points[(b + 1) % points.size]))}\")\n val res = LinkedList()\n if (isLeft){\n for (i in 0 .. a){\n res.push(points[i])\n }\n res.push(crossPoint(line, Edge(points[a], points[(a + 1) % points.size]))!!)\n res.push(crossPoint(line, Edge(points[b], points[(b + 1) % points.size]))!!)\n for (i in (b + 1) until points.size){\n res.push(points[i])\n }\n }else{\n res.push(crossPoint(line, Edge(points[a], points[(a + 1) % points.size]))!!)\n for (i in (a + 1) .. b){\n res.push(points[i])\n }\n res.push(crossPoint(line, Edge(points[b], points[(b + 1) % points.size]))!!)\n }\n return res.toTypedArray()\n}\nfun main(args:Array):Unit{\n val n = readLine()!!.toInt()\n val points = Array(n){\n val (x, y) = readLine()!!.split(' ').map(String::toDouble)\n Point(x, y)\n }\n val q = readLine()!!.toInt()\n for (i in 0 until q){\n val (x1, y1, x2, y2) = readLine()!!.split(' ').map(String::toDouble)\n val cut = cutConvex(points, Point(x1, y1), Point(x2, y2))\n println(convexArea(cut))\n }\n}\n", "problem_context": "Convex Cut\n\nAs shown in the figure above, cut a convex polygon g by a line p1p2 and print the area of the cut polygon which is on the left-hand side of the line.\n\ng is represented by a sequence of points p1, p2,..., pn where line segments connecting pi and pi+1 (1 ≤ i ≤ n−1) are sides of the convex polygon. The line segment connecting pn and p1 is also a side of the polygon.\n\nInput\n\nThe input is given in the following format:\n\ng (the sequence of the points of the polygon)\nq (the number of queries = the number of target lines)\n1st query\n2nd query\n:\nqth query\n\ng is given as a sequence of points p1,..., pn in the following format:\n\nn\nx1 y1\nx2 y2\n:\nxn yn\n\nThe first integer n is the number of points. The coordinate of the i-th point pi is given by two integers xi and yi. The coordinates of points are given in the order of counter-clockwise visit of them. Note that all interior angles of given convex polygons are less than or equal to 180.\n\nFor each query, a line represented by two points p1 and p2 is given. The coordinates of the points are given by four integers p1x, p1y, p2x and p2y.\n\nOutput\n\nFor each query, print the area of the cut polygon. The output values should be in a decimal fraction with an error less than 0.00001.\n\nConstraints\n\n3 ≤ n ≤ 100\n\n1 ≤ q ≤ 100\n\n-10000 ≤ xi, yi ≤ 10000\n\n-10000 ≤ p1x,p1y,p2x,p2y ≤ 10000\n\nNo point in g will occur more than once.\n\np1 ≠ p2\n\nSample Input\n\n4\n1 1\n4 1\n4 3\n1 3\n2\n2 0 2 4\n2 4 2 0\n\nSample Output\n\n2.00000000\n4.00000000", "sample_input": "4\n1 1\n4 1\n4 3\n1 3\n2\n2 0 2 4\n2 4 2 0\n"}, "reference_outputs": ["2.00000000\n4.00000000\n"], "source_document_id": "p02302", "source_text": "Convex Cut\n\nAs shown in the figure above, cut a convex polygon g by a line p1p2 and print the area of the cut polygon which is on the left-hand side of the line.\n\ng is represented by a sequence of points p1, p2,..., pn where line segments connecting pi and pi+1 (1 ≤ i ≤ n−1) are sides of the convex polygon. The line segment connecting pn and p1 is also a side of the polygon.\n\nInput\n\nThe input is given in the following format:\n\ng (the sequence of the points of the polygon)\nq (the number of queries = the number of target lines)\n1st query\n2nd query\n:\nqth query\n\ng is given as a sequence of points p1,..., pn in the following format:\n\nn\nx1 y1\nx2 y2\n:\nxn yn\n\nThe first integer n is the number of points. The coordinate of the i-th point pi is given by two integers xi and yi. The coordinates of points are given in the order of counter-clockwise visit of them. Note that all interior angles of given convex polygons are less than or equal to 180.\n\nFor each query, a line represented by two points p1 and p2 is given. The coordinates of the points are given by four integers p1x, p1y, p2x and p2y.\n\nOutput\n\nFor each query, print the area of the cut polygon. The output values should be in a decimal fraction with an error less than 0.00001.\n\nConstraints\n\n3 ≤ n ≤ 100\n\n1 ≤ q ≤ 100\n\n-10000 ≤ xi, yi ≤ 10000\n\n-10000 ≤ p1x,p1y,p2x,p2y ≤ 10000\n\nNo point in g will occur more than once.\n\np1 ≠ p2\n\nSample Input\n\n4\n1 1\n4 1\n4 3\n1 3\n2\n2 0 2 4\n2 4 2 0\n\nSample Output\n\n2.00000000\n4.00000000", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 4185, "cpu_time_ms": 130, "memory_kb": 32080}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s434395676", "group_id": "codeNet:p02303", "input_text": "import java.math.BigDecimal\nimport java.util.*\nimport kotlin.system.measureTimeMillis\n//var time = 0L\n\nfun solve(a: Array>, sortedAxis: Int = -1): Double {\n if (a.size <= 3) {\n var dist = 1000000000000.0\n for ((i, p1) in a.withIndex()) {\n for (p2 in a.takeLast(a.size-i-1)) {\n dist = Math.min(dist, Math.sqrt(Math.pow(p1[0]-p2[0], 2.0)+Math.pow(p1[1]-p2[1], 2.0)))\n }\n }\n return dist\n }\n\n val mid = a.size/2\n //val startt = System.nanoTime()\n val xSetLen = HashSet(a.map { it -> it[0] }).size\n val (axis1, axis2) = if (xSetLen >= mid) Pair(0, 1) else Pair(1, 0)\n if (axis1 != sortedAxis) a.sortBy { it[axis1] }\n //time += System.nanoTime() - startt\n\n val leftArray = a.sliceArray(0 until mid)\n val rightArray = a.sliceArray(mid until a.size)\n var delta = Math.min(\n solve(leftArray, axis1),\n solve(rightArray, axis1)\n )\n val median = a[mid][axis1]\n val mid_a = a.filter { it[axis1] in median-delta..median+delta }.sortedBy { it[axis2] }\n\n for (i in 0 until mid_a.size-1) {\n val ub = mid_a[i][axis2] + delta\n for (j in i+1 until mid_a.size) {\n if (mid_a[i][axis2] >= ub) break\n delta = Math.min(delta,\n Math.sqrt(Math.pow(mid_a[i][0]-mid_a[j][0], 2.0)+Math.pow(mid_a[i][1]-mid_a[j][1], 2.0)))\n }\n }\n\n return delta\n}\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val N = sc.nextInt()\n val a = Array(N, { arrayOf(java.lang.Double.parseDouble(sc.next()), java.lang.Double.parseDouble(sc.next())) })\n //val tt = measureTimeMillis {\n val ans = solve(a)\n println(BigDecimal.valueOf(ans).toPlainString())\n //}\n //println(tt)\n //print(time/1000000)\n}\n", "language": "Kotlin", "metadata": {"date": 1528612072, "filename_ext": "kt", "original_language": "Kotlin", "problem_description_relpath": "problem_descriptions/p02303.html", "problem_id": "p02303", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02303/input.txt", "sample_output_relpath": "derived/input_output/data/p02303/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02303/Kotlin/s434395676.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s434395676", "user_id": "u197615397"}, "prompt_components": {"gold_output": "1.000000\n", "input_to_evaluate": "import java.math.BigDecimal\nimport java.util.*\nimport kotlin.system.measureTimeMillis\n//var time = 0L\n\nfun solve(a: Array>, sortedAxis: Int = -1): Double {\n if (a.size <= 3) {\n var dist = 1000000000000.0\n for ((i, p1) in a.withIndex()) {\n for (p2 in a.takeLast(a.size-i-1)) {\n dist = Math.min(dist, Math.sqrt(Math.pow(p1[0]-p2[0], 2.0)+Math.pow(p1[1]-p2[1], 2.0)))\n }\n }\n return dist\n }\n\n val mid = a.size/2\n //val startt = System.nanoTime()\n val xSetLen = HashSet(a.map { it -> it[0] }).size\n val (axis1, axis2) = if (xSetLen >= mid) Pair(0, 1) else Pair(1, 0)\n if (axis1 != sortedAxis) a.sortBy { it[axis1] }\n //time += System.nanoTime() - startt\n\n val leftArray = a.sliceArray(0 until mid)\n val rightArray = a.sliceArray(mid until a.size)\n var delta = Math.min(\n solve(leftArray, axis1),\n solve(rightArray, axis1)\n )\n val median = a[mid][axis1]\n val mid_a = a.filter { it[axis1] in median-delta..median+delta }.sortedBy { it[axis2] }\n\n for (i in 0 until mid_a.size-1) {\n val ub = mid_a[i][axis2] + delta\n for (j in i+1 until mid_a.size) {\n if (mid_a[i][axis2] >= ub) break\n delta = Math.min(delta,\n Math.sqrt(Math.pow(mid_a[i][0]-mid_a[j][0], 2.0)+Math.pow(mid_a[i][1]-mid_a[j][1], 2.0)))\n }\n }\n\n return delta\n}\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val N = sc.nextInt()\n val a = Array(N, { arrayOf(java.lang.Double.parseDouble(sc.next()), java.lang.Double.parseDouble(sc.next())) })\n //val tt = measureTimeMillis {\n val ans = solve(a)\n println(BigDecimal.valueOf(ans).toPlainString())\n //}\n //println(tt)\n //print(time/1000000)\n}\n", "problem_context": "Closest Pair\n\nFor given n points in metric space, find the distance of the closest points.\n\nInput\n\nn\nx0 y0\nx1 y1\n:\nxn-1 yn-1\n\nThe first integer n is the number of points.\n\nIn the following n lines, the coordinate of the i-th point is given by two real numbers xi and yi. Each value is a real number with at most 6 digits after the decimal point.\n\nOutput\n\nPrint the distance in a line. The output values should be in a decimal fraction with an error less than 0.000001.\n\nConstraints\n\n2 ≤ n ≤ 100,000\n\n-100 ≤ x, y ≤ 100\n\nSample Input 1\n\n2\n0.0 0.0\n1.0 0.0\n\nSample Output 1\n\n1.000000\n\nSample Input 2\n\n3\n0.0 0.0\n2.0 0.0\n1.0 1.0\n\nSample Output 2\n\n1.41421356237", "sample_input": "2\n0.0 0.0\n1.0 0.0\n"}, "reference_outputs": ["1.000000\n"], "source_document_id": "p02303", "source_text": "Closest Pair\n\nFor given n points in metric space, find the distance of the closest points.\n\nInput\n\nn\nx0 y0\nx1 y1\n:\nxn-1 yn-1\n\nThe first integer n is the number of points.\n\nIn the following n lines, the coordinate of the i-th point is given by two real numbers xi and yi. Each value is a real number with at most 6 digits after the decimal point.\n\nOutput\n\nPrint the distance in a line. The output values should be in a decimal fraction with an error less than 0.000001.\n\nConstraints\n\n2 ≤ n ≤ 100,000\n\n-100 ≤ x, y ≤ 100\n\nSample Input 1\n\n2\n0.0 0.0\n1.0 0.0\n\nSample Output 1\n\n1.000000\n\nSample Input 2\n\n3\n0.0 0.0\n2.0 0.0\n1.0 1.0\n\nSample Output 2\n\n1.41421356237", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1810, "cpu_time_ms": 2110, "memory_kb": 133888}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s620023451", "group_id": "codeNet:p02368", "input_text": "\nimport java.util.*\n\nclass UnionFindTree{\n private var mParent:UnionFindTree? = null\n private fun Parent():UnionFindTree {\n return when(mParent) {\n null -> this\n else -> {\n mParent = mParent!!.Parent()\n mParent !!\n }\n }\n }\n fun Join(other:UnionFindTree):Unit {\n if (!IsSameUnion(other)){\n Parent().mParent = other.Parent()\n }\n }\n fun IsSameUnion(other:UnionFindTree):Boolean = Parent() == other.Parent()\n}\ndata class Edge(val from:Node, val to:Node)\nclass Node(val Id:Int){\n private var mForwardEdges: LinkedList = LinkedList()\n private var mReverseEdges: LinkedList = LinkedList()\n fun ForwardEdges():Iterable = mForwardEdges\n fun ReverseEdges():Iterable = mReverseEdges\n fun AddEdge(edge:Edge):Unit {\n val (from, to) = edge\n when{\n from == this -> mForwardEdges.push(to)\n to == this -> mReverseEdges.push(from)\n }\n }\n}\nfun DFS(current:Node, numArray:Array, init:Int):Int {\n val next = current.ForwardEdges().filter{node -> numArray[node.Id] == -1}\n numArray[current.Id] = 0\n numArray[current.Id] =\n if (next.isEmpty()) init + 1\n else next.fold(init){p, n -> DFS(n, numArray, p)} + 1\n return numArray[current.Id]\n}\nfun InvDFS(current:Node, uft:Array, isSearched:Array):Unit{\n current.ReverseEdges().forEach {\n when{\n !isSearched[it.Id] -> {\n isSearched[it.Id] = true\n uft[current.Id].Join(uft[it.Id])\n InvDFS(it, uft, isSearched)\n }\n }\n }\n}\n\nfun main(args:Array):Unit{\n val (v, e) = readLine()!!.split(' ').map(String::toInt)\n val nodes = Array(v){Node(it)}\n for (i in 0 until e){\n val (from, to) = readLine()!!.split(' ').map(String::toInt)\n val edge = Edge(nodes[from], nodes[to])\n edge.from.AddEdge(edge)\n edge.to.AddEdge(edge)\n }\n val nums = Array(v){-1}\n nodes.fold(0){ init, node ->\n if (nums[node.Id] == -1)\n DFS(node, nums, init)\n else\n init\n }\n val isSearched = Array(v){false}\n val uft = Array(v){UnionFindTree()}\n nums.withIndex().sortedByDescending { it.value }.map {\n nodes[it.index]\n }.forEach { node ->\n if (!isSearched[node.Id]){\n isSearched[node.Id] = true\n InvDFS(node, uft, isSearched)\n }\n }\n for (i in 0 until readLine()!!.toInt()){\n val (a, b) = readLine()!!.split(' ').map(String::toInt)\n println(if (uft[a].IsSameUnion(uft[b])) 1 else 0)\n }\n}\n", "language": "Kotlin", "metadata": {"date": 1527241389, "filename_ext": "kt", "original_language": "Kotlin", "problem_description_relpath": "problem_descriptions/p02368.html", "problem_id": "p02368", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02368/input.txt", "sample_output_relpath": "derived/input_output/data/p02368/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02368/Kotlin/s620023451.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s620023451", "user_id": "u514597327"}, "prompt_components": {"gold_output": "1\n0\n1\n1\n", "input_to_evaluate": "\nimport java.util.*\n\nclass UnionFindTree{\n private var mParent:UnionFindTree? = null\n private fun Parent():UnionFindTree {\n return when(mParent) {\n null -> this\n else -> {\n mParent = mParent!!.Parent()\n mParent !!\n }\n }\n }\n fun Join(other:UnionFindTree):Unit {\n if (!IsSameUnion(other)){\n Parent().mParent = other.Parent()\n }\n }\n fun IsSameUnion(other:UnionFindTree):Boolean = Parent() == other.Parent()\n}\ndata class Edge(val from:Node, val to:Node)\nclass Node(val Id:Int){\n private var mForwardEdges: LinkedList = LinkedList()\n private var mReverseEdges: LinkedList = LinkedList()\n fun ForwardEdges():Iterable = mForwardEdges\n fun ReverseEdges():Iterable = mReverseEdges\n fun AddEdge(edge:Edge):Unit {\n val (from, to) = edge\n when{\n from == this -> mForwardEdges.push(to)\n to == this -> mReverseEdges.push(from)\n }\n }\n}\nfun DFS(current:Node, numArray:Array, init:Int):Int {\n val next = current.ForwardEdges().filter{node -> numArray[node.Id] == -1}\n numArray[current.Id] = 0\n numArray[current.Id] =\n if (next.isEmpty()) init + 1\n else next.fold(init){p, n -> DFS(n, numArray, p)} + 1\n return numArray[current.Id]\n}\nfun InvDFS(current:Node, uft:Array, isSearched:Array):Unit{\n current.ReverseEdges().forEach {\n when{\n !isSearched[it.Id] -> {\n isSearched[it.Id] = true\n uft[current.Id].Join(uft[it.Id])\n InvDFS(it, uft, isSearched)\n }\n }\n }\n}\n\nfun main(args:Array):Unit{\n val (v, e) = readLine()!!.split(' ').map(String::toInt)\n val nodes = Array(v){Node(it)}\n for (i in 0 until e){\n val (from, to) = readLine()!!.split(' ').map(String::toInt)\n val edge = Edge(nodes[from], nodes[to])\n edge.from.AddEdge(edge)\n edge.to.AddEdge(edge)\n }\n val nums = Array(v){-1}\n nodes.fold(0){ init, node ->\n if (nums[node.Id] == -1)\n DFS(node, nums, init)\n else\n init\n }\n val isSearched = Array(v){false}\n val uft = Array(v){UnionFindTree()}\n nums.withIndex().sortedByDescending { it.value }.map {\n nodes[it.index]\n }.forEach { node ->\n if (!isSearched[node.Id]){\n isSearched[node.Id] = true\n InvDFS(node, uft, isSearched)\n }\n }\n for (i in 0 until readLine()!!.toInt()){\n val (a, b) = readLine()!!.split(' ').map(String::toInt)\n println(if (uft[a].IsSameUnion(uft[b])) 1 else 0)\n }\n}\n", "problem_context": "Strongly Connected Components\n\nA direced graph is strongly connected if every two nodes are reachable from each other. In a strongly connected component of a directed graph, every two nodes of the component are mutually reachable.\n\nInput\n\nA directed graph G(V, E) and a sequence of queries where each query contains a pair of nodes u and v.\n\n|V| |E|\ns0 t0\ns1 t1\n:\ns|E|-1 t|E|-1\nQ\nu0 v0\nu1 v1\n:\nuQ-1 vQ-1\n\n|V| is the number of nodes and |E| is the number of edges in the graph. The graph nodes are named with the numbers 0, 1,..., |V|-1 respectively.\n\nsi and ti represent source and target nodes of i-th edge (directed).\n\nui and vi represent a pair of nodes given as the i-th query.\n\nOutput\n\nFor each query, pinrt \"1\" if the given nodes belong to the same strongly connected component, \"0\" otherwise.\n\nConstraints\n\n1 ≤ |V| ≤ 10,000\n\n0 ≤ |E| ≤ 30,000\n\n1 ≤ Q ≤ 100,000\n\nSample Input 1\n\n5 6\n0 1\n1 0\n1 2\n2 4\n4 3\n3 2\n4\n0 1\n0 3\n2 3\n3 4\n\nSample Output 1\n\n1\n0\n1\n1", "sample_input": "5 6\n0 1\n1 0\n1 2\n2 4\n4 3\n3 2\n4\n0 1\n0 3\n2 3\n3 4\n"}, "reference_outputs": ["1\n0\n1\n1\n"], "source_document_id": "p02368", "source_text": "Strongly Connected Components\n\nA direced graph is strongly connected if every two nodes are reachable from each other. In a strongly connected component of a directed graph, every two nodes of the component are mutually reachable.\n\nInput\n\nA directed graph G(V, E) and a sequence of queries where each query contains a pair of nodes u and v.\n\n|V| |E|\ns0 t0\ns1 t1\n:\ns|E|-1 t|E|-1\nQ\nu0 v0\nu1 v1\n:\nuQ-1 vQ-1\n\n|V| is the number of nodes and |E| is the number of edges in the graph. The graph nodes are named with the numbers 0, 1,..., |V|-1 respectively.\n\nsi and ti represent source and target nodes of i-th edge (directed).\n\nui and vi represent a pair of nodes given as the i-th query.\n\nOutput\n\nFor each query, pinrt \"1\" if the given nodes belong to the same strongly connected component, \"0\" otherwise.\n\nConstraints\n\n1 ≤ |V| ≤ 10,000\n\n0 ≤ |E| ≤ 30,000\n\n1 ≤ Q ≤ 100,000\n\nSample Input 1\n\n5 6\n0 1\n1 0\n1 2\n2 4\n4 3\n3 2\n4\n0 1\n0 3\n2 3\n3 4\n\nSample Output 1\n\n1\n0\n1\n1", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2695, "cpu_time_ms": 140, "memory_kb": 32284}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s893483862", "group_id": "codeNet:p02379", "input_text": "\nimport java.util.*\n\nfun main(args : Array) {\n\n val scanner = Scanner(System.`in`)\n val s = scanner.nextLine().split(\" \") ;\n\n val x1 = s[0].toDouble()\n val y1 = s[1].toDouble()\n val x2 = s[2].toDouble()\n val y2 = s[3].toDouble()\n\n val xLine = x2 - x1\n val yLine = y2 - y1\n\n val line = Math.sqrt( Math.pow(xLine, 2.0) + Math.pow(yLine, 2.0) )\n\n println(\"%.8f\".format(line))\n}\n\n", "language": "Kotlin", "metadata": {"date": 1529411495, "filename_ext": "kt", "original_language": "Kotlin", "problem_description_relpath": "problem_descriptions/p02379.html", "problem_id": "p02379", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02379/input.txt", "sample_output_relpath": "derived/input_output/data/p02379/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02379/Kotlin/s893483862.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s893483862", "user_id": "u932203900"}, "prompt_components": {"gold_output": "1.41421356\n", "input_to_evaluate": "\nimport java.util.*\n\nfun main(args : Array) {\n\n val scanner = Scanner(System.`in`)\n val s = scanner.nextLine().split(\" \") ;\n\n val x1 = s[0].toDouble()\n val y1 = s[1].toDouble()\n val x2 = s[2].toDouble()\n val y2 = s[3].toDouble()\n\n val xLine = x2 - x1\n val yLine = y2 - y1\n\n val line = Math.sqrt( Math.pow(xLine, 2.0) + Math.pow(yLine, 2.0) )\n\n println(\"%.8f\".format(line))\n}\n\n", "problem_context": "Distance\n\nWrite a program which calculates the distance between two points P1(x1, y1) and P2(x2, y2).\n\nInput\n\nFour real numbers x1, y1, x2 and y2 are given in a line.\n\nOutput\n\nPrint the distance in real number. The output should not contain an absolute error greater than 10-4.\n\nSample Input\n\n0 0 1 1\n\nSample Output\n\n1.41421356", "sample_input": "0 0 1 1\n"}, "reference_outputs": ["1.41421356\n"], "source_document_id": "p02379", "source_text": "Distance\n\nWrite a program which calculates the distance between two points P1(x1, y1) and P2(x2, y2).\n\nInput\n\nFour real numbers x1, y1, x2 and y2 are given in a line.\n\nOutput\n\nPrint the distance in real number. The output should not contain an absolute error greater than 10-4.\n\nSample Input\n\n0 0 1 1\n\nSample Output\n\n1.41421356", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 394, "cpu_time_ms": 150, "memory_kb": 33412}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s676843731", "group_id": "codeNet:p02390", "input_text": "fun main(args: Array) {\n val S = readLine()!!.toInt()\n\n println(\"${S / 3600}:${S % 3600 / 60}:${S % 60}\")\n}\n\n", "language": "Kotlin", "metadata": {"date": 1556082033, "filename_ext": "kt", "original_language": "Kotlin", "problem_description_relpath": "problem_descriptions/p02390.html", "problem_id": "p02390", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02390/input.txt", "sample_output_relpath": "derived/input_output/data/p02390/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02390/Kotlin/s676843731.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s676843731", "user_id": "u261260518"}, "prompt_components": {"gold_output": "13:2:59\n", "input_to_evaluate": "fun main(args: Array) {\n val S = readLine()!!.toInt()\n\n println(\"${S / 3600}:${S % 3600 / 60}:${S % 60}\")\n}\n\n", "problem_context": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nWatch\n\nWrite a program which reads an integer $S$ [second] and converts it to $h:m:s$ where $h$, $m$, $s$ denote hours, minutes (less than 60) and seconds (less than 60) respectively.\n\nInput\n\nAn integer $S$ is given in a line.\n\nOutput\n\nPrint $h$, $m$ and $s$ separated by ':'. You do not need to put '0' for a value, which consists of a digit.\n\nConstraints\n\n$0 \\leq S \\leq 86400$\n\nSample Input 1\n\n46979\n\nSample Output 1\n\n13:2:59", "sample_input": "46979\n"}, "reference_outputs": ["13:2:59\n"], "source_document_id": "p02390", "source_text": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nWatch\n\nWrite a program which reads an integer $S$ [second] and converts it to $h:m:s$ where $h$, $m$, $s$ denote hours, minutes (less than 60) and seconds (less than 60) respectively.\n\nInput\n\nAn integer $S$ is given in a line.\n\nOutput\n\nPrint $h$, $m$ and $s$ separated by ':'. You do not need to put '0' for a value, which consists of a digit.\n\nConstraints\n\n$0 \\leq S \\leq 86400$\n\nSample Input 1\n\n46979\n\nSample Output 1\n\n13:2:59", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 90, "memory_kb": 27284}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s700018143", "group_id": "codeNet:p02391", "input_text": "fun sle(a: Int, b: Int): String = when {\n a < b -> \"a < b\"\n a > b -> \"a > b\"\n else -> \"a == b\"\n}\n\nfun main(args: Array) {\n val (a,b) = readLine()!!.split(' ').map(String::toInt)\n\n println(sle(a,b))\n}\n\n", "language": "Kotlin", "metadata": {"date": 1568098546, "filename_ext": "kt", "original_language": "Kotlin", "problem_description_relpath": "problem_descriptions/p02391.html", "problem_id": "p02391", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02391/input.txt", "sample_output_relpath": "derived/input_output/data/p02391/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02391/Kotlin/s700018143.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s700018143", "user_id": "u641702731"}, "prompt_components": {"gold_output": "a\n", "input_to_evaluate": "fun sle(a: Int, b: Int): String = when {\n a < b -> \"a < b\"\n a > b -> \"a > b\"\n else -> \"a == b\"\n}\n\nfun main(args: Array) {\n val (a,b) = readLine()!!.split(' ').map(String::toInt)\n\n println(sle(a,b))\n}\n\n", "problem_context": "Small, Large, or Equal\n\nWrite a program which prints small/large/equal relation of given two integers a and b.\n\nInput\n\nTwo integers a and b separated by a single space are given in a line.\n\nOutput\n\nFor given two integers a and b, print\n\na < b\n\nif a is less than b,\n\na > b\n\nif a is greater than b, and\n\na == b\n\nif a equals to b.\n\nConstraints\n\n-1000 ≤ a, b ≤ 1000\n\nSample Input 1\n\n1 2\n\nSample Output 1\n\na < b\n\nSample Input 2\n\n4 3\n\nSample Output 2\n\na > b\n\nSample Input 3\n\n5 5\n\nSample Output 3\n\na == b", "sample_input": "1 2\n"}, "reference_outputs": ["a\n"], "source_document_id": "p02391", "source_text": "Small, Large, or Equal\n\nWrite a program which prints small/large/equal relation of given two integers a and b.\n\nInput\n\nTwo integers a and b separated by a single space are given in a line.\n\nOutput\n\nFor given two integers a and b, print\n\na < b\n\nif a is less than b,\n\na > b\n\nif a is greater than b, and\n\na == b\n\nif a equals to b.\n\nConstraints\n\n-1000 ≤ a, b ≤ 1000\n\nSample Input 1\n\n1 2\n\nSample Output 1\n\na < b\n\nSample Input 2\n\n4 3\n\nSample Output 2\n\na > b\n\nSample Input 3\n\n5 5\n\nSample Output 3\n\na == b", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 140, "memory_kb": 32140}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s347325178", "group_id": "codeNet:p02391", "input_text": "import java.util.Scanner\n\nfun main(args:Array){\n val cin = Scanner(System.`in`)\n val a = cin.nextInt()\n val b = cin.nextInt()\n\n if(a > b){\n\tprintln(\"a > b\")\n } \n \n if(a < b){\n\tprintln(\"a < b\")\n }\n\n if(a == b){\n\tprintln(\"a == b\")\n }\n} \n\n", "language": "Kotlin", "metadata": {"date": 1538910433, "filename_ext": "kt", "original_language": "Kotlin", "problem_description_relpath": "problem_descriptions/p02391.html", "problem_id": "p02391", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02391/input.txt", "sample_output_relpath": "derived/input_output/data/p02391/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02391/Kotlin/s347325178.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s347325178", "user_id": "u837508455"}, "prompt_components": {"gold_output": "a\n", "input_to_evaluate": "import java.util.Scanner\n\nfun main(args:Array){\n val cin = Scanner(System.`in`)\n val a = cin.nextInt()\n val b = cin.nextInt()\n\n if(a > b){\n\tprintln(\"a > b\")\n } \n \n if(a < b){\n\tprintln(\"a < b\")\n }\n\n if(a == b){\n\tprintln(\"a == b\")\n }\n} \n\n", "problem_context": "Small, Large, or Equal\n\nWrite a program which prints small/large/equal relation of given two integers a and b.\n\nInput\n\nTwo integers a and b separated by a single space are given in a line.\n\nOutput\n\nFor given two integers a and b, print\n\na < b\n\nif a is less than b,\n\na > b\n\nif a is greater than b, and\n\na == b\n\nif a equals to b.\n\nConstraints\n\n-1000 ≤ a, b ≤ 1000\n\nSample Input 1\n\n1 2\n\nSample Output 1\n\na < b\n\nSample Input 2\n\n4 3\n\nSample Output 2\n\na > b\n\nSample Input 3\n\n5 5\n\nSample Output 3\n\na == b", "sample_input": "1 2\n"}, "reference_outputs": ["a\n"], "source_document_id": "p02391", "source_text": "Small, Large, or Equal\n\nWrite a program which prints small/large/equal relation of given two integers a and b.\n\nInput\n\nTwo integers a and b separated by a single space are given in a line.\n\nOutput\n\nFor given two integers a and b, print\n\na < b\n\nif a is less than b,\n\na > b\n\nif a is greater than b, and\n\na == b\n\nif a equals to b.\n\nConstraints\n\n-1000 ≤ a, b ≤ 1000\n\nSample Input 1\n\n1 2\n\nSample Output 1\n\na < b\n\nSample Input 2\n\n4 3\n\nSample Output 2\n\na > b\n\nSample Input 3\n\n5 5\n\nSample Output 3\n\na == b", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 100, "memory_kb": 25640}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s599492890", "group_id": "codeNet:p02392", "input_text": "fun main(args: Array) {\n val (a,b,c) = readLine()!!.split(\" \").map{ Integer.parseInt(it) }\n println(if(a) {\n val (a,b,c) = readLine()!!.split(\" \").map{ Integer.parseInt(it) }\n println(if(a) {\n val sc = Scanner(System.`in`)\n val r = sc.nextDouble()\n println(\"${\"%.5f\".format(Math.PI*r*r)} ${\"%.5f\".format(2*Math.PI*r)}\")\n}\n", "language": "Kotlin", "metadata": {"date": 1576062464, "filename_ext": "kt", "original_language": "Kotlin", "problem_description_relpath": "problem_descriptions/p02400.html", "problem_id": "p02400", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02400/input.txt", "sample_output_relpath": "derived/input_output/data/p02400/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02400/Kotlin/s638155347.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s638155347", "user_id": "u294922877"}, "prompt_components": {"gold_output": "12.566371 12.566371\n", "input_to_evaluate": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val r = sc.nextDouble()\n println(\"${\"%.5f\".format(Math.PI*r*r)} ${\"%.5f\".format(2*Math.PI*r)}\")\n}\n", "problem_context": "Circle\n\nWrite a program which calculates the area and circumference of a circle for given radius r.\n\nInput\n\nA real number r is given.\n\nOutput\n\nPrint the area and circumference of the circle in a line. Put a single space between them. The output should not contain an absolute error greater than 10-5.\n\nConstraints\n\n0 < r < 10000\n\nSample Input 1\n\n2\n\nSample Output 1\n\n12.566371 12.566371\n\nSample Input 2\n\n3\n\nSample Output 2\n\n28.274334 18.849556", "sample_input": "2\n"}, "reference_outputs": ["12.566371 12.566371\n"], "source_document_id": "p02400", "source_text": "Circle\n\nWrite a program which calculates the area and circumference of a circle for given radius r.\n\nInput\n\nA real number r is given.\n\nOutput\n\nPrint the area and circumference of the circle in a line. Put a single space between them. The output should not contain an absolute error greater than 10-5.\n\nConstraints\n\n0 < r < 10000\n\nSample Input 1\n\n2\n\nSample Output 1\n\n12.566371 12.566371\n\nSample Input 2\n\n3\n\nSample Output 2\n\n28.274334 18.849556", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 100, "memory_kb": 27140}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s165439174", "group_id": "codeNet:p02401", "input_text": "fun main(args : Array) {\n while (true) {\n val variables = readLine()!!.split(\" \")\n val a = variables[0].toInt()\n val op = variables[1]\n val b = variables[2].toInt()\n\n if (\"?\" == op) {break}\n\n when (op) {\n \"+\" -> println(\"%d\".format(a + b))\n \"-\" -> println(\"%d\".format(a - b))\n \"*\" -> println(\"%d\".format(a * b))\n \"/\" -> println(\"%d\".format(a / b))\n }\n }\n}\n\n", "language": "Kotlin", "metadata": {"date": 1561686003, "filename_ext": "kt", "original_language": "Kotlin", "problem_description_relpath": "problem_descriptions/p02401.html", "problem_id": "p02401", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02401/input.txt", "sample_output_relpath": "derived/input_output/data/p02401/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02401/Kotlin/s165439174.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s165439174", "user_id": "u817810878"}, "prompt_components": {"gold_output": "3\n38\n26\n10\n108\n", "input_to_evaluate": "fun main(args : Array) {\n while (true) {\n val variables = readLine()!!.split(\" \")\n val a = variables[0].toInt()\n val op = variables[1]\n val b = variables[2].toInt()\n\n if (\"?\" == op) {break}\n\n when (op) {\n \"+\" -> println(\"%d\".format(a + b))\n \"-\" -> println(\"%d\".format(a - b))\n \"*\" -> println(\"%d\".format(a * b))\n \"/\" -> println(\"%d\".format(a / b))\n }\n }\n}\n\n", "problem_context": "Simple Calculator\n\nWrite a program which reads two integers a, b and an operator op, and then prints the value of a op b.\n\nThe operator op is '+', '-', '*' or '/' (sum, difference, product or quotient). The division should truncate any fractional part.\n\nInput\n\nThe input consists of multiple datasets. Each dataset is given in the following format.\n\na op b\n\nThe input ends with a dataset where op = '?'. Your program should not process for this dataset.\n\nOutput\n\nFor each dataset, print the value in a line.\n\nConstraints\n\n0 ≤ a, b ≤ 20000\n\nNo divisions by zero are given.\n\nSample Input 1\n\n1 + 2\n56 - 18\n13 * 2\n100 / 10\n27 + 81\n0 ? 0\n\nSample Output 1\n\n3\n38\n26\n10\n108", "sample_input": "1 + 2\n56 - 18\n13 * 2\n100 / 10\n27 + 81\n0 ? 0\n"}, "reference_outputs": ["3\n38\n26\n10\n108\n"], "source_document_id": "p02401", "source_text": "Simple Calculator\n\nWrite a program which reads two integers a, b and an operator op, and then prints the value of a op b.\n\nThe operator op is '+', '-', '*' or '/' (sum, difference, product or quotient). The division should truncate any fractional part.\n\nInput\n\nThe input consists of multiple datasets. Each dataset is given in the following format.\n\na op b\n\nThe input ends with a dataset where op = '?'. Your program should not process for this dataset.\n\nOutput\n\nFor each dataset, print the value in a line.\n\nConstraints\n\n0 ≤ a, b ≤ 20000\n\nNo divisions by zero are given.\n\nSample Input 1\n\n1 + 2\n56 - 18\n13 * 2\n100 / 10\n27 + 81\n0 ? 0\n\nSample Output 1\n\n3\n38\n26\n10\n108", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 464, "cpu_time_ms": 130, "memory_kb": 31892}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s949973907", "group_id": "codeNet:p02401", "input_text": "fun main(argv: Array) {\n val list: MutableList = mutableListOf()\n\n loop@ while (true) {\n val inputs = readLine()!!.split(' ')\n val a = inputs[0].toInt()\n val op = inputs[1]\n val b = inputs[2].toInt()\n val res = when (op) {\n \"+\" -> a+b\n \"-\" -> a-b\n \"*\" -> a*b\n \"/\" -> a/b\n else -> break@loop\n }\n list.add(res)\n }\n\n for (i in list.indices) {\n println(\"${list[i]}\")\n }\n}\n\n", "language": "Kotlin", "metadata": {"date": 1543849650, "filename_ext": "kt", "original_language": "Kotlin", "problem_description_relpath": "problem_descriptions/p02401.html", "problem_id": "p02401", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02401/input.txt", "sample_output_relpath": "derived/input_output/data/p02401/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02401/Kotlin/s949973907.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s949973907", "user_id": "u899067203"}, "prompt_components": {"gold_output": "3\n38\n26\n10\n108\n", "input_to_evaluate": "fun main(argv: Array) {\n val list: MutableList = mutableListOf()\n\n loop@ while (true) {\n val inputs = readLine()!!.split(' ')\n val a = inputs[0].toInt()\n val op = inputs[1]\n val b = inputs[2].toInt()\n val res = when (op) {\n \"+\" -> a+b\n \"-\" -> a-b\n \"*\" -> a*b\n \"/\" -> a/b\n else -> break@loop\n }\n list.add(res)\n }\n\n for (i in list.indices) {\n println(\"${list[i]}\")\n }\n}\n\n", "problem_context": "Simple Calculator\n\nWrite a program which reads two integers a, b and an operator op, and then prints the value of a op b.\n\nThe operator op is '+', '-', '*' or '/' (sum, difference, product or quotient). The division should truncate any fractional part.\n\nInput\n\nThe input consists of multiple datasets. Each dataset is given in the following format.\n\na op b\n\nThe input ends with a dataset where op = '?'. Your program should not process for this dataset.\n\nOutput\n\nFor each dataset, print the value in a line.\n\nConstraints\n\n0 ≤ a, b ≤ 20000\n\nNo divisions by zero are given.\n\nSample Input 1\n\n1 + 2\n56 - 18\n13 * 2\n100 / 10\n27 + 81\n0 ? 0\n\nSample Output 1\n\n3\n38\n26\n10\n108", "sample_input": "1 + 2\n56 - 18\n13 * 2\n100 / 10\n27 + 81\n0 ? 0\n"}, "reference_outputs": ["3\n38\n26\n10\n108\n"], "source_document_id": "p02401", "source_text": "Simple Calculator\n\nWrite a program which reads two integers a, b and an operator op, and then prints the value of a op b.\n\nThe operator op is '+', '-', '*' or '/' (sum, difference, product or quotient). The division should truncate any fractional part.\n\nInput\n\nThe input consists of multiple datasets. Each dataset is given in the following format.\n\na op b\n\nThe input ends with a dataset where op = '?'. Your program should not process for this dataset.\n\nOutput\n\nFor each dataset, print the value in a line.\n\nConstraints\n\n0 ≤ a, b ≤ 20000\n\nNo divisions by zero are given.\n\nSample Input 1\n\n1 + 2\n56 - 18\n13 * 2\n100 / 10\n27 + 81\n0 ? 0\n\nSample Output 1\n\n3\n38\n26\n10\n108", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 442, "cpu_time_ms": 130, "memory_kb": 32132}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s019651137", "group_id": "codeNet:p02404", "input_text": "fun main(args: Array) {\n while (true){\n val (h, w) = readLine()?.split(\" \")?.map { it.toInt() } ?: return\n if (h == 0 && w == 0) return\n for (i in h downTo 1){\n for (j in w downTo 1){\n when{\n j == 1 -> println(\"#\")\n i == 1 || i == h || j == w -> print(\"#\")\n else -> print(\".\")\n }\n }\n }\n println(\"\")\n }\n}\n", "language": "Kotlin", "metadata": {"date": 1515482139, "filename_ext": "kt", "original_language": "Kotlin", "problem_description_relpath": "problem_descriptions/p02404.html", "problem_id": "p02404", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02404/input.txt", "sample_output_relpath": "derived/input_output/data/p02404/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02404/Kotlin/s019651137.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s019651137", "user_id": "u418130569"}, "prompt_components": {"gold_output": "####\n#..#\n####\n\n######\n#....#\n#....#\n#....#\n######\n\n###\n#.#\n###\n", "input_to_evaluate": "fun main(args: Array) {\n while (true){\n val (h, w) = readLine()?.split(\" \")?.map { it.toInt() } ?: return\n if (h == 0 && w == 0) return\n for (i in h downTo 1){\n for (j in w downTo 1){\n when{\n j == 1 -> println(\"#\")\n i == 1 || i == h || j == w -> print(\"#\")\n else -> print(\".\")\n }\n }\n }\n println(\"\")\n }\n}\n", "problem_context": "Print a Frame\n\nDraw a frame which has a height of H cm and a width of W cm. For example, the following figure shows a frame which has a height of 6 cm and a width of 10 cm.\n\n##########\n#........#\n#........#\n#........#\n#........#\n##########\n\nInput\n\nThe input consists of multiple datasets. Each dataset consists of two integers H and W separated by a single space.\n\nThe input ends with two 0 (when both H and W are zero).\n\nOutput\n\nFor each dataset, print the frame made of '#' and '.'.\n\nPrint a blank line after each dataset.\n\nConstraints\n\n3 ≤ H ≤ 300\n\n3 ≤ W ≤ 300\n\nSample Input\n\n3 4\n5 6\n3 3\n0 0\n\nSample Output\n\n####\n#..#\n####\n\n######\n#....#\n#....#\n#....#\n######\n\n###\n#.#\n###", "sample_input": "3 4\n5 6\n3 3\n0 0\n"}, "reference_outputs": ["####\n#..#\n####\n\n######\n#....#\n#....#\n#....#\n######\n\n###\n#.#\n###\n"], "source_document_id": "p02404", "source_text": "Print a Frame\n\nDraw a frame which has a height of H cm and a width of W cm. For example, the following figure shows a frame which has a height of 6 cm and a width of 10 cm.\n\n##########\n#........#\n#........#\n#........#\n#........#\n##########\n\nInput\n\nThe input consists of multiple datasets. Each dataset consists of two integers H and W separated by a single space.\n\nThe input ends with two 0 (when both H and W are zero).\n\nOutput\n\nFor each dataset, print the frame made of '#' and '.'.\n\nPrint a blank line after each dataset.\n\nConstraints\n\n3 ≤ H ≤ 300\n\n3 ≤ W ≤ 300\n\nSample Input\n\n3 4\n5 6\n3 3\n0 0\n\nSample Output\n\n####\n#..#\n####\n\n######\n#....#\n#....#\n#....#\n######\n\n###\n#.#\n###", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 462, "cpu_time_ms": 310, "memory_kb": 39188}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s311848548", "group_id": "codeNet:p02408", "input_text": "fun main(args: Array) {\n\tval n = readLine()!!.toInt()\n\tval a = mutableListOf()\n\n\tfor (p in listOf('S', 'H', 'C', 'D')) {\n\t\tfor (i in 1 .. 13) {\n\t\t\ta.add(\"$p $i\")\n\t\t}\n\t}\n\tfor (i in 0 until n) {\n\t\ta.remove(readLine())\n\t}\n\tif (a.size != 0) println(a.joinToString(\"\\n\"))\n}\n", "language": "Kotlin", "metadata": {"date": 1537880297, "filename_ext": "kt", "original_language": "Kotlin", "problem_description_relpath": "problem_descriptions/p02408.html", "problem_id": "p02408", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02408/input.txt", "sample_output_relpath": "derived/input_output/data/p02408/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02408/Kotlin/s311848548.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s311848548", "user_id": "u973203074"}, "prompt_components": {"gold_output": "S 1\nH 3\nH 7\nC 12\nD 8\n", "input_to_evaluate": "fun main(args: Array) {\n\tval n = readLine()!!.toInt()\n\tval a = mutableListOf()\n\n\tfor (p in listOf('S', 'H', 'C', 'D')) {\n\t\tfor (i in 1 .. 13) {\n\t\t\ta.add(\"$p $i\")\n\t\t}\n\t}\n\tfor (i in 0 until n) {\n\t\ta.remove(readLine())\n\t}\n\tif (a.size != 0) println(a.joinToString(\"\\n\"))\n}\n", "problem_context": "Finding Missing Cards\n\nTaro is going to play a card game. However, now he has only n cards, even though there should be 52 cards (he has no Jokers).\n\nThe 52 cards include 13 ranks of each of the four suits: spade, heart, club and diamond.\n\nInput\n\nIn the first line, the number of cards n (n ≤ 52) is given.\n\nIn the following n lines, data of the n cards are given. Each card is given by a pair of a character and an integer which represent its suit and rank respectively. A suit is represented by 'S', 'H', 'C' and 'D' for spades, hearts, clubs and diamonds respectively. A rank is represented by an integer from 1 to 13.\n\nOutput\n\nPrint the missing cards. The same as the input format, each card should be printed with a character and an integer separated by a space character in a line.\nArrange the missing cards in the following priorities:\n\nPrint cards of spades, hearts, clubs and diamonds in this order.\n\nIf the suits are equal, print cards with lower ranks first.\n\nSample Input\n\n47\nS 10\nS 11\nS 12\nS 13\nH 1\nH 2\nS 6\nS 7\nS 8\nS 9\nH 6\nH 8\nH 9\nH 10\nH 11\nH 4\nH 5\nS 2\nS 3\nS 4\nS 5\nH 12\nH 13\nC 1\nC 2\nD 1\nD 2\nD 3\nD 4\nD 5\nD 6\nD 7\nC 3\nC 4\nC 5\nC 6\nC 7\nC 8\nC 9\nC 10\nC 11\nC 13\nD 9\nD 10\nD 11\nD 12\nD 13\n\nSample Output\n\nS 1\nH 3\nH 7\nC 12\nD 8\n\nNote\n\n      解説", "sample_input": "47\nS 10\nS 11\nS 12\nS 13\nH 1\nH 2\nS 6\nS 7\nS 8\nS 9\nH 6\nH 8\nH 9\nH 10\nH 11\nH 4\nH 5\nS 2\nS 3\nS 4\nS 5\nH 12\nH 13\nC 1\nC 2\nD 1\nD 2\nD 3\nD 4\nD 5\nD 6\nD 7\nC 3\nC 4\nC 5\nC 6\nC 7\nC 8\nC 9\nC 10\nC 11\nC 13\nD 9\nD 10\nD 11\nD 12\nD 13\n"}, "reference_outputs": ["S 1\nH 3\nH 7\nC 12\nD 8\n"], "source_document_id": "p02408", "source_text": "Finding Missing Cards\n\nTaro is going to play a card game. However, now he has only n cards, even though there should be 52 cards (he has no Jokers).\n\nThe 52 cards include 13 ranks of each of the four suits: spade, heart, club and diamond.\n\nInput\n\nIn the first line, the number of cards n (n ≤ 52) is given.\n\nIn the following n lines, data of the n cards are given. Each card is given by a pair of a character and an integer which represent its suit and rank respectively. A suit is represented by 'S', 'H', 'C' and 'D' for spades, hearts, clubs and diamonds respectively. A rank is represented by an integer from 1 to 13.\n\nOutput\n\nPrint the missing cards. The same as the input format, each card should be printed with a character and an integer separated by a space character in a line.\nArrange the missing cards in the following priorities:\n\nPrint cards of spades, hearts, clubs and diamonds in this order.\n\nIf the suits are equal, print cards with lower ranks first.\n\nSample Input\n\n47\nS 10\nS 11\nS 12\nS 13\nH 1\nH 2\nS 6\nS 7\nS 8\nS 9\nH 6\nH 8\nH 9\nH 10\nH 11\nH 4\nH 5\nS 2\nS 3\nS 4\nS 5\nH 12\nH 13\nC 1\nC 2\nD 1\nD 2\nD 3\nD 4\nD 5\nD 6\nD 7\nC 3\nC 4\nC 5\nC 6\nC 7\nC 8\nC 9\nC 10\nC 11\nC 13\nD 9\nD 10\nD 11\nD 12\nD 13\n\nSample Output\n\nS 1\nH 3\nH 7\nC 12\nD 8\n\nNote\n\n      解説", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 100, "memory_kb": 29460}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s358623370", "group_id": "codeNet:p02410", "input_text": "import java.util.*\n\n/**\n * 行列.\n */\ndata class Matrix(val elements: List>) {\n /**\n * 行数.\n */\n val row = this.elements.size\n /**\n * 列数.\n */\n val col = if (this.row > 0) this.elements[0].size else 0\n\n /**\n * 指定された行列の要素を返します.\n * @param row 行\n * @param col 列\n * @return 要素\n */\n fun get(row: Int, col: Int) = this.elements.get(row).get(col)\n\n /**\n * 行列の掛け算の結果を返します.\n * @param other 乗数の行列\n */\n fun times(other: Matrix): Matrix = Matrix(\n elements.map { e ->\n (0..other.col - 1).map { col ->\n e.foldIndexed(0, {row, acc, a -> acc + a * other.get(row, col)})\n }\n }\n )\n\n override fun toString(): String =\n this.elements.map { it.joinToString(\" \") }.joinToString(\"\\n\")\n}\n\nfun main(args: Array) {\n val scanner = Scanner(System.`in`)\n val n = scanner.nextInt()\n val m = scanner.nextInt()\n val A = Matrix((1..n).map {\n (1..m).map { scanner.nextInt() }\n })\n val b = Matrix((1..m).map {\n listOf(scanner.nextInt())\n })\n println(A.times(b))\n}\n", "language": "Kotlin", "metadata": {"date": 1580630886, "filename_ext": "kt", "original_language": "Kotlin", "problem_description_relpath": "problem_descriptions/p02410.html", "problem_id": "p02410", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02410/input.txt", "sample_output_relpath": "derived/input_output/data/p02410/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02410/Kotlin/s358623370.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s358623370", "user_id": "u684367399"}, "prompt_components": {"gold_output": "5\n6\n9\n", "input_to_evaluate": "import java.util.*\n\n/**\n * 行列.\n */\ndata class Matrix(val elements: List>) {\n /**\n * 行数.\n */\n val row = this.elements.size\n /**\n * 列数.\n */\n val col = if (this.row > 0) this.elements[0].size else 0\n\n /**\n * 指定された行列の要素を返します.\n * @param row 行\n * @param col 列\n * @return 要素\n */\n fun get(row: Int, col: Int) = this.elements.get(row).get(col)\n\n /**\n * 行列の掛け算の結果を返します.\n * @param other 乗数の行列\n */\n fun times(other: Matrix): Matrix = Matrix(\n elements.map { e ->\n (0..other.col - 1).map { col ->\n e.foldIndexed(0, {row, acc, a -> acc + a * other.get(row, col)})\n }\n }\n )\n\n override fun toString(): String =\n this.elements.map { it.joinToString(\" \") }.joinToString(\"\\n\")\n}\n\nfun main(args: Array) {\n val scanner = Scanner(System.`in`)\n val n = scanner.nextInt()\n val m = scanner.nextInt()\n val A = Matrix((1..n).map {\n (1..m).map { scanner.nextInt() }\n })\n val b = Matrix((1..m).map {\n listOf(scanner.nextInt())\n })\n println(A.times(b))\n}\n", "problem_context": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nMatrix Vector Multiplication\n\nWrite a program which reads a $ n \\times m$ matrix $A$ and a $m \\times 1$ vector $b$, and prints their product $Ab$.\n\nA column vector with m elements is represented by the following equation.\n\n\\[\nb = \\left(\n\\begin{array}{c}\nb_1 \\\\\nb_2 \\\\\n: \\\\\nb_m \\\\\n\\end{array}\n\\right)\n\\]\n\nA $n \\times m$ matrix with $m$ column vectors, each of which consists of $n$ elements, is represented by the following equation.\n\n\\[\nA = \\left(\n\\begin{array}{cccc}\na_{11} & a_{12} & ... & a_{1m} \\\\\na_{21} & a_{22} & ... & a_{2m} \\\\\n: & : & : & : \\\\\na_{n1} & a_{n2} & ... & a_{nm} \\\\\n\\end{array}\n\\right)\n\\]\n\n$i$-th element of a $m \\times 1$ column vector $b$ is represented by $b_i$ ($i = 1, 2, ..., m$), and the element in $i$-th row and $j$-th column of a matrix $A$ is represented by $a_{ij}$ ($i = 1, 2, ..., n,$ $j = 1, 2, ..., m$).\n\nThe product of a $n \\times m$ matrix $A$ and a $m \\times 1$ column vector $b$ is a $n \\times 1$ column vector $c$, and $c_i$ is obtained by the following formula:\n\n\\[\nc_i = \\sum_{j=1}^m a_{ij}b_j = a_{i1}b_1 + a_{i2}b_2 + ... + a_{im}b_m\n\\]\n\nInput\n\nIn the first line, two integers $n$ and $m$ are given. In the following $n$ lines, $a_{ij}$ are given separated by a single space character. In the next $m$ lines, $b_i$ is given in a line.\n\nOutput\n\nThe output consists of $n$ lines. Print $c_i$ in a line.\n\nConstraints\n\n$1 \\leq n, m \\leq 100$\n\n$0 \\leq b_i, a_{ij} \\leq 1000$\n\nSample Input\n\n3 4\n1 2 0 1\n0 3 0 1\n4 1 1 0\n1\n2\n3\n0\n\nSample Output\n\n5\n6\n9", "sample_input": "3 4\n1 2 0 1\n0 3 0 1\n4 1 1 0\n1\n2\n3\n0\n"}, "reference_outputs": ["5\n6\n9\n"], "source_document_id": "p02410", "source_text": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nMatrix Vector Multiplication\n\nWrite a program which reads a $ n \\times m$ matrix $A$ and a $m \\times 1$ vector $b$, and prints their product $Ab$.\n\nA column vector with m elements is represented by the following equation.\n\n\\[\nb = \\left(\n\\begin{array}{c}\nb_1 \\\\\nb_2 \\\\\n: \\\\\nb_m \\\\\n\\end{array}\n\\right)\n\\]\n\nA $n \\times m$ matrix with $m$ column vectors, each of which consists of $n$ elements, is represented by the following equation.\n\n\\[\nA = \\left(\n\\begin{array}{cccc}\na_{11} & a_{12} & ... & a_{1m} \\\\\na_{21} & a_{22} & ... & a_{2m} \\\\\n: & : & : & : \\\\\na_{n1} & a_{n2} & ... & a_{nm} \\\\\n\\end{array}\n\\right)\n\\]\n\n$i$-th element of a $m \\times 1$ column vector $b$ is represented by $b_i$ ($i = 1, 2, ..., m$), and the element in $i$-th row and $j$-th column of a matrix $A$ is represented by $a_{ij}$ ($i = 1, 2, ..., n,$ $j = 1, 2, ..., m$).\n\nThe product of a $n \\times m$ matrix $A$ and a $m \\times 1$ column vector $b$ is a $n \\times 1$ column vector $c$, and $c_i$ is obtained by the following formula:\n\n\\[\nc_i = \\sum_{j=1}^m a_{ij}b_j = a_{i1}b_1 + a_{i2}b_2 + ... + a_{im}b_m\n\\]\n\nInput\n\nIn the first line, two integers $n$ and $m$ are given. In the following $n$ lines, $a_{ij}$ are given separated by a single space character. In the next $m$ lines, $b_i$ is given in a line.\n\nOutput\n\nThe output consists of $n$ lines. Print $c_i$ in a line.\n\nConstraints\n\n$1 \\leq n, m \\leq 100$\n\n$0 \\leq b_i, a_{ij} \\leq 1000$\n\nSample Input\n\n3 4\n1 2 0 1\n0 3 0 1\n4 1 1 0\n1\n2\n3\n0\n\nSample Output\n\n5\n6\n9", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1205, "cpu_time_ms": 310, "memory_kb": 46072}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s508921870", "group_id": "codeNet:p02412", "input_text": "fun main(args: Array) {\n var count = 0\n while (true) {\n val (n, target) = readLine()?.split(\" \")?.map { it.toInt() } ?: return\n if (n == 0 && target == 0) break\n (1..n).forEach { i ->\n (2..n).forEach { j ->\n (3..n).forEach { k ->\n if (i != j && j != k && k != i && i + j + k == target) {\n count++\n }\n }\n }\n }\n }\n println(count / 2)\n}\n", "language": "Kotlin", "metadata": {"date": 1515572498, "filename_ext": "kt", "original_language": "Kotlin", "problem_description_relpath": "problem_descriptions/p02412.html", "problem_id": "p02412", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02412/input.txt", "sample_output_relpath": "derived/input_output/data/p02412/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02412/Kotlin/s508921870.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s508921870", "user_id": "u418130569"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "fun main(args: Array) {\n var count = 0\n while (true) {\n val (n, target) = readLine()?.split(\" \")?.map { it.toInt() } ?: return\n if (n == 0 && target == 0) break\n (1..n).forEach { i ->\n (2..n).forEach { j ->\n (3..n).forEach { k ->\n if (i != j && j != k && k != i && i + j + k == target) {\n count++\n }\n }\n }\n }\n }\n println(count / 2)\n}\n", "problem_context": "How many ways?\n\nWrite a program which identifies the number of combinations of three integers which satisfy the following conditions:\n\nYou should select three distinct integers from 1 to n.\n\nA total sum of the three integers is x.\n\nFor example, there are two combinations for n = 5 and x = 9.\n\n1 + 3 + 5 = 9\n\n2 + 3 + 4 = 9\n\nInput\n\nThe input consists of multiple datasets. For each dataset, two integers n and x are given in a line.\n\nThe input ends with two zeros for n and x respectively. Your program should not process for these terminal symbols.\n\nConstraints\n\n3 ≤ n ≤ 100\n\n0 ≤ x ≤ 300\n\nOutput\n\nFor each dataset, print the number of combinations in a line.\n\nSample Input\n\n5 9\n0 0\n\nSample Output\n\n2\n\nNote\n\n      解説", "sample_input": "5 9\n0 0\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02412", "source_text": "How many ways?\n\nWrite a program which identifies the number of combinations of three integers which satisfy the following conditions:\n\nYou should select three distinct integers from 1 to n.\n\nA total sum of the three integers is x.\n\nFor example, there are two combinations for n = 5 and x = 9.\n\n1 + 3 + 5 = 9\n\n2 + 3 + 4 = 9\n\nInput\n\nThe input consists of multiple datasets. For each dataset, two integers n and x are given in a line.\n\nThe input ends with two zeros for n and x respectively. Your program should not process for these terminal symbols.\n\nConstraints\n\n3 ≤ n ≤ 100\n\n0 ≤ x ≤ 300\n\nOutput\n\nFor each dataset, print the number of combinations in a line.\n\nSample Input\n\n5 9\n0 0\n\nSample Output\n\n2\n\nNote\n\n      解説", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 495, "cpu_time_ms": 140, "memory_kb": 32076}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s617689101", "group_id": "codeNet:p02417", "input_text": "import java.util.Scanner\n\nfun main(args:Array){\n\n val cin = Scanner(System.`in`)\n var result = Array(26,{0})\n\n while(cin.hasNext()){\n var str = cin.nextLine()\n\t str = str.toLowerCase()\n\n\t for(i in 0..str.length-1){\n\t if(str[i] >= 'a' && str[i] <= 'z'){\n\t val x = str[i].toInt() - 'a'.toInt() \n\t result[x] = result[x] + 1\n\t }\n\t }\n }\n\n for(i in 'a'..'z'){\t\n\tprintln(\"$i : ${result[i.toInt() - 'a'.toInt()]}\")\n } \n\t\n}\n", "language": "Kotlin", "metadata": {"date": 1542730009, "filename_ext": "kt", "original_language": "Kotlin", "problem_description_relpath": "problem_descriptions/p02417.html", "problem_id": "p02417", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02417/input.txt", "sample_output_relpath": "derived/input_output/data/p02417/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02417/Kotlin/s617689101.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s617689101", "user_id": "u837508455"}, "prompt_components": {"gold_output": "a : 1\nb : 0\nc : 0\nd : 0\ne : 1\nf : 0\ng : 0\nh : 1\ni : 2\nj : 0\nk : 0\nl : 0\nm : 0\nn : 1\no : 0\np : 1\nq : 0\nr : 0\ns : 2\nt : 1\nu : 0\nv : 0\nw : 0\nx : 0\ny : 0\nz : 0\n", "input_to_evaluate": "import java.util.Scanner\n\nfun main(args:Array){\n\n val cin = Scanner(System.`in`)\n var result = Array(26,{0})\n\n while(cin.hasNext()){\n var str = cin.nextLine()\n\t str = str.toLowerCase()\n\n\t for(i in 0..str.length-1){\n\t if(str[i] >= 'a' && str[i] <= 'z'){\n\t val x = str[i].toInt() - 'a'.toInt() \n\t result[x] = result[x] + 1\n\t }\n\t }\n }\n\n for(i in 'a'..'z'){\t\n\tprintln(\"$i : ${result[i.toInt() - 'a'.toInt()]}\")\n } \n\t\n}\n", "problem_context": "Counting Characters\n\nWrite a program which counts and reports the number of each alphabetical letter. Ignore the case of characters.\n\nInput\n\nA sentence in English is given in several lines.\n\nOutput\n\nPrints the number of alphabetical letters in the following format:\n\na : The number of 'a'\nb : The number of 'b'\nc : The number of 'c'\n.\n.\nz : The number of 'z'\n\nConstraints\n\nThe number of characters in the sentence < 1200\n\nSample Input\n\nThis is a pen.\n\nSample Output\n\na : 1\nb : 0\nc : 0\nd : 0\ne : 1\nf : 0\ng : 0\nh : 1\ni : 2\nj : 0\nk : 0\nl : 0\nm : 0\nn : 1\no : 0\np : 1\nq : 0\nr : 0\ns : 2\nt : 1\nu : 0\nv : 0\nw : 0\nx : 0\ny : 0\nz : 0", "sample_input": "This is a pen.\n"}, "reference_outputs": ["a : 1\nb : 0\nc : 0\nd : 0\ne : 1\nf : 0\ng : 0\nh : 1\ni : 2\nj : 0\nk : 0\nl : 0\nm : 0\nn : 1\no : 0\np : 1\nq : 0\nr : 0\ns : 2\nt : 1\nu : 0\nv : 0\nw : 0\nx : 0\ny : 0\nz : 0\n"], "source_document_id": "p02417", "source_text": "Counting Characters\n\nWrite a program which counts and reports the number of each alphabetical letter. Ignore the case of characters.\n\nInput\n\nA sentence in English is given in several lines.\n\nOutput\n\nPrints the number of alphabetical letters in the following format:\n\na : The number of 'a'\nb : The number of 'b'\nc : The number of 'c'\n.\n.\nz : The number of 'z'\n\nConstraints\n\nThe number of characters in the sentence < 1200\n\nSample Input\n\nThis is a pen.\n\nSample Output\n\na : 1\nb : 0\nc : 0\nd : 0\ne : 1\nf : 0\ng : 0\nh : 1\ni : 2\nj : 0\nk : 0\nl : 0\nm : 0\nn : 1\no : 0\np : 1\nq : 0\nr : 0\ns : 2\nt : 1\nu : 0\nv : 0\nw : 0\nx : 0\ny : 0\nz : 0", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 498, "cpu_time_ms": 80, "memory_kb": 25556}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s319133620", "group_id": "codeNet:p02419", "input_text": "const val EOF = \"END_OF_TEXT\"\n\nfun main(args: Array) {\n val target = readLine() ?: return\n var count = 0\n while (true) {\n val texts = readLine()?.split(\" \")?.map { if(!it.equals(EOF))it.toLowerCase() else it } ?: break\n texts.forEach{\n if(it == target) count++\n }\n if(texts.contains(EOF)) break\n }\n println(count)\n}\n", "language": "Kotlin", "metadata": {"date": 1516251493, "filename_ext": "kt", "original_language": "Kotlin", "problem_description_relpath": "problem_descriptions/p02419.html", "problem_id": "p02419", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02419/input.txt", "sample_output_relpath": "derived/input_output/data/p02419/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02419/Kotlin/s319133620.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s319133620", "user_id": "u418130569"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "const val EOF = \"END_OF_TEXT\"\n\nfun main(args: Array) {\n val target = readLine() ?: return\n var count = 0\n while (true) {\n val texts = readLine()?.split(\" \")?.map { if(!it.equals(EOF))it.toLowerCase() else it } ?: break\n texts.forEach{\n if(it == target) count++\n }\n if(texts.contains(EOF)) break\n }\n println(count)\n}\n", "problem_context": "Finding a Word\n\nWrite a program which reads a word W and a text T, and prints the number of word W which appears in text T\n\nT consists of string Ti separated by space characters and newlines. Count the number of Ti which equals to W. The word and text are case insensitive.\n\nConstraints\n\nThe length of W ≤ 10\n\nW consists of lower case letters\n\nThe length of T in a line ≤ 1000\n\nInput\n\nIn the first line, the word W is given. In the following lines, the text T is given separated by space characters and newlines.\n\n\"END_OF_TEXT\" indicates the end of the text.\n\nOutput\n\nPrint the number of W in the text.\n\nSample Input\n\ncomputer\nNurtures computer scientists and highly-skilled computer engineers\nwho will create and exploit \"knowledge\" for the new era.\nProvides an outstanding computer environment.\nEND_OF_TEXT\n\nSample Output\n\n3", "sample_input": "computer\nNurtures computer scientists and highly-skilled computer engineers\nwho will create and exploit \"knowledge\" for the new era.\nProvides an outstanding computer environment.\nEND_OF_TEXT\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02419", "source_text": "Finding a Word\n\nWrite a program which reads a word W and a text T, and prints the number of word W which appears in text T\n\nT consists of string Ti separated by space characters and newlines. Count the number of Ti which equals to W. The word and text are case insensitive.\n\nConstraints\n\nThe length of W ≤ 10\n\nW consists of lower case letters\n\nThe length of T in a line ≤ 1000\n\nInput\n\nIn the first line, the word W is given. In the following lines, the text T is given separated by space characters and newlines.\n\n\"END_OF_TEXT\" indicates the end of the text.\n\nOutput\n\nPrint the number of W in the text.\n\nSample Input\n\ncomputer\nNurtures computer scientists and highly-skilled computer engineers\nwho will create and exploit \"knowledge\" for the new era.\nProvides an outstanding computer environment.\nEND_OF_TEXT\n\nSample Output\n\n3", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 378, "cpu_time_ms": 170, "memory_kb": 31920}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s789065390", "group_id": "codeNet:p02421", "input_text": "import java.util.Scanner\n\nfun main(args:Array){\n\n val cin = Scanner(System.`in`)\n val n = cin.nextInt()\n var taro:Int = 0\n var hanako:Int = 0\n \n for(i in 1..n){\n\t val str1 = cin.next()\n\t val str2 = cin.next()\n when{\n\t str1 > str2 -> {taro += 3}\n\t str1 < str2 -> {hanako += 3}\n\t else -> {\n\t\t taro++\n\t\t hanako++\n\t }\n\t }\n }\n println(\"${taro} ${hanako}\")\n}\n\n", "language": "Kotlin", "metadata": {"date": 1545149421, "filename_ext": "kt", "original_language": "Kotlin", "problem_description_relpath": "problem_descriptions/p02421.html", "problem_id": "p02421", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02421/input.txt", "sample_output_relpath": "derived/input_output/data/p02421/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02421/Kotlin/s789065390.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s789065390", "user_id": "u837508455"}, "prompt_components": {"gold_output": "1 7\n", "input_to_evaluate": "import java.util.Scanner\n\nfun main(args:Array){\n\n val cin = Scanner(System.`in`)\n val n = cin.nextInt()\n var taro:Int = 0\n var hanako:Int = 0\n \n for(i in 1..n){\n\t val str1 = cin.next()\n\t val str2 = cin.next()\n when{\n\t str1 > str2 -> {taro += 3}\n\t str1 < str2 -> {hanako += 3}\n\t else -> {\n\t\t taro++\n\t\t hanako++\n\t }\n\t }\n }\n println(\"${taro} ${hanako}\")\n}\n\n", "problem_context": "Card Game\n\nTaro and Hanako are playing card games. They have n cards each, and they compete n turns. At each turn Taro and Hanako respectively puts out a card.\nThe name of the animal consisting of alphabetical letters is written on each card, and the bigger one in lexicographical order becomes the winner of that turn. The winner obtains 3 points. In the case of a draw, they obtain 1 point each.\n\nWrite a program which reads a sequence of cards Taro and Hanako have and reports the final scores of the game.\n\nInput\n\nIn the first line, the number of cards n is given. In the following n lines, the cards for n turns are given respectively. For each line, the first string represents the Taro's card and the second one represents Hanako's card.\n\nConstraints\n\nn ≤ 1000\n\nThe length of the string ≤ 100\n\nOutput\n\nPrint the final scores of Taro and Hanako respectively. Put a single space character between them.\n\nSample Input\n\n3\ncat dog\nfish fish\nlion tiger\n\nSample Output\n\n1 7", "sample_input": "3\ncat dog\nfish fish\nlion tiger\n"}, "reference_outputs": ["1 7\n"], "source_document_id": "p02421", "source_text": "Card Game\n\nTaro and Hanako are playing card games. They have n cards each, and they compete n turns. At each turn Taro and Hanako respectively puts out a card.\nThe name of the animal consisting of alphabetical letters is written on each card, and the bigger one in lexicographical order becomes the winner of that turn. The winner obtains 3 points. In the case of a draw, they obtain 1 point each.\n\nWrite a program which reads a sequence of cards Taro and Hanako have and reports the final scores of the game.\n\nInput\n\nIn the first line, the number of cards n is given. In the following n lines, the cards for n turns are given respectively. For each line, the first string represents the Taro's card and the second one represents Hanako's card.\n\nConstraints\n\nn ≤ 1000\n\nThe length of the string ≤ 100\n\nOutput\n\nPrint the final scores of Taro and Hanako respectively. Put a single space character between them.\n\nSample Input\n\n3\ncat dog\nfish fish\nlion tiger\n\nSample Output\n\n1 7", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 140, "memory_kb": 30984}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s962205551", "group_id": "codeNet:p02422", "input_text": "fun main(args: Array) {\n var str = readLine()!!.toString()\n val q = readLine()!!.toInt()\n\n (0 until q).forEach { _ ->\n val command = readLine()!!.toString().split(\" \")\n val operation = command[0]\n val a = command[1].toInt()\n val b = command[2].toInt()\n val s = str.slice(0 until a)\n val m = str.slice(a..b)\n val e = str.slice(b + 1 until str.length)\n when (operation) {\n \"print\" -> println(m)\n \"reverse\" -> str = s + m.reversed() + e\n \"replace\" -> str = s + command[3] + e\n }\n }\n}\n", "language": "Kotlin", "metadata": {"date": 1588535553, "filename_ext": "kt", "original_language": "Kotlin", "problem_description_relpath": "problem_descriptions/p02422.html", "problem_id": "p02422", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02422/input.txt", "sample_output_relpath": "derived/input_output/data/p02422/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02422/Kotlin/s962205551.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s962205551", "user_id": "u030130676"}, "prompt_components": {"gold_output": "xaze\n", "input_to_evaluate": "fun main(args: Array) {\n var str = readLine()!!.toString()\n val q = readLine()!!.toInt()\n\n (0 until q).forEach { _ ->\n val command = readLine()!!.toString().split(\" \")\n val operation = command[0]\n val a = command[1].toInt()\n val b = command[2].toInt()\n val s = str.slice(0 until a)\n val m = str.slice(a..b)\n val e = str.slice(b + 1 until str.length)\n when (operation) {\n \"print\" -> println(m)\n \"reverse\" -> str = s + m.reversed() + e\n \"replace\" -> str = s + command[3] + e\n }\n }\n}\n", "problem_context": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nTransformation\n\nWrite a program which performs a sequence of commands to a given string $str$. The command is one of:\n\nprint a b: print from the a-th character to the b-th character of $str$\n\nreverse a b: reverse from the a-th character to the b-th character of $str$\n\nreplace a b p: replace from the a-th character to the b-th character of $str$ with p\n\nNote that the indices of $str$ start with 0.\n\nInput\n\nIn the first line, a string $str$ is given. $str$ consists of lowercase letters. In the second line, the number of commands q is given. In the next q lines, each command is given in the above mentioned format.\n\nOutput\n\nFor each print command, print a string in a line.\n\nConstraints\n\n$1 \\leq $ length of $str \\leq 1000$\n\n$1 \\leq q \\leq 100$\n\n$0 \\leq a \\leq b < $ length of $str$\n\nfor replace command, $b - a + 1 = $ length of $p$\n\nSample Input 1\n\nabcde\n3\nreplace 1 3 xyz\nreverse 0 2\nprint 1 4\n\nSample Output 1\n\nxaze\n\nSample Input 2\n\nxyz\n3\nprint 0 2\nreplace 0 2 abc\nprint 0 2\n\nSample Output 2\n\nxyz\nabc", "sample_input": "abcde\n3\nreplace 1 3 xyz\nreverse 0 2\nprint 1 4\n"}, "reference_outputs": ["xaze\n"], "source_document_id": "p02422", "source_text": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nTransformation\n\nWrite a program which performs a sequence of commands to a given string $str$. The command is one of:\n\nprint a b: print from the a-th character to the b-th character of $str$\n\nreverse a b: reverse from the a-th character to the b-th character of $str$\n\nreplace a b p: replace from the a-th character to the b-th character of $str$ with p\n\nNote that the indices of $str$ start with 0.\n\nInput\n\nIn the first line, a string $str$ is given. $str$ consists of lowercase letters. In the second line, the number of commands q is given. In the next q lines, each command is given in the above mentioned format.\n\nOutput\n\nFor each print command, print a string in a line.\n\nConstraints\n\n$1 \\leq $ length of $str \\leq 1000$\n\n$1 \\leq q \\leq 100$\n\n$0 \\leq a \\leq b < $ length of $str$\n\nfor replace command, $b - a + 1 = $ length of $p$\n\nSample Input 1\n\nabcde\n3\nreplace 1 3 xyz\nreverse 0 2\nprint 1 4\n\nSample Output 1\n\nxaze\n\nSample Input 2\n\nxyz\n3\nprint 0 2\nreplace 0 2 abc\nprint 0 2\n\nSample Output 2\n\nxyz\nabc", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 597, "cpu_time_ms": 140, "memory_kb": 33780}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s365673004", "group_id": "codeNet:p02433", "input_text": "import ImmutableList.*\n\nfun main(args:Array):Unit {\n val list = LinkList()\n repeat(readLine()!!.toInt()){\n val arg = readLine()!!.split(' ').map(String::toInt)\n when(arg.first()){\n 0 -> list.insert(arg.last())\n 1 -> list.move(arg.last())\n else -> list.erase()\n }\n }\n println(list)\n}\nfun ImmutableList.append(value:A):ImmutableList = Cons(value, this)\nsealed class ImmutableList:Iterable{\n override fun iterator(): Iterator {\n return ListIterator(this)\n }\n object Nil:ImmutableList()\n data class Cons(val head:T, val tail:ImmutableList):ImmutableList()\n}\nclass ListIterator(private var list:ImmutableList):Iterator {\n override fun hasNext(): Boolean = list is Cons\n\n override fun next(): T {\n val next = list as Cons\n list = next.tail\n return next.head\n }\n\n}\nclass LinkList{\n private var mPrev:ImmutableList = Nil\n private var mNext:ImmutableList = Nil\n private fun moveForward():Unit {\n val next = mNext as Cons\n mPrev = Cons(next.head, mPrev)\n mNext = next.tail\n }\n private fun moveBackward():Unit {\n val prev = mPrev as Cons\n mPrev = prev.tail\n mNext = Cons(prev.head, mNext)\n }\n fun insert(value:Int):Unit {\n mNext = Cons(value, mNext)\n }\n fun move(value:Int):Unit {\n if (value >= 0){\n repeat(value){moveForward()}\n }else{\n repeat(-value){moveBackward()}\n }\n }\n fun erase():Unit {\n mNext = (mNext as Cons).tail\n }\n\n override fun toString(): String {\n return listOf(mPrev.reversed(), mNext).flatten().joinToString (\"\\n\")\n }\n}\n", "language": "Kotlin", "metadata": {"date": 1528507815, "filename_ext": "kt", "original_language": "Kotlin", "problem_description_relpath": "problem_descriptions/p02433.html", "problem_id": "p02433", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02433/input.txt", "sample_output_relpath": "derived/input_output/data/p02433/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02433/Kotlin/s365673004.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s365673004", "user_id": "u514597327"}, "prompt_components": {"gold_output": "3\n1\n", "input_to_evaluate": "import ImmutableList.*\n\nfun main(args:Array):Unit {\n val list = LinkList()\n repeat(readLine()!!.toInt()){\n val arg = readLine()!!.split(' ').map(String::toInt)\n when(arg.first()){\n 0 -> list.insert(arg.last())\n 1 -> list.move(arg.last())\n else -> list.erase()\n }\n }\n println(list)\n}\nfun ImmutableList.append(value:A):ImmutableList = Cons(value, this)\nsealed class ImmutableList:Iterable{\n override fun iterator(): Iterator {\n return ListIterator(this)\n }\n object Nil:ImmutableList()\n data class Cons(val head:T, val tail:ImmutableList):ImmutableList()\n}\nclass ListIterator(private var list:ImmutableList):Iterator {\n override fun hasNext(): Boolean = list is Cons\n\n override fun next(): T {\n val next = list as Cons\n list = next.tail\n return next.head\n }\n\n}\nclass LinkList{\n private var mPrev:ImmutableList = Nil\n private var mNext:ImmutableList = Nil\n private fun moveForward():Unit {\n val next = mNext as Cons\n mPrev = Cons(next.head, mPrev)\n mNext = next.tail\n }\n private fun moveBackward():Unit {\n val prev = mPrev as Cons\n mPrev = prev.tail\n mNext = Cons(prev.head, mNext)\n }\n fun insert(value:Int):Unit {\n mNext = Cons(value, mNext)\n }\n fun move(value:Int):Unit {\n if (value >= 0){\n repeat(value){moveForward()}\n }else{\n repeat(-value){moveBackward()}\n }\n }\n fun erase():Unit {\n mNext = (mNext as Cons).tail\n }\n\n override fun toString(): String {\n return listOf(mPrev.reversed(), mNext).flatten().joinToString (\"\\n\")\n }\n}\n", "problem_context": "List\n\nFor a dynamic list $L$ of integers, perform a sequence of the following operations. $L$ has a special element called END at the end of the list and an element of $L$ is indicated by a cursor.\n\ninsert($x$): Insert $x$ before the element indicated by the cursor. After this operation, the cursor points the inserted element.\n\nmove($d$): Move the cursor to the end by $d$, if $d$ is positive. Move the cursor to the front by $d$, if $d$ is negative.\n\nerase(): Delete the element indicated by the cursor. After this operation, the cursor points the element next to the deleted element. In case there is no such element, the cursor should point END.\n\nIn the initial state, $L$ is empty and the cursor points END.\n\nInput\n\nThe input is given in the following format.\n\n$q$\n$query_1$\n$query_2$\n:\n$query_q$\n\nEach query $query_i$ is given by\n\n0 $x$\n\nor\n\n1 $d$\n\nor\n\n2\n\nwhere the first digits 0, 1 and 2 represent insert, move and erase operations respectively.\n\nOutput\n\nPrint all elements of the list in order after performing given operations. Print an element in a line.\n\nConstraints\n\n$1 \\leq q \\leq 500,000$\n\nThe cursor indicates an element of $L$ or END during the operations\n\nErase operation will not given when the cursor points END\n\n$-1,000,000,000 \\leq x \\leq 1,000,000,000$\n\nMoving distance of the cursor ($\\sum{|d|}$) does not exceed 1,000,000\n\n$L$ is not empty after performing all operations\n\nSample Input 1\n\n5\n0 1\n0 2\n0 3\n1 1\n2\n\nSample Output 1\n\n3\n1", "sample_input": "5\n0 1\n0 2\n0 3\n1 1\n2\n"}, "reference_outputs": ["3\n1\n"], "source_document_id": "p02433", "source_text": "List\n\nFor a dynamic list $L$ of integers, perform a sequence of the following operations. $L$ has a special element called END at the end of the list and an element of $L$ is indicated by a cursor.\n\ninsert($x$): Insert $x$ before the element indicated by the cursor. After this operation, the cursor points the inserted element.\n\nmove($d$): Move the cursor to the end by $d$, if $d$ is positive. Move the cursor to the front by $d$, if $d$ is negative.\n\nerase(): Delete the element indicated by the cursor. After this operation, the cursor points the element next to the deleted element. In case there is no such element, the cursor should point END.\n\nIn the initial state, $L$ is empty and the cursor points END.\n\nInput\n\nThe input is given in the following format.\n\n$q$\n$query_1$\n$query_2$\n:\n$query_q$\n\nEach query $query_i$ is given by\n\n0 $x$\n\nor\n\n1 $d$\n\nor\n\n2\n\nwhere the first digits 0, 1 and 2 represent insert, move and erase operations respectively.\n\nOutput\n\nPrint all elements of the list in order after performing given operations. Print an element in a line.\n\nConstraints\n\n$1 \\leq q \\leq 500,000$\n\nThe cursor indicates an element of $L$ or END during the operations\n\nErase operation will not given when the cursor points END\n\n$-1,000,000,000 \\leq x \\leq 1,000,000,000$\n\nMoving distance of the cursor ($\\sum{|d|}$) does not exceed 1,000,000\n\n$L$ is not empty after performing all operations\n\nSample Input 1\n\n5\n0 1\n0 2\n0 3\n1 1\n2\n\nSample Output 1\n\n3\n1", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1940, "memory_kb": 181044}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s207651788", "group_id": "codeNet:p02434", "input_text": "\nfun main(args:Array):Unit {\n val (n, q) = readLine()!!.split(' ').map(String::toInt)\n val vectors = Array(n){Vector()}\n repeat(q){\n val query = readLine()!!.split(' ').map(String::toInt)\n when(query.first()){\n 0 -> vectors[query[1]].pushBack(query.last())\n 1 -> println(vectors[query.last()].dump())\n else -> vectors[query.last()].clear()\n }\n }\n}\n\nclass Vector{\n private var mArray:Array = Array(100){0}\n var size:Int = 0\n private set\n private fun resize():Unit {\n val newArray = Array(mArray.size * 2){0}\n mArray.forEachIndexed { index, i -> newArray[index] = i }\n mArray = newArray\n }\n fun pushBack(value:Int):Unit {\n if (size == mArray.size) resize()\n mArray[size++] = value\n }\n fun clear():Unit {\n size = 0\n }\n fun dump():String {\n return (0 until size).map{mArray[it]}.joinToString(\" \")\n }\n}\n", "language": "Kotlin", "metadata": {"date": 1528508488, "filename_ext": "kt", "original_language": "Kotlin", "problem_description_relpath": "problem_descriptions/p02434.html", "problem_id": "p02434", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02434/input.txt", "sample_output_relpath": "derived/input_output/data/p02434/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02434/Kotlin/s207651788.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s207651788", "user_id": "u514597327"}, "prompt_components": {"gold_output": "1 2 3\n-1\n4 5\n1 2 3\n\n4 5\n", "input_to_evaluate": "\nfun main(args:Array):Unit {\n val (n, q) = readLine()!!.split(' ').map(String::toInt)\n val vectors = Array(n){Vector()}\n repeat(q){\n val query = readLine()!!.split(' ').map(String::toInt)\n when(query.first()){\n 0 -> vectors[query[1]].pushBack(query.last())\n 1 -> println(vectors[query.last()].dump())\n else -> vectors[query.last()].clear()\n }\n }\n}\n\nclass Vector{\n private var mArray:Array = Array(100){0}\n var size:Int = 0\n private set\n private fun resize():Unit {\n val newArray = Array(mArray.size * 2){0}\n mArray.forEachIndexed { index, i -> newArray[index] = i }\n mArray = newArray\n }\n fun pushBack(value:Int):Unit {\n if (size == mArray.size) resize()\n mArray[size++] = value\n }\n fun clear():Unit {\n size = 0\n }\n fun dump():String {\n return (0 until size).map{mArray[it]}.joinToString(\" \")\n }\n}\n", "problem_context": "Vector II\n\nFor $n$ dynamic arrays $A_i$ ($i = 0, 1, ..., n-1$), perform a sequence of the following operations:\n\npushBack($t$, $x$): Add element $x$ at the end of $A_t$.\n\ndump($t$): Print all elements in $A_t$.\n\nclear($t$): Clear $A_t$. If $A_t$ is empty, do nothing.\n\n$A_i$ is a 0-origin array and it is empty in the initial state.\n\nInput\n\nThe input is given in the following format.\n\n$n$ $q$\n$query_1$\n$query_2$\n:\n$query_q$\n\nEach query $query_i$ is given by\n\n0 $t$ $x$\n\nor\n\n1 $t$\n\nor\n\n2 $t$\n\nwhere the first digits 0, 1 and 2 represent pushBack, dump and clear operations respectively.\n\nOutput\n\nFor each dump operation, print elements of $A_t$ a line. Separete adjacency elements by a space character (do not print the space after the last element). Note that, if the array is empty, an empty line should be printed.\n\nConstraints\n\n$1 \\leq n \\leq 1,000$\n\n$1 \\leq q \\leq 500,000$\n\n$-1,000,000,000 \\leq x \\leq 1,000,000,000$\n\nThe total number of elements printed by dump operations do not exceed 500,000\n\nSample Input 1\n\n3 13\n0 0 1\n0 0 2\n0 0 3\n0 1 -1\n0 2 4\n0 2 5\n1 0\n1 1\n1 2\n2 1\n1 0\n1 1\n1 2\n\nSample Output 1\n\n1 2 3\n-1\n4 5\n1 2 3\n\n4 5", "sample_input": "3 13\n0 0 1\n0 0 2\n0 0 3\n0 1 -1\n0 2 4\n0 2 5\n1 0\n1 1\n1 2\n2 1\n1 0\n1 1\n1 2\n"}, "reference_outputs": ["1 2 3\n-1\n4 5\n1 2 3\n\n4 5\n"], "source_document_id": "p02434", "source_text": "Vector II\n\nFor $n$ dynamic arrays $A_i$ ($i = 0, 1, ..., n-1$), perform a sequence of the following operations:\n\npushBack($t$, $x$): Add element $x$ at the end of $A_t$.\n\ndump($t$): Print all elements in $A_t$.\n\nclear($t$): Clear $A_t$. If $A_t$ is empty, do nothing.\n\n$A_i$ is a 0-origin array and it is empty in the initial state.\n\nInput\n\nThe input is given in the following format.\n\n$n$ $q$\n$query_1$\n$query_2$\n:\n$query_q$\n\nEach query $query_i$ is given by\n\n0 $t$ $x$\n\nor\n\n1 $t$\n\nor\n\n2 $t$\n\nwhere the first digits 0, 1 and 2 represent pushBack, dump and clear operations respectively.\n\nOutput\n\nFor each dump operation, print elements of $A_t$ a line. Separete adjacency elements by a space character (do not print the space after the last element). Note that, if the array is empty, an empty line should be printed.\n\nConstraints\n\n$1 \\leq n \\leq 1,000$\n\n$1 \\leq q \\leq 500,000$\n\n$-1,000,000,000 \\leq x \\leq 1,000,000,000$\n\nThe total number of elements printed by dump operations do not exceed 500,000\n\nSample Input 1\n\n3 13\n0 0 1\n0 0 2\n0 0 3\n0 1 -1\n0 2 4\n0 2 5\n1 0\n1 1\n1 2\n2 1\n1 0\n1 1\n1 2\n\nSample Output 1\n\n1 2 3\n-1\n4 5\n1 2 3\n\n4 5", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 963, "cpu_time_ms": 1430, "memory_kb": 187660}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s130885308", "group_id": "codeNet:p02534", "input_text": "\nimport kotlin.math.*\nimport java.io.BufferedReader\nimport java.io.InputStreamReader\nimport java.util.*\n\n\nprivate var fs = BufferedReader(InputStreamReader(System.`in`))\nprivate fun readLn() = fs.readLine()!!\nprivate fun readStrings() = readLn().split(\" \")\nprivate fun readLong() = readLn().toLong()\nprivate fun readLongs() = readStrings().map { it.toLong() }\nprivate fun readInt() = readLn().toInt()\nprivate fun readInts() = readStrings().map { it.toInt() }\nfun main() {\n// val t = readInt()\n// for (tt in 0 until t) {\n solveA()\n// }\n}\nfun solveA() {\n var K = readInt()\n var ans = \"\"\n for(i in 0 until K){\n ans += \"ACL\"\n }\n println(ans)\n}\n\n", "language": "Kotlin", "metadata": {"date": 1601168502, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02534.html", "problem_id": "p02534", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02534/input.txt", "sample_output_relpath": "derived/input_output/data/p02534/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02534/Kotlin/s130885308.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s130885308", "user_id": "u843609965"}, "prompt_components": {"gold_output": "ACLACLACL\n", "input_to_evaluate": "\nimport kotlin.math.*\nimport java.io.BufferedReader\nimport java.io.InputStreamReader\nimport java.util.*\n\n\nprivate var fs = BufferedReader(InputStreamReader(System.`in`))\nprivate fun readLn() = fs.readLine()!!\nprivate fun readStrings() = readLn().split(\" \")\nprivate fun readLong() = readLn().toLong()\nprivate fun readLongs() = readStrings().map { it.toLong() }\nprivate fun readInt() = readLn().toInt()\nprivate fun readInts() = readStrings().map { it.toInt() }\nfun main() {\n// val t = readInt()\n// for (tt in 0 until t) {\n solveA()\n// }\n}\nfun solveA() {\n var K = readInt()\n var ans = \"\"\n for(i in 0 until K){\n ans += \"ACL\"\n }\n println(ans)\n}\n\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nYou are given an integer K.\nPrint the string obtained by repeating the string ACL K times and concatenating them.\n\nFor example, if K = 3, print ACLACLACL.\n\nConstraints\n\n1 \\leq K \\leq 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 string obtained by repeating the string ACL K times and concatenating them.\n\nSample Input 1\n\n3\n\nSample Output 1\n\nACLACLACL", "sample_input": "3\n"}, "reference_outputs": ["ACLACLACL\n"], "source_document_id": "p02534", "source_text": "Score : 100 points\n\nProblem Statement\n\nYou are given an integer K.\nPrint the string obtained by repeating the string ACL K times and concatenating them.\n\nFor example, if K = 3, print ACLACLACL.\n\nConstraints\n\n1 \\leq K \\leq 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 string obtained by repeating the string ACL K times and concatenating them.\n\nSample Input 1\n\n3\n\nSample Output 1\n\nACLACLACL", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 88, "memory_kb": 33860}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s687752822", "group_id": "codeNet:p02536", "input_text": "import kotlin.math.min\n\nfun main() {\n val (n, m) = readInts()\n\n val con = Array(n + 1) { it }\n\n repeat(m) {\n val (a, b) = readInts()\n\n con[a] = min(con[a], con[b])\n con[b] = min(con[a], con[b])\n }\n\n println(con.drop(1).distinct().size - 1)\n}\n\nprivate fun readInts() = readLine()!!.split(\" \").map { it.toInt() }\nprivate fun readLongs() = readLine()!!.split(\" \").map { it.toInt() }", "language": "Kotlin", "metadata": {"date": 1601175384, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02536.html", "problem_id": "p02536", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02536/input.txt", "sample_output_relpath": "derived/input_output/data/p02536/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02536/Kotlin/s687752822.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s687752822", "user_id": "u178770699"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "import kotlin.math.min\n\nfun main() {\n val (n, m) = readInts()\n\n val con = Array(n + 1) { it }\n\n repeat(m) {\n val (a, b) = readInts()\n\n con[a] = min(con[a], con[b])\n con[b] = min(con[a], con[b])\n }\n\n println(con.drop(1).distinct().size - 1)\n}\n\nprivate fun readInts() = readLine()!!.split(\" \").map { it.toInt() }\nprivate fun readLongs() = readLine()!!.split(\" \").map { it.toInt() }", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere are N cities numbered 1 through N, and M bidirectional roads numbered 1 through M.\nRoad i connects City A_i and City B_i.\n\nSnuke can perform the following operation zero or more times:\n\nChoose two distinct cities that are not directly connected by a road, and build a new road between the two cities.\n\nAfter he finishes the operations, it must be possible to travel from any city to any other cities by following roads (possibly multiple times).\n\nWhat is the minimum number of roads he must build to achieve the goal?\n\nConstraints\n\n2 \\leq N \\leq 100,000\n\n1 \\leq M \\leq 100,000\n\n1 \\leq A_i < B_i \\leq N\n\nNo two roads connect the same pair of cities.\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\n:\nA_M B_M\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n3 1\n1 2\n\nSample Output 1\n\n1\n\nInitially, there are three cities, and there is a road between City 1 and City 2.\n\nSnuke can achieve the goal by building one new road, for example, between City 1 and City 3.\nAfter that,\n\nWe can travel between 1 and 2 directly.\n\nWe can travel between 1 and 3 directly.\n\nWe can travel between 2 and 3 by following both roads (2 - 1 - 3).", "sample_input": "3 1\n1 2\n"}, "reference_outputs": ["1\n"], "source_document_id": "p02536", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere are N cities numbered 1 through N, and M bidirectional roads numbered 1 through M.\nRoad i connects City A_i and City B_i.\n\nSnuke can perform the following operation zero or more times:\n\nChoose two distinct cities that are not directly connected by a road, and build a new road between the two cities.\n\nAfter he finishes the operations, it must be possible to travel from any city to any other cities by following roads (possibly multiple times).\n\nWhat is the minimum number of roads he must build to achieve the goal?\n\nConstraints\n\n2 \\leq N \\leq 100,000\n\n1 \\leq M \\leq 100,000\n\n1 \\leq A_i < B_i \\leq N\n\nNo two roads connect the same pair of cities.\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\n:\nA_M B_M\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n3 1\n1 2\n\nSample Output 1\n\n1\n\nInitially, there are three cities, and there is a road between City 1 and City 2.\n\nSnuke can achieve the goal by building one new road, for example, between City 1 and City 3.\nAfter that,\n\nWe can travel between 1 and 2 directly.\n\nWe can travel between 1 and 3 directly.\n\nWe can travel between 2 and 3 by following both roads (2 - 1 - 3).", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 415, "cpu_time_ms": 570, "memory_kb": 66712}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s356429754", "group_id": "codeNet:p02536", "input_text": "fun main(){\n val (n, m) = readLine()!!.split(\" \").map { it.toInt() }\n val tosi = MutableList(n){ MutableList(0){ 0 } }\n for (i in 0 until m){\n val ab = readLine()!!.split(\" \").map { it.toInt() }\n tosi[ab[0] - 1].add(ab[1])\n tosi[ab[1] - 1].add(ab[0])\n }\n val flagList = MutableList(n){ 0 }\n val checkList = MutableList(0){ 0 }\n var flag = -1\n fun check(d: Int){\n for (i in 0 until tosi[d-1].size){\n if (flagList[tosi[d-1][i] - 1] == 0) {\n checkList.add(tosi[d-1][i])\n flagList[tosi[d-1][i] - 1] = 1\n }\n\n }\n checkList.removeAt(0)\n if (checkList.size > 0) check(checkList[0])\n }\n for (i in 0 until n){\n if (flagList[i] == 0){\n flag++\n flagList[i] = 1\n for (j in 0 until tosi[i].size){\n checkList.add(tosi[i][j])\n flagList[tosi[i][j] - 1] = 1\n }\n }\n if (checkList.size > 0) check(checkList[0])\n\n }\n println(flag)\n}", "language": "Kotlin", "metadata": {"date": 1601171284, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02536.html", "problem_id": "p02536", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02536/input.txt", "sample_output_relpath": "derived/input_output/data/p02536/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02536/Kotlin/s356429754.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s356429754", "user_id": "u385678999"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "fun main(){\n val (n, m) = readLine()!!.split(\" \").map { it.toInt() }\n val tosi = MutableList(n){ MutableList(0){ 0 } }\n for (i in 0 until m){\n val ab = readLine()!!.split(\" \").map { it.toInt() }\n tosi[ab[0] - 1].add(ab[1])\n tosi[ab[1] - 1].add(ab[0])\n }\n val flagList = MutableList(n){ 0 }\n val checkList = MutableList(0){ 0 }\n var flag = -1\n fun check(d: Int){\n for (i in 0 until tosi[d-1].size){\n if (flagList[tosi[d-1][i] - 1] == 0) {\n checkList.add(tosi[d-1][i])\n flagList[tosi[d-1][i] - 1] = 1\n }\n\n }\n checkList.removeAt(0)\n if (checkList.size > 0) check(checkList[0])\n }\n for (i in 0 until n){\n if (flagList[i] == 0){\n flag++\n flagList[i] = 1\n for (j in 0 until tosi[i].size){\n checkList.add(tosi[i][j])\n flagList[tosi[i][j] - 1] = 1\n }\n }\n if (checkList.size > 0) check(checkList[0])\n\n }\n println(flag)\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere are N cities numbered 1 through N, and M bidirectional roads numbered 1 through M.\nRoad i connects City A_i and City B_i.\n\nSnuke can perform the following operation zero or more times:\n\nChoose two distinct cities that are not directly connected by a road, and build a new road between the two cities.\n\nAfter he finishes the operations, it must be possible to travel from any city to any other cities by following roads (possibly multiple times).\n\nWhat is the minimum number of roads he must build to achieve the goal?\n\nConstraints\n\n2 \\leq N \\leq 100,000\n\n1 \\leq M \\leq 100,000\n\n1 \\leq A_i < B_i \\leq N\n\nNo two roads connect the same pair of cities.\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\n:\nA_M B_M\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n3 1\n1 2\n\nSample Output 1\n\n1\n\nInitially, there are three cities, and there is a road between City 1 and City 2.\n\nSnuke can achieve the goal by building one new road, for example, between City 1 and City 3.\nAfter that,\n\nWe can travel between 1 and 2 directly.\n\nWe can travel between 1 and 3 directly.\n\nWe can travel between 2 and 3 by following both roads (2 - 1 - 3).", "sample_input": "3 1\n1 2\n"}, "reference_outputs": ["1\n"], "source_document_id": "p02536", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere are N cities numbered 1 through N, and M bidirectional roads numbered 1 through M.\nRoad i connects City A_i and City B_i.\n\nSnuke can perform the following operation zero or more times:\n\nChoose two distinct cities that are not directly connected by a road, and build a new road between the two cities.\n\nAfter he finishes the operations, it must be possible to travel from any city to any other cities by following roads (possibly multiple times).\n\nWhat is the minimum number of roads he must build to achieve the goal?\n\nConstraints\n\n2 \\leq N \\leq 100,000\n\n1 \\leq M \\leq 100,000\n\n1 \\leq A_i < B_i \\leq N\n\nNo two roads connect the same pair of cities.\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\n:\nA_M B_M\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n3 1\n1 2\n\nSample Output 1\n\n1\n\nInitially, there are three cities, and there is a road between City 1 and City 2.\n\nSnuke can achieve the goal by building one new road, for example, between City 1 and City 3.\nAfter that,\n\nWe can travel between 1 and 2 directly.\n\nWe can travel between 1 and 3 directly.\n\nWe can travel between 2 and 3 by following both roads (2 - 1 - 3).", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 670, "memory_kb": 78108}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s915434191", "group_id": "codeNet:p02540", "input_text": "@file:Suppress(\"NOTHING_TO_INLINE\", \"EXPERIMENTAL_FEATURE_WARNING\", \"OVERRIDE_BY_INLINE\")\n//@file:OptIn(ExperimentalStdlibApi::class)\n\nimport java.io.PrintWriter\nimport java.util.PriorityQueue\nimport java.util.TreeMap\nimport kotlin.math.*\nimport kotlin.random.Random\nimport kotlin.collections.sort as _sort\nimport kotlin.collections.sortDescending as _sortDescending\nimport kotlin.io.println as iprintln\n\n\n/** @author Spheniscine */\nfun main() { _writer.solve(); _writer.flush() }\nfun PrintWriter.solve() {\n// val startTime = System.nanoTime()\n\n val numCases = 1//readInt()\n case@ for(case in 1..numCases) {\n// print(\"Case #$case: \")\n\n val n = readInt()\n val I = IntArray(n)\n val Y = IntArray(n)\n\n for(i in 0 until n) {\n val x = readInt()-1\n val y = readInt()-1\n\n I[x] = i\n Y[x] = y\n }\n\n val D = DSU(n)\n val M = PriorityQueue(compareBy { it.y })\n for(x in 0 until n) {\n val y = Y[x]\n val i = I[x]\n val cy = if(M.isNotEmpty() && M.element().y < y) M.element().y else y\n while(M.isNotEmpty() && M.element().y < y) {\n D.join(i, M.remove().i)\n }\n\n M.add(Entry(cy, i))\n }\n\n for(i in 0 until n) {\n println(D.size(i))\n }\n }\n\n// iprintln(\"Time: ${(System.nanoTime() - startTime) / 1000000} ms\")\n}\n\ndata class Entry(val y: Int, val i: Int)\n\nclass DSU(n: Int) {\n private val id = IntArray(n) { it }\n private val sz = IntArray(n) { 1 }\n\n tailrec fun root(v: Int): Int =\n if(id[v] == v) v else {\n id[v] = id[id[v]]\n root(id[v])\n }\n\n /** @return false if the two vertices are already joined, true if the join operation is successful */\n fun join(u: Int, v: Int): Boolean {\n var ru = root(u)\n var rv = root(v)\n if(ru == rv) return false\n if(sz[ru] < sz[rv]) ru = rv.also { rv = ru }\n id[rv] = ru\n sz[ru] += sz[rv]\n return true\n }\n\n fun isJoined(u: Int, v: Int) = root(u) == root(v)\n\n fun size(v: Int) = sz[root(v)]\n}\n\nclass IntList(initialCapacity: Int = 12) {\n private var _arr = IntArray(initialCapacity)\n private val capacity get() = _arr.size\n var size = 0\n private set\n inline val lastIndex get() = size - 1\n inline val indices get() = 0 until size\n\n constructor(copyFrom: IntArray): this(copyFrom.size) { copyFrom.copyInto(_arr); size = copyFrom.size }\n constructor(copyFrom: Collection): this(copyFrom.size) { _arr = copyFrom.toIntArray(); size = copyFrom.size }\n\n fun contentEquals(other: IntList): Boolean {\n return this === other || size == other.size && indices.all { this[it] == other[it] }\n }\n\n private fun grow(minCapacity: Int = 8) {\n val newCapacity = maxOf(minCapacity, capacity + (capacity shr 1))\n _arr = _arr.copyOf(newCapacity)\n }\n\n fun ensureCapacity(minCapacity: Int) { if(capacity < minCapacity) grow(minCapacity) }\n\n operator fun get(index: Int): Int {\n require(index in 0 until size)\n return _arr[index]\n }\n\n operator fun set(index: Int, value: Int) {\n require(index in 0 until size)\n _arr[index] = value\n }\n\n fun add(value: Int) {\n if(size == capacity) grow()\n _arr[size++] = value\n }\n\n fun addAll(list: IntList) {\n ensureCapacity(size + list.size)\n list._arr.copyInto(_arr, size, 0, list.size)\n size += list.size\n }\n\n fun add(index: Int, element: Int) {\n if(size == capacity) grow()\n _arr.copyInto(_arr, index + 1, index, size)\n size++\n set(index, element)\n }\n\n fun clear() { size = 0 }\n\n fun removeAt(index: Int): Int {\n val e = get(index)\n _arr.copyInto(_arr, index, index + 1, size)\n size--\n return e\n }\n\n fun indexOf(e: Int): Int {\n for(i in 0 until size) if(this[i] == e) return i\n return -1\n }\n\n fun remove(e: Int): Boolean {\n val i = indexOf(e)\n if(i == -1) return false\n removeAt(i)\n return true\n }\n\n operator fun iterator() = object: IntIterator() {\n private var pos = 0\n override fun hasNext() = pos < size\n override fun nextInt() = get(pos++)\n }\n\n inline fun isEmpty() = size == 0\n inline fun isNotEmpty() = size != 0\n\n fun pop() = _arr[--size]\n\n fun popToSize(s: Int) {\n require(s >= 0)\n if(s < size) size = s\n }\n\n fun swap(i: Int, j: Int) { val t = this[i]; this[i] = this[j]; this[j] = t }\n fun reverse() {\n for(i in 0 until size / 2) swap(i, lastIndex - i)\n }\n\n fun shuffle(rnd: Random = random) { for(i in lastIndex downTo 1) swap(i, rnd.nextInt(i+1)) }\n fun sort() { shuffle(); _arr._sort(0, size) }\n fun sortDescending() { sort(); reverse() }\n\n fun joinToString(separator: CharSequence) = if(size == 0) \"\" else let {\n buildString {\n append(it[0])\n for (i in 1 until size) {\n append(separator).append(it[i])\n }\n }\n }\n\n override fun toString() = \"[\" + joinToString(\", \") + \"]\"\n\n fun toIntArray() = _arr.copyOf(size)\n fun toList() = List(size, ::get)\n\n inline fun first() = get(0)\n inline fun last() = get(lastIndex)\n}\n\ninline fun IntList(size: Int, init: (Int) -> Int) = IntList(size).apply {\n for(i in 0 until size) { add(init(i)) }\n}\ninline fun IntArray.toIntList() = IntList(this)\ninline fun Collection.toIntList() = IntList(this)\ninline fun intListOf(vararg values: Int) = IntList(values)\n\nfun IntList.max() = (1 until size).fold(this[0]) { acc, i -> max(acc, this[i]) }\nfun IntList.min() = (1 until size).fold(this[0]) { acc, i -> min(acc, this[i]) }\nfun IntList.getOrNull(i: Int) = if(i in indices) get(i) else null\ninline fun IntList.count(predicate: (Int) -> Boolean) = indices.count { predicate(this[it]) }\nfun IntList.copyOf() = IntList(size, ::get)\n\n/** IO */\n//@JvmField val INPUT = File(\"input.txt\").inputStream()\n//@JvmField val OUTPUT = File(\"output.txt\").outputStream()\n@JvmField val INPUT = System.`in`\n@JvmField val OUTPUT = System.out\n\nconst val _BUFFER_SIZE = 1 shl 16\n@JvmField val _buffer = ByteArray(_BUFFER_SIZE)\n@JvmField var _bufferPt = 0\n@JvmField var _bytesRead = 0\n\ntailrec fun readChar(): Char {\n if(_bufferPt == _bytesRead) {\n _bufferPt = 0\n _bytesRead = INPUT.read(_buffer, 0, _BUFFER_SIZE)\n }\n return if(_bytesRead < 0) Char.MIN_VALUE\n else {\n val c = _buffer[_bufferPt++].toChar()\n if (c == '\\r') readChar()\n else c\n }\n}\n\nfun readLine(): String? {\n var c = readChar()\n return if(c == Char.MIN_VALUE) null\n else buildString {\n while(c != '\\n' && c != Char.MIN_VALUE) {\n append(c)\n c = readChar()\n }\n }\n}\nfun readLn() = readLine()!!\n\nfun read() = buildString {\n var c = readChar()\n while(c <= ' ') {\n if(c == Char.MIN_VALUE) return@buildString\n c = readChar()\n }\n do {\n append(c)\n c = readChar()\n } while(c > ' ')\n}\nfun readInt() = read().toInt()\nfun readDouble() = read().toDouble()\nfun readLong() = read().toLong()\nfun readStrings(n: Int) = List(n) { read() }\nfun readLines(n: Int) = List(n) { readLn() }\nfun readInts(n: Int) = List(n) { read().toInt() }\nfun readIntArray(n: Int) = IntArray(n) { read().toInt() }\nfun readDoubles(n: Int) = List(n) { read().toDouble() }\nfun readDoubleArray(n: Int) = DoubleArray(n) { read().toDouble() }\nfun readLongs(n: Int) = List(n) { read().toLong() }\nfun readLongArray(n: Int) = LongArray(n) { read().toLong() }\n\n@JvmField val _writer = PrintWriter(OUTPUT, false)\n\n/** shuffles and sort overrides to avoid quicksort attacks */\nprivate inline fun _shuffle(rnd: Random, get: (Int) -> T, set: (Int, T) -> Unit, size: Int) {\n // Fisher-Yates shuffle algorithm\n for (i in size - 1 downTo 1) {\n val j = rnd.nextInt(i + 1)\n val temp = get(i)\n set(i, get(j))\n set(j, temp)\n }\n}\n\n@JvmField var _random: Random? = null\nval random get() = _random ?: Random(0x594E215C123 * System.nanoTime()).also { _random = it }\n\nfun IntArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\nfun IntArray.sort() { shuffle(); _sort() }\nfun IntArray.sortDescending() { shuffle(); _sortDescending() }\n\nfun LongArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\nfun LongArray.sort() { shuffle(); _sort() }\nfun LongArray.sortDescending() { shuffle(); _sortDescending() }\n\nfun DoubleArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\nfun DoubleArray.sort() { shuffle(); _sort() }\nfun DoubleArray.sortDescending() { shuffle(); _sortDescending() }\n\nfun CharArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\ninline fun CharArray.sort() { _sort() }\ninline fun CharArray.sortDescending() { _sortDescending() }\n\ninline fun > Array.sort() = _sort()\ninline fun > Array.sortDescending() = _sortDescending()\ninline fun > MutableList.sort() = _sort()\ninline fun > MutableList.sortDescending() = _sortDescending()\n\nfun `please stop removing these imports IntelliJ`() { iprintln(max(1, 2)) }\n\n/** additional commons */\ninline fun Iterable.sumByLong(func: (T) -> Long) = fold(0L) { acc, t -> acc + func(t) }\ninline fun Sequence.sumByLong(func: (T) -> Long) = fold(0L) { acc, t -> acc + func(t) }\ninline fun Array.sumByLong(func: (T) -> Long) = fold(0L) { acc, t -> acc + func(t) }\nfun IntArray.sumLong() = fold(0L, Long::plus)\n", "language": "Kotlin", "metadata": {"date": 1600642185, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02540.html", "problem_id": "p02540", "resource_group": "medium_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/Kotlin/s915434191.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s915434191", "user_id": "u596111103"}, "prompt_components": {"gold_output": "1\n1\n2\n2\n", "input_to_evaluate": "@file:Suppress(\"NOTHING_TO_INLINE\", \"EXPERIMENTAL_FEATURE_WARNING\", \"OVERRIDE_BY_INLINE\")\n//@file:OptIn(ExperimentalStdlibApi::class)\n\nimport java.io.PrintWriter\nimport java.util.PriorityQueue\nimport java.util.TreeMap\nimport kotlin.math.*\nimport kotlin.random.Random\nimport kotlin.collections.sort as _sort\nimport kotlin.collections.sortDescending as _sortDescending\nimport kotlin.io.println as iprintln\n\n\n/** @author Spheniscine */\nfun main() { _writer.solve(); _writer.flush() }\nfun PrintWriter.solve() {\n// val startTime = System.nanoTime()\n\n val numCases = 1//readInt()\n case@ for(case in 1..numCases) {\n// print(\"Case #$case: \")\n\n val n = readInt()\n val I = IntArray(n)\n val Y = IntArray(n)\n\n for(i in 0 until n) {\n val x = readInt()-1\n val y = readInt()-1\n\n I[x] = i\n Y[x] = y\n }\n\n val D = DSU(n)\n val M = PriorityQueue(compareBy { it.y })\n for(x in 0 until n) {\n val y = Y[x]\n val i = I[x]\n val cy = if(M.isNotEmpty() && M.element().y < y) M.element().y else y\n while(M.isNotEmpty() && M.element().y < y) {\n D.join(i, M.remove().i)\n }\n\n M.add(Entry(cy, i))\n }\n\n for(i in 0 until n) {\n println(D.size(i))\n }\n }\n\n// iprintln(\"Time: ${(System.nanoTime() - startTime) / 1000000} ms\")\n}\n\ndata class Entry(val y: Int, val i: Int)\n\nclass DSU(n: Int) {\n private val id = IntArray(n) { it }\n private val sz = IntArray(n) { 1 }\n\n tailrec fun root(v: Int): Int =\n if(id[v] == v) v else {\n id[v] = id[id[v]]\n root(id[v])\n }\n\n /** @return false if the two vertices are already joined, true if the join operation is successful */\n fun join(u: Int, v: Int): Boolean {\n var ru = root(u)\n var rv = root(v)\n if(ru == rv) return false\n if(sz[ru] < sz[rv]) ru = rv.also { rv = ru }\n id[rv] = ru\n sz[ru] += sz[rv]\n return true\n }\n\n fun isJoined(u: Int, v: Int) = root(u) == root(v)\n\n fun size(v: Int) = sz[root(v)]\n}\n\nclass IntList(initialCapacity: Int = 12) {\n private var _arr = IntArray(initialCapacity)\n private val capacity get() = _arr.size\n var size = 0\n private set\n inline val lastIndex get() = size - 1\n inline val indices get() = 0 until size\n\n constructor(copyFrom: IntArray): this(copyFrom.size) { copyFrom.copyInto(_arr); size = copyFrom.size }\n constructor(copyFrom: Collection): this(copyFrom.size) { _arr = copyFrom.toIntArray(); size = copyFrom.size }\n\n fun contentEquals(other: IntList): Boolean {\n return this === other || size == other.size && indices.all { this[it] == other[it] }\n }\n\n private fun grow(minCapacity: Int = 8) {\n val newCapacity = maxOf(minCapacity, capacity + (capacity shr 1))\n _arr = _arr.copyOf(newCapacity)\n }\n\n fun ensureCapacity(minCapacity: Int) { if(capacity < minCapacity) grow(minCapacity) }\n\n operator fun get(index: Int): Int {\n require(index in 0 until size)\n return _arr[index]\n }\n\n operator fun set(index: Int, value: Int) {\n require(index in 0 until size)\n _arr[index] = value\n }\n\n fun add(value: Int) {\n if(size == capacity) grow()\n _arr[size++] = value\n }\n\n fun addAll(list: IntList) {\n ensureCapacity(size + list.size)\n list._arr.copyInto(_arr, size, 0, list.size)\n size += list.size\n }\n\n fun add(index: Int, element: Int) {\n if(size == capacity) grow()\n _arr.copyInto(_arr, index + 1, index, size)\n size++\n set(index, element)\n }\n\n fun clear() { size = 0 }\n\n fun removeAt(index: Int): Int {\n val e = get(index)\n _arr.copyInto(_arr, index, index + 1, size)\n size--\n return e\n }\n\n fun indexOf(e: Int): Int {\n for(i in 0 until size) if(this[i] == e) return i\n return -1\n }\n\n fun remove(e: Int): Boolean {\n val i = indexOf(e)\n if(i == -1) return false\n removeAt(i)\n return true\n }\n\n operator fun iterator() = object: IntIterator() {\n private var pos = 0\n override fun hasNext() = pos < size\n override fun nextInt() = get(pos++)\n }\n\n inline fun isEmpty() = size == 0\n inline fun isNotEmpty() = size != 0\n\n fun pop() = _arr[--size]\n\n fun popToSize(s: Int) {\n require(s >= 0)\n if(s < size) size = s\n }\n\n fun swap(i: Int, j: Int) { val t = this[i]; this[i] = this[j]; this[j] = t }\n fun reverse() {\n for(i in 0 until size / 2) swap(i, lastIndex - i)\n }\n\n fun shuffle(rnd: Random = random) { for(i in lastIndex downTo 1) swap(i, rnd.nextInt(i+1)) }\n fun sort() { shuffle(); _arr._sort(0, size) }\n fun sortDescending() { sort(); reverse() }\n\n fun joinToString(separator: CharSequence) = if(size == 0) \"\" else let {\n buildString {\n append(it[0])\n for (i in 1 until size) {\n append(separator).append(it[i])\n }\n }\n }\n\n override fun toString() = \"[\" + joinToString(\", \") + \"]\"\n\n fun toIntArray() = _arr.copyOf(size)\n fun toList() = List(size, ::get)\n\n inline fun first() = get(0)\n inline fun last() = get(lastIndex)\n}\n\ninline fun IntList(size: Int, init: (Int) -> Int) = IntList(size).apply {\n for(i in 0 until size) { add(init(i)) }\n}\ninline fun IntArray.toIntList() = IntList(this)\ninline fun Collection.toIntList() = IntList(this)\ninline fun intListOf(vararg values: Int) = IntList(values)\n\nfun IntList.max() = (1 until size).fold(this[0]) { acc, i -> max(acc, this[i]) }\nfun IntList.min() = (1 until size).fold(this[0]) { acc, i -> min(acc, this[i]) }\nfun IntList.getOrNull(i: Int) = if(i in indices) get(i) else null\ninline fun IntList.count(predicate: (Int) -> Boolean) = indices.count { predicate(this[it]) }\nfun IntList.copyOf() = IntList(size, ::get)\n\n/** IO */\n//@JvmField val INPUT = File(\"input.txt\").inputStream()\n//@JvmField val OUTPUT = File(\"output.txt\").outputStream()\n@JvmField val INPUT = System.`in`\n@JvmField val OUTPUT = System.out\n\nconst val _BUFFER_SIZE = 1 shl 16\n@JvmField val _buffer = ByteArray(_BUFFER_SIZE)\n@JvmField var _bufferPt = 0\n@JvmField var _bytesRead = 0\n\ntailrec fun readChar(): Char {\n if(_bufferPt == _bytesRead) {\n _bufferPt = 0\n _bytesRead = INPUT.read(_buffer, 0, _BUFFER_SIZE)\n }\n return if(_bytesRead < 0) Char.MIN_VALUE\n else {\n val c = _buffer[_bufferPt++].toChar()\n if (c == '\\r') readChar()\n else c\n }\n}\n\nfun readLine(): String? {\n var c = readChar()\n return if(c == Char.MIN_VALUE) null\n else buildString {\n while(c != '\\n' && c != Char.MIN_VALUE) {\n append(c)\n c = readChar()\n }\n }\n}\nfun readLn() = readLine()!!\n\nfun read() = buildString {\n var c = readChar()\n while(c <= ' ') {\n if(c == Char.MIN_VALUE) return@buildString\n c = readChar()\n }\n do {\n append(c)\n c = readChar()\n } while(c > ' ')\n}\nfun readInt() = read().toInt()\nfun readDouble() = read().toDouble()\nfun readLong() = read().toLong()\nfun readStrings(n: Int) = List(n) { read() }\nfun readLines(n: Int) = List(n) { readLn() }\nfun readInts(n: Int) = List(n) { read().toInt() }\nfun readIntArray(n: Int) = IntArray(n) { read().toInt() }\nfun readDoubles(n: Int) = List(n) { read().toDouble() }\nfun readDoubleArray(n: Int) = DoubleArray(n) { read().toDouble() }\nfun readLongs(n: Int) = List(n) { read().toLong() }\nfun readLongArray(n: Int) = LongArray(n) { read().toLong() }\n\n@JvmField val _writer = PrintWriter(OUTPUT, false)\n\n/** shuffles and sort overrides to avoid quicksort attacks */\nprivate inline fun _shuffle(rnd: Random, get: (Int) -> T, set: (Int, T) -> Unit, size: Int) {\n // Fisher-Yates shuffle algorithm\n for (i in size - 1 downTo 1) {\n val j = rnd.nextInt(i + 1)\n val temp = get(i)\n set(i, get(j))\n set(j, temp)\n }\n}\n\n@JvmField var _random: Random? = null\nval random get() = _random ?: Random(0x594E215C123 * System.nanoTime()).also { _random = it }\n\nfun IntArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\nfun IntArray.sort() { shuffle(); _sort() }\nfun IntArray.sortDescending() { shuffle(); _sortDescending() }\n\nfun LongArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\nfun LongArray.sort() { shuffle(); _sort() }\nfun LongArray.sortDescending() { shuffle(); _sortDescending() }\n\nfun DoubleArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\nfun DoubleArray.sort() { shuffle(); _sort() }\nfun DoubleArray.sortDescending() { shuffle(); _sortDescending() }\n\nfun CharArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\ninline fun CharArray.sort() { _sort() }\ninline fun CharArray.sortDescending() { _sortDescending() }\n\ninline fun > Array.sort() = _sort()\ninline fun > Array.sortDescending() = _sortDescending()\ninline fun > MutableList.sort() = _sort()\ninline fun > MutableList.sortDescending() = _sortDescending()\n\nfun `please stop removing these imports IntelliJ`() { iprintln(max(1, 2)) }\n\n/** additional commons */\ninline fun Iterable.sumByLong(func: (T) -> Long) = fold(0L) { acc, t -> acc + func(t) }\ninline fun Sequence.sumByLong(func: (T) -> Long) = fold(0L) { acc, t -> acc + func(t) }\ninline fun Array.sumByLong(func: (T) -> Long) = fold(0L) { acc, t -> acc + func(t) }\nfun IntArray.sumLong() = fold(0L, Long::plus)\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 9666, "cpu_time_ms": 484, "memory_kb": 61548}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s079996586", "group_id": "codeNet:p02547", "input_text": "import java.util.*\n\nfun main() {\n val sc = Scanner(System.`in`)\n val n = sc.nextInt()\n val ds = (1..n*2).map { sc.nextInt() }\n\n println(calc(ds))\n}\n\nfun calc(ds: List): String {\n var cnt = 0\n var maxCnt = 0\n for(i in ds.indices step 2) {\n if(ds[i] == ds[i+1]) {\n cnt++\n }\n else {\n if(cnt > maxCnt) maxCnt = cnt\n cnt = 0\n }\n }\n if(cnt > maxCnt) maxCnt = cnt\n return if(maxCnt >= 3) \"Yes\" else \"No\"\n}", "language": "Kotlin", "metadata": {"date": 1600543555, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02547.html", "problem_id": "p02547", "resource_group": "medium_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/Kotlin/s079996586.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s079996586", "user_id": "u440530959"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "import java.util.*\n\nfun main() {\n val sc = Scanner(System.`in`)\n val n = sc.nextInt()\n val ds = (1..n*2).map { sc.nextInt() }\n\n println(calc(ds))\n}\n\nfun calc(ds: List): String {\n var cnt = 0\n var maxCnt = 0\n for(i in ds.indices step 2) {\n if(ds[i] == ds[i+1]) {\n cnt++\n }\n else {\n if(cnt > maxCnt) maxCnt = cnt\n cnt = 0\n }\n }\n if(cnt > maxCnt) maxCnt = cnt\n return if(maxCnt >= 3) \"Yes\" else \"No\"\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 494, "cpu_time_ms": 212, "memory_kb": 38028}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s955985760", "group_id": "codeNet:p02548", "input_text": "import java.util.*\nimport kotlin.math.*\n\nfun str() = readLine()!!\nfun int() = str().toInt()\nfun long() = str().toLong()\n\nfun read(d: String = \" \") = str().split(d)\nfun list(d: String = \" \", f: String.() -> T) = read(d).map { f(it) }\nfun list() = list { toInt() }\n\nfun MutableList.removeLast() = this.removeAt(this.lastIndex)\n\nconst val mod = 1000000007L\n\nfun main() {\n abc000X()\n}\n\nfun abc000X() {\n val n = int()\n (1..n).map { (n - 1L) / it }.sum().let { println(it) }\n}\n", "language": "Kotlin", "metadata": {"date": 1600542447, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02548.html", "problem_id": "p02548", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02548/input.txt", "sample_output_relpath": "derived/input_output/data/p02548/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02548/Kotlin/s955985760.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s955985760", "user_id": "u059234158"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "import java.util.*\nimport kotlin.math.*\n\nfun str() = readLine()!!\nfun int() = str().toInt()\nfun long() = str().toLong()\n\nfun read(d: String = \" \") = str().split(d)\nfun list(d: String = \" \", f: String.() -> T) = read(d).map { f(it) }\nfun list() = list { toInt() }\n\nfun MutableList.removeLast() = this.removeAt(this.lastIndex)\n\nconst val mod = 1000000007L\n\nfun main() {\n abc000X()\n}\n\nfun abc000X() {\n val n = int()\n (1..n).map { (n - 1L) / it }.sum().let { println(it) }\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nGiven is a positive integer N.\nHow many tuples (A,B,C) of positive integers satisfy A \\times B + C = N?\n\nConstraints\n\n2 \\leq N \\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\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n3\n\nSample Output 1\n\n3\n\nThere are 3 tuples of integers that satisfy A \\times B + C = 3: (A, B, C) = (1, 1, 2), (1, 2, 1), (2, 1, 1).\n\nSample Input 2\n\n100\n\nSample Output 2\n\n473\n\nSample Input 3\n\n1000000\n\nSample Output 3\n\n13969985", "sample_input": "3\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02548", "source_text": "Score : 300 points\n\nProblem Statement\n\nGiven is a positive integer N.\nHow many tuples (A,B,C) of positive integers satisfy A \\times B + C = N?\n\nConstraints\n\n2 \\leq N \\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\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n3\n\nSample Output 1\n\n3\n\nThere are 3 tuples of integers that satisfy A \\times B + C = 3: (A, B, C) = (1, 1, 2), (1, 2, 1), (2, 1, 1).\n\nSample Input 2\n\n100\n\nSample Output 2\n\n473\n\nSample Input 3\n\n1000000\n\nSample Output 3\n\n13969985", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 156, "memory_kb": 50312}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s113730038", "group_id": "codeNet:p02548", "input_text": "import java.io.BufferedReader\nimport java.io.InputStream\nimport java.io.InputStreamReader\nimport java.io.PrintWriter\nimport java.util.*\n\nfun PrintWriter.solve(sc: FastScanner) {\n val n = sc.nextInt()\n var ans = 0L\n for (a in 1 until n) {\n for (b in 1 until n) {\n if (a * b >= n) break\n ans++\n }\n }\n println(ans)\n}\n\nfun main() {\n val writer = PrintWriter(System.out, false)\n writer.solve(FastScanner(System.`in`))\n writer.flush()\n}\n\nclass FastScanner(s: InputStream) {\n private var st = StringTokenizer(\"\")\n private val br = BufferedReader(InputStreamReader(s))\n\n fun next(): String {\n while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())\n\n return st.nextToken()\n }\n\n fun nextInt() = next().toInt()\n fun nextLong() = next().toLong()\n fun nextLine() = br.readLine()\n fun nextDouble() = next().toDouble()\n fun ready() = br.ready()\n}", "language": "Kotlin", "metadata": {"date": 1600542303, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02548.html", "problem_id": "p02548", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02548/input.txt", "sample_output_relpath": "derived/input_output/data/p02548/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02548/Kotlin/s113730038.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s113730038", "user_id": "u190507186"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "import java.io.BufferedReader\nimport java.io.InputStream\nimport java.io.InputStreamReader\nimport java.io.PrintWriter\nimport java.util.*\n\nfun PrintWriter.solve(sc: FastScanner) {\n val n = sc.nextInt()\n var ans = 0L\n for (a in 1 until n) {\n for (b in 1 until n) {\n if (a * b >= n) break\n ans++\n }\n }\n println(ans)\n}\n\nfun main() {\n val writer = PrintWriter(System.out, false)\n writer.solve(FastScanner(System.`in`))\n writer.flush()\n}\n\nclass FastScanner(s: InputStream) {\n private var st = StringTokenizer(\"\")\n private val br = BufferedReader(InputStreamReader(s))\n\n fun next(): String {\n while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())\n\n return st.nextToken()\n }\n\n fun nextInt() = next().toInt()\n fun nextLong() = next().toLong()\n fun nextLine() = br.readLine()\n fun nextDouble() = next().toDouble()\n fun ready() = br.ready()\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nGiven is a positive integer N.\nHow many tuples (A,B,C) of positive integers satisfy A \\times B + C = N?\n\nConstraints\n\n2 \\leq N \\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\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n3\n\nSample Output 1\n\n3\n\nThere are 3 tuples of integers that satisfy A \\times B + C = 3: (A, B, C) = (1, 1, 2), (1, 2, 1), (2, 1, 1).\n\nSample Input 2\n\n100\n\nSample Output 2\n\n473\n\nSample Input 3\n\n1000000\n\nSample Output 3\n\n13969985", "sample_input": "3\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02548", "source_text": "Score : 300 points\n\nProblem Statement\n\nGiven is a positive integer N.\nHow many tuples (A,B,C) of positive integers satisfy A \\times B + C = N?\n\nConstraints\n\n2 \\leq N \\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\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n3\n\nSample Output 1\n\n3\n\nThere are 3 tuples of integers that satisfy A \\times B + C = 3: (A, B, C) = (1, 1, 2), (1, 2, 1), (2, 1, 1).\n\nSample Input 2\n\n100\n\nSample Output 2\n\n473\n\nSample Input 3\n\n1000000\n\nSample Output 3\n\n13969985", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 941, "cpu_time_ms": 117, "memory_kb": 35236}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s984168873", "group_id": "codeNet:p02549", "input_text": "fun main() {\n val MOD = 998_244_353\n val (n, k) = nextIntList()\n val s = mutableSetOf()\n val map = mutableMapOf(1 to 1L)\n repeat(k) {\n val (l, r) = nextIntList()\n (l..r).forEach {\n s.add(it)\n }\n }\n (2..n).forEach { current ->\n var count = 0L\n s.forEach {\n val i = current - it\n if (i <= 0) return@forEach\n count = count.plus(map.getValue(i)).rem(MOD)\n }\n map[current] = count\n }\n// println(s)\n// println(map)\n println(map[n])\n}\n\n// # Utils\n// ## Input\nfun next() = readLine()!!\nfun nextInt() = next().toInt()\nfun nextLong() = next().toLong()\nfun nextDouble() = next().toDouble()\nfun nextList() = next().split(\" \")\nfun nextIntList() = next().split(\" \").map(String::toInt)\nfun nextLongList() = next().split(\" \").map(String::toLong)\nfun nextDoubleList() = next().split(\" \").map(String::toDouble)\n\n// ## Array\ninline fun sizedArray(size: Int, default: T) = Array(size) { default }\ninline fun sized2DArray(row: Int, column: Int, default: T) = Array(row) { Array(column) { default } }\n\n// ## mod^-1\n// [NOTE] CANNOT use this for 0, mod, 2mod, 3mod ...(return wrong value)\nfun modinv(num: Long, mod: Long): Long {\n var a = num\n var b = mod\n var u = 1L\n var v = 0L\n while (b > 0) {\n val t = a.div(b)\n a -= t * b\n a = b.also { b = a } // swap a and b\n u -= t * v\n u = v.also { v = u } // swap u and v\n }\n u %= mod\n if (u < 0) u += mod\n return u\n}\n\nfun gcd(x: Int, y: Int): Int {\n fun innerGcd(x: Int, y: Int): Int {\n return if (x % y == 0) y else innerGcd(y, x % y)\n }\n return if (x >= y) innerGcd(x, y) else innerGcd(y, x)\n}\n\nfun gcd(x: Long, y: Long): Long {\n fun innerGcd(x: Long, y: Long): Long {\n return if (x % y == 0L) y else innerGcd(y, x % y)\n }\n return if (x >= y) innerGcd(x, y) else innerGcd(y, x)\n}\n\n// classes\nclass UnionFindTree(val size: Int) {\n private val r = sizedArray(size, -1)\n fun root(x: Int): Int {\n if (r[x] < 0) return x\n return root(r[x])\n }\n\n fun unite(x: Int, y: Int) {\n var rx = root(x)\n var ry = root(y)\n if (rx == ry) return\n if (r[rx] > r[ry]) {\n rx = ry.also { ry = rx }\n }\n r[rx] += r[ry]\n r[ry] = rx\n }\n\n fun size(x: Int) = -r[root(x)]\n\n override fun toString(): String {\n return r.joinToString(separator = \", \")\n }\n}", "language": "Kotlin", "metadata": {"date": 1600546915, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02549.html", "problem_id": "p02549", "resource_group": "medium_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/Kotlin/s984168873.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s984168873", "user_id": "u885556801"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "fun main() {\n val MOD = 998_244_353\n val (n, k) = nextIntList()\n val s = mutableSetOf()\n val map = mutableMapOf(1 to 1L)\n repeat(k) {\n val (l, r) = nextIntList()\n (l..r).forEach {\n s.add(it)\n }\n }\n (2..n).forEach { current ->\n var count = 0L\n s.forEach {\n val i = current - it\n if (i <= 0) return@forEach\n count = count.plus(map.getValue(i)).rem(MOD)\n }\n map[current] = count\n }\n// println(s)\n// println(map)\n println(map[n])\n}\n\n// # Utils\n// ## Input\nfun next() = readLine()!!\nfun nextInt() = next().toInt()\nfun nextLong() = next().toLong()\nfun nextDouble() = next().toDouble()\nfun nextList() = next().split(\" \")\nfun nextIntList() = next().split(\" \").map(String::toInt)\nfun nextLongList() = next().split(\" \").map(String::toLong)\nfun nextDoubleList() = next().split(\" \").map(String::toDouble)\n\n// ## Array\ninline fun sizedArray(size: Int, default: T) = Array(size) { default }\ninline fun sized2DArray(row: Int, column: Int, default: T) = Array(row) { Array(column) { default } }\n\n// ## mod^-1\n// [NOTE] CANNOT use this for 0, mod, 2mod, 3mod ...(return wrong value)\nfun modinv(num: Long, mod: Long): Long {\n var a = num\n var b = mod\n var u = 1L\n var v = 0L\n while (b > 0) {\n val t = a.div(b)\n a -= t * b\n a = b.also { b = a } // swap a and b\n u -= t * v\n u = v.also { v = u } // swap u and v\n }\n u %= mod\n if (u < 0) u += mod\n return u\n}\n\nfun gcd(x: Int, y: Int): Int {\n fun innerGcd(x: Int, y: Int): Int {\n return if (x % y == 0) y else innerGcd(y, x % y)\n }\n return if (x >= y) innerGcd(x, y) else innerGcd(y, x)\n}\n\nfun gcd(x: Long, y: Long): Long {\n fun innerGcd(x: Long, y: Long): Long {\n return if (x % y == 0L) y else innerGcd(y, x % y)\n }\n return if (x >= y) innerGcd(x, y) else innerGcd(y, x)\n}\n\n// classes\nclass UnionFindTree(val size: Int) {\n private val r = sizedArray(size, -1)\n fun root(x: Int): Int {\n if (r[x] < 0) return x\n return root(r[x])\n }\n\n fun unite(x: Int, y: Int) {\n var rx = root(x)\n var ry = root(y)\n if (rx == ry) return\n if (r[rx] > r[ry]) {\n rx = ry.also { ry = rx }\n }\n r[rx] += r[ry]\n r[ry] = rx\n }\n\n fun size(x: Int) = -r[root(x)]\n\n override fun toString(): String {\n return r.joinToString(separator = \", \")\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2502, "cpu_time_ms": 2208, "memory_kb": 72248}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s100572704", "group_id": "codeNet:p02550", "input_text": "import java.io.BufferedReader\nimport java.io.InputStreamReader\nimport java.io.PrintWriter\nimport kotlin.math.max\n\nval br = BufferedReader(InputStreamReader(System.`in`))\nval out = PrintWriter(System.out)\n\nfun main() {\n br.use { out.use {\n solve()\n out.flush()\n } }\n}\n\nfun solve() {\n val (n, x, m) = readLongList()\n\n // 何個目の項からループするのかを求める\n val indexMap = mutableMapOf()\n var cur = x\n var curIndex = 0\n while (indexMap.containsKey(cur) == false) {\n indexMap[cur] = curIndex\n curIndex++\n cur = cur * cur % m\n }\n val loopFromIndex = indexMap[cur]!!\n \n // ループする前の合計、1ループの合計、1ループの項数\n val sumBeforeLoop = indexMap.filter { it.value < loopFromIndex }.keys.sum()\n val sumOneLoop = indexMap.filter { it.value >= loopFromIndex }.keys.sum()\n val oneLoopSize = indexMap.count() - loopFromIndex\n\n // ループ開始後のn、ループする数、ループ終了後のn\n val nAfterStartLoop = max(0, n - loopFromIndex)\n val loopCount = nAfterStartLoop / oneLoopSize\n val nAfterEndLoop = nAfterStartLoop % oneLoopSize\n\n var ans = if (n <= loopFromIndex) 0 else sumBeforeLoop + loopCount * sumOneLoop\n\n var pre = if (n <= loopFromIndex) x else cur\n val simulateCount = if (n <= loopFromIndex) n.toInt() else nAfterEndLoop.toInt()\n repeat(simulateCount) {\n ans += pre\n pre = pre * pre % m\n }\n\n out.println(ans)\n return\n}\n\nfun readInteger() = Integer.parseInt(br.readLine())\nfun readLong() = java.lang.Long.parseLong(br.readLine())\nfun readStringList() = br.readLine()!!.split(' ')\nfun readIntegerList() = readStringList().map(Integer::parseInt)\nfun readLongList() = readStringList().map(java.lang.Long::parseLong)\nfun readDoubleList() = readStringList().map(java.lang.Double::parseDouble)\n", "language": "Kotlin", "metadata": {"date": 1600605505, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02550.html", "problem_id": "p02550", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02550/input.txt", "sample_output_relpath": "derived/input_output/data/p02550/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02550/Kotlin/s100572704.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s100572704", "user_id": "u784448849"}, "prompt_components": {"gold_output": "1369\n", "input_to_evaluate": "import java.io.BufferedReader\nimport java.io.InputStreamReader\nimport java.io.PrintWriter\nimport kotlin.math.max\n\nval br = BufferedReader(InputStreamReader(System.`in`))\nval out = PrintWriter(System.out)\n\nfun main() {\n br.use { out.use {\n solve()\n out.flush()\n } }\n}\n\nfun solve() {\n val (n, x, m) = readLongList()\n\n // 何個目の項からループするのかを求める\n val indexMap = mutableMapOf()\n var cur = x\n var curIndex = 0\n while (indexMap.containsKey(cur) == false) {\n indexMap[cur] = curIndex\n curIndex++\n cur = cur * cur % m\n }\n val loopFromIndex = indexMap[cur]!!\n \n // ループする前の合計、1ループの合計、1ループの項数\n val sumBeforeLoop = indexMap.filter { it.value < loopFromIndex }.keys.sum()\n val sumOneLoop = indexMap.filter { it.value >= loopFromIndex }.keys.sum()\n val oneLoopSize = indexMap.count() - loopFromIndex\n\n // ループ開始後のn、ループする数、ループ終了後のn\n val nAfterStartLoop = max(0, n - loopFromIndex)\n val loopCount = nAfterStartLoop / oneLoopSize\n val nAfterEndLoop = nAfterStartLoop % oneLoopSize\n\n var ans = if (n <= loopFromIndex) 0 else sumBeforeLoop + loopCount * sumOneLoop\n\n var pre = if (n <= loopFromIndex) x else cur\n val simulateCount = if (n <= loopFromIndex) n.toInt() else nAfterEndLoop.toInt()\n repeat(simulateCount) {\n ans += pre\n pre = pre * pre % m\n }\n\n out.println(ans)\n return\n}\n\nfun readInteger() = Integer.parseInt(br.readLine())\nfun readLong() = java.lang.Long.parseLong(br.readLine())\nfun readStringList() = br.readLine()!!.split(' ')\nfun readIntegerList() = readStringList().map(Integer::parseInt)\nfun readLongList() = readStringList().map(java.lang.Long::parseLong)\nfun readDoubleList() = readStringList().map(java.lang.Double::parseDouble)\n", "problem_context": "Score : 500 points\n\nProblem Statement\n\nLet us denote by f(x, m) the remainder of the Euclidean division of x by m.\n\nLet A be the sequence that is defined by the initial value A_1=X and the recurrence relation A_{n+1} = f(A_n^2, M).\nFind \\displaystyle{\\sum_{i=1}^N A_i}.\n\nConstraints\n\n1 \\leq N \\leq 10^{10}\n\n0 \\leq X < M \\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 X M\n\nOutput\n\nPrint \\displaystyle{\\sum_{i=1}^N A_i}.\n\nSample Input 1\n\n6 2 1001\n\nSample Output 1\n\n1369\n\nThe sequence A begins 2,4,16,256,471,620,\\ldots Therefore, the answer is 2+4+16+256+471+620=1369.\n\nSample Input 2\n\n1000 2 16\n\nSample Output 2\n\n6\n\nThe sequence A begins 2,4,0,0,\\ldots Therefore, the answer is 6.\n\nSample Input 3\n\n10000000000 10 99959\n\nSample Output 3\n\n492443256176507", "sample_input": "6 2 1001\n"}, "reference_outputs": ["1369\n"], "source_document_id": "p02550", "source_text": "Score : 500 points\n\nProblem Statement\n\nLet us denote by f(x, m) the remainder of the Euclidean division of x by m.\n\nLet A be the sequence that is defined by the initial value A_1=X and the recurrence relation A_{n+1} = f(A_n^2, M).\nFind \\displaystyle{\\sum_{i=1}^N A_i}.\n\nConstraints\n\n1 \\leq N \\leq 10^{10}\n\n0 \\leq X < M \\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 X M\n\nOutput\n\nPrint \\displaystyle{\\sum_{i=1}^N A_i}.\n\nSample Input 1\n\n6 2 1001\n\nSample Output 1\n\n1369\n\nThe sequence A begins 2,4,16,256,471,620,\\ldots Therefore, the answer is 2+4+16+256+471+620=1369.\n\nSample Input 2\n\n1000 2 16\n\nSample Output 2\n\n6\n\nThe sequence A begins 2,4,0,0,\\ldots Therefore, the answer is 6.\n\nSample Input 3\n\n10000000000 10 99959\n\nSample Output 3\n\n492443256176507", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1891, "cpu_time_ms": 202, "memory_kb": 47712}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s806822424", "group_id": "codeNet:p02553", "input_text": "import java.io.BufferedReader\nimport java.io.InputStream\nimport java.io.InputStreamReader\nimport java.io.PrintWriter\nimport java.util.*\n\nfun PrintWriter.solve(sc: FastScanner) {\n val a = sc.nextLong()\n val b = sc.nextLong()\n val c = sc.nextLong()\n val d = sc.nextLong()\n val arr = arrayOf(a * c, a * d, b * c, b * d)\n println(arr.max())\n}\n\nfun main() {\n val writer = PrintWriter(System.out, false)\n writer.solve(FastScanner(System.`in`))\n writer.flush()\n}\n\nclass FastScanner(s: InputStream) {\n private var st = StringTokenizer(\"\")\n private val br = BufferedReader(InputStreamReader(s))\n\n fun next(): String {\n while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())\n\n return st.nextToken()\n }\n\n fun nextInt() = next().toInt()\n fun nextLong() = next().toLong()\n fun nextLine() = br.readLine()\n fun nextDouble() = next().toDouble()\n fun ready() = br.ready()\n}\n", "language": "Kotlin", "metadata": {"date": 1600023710, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02553.html", "problem_id": "p02553", "resource_group": "medium_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/Kotlin/s806822424.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s806822424", "user_id": "u190507186"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import java.io.BufferedReader\nimport java.io.InputStream\nimport java.io.InputStreamReader\nimport java.io.PrintWriter\nimport java.util.*\n\nfun PrintWriter.solve(sc: FastScanner) {\n val a = sc.nextLong()\n val b = sc.nextLong()\n val c = sc.nextLong()\n val d = sc.nextLong()\n val arr = arrayOf(a * c, a * d, b * c, b * d)\n println(arr.max())\n}\n\nfun main() {\n val writer = PrintWriter(System.out, false)\n writer.solve(FastScanner(System.`in`))\n writer.flush()\n}\n\nclass FastScanner(s: InputStream) {\n private var st = StringTokenizer(\"\")\n private val br = BufferedReader(InputStreamReader(s))\n\n fun next(): String {\n while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())\n\n return st.nextToken()\n }\n\n fun nextInt() = next().toInt()\n fun nextLong() = next().toLong()\n fun nextLine() = br.readLine()\n fun nextDouble() = next().toDouble()\n fun ready() = br.ready()\n}\n", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 934, "cpu_time_ms": 114, "memory_kb": 38336}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s753760273", "group_id": "codeNet:p02554", "input_text": "fun main() {\n val n = readLine()?.toLong() ?: return\n val m = (1e9 + 7).toLong()\n if (n == 1L) {\n println(\"0\")\n return\n }\n var a = 1L\n var o = 1L\n var t = 1L\n repeat(n.toInt()) {\n a = a * 10L % m\n o = o * 9L % m\n t = t * 8L % m\n }\n a = (a - o - o + t) % m\n println(a.toString())\n}", "language": "Kotlin", "metadata": {"date": 1600110927, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02554.html", "problem_id": "p02554", "resource_group": "medium_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/Kotlin/s753760273.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s753760273", "user_id": "u979429407"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "fun main() {\n val n = readLine()?.toLong() ?: return\n val m = (1e9 + 7).toLong()\n if (n == 1L) {\n println(\"0\")\n return\n }\n var a = 1L\n var o = 1L\n var t = 1L\n repeat(n.toInt()) {\n a = a * 10L % m\n o = o * 9L % m\n t = t * 8L % m\n }\n a = (a - o - o + t) % m\n println(a.toString())\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 348, "cpu_time_ms": 126, "memory_kb": 34416}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s794165598", "group_id": "codeNet:p02556", "input_text": "import java.util.*\nimport kotlin.math.*\n\nfun str() = readLine()!!\nfun int() = str().toInt()\nfun long() = str().toLong()\n\nfun read(d: String = \" \") = str().split(d)\nfun list(d: String = \" \", f: String.() -> T) = read(d).map { f(it) }\nfun list() = list { toInt() }\n\nfun MutableList.removeLast() = this.removeAt(this.lastIndex)\n\nconst val mod = 1000000007L\n\nfun main() {\n abc000X()\n}\n\nfun abc000X() {\n val n = int()\n val a = Array(n) {\n val (t, u) = list()\n t + u to t - u\n }\n\n val t = a.map { it.first }.sorted()\n val u = a.map { it.second }.sorted()\n\n println(max(t.last() - t.first(), u.last() - u.first()))\n}\n", "language": "Kotlin", "metadata": {"date": 1600027521, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02556.html", "problem_id": "p02556", "resource_group": "medium_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/Kotlin/s794165598.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s794165598", "user_id": "u059234158"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "import java.util.*\nimport kotlin.math.*\n\nfun str() = readLine()!!\nfun int() = str().toInt()\nfun long() = str().toLong()\n\nfun read(d: String = \" \") = str().split(d)\nfun list(d: String = \" \", f: String.() -> T) = read(d).map { f(it) }\nfun list() = list { toInt() }\n\nfun MutableList.removeLast() = this.removeAt(this.lastIndex)\n\nconst val mod = 1000000007L\n\nfun main() {\n abc000X()\n}\n\nfun abc000X() {\n val n = int()\n val a = Array(n) {\n val (t, u) = list()\n t + u to t - u\n }\n\n val t = a.map { it.first }.sorted()\n val u = a.map { it.second }.sorted()\n\n println(max(t.last() - t.first(), u.last() - u.first()))\n}\n", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 656, "cpu_time_ms": 1383, "memory_kb": 79128}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s030191258", "group_id": "codeNet:p02557", "input_text": "import java.io.BufferedReader\nimport java.io.InputStream\nimport java.io.InputStreamReader\nimport java.io.PrintWriter\nimport java.util.*\n\nfun PrintWriter.solve(sc: FastScanner) {\n val n = sc.nextInt()\n val a = Array(n) { sc.nextInt() }\n val b = Array(n) { sc.nextInt() }\n val c = Array(n) { 0 }\n var l = 0\n var r = 0\n for (i in 0 until n) {\n while (l < n && a[l] < b[i]) l++\n if (l == n || a[l] != b[i]) continue\n r = maxOf(l, r)\n while (r + 1 < n && a[r + 1] == b[i]) r++\n if (a[n - 1] == b[i]) r = n - 1\n var d1 = l - i\n if (d1 < 0) d1 += n\n var d2 = r - i\n if (d2 < 0) d2 += n\n if (d1 <= d2) {\n c[d1]++\n if (d2 + 1 != n) {\n c[d2 + 1]--\n }\n } else {\n c[0]++\n c[d2 + 1]--\n c[d1]++\n }\n }\n val d = Array(n) { c[0] }\n for (i in 1 until n) {\n d[i] = d[i - 1] + c[i]\n }\n if (d.contains(0)) {\n val sh = (0 until n).first { d[it] == 0 }\n val ans = (0 until n).map { b[(it + sh) % n] }\n println(\"Yes\")\n println(ans.joinToString(\" \"))\n } else {\n b.reverse()\n val c = Array(n) { 0 }\n var l = n - 1\n var r = n - 1\n for (i in 0 until n) {\n while (r >= 0 && a[r] > b[i]) r--\n if (r < 0 || a[r] != b[i]) continue\n l = minOf(l, r)\n while (l > 0 && a[l - 1] == b[i]) l--\n if (a[0] == b[i]) l = 0\n var d1 = l - i\n if (d1 < 0) d1 += n\n var d2 = r - i\n if (d2 < 0) d2 += n\n if (d1 <= d2) {\n c[d1]++\n if (d2 + 1 != n) {\n c[d2 + 1]--\n }\n } else {\n c[0]++\n c[d2 + 1]--\n c[d1]++\n }\n }\n val d = Array(n) { c[0] }\n for (i in 1 until n) {\n d[i] = d[i - 1] + c[i]\n }\n if (!d.contains(0)) {\n println(\"No\")\n } else {\n val sh = (0 until n).first { d[it] == 0 }\n val ans = (0 until n).map { b[(it + sh) % n] }\n println(\"Yes\")\n println(ans.joinToString(\" \"))\n }\n }\n}\n\nfun main() {\n val writer = PrintWriter(System.out, false)\n writer.solve(FastScanner(System.`in`))\n writer.flush()\n}\n\nclass FastScanner(s: InputStream) {\n private var st = StringTokenizer(\"\")\n private val br = BufferedReader(InputStreamReader(s))\n\n fun next(): String {\n while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())\n\n return st.nextToken()\n }\n\n fun nextInt() = next().toInt()\n fun nextLong() = next().toLong()\n fun nextLine() = br.readLine()\n fun nextDouble() = next().toDouble()\n fun ready() = br.ready()\n}\n", "language": "Kotlin", "metadata": {"date": 1600041155, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02557.html", "problem_id": "p02557", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02557/input.txt", "sample_output_relpath": "derived/input_output/data/p02557/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02557/Kotlin/s030191258.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s030191258", "user_id": "u190507186"}, "prompt_components": {"gold_output": "Yes\n2 2 3 1 1 1\n", "input_to_evaluate": "import java.io.BufferedReader\nimport java.io.InputStream\nimport java.io.InputStreamReader\nimport java.io.PrintWriter\nimport java.util.*\n\nfun PrintWriter.solve(sc: FastScanner) {\n val n = sc.nextInt()\n val a = Array(n) { sc.nextInt() }\n val b = Array(n) { sc.nextInt() }\n val c = Array(n) { 0 }\n var l = 0\n var r = 0\n for (i in 0 until n) {\n while (l < n && a[l] < b[i]) l++\n if (l == n || a[l] != b[i]) continue\n r = maxOf(l, r)\n while (r + 1 < n && a[r + 1] == b[i]) r++\n if (a[n - 1] == b[i]) r = n - 1\n var d1 = l - i\n if (d1 < 0) d1 += n\n var d2 = r - i\n if (d2 < 0) d2 += n\n if (d1 <= d2) {\n c[d1]++\n if (d2 + 1 != n) {\n c[d2 + 1]--\n }\n } else {\n c[0]++\n c[d2 + 1]--\n c[d1]++\n }\n }\n val d = Array(n) { c[0] }\n for (i in 1 until n) {\n d[i] = d[i - 1] + c[i]\n }\n if (d.contains(0)) {\n val sh = (0 until n).first { d[it] == 0 }\n val ans = (0 until n).map { b[(it + sh) % n] }\n println(\"Yes\")\n println(ans.joinToString(\" \"))\n } else {\n b.reverse()\n val c = Array(n) { 0 }\n var l = n - 1\n var r = n - 1\n for (i in 0 until n) {\n while (r >= 0 && a[r] > b[i]) r--\n if (r < 0 || a[r] != b[i]) continue\n l = minOf(l, r)\n while (l > 0 && a[l - 1] == b[i]) l--\n if (a[0] == b[i]) l = 0\n var d1 = l - i\n if (d1 < 0) d1 += n\n var d2 = r - i\n if (d2 < 0) d2 += n\n if (d1 <= d2) {\n c[d1]++\n if (d2 + 1 != n) {\n c[d2 + 1]--\n }\n } else {\n c[0]++\n c[d2 + 1]--\n c[d1]++\n }\n }\n val d = Array(n) { c[0] }\n for (i in 1 until n) {\n d[i] = d[i - 1] + c[i]\n }\n if (!d.contains(0)) {\n println(\"No\")\n } else {\n val sh = (0 until n).first { d[it] == 0 }\n val ans = (0 until n).map { b[(it + sh) % n] }\n println(\"Yes\")\n println(ans.joinToString(\" \"))\n }\n }\n}\n\nfun main() {\n val writer = PrintWriter(System.out, false)\n writer.solve(FastScanner(System.`in`))\n writer.flush()\n}\n\nclass FastScanner(s: InputStream) {\n private var st = StringTokenizer(\"\")\n private val br = BufferedReader(InputStreamReader(s))\n\n fun next(): String {\n while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())\n\n return st.nextToken()\n }\n\n fun nextInt() = next().toInt()\n fun nextLong() = next().toLong()\n fun nextLine() = br.readLine()\n fun nextDouble() = next().toDouble()\n fun ready() = br.ready()\n}\n", "problem_context": "Score : 600 points\n\nProblem Statement\n\nGiven are two sequences A and B, both of length N.\nA and B are each sorted in the ascending order.\nCheck if it is possible to reorder the terms of B so that for each i (1 \\leq i \\leq N) A_i \\neq B_i holds, and if it is possible, output any of the reorderings that achieve it.\n\nConstraints\n\n1\\leq N \\leq 2 \\times 10^5\n\n1\\leq A_i,B_i \\leq N\n\nA and B are each sorted in the ascending order.\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\nB_1 B_2 \\cdots B_N\n\nOutput\n\nIf there exist no reorderings that satisfy the condition, print No.\n\nIf there exists a reordering that satisfies the condition, print Yes on the first line.\nAfter that, print a reordering of B on the second line, separating terms with a whitespace.\n\nIf there are multiple reorderings that satisfy the condition, you can print any of them.\n\nSample Input 1\n\n6\n1 1 1 2 2 3\n1 1 1 2 2 3\n\nSample Output 1\n\nYes\n2 2 3 1 1 1\n\nSample Input 2\n\n3\n1 1 2\n1 1 3\n\nSample Output 2\n\nNo\n\nSample Input 3\n\n4\n1 1 2 3\n1 2 3 3\n\nSample Output 3\n\nYes\n3 3 1 2", "sample_input": "6\n1 1 1 2 2 3\n1 1 1 2 2 3\n"}, "reference_outputs": ["Yes\n2 2 3 1 1 1\n"], "source_document_id": "p02557", "source_text": "Score : 600 points\n\nProblem Statement\n\nGiven are two sequences A and B, both of length N.\nA and B are each sorted in the ascending order.\nCheck if it is possible to reorder the terms of B so that for each i (1 \\leq i \\leq N) A_i \\neq B_i holds, and if it is possible, output any of the reorderings that achieve it.\n\nConstraints\n\n1\\leq N \\leq 2 \\times 10^5\n\n1\\leq A_i,B_i \\leq N\n\nA and B are each sorted in the ascending order.\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\nB_1 B_2 \\cdots B_N\n\nOutput\n\nIf there exist no reorderings that satisfy the condition, print No.\n\nIf there exists a reordering that satisfies the condition, print Yes on the first line.\nAfter that, print a reordering of B on the second line, separating terms with a whitespace.\n\nIf there are multiple reorderings that satisfy the condition, you can print any of them.\n\nSample Input 1\n\n6\n1 1 1 2 2 3\n1 1 1 2 2 3\n\nSample Output 1\n\nYes\n2 2 3 1 1 1\n\nSample Input 2\n\n3\n1 1 2\n1 1 3\n\nSample Output 2\n\nNo\n\nSample Input 3\n\n4\n1 1 2 3\n1 2 3 3\n\nSample Output 3\n\nYes\n3 3 1 2", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2845, "cpu_time_ms": 674, "memory_kb": 78828}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s383448703", "group_id": "codeNet:p02564", "input_text": "@file:Suppress(\"NOTHING_TO_INLINE\", \"EXPERIMENTAL_FEATURE_WARNING\", \"OVERRIDE_BY_INLINE\")\n//@file:OptIn(ExperimentalStdlibApi::class)\n\nimport java.io.PrintWriter\nimport java.util.PriorityQueue\nimport java.util.TreeMap\nimport kotlin.math.*\nimport kotlin.random.Random\nimport kotlin.collections.sort as _sort\nimport kotlin.collections.sortDescending as _sortDescending\nimport kotlin.io.println as iprintln\n\n\n/** @author Spheniscine */\nfun main() { _writer.solve(); _writer.flush() }\nfun PrintWriter.solve() {\n// val startTime = System.nanoTime()\n\n val numCases = 1//readInt()\n case@ for(case in 1..numCases) {\n// print(\"Case #$case: \")\n\n val n = readInt()\n val m = readInt()\n\n val S = SCC(n)\n repeat(m) {\n S.addEdge(readInt(), readInt())\n }\n\n// val n = 500000\n// val m = 500000\n// val rnd = Random(42)\n//\n// val S = SCC(n)\n// repeat(m) {\n// S.addEdge(rnd.nextInt(n), rnd.nextInt(n))\n// }\n\n val ans = S.scc()\n\n println(ans.size)\n for(cmp in ans) {\n print(cmp.size)\n for(v in cmp) {\n print(' ')\n print(v)\n }\n println()\n }\n }\n\n// iprintln(\"Time: ${(System.nanoTime() - startTime) / 1000000} ms\")\n}\n\nclass SCC(val n: Int) {\n val G = Array(n) { IntList() }\n fun addEdge(u: Int, v: Int) {\n G[u].add(v)\n }\n\n fun scc(): List {\n val res = mutableListOf()\n\n var currIdx = 0\n val R = IntList()\n val S = IntList()\n val idx = IntArray(n) { -1 }\n val lowlink = IntArray(n)\n val state = IntArray(n)\n val inS = BooleanArray(n)\n\n for(rt in 0 until n) if(idx[rt] == -1) {\n R.add(rt)\n\n while(R.isNotEmpty()) {\n val v = R.pop()\n val s = state[v]\n if(s == 0) {\n idx[v] = currIdx\n lowlink[v] = currIdx\n currIdx++\n S.add(v)\n inS[v] = true\n }\n if(s < G[v].size) {\n R.add(v)\n val w = G[v][s]\n if(idx[w] == -1) {\n R.add(w)\n } else if(inS[w]) {\n lowlink.setMin(v, idx[w])\n }\n state[v]++\n } else {\n if(lowlink[v] == idx[v]) {\n val comp = IntList()\n do {\n val w = S.pop()\n inS[w] = false\n comp.add(w)\n } while(w != v)\n res.add(comp)\n }\n if(R.isNotEmpty()) lowlink.setMin(R.last(), lowlink[v])\n }\n }\n }\n\n res.reverse() // output will have components topologically ordered relative to each other\n return res\n }\n}\n\nfun IntArray.setMin(i: Int, v: Int) = if(v < get(i)) { set(i, v); true } else false\n\nclass IntList(initialCapacity: Int = 12) {\n private var _arr = IntArray(initialCapacity)\n private val capacity get() = _arr.size\n var size = 0\n private set\n inline val lastIndex get() = size - 1\n inline val indices get() = 0 until size\n\n constructor(copyFrom: IntArray): this(copyFrom.size) { copyFrom.copyInto(_arr); size = copyFrom.size }\n constructor(copyFrom: Collection): this(copyFrom.size) { _arr = copyFrom.toIntArray(); size = copyFrom.size }\n\n fun contentEquals(other: IntList): Boolean {\n return this === other || size == other.size && indices.all { this[it] == other[it] }\n }\n\n private fun grow(minCapacity: Int = 8) {\n val newCapacity = maxOf(minCapacity, capacity + (capacity shr 1))\n _arr = _arr.copyOf(newCapacity)\n }\n\n fun ensureCapacity(minCapacity: Int) { if(capacity < minCapacity) grow(minCapacity) }\n\n operator fun get(index: Int): Int {\n require(index in 0 until size)\n return _arr[index]\n }\n\n operator fun set(index: Int, value: Int) {\n require(index in 0 until size)\n _arr[index] = value\n }\n\n fun add(value: Int) {\n if(size == capacity) grow()\n _arr[size++] = value\n }\n\n fun addAll(list: IntList) {\n ensureCapacity(size + list.size)\n list._arr.copyInto(_arr, size, 0, list.size)\n size += list.size\n }\n\n fun add(index: Int, element: Int) {\n if(size == capacity) grow()\n _arr.copyInto(_arr, index + 1, index, size)\n size++\n set(index, element)\n }\n\n fun clear() { size = 0 }\n\n fun removeAt(index: Int): Int {\n val e = get(index)\n _arr.copyInto(_arr, index, index + 1, size)\n size--\n return e\n }\n\n fun indexOf(e: Int): Int {\n for(i in 0 until size) if(this[i] == e) return i\n return -1\n }\n\n fun remove(e: Int): Boolean {\n val i = indexOf(e)\n if(i == -1) return false\n removeAt(i)\n return true\n }\n\n operator fun iterator() = object: IntIterator() {\n private var pos = 0\n override fun hasNext() = pos < size\n override fun nextInt() = get(pos++)\n }\n\n inline fun isEmpty() = size == 0\n inline fun isNotEmpty() = size != 0\n\n fun pop() = _arr[--size]\n\n fun popToSize(s: Int) { if(s < size) size = s }\n\n fun swap(i: Int, j: Int) { val t = this[i]; this[i] = this[j]; this[j] = t }\n fun reverse() {\n for(i in 0 until size / 2) swap(i, lastIndex - i)\n }\n\n fun shuffle(rnd: Random = random) { for(i in lastIndex downTo 1) swap(i, rnd.nextInt(i+1)) }\n fun sort() { shuffle(); _arr._sort(0, size) }\n fun sortDescending() { sort(); reverse() }\n\n fun joinToString(separator: CharSequence) = if(size == 0) \"\" else let {\n buildString {\n append(it[0])\n for (i in 1 until size) {\n append(separator).append(it[i])\n }\n }\n }\n\n override fun toString() = \"[\" + joinToString(\", \") + \"]\"\n\n fun toIntArray() = _arr.copyOf(size)\n fun toList() = List(size, ::get)\n\n inline fun first() = get(0)\n inline fun last() = get(lastIndex)\n}\n\ninline fun IntList(size: Int, init: (Int) -> Int) = IntList(size).apply {\n for(i in 0 until size) { add(init(i)) }\n}\ninline fun IntArray.toIntList() = IntList(this)\ninline fun Collection.toIntList() = IntList(this)\ninline fun intListOf(vararg values: Int) = IntList(values)\n\nfun IntList.max() = (1 until size).fold(this[0]) { acc, i -> max(acc, this[i]) }\nfun IntList.min() = (1 until size).fold(this[0]) { acc, i -> min(acc, this[i]) }\nfun IntList.getOrNull(i: Int) = if(i in indices) get(i) else null\ninline fun IntList.count(predicate: (Int) -> Boolean) = indices.count { predicate(this[it]) }\nfun IntList.copyOf() = IntList(size, ::get)\n\n/** IO */\n//@JvmField val INPUT = File(\"input.txt\").inputStream()\n//@JvmField val OUTPUT = File(\"output.txt\").outputStream()\n@JvmField val INPUT = System.`in`\n@JvmField val OUTPUT = System.out\n\nconst val _BUFFER_SIZE = 1 shl 16\n@JvmField val _buffer = ByteArray(_BUFFER_SIZE)\n@JvmField var _bufferPt = 0\n@JvmField var _bytesRead = 0\n\ntailrec fun readChar(): Char {\n if(_bufferPt == _bytesRead) {\n _bufferPt = 0\n _bytesRead = INPUT.read(_buffer, 0, _BUFFER_SIZE)\n }\n return if(_bytesRead < 0) Char.MIN_VALUE\n else {\n val c = _buffer[_bufferPt++].toChar()\n if (c == '\\r') readChar()\n else c\n }\n}\n\nfun readLine(): String? {\n var c = readChar()\n return if(c == Char.MIN_VALUE) null\n else buildString {\n while(c != '\\n' && c != Char.MIN_VALUE) {\n append(c)\n c = readChar()\n }\n }\n}\nfun readLn() = readLine()!!\n\nfun read() = buildString {\n var c = readChar()\n while(c <= ' ') {\n if(c == Char.MIN_VALUE) return@buildString\n c = readChar()\n }\n do {\n append(c)\n c = readChar()\n } while(c > ' ')\n}\nfun readInt() = read().toInt()\nfun readDouble() = read().toDouble()\nfun readLong() = read().toLong()\nfun readStrings(n: Int) = List(n) { read() }\nfun readLines(n: Int) = List(n) { readLn() }\nfun readInts(n: Int) = List(n) { read().toInt() }\nfun readIntArray(n: Int) = IntArray(n) { read().toInt() }\nfun readDoubles(n: Int) = List(n) { read().toDouble() }\nfun readDoubleArray(n: Int) = DoubleArray(n) { read().toDouble() }\nfun readLongs(n: Int) = List(n) { read().toLong() }\nfun readLongArray(n: Int) = LongArray(n) { read().toLong() }\n\n@JvmField val _writer = PrintWriter(OUTPUT, false)\n\n/** shuffles and sort overrides to avoid quicksort attacks */\nprivate inline fun _shuffle(rnd: Random, get: (Int) -> T, set: (Int, T) -> Unit, size: Int) {\n // Fisher-Yates shuffle algorithm\n for (i in size - 1 downTo 1) {\n val j = rnd.nextInt(i + 1)\n val temp = get(i)\n set(i, get(j))\n set(j, temp)\n }\n}\n\n@JvmField var _random: Random? = null\nval random get() = _random ?: Random(0x594E215C123 * System.nanoTime()).also { _random = it }\n\nfun IntArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\nfun IntArray.sort() { shuffle(); _sort() }\nfun IntArray.sortDescending() { shuffle(); _sortDescending() }\n\nfun LongArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\nfun LongArray.sort() { shuffle(); _sort() }\nfun LongArray.sortDescending() { shuffle(); _sortDescending() }\n\nfun DoubleArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\nfun DoubleArray.sort() { shuffle(); _sort() }\nfun DoubleArray.sortDescending() { shuffle(); _sortDescending() }\n\nfun CharArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\ninline fun CharArray.sort() { _sort() }\ninline fun CharArray.sortDescending() { _sortDescending() }\n\ninline fun > Array.sort() = _sort()\ninline fun > Array.sortDescending() = _sortDescending()\ninline fun > MutableList.sort() = _sort()\ninline fun > MutableList.sortDescending() = _sortDescending()\n\nfun `please stop removing these imports IntelliJ`() { iprintln(max(1, 2)) }\n\n/** additional commons */\ninline fun Iterable.sumByLong(func: (T) -> Long) = fold(0L) { acc, t -> acc + func(t) }\ninline fun Sequence.sumByLong(func: (T) -> Long) = fold(0L) { acc, t -> acc + func(t) }\ninline fun Array.sumByLong(func: (T) -> Long) = fold(0L) { acc, t -> acc + func(t) }\nfun IntArray.sumLong() = fold(0L, Long::plus)\n", "language": "Kotlin", "metadata": {"date": 1600623167, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02564.html", "problem_id": "p02564", "resource_group": "medium_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/Kotlin/s383448703.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s383448703", "user_id": "u596111103"}, "prompt_components": {"gold_output": "4\n1 5\n2 4 1\n1 2\n2 3 0\n", "input_to_evaluate": "@file:Suppress(\"NOTHING_TO_INLINE\", \"EXPERIMENTAL_FEATURE_WARNING\", \"OVERRIDE_BY_INLINE\")\n//@file:OptIn(ExperimentalStdlibApi::class)\n\nimport java.io.PrintWriter\nimport java.util.PriorityQueue\nimport java.util.TreeMap\nimport kotlin.math.*\nimport kotlin.random.Random\nimport kotlin.collections.sort as _sort\nimport kotlin.collections.sortDescending as _sortDescending\nimport kotlin.io.println as iprintln\n\n\n/** @author Spheniscine */\nfun main() { _writer.solve(); _writer.flush() }\nfun PrintWriter.solve() {\n// val startTime = System.nanoTime()\n\n val numCases = 1//readInt()\n case@ for(case in 1..numCases) {\n// print(\"Case #$case: \")\n\n val n = readInt()\n val m = readInt()\n\n val S = SCC(n)\n repeat(m) {\n S.addEdge(readInt(), readInt())\n }\n\n// val n = 500000\n// val m = 500000\n// val rnd = Random(42)\n//\n// val S = SCC(n)\n// repeat(m) {\n// S.addEdge(rnd.nextInt(n), rnd.nextInt(n))\n// }\n\n val ans = S.scc()\n\n println(ans.size)\n for(cmp in ans) {\n print(cmp.size)\n for(v in cmp) {\n print(' ')\n print(v)\n }\n println()\n }\n }\n\n// iprintln(\"Time: ${(System.nanoTime() - startTime) / 1000000} ms\")\n}\n\nclass SCC(val n: Int) {\n val G = Array(n) { IntList() }\n fun addEdge(u: Int, v: Int) {\n G[u].add(v)\n }\n\n fun scc(): List {\n val res = mutableListOf()\n\n var currIdx = 0\n val R = IntList()\n val S = IntList()\n val idx = IntArray(n) { -1 }\n val lowlink = IntArray(n)\n val state = IntArray(n)\n val inS = BooleanArray(n)\n\n for(rt in 0 until n) if(idx[rt] == -1) {\n R.add(rt)\n\n while(R.isNotEmpty()) {\n val v = R.pop()\n val s = state[v]\n if(s == 0) {\n idx[v] = currIdx\n lowlink[v] = currIdx\n currIdx++\n S.add(v)\n inS[v] = true\n }\n if(s < G[v].size) {\n R.add(v)\n val w = G[v][s]\n if(idx[w] == -1) {\n R.add(w)\n } else if(inS[w]) {\n lowlink.setMin(v, idx[w])\n }\n state[v]++\n } else {\n if(lowlink[v] == idx[v]) {\n val comp = IntList()\n do {\n val w = S.pop()\n inS[w] = false\n comp.add(w)\n } while(w != v)\n res.add(comp)\n }\n if(R.isNotEmpty()) lowlink.setMin(R.last(), lowlink[v])\n }\n }\n }\n\n res.reverse() // output will have components topologically ordered relative to each other\n return res\n }\n}\n\nfun IntArray.setMin(i: Int, v: Int) = if(v < get(i)) { set(i, v); true } else false\n\nclass IntList(initialCapacity: Int = 12) {\n private var _arr = IntArray(initialCapacity)\n private val capacity get() = _arr.size\n var size = 0\n private set\n inline val lastIndex get() = size - 1\n inline val indices get() = 0 until size\n\n constructor(copyFrom: IntArray): this(copyFrom.size) { copyFrom.copyInto(_arr); size = copyFrom.size }\n constructor(copyFrom: Collection): this(copyFrom.size) { _arr = copyFrom.toIntArray(); size = copyFrom.size }\n\n fun contentEquals(other: IntList): Boolean {\n return this === other || size == other.size && indices.all { this[it] == other[it] }\n }\n\n private fun grow(minCapacity: Int = 8) {\n val newCapacity = maxOf(minCapacity, capacity + (capacity shr 1))\n _arr = _arr.copyOf(newCapacity)\n }\n\n fun ensureCapacity(minCapacity: Int) { if(capacity < minCapacity) grow(minCapacity) }\n\n operator fun get(index: Int): Int {\n require(index in 0 until size)\n return _arr[index]\n }\n\n operator fun set(index: Int, value: Int) {\n require(index in 0 until size)\n _arr[index] = value\n }\n\n fun add(value: Int) {\n if(size == capacity) grow()\n _arr[size++] = value\n }\n\n fun addAll(list: IntList) {\n ensureCapacity(size + list.size)\n list._arr.copyInto(_arr, size, 0, list.size)\n size += list.size\n }\n\n fun add(index: Int, element: Int) {\n if(size == capacity) grow()\n _arr.copyInto(_arr, index + 1, index, size)\n size++\n set(index, element)\n }\n\n fun clear() { size = 0 }\n\n fun removeAt(index: Int): Int {\n val e = get(index)\n _arr.copyInto(_arr, index, index + 1, size)\n size--\n return e\n }\n\n fun indexOf(e: Int): Int {\n for(i in 0 until size) if(this[i] == e) return i\n return -1\n }\n\n fun remove(e: Int): Boolean {\n val i = indexOf(e)\n if(i == -1) return false\n removeAt(i)\n return true\n }\n\n operator fun iterator() = object: IntIterator() {\n private var pos = 0\n override fun hasNext() = pos < size\n override fun nextInt() = get(pos++)\n }\n\n inline fun isEmpty() = size == 0\n inline fun isNotEmpty() = size != 0\n\n fun pop() = _arr[--size]\n\n fun popToSize(s: Int) { if(s < size) size = s }\n\n fun swap(i: Int, j: Int) { val t = this[i]; this[i] = this[j]; this[j] = t }\n fun reverse() {\n for(i in 0 until size / 2) swap(i, lastIndex - i)\n }\n\n fun shuffle(rnd: Random = random) { for(i in lastIndex downTo 1) swap(i, rnd.nextInt(i+1)) }\n fun sort() { shuffle(); _arr._sort(0, size) }\n fun sortDescending() { sort(); reverse() }\n\n fun joinToString(separator: CharSequence) = if(size == 0) \"\" else let {\n buildString {\n append(it[0])\n for (i in 1 until size) {\n append(separator).append(it[i])\n }\n }\n }\n\n override fun toString() = \"[\" + joinToString(\", \") + \"]\"\n\n fun toIntArray() = _arr.copyOf(size)\n fun toList() = List(size, ::get)\n\n inline fun first() = get(0)\n inline fun last() = get(lastIndex)\n}\n\ninline fun IntList(size: Int, init: (Int) -> Int) = IntList(size).apply {\n for(i in 0 until size) { add(init(i)) }\n}\ninline fun IntArray.toIntList() = IntList(this)\ninline fun Collection.toIntList() = IntList(this)\ninline fun intListOf(vararg values: Int) = IntList(values)\n\nfun IntList.max() = (1 until size).fold(this[0]) { acc, i -> max(acc, this[i]) }\nfun IntList.min() = (1 until size).fold(this[0]) { acc, i -> min(acc, this[i]) }\nfun IntList.getOrNull(i: Int) = if(i in indices) get(i) else null\ninline fun IntList.count(predicate: (Int) -> Boolean) = indices.count { predicate(this[it]) }\nfun IntList.copyOf() = IntList(size, ::get)\n\n/** IO */\n//@JvmField val INPUT = File(\"input.txt\").inputStream()\n//@JvmField val OUTPUT = File(\"output.txt\").outputStream()\n@JvmField val INPUT = System.`in`\n@JvmField val OUTPUT = System.out\n\nconst val _BUFFER_SIZE = 1 shl 16\n@JvmField val _buffer = ByteArray(_BUFFER_SIZE)\n@JvmField var _bufferPt = 0\n@JvmField var _bytesRead = 0\n\ntailrec fun readChar(): Char {\n if(_bufferPt == _bytesRead) {\n _bufferPt = 0\n _bytesRead = INPUT.read(_buffer, 0, _BUFFER_SIZE)\n }\n return if(_bytesRead < 0) Char.MIN_VALUE\n else {\n val c = _buffer[_bufferPt++].toChar()\n if (c == '\\r') readChar()\n else c\n }\n}\n\nfun readLine(): String? {\n var c = readChar()\n return if(c == Char.MIN_VALUE) null\n else buildString {\n while(c != '\\n' && c != Char.MIN_VALUE) {\n append(c)\n c = readChar()\n }\n }\n}\nfun readLn() = readLine()!!\n\nfun read() = buildString {\n var c = readChar()\n while(c <= ' ') {\n if(c == Char.MIN_VALUE) return@buildString\n c = readChar()\n }\n do {\n append(c)\n c = readChar()\n } while(c > ' ')\n}\nfun readInt() = read().toInt()\nfun readDouble() = read().toDouble()\nfun readLong() = read().toLong()\nfun readStrings(n: Int) = List(n) { read() }\nfun readLines(n: Int) = List(n) { readLn() }\nfun readInts(n: Int) = List(n) { read().toInt() }\nfun readIntArray(n: Int) = IntArray(n) { read().toInt() }\nfun readDoubles(n: Int) = List(n) { read().toDouble() }\nfun readDoubleArray(n: Int) = DoubleArray(n) { read().toDouble() }\nfun readLongs(n: Int) = List(n) { read().toLong() }\nfun readLongArray(n: Int) = LongArray(n) { read().toLong() }\n\n@JvmField val _writer = PrintWriter(OUTPUT, false)\n\n/** shuffles and sort overrides to avoid quicksort attacks */\nprivate inline fun _shuffle(rnd: Random, get: (Int) -> T, set: (Int, T) -> Unit, size: Int) {\n // Fisher-Yates shuffle algorithm\n for (i in size - 1 downTo 1) {\n val j = rnd.nextInt(i + 1)\n val temp = get(i)\n set(i, get(j))\n set(j, temp)\n }\n}\n\n@JvmField var _random: Random? = null\nval random get() = _random ?: Random(0x594E215C123 * System.nanoTime()).also { _random = it }\n\nfun IntArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\nfun IntArray.sort() { shuffle(); _sort() }\nfun IntArray.sortDescending() { shuffle(); _sortDescending() }\n\nfun LongArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\nfun LongArray.sort() { shuffle(); _sort() }\nfun LongArray.sortDescending() { shuffle(); _sortDescending() }\n\nfun DoubleArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\nfun DoubleArray.sort() { shuffle(); _sort() }\nfun DoubleArray.sortDescending() { shuffle(); _sortDescending() }\n\nfun CharArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\ninline fun CharArray.sort() { _sort() }\ninline fun CharArray.sortDescending() { _sortDescending() }\n\ninline fun > Array.sort() = _sort()\ninline fun > Array.sortDescending() = _sortDescending()\ninline fun > MutableList.sort() = _sort()\ninline fun > MutableList.sortDescending() = _sortDescending()\n\nfun `please stop removing these imports IntelliJ`() { iprintln(max(1, 2)) }\n\n/** additional commons */\ninline fun Iterable.sumByLong(func: (T) -> Long) = fold(0L) { acc, t -> acc + func(t) }\ninline fun Sequence.sumByLong(func: (T) -> Long) = fold(0L) { acc, t -> acc + func(t) }\ninline fun Array.sumByLong(func: (T) -> Long) = fold(0L) { acc, t -> acc + func(t) }\nfun IntArray.sumLong() = fold(0L, Long::plus)\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 10611, "cpu_time_ms": 1077, "memory_kb": 192004}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s991733098", "group_id": "codeNet:p02570", "input_text": "fun main() {\n val (d, t, s) = readLine()!!.split(\" \").map(String::toInt)\n if(d<=t*s) println(\"Yes\") else println(\"No\")\n}", "language": "Kotlin", "metadata": {"date": 1599837765, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02570.html", "problem_id": "p02570", "resource_group": "medium_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/Kotlin/s991733098.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s991733098", "user_id": "u966836999"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "fun main() {\n val (d, t, s) = readLine()!!.split(\" \").map(String::toInt)\n if(d<=t*s) println(\"Yes\") else println(\"No\")\n}", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 109, "memory_kb": 36436}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s715690474", "group_id": "codeNet:p02570", "input_text": "fun main (args:Array){\n val(distance, time, fast) = readLine()!!.split(\" \").map(String::toInt)\n if(distance / fast <= time.toFloat()) {\n print(\"Yes\")\n }\n else{\n print(\"No\")\n }\n}", "language": "Kotlin", "metadata": {"date": 1598880377, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02570.html", "problem_id": "p02570", "resource_group": "medium_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/Kotlin/s715690474.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s715690474", "user_id": "u800824593"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "fun main (args:Array){\n val(distance, time, fast) = readLine()!!.split(\" \").map(String::toInt)\n if(distance / fast <= time.toFloat()) {\n print(\"Yes\")\n }\n else{\n print(\"No\")\n }\n}", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 112, "memory_kb": 36244}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s274304132", "group_id": "codeNet:p02571", "input_text": "fun main() {\n val s = readLine()!!.toString()\n val t = readLine()!!.toString()\n\n val lenDiff = s.length - t.length\n (0..lenDiff).map { i ->\n val sub = s.substring(i, i + t.length)\n sub.zip(t) { sc, tc -> sc == tc}.count { it }\n }.max()!!.let { println(t.length - it) }\n}", "language": "Kotlin", "metadata": {"date": 1600331025, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02571.html", "problem_id": "p02571", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02571/input.txt", "sample_output_relpath": "derived/input_output/data/p02571/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02571/Kotlin/s274304132.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s274304132", "user_id": "u245597018"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "fun main() {\n val s = readLine()!!.toString()\n val t = readLine()!!.toString()\n\n val lenDiff = s.length - t.length\n (0..lenDiff).map { i ->\n val sub = s.substring(i, i + t.length)\n sub.zip(t) { sc, tc -> sc == tc}.count { it }\n }.max()!!.let { println(t.length - it) }\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nGiven are two strings S and T.\n\nLet us change some of the characters in S so that T will be a substring of S.\n\nAt least how many characters do we need to change?\n\nHere, a substring is a consecutive subsequence. For example, xxx is a substring of yxxxy, but not a substring of xxyxx.\n\nConstraints\n\nThe lengths of S and T are each at least 1 and at most 1000.\n\nThe length of T is at most that of S.\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\nPrint the minimum number of characters in S that need to be changed.\n\nSample Input 1\n\ncabacc\nabc\n\nSample Output 1\n\n1\n\nFor example, changing the fourth character a in S to c will match the second through fourth characters in S to T.\n\nSince S itself does not have T as its substring, this number of changes - one - is the minimum needed.\n\nSample Input 2\n\ncodeforces\natcoder\n\nSample Output 2\n\n6", "sample_input": "cabacc\nabc\n"}, "reference_outputs": ["1\n"], "source_document_id": "p02571", "source_text": "Score : 200 points\n\nProblem Statement\n\nGiven are two strings S and T.\n\nLet us change some of the characters in S so that T will be a substring of S.\n\nAt least how many characters do we need to change?\n\nHere, a substring is a consecutive subsequence. For example, xxx is a substring of yxxxy, but not a substring of xxyxx.\n\nConstraints\n\nThe lengths of S and T are each at least 1 and at most 1000.\n\nThe length of T is at most that of S.\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\nPrint the minimum number of characters in S that need to be changed.\n\nSample Input 1\n\ncabacc\nabc\n\nSample Output 1\n\n1\n\nFor example, changing the fourth character a in S to c will match the second through fourth characters in S to T.\n\nSince S itself does not have T as its substring, this number of changes - one - is the minimum needed.\n\nSample Input 2\n\ncodeforces\natcoder\n\nSample Output 2\n\n6", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 162, "memory_kb": 40104}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s880642473", "group_id": "codeNet:p02571", "input_text": "fun main(args:Array){\n val strS = readLine()!!\n var strT = readLine()!!\n var count = 0\n for(i in 0..strT.length-2){\n if(strS.contains(strT)){\n print(count)\n return\n }\n else {\n count++\n strT = strT.dropLast(1)\n// println(count)\n// println(strT)\n }\n }\n print(count)\n}", "language": "Kotlin", "metadata": {"date": 1598960908, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02571.html", "problem_id": "p02571", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02571/input.txt", "sample_output_relpath": "derived/input_output/data/p02571/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02571/Kotlin/s880642473.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s880642473", "user_id": "u800824593"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "fun main(args:Array){\n val strS = readLine()!!\n var strT = readLine()!!\n var count = 0\n for(i in 0..strT.length-2){\n if(strS.contains(strT)){\n print(count)\n return\n }\n else {\n count++\n strT = strT.dropLast(1)\n// println(count)\n// println(strT)\n }\n }\n print(count)\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nGiven are two strings S and T.\n\nLet us change some of the characters in S so that T will be a substring of S.\n\nAt least how many characters do we need to change?\n\nHere, a substring is a consecutive subsequence. For example, xxx is a substring of yxxxy, but not a substring of xxyxx.\n\nConstraints\n\nThe lengths of S and T are each at least 1 and at most 1000.\n\nThe length of T is at most that of S.\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\nPrint the minimum number of characters in S that need to be changed.\n\nSample Input 1\n\ncabacc\nabc\n\nSample Output 1\n\n1\n\nFor example, changing the fourth character a in S to c will match the second through fourth characters in S to T.\n\nSince S itself does not have T as its substring, this number of changes - one - is the minimum needed.\n\nSample Input 2\n\ncodeforces\natcoder\n\nSample Output 2\n\n6", "sample_input": "cabacc\nabc\n"}, "reference_outputs": ["1\n"], "source_document_id": "p02571", "source_text": "Score : 200 points\n\nProblem Statement\n\nGiven are two strings S and T.\n\nLet us change some of the characters in S so that T will be a substring of S.\n\nAt least how many characters do we need to change?\n\nHere, a substring is a consecutive subsequence. For example, xxx is a substring of yxxxy, but not a substring of xxyxx.\n\nConstraints\n\nThe lengths of S and T are each at least 1 and at most 1000.\n\nThe length of T is at most that of S.\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\nPrint the minimum number of characters in S that need to be changed.\n\nSample Input 1\n\ncabacc\nabc\n\nSample Output 1\n\n1\n\nFor example, changing the fourth character a in S to c will match the second through fourth characters in S to T.\n\nSince S itself does not have T as its substring, this number of changes - one - is the minimum needed.\n\nSample Input 2\n\ncodeforces\natcoder\n\nSample Output 2\n\n6", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 385, "cpu_time_ms": 126, "memory_kb": 37864}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s669322653", "group_id": "codeNet:p02571", "input_text": "@file:Suppress(\"NOTHING_TO_INLINE\", \"EXPERIMENTAL_FEATURE_WARNING\", \"OVERRIDE_BY_INLINE\")\n//@file:OptIn(ExperimentalStdlibApi::class)\n\nimport java.io.File\nimport java.io.PrintWriter\nimport java.util.Arrays\nimport java.util.NoSuchElementException\nimport java.util.TreeMap\nimport kotlin.math.*\nimport kotlin.random.Random\nimport kotlin.collections.sort as _sort\nimport kotlin.collections.sortDescending as _sortDescending\nimport kotlin.io.println as iprintln\n\n\n/** @author Spheniscine */\nfun main() { _writer.solve(); _writer.flush() }\nfun PrintWriter.solve() {\n// val startTime = System.nanoTime()\n\n val numCases = 1//readInt()\n case@ for(case in 1..numCases) {\n// print(\"Case #$case: \")\n\n val s = read()\n val t = read()\n\n var ans = Int.MAX_VALUE\n for(i in 0 .. s.length - t.length) {\n val res = t.indices.count { j -> s[i+j] != t[j] }\n ans = min(res, ans)\n }\n\n println(ans)\n }\n\n// iprintln(\"Time: ${(System.nanoTime() - startTime) / 1000000} ms\")\n}\n\n\n/** IO */\n//@JvmField val INPUT = File(\"input.txt\").inputStream()\n//@JvmField val OUTPUT = File(\"output.txt\").outputStream()\n@JvmField val INPUT = System.`in`\n@JvmField val OUTPUT = System.out\n\nconst val _BUFFER_SIZE = 1 shl 16\n@JvmField val _buffer = ByteArray(_BUFFER_SIZE)\n@JvmField var _bufferPt = 0\n@JvmField var _bytesRead = 0\n\ntailrec fun readChar(): Char {\n if(_bufferPt == _bytesRead) {\n _bufferPt = 0\n _bytesRead = INPUT.read(_buffer, 0, _BUFFER_SIZE)\n }\n return if(_bytesRead < 0) Char.MIN_VALUE\n else {\n val c = _buffer[_bufferPt++].toChar()\n if (c == '\\r') readChar()\n else c\n }\n}\n\nfun readLine(): String? {\n var c = readChar()\n return if(c == Char.MIN_VALUE) null\n else buildString {\n while(c != '\\n' && c != Char.MIN_VALUE) {\n append(c)\n c = readChar()\n }\n }\n}\nfun readLn() = readLine()!!\n\nfun read() = buildString {\n var c = readChar()\n while(c <= ' ') {\n if(c == Char.MIN_VALUE) return@buildString\n c = readChar()\n }\n do {\n append(c)\n c = readChar()\n } while(c > ' ')\n}\nfun readInt() = read().toInt()\nfun readDouble() = read().toDouble()\nfun readLong() = read().toLong()\nfun readStrings(n: Int) = List(n) { read() }\nfun readLines(n: Int) = List(n) { readLn() }\nfun readInts(n: Int) = List(n) { read().toInt() }\nfun readIntArray(n: Int) = IntArray(n) { read().toInt() }\nfun readDoubles(n: Int) = List(n) { read().toDouble() }\nfun readDoubleArray(n: Int) = DoubleArray(n) { read().toDouble() }\nfun readLongs(n: Int) = List(n) { read().toLong() }\nfun readLongArray(n: Int) = LongArray(n) { read().toLong() }\n\n@JvmField val _writer = PrintWriter(OUTPUT, false)\n\n/** shuffles and sort overrides to avoid quicksort attacks */\nprivate inline fun _shuffle(rnd: Random, get: (Int) -> T, set: (Int, T) -> Unit, size: Int) {\n // Fisher-Yates shuffle algorithm\n for (i in size - 1 downTo 1) {\n val j = rnd.nextInt(i + 1)\n val temp = get(i)\n set(i, get(j))\n set(j, temp)\n }\n}\n\n@JvmField var _random: Random? = null\nval random get() = _random ?: Random(0x594E215C123 * System.nanoTime()).also { _random = it }\n\nfun IntArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\nfun IntArray.sort() { shuffle(); _sort() }\nfun IntArray.sortDescending() { shuffle(); _sortDescending() }\n\nfun LongArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\nfun LongArray.sort() { shuffle(); _sort() }\nfun LongArray.sortDescending() { shuffle(); _sortDescending() }\n\nfun DoubleArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\nfun DoubleArray.sort() { shuffle(); _sort() }\nfun DoubleArray.sortDescending() { shuffle(); _sortDescending() }\n\nfun CharArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\ninline fun CharArray.sort() { _sort() }\ninline fun CharArray.sortDescending() { _sortDescending() }\n\ninline fun > Array.sort() = _sort()\ninline fun > Array.sortDescending() = _sortDescending()\ninline fun > MutableList.sort() = _sort()\ninline fun > MutableList.sortDescending() = _sortDescending()\n\nfun `please stop removing these imports IntelliJ`() { iprintln(max(1, 2)) }\n\n/** additional commons */\ninline fun Iterable.sumByLong(func: (T) -> Long) = fold(0L) { acc, t -> acc + func(t) }\ninline fun Sequence.sumByLong(func: (T) -> Long) = fold(0L) { acc, t -> acc + func(t) }\ninline fun Array.sumByLong(func: (T) -> Long) = fold(0L) { acc, t -> acc + func(t) }\nfun IntArray.sumLong() = fold(0L, Long::plus)\n", "language": "Kotlin", "metadata": {"date": 1598816071, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02571.html", "problem_id": "p02571", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02571/input.txt", "sample_output_relpath": "derived/input_output/data/p02571/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02571/Kotlin/s669322653.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s669322653", "user_id": "u596111103"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "@file:Suppress(\"NOTHING_TO_INLINE\", \"EXPERIMENTAL_FEATURE_WARNING\", \"OVERRIDE_BY_INLINE\")\n//@file:OptIn(ExperimentalStdlibApi::class)\n\nimport java.io.File\nimport java.io.PrintWriter\nimport java.util.Arrays\nimport java.util.NoSuchElementException\nimport java.util.TreeMap\nimport kotlin.math.*\nimport kotlin.random.Random\nimport kotlin.collections.sort as _sort\nimport kotlin.collections.sortDescending as _sortDescending\nimport kotlin.io.println as iprintln\n\n\n/** @author Spheniscine */\nfun main() { _writer.solve(); _writer.flush() }\nfun PrintWriter.solve() {\n// val startTime = System.nanoTime()\n\n val numCases = 1//readInt()\n case@ for(case in 1..numCases) {\n// print(\"Case #$case: \")\n\n val s = read()\n val t = read()\n\n var ans = Int.MAX_VALUE\n for(i in 0 .. s.length - t.length) {\n val res = t.indices.count { j -> s[i+j] != t[j] }\n ans = min(res, ans)\n }\n\n println(ans)\n }\n\n// iprintln(\"Time: ${(System.nanoTime() - startTime) / 1000000} ms\")\n}\n\n\n/** IO */\n//@JvmField val INPUT = File(\"input.txt\").inputStream()\n//@JvmField val OUTPUT = File(\"output.txt\").outputStream()\n@JvmField val INPUT = System.`in`\n@JvmField val OUTPUT = System.out\n\nconst val _BUFFER_SIZE = 1 shl 16\n@JvmField val _buffer = ByteArray(_BUFFER_SIZE)\n@JvmField var _bufferPt = 0\n@JvmField var _bytesRead = 0\n\ntailrec fun readChar(): Char {\n if(_bufferPt == _bytesRead) {\n _bufferPt = 0\n _bytesRead = INPUT.read(_buffer, 0, _BUFFER_SIZE)\n }\n return if(_bytesRead < 0) Char.MIN_VALUE\n else {\n val c = _buffer[_bufferPt++].toChar()\n if (c == '\\r') readChar()\n else c\n }\n}\n\nfun readLine(): String? {\n var c = readChar()\n return if(c == Char.MIN_VALUE) null\n else buildString {\n while(c != '\\n' && c != Char.MIN_VALUE) {\n append(c)\n c = readChar()\n }\n }\n}\nfun readLn() = readLine()!!\n\nfun read() = buildString {\n var c = readChar()\n while(c <= ' ') {\n if(c == Char.MIN_VALUE) return@buildString\n c = readChar()\n }\n do {\n append(c)\n c = readChar()\n } while(c > ' ')\n}\nfun readInt() = read().toInt()\nfun readDouble() = read().toDouble()\nfun readLong() = read().toLong()\nfun readStrings(n: Int) = List(n) { read() }\nfun readLines(n: Int) = List(n) { readLn() }\nfun readInts(n: Int) = List(n) { read().toInt() }\nfun readIntArray(n: Int) = IntArray(n) { read().toInt() }\nfun readDoubles(n: Int) = List(n) { read().toDouble() }\nfun readDoubleArray(n: Int) = DoubleArray(n) { read().toDouble() }\nfun readLongs(n: Int) = List(n) { read().toLong() }\nfun readLongArray(n: Int) = LongArray(n) { read().toLong() }\n\n@JvmField val _writer = PrintWriter(OUTPUT, false)\n\n/** shuffles and sort overrides to avoid quicksort attacks */\nprivate inline fun _shuffle(rnd: Random, get: (Int) -> T, set: (Int, T) -> Unit, size: Int) {\n // Fisher-Yates shuffle algorithm\n for (i in size - 1 downTo 1) {\n val j = rnd.nextInt(i + 1)\n val temp = get(i)\n set(i, get(j))\n set(j, temp)\n }\n}\n\n@JvmField var _random: Random? = null\nval random get() = _random ?: Random(0x594E215C123 * System.nanoTime()).also { _random = it }\n\nfun IntArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\nfun IntArray.sort() { shuffle(); _sort() }\nfun IntArray.sortDescending() { shuffle(); _sortDescending() }\n\nfun LongArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\nfun LongArray.sort() { shuffle(); _sort() }\nfun LongArray.sortDescending() { shuffle(); _sortDescending() }\n\nfun DoubleArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\nfun DoubleArray.sort() { shuffle(); _sort() }\nfun DoubleArray.sortDescending() { shuffle(); _sortDescending() }\n\nfun CharArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\ninline fun CharArray.sort() { _sort() }\ninline fun CharArray.sortDescending() { _sortDescending() }\n\ninline fun > Array.sort() = _sort()\ninline fun > Array.sortDescending() = _sortDescending()\ninline fun > MutableList.sort() = _sort()\ninline fun > MutableList.sortDescending() = _sortDescending()\n\nfun `please stop removing these imports IntelliJ`() { iprintln(max(1, 2)) }\n\n/** additional commons */\ninline fun Iterable.sumByLong(func: (T) -> Long) = fold(0L) { acc, t -> acc + func(t) }\ninline fun Sequence.sumByLong(func: (T) -> Long) = fold(0L) { acc, t -> acc + func(t) }\ninline fun Array.sumByLong(func: (T) -> Long) = fold(0L) { acc, t -> acc + func(t) }\nfun IntArray.sumLong() = fold(0L, Long::plus)\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nGiven are two strings S and T.\n\nLet us change some of the characters in S so that T will be a substring of S.\n\nAt least how many characters do we need to change?\n\nHere, a substring is a consecutive subsequence. For example, xxx is a substring of yxxxy, but not a substring of xxyxx.\n\nConstraints\n\nThe lengths of S and T are each at least 1 and at most 1000.\n\nThe length of T is at most that of S.\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\nPrint the minimum number of characters in S that need to be changed.\n\nSample Input 1\n\ncabacc\nabc\n\nSample Output 1\n\n1\n\nFor example, changing the fourth character a in S to c will match the second through fourth characters in S to T.\n\nSince S itself does not have T as its substring, this number of changes - one - is the minimum needed.\n\nSample Input 2\n\ncodeforces\natcoder\n\nSample Output 2\n\n6", "sample_input": "cabacc\nabc\n"}, "reference_outputs": ["1\n"], "source_document_id": "p02571", "source_text": "Score : 200 points\n\nProblem Statement\n\nGiven are two strings S and T.\n\nLet us change some of the characters in S so that T will be a substring of S.\n\nAt least how many characters do we need to change?\n\nHere, a substring is a consecutive subsequence. For example, xxx is a substring of yxxxy, but not a substring of xxyxx.\n\nConstraints\n\nThe lengths of S and T are each at least 1 and at most 1000.\n\nThe length of T is at most that of S.\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\nPrint the minimum number of characters in S that need to be changed.\n\nSample Input 1\n\ncabacc\nabc\n\nSample Output 1\n\n1\n\nFor example, changing the fourth character a in S to c will match the second through fourth characters in S to T.\n\nSince S itself does not have T as its substring, this number of changes - one - is the minimum needed.\n\nSample Input 2\n\ncodeforces\natcoder\n\nSample Output 2\n\n6", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 4708, "cpu_time_ms": 127, "memory_kb": 36280}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s411593921", "group_id": "codeNet:p02571", "input_text": "import kotlin.math.max\n\nfun main() {\n fun readInt():Int{ return readLine()!!.toInt()}\n fun readLong():Long{return readLine()!!.toLong()}\n fun readString():String{return readLine()!!}\n fun readIntList():List{return readLine()!!.split(\" \").map { it.toInt() }}\n fun readLongList():List{return readLine()!!.split(\" \").map { it.toLong() }}\n fun readStringList():List{return readLine()!!.split(\" \")}\n fun readIntLists(n: Int, sorted: Boolean=false):List>{return if(sorted){(0 until n).map { readIntList().sorted() }}else{(0 until n).map { readIntList()}}}\n fun readLongLists(n:Int, sorted: Boolean=false):List>{return if(sorted){(0 until n).map { readLongList().sorted() }}else{(0 until n).map { readLongList()}}}\n fun readStringLists(n:Int):List>{return (0 until n).map { readStringList() }}\n val a=readString()\n val b=readString()\n val n=a.length-b.length\n var ans=0\n for (i in 0..n){\n val tmp=a.slice(i until i+b.length)\n var s=0\n for (j in 0 until b.length){\n if(tmp[j]==b[j]) {\n s++\n }\n }\n ans= max(ans, s)\n }\n println(b.length-ans)\n}\n", "language": "Kotlin", "metadata": {"date": 1598729358, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02571.html", "problem_id": "p02571", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02571/input.txt", "sample_output_relpath": "derived/input_output/data/p02571/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02571/Kotlin/s411593921.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s411593921", "user_id": "u456173040"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "import kotlin.math.max\n\nfun main() {\n fun readInt():Int{ return readLine()!!.toInt()}\n fun readLong():Long{return readLine()!!.toLong()}\n fun readString():String{return readLine()!!}\n fun readIntList():List{return readLine()!!.split(\" \").map { it.toInt() }}\n fun readLongList():List{return readLine()!!.split(\" \").map { it.toLong() }}\n fun readStringList():List{return readLine()!!.split(\" \")}\n fun readIntLists(n: Int, sorted: Boolean=false):List>{return if(sorted){(0 until n).map { readIntList().sorted() }}else{(0 until n).map { readIntList()}}}\n fun readLongLists(n:Int, sorted: Boolean=false):List>{return if(sorted){(0 until n).map { readLongList().sorted() }}else{(0 until n).map { readLongList()}}}\n fun readStringLists(n:Int):List>{return (0 until n).map { readStringList() }}\n val a=readString()\n val b=readString()\n val n=a.length-b.length\n var ans=0\n for (i in 0..n){\n val tmp=a.slice(i until i+b.length)\n var s=0\n for (j in 0 until b.length){\n if(tmp[j]==b[j]) {\n s++\n }\n }\n ans= max(ans, s)\n }\n println(b.length-ans)\n}\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nGiven are two strings S and T.\n\nLet us change some of the characters in S so that T will be a substring of S.\n\nAt least how many characters do we need to change?\n\nHere, a substring is a consecutive subsequence. For example, xxx is a substring of yxxxy, but not a substring of xxyxx.\n\nConstraints\n\nThe lengths of S and T are each at least 1 and at most 1000.\n\nThe length of T is at most that of S.\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\nPrint the minimum number of characters in S that need to be changed.\n\nSample Input 1\n\ncabacc\nabc\n\nSample Output 1\n\n1\n\nFor example, changing the fourth character a in S to c will match the second through fourth characters in S to T.\n\nSince S itself does not have T as its substring, this number of changes - one - is the minimum needed.\n\nSample Input 2\n\ncodeforces\natcoder\n\nSample Output 2\n\n6", "sample_input": "cabacc\nabc\n"}, "reference_outputs": ["1\n"], "source_document_id": "p02571", "source_text": "Score : 200 points\n\nProblem Statement\n\nGiven are two strings S and T.\n\nLet us change some of the characters in S so that T will be a substring of S.\n\nAt least how many characters do we need to change?\n\nHere, a substring is a consecutive subsequence. For example, xxx is a substring of yxxxy, but not a substring of xxyxx.\n\nConstraints\n\nThe lengths of S and T are each at least 1 and at most 1000.\n\nThe length of T is at most that of S.\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\nPrint the minimum number of characters in S that need to be changed.\n\nSample Input 1\n\ncabacc\nabc\n\nSample Output 1\n\n1\n\nFor example, changing the fourth character a in S to c will match the second through fourth characters in S to T.\n\nSince S itself does not have T as its substring, this number of changes - one - is the minimum needed.\n\nSample Input 2\n\ncodeforces\natcoder\n\nSample Output 2\n\n6", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1207, "cpu_time_ms": 140, "memory_kb": 37964}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s966521893", "group_id": "codeNet:p02571", "input_text": "import java.lang.Integer.min\n\n//\n\nfun main() {\n abc177b()\n}\n\nfun abc177b() {\n val s = readLine()!!\n val t = readLine()!!\n var count = 1000\n for (i in 0 until s.length - t.length) {\n var c = 0\n for (j in 0 until t.length) {\n if (s[i + j] != t[j]) c++\n }\n count = min(count, c)\n }\n println(count)\n}\n", "language": "Kotlin", "metadata": {"date": 1598729016, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02571.html", "problem_id": "p02571", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02571/input.txt", "sample_output_relpath": "derived/input_output/data/p02571/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02571/Kotlin/s966521893.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s966521893", "user_id": "u628907033"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "import java.lang.Integer.min\n\n//\n\nfun main() {\n abc177b()\n}\n\nfun abc177b() {\n val s = readLine()!!\n val t = readLine()!!\n var count = 1000\n for (i in 0 until s.length - t.length) {\n var c = 0\n for (j in 0 until t.length) {\n if (s[i + j] != t[j]) c++\n }\n count = min(count, c)\n }\n println(count)\n}\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nGiven are two strings S and T.\n\nLet us change some of the characters in S so that T will be a substring of S.\n\nAt least how many characters do we need to change?\n\nHere, a substring is a consecutive subsequence. For example, xxx is a substring of yxxxy, but not a substring of xxyxx.\n\nConstraints\n\nThe lengths of S and T are each at least 1 and at most 1000.\n\nThe length of T is at most that of S.\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\nPrint the minimum number of characters in S that need to be changed.\n\nSample Input 1\n\ncabacc\nabc\n\nSample Output 1\n\n1\n\nFor example, changing the fourth character a in S to c will match the second through fourth characters in S to T.\n\nSince S itself does not have T as its substring, this number of changes - one - is the minimum needed.\n\nSample Input 2\n\ncodeforces\natcoder\n\nSample Output 2\n\n6", "sample_input": "cabacc\nabc\n"}, "reference_outputs": ["1\n"], "source_document_id": "p02571", "source_text": "Score : 200 points\n\nProblem Statement\n\nGiven are two strings S and T.\n\nLet us change some of the characters in S so that T will be a substring of S.\n\nAt least how many characters do we need to change?\n\nHere, a substring is a consecutive subsequence. For example, xxx is a substring of yxxxy, but not a substring of xxyxx.\n\nConstraints\n\nThe lengths of S and T are each at least 1 and at most 1000.\n\nThe length of T is at most that of S.\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\nPrint the minimum number of characters in S that need to be changed.\n\nSample Input 1\n\ncabacc\nabc\n\nSample Output 1\n\n1\n\nFor example, changing the fourth character a in S to c will match the second through fourth characters in S to T.\n\nSince S itself does not have T as its substring, this number of changes - one - is the minimum needed.\n\nSample Input 2\n\ncodeforces\natcoder\n\nSample Output 2\n\n6", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 130, "memory_kb": 36012}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s091907895", "group_id": "codeNet:p02573", "input_text": "fun main() {\n val (_, m) = nextIntList()\n val groupList = mutableListOf>()\n repeat(m) {\n val (a, b) = nextIntList()\n val group = groupList.firstOrNull { a in it || b in it }\n if (group == null) {\n groupList.add(mutableSetOf(a, b))\n } else {\n group.add(a)\n group.add(b)\n }\n }\n println(groupList.map { it.size }.max())\n}\n\n// # Utils\n// ## Input\nfun next() = readLine()!!\nfun nextInt() = next().toInt()\nfun nextLong() = next().toLong()\nfun nextDouble() = next().toDouble()\nfun nextList() = next().split(\" \")\nfun nextIntList() = next().split(\" \").map(String::toInt)\nfun nextLongList() = next().split(\" \").map(String::toLong)\nfun nextDoubleList() = next().split(\" \").map(String::toDouble)\n\n// ## Array\ninline fun sizedArray(size: Int, default: T) = Array(size) { default }\ninline fun sized2DArray(row: Int, column: Int, default: T) = Array(row) { Array(column) { default } }\n\n// ## mod^-1\n// [NOTE] CANNOT use this for 0, mod, 2mod, 3mod ...(return wrong value)\nfun modinv(num: Long, mod: Long): Long {\n var a = num\n var b = mod\n var u = 1L\n var v = 0L\n while (b > 0) {\n val t = a.div(b)\n a -= t * b\n a = b.also { b = a } // swap a and b\n u -= t * v\n u = v.also { v = u } // swap u and v\n }\n u %= mod\n if (u < 0) u += mod\n return u\n}", "language": "Kotlin", "metadata": {"date": 1599336538, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02573.html", "problem_id": "p02573", "resource_group": "medium_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/Kotlin/s091907895.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s091907895", "user_id": "u885556801"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "fun main() {\n val (_, m) = nextIntList()\n val groupList = mutableListOf>()\n repeat(m) {\n val (a, b) = nextIntList()\n val group = groupList.firstOrNull { a in it || b in it }\n if (group == null) {\n groupList.add(mutableSetOf(a, b))\n } else {\n group.add(a)\n group.add(b)\n }\n }\n println(groupList.map { it.size }.max())\n}\n\n// # Utils\n// ## Input\nfun next() = readLine()!!\nfun nextInt() = next().toInt()\nfun nextLong() = next().toLong()\nfun nextDouble() = next().toDouble()\nfun nextList() = next().split(\" \")\nfun nextIntList() = next().split(\" \").map(String::toInt)\nfun nextLongList() = next().split(\" \").map(String::toLong)\nfun nextDoubleList() = next().split(\" \").map(String::toDouble)\n\n// ## Array\ninline fun sizedArray(size: Int, default: T) = Array(size) { default }\ninline fun sized2DArray(row: Int, column: Int, default: T) = Array(row) { Array(column) { default } }\n\n// ## mod^-1\n// [NOTE] CANNOT use this for 0, mod, 2mod, 3mod ...(return wrong value)\nfun modinv(num: Long, mod: Long): Long {\n var a = num\n var b = mod\n var u = 1L\n var v = 0L\n while (b > 0) {\n val t = a.div(b)\n a -= t * b\n a = b.also { b = a } // swap a and b\n u -= t * v\n u = v.also { v = u } // swap u and v\n }\n u %= mod\n if (u < 0) u += mod\n return u\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1416, "cpu_time_ms": 2208, "memory_kb": 81672}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s358746518", "group_id": "codeNet:p02573", "input_text": "import java.io.IOException\nimport java.lang.NumberFormatException\nimport java.lang.StringBuilder\nimport java.util.ArrayDeque\nimport kotlin.math.max\nimport kotlin.math.min\n\nobject DMain{\n fun solve() {\n val n = nextInt()\n val m = nextInt()\n\n val par = IntArray(n)\n val rank = IntArray(n)\n for(i in 0 until n){\n par[i] = i\n rank[i] = 0\n }\n\n for (i in 1..m){\n val a = nextInt() - 1\n val b = nextInt() - 1\n unite(par, rank, a, b)\n }\n\n for(i in 0 until n){\n find(par, rank, i)\n }\n\n val num = IntArray(n){0}\n par.forEach { num[it]++ }\n println(num.max())\n\n }\n\n fun find(par: IntArray, rank: IntArray, x: Int): Int{\n if(par[x] == x){\n return x\n }else{\n par[x] = find(par, rank, par[x])\n return par[x]\n }\n }\n\n fun unite(par: IntArray, rank: IntArray, x: Int, y: Int){\n val mx = find(par, rank, x)\n val my = find(par, rank, y)\n if(mx == my) return\n\n if(rank[mx] < rank[my]){\n par[mx] = my\n }else{\n par[my] = mx\n if(rank[mx] == rank[my]) rank[mx]++\n }\n }\n\n fun same(par: IntArray, rank: IntArray, x: Int, y: Int): Boolean{\n return find(par, rank, x) == find(par, rank, y)\n }\n\n\n\n\n // Scanner based on uwi-san's Java code\n val stream = System.`in`\n val buffer = ByteArray(1024)\n var ptr = 0\n var buflen = 0\n\n fun hasNextByte(): Boolean{\n if(ptr < buflen){\n return true\n }else{\n ptr = 0\n try{\n buflen = stream.read(buffer)\n }catch (e: IOException){\n e.printStackTrace()\n }\n if(buflen <= 0){\n return false\n }\n }\n return true\n }\n\n fun readByte() =\n if(hasNextByte()) buffer[ptr++]\n else -1\n\n fun isPrintableChar(c: Byte) = c in 33..126\n\n fun hasNext(): Boolean{\n while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++\n return hasNextByte()\n }\n\n fun next(): String{\n if(!hasNext()) throw NoSuchElementException()\n val sb = StringBuilder()\n var b = readByte()\n while(isPrintableChar(b)){\n sb.appendCodePoint(b.toInt())\n b = readByte()\n }\n return sb.toString()\n }\n\n fun nextLong(): Long{\n if(!hasNext()) throw NoSuchElementException()\n var n = 0L\n var minus = false\n var b = readByte()\n if(b == '-'.toByte()){\n minus = true\n b = readByte()\n }\n if(b !in '0'.toByte()..'9'.toByte())\n throw NumberFormatException()\n while(true){\n if(b in '0'.toByte()..'9'.toByte()){\n n *= 10\n n += b - '0'.toByte()\n }else if(!isPrintableChar(b)){\n return if(minus) -n else n\n }else{\n throw NumberFormatException()\n }\n b = readByte()\n }\n }\n\n fun nextInt(): Int{\n val n1 = nextLong()\n if(n1 !in Int.MIN_VALUE..Int.MAX_VALUE)\n throw NumberFormatException()\n return n1.toInt()\n }\n\n fun NextDouble() = next().toDouble()\n}\n\nfun main(){\n DMain.solve()\n}\n", "language": "Kotlin", "metadata": {"date": 1598734185, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02573.html", "problem_id": "p02573", "resource_group": "medium_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/Kotlin/s358746518.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s358746518", "user_id": "u097204018"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "import java.io.IOException\nimport java.lang.NumberFormatException\nimport java.lang.StringBuilder\nimport java.util.ArrayDeque\nimport kotlin.math.max\nimport kotlin.math.min\n\nobject DMain{\n fun solve() {\n val n = nextInt()\n val m = nextInt()\n\n val par = IntArray(n)\n val rank = IntArray(n)\n for(i in 0 until n){\n par[i] = i\n rank[i] = 0\n }\n\n for (i in 1..m){\n val a = nextInt() - 1\n val b = nextInt() - 1\n unite(par, rank, a, b)\n }\n\n for(i in 0 until n){\n find(par, rank, i)\n }\n\n val num = IntArray(n){0}\n par.forEach { num[it]++ }\n println(num.max())\n\n }\n\n fun find(par: IntArray, rank: IntArray, x: Int): Int{\n if(par[x] == x){\n return x\n }else{\n par[x] = find(par, rank, par[x])\n return par[x]\n }\n }\n\n fun unite(par: IntArray, rank: IntArray, x: Int, y: Int){\n val mx = find(par, rank, x)\n val my = find(par, rank, y)\n if(mx == my) return\n\n if(rank[mx] < rank[my]){\n par[mx] = my\n }else{\n par[my] = mx\n if(rank[mx] == rank[my]) rank[mx]++\n }\n }\n\n fun same(par: IntArray, rank: IntArray, x: Int, y: Int): Boolean{\n return find(par, rank, x) == find(par, rank, y)\n }\n\n\n\n\n // Scanner based on uwi-san's Java code\n val stream = System.`in`\n val buffer = ByteArray(1024)\n var ptr = 0\n var buflen = 0\n\n fun hasNextByte(): Boolean{\n if(ptr < buflen){\n return true\n }else{\n ptr = 0\n try{\n buflen = stream.read(buffer)\n }catch (e: IOException){\n e.printStackTrace()\n }\n if(buflen <= 0){\n return false\n }\n }\n return true\n }\n\n fun readByte() =\n if(hasNextByte()) buffer[ptr++]\n else -1\n\n fun isPrintableChar(c: Byte) = c in 33..126\n\n fun hasNext(): Boolean{\n while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++\n return hasNextByte()\n }\n\n fun next(): String{\n if(!hasNext()) throw NoSuchElementException()\n val sb = StringBuilder()\n var b = readByte()\n while(isPrintableChar(b)){\n sb.appendCodePoint(b.toInt())\n b = readByte()\n }\n return sb.toString()\n }\n\n fun nextLong(): Long{\n if(!hasNext()) throw NoSuchElementException()\n var n = 0L\n var minus = false\n var b = readByte()\n if(b == '-'.toByte()){\n minus = true\n b = readByte()\n }\n if(b !in '0'.toByte()..'9'.toByte())\n throw NumberFormatException()\n while(true){\n if(b in '0'.toByte()..'9'.toByte()){\n n *= 10\n n += b - '0'.toByte()\n }else if(!isPrintableChar(b)){\n return if(minus) -n else n\n }else{\n throw NumberFormatException()\n }\n b = readByte()\n }\n }\n\n fun nextInt(): Int{\n val n1 = nextLong()\n if(n1 !in Int.MIN_VALUE..Int.MAX_VALUE)\n throw NumberFormatException()\n return n1.toInt()\n }\n\n fun NextDouble() = next().toDouble()\n}\n\nfun main(){\n DMain.solve()\n}\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 3386, "cpu_time_ms": 195, "memory_kb": 46964}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s657349419", "group_id": "codeNet:p02573", "input_text": "\nfun main(args: Array) {\n val (n, m) = getInts()\n\n val a = IntArray(n) { it }\n repeat(m) {\n val (x, y) = getInts().map { it - 1 }\n val p1 = parentOf(x, a)\n val p2 = parentOf(y, a)\n if (p1 < p2) {\n a[p2] = p1\n } else {\n a[p1] = p2\n }\n }\n\n val k = HashMap()\n a.indices.forEach {\n val p = parentOf(it, a)\n k[p] = (k[p] ?: 0) + 1\n }\n println(k.map { it.value }.max())\n}\n\nfun parentOf(k: Int, a: IntArray) : Int {\n if (a[k] == k) return k\n else return parentOf(a[k], a).also {\n a[k] = it\n }\n}\n\nfun getInt() = readLine()!!.toInt()\nfun getInts() = readLine()!!.split(\" \").map { it.toInt() }\nfun getLong() = readLine()!!.toLong()\nfun getLongs() = readLine()!!.split(\" \").map { it.toLong() }\n\n", "language": "Kotlin", "metadata": {"date": 1598730856, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02573.html", "problem_id": "p02573", "resource_group": "medium_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/Kotlin/s657349419.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s657349419", "user_id": "u895858420"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "\nfun main(args: Array) {\n val (n, m) = getInts()\n\n val a = IntArray(n) { it }\n repeat(m) {\n val (x, y) = getInts().map { it - 1 }\n val p1 = parentOf(x, a)\n val p2 = parentOf(y, a)\n if (p1 < p2) {\n a[p2] = p1\n } else {\n a[p1] = p2\n }\n }\n\n val k = HashMap()\n a.indices.forEach {\n val p = parentOf(it, a)\n k[p] = (k[p] ?: 0) + 1\n }\n println(k.map { it.value }.max())\n}\n\nfun parentOf(k: Int, a: IntArray) : Int {\n if (a[k] == k) return k\n else return parentOf(a[k], a).also {\n a[k] = it\n }\n}\n\nfun getInt() = readLine()!!.toInt()\nfun getInts() = readLine()!!.split(\" \").map { it.toInt() }\nfun getLong() = readLine()!!.toLong()\nfun getLongs() = readLine()!!.split(\" \").map { it.toLong() }\n\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 820, "cpu_time_ms": 639, "memory_kb": 63832}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s847583147", "group_id": "codeNet:p02575", "input_text": "@file:Suppress(\"NOTHING_TO_INLINE\", \"EXPERIMENTAL_FEATURE_WARNING\", \"OVERRIDE_BY_INLINE\")\n//@file:OptIn(ExperimentalStdlibApi::class)\n\nimport java.io.File\nimport java.io.PrintWriter\nimport java.util.Arrays\nimport java.util.NoSuchElementException\nimport java.util.TreeMap\nimport kotlin.math.*\nimport kotlin.random.Random\nimport kotlin.collections.sort as _sort\nimport kotlin.collections.sortDescending as _sortDescending\nimport kotlin.io.println as iprintln\n\n\n/** @author Spheniscine */\nfun main() { _writer.solve(); _writer.flush() }\nfun PrintWriter.solve() {\n// val startTime = System.nanoTime()\n\n val numCases = 1//readInt()\n case@ for(case in 1..numCases) {\n// print(\"Case #$case: \")\n\n val h = readInt()\n val w = readInt()\n\n val M = object {\n val map = TreeMap().also {\n it[0] = inf\n for(i in 1..w) it[i] = 0\n }\n val bag = TreeMap().also {\n it[0] = w\n it[inf] = 1\n }\n var min = 0\n\n fun bagRemove(v: Int) {\n val c = bag.getOrDefault(v, 0)\n if(c <= 1) {\n bag.remove(v)\n if(min == v) min = if(bag.isEmpty()) inf else bag.firstKey()\n } else bag[v] = c-1\n }\n\n operator fun set(k: Int, v: Int) {\n map.put(k, v)?.let { o -> bagRemove(o) }\n bag[v] = bag.getOrDefault(v, 0) + 1\n if(v < min) min = v\n }\n\n fun remove(k: Int) {\n map.remove(k)?.let { o -> bagRemove(o) }\n }\n\n fun upd(l: Int, rx: Int) {\n if(rx <= w) {\n val (fk: Int, fv: Int) = map.floorEntry(rx)\n val nv = fv + (rx - fk)\n if(map[rx].let { it == null || it > nv }) this[rx] = nv\n }\n var i = map.ceilingKey(l) ?: rx\n while(i < rx) {\n remove(i)\n i = map.ceilingKey(i) ?: rx\n }\n }\n }\n\n repeat(h) { i ->\n val a = readInt()\n val b = readInt()\n M.upd(a, b+1)\n val ans = M.min.let { if(it >= inf) -1 else it + i + 1 }\n println(ans)\n }\n }\n\n// iprintln(\"Time: ${(System.nanoTime() - startTime) / 1000000} ms\")\n}\n\nconst val inf = Int.MAX_VALUE shr 1\n\n\n/** IO */\n//@JvmField val INPUT = File(\"input.txt\").inputStream()\n//@JvmField val OUTPUT = File(\"output.txt\").outputStream()\n@JvmField val INPUT = System.`in`\n@JvmField val OUTPUT = System.out\n\nconst val _BUFFER_SIZE = 1 shl 16\n@JvmField val _buffer = ByteArray(_BUFFER_SIZE)\n@JvmField var _bufferPt = 0\n@JvmField var _bytesRead = 0\n\ntailrec fun readChar(): Char {\n if(_bufferPt == _bytesRead) {\n _bufferPt = 0\n _bytesRead = INPUT.read(_buffer, 0, _BUFFER_SIZE)\n }\n return if(_bytesRead < 0) Char.MIN_VALUE\n else {\n val c = _buffer[_bufferPt++].toChar()\n if (c == '\\r') readChar()\n else c\n }\n}\n\nfun readLine(): String? {\n var c = readChar()\n return if(c == Char.MIN_VALUE) null\n else buildString {\n while(c != '\\n' && c != Char.MIN_VALUE) {\n append(c)\n c = readChar()\n }\n }\n}\nfun readLn() = readLine()!!\n\nfun read() = buildString {\n var c = readChar()\n while(c <= ' ') {\n if(c == Char.MIN_VALUE) return@buildString\n c = readChar()\n }\n do {\n append(c)\n c = readChar()\n } while(c > ' ')\n}\nfun readInt() = read().toInt()\nfun readDouble() = read().toDouble()\nfun readLong() = read().toLong()\nfun readStrings(n: Int) = List(n) { read() }\nfun readLines(n: Int) = List(n) { readLn() }\nfun readInts(n: Int) = List(n) { read().toInt() }\nfun readIntArray(n: Int) = IntArray(n) { read().toInt() }\nfun readDoubles(n: Int) = List(n) { read().toDouble() }\nfun readDoubleArray(n: Int) = DoubleArray(n) { read().toDouble() }\nfun readLongs(n: Int) = List(n) { read().toLong() }\nfun readLongArray(n: Int) = LongArray(n) { read().toLong() }\n\n@JvmField val _writer = PrintWriter(OUTPUT, false)\n\n/** shuffles and sort overrides to avoid quicksort attacks */\nprivate inline fun _shuffle(rnd: Random, get: (Int) -> T, set: (Int, T) -> Unit, size: Int) {\n // Fisher-Yates shuffle algorithm\n for (i in size - 1 downTo 1) {\n val j = rnd.nextInt(i + 1)\n val temp = get(i)\n set(i, get(j))\n set(j, temp)\n }\n}\n\n@JvmField var _random: Random? = null\nval random get() = _random ?: Random(0x594E215C123 * System.nanoTime()).also { _random = it }\n\nfun IntArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\nfun IntArray.sort() { shuffle(); _sort() }\nfun IntArray.sortDescending() { shuffle(); _sortDescending() }\n\nfun LongArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\nfun LongArray.sort() { shuffle(); _sort() }\nfun LongArray.sortDescending() { shuffle(); _sortDescending() }\n\nfun DoubleArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\nfun DoubleArray.sort() { shuffle(); _sort() }\nfun DoubleArray.sortDescending() { shuffle(); _sortDescending() }\n\nfun CharArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\ninline fun CharArray.sort() { _sort() }\ninline fun CharArray.sortDescending() { _sortDescending() }\n\ninline fun > Array.sort() = _sort()\ninline fun > Array.sortDescending() = _sortDescending()\ninline fun > MutableList.sort() = _sort()\ninline fun > MutableList.sortDescending() = _sortDescending()\n\nfun `please stop removing these imports IntelliJ`() { iprintln(max(1, 2)) }\n\n/** additional commons */\ninline fun Iterable.sumByLong(func: (T) -> Long) = fold(0L) { acc, t -> acc + func(t) }\ninline fun Sequence.sumByLong(func: (T) -> Long) = fold(0L) { acc, t -> acc + func(t) }\ninline fun Array.sumByLong(func: (T) -> Long) = fold(0L) { acc, t -> acc + func(t) }\nfun IntArray.sumLong() = fold(0L, Long::plus)\n", "language": "Kotlin", "metadata": {"date": 1598869163, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02575.html", "problem_id": "p02575", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02575/input.txt", "sample_output_relpath": "derived/input_output/data/p02575/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02575/Kotlin/s847583147.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s847583147", "user_id": "u596111103"}, "prompt_components": {"gold_output": "1\n3\n6\n-1\n", "input_to_evaluate": "@file:Suppress(\"NOTHING_TO_INLINE\", \"EXPERIMENTAL_FEATURE_WARNING\", \"OVERRIDE_BY_INLINE\")\n//@file:OptIn(ExperimentalStdlibApi::class)\n\nimport java.io.File\nimport java.io.PrintWriter\nimport java.util.Arrays\nimport java.util.NoSuchElementException\nimport java.util.TreeMap\nimport kotlin.math.*\nimport kotlin.random.Random\nimport kotlin.collections.sort as _sort\nimport kotlin.collections.sortDescending as _sortDescending\nimport kotlin.io.println as iprintln\n\n\n/** @author Spheniscine */\nfun main() { _writer.solve(); _writer.flush() }\nfun PrintWriter.solve() {\n// val startTime = System.nanoTime()\n\n val numCases = 1//readInt()\n case@ for(case in 1..numCases) {\n// print(\"Case #$case: \")\n\n val h = readInt()\n val w = readInt()\n\n val M = object {\n val map = TreeMap().also {\n it[0] = inf\n for(i in 1..w) it[i] = 0\n }\n val bag = TreeMap().also {\n it[0] = w\n it[inf] = 1\n }\n var min = 0\n\n fun bagRemove(v: Int) {\n val c = bag.getOrDefault(v, 0)\n if(c <= 1) {\n bag.remove(v)\n if(min == v) min = if(bag.isEmpty()) inf else bag.firstKey()\n } else bag[v] = c-1\n }\n\n operator fun set(k: Int, v: Int) {\n map.put(k, v)?.let { o -> bagRemove(o) }\n bag[v] = bag.getOrDefault(v, 0) + 1\n if(v < min) min = v\n }\n\n fun remove(k: Int) {\n map.remove(k)?.let { o -> bagRemove(o) }\n }\n\n fun upd(l: Int, rx: Int) {\n if(rx <= w) {\n val (fk: Int, fv: Int) = map.floorEntry(rx)\n val nv = fv + (rx - fk)\n if(map[rx].let { it == null || it > nv }) this[rx] = nv\n }\n var i = map.ceilingKey(l) ?: rx\n while(i < rx) {\n remove(i)\n i = map.ceilingKey(i) ?: rx\n }\n }\n }\n\n repeat(h) { i ->\n val a = readInt()\n val b = readInt()\n M.upd(a, b+1)\n val ans = M.min.let { if(it >= inf) -1 else it + i + 1 }\n println(ans)\n }\n }\n\n// iprintln(\"Time: ${(System.nanoTime() - startTime) / 1000000} ms\")\n}\n\nconst val inf = Int.MAX_VALUE shr 1\n\n\n/** IO */\n//@JvmField val INPUT = File(\"input.txt\").inputStream()\n//@JvmField val OUTPUT = File(\"output.txt\").outputStream()\n@JvmField val INPUT = System.`in`\n@JvmField val OUTPUT = System.out\n\nconst val _BUFFER_SIZE = 1 shl 16\n@JvmField val _buffer = ByteArray(_BUFFER_SIZE)\n@JvmField var _bufferPt = 0\n@JvmField var _bytesRead = 0\n\ntailrec fun readChar(): Char {\n if(_bufferPt == _bytesRead) {\n _bufferPt = 0\n _bytesRead = INPUT.read(_buffer, 0, _BUFFER_SIZE)\n }\n return if(_bytesRead < 0) Char.MIN_VALUE\n else {\n val c = _buffer[_bufferPt++].toChar()\n if (c == '\\r') readChar()\n else c\n }\n}\n\nfun readLine(): String? {\n var c = readChar()\n return if(c == Char.MIN_VALUE) null\n else buildString {\n while(c != '\\n' && c != Char.MIN_VALUE) {\n append(c)\n c = readChar()\n }\n }\n}\nfun readLn() = readLine()!!\n\nfun read() = buildString {\n var c = readChar()\n while(c <= ' ') {\n if(c == Char.MIN_VALUE) return@buildString\n c = readChar()\n }\n do {\n append(c)\n c = readChar()\n } while(c > ' ')\n}\nfun readInt() = read().toInt()\nfun readDouble() = read().toDouble()\nfun readLong() = read().toLong()\nfun readStrings(n: Int) = List(n) { read() }\nfun readLines(n: Int) = List(n) { readLn() }\nfun readInts(n: Int) = List(n) { read().toInt() }\nfun readIntArray(n: Int) = IntArray(n) { read().toInt() }\nfun readDoubles(n: Int) = List(n) { read().toDouble() }\nfun readDoubleArray(n: Int) = DoubleArray(n) { read().toDouble() }\nfun readLongs(n: Int) = List(n) { read().toLong() }\nfun readLongArray(n: Int) = LongArray(n) { read().toLong() }\n\n@JvmField val _writer = PrintWriter(OUTPUT, false)\n\n/** shuffles and sort overrides to avoid quicksort attacks */\nprivate inline fun _shuffle(rnd: Random, get: (Int) -> T, set: (Int, T) -> Unit, size: Int) {\n // Fisher-Yates shuffle algorithm\n for (i in size - 1 downTo 1) {\n val j = rnd.nextInt(i + 1)\n val temp = get(i)\n set(i, get(j))\n set(j, temp)\n }\n}\n\n@JvmField var _random: Random? = null\nval random get() = _random ?: Random(0x594E215C123 * System.nanoTime()).also { _random = it }\n\nfun IntArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\nfun IntArray.sort() { shuffle(); _sort() }\nfun IntArray.sortDescending() { shuffle(); _sortDescending() }\n\nfun LongArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\nfun LongArray.sort() { shuffle(); _sort() }\nfun LongArray.sortDescending() { shuffle(); _sortDescending() }\n\nfun DoubleArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\nfun DoubleArray.sort() { shuffle(); _sort() }\nfun DoubleArray.sortDescending() { shuffle(); _sortDescending() }\n\nfun CharArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\ninline fun CharArray.sort() { _sort() }\ninline fun CharArray.sortDescending() { _sortDescending() }\n\ninline fun > Array.sort() = _sort()\ninline fun > Array.sortDescending() = _sortDescending()\ninline fun > MutableList.sort() = _sort()\ninline fun > MutableList.sortDescending() = _sortDescending()\n\nfun `please stop removing these imports IntelliJ`() { iprintln(max(1, 2)) }\n\n/** additional commons */\ninline fun Iterable.sumByLong(func: (T) -> Long) = fold(0L) { acc, t -> acc + func(t) }\ninline fun Sequence.sumByLong(func: (T) -> Long) = fold(0L) { acc, t -> acc + func(t) }\ninline fun Array.sumByLong(func: (T) -> Long) = fold(0L) { acc, t -> acc + func(t) }\nfun IntArray.sumLong() = fold(0L, Long::plus)\n", "problem_context": "Score : 600 points\n\nProblem Statement\n\nThere is a grid of squares with H+1 horizontal rows and W vertical columns.\n\nYou will start at one of the squares in the top row and repeat moving one square right or down. However, for each integer i from 1 through H, you cannot move down from the A_i-th, (A_i + 1)-th, \\ldots, B_i-th squares from the left in the i-th row from the top.\n\nFor each integer k from 1 through H, find the minimum number of moves needed to reach one of the squares in the (k+1)-th row from the top. (The starting square can be chosen individually for each case.) If, starting from any square in the top row, none of the squares in the (k+1)-th row can be reached, print -1 instead.\n\nConstraints\n\n1 \\leq H,W \\leq 2\\times 10^5\n\n1 \\leq A_i \\leq B_i \\leq W\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\nA_1 B_1\nA_2 B_2\n:\nA_H B_H\n\nOutput\n\nPrint H lines. The i-th line should contain the answer for the case k=i.\n\nSample Input 1\n\n4 4\n2 4\n1 1\n2 3\n2 4\n\nSample Output 1\n\n1\n3\n6\n-1\n\nLet (i,j) denote the square at the i-th row from the top and j-th column from the left.\n\nFor k=1, we need one move such as (1,1) → (2,1).\n\nFor k=2, we need three moves such as (1,1) → (2,1) → (2,2) → (3,2).\n\nFor k=3, we need six moves such as (1,1) → (2,1) → (2,2) → (3,2) → (3,3) → (3,4) → (4,4).\n\nFor k=4, it is impossible to reach any square in the fifth row from the top.", "sample_input": "4 4\n2 4\n1 1\n2 3\n2 4\n"}, "reference_outputs": ["1\n3\n6\n-1\n"], "source_document_id": "p02575", "source_text": "Score : 600 points\n\nProblem Statement\n\nThere is a grid of squares with H+1 horizontal rows and W vertical columns.\n\nYou will start at one of the squares in the top row and repeat moving one square right or down. However, for each integer i from 1 through H, you cannot move down from the A_i-th, (A_i + 1)-th, \\ldots, B_i-th squares from the left in the i-th row from the top.\n\nFor each integer k from 1 through H, find the minimum number of moves needed to reach one of the squares in the (k+1)-th row from the top. (The starting square can be chosen individually for each case.) If, starting from any square in the top row, none of the squares in the (k+1)-th row can be reached, print -1 instead.\n\nConstraints\n\n1 \\leq H,W \\leq 2\\times 10^5\n\n1 \\leq A_i \\leq B_i \\leq W\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\nA_1 B_1\nA_2 B_2\n:\nA_H B_H\n\nOutput\n\nPrint H lines. The i-th line should contain the answer for the case k=i.\n\nSample Input 1\n\n4 4\n2 4\n1 1\n2 3\n2 4\n\nSample Output 1\n\n1\n3\n6\n-1\n\nLet (i,j) denote the square at the i-th row from the top and j-th column from the left.\n\nFor k=1, we need one move such as (1,1) → (2,1).\n\nFor k=2, we need three moves such as (1,1) → (2,1) → (2,2) → (3,2).\n\nFor k=3, we need six moves such as (1,1) → (2,1) → (2,2) → (3,2) → (3,3) → (3,4) → (4,4).\n\nFor k=4, it is impossible to reach any square in the fifth row from the top.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 6124, "cpu_time_ms": 775, "memory_kb": 69672}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s363125756", "group_id": "codeNet:p02576", "input_text": "import java.util.Scanner;\n\nfun main (args : Array) {\n val input = Scanner(System.`in`)\n \n while (input.hasNext()) {\n val N = input.nextInt()\n val X = input.nextInt()\n val T = input.nextInt()\n val unit = N / X + if (N % X != 0) 1 else 0\n \n println (unit * T)\n } \n}", "language": "Kotlin", "metadata": {"date": 1598215759, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02576.html", "problem_id": "p02576", "resource_group": "medium_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/Kotlin/s363125756.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s363125756", "user_id": "u920836104"}, "prompt_components": {"gold_output": "12\n", "input_to_evaluate": "import java.util.Scanner;\n\nfun main (args : Array) {\n val input = Scanner(System.`in`)\n \n while (input.hasNext()) {\n val N = input.nextInt()\n val X = input.nextInt()\n val T = input.nextInt()\n val unit = N / X + if (N % X != 0) 1 else 0\n \n println (unit * T)\n } \n}", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 294, "cpu_time_ms": 126, "memory_kb": 36416}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s279960679", "group_id": "codeNet:p02576", "input_text": "\n\nimport java.util.*\n\nprivate val WHITESPACE = \"\\\\s+\".toRegex()\n\nprivate fun readLn() = readLine()!!\nprivate fun readList() = readLn().split(WHITESPACE)\n\n// helps split strings into multiple tokens\nprivate var tokenizer = StringTokenizer(\"\")\nprivate fun read(): String {\n while (tokenizer.hasMoreTokens().not()) tokenizer = StringTokenizer(readLn(), \" \")\n return tokenizer.nextToken()\n}\n\nprivate fun readInt() = read().toInt()\nprivate fun readLong() = read().toLong()\nprivate fun readDouble() = read().toDouble()\n\nprivate fun readIntList() = readList().map { it.toInt() }\nprivate fun readLongList() = readList().map { it.toLong() }\nprivate fun readDoubleList() = readList().map { it.toDouble() }\n\nprivate fun readIntArray(n: Int = 0) =\n if (n == 0) readList().run { IntArray(size) { get(it).toInt() } } else IntArray(n) { readInt() }\n\nfun main() {\n val n = readInt()\n val x = readInt()\n val t = readInt()\n\n if (n <= x) println(t)\n else {\n val q = n / x\n val r = n % x\n if (r != 0) println((q * t) + t)\n else println(q * t)\n }\n}\n\n\n\n\n", "language": "Kotlin", "metadata": {"date": 1598214096, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02576.html", "problem_id": "p02576", "resource_group": "medium_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/Kotlin/s279960679.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s279960679", "user_id": "u632768540"}, "prompt_components": {"gold_output": "12\n", "input_to_evaluate": "\n\nimport java.util.*\n\nprivate val WHITESPACE = \"\\\\s+\".toRegex()\n\nprivate fun readLn() = readLine()!!\nprivate fun readList() = readLn().split(WHITESPACE)\n\n// helps split strings into multiple tokens\nprivate var tokenizer = StringTokenizer(\"\")\nprivate fun read(): String {\n while (tokenizer.hasMoreTokens().not()) tokenizer = StringTokenizer(readLn(), \" \")\n return tokenizer.nextToken()\n}\n\nprivate fun readInt() = read().toInt()\nprivate fun readLong() = read().toLong()\nprivate fun readDouble() = read().toDouble()\n\nprivate fun readIntList() = readList().map { it.toInt() }\nprivate fun readLongList() = readList().map { it.toLong() }\nprivate fun readDoubleList() = readList().map { it.toDouble() }\n\nprivate fun readIntArray(n: Int = 0) =\n if (n == 0) readList().run { IntArray(size) { get(it).toInt() } } else IntArray(n) { readInt() }\n\nfun main() {\n val n = readInt()\n val x = readInt()\n val t = readInt()\n\n if (n <= x) println(t)\n else {\n val q = n / x\n val r = n % x\n if (r != 0) println((q * t) + t)\n else println(q * t)\n }\n}\n\n\n\n\n", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1087, "cpu_time_ms": 103, "memory_kb": 35224}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s075046010", "group_id": "codeNet:p02576", "input_text": "fun main() {\n val (N, X, T) = readLine()!!.split(\" \").map { it.toInt() }\n var ans = if (N % X == 0) {\n N / X * T\n } else {\n (N / X + 1) * T\n }\n println(ans)\n}", "language": "Kotlin", "metadata": {"date": 1598122992, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02576.html", "problem_id": "p02576", "resource_group": "medium_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/Kotlin/s075046010.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s075046010", "user_id": "u437444592"}, "prompt_components": {"gold_output": "12\n", "input_to_evaluate": "fun main() {\n val (N, X, T) = readLine()!!.split(\" \").map { it.toInt() }\n var ans = if (N % X == 0) {\n N / X * T\n } else {\n (N / X + 1) * T\n }\n println(ans)\n}", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 125, "memory_kb": 36464}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s713014119", "group_id": "codeNet:p02577", "input_text": "fun main() {\n println(if (readLine()!!.toCharArray().map { it.toString().toInt() }.sum() % 9 == 0) \"Yes\" else \"No\")\n}\n", "language": "Kotlin", "metadata": {"date": 1598264548, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02577.html", "problem_id": "p02577", "resource_group": "medium_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/Kotlin/s713014119.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s713014119", "user_id": "u455317716"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "fun main() {\n println(if (readLine()!!.toCharArray().map { it.toString().toInt() }.sum() % 9 == 0) \"Yes\" else \"No\")\n}\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 252, "memory_kb": 50324}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s080696021", "group_id": "codeNet:p02577", "input_text": "fun main() {\n print(if ((readLine()!!.chars().map{it.toInt()}.sum()) % 9 == 0) \"Yes\" else \"No\")\n}\n", "language": "Kotlin", "metadata": {"date": 1598262744, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02577.html", "problem_id": "p02577", "resource_group": "medium_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/Kotlin/s080696021.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s080696021", "user_id": "u455317716"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "fun main() {\n print(if ((readLine()!!.chars().map{it.toInt()}.sum()) % 9 == 0) \"Yes\" else \"No\")\n}\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 222, "memory_kb": 39904}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s227178255", "group_id": "codeNet:p02577", "input_text": "fun main(args: Array) {\n val n = readLine()!!\n\n var sum = 0\n for (i in n.indices) {\n sum += n[i].toString().toInt()\n }\n if (sum%9 == 0) println(\"Yes\")\n else println(\"No\")\n}\n", "language": "Kotlin", "metadata": {"date": 1598133906, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02577.html", "problem_id": "p02577", "resource_group": "medium_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/Kotlin/s227178255.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s227178255", "user_id": "u288435405"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "fun main(args: Array) {\n val n = readLine()!!\n\n var sum = 0\n for (i in n.indices) {\n sum += n[i].toString().toInt()\n }\n if (sum%9 == 0) println(\"Yes\")\n else println(\"No\")\n}\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 206, "cpu_time_ms": 223, "memory_kb": 48524}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s768720176", "group_id": "codeNet:p02578", "input_text": "fun main(){\n\n val n = readLine()!!.toInt()\n\n var list = readLine()!!.split(\" \").map(String::toInt).toMutableList()\n\n var cnt = 0\n\n for (i in 0..list.size-2){\n if (list[i]>list[i+1]){\n cnt += list[i] - list[i+1]\n list[i+1] = list[i]\n }\n }\n\n println(cnt)\n\n}", "language": "Kotlin", "metadata": {"date": 1598125245, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02578.html", "problem_id": "p02578", "resource_group": "medium_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/Kotlin/s768720176.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s768720176", "user_id": "u592533051"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "fun main(){\n\n val n = readLine()!!.toInt()\n\n var list = readLine()!!.split(\" \").map(String::toInt).toMutableList()\n\n var cnt = 0\n\n for (i in 0..list.size-2){\n if (list[i]>list[i+1]){\n cnt += list[i] - list[i+1]\n list[i+1] = list[i]\n }\n }\n\n println(cnt)\n\n}", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 404, "memory_kb": 64760}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s615899846", "group_id": "codeNet:p02578", "input_text": "import kotlin.math.max\n\nfun main() {\n val nk = nextInt()\n val an = nextIntList()\n val ans = solve(an)\n println(ans)\n\n\n}\n\n\nfun solve(k: List): Int {\n return step(k)\n}\n\nfun step(height: List): Int {\n tailrec fun loop(tempMax: Int, stepSum: Int, index: Int): Int {\n return if (height.size == index) {\n stepSum\n } else {\n val newStepSum = if (tempMax > height[index]) stepSum + (tempMax - height[index]) else stepSum\n val newTempMax = max(tempMax, height[index])\n loop(newTempMax, newStepSum, index + 1)\n }\n }\n return loop(0, 0, 0)\n}\n\n\nfun nextInt(): Int {\n return readLine()!!.toInt()\n}\n\nfun nextIntList(): List {\n return readLine()!!.split(\" \").map { it.toInt() }\n}\n\nfun nextLongList(): List {\n return readLine()!!.split(\" \").map { it.toLong() }\n}\n\nfun nextString(): String {\n return readLine()!!\n}", "language": "Kotlin", "metadata": {"date": 1598124448, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02578.html", "problem_id": "p02578", "resource_group": "medium_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/Kotlin/s615899846.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s615899846", "user_id": "u015874590"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "import kotlin.math.max\n\nfun main() {\n val nk = nextInt()\n val an = nextIntList()\n val ans = solve(an)\n println(ans)\n\n\n}\n\n\nfun solve(k: List): Int {\n return step(k)\n}\n\nfun step(height: List): Int {\n tailrec fun loop(tempMax: Int, stepSum: Int, index: Int): Int {\n return if (height.size == index) {\n stepSum\n } else {\n val newStepSum = if (tempMax > height[index]) stepSum + (tempMax - height[index]) else stepSum\n val newTempMax = max(tempMax, height[index])\n loop(newTempMax, newStepSum, index + 1)\n }\n }\n return loop(0, 0, 0)\n}\n\n\nfun nextInt(): Int {\n return readLine()!!.toInt()\n}\n\nfun nextIntList(): List {\n return readLine()!!.split(\" \").map { it.toInt() }\n}\n\nfun nextLongList(): List {\n return readLine()!!.split(\" \").map { it.toLong() }\n}\n\nfun nextString(): String {\n return readLine()!!\n}", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 918, "cpu_time_ms": 406, "memory_kb": 65156}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s677472637", "group_id": "codeNet:p02579", "input_text": "\nimport java.util.*\nval allNeightBours = mutableMapOf,Boolean>()\nval map = mutableListOf()\nvar H = 0\nvar W = 0\nvar s = Pair(0,0)\nvar t = Pair(0,0)\nfun main(args: Array) {\n val reader = Scanner(System.`in`)\n\n H = reader.nextInt()\n W = reader.nextInt()\n s = Pair(reader.nextInt() - 1, reader.nextInt() - 1)\n t = Pair(reader.nextInt() - 1, reader.nextInt() - 1)\n\n repeat(H){\n map.add(reader.next())\n }\n val neighboursQueue = LinkedList>()\n\n neighboursQueue.push(s)\n allNeightBours.put(s, true)\n var swapNum = 0\n var findTarget = false\n\n var checkedNeighbous = mutableListOf>()\n while(neighboursQueue.size > 0 && findTarget.not()){\n val checkPoint = neighboursQueue.pop()\n checkedNeighbous.add(checkPoint)\n val nears = nearNeighbours(checkPoint)\n nears.forEach nearloop@ {\n if(it == t){\n findTarget = true\n return@nearloop\n }\n else {\n neighboursQueue.push(it)\n allNeightBours[it] = true\n }\n }\n if(findTarget){\n break\n }\n if(neighboursQueue.size == 0){\n swapNum+= 1\n checkedNeighbous.forEach farloop@{\n farNeighbours(it).forEach {item ->\n if(item == t){\n findTarget = true\n return@farloop\n }\n else {\n neighboursQueue.push(item)\n allNeightBours[item] = true\n }\n }\n }\n checkedNeighbous.clear()\n }\n }\n println(if(findTarget)swapNum else -1)\n}\n\nfun nearNeighbours(point : Pair) = mutableListOf>().apply {\n listOf(Pair(1, 0), Pair(-1, 0), Pair(0, 1), Pair(0, -1)).forEach {\n var checkPoint = Pair(point.first + it.first, point.second + it.second)\n if ((checkPoint.first >= 0 && checkPoint.first < H && checkPoint.second >= 0 && checkPoint.second < W) && allNeightBours.contains(checkPoint)\n .not() && map[checkPoint.first][checkPoint.second] == '.'\n ) {\n add(checkPoint)\n }\n }\n}\n\nfun farNeighbours(point : Pair) = mutableListOf>().apply {\n val sH = point.first - 2\n val sW = point.second - 2\n\n repeat(5){countH->\n repeat(5){ countW->\n val tempH = sH + countH\n val tempW = sW + countW\n\n if((tempH < 0 || tempH >= H || tempW < 0 || tempW >= W) ||\n allNeightBours.contains(Pair(tempH, tempW)) ||\n map[tempH][tempW] != '.'){\n\n }\n else {\n add(Pair(tempH, tempW))\n }\n }\n }\n}\n", "language": "Kotlin", "metadata": {"date": 1599212596, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02579.html", "problem_id": "p02579", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02579/input.txt", "sample_output_relpath": "derived/input_output/data/p02579/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02579/Kotlin/s677472637.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s677472637", "user_id": "u412306454"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "\nimport java.util.*\nval allNeightBours = mutableMapOf,Boolean>()\nval map = mutableListOf()\nvar H = 0\nvar W = 0\nvar s = Pair(0,0)\nvar t = Pair(0,0)\nfun main(args: Array) {\n val reader = Scanner(System.`in`)\n\n H = reader.nextInt()\n W = reader.nextInt()\n s = Pair(reader.nextInt() - 1, reader.nextInt() - 1)\n t = Pair(reader.nextInt() - 1, reader.nextInt() - 1)\n\n repeat(H){\n map.add(reader.next())\n }\n val neighboursQueue = LinkedList>()\n\n neighboursQueue.push(s)\n allNeightBours.put(s, true)\n var swapNum = 0\n var findTarget = false\n\n var checkedNeighbous = mutableListOf>()\n while(neighboursQueue.size > 0 && findTarget.not()){\n val checkPoint = neighboursQueue.pop()\n checkedNeighbous.add(checkPoint)\n val nears = nearNeighbours(checkPoint)\n nears.forEach nearloop@ {\n if(it == t){\n findTarget = true\n return@nearloop\n }\n else {\n neighboursQueue.push(it)\n allNeightBours[it] = true\n }\n }\n if(findTarget){\n break\n }\n if(neighboursQueue.size == 0){\n swapNum+= 1\n checkedNeighbous.forEach farloop@{\n farNeighbours(it).forEach {item ->\n if(item == t){\n findTarget = true\n return@farloop\n }\n else {\n neighboursQueue.push(item)\n allNeightBours[item] = true\n }\n }\n }\n checkedNeighbous.clear()\n }\n }\n println(if(findTarget)swapNum else -1)\n}\n\nfun nearNeighbours(point : Pair) = mutableListOf>().apply {\n listOf(Pair(1, 0), Pair(-1, 0), Pair(0, 1), Pair(0, -1)).forEach {\n var checkPoint = Pair(point.first + it.first, point.second + it.second)\n if ((checkPoint.first >= 0 && checkPoint.first < H && checkPoint.second >= 0 && checkPoint.second < W) && allNeightBours.contains(checkPoint)\n .not() && map[checkPoint.first][checkPoint.second] == '.'\n ) {\n add(checkPoint)\n }\n }\n}\n\nfun farNeighbours(point : Pair) = mutableListOf>().apply {\n val sH = point.first - 2\n val sW = point.second - 2\n\n repeat(5){countH->\n repeat(5){ countW->\n val tempH = sH + countH\n val tempW = sW + countW\n\n if((tempH < 0 || tempH >= H || tempW < 0 || tempW >= W) ||\n allNeightBours.contains(Pair(tempH, tempW)) ||\n map[tempH][tempW] != '.'){\n\n }\n else {\n add(Pair(tempH, tempW))\n }\n }\n }\n}\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nA maze is composed of a grid of H \\times W squares - H vertical, W horizontal.\n\nThe square at the i-th row from the top and the j-th column from the left - (i,j) - is a wall if S_{ij} is # and a road if S_{ij} is ..\n\nThere is a magician in (C_h,C_w). He can do the following two kinds of moves:\n\nMove A: Walk to a road square that is vertically or horizontally adjacent to the square he is currently in.\n\nMove B: Use magic to warp himself to a road square in the 5\\times 5 area centered at the square he is currently in.\n\nIn either case, he cannot go out of the maze.\n\nAt least how many times does he need to use the magic to reach (D_h, D_w)?\n\nConstraints\n\n1 \\leq H,W \\leq 10^3\n\n1 \\leq C_h,D_h \\leq H\n\n1 \\leq C_w,D_w \\leq W\n\nS_{ij} is # or ..\n\nS_{C_h C_w} and S_{D_h D_w} are ..\n\n(C_h,C_w) \\neq (D_h,D_w)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\nC_h C_w\nD_h D_w\nS_{11}\\ldots S_{1W}\n\\vdots\nS_{H1}\\ldots S_{HW}\n\nOutput\n\nPrint the minimum number of times the magician needs to use the magic. If he cannot reach (D_h,D_w), print -1 instead.\n\nSample Input 1\n\n4 4\n1 1\n4 4\n..#.\n..#.\n.#..\n.#..\n\nSample Output 1\n\n1\n\nFor example, by walking to (2,2) and then using the magic to travel to (4,4), just one use of magic is enough.\n\nNote that he cannot walk diagonally.\n\nSample Input 2\n\n4 4\n1 4\n4 1\n.##.\n####\n####\n.##.\n\nSample Output 2\n\n-1\n\nHe cannot move from there.\n\nSample Input 3\n\n4 4\n2 2\n3 3\n....\n....\n....\n....\n\nSample Output 3\n\n0\n\nNo use of magic is needed.\n\nSample Input 4\n\n4 5\n1 2\n2 5\n#.###\n####.\n#..##\n#..##\n\nSample Output 4\n\n2", "sample_input": "4 4\n1 1\n4 4\n..#.\n..#.\n.#..\n.#..\n"}, "reference_outputs": ["1\n"], "source_document_id": "p02579", "source_text": "Score : 400 points\n\nProblem Statement\n\nA maze is composed of a grid of H \\times W squares - H vertical, W horizontal.\n\nThe square at the i-th row from the top and the j-th column from the left - (i,j) - is a wall if S_{ij} is # and a road if S_{ij} is ..\n\nThere is a magician in (C_h,C_w). He can do the following two kinds of moves:\n\nMove A: Walk to a road square that is vertically or horizontally adjacent to the square he is currently in.\n\nMove B: Use magic to warp himself to a road square in the 5\\times 5 area centered at the square he is currently in.\n\nIn either case, he cannot go out of the maze.\n\nAt least how many times does he need to use the magic to reach (D_h, D_w)?\n\nConstraints\n\n1 \\leq H,W \\leq 10^3\n\n1 \\leq C_h,D_h \\leq H\n\n1 \\leq C_w,D_w \\leq W\n\nS_{ij} is # or ..\n\nS_{C_h C_w} and S_{D_h D_w} are ..\n\n(C_h,C_w) \\neq (D_h,D_w)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\nC_h C_w\nD_h D_w\nS_{11}\\ldots S_{1W}\n\\vdots\nS_{H1}\\ldots S_{HW}\n\nOutput\n\nPrint the minimum number of times the magician needs to use the magic. If he cannot reach (D_h,D_w), print -1 instead.\n\nSample Input 1\n\n4 4\n1 1\n4 4\n..#.\n..#.\n.#..\n.#..\n\nSample Output 1\n\n1\n\nFor example, by walking to (2,2) and then using the magic to travel to (4,4), just one use of magic is enough.\n\nNote that he cannot walk diagonally.\n\nSample Input 2\n\n4 4\n1 4\n4 1\n.##.\n####\n####\n.##.\n\nSample Output 2\n\n-1\n\nHe cannot move from there.\n\nSample Input 3\n\n4 4\n2 2\n3 3\n....\n....\n....\n....\n\nSample Output 3\n\n0\n\nNo use of magic is needed.\n\nSample Input 4\n\n4 5\n1 2\n2 5\n#.###\n####.\n#..##\n#..##\n\nSample Output 4\n\n2", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2840, "cpu_time_ms": 2209, "memory_kb": 106940}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s725169396", "group_id": "codeNet:p02579", "input_text": "import kotlin.math.*\nimport java.util.*\n\nconst val MOD = 1_000_000_007L\n\nfun readI() = readLine()!!.toInt()\nfun readL() = readLine()!!.toLong()\nfun readD() = readLine()!!.toDouble()\nfun readIs() = readLine()!!.split(' ').map(String::toInt)\nfun readLs() = readLine()!!.split(' ').map(String::toLong)\nfun readDs() = readLine()!!.split(' ').map(String::toDouble)\n\ndata class IntPair(val first: Int, val second: Int) {\n operator fun plus(other: IntPair) = when {\n this == ZERO -> other\n other == ZERO -> this\n else -> IntPair(first + other.first, second + other.second)\n }\n operator fun minus(other: IntPair) = when {\n this == ZERO -> other\n other == ZERO -> this\n else -> IntPair(first - other.first, second - other.second)\n }\n override fun toString() = \"($first, $second)\"\n companion object {\n val ZERO = IntPair(0, 0)\n }\n}\ninfix fun Int.und(other: Int) = IntPair(this, other)\n\nval dda = arrayOf(0 und -1, 1 und 0, 0 und 1, -1 und 0)\nval ddb = arrayOf(-2 und -2, -2 und -1, -2 und 0, -2 und 1, -2 und 2, -1 und -2, -1 und -1, -1 und 1, -1 und 2, 0 und -2, 0 und 2, 1 und -2, 1 und -1, 1 und 1, 1 und 2, 2 und -2, 2 und -1, 2 und 0, 2 und 1, 2 und 2)\n\nfun main() {\n val (h, w) = readIs()\n val (ch, cw) = readIs()\n val (dh, dw) = readIs()\n val ss = Array(h) {\n readLine()!!.toCharArray()\n }\n val c = ch - 1 und cw - 1\n val d = dh - 1 und dw - 1\n\n val dist = mutableMapOf()\n val que = ArrayDeque()\n val tmp = mutableListOf()\n dist[c] = 0\n tmp.add(c)\n while (tmp.isNotEmpty() && !dist.containsKey(d)) {\n que.addAll(tmp)\n while (que.isNotEmpty()) {\n val p = que.remove()\n for (delta in dda) {\n val next = p + delta\n if (next.first < 0 || next.second < 0 || h <= next.first || w <= next.second || ss[next.first][next.second] == '#' || dist.containsKey(next)) continue\n dist[next] = dist[p]!!\n que.add(next)\n tmp.add(next)\n }\n }\n que.addAll(tmp)\n tmp.clear()\n while (que.isNotEmpty()) {\n val p = que.remove()\n for (delta in ddb) {\n val next = p + delta\n if (next.first < 0 || next.second < 0 || h <= next.first || w <= next.second || ss[next.first][next.second] == '#' || dist.containsKey(next)) continue\n dist[next] = dist[p]!! + 1\n tmp.add(next)\n }\n }\n }\n println(dist.getOrDefault(d, -1))\n}\n", "language": "Kotlin", "metadata": {"date": 1599072834, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02579.html", "problem_id": "p02579", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02579/input.txt", "sample_output_relpath": "derived/input_output/data/p02579/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02579/Kotlin/s725169396.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s725169396", "user_id": "u051841332"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "import kotlin.math.*\nimport java.util.*\n\nconst val MOD = 1_000_000_007L\n\nfun readI() = readLine()!!.toInt()\nfun readL() = readLine()!!.toLong()\nfun readD() = readLine()!!.toDouble()\nfun readIs() = readLine()!!.split(' ').map(String::toInt)\nfun readLs() = readLine()!!.split(' ').map(String::toLong)\nfun readDs() = readLine()!!.split(' ').map(String::toDouble)\n\ndata class IntPair(val first: Int, val second: Int) {\n operator fun plus(other: IntPair) = when {\n this == ZERO -> other\n other == ZERO -> this\n else -> IntPair(first + other.first, second + other.second)\n }\n operator fun minus(other: IntPair) = when {\n this == ZERO -> other\n other == ZERO -> this\n else -> IntPair(first - other.first, second - other.second)\n }\n override fun toString() = \"($first, $second)\"\n companion object {\n val ZERO = IntPair(0, 0)\n }\n}\ninfix fun Int.und(other: Int) = IntPair(this, other)\n\nval dda = arrayOf(0 und -1, 1 und 0, 0 und 1, -1 und 0)\nval ddb = arrayOf(-2 und -2, -2 und -1, -2 und 0, -2 und 1, -2 und 2, -1 und -2, -1 und -1, -1 und 1, -1 und 2, 0 und -2, 0 und 2, 1 und -2, 1 und -1, 1 und 1, 1 und 2, 2 und -2, 2 und -1, 2 und 0, 2 und 1, 2 und 2)\n\nfun main() {\n val (h, w) = readIs()\n val (ch, cw) = readIs()\n val (dh, dw) = readIs()\n val ss = Array(h) {\n readLine()!!.toCharArray()\n }\n val c = ch - 1 und cw - 1\n val d = dh - 1 und dw - 1\n\n val dist = mutableMapOf()\n val que = ArrayDeque()\n val tmp = mutableListOf()\n dist[c] = 0\n tmp.add(c)\n while (tmp.isNotEmpty() && !dist.containsKey(d)) {\n que.addAll(tmp)\n while (que.isNotEmpty()) {\n val p = que.remove()\n for (delta in dda) {\n val next = p + delta\n if (next.first < 0 || next.second < 0 || h <= next.first || w <= next.second || ss[next.first][next.second] == '#' || dist.containsKey(next)) continue\n dist[next] = dist[p]!!\n que.add(next)\n tmp.add(next)\n }\n }\n que.addAll(tmp)\n tmp.clear()\n while (que.isNotEmpty()) {\n val p = que.remove()\n for (delta in ddb) {\n val next = p + delta\n if (next.first < 0 || next.second < 0 || h <= next.first || w <= next.second || ss[next.first][next.second] == '#' || dist.containsKey(next)) continue\n dist[next] = dist[p]!! + 1\n tmp.add(next)\n }\n }\n }\n println(dist.getOrDefault(d, -1))\n}\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nA maze is composed of a grid of H \\times W squares - H vertical, W horizontal.\n\nThe square at the i-th row from the top and the j-th column from the left - (i,j) - is a wall if S_{ij} is # and a road if S_{ij} is ..\n\nThere is a magician in (C_h,C_w). He can do the following two kinds of moves:\n\nMove A: Walk to a road square that is vertically or horizontally adjacent to the square he is currently in.\n\nMove B: Use magic to warp himself to a road square in the 5\\times 5 area centered at the square he is currently in.\n\nIn either case, he cannot go out of the maze.\n\nAt least how many times does he need to use the magic to reach (D_h, D_w)?\n\nConstraints\n\n1 \\leq H,W \\leq 10^3\n\n1 \\leq C_h,D_h \\leq H\n\n1 \\leq C_w,D_w \\leq W\n\nS_{ij} is # or ..\n\nS_{C_h C_w} and S_{D_h D_w} are ..\n\n(C_h,C_w) \\neq (D_h,D_w)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\nC_h C_w\nD_h D_w\nS_{11}\\ldots S_{1W}\n\\vdots\nS_{H1}\\ldots S_{HW}\n\nOutput\n\nPrint the minimum number of times the magician needs to use the magic. If he cannot reach (D_h,D_w), print -1 instead.\n\nSample Input 1\n\n4 4\n1 1\n4 4\n..#.\n..#.\n.#..\n.#..\n\nSample Output 1\n\n1\n\nFor example, by walking to (2,2) and then using the magic to travel to (4,4), just one use of magic is enough.\n\nNote that he cannot walk diagonally.\n\nSample Input 2\n\n4 4\n1 4\n4 1\n.##.\n####\n####\n.##.\n\nSample Output 2\n\n-1\n\nHe cannot move from there.\n\nSample Input 3\n\n4 4\n2 2\n3 3\n....\n....\n....\n....\n\nSample Output 3\n\n0\n\nNo use of magic is needed.\n\nSample Input 4\n\n4 5\n1 2\n2 5\n#.###\n####.\n#..##\n#..##\n\nSample Output 4\n\n2", "sample_input": "4 4\n1 1\n4 4\n..#.\n..#.\n.#..\n.#..\n"}, "reference_outputs": ["1\n"], "source_document_id": "p02579", "source_text": "Score : 400 points\n\nProblem Statement\n\nA maze is composed of a grid of H \\times W squares - H vertical, W horizontal.\n\nThe square at the i-th row from the top and the j-th column from the left - (i,j) - is a wall if S_{ij} is # and a road if S_{ij} is ..\n\nThere is a magician in (C_h,C_w). He can do the following two kinds of moves:\n\nMove A: Walk to a road square that is vertically or horizontally adjacent to the square he is currently in.\n\nMove B: Use magic to warp himself to a road square in the 5\\times 5 area centered at the square he is currently in.\n\nIn either case, he cannot go out of the maze.\n\nAt least how many times does he need to use the magic to reach (D_h, D_w)?\n\nConstraints\n\n1 \\leq H,W \\leq 10^3\n\n1 \\leq C_h,D_h \\leq H\n\n1 \\leq C_w,D_w \\leq W\n\nS_{ij} is # or ..\n\nS_{C_h C_w} and S_{D_h D_w} are ..\n\n(C_h,C_w) \\neq (D_h,D_w)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\nC_h C_w\nD_h D_w\nS_{11}\\ldots S_{1W}\n\\vdots\nS_{H1}\\ldots S_{HW}\n\nOutput\n\nPrint the minimum number of times the magician needs to use the magic. If he cannot reach (D_h,D_w), print -1 instead.\n\nSample Input 1\n\n4 4\n1 1\n4 4\n..#.\n..#.\n.#..\n.#..\n\nSample Output 1\n\n1\n\nFor example, by walking to (2,2) and then using the magic to travel to (4,4), just one use of magic is enough.\n\nNote that he cannot walk diagonally.\n\nSample Input 2\n\n4 4\n1 4\n4 1\n.##.\n####\n####\n.##.\n\nSample Output 2\n\n-1\n\nHe cannot move from there.\n\nSample Input 3\n\n4 4\n2 2\n3 3\n....\n....\n....\n....\n\nSample Output 3\n\n0\n\nNo use of magic is needed.\n\nSample Input 4\n\n4 5\n1 2\n2 5\n#.###\n####.\n#..##\n#..##\n\nSample Output 4\n\n2", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2590, "cpu_time_ms": 2208, "memory_kb": 108860}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s169508062", "group_id": "codeNet:p02579", "input_text": "import kotlin.math.min\n\nfun main() = abc176d()\n\n@OptIn(ExperimentalStdlibApi::class)\nfun abc176d() = IO_abc176d().exec {\n val (h, w) = readInt() to readInt()\n val (startY, startX) = readInt() - 1 to readInt() - 1\n val (goalY, goalX) = readInt() - 1 to readInt() - 1\n val grid = Array(h) { readString().map { it == '.' }.toBooleanArray() }\n\n data class Q(val y: Int, val x: Int, val warpCount: Long)\n\n val queue = ArrayDeque()\n val around = listOf(-1 to 0, 1 to 0, 0 to -1, 0 to 1)\n val mins = Array(h) { LongArray(w) { Long.MAX_VALUE / 100 } }\n\n queue.add(Q(startY, startX, 0))\n\n while (queue.isNotEmpty()) {\n val (currY, currX, currWarpCount) = queue.removeFirst()\n\n if (currY == goalY && currX == goalX) return@exec println(currWarpCount)\n if (currWarpCount >= mins[currY][currX]) continue\n mins[currY][currX] = min(mins[currY][currX], currWarpCount)\n\n around.map { (addY, addX) -> currY + addY to currX + addX }.filter { (nextY, nextX) ->\n nextY in 0 until h && nextX in 0 until w &&\n grid[nextY][nextX] &&\n currWarpCount < mins[nextY][nextX]\n }.forEach { (nextY, nextX) -> queue.addFirst(Q(nextY, nextX, currWarpCount)) }\n\n for (nextY in (currY - 2..currY + 2).intersect(0 until h)) {\n for (nextX in (currX - 2..currX + 2).intersect(0 until w)) {\n if (nextY == currY && nextX == currX) continue\n if (grid[nextY][nextX] && currWarpCount + 1 < mins[nextY][nextX]) {\n queue.addLast(Q(nextY, nextX, currWarpCount + 1))\n }\n }\n }\n }\n\n println(-1)\n}\n\n// region kokokara template dayo (^o^)\n@Suppress(\"unused\", \"ClassName\", \"SpellCheckingInspection\", \"ConvertToStringTemplate\", \"MemberVisibilityCanBePrivate\")\nprivate class IO_abc176d(private val separator: String = System.lineSeparator()) {\n private val input = System.`in`\n private val buffer = ByteArray(1024)\n private var pointer = 0\n private var bufferLength = 0\n private val sb = StringBuilder()\n private fun Byte.isPrintable() = this in 33..126\n private fun Byte.isNumeric() = this in '0'.toByte()..'9'.toByte()\n private fun Byte.toNumVal() = if (this.isNumeric()) this - '0'.toByte() else error(\"$this is not numeric\")\n\n private fun hasNextByte(): Boolean {\n return if (pointer < bufferLength) true else {\n pointer = 0\n bufferLength = input.read(buffer)\n bufferLength > 0\n }\n }\n\n private fun readByte(): Byte = if (hasNextByte()) buffer[pointer++] else -1\n private fun skipUnprintable() = run { while (hasNextByte() && !buffer[pointer].isPrintable()) pointer++ }\n private fun hasNext(): Boolean = run { skipUnprintable() }.run { hasNextByte() }\n private fun hasNextOrError() = if (!hasNext()) error(\"has no next element.\") else Unit\n\n fun readString(): String {\n hasNextOrError()\n val sb = StringBuilder()\n var b = readByte()\n while (b.isPrintable()) {\n sb.appendCodePoint(b.toInt())\n b = readByte()\n }\n return sb.toString()\n }\n\n fun readLong(): Long {\n hasNextOrError()\n var n = 0L\n var negative = false\n var b = readByte()\n if (b == '-'.toByte()) {\n negative = true\n b = readByte()\n }\n if (!b.isNumeric()) error(\"$b is not numeric.\")\n while (true) {\n when {\n b.isNumeric() -> n = n * 10 + b.toNumVal()\n b.toInt() == -1 || !b.isPrintable() -> return if (negative) -n else n\n else -> error(\"failed to parse. [n=$n, b=$b]\")\n }\n b = readByte()\n }\n }\n\n fun readInt() = readLong()\n .let { if (it in Int.MIN_VALUE..Int.MAX_VALUE) it.toInt() else error(\"$it is not in range of Int.\") }\n\n fun readDouble(): Double {\n var n = 0.0\n var div = 1.0\n var negative = false\n var b = readByte()\n if (b == '-'.toByte()) {\n negative = true\n b = readByte()\n }\n do n = n * 10 + b.toNumVal()\n while (run { b = readByte() }.run { b.isNumeric() })\n if (b == '.'.toByte()) {\n while (run { b = readByte() }.run { b.isNumeric() })\n n += b.toNumVal() / (run { div *= 10 }.run { div })\n }\n return if (negative) -n else n\n }\n\n fun println(): Unit = run { sb.append(separator) }\n fun print(any: Any): Unit = run { sb.append(any) }\n fun println(any: Any): Unit = run { sb.append(any.toString() + separator) }\n fun flush() = run { kotlin.io.println(sb); sb.clear() }\n\n fun exec(action: IO_abc176d.() -> Unit) {\n var t: Throwable? = null\n Thread(null, { action() }, \"solve\", 128 * 1024 * 1024)\n .apply { setUncaughtExceptionHandler { _, t1 -> t = t1 } }\n .apply { start() }.join()\n t?.let { throw it }\n kotlin.io.print(sb)\n }\n\n fun readLine(): Nothing = error(\"readLine is disabled.\")\n}\n// endregion kokomade template dayo (^o^)\n", "language": "Kotlin", "metadata": {"date": 1598309276, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02579.html", "problem_id": "p02579", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02579/input.txt", "sample_output_relpath": "derived/input_output/data/p02579/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02579/Kotlin/s169508062.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s169508062", "user_id": "u139478771"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "import kotlin.math.min\n\nfun main() = abc176d()\n\n@OptIn(ExperimentalStdlibApi::class)\nfun abc176d() = IO_abc176d().exec {\n val (h, w) = readInt() to readInt()\n val (startY, startX) = readInt() - 1 to readInt() - 1\n val (goalY, goalX) = readInt() - 1 to readInt() - 1\n val grid = Array(h) { readString().map { it == '.' }.toBooleanArray() }\n\n data class Q(val y: Int, val x: Int, val warpCount: Long)\n\n val queue = ArrayDeque()\n val around = listOf(-1 to 0, 1 to 0, 0 to -1, 0 to 1)\n val mins = Array(h) { LongArray(w) { Long.MAX_VALUE / 100 } }\n\n queue.add(Q(startY, startX, 0))\n\n while (queue.isNotEmpty()) {\n val (currY, currX, currWarpCount) = queue.removeFirst()\n\n if (currY == goalY && currX == goalX) return@exec println(currWarpCount)\n if (currWarpCount >= mins[currY][currX]) continue\n mins[currY][currX] = min(mins[currY][currX], currWarpCount)\n\n around.map { (addY, addX) -> currY + addY to currX + addX }.filter { (nextY, nextX) ->\n nextY in 0 until h && nextX in 0 until w &&\n grid[nextY][nextX] &&\n currWarpCount < mins[nextY][nextX]\n }.forEach { (nextY, nextX) -> queue.addFirst(Q(nextY, nextX, currWarpCount)) }\n\n for (nextY in (currY - 2..currY + 2).intersect(0 until h)) {\n for (nextX in (currX - 2..currX + 2).intersect(0 until w)) {\n if (nextY == currY && nextX == currX) continue\n if (grid[nextY][nextX] && currWarpCount + 1 < mins[nextY][nextX]) {\n queue.addLast(Q(nextY, nextX, currWarpCount + 1))\n }\n }\n }\n }\n\n println(-1)\n}\n\n// region kokokara template dayo (^o^)\n@Suppress(\"unused\", \"ClassName\", \"SpellCheckingInspection\", \"ConvertToStringTemplate\", \"MemberVisibilityCanBePrivate\")\nprivate class IO_abc176d(private val separator: String = System.lineSeparator()) {\n private val input = System.`in`\n private val buffer = ByteArray(1024)\n private var pointer = 0\n private var bufferLength = 0\n private val sb = StringBuilder()\n private fun Byte.isPrintable() = this in 33..126\n private fun Byte.isNumeric() = this in '0'.toByte()..'9'.toByte()\n private fun Byte.toNumVal() = if (this.isNumeric()) this - '0'.toByte() else error(\"$this is not numeric\")\n\n private fun hasNextByte(): Boolean {\n return if (pointer < bufferLength) true else {\n pointer = 0\n bufferLength = input.read(buffer)\n bufferLength > 0\n }\n }\n\n private fun readByte(): Byte = if (hasNextByte()) buffer[pointer++] else -1\n private fun skipUnprintable() = run { while (hasNextByte() && !buffer[pointer].isPrintable()) pointer++ }\n private fun hasNext(): Boolean = run { skipUnprintable() }.run { hasNextByte() }\n private fun hasNextOrError() = if (!hasNext()) error(\"has no next element.\") else Unit\n\n fun readString(): String {\n hasNextOrError()\n val sb = StringBuilder()\n var b = readByte()\n while (b.isPrintable()) {\n sb.appendCodePoint(b.toInt())\n b = readByte()\n }\n return sb.toString()\n }\n\n fun readLong(): Long {\n hasNextOrError()\n var n = 0L\n var negative = false\n var b = readByte()\n if (b == '-'.toByte()) {\n negative = true\n b = readByte()\n }\n if (!b.isNumeric()) error(\"$b is not numeric.\")\n while (true) {\n when {\n b.isNumeric() -> n = n * 10 + b.toNumVal()\n b.toInt() == -1 || !b.isPrintable() -> return if (negative) -n else n\n else -> error(\"failed to parse. [n=$n, b=$b]\")\n }\n b = readByte()\n }\n }\n\n fun readInt() = readLong()\n .let { if (it in Int.MIN_VALUE..Int.MAX_VALUE) it.toInt() else error(\"$it is not in range of Int.\") }\n\n fun readDouble(): Double {\n var n = 0.0\n var div = 1.0\n var negative = false\n var b = readByte()\n if (b == '-'.toByte()) {\n negative = true\n b = readByte()\n }\n do n = n * 10 + b.toNumVal()\n while (run { b = readByte() }.run { b.isNumeric() })\n if (b == '.'.toByte()) {\n while (run { b = readByte() }.run { b.isNumeric() })\n n += b.toNumVal() / (run { div *= 10 }.run { div })\n }\n return if (negative) -n else n\n }\n\n fun println(): Unit = run { sb.append(separator) }\n fun print(any: Any): Unit = run { sb.append(any) }\n fun println(any: Any): Unit = run { sb.append(any.toString() + separator) }\n fun flush() = run { kotlin.io.println(sb); sb.clear() }\n\n fun exec(action: IO_abc176d.() -> Unit) {\n var t: Throwable? = null\n Thread(null, { action() }, \"solve\", 128 * 1024 * 1024)\n .apply { setUncaughtExceptionHandler { _, t1 -> t = t1 } }\n .apply { start() }.join()\n t?.let { throw it }\n kotlin.io.print(sb)\n }\n\n fun readLine(): Nothing = error(\"readLine is disabled.\")\n}\n// endregion kokomade template dayo (^o^)\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nA maze is composed of a grid of H \\times W squares - H vertical, W horizontal.\n\nThe square at the i-th row from the top and the j-th column from the left - (i,j) - is a wall if S_{ij} is # and a road if S_{ij} is ..\n\nThere is a magician in (C_h,C_w). He can do the following two kinds of moves:\n\nMove A: Walk to a road square that is vertically or horizontally adjacent to the square he is currently in.\n\nMove B: Use magic to warp himself to a road square in the 5\\times 5 area centered at the square he is currently in.\n\nIn either case, he cannot go out of the maze.\n\nAt least how many times does he need to use the magic to reach (D_h, D_w)?\n\nConstraints\n\n1 \\leq H,W \\leq 10^3\n\n1 \\leq C_h,D_h \\leq H\n\n1 \\leq C_w,D_w \\leq W\n\nS_{ij} is # or ..\n\nS_{C_h C_w} and S_{D_h D_w} are ..\n\n(C_h,C_w) \\neq (D_h,D_w)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\nC_h C_w\nD_h D_w\nS_{11}\\ldots S_{1W}\n\\vdots\nS_{H1}\\ldots S_{HW}\n\nOutput\n\nPrint the minimum number of times the magician needs to use the magic. If he cannot reach (D_h,D_w), print -1 instead.\n\nSample Input 1\n\n4 4\n1 1\n4 4\n..#.\n..#.\n.#..\n.#..\n\nSample Output 1\n\n1\n\nFor example, by walking to (2,2) and then using the magic to travel to (4,4), just one use of magic is enough.\n\nNote that he cannot walk diagonally.\n\nSample Input 2\n\n4 4\n1 4\n4 1\n.##.\n####\n####\n.##.\n\nSample Output 2\n\n-1\n\nHe cannot move from there.\n\nSample Input 3\n\n4 4\n2 2\n3 3\n....\n....\n....\n....\n\nSample Output 3\n\n0\n\nNo use of magic is needed.\n\nSample Input 4\n\n4 5\n1 2\n2 5\n#.###\n####.\n#..##\n#..##\n\nSample Output 4\n\n2", "sample_input": "4 4\n1 1\n4 4\n..#.\n..#.\n.#..\n.#..\n"}, "reference_outputs": ["1\n"], "source_document_id": "p02579", "source_text": "Score : 400 points\n\nProblem Statement\n\nA maze is composed of a grid of H \\times W squares - H vertical, W horizontal.\n\nThe square at the i-th row from the top and the j-th column from the left - (i,j) - is a wall if S_{ij} is # and a road if S_{ij} is ..\n\nThere is a magician in (C_h,C_w). He can do the following two kinds of moves:\n\nMove A: Walk to a road square that is vertically or horizontally adjacent to the square he is currently in.\n\nMove B: Use magic to warp himself to a road square in the 5\\times 5 area centered at the square he is currently in.\n\nIn either case, he cannot go out of the maze.\n\nAt least how many times does he need to use the magic to reach (D_h, D_w)?\n\nConstraints\n\n1 \\leq H,W \\leq 10^3\n\n1 \\leq C_h,D_h \\leq H\n\n1 \\leq C_w,D_w \\leq W\n\nS_{ij} is # or ..\n\nS_{C_h C_w} and S_{D_h D_w} are ..\n\n(C_h,C_w) \\neq (D_h,D_w)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\nC_h C_w\nD_h D_w\nS_{11}\\ldots S_{1W}\n\\vdots\nS_{H1}\\ldots S_{HW}\n\nOutput\n\nPrint the minimum number of times the magician needs to use the magic. If he cannot reach (D_h,D_w), print -1 instead.\n\nSample Input 1\n\n4 4\n1 1\n4 4\n..#.\n..#.\n.#..\n.#..\n\nSample Output 1\n\n1\n\nFor example, by walking to (2,2) and then using the magic to travel to (4,4), just one use of magic is enough.\n\nNote that he cannot walk diagonally.\n\nSample Input 2\n\n4 4\n1 4\n4 1\n.##.\n####\n####\n.##.\n\nSample Output 2\n\n-1\n\nHe cannot move from there.\n\nSample Input 3\n\n4 4\n2 2\n3 3\n....\n....\n....\n....\n\nSample Output 3\n\n0\n\nNo use of magic is needed.\n\nSample Input 4\n\n4 5\n1 2\n2 5\n#.###\n####.\n#..##\n#..##\n\nSample Output 4\n\n2", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 5121, "cpu_time_ms": 2208, "memory_kb": 85784}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s418891018", "group_id": "codeNet:p02579", "input_text": "import java.util.*\n\nfun main() {\n var (H, W) = readLine()!!.split(\" \").map(String::toInt)\n var (CH, CW) = readLine()!!.split(\" \").map{it.toInt()-1}\n var (DH, DW) = readLine()!!.split(\" \").map{it.toInt()-1}\n var S = Array(H){\"\"}\n (0 .. H-1).forEach{ i ->\n S[i] = readLine()!!\n }\n\n // スタートノードから各ノードへの距離。ただし未訪問(初期状態)なら-1\n var dist = Array(H) {Array(W) {-1}}\n dist[CH][CW] = 0\n \n // スタートノードをキューに入れる\n var q = LinkedList>()\n q.offer(Pair(CH, CW))\n // 幅優先探索で、未訪問のマスをスタートマスから近い順に巡る\n var DIR1 = arrayOf(Pair(0, 1), Pair(1, 0), Pair(0, -1), Pair(-1, 0))\n var DIR2 = arrayOf(\n Pair(-2, -2), Pair(-2, -1), Pair(-2, 0), Pair(-2, 1), Pair(-2, 2),\n Pair(-1, -2), Pair(-1, -1), Pair(-1, 1), Pair(-1, 2),\n Pair(0, -2), Pair(0, 2),\n Pair(1, -2), Pair(1, -1), Pair(1, 1), Pair(1, 2),\n Pair(2, -2), Pair(2, -1), Pair(2, 0), Pair(2, 1), Pair(2, 2)\n )\n while (!q.isEmpty()) {\n var (y, x) = q.poll()\n var d = dist[y][x]\n DIR1.forEach { (dy, dx) -> \n var ny = y + dy\n var nx = x + dx\n if (0 <= ny && ny < H && 0 <= nx && nx < W && S[ny][nx] == '.' && (dist[ny][nx] == -1 || dist[ny][nx] > d)) {\n dist[ny][nx] = d\n q.offerLast(Pair(ny, nx))\n }\n }\n DIR2.forEach { (dy, dx) -> \n var ny = y + dy\n var nx = x + dx\n if (0 <= ny && ny < H && 0 <= nx && nx < W && S[ny][nx] == '.' && (dist[ny][nx] == -1 || dist[ny][nx] > d+1)) {\n dist[ny][nx] = d + 1\n q.offerFirst(Pair(ny, nx))\n }\n }\n }\n println(dist[DH][DW])\n}\n", "language": "Kotlin", "metadata": {"date": 1598179162, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02579.html", "problem_id": "p02579", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02579/input.txt", "sample_output_relpath": "derived/input_output/data/p02579/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02579/Kotlin/s418891018.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s418891018", "user_id": "u257162238"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "import java.util.*\n\nfun main() {\n var (H, W) = readLine()!!.split(\" \").map(String::toInt)\n var (CH, CW) = readLine()!!.split(\" \").map{it.toInt()-1}\n var (DH, DW) = readLine()!!.split(\" \").map{it.toInt()-1}\n var S = Array(H){\"\"}\n (0 .. H-1).forEach{ i ->\n S[i] = readLine()!!\n }\n\n // スタートノードから各ノードへの距離。ただし未訪問(初期状態)なら-1\n var dist = Array(H) {Array(W) {-1}}\n dist[CH][CW] = 0\n \n // スタートノードをキューに入れる\n var q = LinkedList>()\n q.offer(Pair(CH, CW))\n // 幅優先探索で、未訪問のマスをスタートマスから近い順に巡る\n var DIR1 = arrayOf(Pair(0, 1), Pair(1, 0), Pair(0, -1), Pair(-1, 0))\n var DIR2 = arrayOf(\n Pair(-2, -2), Pair(-2, -1), Pair(-2, 0), Pair(-2, 1), Pair(-2, 2),\n Pair(-1, -2), Pair(-1, -1), Pair(-1, 1), Pair(-1, 2),\n Pair(0, -2), Pair(0, 2),\n Pair(1, -2), Pair(1, -1), Pair(1, 1), Pair(1, 2),\n Pair(2, -2), Pair(2, -1), Pair(2, 0), Pair(2, 1), Pair(2, 2)\n )\n while (!q.isEmpty()) {\n var (y, x) = q.poll()\n var d = dist[y][x]\n DIR1.forEach { (dy, dx) -> \n var ny = y + dy\n var nx = x + dx\n if (0 <= ny && ny < H && 0 <= nx && nx < W && S[ny][nx] == '.' && (dist[ny][nx] == -1 || dist[ny][nx] > d)) {\n dist[ny][nx] = d\n q.offerLast(Pair(ny, nx))\n }\n }\n DIR2.forEach { (dy, dx) -> \n var ny = y + dy\n var nx = x + dx\n if (0 <= ny && ny < H && 0 <= nx && nx < W && S[ny][nx] == '.' && (dist[ny][nx] == -1 || dist[ny][nx] > d+1)) {\n dist[ny][nx] = d + 1\n q.offerFirst(Pair(ny, nx))\n }\n }\n }\n println(dist[DH][DW])\n}\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nA maze is composed of a grid of H \\times W squares - H vertical, W horizontal.\n\nThe square at the i-th row from the top and the j-th column from the left - (i,j) - is a wall if S_{ij} is # and a road if S_{ij} is ..\n\nThere is a magician in (C_h,C_w). He can do the following two kinds of moves:\n\nMove A: Walk to a road square that is vertically or horizontally adjacent to the square he is currently in.\n\nMove B: Use magic to warp himself to a road square in the 5\\times 5 area centered at the square he is currently in.\n\nIn either case, he cannot go out of the maze.\n\nAt least how many times does he need to use the magic to reach (D_h, D_w)?\n\nConstraints\n\n1 \\leq H,W \\leq 10^3\n\n1 \\leq C_h,D_h \\leq H\n\n1 \\leq C_w,D_w \\leq W\n\nS_{ij} is # or ..\n\nS_{C_h C_w} and S_{D_h D_w} are ..\n\n(C_h,C_w) \\neq (D_h,D_w)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\nC_h C_w\nD_h D_w\nS_{11}\\ldots S_{1W}\n\\vdots\nS_{H1}\\ldots S_{HW}\n\nOutput\n\nPrint the minimum number of times the magician needs to use the magic. If he cannot reach (D_h,D_w), print -1 instead.\n\nSample Input 1\n\n4 4\n1 1\n4 4\n..#.\n..#.\n.#..\n.#..\n\nSample Output 1\n\n1\n\nFor example, by walking to (2,2) and then using the magic to travel to (4,4), just one use of magic is enough.\n\nNote that he cannot walk diagonally.\n\nSample Input 2\n\n4 4\n1 4\n4 1\n.##.\n####\n####\n.##.\n\nSample Output 2\n\n-1\n\nHe cannot move from there.\n\nSample Input 3\n\n4 4\n2 2\n3 3\n....\n....\n....\n....\n\nSample Output 3\n\n0\n\nNo use of magic is needed.\n\nSample Input 4\n\n4 5\n1 2\n2 5\n#.###\n####.\n#..##\n#..##\n\nSample Output 4\n\n2", "sample_input": "4 4\n1 1\n4 4\n..#.\n..#.\n.#..\n.#..\n"}, "reference_outputs": ["1\n"], "source_document_id": "p02579", "source_text": "Score : 400 points\n\nProblem Statement\n\nA maze is composed of a grid of H \\times W squares - H vertical, W horizontal.\n\nThe square at the i-th row from the top and the j-th column from the left - (i,j) - is a wall if S_{ij} is # and a road if S_{ij} is ..\n\nThere is a magician in (C_h,C_w). He can do the following two kinds of moves:\n\nMove A: Walk to a road square that is vertically or horizontally adjacent to the square he is currently in.\n\nMove B: Use magic to warp himself to a road square in the 5\\times 5 area centered at the square he is currently in.\n\nIn either case, he cannot go out of the maze.\n\nAt least how many times does he need to use the magic to reach (D_h, D_w)?\n\nConstraints\n\n1 \\leq H,W \\leq 10^3\n\n1 \\leq C_h,D_h \\leq H\n\n1 \\leq C_w,D_w \\leq W\n\nS_{ij} is # or ..\n\nS_{C_h C_w} and S_{D_h D_w} are ..\n\n(C_h,C_w) \\neq (D_h,D_w)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\nC_h C_w\nD_h D_w\nS_{11}\\ldots S_{1W}\n\\vdots\nS_{H1}\\ldots S_{HW}\n\nOutput\n\nPrint the minimum number of times the magician needs to use the magic. If he cannot reach (D_h,D_w), print -1 instead.\n\nSample Input 1\n\n4 4\n1 1\n4 4\n..#.\n..#.\n.#..\n.#..\n\nSample Output 1\n\n1\n\nFor example, by walking to (2,2) and then using the magic to travel to (4,4), just one use of magic is enough.\n\nNote that he cannot walk diagonally.\n\nSample Input 2\n\n4 4\n1 4\n4 1\n.##.\n####\n####\n.##.\n\nSample Output 2\n\n-1\n\nHe cannot move from there.\n\nSample Input 3\n\n4 4\n2 2\n3 3\n....\n....\n....\n....\n\nSample Output 3\n\n0\n\nNo use of magic is needed.\n\nSample Input 4\n\n4 5\n1 2\n2 5\n#.###\n####.\n#..##\n#..##\n\nSample Output 4\n\n2", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1847, "cpu_time_ms": 2212, "memory_kb": 234660}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s636072692", "group_id": "codeNet:p02579", "input_text": "import java.io.IOException\nimport java.lang.NumberFormatException\nimport java.lang.StringBuilder\nimport java.util.ArrayDeque\nimport kotlin.math.max\nimport kotlin.math.min\n\nobject DMain{\n fun solve(){\n val mmax = 5000000\n\n val h = nextInt()\n val w = nextInt()\n val map = Array(h + 4){ IntArray(w + 4){-1} }\n\n val ch = nextInt()\n val cw = nextInt()\n val dh = nextInt()\n val dw = nextInt()\n\n for (i in 0 until h){\n val s = next()\n for(j in 0 until w){\n if(s[j] == '.') map[i+2][j+2] = mmax\n }\n }\n\n map[ch+1][cw+1] = 0\n move(map, h, w, ch+1 to cw+1)\n\n if(map[dh+1][dw+1] == -1 || map[dh+1][dw+1] == mmax){\n println(-1)\n }else{\n println(map[dh+1][dw+1])\n }\n }\n\n fun move(map: Array, h: Int, w: Int, start: Pair){\n val que = ArrayDeque>()\n val move = Array>(4){0 to 0}\n move[0] = 0 to 1\n move[1] = 0 to -1\n move[2] = 1 to 0\n move[3] = -1 to 0\n\n val move2 = Array>(20){0 to 0}\n move[0] = 2 to -2\n move[1] = 2 to -1\n move[2] = 2 to 0\n move[3] = 2 to 1\n move[4] = 2 to 2\n\n move[5] = 1 to -2\n move[6] = 1 to -1\n move[7] = 1 to 1\n move[8] = 1 to 2\n\n move[9] = 0 to -2\n move[10] = 0 to 2\n\n move[11] = -1 to -2\n move[12] = -1 to -1\n move[13] = -1 to 1\n move[14] = -1 to 2\n\n move[15] = -2 to -2\n move[16] = -2 to -1\n move[17] = -2 to 0\n move[18] = -2 to 1\n move[19] = -2 to 2\n\n que.add(start)\n while(!que.isEmpty()){\n val next = que.poll()\n val num = map[next.first][next.second]\n\n for(i in 0 until 4){\n val mx = next.first + move[i].first\n val my = next.second + move[i].second\n if(map[mx][my] > num){\n map[mx][my] = num\n que.add(mx to my)\n }\n }\n\n for( i in 0 until 20){\n val mmmx = next.first+move2[i].first\n val mmmy = next.second+move2[i].second\n if(map[mmmx][mmmy] > num + 1){\n map[mmmx][mmmy] = num + 1\n que.add(mmmx to mmmy)\n }\n }\n }\n }\n\n\n\n\n\n // Scanner based on uwi-san's Java code\n val stream = System.`in`\n val buffer = ByteArray(1024)\n var ptr = 0\n var buflen = 0\n\n fun hasNextByte(): Boolean{\n if(ptr < buflen){\n return true\n }else{\n ptr = 0\n try{\n buflen = stream.read(buffer)\n }catch (e: IOException){\n e.printStackTrace()\n }\n if(buflen <= 0){\n return false\n }\n }\n return true\n }\n\n fun readByte() =\n if(hasNextByte()) buffer[ptr++]\n else -1\n\n fun isPrintableChar(c: Byte) = c in 33..126\n\n fun hasNext(): Boolean{\n while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++\n return hasNextByte()\n }\n\n fun next(): String{\n if(!hasNext()) throw NoSuchElementException()\n val sb = StringBuilder()\n var b = readByte()\n while(isPrintableChar(b)){\n sb.appendCodePoint(b.toInt())\n b = readByte()\n }\n return sb.toString()\n }\n\n fun nextLong(): Long{\n if(!hasNext()) throw NoSuchElementException()\n var n = 0L\n var minus = false\n var b = readByte()\n if(b == '-'.toByte()){\n minus = true\n b = readByte()\n }\n if(b !in '0'.toByte()..'9'.toByte())\n throw NumberFormatException()\n while(true){\n if(b in '0'.toByte()..'9'.toByte()){\n n *= 10\n n += b - '0'.toByte()\n }else if(!isPrintableChar(b)){\n return if(minus) -n else n\n }else{\n throw NumberFormatException()\n }\n b = readByte()\n }\n }\n\n fun nextInt(): Int{\n val n1 = nextLong()\n if(n1 !in Int.MIN_VALUE..Int.MAX_VALUE)\n throw NumberFormatException()\n return n1.toInt()\n }\n\n fun NextDouble() = next().toDouble()\n}\n\nfun main(){\n DMain.solve()\n}\n", "language": "Kotlin", "metadata": {"date": 1598128774, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02579.html", "problem_id": "p02579", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02579/input.txt", "sample_output_relpath": "derived/input_output/data/p02579/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02579/Kotlin/s636072692.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s636072692", "user_id": "u097204018"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "import java.io.IOException\nimport java.lang.NumberFormatException\nimport java.lang.StringBuilder\nimport java.util.ArrayDeque\nimport kotlin.math.max\nimport kotlin.math.min\n\nobject DMain{\n fun solve(){\n val mmax = 5000000\n\n val h = nextInt()\n val w = nextInt()\n val map = Array(h + 4){ IntArray(w + 4){-1} }\n\n val ch = nextInt()\n val cw = nextInt()\n val dh = nextInt()\n val dw = nextInt()\n\n for (i in 0 until h){\n val s = next()\n for(j in 0 until w){\n if(s[j] == '.') map[i+2][j+2] = mmax\n }\n }\n\n map[ch+1][cw+1] = 0\n move(map, h, w, ch+1 to cw+1)\n\n if(map[dh+1][dw+1] == -1 || map[dh+1][dw+1] == mmax){\n println(-1)\n }else{\n println(map[dh+1][dw+1])\n }\n }\n\n fun move(map: Array, h: Int, w: Int, start: Pair){\n val que = ArrayDeque>()\n val move = Array>(4){0 to 0}\n move[0] = 0 to 1\n move[1] = 0 to -1\n move[2] = 1 to 0\n move[3] = -1 to 0\n\n val move2 = Array>(20){0 to 0}\n move[0] = 2 to -2\n move[1] = 2 to -1\n move[2] = 2 to 0\n move[3] = 2 to 1\n move[4] = 2 to 2\n\n move[5] = 1 to -2\n move[6] = 1 to -1\n move[7] = 1 to 1\n move[8] = 1 to 2\n\n move[9] = 0 to -2\n move[10] = 0 to 2\n\n move[11] = -1 to -2\n move[12] = -1 to -1\n move[13] = -1 to 1\n move[14] = -1 to 2\n\n move[15] = -2 to -2\n move[16] = -2 to -1\n move[17] = -2 to 0\n move[18] = -2 to 1\n move[19] = -2 to 2\n\n que.add(start)\n while(!que.isEmpty()){\n val next = que.poll()\n val num = map[next.first][next.second]\n\n for(i in 0 until 4){\n val mx = next.first + move[i].first\n val my = next.second + move[i].second\n if(map[mx][my] > num){\n map[mx][my] = num\n que.add(mx to my)\n }\n }\n\n for( i in 0 until 20){\n val mmmx = next.first+move2[i].first\n val mmmy = next.second+move2[i].second\n if(map[mmmx][mmmy] > num + 1){\n map[mmmx][mmmy] = num + 1\n que.add(mmmx to mmmy)\n }\n }\n }\n }\n\n\n\n\n\n // Scanner based on uwi-san's Java code\n val stream = System.`in`\n val buffer = ByteArray(1024)\n var ptr = 0\n var buflen = 0\n\n fun hasNextByte(): Boolean{\n if(ptr < buflen){\n return true\n }else{\n ptr = 0\n try{\n buflen = stream.read(buffer)\n }catch (e: IOException){\n e.printStackTrace()\n }\n if(buflen <= 0){\n return false\n }\n }\n return true\n }\n\n fun readByte() =\n if(hasNextByte()) buffer[ptr++]\n else -1\n\n fun isPrintableChar(c: Byte) = c in 33..126\n\n fun hasNext(): Boolean{\n while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++\n return hasNextByte()\n }\n\n fun next(): String{\n if(!hasNext()) throw NoSuchElementException()\n val sb = StringBuilder()\n var b = readByte()\n while(isPrintableChar(b)){\n sb.appendCodePoint(b.toInt())\n b = readByte()\n }\n return sb.toString()\n }\n\n fun nextLong(): Long{\n if(!hasNext()) throw NoSuchElementException()\n var n = 0L\n var minus = false\n var b = readByte()\n if(b == '-'.toByte()){\n minus = true\n b = readByte()\n }\n if(b !in '0'.toByte()..'9'.toByte())\n throw NumberFormatException()\n while(true){\n if(b in '0'.toByte()..'9'.toByte()){\n n *= 10\n n += b - '0'.toByte()\n }else if(!isPrintableChar(b)){\n return if(minus) -n else n\n }else{\n throw NumberFormatException()\n }\n b = readByte()\n }\n }\n\n fun nextInt(): Int{\n val n1 = nextLong()\n if(n1 !in Int.MIN_VALUE..Int.MAX_VALUE)\n throw NumberFormatException()\n return n1.toInt()\n }\n\n fun NextDouble() = next().toDouble()\n}\n\nfun main(){\n DMain.solve()\n}\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nA maze is composed of a grid of H \\times W squares - H vertical, W horizontal.\n\nThe square at the i-th row from the top and the j-th column from the left - (i,j) - is a wall if S_{ij} is # and a road if S_{ij} is ..\n\nThere is a magician in (C_h,C_w). He can do the following two kinds of moves:\n\nMove A: Walk to a road square that is vertically or horizontally adjacent to the square he is currently in.\n\nMove B: Use magic to warp himself to a road square in the 5\\times 5 area centered at the square he is currently in.\n\nIn either case, he cannot go out of the maze.\n\nAt least how many times does he need to use the magic to reach (D_h, D_w)?\n\nConstraints\n\n1 \\leq H,W \\leq 10^3\n\n1 \\leq C_h,D_h \\leq H\n\n1 \\leq C_w,D_w \\leq W\n\nS_{ij} is # or ..\n\nS_{C_h C_w} and S_{D_h D_w} are ..\n\n(C_h,C_w) \\neq (D_h,D_w)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\nC_h C_w\nD_h D_w\nS_{11}\\ldots S_{1W}\n\\vdots\nS_{H1}\\ldots S_{HW}\n\nOutput\n\nPrint the minimum number of times the magician needs to use the magic. If he cannot reach (D_h,D_w), print -1 instead.\n\nSample Input 1\n\n4 4\n1 1\n4 4\n..#.\n..#.\n.#..\n.#..\n\nSample Output 1\n\n1\n\nFor example, by walking to (2,2) and then using the magic to travel to (4,4), just one use of magic is enough.\n\nNote that he cannot walk diagonally.\n\nSample Input 2\n\n4 4\n1 4\n4 1\n.##.\n####\n####\n.##.\n\nSample Output 2\n\n-1\n\nHe cannot move from there.\n\nSample Input 3\n\n4 4\n2 2\n3 3\n....\n....\n....\n....\n\nSample Output 3\n\n0\n\nNo use of magic is needed.\n\nSample Input 4\n\n4 5\n1 2\n2 5\n#.###\n####.\n#..##\n#..##\n\nSample Output 4\n\n2", "sample_input": "4 4\n1 1\n4 4\n..#.\n..#.\n.#..\n.#..\n"}, "reference_outputs": ["1\n"], "source_document_id": "p02579", "source_text": "Score : 400 points\n\nProblem Statement\n\nA maze is composed of a grid of H \\times W squares - H vertical, W horizontal.\n\nThe square at the i-th row from the top and the j-th column from the left - (i,j) - is a wall if S_{ij} is # and a road if S_{ij} is ..\n\nThere is a magician in (C_h,C_w). He can do the following two kinds of moves:\n\nMove A: Walk to a road square that is vertically or horizontally adjacent to the square he is currently in.\n\nMove B: Use magic to warp himself to a road square in the 5\\times 5 area centered at the square he is currently in.\n\nIn either case, he cannot go out of the maze.\n\nAt least how many times does he need to use the magic to reach (D_h, D_w)?\n\nConstraints\n\n1 \\leq H,W \\leq 10^3\n\n1 \\leq C_h,D_h \\leq H\n\n1 \\leq C_w,D_w \\leq W\n\nS_{ij} is # or ..\n\nS_{C_h C_w} and S_{D_h D_w} are ..\n\n(C_h,C_w) \\neq (D_h,D_w)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\nC_h C_w\nD_h D_w\nS_{11}\\ldots S_{1W}\n\\vdots\nS_{H1}\\ldots S_{HW}\n\nOutput\n\nPrint the minimum number of times the magician needs to use the magic. If he cannot reach (D_h,D_w), print -1 instead.\n\nSample Input 1\n\n4 4\n1 1\n4 4\n..#.\n..#.\n.#..\n.#..\n\nSample Output 1\n\n1\n\nFor example, by walking to (2,2) and then using the magic to travel to (4,4), just one use of magic is enough.\n\nNote that he cannot walk diagonally.\n\nSample Input 2\n\n4 4\n1 4\n4 1\n.##.\n####\n####\n.##.\n\nSample Output 2\n\n-1\n\nHe cannot move from there.\n\nSample Input 3\n\n4 4\n2 2\n3 3\n....\n....\n....\n....\n\nSample Output 3\n\n0\n\nNo use of magic is needed.\n\nSample Input 4\n\n4 5\n1 2\n2 5\n#.###\n####.\n#..##\n#..##\n\nSample Output 4\n\n2", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 4466, "cpu_time_ms": 169, "memory_kb": 43044}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s610533205", "group_id": "codeNet:p02579", "input_text": "import java.util.*\nimport kotlin.math.max\nimport kotlin.math.min\n\nfun main() {\n val (h, w) = readInts()\n val (ch, cw) = readInts()\n val (dh, dw) = readInts()\n\n val grid = mutableListOf()\n grid.add(\"#\".repeat(w + 2))\n for (i in 0 until h) grid.add(\"#${readLn()}#\")\n grid.add(\"#\".repeat(w + 2))\n\n val component = List(h + 2) { MutableList(w + 2) { -1 } }\n\n val seen = Array(h + 2) { BooleanArray(w + 2) }\n\n fun dfs(i: Int, j: Int, comp: Int) {\n seen[i][j] = true\n component[i][j] = comp\n for (n in -1..1) {\n for (m in -1..1) {\n if ((n == 0 || m == 0) && grid[i + n][j + m] != '#' && !seen[i + n][j + m]) dfs(i + n, j + m, comp)\n }\n }\n }\n\n var currComponent = 0\n for (i in 1..h) {\n for (j in 1..w) {\n if (grid[i][j] == '.' && !seen[i][j]) {\n dfs(i, j, currComponent)\n currComponent++\n }\n }\n }\n\n val compNodes = Array(currComponent) { Node(it) }\n for (i in 1..h) {\n for (j in 1..w) {\n if (grid[i][j] == '.') {\n for (n in (max(0, i - 2))..(min(h, i + 2))) {\n for (m in (max(0, j - 2))..(min(w, j + 2))) {\n if (component[n][m] >= 0 && component[n][m] != component[i][j]) {\n compNodes[component[n][m]].neighbors.add(component[i][j])\n compNodes[component[i][j]].neighbors.add(component[n][m])\n }\n }\n }\n }\n }\n }\n\n if (component[ch][cw] == component[dh][dw]) println(0)\n else {\n val startComp = component[ch][cw]\n val endComp = component[dh][dw]\n val see = BooleanArray(currComponent)\n val queue = LinkedList()\n queue.add(startComp)\n var ans = -1\n while (queue.isNotEmpty()) {\n val curr = queue.removeFirst()\n see[curr] = true\n if (curr == endComp) {\n ans = compNodes[endComp].level\n break\n }\n for (n in compNodes[curr].neighbors) {\n if (!see[n]) {\n compNodes[n].level = 1 + compNodes[curr].level\n queue.add(n)\n }\n }\n }\n println(ans)\n }\n}\n\ndata class Node(val id: Int) {\n val neighbors = mutableListOf()\n var level = 0\n}\n\n// Input Reader\nprivate fun readLn() = readLine()!!\n\nprivate fun readStrings() = readLn().trim().split(\" \")\nprivate fun readInts() = readStrings().map { it.toInt() }\n", "language": "Kotlin", "metadata": {"date": 1598126289, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02579.html", "problem_id": "p02579", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02579/input.txt", "sample_output_relpath": "derived/input_output/data/p02579/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02579/Kotlin/s610533205.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s610533205", "user_id": "u984465701"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "import java.util.*\nimport kotlin.math.max\nimport kotlin.math.min\n\nfun main() {\n val (h, w) = readInts()\n val (ch, cw) = readInts()\n val (dh, dw) = readInts()\n\n val grid = mutableListOf()\n grid.add(\"#\".repeat(w + 2))\n for (i in 0 until h) grid.add(\"#${readLn()}#\")\n grid.add(\"#\".repeat(w + 2))\n\n val component = List(h + 2) { MutableList(w + 2) { -1 } }\n\n val seen = Array(h + 2) { BooleanArray(w + 2) }\n\n fun dfs(i: Int, j: Int, comp: Int) {\n seen[i][j] = true\n component[i][j] = comp\n for (n in -1..1) {\n for (m in -1..1) {\n if ((n == 0 || m == 0) && grid[i + n][j + m] != '#' && !seen[i + n][j + m]) dfs(i + n, j + m, comp)\n }\n }\n }\n\n var currComponent = 0\n for (i in 1..h) {\n for (j in 1..w) {\n if (grid[i][j] == '.' && !seen[i][j]) {\n dfs(i, j, currComponent)\n currComponent++\n }\n }\n }\n\n val compNodes = Array(currComponent) { Node(it) }\n for (i in 1..h) {\n for (j in 1..w) {\n if (grid[i][j] == '.') {\n for (n in (max(0, i - 2))..(min(h, i + 2))) {\n for (m in (max(0, j - 2))..(min(w, j + 2))) {\n if (component[n][m] >= 0 && component[n][m] != component[i][j]) {\n compNodes[component[n][m]].neighbors.add(component[i][j])\n compNodes[component[i][j]].neighbors.add(component[n][m])\n }\n }\n }\n }\n }\n }\n\n if (component[ch][cw] == component[dh][dw]) println(0)\n else {\n val startComp = component[ch][cw]\n val endComp = component[dh][dw]\n val see = BooleanArray(currComponent)\n val queue = LinkedList()\n queue.add(startComp)\n var ans = -1\n while (queue.isNotEmpty()) {\n val curr = queue.removeFirst()\n see[curr] = true\n if (curr == endComp) {\n ans = compNodes[endComp].level\n break\n }\n for (n in compNodes[curr].neighbors) {\n if (!see[n]) {\n compNodes[n].level = 1 + compNodes[curr].level\n queue.add(n)\n }\n }\n }\n println(ans)\n }\n}\n\ndata class Node(val id: Int) {\n val neighbors = mutableListOf()\n var level = 0\n}\n\n// Input Reader\nprivate fun readLn() = readLine()!!\n\nprivate fun readStrings() = readLn().trim().split(\" \")\nprivate fun readInts() = readStrings().map { it.toInt() }\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nA maze is composed of a grid of H \\times W squares - H vertical, W horizontal.\n\nThe square at the i-th row from the top and the j-th column from the left - (i,j) - is a wall if S_{ij} is # and a road if S_{ij} is ..\n\nThere is a magician in (C_h,C_w). He can do the following two kinds of moves:\n\nMove A: Walk to a road square that is vertically or horizontally adjacent to the square he is currently in.\n\nMove B: Use magic to warp himself to a road square in the 5\\times 5 area centered at the square he is currently in.\n\nIn either case, he cannot go out of the maze.\n\nAt least how many times does he need to use the magic to reach (D_h, D_w)?\n\nConstraints\n\n1 \\leq H,W \\leq 10^3\n\n1 \\leq C_h,D_h \\leq H\n\n1 \\leq C_w,D_w \\leq W\n\nS_{ij} is # or ..\n\nS_{C_h C_w} and S_{D_h D_w} are ..\n\n(C_h,C_w) \\neq (D_h,D_w)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\nC_h C_w\nD_h D_w\nS_{11}\\ldots S_{1W}\n\\vdots\nS_{H1}\\ldots S_{HW}\n\nOutput\n\nPrint the minimum number of times the magician needs to use the magic. If he cannot reach (D_h,D_w), print -1 instead.\n\nSample Input 1\n\n4 4\n1 1\n4 4\n..#.\n..#.\n.#..\n.#..\n\nSample Output 1\n\n1\n\nFor example, by walking to (2,2) and then using the magic to travel to (4,4), just one use of magic is enough.\n\nNote that he cannot walk diagonally.\n\nSample Input 2\n\n4 4\n1 4\n4 1\n.##.\n####\n####\n.##.\n\nSample Output 2\n\n-1\n\nHe cannot move from there.\n\nSample Input 3\n\n4 4\n2 2\n3 3\n....\n....\n....\n....\n\nSample Output 3\n\n0\n\nNo use of magic is needed.\n\nSample Input 4\n\n4 5\n1 2\n2 5\n#.###\n####.\n#..##\n#..##\n\nSample Output 4\n\n2", "sample_input": "4 4\n1 1\n4 4\n..#.\n..#.\n.#..\n.#..\n"}, "reference_outputs": ["1\n"], "source_document_id": "p02579", "source_text": "Score : 400 points\n\nProblem Statement\n\nA maze is composed of a grid of H \\times W squares - H vertical, W horizontal.\n\nThe square at the i-th row from the top and the j-th column from the left - (i,j) - is a wall if S_{ij} is # and a road if S_{ij} is ..\n\nThere is a magician in (C_h,C_w). He can do the following two kinds of moves:\n\nMove A: Walk to a road square that is vertically or horizontally adjacent to the square he is currently in.\n\nMove B: Use magic to warp himself to a road square in the 5\\times 5 area centered at the square he is currently in.\n\nIn either case, he cannot go out of the maze.\n\nAt least how many times does he need to use the magic to reach (D_h, D_w)?\n\nConstraints\n\n1 \\leq H,W \\leq 10^3\n\n1 \\leq C_h,D_h \\leq H\n\n1 \\leq C_w,D_w \\leq W\n\nS_{ij} is # or ..\n\nS_{C_h C_w} and S_{D_h D_w} are ..\n\n(C_h,C_w) \\neq (D_h,D_w)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\nC_h C_w\nD_h D_w\nS_{11}\\ldots S_{1W}\n\\vdots\nS_{H1}\\ldots S_{HW}\n\nOutput\n\nPrint the minimum number of times the magician needs to use the magic. If he cannot reach (D_h,D_w), print -1 instead.\n\nSample Input 1\n\n4 4\n1 1\n4 4\n..#.\n..#.\n.#..\n.#..\n\nSample Output 1\n\n1\n\nFor example, by walking to (2,2) and then using the magic to travel to (4,4), just one use of magic is enough.\n\nNote that he cannot walk diagonally.\n\nSample Input 2\n\n4 4\n1 4\n4 1\n.##.\n####\n####\n.##.\n\nSample Output 2\n\n-1\n\nHe cannot move from there.\n\nSample Input 3\n\n4 4\n2 2\n3 3\n....\n....\n....\n....\n\nSample Output 3\n\n0\n\nNo use of magic is needed.\n\nSample Input 4\n\n4 5\n1 2\n2 5\n#.###\n####.\n#..##\n#..##\n\nSample Output 4\n\n2", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2624, "cpu_time_ms": 2228, "memory_kb": 606192}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s340500175", "group_id": "codeNet:p02579", "input_text": "import kotlin.math.min\n\nfun main() = abc176d()\n\n@OptIn(ExperimentalStdlibApi::class)\nfun abc176d() = IO_abc176d().exec {\n val (h, w) = readInt() to readInt()\n val (startY, startX) = readInt() - 1 to readInt() - 1\n val (goalY, goalX) = readInt() - 1 to readInt() - 1\n val grid = Array(h) { readString().map { it == '.' }.toBooleanArray() }\n\n data class Q(val y: Int, val x: Int, val warpCount: Long) {\n override fun equals(other: Any?): Boolean {\n if (this === other) return true\n if (other !is Q) return false\n\n if (y != other.y) return false\n if (x != other.x) return false\n\n return true\n }\n\n override fun hashCode(): Int {\n var result = y\n result = 31 * result + x\n return result\n }\n }\n\n val inf = Long.MAX_VALUE / 100\n val queue = ArrayDeque()\n val around = listOf(-1 to 0, 1 to 0, 0 to -1, 0 to 1)\n val mins = Array(h) { LongArray(w) { inf } }\n\n queue.add(Q(startY, startX, 0))\n\n while (queue.isNotEmpty()) {\n val (y, x, warpCount) = queue.removeFirst()\n\n if (mins[y][x] <= warpCount) continue\n mins[y][x] = min(mins[y][x], warpCount)\n\n around.map { (addY, addX) -> Q(y + addY, x + addX, warpCount) }.filter {\n it.y in 0 until h && it.x in 0 until w &&\n grid[it.y][it.x] &&\n warpCount < mins[it.y][it.x]\n }.forEach { queue.addLast(it) }\n\n for (addY in -2..2) for (addX in -2..2) {\n if (addY == 0 && addX == 0) continue\n val q = Q(y + addY, x + addX, warpCount + 1)\n if (q.y in 0 until h && q.x in 0 until w &&\n grid[q.y][q.x] &&\n warpCount < mins[q.y][q.x]\n ) {\n queue.addLast(q)\n }\n }\n }\n\n val answer = mins[goalY][goalX].takeIf { it != inf } ?: -1\n\n println(answer)\n}\n\n// region kokokara template dayo (^o^)\n@Suppress(\"unused\", \"ClassName\", \"SpellCheckingInspection\", \"ConvertToStringTemplate\", \"MemberVisibilityCanBePrivate\")\nprivate class IO_abc176d(private val separator: String = System.lineSeparator()) {\n private val input = System.`in`\n private val buffer = ByteArray(1024)\n private var pointer = 0\n private var bufferLength = 0\n private val sb = StringBuilder()\n private fun Byte.isPrintable() = this in 33..126\n private fun Byte.isNumeric() = this in '0'.toByte()..'9'.toByte()\n private fun Byte.toNumVal() = if (this.isNumeric()) this - '0'.toByte() else error(\"$this is not numeric\")\n\n private fun hasNextByte(): Boolean {\n return if (pointer < bufferLength) true else {\n pointer = 0\n bufferLength = input.read(buffer)\n bufferLength > 0\n }\n }\n\n private fun readByte(): Byte = if (hasNextByte()) buffer[pointer++] else -1\n private fun skipUnprintable() = run { while (hasNextByte() && !buffer[pointer].isPrintable()) pointer++ }\n private fun hasNext(): Boolean = run { skipUnprintable() }.run { hasNextByte() }\n private fun hasNextOrError() = if (!hasNext()) error(\"has no next element.\") else Unit\n\n fun readString(): String {\n hasNextOrError()\n val sb = StringBuilder()\n var b = readByte()\n while (b.isPrintable()) {\n sb.appendCodePoint(b.toInt())\n b = readByte()\n }\n return sb.toString()\n }\n\n fun readLong(): Long {\n hasNextOrError()\n var n = 0L\n var negative = false\n var b = readByte()\n if (b == '-'.toByte()) {\n negative = true\n b = readByte()\n }\n if (!b.isNumeric()) error(\"$b is not numeric.\")\n while (true) {\n when {\n b.isNumeric() -> n = n * 10 + b.toNumVal()\n b.toInt() == -1 || !b.isPrintable() -> return if (negative) -n else n\n else -> error(\"failed to parse. [n=$n, b=$b]\")\n }\n b = readByte()\n }\n }\n\n fun readInt() = readLong()\n .let { if (it in Int.MIN_VALUE..Int.MAX_VALUE) it.toInt() else error(\"$it is not in range of Int.\") }\n\n fun readDouble(): Double {\n var n = 0.0\n var div = 1.0\n var negative = false\n var b = readByte()\n if (b == '-'.toByte()) {\n negative = true\n b = readByte()\n }\n do n = n * 10 + b.toNumVal()\n while (run { b = readByte() }.run { b.isNumeric() })\n if (b == '.'.toByte()) {\n while (run { b = readByte() }.run { b.isNumeric() })\n n += b.toNumVal() / (run { div *= 10 }.run { div })\n }\n return if (negative) -n else n\n }\n\n fun println(): Unit = run { sb.append(separator) }\n fun print(any: Any): Unit = run { sb.append(any) }\n fun println(any: Any): Unit = run { sb.append(any.toString() + separator) }\n fun flush() = run { kotlin.io.println(sb); sb.clear() }\n\n fun exec(action: IO_abc176d.() -> Unit) {\n var t: Throwable? = null\n Thread(null, { action() }, \"solve\", 128 * 1024 * 1024)\n .apply { setUncaughtExceptionHandler { _, t1 -> t = t1 } }\n .apply { start() }.join()\n t?.let { throw it }\n kotlin.io.print(sb)\n }\n\n fun readLine(): Nothing = error(\"readLine is disabled.\")\n}\n// endregion kokomade template dayo (^o^)\n", "language": "Kotlin", "metadata": {"date": 1598125555, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02579.html", "problem_id": "p02579", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02579/input.txt", "sample_output_relpath": "derived/input_output/data/p02579/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02579/Kotlin/s340500175.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s340500175", "user_id": "u139478771"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "import kotlin.math.min\n\nfun main() = abc176d()\n\n@OptIn(ExperimentalStdlibApi::class)\nfun abc176d() = IO_abc176d().exec {\n val (h, w) = readInt() to readInt()\n val (startY, startX) = readInt() - 1 to readInt() - 1\n val (goalY, goalX) = readInt() - 1 to readInt() - 1\n val grid = Array(h) { readString().map { it == '.' }.toBooleanArray() }\n\n data class Q(val y: Int, val x: Int, val warpCount: Long) {\n override fun equals(other: Any?): Boolean {\n if (this === other) return true\n if (other !is Q) return false\n\n if (y != other.y) return false\n if (x != other.x) return false\n\n return true\n }\n\n override fun hashCode(): Int {\n var result = y\n result = 31 * result + x\n return result\n }\n }\n\n val inf = Long.MAX_VALUE / 100\n val queue = ArrayDeque()\n val around = listOf(-1 to 0, 1 to 0, 0 to -1, 0 to 1)\n val mins = Array(h) { LongArray(w) { inf } }\n\n queue.add(Q(startY, startX, 0))\n\n while (queue.isNotEmpty()) {\n val (y, x, warpCount) = queue.removeFirst()\n\n if (mins[y][x] <= warpCount) continue\n mins[y][x] = min(mins[y][x], warpCount)\n\n around.map { (addY, addX) -> Q(y + addY, x + addX, warpCount) }.filter {\n it.y in 0 until h && it.x in 0 until w &&\n grid[it.y][it.x] &&\n warpCount < mins[it.y][it.x]\n }.forEach { queue.addLast(it) }\n\n for (addY in -2..2) for (addX in -2..2) {\n if (addY == 0 && addX == 0) continue\n val q = Q(y + addY, x + addX, warpCount + 1)\n if (q.y in 0 until h && q.x in 0 until w &&\n grid[q.y][q.x] &&\n warpCount < mins[q.y][q.x]\n ) {\n queue.addLast(q)\n }\n }\n }\n\n val answer = mins[goalY][goalX].takeIf { it != inf } ?: -1\n\n println(answer)\n}\n\n// region kokokara template dayo (^o^)\n@Suppress(\"unused\", \"ClassName\", \"SpellCheckingInspection\", \"ConvertToStringTemplate\", \"MemberVisibilityCanBePrivate\")\nprivate class IO_abc176d(private val separator: String = System.lineSeparator()) {\n private val input = System.`in`\n private val buffer = ByteArray(1024)\n private var pointer = 0\n private var bufferLength = 0\n private val sb = StringBuilder()\n private fun Byte.isPrintable() = this in 33..126\n private fun Byte.isNumeric() = this in '0'.toByte()..'9'.toByte()\n private fun Byte.toNumVal() = if (this.isNumeric()) this - '0'.toByte() else error(\"$this is not numeric\")\n\n private fun hasNextByte(): Boolean {\n return if (pointer < bufferLength) true else {\n pointer = 0\n bufferLength = input.read(buffer)\n bufferLength > 0\n }\n }\n\n private fun readByte(): Byte = if (hasNextByte()) buffer[pointer++] else -1\n private fun skipUnprintable() = run { while (hasNextByte() && !buffer[pointer].isPrintable()) pointer++ }\n private fun hasNext(): Boolean = run { skipUnprintable() }.run { hasNextByte() }\n private fun hasNextOrError() = if (!hasNext()) error(\"has no next element.\") else Unit\n\n fun readString(): String {\n hasNextOrError()\n val sb = StringBuilder()\n var b = readByte()\n while (b.isPrintable()) {\n sb.appendCodePoint(b.toInt())\n b = readByte()\n }\n return sb.toString()\n }\n\n fun readLong(): Long {\n hasNextOrError()\n var n = 0L\n var negative = false\n var b = readByte()\n if (b == '-'.toByte()) {\n negative = true\n b = readByte()\n }\n if (!b.isNumeric()) error(\"$b is not numeric.\")\n while (true) {\n when {\n b.isNumeric() -> n = n * 10 + b.toNumVal()\n b.toInt() == -1 || !b.isPrintable() -> return if (negative) -n else n\n else -> error(\"failed to parse. [n=$n, b=$b]\")\n }\n b = readByte()\n }\n }\n\n fun readInt() = readLong()\n .let { if (it in Int.MIN_VALUE..Int.MAX_VALUE) it.toInt() else error(\"$it is not in range of Int.\") }\n\n fun readDouble(): Double {\n var n = 0.0\n var div = 1.0\n var negative = false\n var b = readByte()\n if (b == '-'.toByte()) {\n negative = true\n b = readByte()\n }\n do n = n * 10 + b.toNumVal()\n while (run { b = readByte() }.run { b.isNumeric() })\n if (b == '.'.toByte()) {\n while (run { b = readByte() }.run { b.isNumeric() })\n n += b.toNumVal() / (run { div *= 10 }.run { div })\n }\n return if (negative) -n else n\n }\n\n fun println(): Unit = run { sb.append(separator) }\n fun print(any: Any): Unit = run { sb.append(any) }\n fun println(any: Any): Unit = run { sb.append(any.toString() + separator) }\n fun flush() = run { kotlin.io.println(sb); sb.clear() }\n\n fun exec(action: IO_abc176d.() -> Unit) {\n var t: Throwable? = null\n Thread(null, { action() }, \"solve\", 128 * 1024 * 1024)\n .apply { setUncaughtExceptionHandler { _, t1 -> t = t1 } }\n .apply { start() }.join()\n t?.let { throw it }\n kotlin.io.print(sb)\n }\n\n fun readLine(): Nothing = error(\"readLine is disabled.\")\n}\n// endregion kokomade template dayo (^o^)\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nA maze is composed of a grid of H \\times W squares - H vertical, W horizontal.\n\nThe square at the i-th row from the top and the j-th column from the left - (i,j) - is a wall if S_{ij} is # and a road if S_{ij} is ..\n\nThere is a magician in (C_h,C_w). He can do the following two kinds of moves:\n\nMove A: Walk to a road square that is vertically or horizontally adjacent to the square he is currently in.\n\nMove B: Use magic to warp himself to a road square in the 5\\times 5 area centered at the square he is currently in.\n\nIn either case, he cannot go out of the maze.\n\nAt least how many times does he need to use the magic to reach (D_h, D_w)?\n\nConstraints\n\n1 \\leq H,W \\leq 10^3\n\n1 \\leq C_h,D_h \\leq H\n\n1 \\leq C_w,D_w \\leq W\n\nS_{ij} is # or ..\n\nS_{C_h C_w} and S_{D_h D_w} are ..\n\n(C_h,C_w) \\neq (D_h,D_w)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\nC_h C_w\nD_h D_w\nS_{11}\\ldots S_{1W}\n\\vdots\nS_{H1}\\ldots S_{HW}\n\nOutput\n\nPrint the minimum number of times the magician needs to use the magic. If he cannot reach (D_h,D_w), print -1 instead.\n\nSample Input 1\n\n4 4\n1 1\n4 4\n..#.\n..#.\n.#..\n.#..\n\nSample Output 1\n\n1\n\nFor example, by walking to (2,2) and then using the magic to travel to (4,4), just one use of magic is enough.\n\nNote that he cannot walk diagonally.\n\nSample Input 2\n\n4 4\n1 4\n4 1\n.##.\n####\n####\n.##.\n\nSample Output 2\n\n-1\n\nHe cannot move from there.\n\nSample Input 3\n\n4 4\n2 2\n3 3\n....\n....\n....\n....\n\nSample Output 3\n\n0\n\nNo use of magic is needed.\n\nSample Input 4\n\n4 5\n1 2\n2 5\n#.###\n####.\n#..##\n#..##\n\nSample Output 4\n\n2", "sample_input": "4 4\n1 1\n4 4\n..#.\n..#.\n.#..\n.#..\n"}, "reference_outputs": ["1\n"], "source_document_id": "p02579", "source_text": "Score : 400 points\n\nProblem Statement\n\nA maze is composed of a grid of H \\times W squares - H vertical, W horizontal.\n\nThe square at the i-th row from the top and the j-th column from the left - (i,j) - is a wall if S_{ij} is # and a road if S_{ij} is ..\n\nThere is a magician in (C_h,C_w). He can do the following two kinds of moves:\n\nMove A: Walk to a road square that is vertically or horizontally adjacent to the square he is currently in.\n\nMove B: Use magic to warp himself to a road square in the 5\\times 5 area centered at the square he is currently in.\n\nIn either case, he cannot go out of the maze.\n\nAt least how many times does he need to use the magic to reach (D_h, D_w)?\n\nConstraints\n\n1 \\leq H,W \\leq 10^3\n\n1 \\leq C_h,D_h \\leq H\n\n1 \\leq C_w,D_w \\leq W\n\nS_{ij} is # or ..\n\nS_{C_h C_w} and S_{D_h D_w} are ..\n\n(C_h,C_w) \\neq (D_h,D_w)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\nC_h C_w\nD_h D_w\nS_{11}\\ldots S_{1W}\n\\vdots\nS_{H1}\\ldots S_{HW}\n\nOutput\n\nPrint the minimum number of times the magician needs to use the magic. If he cannot reach (D_h,D_w), print -1 instead.\n\nSample Input 1\n\n4 4\n1 1\n4 4\n..#.\n..#.\n.#..\n.#..\n\nSample Output 1\n\n1\n\nFor example, by walking to (2,2) and then using the magic to travel to (4,4), just one use of magic is enough.\n\nNote that he cannot walk diagonally.\n\nSample Input 2\n\n4 4\n1 4\n4 1\n.##.\n####\n####\n.##.\n\nSample Output 2\n\n-1\n\nHe cannot move from there.\n\nSample Input 3\n\n4 4\n2 2\n3 3\n....\n....\n....\n....\n\nSample Output 3\n\n0\n\nNo use of magic is needed.\n\nSample Input 4\n\n4 5\n1 2\n2 5\n#.###\n####.\n#..##\n#..##\n\nSample Output 4\n\n2", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 5380, "cpu_time_ms": 2210, "memory_kb": 107940}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s750329302", "group_id": "codeNet:p02582", "input_text": "fun main(args: Array) {\n when(readLine()!!) {\n \"SRR\", \"RRS\" -> println(\"2\")\n \"RRR\" -> println(\"3\")\n \"SSS\" -> println(\"0\")\n else -> println(\"1\")\n }\n}", "language": "Kotlin", "metadata": {"date": 1597762629, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02582.html", "problem_id": "p02582", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02582/input.txt", "sample_output_relpath": "derived/input_output/data/p02582/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02582/Kotlin/s750329302.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s750329302", "user_id": "u038956474"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "fun main(args: Array) {\n when(readLine()!!) {\n \"SRR\", \"RRS\" -> println(\"2\")\n \"RRR\" -> println(\"3\")\n \"SSS\" -> println(\"0\")\n else -> println(\"1\")\n }\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nWe have weather records at AtCoder Town for some consecutive three days. A string of length 3, S, represents the records - if the i-th character is S, it means it was sunny on the i-th day; if that character is R, it means it was rainy on that day.\n\nFind the maximum number of consecutive rainy days in this period.\n\nConstraints\n\n|S| = 3\n\nEach character of S is S or R.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the maximum number of consecutive rainy days in the period.\n\nSample Input 1\n\nRRS\n\nSample Output 1\n\n2\n\nWe had rain on the 1-st and 2-nd days in the period. Here, the maximum number of consecutive rainy days is 2, so we should print 2.\n\nSample Input 2\n\nSSS\n\nSample Output 2\n\n0\n\nIt was sunny throughout the period. We had no rainy days, so we should print 0.\n\nSample Input 3\n\nRSR\n\nSample Output 3\n\n1\n\nWe had rain on the 1-st and 3-rd days - two \"streaks\" of one rainy day, so we should print 1.", "sample_input": "RRS\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02582", "source_text": "Score : 100 points\n\nProblem Statement\n\nWe have weather records at AtCoder Town for some consecutive three days. A string of length 3, S, represents the records - if the i-th character is S, it means it was sunny on the i-th day; if that character is R, it means it was rainy on that day.\n\nFind the maximum number of consecutive rainy days in this period.\n\nConstraints\n\n|S| = 3\n\nEach character of S is S or R.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the maximum number of consecutive rainy days in the period.\n\nSample Input 1\n\nRRS\n\nSample Output 1\n\n2\n\nWe had rain on the 1-st and 2-nd days in the period. Here, the maximum number of consecutive rainy days is 2, so we should print 2.\n\nSample Input 2\n\nSSS\n\nSample Output 2\n\n0\n\nIt was sunny throughout the period. We had no rainy days, so we should print 0.\n\nSample Input 3\n\nRSR\n\nSample Output 3\n\n1\n\nWe had rain on the 1-st and 3-rd days - two \"streaks\" of one rainy day, so we should print 1.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 106, "memory_kb": 34400}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s160798303", "group_id": "codeNet:p02583", "input_text": "\nfun main() {\n b()\n}\n\nfun a() {\n val s = readLine()!!\n fun aa(): Int {\n if (s == \"RRR\") return 3\n if (s.take(2) == \"RR\" || s.takeLast(2) == \"RR\") return 2\n if (s.any { it == 'R' }) return 1\n return 0\n }\n aa().toLong().print()\n}\n\nfun b() {\n val N = readLong()\n val L = readLongList().sorted()\n var ans = 0L\n L.forEachIndexed { i, l ->\n L.drop(i + 1).forEachIndexed{ j, m ->\n L.drop(i + j + 2).forEachIndexed { k, n ->\n if (l + m > n) {\n if (l != m && l != n && m != n) {\n ans++\n }\n }\n }\n }\n }\n ans.print()\n}\n\nfun readLong() = readLine()!!.toLong()\nfun readLongList() = readLine()!!.split(\" \").map { it.toLong() }\n\nfun Long.bitEach(action: (Int) -> Unit) {\n (0 until Long.SIZE_BITS).forEach { action(((this shr it) and 1).toInt()) }\n}\n\nfun Long.bitFilter(bit: Int) = (0 until Long.SIZE_BITS).filter { ((this shr it) and 1) == 1L }\n\nfun pairs(first: Iterable, second: Iterable) = first.flatMap { t1 -> second.map { t2 -> t1 to t2 } }\n\nfun Long.primeSequence() = sequence {\n var n = this@primeSequence\n if (n % 2L == 0L) {\n yield(2L)\n n /= 2L\n }\n var i = 3L\n while (n > 0) {\n if (n % i == 0L) {\n yield(i)\n n /= i\n }\n i += 2L\n }\n}\n\nfun Long.print() {\n println(this)\n}", "language": "Kotlin", "metadata": {"date": 1597519676, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02583.html", "problem_id": "p02583", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02583/input.txt", "sample_output_relpath": "derived/input_output/data/p02583/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02583/Kotlin/s160798303.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s160798303", "user_id": "u915119935"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "\nfun main() {\n b()\n}\n\nfun a() {\n val s = readLine()!!\n fun aa(): Int {\n if (s == \"RRR\") return 3\n if (s.take(2) == \"RR\" || s.takeLast(2) == \"RR\") return 2\n if (s.any { it == 'R' }) return 1\n return 0\n }\n aa().toLong().print()\n}\n\nfun b() {\n val N = readLong()\n val L = readLongList().sorted()\n var ans = 0L\n L.forEachIndexed { i, l ->\n L.drop(i + 1).forEachIndexed{ j, m ->\n L.drop(i + j + 2).forEachIndexed { k, n ->\n if (l + m > n) {\n if (l != m && l != n && m != n) {\n ans++\n }\n }\n }\n }\n }\n ans.print()\n}\n\nfun readLong() = readLine()!!.toLong()\nfun readLongList() = readLine()!!.split(\" \").map { it.toLong() }\n\nfun Long.bitEach(action: (Int) -> Unit) {\n (0 until Long.SIZE_BITS).forEach { action(((this shr it) and 1).toInt()) }\n}\n\nfun Long.bitFilter(bit: Int) = (0 until Long.SIZE_BITS).filter { ((this shr it) and 1) == 1L }\n\nfun pairs(first: Iterable, second: Iterable) = first.flatMap { t1 -> second.map { t2 -> t1 to t2 } }\n\nfun Long.primeSequence() = sequence {\n var n = this@primeSequence\n if (n % 2L == 0L) {\n yield(2L)\n n /= 2L\n }\n var i = 3L\n while (n > 0) {\n if (n % i == 0L) {\n yield(i)\n n /= i\n }\n i += 2L\n }\n}\n\nfun Long.print() {\n println(this)\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nWe have sticks numbered 1, \\cdots, N. The length of Stick i (1 \\leq i \\leq N) is L_i.\n\nIn how many ways can we choose three of the sticks with different lengths that can form a triangle?\n\nThat is, find the number of triples of integers (i, j, k) (1 \\leq i < j < k \\leq N) that satisfy both of the following conditions:\n\nL_i, L_j, and L_k are all different.\n\nThere exists a triangle whose sides have lengths L_i, L_j, and L_k.\n\nConstraints\n\n1 \\leq N \\leq 100\n\n1 \\leq L_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 L_2 \\cdots L_N\n\nOutput\n\nPrint the number of ways to choose three of the sticks with different lengths that can form a triangle.\n\nSample Input 1\n\n5\n4 4 9 7 5\n\nSample Output 1\n\n5\n\nThe following five triples (i, j, k) satisfy the conditions: (1, 3, 4), (1, 4, 5), (2, 3, 4), (2, 4, 5), and (3, 4, 5).\n\nSample Input 2\n\n6\n4 5 4 3 3 5\n\nSample Output 2\n\n8\n\nWe have two sticks for each of the lengths 3, 4, and 5. To satisfy the first condition, we have to choose one from each length.\n\nThere is a triangle whose sides have lengths 3, 4, and 5, so we have 2 ^ 3 = 8 triples (i, j, k) that satisfy the conditions.\n\nSample Input 3\n\n10\n9 4 6 1 9 6 10 6 6 8\n\nSample Output 3\n\n39\n\nSample Input 4\n\n2\n1 1\n\nSample Output 4\n\n0\n\nNo triple (i, j, k) satisfies 1 \\leq i < j < k \\leq N, so we should print 0.", "sample_input": "5\n4 4 9 7 5\n"}, "reference_outputs": ["5\n"], "source_document_id": "p02583", "source_text": "Score : 200 points\n\nProblem Statement\n\nWe have sticks numbered 1, \\cdots, N. The length of Stick i (1 \\leq i \\leq N) is L_i.\n\nIn how many ways can we choose three of the sticks with different lengths that can form a triangle?\n\nThat is, find the number of triples of integers (i, j, k) (1 \\leq i < j < k \\leq N) that satisfy both of the following conditions:\n\nL_i, L_j, and L_k are all different.\n\nThere exists a triangle whose sides have lengths L_i, L_j, and L_k.\n\nConstraints\n\n1 \\leq N \\leq 100\n\n1 \\leq L_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 L_2 \\cdots L_N\n\nOutput\n\nPrint the number of ways to choose three of the sticks with different lengths that can form a triangle.\n\nSample Input 1\n\n5\n4 4 9 7 5\n\nSample Output 1\n\n5\n\nThe following five triples (i, j, k) satisfy the conditions: (1, 3, 4), (1, 4, 5), (2, 3, 4), (2, 4, 5), and (3, 4, 5).\n\nSample Input 2\n\n6\n4 5 4 3 3 5\n\nSample Output 2\n\n8\n\nWe have two sticks for each of the lengths 3, 4, and 5. To satisfy the first condition, we have to choose one from each length.\n\nThere is a triangle whose sides have lengths 3, 4, and 5, so we have 2 ^ 3 = 8 triples (i, j, k) that satisfy the conditions.\n\nSample Input 3\n\n10\n9 4 6 1 9 6 10 6 6 8\n\nSample Output 3\n\n39\n\nSample Input 4\n\n2\n1 1\n\nSample Output 4\n\n0\n\nNo triple (i, j, k) satisfies 1 \\leq i < j < k \\leq N, so we should print 0.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1454, "cpu_time_ms": 188, "memory_kb": 42744}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s650415176", "group_id": "codeNet:p02583", "input_text": "import java.io.BufferedReader\nimport java.io.InputStreamReader\nimport java.io.PrintWriter\nimport java.util.*\nimport kotlin.math.abs\nimport kotlin.math.max\nimport kotlin.math.sqrt\nimport kotlin.math.tan\n\nval br = BufferedReader(InputStreamReader(System.`in`))\nval out = PrintWriter(System.out)\n\nfun main() {\n br.use { out.use {\n solve()\n out.flush()\n } }\n}\n\nfun solve() {\n val n = readInteger()\n val lList = readLongList()\n\n var ans = 0L\n for (i in 0 until n) {\n for (j in (i + 1) until n) {\n for (k in (j + 1) until n) {\n val a = listOf(lList[i], lList[j], lList[k]).sortedDescending()\n if (a.toSet().size != 3) {\n continue\n }\n\n if (a[0] < a[1] + a[2]) {\n ans++\n }\n }\n }\n }\n out.println(ans)\n}\n\nfun readInteger() = Integer.parseInt(br.readLine())\nfun readLong() = java.lang.Long.parseLong(br.readLine())\nfun readStringList() = br.readLine()!!.split(' ')\nfun readIntegerList() = readStringList().map(Integer::parseInt)\nfun readLongList() = readStringList().map(java.lang.Long::parseLong)\nfun readDoubleList() = readStringList().map(java.lang.Double::parseDouble)\n", "language": "Kotlin", "metadata": {"date": 1597518595, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02583.html", "problem_id": "p02583", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02583/input.txt", "sample_output_relpath": "derived/input_output/data/p02583/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02583/Kotlin/s650415176.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s650415176", "user_id": "u784448849"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "import java.io.BufferedReader\nimport java.io.InputStreamReader\nimport java.io.PrintWriter\nimport java.util.*\nimport kotlin.math.abs\nimport kotlin.math.max\nimport kotlin.math.sqrt\nimport kotlin.math.tan\n\nval br = BufferedReader(InputStreamReader(System.`in`))\nval out = PrintWriter(System.out)\n\nfun main() {\n br.use { out.use {\n solve()\n out.flush()\n } }\n}\n\nfun solve() {\n val n = readInteger()\n val lList = readLongList()\n\n var ans = 0L\n for (i in 0 until n) {\n for (j in (i + 1) until n) {\n for (k in (j + 1) until n) {\n val a = listOf(lList[i], lList[j], lList[k]).sortedDescending()\n if (a.toSet().size != 3) {\n continue\n }\n\n if (a[0] < a[1] + a[2]) {\n ans++\n }\n }\n }\n }\n out.println(ans)\n}\n\nfun readInteger() = Integer.parseInt(br.readLine())\nfun readLong() = java.lang.Long.parseLong(br.readLine())\nfun readStringList() = br.readLine()!!.split(' ')\nfun readIntegerList() = readStringList().map(Integer::parseInt)\nfun readLongList() = readStringList().map(java.lang.Long::parseLong)\nfun readDoubleList() = readStringList().map(java.lang.Double::parseDouble)\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nWe have sticks numbered 1, \\cdots, N. The length of Stick i (1 \\leq i \\leq N) is L_i.\n\nIn how many ways can we choose three of the sticks with different lengths that can form a triangle?\n\nThat is, find the number of triples of integers (i, j, k) (1 \\leq i < j < k \\leq N) that satisfy both of the following conditions:\n\nL_i, L_j, and L_k are all different.\n\nThere exists a triangle whose sides have lengths L_i, L_j, and L_k.\n\nConstraints\n\n1 \\leq N \\leq 100\n\n1 \\leq L_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 L_2 \\cdots L_N\n\nOutput\n\nPrint the number of ways to choose three of the sticks with different lengths that can form a triangle.\n\nSample Input 1\n\n5\n4 4 9 7 5\n\nSample Output 1\n\n5\n\nThe following five triples (i, j, k) satisfy the conditions: (1, 3, 4), (1, 4, 5), (2, 3, 4), (2, 4, 5), and (3, 4, 5).\n\nSample Input 2\n\n6\n4 5 4 3 3 5\n\nSample Output 2\n\n8\n\nWe have two sticks for each of the lengths 3, 4, and 5. To satisfy the first condition, we have to choose one from each length.\n\nThere is a triangle whose sides have lengths 3, 4, and 5, so we have 2 ^ 3 = 8 triples (i, j, k) that satisfy the conditions.\n\nSample Input 3\n\n10\n9 4 6 1 9 6 10 6 6 8\n\nSample Output 3\n\n39\n\nSample Input 4\n\n2\n1 1\n\nSample Output 4\n\n0\n\nNo triple (i, j, k) satisfies 1 \\leq i < j < k \\leq N, so we should print 0.", "sample_input": "5\n4 4 9 7 5\n"}, "reference_outputs": ["5\n"], "source_document_id": "p02583", "source_text": "Score : 200 points\n\nProblem Statement\n\nWe have sticks numbered 1, \\cdots, N. The length of Stick i (1 \\leq i \\leq N) is L_i.\n\nIn how many ways can we choose three of the sticks with different lengths that can form a triangle?\n\nThat is, find the number of triples of integers (i, j, k) (1 \\leq i < j < k \\leq N) that satisfy both of the following conditions:\n\nL_i, L_j, and L_k are all different.\n\nThere exists a triangle whose sides have lengths L_i, L_j, and L_k.\n\nConstraints\n\n1 \\leq N \\leq 100\n\n1 \\leq L_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 L_2 \\cdots L_N\n\nOutput\n\nPrint the number of ways to choose three of the sticks with different lengths that can form a triangle.\n\nSample Input 1\n\n5\n4 4 9 7 5\n\nSample Output 1\n\n5\n\nThe following five triples (i, j, k) satisfy the conditions: (1, 3, 4), (1, 4, 5), (2, 3, 4), (2, 4, 5), and (3, 4, 5).\n\nSample Input 2\n\n6\n4 5 4 3 3 5\n\nSample Output 2\n\n8\n\nWe have two sticks for each of the lengths 3, 4, and 5. To satisfy the first condition, we have to choose one from each length.\n\nThere is a triangle whose sides have lengths 3, 4, and 5, so we have 2 ^ 3 = 8 triples (i, j, k) that satisfy the conditions.\n\nSample Input 3\n\n10\n9 4 6 1 9 6 10 6 6 8\n\nSample Output 3\n\n39\n\nSample Input 4\n\n2\n1 1\n\nSample Output 4\n\n0\n\nNo triple (i, j, k) satisfies 1 \\leq i < j < k \\leq N, so we should print 0.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1249, "cpu_time_ms": 337, "memory_kb": 56900}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s213765294", "group_id": "codeNet:p02584", "input_text": "fun main() {\n // 文字列\n// var n = readLine()!!.toInt()\n// val x: String = readLine()!!\n // 数値\n// val int =readLine()!!.toInt()\n // 行\n// val list = readLine()!!.split(\" \").map (String::toInt )\n var (x, k, d) = readLine()!!.split(\" \").map(String::toLong)\n// val xys = List(n) {\n//// readLine()!!.split(\" \").map(String::toLong)\n// readLine()!!.toDouble()\n// }\n \n x=Math.abs(x)\n var ans=0L\n if (x / d >= k) {\n ans=x - k * d\n } else {\n val street_step = (x / d).toLong()\n val remainder_step = k - street_step\n if (remainder_step % 2 == 0L) {\n ans=x-(street_step*d)\n }else{\n ans=Math.abs(x-(street_step*d)-d)\n }\n }\n print(ans)\n\n}", "language": "Kotlin", "metadata": {"date": 1597612322, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02584.html", "problem_id": "p02584", "resource_group": "medium_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/Kotlin/s213765294.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s213765294", "user_id": "u826331398"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "fun main() {\n // 文字列\n// var n = readLine()!!.toInt()\n// val x: String = readLine()!!\n // 数値\n// val int =readLine()!!.toInt()\n // 行\n// val list = readLine()!!.split(\" \").map (String::toInt )\n var (x, k, d) = readLine()!!.split(\" \").map(String::toLong)\n// val xys = List(n) {\n//// readLine()!!.split(\" \").map(String::toLong)\n// readLine()!!.toDouble()\n// }\n \n x=Math.abs(x)\n var ans=0L\n if (x / d >= k) {\n ans=x - k * d\n } else {\n val street_step = (x / d).toLong()\n val remainder_step = k - street_step\n if (remainder_step % 2 == 0L) {\n ans=x-(street_step*d)\n }else{\n ans=Math.abs(x-(street_step*d)-d)\n }\n }\n print(ans)\n\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 762, "cpu_time_ms": 114, "memory_kb": 36472}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s172656692", "group_id": "codeNet:p02584", "input_text": "import java.util.*\nimport kotlin.math.abs\n\nfun main() {\n val pw = java.io.PrintWriter(System.out)\n Problem.solve(Scanner(System.`in`), pw)\n pw.flush()\n}\n\nobject Problem {\n fun solve(sc: Scanner, pw: java.io.PrintWriter) {\n var X = sc.next().toLong()\n var K = sc.next().toLong()\n val D = sc.next().toLong()\n val a1 = abs(X) / D\n if (K <= a1) {\n if (X > 0) X -= D * K else X += D * K\n pw.println(X)\n return\n }\n if (X > 0) X -= D * a1 else X += D * a1\n K -= a1\n if (K % 2 != 0L) {\n if (X > 0) X -= D else X += D\n }\n pw.println(abs(X))\n }\n}\n", "language": "Kotlin", "metadata": {"date": 1597590397, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02584.html", "problem_id": "p02584", "resource_group": "medium_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/Kotlin/s172656692.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s172656692", "user_id": "u297767059"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import java.util.*\nimport kotlin.math.abs\n\nfun main() {\n val pw = java.io.PrintWriter(System.out)\n Problem.solve(Scanner(System.`in`), pw)\n pw.flush()\n}\n\nobject Problem {\n fun solve(sc: Scanner, pw: java.io.PrintWriter) {\n var X = sc.next().toLong()\n var K = sc.next().toLong()\n val D = sc.next().toLong()\n val a1 = abs(X) / D\n if (K <= a1) {\n if (X > 0) X -= D * K else X += D * K\n pw.println(X)\n return\n }\n if (X > 0) X -= D * a1 else X += D * a1\n K -= a1\n if (K % 2 != 0L) {\n if (X > 0) X -= D else X += D\n }\n pw.println(abs(X))\n }\n}\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 673, "cpu_time_ms": 131, "memory_kb": 36384}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s098104233", "group_id": "codeNet:p02584", "input_text": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val x = sc.nextLong()\n val k = sc.nextLong()\n val d = sc.nextLong()\n println(problem175c(x, k, d))\n}\n\nfun problem175c(x: Long, k: Long, d: Long): Long {\n val x = Math.abs(x)\n if (k * d <= x) {\n return x - k * d\n }\n if (x % d != 0L && k % 2 == 0L) {\n return x % d\n } else {\n return Math.min(Math.abs((x % d) - d), (x % d) + d)\n }\n}", "language": "Kotlin", "metadata": {"date": 1597524855, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02584.html", "problem_id": "p02584", "resource_group": "medium_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/Kotlin/s098104233.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s098104233", "user_id": "u073232808"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val x = sc.nextLong()\n val k = sc.nextLong()\n val d = sc.nextLong()\n println(problem175c(x, k, d))\n}\n\nfun problem175c(x: Long, k: Long, d: Long): Long {\n val x = Math.abs(x)\n if (k * d <= x) {\n return x - k * d\n }\n if (x % d != 0L && k % 2 == 0L) {\n return x % d\n } else {\n return Math.min(Math.abs((x % d) - d), (x % d) + d)\n }\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 468, "cpu_time_ms": 134, "memory_kb": 36436}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s347828408", "group_id": "codeNet:p02584", "input_text": "fun main(args: Array) {\n val (x, k, d) = readLine()!!.split(\" \").map { Math.abs(it.toLong()) }\n if (x > k * d) {\n println(x - k * d)\n }\n else\n {\n val remainder = x % d\n // 正サイド\n if (remainder < Math.abs(remainder - d)) {\n if (d - x / k == 1L) {\n println(remainder)\n } else {\n println(Math.abs(remainder - d))\n }\n }\n // 負サイド\n else {\n if (d - x / k != 1L) {\n println(remainder)\n } else {\n println(Math.abs(remainder - d))\n\n }\n }\n }\n}\n", "language": "Kotlin", "metadata": {"date": 1597523798, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02584.html", "problem_id": "p02584", "resource_group": "medium_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/Kotlin/s347828408.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s347828408", "user_id": "u227189389"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "fun main(args: Array) {\n val (x, k, d) = readLine()!!.split(\" \").map { Math.abs(it.toLong()) }\n if (x > k * d) {\n println(x - k * d)\n }\n else\n {\n val remainder = x % d\n // 正サイド\n if (remainder < Math.abs(remainder - d)) {\n if (d - x / k == 1L) {\n println(remainder)\n } else {\n println(Math.abs(remainder - d))\n }\n }\n // 負サイド\n else {\n if (d - x / k != 1L) {\n println(remainder)\n } else {\n println(Math.abs(remainder - d))\n\n }\n }\n }\n}\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 656, "cpu_time_ms": 132, "memory_kb": 36396}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s263766217", "group_id": "codeNet:p02584", "input_text": "import kotlin.math.abs\n\nfun main(args: Array) {\n \n val (x, k, d) = readLine()!!.split(\" \").map { it.toLong() }\n \n\n //val (x, k, d) = Triple(7, 1, 10)\n\n val needBestTimes = if (x > d) abs(x) / d else 1L\n val bestPos = if (x > d) abs(x) % d else d - abs(x)\n\n val answer = when {\n needBestTimes > k -> { // OK\n abs(x) - k * d\n }\n (k - needBestTimes) % 2 == 0L -> {\n bestPos\n }\n (k - needBestTimes) % 2 == 1L -> {\n bestPos + d\n }\n\n else -> {\n 0L\n }\n }\n\n println(\"$answer\")\n}\n", "language": "Kotlin", "metadata": {"date": 1597523239, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02584.html", "problem_id": "p02584", "resource_group": "medium_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/Kotlin/s263766217.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s263766217", "user_id": "u393104209"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import kotlin.math.abs\n\nfun main(args: Array) {\n \n val (x, k, d) = readLine()!!.split(\" \").map { it.toLong() }\n \n\n //val (x, k, d) = Triple(7, 1, 10)\n\n val needBestTimes = if (x > d) abs(x) / d else 1L\n val bestPos = if (x > d) abs(x) % d else d - abs(x)\n\n val answer = when {\n needBestTimes > k -> { // OK\n abs(x) - k * d\n }\n (k - needBestTimes) % 2 == 0L -> {\n bestPos\n }\n (k - needBestTimes) % 2 == 1L -> {\n bestPos + d\n }\n\n else -> {\n 0L\n }\n }\n\n println(\"$answer\")\n}\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 125, "memory_kb": 36424}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s313399219", "group_id": "codeNet:p02586", "input_text": "import kotlin.math.*\n\nfun str() = readLine()!!\nfun int() = str().toInt()\nfun long() = str().toLong()\n\nfun read(d:String = \" \") = str().split(d)\nfun list(d:String = \" \",f:String.()->T) = read(d).map {f(it)}\nfun list() = list {toInt()}\n\nfun MutableList.removeLast() = this.removeAt(this.lastIndex)\n\nconst val mod = 1000000007L\n\nfun main() {\n\tabc000X()\n}\n\nfun abc000X() {\n\tval (r,c,k) = list()\n\tval value = Array(r) {LongArray(c) {0L}}\n\tfor(i in 1..k) {\n\t\tval (r,c,v) = list()\n\t\tvalue[r-1][c-1] = v.toLong()\n\t}\n\n\tval dp = Array(r) {Array(c) {LongArray(4) {0L}}}\n\n\tfor(i in 0 until r) {\n\t\tfor(j in 0 until c) {\n\t\t\tif(i>0)\n\t\t\t\tdp[i][j][0] = max(dp[i][j][0],dp[i-1][j][3])\n\t\t\tif(j>0)\n\t\t\t\tfor(k in 0..3)\n\t\t\t\t\tdp[i][j][k] = max(dp[i][j][k],dp[i][j-1][k])\n\n\t\t\tfor(k in 3 downTo 1)\n\t\t\t\tdp[i][j][k] = max(dp[i][j][k],dp[i][j][k-1]+value[i][j])\n\t\t}\n\t}\n\tprintln(dp[r-1][c-1].max())\n}\n", "language": "Kotlin", "metadata": {"date": 1597544922, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02586.html", "problem_id": "p02586", "resource_group": "medium_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/Kotlin/s313399219.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s313399219", "user_id": "u059234158"}, "prompt_components": {"gold_output": "8\n", "input_to_evaluate": "import kotlin.math.*\n\nfun str() = readLine()!!\nfun int() = str().toInt()\nfun long() = str().toLong()\n\nfun read(d:String = \" \") = str().split(d)\nfun list(d:String = \" \",f:String.()->T) = read(d).map {f(it)}\nfun list() = list {toInt()}\n\nfun MutableList.removeLast() = this.removeAt(this.lastIndex)\n\nconst val mod = 1000000007L\n\nfun main() {\n\tabc000X()\n}\n\nfun abc000X() {\n\tval (r,c,k) = list()\n\tval value = Array(r) {LongArray(c) {0L}}\n\tfor(i in 1..k) {\n\t\tval (r,c,v) = list()\n\t\tvalue[r-1][c-1] = v.toLong()\n\t}\n\n\tval dp = Array(r) {Array(c) {LongArray(4) {0L}}}\n\n\tfor(i in 0 until r) {\n\t\tfor(j in 0 until c) {\n\t\t\tif(i>0)\n\t\t\t\tdp[i][j][0] = max(dp[i][j][0],dp[i-1][j][3])\n\t\t\tif(j>0)\n\t\t\t\tfor(k in 0..3)\n\t\t\t\t\tdp[i][j][k] = max(dp[i][j][k],dp[i][j-1][k])\n\n\t\t\tfor(k in 3 downTo 1)\n\t\t\t\tdp[i][j][k] = max(dp[i][j][k],dp[i][j][k-1]+value[i][j])\n\t\t}\n\t}\n\tprintln(dp[r-1][c-1].max())\n}\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 882, "cpu_time_ms": 2147, "memory_kb": 733332}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s633783401", "group_id": "codeNet:p02589", "input_text": "@file:Suppress(\"NOTHING_TO_INLINE\", \"EXPERIMENTAL_FEATURE_WARNING\", \"OVERRIDE_BY_INLINE\")\n//@file:OptIn(ExperimentalStdlibApi::class)\n\nimport java.io.PrintWriter\nimport kotlin.math.*\nimport kotlin.random.Random\nimport kotlin.collections.sort as _sort\nimport kotlin.collections.sortDescending as _sortDescending\nimport kotlin.io.println as iprintln\n\n/** @author Spheniscine */\nfun main() { _writer.solve(); _writer.flush() }\nfun PrintWriter.solve() {\n// val startTime = System.nanoTime()\n\n val numCases = 1//readInt()\n case@ for(case in 1..numCases) {\n// print(\"Case #$case: \")\n\n val n = readInt()\n val S = Array(n) { read() }\n\n val P = Array(n) { i ->\n val s = S[i]\n val res = Array(s.length) { BooleanArray(26) }\n for(j in s.indices) {\n if(j > 0) res[j-1].copyInto(res[j])\n res[j][s[j] - 'a'] = true\n }\n res\n }\n\n val conc = StringBuilder()\n val posInConc = IntArray(n)\n for(i in 0 until n) {\n posInConc[i] = conc.length\n conc.append(S[i]).append('$')\n }\n\n var (suff, lcp) = conc.suffixArrayAndLCP()\n suff = suff.copyOfRange(1, suff.size)\n lcp = lcp.copyOfRange(1, lcp.size)\n\n val id = IntArray(suff.size)\n val pos = IntArray(suff.size)\n val sufflen = IntArray(suff.size)\n\n for(i in suff.indices) {\n id[i] = posInConc.bsIndexOfLast { suff[i] >= it }\n pos[i] = suff[i] - posInConc[id[i]]\n sufflen[i] = S[id[i]].length - pos[i]\n }\n\n var start = 0\n var ans = 0L\n\n while(start < suff.size) {\n var end = start\n while(end < lcp.size && lcp[end] > sufflen[end]) end++\n\n val cat1 = IntList()\n val cat2 = IntList()\n\n for(i in start..end) {\n when {\n pos[i] == 1 -> cat1.add(i)\n pos[i] > 1 -> cat2.add(i)\n }\n }\n\n val cnt = IntArray(26)\n for(i in cat2) {\n val p = P[id[i]][pos[i]-1]\n for(j in 0 until 26) if(p[j]) cnt[j]++\n }\n\n for(i in cat1) {\n val c = S[id[i]][pos[i]-1]\n ans += cnt[c - 'a']\n }\n\n start = end + 1\n }\n\n println(ans)\n\n }\n\n// iprintln(\"Time: ${(System.nanoTime() - startTime) / 1000000} ms\")\n}\n\nclass IntList(initialCapacity: Int = 12) {\n private var _arr = IntArray(initialCapacity)\n private val capacity get() = _arr.size\n var size = 0\n private set\n inline val lastIndex get() = size - 1\n inline val indices get() = 0 until size\n\n constructor(copyFrom: IntArray): this(copyFrom.size) { copyFrom.copyInto(_arr); size = copyFrom.size }\n constructor(copyFrom: Collection): this(copyFrom.size) { _arr = copyFrom.toIntArray(); size = copyFrom.size }\n\n fun contentEquals(other: IntList): Boolean {\n return this === other || size == other.size && indices.all { this[it] == other[it] }\n }\n\n private fun grow(minCapacity: Int = 8) {\n val newCapacity = maxOf(minCapacity, capacity + (capacity shr 1))\n _arr = _arr.copyOf(newCapacity)\n }\n\n fun ensureCapacity(minCapacity: Int) { if(capacity < minCapacity) grow(minCapacity) }\n\n operator fun get(index: Int): Int {\n require(index in 0 until size)\n return _arr[index]\n }\n\n operator fun set(index: Int, value: Int) {\n require(index in 0 until size)\n _arr[index] = value\n }\n\n fun add(value: Int) {\n if(size == capacity) grow()\n _arr[size++] = value\n }\n\n fun addAll(list: IntList) {\n ensureCapacity(size + list.size)\n list._arr.copyInto(_arr, size, 0, list.size)\n size += list.size\n }\n\n fun add(index: Int, element: Int) {\n if(size == capacity) grow()\n _arr.copyInto(_arr, index + 1, index, size)\n size++\n set(index, element)\n }\n\n fun clear() { size = 0 }\n\n fun removeAt(index: Int): Int {\n val e = get(index)\n _arr.copyInto(_arr, index, index + 1, size)\n size--\n return e\n }\n\n operator fun iterator() = object: IntIterator() {\n private var pos = 0\n override fun hasNext() = pos < size\n override fun nextInt() = get(pos++)\n }\n\n inline fun isEmpty() = size == 0\n inline fun isNotEmpty() = size != 0\n\n fun pop() = _arr[--size]\n\n fun swap(i: Int, j: Int) { val t = this[i]; this[i] = this[j]; this[j] = t }\n fun reverse() {\n for(i in 0 until size / 2) swap(i, lastIndex - i)\n }\n\n fun shuffle(rnd: Random = random) = _shuffle(rnd, _arr::get, _arr::set, size)\n fun sort() { shuffle(); _arr._sort(0, size) }\n fun sortDescending() { sort(); reverse() }\n\n fun joinToString(separator: CharSequence) = if(size == 0) \"\" else let {\n buildString {\n append(it[0])\n for (i in 1 until size) {\n append(separator).append(it[i])\n }\n }\n }\n\n override fun toString() = \"[\" + joinToString(\", \") + \"]\"\n\n fun toIntArray() = _arr.copyOf(size)\n fun toList() = List(size, ::get)\n\n inline fun first() = get(0)\n inline fun last() = get(lastIndex)\n}\n\ninline fun IntList(size: Int, init: (Int) -> Int) = IntList(size).apply {\n for(i in 0 until size) { add(init(i)) }\n}\ninline fun IntArray.toIntList() = IntList(this)\ninline fun Collection.toIntList() = IntList(this)\ninline fun intListOf(vararg values: Int) = IntList(values)\n\nfun IntList.max() = (1 until size).fold(this[0]) { acc, i -> max(acc, this[i]) }\nfun IntList.min() = (1 until size).fold(this[0]) { acc, i -> min(acc, this[i]) }\nfun IntList.getOrNull(i: Int) = if(i in indices) get(i) else null\ninline fun IntList.count(predicate: (Int) -> Boolean) = indices.count { predicate(this[it]) }\nfun IntList.copyOf() = IntList(size, ::get)\n\n\ninline fun bsFirst(first: Int, last: Int, predicate: (Int) -> Boolean): Int {\n var low = first\n var high = last\n\n while (low <= high) {\n val mid = low.and(high) + low.xor(high).shr(1)\n if(predicate(mid)) high = mid - 1\n else low = mid + 1\n }\n return low\n}\ninline fun IntRange.bsFirst(predicate: (Int) -> Boolean) = bsFirst(first, last, predicate)\n\ninline fun bsLast(first: Int, last: Int, predicate: (Int) -> Boolean) = bsFirst(first, last) { !predicate(it) } - 1\ninline fun IntRange.bsLast(predicate: (Int) -> Boolean) = bsLast(first, last, predicate)\n\ninline fun IntArray.bsIndexOfFirst(predicate: (Int) -> Boolean) = bsFirst(0, lastIndex) { predicate(get(it)) }\ninline fun IntArray.bsFirst(predicate: (Int) -> Boolean) = get(bsIndexOfFirst(predicate))\ninline fun IntArray.bsFirstOrNull(predicate: (Int) -> Boolean) = getOrNull(bsIndexOfFirst(predicate))\ninline fun IntArray.bsIndexOfLast(predicate: (Int) -> Boolean) = bsLast(0, lastIndex) { predicate(get(it)) }\ninline fun IntArray.bsLast(predicate: (Int) -> Boolean) = get(bsIndexOfLast(predicate))\ninline fun IntArray.bsLastOrNull(predicate: (Int) -> Boolean) = getOrNull(bsIndexOfLast(predicate))\n\nfun CharSequence.suffixArrayAndLCP(): Pair {\n if(isEmpty()) return intArrayOf(0) to intArrayOf()\n\n val n = length\n\n var S = IntArray(n + 1)\n S[0] = n // for empty suffix ('$')\n\n // counting sort for ascii (max value assumed 127)\n val bkt = IntArray(129)\n bkt[0] = 1 // for empty suffix\n for(i in 0 until n) {\n bkt[this[i].toInt() + 1]++\n }\n for(i in 1 until bkt.lastIndex) {\n bkt[i] += bkt[i-1]\n }\n for(i in 0 until n) {\n S[bkt[this[i].toInt()]++] = i\n }\n\n // STL sort\n// val A = MutableList(n) { it }\n// A.sortBy { this[it] }\n// for(i in 0 until n) S[i+1] = A[i]\n\n var C = IntArray(n + 1)\n C[S[1]] = 1\n for(i in 2..n) {\n C[S[i]] = C[S[i-1]]\n if(this[S[i]] != this[S[i-1]]) C[S[i]]++\n }\n\n var k = 1\n while(k < n) {\n // counting sort\n @Suppress(\"NAME_SHADOWING\")\n val bkt = IntArray(n+2)\n for(i in 0..n) {\n bkt[C[i]+1]++\n }\n for(i in 2..n) {\n bkt[i] += bkt[i-1]\n }\n\n val Sk = IntArray(n+1)\n for(s in S) {\n val j = s - k modulo n+1\n Sk[bkt[C[j]]++] = j\n }\n\n val Ck = IntArray(n+1)\n for(i in 1..n) {\n val a = Sk[i]\n val b = Sk[i-1]\n Ck[a] = Ck[b]\n\n val cmp = C[a] != C[b] || C[(a + k) % (n+1)] != C[(b + k) % (n+1)]\n if(cmp) Ck[a]++\n }\n\n S = Sk\n C = Ck\n\n k = k shl 1\n }\n\n // LCP\n val L = IntArray(n)\n k = 0\n for(i in 0 until n) {\n val pi = C[i] // final C = S^-1\n val j = S[pi - 1]\n while(max(i, j) + k < n && this[i+k] == this[j+k]) k++\n L[pi-1] = k\n if(k > 0) k--\n }\n\n return S to L\n}\n\ninfix fun Int.modulo(mod: Int): Int = (this % mod).let { (it shr Int.SIZE_BITS - 1 and mod) + it }\n\n\n/** IO */\n//@JvmField val INPUT = File(\"input.txt\").inputStream()\n//@JvmField val OUTPUT = File(\"output.txt\").outputStream()\n@JvmField val INPUT = System.`in`\n@JvmField val OUTPUT = System.out\n\nconst val _BUFFER_SIZE = 1 shl 16\n@JvmField val _buffer = ByteArray(_BUFFER_SIZE)\n@JvmField var _bufferPt = 0\n@JvmField var _bytesRead = 0\n\ntailrec fun readChar(): Char {\n if(_bufferPt == _bytesRead) {\n _bufferPt = 0\n _bytesRead = INPUT.read(_buffer, 0, _BUFFER_SIZE)\n }\n return if(_bytesRead < 0) Char.MIN_VALUE\n else {\n val c = _buffer[_bufferPt++].toChar()\n if (c == '\\r') readChar()\n else c\n }\n}\n\nfun readLine(): String? {\n var c = readChar()\n return if(c == Char.MIN_VALUE) null\n else buildString {\n while(c != '\\n' && c != Char.MIN_VALUE) {\n append(c)\n c = readChar()\n }\n }\n}\nfun readLn() = readLine()!!\n\nfun read() = buildString {\n var c = readChar()\n while(c <= ' ') {\n if(c == Char.MIN_VALUE) return@buildString\n c = readChar()\n }\n do {\n append(c)\n c = readChar()\n } while(c > ' ')\n}\nfun readInt() = read().toInt()\nfun readDouble() = read().toDouble()\nfun readLong() = read().toLong()\nfun readStrings(n: Int) = List(n) { read() }\nfun readLines(n: Int) = List(n) { readLn() }\nfun readInts(n: Int) = List(n) { read().toInt() }\nfun readIntArray(n: Int) = IntArray(n) { read().toInt() }\nfun readDoubles(n: Int) = List(n) { read().toDouble() }\nfun readDoubleArray(n: Int) = DoubleArray(n) { read().toDouble() }\nfun readLongs(n: Int) = List(n) { read().toLong() }\nfun readLongArray(n: Int) = LongArray(n) { read().toLong() }\n\n@JvmField val _writer = PrintWriter(OUTPUT, false)\n\n/** shuffles and sort overrides to avoid quicksort attacks */\nprivate inline fun _shuffle(rnd: Random, get: (Int) -> T, set: (Int, T) -> Unit, size: Int) {\n // Fisher-Yates shuffle algorithm\n for (i in size - 1 downTo 1) {\n val j = rnd.nextInt(i + 1)\n val temp = get(i)\n set(i, get(j))\n set(j, temp)\n }\n}\n\n@JvmField var _random: Random? = null\nval random get() = _random ?: Random(0x594E215C123 * System.nanoTime()).also { _random = it }\n\nfun IntArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\nfun IntArray.sort() { shuffle(); _sort() }\nfun IntArray.sortDescending() { shuffle(); _sortDescending() }\n\nfun LongArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\nfun LongArray.sort() { shuffle(); _sort() }\nfun LongArray.sortDescending() { shuffle(); _sortDescending() }\n\nfun DoubleArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\nfun DoubleArray.sort() { shuffle(); _sort() }\nfun DoubleArray.sortDescending() { shuffle(); _sortDescending() }\n\nfun CharArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\ninline fun CharArray.sort() { _sort() }\ninline fun CharArray.sortDescending() { _sortDescending() }\n\ninline fun > Array.sort() = _sort()\ninline fun > Array.sortDescending() = _sortDescending()\ninline fun > MutableList.sort() = _sort()\ninline fun > MutableList.sortDescending() = _sortDescending()\n\nfun `please stop removing these imports IntelliJ`() { iprintln(max(1, 2)) }\n\n/** additional commons */\ninline fun Iterable.sumByLong(func: (T) -> Long) = fold(0L) { acc, t -> acc + func(t) }\ninline fun Sequence.sumByLong(func: (T) -> Long) = fold(0L) { acc, t -> acc + func(t) }\ninline fun Array.sumByLong(func: (T) -> Long) = fold(0L) { acc, t -> acc + func(t) }\nfun IntArray.sumLong() = fold(0L, Long::plus)\n", "language": "Kotlin", "metadata": {"date": 1597072601, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02589.html", "problem_id": "p02589", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02589/input.txt", "sample_output_relpath": "derived/input_output/data/p02589/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02589/Kotlin/s633783401.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s633783401", "user_id": "u596111103"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "@file:Suppress(\"NOTHING_TO_INLINE\", \"EXPERIMENTAL_FEATURE_WARNING\", \"OVERRIDE_BY_INLINE\")\n//@file:OptIn(ExperimentalStdlibApi::class)\n\nimport java.io.PrintWriter\nimport kotlin.math.*\nimport kotlin.random.Random\nimport kotlin.collections.sort as _sort\nimport kotlin.collections.sortDescending as _sortDescending\nimport kotlin.io.println as iprintln\n\n/** @author Spheniscine */\nfun main() { _writer.solve(); _writer.flush() }\nfun PrintWriter.solve() {\n// val startTime = System.nanoTime()\n\n val numCases = 1//readInt()\n case@ for(case in 1..numCases) {\n// print(\"Case #$case: \")\n\n val n = readInt()\n val S = Array(n) { read() }\n\n val P = Array(n) { i ->\n val s = S[i]\n val res = Array(s.length) { BooleanArray(26) }\n for(j in s.indices) {\n if(j > 0) res[j-1].copyInto(res[j])\n res[j][s[j] - 'a'] = true\n }\n res\n }\n\n val conc = StringBuilder()\n val posInConc = IntArray(n)\n for(i in 0 until n) {\n posInConc[i] = conc.length\n conc.append(S[i]).append('$')\n }\n\n var (suff, lcp) = conc.suffixArrayAndLCP()\n suff = suff.copyOfRange(1, suff.size)\n lcp = lcp.copyOfRange(1, lcp.size)\n\n val id = IntArray(suff.size)\n val pos = IntArray(suff.size)\n val sufflen = IntArray(suff.size)\n\n for(i in suff.indices) {\n id[i] = posInConc.bsIndexOfLast { suff[i] >= it }\n pos[i] = suff[i] - posInConc[id[i]]\n sufflen[i] = S[id[i]].length - pos[i]\n }\n\n var start = 0\n var ans = 0L\n\n while(start < suff.size) {\n var end = start\n while(end < lcp.size && lcp[end] > sufflen[end]) end++\n\n val cat1 = IntList()\n val cat2 = IntList()\n\n for(i in start..end) {\n when {\n pos[i] == 1 -> cat1.add(i)\n pos[i] > 1 -> cat2.add(i)\n }\n }\n\n val cnt = IntArray(26)\n for(i in cat2) {\n val p = P[id[i]][pos[i]-1]\n for(j in 0 until 26) if(p[j]) cnt[j]++\n }\n\n for(i in cat1) {\n val c = S[id[i]][pos[i]-1]\n ans += cnt[c - 'a']\n }\n\n start = end + 1\n }\n\n println(ans)\n\n }\n\n// iprintln(\"Time: ${(System.nanoTime() - startTime) / 1000000} ms\")\n}\n\nclass IntList(initialCapacity: Int = 12) {\n private var _arr = IntArray(initialCapacity)\n private val capacity get() = _arr.size\n var size = 0\n private set\n inline val lastIndex get() = size - 1\n inline val indices get() = 0 until size\n\n constructor(copyFrom: IntArray): this(copyFrom.size) { copyFrom.copyInto(_arr); size = copyFrom.size }\n constructor(copyFrom: Collection): this(copyFrom.size) { _arr = copyFrom.toIntArray(); size = copyFrom.size }\n\n fun contentEquals(other: IntList): Boolean {\n return this === other || size == other.size && indices.all { this[it] == other[it] }\n }\n\n private fun grow(minCapacity: Int = 8) {\n val newCapacity = maxOf(minCapacity, capacity + (capacity shr 1))\n _arr = _arr.copyOf(newCapacity)\n }\n\n fun ensureCapacity(minCapacity: Int) { if(capacity < minCapacity) grow(minCapacity) }\n\n operator fun get(index: Int): Int {\n require(index in 0 until size)\n return _arr[index]\n }\n\n operator fun set(index: Int, value: Int) {\n require(index in 0 until size)\n _arr[index] = value\n }\n\n fun add(value: Int) {\n if(size == capacity) grow()\n _arr[size++] = value\n }\n\n fun addAll(list: IntList) {\n ensureCapacity(size + list.size)\n list._arr.copyInto(_arr, size, 0, list.size)\n size += list.size\n }\n\n fun add(index: Int, element: Int) {\n if(size == capacity) grow()\n _arr.copyInto(_arr, index + 1, index, size)\n size++\n set(index, element)\n }\n\n fun clear() { size = 0 }\n\n fun removeAt(index: Int): Int {\n val e = get(index)\n _arr.copyInto(_arr, index, index + 1, size)\n size--\n return e\n }\n\n operator fun iterator() = object: IntIterator() {\n private var pos = 0\n override fun hasNext() = pos < size\n override fun nextInt() = get(pos++)\n }\n\n inline fun isEmpty() = size == 0\n inline fun isNotEmpty() = size != 0\n\n fun pop() = _arr[--size]\n\n fun swap(i: Int, j: Int) { val t = this[i]; this[i] = this[j]; this[j] = t }\n fun reverse() {\n for(i in 0 until size / 2) swap(i, lastIndex - i)\n }\n\n fun shuffle(rnd: Random = random) = _shuffle(rnd, _arr::get, _arr::set, size)\n fun sort() { shuffle(); _arr._sort(0, size) }\n fun sortDescending() { sort(); reverse() }\n\n fun joinToString(separator: CharSequence) = if(size == 0) \"\" else let {\n buildString {\n append(it[0])\n for (i in 1 until size) {\n append(separator).append(it[i])\n }\n }\n }\n\n override fun toString() = \"[\" + joinToString(\", \") + \"]\"\n\n fun toIntArray() = _arr.copyOf(size)\n fun toList() = List(size, ::get)\n\n inline fun first() = get(0)\n inline fun last() = get(lastIndex)\n}\n\ninline fun IntList(size: Int, init: (Int) -> Int) = IntList(size).apply {\n for(i in 0 until size) { add(init(i)) }\n}\ninline fun IntArray.toIntList() = IntList(this)\ninline fun Collection.toIntList() = IntList(this)\ninline fun intListOf(vararg values: Int) = IntList(values)\n\nfun IntList.max() = (1 until size).fold(this[0]) { acc, i -> max(acc, this[i]) }\nfun IntList.min() = (1 until size).fold(this[0]) { acc, i -> min(acc, this[i]) }\nfun IntList.getOrNull(i: Int) = if(i in indices) get(i) else null\ninline fun IntList.count(predicate: (Int) -> Boolean) = indices.count { predicate(this[it]) }\nfun IntList.copyOf() = IntList(size, ::get)\n\n\ninline fun bsFirst(first: Int, last: Int, predicate: (Int) -> Boolean): Int {\n var low = first\n var high = last\n\n while (low <= high) {\n val mid = low.and(high) + low.xor(high).shr(1)\n if(predicate(mid)) high = mid - 1\n else low = mid + 1\n }\n return low\n}\ninline fun IntRange.bsFirst(predicate: (Int) -> Boolean) = bsFirst(first, last, predicate)\n\ninline fun bsLast(first: Int, last: Int, predicate: (Int) -> Boolean) = bsFirst(first, last) { !predicate(it) } - 1\ninline fun IntRange.bsLast(predicate: (Int) -> Boolean) = bsLast(first, last, predicate)\n\ninline fun IntArray.bsIndexOfFirst(predicate: (Int) -> Boolean) = bsFirst(0, lastIndex) { predicate(get(it)) }\ninline fun IntArray.bsFirst(predicate: (Int) -> Boolean) = get(bsIndexOfFirst(predicate))\ninline fun IntArray.bsFirstOrNull(predicate: (Int) -> Boolean) = getOrNull(bsIndexOfFirst(predicate))\ninline fun IntArray.bsIndexOfLast(predicate: (Int) -> Boolean) = bsLast(0, lastIndex) { predicate(get(it)) }\ninline fun IntArray.bsLast(predicate: (Int) -> Boolean) = get(bsIndexOfLast(predicate))\ninline fun IntArray.bsLastOrNull(predicate: (Int) -> Boolean) = getOrNull(bsIndexOfLast(predicate))\n\nfun CharSequence.suffixArrayAndLCP(): Pair {\n if(isEmpty()) return intArrayOf(0) to intArrayOf()\n\n val n = length\n\n var S = IntArray(n + 1)\n S[0] = n // for empty suffix ('$')\n\n // counting sort for ascii (max value assumed 127)\n val bkt = IntArray(129)\n bkt[0] = 1 // for empty suffix\n for(i in 0 until n) {\n bkt[this[i].toInt() + 1]++\n }\n for(i in 1 until bkt.lastIndex) {\n bkt[i] += bkt[i-1]\n }\n for(i in 0 until n) {\n S[bkt[this[i].toInt()]++] = i\n }\n\n // STL sort\n// val A = MutableList(n) { it }\n// A.sortBy { this[it] }\n// for(i in 0 until n) S[i+1] = A[i]\n\n var C = IntArray(n + 1)\n C[S[1]] = 1\n for(i in 2..n) {\n C[S[i]] = C[S[i-1]]\n if(this[S[i]] != this[S[i-1]]) C[S[i]]++\n }\n\n var k = 1\n while(k < n) {\n // counting sort\n @Suppress(\"NAME_SHADOWING\")\n val bkt = IntArray(n+2)\n for(i in 0..n) {\n bkt[C[i]+1]++\n }\n for(i in 2..n) {\n bkt[i] += bkt[i-1]\n }\n\n val Sk = IntArray(n+1)\n for(s in S) {\n val j = s - k modulo n+1\n Sk[bkt[C[j]]++] = j\n }\n\n val Ck = IntArray(n+1)\n for(i in 1..n) {\n val a = Sk[i]\n val b = Sk[i-1]\n Ck[a] = Ck[b]\n\n val cmp = C[a] != C[b] || C[(a + k) % (n+1)] != C[(b + k) % (n+1)]\n if(cmp) Ck[a]++\n }\n\n S = Sk\n C = Ck\n\n k = k shl 1\n }\n\n // LCP\n val L = IntArray(n)\n k = 0\n for(i in 0 until n) {\n val pi = C[i] // final C = S^-1\n val j = S[pi - 1]\n while(max(i, j) + k < n && this[i+k] == this[j+k]) k++\n L[pi-1] = k\n if(k > 0) k--\n }\n\n return S to L\n}\n\ninfix fun Int.modulo(mod: Int): Int = (this % mod).let { (it shr Int.SIZE_BITS - 1 and mod) + it }\n\n\n/** IO */\n//@JvmField val INPUT = File(\"input.txt\").inputStream()\n//@JvmField val OUTPUT = File(\"output.txt\").outputStream()\n@JvmField val INPUT = System.`in`\n@JvmField val OUTPUT = System.out\n\nconst val _BUFFER_SIZE = 1 shl 16\n@JvmField val _buffer = ByteArray(_BUFFER_SIZE)\n@JvmField var _bufferPt = 0\n@JvmField var _bytesRead = 0\n\ntailrec fun readChar(): Char {\n if(_bufferPt == _bytesRead) {\n _bufferPt = 0\n _bytesRead = INPUT.read(_buffer, 0, _BUFFER_SIZE)\n }\n return if(_bytesRead < 0) Char.MIN_VALUE\n else {\n val c = _buffer[_bufferPt++].toChar()\n if (c == '\\r') readChar()\n else c\n }\n}\n\nfun readLine(): String? {\n var c = readChar()\n return if(c == Char.MIN_VALUE) null\n else buildString {\n while(c != '\\n' && c != Char.MIN_VALUE) {\n append(c)\n c = readChar()\n }\n }\n}\nfun readLn() = readLine()!!\n\nfun read() = buildString {\n var c = readChar()\n while(c <= ' ') {\n if(c == Char.MIN_VALUE) return@buildString\n c = readChar()\n }\n do {\n append(c)\n c = readChar()\n } while(c > ' ')\n}\nfun readInt() = read().toInt()\nfun readDouble() = read().toDouble()\nfun readLong() = read().toLong()\nfun readStrings(n: Int) = List(n) { read() }\nfun readLines(n: Int) = List(n) { readLn() }\nfun readInts(n: Int) = List(n) { read().toInt() }\nfun readIntArray(n: Int) = IntArray(n) { read().toInt() }\nfun readDoubles(n: Int) = List(n) { read().toDouble() }\nfun readDoubleArray(n: Int) = DoubleArray(n) { read().toDouble() }\nfun readLongs(n: Int) = List(n) { read().toLong() }\nfun readLongArray(n: Int) = LongArray(n) { read().toLong() }\n\n@JvmField val _writer = PrintWriter(OUTPUT, false)\n\n/** shuffles and sort overrides to avoid quicksort attacks */\nprivate inline fun _shuffle(rnd: Random, get: (Int) -> T, set: (Int, T) -> Unit, size: Int) {\n // Fisher-Yates shuffle algorithm\n for (i in size - 1 downTo 1) {\n val j = rnd.nextInt(i + 1)\n val temp = get(i)\n set(i, get(j))\n set(j, temp)\n }\n}\n\n@JvmField var _random: Random? = null\nval random get() = _random ?: Random(0x594E215C123 * System.nanoTime()).also { _random = it }\n\nfun IntArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\nfun IntArray.sort() { shuffle(); _sort() }\nfun IntArray.sortDescending() { shuffle(); _sortDescending() }\n\nfun LongArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\nfun LongArray.sort() { shuffle(); _sort() }\nfun LongArray.sortDescending() { shuffle(); _sortDescending() }\n\nfun DoubleArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\nfun DoubleArray.sort() { shuffle(); _sort() }\nfun DoubleArray.sortDescending() { shuffle(); _sortDescending() }\n\nfun CharArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\ninline fun CharArray.sort() { _sort() }\ninline fun CharArray.sortDescending() { _sortDescending() }\n\ninline fun > Array.sort() = _sort()\ninline fun > Array.sortDescending() = _sortDescending()\ninline fun > MutableList.sort() = _sort()\ninline fun > MutableList.sortDescending() = _sortDescending()\n\nfun `please stop removing these imports IntelliJ`() { iprintln(max(1, 2)) }\n\n/** additional commons */\ninline fun Iterable.sumByLong(func: (T) -> Long) = fold(0L) { acc, t -> acc + func(t) }\ninline fun Sequence.sumByLong(func: (T) -> Long) = fold(0L) { acc, t -> acc + func(t) }\ninline fun Array.sumByLong(func: (T) -> Long) = fold(0L) { acc, t -> acc + func(t) }\nfun IntArray.sumLong() = fold(0L, Long::plus)\n", "problem_context": "Score : 700 points\n\nProblem Statement\n\nLimak can repeatedly remove one of the first two characters of a string,\nfor example abcxyx \\rightarrow acxyx \\rightarrow cxyx \\rightarrow cyx.\n\nYou are given N different strings S_1, S_2, \\ldots, S_N.\nAmong N \\cdot (N-1) / 2 pairs (S_i, S_j),\nin how many pairs could Limak obtain one string from the other?\n\nConstraints\n\n2 \\leq N \\leq 200\\,000\n\nS_i consists of lowercase English letters a-z.\n\nS_i \\neq S_j\n\n1 \\leq |S_i|\n\n|S_1| + |S_2| + \\ldots + |S_N| \\leq 10^6\n\nInput\n\nInput is given from Standard Input in the following format.\n\nN\nS_1\nS_2\n\\vdots\nS_N\n\nOutput\n\nPrint the number of unordered pairs (S_i, S_j)\nwhere i \\neq j and Limak can obtain one string from the other.\n\nSample Input 1\n\n3\nabcxyx\ncyx\nabc\n\nSample Output 1\n\n1\n\nThe only good pair is (abcxyx, cyx).\n\nSample Input 2\n\n6\nb\na\nabc\nc\nd\nab\n\nSample Output 2\n\n5\n\nThere are five good pairs: (b, abc), (a, abc), (abc, c), (b, ab), (a, ab).", "sample_input": "3\nabcxyx\ncyx\nabc\n"}, "reference_outputs": ["1\n"], "source_document_id": "p02589", "source_text": "Score : 700 points\n\nProblem Statement\n\nLimak can repeatedly remove one of the first two characters of a string,\nfor example abcxyx \\rightarrow acxyx \\rightarrow cxyx \\rightarrow cyx.\n\nYou are given N different strings S_1, S_2, \\ldots, S_N.\nAmong N \\cdot (N-1) / 2 pairs (S_i, S_j),\nin how many pairs could Limak obtain one string from the other?\n\nConstraints\n\n2 \\leq N \\leq 200\\,000\n\nS_i consists of lowercase English letters a-z.\n\nS_i \\neq S_j\n\n1 \\leq |S_i|\n\n|S_1| + |S_2| + \\ldots + |S_N| \\leq 10^6\n\nInput\n\nInput is given from Standard Input in the following format.\n\nN\nS_1\nS_2\n\\vdots\nS_N\n\nOutput\n\nPrint the number of unordered pairs (S_i, S_j)\nwhere i \\neq j and Limak can obtain one string from the other.\n\nSample Input 1\n\n3\nabcxyx\ncyx\nabc\n\nSample Output 1\n\n1\n\nThe only good pair is (abcxyx, cyx).\n\nSample Input 2\n\n6\nb\na\nabc\nc\nd\nab\n\nSample Output 2\n\n5\n\nThere are five good pairs: (b, abc), (a, abc), (abc, c), (b, ab), (a, ab).", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 12689, "cpu_time_ms": 3251, "memory_kb": 237352}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s208767216", "group_id": "codeNet:p02594", "input_text": "import java.util.*\nimport kotlin.math.abs\n\nfun main() {\n a()\n}\n\nfun a() {\n val x = readLong()\n if (x >= 30) {\n \"Yes\"\n } else {\n \"No\"\n }.let { println(it) }\n}\n\nfun readLong() = readLine()!!.toLong()\nfun readLongList() = readLine()!!.split(\" \").map { it.toLong() }\n\nfun Long.bitEach(action: (Int) -> Unit) {\n (0 until Long.SIZE_BITS).forEach { action(((this shr it) and 1).toInt()) }\n}\n\nfun Long.bitFilter(bit: Int) = (0 until Long.SIZE_BITS).filter { ((this shr it) and 1) == 1L }\n\nfun pairs(first: Iterable, second: Iterable) = first.flatMap { t1 -> second.map { t2 -> t1 to t2 } }\n\nfun Long.print() {\n println(this)\n}", "language": "Kotlin", "metadata": {"date": 1596416662, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02594.html", "problem_id": "p02594", "resource_group": "medium_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/Kotlin/s208767216.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s208767216", "user_id": "u915119935"}, "prompt_components": {"gold_output": "No\n", "input_to_evaluate": "import java.util.*\nimport kotlin.math.abs\n\nfun main() {\n a()\n}\n\nfun a() {\n val x = readLong()\n if (x >= 30) {\n \"Yes\"\n } else {\n \"No\"\n }.let { println(it) }\n}\n\nfun readLong() = readLine()!!.toLong()\nfun readLongList() = readLine()!!.split(\" \").map { it.toLong() }\n\nfun Long.bitEach(action: (Int) -> Unit) {\n (0 until Long.SIZE_BITS).forEach { action(((this shr it) and 1).toInt()) }\n}\n\nfun Long.bitFilter(bit: Int) = (0 until Long.SIZE_BITS).filter { ((this shr it) and 1) == 1L }\n\nfun pairs(first: Iterable, second: Iterable) = first.flatMap { t1 -> second.map { t2 -> t1 to t2 } }\n\nfun Long.print() {\n println(this)\n}", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 113, "memory_kb": 34472}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s755106149", "group_id": "codeNet:p02594", "input_text": "fun main() {\n println(if (readInt() >= 30) \"Yes\" else \"No\")\n}\n\n// Input Reader\nprivate fun readLn() = readLine()!!\n\nprivate fun readStrings() = readLn().trim().split(\" \")\nprivate fun readInt() = readLn().toInt()\nprivate fun readInts() = readStrings().map { it.toInt() }\n", "language": "Kotlin", "metadata": {"date": 1596416456, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02594.html", "problem_id": "p02594", "resource_group": "medium_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/Kotlin/s755106149.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s755106149", "user_id": "u984465701"}, "prompt_components": {"gold_output": "No\n", "input_to_evaluate": "fun main() {\n println(if (readInt() >= 30) \"Yes\" else \"No\")\n}\n\n// Input Reader\nprivate fun readLn() = readLine()!!\n\nprivate fun readStrings() = readLn().trim().split(\" \")\nprivate fun readInt() = readLn().toInt()\nprivate fun readInts() = readStrings().map { it.toInt() }\n", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 120, "memory_kb": 34564}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s851987009", "group_id": "codeNet:p02595", "input_text": "import kotlin.math.sqrt\nfun main() {\n // 文字列\n// var n = readLine()!!.toInt()\n// val x: String = readLine()!!\n // 数値\n// val int =readLine()!!.toInt()\n // 行\n// val list = readLine()!!.split(\" \").map (String::toInt )\n val (n,d) = readLine()!!.split(\" \").map(String::toInt)\n val xys = List(n) {\n readLine()!!.split(\" \").map(String::toLong)\n }\n var sum=0\n for (xy in xys){\n val moto= sqrt((xy[0]*xy[0]+xy[1]*xy[1]).toDouble())\n if (d>= moto){\n\n sum++\n }\n }\n print(sum)\n// var k = readLine()!!.toInt()\n}", "language": "Kotlin", "metadata": {"date": 1596419072, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02595.html", "problem_id": "p02595", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02595/input.txt", "sample_output_relpath": "derived/input_output/data/p02595/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02595/Kotlin/s851987009.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s851987009", "user_id": "u826331398"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "import kotlin.math.sqrt\nfun main() {\n // 文字列\n// var n = readLine()!!.toInt()\n// val x: String = readLine()!!\n // 数値\n// val int =readLine()!!.toInt()\n // 行\n// val list = readLine()!!.split(\" \").map (String::toInt )\n val (n,d) = readLine()!!.split(\" \").map(String::toInt)\n val xys = List(n) {\n readLine()!!.split(\" \").map(String::toLong)\n }\n var sum=0\n for (xy in xys){\n val moto= sqrt((xy[0]*xy[0]+xy[1]*xy[1]).toDouble())\n if (d>= moto){\n\n sum++\n }\n }\n print(sum)\n// var k = readLine()!!.toInt()\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nWe have N points in the two-dimensional plane. The coordinates of the i-th point are (X_i,Y_i).\n\nAmong them, we are looking for the points such that the distance from the origin is at most D. How many such points are there?\n\nWe remind you that the distance between the origin and the point (p, q) can be represented as \\sqrt{p^2+q^2}.\n\nConstraints\n\n1 \\leq N \\leq 2\\times 10^5\n\n0 \\leq D \\leq 2\\times 10^5\n\n|X_i|,|Y_i| \\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 D\nX_1 Y_1\n\\vdots\nX_N Y_N\n\nOutput\n\nPrint an integer representing the number of points such that the distance from the origin is at most D.\n\nSample Input 1\n\n4 5\n0 5\n-2 4\n3 4\n4 -4\n\nSample Output 1\n\n3\n\nThe distance between the origin and each of the given points is as follows:\n\n\\sqrt{0^2+5^2}=5\n\n\\sqrt{(-2)^2+4^2}=4.472\\ldots\n\n\\sqrt{3^2+4^2}=5\n\n\\sqrt{4^2+(-4)^2}=5.656\\ldots\n\nThus, we have three points such that the distance from the origin is at most 5.\n\nSample Input 2\n\n12 3\n1 1\n1 1\n1 1\n1 1\n1 2\n1 3\n2 1\n2 2\n2 3\n3 1\n3 2\n3 3\n\nSample Output 2\n\n7\n\nMultiple points may exist at the same coordinates.\n\nSample Input 3\n\n20 100000\n14309 -32939\n-56855 100340\n151364 25430\n103789 -113141\n147404 -136977\n-37006 -30929\n188810 -49557\n13419 70401\n-88280 165170\n-196399 137941\n-176527 -61904\n46659 115261\n-153551 114185\n98784 -6820\n94111 -86268\n-30401 61477\n-55056 7872\n5901 -163796\n138819 -185986\n-69848 -96669\n\nSample Output 3\n\n6", "sample_input": "4 5\n0 5\n-2 4\n3 4\n4 -4\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02595", "source_text": "Score : 200 points\n\nProblem Statement\n\nWe have N points in the two-dimensional plane. The coordinates of the i-th point are (X_i,Y_i).\n\nAmong them, we are looking for the points such that the distance from the origin is at most D. How many such points are there?\n\nWe remind you that the distance between the origin and the point (p, q) can be represented as \\sqrt{p^2+q^2}.\n\nConstraints\n\n1 \\leq N \\leq 2\\times 10^5\n\n0 \\leq D \\leq 2\\times 10^5\n\n|X_i|,|Y_i| \\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 D\nX_1 Y_1\n\\vdots\nX_N Y_N\n\nOutput\n\nPrint an integer representing the number of points such that the distance from the origin is at most D.\n\nSample Input 1\n\n4 5\n0 5\n-2 4\n3 4\n4 -4\n\nSample Output 1\n\n3\n\nThe distance between the origin and each of the given points is as follows:\n\n\\sqrt{0^2+5^2}=5\n\n\\sqrt{(-2)^2+4^2}=4.472\\ldots\n\n\\sqrt{3^2+4^2}=5\n\n\\sqrt{4^2+(-4)^2}=5.656\\ldots\n\nThus, we have three points such that the distance from the origin is at most 5.\n\nSample Input 2\n\n12 3\n1 1\n1 1\n1 1\n1 1\n1 2\n1 3\n2 1\n2 2\n2 3\n3 1\n3 2\n3 3\n\nSample Output 2\n\n7\n\nMultiple points may exist at the same coordinates.\n\nSample Input 3\n\n20 100000\n14309 -32939\n-56855 100340\n151364 25430\n103789 -113141\n147404 -136977\n-37006 -30929\n188810 -49557\n13419 70401\n-88280 165170\n-196399 137941\n-176527 -61904\n46659 115261\n-153551 114185\n98784 -6820\n94111 -86268\n-30401 61477\n-55056 7872\n5901 -163796\n138819 -185986\n-69848 -96669\n\nSample Output 3\n\n6", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 593, "cpu_time_ms": 753, "memory_kb": 83968}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s207082295", "group_id": "codeNet:p02595", "input_text": "fun main() {\n val (N, D) = readLongs()\n var cnt = 0\n repeat(N.toInt()) {\n val (X, Y) = readLongs()\n if (X * X + Y * Y <= D * D) cnt++\n }\n println(cnt)\n}\n\nfun readString() = readLine()!!\nfun readStrings() = readString().split(\" \")\nfun readInt() = readString().toInt()\nfun readLong() = readString().toLong()\nfun readInts() = readStrings().map { it.toInt() }\nfun readLongs() = readStrings().map { it.toLong() }\n", "language": "Kotlin", "metadata": {"date": 1596416637, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02595.html", "problem_id": "p02595", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02595/input.txt", "sample_output_relpath": "derived/input_output/data/p02595/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02595/Kotlin/s207082295.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s207082295", "user_id": "u979004569"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "fun main() {\n val (N, D) = readLongs()\n var cnt = 0\n repeat(N.toInt()) {\n val (X, Y) = readLongs()\n if (X * X + Y * Y <= D * D) cnt++\n }\n println(cnt)\n}\n\nfun readString() = readLine()!!\nfun readStrings() = readString().split(\" \")\nfun readInt() = readString().toInt()\nfun readLong() = readString().toLong()\nfun readInts() = readStrings().map { it.toInt() }\nfun readLongs() = readStrings().map { it.toLong() }\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nWe have N points in the two-dimensional plane. The coordinates of the i-th point are (X_i,Y_i).\n\nAmong them, we are looking for the points such that the distance from the origin is at most D. How many such points are there?\n\nWe remind you that the distance between the origin and the point (p, q) can be represented as \\sqrt{p^2+q^2}.\n\nConstraints\n\n1 \\leq N \\leq 2\\times 10^5\n\n0 \\leq D \\leq 2\\times 10^5\n\n|X_i|,|Y_i| \\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 D\nX_1 Y_1\n\\vdots\nX_N Y_N\n\nOutput\n\nPrint an integer representing the number of points such that the distance from the origin is at most D.\n\nSample Input 1\n\n4 5\n0 5\n-2 4\n3 4\n4 -4\n\nSample Output 1\n\n3\n\nThe distance between the origin and each of the given points is as follows:\n\n\\sqrt{0^2+5^2}=5\n\n\\sqrt{(-2)^2+4^2}=4.472\\ldots\n\n\\sqrt{3^2+4^2}=5\n\n\\sqrt{4^2+(-4)^2}=5.656\\ldots\n\nThus, we have three points such that the distance from the origin is at most 5.\n\nSample Input 2\n\n12 3\n1 1\n1 1\n1 1\n1 1\n1 2\n1 3\n2 1\n2 2\n2 3\n3 1\n3 2\n3 3\n\nSample Output 2\n\n7\n\nMultiple points may exist at the same coordinates.\n\nSample Input 3\n\n20 100000\n14309 -32939\n-56855 100340\n151364 25430\n103789 -113141\n147404 -136977\n-37006 -30929\n188810 -49557\n13419 70401\n-88280 165170\n-196399 137941\n-176527 -61904\n46659 115261\n-153551 114185\n98784 -6820\n94111 -86268\n-30401 61477\n-55056 7872\n5901 -163796\n138819 -185986\n-69848 -96669\n\nSample Output 3\n\n6", "sample_input": "4 5\n0 5\n-2 4\n3 4\n4 -4\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02595", "source_text": "Score : 200 points\n\nProblem Statement\n\nWe have N points in the two-dimensional plane. The coordinates of the i-th point are (X_i,Y_i).\n\nAmong them, we are looking for the points such that the distance from the origin is at most D. How many such points are there?\n\nWe remind you that the distance between the origin and the point (p, q) can be represented as \\sqrt{p^2+q^2}.\n\nConstraints\n\n1 \\leq N \\leq 2\\times 10^5\n\n0 \\leq D \\leq 2\\times 10^5\n\n|X_i|,|Y_i| \\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 D\nX_1 Y_1\n\\vdots\nX_N Y_N\n\nOutput\n\nPrint an integer representing the number of points such that the distance from the origin is at most D.\n\nSample Input 1\n\n4 5\n0 5\n-2 4\n3 4\n4 -4\n\nSample Output 1\n\n3\n\nThe distance between the origin and each of the given points is as follows:\n\n\\sqrt{0^2+5^2}=5\n\n\\sqrt{(-2)^2+4^2}=4.472\\ldots\n\n\\sqrt{3^2+4^2}=5\n\n\\sqrt{4^2+(-4)^2}=5.656\\ldots\n\nThus, we have three points such that the distance from the origin is at most 5.\n\nSample Input 2\n\n12 3\n1 1\n1 1\n1 1\n1 1\n1 2\n1 3\n2 1\n2 2\n2 3\n3 1\n3 2\n3 3\n\nSample Output 2\n\n7\n\nMultiple points may exist at the same coordinates.\n\nSample Input 3\n\n20 100000\n14309 -32939\n-56855 100340\n151364 25430\n103789 -113141\n147404 -136977\n-37006 -30929\n188810 -49557\n13419 70401\n-88280 165170\n-196399 137941\n-176527 -61904\n46659 115261\n-153551 114185\n98784 -6820\n94111 -86268\n-30401 61477\n-55056 7872\n5901 -163796\n138819 -185986\n-69848 -96669\n\nSample Output 3\n\n6", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 634, "memory_kb": 64220}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s162739920", "group_id": "codeNet:p02597", "input_text": "import kotlin.math.*\nimport java.util.*\n\nconst val MOD = 1_000_000_007L\n\nfun readI() = readLine()!!.toInt()\nfun readL() = readLine()!!.toLong()\nfun readD() = readLine()!!.toDouble()\nfun readIs() = readLine()!!.split(' ').map(String::toInt)\nfun readLs() = readLine()!!.split(' ').map(String::toLong)\nfun readDs() = readLine()!!.split(' ').map(String::toDouble)\n\ndata class Seq(val c: Char, var n: Int)\n\nfun finish(seq: List, start: Int, end: Int): Boolean {\n return end - start == 1 && (\n (seq[start].c == 'R' && seq[end].c == 'W') ||\n (seq[start].c == 'R' && seq[end].c == 'R') ||\n (seq[start].c == 'W' && seq[end].c == 'W')\n )\n}\n\nfun main(args: Array) {\n val n = readI()\n val s = readLine()!!\n val list = mutableListOf()\n var i = 0\n while (i < n) {\n val j = i\n while (i + 1 < n && s[i] == s[i + 1]) i++\n list += Seq(s[j], i - j + 1)\n i++\n }\n var ans = 0\n var start = 0\n var end = list.size - 1\n do {\n while (start < end && list[start].c == 'R') start++\n while (start < end && list[end].c == 'W') end--\n if (end <= start) break\n\n val a = list[start]\n val b = list[end]\n if (a.n == b.n) {\n ans += a.n\n start++\n end--\n } else if (a.n < b.n) {\n ans += a.n\n start++\n b.n -= a.n\n } else {\n ans += b.n\n end--\n a.n -= b.n\n }\n } while (!finish(list, start, end))\n println(ans)\n}\n", "language": "Kotlin", "metadata": {"date": 1596422664, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02597.html", "problem_id": "p02597", "resource_group": "medium_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/Kotlin/s162739920.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s162739920", "user_id": "u051841332"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import kotlin.math.*\nimport java.util.*\n\nconst val MOD = 1_000_000_007L\n\nfun readI() = readLine()!!.toInt()\nfun readL() = readLine()!!.toLong()\nfun readD() = readLine()!!.toDouble()\nfun readIs() = readLine()!!.split(' ').map(String::toInt)\nfun readLs() = readLine()!!.split(' ').map(String::toLong)\nfun readDs() = readLine()!!.split(' ').map(String::toDouble)\n\ndata class Seq(val c: Char, var n: Int)\n\nfun finish(seq: List, start: Int, end: Int): Boolean {\n return end - start == 1 && (\n (seq[start].c == 'R' && seq[end].c == 'W') ||\n (seq[start].c == 'R' && seq[end].c == 'R') ||\n (seq[start].c == 'W' && seq[end].c == 'W')\n )\n}\n\nfun main(args: Array) {\n val n = readI()\n val s = readLine()!!\n val list = mutableListOf()\n var i = 0\n while (i < n) {\n val j = i\n while (i + 1 < n && s[i] == s[i + 1]) i++\n list += Seq(s[j], i - j + 1)\n i++\n }\n var ans = 0\n var start = 0\n var end = list.size - 1\n do {\n while (start < end && list[start].c == 'R') start++\n while (start < end && list[end].c == 'W') end--\n if (end <= start) break\n\n val a = list[start]\n val b = list[end]\n if (a.n == b.n) {\n ans += a.n\n start++\n end--\n } else if (a.n < b.n) {\n ans += a.n\n start++\n b.n -= a.n\n } else {\n ans += b.n\n end--\n a.n -= b.n\n }\n } while (!finish(list, start, end))\n println(ans)\n}\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1396, "cpu_time_ms": 219, "memory_kb": 43088}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s983828292", "group_id": "codeNet:p02597", "input_text": "import java.io.BufferedReader\nimport java.io.InputStreamReader\nimport java.io.PrintWriter\nimport kotlin.math.max\nimport kotlin.math.min\n\nval br = BufferedReader(InputStreamReader(System.`in`))\nval out = PrintWriter(System.out)\n\nfun main() {\n br.use { out.use {\n solve()\n out.flush()\n } }\n}\n\nfun solve() {\n // 白 赤 はだね\n // 白 赤 OK\n\n val n = readInteger()\n val cString = br.readLine()!!\n val rSums = IntArray(n + 1)\n val wSums = IntArray(n + 1)\n for (i in 0 until n) {\n rSums[i + 1] += rSums[i] + if (cString[i] == 'R') 1 else 0\n wSums[i + 1] += wSums[i] + if (cString[i] == 'W') 1 else 0\n }\n\n var ans = Int.MAX_VALUE\n for (pivot in 0..n) {\n val leftWCount = wSums[pivot]\n val rightRCount = rSums.last() - rSums[pivot]\n\n val swapCount = min(leftWCount, rightRCount)\n val changeCount = max(leftWCount, rightRCount) - swapCount\n ans = min(ans, swapCount + changeCount)\n }\n out.println(ans)\n}\n\nfun readInteger() = Integer.parseInt(br.readLine())\nfun readLong() = java.lang.Long.parseLong(br.readLine())\nfun readStringList() = br.readLine()!!.split(' ')\nfun readIntegerList() = readStringList().map(Integer::parseInt)\nfun readLongList() = readStringList().map(java.lang.Long::parseLong)\nfun readDoubleList() = readStringList().map(java.lang.Double::parseDouble)\n", "language": "Kotlin", "metadata": {"date": 1596417427, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02597.html", "problem_id": "p02597", "resource_group": "medium_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/Kotlin/s983828292.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s983828292", "user_id": "u784448849"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import java.io.BufferedReader\nimport java.io.InputStreamReader\nimport java.io.PrintWriter\nimport kotlin.math.max\nimport kotlin.math.min\n\nval br = BufferedReader(InputStreamReader(System.`in`))\nval out = PrintWriter(System.out)\n\nfun main() {\n br.use { out.use {\n solve()\n out.flush()\n } }\n}\n\nfun solve() {\n // 白 赤 はだね\n // 白 赤 OK\n\n val n = readInteger()\n val cString = br.readLine()!!\n val rSums = IntArray(n + 1)\n val wSums = IntArray(n + 1)\n for (i in 0 until n) {\n rSums[i + 1] += rSums[i] + if (cString[i] == 'R') 1 else 0\n wSums[i + 1] += wSums[i] + if (cString[i] == 'W') 1 else 0\n }\n\n var ans = Int.MAX_VALUE\n for (pivot in 0..n) {\n val leftWCount = wSums[pivot]\n val rightRCount = rSums.last() - rSums[pivot]\n\n val swapCount = min(leftWCount, rightRCount)\n val changeCount = max(leftWCount, rightRCount) - swapCount\n ans = min(ans, swapCount + changeCount)\n }\n out.println(ans)\n}\n\nfun readInteger() = Integer.parseInt(br.readLine())\nfun readLong() = java.lang.Long.parseLong(br.readLine())\nfun readStringList() = br.readLine()!!.split(' ')\nfun readIntegerList() = readStringList().map(Integer::parseInt)\nfun readLongList() = readStringList().map(java.lang.Long::parseLong)\nfun readDoubleList() = readStringList().map(java.lang.Double::parseDouble)\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1381, "cpu_time_ms": 182, "memory_kb": 42832}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s042371969", "group_id": "codeNet:p02598", "input_text": "import kotlin.math.*\n\nfun list() = readLine()!!.split(\" \").map {it.toInt()}\n\nfun binarySearch(ok:Int,ng:Int,eps:Int,f:(Int)->Boolean):Int {\n\tvar _ok = ok\n\tvar _ng = ng\n\twhile(abs(_ok-_ng)>eps) {\n\t\tval mid = (_ok+_ng)/2\n\t\tif(f(mid))\n\t\t\t_ok = mid\n\t\telse\n\t\t\t_ng = mid\n\t}\n\treturn _ok\n}\n\nfun main() {\n\tval (n,k) = list()\n\tval a = list()\n\tprintln(binarySearch(1000000000,0,1) {l->\n\t\ta.map {(it+l-1)/l-1}.sum()<=k\n\t})\n}\n", "language": "Kotlin", "metadata": {"date": 1597266944, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02598.html", "problem_id": "p02598", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02598/input.txt", "sample_output_relpath": "derived/input_output/data/p02598/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02598/Kotlin/s042371969.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s042371969", "user_id": "u059234158"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "import kotlin.math.*\n\nfun list() = readLine()!!.split(\" \").map {it.toInt()}\n\nfun binarySearch(ok:Int,ng:Int,eps:Int,f:(Int)->Boolean):Int {\n\tvar _ok = ok\n\tvar _ng = ng\n\twhile(abs(_ok-_ng)>eps) {\n\t\tval mid = (_ok+_ng)/2\n\t\tif(f(mid))\n\t\t\t_ok = mid\n\t\telse\n\t\t\t_ng = mid\n\t}\n\treturn _ok\n}\n\nfun main() {\n\tval (n,k) = list()\n\tval a = list()\n\tprintln(binarySearch(1000000000,0,1) {l->\n\t\ta.map {(it+l-1)/l-1}.sum()<=k\n\t})\n}\n", "problem_context": "Score : 500 points\n\nProblem Statement\n\nWe have N logs of lengths A_1,A_2,\\cdots A_N.\n\nWe can cut these logs at most K times in total. When a log of length L is cut at a point whose distance from an end of the log is t (0 l) {\n val m = (r + l) / 2\n var count = 0\n for (x in a) {\n if (x % m == 0) {\n count += x / m - 1\n } else {\n count += x / m\n }\n }\n if (count > k) {\n l = m + 1\n } else {\n r = m\n }\n }\n println(r)\n }\n\n var tokenBuffer = listOf()\n var bufferPosition = 0\n\n private fun checkBuffer() {\n if (bufferPosition == tokenBuffer.size) {\n tokenBuffer = nextLine().split(\" \")\n bufferPosition = 0\n }\n }\n\n fun nextLine() = readLine()!!\n fun nextInt(): Int {\n checkBuffer()\n return tokenBuffer[bufferPosition++].toInt()\n }\n\n fun nextLong(): Long {\n checkBuffer()\n return tokenBuffer[bufferPosition++].toLong()\n }\n\n fun nextDouble(): Double {\n checkBuffer()\n return tokenBuffer[bufferPosition++].toDouble()\n }\n\n fun nextToken(): String {\n checkBuffer()\n return tokenBuffer[bufferPosition++]\n }\n}\n\nfun main() {\n val reader = E().solve()\n\n}\n", "language": "Kotlin", "metadata": {"date": 1596418810, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02598.html", "problem_id": "p02598", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02598/input.txt", "sample_output_relpath": "derived/input_output/data/p02598/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02598/Kotlin/s144217657.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s144217657", "user_id": "u331037015"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "import kotlin.math.abs\nimport kotlin.math.floor\nimport kotlin.math.round\nimport kotlin.math.roundToInt\n\nprivate class E {\n fun solve() {\n val n = nextInt()\n val k = nextInt()\n val a = Array(n) { nextInt() }\n\n var l = 1\n var r = a.max()!!\n while (r > l) {\n val m = (r + l) / 2\n var count = 0\n for (x in a) {\n if (x % m == 0) {\n count += x / m - 1\n } else {\n count += x / m\n }\n }\n if (count > k) {\n l = m + 1\n } else {\n r = m\n }\n }\n println(r)\n }\n\n var tokenBuffer = listOf()\n var bufferPosition = 0\n\n private fun checkBuffer() {\n if (bufferPosition == tokenBuffer.size) {\n tokenBuffer = nextLine().split(\" \")\n bufferPosition = 0\n }\n }\n\n fun nextLine() = readLine()!!\n fun nextInt(): Int {\n checkBuffer()\n return tokenBuffer[bufferPosition++].toInt()\n }\n\n fun nextLong(): Long {\n checkBuffer()\n return tokenBuffer[bufferPosition++].toLong()\n }\n\n fun nextDouble(): Double {\n checkBuffer()\n return tokenBuffer[bufferPosition++].toDouble()\n }\n\n fun nextToken(): String {\n checkBuffer()\n return tokenBuffer[bufferPosition++]\n }\n}\n\nfun main() {\n val reader = E().solve()\n\n}\n", "problem_context": "Score : 500 points\n\nProblem Statement\n\nWe have N logs of lengths A_1,A_2,\\cdots A_N.\n\nWe can cut these logs at most K times in total. When a log of length L is cut at a point whose distance from an end of the log is t (0) {\n val n = readInt()\n val a = readIntList()\n\n val d = mutableListOf(0)\n for (i in 0..a.size - 2) {\n d.add(a[i + 1] - a[i])\n }\n\n var ans = 1000\n for (i in 1 until d.size) {\n if (d[i] > 0) {\n val numBuy = ans / a[i-1]\n ans -= a[i-1] * numBuy\n ans += a[i] * numBuy\n }\n }\n println(ans)\n}\n\n// Tools\nfun readString() = readLine()!!\nfun readInt() = readLine()!!.toInt()\nfun readLong() = readLine()!!.toLong()\nfun readStringList() = readLine()!!.split(\" \")\nfun readIntList() = readLine()!!.split(\" \").map(String::toInt)", "language": "Kotlin", "metadata": {"date": 1595728298, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02603.html", "problem_id": "p02603", "resource_group": "medium_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/Kotlin/s189908232.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s189908232", "user_id": "u697467902"}, "prompt_components": {"gold_output": "1685\n", "input_to_evaluate": "fun main(args: Array) {\n val n = readInt()\n val a = readIntList()\n\n val d = mutableListOf(0)\n for (i in 0..a.size - 2) {\n d.add(a[i + 1] - a[i])\n }\n\n var ans = 1000\n for (i in 1 until d.size) {\n if (d[i] > 0) {\n val numBuy = ans / a[i-1]\n ans -= a[i-1] * numBuy\n ans += a[i] * numBuy\n }\n }\n println(ans)\n}\n\n// Tools\nfun readString() = readLine()!!\nfun readInt() = readLine()!!.toInt()\nfun readLong() = readLine()!!.toLong()\nfun readStringList() = readLine()!!.split(\" \")\nfun readIntList() = readLine()!!.split(\" \").map(String::toInt)", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 622, "cpu_time_ms": 130, "memory_kb": 36584}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s902482559", "group_id": "codeNet:p02603", "input_text": "import java.io.BufferedReader\nimport kotlin.math.max\n\nfun main() {\n val br = System.`in`.bufferedReader()\n val n = br.readInt()\n val a = IntArray(n) { br.readInt() }\n var curMoney = 1000\n var curStocks = 0\n var lastPrice = 200\n var boughtPrice = 0\n\n for (x in 0 until n) {\n val price = a[x]\n if (curStocks == 0) {\n if (price > lastPrice) {\n curStocks = curMoney / lastPrice\n curMoney -= lastPrice * curStocks\n boughtPrice = lastPrice\n }\n } else if (price < lastPrice) {\n curMoney += curStocks * lastPrice\n curStocks = 0\n }\n lastPrice = price\n\n }\n if (curStocks != 0) {\n curMoney += curStocks * max(boughtPrice, lastPrice)\n }\n print(curMoney)\n}\n\n\nprivate const val SPACE_INT = ' '.toInt()\nprivate const val ZERO_INT = '0'.toInt()\nprivate const val NL_INT = '\\n'.toInt()\n\nprivate fun BufferedReader.readInt(): Int {\n var ret = read()\n while (ret <= SPACE_INT) {\n ret = read()\n }\n val neg = ret == '-'.toInt()\n if (neg) {\n ret = read()\n }\n ret -= ZERO_INT\n var read = read()\n while (read >= ZERO_INT) {\n ret *= 10\n ret += read - ZERO_INT\n read = read()\n }\n\n while (read <= SPACE_INT && read != -1 && read != NL_INT) {\n mark(1)\n read = read()\n }\n if (read > SPACE_INT) {\n reset()\n }\n return if (neg) -ret else ret\n}", "language": "Kotlin", "metadata": {"date": 1595726634, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02603.html", "problem_id": "p02603", "resource_group": "medium_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/Kotlin/s902482559.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s902482559", "user_id": "u669089376"}, "prompt_components": {"gold_output": "1685\n", "input_to_evaluate": "import java.io.BufferedReader\nimport kotlin.math.max\n\nfun main() {\n val br = System.`in`.bufferedReader()\n val n = br.readInt()\n val a = IntArray(n) { br.readInt() }\n var curMoney = 1000\n var curStocks = 0\n var lastPrice = 200\n var boughtPrice = 0\n\n for (x in 0 until n) {\n val price = a[x]\n if (curStocks == 0) {\n if (price > lastPrice) {\n curStocks = curMoney / lastPrice\n curMoney -= lastPrice * curStocks\n boughtPrice = lastPrice\n }\n } else if (price < lastPrice) {\n curMoney += curStocks * lastPrice\n curStocks = 0\n }\n lastPrice = price\n\n }\n if (curStocks != 0) {\n curMoney += curStocks * max(boughtPrice, lastPrice)\n }\n print(curMoney)\n}\n\n\nprivate const val SPACE_INT = ' '.toInt()\nprivate const val ZERO_INT = '0'.toInt()\nprivate const val NL_INT = '\\n'.toInt()\n\nprivate fun BufferedReader.readInt(): Int {\n var ret = read()\n while (ret <= SPACE_INT) {\n ret = read()\n }\n val neg = ret == '-'.toInt()\n if (neg) {\n ret = read()\n }\n ret -= ZERO_INT\n var read = read()\n while (read >= ZERO_INT) {\n ret *= 10\n ret += read - ZERO_INT\n read = read()\n }\n\n while (read <= SPACE_INT && read != -1 && read != NL_INT) {\n mark(1)\n read = read()\n }\n if (read > SPACE_INT) {\n reset()\n }\n return if (neg) -ret else ret\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1479, "cpu_time_ms": 104, "memory_kb": 34288}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s732923370", "group_id": "codeNet:p02604", "input_text": "import kotlin.math.abs\nimport kotlin.math.min\n\nfun main() {\n val n = nextInt()\n val X = mutableListOf()\n val Y = mutableListOf()\n val P = mutableListOf()\n repeat(n) {\n val (x, y, p) = nextLongList()\n X.add(x)\n Y.add(y)\n P.add(p)\n }\n val xsel = Array(1 shl n) { Array(n) { 0L } }\n val ysel = Array(1 shl n) { Array(n) { 0L } }\n (0 until (1 shl n)).forEach { i ->\n (0 until n).forEach { j ->\n xsel[i][j] += abs(X[j])\n ysel[i][j] += abs(Y[j])\n (0 until n).forEach { k ->\n if ((i shr k) and 1 == 1) {\n xsel[i][j] = min(xsel[i][j], abs(X[j] - X[k]))\n ysel[i][j] = min(ysel[i][j], abs(Y[j] - Y[k]))\n }\n }\n }\n }\n (0 until (1 shl n)).forEach { i ->\n (0 until n).forEach { j ->\n xsel[i][j] *= P[j]\n ysel[i][j] *= P[j]\n }\n }\n\n val ans = sizedArray(n + 1, Long.MAX_VALUE)\n (0 until (1 shl n)).forEach { i ->\n val count = (0 until n).count {\n i shr it and 1 == 1\n }\n var j = i\n while (j >= 0) {\n j = j and i\n var cost = 0L\n (0 until n).forEach { k ->\n cost += min(xsel[j][k], ysel[i - j][k])\n }\n ans[count] = min(ans[count], cost)\n j--\n }\n// ans.forEach(::println)\n// return\n }\n ans.forEach(::println)\n}\n\n// # Utils\n// ## Input\nfun next() = readLine()!!\nfun nextInt() = next().toInt()\nfun nextLong() = next().toLong()\nfun nextDouble() = next().toDouble()\nfun nextList() = next().split(\" \")\nfun nextIntList() = next().split(\" \").map(String::toInt)\nfun nextLongList() = next().split(\" \").map(String::toLong)\nfun nextDoubleList() = next().split(\" \").map(String::toDouble)\n\n// ## Array\ninline fun sizedArray(size: Int, default: T) = Array(size) { default }\n\n// ## mod^-1\n// [NOTE] CANNOT use this for 0, mod, 2mod, 3mod ...(return wrong value)\nfun modinv(num: Long, mod: Long): Long {\n var a = num\n var b = mod\n var u = 1L\n var v = 0L\n while (b > 0) {\n val t = a.div(b)\n a -= t * b\n a = b.also { b = a } // swap a and b\n u -= t * v\n u = v.also { v = u } // swap u and v\n }\n u %= mod\n if (u < 0) u += mod\n return u\n}", "language": "Kotlin", "metadata": {"date": 1595800834, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02604.html", "problem_id": "p02604", "resource_group": "medium_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/Kotlin/s732923370.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s732923370", "user_id": "u885556801"}, "prompt_components": {"gold_output": "2900\n900\n0\n0\n", "input_to_evaluate": "import kotlin.math.abs\nimport kotlin.math.min\n\nfun main() {\n val n = nextInt()\n val X = mutableListOf()\n val Y = mutableListOf()\n val P = mutableListOf()\n repeat(n) {\n val (x, y, p) = nextLongList()\n X.add(x)\n Y.add(y)\n P.add(p)\n }\n val xsel = Array(1 shl n) { Array(n) { 0L } }\n val ysel = Array(1 shl n) { Array(n) { 0L } }\n (0 until (1 shl n)).forEach { i ->\n (0 until n).forEach { j ->\n xsel[i][j] += abs(X[j])\n ysel[i][j] += abs(Y[j])\n (0 until n).forEach { k ->\n if ((i shr k) and 1 == 1) {\n xsel[i][j] = min(xsel[i][j], abs(X[j] - X[k]))\n ysel[i][j] = min(ysel[i][j], abs(Y[j] - Y[k]))\n }\n }\n }\n }\n (0 until (1 shl n)).forEach { i ->\n (0 until n).forEach { j ->\n xsel[i][j] *= P[j]\n ysel[i][j] *= P[j]\n }\n }\n\n val ans = sizedArray(n + 1, Long.MAX_VALUE)\n (0 until (1 shl n)).forEach { i ->\n val count = (0 until n).count {\n i shr it and 1 == 1\n }\n var j = i\n while (j >= 0) {\n j = j and i\n var cost = 0L\n (0 until n).forEach { k ->\n cost += min(xsel[j][k], ysel[i - j][k])\n }\n ans[count] = min(ans[count], cost)\n j--\n }\n// ans.forEach(::println)\n// return\n }\n ans.forEach(::println)\n}\n\n// # Utils\n// ## Input\nfun next() = readLine()!!\nfun nextInt() = next().toInt()\nfun nextLong() = next().toLong()\nfun nextDouble() = next().toDouble()\nfun nextList() = next().split(\" \")\nfun nextIntList() = next().split(\" \").map(String::toInt)\nfun nextLongList() = next().split(\" \").map(String::toLong)\nfun nextDoubleList() = next().split(\" \").map(String::toDouble)\n\n// ## Array\ninline fun sizedArray(size: Int, default: T) = Array(size) { default }\n\n// ## mod^-1\n// [NOTE] CANNOT use this for 0, mod, 2mod, 3mod ...(return wrong value)\nfun modinv(num: Long, mod: Long): Long {\n var a = num\n var b = mod\n var u = 1L\n var v = 0L\n while (b > 0) {\n val t = a.div(b)\n a -= t * b\n a = b.also { b = a } // swap a and b\n u -= t * v\n u = v.also { v = u } // swap u and v\n }\n u %= mod\n if (u < 0) u += mod\n return u\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2377, "cpu_time_ms": 2842, "memory_kb": 91496}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s273260108", "group_id": "codeNet:p02604", "input_text": "import java.io.BufferedReader\nimport kotlin.math.absoluteValue\nimport kotlin.math.min\n\nfun main() {\n val br = System.`in`.bufferedReader()\n val sb = StringBuilder()\n val n = br.readInt()\n val areas = Array>(n) { Triple(br.readInt(), br.readInt(), br.readInt().toLong()) }\n val lows = LongArray(n + 1) { Long.MAX_VALUE }\n fun solve(state: Int, numAdded: Int, nextToAdd: Int) {\n if (nextToAdd == n) {\n var cost = 0L\n for (city in 0 until n) {\n var cityCost = min(areas[city].first.absoluteValue, areas[city].second.absoluteValue)\n if ((state shr (city * 2)) and 3 == 0) {\n for (road in 0 until n) {\n when ((state shr (road * 2)) and 3) {\n 2 -> {\n cityCost = cityCost.coerceAtMost((areas[road].first - areas[city].first).absoluteValue)\n }\n 1 -> {\n cityCost = cityCost.coerceAtMost((areas[road].second - areas[city].second).absoluteValue)\n }\n }\n }\n } else {\n cityCost = 0\n }\n cost += cityCost * areas[city].third\n }\n lows[numAdded] = min(lows[numAdded], cost)\n } else {\n for(x in nextToAdd until n){\n for(y in 1..2){\n solve(state or (y shl (x * 2)), numAdded + 1, x + 1)\n }\n }\n }\n }\n solve(0, 0, 0)\n for (k in 0..n) {\n sb.append(lows[k]).append('\\n')\n }\n print(sb)\n}\n\n\nprivate const val SPACE_INT = ' '.toInt()\nprivate const val ZERO_INT = '0'.toInt()\nprivate const val NL_INT = '\\n'.toInt()\n\nprivate fun BufferedReader.readInt(): Int {\n var ret = read()\n while (ret <= SPACE_INT) {\n ret = read()\n }\n val neg = ret == '-'.toInt()\n if (neg) {\n ret = read()\n }\n ret -= ZERO_INT\n var read = read()\n while (read >= ZERO_INT) {\n ret *= 10\n ret += read - ZERO_INT\n read = read()\n }\n\n while (read <= SPACE_INT && read != -1 && read != NL_INT) {\n mark(1)\n read = read()\n }\n if (read > SPACE_INT) {\n reset()\n }\n return if (neg) -ret else ret\n}", "language": "Kotlin", "metadata": {"date": 1595730369, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02604.html", "problem_id": "p02604", "resource_group": "medium_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/Kotlin/s273260108.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s273260108", "user_id": "u669089376"}, "prompt_components": {"gold_output": "2900\n900\n0\n0\n", "input_to_evaluate": "import java.io.BufferedReader\nimport kotlin.math.absoluteValue\nimport kotlin.math.min\n\nfun main() {\n val br = System.`in`.bufferedReader()\n val sb = StringBuilder()\n val n = br.readInt()\n val areas = Array>(n) { Triple(br.readInt(), br.readInt(), br.readInt().toLong()) }\n val lows = LongArray(n + 1) { Long.MAX_VALUE }\n fun solve(state: Int, numAdded: Int, nextToAdd: Int) {\n if (nextToAdd == n) {\n var cost = 0L\n for (city in 0 until n) {\n var cityCost = min(areas[city].first.absoluteValue, areas[city].second.absoluteValue)\n if ((state shr (city * 2)) and 3 == 0) {\n for (road in 0 until n) {\n when ((state shr (road * 2)) and 3) {\n 2 -> {\n cityCost = cityCost.coerceAtMost((areas[road].first - areas[city].first).absoluteValue)\n }\n 1 -> {\n cityCost = cityCost.coerceAtMost((areas[road].second - areas[city].second).absoluteValue)\n }\n }\n }\n } else {\n cityCost = 0\n }\n cost += cityCost * areas[city].third\n }\n lows[numAdded] = min(lows[numAdded], cost)\n } else {\n for(x in nextToAdd until n){\n for(y in 1..2){\n solve(state or (y shl (x * 2)), numAdded + 1, x + 1)\n }\n }\n }\n }\n solve(0, 0, 0)\n for (k in 0..n) {\n sb.append(lows[k]).append('\\n')\n }\n print(sb)\n}\n\n\nprivate const val SPACE_INT = ' '.toInt()\nprivate const val ZERO_INT = '0'.toInt()\nprivate const val NL_INT = '\\n'.toInt()\n\nprivate fun BufferedReader.readInt(): Int {\n var ret = read()\n while (ret <= SPACE_INT) {\n ret = read()\n }\n val neg = ret == '-'.toInt()\n if (neg) {\n ret = read()\n }\n ret -= ZERO_INT\n var read = read()\n while (read >= ZERO_INT) {\n ret *= 10\n ret += read - ZERO_INT\n read = read()\n }\n\n while (read <= SPACE_INT && read != -1 && read != NL_INT) {\n mark(1)\n read = read()\n }\n if (read > SPACE_INT) {\n reset()\n }\n return if (neg) -ret else ret\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2378, "cpu_time_ms": 3309, "memory_kb": 36900}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s096848225", "group_id": "codeNet:p02604", "input_text": "fun main(args: Array) {\n val n = readLine()!!.toInt()\n\n var mp = mutableMapOf()\n mp[0] = 0\n var ans = 0\n repeat (n) {\n val (x, y, p) = readLine()!!.split(' ').map { it.toInt() }\n val dist = Math.min(x, y)\n if (mp[dist] != null) mp[dist] = mp[dist]!! + p\n else mp[dist] = p\n\n ans += dist * p\n }\n println(ans)\n\n repeat(n) {\n ans = 0\n val yotei = mp.maxBy { it.key * it.value }!!.key\n val move = mp[yotei]!!\n mp[yotei] = 0\n mp[0] = mp[0]!! + move\n\n mp.forEach {\n ans += it.key * it.value\n }\n println(ans)\n }\n}\n", "language": "Kotlin", "metadata": {"date": 1595729385, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02604.html", "problem_id": "p02604", "resource_group": "medium_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/Kotlin/s096848225.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s096848225", "user_id": "u288435405"}, "prompt_components": {"gold_output": "2900\n900\n0\n0\n", "input_to_evaluate": "fun main(args: Array) {\n val n = readLine()!!.toInt()\n\n var mp = mutableMapOf()\n mp[0] = 0\n var ans = 0\n repeat (n) {\n val (x, y, p) = readLine()!!.split(' ').map { it.toInt() }\n val dist = Math.min(x, y)\n if (mp[dist] != null) mp[dist] = mp[dist]!! + p\n else mp[dist] = p\n\n ans += dist * p\n }\n println(ans)\n\n repeat(n) {\n ans = 0\n val yotei = mp.maxBy { it.key * it.value }!!.key\n val move = mp[yotei]!!\n mp[yotei] = 0\n mp[0] = mp[0]!! + move\n\n mp.forEach {\n ans += it.key * it.value\n }\n println(ans)\n }\n}\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 129, "memory_kb": 36504}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s022266633", "group_id": "codeNet:p02606", "input_text": "fun main() {\n val (l, r, d) = nextIntList()\n println(r.div(d).minus(l.minus(1).div(d)))\n}\n\n// # Utils\n// ## Input\nfun next() = readLine()!!\nfun nextInt() = next().toInt()\nfun nextLong() = next().toLong()\nfun nextDouble() = next().toDouble()\nfun nextList() = next().split(\" \")\nfun nextIntList() = next().split(\" \").map(String::toInt)\nfun nextLongList() = next().split(\" \").map(String::toLong)\nfun nextDoubleList() = next().split(\" \").map(String::toDouble)\n\n// ## Array\ninline fun sizedArray(size: Int, default: T) = Array(size) { default }\n\n// ## mod^-1\n// [NOTE] CANNOT use this for 0, mod, 2mod, 3mod ...(return wrong value)\nfun modinv(num: Long, mod: Long): Long {\n var a = num\n var b = mod\n var u = 1L\n var v = 0L\n while (b > 0) {\n val t = a.div(b)\n a -= t * b\n a = b.also { b = a } // swap a and b\n u -= t * v\n u = v.also { v = u } // swap u and v\n }\n u %= mod\n if (u < 0) u += mod\n return u\n}\n", "language": "Kotlin", "metadata": {"date": 1594587602, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02606.html", "problem_id": "p02606", "resource_group": "medium_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/Kotlin/s022266633.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s022266633", "user_id": "u885556801"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "fun main() {\n val (l, r, d) = nextIntList()\n println(r.div(d).minus(l.minus(1).div(d)))\n}\n\n// # Utils\n// ## Input\nfun next() = readLine()!!\nfun nextInt() = next().toInt()\nfun nextLong() = next().toLong()\nfun nextDouble() = next().toDouble()\nfun nextList() = next().split(\" \")\nfun nextIntList() = next().split(\" \").map(String::toInt)\nfun nextLongList() = next().split(\" \").map(String::toLong)\nfun nextDoubleList() = next().split(\" \").map(String::toDouble)\n\n// ## Array\ninline fun sizedArray(size: Int, default: T) = Array(size) { default }\n\n// ## mod^-1\n// [NOTE] CANNOT use this for 0, mod, 2mod, 3mod ...(return wrong value)\nfun modinv(num: Long, mod: Long): Long {\n var a = num\n var b = mod\n var u = 1L\n var v = 0L\n while (b > 0) {\n val t = a.div(b)\n a -= t * b\n a = b.also { b = a } // swap a and b\n u -= t * v\n u = v.also { v = u } // swap u and v\n }\n u %= mod\n if (u < 0) u += mod\n return u\n}\n", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 981, "cpu_time_ms": 117, "memory_kb": 36360}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s221399459", "group_id": "codeNet:p02607", "input_text": "fun main(args: Array) {\n val first = readLine()?.toInt() ?: return\n val second = readLine()?.split(\" \")?.map(String::toInt)?.toIntArray() ?: return\n var count = 0;\n (1..first).forEach {\n count += if (second[it - 1] % 2 == 1 && it % 2 == 1) 1 else 0\n }\n \tprintln(count)\n}", "language": "Kotlin", "metadata": {"date": 1594517361, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02607.html", "problem_id": "p02607", "resource_group": "medium_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/Kotlin/s221399459.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s221399459", "user_id": "u213346280"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "fun main(args: Array) {\n val first = readLine()?.toInt() ?: return\n val second = readLine()?.split(\" \")?.map(String::toInt)?.toIntArray() ?: return\n var count = 0;\n (1..first).forEach {\n count += if (second[it - 1] % 2 == 1 && it % 2 == 1) 1 else 0\n }\n \tprintln(count)\n}", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 135, "memory_kb": 36568}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s912128618", "group_id": "codeNet:p02608", "input_text": "fun main(args: Array) {\n val n = readLine()!!.toInt()\n\n val ans = IntArray(n + 1) { 0 }\n\n for (x in 1..n) {\n if ((x * x) + (x) + 1 + (1 * x) >= n) break\n\n for (y in 1..n) {\n if ((x * x) + (y * y) + (x * y) + (y) + (x) >= n) break\n\n for (z in 1..n) {\n if ((x * x) + (y * y) + (z * z) + (x * y) + (y * z) + (z * x) > n) break\n\n val count = (x * x) + (y * y) + (z * z) + (x * y) + (y * z) + (z * x)\n if (count <= n) {\n ans[count]++\n }\n }\n }\n }\n ans.forEach {\n println(it)\n }\n}", "language": "Kotlin", "metadata": {"date": 1594561406, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02608.html", "problem_id": "p02608", "resource_group": "medium_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/Kotlin/s912128618.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s912128618", "user_id": "u366280250"}, "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": "fun main(args: Array) {\n val n = readLine()!!.toInt()\n\n val ans = IntArray(n + 1) { 0 }\n\n for (x in 1..n) {\n if ((x * x) + (x) + 1 + (1 * x) >= n) break\n\n for (y in 1..n) {\n if ((x * x) + (y * y) + (x * y) + (y) + (x) >= n) break\n\n for (z in 1..n) {\n if ((x * x) + (y * y) + (z * z) + (x * y) + (y * z) + (z * x) > n) break\n\n val count = (x * x) + (y * y) + (z * z) + (x * y) + (y * z) + (z * x)\n if (count <= n) {\n ans[count]++\n }\n }\n }\n }\n ans.forEach {\n println(it)\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 639, "cpu_time_ms": 198, "memory_kb": 37780}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s872280463", "group_id": "codeNet:p02608", "input_text": "fun main() {\n val n = readLine()!!.toInt()\n val resultMap = IntArray(n + 1) { 0 }\n\n for (a in 1..n) {\n if (a * a > n) continue\n for (b in 1..n) {\n if (a * a + b * b + a * b > n) continue\n for (c in 1..n) {\n val count = a * a + b * b + c * c + a * b + b * c + c * a\n if (count <= n) {\n resultMap[count] += 1\n }\n }\n }\n }\n\n resultMap.takeLast(n).forEach { println(it) }\n}\n", "language": "Kotlin", "metadata": {"date": 1594520381, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02608.html", "problem_id": "p02608", "resource_group": "medium_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/Kotlin/s872280463.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s872280463", "user_id": "u897579945"}, "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": "fun main() {\n val n = readLine()!!.toInt()\n val resultMap = IntArray(n + 1) { 0 }\n\n for (a in 1..n) {\n if (a * a > n) continue\n for (b in 1..n) {\n if (a * a + b * b + a * b > n) continue\n for (c in 1..n) {\n val count = a * a + b * b + c * c + a * b + b * c + c * a\n if (count <= n) {\n resultMap[count] += 1\n }\n }\n }\n }\n\n resultMap.takeLast(n).forEach { println(it) }\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 502, "cpu_time_ms": 289, "memory_kb": 40876}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s149880381", "group_id": "codeNet:p02609", "input_text": "fun main() {\n val N = readLine()!!.toInt()\n val x = readLine()!!\n\n for (i in 0 until N) {\n println(calc(x, i, N))\n }\n}\n\nfun calc(x: String, i: Int, N: Int): Long {\n var replaced = x.toCharArray()\n replaced[i] = if (replaced[i] == '0') '1' else '0'\n\n replaced = replaced.reversedArray()\n var target = 0L\n for (i in 0 until N) {\n val tmp = Math.pow(2.toDouble(), i.toDouble()).toLong()\n if (replaced[i] == '1') {\n target += tmp\n }\n }\n return calcF(target)\n}\n\nfun calcF(i: Long): Long {\n if (i == 0L) {\n return 0\n }\n val popCount = java.lang.Long.bitCount(i)\n\n return 1 + calcF(i % popCount)\n}\n", "language": "Kotlin", "metadata": {"date": 1594520278, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02609.html", "problem_id": "p02609", "resource_group": "medium_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/Kotlin/s149880381.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s149880381", "user_id": "u542748657"}, "prompt_components": {"gold_output": "2\n1\n1\n", "input_to_evaluate": "fun main() {\n val N = readLine()!!.toInt()\n val x = readLine()!!\n\n for (i in 0 until N) {\n println(calc(x, i, N))\n }\n}\n\nfun calc(x: String, i: Int, N: Int): Long {\n var replaced = x.toCharArray()\n replaced[i] = if (replaced[i] == '0') '1' else '0'\n\n replaced = replaced.reversedArray()\n var target = 0L\n for (i in 0 until N) {\n val tmp = Math.pow(2.toDouble(), i.toDouble()).toLong()\n if (replaced[i] == '1') {\n target += tmp\n }\n }\n return calcF(target)\n}\n\nfun calcF(i: Long): Long {\n if (i == 0L) {\n return 0\n }\n val popCount = java.lang.Long.bitCount(i)\n\n return 1 + calcF(i % popCount)\n}\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 682, "cpu_time_ms": 2207, "memory_kb": 59284}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s808586393", "group_id": "codeNet:p02613", "input_text": "fun main() {\n b()\n}\n\nfun a() {\n val N = readLong()\n val otsuri = (1000 - N%1000)%1000\n println(\"${otsuri}\")\n}\n\nfun b() {\n val N = readLong().toInt()\n val map = mutableMapOf()\n repeat(N) {\n val s = readLine()!!\n map[s] = map.getOrDefault(s, 0) + 1\n }\n listOf(\"AC\", \"WA\", \"TLE\", \"RE\").forEach {\n println(\"$it x ${map.getOrDefault(it, 0)}\")\n }\n}\n\nfun readLong() = readLine()!!.toLong()\nfun readLongList() = readLine()!!.split(\" \").map { it.toLong() }\n\nfun Long.print() { println(this) }", "language": "Kotlin", "metadata": {"date": 1594518071, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02613.html", "problem_id": "p02613", "resource_group": "medium_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/Kotlin/s808586393.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s808586393", "user_id": "u915119935"}, "prompt_components": {"gold_output": "AC x 3\nWA x 1\nTLE x 2\nRE x 0\n", "input_to_evaluate": "fun main() {\n b()\n}\n\nfun a() {\n val N = readLong()\n val otsuri = (1000 - N%1000)%1000\n println(\"${otsuri}\")\n}\n\nfun b() {\n val N = readLong().toInt()\n val map = mutableMapOf()\n repeat(N) {\n val s = readLine()!!\n map[s] = map.getOrDefault(s, 0) + 1\n }\n listOf(\"AC\", \"WA\", \"TLE\", \"RE\").forEach {\n println(\"$it x ${map.getOrDefault(it, 0)}\")\n }\n}\n\nfun readLong() = readLine()!!.toLong()\nfun readLongList() = readLine()!!.split(\" \").map { it.toLong() }\n\nfun Long.print() { println(this) }", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 548, "cpu_time_ms": 318, "memory_kb": 59088}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s681127775", "group_id": "codeNet:p02613", "input_text": "fun main (args:Array){\n val testCase = readLine()!!.toInt()\n var judgeCountMap = mutableMapOf()\n judgeCountMap[\"AC\"] = 0\n judgeCountMap[\"WA\"] = 0\n judgeCountMap[\"TLE\"] = 0\n judgeCountMap[\"RE\"] = 0\n\n for (i in 1..testCase){\n val judge = readLine()!!\n judgeCountMap[judge] = judgeCountMap[judge]!!.inc()\n }\n\n println(\"AC x ${judgeCountMap[\"AC\"]}\")\n println(\"WA x ${judgeCountMap[\"WA\"]}\")\n println(\"TLE x ${judgeCountMap[\"TLE\"]}\")\n println(\"RE x ${judgeCountMap[\"RE\"]}\")\n}\n", "language": "Kotlin", "metadata": {"date": 1594131794, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02613.html", "problem_id": "p02613", "resource_group": "medium_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/Kotlin/s681127775.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s681127775", "user_id": "u838133978"}, "prompt_components": {"gold_output": "AC x 3\nWA x 1\nTLE x 2\nRE x 0\n", "input_to_evaluate": "fun main (args:Array){\n val testCase = readLine()!!.toInt()\n var judgeCountMap = mutableMapOf()\n judgeCountMap[\"AC\"] = 0\n judgeCountMap[\"WA\"] = 0\n judgeCountMap[\"TLE\"] = 0\n judgeCountMap[\"RE\"] = 0\n\n for (i in 1..testCase){\n val judge = readLine()!!\n judgeCountMap[judge] = judgeCountMap[judge]!!.inc()\n }\n\n println(\"AC x ${judgeCountMap[\"AC\"]}\")\n println(\"WA x ${judgeCountMap[\"WA\"]}\")\n println(\"TLE x ${judgeCountMap[\"TLE\"]}\")\n println(\"RE x ${judgeCountMap[\"RE\"]}\")\n}\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 283, "memory_kb": 59156}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s629458127", "group_id": "codeNet:p02613", "input_text": "fun main(args: Array) {\n val n = readLine()!!.toInt()\n val map = mutableMapOf()\n map[\"AC\"] = 0\n map[\"WA\"] = 0\n map[\"TLE\"] = 0\n map[\"RE\"] = 0\n repeat(n) {\n val s = readLine()!!\n val v = map[s]!!\n map[s] = v+1\n }\n println(\"AC x ${map[\"AC\"]}\")\n println(\"WA x ${map[\"WA\"]}\")\n println(\"TLE x ${map[\"TLE\"]}\")\n println(\"RE x ${map[\"RE\"]}\")\n}\n\n", "language": "Kotlin", "metadata": {"date": 1594084115, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02613.html", "problem_id": "p02613", "resource_group": "medium_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/Kotlin/s629458127.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s629458127", "user_id": "u172820018"}, "prompt_components": {"gold_output": "AC x 3\nWA x 1\nTLE x 2\nRE x 0\n", "input_to_evaluate": "fun main(args: Array) {\n val n = readLine()!!.toInt()\n val map = mutableMapOf()\n map[\"AC\"] = 0\n map[\"WA\"] = 0\n map[\"TLE\"] = 0\n map[\"RE\"] = 0\n repeat(n) {\n val s = readLine()!!\n val v = map[s]!!\n map[s] = v+1\n }\n println(\"AC x ${map[\"AC\"]}\")\n println(\"WA x ${map[\"WA\"]}\")\n println(\"TLE x ${map[\"TLE\"]}\")\n println(\"RE x ${map[\"RE\"]}\")\n}\n\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 414, "cpu_time_ms": 282, "memory_kb": 59096}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s364518342", "group_id": "codeNet:p02613", "input_text": "import java.io.PrintWriter\nimport java.util.*\nimport java.math.*\nimport java.lang.*\nimport kotlin.comparisons.*\n\nval pw = PrintWriter(System.out)\nval MOD: Long = (1e+9 + 7).toLong()\n\nfun main(args: Array) {\n val n = readInt()\n val sArr = Array(n) { read() }\n\n val aMap = mutableMapOf(\"AC\" to 0, \"WA\" to 0, \"TLE\" to 0, \"RE\" to 0)\n for(s in sArr) {\n aMap[s] = (aMap[s]?:0) + 1\n }\n \n val labels = listOf(\"AC\", \"WA\", \"TLE\", \"RE\")\n labels.forEach { label -> println(\"${label} x ${aMap[label]}\") }\n\n\tpw.flush()\n}\n\n/****** Declared Functions and Data Structures ******/\n// IO\nfun read() = readLine()!!\nfun readInt() = read().toInt()\nfun readLong() = read().toLong()\nfun readDouble() = read().toDouble()\nfun readListOfString() = read().split(\" \")\nfun readListOfInt() = readListOfString().map { it.toInt() }\nfun readListOfLong() = readListOfString().map { it.toLong() }\nfun readListOfDouble() = readListOfString().map { it.toDouble() }\n\nfun Double.format(digits: Int) = String.format(\"%.${digits}f\", this)\nfun Float.format(digits: Int) = String.format(\"%.${digits}f\", this)\n\nfun print(value: Any) { pw.print(value) }\nfun println(value : Any) { pw.println(value) }\n\n// Extensions\nfun List.toBuckets(): Map\n\t= this.groupBy { it }.mapValues { it.value.size }\n\nfun> Array.upperBound(element: T, fromIndex: Int=0, toIndex: Int=this.size): Int\n\t= this.toList().upperBound(element, fromIndex, toIndex)\n\nfun> List.upperBound(element: T, fromIndex: Int=0, toIndex: Int=this.size): Int {\n\tvar l = fromIndex\n\tvar r = toIndex\n\twhile(l < r) {\n\t\tval mid = (l+r) / 2\n\t\tif(element >= this[mid]) { \n\t\t\tl = mid + 1\n\t\t} else {\n\t\t\tr = mid\n\t\t}\n\t}\n\treturn l\n}\n\nfun> Array.lowerBound(element: T, fromIndex: Int=0, toIndex: Int=this.size): Int\n\t= this.toList().lowerBound(element, fromIndex, toIndex)\n\nfun> List.lowerBound(element: T, fromIndex: Int=0, toIndex: Int=this.size): Int {\n\tvar l = fromIndex\n\tvar r = toIndex\n\twhile(l < r) {\n\t\tval mid = (l+r) / 2\n\t\tif(element > this[mid]) { \n\t\t\tl = mid + 1\n\t\t} else {\n\t\t\tr = mid\n\t\t}\n\t}\n\treturn r \n}\n\nfun Map.toMutableMap(): MutableMap = HashMap(this)\n\n// Util Functions\nfun Long.makeDivisors(): List {\n\tval divisors = mutableListOf()\n\tfor(i in 1L .. Math.sqrt(this.toDouble()).toLong()+1L) {\n\t\tif(this % i == 0L) {\n\t\t\tdivisors.add(i)\n\t\t\tif(i != this/i) {\n\t\t\t\tdivisors.add(this/i)\n\t\t\t}\n\t\t}\n\t}\n\treturn divisors.distinct().sorted()\n}\n\nfun Long.isPrime(): Boolean {\n\tif(this==1L) return false\n\tfor(i in 2L .. Math.sqrt(this.toDouble()).toLong() + 1L) {\n\t\tif(this % i == 0L && this != i) {\n\t\t\treturn false\n\t\t}\n\t}\n\treturn true\n}\n\nfun Long.primeFactorize(): Map {\n\tval map = mutableMapOf()\n\tvar num = this\n\tfor(i in 2L .. Math.sqrt(num.toDouble()).toLong()+1L) {\n\t\tif(num % i == 0L) {\n\t\t\twhile(num % i == 0L) {\n\t\t\t\tmap[i] = (map[i]?:0) + 1\n\t\t\t\tnum /= i\n\t\t\t}\n\t\t}\n\t}\n\tif(num != 1L) {\n\t\tmap[this] = 1 \n\t}\n\treturn map\n}\n\nfun permutations(src: List): List> {\n\tif(src.size == 1) return listOf(src)\n\tval perms = mutableListOf>()\n\tval insertElement = src[0]\n\tpermutations(src.drop(1)).forEach { perm ->\n\t\tfor(i in 0..perm.size) {\n\t\t\tval newPerm = perm.toMutableList()\n\t\t\tnewPerm.add(i, insertElement)\n\t\t\tperms.add(newPerm.toList())\n\t\t}\n\t}\n\treturn perms\n}\n\n// return nCr, if you want nCr, please access v[n][r]\nfun combinations(n: Long): List> {\n\tval v = (0..n).map { (0..n).map{0L}.toMutableList() }.toMutableList()\n\tfor(i in 0 until v.size) {\n\t\tv[i][0] = 1L\n\t\tv[i][i] = 1L\n\t}\n\tfor(i in 0 until v.size) {\n\t\tfor(j in 1 until i) {\n\t\t\tv[i][j] = (v[i-1][j-1] + v[i-1][j]) % MOD\n\t\t}\n\t}\n\treturn v.map { it.toList() }.toList()\n}\n\nfun repeatedModPow(a: Long, n: Long, mod: Long): Long = \n\twhen {\n\t\tn == 0L -> 1L\n\t\tn == 1L -> a % mod\n\t\tn % 2L == 1L -> (a * repeatedModPow(a, n-1L, mod)) % mod\n\t\telse -> {\n\t\t\tval tmp = repeatedModPow(a, n / 2L, mod)\n\t\t\t(tmp * tmp) % mod\n\t\t}\n\t}\n\n// return nCr % MOD\nfun modnCkWithoutArray(n: Long, k: Long, mod: Long): Long {\n\tvar ret = 1L\n\tval min = Math.min(k, n-k)\n\t// まず分母の計算\n\tfor(i in n downTo (n - min + 1)) {\n\t\tret = ret * i % mod\n\t}\n\tfor(i in min downTo 1) {\n\t\tret = ret * repeatedModPow(i, (mod - 2L), mod) % mod\n\t}\n\treturn ret\n}\n\n// return nCr % MOD\nfun modnCk(n: Int, k: Int, mod: Long): Long {\n\tval factorials = Array(n+1) { 0L }.apply {\n\t\tthis[0] = 1L\n\t\tif(this.size > 1) this[1] = 1L\n\t}\n\tval inverses = Array(n+1) { 0L }.apply {\n\t\tthis[0] = 1L\n\t\tif(this.size > 1) this[1] = 1L\n\t}\n\tval factorialInverses = Array(n+1) { 0L }.apply {\n\t\tthis[0] = 1L\n\t\tif(this.size > 1) this[1] = 1L\n\t}\n\tfor(i in 2 .. n) {\n\t\tfactorials[i] = (factorials[i-1] * i.toLong() % mod)\n\t\tinverses[i] = (mod - inverses[mod.toInt() % i] * (mod / i.toLong()) % mod)\n\t\tfactorialInverses[i] = (factorialInverses[i-1] * inverses[i] % mod)\n\t}\n\n\treturn factorials[n] % mod * (factorialInverses[k] * factorialInverses[n-k] % mod) % mod\n}\n\n// should be a >= b\nfun gcd(a: Long, b: Long): Long = \n\tif(b == 0L) a else gcd(b, a % b)\n\n// shoud be a >= b\nfun lcm(a: Long, b: Long): Long = \n\ta / gcd(a, b) * b\n\nfun sumDigits(num_: Long): Long {\n\tvar num = num_\n\tvar rtn: Long = 0\n\twhile(num != 0.toLong()) {\n\t\tval tmp = num % 10\n\t\trtn += tmp\n\t\tnum /= 10\n\t}\n\treturn rtn\n}\n\nfun Double.isDecimal(): Boolean = ((this - Math.floor(this)) != 0.0)\n\n// Data Structures\n\nclass UnionFind(private val n: Int) {\n\tprivate val parent: Array = Array(n) { 0 }\n\tprivate val rank: Array = Array(n) { 0 }\n\tprivate val size: Array = Array(n) { 0 }\n\n\tinit {\n\t\tfor(i in 0 until n) {\n\t\t\tparent[i] = i\n\t\t\trank[i] = 1\n\t\t\tsize[i] = 1\n\t\t}\n\t}\n\n\tfun union(u: Int, v: Int) {\n\t\tvar x = root(u)\n\t\tvar y = root(v)\n\t\tif(x != y) {\n\t\t\tif(rank[y] < rank[x]) {\n\t\t\t\tval tmp = y \n\t\t\t\ty = x\n\t\t\t\tx = tmp \n\t\t\t}\n\t\t\tparent[x] = y\n\t\t\trank[y] += rank[x]\n\t\t\trank[x] = -1\n\t\t\tval totalSize = size[x] + size[y]\n\t\t\tsize[x] = totalSize\n\t\t\tsize[y] = totalSize\n\t\t}\n\t}\n\n\tfun root(u: Int): Int {\n\t\tvar x = u\n\t\twhile(parent[x] != x) {\n\t\t\tx = parent[x]\n\t\t}\n\t\treturn x \n\t}\n\n\tfun size(u: Int): Int = size[root(u)]\n}\n", "language": "Kotlin", "metadata": {"date": 1593997668, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02613.html", "problem_id": "p02613", "resource_group": "medium_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/Kotlin/s364518342.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s364518342", "user_id": "u026686258"}, "prompt_components": {"gold_output": "AC x 3\nWA x 1\nTLE x 2\nRE x 0\n", "input_to_evaluate": "import java.io.PrintWriter\nimport java.util.*\nimport java.math.*\nimport java.lang.*\nimport kotlin.comparisons.*\n\nval pw = PrintWriter(System.out)\nval MOD: Long = (1e+9 + 7).toLong()\n\nfun main(args: Array) {\n val n = readInt()\n val sArr = Array(n) { read() }\n\n val aMap = mutableMapOf(\"AC\" to 0, \"WA\" to 0, \"TLE\" to 0, \"RE\" to 0)\n for(s in sArr) {\n aMap[s] = (aMap[s]?:0) + 1\n }\n \n val labels = listOf(\"AC\", \"WA\", \"TLE\", \"RE\")\n labels.forEach { label -> println(\"${label} x ${aMap[label]}\") }\n\n\tpw.flush()\n}\n\n/****** Declared Functions and Data Structures ******/\n// IO\nfun read() = readLine()!!\nfun readInt() = read().toInt()\nfun readLong() = read().toLong()\nfun readDouble() = read().toDouble()\nfun readListOfString() = read().split(\" \")\nfun readListOfInt() = readListOfString().map { it.toInt() }\nfun readListOfLong() = readListOfString().map { it.toLong() }\nfun readListOfDouble() = readListOfString().map { it.toDouble() }\n\nfun Double.format(digits: Int) = String.format(\"%.${digits}f\", this)\nfun Float.format(digits: Int) = String.format(\"%.${digits}f\", this)\n\nfun print(value: Any) { pw.print(value) }\nfun println(value : Any) { pw.println(value) }\n\n// Extensions\nfun List.toBuckets(): Map\n\t= this.groupBy { it }.mapValues { it.value.size }\n\nfun> Array.upperBound(element: T, fromIndex: Int=0, toIndex: Int=this.size): Int\n\t= this.toList().upperBound(element, fromIndex, toIndex)\n\nfun> List.upperBound(element: T, fromIndex: Int=0, toIndex: Int=this.size): Int {\n\tvar l = fromIndex\n\tvar r = toIndex\n\twhile(l < r) {\n\t\tval mid = (l+r) / 2\n\t\tif(element >= this[mid]) { \n\t\t\tl = mid + 1\n\t\t} else {\n\t\t\tr = mid\n\t\t}\n\t}\n\treturn l\n}\n\nfun> Array.lowerBound(element: T, fromIndex: Int=0, toIndex: Int=this.size): Int\n\t= this.toList().lowerBound(element, fromIndex, toIndex)\n\nfun> List.lowerBound(element: T, fromIndex: Int=0, toIndex: Int=this.size): Int {\n\tvar l = fromIndex\n\tvar r = toIndex\n\twhile(l < r) {\n\t\tval mid = (l+r) / 2\n\t\tif(element > this[mid]) { \n\t\t\tl = mid + 1\n\t\t} else {\n\t\t\tr = mid\n\t\t}\n\t}\n\treturn r \n}\n\nfun Map.toMutableMap(): MutableMap = HashMap(this)\n\n// Util Functions\nfun Long.makeDivisors(): List {\n\tval divisors = mutableListOf()\n\tfor(i in 1L .. Math.sqrt(this.toDouble()).toLong()+1L) {\n\t\tif(this % i == 0L) {\n\t\t\tdivisors.add(i)\n\t\t\tif(i != this/i) {\n\t\t\t\tdivisors.add(this/i)\n\t\t\t}\n\t\t}\n\t}\n\treturn divisors.distinct().sorted()\n}\n\nfun Long.isPrime(): Boolean {\n\tif(this==1L) return false\n\tfor(i in 2L .. Math.sqrt(this.toDouble()).toLong() + 1L) {\n\t\tif(this % i == 0L && this != i) {\n\t\t\treturn false\n\t\t}\n\t}\n\treturn true\n}\n\nfun Long.primeFactorize(): Map {\n\tval map = mutableMapOf()\n\tvar num = this\n\tfor(i in 2L .. Math.sqrt(num.toDouble()).toLong()+1L) {\n\t\tif(num % i == 0L) {\n\t\t\twhile(num % i == 0L) {\n\t\t\t\tmap[i] = (map[i]?:0) + 1\n\t\t\t\tnum /= i\n\t\t\t}\n\t\t}\n\t}\n\tif(num != 1L) {\n\t\tmap[this] = 1 \n\t}\n\treturn map\n}\n\nfun permutations(src: List): List> {\n\tif(src.size == 1) return listOf(src)\n\tval perms = mutableListOf>()\n\tval insertElement = src[0]\n\tpermutations(src.drop(1)).forEach { perm ->\n\t\tfor(i in 0..perm.size) {\n\t\t\tval newPerm = perm.toMutableList()\n\t\t\tnewPerm.add(i, insertElement)\n\t\t\tperms.add(newPerm.toList())\n\t\t}\n\t}\n\treturn perms\n}\n\n// return nCr, if you want nCr, please access v[n][r]\nfun combinations(n: Long): List> {\n\tval v = (0..n).map { (0..n).map{0L}.toMutableList() }.toMutableList()\n\tfor(i in 0 until v.size) {\n\t\tv[i][0] = 1L\n\t\tv[i][i] = 1L\n\t}\n\tfor(i in 0 until v.size) {\n\t\tfor(j in 1 until i) {\n\t\t\tv[i][j] = (v[i-1][j-1] + v[i-1][j]) % MOD\n\t\t}\n\t}\n\treturn v.map { it.toList() }.toList()\n}\n\nfun repeatedModPow(a: Long, n: Long, mod: Long): Long = \n\twhen {\n\t\tn == 0L -> 1L\n\t\tn == 1L -> a % mod\n\t\tn % 2L == 1L -> (a * repeatedModPow(a, n-1L, mod)) % mod\n\t\telse -> {\n\t\t\tval tmp = repeatedModPow(a, n / 2L, mod)\n\t\t\t(tmp * tmp) % mod\n\t\t}\n\t}\n\n// return nCr % MOD\nfun modnCkWithoutArray(n: Long, k: Long, mod: Long): Long {\n\tvar ret = 1L\n\tval min = Math.min(k, n-k)\n\t// まず分母の計算\n\tfor(i in n downTo (n - min + 1)) {\n\t\tret = ret * i % mod\n\t}\n\tfor(i in min downTo 1) {\n\t\tret = ret * repeatedModPow(i, (mod - 2L), mod) % mod\n\t}\n\treturn ret\n}\n\n// return nCr % MOD\nfun modnCk(n: Int, k: Int, mod: Long): Long {\n\tval factorials = Array(n+1) { 0L }.apply {\n\t\tthis[0] = 1L\n\t\tif(this.size > 1) this[1] = 1L\n\t}\n\tval inverses = Array(n+1) { 0L }.apply {\n\t\tthis[0] = 1L\n\t\tif(this.size > 1) this[1] = 1L\n\t}\n\tval factorialInverses = Array(n+1) { 0L }.apply {\n\t\tthis[0] = 1L\n\t\tif(this.size > 1) this[1] = 1L\n\t}\n\tfor(i in 2 .. n) {\n\t\tfactorials[i] = (factorials[i-1] * i.toLong() % mod)\n\t\tinverses[i] = (mod - inverses[mod.toInt() % i] * (mod / i.toLong()) % mod)\n\t\tfactorialInverses[i] = (factorialInverses[i-1] * inverses[i] % mod)\n\t}\n\n\treturn factorials[n] % mod * (factorialInverses[k] * factorialInverses[n-k] % mod) % mod\n}\n\n// should be a >= b\nfun gcd(a: Long, b: Long): Long = \n\tif(b == 0L) a else gcd(b, a % b)\n\n// shoud be a >= b\nfun lcm(a: Long, b: Long): Long = \n\ta / gcd(a, b) * b\n\nfun sumDigits(num_: Long): Long {\n\tvar num = num_\n\tvar rtn: Long = 0\n\twhile(num != 0.toLong()) {\n\t\tval tmp = num % 10\n\t\trtn += tmp\n\t\tnum /= 10\n\t}\n\treturn rtn\n}\n\nfun Double.isDecimal(): Boolean = ((this - Math.floor(this)) != 0.0)\n\n// Data Structures\n\nclass UnionFind(private val n: Int) {\n\tprivate val parent: Array = Array(n) { 0 }\n\tprivate val rank: Array = Array(n) { 0 }\n\tprivate val size: Array = Array(n) { 0 }\n\n\tinit {\n\t\tfor(i in 0 until n) {\n\t\t\tparent[i] = i\n\t\t\trank[i] = 1\n\t\t\tsize[i] = 1\n\t\t}\n\t}\n\n\tfun union(u: Int, v: Int) {\n\t\tvar x = root(u)\n\t\tvar y = root(v)\n\t\tif(x != y) {\n\t\t\tif(rank[y] < rank[x]) {\n\t\t\t\tval tmp = y \n\t\t\t\ty = x\n\t\t\t\tx = tmp \n\t\t\t}\n\t\t\tparent[x] = y\n\t\t\trank[y] += rank[x]\n\t\t\trank[x] = -1\n\t\t\tval totalSize = size[x] + size[y]\n\t\t\tsize[x] = totalSize\n\t\t\tsize[y] = totalSize\n\t\t}\n\t}\n\n\tfun root(u: Int): Int {\n\t\tvar x = u\n\t\twhile(parent[x] != x) {\n\t\t\tx = parent[x]\n\t\t}\n\t\treturn x \n\t}\n\n\tfun size(u: Int): Int = size[root(u)]\n}\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 6104, "cpu_time_ms": 320, "memory_kb": 61912}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s913068014", "group_id": "codeNet:p02614", "input_text": "import kotlin.math.pow\n\nfun main() {\n val (h, w, k) = nextIntArray(3)\n val c = Array(h) { BooleanArray(w) }\n var total = 0\n repeat(h) { i ->\n val line = next()\n repeat(w) { j ->\n if (line[j] == '#') {\n total++\n c[i][j] = true\n }\n }\n }\n if (total < k) {\n return println(0)\n } else if (total == k) {\n return println(1)\n }\n val hmax = (2.0).pow(h).toInt()\n val wmax = (2.0).pow(w).toInt()\n var ans = 0\n for (hi in 0 until hmax) {\n for (hj in 0 until wmax) {\n var count = 0\n for (i in 0 until h) {\n for (j in 0 until w) {\n if (((hi shr i) % 2 == 1 || (hj shr j) % 2 == 1) && c[i][j]) {\n count++\n }\n }\n }\n if (total - count == k) {\n ans++\n }\n }\n }\n println(ans)\n}\n\nval sc = java.util.Scanner(System.`in`)\nfun next(): String = sc.next()\nfun nextInt() = sc.nextInt()\nfun nextIntArray(size: Int) = IntArray(size) { nextInt() }\nfun nextLong() = sc.nextLong()\nfun nextLine(): String = sc.nextLine()", "language": "Kotlin", "metadata": {"date": 1594000749, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02614.html", "problem_id": "p02614", "resource_group": "medium_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/Kotlin/s913068014.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s913068014", "user_id": "u896320985"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "import kotlin.math.pow\n\nfun main() {\n val (h, w, k) = nextIntArray(3)\n val c = Array(h) { BooleanArray(w) }\n var total = 0\n repeat(h) { i ->\n val line = next()\n repeat(w) { j ->\n if (line[j] == '#') {\n total++\n c[i][j] = true\n }\n }\n }\n if (total < k) {\n return println(0)\n } else if (total == k) {\n return println(1)\n }\n val hmax = (2.0).pow(h).toInt()\n val wmax = (2.0).pow(w).toInt()\n var ans = 0\n for (hi in 0 until hmax) {\n for (hj in 0 until wmax) {\n var count = 0\n for (i in 0 until h) {\n for (j in 0 until w) {\n if (((hi shr i) % 2 == 1 || (hj shr j) % 2 == 1) && c[i][j]) {\n count++\n }\n }\n }\n if (total - count == k) {\n ans++\n }\n }\n }\n println(ans)\n}\n\nval sc = java.util.Scanner(System.`in`)\nfun next(): String = sc.next()\nfun nextInt() = sc.nextInt()\nfun nextIntArray(size: Int) = IntArray(size) { nextInt() }\nfun nextLong() = sc.nextLong()\nfun nextLine(): String = sc.nextLine()", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 138, "memory_kb": 36604}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s238581460", "group_id": "codeNet:p02615", "input_text": "import java.io.BufferedReader\nimport java.io.BufferedWriter\n\nfun main() = Case().exec(::solve)\n\nfun solve(c: Case) {\n c.long().toInt()\n c.println(c.longList().sorted().drop(1).sum().toString())\n}\n\nclass Case(\n private val input: BufferedReader = System.`in`.bufferedReader(),\n private val out: BufferedWriter = System.out.bufferedWriter()\n) {\n fun exec(fn: (Case) -> Unit) = input.use { out.use { execInThread(fn) } }\n private fun execInThread(fn: (Case) -> Unit) =\n Thread(null, { fn(this) }, \"solve\", 64 * 1024 * 1024)\n .apply { setUncaughtExceptionHandler { _, e -> e.printStackTrace(); kotlin.system.exitProcess(1) } }\n .apply { start() }.join()\n\n fun println(c: CharSequence?) = out.appendln(c)\n fun string(): String = input.readLine().trimEnd()\n fun long(): Long = input.readLine().toLong()\n fun intList(): List = input.readLine().split(\" \").map { it.toInt() }\n fun longList(): List = input.readLine().split(\" \").map { it.toLong() }\n}", "language": "Kotlin", "metadata": {"date": 1600031588, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02615.html", "problem_id": "p02615", "resource_group": "medium_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/Kotlin/s238581460.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s238581460", "user_id": "u843036991"}, "prompt_components": {"gold_output": "7\n", "input_to_evaluate": "import java.io.BufferedReader\nimport java.io.BufferedWriter\n\nfun main() = Case().exec(::solve)\n\nfun solve(c: Case) {\n c.long().toInt()\n c.println(c.longList().sorted().drop(1).sum().toString())\n}\n\nclass Case(\n private val input: BufferedReader = System.`in`.bufferedReader(),\n private val out: BufferedWriter = System.out.bufferedWriter()\n) {\n fun exec(fn: (Case) -> Unit) = input.use { out.use { execInThread(fn) } }\n private fun execInThread(fn: (Case) -> Unit) =\n Thread(null, { fn(this) }, \"solve\", 64 * 1024 * 1024)\n .apply { setUncaughtExceptionHandler { _, e -> e.printStackTrace(); kotlin.system.exitProcess(1) } }\n .apply { start() }.join()\n\n fun println(c: CharSequence?) = out.appendln(c)\n fun string(): String = input.readLine().trimEnd()\n fun long(): Long = input.readLine().toLong()\n fun intList(): List = input.readLine().split(\" \").map { it.toInt() }\n fun longList(): List = input.readLine().split(\" \").map { it.toLong() }\n}", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1013, "cpu_time_ms": 663, "memory_kb": 66752}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s888146769", "group_id": "codeNet:p02615", "input_text": "fun main() {\n val n = nextInt()\n val a = nextIntArray(n)\n a.sortDescending()\n var sum = 0L\n var count = 1\n var current = a[0]\n var next = 0\n for (i in a.slice(1 until a.size)) {\n sum += current\n if (current == i) {\n count++\n } else {\n if (i > next) {\n next = i\n }\n count--\n }\n if (count == 0) {\n current = next\n next = 0\n count = 2\n }\n }\n println(sum)\n}\n\nval sc = java.util.Scanner(System.`in`)\nfun next(): String = sc.next()\nfun nextInt() = sc.nextInt()\nfun next2Int() = Pair(nextInt(), nextInt())\nfun next3Int() = Triple(nextInt(), nextInt(), nextInt())\nfun nextIntArray(size: Int) = IntArray(size) { nextInt() }\nfun nextLong() = sc.nextLong()\nfun nextLine(): String = sc.nextLine()", "language": "Kotlin", "metadata": {"date": 1594000292, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02615.html", "problem_id": "p02615", "resource_group": "medium_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/Kotlin/s888146769.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s888146769", "user_id": "u896320985"}, "prompt_components": {"gold_output": "7\n", "input_to_evaluate": "fun main() {\n val n = nextInt()\n val a = nextIntArray(n)\n a.sortDescending()\n var sum = 0L\n var count = 1\n var current = a[0]\n var next = 0\n for (i in a.slice(1 until a.size)) {\n sum += current\n if (current == i) {\n count++\n } else {\n if (i > next) {\n next = i\n }\n count--\n }\n if (count == 0) {\n current = next\n next = 0\n count = 2\n }\n }\n println(sum)\n}\n\nval sc = java.util.Scanner(System.`in`)\nfun next(): String = sc.next()\nfun nextInt() = sc.nextInt()\nfun next2Int() = Pair(nextInt(), nextInt())\nfun next3Int() = Triple(nextInt(), nextInt(), nextInt())\nfun nextIntArray(size: Int) = IntArray(size) { nextInt() }\nfun nextLong() = sc.nextLong()\nfun nextLine(): String = sc.nextLine()", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 848, "cpu_time_ms": 696, "memory_kb": 63516}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s948336673", "group_id": "codeNet:p02616", "input_text": "import kotlin.math.abs\n\nfun main() = Thread(null, ::abc173e, \"(^o^)\", 128 * 1024 * 1024).apply { start() }.join()\n\n@OptIn(ExperimentalStdlibApi::class)\nfun abc173e() {\n val (n, k) = readLine()!!.split(' ').map { it.toInt() }\n val aList = readLine()!!.split(' ').map { it.toLong() }\n\n val (positives, negatives) = aList\n .sortedByDescending { abs(it) }.partition { it >= 0 }.let { ArrayDeque(it.first) to ArrayDeque(it.second) }\n\n if (positives.isEmpty() && k % 2 != 0) return println(negatives.takeLast(k).fold(Mint(1), Mint::times))\n\n var answer = Mint(1)\n\n if (k % 2 != 0 && positives.isNotEmpty()) answer *= positives.removeFirst()\n\n repeat(k / 2) {\n when {\n positives.size >= 2 && negatives.size >= 2 -> {\n val (pos1, pos2) = positives.removeFirst() to positives.removeFirst()\n val pos = pos1 * pos2\n val (neg1, neg2) = negatives.removeFirst() to negatives.removeFirst()\n val neg = neg1 * neg2\n if (pos > neg) {\n answer *= pos\n negatives.apply {\n addFirst(neg2)\n addFirst(neg1)\n }\n } else {\n answer *= neg\n negatives.apply {\n addFirst(pos2)\n addFirst(pos1)\n }\n }\n }\n positives.size >= 2 -> answer *= positives.removeFirst() * positives.removeFirst()\n negatives.size >= 2 -> answer *= negatives.removeFirst() * negatives.removeFirst()\n }\n }\n\n println(answer)\n}\n\nprivate const val MOD = 1_000_000_007L\n\n@Suppress(\"unused\")\nprivate class Mint(value: Long = 0L) {\n constructor(other: Mint) : this(other.value)\n\n private val value = if (value < 0) (value % MOD) + MOD else value % MOD\n operator fun unaryPlus() = this\n operator fun unaryMinus() = Mint(MOD - this.value)\n operator fun inc() = this.plus(1)\n operator fun dec() = this.minus(1)\n operator fun plus(other: Long) = Mint(this.value + other)\n operator fun plus(other: Mint) = this.plus(other.value)\n operator fun minus(other: Long) = Mint(this.value - other)\n operator fun minus(other: Mint) = this.plus(-other)\n operator fun times(other: Long) = Mint(this.value * (other % MOD))\n operator fun times(other: Mint) = this.times(other.value)\n operator fun div(other: Long) = this.times(modPow(other, MOD - 2))\n operator fun div(other: Mint) = this.div(other.value)\n fun mod(mod: Long) = Mint(this.value % mod)\n fun modPow(other: Long) = Mint(modPow(this.value, other))\n fun toLong() = this.value\n override fun toString() = this.value.toString()\n override fun hashCode() = value.hashCode()\n override fun equals(other: Any?): Boolean {\n if (this === other) return true\n if (javaClass != other?.javaClass) return false\n other as Mint\n return value == other.value\n }\n\n companion object {\n private fun modPow(n: Long, p: Long): Long {\n var x = n % MOD\n var y = p\n var result = 1L\n while (y > 0) {\n if (y % 2 == 1L) result = (result * x) % MOD\n y = y shr 1\n x = (x * x) % MOD\n }\n return result\n }\n }\n}\n", "language": "Kotlin", "metadata": {"date": 1593991169, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02616.html", "problem_id": "p02616", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02616/input.txt", "sample_output_relpath": "derived/input_output/data/p02616/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02616/Kotlin/s948336673.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s948336673", "user_id": "u139478771"}, "prompt_components": {"gold_output": "12\n", "input_to_evaluate": "import kotlin.math.abs\n\nfun main() = Thread(null, ::abc173e, \"(^o^)\", 128 * 1024 * 1024).apply { start() }.join()\n\n@OptIn(ExperimentalStdlibApi::class)\nfun abc173e() {\n val (n, k) = readLine()!!.split(' ').map { it.toInt() }\n val aList = readLine()!!.split(' ').map { it.toLong() }\n\n val (positives, negatives) = aList\n .sortedByDescending { abs(it) }.partition { it >= 0 }.let { ArrayDeque(it.first) to ArrayDeque(it.second) }\n\n if (positives.isEmpty() && k % 2 != 0) return println(negatives.takeLast(k).fold(Mint(1), Mint::times))\n\n var answer = Mint(1)\n\n if (k % 2 != 0 && positives.isNotEmpty()) answer *= positives.removeFirst()\n\n repeat(k / 2) {\n when {\n positives.size >= 2 && negatives.size >= 2 -> {\n val (pos1, pos2) = positives.removeFirst() to positives.removeFirst()\n val pos = pos1 * pos2\n val (neg1, neg2) = negatives.removeFirst() to negatives.removeFirst()\n val neg = neg1 * neg2\n if (pos > neg) {\n answer *= pos\n negatives.apply {\n addFirst(neg2)\n addFirst(neg1)\n }\n } else {\n answer *= neg\n negatives.apply {\n addFirst(pos2)\n addFirst(pos1)\n }\n }\n }\n positives.size >= 2 -> answer *= positives.removeFirst() * positives.removeFirst()\n negatives.size >= 2 -> answer *= negatives.removeFirst() * negatives.removeFirst()\n }\n }\n\n println(answer)\n}\n\nprivate const val MOD = 1_000_000_007L\n\n@Suppress(\"unused\")\nprivate class Mint(value: Long = 0L) {\n constructor(other: Mint) : this(other.value)\n\n private val value = if (value < 0) (value % MOD) + MOD else value % MOD\n operator fun unaryPlus() = this\n operator fun unaryMinus() = Mint(MOD - this.value)\n operator fun inc() = this.plus(1)\n operator fun dec() = this.minus(1)\n operator fun plus(other: Long) = Mint(this.value + other)\n operator fun plus(other: Mint) = this.plus(other.value)\n operator fun minus(other: Long) = Mint(this.value - other)\n operator fun minus(other: Mint) = this.plus(-other)\n operator fun times(other: Long) = Mint(this.value * (other % MOD))\n operator fun times(other: Mint) = this.times(other.value)\n operator fun div(other: Long) = this.times(modPow(other, MOD - 2))\n operator fun div(other: Mint) = this.div(other.value)\n fun mod(mod: Long) = Mint(this.value % mod)\n fun modPow(other: Long) = Mint(modPow(this.value, other))\n fun toLong() = this.value\n override fun toString() = this.value.toString()\n override fun hashCode() = value.hashCode()\n override fun equals(other: Any?): Boolean {\n if (this === other) return true\n if (javaClass != other?.javaClass) return false\n other as Mint\n return value == other.value\n }\n\n companion object {\n private fun modPow(n: Long, p: Long): Long {\n var x = n % MOD\n var y = p\n var result = 1L\n while (y > 0) {\n if (y % 2 == 1L) result = (result * x) % MOD\n y = y shr 1\n x = (x * x) % MOD\n }\n return result\n }\n }\n}\n", "problem_context": "Score : 500 points\n\nProblem Statement\n\nGiven are N integers A_1,\\ldots,A_N.\n\nWe will choose exactly K of these elements. Find the maximum possible product of the chosen elements.\n\nThen, print the maximum product modulo (10^9+7), using an integer between 0 and 10^9+6 (inclusive).\n\nConstraints\n\n1 \\leq K \\leq N \\leq 2\\times 10^5\n\n|A_i| \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nA_1 \\ldots A_N\n\nOutput\n\nPrint the maximum product modulo (10^9+7), using an integer between 0 and 10^9+6 (inclusive).\n\nSample Input 1\n\n4 2\n1 2 -3 -4\n\nSample Output 1\n\n12\n\nThe possible products of the two chosen elements are 2, -3, -4, -6, -8, and 12, so the maximum product is 12.\n\nSample Input 2\n\n4 3\n-1 -2 -3 -4\n\nSample Output 2\n\n1000000001\n\nThe possible products of the three chosen elements are -24, -12, -8, and -6, so the maximum product is -6.\n\nWe print this value modulo (10^9+7), that is, 1000000001.\n\nSample Input 3\n\n2 1\n-1 1000000000\n\nSample Output 3\n\n1000000000\n\nThe possible products of the one chosen element are -1 and 1000000000, so the maximum product is 1000000000.\n\nSample Input 4\n\n10 10\n1000000000 100000000 10000000 1000000 100000 10000 1000 100 10 1\n\nSample Output 4\n\n999983200\n\nBe sure to print the product modulo (10^9+7).", "sample_input": "4 2\n1 2 -3 -4\n"}, "reference_outputs": ["12\n"], "source_document_id": "p02616", "source_text": "Score : 500 points\n\nProblem Statement\n\nGiven are N integers A_1,\\ldots,A_N.\n\nWe will choose exactly K of these elements. Find the maximum possible product of the chosen elements.\n\nThen, print the maximum product modulo (10^9+7), using an integer between 0 and 10^9+6 (inclusive).\n\nConstraints\n\n1 \\leq K \\leq N \\leq 2\\times 10^5\n\n|A_i| \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nA_1 \\ldots A_N\n\nOutput\n\nPrint the maximum product modulo (10^9+7), using an integer between 0 and 10^9+6 (inclusive).\n\nSample Input 1\n\n4 2\n1 2 -3 -4\n\nSample Output 1\n\n12\n\nThe possible products of the two chosen elements are 2, -3, -4, -6, -8, and 12, so the maximum product is 12.\n\nSample Input 2\n\n4 3\n-1 -2 -3 -4\n\nSample Output 2\n\n1000000001\n\nThe possible products of the three chosen elements are -24, -12, -8, and -6, so the maximum product is -6.\n\nWe print this value modulo (10^9+7), that is, 1000000001.\n\nSample Input 3\n\n2 1\n-1 1000000000\n\nSample Output 3\n\n1000000000\n\nThe possible products of the one chosen element are -1 and 1000000000, so the maximum product is 1000000000.\n\nSample Input 4\n\n10 10\n1000000000 100000000 10000000 1000000 100000 10000 1000 100 10 1\n\nSample Output 4\n\n999983200\n\nBe sure to print the product modulo (10^9+7).", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 3375, "cpu_time_ms": 769, "memory_kb": 78860}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s375482157", "group_id": "codeNet:p02616", "input_text": "fun main() {\n val mod = 1000000007L\n val (n, k) = readInts()\n val a = readInts().map { it.toLong() }\n val positives = a.filter { it > 0L }.sorted().reversed()\n val zeros = a.filter { it == 0L }\n val negatives = a.filter { it < 0L }.sorted()\n\n fun mapNumToMod(num: Long): Long {\n val times = kotlin.math.abs(num / mod) + 1\n return (times * mod + num) % mod\n }\n\n if (positives.isEmpty() && zeros.isEmpty()) {\n val prod = negatives.reversed().subList(0, k).map {\n mapNumToMod(it)\n }.reduce { acc, num ->\n (acc * num) % mod\n }\n println(prod)\n } else if (positives.isEmpty()) println(0)\n else if (n - zeros.size < k) println(0)\n else {\n// negatives = negatives.map { kotlin.math.abs(it) }\n val combined = mutableListOf()\n var pos = 0\n var neg = 0\n if (k % 2 == 1) {\n combined.add(positives[pos])\n pos++\n }\n while (combined.size < k) {\n if (pos + 2 <= positives.size && neg + 2 <= negatives.size) {\n if (positives[pos] * positives[pos + 1] >= negatives[neg] * negatives[neg + 1]) {\n combined.add(positives[pos])\n combined.add(positives[pos + 1])\n pos += 2\n } else {\n combined.add(negatives[neg])\n combined.add(negatives[neg + 1])\n neg += 2\n }\n } else if (pos + 2 <= positives.size) {\n combined.add(positives[pos])\n combined.add(positives[pos + 1])\n pos += 2\n } else if (neg + 2 <= positives.size) {\n combined.add(negatives[neg])\n combined.add(negatives[neg + 1])\n neg += 2\n } else {\n if (pos < positives.size) {\n combined.add(positives[pos])\n pos++\n } else if (neg < negatives.size) {\n combined.add(negatives[neg])\n neg++\n }\n }\n }\n if (neg % 2 == 1 && zeros.isNotEmpty()) println(0)\n else println(combined.map { mapNumToMod(it) }.reduce { acc, num -> (acc * num) % mod })\n// println(combined)\n }\n\n}\n\n// Input Reader\nprivate fun readLn() = readLine()!!\n\nprivate fun readStrings() = readLn().trim().split(\" \")\nprivate fun readInts() = readStrings().map { it.toInt() }\n", "language": "Kotlin", "metadata": {"date": 1593990124, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02616.html", "problem_id": "p02616", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02616/input.txt", "sample_output_relpath": "derived/input_output/data/p02616/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02616/Kotlin/s375482157.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s375482157", "user_id": "u984465701"}, "prompt_components": {"gold_output": "12\n", "input_to_evaluate": "fun main() {\n val mod = 1000000007L\n val (n, k) = readInts()\n val a = readInts().map { it.toLong() }\n val positives = a.filter { it > 0L }.sorted().reversed()\n val zeros = a.filter { it == 0L }\n val negatives = a.filter { it < 0L }.sorted()\n\n fun mapNumToMod(num: Long): Long {\n val times = kotlin.math.abs(num / mod) + 1\n return (times * mod + num) % mod\n }\n\n if (positives.isEmpty() && zeros.isEmpty()) {\n val prod = negatives.reversed().subList(0, k).map {\n mapNumToMod(it)\n }.reduce { acc, num ->\n (acc * num) % mod\n }\n println(prod)\n } else if (positives.isEmpty()) println(0)\n else if (n - zeros.size < k) println(0)\n else {\n// negatives = negatives.map { kotlin.math.abs(it) }\n val combined = mutableListOf()\n var pos = 0\n var neg = 0\n if (k % 2 == 1) {\n combined.add(positives[pos])\n pos++\n }\n while (combined.size < k) {\n if (pos + 2 <= positives.size && neg + 2 <= negatives.size) {\n if (positives[pos] * positives[pos + 1] >= negatives[neg] * negatives[neg + 1]) {\n combined.add(positives[pos])\n combined.add(positives[pos + 1])\n pos += 2\n } else {\n combined.add(negatives[neg])\n combined.add(negatives[neg + 1])\n neg += 2\n }\n } else if (pos + 2 <= positives.size) {\n combined.add(positives[pos])\n combined.add(positives[pos + 1])\n pos += 2\n } else if (neg + 2 <= positives.size) {\n combined.add(negatives[neg])\n combined.add(negatives[neg + 1])\n neg += 2\n } else {\n if (pos < positives.size) {\n combined.add(positives[pos])\n pos++\n } else if (neg < negatives.size) {\n combined.add(negatives[neg])\n neg++\n }\n }\n }\n if (neg % 2 == 1 && zeros.isNotEmpty()) println(0)\n else println(combined.map { mapNumToMod(it) }.reduce { acc, num -> (acc * num) % mod })\n// println(combined)\n }\n\n}\n\n// Input Reader\nprivate fun readLn() = readLine()!!\n\nprivate fun readStrings() = readLn().trim().split(\" \")\nprivate fun readInts() = readStrings().map { it.toInt() }\n", "problem_context": "Score : 500 points\n\nProblem Statement\n\nGiven are N integers A_1,\\ldots,A_N.\n\nWe will choose exactly K of these elements. Find the maximum possible product of the chosen elements.\n\nThen, print the maximum product modulo (10^9+7), using an integer between 0 and 10^9+6 (inclusive).\n\nConstraints\n\n1 \\leq K \\leq N \\leq 2\\times 10^5\n\n|A_i| \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nA_1 \\ldots A_N\n\nOutput\n\nPrint the maximum product modulo (10^9+7), using an integer between 0 and 10^9+6 (inclusive).\n\nSample Input 1\n\n4 2\n1 2 -3 -4\n\nSample Output 1\n\n12\n\nThe possible products of the two chosen elements are 2, -3, -4, -6, -8, and 12, so the maximum product is 12.\n\nSample Input 2\n\n4 3\n-1 -2 -3 -4\n\nSample Output 2\n\n1000000001\n\nThe possible products of the three chosen elements are -24, -12, -8, and -6, so the maximum product is -6.\n\nWe print this value modulo (10^9+7), that is, 1000000001.\n\nSample Input 3\n\n2 1\n-1 1000000000\n\nSample Output 3\n\n1000000000\n\nThe possible products of the one chosen element are -1 and 1000000000, so the maximum product is 1000000000.\n\nSample Input 4\n\n10 10\n1000000000 100000000 10000000 1000000 100000 10000 1000 100 10 1\n\nSample Output 4\n\n999983200\n\nBe sure to print the product modulo (10^9+7).", "sample_input": "4 2\n1 2 -3 -4\n"}, "reference_outputs": ["12\n"], "source_document_id": "p02616", "source_text": "Score : 500 points\n\nProblem Statement\n\nGiven are N integers A_1,\\ldots,A_N.\n\nWe will choose exactly K of these elements. Find the maximum possible product of the chosen elements.\n\nThen, print the maximum product modulo (10^9+7), using an integer between 0 and 10^9+6 (inclusive).\n\nConstraints\n\n1 \\leq K \\leq N \\leq 2\\times 10^5\n\n|A_i| \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nA_1 \\ldots A_N\n\nOutput\n\nPrint the maximum product modulo (10^9+7), using an integer between 0 and 10^9+6 (inclusive).\n\nSample Input 1\n\n4 2\n1 2 -3 -4\n\nSample Output 1\n\n12\n\nThe possible products of the two chosen elements are 2, -3, -4, -6, -8, and 12, so the maximum product is 12.\n\nSample Input 2\n\n4 3\n-1 -2 -3 -4\n\nSample Output 2\n\n1000000001\n\nThe possible products of the three chosen elements are -24, -12, -8, and -6, so the maximum product is -6.\n\nWe print this value modulo (10^9+7), that is, 1000000001.\n\nSample Input 3\n\n2 1\n-1 1000000000\n\nSample Output 3\n\n1000000000\n\nThe possible products of the one chosen element are -1 and 1000000000, so the maximum product is 1000000000.\n\nSample Input 4\n\n10 10\n1000000000 100000000 10000000 1000000 100000 10000 1000 100 10 1\n\nSample Output 4\n\n999983200\n\nBe sure to print the product modulo (10^9+7).", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2493, "cpu_time_ms": 880, "memory_kb": 77888}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s617757388", "group_id": "codeNet:p02617", "input_text": "import java.io.BufferedReader\nimport java.io.InputStream\nimport java.io.InputStreamReader\nimport java.io.PrintWriter\nimport java.util.*\n\nfun PrintWriter.solve(sc: FastScanner) {\n val n = sc.nextInt()\n var ans = 0L\n for (i in 1..n) {\n ans += i * (i + 1L) / 2\n }\n for (i in 0 until n - 1) {\n val u = sc.nextInt()\n val v = sc.nextInt()\n val a = minOf(u, v)\n val b = maxOf(u, v)\n ans -= a * (n - b + 1L)\n }\n println(ans)\n}\n\nfun main() {\n val writer = PrintWriter(System.out, false)\n writer.solve(FastScanner(System.`in`))\n writer.flush()\n}\n\nclass FastScanner(s: InputStream) {\n private var st = StringTokenizer(\"\")\n private val br = BufferedReader(InputStreamReader(s))\n\n fun next(): String {\n while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())\n\n return st.nextToken()\n }\n\n fun nextInt() = next().toInt()\n fun nextLong() = next().toLong()\n fun nextLine() = br.readLine()\n fun nextDouble() = next().toDouble()\n fun ready() = br.ready()\n}\n", "language": "Kotlin", "metadata": {"date": 1594220329, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02617.html", "problem_id": "p02617", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02617/input.txt", "sample_output_relpath": "derived/input_output/data/p02617/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02617/Kotlin/s617757388.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s617757388", "user_id": "u190507186"}, "prompt_components": {"gold_output": "7\n", "input_to_evaluate": "import java.io.BufferedReader\nimport java.io.InputStream\nimport java.io.InputStreamReader\nimport java.io.PrintWriter\nimport java.util.*\n\nfun PrintWriter.solve(sc: FastScanner) {\n val n = sc.nextInt()\n var ans = 0L\n for (i in 1..n) {\n ans += i * (i + 1L) / 2\n }\n for (i in 0 until n - 1) {\n val u = sc.nextInt()\n val v = sc.nextInt()\n val a = minOf(u, v)\n val b = maxOf(u, v)\n ans -= a * (n - b + 1L)\n }\n println(ans)\n}\n\nfun main() {\n val writer = PrintWriter(System.out, false)\n writer.solve(FastScanner(System.`in`))\n writer.flush()\n}\n\nclass FastScanner(s: InputStream) {\n private var st = StringTokenizer(\"\")\n private val br = BufferedReader(InputStreamReader(s))\n\n fun next(): String {\n while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())\n\n return st.nextToken()\n }\n\n fun nextInt() = next().toInt()\n fun nextLong() = next().toLong()\n fun nextLine() = br.readLine()\n fun nextDouble() = next().toDouble()\n fun ready() = br.ready()\n}\n", "problem_context": "Score : 600 points\n\nProblem Statement\n\nWe have a tree with N vertices and N-1 edges, respectively numbered 1, 2,\\cdots, N and 1, 2, \\cdots, N-1. Edge i connects Vertex u_i and v_i.\n\nFor integers L, R (1 \\leq L \\leq R \\leq N), let us define a function f(L, R) as follows:\n\nLet S be the set of the vertices numbered L through R. f(L, R) represents the number of connected components in the subgraph formed only from the vertex set S and the edges whose endpoints both belong to S.\n\nCompute \\sum_{L=1}^{N} \\sum_{R=L}^{N} f(L, R).\n\nConstraints\n\n1 \\leq N \\leq 2 \\times 10^5\n\n1 \\leq u_i, v_i \\leq N\n\nThe given graph is a tree.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nu_1 v_1\nu_2 v_2\n:\nu_{N-1} v_{N-1}\n\nOutput\n\nPrint \\sum_{L=1}^{N} \\sum_{R=L}^{N} f(L, R).\n\nSample Input 1\n\n3\n1 3\n2 3\n\nSample Output 1\n\n7\n\nWe have six possible pairs (L, R) as follows:\n\nFor L = 1, R = 1, S = \\{1\\} and we have 1 connected component.\n\nFor L = 1, R = 2, S = \\{1, 2\\} and we have 2 connected components.\n\nFor L = 1, R = 3, S = \\{1, 2, 3\\} and we have 1 connected component, since S contains both endpoints of each of the edges 1, 2.\n\nFor L = 2, R = 2, S = \\{2\\} and we have 1 connected component.\n\nFor L = 2, R = 3, S = \\{2, 3\\} and we have 1 connected component, since S contains both endpoints of Edge 2.\n\nFor L = 3, R = 3, S = \\{3\\} and we have 1 connected component.\n\nThe sum of these is 7.\n\nSample Input 2\n\n2\n1 2\n\nSample Output 2\n\n3\n\nSample Input 3\n\n10\n5 3\n5 7\n8 9\n1 9\n9 10\n8 4\n7 4\n6 10\n7 2\n\nSample Output 3\n\n113", "sample_input": "3\n1 3\n2 3\n"}, "reference_outputs": ["7\n"], "source_document_id": "p02617", "source_text": "Score : 600 points\n\nProblem Statement\n\nWe have a tree with N vertices and N-1 edges, respectively numbered 1, 2,\\cdots, N and 1, 2, \\cdots, N-1. Edge i connects Vertex u_i and v_i.\n\nFor integers L, R (1 \\leq L \\leq R \\leq N), let us define a function f(L, R) as follows:\n\nLet S be the set of the vertices numbered L through R. f(L, R) represents the number of connected components in the subgraph formed only from the vertex set S and the edges whose endpoints both belong to S.\n\nCompute \\sum_{L=1}^{N} \\sum_{R=L}^{N} f(L, R).\n\nConstraints\n\n1 \\leq N \\leq 2 \\times 10^5\n\n1 \\leq u_i, v_i \\leq N\n\nThe given graph is a tree.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nu_1 v_1\nu_2 v_2\n:\nu_{N-1} v_{N-1}\n\nOutput\n\nPrint \\sum_{L=1}^{N} \\sum_{R=L}^{N} f(L, R).\n\nSample Input 1\n\n3\n1 3\n2 3\n\nSample Output 1\n\n7\n\nWe have six possible pairs (L, R) as follows:\n\nFor L = 1, R = 1, S = \\{1\\} and we have 1 connected component.\n\nFor L = 1, R = 2, S = \\{1, 2\\} and we have 2 connected components.\n\nFor L = 1, R = 3, S = \\{1, 2, 3\\} and we have 1 connected component, since S contains both endpoints of each of the edges 1, 2.\n\nFor L = 2, R = 2, S = \\{2\\} and we have 1 connected component.\n\nFor L = 2, R = 3, S = \\{2, 3\\} and we have 1 connected component, since S contains both endpoints of Edge 2.\n\nFor L = 3, R = 3, S = \\{3\\} and we have 1 connected component.\n\nThe sum of these is 7.\n\nSample Input 2\n\n2\n1 2\n\nSample Output 2\n\n3\n\nSample Input 3\n\n10\n5 3\n5 7\n8 9\n1 9\n9 10\n8 4\n7 4\n6 10\n7 2\n\nSample Output 3\n\n113", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1059, "cpu_time_ms": 308, "memory_kb": 57612}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s613754134", "group_id": "codeNet:p02617", "input_text": "import java.io.BufferedReader\nimport java.io.InputStream\nimport java.io.InputStreamReader\nimport java.util.*\nimport kotlin.math.abs\nimport kotlin.math.max\nimport kotlin.math.min\n\nval MOD = 1_000_000_007L\nfun packUGraph(n: Int, from: IntArray, to: IntArray): Array {\n val p = IntArray(n)\n val m = from.size\n for (i in 0 until m) {\n ++p[from[i]]\n ++p[to[i]]\n }\n val g = Array(n){IntArray(p[it])}\n for (i in 0 until m) {\n g[from[i]][--p[from[i]]] = to[i]\n g[to[i]][--p[to[i]]] = from[i]\n }\n return g\n}\nclass Solver(stream: InputStream, private val out: java.io.PrintWriter) {\n fun solve() {\n val N = ni()\n val (from, to) = na2(N - 1, - 1)\n val g = packUGraph(N, from, to)\n var edges = 0L\n var ans = 0L\n for (i in 0 until N) {\n for (j in g[i]) {\n if (j >= i) continue\n edges += j + 1\n }\n ans += (i + 1) * (i + 2) / 2\n ans -= edges\n }\n out.println(ans)\n }\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n private val isDebug = try {\n // なんか本番でエラーでる\n System.getenv(\"MY_DEBUG\") != null\n } catch (t: Throwable) {\n false\n }\n\n private var tokenizer: StringTokenizer? = null\n private val reader = BufferedReader(InputStreamReader(stream), 32768)\n private fun next(): String {\n while (tokenizer == null || !tokenizer!!.hasMoreTokens()) {\n tokenizer = StringTokenizer(reader.readLine())\n }\n return tokenizer!!.nextToken()\n }\n\n private fun ni() = next().toInt()\n private fun nl() = next().toLong()\n private fun ns() = next()\n private fun na(n: Int, offset: Int = 0): IntArray {\n return map(n) { ni() + offset }\n }\n private fun nal(n: Int, offset: Int = 0): LongArray {\n val res = LongArray(n)\n for (i in 0 until n) {\n res[i] = nl() + offset\n }\n return res\n }\n\n private fun na2(n: Int, offset: Int = 0): Array {\n val a = Array(2){IntArray(n)}\n for (i in 0 until n) {\n for (e in a) {\n e[i] = ni() + offset\n }\n }\n return a\n }\n\n private inline fun map(n: Int, f: (Int) -> Int): IntArray {\n val res = IntArray(n)\n for (i in 0 until n) {\n res[i] = f(i)\n }\n return res\n }\n\n private inline fun debug(msg: () -> String) {\n if (isDebug) System.err.println(msg())\n }\n\n private fun debug(a: LongArray) {\n debug { a.joinToString(\" \") }\n }\n\n private fun debug(a: IntArray) {\n debug { a.joinToString(\" \") }\n }\n\n private fun debug(a: BooleanArray) {\n debug { a.map { if (it) 1 else 0 }.joinToString(\"\") }\n }\n\n private fun debugDim(A: Array) {\n if (isDebug) {\n for (a in A) {\n debug(a)\n }\n }\n }\n private fun debugDim(A: Array) {\n if (isDebug) {\n for (a in A) {\n debug(a)\n }\n }\n }\n\n /**\n * 勝手にimport消されるのを防ぎたい\n */\n private fun hoge() {\n min(1, 2)\n max(1, 2)\n abs(-10)\n }\n}\n\nfun main() {\n val out = java.io.PrintWriter(System.out)\n Solver(System.`in`, out).solve()\n out.flush()\n}\n", "language": "Kotlin", "metadata": {"date": 1593980106, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02617.html", "problem_id": "p02617", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02617/input.txt", "sample_output_relpath": "derived/input_output/data/p02617/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02617/Kotlin/s613754134.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s613754134", "user_id": "u460609472"}, "prompt_components": {"gold_output": "7\n", "input_to_evaluate": "import java.io.BufferedReader\nimport java.io.InputStream\nimport java.io.InputStreamReader\nimport java.util.*\nimport kotlin.math.abs\nimport kotlin.math.max\nimport kotlin.math.min\n\nval MOD = 1_000_000_007L\nfun packUGraph(n: Int, from: IntArray, to: IntArray): Array {\n val p = IntArray(n)\n val m = from.size\n for (i in 0 until m) {\n ++p[from[i]]\n ++p[to[i]]\n }\n val g = Array(n){IntArray(p[it])}\n for (i in 0 until m) {\n g[from[i]][--p[from[i]]] = to[i]\n g[to[i]][--p[to[i]]] = from[i]\n }\n return g\n}\nclass Solver(stream: InputStream, private val out: java.io.PrintWriter) {\n fun solve() {\n val N = ni()\n val (from, to) = na2(N - 1, - 1)\n val g = packUGraph(N, from, to)\n var edges = 0L\n var ans = 0L\n for (i in 0 until N) {\n for (j in g[i]) {\n if (j >= i) continue\n edges += j + 1\n }\n ans += (i + 1) * (i + 2) / 2\n ans -= edges\n }\n out.println(ans)\n }\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n private val isDebug = try {\n // なんか本番でエラーでる\n System.getenv(\"MY_DEBUG\") != null\n } catch (t: Throwable) {\n false\n }\n\n private var tokenizer: StringTokenizer? = null\n private val reader = BufferedReader(InputStreamReader(stream), 32768)\n private fun next(): String {\n while (tokenizer == null || !tokenizer!!.hasMoreTokens()) {\n tokenizer = StringTokenizer(reader.readLine())\n }\n return tokenizer!!.nextToken()\n }\n\n private fun ni() = next().toInt()\n private fun nl() = next().toLong()\n private fun ns() = next()\n private fun na(n: Int, offset: Int = 0): IntArray {\n return map(n) { ni() + offset }\n }\n private fun nal(n: Int, offset: Int = 0): LongArray {\n val res = LongArray(n)\n for (i in 0 until n) {\n res[i] = nl() + offset\n }\n return res\n }\n\n private fun na2(n: Int, offset: Int = 0): Array {\n val a = Array(2){IntArray(n)}\n for (i in 0 until n) {\n for (e in a) {\n e[i] = ni() + offset\n }\n }\n return a\n }\n\n private inline fun map(n: Int, f: (Int) -> Int): IntArray {\n val res = IntArray(n)\n for (i in 0 until n) {\n res[i] = f(i)\n }\n return res\n }\n\n private inline fun debug(msg: () -> String) {\n if (isDebug) System.err.println(msg())\n }\n\n private fun debug(a: LongArray) {\n debug { a.joinToString(\" \") }\n }\n\n private fun debug(a: IntArray) {\n debug { a.joinToString(\" \") }\n }\n\n private fun debug(a: BooleanArray) {\n debug { a.map { if (it) 1 else 0 }.joinToString(\"\") }\n }\n\n private fun debugDim(A: Array) {\n if (isDebug) {\n for (a in A) {\n debug(a)\n }\n }\n }\n private fun debugDim(A: Array) {\n if (isDebug) {\n for (a in A) {\n debug(a)\n }\n }\n }\n\n /**\n * 勝手にimport消されるのを防ぎたい\n */\n private fun hoge() {\n min(1, 2)\n max(1, 2)\n abs(-10)\n }\n}\n\nfun main() {\n val out = java.io.PrintWriter(System.out)\n Solver(System.`in`, out).solve()\n out.flush()\n}\n", "problem_context": "Score : 600 points\n\nProblem Statement\n\nWe have a tree with N vertices and N-1 edges, respectively numbered 1, 2,\\cdots, N and 1, 2, \\cdots, N-1. Edge i connects Vertex u_i and v_i.\n\nFor integers L, R (1 \\leq L \\leq R \\leq N), let us define a function f(L, R) as follows:\n\nLet S be the set of the vertices numbered L through R. f(L, R) represents the number of connected components in the subgraph formed only from the vertex set S and the edges whose endpoints both belong to S.\n\nCompute \\sum_{L=1}^{N} \\sum_{R=L}^{N} f(L, R).\n\nConstraints\n\n1 \\leq N \\leq 2 \\times 10^5\n\n1 \\leq u_i, v_i \\leq N\n\nThe given graph is a tree.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nu_1 v_1\nu_2 v_2\n:\nu_{N-1} v_{N-1}\n\nOutput\n\nPrint \\sum_{L=1}^{N} \\sum_{R=L}^{N} f(L, R).\n\nSample Input 1\n\n3\n1 3\n2 3\n\nSample Output 1\n\n7\n\nWe have six possible pairs (L, R) as follows:\n\nFor L = 1, R = 1, S = \\{1\\} and we have 1 connected component.\n\nFor L = 1, R = 2, S = \\{1, 2\\} and we have 2 connected components.\n\nFor L = 1, R = 3, S = \\{1, 2, 3\\} and we have 1 connected component, since S contains both endpoints of each of the edges 1, 2.\n\nFor L = 2, R = 2, S = \\{2\\} and we have 1 connected component.\n\nFor L = 2, R = 3, S = \\{2, 3\\} and we have 1 connected component, since S contains both endpoints of Edge 2.\n\nFor L = 3, R = 3, S = \\{3\\} and we have 1 connected component.\n\nThe sum of these is 7.\n\nSample Input 2\n\n2\n1 2\n\nSample Output 2\n\n3\n\nSample Input 3\n\n10\n5 3\n5 7\n8 9\n1 9\n9 10\n8 4\n7 4\n6 10\n7 2\n\nSample Output 3\n\n113", "sample_input": "3\n1 3\n2 3\n"}, "reference_outputs": ["7\n"], "source_document_id": "p02617", "source_text": "Score : 600 points\n\nProblem Statement\n\nWe have a tree with N vertices and N-1 edges, respectively numbered 1, 2,\\cdots, N and 1, 2, \\cdots, N-1. Edge i connects Vertex u_i and v_i.\n\nFor integers L, R (1 \\leq L \\leq R \\leq N), let us define a function f(L, R) as follows:\n\nLet S be the set of the vertices numbered L through R. f(L, R) represents the number of connected components in the subgraph formed only from the vertex set S and the edges whose endpoints both belong to S.\n\nCompute \\sum_{L=1}^{N} \\sum_{R=L}^{N} f(L, R).\n\nConstraints\n\n1 \\leq N \\leq 2 \\times 10^5\n\n1 \\leq u_i, v_i \\leq N\n\nThe given graph is a tree.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nu_1 v_1\nu_2 v_2\n:\nu_{N-1} v_{N-1}\n\nOutput\n\nPrint \\sum_{L=1}^{N} \\sum_{R=L}^{N} f(L, R).\n\nSample Input 1\n\n3\n1 3\n2 3\n\nSample Output 1\n\n7\n\nWe have six possible pairs (L, R) as follows:\n\nFor L = 1, R = 1, S = \\{1\\} and we have 1 connected component.\n\nFor L = 1, R = 2, S = \\{1, 2\\} and we have 2 connected components.\n\nFor L = 1, R = 3, S = \\{1, 2, 3\\} and we have 1 connected component, since S contains both endpoints of each of the edges 1, 2.\n\nFor L = 2, R = 2, S = \\{2\\} and we have 1 connected component.\n\nFor L = 2, R = 3, S = \\{2, 3\\} and we have 1 connected component, since S contains both endpoints of Edge 2.\n\nFor L = 3, R = 3, S = \\{3\\} and we have 1 connected component.\n\nThe sum of these is 7.\n\nSample Input 2\n\n2\n1 2\n\nSample Output 2\n\n3\n\nSample Input 3\n\n10\n5 3\n5 7\n8 9\n1 9\n9 10\n8 4\n7 4\n6 10\n7 2\n\nSample Output 3\n\n113", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 3010, "cpu_time_ms": 335, "memory_kb": 62856}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s419108903", "group_id": "codeNet:p02621", "input_text": "\nfun main(args: Array) {\n // var numberTests = readLine()!!.toInt()\n // var results = mutableListOf()\n\n // for (i in 0..numberTests-1) {\n var tmpLine = readLine()\n\n \n val result = experiment(tmpLine!!.toInt())\n // results.add(result)\n // }\n\n // for (result in results) {\n println(result)\n // }\n}\n\nfun experiment(a: Int) : String {\n\n var result = a + a * a + a * a * a\n\n return result.toString()\n}", "language": "Kotlin", "metadata": {"date": 1593306412, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02621.html", "problem_id": "p02621", "resource_group": "medium_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/Kotlin/s419108903.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s419108903", "user_id": "u294297802"}, "prompt_components": {"gold_output": "14\n", "input_to_evaluate": "\nfun main(args: Array) {\n // var numberTests = readLine()!!.toInt()\n // var results = mutableListOf()\n\n // for (i in 0..numberTests-1) {\n var tmpLine = readLine()\n\n \n val result = experiment(tmpLine!!.toInt())\n // results.add(result)\n // }\n\n // for (result in results) {\n println(result)\n // }\n}\n\nfun experiment(a: Int) : String {\n\n var result = a + a * a + a * a * a\n\n return result.toString()\n}", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 102, "memory_kb": 34564}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s248447340", "group_id": "codeNet:p02621", "input_text": "import java.io.BufferedReader\n\nfun main() {\n val br = System.`in`.bufferedReader()\n val a = br.readInt()\n print(a + a * a + a * a * a)\n}\n\nprivate const val SPACE_INT = ' '.toInt()\nprivate const val ZERO_INT = '0'.toInt()\nprivate const val NL_INT = '\\n'.toInt()\n\nprivate fun BufferedReader.readInt(): Int {\n var ret = read()\n while (ret <= SPACE_INT) {\n ret = read()\n }\n val neg = ret == '-'.toInt()\n if (neg) {\n ret = read()\n }\n ret -= ZERO_INT\n var read = read()\n while (read >= ZERO_INT) {\n ret *= 10\n ret += read - ZERO_INT\n read = read()\n }\n\n while (read <= SPACE_INT && read != -1 && read != NL_INT) {\n mark(1)\n read = read()\n }\n if (read > SPACE_INT) {\n reset()\n }\n return if (neg) -ret else ret\n}", "language": "Kotlin", "metadata": {"date": 1593306069, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02621.html", "problem_id": "p02621", "resource_group": "medium_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/Kotlin/s248447340.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s248447340", "user_id": "u669089376"}, "prompt_components": {"gold_output": "14\n", "input_to_evaluate": "import java.io.BufferedReader\n\nfun main() {\n val br = System.`in`.bufferedReader()\n val a = br.readInt()\n print(a + a * a + a * a * a)\n}\n\nprivate const val SPACE_INT = ' '.toInt()\nprivate const val ZERO_INT = '0'.toInt()\nprivate const val NL_INT = '\\n'.toInt()\n\nprivate fun BufferedReader.readInt(): Int {\n var ret = read()\n while (ret <= SPACE_INT) {\n ret = read()\n }\n val neg = ret == '-'.toInt()\n if (neg) {\n ret = read()\n }\n ret -= ZERO_INT\n var read = read()\n while (read >= ZERO_INT) {\n ret *= 10\n ret += read - ZERO_INT\n read = read()\n }\n\n while (read <= SPACE_INT && read != -1 && read != NL_INT) {\n mark(1)\n read = read()\n }\n if (read > SPACE_INT) {\n reset()\n }\n return if (neg) -ret else ret\n}", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 813, "cpu_time_ms": 93, "memory_kb": 34288}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s860637609", "group_id": "codeNet:p02621", "input_text": "@file:Suppress(\"NOTHING_TO_INLINE\", \"EXPERIMENTAL_FEATURE_WARNING\", \"OVERRIDE_BY_INLINE\")\n\nimport java.io.File\nimport java.io.PrintWriter\nimport java.text.SimpleDateFormat\nimport java.util.Calendar\nimport java.util.TimeZone\nimport kotlin.math.*\nimport kotlin.random.Random\nimport kotlin.collections.sort as _sort\nimport kotlin.collections.sortDescending as _sortDescending\nimport kotlin.io.println as iprintln\n\n/** @author Spheniscine */\nfun main() { _writer.solve(); _writer.flush() }\nfun PrintWriter.solve() {\n// val startTime = System.nanoTime()\n\n val numCases = 1//readInt()\n case@ for(case in 1..numCases) {\n val a = readInt()\n\n val ans = a + a*a + a*a*a\n\n println(ans)\n }\n\n// iprintln(\"Time: ${(System.nanoTime() - startTime) / 1000000} ms\")\n}\n\n\n/** IO */\n//@JvmField val INPUT = File(\"input.txt\").inputStream()\n//@JvmField val OUTPUT = File(\"output.txt\").outputStream()\n@JvmField val INPUT = System.`in`\n@JvmField val OUTPUT = System.out\n\nconst val _BUFFER_SIZE = 1 shl 16\n@JvmField val _buffer = ByteArray(_BUFFER_SIZE)\n@JvmField var _bufferPt = 0\n@JvmField var _bytesRead = 0\n\ntailrec fun readChar(): Char {\n if(_bufferPt == _bytesRead) {\n _bufferPt = 0\n _bytesRead = INPUT.read(_buffer, 0, _BUFFER_SIZE)\n }\n return if(_bytesRead < 0) Char.MIN_VALUE\n else {\n val c = _buffer[_bufferPt++].toChar()\n if (c == '\\r') readChar()\n else c\n }\n}\n\nfun readLine(): String? {\n var c = readChar()\n return if(c == Char.MIN_VALUE) null\n else buildString {\n while(c != '\\n' && c != Char.MIN_VALUE) {\n append(c)\n c = readChar()\n }\n }\n}\nfun readLn() = readLine()!!\n\nfun read() = buildString {\n var c = readChar()\n while(c <= ' ') {\n if(c == Char.MIN_VALUE) return@buildString\n c = readChar()\n }\n do {\n append(c)\n c = readChar()\n } while(c > ' ')\n}\nfun readInt() = read().toInt()\nfun readDouble() = read().toDouble()\nfun readLong() = read().toLong()\nfun readStrings(n: Int) = List(n) { read() }\nfun readLines(n: Int) = List(n) { readLn() }\nfun readInts(n: Int) = List(n) { read().toInt() }\nfun readIntArray(n: Int) = IntArray(n) { read().toInt() }\nfun readDoubles(n: Int) = List(n) { read().toDouble() }\nfun readDoubleArray(n: Int) = DoubleArray(n) { read().toDouble() }\nfun readLongs(n: Int) = List(n) { read().toLong() }\nfun readLongArray(n: Int) = LongArray(n) { read().toLong() }\n\n@JvmField val _writer = PrintWriter(OUTPUT, false)\n\n/** shuffles and sort overrides to avoid quicksort attacks */\nprivate inline fun _shuffle(rnd: Random, get: (Int) -> T, set: (Int, T) -> Unit, size: Int) {\n // Fisher-Yates shuffle algorithm\n for (i in size - 1 downTo 1) {\n val j = rnd.nextInt(i + 1)\n val temp = get(i)\n set(i, get(j))\n set(j, temp)\n }\n}\n\n@JvmField var _random: Random? = null\nval random get() = _random ?: Random(0x594E215C123 * System.nanoTime()).also { _random = it }\n\nfun IntArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\nfun IntArray.sort() { shuffle(); _sort() }\nfun IntArray.sortDescending() { shuffle(); _sortDescending() }\n\nfun LongArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\nfun LongArray.sort() { shuffle(); _sort() }\nfun LongArray.sortDescending() { shuffle(); _sortDescending() }\n\nfun DoubleArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\nfun DoubleArray.sort() { shuffle(); _sort() }\nfun DoubleArray.sortDescending() { shuffle(); _sortDescending() }\n\nfun CharArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\ninline fun CharArray.sort() { _sort() }\ninline fun CharArray.sortDescending() { _sortDescending() }\n\ninline fun > Array.sort() = _sort()\ninline fun > Array.sortDescending() = _sortDescending()\ninline fun > MutableList.sort() = _sort()\ninline fun > MutableList.sortDescending() = _sortDescending()\n\nfun `please stop removing these imports IntelliJ`() { iprintln(max(1, 2)) }\n\n/** additional commons */\ninline fun Iterable.sumByLong(func: (T) -> Long) = fold(0L) { acc, t -> acc + func(t) }\ninline fun Sequence.sumByLong(func: (T) -> Long) = fold(0L) { acc, t -> acc + func(t) }\ninline fun Array.sumByLong(func: (T) -> Long) = fold(0L) { acc, t -> acc + func(t) }\nfun IntArray.sumLong() = fold(0L, Long::plus)", "language": "Kotlin", "metadata": {"date": 1593306057, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02621.html", "problem_id": "p02621", "resource_group": "medium_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/Kotlin/s860637609.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s860637609", "user_id": "u596111103"}, "prompt_components": {"gold_output": "14\n", "input_to_evaluate": "@file:Suppress(\"NOTHING_TO_INLINE\", \"EXPERIMENTAL_FEATURE_WARNING\", \"OVERRIDE_BY_INLINE\")\n\nimport java.io.File\nimport java.io.PrintWriter\nimport java.text.SimpleDateFormat\nimport java.util.Calendar\nimport java.util.TimeZone\nimport kotlin.math.*\nimport kotlin.random.Random\nimport kotlin.collections.sort as _sort\nimport kotlin.collections.sortDescending as _sortDescending\nimport kotlin.io.println as iprintln\n\n/** @author Spheniscine */\nfun main() { _writer.solve(); _writer.flush() }\nfun PrintWriter.solve() {\n// val startTime = System.nanoTime()\n\n val numCases = 1//readInt()\n case@ for(case in 1..numCases) {\n val a = readInt()\n\n val ans = a + a*a + a*a*a\n\n println(ans)\n }\n\n// iprintln(\"Time: ${(System.nanoTime() - startTime) / 1000000} ms\")\n}\n\n\n/** IO */\n//@JvmField val INPUT = File(\"input.txt\").inputStream()\n//@JvmField val OUTPUT = File(\"output.txt\").outputStream()\n@JvmField val INPUT = System.`in`\n@JvmField val OUTPUT = System.out\n\nconst val _BUFFER_SIZE = 1 shl 16\n@JvmField val _buffer = ByteArray(_BUFFER_SIZE)\n@JvmField var _bufferPt = 0\n@JvmField var _bytesRead = 0\n\ntailrec fun readChar(): Char {\n if(_bufferPt == _bytesRead) {\n _bufferPt = 0\n _bytesRead = INPUT.read(_buffer, 0, _BUFFER_SIZE)\n }\n return if(_bytesRead < 0) Char.MIN_VALUE\n else {\n val c = _buffer[_bufferPt++].toChar()\n if (c == '\\r') readChar()\n else c\n }\n}\n\nfun readLine(): String? {\n var c = readChar()\n return if(c == Char.MIN_VALUE) null\n else buildString {\n while(c != '\\n' && c != Char.MIN_VALUE) {\n append(c)\n c = readChar()\n }\n }\n}\nfun readLn() = readLine()!!\n\nfun read() = buildString {\n var c = readChar()\n while(c <= ' ') {\n if(c == Char.MIN_VALUE) return@buildString\n c = readChar()\n }\n do {\n append(c)\n c = readChar()\n } while(c > ' ')\n}\nfun readInt() = read().toInt()\nfun readDouble() = read().toDouble()\nfun readLong() = read().toLong()\nfun readStrings(n: Int) = List(n) { read() }\nfun readLines(n: Int) = List(n) { readLn() }\nfun readInts(n: Int) = List(n) { read().toInt() }\nfun readIntArray(n: Int) = IntArray(n) { read().toInt() }\nfun readDoubles(n: Int) = List(n) { read().toDouble() }\nfun readDoubleArray(n: Int) = DoubleArray(n) { read().toDouble() }\nfun readLongs(n: Int) = List(n) { read().toLong() }\nfun readLongArray(n: Int) = LongArray(n) { read().toLong() }\n\n@JvmField val _writer = PrintWriter(OUTPUT, false)\n\n/** shuffles and sort overrides to avoid quicksort attacks */\nprivate inline fun _shuffle(rnd: Random, get: (Int) -> T, set: (Int, T) -> Unit, size: Int) {\n // Fisher-Yates shuffle algorithm\n for (i in size - 1 downTo 1) {\n val j = rnd.nextInt(i + 1)\n val temp = get(i)\n set(i, get(j))\n set(j, temp)\n }\n}\n\n@JvmField var _random: Random? = null\nval random get() = _random ?: Random(0x594E215C123 * System.nanoTime()).also { _random = it }\n\nfun IntArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\nfun IntArray.sort() { shuffle(); _sort() }\nfun IntArray.sortDescending() { shuffle(); _sortDescending() }\n\nfun LongArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\nfun LongArray.sort() { shuffle(); _sort() }\nfun LongArray.sortDescending() { shuffle(); _sortDescending() }\n\nfun DoubleArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\nfun DoubleArray.sort() { shuffle(); _sort() }\nfun DoubleArray.sortDescending() { shuffle(); _sortDescending() }\n\nfun CharArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\ninline fun CharArray.sort() { _sort() }\ninline fun CharArray.sortDescending() { _sortDescending() }\n\ninline fun > Array.sort() = _sort()\ninline fun > Array.sortDescending() = _sortDescending()\ninline fun > MutableList.sort() = _sort()\ninline fun > MutableList.sortDescending() = _sortDescending()\n\nfun `please stop removing these imports IntelliJ`() { iprintln(max(1, 2)) }\n\n/** additional commons */\ninline fun Iterable.sumByLong(func: (T) -> Long) = fold(0L) { acc, t -> acc + func(t) }\ninline fun Sequence.sumByLong(func: (T) -> Long) = fold(0L) { acc, t -> acc + func(t) }\ninline fun Array.sumByLong(func: (T) -> Long) = fold(0L) { acc, t -> acc + func(t) }\nfun IntArray.sumLong() = fold(0L, Long::plus)", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 4458, "cpu_time_ms": 100, "memory_kb": 34380}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s574960739", "group_id": "codeNet:p02622", "input_text": "fun main() {\n val S = readLine()!!\n val T = readLine()!!\n var ans = 0\n for ((index, char) in S.withIndex()) {\n if (T[index] != char) ans ++\n }\n println(ans)\n}", "language": "Kotlin", "metadata": {"date": 1593306617, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02622.html", "problem_id": "p02622", "resource_group": "medium_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/Kotlin/s574960739.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s574960739", "user_id": "u243733932"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "fun main() {\n val S = readLine()!!\n val T = readLine()!!\n var ans = 0\n for ((index, char) in S.withIndex()) {\n if (T[index] != char) ans ++\n }\n println(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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 230, "memory_kb": 40684}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s085182719", "group_id": "codeNet:p02622", "input_text": "\nfun main(args: Array) {\n\n val S = readLine()!!.toString()\n val T = readLine()!!.toString()\n\n\n var count = 0\n S.forEachIndexed { index, c ->\n if (!c.equals(T.get(index))) {\n count++\n }\n }\n println(count)\n}", "language": "Kotlin", "metadata": {"date": 1593306561, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02622.html", "problem_id": "p02622", "resource_group": "medium_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/Kotlin/s085182719.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s085182719", "user_id": "u727736935"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "\nfun main(args: Array) {\n\n val S = readLine()!!.toString()\n val T = readLine()!!.toString()\n\n\n var count = 0\n S.forEachIndexed { index, c ->\n if (!c.equals(T.get(index))) {\n count++\n }\n }\n println(count)\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 264, "memory_kb": 40584}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s528030300", "group_id": "codeNet:p02622", "input_text": "fun main() {\n val s = readLine()!!\n val t = readLine()!!\n\n var result = 0\n\n for(i in s.indices){\n if(s[i] != t[i]) {\n result++\n }\n }\n\n println(result)\n}", "language": "Kotlin", "metadata": {"date": 1593306409, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02622.html", "problem_id": "p02622", "resource_group": "medium_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/Kotlin/s528030300.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s528030300", "user_id": "u430710262"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "fun main() {\n val s = readLine()!!\n val t = readLine()!!\n\n var result = 0\n\n for(i in s.indices){\n if(s[i] != t[i]) {\n result++\n }\n }\n\n println(result)\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 195, "cpu_time_ms": 257, "memory_kb": 40272}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s714465799", "group_id": "codeNet:p02622", "input_text": "fun main(args: Array) {\n val s = readLine() ?: return\n val t = readLine() ?: return\n var count = 0\n s.forEachIndexed { i, c ->\n if (t[i] != c) {\n count++\n }\n }\n println(count.toString())\n}", "language": "Kotlin", "metadata": {"date": 1593306191, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02622.html", "problem_id": "p02622", "resource_group": "medium_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/Kotlin/s714465799.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s714465799", "user_id": "u979429407"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "fun main(args: Array) {\n val s = readLine() ?: return\n val t = readLine() ?: return\n var count = 0\n s.forEachIndexed { i, c ->\n if (t[i] != c) {\n count++\n }\n }\n println(count.toString())\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 239, "cpu_time_ms": 243, "memory_kb": 40260}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s124597260", "group_id": "codeNet:p02627", "input_text": "fun main(args: Array){\n val input = readLine().toString()\n val result = if (input[0].isLowerCase()){\n \"a\"\n }else{\n \"A\"\n }\n print(result)\n}\n", "language": "Kotlin", "metadata": {"date": 1593054718, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02627.html", "problem_id": "p02627", "resource_group": "medium_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/Kotlin/s124597260.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s124597260", "user_id": "u006844829"}, "prompt_components": {"gold_output": "A\n", "input_to_evaluate": "fun main(args: Array){\n val input = readLine().toString()\n val result = if (input[0].isLowerCase()){\n \"a\"\n }else{\n \"A\"\n }\n print(result)\n}\n", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 176, "cpu_time_ms": 98, "memory_kb": 34508}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s841849066", "group_id": "codeNet:p02627", "input_text": "fun main()=println(if(readLine()!![0] in 'A'..'Z') 'A' else 'a')\n", "language": "Kotlin", "metadata": {"date": 1592794255, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02627.html", "problem_id": "p02627", "resource_group": "medium_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/Kotlin/s841849066.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s841849066", "user_id": "u059234158"}, "prompt_components": {"gold_output": "A\n", "input_to_evaluate": "fun main()=println(if(readLine()!![0] in 'A'..'Z') 'A' else 'a')\n", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 115, "memory_kb": 34464}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s884983192", "group_id": "codeNet:p02627", "input_text": "import java.util.*\n\nfun main(args: Array) {\n val scan = Scanner(System.`in`)\n var kotlin=scan.nextLine()\n if(kotlin[0].isUpperCase())\n println(\"A\")\n else\n println(\"a\")\n}\n", "language": "Kotlin", "metadata": {"date": 1592787682, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02627.html", "problem_id": "p02627", "resource_group": "medium_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/Kotlin/s884983192.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s884983192", "user_id": "u801179767"}, "prompt_components": {"gold_output": "A\n", "input_to_evaluate": "import java.util.*\n\nfun main(args: Array) {\n val scan = Scanner(System.`in`)\n var kotlin=scan.nextLine()\n if(kotlin[0].isUpperCase())\n println(\"A\")\n else\n println(\"a\")\n}\n", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 163, "memory_kb": 36336}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s525424330", "group_id": "codeNet:p02627", "input_text": "\nfun main() {\n val a = readLine()!!.trim()\n println(\n if (a.toUpperCase() == a) \"A\" else \"a\"\n )\n}", "language": "Kotlin", "metadata": {"date": 1592787667, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02627.html", "problem_id": "p02627", "resource_group": "medium_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/Kotlin/s525424330.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s525424330", "user_id": "u419330815"}, "prompt_components": {"gold_output": "A\n", "input_to_evaluate": "\nfun main() {\n val a = readLine()!!.trim()\n println(\n if (a.toUpperCase() == a) \"A\" else \"a\"\n )\n}", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 110, "memory_kb": 35788}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s523225173", "group_id": "codeNet:p02628", "input_text": "\nfun main(args: Array) {\n val (n, k) = readListInt()\n var p = readListInt().toMutableList().sorted()\n var count = 0\n for (i in 0 until k) {\n count += p[i]\n }\n println(count)\n\n\n\n}\n\nprivate fun read() = readLine()!!\n\nprivate fun readInt() = read().toInt()\n\nprivate fun readLong() = read().toLong()\n\nprivate fun readDouble() = read().toDouble()\n\nprivate fun readListString() = read().split(\" \")\n\nprivate fun readListInt() = readListString().map { it.toInt() }\n\nprivate fun readListLong() = readListString().map { it.toLong() }\n\nprivate fun readListDouble() = readListString().map { it.toDouble() }\n\nprivate fun readMatrixString(n: Int): List> {\n val matrix = mutableListOf>()\n for (i in 0 until n) {\n val list = readListString()\n matrix.add(list)\n }\n return matrix\n}\n\nprivate fun readMatrixInt(n: Int): List> {\n val matrix = mutableListOf>()\n for (i in 0 until n) {\n val list = readListInt()\n matrix.add(list)\n }\n return matrix\n}\n\nprivate fun readMatrixDouble(n: Int): List> {\n val matrix = mutableListOf>()\n for (i in 0 until n) {\n val list = readListDouble()\n matrix.add(list)\n }\n return matrix\n}\n\nprivate fun readMatrixLong(n: Int): List> {\n val matrix = mutableListOf>()\n for (i in 0 until n) {\n val list = readListLong()\n matrix.add(list)\n }\n return matrix\n}\n\n", "language": "Kotlin", "metadata": {"date": 1592788048, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02628.html", "problem_id": "p02628", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02628/input.txt", "sample_output_relpath": "derived/input_output/data/p02628/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02628/Kotlin/s523225173.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s523225173", "user_id": "u698000453"}, "prompt_components": {"gold_output": "210\n", "input_to_evaluate": "\nfun main(args: Array) {\n val (n, k) = readListInt()\n var p = readListInt().toMutableList().sorted()\n var count = 0\n for (i in 0 until k) {\n count += p[i]\n }\n println(count)\n\n\n\n}\n\nprivate fun read() = readLine()!!\n\nprivate fun readInt() = read().toInt()\n\nprivate fun readLong() = read().toLong()\n\nprivate fun readDouble() = read().toDouble()\n\nprivate fun readListString() = read().split(\" \")\n\nprivate fun readListInt() = readListString().map { it.toInt() }\n\nprivate fun readListLong() = readListString().map { it.toLong() }\n\nprivate fun readListDouble() = readListString().map { it.toDouble() }\n\nprivate fun readMatrixString(n: Int): List> {\n val matrix = mutableListOf>()\n for (i in 0 until n) {\n val list = readListString()\n matrix.add(list)\n }\n return matrix\n}\n\nprivate fun readMatrixInt(n: Int): List> {\n val matrix = mutableListOf>()\n for (i in 0 until n) {\n val list = readListInt()\n matrix.add(list)\n }\n return matrix\n}\n\nprivate fun readMatrixDouble(n: Int): List> {\n val matrix = mutableListOf>()\n for (i in 0 until n) {\n val list = readListDouble()\n matrix.add(list)\n }\n return matrix\n}\n\nprivate fun readMatrixLong(n: Int): List> {\n val matrix = mutableListOf>()\n for (i in 0 until n) {\n val list = readListLong()\n matrix.add(list)\n }\n return matrix\n}\n\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nA shop sells N kinds of fruits, Fruit 1, \\ldots, N, at prices of p_1, \\ldots, p_N yen per item, respectively. (Yen is the currency of Japan.)\n\nHere, we will choose K kinds of fruits and buy one of each chosen kind. Find the minimum possible total price of those fruits.\n\nConstraints\n\n1 \\leq K \\leq N \\leq 1000\n\n1 \\leq p_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 K\np_1 p_2 \\ldots p_N\n\nOutput\n\nPrint an integer representing the minimum possible total price of fruits.\n\nSample Input 1\n\n5 3\n50 100 80 120 80\n\nSample Output 1\n\n210\n\nThis shop sells Fruit 1, 2, 3, 4, and 5 for 50 yen, 100 yen, 80 yen, 120 yen, and 80 yen, respectively.\n\nThe minimum total price for three kinds of fruits is 50 + 80 + 80 = 210 yen when choosing Fruit 1, 3, and 5.\n\nSample Input 2\n\n1 1\n1000\n\nSample Output 2\n\n1000", "sample_input": "5 3\n50 100 80 120 80\n"}, "reference_outputs": ["210\n"], "source_document_id": "p02628", "source_text": "Score : 200 points\n\nProblem Statement\n\nA shop sells N kinds of fruits, Fruit 1, \\ldots, N, at prices of p_1, \\ldots, p_N yen per item, respectively. (Yen is the currency of Japan.)\n\nHere, we will choose K kinds of fruits and buy one of each chosen kind. Find the minimum possible total price of those fruits.\n\nConstraints\n\n1 \\leq K \\leq N \\leq 1000\n\n1 \\leq p_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 K\np_1 p_2 \\ldots p_N\n\nOutput\n\nPrint an integer representing the minimum possible total price of fruits.\n\nSample Input 1\n\n5 3\n50 100 80 120 80\n\nSample Output 1\n\n210\n\nThis shop sells Fruit 1, 2, 3, 4, and 5 for 50 yen, 100 yen, 80 yen, 120 yen, and 80 yen, respectively.\n\nThe minimum total price for three kinds of fruits is 50 + 80 + 80 = 210 yen when choosing Fruit 1, 3, and 5.\n\nSample Input 2\n\n1 1\n1000\n\nSample Output 2\n\n1000", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1494, "cpu_time_ms": 159, "memory_kb": 40704}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s045242389", "group_id": "codeNet:p02629", "input_text": "fun main(args: Array) {\n\n var tmpLine = readLine()\n\n \n val result = experiment(tmpLine!!)\n\n println(result)\n}\n\nfun experiment(input: String) : String {\n\n val n = input.toInt()\n var result = \"\"\n val atozList = mutableListOf()\n for (alphabet in 'a'..'z') {\n atozList.add(\"${alphabet}\")\n }\n\n\n\n val amari1 = n % 26\n val sho1 = (n - amari1) / 26\n result = atozList[amari1-1] + result\n if (sho1 == 0) return result\n\n var nextVal = sho1\n\n while (nextVal > 0) {\n val amari2 = nextVal % 26\n val sho2 = (nextVal - amari2) / 26\n result = atozList[amari2-1] + result\n if (sho2 == 0) return result\n nextVal = sho2\n } \n\n // var nextVal2 = sho1\n // val amari2 = nextVal2 % 26\n // val sho2 = (nextVal2 - amari2) / 26\n // result = atozList[amari2-1] + result\n // if (sho2 == 0) return result\n\n // var nextVal3 = sho2\n // val amari3 = nextVal3 % 26\n // val sho3 = (nextVal3 - amari3) / 26\n // result = atozList[amari3-1] + result\n // if (sho3 == 0) return result\n\n // var nextVal4 = sho3\n // val amari4 = nextVal4 % 26\n // val sho4 = (nextVal4 - amari4) / 26\n // result = atozList[amari4-1] + result\n // if (sho4 == 0) return result\n\n // var nextVal5 = sho4\n // val amari5 = nextVal5 % 26\n // val sho5 = (nextVal5 - amari5) / 26\n // result = atozList[amari5-1] + result\n // if (sho5 == 0) return result\n\n // var nextVal6 = sho5\n // val amari6 = nextVal6 % 26\n // val sho6 = (nextVal6 - amari6) / 26\n // result = atozList[amari6-1] + result\n // if (sho6 == 0) return result\n\n return result\n}\n", "language": "Kotlin", "metadata": {"date": 1592791900, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02629.html", "problem_id": "p02629", "resource_group": "medium_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/Kotlin/s045242389.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s045242389", "user_id": "u294297802"}, "prompt_components": {"gold_output": "b\n", "input_to_evaluate": "fun main(args: Array) {\n\n var tmpLine = readLine()\n\n \n val result = experiment(tmpLine!!)\n\n println(result)\n}\n\nfun experiment(input: String) : String {\n\n val n = input.toInt()\n var result = \"\"\n val atozList = mutableListOf()\n for (alphabet in 'a'..'z') {\n atozList.add(\"${alphabet}\")\n }\n\n\n\n val amari1 = n % 26\n val sho1 = (n - amari1) / 26\n result = atozList[amari1-1] + result\n if (sho1 == 0) return result\n\n var nextVal = sho1\n\n while (nextVal > 0) {\n val amari2 = nextVal % 26\n val sho2 = (nextVal - amari2) / 26\n result = atozList[amari2-1] + result\n if (sho2 == 0) return result\n nextVal = sho2\n } \n\n // var nextVal2 = sho1\n // val amari2 = nextVal2 % 26\n // val sho2 = (nextVal2 - amari2) / 26\n // result = atozList[amari2-1] + result\n // if (sho2 == 0) return result\n\n // var nextVal3 = sho2\n // val amari3 = nextVal3 % 26\n // val sho3 = (nextVal3 - amari3) / 26\n // result = atozList[amari3-1] + result\n // if (sho3 == 0) return result\n\n // var nextVal4 = sho3\n // val amari4 = nextVal4 % 26\n // val sho4 = (nextVal4 - amari4) / 26\n // result = atozList[amari4-1] + result\n // if (sho4 == 0) return result\n\n // var nextVal5 = sho4\n // val amari5 = nextVal5 % 26\n // val sho5 = (nextVal5 - amari5) / 26\n // result = atozList[amari5-1] + result\n // if (sho5 == 0) return result\n\n // var nextVal6 = sho5\n // val amari6 = nextVal6 % 26\n // val sho6 = (nextVal6 - amari6) / 26\n // result = atozList[amari6-1] + result\n // if (sho6 == 0) return result\n\n return result\n}\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1657, "cpu_time_ms": 118, "memory_kb": 35604}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s994159378", "group_id": "codeNet:p02629", "input_text": "import java.util.*\n\nfun main() {\n val sc = Scanner(System.`in`)\n var n = sc.nextLong()\n val base = 'a'.toInt() - 1\n\n val result = mutableListOf()\n while (true) {\n if (n <= 0) break\n var diff = (n % 26L).toInt()\n val is26 = diff == 0\n if (is26) {\n diff = 26\n }\n val char = (diff + base).toChar()\n result.add(char)\n\n n /= 26L\n if (is26) {\n n -= 1\n }\n }\n\n result.asReversed().forEach { print(it) }\n}", "language": "Kotlin", "metadata": {"date": 1592790452, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02629.html", "problem_id": "p02629", "resource_group": "medium_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/Kotlin/s994159378.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s994159378", "user_id": "u897579945"}, "prompt_components": {"gold_output": "b\n", "input_to_evaluate": "import java.util.*\n\nfun main() {\n val sc = Scanner(System.`in`)\n var n = sc.nextLong()\n val base = 'a'.toInt() - 1\n\n val result = mutableListOf()\n while (true) {\n if (n <= 0) break\n var diff = (n % 26L).toInt()\n val is26 = diff == 0\n if (is26) {\n diff = 26\n }\n val char = (diff + base).toChar()\n result.add(char)\n\n n /= 26L\n if (is26) {\n n -= 1\n }\n }\n\n result.asReversed().forEach { print(it) }\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 515, "cpu_time_ms": 166, "memory_kb": 37396}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s891516997", "group_id": "codeNet:p02629", "input_text": "import java.io.PrintWriter\nimport java.util.*\nimport java.math.*\nimport java.lang.*\nimport kotlin.comparisons.*\n\nval pw = PrintWriter(System.out)\nval MOD: Long = (1e+9 + 7).toLong()\n\nfun main(args: Array) {\n var n = readLong() - 1L\n var ans = \"\"\n val charList = ('a' .. 'z').toList()\n var firstFlg = true\n while(n > 0L) {\n var i = (n % 26L).toInt()\n if(!firstFlg) {\n i--\n }\n ans = charList[i] + ans\n n /= 26L\n if(firstFlg) firstFlg = false\n }\n println(ans)\n\n\tpw.flush()\n}\n\n/****** Declared Functions and Data Structures ******/\n// IO\nfun read() = readLine()!!\nfun readInt() = read().toInt()\nfun readLong() = read().toLong()\nfun readDouble() = read().toDouble()\nfun readListOfString() = read().split(\" \")\nfun readListOfInt() = readListOfString().map { it.toInt() }\nfun readListOfLong() = readListOfString().map { it.toLong() }\nfun readListOfDouble() = readListOfString().map { it.toDouble() }\n\nfun Double.format(digits: Int) = String.format(\"%.${digits}f\", this)\nfun Float.format(digits: Int) = String.format(\"%.${digits}f\", this)\n\nfun print(value: Any) { pw.print(value) }\nfun println(value : Any) { pw.println(value) }\n\n// Extensions\nfun List.toBuckets(): Map\n\t= this.groupBy { it }.mapValues { it.value.size }\n\nfun> Array.upperBound(element: T, fromIndex: Int=0, toIndex: Int=this.size): Int\n\t= this.toList().upperBound(element, fromIndex, toIndex)\n\nfun> List.upperBound(element: T, fromIndex: Int=0, toIndex: Int=this.size): Int {\n\tvar l = fromIndex\n\tvar r = toIndex\n\twhile(l < r) {\n\t\tval mid = (l+r) / 2\n\t\tif(element >= this[mid]) { \n\t\t\tl = mid + 1\n\t\t} else {\n\t\t\tr = mid\n\t\t}\n\t}\n\treturn l\n}\n\nfun> Array.lowerBound(element: T, fromIndex: Int=0, toIndex: Int=this.size): Int\n\t= this.toList().lowerBound(element, fromIndex, toIndex)\n\nfun> List.lowerBound(element: T, fromIndex: Int=0, toIndex: Int=this.size): Int {\n\tvar l = fromIndex\n\tvar r = toIndex\n\twhile(l < r) {\n\t\tval mid = (l+r) / 2\n\t\tif(element > this[mid]) { \n\t\t\tl = mid + 1\n\t\t} else {\n\t\t\tr = mid\n\t\t}\n\t}\n\treturn r \n}\n\nfun Map.toMutableMap(): MutableMap = HashMap(this)\n\n// Util Functions\nfun Long.makeDivisors(): List {\n\tval divisors = mutableListOf()\n\tfor(i in 1L .. Math.sqrt(this.toDouble()).toLong()+1L) {\n\t\tif(this % i == 0L) {\n\t\t\tdivisors.add(i)\n\t\t\tif(i != this/i) {\n\t\t\t\tdivisors.add(this/i)\n\t\t\t}\n\t\t}\n\t}\n\treturn divisors.distinct().sorted()\n}\n\nfun Long.isPrime(): Boolean {\n\tif(this==1L) return false\n\tfor(i in 2L .. Math.sqrt(this.toDouble()).toLong() + 1L) {\n\t\tif(this % i == 0L && this != i) {\n\t\t\treturn false\n\t\t}\n\t}\n\treturn true\n}\n\nfun Long.primeFactorize(): Map {\n\tval map = mutableMapOf()\n\tvar num = this\n\tfor(i in 2L .. Math.sqrt(num.toDouble()).toLong()+1L) {\n\t\tif(num % i == 0L) {\n\t\t\twhile(num % i == 0L) {\n\t\t\t\tmap[i] = (map[i]?:0) + 1\n\t\t\t\tnum /= i\n\t\t\t}\n\t\t}\n\t}\n\tif(num != 1L) {\n\t\tmap[this] = 1 \n\t}\n\treturn map\n}\n\nfun permutations(src: List): List> {\n\tif(src.size == 1) return listOf(src)\n\tval perms = mutableListOf>()\n\tval insertElement = src[0]\n\tpermutations(src.drop(1)).forEach { perm ->\n\t\tfor(i in 0..perm.size) {\n\t\t\tval newPerm = perm.toMutableList()\n\t\t\tnewPerm.add(i, insertElement)\n\t\t\tperms.add(newPerm.toList())\n\t\t}\n\t}\n\treturn perms\n}\n\n// return nCr, if you want nCr, please access v[n][r]\nfun combinations(n: Long): List> {\n\tval v = (0..n).map { (0..n).map{0L}.toMutableList() }.toMutableList()\n\tfor(i in 0 until v.size) {\n\t\tv[i][0] = 1L\n\t\tv[i][i] = 1L\n\t}\n\tfor(i in 0 until v.size) {\n\t\tfor(j in 1 until i) {\n\t\t\tv[i][j] = (v[i-1][j-1] + v[i-1][j]) % MOD\n\t\t}\n\t}\n\treturn v.map { it.toList() }.toList()\n}\n\nfun repeatedModPow(a: Long, n: Long, mod: Long): Long = \n\twhen {\n\t\tn == 0L -> 1L\n\t\tn == 1L -> a % mod\n\t\tn % 2L == 1L -> (a * repeatedModPow(a, n-1L, mod)) % mod\n\t\telse -> {\n\t\t\tval tmp = repeatedModPow(a, n / 2L, mod)\n\t\t\t(tmp * tmp) % mod\n\t\t}\n\t}\n\n// return nCr % MOD\nfun modnCkWithoutArray(n: Long, k: Long, mod: Long): Long {\n\tvar ret = 1L\n\tval min = Math.min(k, n-k)\n\t// まず分母の計算\n\tfor(i in n downTo (n - min + 1)) {\n\t\tret = ret * i % mod\n\t}\n\tfor(i in min downTo 1) {\n\t\tret = ret * repeatedModPow(i, (mod - 2L), mod) % mod\n\t}\n\treturn ret\n}\n\n// return nCr % MOD\nfun modnCk(n: Int, k: Int, mod: Long): Long {\n\tval factorials = Array(n+1) { 0L }.apply {\n\t\tthis[0] = 1L\n\t\tif(this.size > 1) this[1] = 1L\n\t}\n\tval inverses = Array(n+1) { 0L }.apply {\n\t\tthis[0] = 1L\n\t\tif(this.size > 1) this[1] = 1L\n\t}\n\tval factorialInverses = Array(n+1) { 0L }.apply {\n\t\tthis[0] = 1L\n\t\tif(this.size > 1) this[1] = 1L\n\t}\n\tfor(i in 2 .. n) {\n\t\tfactorials[i] = (factorials[i-1] * i.toLong() % mod)\n\t\tinverses[i] = (mod - inverses[mod.toInt() % i] * (mod / i.toLong()) % mod)\n\t\tfactorialInverses[i] = (factorialInverses[i-1] * inverses[i] % mod)\n\t}\n\n\treturn factorials[n] % mod * (factorialInverses[k] * factorialInverses[n-k] % mod) % mod\n}\n\n// should be a >= b\nfun gcd(a: Long, b: Long): Long = \n\tif(b == 0L) a else gcd(b, a % b)\n\n// shoud be a >= b\nfun lcm(a: Long, b: Long): Long = \n\ta / gcd(a, b) * b\n\nfun sumDigits(num_: Long): Long {\n\tvar num = num_\n\tvar rtn: Long = 0\n\twhile(num != 0.toLong()) {\n\t\tval tmp = num % 10\n\t\trtn += tmp\n\t\tnum /= 10\n\t}\n\treturn rtn\n}\n\nfun Double.isDecimal(): Boolean = ((this - Math.floor(this)) != 0.0)\n\n// Data Structures\n\nclass UnionFind(private val n: Int) {\n\tprivate val parent: Array = Array(n) { 0 }\n\tprivate val rank: Array = Array(n) { 0 }\n\tprivate val size: Array = Array(n) { 0 }\n\n\tinit {\n\t\tfor(i in 0 until n) {\n\t\t\tparent[i] = i\n\t\t\trank[i] = 1\n\t\t\tsize[i] = 1\n\t\t}\n\t}\n\n\tfun union(u: Int, v: Int) {\n\t\tvar x = root(u)\n\t\tvar y = root(v)\n\t\tif(x != y) {\n\t\t\tif(rank[y] < rank[x]) {\n\t\t\t\tval tmp = y \n\t\t\t\ty = x\n\t\t\t\tx = tmp \n\t\t\t}\n\t\t\tparent[x] = y\n\t\t\trank[y] += rank[x]\n\t\t\trank[x] = -1\n\t\t\tval totalSize = size[x] + size[y]\n\t\t\tsize[x] = totalSize\n\t\t\tsize[y] = totalSize\n\t\t}\n\t}\n\n\tfun root(u: Int): Int {\n\t\tvar x = u\n\t\twhile(parent[x] != x) {\n\t\t\tx = parent[x]\n\t\t}\n\t\treturn x \n\t}\n\n\tfun size(u: Int): Int = size[root(u)]\n}\n", "language": "Kotlin", "metadata": {"date": 1592789469, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02629.html", "problem_id": "p02629", "resource_group": "medium_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/Kotlin/s891516997.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s891516997", "user_id": "u026686258"}, "prompt_components": {"gold_output": "b\n", "input_to_evaluate": "import java.io.PrintWriter\nimport java.util.*\nimport java.math.*\nimport java.lang.*\nimport kotlin.comparisons.*\n\nval pw = PrintWriter(System.out)\nval MOD: Long = (1e+9 + 7).toLong()\n\nfun main(args: Array) {\n var n = readLong() - 1L\n var ans = \"\"\n val charList = ('a' .. 'z').toList()\n var firstFlg = true\n while(n > 0L) {\n var i = (n % 26L).toInt()\n if(!firstFlg) {\n i--\n }\n ans = charList[i] + ans\n n /= 26L\n if(firstFlg) firstFlg = false\n }\n println(ans)\n\n\tpw.flush()\n}\n\n/****** Declared Functions and Data Structures ******/\n// IO\nfun read() = readLine()!!\nfun readInt() = read().toInt()\nfun readLong() = read().toLong()\nfun readDouble() = read().toDouble()\nfun readListOfString() = read().split(\" \")\nfun readListOfInt() = readListOfString().map { it.toInt() }\nfun readListOfLong() = readListOfString().map { it.toLong() }\nfun readListOfDouble() = readListOfString().map { it.toDouble() }\n\nfun Double.format(digits: Int) = String.format(\"%.${digits}f\", this)\nfun Float.format(digits: Int) = String.format(\"%.${digits}f\", this)\n\nfun print(value: Any) { pw.print(value) }\nfun println(value : Any) { pw.println(value) }\n\n// Extensions\nfun List.toBuckets(): Map\n\t= this.groupBy { it }.mapValues { it.value.size }\n\nfun> Array.upperBound(element: T, fromIndex: Int=0, toIndex: Int=this.size): Int\n\t= this.toList().upperBound(element, fromIndex, toIndex)\n\nfun> List.upperBound(element: T, fromIndex: Int=0, toIndex: Int=this.size): Int {\n\tvar l = fromIndex\n\tvar r = toIndex\n\twhile(l < r) {\n\t\tval mid = (l+r) / 2\n\t\tif(element >= this[mid]) { \n\t\t\tl = mid + 1\n\t\t} else {\n\t\t\tr = mid\n\t\t}\n\t}\n\treturn l\n}\n\nfun> Array.lowerBound(element: T, fromIndex: Int=0, toIndex: Int=this.size): Int\n\t= this.toList().lowerBound(element, fromIndex, toIndex)\n\nfun> List.lowerBound(element: T, fromIndex: Int=0, toIndex: Int=this.size): Int {\n\tvar l = fromIndex\n\tvar r = toIndex\n\twhile(l < r) {\n\t\tval mid = (l+r) / 2\n\t\tif(element > this[mid]) { \n\t\t\tl = mid + 1\n\t\t} else {\n\t\t\tr = mid\n\t\t}\n\t}\n\treturn r \n}\n\nfun Map.toMutableMap(): MutableMap = HashMap(this)\n\n// Util Functions\nfun Long.makeDivisors(): List {\n\tval divisors = mutableListOf()\n\tfor(i in 1L .. Math.sqrt(this.toDouble()).toLong()+1L) {\n\t\tif(this % i == 0L) {\n\t\t\tdivisors.add(i)\n\t\t\tif(i != this/i) {\n\t\t\t\tdivisors.add(this/i)\n\t\t\t}\n\t\t}\n\t}\n\treturn divisors.distinct().sorted()\n}\n\nfun Long.isPrime(): Boolean {\n\tif(this==1L) return false\n\tfor(i in 2L .. Math.sqrt(this.toDouble()).toLong() + 1L) {\n\t\tif(this % i == 0L && this != i) {\n\t\t\treturn false\n\t\t}\n\t}\n\treturn true\n}\n\nfun Long.primeFactorize(): Map {\n\tval map = mutableMapOf()\n\tvar num = this\n\tfor(i in 2L .. Math.sqrt(num.toDouble()).toLong()+1L) {\n\t\tif(num % i == 0L) {\n\t\t\twhile(num % i == 0L) {\n\t\t\t\tmap[i] = (map[i]?:0) + 1\n\t\t\t\tnum /= i\n\t\t\t}\n\t\t}\n\t}\n\tif(num != 1L) {\n\t\tmap[this] = 1 \n\t}\n\treturn map\n}\n\nfun permutations(src: List): List> {\n\tif(src.size == 1) return listOf(src)\n\tval perms = mutableListOf>()\n\tval insertElement = src[0]\n\tpermutations(src.drop(1)).forEach { perm ->\n\t\tfor(i in 0..perm.size) {\n\t\t\tval newPerm = perm.toMutableList()\n\t\t\tnewPerm.add(i, insertElement)\n\t\t\tperms.add(newPerm.toList())\n\t\t}\n\t}\n\treturn perms\n}\n\n// return nCr, if you want nCr, please access v[n][r]\nfun combinations(n: Long): List> {\n\tval v = (0..n).map { (0..n).map{0L}.toMutableList() }.toMutableList()\n\tfor(i in 0 until v.size) {\n\t\tv[i][0] = 1L\n\t\tv[i][i] = 1L\n\t}\n\tfor(i in 0 until v.size) {\n\t\tfor(j in 1 until i) {\n\t\t\tv[i][j] = (v[i-1][j-1] + v[i-1][j]) % MOD\n\t\t}\n\t}\n\treturn v.map { it.toList() }.toList()\n}\n\nfun repeatedModPow(a: Long, n: Long, mod: Long): Long = \n\twhen {\n\t\tn == 0L -> 1L\n\t\tn == 1L -> a % mod\n\t\tn % 2L == 1L -> (a * repeatedModPow(a, n-1L, mod)) % mod\n\t\telse -> {\n\t\t\tval tmp = repeatedModPow(a, n / 2L, mod)\n\t\t\t(tmp * tmp) % mod\n\t\t}\n\t}\n\n// return nCr % MOD\nfun modnCkWithoutArray(n: Long, k: Long, mod: Long): Long {\n\tvar ret = 1L\n\tval min = Math.min(k, n-k)\n\t// まず分母の計算\n\tfor(i in n downTo (n - min + 1)) {\n\t\tret = ret * i % mod\n\t}\n\tfor(i in min downTo 1) {\n\t\tret = ret * repeatedModPow(i, (mod - 2L), mod) % mod\n\t}\n\treturn ret\n}\n\n// return nCr % MOD\nfun modnCk(n: Int, k: Int, mod: Long): Long {\n\tval factorials = Array(n+1) { 0L }.apply {\n\t\tthis[0] = 1L\n\t\tif(this.size > 1) this[1] = 1L\n\t}\n\tval inverses = Array(n+1) { 0L }.apply {\n\t\tthis[0] = 1L\n\t\tif(this.size > 1) this[1] = 1L\n\t}\n\tval factorialInverses = Array(n+1) { 0L }.apply {\n\t\tthis[0] = 1L\n\t\tif(this.size > 1) this[1] = 1L\n\t}\n\tfor(i in 2 .. n) {\n\t\tfactorials[i] = (factorials[i-1] * i.toLong() % mod)\n\t\tinverses[i] = (mod - inverses[mod.toInt() % i] * (mod / i.toLong()) % mod)\n\t\tfactorialInverses[i] = (factorialInverses[i-1] * inverses[i] % mod)\n\t}\n\n\treturn factorials[n] % mod * (factorialInverses[k] * factorialInverses[n-k] % mod) % mod\n}\n\n// should be a >= b\nfun gcd(a: Long, b: Long): Long = \n\tif(b == 0L) a else gcd(b, a % b)\n\n// shoud be a >= b\nfun lcm(a: Long, b: Long): Long = \n\ta / gcd(a, b) * b\n\nfun sumDigits(num_: Long): Long {\n\tvar num = num_\n\tvar rtn: Long = 0\n\twhile(num != 0.toLong()) {\n\t\tval tmp = num % 10\n\t\trtn += tmp\n\t\tnum /= 10\n\t}\n\treturn rtn\n}\n\nfun Double.isDecimal(): Boolean = ((this - Math.floor(this)) != 0.0)\n\n// Data Structures\n\nclass UnionFind(private val n: Int) {\n\tprivate val parent: Array = Array(n) { 0 }\n\tprivate val rank: Array = Array(n) { 0 }\n\tprivate val size: Array = Array(n) { 0 }\n\n\tinit {\n\t\tfor(i in 0 until n) {\n\t\t\tparent[i] = i\n\t\t\trank[i] = 1\n\t\t\tsize[i] = 1\n\t\t}\n\t}\n\n\tfun union(u: Int, v: Int) {\n\t\tvar x = root(u)\n\t\tvar y = root(v)\n\t\tif(x != y) {\n\t\t\tif(rank[y] < rank[x]) {\n\t\t\t\tval tmp = y \n\t\t\t\ty = x\n\t\t\t\tx = tmp \n\t\t\t}\n\t\t\tparent[x] = y\n\t\t\trank[y] += rank[x]\n\t\t\trank[x] = -1\n\t\t\tval totalSize = size[x] + size[y]\n\t\t\tsize[x] = totalSize\n\t\t\tsize[y] = totalSize\n\t\t}\n\t}\n\n\tfun root(u: Int): Int {\n\t\tvar x = u\n\t\twhile(parent[x] != x) {\n\t\t\tx = parent[x]\n\t\t}\n\t\treturn x \n\t}\n\n\tfun size(u: Int): Int = size[root(u)]\n}\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 6099, "cpu_time_ms": 126, "memory_kb": 36880}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s910509784", "group_id": "codeNet:p02629", "input_text": "fun readString() = readLine()!!\nfun readInt() = readLine()!!.toInt()\nfun readLong() = readLine()!!.toLong()\nfun readIntList() = readLine()!!.split(\" \").map(String::toInt)\nfun readLongList() = readLine()!!.split(\" \").map(String::toLong)\nfun Array>.print() {\n this.forEach {\n println(it.joinToString(\" \"))\n }\n}\n\nfun main() {\n var n = readLong()\n var res = \"\"\n if (n == 1L) {\n println('a')\n return\n }\n while (n > 1) {\n var numInt = n % 26\n if (numInt == 0L) {\n numInt = 26\n }\n val num = ('a'.toInt() + numInt - 1).toChar()\n// println(numInt)\n// println(num)\n res += num\n n /= 26\n// n -= 1\n }\n println(res.reversed())\n}", "language": "Kotlin", "metadata": {"date": 1592788870, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02629.html", "problem_id": "p02629", "resource_group": "medium_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/Kotlin/s910509784.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s910509784", "user_id": "u657541767"}, "prompt_components": {"gold_output": "b\n", "input_to_evaluate": "fun readString() = readLine()!!\nfun readInt() = readLine()!!.toInt()\nfun readLong() = readLine()!!.toLong()\nfun readIntList() = readLine()!!.split(\" \").map(String::toInt)\nfun readLongList() = readLine()!!.split(\" \").map(String::toLong)\nfun Array>.print() {\n this.forEach {\n println(it.joinToString(\" \"))\n }\n}\n\nfun main() {\n var n = readLong()\n var res = \"\"\n if (n == 1L) {\n println('a')\n return\n }\n while (n > 1) {\n var numInt = n % 26\n if (numInt == 0L) {\n numInt = 26\n }\n val num = ('a'.toInt() + numInt - 1).toChar()\n// println(numInt)\n// println(num)\n res += num\n n /= 26\n// n -= 1\n }\n println(res.reversed())\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 750, "cpu_time_ms": 111, "memory_kb": 35772}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s330348389", "group_id": "codeNet:p02629", "input_text": "fun main() {\n var n = readLine()!!.toLong()\n var ans = \"\"\n while (true) {\n ans += ('a' + ((n - 1) % 26).toInt())\n n /= 26\n if (n == 0L) break\n }\n println(ans.reversed())\n}\n", "language": "Kotlin", "metadata": {"date": 1592788256, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02629.html", "problem_id": "p02629", "resource_group": "medium_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/Kotlin/s330348389.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s330348389", "user_id": "u863309603"}, "prompt_components": {"gold_output": "b\n", "input_to_evaluate": "fun main() {\n var n = readLine()!!.toLong()\n var ans = \"\"\n while (true) {\n ans += ('a' + ((n - 1) % 26).toInt())\n n /= 26\n if (n == 0L) break\n }\n println(ans.reversed())\n}\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 128, "memory_kb": 35796}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s153943278", "group_id": "codeNet:p02630", "input_text": "fun main(args: Array) {\n val n = readLine()!!.toInt()\n val numbers = Array(1000000) { 0L }\n val input = readLine()!!.split(\" \").map { it.toLong() }\n input.forEach { numbers[it.toInt()]++ }\n var sum = input.sum()\n val q = readLine()!!.toInt()\n repeat(q) {\n val (b,c) = readLine()!!.split(\" \").map { it.toLong() }\n val numberB = numbers[b.toInt()]\n sum += (c-b) * numberB\n println(sum)\n numbers[c.toInt()] += numberB\n numbers[b.toInt()] = 0L\n }\n}\n", "language": "Kotlin", "metadata": {"date": 1593120364, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02630.html", "problem_id": "p02630", "resource_group": "medium_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/Kotlin/s153943278.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s153943278", "user_id": "u172820018"}, "prompt_components": {"gold_output": "11\n12\n16\n", "input_to_evaluate": "fun main(args: Array) {\n val n = readLine()!!.toInt()\n val numbers = Array(1000000) { 0L }\n val input = readLine()!!.split(\" \").map { it.toLong() }\n input.forEach { numbers[it.toInt()]++ }\n var sum = input.sum()\n val q = readLine()!!.toInt()\n repeat(q) {\n val (b,c) = readLine()!!.split(\" \").map { it.toLong() }\n val numberB = numbers[b.toInt()]\n sum += (c-b) * numberB\n println(sum)\n numbers[c.toInt()] += numberB\n numbers[b.toInt()] = 0L\n }\n}\n", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1110, "memory_kb": 71160}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s962564985", "group_id": "codeNet:p02630", "input_text": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val n = sc.nextInt()\n val a = (0 until n).map { sc.next().toInt() }\n val q = sc.nextInt()\n val bc = (0 until q).map { sc.next().toInt() to sc.next().toInt() }\n println(problem171d(n, a, q, bc))\n}\n\nfun problem171d(\n n: Int,\n a: List,\n q: Int,\n bc: List>\n): String {\n val ans = mutableListOf()\n var sum = 0L\n for (i in 0 until n) {\n sum += a[i]\n }\n ans.add(sum)\n val counts = mutableMapOf()\n for (i in 0 until n) {\n val ai = a[i]\n if (counts[ai] == null) {\n counts[ai] = 0\n }\n counts[ai] = counts[ai]!!.plus(1)\n }\n for (i in 0 until q) {\n val (b, c) = bc[i]\n if (counts[b] == null) {\n ans.add(ans.last())\n continue\n }\n val bC = counts[b]!!\n val cC = counts[c]\n counts[c] = (cC ?: 0) + bC\n counts[b] = 0\n var s = 0L\n for (j in counts) {\n s += j.key * j.value\n }\n ans.add(s)\n }\n return ans.drop(1).joinToString(\"\\n\")\n}", "language": "Kotlin", "metadata": {"date": 1592794683, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02630.html", "problem_id": "p02630", "resource_group": "medium_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/Kotlin/s962564985.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s962564985", "user_id": "u073232808"}, "prompt_components": {"gold_output": "11\n12\n16\n", "input_to_evaluate": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val n = sc.nextInt()\n val a = (0 until n).map { sc.next().toInt() }\n val q = sc.nextInt()\n val bc = (0 until q).map { sc.next().toInt() to sc.next().toInt() }\n println(problem171d(n, a, q, bc))\n}\n\nfun problem171d(\n n: Int,\n a: List,\n q: Int,\n bc: List>\n): String {\n val ans = mutableListOf()\n var sum = 0L\n for (i in 0 until n) {\n sum += a[i]\n }\n ans.add(sum)\n val counts = mutableMapOf()\n for (i in 0 until n) {\n val ai = a[i]\n if (counts[ai] == null) {\n counts[ai] = 0\n }\n counts[ai] = counts[ai]!!.plus(1)\n }\n for (i in 0 until q) {\n val (b, c) = bc[i]\n if (counts[b] == null) {\n ans.add(ans.last())\n continue\n }\n val bC = counts[b]!!\n val cC = counts[c]\n counts[c] = (cC ?: 0) + bC\n counts[b] = 0\n var s = 0L\n for (j in counts) {\n s += j.key * j.value\n }\n ans.add(s)\n }\n return ans.drop(1).joinToString(\"\\n\")\n}", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1137, "cpu_time_ms": 2209, "memory_kb": 78660}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s136691250", "group_id": "codeNet:p02630", "input_text": "fun main(args: Array) {\n val n = readInt()\n var a = readListInt().sorted().toMutableList()\n val q = readInt()\n var bc = readMatrixInt(q)\n var list = LongArray(100007).toMutableList()\n a.forEach {\n list[it]++\n }\n\n var ans:Long = a.sum().toLong()\n\n\n for (i in 0 until q) {\n\n val b = bc[i][0]\n val c = bc[i][1]\n var sa: Int = c - b\n var count: Long = list[b]\n\n list[b] -= count\n list[c] += count\n\n ans += sa * count\n println(ans)\n }\n}\n\nprivate fun read() = readLine()!!\n\nprivate fun readInt() = read().toInt()\n\nprivate fun readLong() = read().toLong()\n\nprivate fun readDouble() = read().toDouble()\n\nprivate fun readListString() = read().split(\" \")\n\nprivate fun readListInt() = readListString().map { it.toInt() }\n\nprivate fun readListLong() = readListString().map { it.toLong() }\n\nprivate fun readListDouble() = readListString().map { it.toDouble() }\n\nprivate fun readMatrixString(n: Int): List> {\n val matrix = mutableListOf>()\n for (i in 0 until n) {\n val list = readListString()\n matrix.add(list)\n }\n return matrix\n}\n\nprivate fun readMatrixInt(n: Int): List> {\n val matrix = mutableListOf>()\n for (i in 0 until n) {\n val list = readListInt()\n matrix.add(list)\n }\n return matrix\n}\n\nprivate fun readMatrixDouble(n: Int): List> {\n val matrix = mutableListOf>()\n for (i in 0 until n) {\n val list = readListDouble()\n matrix.add(list)\n }\n return matrix\n}\n\nprivate fun readMatrixLong(n: Int): List> {\n val matrix = mutableListOf>()\n for (i in 0 until n) {\n val list = readListLong()\n matrix.add(list)\n }\n return matrix\n}\n\n", "language": "Kotlin", "metadata": {"date": 1592792786, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02630.html", "problem_id": "p02630", "resource_group": "medium_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/Kotlin/s136691250.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s136691250", "user_id": "u698000453"}, "prompt_components": {"gold_output": "11\n12\n16\n", "input_to_evaluate": "fun main(args: Array) {\n val n = readInt()\n var a = readListInt().sorted().toMutableList()\n val q = readInt()\n var bc = readMatrixInt(q)\n var list = LongArray(100007).toMutableList()\n a.forEach {\n list[it]++\n }\n\n var ans:Long = a.sum().toLong()\n\n\n for (i in 0 until q) {\n\n val b = bc[i][0]\n val c = bc[i][1]\n var sa: Int = c - b\n var count: Long = list[b]\n\n list[b] -= count\n list[c] += count\n\n ans += sa * count\n println(ans)\n }\n}\n\nprivate fun read() = readLine()!!\n\nprivate fun readInt() = read().toInt()\n\nprivate fun readLong() = read().toLong()\n\nprivate fun readDouble() = read().toDouble()\n\nprivate fun readListString() = read().split(\" \")\n\nprivate fun readListInt() = readListString().map { it.toInt() }\n\nprivate fun readListLong() = readListString().map { it.toLong() }\n\nprivate fun readListDouble() = readListString().map { it.toDouble() }\n\nprivate fun readMatrixString(n: Int): List> {\n val matrix = mutableListOf>()\n for (i in 0 until n) {\n val list = readListString()\n matrix.add(list)\n }\n return matrix\n}\n\nprivate fun readMatrixInt(n: Int): List> {\n val matrix = mutableListOf>()\n for (i in 0 until n) {\n val list = readListInt()\n matrix.add(list)\n }\n return matrix\n}\n\nprivate fun readMatrixDouble(n: Int): List> {\n val matrix = mutableListOf>()\n for (i in 0 until n) {\n val list = readListDouble()\n matrix.add(list)\n }\n return matrix\n}\n\nprivate fun readMatrixLong(n: Int): List> {\n val matrix = mutableListOf>()\n for (i in 0 until n) {\n val list = readListLong()\n matrix.add(list)\n }\n return matrix\n}\n\n", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1814, "cpu_time_ms": 1434, "memory_kb": 80848}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s950173129", "group_id": "codeNet:p02631", "input_text": "import java.io.BufferedReader\nimport java.io.InputStream\nimport java.io.InputStreamReader\nimport java.io.PrintWriter\nimport java.lang.IllegalArgumentException\nimport java.lang.StringBuilder\nimport java.util.*\n\nfun PrintWriter.solve(sc: FastScanner) {\n val n = sc.nextInt()\n val a = Array(n) { sc.nextInt() }\n val ans = mutableListOf()\n var x = 0\n for (i in 0 until n) {\n x = x xor a[i]\n }\n for (i in 0 until n) {\n ans.add(x xor a[i])\n }\n println(ans.joinToString(\" \"))\n}\n\nfun main(args: Array) {\n val writer = PrintWriter(System.out, false)\n writer.solve(FastScanner(System.`in`))\n writer.flush()\n}\n\nclass FastScanner(s: InputStream) {\n private var st = StringTokenizer(\"\")\n private val br = BufferedReader(InputStreamReader(s))\n\n fun next(): String {\n while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())\n\n return st.nextToken()\n }\n\n fun nextInt() = next().toInt()\n fun nextLong() = next().toLong()\n fun nextLine() = br.readLine()\n fun nextDouble() = next().toDouble()\n fun ready() = br.ready()\n}", "language": "Kotlin", "metadata": {"date": 1592788981, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02631.html", "problem_id": "p02631", "resource_group": "medium_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/Kotlin/s950173129.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s950173129", "user_id": "u190507186"}, "prompt_components": {"gold_output": "26 5 7 22\n", "input_to_evaluate": "import java.io.BufferedReader\nimport java.io.InputStream\nimport java.io.InputStreamReader\nimport java.io.PrintWriter\nimport java.lang.IllegalArgumentException\nimport java.lang.StringBuilder\nimport java.util.*\n\nfun PrintWriter.solve(sc: FastScanner) {\n val n = sc.nextInt()\n val a = Array(n) { sc.nextInt() }\n val ans = mutableListOf()\n var x = 0\n for (i in 0 until n) {\n x = x xor a[i]\n }\n for (i in 0 until n) {\n ans.add(x xor a[i])\n }\n println(ans.joinToString(\" \"))\n}\n\nfun main(args: Array) {\n val writer = PrintWriter(System.out, false)\n writer.solve(FastScanner(System.`in`))\n writer.flush()\n}\n\nclass FastScanner(s: InputStream) {\n private var st = StringTokenizer(\"\")\n private val br = BufferedReader(InputStreamReader(s))\n\n fun next(): String {\n while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())\n\n return st.nextToken()\n }\n\n fun nextInt() = next().toInt()\n fun nextLong() = next().toLong()\n fun nextLine() = br.readLine()\n fun nextDouble() = next().toDouble()\n fun ready() = br.ready()\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1112, "cpu_time_ms": 453, "memory_kb": 70540}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s885181838", "group_id": "codeNet:p02632", "input_text": "import java.io.BufferedReader\nimport java.io.InputStreamReader\n\nconst val MOD = 1000000007L\nval INV_26 = 26L pow -1\n\nfun main() {\n val jin = BufferedReader(InputStreamReader(System.`in`))\n val k = jin.readLine().toInt()\n val n = jin.readLine().length\n var answer = 0L\n var curr = 26L pow k\n for (j in n..n + k) {\n answer += curr\n curr *= (j + 1 - n).toLong() pow -1\n curr %= MOD\n curr *= INV_26\n curr %= MOD\n curr *= j.toLong()\n curr *= 25L\n curr %= MOD\n }\n println(answer % MOD)\n}\n\nval MOD_TOTIENT = (MOD - 1).toInt()\n\ninfix fun Long.pow(power: Int): Long {\n var e = power\n e %= MOD_TOTIENT\n if (e < 0) {\n e += MOD_TOTIENT\n }\n if (e == 0 && this == 0L) {\n return this\n }\n var b = this % MOD\n var res = 1L\n while (e > 0) {\n if (e and 1 != 0) {\n res *= b\n res %= MOD\n }\n b *= b\n b %= MOD\n e = e shr 1\n }\n return res\n}", "language": "Kotlin", "metadata": {"date": 1592898360, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02632.html", "problem_id": "p02632", "resource_group": "medium_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/Kotlin/s885181838.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s885181838", "user_id": "u590243733"}, "prompt_components": {"gold_output": "575111451\n", "input_to_evaluate": "import java.io.BufferedReader\nimport java.io.InputStreamReader\n\nconst val MOD = 1000000007L\nval INV_26 = 26L pow -1\n\nfun main() {\n val jin = BufferedReader(InputStreamReader(System.`in`))\n val k = jin.readLine().toInt()\n val n = jin.readLine().length\n var answer = 0L\n var curr = 26L pow k\n for (j in n..n + k) {\n answer += curr\n curr *= (j + 1 - n).toLong() pow -1\n curr %= MOD\n curr *= INV_26\n curr %= MOD\n curr *= j.toLong()\n curr *= 25L\n curr %= MOD\n }\n println(answer % MOD)\n}\n\nval MOD_TOTIENT = (MOD - 1).toInt()\n\ninfix fun Long.pow(power: Int): Long {\n var e = power\n e %= MOD_TOTIENT\n if (e < 0) {\n e += MOD_TOTIENT\n }\n if (e == 0 && this == 0L) {\n return this\n }\n var b = this % MOD\n var res = 1L\n while (e > 0) {\n if (e and 1 != 0) {\n res *= b\n res %= MOD\n }\n b *= b\n b %= MOD\n e = e shr 1\n }\n return res\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1000, "cpu_time_ms": 306, "memory_kb": 40240}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s579624094", "group_id": "codeNet:p02633", "input_text": "fun main() {\n val x = readLine()!!.toInt()\n var ans = 360 / x\n \n print(ans)\n}", "language": "Kotlin", "metadata": {"date": 1592701701, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02633.html", "problem_id": "p02633", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02633/input.txt", "sample_output_relpath": "derived/input_output/data/p02633/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02633/Kotlin/s579624094.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s579624094", "user_id": "u682597394"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "fun main() {\n val x = readLine()!!.toInt()\n var ans = 360 / x\n \n print(ans)\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nTakahashi is standing on a two-dimensional plane, facing north. Find the minimum positive integer K such that Takahashi will be at the starting position again after he does the following action K times:\n\nGo one meter in the direction he is facing. Then, turn X degrees counter-clockwise.\n\nConstraints\n\n1 \\leq X \\leq 179\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 number of times Takahashi will do the action before he is at the starting position again.\n\nSample Input 1\n\n90\n\nSample Output 1\n\n4\n\nTakahashi's path is a square.\n\nSample Input 2\n\n1\n\nSample Output 2\n\n360", "sample_input": "90\n"}, "reference_outputs": ["4\n"], "source_document_id": "p02633", "source_text": "Score : 200 points\n\nProblem Statement\n\nTakahashi is standing on a two-dimensional plane, facing north. Find the minimum positive integer K such that Takahashi will be at the starting position again after he does the following action K times:\n\nGo one meter in the direction he is facing. Then, turn X degrees counter-clockwise.\n\nConstraints\n\n1 \\leq X \\leq 179\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 number of times Takahashi will do the action before he is at the starting position again.\n\nSample Input 1\n\n90\n\nSample Output 1\n\n4\n\nTakahashi's path is a square.\n\nSample Input 2\n\n1\n\nSample Output 2\n\n360", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 98, "memory_kb": 34320}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s817564696", "group_id": "codeNet:p02635", "input_text": "import java.io.BufferedReader\nimport java.io.InputStreamReader\nimport kotlin.math.min\n\nconst val MOD = 998244353L\n\nfun main() {\n val jin = BufferedReader(InputStreamReader(System.`in`))\n val line = jin.readLine().split(\" \")\n val s = line[0]\n val k = line[1].toInt()\n val ones = mutableListOf()\n var curr = 0\n for (chara in s.reversed()) {\n when (chara) {\n '0' -> {\n ones.add(curr)\n curr = 0\n }\n '1' -> curr += 1\n }\n }\n ones.add(curr)\n var dp = Array(301) { LongArray(601) }\n dp[0][0] = 1L\n var j = 0\n for (nu in ones) {\n j++\n val dpUp = Array(301) { LongArray(601) }\n val dpDown = Array(301) { LongArray(601) }\n for (b in 0..300) {\n for (c in 0..600) {\n if (b > 0 && c > 0) {\n dpUp[b][c] = dpUp[b - 1][c - 1]\n dpUp[b][c] += dp[b - 1][c - 1]\n }\n if (b - nu - 1 >= 0 && c - nu - 1 >= 0) {\n dpUp[b][c] -= dp[b - nu - 1][c - nu - 1]\n }\n dpUp[b][c] %= MOD\n }\n }\n for (b in 300 downTo 0) {\n for (c in 600 downTo 0) {\n if (b + 1 <= 300 && c > 0) {\n dpDown[b][c] = dpDown[b + 1][c - 1]\n }\n dpDown[b][c] += dp[b][c]\n dpDown[b][c] %= MOD\n }\n }\n for (b in 0..300) {\n dp[b].fill(0L)\n for (c in 0..600) {\n dp[b][c] = dpDown[b][c] + dpUp[b][c]\n dp[b][c] %= MOD\n }\n }\n }\n var answer = 0L\n for (c in 0..min(600, 2 * k)) {\n answer += dp[0][c]\n answer %= MOD\n }\n answer += MOD\n answer %= MOD\n println(answer)\n}", "language": "Kotlin", "metadata": {"date": 1592703842, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02635.html", "problem_id": "p02635", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02635/input.txt", "sample_output_relpath": "derived/input_output/data/p02635/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02635/Kotlin/s817564696.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s817564696", "user_id": "u590243733"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "import java.io.BufferedReader\nimport java.io.InputStreamReader\nimport kotlin.math.min\n\nconst val MOD = 998244353L\n\nfun main() {\n val jin = BufferedReader(InputStreamReader(System.`in`))\n val line = jin.readLine().split(\" \")\n val s = line[0]\n val k = line[1].toInt()\n val ones = mutableListOf()\n var curr = 0\n for (chara in s.reversed()) {\n when (chara) {\n '0' -> {\n ones.add(curr)\n curr = 0\n }\n '1' -> curr += 1\n }\n }\n ones.add(curr)\n var dp = Array(301) { LongArray(601) }\n dp[0][0] = 1L\n var j = 0\n for (nu in ones) {\n j++\n val dpUp = Array(301) { LongArray(601) }\n val dpDown = Array(301) { LongArray(601) }\n for (b in 0..300) {\n for (c in 0..600) {\n if (b > 0 && c > 0) {\n dpUp[b][c] = dpUp[b - 1][c - 1]\n dpUp[b][c] += dp[b - 1][c - 1]\n }\n if (b - nu - 1 >= 0 && c - nu - 1 >= 0) {\n dpUp[b][c] -= dp[b - nu - 1][c - nu - 1]\n }\n dpUp[b][c] %= MOD\n }\n }\n for (b in 300 downTo 0) {\n for (c in 600 downTo 0) {\n if (b + 1 <= 300 && c > 0) {\n dpDown[b][c] = dpDown[b + 1][c - 1]\n }\n dpDown[b][c] += dp[b][c]\n dpDown[b][c] %= MOD\n }\n }\n for (b in 0..300) {\n dp[b].fill(0L)\n for (c in 0..600) {\n dp[b][c] = dpDown[b][c] + dpUp[b][c]\n dp[b][c] %= MOD\n }\n }\n }\n var answer = 0L\n for (c in 0..min(600, 2 * k)) {\n answer += dp[0][c]\n answer %= MOD\n }\n answer += MOD\n answer %= MOD\n println(answer)\n}", "problem_context": "Score : 800 points\n\nProblem Statement\n\nGiven is a string S consisting of 0 and 1. Find the number of strings, modulo 998244353, that can result from applying the following operation on S between 0 and K times (inclusive):\n\nChoose a pair of integers i, j (1\\leq i < j\\leq |S|) such that the i-th and j-th characters of S are 0 and 1, respectively. Remove the j-th character from S and insert it to the immediate left of the i-th character.\n\nConstraints\n\n1 \\leq |S| \\leq 300\n\n0 \\leq K \\leq 10^9\n\nS consists of 0 and 1.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS K\n\nOutput\n\nFind the number of strings, modulo 998244353, that can result from applying the operation on S between 0 and K times (inclusive).\n\nSample Input 1\n\n0101 1\n\nSample Output 1\n\n4\n\nFour strings, 0101, 0110, 1001, and 1010, can result.\n\nSample Input 2\n\n01100110 2\n\nSample Output 2\n\n14\n\nSample Input 3\n\n1101010010101101110111100011011111011000111101110101010010101010101 20\n\nSample Output 3\n\n113434815", "sample_input": "0101 1\n"}, "reference_outputs": ["4\n"], "source_document_id": "p02635", "source_text": "Score : 800 points\n\nProblem Statement\n\nGiven is a string S consisting of 0 and 1. Find the number of strings, modulo 998244353, that can result from applying the following operation on S between 0 and K times (inclusive):\n\nChoose a pair of integers i, j (1\\leq i < j\\leq |S|) such that the i-th and j-th characters of S are 0 and 1, respectively. Remove the j-th character from S and insert it to the immediate left of the i-th character.\n\nConstraints\n\n1 \\leq |S| \\leq 300\n\n0 \\leq K \\leq 10^9\n\nS consists of 0 and 1.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS K\n\nOutput\n\nFind the number of strings, modulo 998244353, that can result from applying the operation on S between 0 and K times (inclusive).\n\nSample Input 1\n\n0101 1\n\nSample Output 1\n\n4\n\nFour strings, 0101, 0110, 1001, and 1010, can result.\n\nSample Input 2\n\n01100110 2\n\nSample Output 2\n\n14\n\nSample Input 3\n\n1101010010101101110111100011011111011000111101110101010010101010101 20\n\nSample Output 3\n\n113434815", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1829, "cpu_time_ms": 1251, "memory_kb": 71508}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s472561546", "group_id": "codeNet:p02639", "input_text": "import kotlin.math.*\nimport java.util.*\n\nconst val MOD = 1_000_000_007L\n\nfun readI() = readLine()!!.toInt()\nfun readL() = readLine()!!.toLong()\nfun readD() = readLine()!!.toDouble()\nfun readIs() = readLine()!!.split(' ').map(String::toInt)\nfun readLs() = readLine()!!.split(' ').map(String::toLong)\nfun readDs() = readLine()!!.split(' ').map(String::toDouble)\n\nfun main(args: Array) {\n println(readIs().find { it == 0 }!! + 1)\n}\n", "language": "Kotlin", "metadata": {"date": 1598496940, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02639.html", "problem_id": "p02639", "resource_group": "medium_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/Kotlin/s472561546.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s472561546", "user_id": "u051841332"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "import kotlin.math.*\nimport java.util.*\n\nconst val MOD = 1_000_000_007L\n\nfun readI() = readLine()!!.toInt()\nfun readL() = readLine()!!.toLong()\nfun readD() = readLine()!!.toDouble()\nfun readIs() = readLine()!!.split(' ').map(String::toInt)\nfun readLs() = readLine()!!.split(' ').map(String::toLong)\nfun readDs() = readLine()!!.split(' ').map(String::toDouble)\n\nfun main(args: Array) {\n println(readIs().find { it == 0 }!! + 1)\n}\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 438, "cpu_time_ms": 121, "memory_kb": 36284}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s148049658", "group_id": "codeNet:p02639", "input_text": "import java.util.*\n\n\n \nfun main(args: Array){\n \n val(a,b,c,d,e) = readLine()!!.split(\" \").map{it.toInt()}\n \n when(a+b+c+d+e){\n 14 -> print(\"1\")\n \n 13 -> print(\"2\")\n \n 12 -> print(\"3\")\n \n 11 -> print(\"4\")\n \n 10 -> print(\"5\")\n }\n \n}", "language": "Kotlin", "metadata": {"date": 1592184153, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02639.html", "problem_id": "p02639", "resource_group": "medium_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/Kotlin/s148049658.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s148049658", "user_id": "u575188262"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "import java.util.*\n\n\n \nfun main(args: Array){\n \n val(a,b,c,d,e) = readLine()!!.split(\" \").map{it.toInt()}\n \n when(a+b+c+d+e){\n 14 -> print(\"1\")\n \n 13 -> print(\"2\")\n \n 12 -> print(\"3\")\n \n 11 -> print(\"4\")\n \n 10 -> print(\"5\")\n }\n \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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 100, "memory_kb": 35376}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s348921600", "group_id": "codeNet:p02639", "input_text": "fun main() {\n val i = readLine()!!.split(\" \").indexOf(\"0\") + 1\n println(i)\n}\n", "language": "Kotlin", "metadata": {"date": 1592182997, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02639.html", "problem_id": "p02639", "resource_group": "medium_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/Kotlin/s348921600.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s348921600", "user_id": "u267722582"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "fun main() {\n val i = readLine()!!.split(\" \").indexOf(\"0\") + 1\n println(i)\n}\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 94, "memory_kb": 35580}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s187393059", "group_id": "codeNet:p02639", "input_text": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val x1 = sc.nextInt()\n val x2 = sc.nextInt()\n val x3 = sc.nextInt()\n val x4 = sc.nextInt()\n val x5 = sc.nextInt()\n println(problem170a(x1, x2, x3, x4, x5))\n}\n\nfun problem170a(x1: Int, x2: Int, x3: Int, x4: Int, x5: Int): Int {\n return when {\n x1 == 0 -> return 1\n x2 == 0 -> return 2\n x3 == 0 -> return 3\n x4 == 0 -> return 4\n x5 == 0 -> return 5\n else -> 0\n }\n}", "language": "Kotlin", "metadata": {"date": 1592182939, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02639.html", "problem_id": "p02639", "resource_group": "medium_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/Kotlin/s187393059.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s187393059", "user_id": "u073232808"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val x1 = sc.nextInt()\n val x2 = sc.nextInt()\n val x3 = sc.nextInt()\n val x4 = sc.nextInt()\n val x5 = sc.nextInt()\n println(problem170a(x1, x2, x3, x4, x5))\n}\n\nfun problem170a(x1: Int, x2: Int, x3: Int, x4: Int, x5: Int): Int {\n return when {\n x1 == 0 -> return 1\n x2 == 0 -> return 2\n x3 == 0 -> return 3\n x4 == 0 -> return 4\n x5 == 0 -> return 5\n else -> 0\n }\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 515, "cpu_time_ms": 130, "memory_kb": 36416}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s461700963", "group_id": "codeNet:p02640", "input_text": "fun main(){\n val (x, y) = readLine()!!.split(\" \").map{it.toInt()}\n \n val turu_leg = x * 2\n val remain_leg = y - turu_leg\n val amount_kame = remain_leg / 2\n val amount_turu = x - amount_kame\n\n if (amount_turu <= 0){\n println(\"Yes\")\n } else println(\"No\")\n\n}", "language": "Kotlin", "metadata": {"date": 1592187396, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02640.html", "problem_id": "p02640", "resource_group": "medium_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/Kotlin/s461700963.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s461700963", "user_id": "u319722345"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "fun main(){\n val (x, y) = readLine()!!.split(\" \").map{it.toInt()}\n \n val turu_leg = x * 2\n val remain_leg = y - turu_leg\n val amount_kame = remain_leg / 2\n val amount_turu = x - amount_kame\n\n if (amount_turu <= 0){\n println(\"Yes\")\n } else println(\"No\")\n\n}", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 100, "memory_kb": 36480}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s392593097", "group_id": "codeNet:p02640", "input_text": "fun main() {\n val (x, y) = readLine()!!.split(\" \").map(String::toInt)\n val a = 4 * x - y\n val b = -2 * x + y\n if (a % 2 == 0 && b % 2 == 0) {\n println(\"Yes\")\n } else {\n println(\"No\")\n }\n}\n", "language": "Kotlin", "metadata": {"date": 1592184134, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02640.html", "problem_id": "p02640", "resource_group": "medium_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/Kotlin/s392593097.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s392593097", "user_id": "u267722582"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "fun main() {\n val (x, y) = readLine()!!.split(\" \").map(String::toInt)\n val a = 4 * x - y\n val b = -2 * x + y\n if (a % 2 == 0 && b % 2 == 0) {\n println(\"Yes\")\n } else {\n println(\"No\")\n }\n}\n", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 100, "memory_kb": 36368}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s151713164", "group_id": "codeNet:p02641", "input_text": "fun main(args: Array) {\n var (x, n) = readLine()!!.split(\" \").map { it.toInt() }\n val planePInput = readLine()\n val pList = if (planePInput.isNullOrEmpty()) {\n null\n } else {\n planePInput.split(\" \").map { it.toInt() }\n }\n\n var distance = 0\n val forbiddenList: ArrayList\n if (pList == null) {\n println(x)\n } else {\n forbiddenList = pList as ArrayList\n while (true) {\n if (forbiddenList.contains(x - distance)) {\n if (forbiddenList.contains(x + distance)) {\n distance++\n continue\n } else {\n println(x + distance)\n break\n }\n } else {\n println(x - distance)\n break\n }\n }\n }\n}", "language": "Kotlin", "metadata": {"date": 1592187037, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02641.html", "problem_id": "p02641", "resource_group": "medium_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/Kotlin/s151713164.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s151713164", "user_id": "u621958170"}, "prompt_components": {"gold_output": "8\n", "input_to_evaluate": "fun main(args: Array) {\n var (x, n) = readLine()!!.split(\" \").map { it.toInt() }\n val planePInput = readLine()\n val pList = if (planePInput.isNullOrEmpty()) {\n null\n } else {\n planePInput.split(\" \").map { it.toInt() }\n }\n\n var distance = 0\n val forbiddenList: ArrayList\n if (pList == null) {\n println(x)\n } else {\n forbiddenList = pList as ArrayList\n while (true) {\n if (forbiddenList.contains(x - distance)) {\n if (forbiddenList.contains(x + distance)) {\n distance++\n continue\n } else {\n println(x + distance)\n break\n }\n } else {\n println(x - distance)\n break\n }\n }\n }\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 845, "cpu_time_ms": 106, "memory_kb": 36388}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s105087199", "group_id": "codeNet:p02641", "input_text": "fun main() {\n var (x, y) = readLine()!!.split(\" \").map { it.toInt() }\n \n if (y == 0) {\n println(x)\n }\n else {\n var arr = readLine()!!.split(\" \").map { it.toInt() }.toIntArray()\n var ind = arr.indexOf(x)\n var i = -1\n var j = 1\n\n while(true) {\n var a = x + i\n var b = x + j\n if (a !in arr) {\n println(a)\n break\n }\n if (b !in arr) {\n println(b)\n break\n }\n }\n }\n}\n", "language": "Kotlin", "metadata": {"date": 1592186550, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02641.html", "problem_id": "p02641", "resource_group": "medium_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/Kotlin/s105087199.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s105087199", "user_id": "u702770355"}, "prompt_components": {"gold_output": "8\n", "input_to_evaluate": "fun main() {\n var (x, y) = readLine()!!.split(\" \").map { it.toInt() }\n \n if (y == 0) {\n println(x)\n }\n else {\n var arr = readLine()!!.split(\" \").map { it.toInt() }.toIntArray()\n var ind = arr.indexOf(x)\n var i = -1\n var j = 1\n\n while(true) {\n var a = x + i\n var b = x + j\n if (a !in arr) {\n println(a)\n break\n }\n if (b !in arr) {\n println(b)\n break\n }\n }\n }\n}\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 2207, "memory_kb": 41084}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s168376009", "group_id": "codeNet:p02641", "input_text": "import kotlin.math.abs\n\nfun main() {\n val x = readLine()!!.split(\" \").map(String::toInt).first()\n val nums = readLine()!!.split(\" \").map(String::toInt).sorted()\n var near = nums.first() - 1\n (nums.first()..nums.last()).forEach {\n if (it !in nums) {\n if (abs(x - it) < abs(x - near)) {\n near = it\n }\n }\n }\n println(near)\n}\n", "language": "Kotlin", "metadata": {"date": 1592186341, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02641.html", "problem_id": "p02641", "resource_group": "medium_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/Kotlin/s168376009.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s168376009", "user_id": "u267722582"}, "prompt_components": {"gold_output": "8\n", "input_to_evaluate": "import kotlin.math.abs\n\nfun main() {\n val x = readLine()!!.split(\" \").map(String::toInt).first()\n val nums = readLine()!!.split(\" \").map(String::toInt).sorted()\n var near = nums.first() - 1\n (nums.first()..nums.last()).forEach {\n if (it !in nums) {\n if (abs(x - it) < abs(x - near)) {\n near = it\n }\n }\n }\n println(near)\n}\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 391, "cpu_time_ms": 117, "memory_kb": 38996}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s457328451", "group_id": "codeNet:p02641", "input_text": "import java.lang.Math.abs\n\nprivate fun readLn() = readLine()!!\nprivate fun readInt() = readLn().toInt()\nprivate fun readStrings() = readLn().split(\" \")\nprivate fun readInts() = readStrings().map(String::toInt)\nprivate fun readStrings2() = readLn().split(\"\").filter { it.isNotEmpty() }\nprivate fun readInts2() = readStrings2().map(String::toInt)\nprivate fun initArray(n:Int, v:String) = Array(n) { v }\nprivate fun initIntArray(n:Int, v:Int) = IntArray(n) { v }\n\nfun main(args: Array) {\n val (X, N) = readInts()\n val p = readInts().sorted()\n\n if (N == 0) {\n println(X)\n } else {\n for (i in 0 until N) {\n val t1 = X - i\n val t2 = X + i\n if (!p.contains(t1)) {\n println(t1)\n break\n } else if (!p.contains(t2)) {\n println(t2)\n break\n }\n }\n }\n}", "language": "Kotlin", "metadata": {"date": 1592185051, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02641.html", "problem_id": "p02641", "resource_group": "medium_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/Kotlin/s457328451.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s457328451", "user_id": "u371560174"}, "prompt_components": {"gold_output": "8\n", "input_to_evaluate": "import java.lang.Math.abs\n\nprivate fun readLn() = readLine()!!\nprivate fun readInt() = readLn().toInt()\nprivate fun readStrings() = readLn().split(\" \")\nprivate fun readInts() = readStrings().map(String::toInt)\nprivate fun readStrings2() = readLn().split(\"\").filter { it.isNotEmpty() }\nprivate fun readInts2() = readStrings2().map(String::toInt)\nprivate fun initArray(n:Int, v:String) = Array(n) { v }\nprivate fun initIntArray(n:Int, v:Int) = IntArray(n) { v }\n\nfun main(args: Array) {\n val (X, N) = readInts()\n val p = readInts().sorted()\n\n if (N == 0) {\n println(X)\n } else {\n for (i in 0 until N) {\n val t1 = X - i\n val t2 = X + i\n if (!p.contains(t1)) {\n println(t1)\n break\n } else if (!p.contains(t2)) {\n println(t2)\n break\n }\n }\n }\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 897, "cpu_time_ms": 119, "memory_kb": 38964}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s763913666", "group_id": "codeNet:p02641", "input_text": "import java.util.Scanner\n\nfun main(args: Array) {\n val cin = Scanner(System.`in`)\n val x = cin.nextInt()\n val n = cin.nextInt()\n val s = Array(105, {true})\n\n for (i in 0 until n) {\n val a = cin.nextInt()\n s[a] = false\n }\n\n for (i in 0..100) {\n if (x - i >= 0) {\n if (s[x - i]) {\n println(x - i)\n cin.close()\n return\n }\n }\n if (x + i <= 100) {\n if (s[x + i]) {\n println(x + i)\n cin.close()\n return\n }\n }\n }\n\n cin.close()\n}", "language": "Kotlin", "metadata": {"date": 1592184070, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02641.html", "problem_id": "p02641", "resource_group": "medium_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/Kotlin/s763913666.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s763913666", "user_id": "u194575259"}, "prompt_components": {"gold_output": "8\n", "input_to_evaluate": "import java.util.Scanner\n\nfun main(args: Array) {\n val cin = Scanner(System.`in`)\n val x = cin.nextInt()\n val n = cin.nextInt()\n val s = Array(105, {true})\n\n for (i in 0 until n) {\n val a = cin.nextInt()\n s[a] = false\n }\n\n for (i in 0..100) {\n if (x - i >= 0) {\n if (s[x - i]) {\n println(x - i)\n cin.close()\n return\n }\n }\n if (x + i <= 100) {\n if (s[x + i]) {\n println(x + i)\n cin.close()\n return\n }\n }\n }\n\n cin.close()\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 527, "cpu_time_ms": 120, "memory_kb": 36624}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s747822284", "group_id": "codeNet:p02641", "input_text": "import java.io.BufferedReader\nimport java.io.InputStream\nimport java.io.InputStreamReader\nimport java.util.*\nimport kotlin.math.abs\nimport kotlin.math.max\nimport kotlin.math.min\n\nval MOD = 1_000_000_007L\n\nclass Solver(stream: InputStream, private val out: java.io.PrintWriter) {\n fun solve() {\n val X =ni()\n val N =ni()\n val P = na(N).toSet()\n for (i in 0 until 100) {\n if (!P.contains(X - i)) {\n out.println(X - i)\n return\n } else if (!P.contains(X + i)) {\n out.println(X + i)\n return\n }\n }\n }\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n private val isDebug = try {\n // なんか本番でエラーでる\n System.getenv(\"MY_DEBUG\") != null\n } catch (t: Throwable) {\n false\n }\n\n private var tokenizer: StringTokenizer? = null\n private val reader = BufferedReader(InputStreamReader(stream), 32768)\n private fun next(): String {\n while (tokenizer == null || !tokenizer!!.hasMoreTokens()) {\n tokenizer = StringTokenizer(reader.readLine())\n }\n return tokenizer!!.nextToken()\n }\n\n private fun ni() = next().toInt()\n private fun nl() = next().toLong()\n private fun ns() = next()\n private fun na(n: Int, offset: Int = 0): IntArray {\n return map(n) { ni() + offset }\n }\n private fun nal(n: Int, offset: Int = 0): LongArray {\n val res = LongArray(n)\n for (i in 0 until n) {\n res[i] = nl() + offset\n }\n return res\n }\n\n private fun na2(n: Int, offset: Int = 0): Array {\n val a = Array(2){IntArray(n)}\n for (i in 0 until n) {\n for (e in a) {\n e[i] = ni() + offset\n }\n }\n return a\n }\n\n private inline fun map(n: Int, f: (Int) -> Int): IntArray {\n val res = IntArray(n)\n for (i in 0 until n) {\n res[i] = f(i)\n }\n return res\n }\n\n private inline fun debug(msg: () -> String) {\n if (isDebug) System.err.println(msg())\n }\n\n private fun debug(a: LongArray) {\n debug { a.joinToString(\" \") }\n }\n\n private fun debug(a: IntArray) {\n debug { a.joinToString(\" \") }\n }\n\n private fun debug(a: BooleanArray) {\n debug { a.map { if (it) 1 else 0 }.joinToString(\"\") }\n }\n\n private fun debugDim(A: Array) {\n if (isDebug) {\n for (a in A) {\n debug(a)\n }\n }\n }\n private fun debugDim(A: Array) {\n if (isDebug) {\n for (a in A) {\n debug(a)\n }\n }\n }\n\n /**\n * 勝手にimport消されるのを防ぎたい\n */\n private fun hoge() {\n min(1, 2)\n max(1, 2)\n abs(-10)\n }\n}\n\nfun main() {\n val out = java.io.PrintWriter(System.out)\n Solver(System.`in`, out).solve()\n out.flush()\n}", "language": "Kotlin", "metadata": {"date": 1592183163, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02641.html", "problem_id": "p02641", "resource_group": "medium_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/Kotlin/s747822284.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s747822284", "user_id": "u460609472"}, "prompt_components": {"gold_output": "8\n", "input_to_evaluate": "import java.io.BufferedReader\nimport java.io.InputStream\nimport java.io.InputStreamReader\nimport java.util.*\nimport kotlin.math.abs\nimport kotlin.math.max\nimport kotlin.math.min\n\nval MOD = 1_000_000_007L\n\nclass Solver(stream: InputStream, private val out: java.io.PrintWriter) {\n fun solve() {\n val X =ni()\n val N =ni()\n val P = na(N).toSet()\n for (i in 0 until 100) {\n if (!P.contains(X - i)) {\n out.println(X - i)\n return\n } else if (!P.contains(X + i)) {\n out.println(X + i)\n return\n }\n }\n }\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n private val isDebug = try {\n // なんか本番でエラーでる\n System.getenv(\"MY_DEBUG\") != null\n } catch (t: Throwable) {\n false\n }\n\n private var tokenizer: StringTokenizer? = null\n private val reader = BufferedReader(InputStreamReader(stream), 32768)\n private fun next(): String {\n while (tokenizer == null || !tokenizer!!.hasMoreTokens()) {\n tokenizer = StringTokenizer(reader.readLine())\n }\n return tokenizer!!.nextToken()\n }\n\n private fun ni() = next().toInt()\n private fun nl() = next().toLong()\n private fun ns() = next()\n private fun na(n: Int, offset: Int = 0): IntArray {\n return map(n) { ni() + offset }\n }\n private fun nal(n: Int, offset: Int = 0): LongArray {\n val res = LongArray(n)\n for (i in 0 until n) {\n res[i] = nl() + offset\n }\n return res\n }\n\n private fun na2(n: Int, offset: Int = 0): Array {\n val a = Array(2){IntArray(n)}\n for (i in 0 until n) {\n for (e in a) {\n e[i] = ni() + offset\n }\n }\n return a\n }\n\n private inline fun map(n: Int, f: (Int) -> Int): IntArray {\n val res = IntArray(n)\n for (i in 0 until n) {\n res[i] = f(i)\n }\n return res\n }\n\n private inline fun debug(msg: () -> String) {\n if (isDebug) System.err.println(msg())\n }\n\n private fun debug(a: LongArray) {\n debug { a.joinToString(\" \") }\n }\n\n private fun debug(a: IntArray) {\n debug { a.joinToString(\" \") }\n }\n\n private fun debug(a: BooleanArray) {\n debug { a.map { if (it) 1 else 0 }.joinToString(\"\") }\n }\n\n private fun debugDim(A: Array) {\n if (isDebug) {\n for (a in A) {\n debug(a)\n }\n }\n }\n private fun debugDim(A: Array) {\n if (isDebug) {\n for (a in A) {\n debug(a)\n }\n }\n }\n\n /**\n * 勝手にimport消されるのを防ぎたい\n */\n private fun hoge() {\n min(1, 2)\n max(1, 2)\n abs(-10)\n }\n}\n\nfun main() {\n val out = java.io.PrintWriter(System.out)\n Solver(System.`in`, out).solve()\n out.flush()\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2623, "cpu_time_ms": 129, "memory_kb": 38996}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s613255535", "group_id": "codeNet:p02644", "input_text": "import java.util.*\n\nfun main() {\n val builder = StringBuilder()\n\n val (h, w, k) = readInputLine().split(\" \").map { it.toInt() }\n\n val (y1, x1, y2, x2) = readInputLine().split(\" \").map { it.toInt() - 1 }\n\n val map = Array(h) { readInputLine().toCharArray() }\n\n val cost = Array(h) { IntArray(w) { Int.MAX_VALUE } }\n\n // (x, y)\n val queue = ArrayDeque>()\n\n queue.addLast(Pair(x1, y1))\n\n cost[y1][x1] = 0\n\n while (queue.isNotEmpty()) {\n val (x, y) = queue.pollFirst()\n\n val currentCost = cost[y][x]\n\n if (x == x2 && y == y2) {\n println(currentCost)\n return\n }\n\n for (i in x downTo (x - k).coerceAtLeast(0)) {\n if (map[y][i] == '@') {\n break\n }\n if (cost[y][i] < currentCost) {\n break\n }\n if (cost[y][i] > currentCost + 1) {\n cost[y][i] = currentCost + 1\n queue.add(Pair(i, y))\n }\n }\n for (i in x..(x + k).coerceAtMost(w - 1)) {\n if (map[y][i] == '@') {\n break\n }\n if (cost[y][i] < currentCost) {\n break\n }\n if (cost[y][i] > currentCost + 1) {\n cost[y][i] = currentCost + 1\n queue.add(Pair(i, y))\n }\n }\n\n for (i in y downTo (y - k).coerceAtLeast(0)) {\n if (map[i][x] == '@') {\n break\n }\n if (cost[i][x] < currentCost) {\n break\n }\n if (cost[i][x] > currentCost + 1) {\n cost[i][x] = currentCost + 1\n queue.add(Pair(x, i))\n }\n }\n for (i in y..(y + k).coerceAtMost(h - 1)) {\n if (map[i][x] == '@') {\n break\n }\n if (cost[i][x] < currentCost) {\n break\n }\n if (cost[i][x] > currentCost + 1) {\n cost[i][x] = currentCost + 1\n queue.add(Pair(x, i))\n }\n }\n }\n\n println(-1)\n\n// print(builder.toString())\n}\n\nfun readInputLine(): String {\n return readLine()!!\n}\n", "language": "Kotlin", "metadata": {"date": 1592444099, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02644.html", "problem_id": "p02644", "resource_group": "medium_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/Kotlin/s613255535.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s613255535", "user_id": "u505558493"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "import java.util.*\n\nfun main() {\n val builder = StringBuilder()\n\n val (h, w, k) = readInputLine().split(\" \").map { it.toInt() }\n\n val (y1, x1, y2, x2) = readInputLine().split(\" \").map { it.toInt() - 1 }\n\n val map = Array(h) { readInputLine().toCharArray() }\n\n val cost = Array(h) { IntArray(w) { Int.MAX_VALUE } }\n\n // (x, y)\n val queue = ArrayDeque>()\n\n queue.addLast(Pair(x1, y1))\n\n cost[y1][x1] = 0\n\n while (queue.isNotEmpty()) {\n val (x, y) = queue.pollFirst()\n\n val currentCost = cost[y][x]\n\n if (x == x2 && y == y2) {\n println(currentCost)\n return\n }\n\n for (i in x downTo (x - k).coerceAtLeast(0)) {\n if (map[y][i] == '@') {\n break\n }\n if (cost[y][i] < currentCost) {\n break\n }\n if (cost[y][i] > currentCost + 1) {\n cost[y][i] = currentCost + 1\n queue.add(Pair(i, y))\n }\n }\n for (i in x..(x + k).coerceAtMost(w - 1)) {\n if (map[y][i] == '@') {\n break\n }\n if (cost[y][i] < currentCost) {\n break\n }\n if (cost[y][i] > currentCost + 1) {\n cost[y][i] = currentCost + 1\n queue.add(Pair(i, y))\n }\n }\n\n for (i in y downTo (y - k).coerceAtLeast(0)) {\n if (map[i][x] == '@') {\n break\n }\n if (cost[i][x] < currentCost) {\n break\n }\n if (cost[i][x] > currentCost + 1) {\n cost[i][x] = currentCost + 1\n queue.add(Pair(x, i))\n }\n }\n for (i in y..(y + k).coerceAtMost(h - 1)) {\n if (map[i][x] == '@') {\n break\n }\n if (cost[i][x] < currentCost) {\n break\n }\n if (cost[i][x] > currentCost + 1) {\n cost[i][x] = currentCost + 1\n queue.add(Pair(x, i))\n }\n }\n }\n\n println(-1)\n\n// print(builder.toString())\n}\n\nfun readInputLine(): String {\n return readLine()!!\n}\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2211, "cpu_time_ms": 3310, "memory_kb": 68292}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s905525421", "group_id": "codeNet:p02645", "input_text": "fun main(args: Array) {\n var s = readLine()!!\n \n println(s.substring(0, 3))\n}", "language": "Kotlin", "metadata": {"date": 1592096685, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02645.html", "problem_id": "p02645", "resource_group": "medium_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/Kotlin/s905525421.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s905525421", "user_id": "u952914882"}, "prompt_components": {"gold_output": "tak\n", "input_to_evaluate": "fun main(args: Array) {\n var s = readLine()!!\n \n println(s.substring(0, 3))\n}", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 83, "memory_kb": 34512}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s647472178", "group_id": "codeNet:p02646", "input_text": "import java.io.PrintWriter\nimport kotlin.math.abs\n\nfun main() {\n PrintWriter(System.out).use { out ->\n solve(out)\n out.flush()\n }\n}\n\nfun solve(out: PrintWriter) {\n val (a, v) = readLongList()\n val (b, w) = readLongList()\n val t = readLong()\n\n if (w >= v) {\n println(\"NO\")\n } else {\n val d = abs(a - b)\n if (d <= t * (v - w)) {\n println(\"YES\")\n } else {\n println(\"NO\")\n }\n }\n}\n\nfun readInteger() = readLine()!!.toInt()\nfun readLong() = readLine()!!.toLong()\nfun readStringList() = readLine()!!.split(\" \")\nfun readIntegerList() = readStringList().map(String::toInt)\nfun readLongList() = readStringList().map(String::toLong)\nfun readDoubleList() = readStringList().map(String::toDouble)\n", "language": "Kotlin", "metadata": {"date": 1593239767, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02646.html", "problem_id": "p02646", "resource_group": "medium_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/Kotlin/s647472178.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s647472178", "user_id": "u784448849"}, "prompt_components": {"gold_output": "YES\n", "input_to_evaluate": "import java.io.PrintWriter\nimport kotlin.math.abs\n\nfun main() {\n PrintWriter(System.out).use { out ->\n solve(out)\n out.flush()\n }\n}\n\nfun solve(out: PrintWriter) {\n val (a, v) = readLongList()\n val (b, w) = readLongList()\n val t = readLong()\n\n if (w >= v) {\n println(\"NO\")\n } else {\n val d = abs(a - b)\n if (d <= t * (v - w)) {\n println(\"YES\")\n } else {\n println(\"NO\")\n }\n }\n}\n\nfun readInteger() = readLine()!!.toInt()\nfun readLong() = readLine()!!.toLong()\nfun readStringList() = readLine()!!.split(\" \")\nfun readIntegerList() = readStringList().map(String::toInt)\nfun readLongList() = readStringList().map(String::toLong)\nfun readDoubleList() = readStringList().map(String::toDouble)\n", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 779, "cpu_time_ms": 117, "memory_kb": 36360}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s601031411", "group_id": "codeNet:p02646", "input_text": "fun main(args: Array) {\n val (a, v) = readLine()?.split(\" \")?.map(String::toLong)?: return\n val (b, w) = readLine()?.split(\" \")?.map(String::toLong)?: return\n val t = readLine()?.toLong()?: return\n if (Math.abs(a-b) <= (v - w) * t) {\n println(\"YES\")\n } else {\n println(\"NO\")\n }\n}\n", "language": "Kotlin", "metadata": {"date": 1592211557, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02646.html", "problem_id": "p02646", "resource_group": "medium_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/Kotlin/s601031411.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s601031411", "user_id": "u228849856"}, "prompt_components": {"gold_output": "YES\n", "input_to_evaluate": "fun main(args: Array) {\n val (a, v) = readLine()?.split(\" \")?.map(String::toLong)?: return\n val (b, w) = readLine()?.split(\" \")?.map(String::toLong)?: return\n val t = readLine()?.toLong()?: return\n if (Math.abs(a-b) <= (v - w) * t) {\n println(\"YES\")\n } else {\n println(\"NO\")\n }\n}\n", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 98, "memory_kb": 36380}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s817565884", "group_id": "codeNet:p02646", "input_text": "fun main(args: Array) {\n val (a, v) = readLine()?.split(\" \")?.map(String::toInt)?: return\n val (b, w) = readLine()?.split(\" \")?.map(String::toInt)?: return\n val t = readLine()?.toInt()?: return\n var daemonPosition = a\n var targetPosition = b\n var isMatched = false\n for (i in 0 until t) {\n daemonPosition += v\n if (daemonPosition == targetPosition) {\n isMatched = true\n break\n }\n targetPosition += w\n if (daemonPosition == targetPosition) {\n isMatched = true\n break\n }\n }\n if (isMatched) {\n println(\"YES\")\n } else {\n println(\"NO\")\n }\n}", "language": "Kotlin", "metadata": {"date": 1592159347, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02646.html", "problem_id": "p02646", "resource_group": "medium_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/Kotlin/s817565884.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s817565884", "user_id": "u228849856"}, "prompt_components": {"gold_output": "YES\n", "input_to_evaluate": "fun main(args: Array) {\n val (a, v) = readLine()?.split(\" \")?.map(String::toInt)?: return\n val (b, w) = readLine()?.split(\" \")?.map(String::toInt)?: return\n val t = readLine()?.toInt()?: return\n var daemonPosition = a\n var targetPosition = b\n var isMatched = false\n for (i in 0 until t) {\n daemonPosition += v\n if (daemonPosition == targetPosition) {\n isMatched = true\n break\n }\n targetPosition += w\n if (daemonPosition == targetPosition) {\n isMatched = true\n break\n }\n }\n if (isMatched) {\n println(\"YES\")\n } else {\n println(\"NO\")\n }\n}", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 676, "cpu_time_ms": 766, "memory_kb": 36572}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s537440881", "group_id": "codeNet:p02646", "input_text": "fun main(args : Array) {\n val (a, v) = readLine()!!.split(\" \").map { it.toInt() }\n val (b, w) = readLine()!!.split(\" \").map { it.toInt() }\n val t = readLine()!!.toInt()\n\n if (v <= w) {\n println(\"NO\")\n return\n }\n\n val diff = Math.abs(b - a)\n val fill = v - w\n\n println(if (diff / fill <= t) \"YES\" else \"NO\")\n}", "language": "Kotlin", "metadata": {"date": 1592115187, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02646.html", "problem_id": "p02646", "resource_group": "medium_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/Kotlin/s537440881.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s537440881", "user_id": "u262403099"}, "prompt_components": {"gold_output": "YES\n", "input_to_evaluate": "fun main(args : Array) {\n val (a, v) = readLine()!!.split(\" \").map { it.toInt() }\n val (b, w) = readLine()!!.split(\" \").map { it.toInt() }\n val t = readLine()!!.toInt()\n\n if (v <= w) {\n println(\"NO\")\n return\n }\n\n val diff = Math.abs(b - a)\n val fill = v - w\n\n println(if (diff / fill <= t) \"YES\" else \"NO\")\n}", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 108, "memory_kb": 36276}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s362621800", "group_id": "codeNet:p02646", "input_text": "import java.math.BigDecimal\n\nfun main() {\n val (A, V) = readLine()!!.split(\" \").map { BigDecimal(it) }\n val (B, W) = readLine()!!.split(\" \").map { BigDecimal(it) }\n val T = BigDecimal(readLine()!!)\n if(W >= V){\n println(\"NO\")\n return\n }\n\n val l = (A - B).abs()\n val v = V - W\n if(l.remainder(v) == BigDecimal.ZERO && l.divide(v) <= T){\n println(\"YES\")\n }else{\n println(\"NO\")\n }\n}", "language": "Kotlin", "metadata": {"date": 1592100489, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02646.html", "problem_id": "p02646", "resource_group": "medium_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/Kotlin/s362621800.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s362621800", "user_id": "u531770859"}, "prompt_components": {"gold_output": "YES\n", "input_to_evaluate": "import java.math.BigDecimal\n\nfun main() {\n val (A, V) = readLine()!!.split(\" \").map { BigDecimal(it) }\n val (B, W) = readLine()!!.split(\" \").map { BigDecimal(it) }\n val T = BigDecimal(readLine()!!)\n if(W >= V){\n println(\"NO\")\n return\n }\n\n val l = (A - B).abs()\n val v = V - W\n if(l.remainder(v) == BigDecimal.ZERO && l.divide(v) <= T){\n println(\"YES\")\n }else{\n println(\"NO\")\n }\n}", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 100, "memory_kb": 36772}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s726168511", "group_id": "codeNet:p02646", "input_text": "//\n\nfun main() {\n tokiomarine2020b()\n}\n\nfun tokiomarine2020b() {\n val (a, v) = readLine()!!.split(\" \").map { it.toLong() }\n val (b, w) = readLine()!!.split(\" \").map { it.toLong() }\n val t = readLine()!!.toLong()\n if (v <= w) {\n // 永遠に追いつけない\n println(\"NO\")\n return\n }\n if (a > b) {\n for (i in 0..t) {\n if (v * i + a == w * i + b) {\n println(\"YES\")\n return\n }\n }\n } else {\n for (i in 0..t) {\n if (v * i + a == w * i + b) {\n println(\"YES\")\n return\n }\n }\n }\n println(\"NO\")\n}\n", "language": "Kotlin", "metadata": {"date": 1592097732, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02646.html", "problem_id": "p02646", "resource_group": "medium_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/Kotlin/s726168511.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s726168511", "user_id": "u628907033"}, "prompt_components": {"gold_output": "YES\n", "input_to_evaluate": "//\n\nfun main() {\n tokiomarine2020b()\n}\n\nfun tokiomarine2020b() {\n val (a, v) = readLine()!!.split(\" \").map { it.toLong() }\n val (b, w) = readLine()!!.split(\" \").map { it.toLong() }\n val t = readLine()!!.toLong()\n if (v <= w) {\n // 永遠に追いつけない\n println(\"NO\")\n return\n }\n if (a > b) {\n for (i in 0..t) {\n if (v * i + a == w * i + b) {\n println(\"YES\")\n return\n }\n }\n } else {\n for (i in 0..t) {\n if (v * i + a == w * i + b) {\n println(\"YES\")\n return\n }\n }\n }\n println(\"NO\")\n}\n", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 672, "cpu_time_ms": 913, "memory_kb": 37072}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s057416086", "group_id": "codeNet:p02646", "input_text": "fun main(args: Array) {\n val (a,v) = readLine()!!.split(\" \").map { it.toInt() }\n val (b,w) = readLine()!!.split(\" \").map { it.toInt() }\n val t= readLine()!!.toInt()\n\n val aAble = a + v * t\n val bAble = b + w * t\n\n val touchaable = bAble <= aAble\n println(if (touchaable) \"YES\" else \"NO\")\n}\n", "language": "Kotlin", "metadata": {"date": 1592097463, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02646.html", "problem_id": "p02646", "resource_group": "medium_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/Kotlin/s057416086.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s057416086", "user_id": "u381359012"}, "prompt_components": {"gold_output": "YES\n", "input_to_evaluate": "fun main(args: Array) {\n val (a,v) = readLine()!!.split(\" \").map { it.toInt() }\n val (b,w) = readLine()!!.split(\" \").map { it.toInt() }\n val t= readLine()!!.toInt()\n\n val aAble = a + v * t\n val bAble = b + w * t\n\n val touchaable = bAble <= aAble\n println(if (touchaable) \"YES\" else \"NO\")\n}\n", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 103, "memory_kb": 36404}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s835555615", "group_id": "codeNet:p02647", "input_text": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val n = sc.nextInt()\n val k = sc.nextInt()\n val a = (0 until n).map { sc.next().toInt() }\n println(problem2020c(n, k, a))\n}\n\nfun problem2020c(n: Int, k: Int, a: List): String {\n val power = Array(k + 1) { IntArray(n) }\n power[0] = a.toIntArray()\n for (i in 0 until k) {\n for (j in 0 until n) {\n val px = power[i][j]\n// val range = (Math.max(0, j - px)..Math.min(j + px, n - 1))\n// for (r in range) {\n// power[i + 1][r] += 1\n// }\n }\n if (power.last().all { it == n }) break\n }\n return power.last().joinToString(\" \")\n}", "language": "Kotlin", "metadata": {"date": 1592104366, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02647.html", "problem_id": "p02647", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02647/input.txt", "sample_output_relpath": "derived/input_output/data/p02647/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02647/Kotlin/s835555615.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s835555615", "user_id": "u073232808"}, "prompt_components": {"gold_output": "1 2 2 1 2\n", "input_to_evaluate": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val n = sc.nextInt()\n val k = sc.nextInt()\n val a = (0 until n).map { sc.next().toInt() }\n println(problem2020c(n, k, a))\n}\n\nfun problem2020c(n: Int, k: Int, a: List): String {\n val power = Array(k + 1) { IntArray(n) }\n power[0] = a.toIntArray()\n for (i in 0 until k) {\n for (j in 0 until n) {\n val px = power[i][j]\n// val range = (Math.max(0, j - px)..Math.min(j + px, n - 1))\n// for (r in range) {\n// power[i + 1][r] += 1\n// }\n }\n if (power.last().all { it == n }) break\n }\n return power.last().joinToString(\" \")\n}", "problem_context": "Score : 500 points\n\nProblem Statement\n\nWe have N bulbs arranged on a number line, numbered 1 to N from left to right.\nBulb i is at coordinate i.\n\nEach bulb has a non-negative integer parameter called intensity.\nWhen there is a bulb of intensity d at coordinate x, the bulb illuminates the segment from coordinate x-d-0.5 to x+d+0.5.\nInitially, the intensity of Bulb i is A_i. We will now do the following operation K times in a row:\n\nFor each integer i between 1 and N (inclusive), let B_i be the number of bulbs illuminating coordinate i. Then, change the intensity of each bulb i to B_i.\n\nFind the intensity of each bulb after the K operations.\n\nConstraints\n\n1 \\leq N \\leq 2 \\times 10^5\n\n1 \\leq K \\leq 2 \\times 10^5\n\n0 \\leq A_i \\leq N\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\nPrint the intensity A{'}_i of each bulb i after the K operations to Standard Output in the following format:\n\nA{'}_1 A{'}_2 \\ldots A{'}_N\n\nSample Input 1\n\n5 1\n1 0 0 1 0\n\nSample Output 1\n\n1 2 2 1 2\n\nInitially, only Bulb 1 illuminates coordinate 1, so the intensity of Bulb 1 becomes 1 after the operation.\nSimilarly, the bulbs initially illuminating coordinate 2 are Bulb 1 and 2, so the intensity of Bulb 2 becomes 2.\n\nSample Input 2\n\n5 2\n1 0 0 1 0\n\nSample Output 2\n\n3 3 4 4 3", "sample_input": "5 1\n1 0 0 1 0\n"}, "reference_outputs": ["1 2 2 1 2\n"], "source_document_id": "p02647", "source_text": "Score : 500 points\n\nProblem Statement\n\nWe have N bulbs arranged on a number line, numbered 1 to N from left to right.\nBulb i is at coordinate i.\n\nEach bulb has a non-negative integer parameter called intensity.\nWhen there is a bulb of intensity d at coordinate x, the bulb illuminates the segment from coordinate x-d-0.5 to x+d+0.5.\nInitially, the intensity of Bulb i is A_i. We will now do the following operation K times in a row:\n\nFor each integer i between 1 and N (inclusive), let B_i be the number of bulbs illuminating coordinate i. Then, change the intensity of each bulb i to B_i.\n\nFind the intensity of each bulb after the K operations.\n\nConstraints\n\n1 \\leq N \\leq 2 \\times 10^5\n\n1 \\leq K \\leq 2 \\times 10^5\n\n0 \\leq A_i \\leq N\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\nPrint the intensity A{'}_i of each bulb i after the K operations to Standard Output in the following format:\n\nA{'}_1 A{'}_2 \\ldots A{'}_N\n\nSample Input 1\n\n5 1\n1 0 0 1 0\n\nSample Output 1\n\n1 2 2 1 2\n\nInitially, only Bulb 1 illuminates coordinate 1, so the intensity of Bulb 1 becomes 1 after the operation.\nSimilarly, the bulbs initially illuminating coordinate 2 are Bulb 1 and 2, so the intensity of Bulb 2 becomes 2.\n\nSample Input 2\n\n5 2\n1 0 0 1 0\n\nSample Output 2\n\n3 3 4 4 3", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1415, "memory_kb": 963300}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s450697882", "group_id": "codeNet:p02657", "input_text": "fun main(args: Array) {\n val input = readLine()!!.split(\" \").map(String::toInt)\n println(input[0] * input[1])\n}", "language": "Kotlin", "metadata": {"date": 1594646648, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02657.html", "problem_id": "p02657", "resource_group": "medium_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/Kotlin/s450697882.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s450697882", "user_id": "u038956474"}, "prompt_components": {"gold_output": "10\n", "input_to_evaluate": "fun main(args: Array) {\n val input = readLine()!!.split(\" \").map(String::toInt)\n println(input[0] * input[1])\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 125, "cpu_time_ms": 111, "memory_kb": 36396}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s160657984", "group_id": "codeNet:p02657", "input_text": "import kotlin.math.pow\nimport kotlin.system.exitProcess\n\nfun main() {\n val numberOfNumbers = readLine()?.toInt()\n\n if (numberOfNumbers != null) {\n if(numberOfNumbers < 2 || numberOfNumbers > 10.0.pow(15.0)) {\n exitProcess(0)\n } else {\n val numbers = readLine()\n val numbers2 = numbers?.split(\" \")?.map { it.toLong() }\n multiply(numbers2)\n }\n }\n}\n\nfun multiply(numbersToBeMultiplied: List?) {\n var result = 1L\n\n if (numbersToBeMultiplied != null) {\n for (item in numbersToBeMultiplied) {\n result *= item\n }\n }\n\n return if (result > 10.0.pow(18.0))\n println(\"-1\")\n else\n println(result)\n}", "language": "Kotlin", "metadata": {"date": 1591560770, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02657.html", "problem_id": "p02657", "resource_group": "medium_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/Kotlin/s160657984.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s160657984", "user_id": "u124420353"}, "prompt_components": {"gold_output": "10\n", "input_to_evaluate": "import kotlin.math.pow\nimport kotlin.system.exitProcess\n\nfun main() {\n val numberOfNumbers = readLine()?.toInt()\n\n if (numberOfNumbers != null) {\n if(numberOfNumbers < 2 || numberOfNumbers > 10.0.pow(15.0)) {\n exitProcess(0)\n } else {\n val numbers = readLine()\n val numbers2 = numbers?.split(\" \")?.map { it.toLong() }\n multiply(numbers2)\n }\n }\n}\n\nfun multiply(numbersToBeMultiplied: List?) {\n var result = 1L\n\n if (numbersToBeMultiplied != null) {\n for (item in numbersToBeMultiplied) {\n result *= item\n }\n }\n\n return if (result > 10.0.pow(18.0))\n println(\"-1\")\n else\n println(result)\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 719, "cpu_time_ms": 90, "memory_kb": 34480}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s940135687", "group_id": "codeNet:p02657", "input_text": "fun main(args: Array) {\n val n = readLine()!!.split(\" \").map(String::toInt)\n\n println(n[0] * n[1])\n}\n\n", "language": "Kotlin", "metadata": {"date": 1590973388, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02657.html", "problem_id": "p02657", "resource_group": "medium_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/Kotlin/s940135687.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s940135687", "user_id": "u143634246"}, "prompt_components": {"gold_output": "10\n", "input_to_evaluate": "fun main(args: Array) {\n val n = readLine()!!.split(\" \").map(String::toInt)\n\n println(n[0] * n[1])\n}\n\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 94, "memory_kb": 36364}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s312825587", "group_id": "codeNet:p02660", "input_text": "import kotlin.math.sqrt\n\nfun main(){\n val N = readLine()!!.toLong()\n\n if(N == 1L){\n println(0)\n return\n }\n\n var x = N\n val pSet = mutableSetOf()\n for(i in 2..sqrt(N.toDouble()).toInt()){\n while(x % i == 0L){\n pSet.add(i.toLong())\n x /= i\n }\n }\n\n if(pSet.isEmpty()){\n println(1)\n return\n }\n\n var ans = 0\n x = N\n pSet.forEach { p ->\n var pp = p\n while (x % pp == 0L){\n ans++\n x /= pp\n pp *= p\n }\n }\n println(ans)\n}", "language": "Kotlin", "metadata": {"date": 1590975611, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02660.html", "problem_id": "p02660", "resource_group": "medium_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/Kotlin/s312825587.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s312825587", "user_id": "u531770859"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "import kotlin.math.sqrt\n\nfun main(){\n val N = readLine()!!.toLong()\n\n if(N == 1L){\n println(0)\n return\n }\n\n var x = N\n val pSet = mutableSetOf()\n for(i in 2..sqrt(N.toDouble()).toInt()){\n while(x % i == 0L){\n pSet.add(i.toLong())\n x /= i\n }\n }\n\n if(pSet.isEmpty()){\n println(1)\n return\n }\n\n var ans = 0\n x = N\n pSet.forEach { p ->\n var pp = p\n while (x % pp == 0L){\n ans++\n x /= pp\n pp *= p\n }\n }\n println(ans)\n}", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 578, "cpu_time_ms": 98, "memory_kb": 34596}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s866983443", "group_id": "codeNet:p02661", "input_text": "@file:Suppress(\"NOTHING_TO_INLINE\", \"EXPERIMENTAL_FEATURE_WARNING\", \"OVERRIDE_BY_INLINE\")\n\nimport java.io.PrintWriter\nimport java.math.MathContext\nimport java.math.RoundingMode\nimport kotlin.math.*\nimport kotlin.random.Random\nimport kotlin.collections.sort as _sort\nimport kotlin.collections.sortDescending as _sortDescending\nimport kotlin.io.println as iprintln\n\n/** @author Spheniscine */\nfun main() { _writer.solve(); _writer.flush() }\nfun PrintWriter.solve() {\n val numCases = 1//readInt()\n for(case in 1..numCases) {\n //print(\"Case #$case: \")\n\n val n = readInt()\n val A = IntArray(n)\n val B = IntArray(n) {\n A[it] = readInt()\n readInt()\n }\n\n val ans = if(n and 1 == 1) B.quickSelect(n/2) - A.quickSelect(n/2) + 1\n else {\n val lo = A.quickSelect(n/2) + A.quickSelect(n/2-1)\n val hi = B.quickSelect(n/2) + B.quickSelect(n/2-1)\n\n hi - lo + 1\n }\n\n println(ans)\n }\n}\n\nfun IntArray.swap(i: Int, j: Int) { val t = this[i]; this[i] = this[j]; this[j] = t }\nfun LongArray.swap(i: Int, j: Int) { val t = this[i]; this[i] = this[j]; this[j] = t }\n\nfun IntArray.quickSelect(k: Int): Int {\n require(k in indices)\n\n var lb = 0\n var rb = size\n \n while(true) {\n val pivot = this[random.nextInt(lb, rb)]\n var lt = lb\n var gt = rb\n \n for(i in lb until rb) {\n if(i == gt) break\n when {\n this[i] < pivot -> {\n swap(i, lt++)\n }\n this[i] > pivot -> {\n swap(i, --gt)\n }\n }\n \n when {\n k < lt -> rb = lt\n k >= gt -> lb = gt\n else -> return this[k]\n }\n }\n }\n}\n\n/** IO */\n//@JvmField val INPUT = File(\"input.txt\").inputStream()\n//@JvmField val OUTPUT = File(\"output.txt\").outputStream()\n@JvmField val INPUT = System.`in`\n@JvmField val OUTPUT = System.out\n\nconst val _BUFFER_SIZE = 1 shl 16\n@JvmField val _buffer = ByteArray(_BUFFER_SIZE)\n@JvmField var _bufferPt = 0\n@JvmField var _bytesRead = 0\n\ntailrec fun readChar(): Char {\n if(_bufferPt == _bytesRead) {\n _bufferPt = 0\n _bytesRead = INPUT.read(_buffer, 0, _BUFFER_SIZE)\n }\n return if(_bytesRead < 0) Char.MIN_VALUE\n else {\n val c = _buffer[_bufferPt++].toChar()\n if (c == '\\r') readChar()\n else c\n }\n}\n\nfun readLine(): String? {\n var c = readChar()\n return if(c == Char.MIN_VALUE) null\n else buildString {\n while(true) {\n when(c) {\n '\\n', Char.MIN_VALUE -> return@buildString\n else -> {\n append(c)\n c = readChar()\n }\n }\n }\n }\n}\nfun readLn() = readLine()!!\n\nfun read() = buildString {\n var c = readChar()\n while(c <= ' ') {\n if(c == Char.MIN_VALUE) return@buildString\n c = readChar()\n }\n do {\n append(c)\n c = readChar()\n } while(c > ' ')\n}\nfun readInt() = read().toInt()\nfun readDouble() = read().toDouble()\nfun readLong() = read().toLong()\nfun readStrings(n: Int) = List(n) { read() }\nfun readLines(n: Int) = List(n) { readLn() }\nfun readInts(n: Int) = List(n) { read().toInt() }\nfun readIntArray(n: Int) = IntArray(n) { read().toInt() }\nfun readDoubles(n: Int) = List(n) { read().toDouble() }\nfun readDoubleArray(n: Int) = DoubleArray(n) { read().toDouble() }\nfun readLongs(n: Int) = List(n) { read().toLong() }\nfun readLongArray(n: Int) = LongArray(n) { read().toLong() }\n\n@JvmField val _writer = PrintWriter(OUTPUT, false)\n\n/** shuffles and sort overrides to avoid quicksort attacks */\nprivate inline fun _shuffle(rnd: Random, get: (Int) -> T, set: (Int, T) -> Unit, size: Int) {\n // Fisher-Yates shuffle algorithm\n for (i in size - 1 downTo 1) {\n val j = rnd.nextInt(i + 1)\n val temp = get(i)\n set(i, get(j))\n set(j, temp)\n }\n}\n\n@JvmField var _random: Random? = null\nval random get() = _random ?: Random(0x594E215C123 * System.nanoTime()).also { _random = it }\n\nfun IntArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\nfun IntArray.sort() { shuffle(); _sort() }\nfun IntArray.sortDescending() { shuffle(); _sortDescending() }\n\nfun LongArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\nfun LongArray.sort() { shuffle(); _sort() }\nfun LongArray.sortDescending() { shuffle(); _sortDescending() }\n\nfun DoubleArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\nfun DoubleArray.sort() { shuffle(); _sort() }\nfun DoubleArray.sortDescending() { shuffle(); _sortDescending() }\n\nfun CharArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\ninline fun CharArray.sort() { _sort() }\ninline fun CharArray.sortDescending() { _sortDescending() }\n\ninline fun > Array.sort() = _sort()\ninline fun > Array.sortDescending() = _sortDescending()\ninline fun > MutableList.sort() = _sort()\ninline fun > MutableList.sortDescending() = _sortDescending()\n\nfun `please stop removing these imports IntelliJ`() { iprintln(max(1, 2)) }\n\n/** additional commons */\ninline fun Iterable.sumByLong(func: (T) -> Long) = fold(0L) { acc, t -> acc + func(t) }\ninline fun Sequence.sumByLong(func: (T) -> Long) = fold(0L) { acc, t -> acc + func(t) }\ninline fun Array.sumByLong(func: (T) -> Long) = fold(0L) { acc, t -> acc + func(t) }\nfun IntArray.sumLong() = fold(0L, Long::plus)\n", "language": "Kotlin", "metadata": {"date": 1591052564, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02661.html", "problem_id": "p02661", "resource_group": "medium_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/Kotlin/s866983443.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s866983443", "user_id": "u596111103"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "@file:Suppress(\"NOTHING_TO_INLINE\", \"EXPERIMENTAL_FEATURE_WARNING\", \"OVERRIDE_BY_INLINE\")\n\nimport java.io.PrintWriter\nimport java.math.MathContext\nimport java.math.RoundingMode\nimport kotlin.math.*\nimport kotlin.random.Random\nimport kotlin.collections.sort as _sort\nimport kotlin.collections.sortDescending as _sortDescending\nimport kotlin.io.println as iprintln\n\n/** @author Spheniscine */\nfun main() { _writer.solve(); _writer.flush() }\nfun PrintWriter.solve() {\n val numCases = 1//readInt()\n for(case in 1..numCases) {\n //print(\"Case #$case: \")\n\n val n = readInt()\n val A = IntArray(n)\n val B = IntArray(n) {\n A[it] = readInt()\n readInt()\n }\n\n val ans = if(n and 1 == 1) B.quickSelect(n/2) - A.quickSelect(n/2) + 1\n else {\n val lo = A.quickSelect(n/2) + A.quickSelect(n/2-1)\n val hi = B.quickSelect(n/2) + B.quickSelect(n/2-1)\n\n hi - lo + 1\n }\n\n println(ans)\n }\n}\n\nfun IntArray.swap(i: Int, j: Int) { val t = this[i]; this[i] = this[j]; this[j] = t }\nfun LongArray.swap(i: Int, j: Int) { val t = this[i]; this[i] = this[j]; this[j] = t }\n\nfun IntArray.quickSelect(k: Int): Int {\n require(k in indices)\n\n var lb = 0\n var rb = size\n \n while(true) {\n val pivot = this[random.nextInt(lb, rb)]\n var lt = lb\n var gt = rb\n \n for(i in lb until rb) {\n if(i == gt) break\n when {\n this[i] < pivot -> {\n swap(i, lt++)\n }\n this[i] > pivot -> {\n swap(i, --gt)\n }\n }\n \n when {\n k < lt -> rb = lt\n k >= gt -> lb = gt\n else -> return this[k]\n }\n }\n }\n}\n\n/** IO */\n//@JvmField val INPUT = File(\"input.txt\").inputStream()\n//@JvmField val OUTPUT = File(\"output.txt\").outputStream()\n@JvmField val INPUT = System.`in`\n@JvmField val OUTPUT = System.out\n\nconst val _BUFFER_SIZE = 1 shl 16\n@JvmField val _buffer = ByteArray(_BUFFER_SIZE)\n@JvmField var _bufferPt = 0\n@JvmField var _bytesRead = 0\n\ntailrec fun readChar(): Char {\n if(_bufferPt == _bytesRead) {\n _bufferPt = 0\n _bytesRead = INPUT.read(_buffer, 0, _BUFFER_SIZE)\n }\n return if(_bytesRead < 0) Char.MIN_VALUE\n else {\n val c = _buffer[_bufferPt++].toChar()\n if (c == '\\r') readChar()\n else c\n }\n}\n\nfun readLine(): String? {\n var c = readChar()\n return if(c == Char.MIN_VALUE) null\n else buildString {\n while(true) {\n when(c) {\n '\\n', Char.MIN_VALUE -> return@buildString\n else -> {\n append(c)\n c = readChar()\n }\n }\n }\n }\n}\nfun readLn() = readLine()!!\n\nfun read() = buildString {\n var c = readChar()\n while(c <= ' ') {\n if(c == Char.MIN_VALUE) return@buildString\n c = readChar()\n }\n do {\n append(c)\n c = readChar()\n } while(c > ' ')\n}\nfun readInt() = read().toInt()\nfun readDouble() = read().toDouble()\nfun readLong() = read().toLong()\nfun readStrings(n: Int) = List(n) { read() }\nfun readLines(n: Int) = List(n) { readLn() }\nfun readInts(n: Int) = List(n) { read().toInt() }\nfun readIntArray(n: Int) = IntArray(n) { read().toInt() }\nfun readDoubles(n: Int) = List(n) { read().toDouble() }\nfun readDoubleArray(n: Int) = DoubleArray(n) { read().toDouble() }\nfun readLongs(n: Int) = List(n) { read().toLong() }\nfun readLongArray(n: Int) = LongArray(n) { read().toLong() }\n\n@JvmField val _writer = PrintWriter(OUTPUT, false)\n\n/** shuffles and sort overrides to avoid quicksort attacks */\nprivate inline fun _shuffle(rnd: Random, get: (Int) -> T, set: (Int, T) -> Unit, size: Int) {\n // Fisher-Yates shuffle algorithm\n for (i in size - 1 downTo 1) {\n val j = rnd.nextInt(i + 1)\n val temp = get(i)\n set(i, get(j))\n set(j, temp)\n }\n}\n\n@JvmField var _random: Random? = null\nval random get() = _random ?: Random(0x594E215C123 * System.nanoTime()).also { _random = it }\n\nfun IntArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\nfun IntArray.sort() { shuffle(); _sort() }\nfun IntArray.sortDescending() { shuffle(); _sortDescending() }\n\nfun LongArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\nfun LongArray.sort() { shuffle(); _sort() }\nfun LongArray.sortDescending() { shuffle(); _sortDescending() }\n\nfun DoubleArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\nfun DoubleArray.sort() { shuffle(); _sort() }\nfun DoubleArray.sortDescending() { shuffle(); _sortDescending() }\n\nfun CharArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\ninline fun CharArray.sort() { _sort() }\ninline fun CharArray.sortDescending() { _sortDescending() }\n\ninline fun > Array.sort() = _sort()\ninline fun > Array.sortDescending() = _sortDescending()\ninline fun > MutableList.sort() = _sort()\ninline fun > MutableList.sortDescending() = _sortDescending()\n\nfun `please stop removing these imports IntelliJ`() { iprintln(max(1, 2)) }\n\n/** additional commons */\ninline fun Iterable.sumByLong(func: (T) -> Long) = fold(0L) { acc, t -> acc + func(t) }\ninline fun Sequence.sumByLong(func: (T) -> Long) = fold(0L) { acc, t -> acc + func(t) }\ninline fun Array.sumByLong(func: (T) -> Long) = fold(0L) { acc, t -> acc + func(t) }\nfun IntArray.sumLong() = fold(0L, Long::plus)\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 5634, "cpu_time_ms": 191, "memory_kb": 56484}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s957266081", "group_id": "codeNet:p02663", "input_text": "fun main(args: Array) {\n val (h1, m1, h2, m2, k) = readLine()!!.split(' ').map { it.toInt() }\n\n\n val e = h2* 60 + m2\n val s = h1 * 60 + m1\n val l = e-s\n\n println(l-k)\n}\n", "language": "Kotlin", "metadata": {"date": 1590886924, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02663.html", "problem_id": "p02663", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02663/input.txt", "sample_output_relpath": "derived/input_output/data/p02663/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02663/Kotlin/s957266081.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s957266081", "user_id": "u288435405"}, "prompt_components": {"gold_output": "270\n", "input_to_evaluate": "fun main(args: Array) {\n val (h1, m1, h2, m2, k) = readLine()!!.split(' ').map { it.toInt() }\n\n\n val e = h2* 60 + m2\n val s = h1 * 60 + m1\n val l = e-s\n\n println(l-k)\n}\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nIn this problem, we use the 24-hour clock.\n\nTakahashi gets up exactly at the time H_1 : M_1 and goes to bed exactly at the time H_2 : M_2. (See Sample Inputs below for clarity.)\nHe has decided to study for K consecutive minutes while he is up.\nWhat is the length of the period in which he can start studying?\n\nConstraints\n\n0 \\le H_1, H_2 \\le 23\n\n0 \\le M_1, M_2 \\le 59\n\nThe time H_1 : M_1 comes before the time H_2 : M_2.\n\nK \\ge 1\n\nTakahashi is up for at least K minutes.\n\nAll values in input are integers (without leading zeros).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH_1 M_1 H_2 M_2 K\n\nOutput\n\nPrint the length of the period in which he can start studying, as an integer.\n\nSample Input 1\n\n10 0 15 0 30\n\nSample Output 1\n\n270\n\nTakahashi gets up at exactly ten in the morning and goes to bed at exactly three in the afternoon.\nIt takes 30 minutes to do the study, so he can start it in the period between ten o'clock and half-past two. The length of this period is 270 minutes, so we should print 270.\n\nSample Input 2\n\n10 0 12 0 120\n\nSample Output 2\n\n0\n\nTakahashi gets up at exactly ten in the morning and goes to bed at exactly noon. It takes 120 minutes to do the study, so he has to start it at exactly ten o'clock. Thus, we should print 0.", "sample_input": "10 0 15 0 30\n"}, "reference_outputs": ["270\n"], "source_document_id": "p02663", "source_text": "Score : 100 points\n\nProblem Statement\n\nIn this problem, we use the 24-hour clock.\n\nTakahashi gets up exactly at the time H_1 : M_1 and goes to bed exactly at the time H_2 : M_2. (See Sample Inputs below for clarity.)\nHe has decided to study for K consecutive minutes while he is up.\nWhat is the length of the period in which he can start studying?\n\nConstraints\n\n0 \\le H_1, H_2 \\le 23\n\n0 \\le M_1, M_2 \\le 59\n\nThe time H_1 : M_1 comes before the time H_2 : M_2.\n\nK \\ge 1\n\nTakahashi is up for at least K minutes.\n\nAll values in input are integers (without leading zeros).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH_1 M_1 H_2 M_2 K\n\nOutput\n\nPrint the length of the period in which he can start studying, as an integer.\n\nSample Input 1\n\n10 0 15 0 30\n\nSample Output 1\n\n270\n\nTakahashi gets up at exactly ten in the morning and goes to bed at exactly three in the afternoon.\nIt takes 30 minutes to do the study, so he can start it in the period between ten o'clock and half-past two. The length of this period is 270 minutes, so we should print 270.\n\nSample Input 2\n\n10 0 12 0 120\n\nSample Output 2\n\n0\n\nTakahashi gets up at exactly ten in the morning and goes to bed at exactly noon. It takes 120 minutes to do the study, so he has to start it at exactly ten o'clock. Thus, we should print 0.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 100, "memory_kb": 36260}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s691820718", "group_id": "codeNet:p02665", "input_text": "import java.io.*\nimport java.util.*\nimport java.lang.*\nimport java.lang.Math.*\n\nclass CumSum(val A: LongArray) {\n private var csum: LongArray = LongArray(A.size + 1){0L}\n init {\n for (i in 1..A.size) {\n this.csum[i] = this.csum[i-1] + A[i-1]\n }\n }\n fun sum(L: Int, R: Int): Long {\n val r = min(R, A.size)\n val l = max(L, 0)\n if (l >= r) return 0\n return this.csum[r] - this.csum[l]\n }\n}\n\nfun solve() {\n val N = rd.readInt()\n val A = rd.readLongArray()\n\n if (N==0 && A[0]==0L || N>1 && A[0]>0L) {\n println(-1)\n return\n }\n\n val Lim = Array(N+1){LINF}\n for (d in 0 .. min(N, 60)) {\n Lim[d] = (1L shl d)\n }\n \n val B = LongArray(N+1){0L}\n B[0] = if (A[0]==0L) 1L else 0L\n val cs = CumSum(A)\n for (d in 1 .. N) {\n B[d] = min(B[d-1]*2, cs.sum(d,N+1)) - A[d]\n if (B[d]<0) {\n println(-1)\n return\n }\n }\n\n for (d in 0 .. N) {\n if ((d>0 && B[d-1] == 0L && A[d] > 0L)\n || (A[d]+B[d] > Lim[d])) {\n println(-1)\n return\n }\n }\n\n val ans = B.sum() + A.sum()\n println(ans)\n}\n\n\n//val rd = debug.Reader(\"etc\", \"nomura2020\", \"c\", \"sample-4\")\nval rd = Reader()\n\n\nfun main(args: Array) {\n try {\n var exception: Throwable? = null\n val sth = Thread(null, SolveThread(), \"solveThread\", 128 * 1024 * 1024)\n sth.setUncaughtExceptionHandler { _, e -> exception = e }\n sth.start(); sth.join()\n if (exception != null) throw exception!! }\n catch (e: Exception) { throw e }\n finally { rd.close() }\n}\nconst val MOD = 1_000_000_007L; const val INF = Int.MAX_VALUE/2; const val LINF = Long.MAX_VALUE/2\nconst val EPS = 1e-9; fun DBLEQ(a: Double, b: Double): Boolean {return abs(a - b) < EPS}\ndata class IntPair(val first: Int, val second: Int)\ndata class To(val idx: Int, val cost: Long)\ntypealias ALI = ArrayList\nfun edge(V: Int): Array> { return Array(V){ArrayList()} }\nval errPrintln: (Any) -> Unit = { msg -> System.err.println(msg) }\nfun rAssert(exp: Boolean, lazyMsg: () -> String = {\"\"}) {\n if (!exp) { val msg = lazyMsg(); errPrintln(\"EAssert Error: $msg\"); throw Error(msg) }\n}\nfun tAssert(exp: Boolean, lazyMsg: () -> String = {\"\"}) {\n if (!exp) { val msg = lazyMsg(); errPrintln(\"TAssert Error: $msg\"); Thread.sleep(3000) }\n}\nclass SolveThread : Runnable {\n override fun run() { solve() }\n}\nclass Reader {\n private val br = BufferedReader(InputStreamReader(System.`in`))\n val readString: () -> String = { br.readLine() }\n val readInt: () -> Int = { br.readLine().toInt() }\n val readLong: () -> Long = { br.readLine().toLong() }\n val readIntArray: () -> IntArray = { br.readLine().split(' ').map { it.toInt() }.toIntArray() }\n val readLongArray: () -> LongArray = { br.readLine().split(' ').map { it.toLong() }.toLongArray() }\n val readListInt: () -> List = { br.readLine().split(' ').map { it.toInt() } }\n val readListLong: () -> List = { br.readLine().split(' ').map { it.toLong() } }\n val readListIntCol: (Int) -> List = { N -> (0 until N).map { readInt() } }\n val readListIntCols: (Int) -> List> = { N -> (0 until N).map { br.readLine().split(' ').map { it.toInt() } } }\n val readListLongCol: (Int) -> List = { N -> (0 until N).map { readLong() } }\n val readListLongCols: (Int) -> List> = { N -> (0 until N).map { br.readLine().split(' ').map { it.toLong() } } }\n val close: () -> Unit = { br.close() }\n protected fun finalize() { close() }\n}\n", "language": "Kotlin", "metadata": {"date": 1599706406, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02665.html", "problem_id": "p02665", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02665/input.txt", "sample_output_relpath": "derived/input_output/data/p02665/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02665/Kotlin/s691820718.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s691820718", "user_id": "u404244809"}, "prompt_components": {"gold_output": "7\n", "input_to_evaluate": "import java.io.*\nimport java.util.*\nimport java.lang.*\nimport java.lang.Math.*\n\nclass CumSum(val A: LongArray) {\n private var csum: LongArray = LongArray(A.size + 1){0L}\n init {\n for (i in 1..A.size) {\n this.csum[i] = this.csum[i-1] + A[i-1]\n }\n }\n fun sum(L: Int, R: Int): Long {\n val r = min(R, A.size)\n val l = max(L, 0)\n if (l >= r) return 0\n return this.csum[r] - this.csum[l]\n }\n}\n\nfun solve() {\n val N = rd.readInt()\n val A = rd.readLongArray()\n\n if (N==0 && A[0]==0L || N>1 && A[0]>0L) {\n println(-1)\n return\n }\n\n val Lim = Array(N+1){LINF}\n for (d in 0 .. min(N, 60)) {\n Lim[d] = (1L shl d)\n }\n \n val B = LongArray(N+1){0L}\n B[0] = if (A[0]==0L) 1L else 0L\n val cs = CumSum(A)\n for (d in 1 .. N) {\n B[d] = min(B[d-1]*2, cs.sum(d,N+1)) - A[d]\n if (B[d]<0) {\n println(-1)\n return\n }\n }\n\n for (d in 0 .. N) {\n if ((d>0 && B[d-1] == 0L && A[d] > 0L)\n || (A[d]+B[d] > Lim[d])) {\n println(-1)\n return\n }\n }\n\n val ans = B.sum() + A.sum()\n println(ans)\n}\n\n\n//val rd = debug.Reader(\"etc\", \"nomura2020\", \"c\", \"sample-4\")\nval rd = Reader()\n\n\nfun main(args: Array) {\n try {\n var exception: Throwable? = null\n val sth = Thread(null, SolveThread(), \"solveThread\", 128 * 1024 * 1024)\n sth.setUncaughtExceptionHandler { _, e -> exception = e }\n sth.start(); sth.join()\n if (exception != null) throw exception!! }\n catch (e: Exception) { throw e }\n finally { rd.close() }\n}\nconst val MOD = 1_000_000_007L; const val INF = Int.MAX_VALUE/2; const val LINF = Long.MAX_VALUE/2\nconst val EPS = 1e-9; fun DBLEQ(a: Double, b: Double): Boolean {return abs(a - b) < EPS}\ndata class IntPair(val first: Int, val second: Int)\ndata class To(val idx: Int, val cost: Long)\ntypealias ALI = ArrayList\nfun edge(V: Int): Array> { return Array(V){ArrayList()} }\nval errPrintln: (Any) -> Unit = { msg -> System.err.println(msg) }\nfun rAssert(exp: Boolean, lazyMsg: () -> String = {\"\"}) {\n if (!exp) { val msg = lazyMsg(); errPrintln(\"EAssert Error: $msg\"); throw Error(msg) }\n}\nfun tAssert(exp: Boolean, lazyMsg: () -> String = {\"\"}) {\n if (!exp) { val msg = lazyMsg(); errPrintln(\"TAssert Error: $msg\"); Thread.sleep(3000) }\n}\nclass SolveThread : Runnable {\n override fun run() { solve() }\n}\nclass Reader {\n private val br = BufferedReader(InputStreamReader(System.`in`))\n val readString: () -> String = { br.readLine() }\n val readInt: () -> Int = { br.readLine().toInt() }\n val readLong: () -> Long = { br.readLine().toLong() }\n val readIntArray: () -> IntArray = { br.readLine().split(' ').map { it.toInt() }.toIntArray() }\n val readLongArray: () -> LongArray = { br.readLine().split(' ').map { it.toLong() }.toLongArray() }\n val readListInt: () -> List = { br.readLine().split(' ').map { it.toInt() } }\n val readListLong: () -> List = { br.readLine().split(' ').map { it.toLong() } }\n val readListIntCol: (Int) -> List = { N -> (0 until N).map { readInt() } }\n val readListIntCols: (Int) -> List> = { N -> (0 until N).map { br.readLine().split(' ').map { it.toInt() } } }\n val readListLongCol: (Int) -> List = { N -> (0 until N).map { readLong() } }\n val readListLongCols: (Int) -> List> = { N -> (0 until N).map { br.readLine().split(' ').map { it.toLong() } } }\n val close: () -> Unit = { br.close() }\n protected fun finalize() { close() }\n}\n", "problem_context": "Score : 600 points\n\nProblem Statement\n\nGiven is an integer sequence of length N+1: A_0, A_1, A_2, \\ldots, A_N. Is there a binary tree of depth N such that, for each d = 0, 1, \\ldots, N, there are exactly A_d leaves at depth d? If such a tree exists, print the maximum possible number of vertices in such a tree; otherwise, print -1.\n\nNotes\n\nA binary tree is a rooted tree such that each vertex has at most two direct children.\n\nA leaf in a binary tree is a vertex with zero children.\n\nThe depth of a vertex v in a binary tree is the distance from the tree's root to v. (The root has the depth of 0.)\n\nThe depth of a binary tree is the maximum depth of a vertex in the tree.\n\nConstraints\n\n0 \\leq N \\leq 10^5\n\n0 \\leq A_i \\leq 10^{8} (0 \\leq i \\leq N)\n\nA_N \\geq 1\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 \\cdots A_N\n\nOutput\n\nPrint the answer as an integer.\n\nSample Input 1\n\n3\n0 1 1 2\n\nSample Output 1\n\n7\n\nBelow is the tree with the maximum possible number of vertices. It has seven vertices, so we should print 7.\n\nSample Input 2\n\n4\n0 0 1 0 2\n\nSample Output 2\n\n10\n\nSample Input 3\n\n2\n0 3 1\n\nSample Output 3\n\n-1\n\nSample Input 4\n\n1\n1 1\n\nSample Output 4\n\n-1\n\nSample Input 5\n\n10\n0 0 1 1 2 3 5 8 13 21 34\n\nSample Output 5\n\n264", "sample_input": "3\n0 1 1 2\n"}, "reference_outputs": ["7\n"], "source_document_id": "p02665", "source_text": "Score : 600 points\n\nProblem Statement\n\nGiven is an integer sequence of length N+1: A_0, A_1, A_2, \\ldots, A_N. Is there a binary tree of depth N such that, for each d = 0, 1, \\ldots, N, there are exactly A_d leaves at depth d? If such a tree exists, print the maximum possible number of vertices in such a tree; otherwise, print -1.\n\nNotes\n\nA binary tree is a rooted tree such that each vertex has at most two direct children.\n\nA leaf in a binary tree is a vertex with zero children.\n\nThe depth of a vertex v in a binary tree is the distance from the tree's root to v. (The root has the depth of 0.)\n\nThe depth of a binary tree is the maximum depth of a vertex in the tree.\n\nConstraints\n\n0 \\leq N \\leq 10^5\n\n0 \\leq A_i \\leq 10^{8} (0 \\leq i \\leq N)\n\nA_N \\geq 1\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 \\cdots A_N\n\nOutput\n\nPrint the answer as an integer.\n\nSample Input 1\n\n3\n0 1 1 2\n\nSample Output 1\n\n7\n\nBelow is the tree with the maximum possible number of vertices. It has seven vertices, so we should print 7.\n\nSample Input 2\n\n4\n0 0 1 0 2\n\nSample Output 2\n\n10\n\nSample Input 3\n\n2\n0 3 1\n\nSample Output 3\n\n-1\n\nSample Input 4\n\n1\n1 1\n\nSample Output 4\n\n-1\n\nSample Input 5\n\n10\n0 0 1 1 2 3 5 8 13 21 34\n\nSample Output 5\n\n264", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 3629, "cpu_time_ms": 321, "memory_kb": 58208}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s632323539", "group_id": "codeNet:p02665", "input_text": "fun main() {\n val n = readLine()!!.toInt()\n val a = readLine()!!.split(' ').map { it.toInt() }.toIntArray()\n var min = LongArray(n + 1)\n val max = LongArray(n + 1)\n min[n] = a.last().toLong()\n max[n] = a.last().toLong()\n\n fun limit(level: Int, vertices: Long): Long = if (level > 63) vertices else kotlin.math.min(1L shl level, vertices)\n\n for (i in n - 1 downTo 0) {\n val mn = (min[i + 1] + 1) / 2 + a[i]\n val mx = limit(i,max[i + 1] + a[i])\n\n if (mn > mx) {\n println(-1)\n return\n }\n\n min[i] = mn\n max[i] = mx\n }\n\n for (i in 1..n) {\n if ((max[i] + 1) / 2 > max[i - 1] - a[i - 1]) {\n max[i] = kotlin.math.min(max[i], (max[i - 1] - a[i - 1]) * 2)\n }\n if (max[i] < min[i]) {\n println(-1)\n return\n }\n }\n check(max.find { it < 0 } == null)\n\n if (max[0] != 1L) {\n println(-1)\n return\n }\n\n println(max.sum())\n}", "language": "Kotlin", "metadata": {"date": 1590889435, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02665.html", "problem_id": "p02665", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02665/input.txt", "sample_output_relpath": "derived/input_output/data/p02665/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02665/Kotlin/s632323539.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s632323539", "user_id": "u496795059"}, "prompt_components": {"gold_output": "7\n", "input_to_evaluate": "fun main() {\n val n = readLine()!!.toInt()\n val a = readLine()!!.split(' ').map { it.toInt() }.toIntArray()\n var min = LongArray(n + 1)\n val max = LongArray(n + 1)\n min[n] = a.last().toLong()\n max[n] = a.last().toLong()\n\n fun limit(level: Int, vertices: Long): Long = if (level > 63) vertices else kotlin.math.min(1L shl level, vertices)\n\n for (i in n - 1 downTo 0) {\n val mn = (min[i + 1] + 1) / 2 + a[i]\n val mx = limit(i,max[i + 1] + a[i])\n\n if (mn > mx) {\n println(-1)\n return\n }\n\n min[i] = mn\n max[i] = mx\n }\n\n for (i in 1..n) {\n if ((max[i] + 1) / 2 > max[i - 1] - a[i - 1]) {\n max[i] = kotlin.math.min(max[i], (max[i - 1] - a[i - 1]) * 2)\n }\n if (max[i] < min[i]) {\n println(-1)\n return\n }\n }\n check(max.find { it < 0 } == null)\n\n if (max[0] != 1L) {\n println(-1)\n return\n }\n\n println(max.sum())\n}", "problem_context": "Score : 600 points\n\nProblem Statement\n\nGiven is an integer sequence of length N+1: A_0, A_1, A_2, \\ldots, A_N. Is there a binary tree of depth N such that, for each d = 0, 1, \\ldots, N, there are exactly A_d leaves at depth d? If such a tree exists, print the maximum possible number of vertices in such a tree; otherwise, print -1.\n\nNotes\n\nA binary tree is a rooted tree such that each vertex has at most two direct children.\n\nA leaf in a binary tree is a vertex with zero children.\n\nThe depth of a vertex v in a binary tree is the distance from the tree's root to v. (The root has the depth of 0.)\n\nThe depth of a binary tree is the maximum depth of a vertex in the tree.\n\nConstraints\n\n0 \\leq N \\leq 10^5\n\n0 \\leq A_i \\leq 10^{8} (0 \\leq i \\leq N)\n\nA_N \\geq 1\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 \\cdots A_N\n\nOutput\n\nPrint the answer as an integer.\n\nSample Input 1\n\n3\n0 1 1 2\n\nSample Output 1\n\n7\n\nBelow is the tree with the maximum possible number of vertices. It has seven vertices, so we should print 7.\n\nSample Input 2\n\n4\n0 0 1 0 2\n\nSample Output 2\n\n10\n\nSample Input 3\n\n2\n0 3 1\n\nSample Output 3\n\n-1\n\nSample Input 4\n\n1\n1 1\n\nSample Output 4\n\n-1\n\nSample Input 5\n\n10\n0 0 1 1 2 3 5 8 13 21 34\n\nSample Output 5\n\n264", "sample_input": "3\n0 1 1 2\n"}, "reference_outputs": ["7\n"], "source_document_id": "p02665", "source_text": "Score : 600 points\n\nProblem Statement\n\nGiven is an integer sequence of length N+1: A_0, A_1, A_2, \\ldots, A_N. Is there a binary tree of depth N such that, for each d = 0, 1, \\ldots, N, there are exactly A_d leaves at depth d? If such a tree exists, print the maximum possible number of vertices in such a tree; otherwise, print -1.\n\nNotes\n\nA binary tree is a rooted tree such that each vertex has at most two direct children.\n\nA leaf in a binary tree is a vertex with zero children.\n\nThe depth of a vertex v in a binary tree is the distance from the tree's root to v. (The root has the depth of 0.)\n\nThe depth of a binary tree is the maximum depth of a vertex in the tree.\n\nConstraints\n\n0 \\leq N \\leq 10^5\n\n0 \\leq A_i \\leq 10^{8} (0 \\leq i \\leq N)\n\nA_N \\geq 1\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 \\cdots A_N\n\nOutput\n\nPrint the answer as an integer.\n\nSample Input 1\n\n3\n0 1 1 2\n\nSample Output 1\n\n7\n\nBelow is the tree with the maximum possible number of vertices. It has seven vertices, so we should print 7.\n\nSample Input 2\n\n4\n0 0 1 0 2\n\nSample Output 2\n\n10\n\nSample Input 3\n\n2\n0 3 1\n\nSample Output 3\n\n-1\n\nSample Input 4\n\n1\n1 1\n\nSample Output 4\n\n-1\n\nSample Input 5\n\n10\n0 0 1 1 2 3 5 8 13 21 34\n\nSample Output 5\n\n264", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 880, "cpu_time_ms": 338, "memory_kb": 57640}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s308365227", "group_id": "codeNet:p02669", "input_text": "import kotlin.math.*\n\nfun main(){\n val t = readLine()!!.toInt()\n repeat(t){\n val (n, a, b, c, d) = readLine()!!.split(\" \").map(String::toLong)\n val memo = mutableMapOf()\n val array = arrayOf(Pair(2, a), Pair(3, b), Pair(5, c))\n\n fun search(now: Long): Long{\n if(now == 0L){\n return 0\n }else if(now == 1L){\n return d\n }else if(memo.containsKey(now)){\n return memo[now]!!\n }else{\n var res = Long.MAX_VALUE / 10\n array.forEach {\n val l = (n / it.first) * it.first\n val r = ((n + it.first - 1) / n) * it.first\n res = min(res, d * abs(l - n) + it.second + search(l/it.first))\n res = min(res, d * abs(r - n) + it.second + search(r/it.first))\n }\n memo[now] = res\n return res\n }\n }\n search(n)\n println(memo[n]!!)\n }\n}", "language": "Kotlin", "metadata": {"date": 1590294537, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02669.html", "problem_id": "p02669", "resource_group": "medium_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/Kotlin/s308365227.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s308365227", "user_id": "u531770859"}, "prompt_components": {"gold_output": "20\n19\n26\n3821859835\n23441258666\n", "input_to_evaluate": "import kotlin.math.*\n\nfun main(){\n val t = readLine()!!.toInt()\n repeat(t){\n val (n, a, b, c, d) = readLine()!!.split(\" \").map(String::toLong)\n val memo = mutableMapOf()\n val array = arrayOf(Pair(2, a), Pair(3, b), Pair(5, c))\n\n fun search(now: Long): Long{\n if(now == 0L){\n return 0\n }else if(now == 1L){\n return d\n }else if(memo.containsKey(now)){\n return memo[now]!!\n }else{\n var res = Long.MAX_VALUE / 10\n array.forEach {\n val l = (n / it.first) * it.first\n val r = ((n + it.first - 1) / n) * it.first\n res = min(res, d * abs(l - n) + it.second + search(l/it.first))\n res = min(res, d * abs(r - n) + it.second + search(r/it.first))\n }\n memo[now] = res\n return res\n }\n }\n search(n)\n println(memo[n]!!)\n }\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1030, "cpu_time_ms": 154, "memory_kb": 40148}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s225146220", "group_id": "codeNet:p02670", "input_text": "import java.util.*\n\nprivate class B {\n fun solve() {\n val n = nextInt();\n val p = Array(n * n) { nextInt() - 1 }\n val hall = Array(n) { Array(n) { 1 } }\n val hatred = Array(n) { x -> Array(n) {y -> x.coerceAtMost(y).coerceAtMost(n - x - 1).coerceAtMost(n - y - 1)} }\n var ans = 0\n for (current in p) {\n val q = LinkedList()\n val x = current % n\n val y = current / n\n q.add(Point(x, y))\n hall[x][y] = 0\n ans += hatred[x][y]\n while (!q.isEmpty()) {\n val current = q.pollFirst()\n val nextHatred = hatred[current.x][current.y] + hall[current.x][current.y]\n for (i in 0..3) {\n val next = current.shift(i)\n if (next.isGood(n) && nextHatred < hatred[next.x][next.y]) {\n hatred[next.x][next.y] = nextHatred\n q.addLast(next)\n }\n }\n }\n }\n println(ans)\n }\n\n class Point(val x: Int, val y: Int) {\n val dx = intArrayOf(-1, 1, 0, 0)\n val dy = intArrayOf(0, 0, -1, 1)\n\n fun shift(dir: Int): Point {\n return Point(x + dx[dir], y + dy[dir])\n }\n\n fun isGood(n: Int): Boolean {\n return x >= 0 && x < n && y >= 0 && y < n\n }\n }\n\n\n var tokenBuffer = listOf()\n var bufferPosition = 0\n\n private fun checkBuffer() {\n if (bufferPosition == tokenBuffer.size) {\n tokenBuffer = nextLine().split(\" \")\n bufferPosition = 0\n }\n }\n\n fun nextLine() = readLine()!!\n fun nextInt(): Int {\n checkBuffer()\n return tokenBuffer[bufferPosition++].toInt()\n }\n\n fun nextLong(): Long {\n checkBuffer()\n return tokenBuffer[bufferPosition++].toLong()\n }\n\n fun nextDouble(): Double {\n checkBuffer()\n return tokenBuffer[bufferPosition++].toDouble()\n }\n\n fun nextToken(): String {\n checkBuffer()\n return tokenBuffer[bufferPosition++]\n }\n}\n\nfun main() {\n val reader = B().solve()\n\n}\n", "language": "Kotlin", "metadata": {"date": 1590368275, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02670.html", "problem_id": "p02670", "resource_group": "medium_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/Kotlin/s225146220.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s225146220", "user_id": "u331037015"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "import java.util.*\n\nprivate class B {\n fun solve() {\n val n = nextInt();\n val p = Array(n * n) { nextInt() - 1 }\n val hall = Array(n) { Array(n) { 1 } }\n val hatred = Array(n) { x -> Array(n) {y -> x.coerceAtMost(y).coerceAtMost(n - x - 1).coerceAtMost(n - y - 1)} }\n var ans = 0\n for (current in p) {\n val q = LinkedList()\n val x = current % n\n val y = current / n\n q.add(Point(x, y))\n hall[x][y] = 0\n ans += hatred[x][y]\n while (!q.isEmpty()) {\n val current = q.pollFirst()\n val nextHatred = hatred[current.x][current.y] + hall[current.x][current.y]\n for (i in 0..3) {\n val next = current.shift(i)\n if (next.isGood(n) && nextHatred < hatred[next.x][next.y]) {\n hatred[next.x][next.y] = nextHatred\n q.addLast(next)\n }\n }\n }\n }\n println(ans)\n }\n\n class Point(val x: Int, val y: Int) {\n val dx = intArrayOf(-1, 1, 0, 0)\n val dy = intArrayOf(0, 0, -1, 1)\n\n fun shift(dir: Int): Point {\n return Point(x + dx[dir], y + dy[dir])\n }\n\n fun isGood(n: Int): Boolean {\n return x >= 0 && x < n && y >= 0 && y < n\n }\n }\n\n\n var tokenBuffer = listOf()\n var bufferPosition = 0\n\n private fun checkBuffer() {\n if (bufferPosition == tokenBuffer.size) {\n tokenBuffer = nextLine().split(\" \")\n bufferPosition = 0\n }\n }\n\n fun nextLine() = readLine()!!\n fun nextInt(): Int {\n checkBuffer()\n return tokenBuffer[bufferPosition++].toInt()\n }\n\n fun nextLong(): Long {\n checkBuffer()\n return tokenBuffer[bufferPosition++].toLong()\n }\n\n fun nextDouble(): Double {\n checkBuffer()\n return tokenBuffer[bufferPosition++].toDouble()\n }\n\n fun nextToken(): String {\n checkBuffer()\n return tokenBuffer[bufferPosition++]\n }\n}\n\nfun main() {\n val reader = B().solve()\n\n}\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2163, "cpu_time_ms": 2208, "memory_kb": 73652}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s600264217", "group_id": "codeNet:p02675", "input_text": "\nfun main(args: Array) {\n val number = readLine()!!\n\n val StrToNum = hashMapOf(\"hon\" to \"24579\", \"pon\" to \"0168\", \"bon\" to \"3\")\n\n fun matchDigit(num: Char, strMap: HashMap): String = strMap.filter { it.value.contains(num) }.keys.first()\n\n val matchedKey = matchDigit(number.last(), StrToNum)\n println(matchedKey)\n}\n", "language": "Kotlin", "metadata": {"date": 1600106547, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02675.html", "problem_id": "p02675", "resource_group": "medium_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/Kotlin/s600264217.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s600264217", "user_id": "u496449946"}, "prompt_components": {"gold_output": "pon\n", "input_to_evaluate": "\nfun main(args: Array) {\n val number = readLine()!!\n\n val StrToNum = hashMapOf(\"hon\" to \"24579\", \"pon\" to \"0168\", \"bon\" to \"3\")\n\n fun matchDigit(num: Char, strMap: HashMap): String = strMap.filter { it.value.contains(num) }.keys.first()\n\n val matchedKey = matchDigit(number.last(), StrToNum)\n println(matchedKey)\n}\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 136, "memory_kb": 36312}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s412693662", "group_id": "codeNet:p02675", "input_text": "fun main(args: Array) {\n val input1 = readLine()!!.toInt()\n val result = when (input1 % 10) {\n 2, 4, 5, 7, 9 -> \"hon\"\n 0, 1, 6, 8 -> \"pon\"\n 3 -> \"bon\"\n else -> \"\"\n }\n println(result)\n}\n", "language": "Kotlin", "metadata": {"date": 1589768238, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02675.html", "problem_id": "p02675", "resource_group": "medium_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/Kotlin/s412693662.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s412693662", "user_id": "u388084726"}, "prompt_components": {"gold_output": "pon\n", "input_to_evaluate": "fun main(args: Array) {\n val input1 = readLine()!!.toInt()\n val result = when (input1 % 10) {\n 2, 4, 5, 7, 9 -> \"hon\"\n 0, 1, 6, 8 -> \"pon\"\n 3 -> \"bon\"\n else -> \"\"\n }\n println(result)\n}\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 209, "cpu_time_ms": 82, "memory_kb": 34448}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s492434965", "group_id": "codeNet:p02675", "input_text": "fun main(args: Array) {\n val n = readLine()!!.toInt()\n if(n%10 == 3) {\n println(\"bon\")\n }else if(n%10==0 || n%10==1 || n%10==6 || n%10==8){\n println(\"pon\")\n }else {\n println(\"hon\")\n }\n}", "language": "Kotlin", "metadata": {"date": 1589765092, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02675.html", "problem_id": "p02675", "resource_group": "medium_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/Kotlin/s492434965.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s492434965", "user_id": "u362573766"}, "prompt_components": {"gold_output": "pon\n", "input_to_evaluate": "fun main(args: Array) {\n val n = readLine()!!.toInt()\n if(n%10 == 3) {\n println(\"bon\")\n }else if(n%10==0 || n%10==1 || n%10==6 || n%10==8){\n println(\"pon\")\n }else {\n println(\"hon\")\n }\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 83, "memory_kb": 34472}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s315790320", "group_id": "codeNet:p02676", "input_text": "fun main(args: Array) {\n val length = readLine()!!.toInt()\n val input = readLine()!!\n println(\n if (input.length > length) {\n \"${input.substring(0 until length)}...\"\n } else {\n input\n }\n )\n}", "language": "Kotlin", "metadata": {"date": 1589764901, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02676.html", "problem_id": "p02676", "resource_group": "medium_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/Kotlin/s315790320.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s315790320", "user_id": "u784615990"}, "prompt_components": {"gold_output": "nikoand...\n", "input_to_evaluate": "fun main(args: Array) {\n val length = readLine()!!.toInt()\n val input = readLine()!!\n println(\n if (input.length > length) {\n \"${input.substring(0 until length)}...\"\n } else {\n input\n }\n )\n}", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 253, "cpu_time_ms": 97, "memory_kb": 35884}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s998757559", "group_id": "codeNet:p02677", "input_text": "fun main(args: Array) {\n val (a, b, h, m) = readLine()!!.split(' ').map { it.toDouble() }\n\n // 短針 1分0.5度\n val sd = (h*30 + m*0.5) * Math.PI/180\n val sx = Math.sin(sd) * a\n val sy = Math.cos(sd) * a\n\n // 長針 1分6度\n val ld = m*6 * Math.PI/180\n val lx = Math.sin(ld) * b\n val ly = Math.cos(ld) * b\n\n\n println(\"%.20f\".format(Math.sqrt(Math.pow(sx-lx,2.0) + Math.pow(sy-ly,2.0))))\n\n}\n", "language": "Kotlin", "metadata": {"date": 1589764708, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02677.html", "problem_id": "p02677", "resource_group": "medium_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/Kotlin/s998757559.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s998757559", "user_id": "u288435405"}, "prompt_components": {"gold_output": "5.00000000000000000000\n", "input_to_evaluate": "fun main(args: Array) {\n val (a, b, h, m) = readLine()!!.split(' ').map { it.toDouble() }\n\n // 短針 1分0.5度\n val sd = (h*30 + m*0.5) * Math.PI/180\n val sx = Math.sin(sd) * a\n val sy = Math.cos(sd) * a\n\n // 長針 1分6度\n val ld = m*6 * Math.PI/180\n val lx = Math.sin(ld) * b\n val ly = Math.cos(ld) * b\n\n\n println(\"%.20f\".format(Math.sqrt(Math.pow(sx-lx,2.0) + Math.pow(sy-ly,2.0))))\n\n}\n", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 112, "memory_kb": 37720}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s355072327", "group_id": "codeNet:p02678", "input_text": "import java.util.*\n\nfun main(args: Array) {\n val (n, m) = readListInt()\n var graph = Array(100005) { mutableListOf() }\n for (i in 0 until m) {\n val (a, b) = readListInt()\n graph[a-1].add(b-1)\n graph[b-1].add(a-1)\n }\n\n var queue = ArrayDeque()\n var dist = List(n){Int.MAX_VALUE }.toMutableList()\n var pre = List(n){ -1 }.toMutableList()\n dist[0] = 0\n queue.push(0)\n while (!queue.isEmpty()) {\n var v = queue.first()\n queue.pop()\n for (u in graph[v]) {\n if (dist[u] != Int.MAX_VALUE) continue\n dist[u] = dist[v] + 1\n pre[u] = v\n queue.push(u)\n\n }\n }\n println(\"Yes\")\n for (i in 1 until n) {\n var ans = pre[i]\n ans++\n println(ans)\n }\n}\n\nprivate fun read() = readLine()!!\n\nprivate fun readInt() = read().toInt()\n\nprivate fun readLong() = read().toLong()\n\nprivate fun readDouble() = read().toDouble()\n\nprivate fun readListString() = read().split(\" \")\n\nprivate fun readListInt() = readListString().map { it.toInt() }\n\nprivate fun readListLong() = readListString().map { it.toLong() }\n\nprivate fun readListDouble() = readListString().map { it.toDouble() }\n\nprivate fun readMatrixString(n: Int): List> {\n val matrix = mutableListOf>()\n for (i in 0 until n) {\n val list = readListString()\n matrix.add(list)\n }\n return matrix\n}\n\nprivate fun readMatrixInt(n: Int): List> {\n val matrix = mutableListOf>()\n for (i in 0 until n) {\n val list = readListInt()\n matrix.add(list)\n }\n return matrix\n}\n\nprivate fun readMatrixDouble(n: Int): List> {\n val matrix = mutableListOf>()\n for (i in 0 until n) {\n val list = readListDouble()\n matrix.add(list)\n }\n return matrix\n}\n\nprivate fun readMatrixLong(n: Int): List> {\n val matrix = mutableListOf>()\n for (i in 0 until n) {\n val list = readListLong()\n matrix.add(list)\n }\n return matrix\n}\n\n", "language": "Kotlin", "metadata": {"date": 1592893060, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02678.html", "problem_id": "p02678", "resource_group": "medium_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/Kotlin/s355072327.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s355072327", "user_id": "u698000453"}, "prompt_components": {"gold_output": "Yes\n1\n2\n2\n", "input_to_evaluate": "import java.util.*\n\nfun main(args: Array) {\n val (n, m) = readListInt()\n var graph = Array(100005) { mutableListOf() }\n for (i in 0 until m) {\n val (a, b) = readListInt()\n graph[a-1].add(b-1)\n graph[b-1].add(a-1)\n }\n\n var queue = ArrayDeque()\n var dist = List(n){Int.MAX_VALUE }.toMutableList()\n var pre = List(n){ -1 }.toMutableList()\n dist[0] = 0\n queue.push(0)\n while (!queue.isEmpty()) {\n var v = queue.first()\n queue.pop()\n for (u in graph[v]) {\n if (dist[u] != Int.MAX_VALUE) continue\n dist[u] = dist[v] + 1\n pre[u] = v\n queue.push(u)\n\n }\n }\n println(\"Yes\")\n for (i in 1 until n) {\n var ans = pre[i]\n ans++\n println(ans)\n }\n}\n\nprivate fun read() = readLine()!!\n\nprivate fun readInt() = read().toInt()\n\nprivate fun readLong() = read().toLong()\n\nprivate fun readDouble() = read().toDouble()\n\nprivate fun readListString() = read().split(\" \")\n\nprivate fun readListInt() = readListString().map { it.toInt() }\n\nprivate fun readListLong() = readListString().map { it.toLong() }\n\nprivate fun readListDouble() = readListString().map { it.toDouble() }\n\nprivate fun readMatrixString(n: Int): List> {\n val matrix = mutableListOf>()\n for (i in 0 until n) {\n val list = readListString()\n matrix.add(list)\n }\n return matrix\n}\n\nprivate fun readMatrixInt(n: Int): List> {\n val matrix = mutableListOf>()\n for (i in 0 until n) {\n val list = readListInt()\n matrix.add(list)\n }\n return matrix\n}\n\nprivate fun readMatrixDouble(n: Int): List> {\n val matrix = mutableListOf>()\n for (i in 0 until n) {\n val list = readListDouble()\n matrix.add(list)\n }\n return matrix\n}\n\nprivate fun readMatrixLong(n: Int): List> {\n val matrix = mutableListOf>()\n for (i in 0 until n) {\n val list = readListLong()\n matrix.add(list)\n }\n return matrix\n}\n\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2097, "cpu_time_ms": 1256, "memory_kb": 81204}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s241875273", "group_id": "codeNet:p02678", "input_text": "fun main() {\n val (n, m) = readLine()!!.split(\" \").map(String::toInt)\n\n val map = Array(n) { mutableListOf() }\n\n repeat(m) {\n val (a, b) = readLine()!!.split(\" \").map { it.toInt() - 1 }\n map[a].add(b)\n map[b].add(a)\n }\n\n val dist = Array(n) { -1 }\n dist[0] = 0\n\n val que = mutableListOf()\n que.push(0)\n\n while (que.isNotEmpty()) {\n val v = que.pop()\n\n map[v].forEach {\n if (dist[it] != -1) return@forEach\n\n dist[it] = v + 1\n que.push(it)\n }\n }\n\n println(\"Yes\")\n dist.takeLast(n - 1).forEach {\n println(it)\n }\n}\n\nprivate fun MutableList.push(e: T) = add(e)\nprivate fun MutableList.pop() = removeAt(0)", "language": "Kotlin", "metadata": {"date": 1589801607, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02678.html", "problem_id": "p02678", "resource_group": "medium_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/Kotlin/s241875273.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s241875273", "user_id": "u897579945"}, "prompt_components": {"gold_output": "Yes\n1\n2\n2\n", "input_to_evaluate": "fun main() {\n val (n, m) = readLine()!!.split(\" \").map(String::toInt)\n\n val map = Array(n) { mutableListOf() }\n\n repeat(m) {\n val (a, b) = readLine()!!.split(\" \").map { it.toInt() - 1 }\n map[a].add(b)\n map[b].add(a)\n }\n\n val dist = Array(n) { -1 }\n dist[0] = 0\n\n val que = mutableListOf()\n que.push(0)\n\n while (que.isNotEmpty()) {\n val v = que.pop()\n\n map[v].forEach {\n if (dist[it] != -1) return@forEach\n\n dist[it] = v + 1\n que.push(it)\n }\n }\n\n println(\"Yes\")\n dist.takeLast(n - 1).forEach {\n println(it)\n }\n}\n\nprivate fun MutableList.push(e: T) = add(e)\nprivate fun MutableList.pop() = removeAt(0)", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 744, "cpu_time_ms": 1636, "memory_kb": 86604}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s919930546", "group_id": "codeNet:p02678", "input_text": "fun main() = ABC168D.main()\n\nobject ABC168D {\n fun log(message: Any?) {\n println(message)// TODO: ←消す\n }\n\n fun main() {\n val (N, M) = readInts()\n val edges = (1..M).flatMap {\n val (A, B) = readInts()\n listOf(A - 1 to B - 1, B - 1 to A - 1)\n }.groupBy { it.first }.mapValues { it.value.map { it.second }.toSet() }\n\n val dests = (1..N).map { null as Int? }.toMutableList()\n\n val stack = mutableListOf(0)\n while (stack.isNotEmpty()) {\n val dest = stack.first()\n stack.removeAt(0)\n edges[dest]?.let { tos ->\n tos.forEach { to ->\n if (dests[to] == null) {\n dests[to] = dest\n stack.add(to)\n }\n }\n }\n }\n\n val valid = dests.all { it != null }\n println(valid.yesOrNo())\n if(valid){\n val ans = dests.drop(1).map { it?.plus(1) }\n println(ans.joinToString(\"\\n\"))\n }\n }\n\n\n /*####################################################################################*/\n\n fun readString() = readLine()!!\n fun readStrings() = readLine()!!.split(\" \")\n fun readInt() = readLine()!!.toInt()\n fun readInts() = readLine()!!.split(\" \").map { it.toInt() }\n fun readLong() = readLine()!!.toLong()\n fun readLongs() = readLine()!!.split(\" \").map { it.toLong() }\n fun readMatrixRows(height: Int) = (1..height).map { readLine()!!.toList() }\n\n fun Boolean.yesOrNo() = if (this) \"Yes\" else \"No\"\n fun Double.toNaturalExpr() = println(\"%f\".format(this))\n}", "language": "Kotlin", "metadata": {"date": 1589767232, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02678.html", "problem_id": "p02678", "resource_group": "medium_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/Kotlin/s919930546.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s919930546", "user_id": "u981616728"}, "prompt_components": {"gold_output": "Yes\n1\n2\n2\n", "input_to_evaluate": "fun main() = ABC168D.main()\n\nobject ABC168D {\n fun log(message: Any?) {\n println(message)// TODO: ←消す\n }\n\n fun main() {\n val (N, M) = readInts()\n val edges = (1..M).flatMap {\n val (A, B) = readInts()\n listOf(A - 1 to B - 1, B - 1 to A - 1)\n }.groupBy { it.first }.mapValues { it.value.map { it.second }.toSet() }\n\n val dests = (1..N).map { null as Int? }.toMutableList()\n\n val stack = mutableListOf(0)\n while (stack.isNotEmpty()) {\n val dest = stack.first()\n stack.removeAt(0)\n edges[dest]?.let { tos ->\n tos.forEach { to ->\n if (dests[to] == null) {\n dests[to] = dest\n stack.add(to)\n }\n }\n }\n }\n\n val valid = dests.all { it != null }\n println(valid.yesOrNo())\n if(valid){\n val ans = dests.drop(1).map { it?.plus(1) }\n println(ans.joinToString(\"\\n\"))\n }\n }\n\n\n /*####################################################################################*/\n\n fun readString() = readLine()!!\n fun readStrings() = readLine()!!.split(\" \")\n fun readInt() = readLine()!!.toInt()\n fun readInts() = readLine()!!.split(\" \").map { it.toInt() }\n fun readLong() = readLine()!!.toLong()\n fun readLongs() = readLine()!!.split(\" \").map { it.toLong() }\n fun readMatrixRows(height: Int) = (1..height).map { readLine()!!.toList() }\n\n fun Boolean.yesOrNo() = if (this) \"Yes\" else \"No\"\n fun Double.toNaturalExpr() = println(\"%f\".format(this))\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1834, "memory_kb": 155180}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s593660779", "group_id": "codeNet:p02679", "input_text": "import kotlin.math.abs\n\nval MOD = 1000000007\n\nfun main() {\n val n = readLine()!!.toInt()\n\n val group = mutableMapOf, Long>()\n var worstIwashiCount = 0L\n\n repeat(n) {\n var (a, b) = readLine()!!.split(\" \").map { it.toLong() }\n\n if (a == 0L && b == 0L) {\n worstIwashiCount++\n } else if (a == 0L) {\n increment(0L to -1L, group)\n } else if (b == 0L) {\n increment(1L to 0L, group)\n } else {\n val gcd = gcd(a, b)\n a /= gcd\n b /= gcd\n if (a < 0) {\n a *= -1\n b *= -1\n }\n increment(a to b, group)\n }\n }\n var ans = 1L\n\n while (group.isNotEmpty()) {\n val (k, count) = group.entries.first()\n val (a, b) = k\n group.remove(k)\n\n val pairCount = if (b < 0) group.remove(-b to a) ?: 0 else group.remove(b to -a) ?: 0\n\n ans *= pow2(count) + pow2(pairCount) - 1\n ans %= MOD\n }\n println((ans + worstIwashiCount - 1L) % MOD)\n}\n\nfun pow2(n: Long): Long {\n tailrec fun go(n: Long, acc: Long): Long = if (n == 0L) acc else go(n - 1, acc * 2 % MOD)\n return go(n, 1)\n}\n\nfun increment(key: K, m: MutableMap) {\n val n = m.getOrDefault(key, 0)\n m[key] = n + 1\n}\n\nfun gcd(a: Long, b: Long): Long {\n tailrec fun go(c: Long, d: Long): Long = if (d == 0L) c else go(d, c % d)\n return go(abs(a), abs(b))\n}\n", "language": "Kotlin", "metadata": {"date": 1591478009, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02679.html", "problem_id": "p02679", "resource_group": "medium_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/Kotlin/s593660779.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s593660779", "user_id": "u153253722"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "import kotlin.math.abs\n\nval MOD = 1000000007\n\nfun main() {\n val n = readLine()!!.toInt()\n\n val group = mutableMapOf, Long>()\n var worstIwashiCount = 0L\n\n repeat(n) {\n var (a, b) = readLine()!!.split(\" \").map { it.toLong() }\n\n if (a == 0L && b == 0L) {\n worstIwashiCount++\n } else if (a == 0L) {\n increment(0L to -1L, group)\n } else if (b == 0L) {\n increment(1L to 0L, group)\n } else {\n val gcd = gcd(a, b)\n a /= gcd\n b /= gcd\n if (a < 0) {\n a *= -1\n b *= -1\n }\n increment(a to b, group)\n }\n }\n var ans = 1L\n\n while (group.isNotEmpty()) {\n val (k, count) = group.entries.first()\n val (a, b) = k\n group.remove(k)\n\n val pairCount = if (b < 0) group.remove(-b to a) ?: 0 else group.remove(b to -a) ?: 0\n\n ans *= pow2(count) + pow2(pairCount) - 1\n ans %= MOD\n }\n println((ans + worstIwashiCount - 1L) % MOD)\n}\n\nfun pow2(n: Long): Long {\n tailrec fun go(n: Long, acc: Long): Long = if (n == 0L) acc else go(n - 1, acc * 2 % MOD)\n return go(n, 1)\n}\n\nfun increment(key: K, m: MutableMap) {\n val n = m.getOrDefault(key, 0)\n m[key] = n + 1\n}\n\nfun gcd(a: Long, b: Long): Long {\n tailrec fun go(c: Long, d: Long): Long = if (d == 0L) c else go(d, c % d)\n return go(abs(a), abs(b))\n}\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1459, "cpu_time_ms": 1215, "memory_kb": 86808}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s103856753", "group_id": "codeNet:p02681", "input_text": "import java.util.*\n\nfun main(args: Array) {\n val s = readLine()!!\n val t = readLine()!!\n println(if (t.dropLast(1) == s) \"Yes\" else \"No\")\n}\n", "language": "Kotlin", "metadata": {"date": 1589180370, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02681.html", "problem_id": "p02681", "resource_group": "medium_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/Kotlin/s103856753.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s103856753", "user_id": "u051841332"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "import java.util.*\n\nfun main(args: Array) {\n val s = readLine()!!\n val t = readLine()!!\n println(if (t.dropLast(1) == s) \"Yes\" else \"No\")\n}\n", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 100, "memory_kb": 35944}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s970095895", "group_id": "codeNet:p02681", "input_text": "fun main() {\n val s = readLine()!!\n val t = readLine()!!\n if (s == t.substring(0, (t.length - 1))) {\n println(\"Yes\")\n } else {\n println(\"No\")\n }\n}\n", "language": "Kotlin", "metadata": {"date": 1589158939, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02681.html", "problem_id": "p02681", "resource_group": "medium_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/Kotlin/s970095895.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s970095895", "user_id": "u996672406"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "fun main() {\n val s = readLine()!!\n val t = readLine()!!\n if (s == t.substring(0, (t.length - 1))) {\n println(\"Yes\")\n } else {\n println(\"No\")\n }\n}\n", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 176, "cpu_time_ms": 90, "memory_kb": 34576}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s057141194", "group_id": "codeNet:p02681", "input_text": "fun main(args: Array) {\n val s = readLine()!!\n val t = readLine()!!\n\n if(t.replace(s,\"\").length == 1) println(\"Yes\")\n else println(\"No\")\n}\n", "language": "Kotlin", "metadata": {"date": 1589158902, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02681.html", "problem_id": "p02681", "resource_group": "medium_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/Kotlin/s057141194.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s057141194", "user_id": "u288435405"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "fun main(args: Array) {\n val s = readLine()!!\n val t = readLine()!!\n\n if(t.replace(s,\"\").length == 1) println(\"Yes\")\n else println(\"No\")\n}\n", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 120, "memory_kb": 39836}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s744584495", "group_id": "codeNet:p02682", "input_text": "fun main() {\n val (A, B, C, K) = readLine()!!.split(\" \").map { it.toInt() }\n var ans = 0\n ans = if (A >= K) {\n K\n } else {\n if (A+B >= K) {\n A\n } else {\n A - (K - A -B)\n }\n }\n println(ans)\n} ", "language": "Kotlin", "metadata": {"date": 1597407191, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02682.html", "problem_id": "p02682", "resource_group": "medium_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/Kotlin/s744584495.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s744584495", "user_id": "u437444592"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "fun main() {\n val (A, B, C, K) = readLine()!!.split(\" \").map { it.toInt() }\n var ans = 0\n ans = if (A >= K) {\n K\n } else {\n if (A+B >= K) {\n A\n } else {\n A - (K - A -B)\n }\n }\n println(ans)\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 113, "memory_kb": 36504}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s184367072", "group_id": "codeNet:p02682", "input_text": "fun main() {\n val (a, b, c, k) = readLine()!!.split(\" \").map { it.toInt() }\n var ans = 0\n if (k <= a) {\n ans = k\n } else {\n ans = a\n if (k <= a + b) {\n } else {\n ans -= k - (a + b)\n }\n }\n println(ans)\n}", "language": "Kotlin", "metadata": {"date": 1595568670, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02682.html", "problem_id": "p02682", "resource_group": "medium_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/Kotlin/s184367072.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s184367072", "user_id": "u945228737"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "fun main() {\n val (a, b, c, k) = readLine()!!.split(\" \").map { it.toInt() }\n var ans = 0\n if (k <= a) {\n ans = k\n } else {\n ans = a\n if (k <= a + b) {\n } else {\n ans -= k - (a + b)\n }\n }\n println(ans)\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 115, "memory_kb": 36420}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s846940709", "group_id": "codeNet:p02682", "input_text": "fun main (args:Array){\n val (a , b , c , k) = readLine()!!.split(\" \").map(String::toInt)\n var maxVal = 0\n if(a < k) {\n maxVal += a * 1\n maxVal += (k - a) * 0\n if (k - a - b > 0) {\n maxVal += (k - a - b) * -1\n print(maxVal)\n return\n }\n print(maxVal)\n }\n if(a == k || a > k){\n maxVal += a * 1\n print(maxVal)\n }\n}", "language": "Kotlin", "metadata": {"date": 1593613506, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02682.html", "problem_id": "p02682", "resource_group": "medium_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/Kotlin/s846940709.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s846940709", "user_id": "u800824593"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "fun main (args:Array){\n val (a , b , c , k) = readLine()!!.split(\" \").map(String::toInt)\n var maxVal = 0\n if(a < k) {\n maxVal += a * 1\n maxVal += (k - a) * 0\n if (k - a - b > 0) {\n maxVal += (k - a - b) * -1\n print(maxVal)\n return\n }\n print(maxVal)\n }\n if(a == k || a > k){\n maxVal += a * 1\n print(maxVal)\n }\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 418, "cpu_time_ms": 109, "memory_kb": 36448}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s745925956", "group_id": "codeNet:p02682", "input_text": "fun main() {\n var (a, b, c,k) = readListInt()\n var ans = 0\n\n if (a >= k) {\n println(k)\n return\n }\n ans += a\n k -= a\n if (b >= k) {\n println(ans)\n return\n }\n ans -= (k - c)\n println(ans)\n\n}\n\nprivate fun read() = readLine()!!\n\nprivate fun readInt() = read().toInt()\n\nprivate fun readLong() = read().toLong()\n\nprivate fun readDouble() = read().toDouble()\n\nprivate fun readListString() = read().split(\" \")\n\nprivate fun readListInt() = readListString().map { it.toInt() }\n\nprivate fun readListLong() = readListString().map { it.toLong() }\n\nprivate fun readListDouble() = readListString().map { it.toDouble() }\n\n\n", "language": "Kotlin", "metadata": {"date": 1591583114, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02682.html", "problem_id": "p02682", "resource_group": "medium_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/Kotlin/s745925956.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s745925956", "user_id": "u698000453"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "fun main() {\n var (a, b, c,k) = readListInt()\n var ans = 0\n\n if (a >= k) {\n println(k)\n return\n }\n ans += a\n k -= a\n if (b >= k) {\n println(ans)\n return\n }\n ans -= (k - c)\n println(ans)\n\n}\n\nprivate fun read() = readLine()!!\n\nprivate fun readInt() = read().toInt()\n\nprivate fun readLong() = read().toLong()\n\nprivate fun readDouble() = read().toDouble()\n\nprivate fun readListString() = read().split(\" \")\n\nprivate fun readListInt() = readListString().map { it.toInt() }\n\nprivate fun readListLong() = readListString().map { it.toLong() }\n\nprivate fun readListDouble() = readListString().map { it.toDouble() }\n\n\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 665, "cpu_time_ms": 97, "memory_kb": 36368}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s302076388", "group_id": "codeNet:p02683", "input_text": "import java.io.PrintWriter\nimport kotlin.math.max\nimport kotlin.math.min\n\nfun next() = readLine()!!\nfun nextInt() = next().toInt()\nfun nextLong() = next().toLong()\nfun nextDouble() = next().toDouble()\nfun nextList() = next().split(\" \")\nfun nextIntList() = nextList().map(String::toInt)\nfun nextLongList() = nextList().map(String::toLong)\nfun nextDoubleList() = nextList().map(String::toDouble)\n\nval pw = PrintWriter(System.out)\nfun print(s: Any = \"\") = pw.print(s)\nfun println(s: Any = \"\") = pw.println(s)\n\nfun Iterable.join(separator: CharSequence = \", \", prefix: CharSequence = \"\", postfix: CharSequence = \"\") = joinToString(separator, prefix, postfix)\nfun Array.join(separator: CharSequence = \", \", prefix: CharSequence = \"\", postfix: CharSequence = \"\") = joinToString(separator, prefix, postfix)\n\nfun main(args: Array) {\n main()\n pw.flush()\n}\n\nfun main() {\n val (N, M, X) = nextIntList()\n val A = Array(N) { nextIntList() }\n val ans = rec_bit(A, M, X)\n println(ans)\n}\n\nfun rec_bit(seeds: Array>, M: Int, X: Int, pos: Int = 0, patterns: Array = emptyArray()): Int {\n return if (pos < seeds.size) {\n val res1 = rec_bit(seeds, M, X, pos + 1, patterns + pos)\n val res2 = rec_bit(seeds, M, X, pos + 1, patterns)\n if (res1 >= 0 && res2 >= 0) min(res1, res2) else max(res1, res2)\n } else {\n var cost = 0\n val A = IntArray(M)\n for (i in patterns) {\n val CA = seeds[i]\n cost += CA[0]\n for (j in 0 until M) {\n A[j] += CA[j + 1]\n }\n }\n if (A.all { it >= X }) cost else -1\n }\n}", "language": "Kotlin", "metadata": {"date": 1593665656, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02683.html", "problem_id": "p02683", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02683/input.txt", "sample_output_relpath": "derived/input_output/data/p02683/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02683/Kotlin/s302076388.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s302076388", "user_id": "u860789370"}, "prompt_components": {"gold_output": "120\n", "input_to_evaluate": "import java.io.PrintWriter\nimport kotlin.math.max\nimport kotlin.math.min\n\nfun next() = readLine()!!\nfun nextInt() = next().toInt()\nfun nextLong() = next().toLong()\nfun nextDouble() = next().toDouble()\nfun nextList() = next().split(\" \")\nfun nextIntList() = nextList().map(String::toInt)\nfun nextLongList() = nextList().map(String::toLong)\nfun nextDoubleList() = nextList().map(String::toDouble)\n\nval pw = PrintWriter(System.out)\nfun print(s: Any = \"\") = pw.print(s)\nfun println(s: Any = \"\") = pw.println(s)\n\nfun Iterable.join(separator: CharSequence = \", \", prefix: CharSequence = \"\", postfix: CharSequence = \"\") = joinToString(separator, prefix, postfix)\nfun Array.join(separator: CharSequence = \", \", prefix: CharSequence = \"\", postfix: CharSequence = \"\") = joinToString(separator, prefix, postfix)\n\nfun main(args: Array) {\n main()\n pw.flush()\n}\n\nfun main() {\n val (N, M, X) = nextIntList()\n val A = Array(N) { nextIntList() }\n val ans = rec_bit(A, M, X)\n println(ans)\n}\n\nfun rec_bit(seeds: Array>, M: Int, X: Int, pos: Int = 0, patterns: Array = emptyArray()): Int {\n return if (pos < seeds.size) {\n val res1 = rec_bit(seeds, M, X, pos + 1, patterns + pos)\n val res2 = rec_bit(seeds, M, X, pos + 1, patterns)\n if (res1 >= 0 && res2 >= 0) min(res1, res2) else max(res1, res2)\n } else {\n var cost = 0\n val A = IntArray(M)\n for (i in patterns) {\n val CA = seeds[i]\n cost += CA[0]\n for (j in 0 until M) {\n A[j] += CA[j + 1]\n }\n }\n if (A.all { it >= X }) cost else -1\n }\n}", "problem_context": "Score : 300 points\n\nProblem\n\nTakahashi, who is a novice in competitive programming, wants to learn M algorithms.\nInitially, his understanding level of each of the M algorithms is 0.\n\nTakahashi is visiting a bookstore, where he finds N books on algorithms.\nThe i-th book (1\\leq i\\leq N) is sold for C_i yen (the currency of Japan). If he buys and reads it, his understanding level of the j-th algorithm will increase by A_{i,j} for each j (1\\leq j\\leq M).\nThere is no other way to increase the understanding levels of the algorithms.\n\nTakahashi's objective is to make his understanding levels of all the M algorithms X or higher. Determine whether this objective is achievable. If it is achievable, find the minimum amount of money needed to achieve it.\n\nConstraints\n\nAll values in input are integers.\n\n1\\leq N, M\\leq 12\n\n1\\leq X\\leq 10^5\n\n1\\leq C_i \\leq 10^5\n\n0\\leq A_{i, j} \\leq 10^5\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M X\nC_1 A_{1,1} A_{1,2} \\cdots A_{1,M}\nC_2 A_{2,1} A_{2,2} \\cdots A_{2,M}\n\\vdots\nC_N A_{N,1} A_{N,2} \\cdots A_{N,M}\n\nOutput\n\nIf the objective is not achievable, print -1; otherwise, print the minimum amount of money needed to achieve it.\n\nSample Input 1\n\n3 3 10\n60 2 2 4\n70 8 7 9\n50 2 3 9\n\nSample Output 1\n\n120\n\nBuying the second and third books makes his understanding levels of all the algorithms 10 or higher, at the minimum cost possible.\n\nSample Input 2\n\n3 3 10\n100 3 1 4\n100 1 5 9\n100 2 6 5\n\nSample Output 2\n\n-1\n\nBuying all the books is still not enough to make his understanding levels of all the algorithms 10 or higher.\n\nSample Input 3\n\n8 5 22\n100 3 7 5 3 1\n164 4 5 2 7 8\n334 7 2 7 2 9\n234 4 7 2 8 2\n541 5 4 3 3 6\n235 4 8 6 9 7\n394 3 6 1 6 2\n872 8 4 3 7 2\n\nSample Output 3\n\n1067", "sample_input": "3 3 10\n60 2 2 4\n70 8 7 9\n50 2 3 9\n"}, "reference_outputs": ["120\n"], "source_document_id": "p02683", "source_text": "Score : 300 points\n\nProblem\n\nTakahashi, who is a novice in competitive programming, wants to learn M algorithms.\nInitially, his understanding level of each of the M algorithms is 0.\n\nTakahashi is visiting a bookstore, where he finds N books on algorithms.\nThe i-th book (1\\leq i\\leq N) is sold for C_i yen (the currency of Japan). If he buys and reads it, his understanding level of the j-th algorithm will increase by A_{i,j} for each j (1\\leq j\\leq M).\nThere is no other way to increase the understanding levels of the algorithms.\n\nTakahashi's objective is to make his understanding levels of all the M algorithms X or higher. Determine whether this objective is achievable. If it is achievable, find the minimum amount of money needed to achieve it.\n\nConstraints\n\nAll values in input are integers.\n\n1\\leq N, M\\leq 12\n\n1\\leq X\\leq 10^5\n\n1\\leq C_i \\leq 10^5\n\n0\\leq A_{i, j} \\leq 10^5\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M X\nC_1 A_{1,1} A_{1,2} \\cdots A_{1,M}\nC_2 A_{2,1} A_{2,2} \\cdots A_{2,M}\n\\vdots\nC_N A_{N,1} A_{N,2} \\cdots A_{N,M}\n\nOutput\n\nIf the objective is not achievable, print -1; otherwise, print the minimum amount of money needed to achieve it.\n\nSample Input 1\n\n3 3 10\n60 2 2 4\n70 8 7 9\n50 2 3 9\n\nSample Output 1\n\n120\n\nBuying the second and third books makes his understanding levels of all the algorithms 10 or higher, at the minimum cost possible.\n\nSample Input 2\n\n3 3 10\n100 3 1 4\n100 1 5 9\n100 2 6 5\n\nSample Output 2\n\n-1\n\nBuying all the books is still not enough to make his understanding levels of all the algorithms 10 or higher.\n\nSample Input 3\n\n8 5 22\n100 3 7 5 3 1\n164 4 5 2 7 8\n334 7 2 7 2 9\n234 4 7 2 8 2\n541 5 4 3 3 6\n235 4 8 6 9 7\n394 3 6 1 6 2\n872 8 4 3 7 2\n\nSample Output 3\n\n1067", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1648, "cpu_time_ms": 166, "memory_kb": 42996}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s916557153", "group_id": "codeNet:p02683", "input_text": "fun main() = abc167c()\n\n@OptIn(ExperimentalStdlibApi::class)\nfun abc167c() {\n val (n, m, x) = readLine()!!.split(' ').map { it.toLong() }\n val books = (1..n).map {\n val map = readLine()!!.split(' ').map { it.toLong() }\n map[0] to map.drop(1)\n }\n\n var answer = Long.MAX_VALUE\n\n for (b in bits(2, n.toInt())) {\n val filtered = books.filterIndexed { index, _ -> b[index] == 1 }\n\n val sum = LongArray(m.toInt())\n filtered.forEach { it.second.forEachIndexed { index, l -> sum[index] += l } }\n\n if (sum.all { it >= x }) {\n answer = filtered.map { it.first }.sum().coerceAtMost(answer)\n }\n }\n\n if (answer == Long.MAX_VALUE) answer = -1\n\n println(answer)\n}\n\nprivate fun pow(n: Long, p: Long): Long {\n var x = n\n var y = p\n var result = 1L\n while (y > 0) {\n if (y % 2 == 1L)\n result = (result * x)\n y = y shr 1\n x = (x * x)\n }\n return result\n}\n\nprivate fun bits(pattern: Int, length: Int): Array {\n val patterns = pow(pattern.toLong(), length.toLong()).toInt()\n val array = Array(patterns) { IntArray(length) }\n for (i in 0 until patterns) for (j in 0 until length) {\n array[i][length - j - 1] = (i / pow(pattern.toLong(), j.toLong()) % pattern).toInt()\n }\n return array\n}\n", "language": "Kotlin", "metadata": {"date": 1589176656, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02683.html", "problem_id": "p02683", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02683/input.txt", "sample_output_relpath": "derived/input_output/data/p02683/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02683/Kotlin/s916557153.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s916557153", "user_id": "u139478771"}, "prompt_components": {"gold_output": "120\n", "input_to_evaluate": "fun main() = abc167c()\n\n@OptIn(ExperimentalStdlibApi::class)\nfun abc167c() {\n val (n, m, x) = readLine()!!.split(' ').map { it.toLong() }\n val books = (1..n).map {\n val map = readLine()!!.split(' ').map { it.toLong() }\n map[0] to map.drop(1)\n }\n\n var answer = Long.MAX_VALUE\n\n for (b in bits(2, n.toInt())) {\n val filtered = books.filterIndexed { index, _ -> b[index] == 1 }\n\n val sum = LongArray(m.toInt())\n filtered.forEach { it.second.forEachIndexed { index, l -> sum[index] += l } }\n\n if (sum.all { it >= x }) {\n answer = filtered.map { it.first }.sum().coerceAtMost(answer)\n }\n }\n\n if (answer == Long.MAX_VALUE) answer = -1\n\n println(answer)\n}\n\nprivate fun pow(n: Long, p: Long): Long {\n var x = n\n var y = p\n var result = 1L\n while (y > 0) {\n if (y % 2 == 1L)\n result = (result * x)\n y = y shr 1\n x = (x * x)\n }\n return result\n}\n\nprivate fun bits(pattern: Int, length: Int): Array {\n val patterns = pow(pattern.toLong(), length.toLong()).toInt()\n val array = Array(patterns) { IntArray(length) }\n for (i in 0 until patterns) for (j in 0 until length) {\n array[i][length - j - 1] = (i / pow(pattern.toLong(), j.toLong()) % pattern).toInt()\n }\n return array\n}\n", "problem_context": "Score : 300 points\n\nProblem\n\nTakahashi, who is a novice in competitive programming, wants to learn M algorithms.\nInitially, his understanding level of each of the M algorithms is 0.\n\nTakahashi is visiting a bookstore, where he finds N books on algorithms.\nThe i-th book (1\\leq i\\leq N) is sold for C_i yen (the currency of Japan). If he buys and reads it, his understanding level of the j-th algorithm will increase by A_{i,j} for each j (1\\leq j\\leq M).\nThere is no other way to increase the understanding levels of the algorithms.\n\nTakahashi's objective is to make his understanding levels of all the M algorithms X or higher. Determine whether this objective is achievable. If it is achievable, find the minimum amount of money needed to achieve it.\n\nConstraints\n\nAll values in input are integers.\n\n1\\leq N, M\\leq 12\n\n1\\leq X\\leq 10^5\n\n1\\leq C_i \\leq 10^5\n\n0\\leq A_{i, j} \\leq 10^5\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M X\nC_1 A_{1,1} A_{1,2} \\cdots A_{1,M}\nC_2 A_{2,1} A_{2,2} \\cdots A_{2,M}\n\\vdots\nC_N A_{N,1} A_{N,2} \\cdots A_{N,M}\n\nOutput\n\nIf the objective is not achievable, print -1; otherwise, print the minimum amount of money needed to achieve it.\n\nSample Input 1\n\n3 3 10\n60 2 2 4\n70 8 7 9\n50 2 3 9\n\nSample Output 1\n\n120\n\nBuying the second and third books makes his understanding levels of all the algorithms 10 or higher, at the minimum cost possible.\n\nSample Input 2\n\n3 3 10\n100 3 1 4\n100 1 5 9\n100 2 6 5\n\nSample Output 2\n\n-1\n\nBuying all the books is still not enough to make his understanding levels of all the algorithms 10 or higher.\n\nSample Input 3\n\n8 5 22\n100 3 7 5 3 1\n164 4 5 2 7 8\n334 7 2 7 2 9\n234 4 7 2 8 2\n541 5 4 3 3 6\n235 4 8 6 9 7\n394 3 6 1 6 2\n872 8 4 3 7 2\n\nSample Output 3\n\n1067", "sample_input": "3 3 10\n60 2 2 4\n70 8 7 9\n50 2 3 9\n"}, "reference_outputs": ["120\n"], "source_document_id": "p02683", "source_text": "Score : 300 points\n\nProblem\n\nTakahashi, who is a novice in competitive programming, wants to learn M algorithms.\nInitially, his understanding level of each of the M algorithms is 0.\n\nTakahashi is visiting a bookstore, where he finds N books on algorithms.\nThe i-th book (1\\leq i\\leq N) is sold for C_i yen (the currency of Japan). If he buys and reads it, his understanding level of the j-th algorithm will increase by A_{i,j} for each j (1\\leq j\\leq M).\nThere is no other way to increase the understanding levels of the algorithms.\n\nTakahashi's objective is to make his understanding levels of all the M algorithms X or higher. Determine whether this objective is achievable. If it is achievable, find the minimum amount of money needed to achieve it.\n\nConstraints\n\nAll values in input are integers.\n\n1\\leq N, M\\leq 12\n\n1\\leq X\\leq 10^5\n\n1\\leq C_i \\leq 10^5\n\n0\\leq A_{i, j} \\leq 10^5\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M X\nC_1 A_{1,1} A_{1,2} \\cdots A_{1,M}\nC_2 A_{2,1} A_{2,2} \\cdots A_{2,M}\n\\vdots\nC_N A_{N,1} A_{N,2} \\cdots A_{N,M}\n\nOutput\n\nIf the objective is not achievable, print -1; otherwise, print the minimum amount of money needed to achieve it.\n\nSample Input 1\n\n3 3 10\n60 2 2 4\n70 8 7 9\n50 2 3 9\n\nSample Output 1\n\n120\n\nBuying the second and third books makes his understanding levels of all the algorithms 10 or higher, at the minimum cost possible.\n\nSample Input 2\n\n3 3 10\n100 3 1 4\n100 1 5 9\n100 2 6 5\n\nSample Output 2\n\n-1\n\nBuying all the books is still not enough to make his understanding levels of all the algorithms 10 or higher.\n\nSample Input 3\n\n8 5 22\n100 3 7 5 3 1\n164 4 5 2 7 8\n334 7 2 7 2 9\n234 4 7 2 8 2\n541 5 4 3 3 6\n235 4 8 6 9 7\n394 3 6 1 6 2\n872 8 4 3 7 2\n\nSample Output 3\n\n1067", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 188, "memory_kb": 42820}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s327121855", "group_id": "codeNet:p02686", "input_text": "import java.io.BufferedReader\nimport java.io.InputStream\nimport java.io.InputStreamReader\nimport java.io.PrintWriter\nimport java.lang.StringBuilder\nimport java.util.*\n\nfun PrintWriter.solve(sc: FastScanner) {\n val n = sc.nextInt()\n val s = Array(n) { sc.nextLine() }\n val data = Array(n) { 0 to 0 }\n for (i in 0 until n) {\n var v = 0\n var min = 0\n for (c in s[i]) {\n if (c == '(') {\n v++\n } else {\n v--\n }\n min = minOf(min, v)\n }\n data[i] = v to min\n }\n val final = data.map { it.first }.sum()\n if (final != 0) {\n println(\"No\")\n return\n }\n var value = 0\n val data2 = data.filter { it.first >= 0 }.sortedWith(compareByDescending> { it.second }.thenByDescending { it.first })\n for ((v, min) in data2) {\n if (value + min < 0) {\n println(\"No\")\n return\n }\n value += v\n }\n println(\"Yes\")\n}\n\nfun main(args: Array) {\n val writer = PrintWriter(System.out, false)\n writer.solve(FastScanner(System.`in`))\n writer.flush()\n}\n\nclass FastScanner(s: InputStream) {\n private var st = StringTokenizer(\"\")\n private val br = BufferedReader(InputStreamReader(s))\n\n fun next(): String {\n while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())\n\n return st.nextToken()\n }\n\n fun nextInt() = next().toInt()\n fun nextLong() = next().toLong()\n fun nextLine() = br.readLine()\n fun nextDouble() = next().toDouble()\n fun ready() = br.ready()\n}\n", "language": "Kotlin", "metadata": {"date": 1589352039, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02686.html", "problem_id": "p02686", "resource_group": "medium_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/Kotlin/s327121855.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s327121855", "user_id": "u190507186"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "import java.io.BufferedReader\nimport java.io.InputStream\nimport java.io.InputStreamReader\nimport java.io.PrintWriter\nimport java.lang.StringBuilder\nimport java.util.*\n\nfun PrintWriter.solve(sc: FastScanner) {\n val n = sc.nextInt()\n val s = Array(n) { sc.nextLine() }\n val data = Array(n) { 0 to 0 }\n for (i in 0 until n) {\n var v = 0\n var min = 0\n for (c in s[i]) {\n if (c == '(') {\n v++\n } else {\n v--\n }\n min = minOf(min, v)\n }\n data[i] = v to min\n }\n val final = data.map { it.first }.sum()\n if (final != 0) {\n println(\"No\")\n return\n }\n var value = 0\n val data2 = data.filter { it.first >= 0 }.sortedWith(compareByDescending> { it.second }.thenByDescending { it.first })\n for ((v, min) in data2) {\n if (value + min < 0) {\n println(\"No\")\n return\n }\n value += v\n }\n println(\"Yes\")\n}\n\nfun main(args: Array) {\n val writer = PrintWriter(System.out, false)\n writer.solve(FastScanner(System.`in`))\n writer.flush()\n}\n\nclass FastScanner(s: InputStream) {\n private var st = StringTokenizer(\"\")\n private val br = BufferedReader(InputStreamReader(s))\n\n fun next(): String {\n while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())\n\n return st.nextToken()\n }\n\n fun nextInt() = next().toInt()\n fun nextLong() = next().toLong()\n fun nextLine() = br.readLine()\n fun nextDouble() = next().toDouble()\n fun ready() = br.ready()\n}\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1599, "cpu_time_ms": 678, "memory_kb": 171928}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s261183808", "group_id": "codeNet:p02686", "input_text": "import java.util.*\n\nclass Scanner(`in`: java.io.InputStream) {\n private val reader = java.io.BufferedReader(java.io.InputStreamReader(`in`))\n private var tokenizer: StringTokenizer? = null\n\n fun next(): String {\n if (tokenizer?.hasMoreTokens() != true) {\n tokenizer = StringTokenizer(reader.readLine())\n }\n return tokenizer!!.nextToken()\n }\n\n fun nextLine(): String {\n return if (tokenizer?.hasMoreTokens() != true) {\n reader.readLine()\n } else tokenizer!!.nextToken(\"\\n\")\n }\n}\n\nfun main(args: Array) {\n val pw = java.io.PrintWriter(System.out)\n Problem.solve(Scanner(System.`in`), pw)\n pw.flush()\n}\n\n////////////////////////////////////////////////////////////////////////\n\nfun dprint(v: Any?, indent: Int = 0) {\n val indentStr = (1..indent).joinToString(\"\") { \" \" }\n when (v) {\n is Iterable<*> -> {\n System.err.println(\"$indentStr[\")\n v.forEach { dprint(it, indent + 1) }\n System.err.println(\"$indentStr]\")\n }\n is Array<*> -> {\n System.err.println(\"$indentStr[\")\n v.forEach { dprint(it, indent + 1) }\n System.err.println(\"$indentStr]\")\n }\n is IntArray -> System.err.println(indentStr + \"[\" + v.joinToString(\",\") + \"]\")\n is LongArray -> System.err.println(indentStr + \"[\" + v.joinToString(\",\") + \"]\")\n is DoubleArray -> System.err.println(indentStr + \"[\" + v.joinToString(\",\") + \"]\")\n else -> System.err.println(indentStr + v)\n }\n}\n\nfun > min(a: A, b: A) = if (a < b) a else b\nfun > min(vararg a: A) = a.reduce { acc, x -> min(acc, x) }\nfun > max(a: A, b: A) = if (a > b) a else b\nfun > max(vararg a: A) = a.reduce { acc, x -> max(acc, x) }\n\n////////////////////////////////////////////////////////////////////////\n\nobject Problem {\n fun solve(sc: Scanner, pw: java.io.PrintWriter) {\n val N = sc.next().toInt()\n val S = Array(N) { sc.next() }\n val S1 = mutableListOf>()\n val S2 = mutableListOf>()\n S.forEach { s ->\n var min = 0L\n var sum = 0L\n s.forEach { c ->\n if (c == '(') sum++ else sum--\n if (min > sum) min = sum\n }\n when {\n sum >= 0 -> S1.add(Pair(sum, min))\n else -> S2.add(Pair(-sum, min - sum))\n }\n }\n S1.sortBy { -it.second }\n S2.sortBy { it.second }\n val check1 = check(S1)\n val check2 = check(S2)\n if (check1 >= 0 && check2 >= 0 && check1 == check2) {\n pw.println(\"Yes\")\n } else {\n pw.println(\"No\")\n }\n }\n\n private fun check(a: List>): Long {\n var n = 0L\n a.forEach {\n val sum = it.first\n val min = it.second\n if (n + min < 0) {\n return -1\n }\n n += sum\n }\n return n\n }\n}\n", "language": "Kotlin", "metadata": {"date": 1589246076, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02686.html", "problem_id": "p02686", "resource_group": "medium_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/Kotlin/s261183808.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s261183808", "user_id": "u297767059"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "import java.util.*\n\nclass Scanner(`in`: java.io.InputStream) {\n private val reader = java.io.BufferedReader(java.io.InputStreamReader(`in`))\n private var tokenizer: StringTokenizer? = null\n\n fun next(): String {\n if (tokenizer?.hasMoreTokens() != true) {\n tokenizer = StringTokenizer(reader.readLine())\n }\n return tokenizer!!.nextToken()\n }\n\n fun nextLine(): String {\n return if (tokenizer?.hasMoreTokens() != true) {\n reader.readLine()\n } else tokenizer!!.nextToken(\"\\n\")\n }\n}\n\nfun main(args: Array) {\n val pw = java.io.PrintWriter(System.out)\n Problem.solve(Scanner(System.`in`), pw)\n pw.flush()\n}\n\n////////////////////////////////////////////////////////////////////////\n\nfun dprint(v: Any?, indent: Int = 0) {\n val indentStr = (1..indent).joinToString(\"\") { \" \" }\n when (v) {\n is Iterable<*> -> {\n System.err.println(\"$indentStr[\")\n v.forEach { dprint(it, indent + 1) }\n System.err.println(\"$indentStr]\")\n }\n is Array<*> -> {\n System.err.println(\"$indentStr[\")\n v.forEach { dprint(it, indent + 1) }\n System.err.println(\"$indentStr]\")\n }\n is IntArray -> System.err.println(indentStr + \"[\" + v.joinToString(\",\") + \"]\")\n is LongArray -> System.err.println(indentStr + \"[\" + v.joinToString(\",\") + \"]\")\n is DoubleArray -> System.err.println(indentStr + \"[\" + v.joinToString(\",\") + \"]\")\n else -> System.err.println(indentStr + v)\n }\n}\n\nfun > min(a: A, b: A) = if (a < b) a else b\nfun > min(vararg a: A) = a.reduce { acc, x -> min(acc, x) }\nfun > max(a: A, b: A) = if (a > b) a else b\nfun > max(vararg a: A) = a.reduce { acc, x -> max(acc, x) }\n\n////////////////////////////////////////////////////////////////////////\n\nobject Problem {\n fun solve(sc: Scanner, pw: java.io.PrintWriter) {\n val N = sc.next().toInt()\n val S = Array(N) { sc.next() }\n val S1 = mutableListOf>()\n val S2 = mutableListOf>()\n S.forEach { s ->\n var min = 0L\n var sum = 0L\n s.forEach { c ->\n if (c == '(') sum++ else sum--\n if (min > sum) min = sum\n }\n when {\n sum >= 0 -> S1.add(Pair(sum, min))\n else -> S2.add(Pair(-sum, min - sum))\n }\n }\n S1.sortBy { -it.second }\n S2.sortBy { it.second }\n val check1 = check(S1)\n val check2 = check(S2)\n if (check1 >= 0 && check2 >= 0 && check1 == check2) {\n pw.println(\"Yes\")\n } else {\n pw.println(\"No\")\n }\n }\n\n private fun check(a: List>): Long {\n var n = 0L\n a.forEach {\n val sum = it.first\n val min = it.second\n if (n + min < 0) {\n return -1\n }\n n += sum\n }\n return n\n }\n}\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 3080, "cpu_time_ms": 652, "memory_kb": 143364}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s277856325", "group_id": "codeNet:p02686", "input_text": "import java.util.*\nimport kotlin.collections.ArrayList\n\ndata class Node(val p:Int, val n:Int)\n\nfun main() {\n val sc = Scanner(System.`in`)\n val n = sc.nextInt()\n val list = ArrayList()\n var start = 0\n var end = 0\n\n for(i in 0 until n) {\n var k = 0\n var minus = 0\n var plus = 0\n val s = sc.next()\n for(c in s) {\n if(c == '(') {\n if(k < 0) {\n minus += k\n k = 0\n }\n ++k\n } else if(c==')'){\n --k\n }\n }\n if(k > 0) {\n plus += k\n } else if(k < 0) {\n minus += k\n }\n\n if(minus == 0 || plus == 0) {\n start += plus\n end += minus\n } else {\n list.add(Node(plus, minus))\n }\n }\n\n val pq = PriorityQueue(kotlin.Comparator { o1, o2 ->\n val v1 = o1.n + o1.p\n val v2 = o2.n + o2.p\n return@Comparator v2.compareTo(v1)\n })\n\n list.sortByDescending { it.n }\n\n var idx = 0\n var isSuccess = true\n\n while (isSuccess && idx < list.size) {\n while(idx < list.size && list[idx].n <= start) {\n pq.add(list[idx++])\n }\n while (pq.isNotEmpty()) {\n val node = pq.poll()\n start += node.n\n if(start < 0) {\n isSuccess = false\n break\n }\n start += node.p\n }\n }\n if(isSuccess) {\n val ret = start + end\n isSuccess = ret == 0\n }\n\n if(isSuccess) {\n print(\"Yes\")\n } else {\n print(\"No\")\n }\n}", "language": "Kotlin", "metadata": {"date": 1589239674, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02686.html", "problem_id": "p02686", "resource_group": "medium_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/Kotlin/s277856325.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s277856325", "user_id": "u682597394"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "import java.util.*\nimport kotlin.collections.ArrayList\n\ndata class Node(val p:Int, val n:Int)\n\nfun main() {\n val sc = Scanner(System.`in`)\n val n = sc.nextInt()\n val list = ArrayList()\n var start = 0\n var end = 0\n\n for(i in 0 until n) {\n var k = 0\n var minus = 0\n var plus = 0\n val s = sc.next()\n for(c in s) {\n if(c == '(') {\n if(k < 0) {\n minus += k\n k = 0\n }\n ++k\n } else if(c==')'){\n --k\n }\n }\n if(k > 0) {\n plus += k\n } else if(k < 0) {\n minus += k\n }\n\n if(minus == 0 || plus == 0) {\n start += plus\n end += minus\n } else {\n list.add(Node(plus, minus))\n }\n }\n\n val pq = PriorityQueue(kotlin.Comparator { o1, o2 ->\n val v1 = o1.n + o1.p\n val v2 = o2.n + o2.p\n return@Comparator v2.compareTo(v1)\n })\n\n list.sortByDescending { it.n }\n\n var idx = 0\n var isSuccess = true\n\n while (isSuccess && idx < list.size) {\n while(idx < list.size && list[idx].n <= start) {\n pq.add(list[idx++])\n }\n while (pq.isNotEmpty()) {\n val node = pq.poll()\n start += node.n\n if(start < 0) {\n isSuccess = false\n break\n }\n start += node.p\n }\n }\n if(isSuccess) {\n val ret = start + end\n isSuccess = ret == 0\n }\n\n if(isSuccess) {\n print(\"Yes\")\n } else {\n print(\"No\")\n }\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1657, "cpu_time_ms": 582, "memory_kb": 67876}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s334676795", "group_id": "codeNet:p02686", "input_text": "import java.util.*\nimport kotlin.collections.ArrayList\nimport kotlin.math.max\nimport kotlin.random.Random\n\nfun main() {\n val sc = Scanner(System.`in`)\n var n = sc.nextInt()\n var arr = Array(n){\"\"}\n var m = Array(n){ArrayList()}\n\n fun createP(n:Int): String {\n val sb = StringBuilder()\n val c = arrayOf('(',')')\n for(i in 0 until n) {\n sb.append(c[Random.nextInt(0, 100) % 2])\n }\n return sb.toString()\n }\n fun createRand() {\n n = (7000).toInt()\n arr = Array(n){\"\"}\n for(i in 0 until n) {\n val len = Random.nextInt(1, 2200)\n arr[i] = createP(len)\n }\n m = Array(n){ArrayList()}\n }\n\n for(i in 0 until n) {\n arr[i] = sc.next()\n arr[i] = arr[i].trim()\n }\n\n// createRand()\n\n for(i in 0 until n) {\n var k = 0\n val l = ArrayList()\n for(c in arr[i]) {\n if(c == '(') {\n if(k < 0) {\n l.add(k)\n k = 0\n }\n ++k\n } else if(c==')'){\n --k\n }\n }\n if(k != 0) {\n l.add(k)\n }\n m[i] = l\n }\n\n fun ex(d:Int): Int {\n if(d > 0) return 1\n return max(-1, d)\n }\n\n m.sortWith(kotlin.Comparator { o1, o2 ->\n if(o1.size == o2.size) {\n for(i in o1.indices) {\n val l = ex(o1[i])\n val r = ex(o2[i])\n if(l == r) continue\n return@Comparator r.compareTo(l)\n }\n return@Comparator 0\n }\n for(i in 0 until max(o1.size, o2.size)) {\n val l = if(i >= o1.size) {\n 0\n } else {\n ex(o1[i])\n }\n val r = if(i >= o2.size) {\n 0\n } else {\n ex(o2[i])\n }\n if(l == r) continue\n return@Comparator r.compareTo(l)\n }\n return@Comparator 0\n })\n\n val ans = ArrayList()\n m.forEach {x ->\n x.forEach { ans.add(it) }\n }\n\n var acc = 0L\n for(d in ans) {\n acc += d\n if(acc < 0L) {\n break\n }\n }\n\n if(acc == 0L) {\n print(\"Yes\")\n } else {\n print(\"No\")\n }\n\n\n}\n", "language": "Kotlin", "metadata": {"date": 1589235659, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02686.html", "problem_id": "p02686", "resource_group": "medium_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/Kotlin/s334676795.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s334676795", "user_id": "u682597394"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "import java.util.*\nimport kotlin.collections.ArrayList\nimport kotlin.math.max\nimport kotlin.random.Random\n\nfun main() {\n val sc = Scanner(System.`in`)\n var n = sc.nextInt()\n var arr = Array(n){\"\"}\n var m = Array(n){ArrayList()}\n\n fun createP(n:Int): String {\n val sb = StringBuilder()\n val c = arrayOf('(',')')\n for(i in 0 until n) {\n sb.append(c[Random.nextInt(0, 100) % 2])\n }\n return sb.toString()\n }\n fun createRand() {\n n = (7000).toInt()\n arr = Array(n){\"\"}\n for(i in 0 until n) {\n val len = Random.nextInt(1, 2200)\n arr[i] = createP(len)\n }\n m = Array(n){ArrayList()}\n }\n\n for(i in 0 until n) {\n arr[i] = sc.next()\n arr[i] = arr[i].trim()\n }\n\n// createRand()\n\n for(i in 0 until n) {\n var k = 0\n val l = ArrayList()\n for(c in arr[i]) {\n if(c == '(') {\n if(k < 0) {\n l.add(k)\n k = 0\n }\n ++k\n } else if(c==')'){\n --k\n }\n }\n if(k != 0) {\n l.add(k)\n }\n m[i] = l\n }\n\n fun ex(d:Int): Int {\n if(d > 0) return 1\n return max(-1, d)\n }\n\n m.sortWith(kotlin.Comparator { o1, o2 ->\n if(o1.size == o2.size) {\n for(i in o1.indices) {\n val l = ex(o1[i])\n val r = ex(o2[i])\n if(l == r) continue\n return@Comparator r.compareTo(l)\n }\n return@Comparator 0\n }\n for(i in 0 until max(o1.size, o2.size)) {\n val l = if(i >= o1.size) {\n 0\n } else {\n ex(o1[i])\n }\n val r = if(i >= o2.size) {\n 0\n } else {\n ex(o2[i])\n }\n if(l == r) continue\n return@Comparator r.compareTo(l)\n }\n return@Comparator 0\n })\n\n val ans = ArrayList()\n m.forEach {x ->\n x.forEach { ans.add(it) }\n }\n\n var acc = 0L\n for(d in ans) {\n acc += d\n if(acc < 0L) {\n break\n }\n }\n\n if(acc == 0L) {\n print(\"Yes\")\n } else {\n print(\"No\")\n }\n\n\n}\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2334, "cpu_time_ms": 1752, "memory_kb": 252008}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s022137345", "group_id": "codeNet:p02686", "input_text": "import kotlin.math.min\n\nfun main() = abc167f()\n\n@OptIn(ExperimentalStdlibApi::class)\nfun abc167f() {\n data class Bracket(val lowestHeight: Int, val transition: Int)\n\n val n = readLine()!!.toInt()\n val brackets = (1..n).map {\n val s = readLine()!!\n var currHeight = 0\n var lowestHeight = 0\n for (c in s) {\n when (c) {\n '(' -> currHeight++\n else -> currHeight--\n }\n lowestHeight = min(lowestHeight, currHeight)\n }\n Bracket(lowestHeight, currHeight)\n }\n\n var currHeight = 0\n val grouped = brackets.sortedByDescending { it.lowestHeight }\n .partition { it.transition > 0 }.let { it.first + it.second }\n\n for ((lowestHeight, transition) in grouped) {\n if (currHeight + lowestHeight < 0) return println(\"No\")\n currHeight += transition\n }\n\n val answer = if (currHeight == 0) \"Yes\" else \"No\"\n\n println(answer)\n}\n", "language": "Kotlin", "metadata": {"date": 1589178862, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02686.html", "problem_id": "p02686", "resource_group": "medium_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/Kotlin/s022137345.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s022137345", "user_id": "u139478771"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "import kotlin.math.min\n\nfun main() = abc167f()\n\n@OptIn(ExperimentalStdlibApi::class)\nfun abc167f() {\n data class Bracket(val lowestHeight: Int, val transition: Int)\n\n val n = readLine()!!.toInt()\n val brackets = (1..n).map {\n val s = readLine()!!\n var currHeight = 0\n var lowestHeight = 0\n for (c in s) {\n when (c) {\n '(' -> currHeight++\n else -> currHeight--\n }\n lowestHeight = min(lowestHeight, currHeight)\n }\n Bracket(lowestHeight, currHeight)\n }\n\n var currHeight = 0\n val grouped = brackets.sortedByDescending { it.lowestHeight }\n .partition { it.transition > 0 }.let { it.first + it.second }\n\n for ((lowestHeight, transition) in grouped) {\n if (currHeight + lowestHeight < 0) return println(\"No\")\n currHeight += transition\n }\n\n val answer = if (currHeight == 0) \"Yes\" else \"No\"\n\n println(answer)\n}\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 959, "cpu_time_ms": 749, "memory_kb": 108592}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s130272346", "group_id": "codeNet:p02686", "input_text": "fun main() {\n val builder = StringBuilder()\n\n val n = readInputLine().toInt()\n\n val tmpBuilder = StringBuilder()\n\n repeat(n) {\n val input = readInputLine()\n var lbCnt = 0\n var rbCnt = 0\n\n for (c in input) {\n when(c) {\n ')' -> lbCnt++\n else -> rbCnt++\n }\n if (lbCnt > rbCnt) {\n break\n }\n }\n if (lbCnt > rbCnt) {\n tmpBuilder.append(input)\n } else {\n tmpBuilder.insert(0, input)\n }\n }\n\n var lbCnt = 0\n var rbCnt = 0\n\n for (c in tmpBuilder.toString()) {\n when(c) {\n ')' -> lbCnt++\n else -> rbCnt++\n }\n if (lbCnt > rbCnt) {\n println(\"No\")\n return\n }\n }\n\n if (lbCnt != rbCnt) {\n println(\"No\")\n } else {\n println(\"Yes\")\n }\n\n /*\n var allParenCol = true\n var existsLopen = false\n var existsRopen = false\n\n for (i in 0 until n) {\n val input = readInputLine().toCharArray()\n var lbCntLocal = 0\n var rbCntLocal = 0\n\n var isLopen = false\n var isRopen = false\n for (c in input) {\n when(c) {\n ')' -> {\n lbCntLocal++\n if (lbCntLocal > rbCntLocal) {\n isLopen = true\n }\n }\n '(' -> {\n rbCntLocal++\n }\n }\n }\n\n var lbCntLocal2 = 0\n var rbCntLocal2 = 0\n for (c in input.reversed()) {\n when(c) {\n ')' -> {\n lbCntLocal2++\n }\n '(' -> {\n rbCntLocal2++\n if (rbCntLocal2 > lbCntLocal2) {\n isRopen = true\n }\n }\n }\n if (isRopen) {\n break\n }\n }\n\n if (isLopen || isRopen) {\n allParenCol = false\n }\n if (isLopen && !isRopen) {\n existsLopen = true\n }\n if (isRopen && !isLopen) {\n existsRopen = true\n }\n\n lbCnt += lbCntLocal\n rbCnt += rbCntLocal\n }\n\n if (lbCnt != rbCnt) {\n builder.appendln(\"No\")\n } else if (allParenCol || (existsLopen && existsRopen)) {\n builder.appendln(\"Yes\")\n } else {\n builder.appendln(\"No\")\n }\n\n print(builder.toString())\n */\n}\n\nfun readInputLine(): String {\n return readLine()!!\n}\n", "language": "Kotlin", "metadata": {"date": 1589164248, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02686.html", "problem_id": "p02686", "resource_group": "medium_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/Kotlin/s130272346.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s130272346", "user_id": "u505558493"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "fun main() {\n val builder = StringBuilder()\n\n val n = readInputLine().toInt()\n\n val tmpBuilder = StringBuilder()\n\n repeat(n) {\n val input = readInputLine()\n var lbCnt = 0\n var rbCnt = 0\n\n for (c in input) {\n when(c) {\n ')' -> lbCnt++\n else -> rbCnt++\n }\n if (lbCnt > rbCnt) {\n break\n }\n }\n if (lbCnt > rbCnt) {\n tmpBuilder.append(input)\n } else {\n tmpBuilder.insert(0, input)\n }\n }\n\n var lbCnt = 0\n var rbCnt = 0\n\n for (c in tmpBuilder.toString()) {\n when(c) {\n ')' -> lbCnt++\n else -> rbCnt++\n }\n if (lbCnt > rbCnt) {\n println(\"No\")\n return\n }\n }\n\n if (lbCnt != rbCnt) {\n println(\"No\")\n } else {\n println(\"Yes\")\n }\n\n /*\n var allParenCol = true\n var existsLopen = false\n var existsRopen = false\n\n for (i in 0 until n) {\n val input = readInputLine().toCharArray()\n var lbCntLocal = 0\n var rbCntLocal = 0\n\n var isLopen = false\n var isRopen = false\n for (c in input) {\n when(c) {\n ')' -> {\n lbCntLocal++\n if (lbCntLocal > rbCntLocal) {\n isLopen = true\n }\n }\n '(' -> {\n rbCntLocal++\n }\n }\n }\n\n var lbCntLocal2 = 0\n var rbCntLocal2 = 0\n for (c in input.reversed()) {\n when(c) {\n ')' -> {\n lbCntLocal2++\n }\n '(' -> {\n rbCntLocal2++\n if (rbCntLocal2 > lbCntLocal2) {\n isRopen = true\n }\n }\n }\n if (isRopen) {\n break\n }\n }\n\n if (isLopen || isRopen) {\n allParenCol = false\n }\n if (isLopen && !isRopen) {\n existsLopen = true\n }\n if (isRopen && !isLopen) {\n existsRopen = true\n }\n\n lbCnt += lbCntLocal\n rbCnt += rbCntLocal\n }\n\n if (lbCnt != rbCnt) {\n builder.appendln(\"No\")\n } else if (allParenCol || (existsLopen && existsRopen)) {\n builder.appendln(\"Yes\")\n } else {\n builder.appendln(\"No\")\n }\n\n print(builder.toString())\n */\n}\n\nfun readInputLine(): String {\n return readLine()!!\n}\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2586, "cpu_time_ms": 2207, "memory_kb": 60272}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s678457465", "group_id": "codeNet:p02688", "input_text": "fun main(args: Array) {\n val (N, K) = readLine()!!.split(\" \").map { it.toInt() }\n val snackHolders = (0 until K).map {\n readLine() // needless value\n readLine()!!.split(\" \").map { it.toInt() } }\n \n val population = snackHolders.fold(setOf(), { acc, list -> acc + list.toSet() } )\n val mischiefs = (1..N).filterNot { population.contains(it) }\n \n println(mischiefs.count())\n}\n\n", "language": "Kotlin", "metadata": {"date": 1600121858, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02688.html", "problem_id": "p02688", "resource_group": "medium_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/Kotlin/s678457465.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s678457465", "user_id": "u496449946"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "fun main(args: Array) {\n val (N, K) = readLine()!!.split(\" \").map { it.toInt() }\n val snackHolders = (0 until K).map {\n readLine() // needless value\n readLine()!!.split(\" \").map { it.toInt() } }\n \n val population = snackHolders.fold(setOf(), { acc, list -> acc + list.toSet() } )\n val mischiefs = (1..N).filterNot { population.contains(it) }\n \n println(mischiefs.count())\n}\n\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 186, "memory_kb": 40736}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s022987839", "group_id": "codeNet:p02688", "input_text": "fun main(args: Array) {\n val (n,k) = readLine()!!.split(\" \").map { it.toInt() }\n val points = MutableList(n) { 0 }\n for (i in 0 until n) {\n val d = readLine()!!.toInt()\n readLine()!!.split(\" \").map { it.toInt() - 1 }.forEach{ points[it]++ }\n }\n println(points.count { it == 0 })\n}\n\n", "language": "Kotlin", "metadata": {"date": 1592767645, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02688.html", "problem_id": "p02688", "resource_group": "medium_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/Kotlin/s022987839.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s022987839", "user_id": "u172820018"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "fun main(args: Array) {\n val (n,k) = readLine()!!.split(\" \").map { it.toInt() }\n val points = MutableList(n) { 0 }\n for (i in 0 until n) {\n val d = readLine()!!.toInt()\n readLine()!!.split(\" \").map { it.toInt() - 1 }.forEach{ points[it]++ }\n }\n println(points.count { it == 0 })\n}\n\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 176, "memory_kb": 39252}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s934228121", "group_id": "codeNet:p02688", "input_text": "import java.util.*\n\nfun main() {\n val snukes = mutableSetOf()\n val jin = Scanner(System.`in`)\n val n = jin.nextInt()\n val k = jin.nextInt()\n snukes.addAll(1..n)\n for (j1 in 1..k) {\n val d = jin.nextInt()\n for (j2 in 1..d) {\n snukes.remove(jin.nextInt())\n }\n }\n println(snukes.size)\n}", "language": "Kotlin", "metadata": {"date": 1588564989, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02688.html", "problem_id": "p02688", "resource_group": "medium_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/Kotlin/s934228121.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s934228121", "user_id": "u590243733"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "import java.util.*\n\nfun main() {\n val snukes = mutableSetOf()\n val jin = Scanner(System.`in`)\n val n = jin.nextInt()\n val k = jin.nextInt()\n snukes.addAll(1..n)\n for (j1 in 1..k) {\n val d = jin.nextInt()\n for (j2 in 1..d) {\n snukes.remove(jin.nextInt())\n }\n }\n println(snukes.size)\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 344, "cpu_time_ms": 196, "memory_kb": 48040}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s753153922", "group_id": "codeNet:p02688", "input_text": "fun main(){\n val (n, k) = readLine()!!.split(\" \").map { it.toInt() }\n val aList = mutableListOf>()\n for (i in 0 until k){\n val d = readLine()!!.toInt()\n val a = readLine()!!.split(\" \").map { it.toInt() }\n aList.add(a.toList())\n }\n\n val f = Array(n){true}\n aList.forEach { a ->\n a.forEach { f[it - 1] = false }\n }\n println(f.filter { it }.size)\n}", "language": "Kotlin", "metadata": {"date": 1588554631, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02688.html", "problem_id": "p02688", "resource_group": "medium_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/Kotlin/s753153922.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s753153922", "user_id": "u531770859"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "fun main(){\n val (n, k) = readLine()!!.split(\" \").map { it.toInt() }\n val aList = mutableListOf>()\n for (i in 0 until k){\n val d = readLine()!!.toInt()\n val a = readLine()!!.split(\" \").map { it.toInt() }\n aList.add(a.toList())\n }\n\n val f = Array(n){true}\n aList.forEach { a ->\n a.forEach { f[it - 1] = false }\n }\n println(f.filter { it }.size)\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 407, "cpu_time_ms": 152, "memory_kb": 39248}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s209188904", "group_id": "codeNet:p02688", "input_text": "fun main() {\n val l = readLine()!!.split(' ').map { it.toInt() }\n var map: MutableList = (1..l[0]).toMutableList()\n\n for (i in 0 until l[1]) {\n readLine()!!\n val a = readLine()!!.split(' ').map { it.toInt() }\n for (x in a) {\n map.remove(x)\n }\n }\n println(map.count())\n}\n\n", "language": "Kotlin", "metadata": {"date": 1588554540, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02688.html", "problem_id": "p02688", "resource_group": "medium_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/Kotlin/s209188904.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s209188904", "user_id": "u213256030"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "fun main() {\n val l = readLine()!!.split(' ').map { it.toInt() }\n var map: MutableList = (1..l[0]).toMutableList()\n\n for (i in 0 until l[1]) {\n readLine()!!\n val a = readLine()!!.split(' ').map { it.toInt() }\n for (x in a) {\n map.remove(x)\n }\n }\n println(map.count())\n}\n\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 330, "cpu_time_ms": 153, "memory_kb": 39244}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s976206925", "group_id": "codeNet:p02689", "input_text": "fun main(args: Array) {\n val (n, m) = readLine()!!.split(\" \").map { it.toInt() }\n\n val h = readLine()!!.split(\" \").map { it.toInt() }\n val good = (0 until n).toHashSet()\n for (i in 0 until m) {\n val (a, b) = readLine()!!.split(\" \").map { it.toInt() - 1 }\n if (h[a] <= h[b]) {\n good.remove(a)\n }\n if (h[a] >= h[b]) {\n good.remove(b)\n }\n }\n println(good.size)\n}", "language": "Kotlin", "metadata": {"date": 1588555240, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02689.html", "problem_id": "p02689", "resource_group": "medium_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/Kotlin/s976206925.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s976206925", "user_id": "u732371409"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "fun main(args: Array) {\n val (n, m) = readLine()!!.split(\" \").map { it.toInt() }\n\n val h = readLine()!!.split(\" \").map { it.toInt() }\n val good = (0 until n).toHashSet()\n for (i in 0 until m) {\n val (a, b) = readLine()!!.split(\" \").map { it.toInt() - 1 }\n if (h[a] <= h[b]) {\n good.remove(a)\n }\n if (h[a] >= h[b]) {\n good.remove(b)\n }\n }\n println(good.size)\n}", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 442, "cpu_time_ms": 642, "memory_kb": 69584}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s399531301", "group_id": "codeNet:p02690", "input_text": "import kotlin.math.*\n\nfun main(args: Array) {\n d()\n}\n\nfun a() {\n when(readLine()) {\n \"ABC\" -> println(\"ARC\")\n \"ARC\" -> println(\"ABC\")\n else -> Unit\n }\n}\n\nfun b() {\n val (N, K) = readLine()!!.split(\" \").map { it.toInt() }.let { it[0] to it[1] }\n val set = (1 .. N).toMutableSet()\n repeat(K) {\n val d = readLine()!!.toInt()\n val As = readLine()!!.split(\" \").map { it.toInt() }\n set.removeAll(As)\n }\n println(set.count())\n}\n\nfun c() {\n val (N, M) = readLine()!!.split(\" \").map { it.toInt() }.let { it[0] to it[1] }\n val H = readLine()!!.split(\" \").map { it.toLong() }\n val set = (0 until N).toMutableSet()\n repeat(M) {\n val (A, B) = readLine()!!.split(\" \").map { it.toInt() - 1 }.let { it[0] to it[1] }\n when {\n H[A] == H[B] -> {\n set.remove(A)\n set.remove(B)\n }\n H[A] > H[B] -> {\n set.remove(B)\n }\n H[A] < H[B] -> {\n set.remove(A)\n }\n }\n }\n println(set.count())\n}\n\nfun d() {\n val X = readLine()!!.toLong()\n val list = primeFactorization(X)\n list.forEach {\n val pow5 = it.toDouble().pow(5).toLong()\n when{\n pow5 == X -> { println(\"$it 0\"); return }\n pow5 > X -> {\n var l = pow5\n var a = it\n var b = 0\n while (l > X) {\n a--\n b++\n l = a*a*a*a*a - b*b*b*b*b\n if (X == l) {\n println(\"$a $b\")\n return\n }\n }\n }\n pow5 < X -> {\n var l = pow5\n var a = it\n var b = 0\n while (l < X) {\n a++\n b--\n l = a*a*a*a*a - b*b*b*b*b\n if (X == l) {\n println(\"$a $b\")\n return\n }\n }\n }\n }\n }\n}\n\nfun primeFactorization(value : Long) : List{\n if (value == 1L) return listOf(1)\n val max = Math.sqrt(value.toDouble()).toLong()\n return prime(2, max).filter { value % it == 0L }\n}\n\nfun prime(from : Long, to : Long = from) : List {\n return (from..to).filter { i ->\n val max = Math.sqrt(i.toDouble()).toLong()\n (2..max).all { j -> i % j != 0L }\n }\n}", "language": "Kotlin", "metadata": {"date": 1588559953, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02690.html", "problem_id": "p02690", "resource_group": "medium_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/Kotlin/s399531301.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s399531301", "user_id": "u915119935"}, "prompt_components": {"gold_output": "2 -1\n", "input_to_evaluate": "import kotlin.math.*\n\nfun main(args: Array) {\n d()\n}\n\nfun a() {\n when(readLine()) {\n \"ABC\" -> println(\"ARC\")\n \"ARC\" -> println(\"ABC\")\n else -> Unit\n }\n}\n\nfun b() {\n val (N, K) = readLine()!!.split(\" \").map { it.toInt() }.let { it[0] to it[1] }\n val set = (1 .. N).toMutableSet()\n repeat(K) {\n val d = readLine()!!.toInt()\n val As = readLine()!!.split(\" \").map { it.toInt() }\n set.removeAll(As)\n }\n println(set.count())\n}\n\nfun c() {\n val (N, M) = readLine()!!.split(\" \").map { it.toInt() }.let { it[0] to it[1] }\n val H = readLine()!!.split(\" \").map { it.toLong() }\n val set = (0 until N).toMutableSet()\n repeat(M) {\n val (A, B) = readLine()!!.split(\" \").map { it.toInt() - 1 }.let { it[0] to it[1] }\n when {\n H[A] == H[B] -> {\n set.remove(A)\n set.remove(B)\n }\n H[A] > H[B] -> {\n set.remove(B)\n }\n H[A] < H[B] -> {\n set.remove(A)\n }\n }\n }\n println(set.count())\n}\n\nfun d() {\n val X = readLine()!!.toLong()\n val list = primeFactorization(X)\n list.forEach {\n val pow5 = it.toDouble().pow(5).toLong()\n when{\n pow5 == X -> { println(\"$it 0\"); return }\n pow5 > X -> {\n var l = pow5\n var a = it\n var b = 0\n while (l > X) {\n a--\n b++\n l = a*a*a*a*a - b*b*b*b*b\n if (X == l) {\n println(\"$a $b\")\n return\n }\n }\n }\n pow5 < X -> {\n var l = pow5\n var a = it\n var b = 0\n while (l < X) {\n a++\n b--\n l = a*a*a*a*a - b*b*b*b*b\n if (X == l) {\n println(\"$a $b\")\n return\n }\n }\n }\n }\n }\n}\n\nfun primeFactorization(value : Long) : List{\n if (value == 1L) return listOf(1)\n val max = Math.sqrt(value.toDouble()).toLong()\n return prime(2, max).filter { value % it == 0L }\n}\n\nfun prime(from : Long, to : Long = from) : List {\n return (from..to).filter { i ->\n val max = Math.sqrt(i.toDouble()).toLong()\n (2..max).all { j -> i % j != 0L }\n }\n}", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2515, "cpu_time_ms": 130, "memory_kb": 39100}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s654428441", "group_id": "codeNet:p02690", "input_text": "fun main() {\n val x = readLine()!!.toLong()\n\n var a = 0.0\n var b = 0\n\n while(true){\n a = Math.pow(((b * b * b * b * b) + x).toDouble(), 1.0 / 5.0)\n\n if(a.toString().split(\".\")[1].all { it == '0' }){\n break\n }\n\n a = Math.pow(((-b * b * b * b * b) + x).toDouble(), 1.0 / 5.0)\n\n if(a.toString().split(\".\")[1].all { it == '0' }){\n break\n }\n\n b++\n }\n println(\"${a.toInt()} $b\")\n}", "language": "Kotlin", "metadata": {"date": 1588559462, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02690.html", "problem_id": "p02690", "resource_group": "medium_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/Kotlin/s654428441.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s654428441", "user_id": "u862494256"}, "prompt_components": {"gold_output": "2 -1\n", "input_to_evaluate": "fun main() {\n val x = readLine()!!.toLong()\n\n var a = 0.0\n var b = 0\n\n while(true){\n a = Math.pow(((b * b * b * b * b) + x).toDouble(), 1.0 / 5.0)\n\n if(a.toString().split(\".\")[1].all { it == '0' }){\n break\n }\n\n a = Math.pow(((-b * b * b * b * b) + x).toDouble(), 1.0 / 5.0)\n\n if(a.toString().split(\".\")[1].all { it == '0' }){\n break\n }\n\n b++\n }\n println(\"${a.toInt()} $b\")\n}", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 463, "cpu_time_ms": 101, "memory_kb": 36704}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s308011180", "group_id": "codeNet:p02690", "input_text": "fun main(args: Array) = ABC166D.main()\n\nobject ABC166D {\n fun log(message: Any?) {\n println(message)// TODO: ←消す\n }\n\n fun main() {\n val X = readInt()\n\n val (al, be) = (1..Int.MAX_VALUE).asSequence().mapNotNull { al ->\n val al2 = al * al\n val al4 = al2 * al2\n if (X % al != 0\n || ((X / al) - al4) % 5 != 0\n ) return@mapNotNull null\n\n val ga = ((X / al) - al4) / 5\n val s = if (ga == 0) 1 else ga\n val beta = (1..al step s).asSequence()\n //.filter { b -> ga % b == 0 }\n .mapNotNull { pb ->\n val pLeft = al2 + pb\n val pRight = ga / pb\n\n val mb = -pb\n val mLeft = al2 + mb\n val mRight = ga / mb\n when {\n (pLeft == pRight) -> pb\n (mLeft == mRight) -> mb\n else -> null\n }\n }.firstOrNull()\n beta?.let { al to it }\n }.first()\n //////\n val D = Math.sqrt((al * al + 4 * be).toDouble()).toInt()\n val A1 = (al + D) / 2\n val A2 = (al - D) / 2\n val B1 = A1 - al\n val B2 = A2 - al\n val ans = when {\n check(A1, B1, X) -> A1 to B1\n check(A2, B2, X) -> A2 to B2\n else -> null\n }\n println(\"${ans?.first} ${ans?.second}\")\n }\n\n fun check(A: Int, B: Int, X: Int) = (A * A * A * A * A - B * B * B * B * B) == X\n\n /*####################################################################################*/\n\n fun readString() = readLine()!!\n fun readStrings() = readLine()!!.split(\" \")\n fun readInt() = readLine()!!.toInt()\n fun readInts() = readLine()!!.split(\" \").map { it.toInt() }\n fun readLong() = readLine()!!.toLong()\n fun readLongs() = readLine()!!.split(\" \").map { it.toLong() }\n fun readMatrixRows(height: Int) = (1..height).map { readLine()!!.toList() }\n\n fun Boolean.yesOrNo() = if (this) \"Yes\" else \"No\"\n fun Double.toNaturalExpr() = println(\"%f\".format(this))\n}", "language": "Kotlin", "metadata": {"date": 1588558121, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02690.html", "problem_id": "p02690", "resource_group": "medium_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/Kotlin/s308011180.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s308011180", "user_id": "u981616728"}, "prompt_components": {"gold_output": "2 -1\n", "input_to_evaluate": "fun main(args: Array) = ABC166D.main()\n\nobject ABC166D {\n fun log(message: Any?) {\n println(message)// TODO: ←消す\n }\n\n fun main() {\n val X = readInt()\n\n val (al, be) = (1..Int.MAX_VALUE).asSequence().mapNotNull { al ->\n val al2 = al * al\n val al4 = al2 * al2\n if (X % al != 0\n || ((X / al) - al4) % 5 != 0\n ) return@mapNotNull null\n\n val ga = ((X / al) - al4) / 5\n val s = if (ga == 0) 1 else ga\n val beta = (1..al step s).asSequence()\n //.filter { b -> ga % b == 0 }\n .mapNotNull { pb ->\n val pLeft = al2 + pb\n val pRight = ga / pb\n\n val mb = -pb\n val mLeft = al2 + mb\n val mRight = ga / mb\n when {\n (pLeft == pRight) -> pb\n (mLeft == mRight) -> mb\n else -> null\n }\n }.firstOrNull()\n beta?.let { al to it }\n }.first()\n //////\n val D = Math.sqrt((al * al + 4 * be).toDouble()).toInt()\n val A1 = (al + D) / 2\n val A2 = (al - D) / 2\n val B1 = A1 - al\n val B2 = A2 - al\n val ans = when {\n check(A1, B1, X) -> A1 to B1\n check(A2, B2, X) -> A2 to B2\n else -> null\n }\n println(\"${ans?.first} ${ans?.second}\")\n }\n\n fun check(A: Int, B: Int, X: Int) = (A * A * A * A * A - B * B * B * B * B) == X\n\n /*####################################################################################*/\n\n fun readString() = readLine()!!\n fun readStrings() = readLine()!!.split(\" \")\n fun readInt() = readLine()!!.toInt()\n fun readInts() = readLine()!!.split(\" \").map { it.toInt() }\n fun readLong() = readLine()!!.toLong()\n fun readLongs() = readLine()!!.split(\" \").map { it.toLong() }\n fun readMatrixRows(height: Int) = (1..height).map { readLine()!!.toList() }\n\n fun Boolean.yesOrNo() = if (this) \"Yes\" else \"No\"\n fun Double.toNaturalExpr() = println(\"%f\".format(this))\n}", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2180, "cpu_time_ms": 2207, "memory_kb": 37760}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s790451366", "group_id": "codeNet:p02690", "input_text": "import java.io.PrintWriter\nimport java.util.*\nimport java.math.*\nimport java.lang.*\nimport kotlin.comparisons.*\n\nval pw = PrintWriter(System.out)\nval MOD: Long = (1e+9 + 7).toLong()\n\nfun main(args: Array) {\n val x = readLong()\n for(a in -100L .. 100L) {\n for(b in -100L .. 100L) {\n val a5 = (0 until 5).map { a }.reduce { v1, v2 -> v1 * v2 }\n val b5 = (0 until 5).map { b }.reduce { v1, v2 -> v1 * v2 }\n val n = a5 - b5\n if(n == x) {\n println(\"$a $b\")\n break\n }\n }\n }\n\tpw.flush()\n}\n\n/****** Declared Functions and Data Structures ******/\n// IO\nfun read() = readLine()!!\nfun readInt() = read().toInt()\nfun readLong() = read().toLong()\nfun readDouble() = read().toDouble()\nfun readListOfString() = read().split(\" \")\nfun readListOfInt() = readListOfString().map { it.toInt() }\nfun readListOfLong() = readListOfString().map { it.toLong() }\nfun readListOfDouble() = readListOfString().map { it.toDouble() }\n\nfun Double.format(digits: Int) = String.format(\"%.${digits}f\", this)\nfun Float.format(digits: Int) = String.format(\"%.${digits}f\", this)\n\nfun print(value: Any) { pw.print(value) }\nfun println(value : Any) { pw.println(value) }\n\n// Extensions\nfun List.toBuckets(): Map\n\t= this.groupBy { it }.mapValues { it.value.size }\n\nfun> List.upperBound(element: T, fromIndex: Int=0, toIndex: Int=this.size): Int {\n\tvar l = fromIndex\n\tvar r = toIndex\n\twhile(l < r) {\n\t\tval mid = (l+r) / 2\n\t\tif(element >= this[mid]) { \n\t\t\tl = mid + 1\n\t\t} else {\n\t\t\tr = mid\n\t\t}\n\t}\n\treturn l\n}\n\nfun> List.lowerBound(element: T, fromIndex: Int=0, toIndex: Int=this.size): Int {\n\tvar l = fromIndex\n\tvar r = toIndex\n\twhile(l < r) {\n\t\tval mid = (l+r) / 2\n\t\tif(element <= this[mid]) { \n\t\t\tr = mid\n\t\t} else {\n\t\t\tl = mid + 1\n\t\t}\n\t}\n\treturn r \n}\n\nfun Map.toMutableMap(): MutableMap = HashMap(this)\n\n// Util Functions\nfun Long.makeDivisors(): List {\n\tval divisors = mutableListOf()\n\tfor(i in 1L .. Math.sqrt(this.toDouble()).toLong()+1L) {\n\t\tif(this % i == 0L) {\n\t\t\tdivisors.add(i)\n\t\t\tif(i != this/i) {\n\t\t\t\tdivisors.add(this/i)\n\t\t\t}\n\t\t}\n\t}\n\treturn divisors.distinct().sorted()\n}\n\nfun Long.isPrime(): Boolean {\n\tif(this==1L) return false\n\tfor(i in 2L .. Math.sqrt(this.toDouble()).toLong() + 1L) {\n\t\tif(this % i == 0L && this != i) {\n\t\t\treturn false\n\t\t}\n\t}\n\treturn true\n}\n\n\nfun permutations(src: List): List> {\n\tif(src.size == 1) return listOf(src)\n\tval perms = mutableListOf>()\n\tval insertElement = src[0]\n\tpermutations(src.drop(1)).forEach { perm ->\n\t\tfor(i in 0..perm.size) {\n\t\t\tval newPerm = perm.toMutableList()\n\t\t\tnewPerm.add(i, insertElement)\n\t\t\tperms.add(newPerm.toList())\n\t\t}\n\t}\n\treturn perms\n}\n\n// return nCr, if you want nCr, please access v[n][r]\nfun combinations(n: Long): List> {\n\tval v = (0..n).map { (0..n).map{0L}.toMutableList() }.toMutableList()\n\tfor(i in 0 until v.size) {\n\t\tv[i][0] = 1L\n\t\tv[i][i] = 1L\n\t}\n\tfor(i in 0 until v.size) {\n\t\tfor(j in 1 until i) {\n\t\t\tv[i][j] = (v[i-1][j-1] + v[i-1][j]) % MOD\n\t\t}\n\t}\n\treturn v.map { it.toList() }.toList()\n}\n\nfun repeatedModPow(a: Long, n: Long, mod: Long): Long = \n\twhen {\n\t\tn == 0L -> 1L\n\t\tn == 1L -> a % mod\n\t\tn % 2L == 1L -> (a * repeatedModPow(a, n-1L, mod)) % mod\n\t\telse -> {\n\t\t\tval tmp = repeatedModPow(a, n / 2L, mod)\n\t\t\t(tmp * tmp) % mod\n\t\t}\n\t}\n\n// return nCr % MOD\nfun modnCkWithoutArray(n: Long, k: Long, mod: Long): Long {\n\tvar ret = 1L\n\tval min = Math.min(k, n-k)\n\t// まず分母の計算\n\tfor(i in n downTo (n - min + 1)) {\n\t\tret = ret * i % mod\n\t}\n\tfor(i in min downTo 1) {\n\t\tret = ret * repeatedModPow(i, (mod - 2L), mod) % mod\n\t}\n\treturn ret\n}\n\n// return nCr % MOD\nfun modnCk(n: Int, k: Int, mod: Long): Long {\n\tval factorials = Array(n+1) { 0L }.apply {\n\t\tthis[0] = 1L\n\t\tif(this.size > 1) this[1] = 1L\n\t}\n\tval inverses = Array(n+1) { 0L }.apply {\n\t\tthis[0] = 1L\n\t\tif(this.size > 1) this[1] = 1L\n\t}\n\tval factorialInverses = Array(n+1) { 0L }.apply {\n\t\tthis[0] = 1L\n\t\tif(this.size > 1) this[1] = 1L\n\t}\n\tfor(i in 2 .. n) {\n\t\tfactorials[i] = (factorials[i-1] * i.toLong() % mod)\n\t\tinverses[i] = (mod - inverses[mod.toInt() % i] * (mod / i.toLong()) % mod)\n\t\tfactorialInverses[i] = (factorialInverses[i-1] * inverses[i] % mod)\n\t}\n\n\treturn factorials[n] % mod * (factorialInverses[k] * factorialInverses[n-k] % mod) % mod\n}\n\n// should be a >= b\nfun gcd(a: Long, b: Long): Long = \n\tif(b == 0L) a else gcd(b, a % b)\n\n// shoud be a >= b\nfun lcm(a: Long, b: Long): Long = \n\ta / gcd(a, b) * b\n\nfun sumDigits(num_: Long): Long {\n\tvar num = num_\n\tvar rtn: Long = 0\n\twhile(num != 0.toLong()) {\n\t\tval tmp = num % 10\n\t\trtn += tmp\n\t\tnum /= 10\n\t}\n\treturn rtn\n}\n\nfun Double.isDecimal(): Boolean = ((this - Math.floor(this)) != 0.0)\n\n// Data Structures\n\nclass UnionFind(private val n: Int) {\n\tprivate val parent: Array = Array(n) { 0 }\n\tprivate val rank: Array = Array(n) { 0 }\n\tprivate val size: Array = Array(n) { 0 }\n\n\tinit {\n\t\tfor(i in 0 until n) {\n\t\t\tparent[i] = i\n\t\t\trank[i] = 1\n\t\t\tsize[i] = 1\n\t\t}\n\t}\n\n\tfun union(u: Int, v: Int) {\n\t\tvar x = root(u)\n\t\tvar y = root(v)\n\t\tif(x != y) {\n\t\t\tif(rank[y] < rank[x]) {\n\t\t\t\tval tmp = y \n\t\t\t\ty = x\n\t\t\t\tx = tmp \n\t\t\t}\n\t\t\tparent[x] = y\n\t\t\trank[y] += rank[x]\n\t\t\trank[x] = -1\n\t\t\tval totalSize = size[x] + size[y]\n\t\t\tsize[x] = totalSize\n\t\t\tsize[y] = totalSize\n\t\t}\n\t}\n\n\tfun root(u: Int): Int {\n\t\tvar x = u\n\t\twhile(parent[x] != x) {\n\t\t\tx = parent[x]\n\t\t}\n\t\treturn x \n\t}\n\n\tfun size(u: Int): Int = size[root(u)]\n}\n", "language": "Kotlin", "metadata": {"date": 1588555441, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02690.html", "problem_id": "p02690", "resource_group": "medium_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/Kotlin/s790451366.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s790451366", "user_id": "u026686258"}, "prompt_components": {"gold_output": "2 -1\n", "input_to_evaluate": "import java.io.PrintWriter\nimport java.util.*\nimport java.math.*\nimport java.lang.*\nimport kotlin.comparisons.*\n\nval pw = PrintWriter(System.out)\nval MOD: Long = (1e+9 + 7).toLong()\n\nfun main(args: Array) {\n val x = readLong()\n for(a in -100L .. 100L) {\n for(b in -100L .. 100L) {\n val a5 = (0 until 5).map { a }.reduce { v1, v2 -> v1 * v2 }\n val b5 = (0 until 5).map { b }.reduce { v1, v2 -> v1 * v2 }\n val n = a5 - b5\n if(n == x) {\n println(\"$a $b\")\n break\n }\n }\n }\n\tpw.flush()\n}\n\n/****** Declared Functions and Data Structures ******/\n// IO\nfun read() = readLine()!!\nfun readInt() = read().toInt()\nfun readLong() = read().toLong()\nfun readDouble() = read().toDouble()\nfun readListOfString() = read().split(\" \")\nfun readListOfInt() = readListOfString().map { it.toInt() }\nfun readListOfLong() = readListOfString().map { it.toLong() }\nfun readListOfDouble() = readListOfString().map { it.toDouble() }\n\nfun Double.format(digits: Int) = String.format(\"%.${digits}f\", this)\nfun Float.format(digits: Int) = String.format(\"%.${digits}f\", this)\n\nfun print(value: Any) { pw.print(value) }\nfun println(value : Any) { pw.println(value) }\n\n// Extensions\nfun List.toBuckets(): Map\n\t= this.groupBy { it }.mapValues { it.value.size }\n\nfun> List.upperBound(element: T, fromIndex: Int=0, toIndex: Int=this.size): Int {\n\tvar l = fromIndex\n\tvar r = toIndex\n\twhile(l < r) {\n\t\tval mid = (l+r) / 2\n\t\tif(element >= this[mid]) { \n\t\t\tl = mid + 1\n\t\t} else {\n\t\t\tr = mid\n\t\t}\n\t}\n\treturn l\n}\n\nfun> List.lowerBound(element: T, fromIndex: Int=0, toIndex: Int=this.size): Int {\n\tvar l = fromIndex\n\tvar r = toIndex\n\twhile(l < r) {\n\t\tval mid = (l+r) / 2\n\t\tif(element <= this[mid]) { \n\t\t\tr = mid\n\t\t} else {\n\t\t\tl = mid + 1\n\t\t}\n\t}\n\treturn r \n}\n\nfun Map.toMutableMap(): MutableMap = HashMap(this)\n\n// Util Functions\nfun Long.makeDivisors(): List {\n\tval divisors = mutableListOf()\n\tfor(i in 1L .. Math.sqrt(this.toDouble()).toLong()+1L) {\n\t\tif(this % i == 0L) {\n\t\t\tdivisors.add(i)\n\t\t\tif(i != this/i) {\n\t\t\t\tdivisors.add(this/i)\n\t\t\t}\n\t\t}\n\t}\n\treturn divisors.distinct().sorted()\n}\n\nfun Long.isPrime(): Boolean {\n\tif(this==1L) return false\n\tfor(i in 2L .. Math.sqrt(this.toDouble()).toLong() + 1L) {\n\t\tif(this % i == 0L && this != i) {\n\t\t\treturn false\n\t\t}\n\t}\n\treturn true\n}\n\n\nfun permutations(src: List): List> {\n\tif(src.size == 1) return listOf(src)\n\tval perms = mutableListOf>()\n\tval insertElement = src[0]\n\tpermutations(src.drop(1)).forEach { perm ->\n\t\tfor(i in 0..perm.size) {\n\t\t\tval newPerm = perm.toMutableList()\n\t\t\tnewPerm.add(i, insertElement)\n\t\t\tperms.add(newPerm.toList())\n\t\t}\n\t}\n\treturn perms\n}\n\n// return nCr, if you want nCr, please access v[n][r]\nfun combinations(n: Long): List> {\n\tval v = (0..n).map { (0..n).map{0L}.toMutableList() }.toMutableList()\n\tfor(i in 0 until v.size) {\n\t\tv[i][0] = 1L\n\t\tv[i][i] = 1L\n\t}\n\tfor(i in 0 until v.size) {\n\t\tfor(j in 1 until i) {\n\t\t\tv[i][j] = (v[i-1][j-1] + v[i-1][j]) % MOD\n\t\t}\n\t}\n\treturn v.map { it.toList() }.toList()\n}\n\nfun repeatedModPow(a: Long, n: Long, mod: Long): Long = \n\twhen {\n\t\tn == 0L -> 1L\n\t\tn == 1L -> a % mod\n\t\tn % 2L == 1L -> (a * repeatedModPow(a, n-1L, mod)) % mod\n\t\telse -> {\n\t\t\tval tmp = repeatedModPow(a, n / 2L, mod)\n\t\t\t(tmp * tmp) % mod\n\t\t}\n\t}\n\n// return nCr % MOD\nfun modnCkWithoutArray(n: Long, k: Long, mod: Long): Long {\n\tvar ret = 1L\n\tval min = Math.min(k, n-k)\n\t// まず分母の計算\n\tfor(i in n downTo (n - min + 1)) {\n\t\tret = ret * i % mod\n\t}\n\tfor(i in min downTo 1) {\n\t\tret = ret * repeatedModPow(i, (mod - 2L), mod) % mod\n\t}\n\treturn ret\n}\n\n// return nCr % MOD\nfun modnCk(n: Int, k: Int, mod: Long): Long {\n\tval factorials = Array(n+1) { 0L }.apply {\n\t\tthis[0] = 1L\n\t\tif(this.size > 1) this[1] = 1L\n\t}\n\tval inverses = Array(n+1) { 0L }.apply {\n\t\tthis[0] = 1L\n\t\tif(this.size > 1) this[1] = 1L\n\t}\n\tval factorialInverses = Array(n+1) { 0L }.apply {\n\t\tthis[0] = 1L\n\t\tif(this.size > 1) this[1] = 1L\n\t}\n\tfor(i in 2 .. n) {\n\t\tfactorials[i] = (factorials[i-1] * i.toLong() % mod)\n\t\tinverses[i] = (mod - inverses[mod.toInt() % i] * (mod / i.toLong()) % mod)\n\t\tfactorialInverses[i] = (factorialInverses[i-1] * inverses[i] % mod)\n\t}\n\n\treturn factorials[n] % mod * (factorialInverses[k] * factorialInverses[n-k] % mod) % mod\n}\n\n// should be a >= b\nfun gcd(a: Long, b: Long): Long = \n\tif(b == 0L) a else gcd(b, a % b)\n\n// shoud be a >= b\nfun lcm(a: Long, b: Long): Long = \n\ta / gcd(a, b) * b\n\nfun sumDigits(num_: Long): Long {\n\tvar num = num_\n\tvar rtn: Long = 0\n\twhile(num != 0.toLong()) {\n\t\tval tmp = num % 10\n\t\trtn += tmp\n\t\tnum /= 10\n\t}\n\treturn rtn\n}\n\nfun Double.isDecimal(): Boolean = ((this - Math.floor(this)) != 0.0)\n\n// Data Structures\n\nclass UnionFind(private val n: Int) {\n\tprivate val parent: Array = Array(n) { 0 }\n\tprivate val rank: Array = Array(n) { 0 }\n\tprivate val size: Array = Array(n) { 0 }\n\n\tinit {\n\t\tfor(i in 0 until n) {\n\t\t\tparent[i] = i\n\t\t\trank[i] = 1\n\t\t\tsize[i] = 1\n\t\t}\n\t}\n\n\tfun union(u: Int, v: Int) {\n\t\tvar x = root(u)\n\t\tvar y = root(v)\n\t\tif(x != y) {\n\t\t\tif(rank[y] < rank[x]) {\n\t\t\t\tval tmp = y \n\t\t\t\ty = x\n\t\t\t\tx = tmp \n\t\t\t}\n\t\t\tparent[x] = y\n\t\t\trank[y] += rank[x]\n\t\t\trank[x] = -1\n\t\t\tval totalSize = size[x] + size[y]\n\t\t\tsize[x] = totalSize\n\t\t\tsize[y] = totalSize\n\t\t}\n\t}\n\n\tfun root(u: Int): Int {\n\t\tvar x = u\n\t\twhile(parent[x] != x) {\n\t\t\tx = parent[x]\n\t\t}\n\t\treturn x \n\t}\n\n\tfun size(u: Int): Int = size[root(u)]\n}\n", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 5519, "cpu_time_ms": 222, "memory_kb": 54844}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s902631904", "group_id": "codeNet:p02691", "input_text": "fun main() {\n var min = 0\n var max = 0\n val n = readLine()!!.toInt()\n val a = readLine()!!.split(' ').map { it .toInt() }\n var mapL: MutableMap = mutableMapOf()\n var mapR: MutableMap = mutableMapOf()\n a.forEachIndexed { idx, value ->\n val l = idx-value\n val r = idx+value\n if (!mapL.containsKey(l)) mapL[l] = 0\n if (!mapR.containsKey(r)) mapR[r] = 0\n mapL[l] = mapL[l]!!+1\n mapR[r] = mapR[r]!!+1\n min = Math.min(min, l)\n max = Math.max(max, r)\n }\n var cnt = 0\n for (x in min..max) {\n if (mapL.containsKey(x) && mapR.containsKey(x)) cnt += mapL[x]!!*mapR[x]!!\n }\n println(cnt)\n}\n", "language": "Kotlin", "metadata": {"date": 1588571957, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02691.html", "problem_id": "p02691", "resource_group": "medium_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/Kotlin/s902631904.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s902631904", "user_id": "u213256030"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "fun main() {\n var min = 0\n var max = 0\n val n = readLine()!!.toInt()\n val a = readLine()!!.split(' ').map { it .toInt() }\n var mapL: MutableMap = mutableMapOf()\n var mapR: MutableMap = mutableMapOf()\n a.forEachIndexed { idx, value ->\n val l = idx-value\n val r = idx+value\n if (!mapL.containsKey(l)) mapL[l] = 0\n if (!mapR.containsKey(r)) mapR[r] = 0\n mapL[l] = mapL[l]!!+1\n mapR[r] = mapR[r]!!+1\n min = Math.min(min, l)\n max = Math.max(max, r)\n }\n var cnt = 0\n for (x in min..max) {\n if (mapL.containsKey(x) && mapR.containsKey(x)) cnt += mapL[x]!!*mapR[x]!!\n }\n println(cnt)\n}\n", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 2208, "memory_kb": 95044}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s090930392", "group_id": "codeNet:p02691", "input_text": "fun main() {\n val n = readLine()!!.toInt()\n val a = readLine()!!.split(' ').map { it.toInt() }\n\n val m = mutableMapOf>()\n for (i in a.indices) {\n if (a[i] >= n) continue\n m[a[i]] = m[a[i]] ?: mutableSetOf()\n m[a[i]]!!.add(i)\n }\n\n var ans = 0L\n\n for (i in m.keys) {\n for (j in m.keys) {\n val s = i + j\n if (s >= n) continue\n\n for (k in m[i]!!) {\n if (m[j]!!.contains(k + s)) ans++\n }\n }\n }\n\n println(ans)\n}\n", "language": "Kotlin", "metadata": {"date": 1588559600, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02691.html", "problem_id": "p02691", "resource_group": "medium_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/Kotlin/s090930392.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s090930392", "user_id": "u863309603"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "fun main() {\n val n = readLine()!!.toInt()\n val a = readLine()!!.split(' ').map { it.toInt() }\n\n val m = mutableMapOf>()\n for (i in a.indices) {\n if (a[i] >= n) continue\n m[a[i]] = m[a[i]] ?: mutableSetOf()\n m[a[i]]!!.add(i)\n }\n\n var ans = 0L\n\n for (i in m.keys) {\n for (j in m.keys) {\n val s = i + j\n if (s >= n) continue\n\n for (k in m[i]!!) {\n if (m[j]!!.contains(k + s)) ans++\n }\n }\n }\n\n println(ans)\n}\n", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 548, "cpu_time_ms": 2211, "memory_kb": 136000}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s049850828", "group_id": "codeNet:p02691", "input_text": "import java.util.Scanner\n\nfun main() {\n\tval scn = Scanner(System.`in`)\n\tval n = scn.nextInt()\n\tval a = IntArray(n){scn.nextInt()}\n\tvar cnt = 0L\n\tval s = a.mapIndexed{i,v -> i-v}.sorted()\n\tfor (i in a.indices){\n\t\tval t = a[i]+i\n\t\tvar jidx = s.binarySearch(t)\n\t\tval tmp = jidx\n\t\tif (jidx<0) continue\n\t\twhile(jidx=0 && s[jidx]==t){\n\t\t\tcnt++\n\t\t\tjidx--\n\t\t}\n\t}\n\tprintln(cnt)\n}", "language": "Kotlin", "metadata": {"date": 1588558501, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02691.html", "problem_id": "p02691", "resource_group": "medium_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/Kotlin/s049850828.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s049850828", "user_id": "u914590612"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "import java.util.Scanner\n\nfun main() {\n\tval scn = Scanner(System.`in`)\n\tval n = scn.nextInt()\n\tval a = IntArray(n){scn.nextInt()}\n\tvar cnt = 0L\n\tval s = a.mapIndexed{i,v -> i-v}.sorted()\n\tfor (i in a.indices){\n\t\tval t = a[i]+i\n\t\tvar jidx = s.binarySearch(t)\n\t\tval tmp = jidx\n\t\tif (jidx<0) continue\n\t\twhile(jidx=0 && s[jidx]==t){\n\t\t\tcnt++\n\t\t\tjidx--\n\t\t}\n\t}\n\tprintln(cnt)\n}", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 440, "cpu_time_ms": 2208, "memory_kb": 66412}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s548271866", "group_id": "codeNet:p02691", "input_text": "fun main(args: Array) {\n val n = readLine()!!.toInt()\n val a = readLine()!!.split(' ').map { it.toInt() }\n\n var ans = 0\n for (i in 0 .. n-2) {\n for (j in i+1 .. n-1) {\n val sum = a[i] + a[j]\n val sub = Math.abs(i-j)\n if (sum == sub) ans++\n }\n }\n\n println(ans)\n\n}\n", "language": "Kotlin", "metadata": {"date": 1588556765, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02691.html", "problem_id": "p02691", "resource_group": "medium_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/Kotlin/s548271866.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s548271866", "user_id": "u288435405"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "fun main(args: Array) {\n val n = readLine()!!.toInt()\n val a = readLine()!!.split(' ').map { it.toInt() }\n\n var ans = 0\n for (i in 0 .. n-2) {\n for (j in i+1 .. n-1) {\n val sum = a[i] + a[j]\n val sub = Math.abs(i-j)\n if (sum == sub) ans++\n }\n }\n\n println(ans)\n\n}\n", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 336, "cpu_time_ms": 2208, "memory_kb": 65380}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s651376388", "group_id": "codeNet:p02693", "input_text": "fun main(args: Array) {\n\tval k = readLine()!!.toInt()\n \tval (a, b) = readLine()!!.split(\" \").map(String::toInt)\n \tvar i = 0\n \tvar flg = 0\n \n \tval count = 1000 / k\n \n \tfor (i in 0..count) {\n \tval len = i * k\n \tif(len >= a && len <= b) {\n \tprint(\"OK\")\n \tflg = 1\n \tbreak;\n }\n }\n \tif (flg == 0) {\n \tprint(\"NG\") \n }\n}", "language": "Kotlin", "metadata": {"date": 1588470343, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02693.html", "problem_id": "p02693", "resource_group": "medium_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/Kotlin/s651376388.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s651376388", "user_id": "u584667718"}, "prompt_components": {"gold_output": "OK\n", "input_to_evaluate": "fun main(args: Array) {\n\tval k = readLine()!!.toInt()\n \tval (a, b) = readLine()!!.split(\" \").map(String::toInt)\n \tvar i = 0\n \tvar flg = 0\n \n \tval count = 1000 / k\n \n \tfor (i in 0..count) {\n \tval len = i * k\n \tif(len >= a && len <= b) {\n \tprint(\"OK\")\n \tflg = 1\n \tbreak;\n }\n }\n \tif (flg == 0) {\n \tprint(\"NG\") \n }\n}", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 379, "cpu_time_ms": 97, "memory_kb": 36304}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s574837128", "group_id": "codeNet:p02694", "input_text": "import java.math.BigDecimal\n\nfun main() {\n var x = readLine()!!.toBigDecimal()\n\n var interest = 1.01.toBigDecimal()\n val hund = 100.toBigDecimal()\n var result = 0.toBigDecimal()\n var depo = 100.toBigDecimal()\n\n run loop@{\n while(true){\n depo = (depo * interest).setScale(0,BigDecimal.ROUND_DOWN)\n result += 1.toBigDecimal()\n if(depo >= x){\n return@loop\n }\n\n }\n }\n\n\n\n\n println(result)\n}", "language": "Kotlin", "metadata": {"date": 1588473564, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02694.html", "problem_id": "p02694", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02694/input.txt", "sample_output_relpath": "derived/input_output/data/p02694/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02694/Kotlin/s574837128.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s574837128", "user_id": "u430710262"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "import java.math.BigDecimal\n\nfun main() {\n var x = readLine()!!.toBigDecimal()\n\n var interest = 1.01.toBigDecimal()\n val hund = 100.toBigDecimal()\n var result = 0.toBigDecimal()\n var depo = 100.toBigDecimal()\n\n run loop@{\n while(true){\n depo = (depo * interest).setScale(0,BigDecimal.ROUND_DOWN)\n result += 1.toBigDecimal()\n if(depo >= x){\n return@loop\n }\n\n }\n }\n\n\n\n\n println(result)\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nTakahashi has a deposit of 100 yen (the currency of Japan) in AtCoder Bank.\n\nThe bank pays an annual interest rate of 1 % compounded annually. (A fraction of less than one yen is discarded.)\n\nAssuming that nothing other than the interest affects Takahashi's balance, in how many years does the balance reach X yen or above for the first time?\n\nConstraints\n\n101 \\le X \\le 10^{18}\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 number of years it takes for Takahashi's balance to reach X yen or above for the first time.\n\nSample Input 1\n\n103\n\nSample Output 1\n\n3\n\nThe balance after one year is 101 yen.\n\nThe balance after two years is 102 yen.\n\nThe balance after three years is 103 yen.\n\nThus, it takes three years for the balance to reach 103 yen or above.\n\nSample Input 2\n\n1000000000000000000\n\nSample Output 2\n\n3760\n\nSample Input 3\n\n1333333333\n\nSample Output 3\n\n1706", "sample_input": "103\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02694", "source_text": "Score : 200 points\n\nProblem Statement\n\nTakahashi has a deposit of 100 yen (the currency of Japan) in AtCoder Bank.\n\nThe bank pays an annual interest rate of 1 % compounded annually. (A fraction of less than one yen is discarded.)\n\nAssuming that nothing other than the interest affects Takahashi's balance, in how many years does the balance reach X yen or above for the first time?\n\nConstraints\n\n101 \\le X \\le 10^{18}\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 number of years it takes for Takahashi's balance to reach X yen or above for the first time.\n\nSample Input 1\n\n103\n\nSample Output 1\n\n3\n\nThe balance after one year is 101 yen.\n\nThe balance after two years is 102 yen.\n\nThe balance after three years is 103 yen.\n\nThus, it takes three years for the balance to reach 103 yen or above.\n\nSample Input 2\n\n1000000000000000000\n\nSample Output 2\n\n3760\n\nSample Input 3\n\n1333333333\n\nSample Output 3\n\n1706", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 96, "memory_kb": 35444}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s622486056", "group_id": "codeNet:p02694", "input_text": "\n\nimport kotlin.math.* \nfun main(args : Array){\n var k: Long = readLine()!!.toLong()\n \n var zandaka:Long = 100\n for (i in 1..k){\n zandaka = (floor(zandaka.toDouble() * 1.01)).toLong()\n if (zandaka > k){\n print(i.toString())\n break\n }\n }\n}", "language": "Kotlin", "metadata": {"date": 1588473212, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02694.html", "problem_id": "p02694", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02694/input.txt", "sample_output_relpath": "derived/input_output/data/p02694/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02694/Kotlin/s622486056.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s622486056", "user_id": "u803742109"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "\n\nimport kotlin.math.* \nfun main(args : Array){\n var k: Long = readLine()!!.toLong()\n \n var zandaka:Long = 100\n for (i in 1..k){\n zandaka = (floor(zandaka.toDouble() * 1.01)).toLong()\n if (zandaka > k){\n print(i.toString())\n break\n }\n }\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nTakahashi has a deposit of 100 yen (the currency of Japan) in AtCoder Bank.\n\nThe bank pays an annual interest rate of 1 % compounded annually. (A fraction of less than one yen is discarded.)\n\nAssuming that nothing other than the interest affects Takahashi's balance, in how many years does the balance reach X yen or above for the first time?\n\nConstraints\n\n101 \\le X \\le 10^{18}\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 number of years it takes for Takahashi's balance to reach X yen or above for the first time.\n\nSample Input 1\n\n103\n\nSample Output 1\n\n3\n\nThe balance after one year is 101 yen.\n\nThe balance after two years is 102 yen.\n\nThe balance after three years is 103 yen.\n\nThus, it takes three years for the balance to reach 103 yen or above.\n\nSample Input 2\n\n1000000000000000000\n\nSample Output 2\n\n3760\n\nSample Input 3\n\n1333333333\n\nSample Output 3\n\n1706", "sample_input": "103\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02694", "source_text": "Score : 200 points\n\nProblem Statement\n\nTakahashi has a deposit of 100 yen (the currency of Japan) in AtCoder Bank.\n\nThe bank pays an annual interest rate of 1 % compounded annually. (A fraction of less than one yen is discarded.)\n\nAssuming that nothing other than the interest affects Takahashi's balance, in how many years does the balance reach X yen or above for the first time?\n\nConstraints\n\n101 \\le X \\le 10^{18}\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 number of years it takes for Takahashi's balance to reach X yen or above for the first time.\n\nSample Input 1\n\n103\n\nSample Output 1\n\n3\n\nThe balance after one year is 101 yen.\n\nThe balance after two years is 102 yen.\n\nThe balance after three years is 103 yen.\n\nThus, it takes three years for the balance to reach 103 yen or above.\n\nSample Input 2\n\n1000000000000000000\n\nSample Output 2\n\n3760\n\nSample Input 3\n\n1333333333\n\nSample Output 3\n\n1706", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 305, "cpu_time_ms": 85, "memory_kb": 34496}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s901661162", "group_id": "codeNet:p02694", "input_text": "fun main(args: Array){\n val X = readLine()!!.toLong()\n var motohyaku:Double = 100.0\n var nensuu = 0\n\n while (X > motohyaku){\n motohyaku = Math.floor(motohyaku * 1.01)\n nensuu += 1\n }\n println(nensuu)\n}", "language": "Kotlin", "metadata": {"date": 1588469123, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02694.html", "problem_id": "p02694", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02694/input.txt", "sample_output_relpath": "derived/input_output/data/p02694/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02694/Kotlin/s901661162.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s901661162", "user_id": "u856032619"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "fun main(args: Array){\n val X = readLine()!!.toLong()\n var motohyaku:Double = 100.0\n var nensuu = 0\n\n while (X > motohyaku){\n motohyaku = Math.floor(motohyaku * 1.01)\n nensuu += 1\n }\n println(nensuu)\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nTakahashi has a deposit of 100 yen (the currency of Japan) in AtCoder Bank.\n\nThe bank pays an annual interest rate of 1 % compounded annually. (A fraction of less than one yen is discarded.)\n\nAssuming that nothing other than the interest affects Takahashi's balance, in how many years does the balance reach X yen or above for the first time?\n\nConstraints\n\n101 \\le X \\le 10^{18}\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 number of years it takes for Takahashi's balance to reach X yen or above for the first time.\n\nSample Input 1\n\n103\n\nSample Output 1\n\n3\n\nThe balance after one year is 101 yen.\n\nThe balance after two years is 102 yen.\n\nThe balance after three years is 103 yen.\n\nThus, it takes three years for the balance to reach 103 yen or above.\n\nSample Input 2\n\n1000000000000000000\n\nSample Output 2\n\n3760\n\nSample Input 3\n\n1333333333\n\nSample Output 3\n\n1706", "sample_input": "103\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02694", "source_text": "Score : 200 points\n\nProblem Statement\n\nTakahashi has a deposit of 100 yen (the currency of Japan) in AtCoder Bank.\n\nThe bank pays an annual interest rate of 1 % compounded annually. (A fraction of less than one yen is discarded.)\n\nAssuming that nothing other than the interest affects Takahashi's balance, in how many years does the balance reach X yen or above for the first time?\n\nConstraints\n\n101 \\le X \\le 10^{18}\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 number of years it takes for Takahashi's balance to reach X yen or above for the first time.\n\nSample Input 1\n\n103\n\nSample Output 1\n\n3\n\nThe balance after one year is 101 yen.\n\nThe balance after two years is 102 yen.\n\nThe balance after three years is 103 yen.\n\nThus, it takes three years for the balance to reach 103 yen or above.\n\nSample Input 2\n\n1000000000000000000\n\nSample Output 2\n\n3760\n\nSample Input 3\n\n1333333333\n\nSample Output 3\n\n1706", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 241, "cpu_time_ms": 82, "memory_kb": 34408}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s923409766", "group_id": "codeNet:p02696", "input_text": "import java.util.*\nimport kotlin.math.floor\n\nval sc = Scanner(System.`in`)\n\nfun main(args: Array) {\n\n val A = sc.nextLong().toDouble()\n val B = sc.nextLong().toDouble()\n val N = sc.nextLong().toDouble()\n\n val x = if(N < B - 1) N else B - 1\n val ans = floor(A * x / B) - A * floor(x / B)\n println(ans.toInt())\n}\n\n", "language": "Kotlin", "metadata": {"date": 1589075848, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02696.html", "problem_id": "p02696", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02696/input.txt", "sample_output_relpath": "derived/input_output/data/p02696/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02696/Kotlin/s923409766.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s923409766", "user_id": "u105098339"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import java.util.*\nimport kotlin.math.floor\n\nval sc = Scanner(System.`in`)\n\nfun main(args: Array) {\n\n val A = sc.nextLong().toDouble()\n val B = sc.nextLong().toDouble()\n val N = sc.nextLong().toDouble()\n\n val x = if(N < B - 1) N else B - 1\n val ans = floor(A * x / B) - A * floor(x / B)\n println(ans.toInt())\n}\n\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nGiven are integers A, B, and N.\n\nFind the maximum possible value of floor(Ax/B) - A × floor(x/B) for a non-negative integer x not greater than N.\n\nHere floor(t) denotes the greatest integer not greater than the real number t.\n\nConstraints\n\n1 ≤ A ≤ 10^{6}\n\n1 ≤ B ≤ 10^{12}\n\n1 ≤ N ≤ 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 N\n\nOutput\n\nPrint the maximum possible value of floor(Ax/B) - A × floor(x/B) for a non-negative integer x not greater than N, as an integer.\n\nSample Input 1\n\n5 7 4\n\nSample Output 1\n\n2\n\nWhen x=3, floor(Ax/B)-A×floor(x/B) = floor(15/7) - 5×floor(3/7) = 2. This is the maximum value possible.\n\nSample Input 2\n\n11 10 9\n\nSample Output 2\n\n9", "sample_input": "5 7 4\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02696", "source_text": "Score : 400 points\n\nProblem Statement\n\nGiven are integers A, B, and N.\n\nFind the maximum possible value of floor(Ax/B) - A × floor(x/B) for a non-negative integer x not greater than N.\n\nHere floor(t) denotes the greatest integer not greater than the real number t.\n\nConstraints\n\n1 ≤ A ≤ 10^{6}\n\n1 ≤ B ≤ 10^{12}\n\n1 ≤ N ≤ 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 N\n\nOutput\n\nPrint the maximum possible value of floor(Ax/B) - A × floor(x/B) for a non-negative integer x not greater than N, as an integer.\n\nSample Input 1\n\n5 7 4\n\nSample Output 1\n\n2\n\nWhen x=3, floor(Ax/B)-A×floor(x/B) = floor(15/7) - 5×floor(3/7) = 2. This is the maximum value possible.\n\nSample Input 2\n\n11 10 9\n\nSample Output 2\n\n9", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 338, "cpu_time_ms": 116, "memory_kb": 36512}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s238807881", "group_id": "codeNet:p02696", "input_text": "\nfun main(args: Array) {\n val (A, B, N) = readLine()!!.split(\" \").map(String::toLong)\n\n val n = N / B\n if(n * B <= N && N <= n * B + listOf(B / A, 1L).max()!!) { (N/ B) * B - listOf(Math.floor(B.toDouble()/ A.toDouble()).toLong(), 1).max()!! } else { N }.let {\n (Math.floor(A.toDouble() * it.toDouble() / B.toDouble()) - A.toDouble() * Math.floor(it.toDouble() / B.toDouble())).toLong()\n }.run(::println)\n}", "language": "Kotlin", "metadata": {"date": 1588474468, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02696.html", "problem_id": "p02696", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02696/input.txt", "sample_output_relpath": "derived/input_output/data/p02696/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02696/Kotlin/s238807881.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s238807881", "user_id": "u181807786"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "\nfun main(args: Array) {\n val (A, B, N) = readLine()!!.split(\" \").map(String::toLong)\n\n val n = N / B\n if(n * B <= N && N <= n * B + listOf(B / A, 1L).max()!!) { (N/ B) * B - listOf(Math.floor(B.toDouble()/ A.toDouble()).toLong(), 1).max()!! } else { N }.let {\n (Math.floor(A.toDouble() * it.toDouble() / B.toDouble()) - A.toDouble() * Math.floor(it.toDouble() / B.toDouble())).toLong()\n }.run(::println)\n}", "problem_context": "Score : 400 points\n\nProblem Statement\n\nGiven are integers A, B, and N.\n\nFind the maximum possible value of floor(Ax/B) - A × floor(x/B) for a non-negative integer x not greater than N.\n\nHere floor(t) denotes the greatest integer not greater than the real number t.\n\nConstraints\n\n1 ≤ A ≤ 10^{6}\n\n1 ≤ B ≤ 10^{12}\n\n1 ≤ N ≤ 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 N\n\nOutput\n\nPrint the maximum possible value of floor(Ax/B) - A × floor(x/B) for a non-negative integer x not greater than N, as an integer.\n\nSample Input 1\n\n5 7 4\n\nSample Output 1\n\n2\n\nWhen x=3, floor(Ax/B)-A×floor(x/B) = floor(15/7) - 5×floor(3/7) = 2. This is the maximum value possible.\n\nSample Input 2\n\n11 10 9\n\nSample Output 2\n\n9", "sample_input": "5 7 4\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02696", "source_text": "Score : 400 points\n\nProblem Statement\n\nGiven are integers A, B, and N.\n\nFind the maximum possible value of floor(Ax/B) - A × floor(x/B) for a non-negative integer x not greater than N.\n\nHere floor(t) denotes the greatest integer not greater than the real number t.\n\nConstraints\n\n1 ≤ A ≤ 10^{6}\n\n1 ≤ B ≤ 10^{12}\n\n1 ≤ N ≤ 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 N\n\nOutput\n\nPrint the maximum possible value of floor(Ax/B) - A × floor(x/B) for a non-negative integer x not greater than N, as an integer.\n\nSample Input 1\n\n5 7 4\n\nSample Output 1\n\n2\n\nWhen x=3, floor(Ax/B)-A×floor(x/B) = floor(15/7) - 5×floor(3/7) = 2. This is the maximum value possible.\n\nSample Input 2\n\n11 10 9\n\nSample Output 2\n\n9", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 441, "cpu_time_ms": 113, "memory_kb": 38992}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s993754103", "group_id": "codeNet:p02696", "input_text": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val a = sc.nextInt()\n val b = sc.nextLong()\n val n = sc.nextLong()\n\n println(abc165d(a, b, n))\n}\n\nprivate fun abc165d(a: Int, b: Long, n: Long): Int {\n val ansList = mutableListOf()\n for (i in 1..n) {\n val tmp = Math.floor(((a * i)/b).toDouble()) - 5 * Math.floor((i/b).toDouble())\n ansList.add(tmp)\n }\n val ans = ansList.max()!!\n return ans.toInt()\n}\n", "language": "Kotlin", "metadata": {"date": 1588473288, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02696.html", "problem_id": "p02696", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02696/input.txt", "sample_output_relpath": "derived/input_output/data/p02696/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02696/Kotlin/s993754103.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s993754103", "user_id": "u323522006"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val a = sc.nextInt()\n val b = sc.nextLong()\n val n = sc.nextLong()\n\n println(abc165d(a, b, n))\n}\n\nprivate fun abc165d(a: Int, b: Long, n: Long): Int {\n val ansList = mutableListOf()\n for (i in 1..n) {\n val tmp = Math.floor(((a * i)/b).toDouble()) - 5 * Math.floor((i/b).toDouble())\n ansList.add(tmp)\n }\n val ans = ansList.max()!!\n return ans.toInt()\n}\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nGiven are integers A, B, and N.\n\nFind the maximum possible value of floor(Ax/B) - A × floor(x/B) for a non-negative integer x not greater than N.\n\nHere floor(t) denotes the greatest integer not greater than the real number t.\n\nConstraints\n\n1 ≤ A ≤ 10^{6}\n\n1 ≤ B ≤ 10^{12}\n\n1 ≤ N ≤ 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 N\n\nOutput\n\nPrint the maximum possible value of floor(Ax/B) - A × floor(x/B) for a non-negative integer x not greater than N, as an integer.\n\nSample Input 1\n\n5 7 4\n\nSample Output 1\n\n2\n\nWhen x=3, floor(Ax/B)-A×floor(x/B) = floor(15/7) - 5×floor(3/7) = 2. This is the maximum value possible.\n\nSample Input 2\n\n11 10 9\n\nSample Output 2\n\n9", "sample_input": "5 7 4\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02696", "source_text": "Score : 400 points\n\nProblem Statement\n\nGiven are integers A, B, and N.\n\nFind the maximum possible value of floor(Ax/B) - A × floor(x/B) for a non-negative integer x not greater than N.\n\nHere floor(t) denotes the greatest integer not greater than the real number t.\n\nConstraints\n\n1 ≤ A ≤ 10^{6}\n\n1 ≤ B ≤ 10^{12}\n\n1 ≤ N ≤ 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 N\n\nOutput\n\nPrint the maximum possible value of floor(Ax/B) - A × floor(x/B) for a non-negative integer x not greater than N, as an integer.\n\nSample Input 1\n\n5 7 4\n\nSample Output 1\n\n2\n\nWhen x=3, floor(Ax/B)-A×floor(x/B) = floor(15/7) - 5×floor(3/7) = 2. This is the maximum value possible.\n\nSample Input 2\n\n11 10 9\n\nSample Output 2\n\n9", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 460, "cpu_time_ms": 2235, "memory_kb": 781016}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s404859866", "group_id": "codeNet:p02697", "input_text": "fun main(args: Array) {\n val (n, m) = readLine()!!.split(' ').map(String::toInt)\n val ansList = mutableListOf>()\n var ll = 1\n var lr = ll + m\n var rl = lr + 1\n var rr = rl + m - 1\n while (ll < lr) {\n ansList.add(Pair(ll++, lr--))\n }\n while (rl < rr) {\n ansList.add(Pair(rl++, rr--))\n }\n\n for (i in 0 until m) {\n println(ansList[i].first.toString() + \" \" + ansList[i].second)\n }\n}", "language": "Kotlin", "metadata": {"date": 1588553293, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02697.html", "problem_id": "p02697", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02697/input.txt", "sample_output_relpath": "derived/input_output/data/p02697/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02697/Kotlin/s404859866.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s404859866", "user_id": "u099066216"}, "prompt_components": {"gold_output": "2 3\n", "input_to_evaluate": "fun main(args: Array) {\n val (n, m) = readLine()!!.split(' ').map(String::toInt)\n val ansList = mutableListOf>()\n var ll = 1\n var lr = ll + m\n var rl = lr + 1\n var rr = rl + m - 1\n while (ll < lr) {\n ansList.add(Pair(ll++, lr--))\n }\n while (rl < rr) {\n ansList.add(Pair(rl++, rr--))\n }\n\n for (i in 0 until m) {\n println(ansList[i].first.toString() + \" \" + ansList[i].second)\n }\n}", "problem_context": "Score : 500 points\n\nProblem Statement\n\nYou are going to hold a competition of one-to-one game called AtCoder Janken. (Janken is the Japanese name for Rock-paper-scissors.)\nN players will participate in this competition, and they are given distinct integers from 1 through N.\nThe arena has M playing fields for two players. You need to assign each playing field two distinct integers between 1 and N (inclusive).\nYou cannot assign the same integer to multiple playing fields.\nThe competition consists of N rounds, each of which proceeds as follows:\n\nFor each player, if there is a playing field that is assigned the player's integer, the player goes to that field and fight the other player who comes there.\n\nThen, each player adds 1 to its integer. If it becomes N+1, change it to 1.\n\nYou want to ensure that no player fights the same opponent more than once during the N rounds.\nPrint an assignment of integers to the playing fields satisfying this condition.\nIt can be proved that such an assignment always exists under the constraints given.\n\nConstraints\n\n1 \\leq M\n\nM \\times 2 +1 \\leq N \\leq 200000\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\n\nOutput\n\nPrint M lines in the format below.\nThe i-th line should contain the two integers a_i and b_i assigned to the i-th playing field.\n\na_1 b_1\na_2 b_2\n:\na_M b_M\n\nSample Input 1\n\n4 1\n\nSample Output 1\n\n2 3\n\nLet us call the four players A, B, C, and D, and assume that they are initially given the integers 1, 2, 3, and 4, respectively.\n\nThe 1-st round is fought by B and C, who has the integers 2 and 3, respectively. After this round, A, B, C, and D have the integers 2, 3, 4, and 1, respectively.\n\nThe 2-nd round is fought by A and B, who has the integers 2 and 3, respectively. After this round, A, B, C, and D have the integers 3, 4, 1, and 2, respectively.\n\nThe 3-rd round is fought by D and A, who has the integers 2 and 3, respectively. After this round, A, B, C, and D have the integers 4, 1, 2, and 3, respectively.\n\nThe 4-th round is fought by C and D, who has the integers 2 and 3, respectively. After this round, A, B, C, and D have the integers 1, 2, 3, and 4, respectively.\n\nNo player fights the same opponent more than once during the four rounds, so this solution will be accepted.\n\nSample Input 2\n\n7 3\n\nSample Output 2\n\n1 6\n2 5\n3 4", "sample_input": "4 1\n"}, "reference_outputs": ["2 3\n"], "source_document_id": "p02697", "source_text": "Score : 500 points\n\nProblem Statement\n\nYou are going to hold a competition of one-to-one game called AtCoder Janken. (Janken is the Japanese name for Rock-paper-scissors.)\nN players will participate in this competition, and they are given distinct integers from 1 through N.\nThe arena has M playing fields for two players. You need to assign each playing field two distinct integers between 1 and N (inclusive).\nYou cannot assign the same integer to multiple playing fields.\nThe competition consists of N rounds, each of which proceeds as follows:\n\nFor each player, if there is a playing field that is assigned the player's integer, the player goes to that field and fight the other player who comes there.\n\nThen, each player adds 1 to its integer. If it becomes N+1, change it to 1.\n\nYou want to ensure that no player fights the same opponent more than once during the N rounds.\nPrint an assignment of integers to the playing fields satisfying this condition.\nIt can be proved that such an assignment always exists under the constraints given.\n\nConstraints\n\n1 \\leq M\n\nM \\times 2 +1 \\leq N \\leq 200000\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\n\nOutput\n\nPrint M lines in the format below.\nThe i-th line should contain the two integers a_i and b_i assigned to the i-th playing field.\n\na_1 b_1\na_2 b_2\n:\na_M b_M\n\nSample Input 1\n\n4 1\n\nSample Output 1\n\n2 3\n\nLet us call the four players A, B, C, and D, and assume that they are initially given the integers 1, 2, 3, and 4, respectively.\n\nThe 1-st round is fought by B and C, who has the integers 2 and 3, respectively. After this round, A, B, C, and D have the integers 2, 3, 4, and 1, respectively.\n\nThe 2-nd round is fought by A and B, who has the integers 2 and 3, respectively. After this round, A, B, C, and D have the integers 3, 4, 1, and 2, respectively.\n\nThe 3-rd round is fought by D and A, who has the integers 2 and 3, respectively. After this round, A, B, C, and D have the integers 4, 1, 2, and 3, respectively.\n\nThe 4-th round is fought by C and D, who has the integers 2 and 3, respectively. After this round, A, B, C, and D have the integers 1, 2, 3, and 4, respectively.\n\nNo player fights the same opponent more than once during the four rounds, so this solution will be accepted.\n\nSample Input 2\n\n7 3\n\nSample Output 2\n\n1 6\n2 5\n3 4", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 612, "memory_kb": 61732}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s894161358", "group_id": "codeNet:p02698", "input_text": "import java.util.*\nimport kotlin.collections.ArrayList\n\nval sc = Scanner(System.`in`)\nfun nextIntArray() = sc.nextLine().split(\" \").map(String::toInt).toTypedArray()\n\nconst val INF = 10000000\n\nvar N = 0\nvar a = Array(0){1}\nvar map = Array(0){ArrayList()}\n// 最大部分増加列のダンプ\nvar dp = Array(0){0}\nvar cnt = 0\nvar ans = Array(0){0}\n\nfun main(args: Array) {\n\n N = sc.nextLine().toInt()\n a = nextIntArray()\n map = Array(N){ArrayList()}\n dp = Array(N){INF}\n ans = Array(N){0}\n\n for(i in 0..N-2){\n val u = sc.nextInt()-1\n val v = sc.nextInt()-1\n map[u].add(v)\n map[v].add(u)\n }\n\n calc(0, -1)\n\n for(t in ans){\n println(t)\n }\n}\n\nfun calc(i: Int, p: Int){\n // 自身のdpに自身の番号を適用する\n val idx = bisearch(dp, cnt, a[i])\n val pre = dp[idx]\n if(pre == INF) cnt++\n dp[idx] = a[i]\n ans[i] = cnt\n // 次の頂点へ再帰呼び出し\n for(j in map[i]){\n if(j == p) continue\n calc(j, i)\n dp[idx] = pre\n if(pre == INF)cnt--\n }\n}\n\n/**\n * 単調増加列arrの部分列[0]~[len-1]に対し、値vが挿入できる位置のインデックスを返す\n * ・二分探索\n * ・arr[len-1], len: Int, v: Int): Int{\n\n var left = 0\n var right = len\n var mid = 0\n while(left < right) {\n mid = (left + right) / 2\n if(arr[mid] < v){\n left = mid + 1\n }else if(arr[mid] > v){\n right = mid - 1\n }else {\n return mid\n }\n }\n\n // ここに来るパターンは2つ\n // 1)最後のループで leftとrightの差が1しかなく(left=mid)、right=mid-1の結果、right()}\n// 最大部分増加列のダンプ\nvar dp = Array(0){0}\nvar cnt = 0\nvar ans = Array(0){0}\n\nfun main(args: Array) {\n\n N = sc.nextLine().toInt()\n a = nextIntArray()\n map = Array(N){ArrayList()}\n dp = Array(N){INF}\n ans = Array(N){0}\n\n for(i in 0..N-2){\n val u = sc.nextInt()-1\n val v = sc.nextInt()-1\n map[u].add(v)\n map[v].add(u)\n }\n\n calc(0, -1)\n\n for(t in ans){\n println(t)\n }\n}\n\nfun calc(i: Int, p: Int){\n // 自身のdpに自身の番号を適用する\n val idx = bisearch(dp, cnt, a[i])\n val pre = dp[idx]\n if(pre == INF) cnt++\n dp[idx] = a[i]\n ans[i] = cnt\n // 次の頂点へ再帰呼び出し\n for(j in map[i]){\n if(j == p) continue\n calc(j, i)\n dp[idx] = pre\n if(pre == INF)cnt--\n }\n}\n\n/**\n * 単調増加列arrの部分列[0]~[len-1]に対し、値vが挿入できる位置のインデックスを返す\n * ・二分探索\n * ・arr[len-1], len: Int, v: Int): Int{\n\n var left = 0\n var right = len\n var mid = 0\n while(left < right) {\n mid = (left + right) / 2\n if(arr[mid] < v){\n left = mid + 1\n }else if(arr[mid] > v){\n right = mid - 1\n }else {\n return mid\n }\n }\n\n // ここに来るパターンは2つ\n // 1)最後のループで leftとrightの差が1しかなく(left=mid)、right=mid-1の結果、right) {\n val n = readLine()!!.toInt()\n val a = readLine()!!.split(\" \").map { it.toInt() }.toIntArray()\n val c = compressed(a)\n val t = Array>(n) { mutableListOf() }\n repeat(n-1) {\n val (u, v) = readLine()!!.split(\" \").map { it.toInt()-1 }\n t[u].add(v)\n t[v].add(u)\n }\n val dp = IntArray(n+1) { INF }\n dp[0] = -1\n fun lowerBound(v: Int): Int {\n var l = 0\n var r = n\n while (r-l > 1) {\n val m = (l+r)/2\n if (dp[m] < v) l = m else r = m\n }\n return l\n }\n val ans = IntArray(n)\n fun dfs(v: Int, p: Int) {\n val index = lowerBound(c[v])+1\n val prev = dp[index]\n dp[index] = c[v]\n ans[v] = lowerBound(INF)\n for (u in t[v]) {\n if (u == p) continue\n dfs(u, v)\n }\n dp[index] = prev\n }\n dfs(0, -1)\n ans.forEach { println(it) }\n}\nfun compressed(a: IntArray): IntArray {\n val b = a.withIndex().sortedBy { it.value }\n var tmp = b[0].value-1\n var cnt = -1\n val c = IntArray(a.size)\n for (i in b.indices) {\n if (b[i].value > tmp) {\n cnt++\n tmp = b[i].value\n }\n c[b[i].index] = cnt\n }\n return c\n}", "language": "Kotlin", "metadata": {"date": 1588478945, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02698.html", "problem_id": "p02698", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02698/input.txt", "sample_output_relpath": "derived/input_output/data/p02698/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02698/Kotlin/s132653638.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s132653638", "user_id": "u506403362"}, "prompt_components": {"gold_output": "1\n2\n3\n3\n4\n4\n5\n2\n2\n3\n", "input_to_evaluate": "const val INF = 100_000_000\n\n@kotlin.ExperimentalStdlibApi\nfun main(args: Array) {\n val n = readLine()!!.toInt()\n val a = readLine()!!.split(\" \").map { it.toInt() }.toIntArray()\n val c = compressed(a)\n val t = Array>(n) { mutableListOf() }\n repeat(n-1) {\n val (u, v) = readLine()!!.split(\" \").map { it.toInt()-1 }\n t[u].add(v)\n t[v].add(u)\n }\n val dp = IntArray(n+1) { INF }\n dp[0] = -1\n fun lowerBound(v: Int): Int {\n var l = 0\n var r = n\n while (r-l > 1) {\n val m = (l+r)/2\n if (dp[m] < v) l = m else r = m\n }\n return l\n }\n val ans = IntArray(n)\n fun dfs(v: Int, p: Int) {\n val index = lowerBound(c[v])+1\n val prev = dp[index]\n dp[index] = c[v]\n ans[v] = lowerBound(INF)\n for (u in t[v]) {\n if (u == p) continue\n dfs(u, v)\n }\n dp[index] = prev\n }\n dfs(0, -1)\n ans.forEach { println(it) }\n}\nfun compressed(a: IntArray): IntArray {\n val b = a.withIndex().sortedBy { it.value }\n var tmp = b[0].value-1\n var cnt = -1\n val c = IntArray(a.size)\n for (i in b.indices) {\n if (b[i].value > tmp) {\n cnt++\n tmp = b[i].value\n }\n c[b[i].index] = cnt\n }\n return c\n}", "problem_context": "Score : 600 points\n\nProblem Statement\n\nWe have a tree with N vertices, whose i-th edge connects Vertex u_i and Vertex v_i.\nVertex i has an integer a_i written on it.\nFor every integer k from 1 through N, solve the following problem:\n\nWe will make a sequence by lining up the integers written on the vertices along the shortest path from Vertex 1 to Vertex k, in the order they appear. Find the length of the longest increasing subsequence of this sequence.\n\nHere, the longest increasing subsequence of a sequence A of length L is the subsequence A_{i_1} , A_{i_2} , ... , A_{i_M} with the greatest possible value of M such that 1 \\leq i_1 < i_2 < ... < i_M \\leq L and A_{i_1} < A_{i_2} < ... < A_{i_M}.\n\nConstraints\n\n2 \\leq N \\leq 2 \\times 10^5\n\n1 \\leq a_i \\leq 10^9\n\n1 \\leq u_i , v_i \\leq N\n\nu_i \\neq v_i\n\nThe given graph is a tree.\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\nu_1 v_1\nu_2 v_2\n:\nu_{N-1} v_{N-1}\n\nOutput\n\nPrint N lines. The k-th line, print the length of the longest increasing subsequence of the sequence obtained from the shortest path from Vertex 1 to Vertex k.\n\nSample Input 1\n\n10\n1 2 5 3 4 6 7 3 2 4\n1 2\n2 3\n3 4\n4 5\n3 6\n6 7\n1 8\n8 9\n9 10\n\nSample Output 1\n\n1\n2\n3\n3\n4\n4\n5\n2\n2\n3\n\nFor example, the sequence A obtained from the shortest path from Vertex 1 to Vertex 5 is 1,2,5,3,4. Its longest increasing subsequence is A_1, A_2, A_4, A_5, with the length of 4.", "sample_input": "10\n1 2 5 3 4 6 7 3 2 4\n1 2\n2 3\n3 4\n4 5\n3 6\n6 7\n1 8\n8 9\n9 10\n"}, "reference_outputs": ["1\n2\n3\n3\n4\n4\n5\n2\n2\n3\n"], "source_document_id": "p02698", "source_text": "Score : 600 points\n\nProblem Statement\n\nWe have a tree with N vertices, whose i-th edge connects Vertex u_i and Vertex v_i.\nVertex i has an integer a_i written on it.\nFor every integer k from 1 through N, solve the following problem:\n\nWe will make a sequence by lining up the integers written on the vertices along the shortest path from Vertex 1 to Vertex k, in the order they appear. Find the length of the longest increasing subsequence of this sequence.\n\nHere, the longest increasing subsequence of a sequence A of length L is the subsequence A_{i_1} , A_{i_2} , ... , A_{i_M} with the greatest possible value of M such that 1 \\leq i_1 < i_2 < ... < i_M \\leq L and A_{i_1} < A_{i_2} < ... < A_{i_M}.\n\nConstraints\n\n2 \\leq N \\leq 2 \\times 10^5\n\n1 \\leq a_i \\leq 10^9\n\n1 \\leq u_i , v_i \\leq N\n\nu_i \\neq v_i\n\nThe given graph is a tree.\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\nu_1 v_1\nu_2 v_2\n:\nu_{N-1} v_{N-1}\n\nOutput\n\nPrint N lines. The k-th line, print the length of the longest increasing subsequence of the sequence obtained from the shortest path from Vertex 1 to Vertex k.\n\nSample Input 1\n\n10\n1 2 5 3 4 6 7 3 2 4\n1 2\n2 3\n3 4\n4 5\n3 6\n6 7\n1 8\n8 9\n9 10\n\nSample Output 1\n\n1\n2\n3\n3\n4\n4\n5\n2\n2\n3\n\nFor example, the sequence A obtained from the shortest path from Vertex 1 to Vertex 5 is 1,2,5,3,4. Its longest increasing subsequence is A_1, A_2, A_4, A_5, with the length of 4.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1189, "cpu_time_ms": 2168, "memory_kb": 113592}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s609418767", "group_id": "codeNet:p02699", "input_text": "fun main(args: Array) {\n val line = readLine()!!.trim()\n val (s, w) = line.split(\" \").map {it.toInt()}\n\n if (s <= w) {\n println(\"unsafe\")\n } else {\n println(\"safe\")\n }\n}", "language": "Kotlin", "metadata": {"date": 1587949380, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02699.html", "problem_id": "p02699", "resource_group": "medium_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/Kotlin/s609418767.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s609418767", "user_id": "u146343951"}, "prompt_components": {"gold_output": "unsafe\n", "input_to_evaluate": "fun main(args: Array) {\n val line = readLine()!!.trim()\n val (s, w) = line.split(\" \").map {it.toInt()}\n\n if (s <= w) {\n println(\"unsafe\")\n } else {\n println(\"safe\")\n }\n}", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 206, "cpu_time_ms": 101, "memory_kb": 36412}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s398319538", "group_id": "codeNet:p02699", "input_text": "import java.io.PrintWriter\n\nfun main() {\n val pw = PrintWriter(System.out)\n\n val (s, w) = readInputLine().split(\" \").map { it.toInt() }\n\n if (w >= s) {\n pw.println(\"unsafe\")\n } else {\n pw.println(\"safe\")\n }\n\n pw.flush()\n}\n\nfun readInputLine(): String {\n return readLine()!!\n}\n", "language": "Kotlin", "metadata": {"date": 1587949280, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02699.html", "problem_id": "p02699", "resource_group": "medium_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/Kotlin/s398319538.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s398319538", "user_id": "u505558493"}, "prompt_components": {"gold_output": "unsafe\n", "input_to_evaluate": "import java.io.PrintWriter\n\nfun main() {\n val pw = PrintWriter(System.out)\n\n val (s, w) = readInputLine().split(\" \").map { it.toInt() }\n\n if (w >= s) {\n pw.println(\"unsafe\")\n } else {\n pw.println(\"safe\")\n }\n\n pw.flush()\n}\n\nfun readInputLine(): String {\n return readLine()!!\n}\n", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 311, "cpu_time_ms": 98, "memory_kb": 36452}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s853198142", "group_id": "codeNet:p02701", "input_text": "fun main() {\n val n = readLine()!!.toInt()\n val s = (1..n).map { readLine()!! }\n \n println(s.distinct().count())\n}", "language": "Kotlin", "metadata": {"date": 1588294870, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02701.html", "problem_id": "p02701", "resource_group": "medium_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/Kotlin/s853198142.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s853198142", "user_id": "u563556491"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "fun main() {\n val n = readLine()!!.toInt()\n val s = (1..n).map { readLine()!! }\n \n println(s.distinct().count())\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 495, "memory_kb": 75312}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s167008038", "group_id": "codeNet:p02701", "input_text": "fun main(args: Array) {\n val n = readLine()!!.toInt()\n val list = mutableListOf(\"\")\n for (i in 0 until n) {\n val s = readLine()!!\n if (list.contains(s)) {\n continue\n } else {\n list.add(s)\n }\n }\n println(list.size - 1)\n}\n", "language": "Kotlin", "metadata": {"date": 1587950133, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02701.html", "problem_id": "p02701", "resource_group": "medium_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/Kotlin/s167008038.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s167008038", "user_id": "u213256030"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "fun main(args: Array) {\n val n = readLine()!!.toInt()\n val list = mutableListOf(\"\")\n for (i in 0 until n) {\n val s = readLine()!!\n if (list.contains(s)) {\n continue\n } else {\n list.add(s)\n }\n }\n println(list.size - 1)\n}\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 2207, "memory_kb": 58404}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s425446113", "group_id": "codeNet:p02701", "input_text": "fun main(args: Array) {\n val n = readLine()!!.toInt()\n var l = mutableSetOf()\n for(i in 0 until n){\n l.add(readLine()!!)\n }\n println(l.size)\n}\n", "language": "Kotlin", "metadata": {"date": 1587949857, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02701.html", "problem_id": "p02701", "resource_group": "medium_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/Kotlin/s425446113.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s425446113", "user_id": "u227189389"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "fun main(args: Array) {\n val n = readLine()!!.toInt()\n var l = mutableSetOf()\n for(i in 0 until n){\n l.add(readLine()!!)\n }\n println(l.size)\n}\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 475, "memory_kb": 78176}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s478282016", "group_id": "codeNet:p02704", "input_text": "\n\n\nfun verify(suspect: Array, s: IntArray, t: IntArray, u: LongArray, v: LongArray): Boolean {\n for (i in s.indices) {\n val result = if (s[i] == 0) {\n t.indices.fold(0L.inv()){acc, j -> acc and suspect[i][j]}\n }else {\n t.indices.fold(0L){acc, j -> acc or suspect[i][j]}\n }\n if (result != u[i]) return false\n }\n for (i in t.indices) {\n val result = if (t[i] == 0) {\n s.indices.fold(0L.inv()){acc, j -> acc and suspect[j][i]}\n }else {\n s.indices.fold(0L){acc, j -> acc or suspect[j][i]}\n }\n if (result != v[i]) return false\n }\n return true\n}\nfun Long.nthBit(n: Int): Long {\n return this and (1L shl n)\n}\nfun main() {\n val n = readLine()!!.trim().toInt()\n val s = readLine()!!.trim().split(' ').map(String::toInt).toIntArray()\n val t = readLine()!!.trim().split(' ').map(String::toInt).toIntArray()\n val u = readLine()!!.trim().split(' ').map(String::toLong).toLongArray()\n val v = readLine()!!.trim().split(' ').map(String::toLong).toLongArray()\n val result = Array(n){LongArray(n){0} }\n val (andS, orS) = s.indices.partition{s[it] == 0}\n val (andT, orT) = t.indices.partition{t[it] == 0}\n for (d in 0 until 64) {\n var digit = 1L\n for (i in s.indices) if ((s[i] == 0 && u[i].nthBit(d) == 0L) || (s[i] == 1 && u[i].nthBit(d) != 0L)) {\n for (j in t.indices) if ((t[i] == 0 && v[i].nthBit(d) == 0L) || (t[i] == 1 && v[i].nthBit(d) != 0L)) {\n result[i][j] = result[i][j] or (digit shl d)\n digit = 1 - digit\n }\n }\n for (i in andS) if (u[i].nthBit(d) != 0L) {\n for (j in t.indices) result[i][j] = result[i][j] or (1L shl d)\n }\n for (j in andT) if (v[j].nthBit(d) != 0L) {\n for (i in s.indices) result[i][j] = result[i][j] or (1L shl d)\n }\n for (i in orS) if (u[i].nthBit(d) == 0L) {\n for (j in t.indices) result[i][j] = result[i][j] and (1L shl d).inv()\n }\n for (j in orT) if (v[j].nthBit(d) == 0L) {\n for (i in s.indices) result[i][j] = result[i][j] and (1L shl d).inv()\n }\n }\n if (verify(result, s, t, u, v)) {\n println(result.joinToString(\"\\n\"){it.joinToString(\" \")})\n }else {\n println(-1)\n }\n}\n", "language": "Kotlin", "metadata": {"date": 1591501379, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02704.html", "problem_id": "p02704", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02704/input.txt", "sample_output_relpath": "derived/input_output/data/p02704/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02704/Kotlin/s478282016.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s478282016", "user_id": "u419330815"}, "prompt_components": {"gold_output": "1 1\n1 0\n", "input_to_evaluate": "\n\n\nfun verify(suspect: Array, s: IntArray, t: IntArray, u: LongArray, v: LongArray): Boolean {\n for (i in s.indices) {\n val result = if (s[i] == 0) {\n t.indices.fold(0L.inv()){acc, j -> acc and suspect[i][j]}\n }else {\n t.indices.fold(0L){acc, j -> acc or suspect[i][j]}\n }\n if (result != u[i]) return false\n }\n for (i in t.indices) {\n val result = if (t[i] == 0) {\n s.indices.fold(0L.inv()){acc, j -> acc and suspect[j][i]}\n }else {\n s.indices.fold(0L){acc, j -> acc or suspect[j][i]}\n }\n if (result != v[i]) return false\n }\n return true\n}\nfun Long.nthBit(n: Int): Long {\n return this and (1L shl n)\n}\nfun main() {\n val n = readLine()!!.trim().toInt()\n val s = readLine()!!.trim().split(' ').map(String::toInt).toIntArray()\n val t = readLine()!!.trim().split(' ').map(String::toInt).toIntArray()\n val u = readLine()!!.trim().split(' ').map(String::toLong).toLongArray()\n val v = readLine()!!.trim().split(' ').map(String::toLong).toLongArray()\n val result = Array(n){LongArray(n){0} }\n val (andS, orS) = s.indices.partition{s[it] == 0}\n val (andT, orT) = t.indices.partition{t[it] == 0}\n for (d in 0 until 64) {\n var digit = 1L\n for (i in s.indices) if ((s[i] == 0 && u[i].nthBit(d) == 0L) || (s[i] == 1 && u[i].nthBit(d) != 0L)) {\n for (j in t.indices) if ((t[i] == 0 && v[i].nthBit(d) == 0L) || (t[i] == 1 && v[i].nthBit(d) != 0L)) {\n result[i][j] = result[i][j] or (digit shl d)\n digit = 1 - digit\n }\n }\n for (i in andS) if (u[i].nthBit(d) != 0L) {\n for (j in t.indices) result[i][j] = result[i][j] or (1L shl d)\n }\n for (j in andT) if (v[j].nthBit(d) != 0L) {\n for (i in s.indices) result[i][j] = result[i][j] or (1L shl d)\n }\n for (i in orS) if (u[i].nthBit(d) == 0L) {\n for (j in t.indices) result[i][j] = result[i][j] and (1L shl d).inv()\n }\n for (j in orT) if (v[j].nthBit(d) == 0L) {\n for (i in s.indices) result[i][j] = result[i][j] and (1L shl d).inv()\n }\n }\n if (verify(result, s, t, u, v)) {\n println(result.joinToString(\"\\n\"){it.joinToString(\" \")})\n }else {\n println(-1)\n }\n}\n", "problem_context": "Score : 600 points\n\nProblem Statement\n\nGiven are an integer N and arrays S, T, U, and V, each of length N.\nConstruct an N×N matrix a that satisfy the following conditions:\n\na_{i,j} is an integer.\n\n0 \\leq a_{i,j} \\lt 2^{64}.\n\nIf S_{i} = 0, the bitwise AND of the elements in the i-th row is U_{i}.\n\nIf S_{i} = 1, the bitwise OR of the elements in the i-th row is U_{i}.\n\nIf T_{i} = 0, the bitwise AND of the elements in the i-th column is V_{i}.\n\nIf T_{i} = 1, the bitwise OR of the elements in the i-th column is V_{i}.\n\nHowever, there may be cases where no matrix satisfies the conditions.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 500\n\n0 \\leq S_{i} \\leq 1\n\n0 \\leq T_{i} \\leq 1\n\n0 \\leq U_{i} \\lt 2^{64}\n\n0 \\leq V_{i} \\lt 2^{64}\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS_{1} S_{2} ... S_{N}\nT_{1} T_{2} ... T_{N}\nU_{1} U_{2} ... U_{N}\nV_{1} V_{2} ... V_{N}\n\nOutput\n\nIf there exists a matrix that satisfies the conditions, print one such matrix in the following format:\n\na_{1,1} ... a_{1,N}\n:\na_{N,1} ... a_{N,N}\n\nNote that any matrix satisfying the conditions is accepted.\n\nIf no matrix satisfies the conditions, print -1.\n\nSample Input 1\n\n2\n0 1\n1 0\n1 1\n1 0\n\nSample Output 1\n\n1 1\n1 0\n\nIn Sample Input 1, we need to find a matrix such that:\n\nthe bitwise AND of the elements in the 1-st row is 1;\n\nthe bitwise OR of the elements in the 2-nd row is 1;\n\nthe bitwise OR of the elements in the 1-st column is 1;\n\nthe bitwise AND of the elements in the 2-nd column is 0.\n\nSample Input 2\n\n2\n1 1\n1 0\n15 15\n15 11\n\nSample Output 2\n\n15 11\n15 11", "sample_input": "2\n0 1\n1 0\n1 1\n1 0\n"}, "reference_outputs": ["1 1\n1 0\n"], "source_document_id": "p02704", "source_text": "Score : 600 points\n\nProblem Statement\n\nGiven are an integer N and arrays S, T, U, and V, each of length N.\nConstruct an N×N matrix a that satisfy the following conditions:\n\na_{i,j} is an integer.\n\n0 \\leq a_{i,j} \\lt 2^{64}.\n\nIf S_{i} = 0, the bitwise AND of the elements in the i-th row is U_{i}.\n\nIf S_{i} = 1, the bitwise OR of the elements in the i-th row is U_{i}.\n\nIf T_{i} = 0, the bitwise AND of the elements in the i-th column is V_{i}.\n\nIf T_{i} = 1, the bitwise OR of the elements in the i-th column is V_{i}.\n\nHowever, there may be cases where no matrix satisfies the conditions.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 500\n\n0 \\leq S_{i} \\leq 1\n\n0 \\leq T_{i} \\leq 1\n\n0 \\leq U_{i} \\lt 2^{64}\n\n0 \\leq V_{i} \\lt 2^{64}\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS_{1} S_{2} ... S_{N}\nT_{1} T_{2} ... T_{N}\nU_{1} U_{2} ... U_{N}\nV_{1} V_{2} ... V_{N}\n\nOutput\n\nIf there exists a matrix that satisfies the conditions, print one such matrix in the following format:\n\na_{1,1} ... a_{1,N}\n:\na_{N,1} ... a_{N,N}\n\nNote that any matrix satisfying the conditions is accepted.\n\nIf no matrix satisfies the conditions, print -1.\n\nSample Input 1\n\n2\n0 1\n1 0\n1 1\n1 0\n\nSample Output 1\n\n1 1\n1 0\n\nIn Sample Input 1, we need to find a matrix such that:\n\nthe bitwise AND of the elements in the 1-st row is 1;\n\nthe bitwise OR of the elements in the 2-nd row is 1;\n\nthe bitwise OR of the elements in the 1-st column is 1;\n\nthe bitwise AND of the elements in the 2-nd column is 0.\n\nSample Input 2\n\n2\n1 1\n1 0\n15 15\n15 11\n\nSample Output 2\n\n15 11\n15 11", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2345, "cpu_time_ms": 140, "memory_kb": 40272}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s498399892", "group_id": "codeNet:p02706", "input_text": "fun main() {\n val (n, _) = readInts()\n val sum = readInts().sum()\n println(if (sum > n) -1 else n - sum)\n}\n\n// Input Reader\nprivate fun readLn() = readLine()!!\n\nprivate fun readStrings() = readLn().trim().split(\" \")\nprivate fun readInts() = readStrings().map { it.toInt() }\n", "language": "Kotlin", "metadata": {"date": 1587345112, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02706.html", "problem_id": "p02706", "resource_group": "medium_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/Kotlin/s498399892.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s498399892", "user_id": "u984465701"}, "prompt_components": {"gold_output": "30\n", "input_to_evaluate": "fun main() {\n val (n, _) = readInts()\n val sum = readInts().sum()\n println(if (sum > n) -1 else n - sum)\n}\n\n// Input Reader\nprivate fun readLn() = readLine()!!\n\nprivate fun readStrings() = readLn().trim().split(\" \")\nprivate fun readInts() = readStrings().map { it.toInt() }\n", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 172, "memory_kb": 39444}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s635878591", "group_id": "codeNet:p02707", "input_text": "fun main(args: Array) {\n var n = readLine()!!.toInt()\n var a = readLine()!!.split(\" \").map(String::toInt)\n var count = MutableList(n, {0})\n for (ai in a)\n count[ai-1] ++\n println(count.joinToString(\"\\n\"))\n}\n", "language": "Kotlin", "metadata": {"date": 1587708356, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02707.html", "problem_id": "p02707", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02707/input.txt", "sample_output_relpath": "derived/input_output/data/p02707/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02707/Kotlin/s635878591.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s635878591", "user_id": "u906501980"}, "prompt_components": {"gold_output": "2\n2\n0\n0\n0\n", "input_to_evaluate": "fun main(args: Array) {\n var n = readLine()!!.toInt()\n var a = readLine()!!.split(\" \").map(String::toInt)\n var count = MutableList(n, {0})\n for (ai in a)\n count[ai-1] ++\n println(count.joinToString(\"\\n\"))\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nA company has N members, who are assigned ID numbers 1, ..., N.\n\nEvery member, except the member numbered 1, has exactly one immediate boss with a smaller ID number.\n\nWhen a person X is the immediate boss of a person Y, the person Y is said to be an immediate subordinate of the person X.\n\nYou are given the information that the immediate boss of the member numbered i is the member numbered A_i. For each member, find how many immediate subordinates it has.\n\nConstraints\n\n2 \\leq N \\leq 2 \\times 10^5\n\n1 \\leq A_i < i\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_2 ... A_N\n\nOutput\n\nFor each of the members numbered 1, 2, ..., N, print the number of immediate subordinates it has, in its own line.\n\nSample Input 1\n\n5\n1 1 2 2\n\nSample Output 1\n\n2\n2\n0\n0\n0\n\nThe member numbered 1 has two immediate subordinates: the members numbered 2 and 3.\n\nThe member numbered 2 has two immediate subordinates: the members numbered 4 and 5.\n\nThe members numbered 3, 4, and 5 do not have immediate subordinates.\n\nSample Input 2\n\n10\n1 1 1 1 1 1 1 1 1\n\nSample Output 2\n\n9\n0\n0\n0\n0\n0\n0\n0\n0\n0\n\nSample Input 3\n\n7\n1 2 3 4 5 6\n\nSample Output 3\n\n1\n1\n1\n1\n1\n1\n0", "sample_input": "5\n1 1 2 2\n"}, "reference_outputs": ["2\n2\n0\n0\n0\n"], "source_document_id": "p02707", "source_text": "Score : 300 points\n\nProblem Statement\n\nA company has N members, who are assigned ID numbers 1, ..., N.\n\nEvery member, except the member numbered 1, has exactly one immediate boss with a smaller ID number.\n\nWhen a person X is the immediate boss of a person Y, the person Y is said to be an immediate subordinate of the person X.\n\nYou are given the information that the immediate boss of the member numbered i is the member numbered A_i. For each member, find how many immediate subordinates it has.\n\nConstraints\n\n2 \\leq N \\leq 2 \\times 10^5\n\n1 \\leq A_i < i\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_2 ... A_N\n\nOutput\n\nFor each of the members numbered 1, 2, ..., N, print the number of immediate subordinates it has, in its own line.\n\nSample Input 1\n\n5\n1 1 2 2\n\nSample Output 1\n\n2\n2\n0\n0\n0\n\nThe member numbered 1 has two immediate subordinates: the members numbered 2 and 3.\n\nThe member numbered 2 has two immediate subordinates: the members numbered 4 and 5.\n\nThe members numbered 3, 4, and 5 do not have immediate subordinates.\n\nSample Input 2\n\n10\n1 1 1 1 1 1 1 1 1\n\nSample Output 2\n\n9\n0\n0\n0\n0\n0\n0\n0\n0\n0\n\nSample Input 3\n\n7\n1 2 3 4 5 6\n\nSample Output 3\n\n1\n1\n1\n1\n1\n1\n0", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 479, "memory_kb": 72676}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s120294210", "group_id": "codeNet:p02707", "input_text": "import java.io.PrintWriter\n\n//private val inp = java.io.File(\"in\")\nprivate val inp = System.`in`\nprivate val reader = inp.bufferedReader()\nprivate val wr = PrintWriter(System.out.bufferedWriter())\n\nprivate fun readLn(): String = reader.readLine()\nprivate fun readInt(): Int = readLn().toInt()\nprivate fun readStrs(): List = readLn().split(\" \")\nprivate fun readInts(): IntArray = readStrs().map { it.toInt() }.toIntArray()\nprivate fun readChars(): CharArray = readStrs().map { it.single() }.toCharArray()\n\nfun main() {\n val n = readInt()\n val a = readInts()\n\n val b = IntArray(n + 1)\n for (ai in a) {\n b[ai]++\n }\n\n for (i in 1..n) wr.println(b[i])\n wr.flush()\n}", "language": "Kotlin", "metadata": {"date": 1587348665, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02707.html", "problem_id": "p02707", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02707/input.txt", "sample_output_relpath": "derived/input_output/data/p02707/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02707/Kotlin/s120294210.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s120294210", "user_id": "u366116119"}, "prompt_components": {"gold_output": "2\n2\n0\n0\n0\n", "input_to_evaluate": "import java.io.PrintWriter\n\n//private val inp = java.io.File(\"in\")\nprivate val inp = System.`in`\nprivate val reader = inp.bufferedReader()\nprivate val wr = PrintWriter(System.out.bufferedWriter())\n\nprivate fun readLn(): String = reader.readLine()\nprivate fun readInt(): Int = readLn().toInt()\nprivate fun readStrs(): List = readLn().split(\" \")\nprivate fun readInts(): IntArray = readStrs().map { it.toInt() }.toIntArray()\nprivate fun readChars(): CharArray = readStrs().map { it.single() }.toCharArray()\n\nfun main() {\n val n = readInt()\n val a = readInts()\n\n val b = IntArray(n + 1)\n for (ai in a) {\n b[ai]++\n }\n\n for (i in 1..n) wr.println(b[i])\n wr.flush()\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nA company has N members, who are assigned ID numbers 1, ..., N.\n\nEvery member, except the member numbered 1, has exactly one immediate boss with a smaller ID number.\n\nWhen a person X is the immediate boss of a person Y, the person Y is said to be an immediate subordinate of the person X.\n\nYou are given the information that the immediate boss of the member numbered i is the member numbered A_i. For each member, find how many immediate subordinates it has.\n\nConstraints\n\n2 \\leq N \\leq 2 \\times 10^5\n\n1 \\leq A_i < i\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_2 ... A_N\n\nOutput\n\nFor each of the members numbered 1, 2, ..., N, print the number of immediate subordinates it has, in its own line.\n\nSample Input 1\n\n5\n1 1 2 2\n\nSample Output 1\n\n2\n2\n0\n0\n0\n\nThe member numbered 1 has two immediate subordinates: the members numbered 2 and 3.\n\nThe member numbered 2 has two immediate subordinates: the members numbered 4 and 5.\n\nThe members numbered 3, 4, and 5 do not have immediate subordinates.\n\nSample Input 2\n\n10\n1 1 1 1 1 1 1 1 1\n\nSample Output 2\n\n9\n0\n0\n0\n0\n0\n0\n0\n0\n0\n\nSample Input 3\n\n7\n1 2 3 4 5 6\n\nSample Output 3\n\n1\n1\n1\n1\n1\n1\n0", "sample_input": "5\n1 1 2 2\n"}, "reference_outputs": ["2\n2\n0\n0\n0\n"], "source_document_id": "p02707", "source_text": "Score : 300 points\n\nProblem Statement\n\nA company has N members, who are assigned ID numbers 1, ..., N.\n\nEvery member, except the member numbered 1, has exactly one immediate boss with a smaller ID number.\n\nWhen a person X is the immediate boss of a person Y, the person Y is said to be an immediate subordinate of the person X.\n\nYou are given the information that the immediate boss of the member numbered i is the member numbered A_i. For each member, find how many immediate subordinates it has.\n\nConstraints\n\n2 \\leq N \\leq 2 \\times 10^5\n\n1 \\leq A_i < i\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_2 ... A_N\n\nOutput\n\nFor each of the members numbered 1, 2, ..., N, print the number of immediate subordinates it has, in its own line.\n\nSample Input 1\n\n5\n1 1 2 2\n\nSample Output 1\n\n2\n2\n0\n0\n0\n\nThe member numbered 1 has two immediate subordinates: the members numbered 2 and 3.\n\nThe member numbered 2 has two immediate subordinates: the members numbered 4 and 5.\n\nThe members numbered 3, 4, and 5 do not have immediate subordinates.\n\nSample Input 2\n\n10\n1 1 1 1 1 1 1 1 1\n\nSample Output 2\n\n9\n0\n0\n0\n0\n0\n0\n0\n0\n0\n\nSample Input 3\n\n7\n1 2 3 4 5 6\n\nSample Output 3\n\n1\n1\n1\n1\n1\n1\n0", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 696, "cpu_time_ms": 375, "memory_kb": 65932}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s123570610", "group_id": "codeNet:p02708", "input_text": "const val mod = 1000000007\n\nfun main() {\n\tval (n,k) = readLine()!!.split(\" \").map {it.toInt()}\n\tval a = LongArray(n+1) {it.toLong()}\n\tfor(i in 1..n)\n\t\ta[i] = (a[i]+a[i-1])%mod\n\n\t(k-1..n).map {\n\t\t(a[n]-a.elementAtOrElse(n-1-it) {0}-a[it]+1+mod*2)%mod\n\t}.fold(0L) {a,b-> (a+b)%mod}\n\t\t\t.let {println(it)}\n}\n", "language": "Kotlin", "metadata": {"date": 1588222734, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02708.html", "problem_id": "p02708", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02708/input.txt", "sample_output_relpath": "derived/input_output/data/p02708/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02708/Kotlin/s123570610.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s123570610", "user_id": "u059234158"}, "prompt_components": {"gold_output": "10\n", "input_to_evaluate": "const val mod = 1000000007\n\nfun main() {\n\tval (n,k) = readLine()!!.split(\" \").map {it.toInt()}\n\tval a = LongArray(n+1) {it.toLong()}\n\tfor(i in 1..n)\n\t\ta[i] = (a[i]+a[i-1])%mod\n\n\t(k-1..n).map {\n\t\t(a[n]-a.elementAtOrElse(n-1-it) {0}-a[it]+1+mod*2)%mod\n\t}.fold(0L) {a,b-> (a+b)%mod}\n\t\t\t.let {println(it)}\n}\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nWe have N+1 integers: 10^{100}, 10^{100}+1, ..., 10^{100}+N.\n\nWe will choose K or more of these integers. Find the number of possible values of the sum of the chosen numbers, modulo (10^9+7).\n\nConstraints\n\n1 \\leq N \\leq 2\\times 10^5\n\n1 \\leq K \\leq N+1\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 number of possible values of the sum, modulo (10^9+7).\n\nSample Input 1\n\n3 2\n\nSample Output 1\n\n10\n\nThe sum can take 10 values, as follows:\n\n(10^{100})+(10^{100}+1)=2\\times 10^{100}+1\n\n(10^{100})+(10^{100}+2)=2\\times 10^{100}+2\n\n(10^{100})+(10^{100}+3)=(10^{100}+1)+(10^{100}+2)=2\\times 10^{100}+3\n\n(10^{100}+1)+(10^{100}+3)=2\\times 10^{100}+4\n\n(10^{100}+2)+(10^{100}+3)=2\\times 10^{100}+5\n\n(10^{100})+(10^{100}+1)+(10^{100}+2)=3\\times 10^{100}+3\n\n(10^{100})+(10^{100}+1)+(10^{100}+3)=3\\times 10^{100}+4\n\n(10^{100})+(10^{100}+2)+(10^{100}+3)=3\\times 10^{100}+5\n\n(10^{100}+1)+(10^{100}+2)+(10^{100}+3)=3\\times 10^{100}+6\n\n(10^{100})+(10^{100}+1)+(10^{100}+2)+(10^{100}+3)=4\\times 10^{100}+6\n\nSample Input 2\n\n200000 200001\n\nSample Output 2\n\n1\n\nWe must choose all of the integers, so the sum can take just 1 value.\n\nSample Input 3\n\n141421 35623\n\nSample Output 3\n\n220280457", "sample_input": "3 2\n"}, "reference_outputs": ["10\n"], "source_document_id": "p02708", "source_text": "Score : 400 points\n\nProblem Statement\n\nWe have N+1 integers: 10^{100}, 10^{100}+1, ..., 10^{100}+N.\n\nWe will choose K or more of these integers. Find the number of possible values of the sum of the chosen numbers, modulo (10^9+7).\n\nConstraints\n\n1 \\leq N \\leq 2\\times 10^5\n\n1 \\leq K \\leq N+1\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 number of possible values of the sum, modulo (10^9+7).\n\nSample Input 1\n\n3 2\n\nSample Output 1\n\n10\n\nThe sum can take 10 values, as follows:\n\n(10^{100})+(10^{100}+1)=2\\times 10^{100}+1\n\n(10^{100})+(10^{100}+2)=2\\times 10^{100}+2\n\n(10^{100})+(10^{100}+3)=(10^{100}+1)+(10^{100}+2)=2\\times 10^{100}+3\n\n(10^{100}+1)+(10^{100}+3)=2\\times 10^{100}+4\n\n(10^{100}+2)+(10^{100}+3)=2\\times 10^{100}+5\n\n(10^{100})+(10^{100}+1)+(10^{100}+2)=3\\times 10^{100}+3\n\n(10^{100})+(10^{100}+1)+(10^{100}+3)=3\\times 10^{100}+4\n\n(10^{100})+(10^{100}+2)+(10^{100}+3)=3\\times 10^{100}+5\n\n(10^{100}+1)+(10^{100}+2)+(10^{100}+3)=3\\times 10^{100}+6\n\n(10^{100})+(10^{100}+1)+(10^{100}+2)+(10^{100}+3)=4\\times 10^{100}+6\n\nSample Input 2\n\n200000 200001\n\nSample Output 2\n\n1\n\nWe must choose all of the integers, so the sum can take just 1 value.\n\nSample Input 3\n\n141421 35623\n\nSample Output 3\n\n220280457", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 304, "cpu_time_ms": 158, "memory_kb": 49368}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s940607495", "group_id": "codeNet:p02709", "input_text": "@file:Suppress(\"NOTHING_TO_INLINE\", \"EXPERIMENTAL_FEATURE_WARNING\", \"OVERRIDE_BY_INLINE\")\n\nimport java.io.PrintWriter\nimport java.util.PriorityQueue\nimport kotlin.math.*\nimport kotlin.random.Random\nimport kotlin.collections.sort as _sort\nimport kotlin.collections.sortDescending as _sortDescending\nimport kotlin.io.println as iprintln\n\n/** @author Spheniscine */\nfun main() { _writer.solve(); _writer.flush() }\nfun PrintWriter.solve() {\n val n = readInt()\n val A = readIntArray(n)\n val J = (0 until n).sortedByDescending { A[it] }\n\n val D = Array(n+1) { LongArray(n - it + 1) }\n\n for(i in 0 until n) {\n val j = J[i]\n val a = A[j].toLong()\n for(k in 0..i) {\n val l = i-k\n val d = D[k][l]\n D.setMax(k+1, l, d + a * abs(j - k))\n D.setMax(k, l+1, d + a * abs(j - (n - l - 1)))\n }\n }\n\n var ans = 0L\n for(i in 0..n) ans = max(ans, D[i][n-i])\n\n println(ans)\n}\n\nfun Array.setMax(i: Int, j: Int, v: Long) { if(v > this[i][j]) this[i][j] = v }\n\n/** IO code start */\n//@JvmField val INPUT = File(\"input.txt\").inputStream()\n//@JvmField val OUTPUT = File(\"output.txt\").outputStream()\n@JvmField val INPUT = System.`in`\n@JvmField val OUTPUT = System.out\n\n@JvmField val _reader = INPUT.bufferedReader()\nfun readLine(): String? = _reader.readLine()\nfun readLn() = _reader.readLine()!!\n@JvmField var _ln = \"\"\n@JvmField var _lnPtr = 0\nfun read(): String {\n while (_lnPtr >= _ln.length) {\n _ln = readLine() ?: return \"\"\n _lnPtr = 0\n }\n var j = _ln.indexOf(' ', _lnPtr)\n if(j < 0) j = _ln.length\n val res = _ln.substring(_lnPtr, j)\n _lnPtr = j + 1\n return res\n}\nfun readRem(): String /* reads remainder of current line */ =\n _ln.substring(min(_lnPtr, _ln.length)).also { _lnPtr = _ln.length }\nfun readInt() = read().toInt()\nfun readDouble() = read().toDouble()\nfun readLong() = read().toLong()\nfun readStrings(n: Int) = List(n) { read() }\nfun readLines(n: Int) = List(n) { readLn() }\nfun readInts(n: Int) = List(n) { read().toInt() }\nfun readIntArray(n: Int) = IntArray(n) { read().toInt() }\nfun readDoubles(n: Int) = List(n) { read().toDouble() }\nfun readDoubleArray(n: Int) = DoubleArray(n) { read().toDouble() }\nfun readLongs(n: Int) = List(n) { read().toLong() }\nfun readLongArray(n: Int) = LongArray(n) { read().toLong() }\n\n@JvmField val _writer = PrintWriter(OUTPUT, false)\n\n/** shuffles and sort overrides to avoid quicksort attacks */\nprivate inline fun _shuffle(rnd: Random, get: (Int) -> T, set: (Int, T) -> Unit, size: Int) {\n // Fisher-Yates shuffle algorithm\n for (i in size - 1 downTo 1) {\n val j = rnd.nextInt(i + 1)\n val temp = get(i)\n set(i, get(j))\n set(j, temp)\n }\n}\n\n@JvmField var _random: Random? = null\nval random get() = _random ?: Random(0x594E215C123 * System.nanoTime()).also { _random = it }\n\nfun IntArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\nfun IntArray.sort() { shuffle(); _sort() }\nfun IntArray.sortDescending() { shuffle(); _sortDescending() }\n\nfun LongArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\nfun LongArray.sort() { shuffle(); _sort() }\nfun LongArray.sortDescending() { shuffle(); _sortDescending() }\n\nfun DoubleArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\nfun DoubleArray.sort() { shuffle(); _sort() }\nfun DoubleArray.sortDescending() { shuffle(); _sortDescending() }\n\nfun CharArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\ninline fun CharArray.sort() { _sort() }\ninline fun CharArray.sortDescending() { _sortDescending() }\n\ninline fun > Array.sort() = _sort()\ninline fun > Array.sortDescending() = _sortDescending()\ninline fun > MutableList.sort() = _sort()\ninline fun > MutableList.sortDescending() = _sortDescending()\n\nfun `please stop removing these imports IntelliJ`() {\n iprintln(max(1, 2))\n}", "language": "Kotlin", "metadata": {"date": 1587442590, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02709.html", "problem_id": "p02709", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02709/input.txt", "sample_output_relpath": "derived/input_output/data/p02709/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02709/Kotlin/s940607495.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s940607495", "user_id": "u596111103"}, "prompt_components": {"gold_output": "20\n", "input_to_evaluate": "@file:Suppress(\"NOTHING_TO_INLINE\", \"EXPERIMENTAL_FEATURE_WARNING\", \"OVERRIDE_BY_INLINE\")\n\nimport java.io.PrintWriter\nimport java.util.PriorityQueue\nimport kotlin.math.*\nimport kotlin.random.Random\nimport kotlin.collections.sort as _sort\nimport kotlin.collections.sortDescending as _sortDescending\nimport kotlin.io.println as iprintln\n\n/** @author Spheniscine */\nfun main() { _writer.solve(); _writer.flush() }\nfun PrintWriter.solve() {\n val n = readInt()\n val A = readIntArray(n)\n val J = (0 until n).sortedByDescending { A[it] }\n\n val D = Array(n+1) { LongArray(n - it + 1) }\n\n for(i in 0 until n) {\n val j = J[i]\n val a = A[j].toLong()\n for(k in 0..i) {\n val l = i-k\n val d = D[k][l]\n D.setMax(k+1, l, d + a * abs(j - k))\n D.setMax(k, l+1, d + a * abs(j - (n - l - 1)))\n }\n }\n\n var ans = 0L\n for(i in 0..n) ans = max(ans, D[i][n-i])\n\n println(ans)\n}\n\nfun Array.setMax(i: Int, j: Int, v: Long) { if(v > this[i][j]) this[i][j] = v }\n\n/** IO code start */\n//@JvmField val INPUT = File(\"input.txt\").inputStream()\n//@JvmField val OUTPUT = File(\"output.txt\").outputStream()\n@JvmField val INPUT = System.`in`\n@JvmField val OUTPUT = System.out\n\n@JvmField val _reader = INPUT.bufferedReader()\nfun readLine(): String? = _reader.readLine()\nfun readLn() = _reader.readLine()!!\n@JvmField var _ln = \"\"\n@JvmField var _lnPtr = 0\nfun read(): String {\n while (_lnPtr >= _ln.length) {\n _ln = readLine() ?: return \"\"\n _lnPtr = 0\n }\n var j = _ln.indexOf(' ', _lnPtr)\n if(j < 0) j = _ln.length\n val res = _ln.substring(_lnPtr, j)\n _lnPtr = j + 1\n return res\n}\nfun readRem(): String /* reads remainder of current line */ =\n _ln.substring(min(_lnPtr, _ln.length)).also { _lnPtr = _ln.length }\nfun readInt() = read().toInt()\nfun readDouble() = read().toDouble()\nfun readLong() = read().toLong()\nfun readStrings(n: Int) = List(n) { read() }\nfun readLines(n: Int) = List(n) { readLn() }\nfun readInts(n: Int) = List(n) { read().toInt() }\nfun readIntArray(n: Int) = IntArray(n) { read().toInt() }\nfun readDoubles(n: Int) = List(n) { read().toDouble() }\nfun readDoubleArray(n: Int) = DoubleArray(n) { read().toDouble() }\nfun readLongs(n: Int) = List(n) { read().toLong() }\nfun readLongArray(n: Int) = LongArray(n) { read().toLong() }\n\n@JvmField val _writer = PrintWriter(OUTPUT, false)\n\n/** shuffles and sort overrides to avoid quicksort attacks */\nprivate inline fun _shuffle(rnd: Random, get: (Int) -> T, set: (Int, T) -> Unit, size: Int) {\n // Fisher-Yates shuffle algorithm\n for (i in size - 1 downTo 1) {\n val j = rnd.nextInt(i + 1)\n val temp = get(i)\n set(i, get(j))\n set(j, temp)\n }\n}\n\n@JvmField var _random: Random? = null\nval random get() = _random ?: Random(0x594E215C123 * System.nanoTime()).also { _random = it }\n\nfun IntArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\nfun IntArray.sort() { shuffle(); _sort() }\nfun IntArray.sortDescending() { shuffle(); _sortDescending() }\n\nfun LongArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\nfun LongArray.sort() { shuffle(); _sort() }\nfun LongArray.sortDescending() { shuffle(); _sortDescending() }\n\nfun DoubleArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\nfun DoubleArray.sort() { shuffle(); _sort() }\nfun DoubleArray.sortDescending() { shuffle(); _sortDescending() }\n\nfun CharArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\ninline fun CharArray.sort() { _sort() }\ninline fun CharArray.sortDescending() { _sortDescending() }\n\ninline fun > Array.sort() = _sort()\ninline fun > Array.sortDescending() = _sortDescending()\ninline fun > MutableList.sort() = _sort()\ninline fun > MutableList.sortDescending() = _sortDescending()\n\nfun `please stop removing these imports IntelliJ`() {\n iprintln(max(1, 2))\n}", "problem_context": "Score : 500 points\n\nProblem Statement\n\nThere are N children standing in a line from left to right. The activeness of the i-th child from the left is A_i.\n\nYou can rearrange these children just one time in any order you like.\n\nWhen a child who originally occupies the x-th position from the left in the line moves to the y-th position from the left, that child earns A_x \\times |x-y| happiness points.\n\nFind the maximum total happiness points the children can earn.\n\nConstraints\n\n2 \\leq N \\leq 2000\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 total happiness points the children can earn.\n\nSample Input 1\n\n4\n1 3 4 2\n\nSample Output 1\n\n20\n\nIf we move the 1-st child from the left to the 3-rd position from the left, the 2-nd child to the 4-th position, the 3-rd child to the 1-st position, and the 4-th child to the 2-nd position, the children earns 1 \\times |1-3|+3 \\times |2-4|+4 \\times |3-1|+2 \\times |4-2|=20 happiness points in total.\n\nSample Input 2\n\n6\n5 5 6 1 1 1\n\nSample Output 2\n\n58\n\nSample Input 3\n\n6\n8 6 9 1 2 1\n\nSample Output 3\n\n85", "sample_input": "4\n1 3 4 2\n"}, "reference_outputs": ["20\n"], "source_document_id": "p02709", "source_text": "Score : 500 points\n\nProblem Statement\n\nThere are N children standing in a line from left to right. The activeness of the i-th child from the left is A_i.\n\nYou can rearrange these children just one time in any order you like.\n\nWhen a child who originally occupies the x-th position from the left in the line moves to the y-th position from the left, that child earns A_x \\times |x-y| happiness points.\n\nFind the maximum total happiness points the children can earn.\n\nConstraints\n\n2 \\leq N \\leq 2000\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 total happiness points the children can earn.\n\nSample Input 1\n\n4\n1 3 4 2\n\nSample Output 1\n\n20\n\nIf we move the 1-st child from the left to the 3-rd position from the left, the 2-nd child to the 4-th position, the 3-rd child to the 1-st position, and the 4-th child to the 2-nd position, the children earns 1 \\times |1-3|+3 \\times |2-4|+4 \\times |3-1|+2 \\times |4-2|=20 happiness points in total.\n\nSample Input 2\n\n6\n5 5 6 1 1 1\n\nSample Output 2\n\n58\n\nSample Input 3\n\n6\n8 6 9 1 2 1\n\nSample Output 3\n\n85", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 4011, "cpu_time_ms": 180, "memory_kb": 66288}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s006134598", "group_id": "codeNet:p02710", "input_text": "@file:Suppress(\"NOTHING_TO_INLINE\", \"EXPERIMENTAL_FEATURE_WARNING\", \"OVERRIDE_BY_INLINE\")\n\nimport java.io.PrintWriter\nimport kotlin.math.*\nimport kotlin.random.Random\nimport kotlin.collections.sort as _sort\nimport kotlin.collections.sortDescending as _sortDescending\nimport kotlin.io.println as iprintln\n\n/** @author Spheniscine */\nfun main() { _writer.solve(); _writer.flush() }\nfun PrintWriter.solve() {\n val n = readInt()\n val C = IntArray(n) { readInt()-1 }\n val G = Array(n) { IntList() }.also { G ->\n repeat(n-1) {\n val u = readInt()-1\n val v = readInt()-1\n G[u].add(v)\n G[v].add(u)\n }\n }\n\n val sub = IntArray(n)\n val par = IntArray(n) { -1 }\n\n val S = IntList()\n S.add(1)\n\n while(S.isNotEmpty()) {\n val s = S.pop()\n val v = s ushr 1\n val in_ = s and 1 == 1\n if(in_) {\n sub[v] = 1\n S.add(v shl 1)\n for(u in G[v]) if(par[v] != u) {\n par[u] = v\n S.add(u shl 1 or 1)\n }\n } else {\n if(v != 0) {\n val u = par[v]\n sub[u] += sub[v]\n }\n }\n }\n\n val ntr = n.tr\n val ans = LongArray(n) { ntr }\n\n S.add(1)\n val K = Array(n) { IntList().also { it.add(n) } }\n\n while(S.isNotEmpty()) {\n val s = S.pop()\n val v = s ushr 1\n val in_ = s and 1 == 1\n if(in_) {\n val c = C[v]\n K[c].last -= sub[v]\n S.add(v shl 1)\n for(u in G[v]) if(par[v] != u) {\n K[c].add(sub[u])\n S.add(u shl 1 or 1)\n }\n } else {\n if(v != 0) {\n val u = par[v]\n val c = C[u]\n ans[c] -= K[c].pop().tr\n }\n }\n }\n for(i in 0 until n) ans[i] -= K[i][0].tr\n\n ans.forEach(::println)\n}\n\n\nval Int.tr get() = toLong() * plus(1) / 2\n\nvar IntList.last get() = get(lastIndex)\n set(value) {set(lastIndex, value)}\n\nfun HashMap.add(u: Int, v: Int) {\n getOrPut(u) { IntList() }.add(v)\n}\n\nclass IntList(initialCapacity: Int = 12) {\n private var _arr = IntArray(initialCapacity)\n private val capacity get() = _arr.size\n var size = 0\n private set\n inline val lastIndex get() = size - 1\n inline val indices get() = 0 until size\n\n constructor(copyFrom: IntArray): this(copyFrom.size) { copyFrom.copyInto(_arr) }\n constructor(copyFrom: Collection): this(copyFrom.size) { _arr = copyFrom.toIntArray() }\n\n fun contentEquals(other: IntList): Boolean {\n return this === other || size == other.size && indices.all { this[it] == other[it] }\n }\n\n private fun grow(minCapacity: Int = 8) {\n val newCapacity = maxOf(minCapacity, capacity + (capacity shr 1))\n _arr = _arr.copyOf(newCapacity)\n }\n\n fun ensureCapacity(minCapacity: Int) { if(capacity < minCapacity) grow(minCapacity) }\n\n operator fun get(index: Int): Int {\n require(index in 0 until size)\n return _arr[index]\n }\n\n operator fun set(index: Int, value: Int) {\n require(index in 0 until size)\n _arr[index] = value\n }\n\n fun add(value: Int) {\n if(size == capacity) grow()\n _arr[size++] = value\n }\n\n fun add(index: Int, element: Int) {\n if(size == capacity) grow()\n _arr.copyInto(_arr, index + 1, index, size)\n size++\n set(index, element)\n }\n\n fun clear() { size = 0 }\n\n fun removeAt(index: Int): Int {\n val e = get(index)\n _arr.copyInto(_arr, index, index + 1, size)\n size--\n return e\n }\n\n operator fun iterator() = object: IntIterator() {\n private var pos = 0\n override fun hasNext() = pos < size\n override fun nextInt() = get(pos++)\n }\n\n inline fun isEmpty() = size == 0\n inline fun isNotEmpty() = size != 0\n\n fun pop() = _arr[--size]\n\n fun swap(i: Int, j: Int) { this[i] = this[j].also { this[j] = this[i]} }\n fun reverse() {\n for(i in 0 until size / 2) swap(i, lastIndex - i)\n }\n\n fun shuffle(rnd: Random = random) = _shuffle(rnd, _arr::get, _arr::set, size)\n fun sort() { shuffle(); _arr._sort(0, size) }\n fun sortDescending() { sort(); reverse() }\n\n fun joinToString(separator: String) = if(size == 0) \"\" else let {\n buildString {\n append(it[0])\n for (i in 1 until size) {\n append(separator).append(it[i])\n }\n }\n }\n\n override fun toString() = \"[\" + joinToString(\", \") + \"]\"\n\n fun toIntArray() = _arr.copyOf(size)\n fun toList() = List(size, ::get)\n\n inline fun first() = get(0)\n inline fun last() = get(lastIndex)\n}\n\ninline fun IntList(size: Int, init: (Int) -> Int) = IntList(size).apply {\n for(i in 0 until size) { add(init(i)) }\n}\ninline fun IntArray.toIntList() = IntList(this)\ninline fun Collection.toIntList() = IntList(this)\n\nfun IntList.max() = (1 until size).fold(this[0]) { acc, i -> max(acc, this[i]) }\nfun IntList.min() = (1 until size).fold(this[0]) { acc, i -> min(acc, this[i]) }\nfun IntList.getOrNull(i: Int) = if(i in indices) get(i) else null\ninline fun IntList.count(predicate: (Int) -> Boolean) = indices.count { predicate(this[it]) }\n\nfun MutableList.pop() = removeAt(lastIndex)\n\n/** IO code start */\n//@JvmField val INPUT = File(\"input.txt\").inputStream()\n//@JvmField val OUTPUT = File(\"output.txt\").outputStream()\n@JvmField val INPUT = System.`in`\n@JvmField val OUTPUT = System.out\n\n@JvmField val _reader = INPUT.bufferedReader()\nfun readLine(): String? = _reader.readLine()\nfun readLn() = _reader.readLine()!!\n@JvmField var _ln = \"\"\n@JvmField var _lnPtr = 0\nfun read(): String {\n while (_lnPtr >= _ln.length) {\n _ln = readLine() ?: return \"\"\n _lnPtr = 0\n }\n var j = _ln.indexOf(' ', _lnPtr)\n if(j < 0) j = _ln.length\n val res = _ln.substring(_lnPtr, j)\n _lnPtr = j + 1\n return res\n}\nfun readRem(): String /* reads remainder of current line */ =\n _ln.substring(min(_lnPtr, _ln.length)).also { _lnPtr = _ln.length }\nfun readInt() = read().toInt()\nfun readDouble() = read().toDouble()\nfun readLong() = read().toLong()\nfun readStrings(n: Int) = List(n) { read() }\nfun readLines(n: Int) = List(n) { readLn() }\nfun readInts(n: Int) = List(n) { read().toInt() }\nfun readIntArray(n: Int) = IntArray(n) { read().toInt() }\nfun readDoubles(n: Int) = List(n) { read().toDouble() }\nfun readDoubleArray(n: Int) = DoubleArray(n) { read().toDouble() }\nfun readLongs(n: Int) = List(n) { read().toLong() }\nfun readLongArray(n: Int) = LongArray(n) { read().toLong() }\n\n@JvmField val _writer = PrintWriter(OUTPUT, false)\n\n/** shuffles and sort overrides to avoid quicksort attacks */\nprivate inline fun _shuffle(rnd: Random, get: (Int) -> T, set: (Int, T) -> Unit, size: Int) {\n // Fisher-Yates shuffle algorithm\n for (i in size - 1 downTo 1) {\n val j = rnd.nextInt(i + 1)\n val temp = get(i)\n set(i, get(j))\n set(j, temp)\n }\n}\n\n@JvmField var _random: Random? = null\nval random get() = _random ?: Random(0x594E215C123 * System.nanoTime()).also { _random = it }\n\nfun IntArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\nfun IntArray.sort() { shuffle(); _sort() }\nfun IntArray.sortDescending() { shuffle(); _sortDescending() }\n\nfun LongArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\nfun LongArray.sort() { shuffle(); _sort() }\nfun LongArray.sortDescending() { shuffle(); _sortDescending() }\n\nfun DoubleArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\nfun DoubleArray.sort() { shuffle(); _sort() }\nfun DoubleArray.sortDescending() { shuffle(); _sortDescending() }\n\nfun CharArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\ninline fun CharArray.sort() { _sort() }\ninline fun CharArray.sortDescending() { _sortDescending() }\n\ninline fun > Array.sort() = _sort()\ninline fun > Array.sortDescending() = _sortDescending()\ninline fun > MutableList.sort() = _sort()\ninline fun > MutableList.sortDescending() = _sortDescending()\n\nfun `please stop removing these imports IntelliJ`() {\n iprintln(max(1, 2))\n}\n", "language": "Kotlin", "metadata": {"date": 1587515043, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02710.html", "problem_id": "p02710", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02710/input.txt", "sample_output_relpath": "derived/input_output/data/p02710/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02710/Kotlin/s006134598.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s006134598", "user_id": "u596111103"}, "prompt_components": {"gold_output": "5\n4\n0\n", "input_to_evaluate": "@file:Suppress(\"NOTHING_TO_INLINE\", \"EXPERIMENTAL_FEATURE_WARNING\", \"OVERRIDE_BY_INLINE\")\n\nimport java.io.PrintWriter\nimport kotlin.math.*\nimport kotlin.random.Random\nimport kotlin.collections.sort as _sort\nimport kotlin.collections.sortDescending as _sortDescending\nimport kotlin.io.println as iprintln\n\n/** @author Spheniscine */\nfun main() { _writer.solve(); _writer.flush() }\nfun PrintWriter.solve() {\n val n = readInt()\n val C = IntArray(n) { readInt()-1 }\n val G = Array(n) { IntList() }.also { G ->\n repeat(n-1) {\n val u = readInt()-1\n val v = readInt()-1\n G[u].add(v)\n G[v].add(u)\n }\n }\n\n val sub = IntArray(n)\n val par = IntArray(n) { -1 }\n\n val S = IntList()\n S.add(1)\n\n while(S.isNotEmpty()) {\n val s = S.pop()\n val v = s ushr 1\n val in_ = s and 1 == 1\n if(in_) {\n sub[v] = 1\n S.add(v shl 1)\n for(u in G[v]) if(par[v] != u) {\n par[u] = v\n S.add(u shl 1 or 1)\n }\n } else {\n if(v != 0) {\n val u = par[v]\n sub[u] += sub[v]\n }\n }\n }\n\n val ntr = n.tr\n val ans = LongArray(n) { ntr }\n\n S.add(1)\n val K = Array(n) { IntList().also { it.add(n) } }\n\n while(S.isNotEmpty()) {\n val s = S.pop()\n val v = s ushr 1\n val in_ = s and 1 == 1\n if(in_) {\n val c = C[v]\n K[c].last -= sub[v]\n S.add(v shl 1)\n for(u in G[v]) if(par[v] != u) {\n K[c].add(sub[u])\n S.add(u shl 1 or 1)\n }\n } else {\n if(v != 0) {\n val u = par[v]\n val c = C[u]\n ans[c] -= K[c].pop().tr\n }\n }\n }\n for(i in 0 until n) ans[i] -= K[i][0].tr\n\n ans.forEach(::println)\n}\n\n\nval Int.tr get() = toLong() * plus(1) / 2\n\nvar IntList.last get() = get(lastIndex)\n set(value) {set(lastIndex, value)}\n\nfun HashMap.add(u: Int, v: Int) {\n getOrPut(u) { IntList() }.add(v)\n}\n\nclass IntList(initialCapacity: Int = 12) {\n private var _arr = IntArray(initialCapacity)\n private val capacity get() = _arr.size\n var size = 0\n private set\n inline val lastIndex get() = size - 1\n inline val indices get() = 0 until size\n\n constructor(copyFrom: IntArray): this(copyFrom.size) { copyFrom.copyInto(_arr) }\n constructor(copyFrom: Collection): this(copyFrom.size) { _arr = copyFrom.toIntArray() }\n\n fun contentEquals(other: IntList): Boolean {\n return this === other || size == other.size && indices.all { this[it] == other[it] }\n }\n\n private fun grow(minCapacity: Int = 8) {\n val newCapacity = maxOf(minCapacity, capacity + (capacity shr 1))\n _arr = _arr.copyOf(newCapacity)\n }\n\n fun ensureCapacity(minCapacity: Int) { if(capacity < minCapacity) grow(minCapacity) }\n\n operator fun get(index: Int): Int {\n require(index in 0 until size)\n return _arr[index]\n }\n\n operator fun set(index: Int, value: Int) {\n require(index in 0 until size)\n _arr[index] = value\n }\n\n fun add(value: Int) {\n if(size == capacity) grow()\n _arr[size++] = value\n }\n\n fun add(index: Int, element: Int) {\n if(size == capacity) grow()\n _arr.copyInto(_arr, index + 1, index, size)\n size++\n set(index, element)\n }\n\n fun clear() { size = 0 }\n\n fun removeAt(index: Int): Int {\n val e = get(index)\n _arr.copyInto(_arr, index, index + 1, size)\n size--\n return e\n }\n\n operator fun iterator() = object: IntIterator() {\n private var pos = 0\n override fun hasNext() = pos < size\n override fun nextInt() = get(pos++)\n }\n\n inline fun isEmpty() = size == 0\n inline fun isNotEmpty() = size != 0\n\n fun pop() = _arr[--size]\n\n fun swap(i: Int, j: Int) { this[i] = this[j].also { this[j] = this[i]} }\n fun reverse() {\n for(i in 0 until size / 2) swap(i, lastIndex - i)\n }\n\n fun shuffle(rnd: Random = random) = _shuffle(rnd, _arr::get, _arr::set, size)\n fun sort() { shuffle(); _arr._sort(0, size) }\n fun sortDescending() { sort(); reverse() }\n\n fun joinToString(separator: String) = if(size == 0) \"\" else let {\n buildString {\n append(it[0])\n for (i in 1 until size) {\n append(separator).append(it[i])\n }\n }\n }\n\n override fun toString() = \"[\" + joinToString(\", \") + \"]\"\n\n fun toIntArray() = _arr.copyOf(size)\n fun toList() = List(size, ::get)\n\n inline fun first() = get(0)\n inline fun last() = get(lastIndex)\n}\n\ninline fun IntList(size: Int, init: (Int) -> Int) = IntList(size).apply {\n for(i in 0 until size) { add(init(i)) }\n}\ninline fun IntArray.toIntList() = IntList(this)\ninline fun Collection.toIntList() = IntList(this)\n\nfun IntList.max() = (1 until size).fold(this[0]) { acc, i -> max(acc, this[i]) }\nfun IntList.min() = (1 until size).fold(this[0]) { acc, i -> min(acc, this[i]) }\nfun IntList.getOrNull(i: Int) = if(i in indices) get(i) else null\ninline fun IntList.count(predicate: (Int) -> Boolean) = indices.count { predicate(this[it]) }\n\nfun MutableList.pop() = removeAt(lastIndex)\n\n/** IO code start */\n//@JvmField val INPUT = File(\"input.txt\").inputStream()\n//@JvmField val OUTPUT = File(\"output.txt\").outputStream()\n@JvmField val INPUT = System.`in`\n@JvmField val OUTPUT = System.out\n\n@JvmField val _reader = INPUT.bufferedReader()\nfun readLine(): String? = _reader.readLine()\nfun readLn() = _reader.readLine()!!\n@JvmField var _ln = \"\"\n@JvmField var _lnPtr = 0\nfun read(): String {\n while (_lnPtr >= _ln.length) {\n _ln = readLine() ?: return \"\"\n _lnPtr = 0\n }\n var j = _ln.indexOf(' ', _lnPtr)\n if(j < 0) j = _ln.length\n val res = _ln.substring(_lnPtr, j)\n _lnPtr = j + 1\n return res\n}\nfun readRem(): String /* reads remainder of current line */ =\n _ln.substring(min(_lnPtr, _ln.length)).also { _lnPtr = _ln.length }\nfun readInt() = read().toInt()\nfun readDouble() = read().toDouble()\nfun readLong() = read().toLong()\nfun readStrings(n: Int) = List(n) { read() }\nfun readLines(n: Int) = List(n) { readLn() }\nfun readInts(n: Int) = List(n) { read().toInt() }\nfun readIntArray(n: Int) = IntArray(n) { read().toInt() }\nfun readDoubles(n: Int) = List(n) { read().toDouble() }\nfun readDoubleArray(n: Int) = DoubleArray(n) { read().toDouble() }\nfun readLongs(n: Int) = List(n) { read().toLong() }\nfun readLongArray(n: Int) = LongArray(n) { read().toLong() }\n\n@JvmField val _writer = PrintWriter(OUTPUT, false)\n\n/** shuffles and sort overrides to avoid quicksort attacks */\nprivate inline fun _shuffle(rnd: Random, get: (Int) -> T, set: (Int, T) -> Unit, size: Int) {\n // Fisher-Yates shuffle algorithm\n for (i in size - 1 downTo 1) {\n val j = rnd.nextInt(i + 1)\n val temp = get(i)\n set(i, get(j))\n set(j, temp)\n }\n}\n\n@JvmField var _random: Random? = null\nval random get() = _random ?: Random(0x594E215C123 * System.nanoTime()).also { _random = it }\n\nfun IntArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\nfun IntArray.sort() { shuffle(); _sort() }\nfun IntArray.sortDescending() { shuffle(); _sortDescending() }\n\nfun LongArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\nfun LongArray.sort() { shuffle(); _sort() }\nfun LongArray.sortDescending() { shuffle(); _sortDescending() }\n\nfun DoubleArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\nfun DoubleArray.sort() { shuffle(); _sort() }\nfun DoubleArray.sortDescending() { shuffle(); _sortDescending() }\n\nfun CharArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\ninline fun CharArray.sort() { _sort() }\ninline fun CharArray.sortDescending() { _sortDescending() }\n\ninline fun > Array.sort() = _sort()\ninline fun > Array.sortDescending() = _sortDescending()\ninline fun > MutableList.sort() = _sort()\ninline fun > MutableList.sortDescending() = _sortDescending()\n\nfun `please stop removing these imports IntelliJ`() {\n iprintln(max(1, 2))\n}\n", "problem_context": "Score : 600 points\n\nProblem Statement\n\nWe have a tree with N vertices numbered 1 to N. The i-th edge in this tree connects Vertex a_i and b_i.\nAdditionally, each vertex is painted in a color, and the color of Vertex i is c_i. Here, the color of each vertex is represented by an integer between 1 and N (inclusive). The same integer corresponds to the same color; different integers correspond to different colors.\n\nFor each k=1, 2, ..., N, solve the following problem:\n\nFind the number of simple paths that visit a vertex painted in the color k one or more times.\n\nNote: The simple paths from Vertex u to v and from v to u are not distinguished.\n\nConstraints\n\n1 \\leq N \\leq 2 \\times 10^5\n\n1 \\leq c_i \\leq N\n\n1 \\leq a_i,b_i \\leq N\n\nThe given graph is a tree.\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 ... c_N\na_1 b_1\n:\na_{N-1} b_{N-1}\n\nOutput\n\nPrint the answers for k = 1, 2, ..., N in order, each in its own line.\n\nSample Input 1\n\n3\n1 2 1\n1 2\n2 3\n\nSample Output 1\n\n5\n4\n0\n\nLet P_{i,j} denote the simple path connecting Vertex i and j.\n\nThere are 5 simple paths that visit a vertex painted in the color 1 one or more times:\n\nP_{1,1}\\,,\\,\nP_{1,2}\\,,\\,\nP_{1,3}\\,,\\,\nP_{2,3}\\,,\\,\nP_{3,3}\n\nThere are 4 simple paths that visit a vertex painted in the color 2 one or more times:\n\nP_{1,2}\\,,\\,\nP_{1,3}\\,,\\,\nP_{2,2}\\,,\\,\nP_{2,3}\n\nThere are no simple paths that visit a vertex painted in the color 3 one or more times.\n\nSample Input 2\n\n1\n1\n\nSample Output 2\n\n1\n\nSample Input 3\n\n2\n1 2\n1 2\n\nSample Output 3\n\n2\n2\n\nSample Input 4\n\n5\n1 2 3 4 5\n1 2\n2 3\n3 4\n3 5\n\nSample Output 4\n\n5\n8\n10\n5\n5\n\nSample Input 5\n\n8\n2 7 2 5 4 1 7 5\n3 1\n1 2\n2 7\n4 5\n5 6\n6 8\n7 8\n\nSample Output 5\n\n18\n15\n0\n14\n23\n0\n23\n0", "sample_input": "3\n1 2 1\n1 2\n2 3\n"}, "reference_outputs": ["5\n4\n0\n"], "source_document_id": "p02710", "source_text": "Score : 600 points\n\nProblem Statement\n\nWe have a tree with N vertices numbered 1 to N. The i-th edge in this tree connects Vertex a_i and b_i.\nAdditionally, each vertex is painted in a color, and the color of Vertex i is c_i. Here, the color of each vertex is represented by an integer between 1 and N (inclusive). The same integer corresponds to the same color; different integers correspond to different colors.\n\nFor each k=1, 2, ..., N, solve the following problem:\n\nFind the number of simple paths that visit a vertex painted in the color k one or more times.\n\nNote: The simple paths from Vertex u to v and from v to u are not distinguished.\n\nConstraints\n\n1 \\leq N \\leq 2 \\times 10^5\n\n1 \\leq c_i \\leq N\n\n1 \\leq a_i,b_i \\leq N\n\nThe given graph is a tree.\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 ... c_N\na_1 b_1\n:\na_{N-1} b_{N-1}\n\nOutput\n\nPrint the answers for k = 1, 2, ..., N in order, each in its own line.\n\nSample Input 1\n\n3\n1 2 1\n1 2\n2 3\n\nSample Output 1\n\n5\n4\n0\n\nLet P_{i,j} denote the simple path connecting Vertex i and j.\n\nThere are 5 simple paths that visit a vertex painted in the color 1 one or more times:\n\nP_{1,1}\\,,\\,\nP_{1,2}\\,,\\,\nP_{1,3}\\,,\\,\nP_{2,3}\\,,\\,\nP_{3,3}\n\nThere are 4 simple paths that visit a vertex painted in the color 2 one or more times:\n\nP_{1,2}\\,,\\,\nP_{1,3}\\,,\\,\nP_{2,2}\\,,\\,\nP_{2,3}\n\nThere are no simple paths that visit a vertex painted in the color 3 one or more times.\n\nSample Input 2\n\n1\n1\n\nSample Output 2\n\n1\n\nSample Input 3\n\n2\n1 2\n1 2\n\nSample Output 3\n\n2\n2\n\nSample Input 4\n\n5\n1 2 3 4 5\n1 2\n2 3\n3 4\n3 5\n\nSample Output 4\n\n5\n8\n10\n5\n5\n\nSample Input 5\n\n8\n2 7 2 5 4 1 7 5\n3 1\n1 2\n2 7\n4 5\n5 6\n6 8\n7 8\n\nSample Output 5\n\n18\n15\n0\n14\n23\n0\n23\n0", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 8303, "cpu_time_ms": 887, "memory_kb": 102200}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s042664776", "group_id": "codeNet:p02710", "input_text": "@file:Suppress(\"NOTHING_TO_INLINE\", \"EXPERIMENTAL_FEATURE_WARNING\", \"OVERRIDE_BY_INLINE\")\n\nimport java.io.PrintWriter\nimport kotlin.math.*\nimport kotlin.random.Random\nimport kotlin.collections.sort as _sort\nimport kotlin.collections.sortDescending as _sortDescending\nimport kotlin.io.println as iprintln\n\n/** @author Spheniscine */\nfun main() { _writer.solve(); _writer.flush() }\nfun PrintWriter.solve() {\n object {\n val n = readInt()\n val C = IntArray(n) { readInt()-1 }\n val G = Array(n) { IntList() }.also { G ->\n repeat(n-1) {\n val u = readInt()-1\n val v = readInt()-1\n G[u].add(v)\n G[v].add(u)\n }\n }\n\n val sub = IntArray(n)\n val par = IntArray(n) { -1 }\n val H = Array(n) { HashMap() }\n\n fun dfs() {\n val S = IntList()\n S.add(1)\n val CS = Array(n) { IntList().also { it.add(0) } }\n\n while(S.isNotEmpty()) {\n val s = S.pop()\n val v = s ushr 1\n val in_ = s and 1 == 1\n if(in_) {\n sub[v] = 1\n val c = C[v]\n H[c].add(CS[c].last(), v)\n S.add(v shl 1)\n for(u in G[v]) if(par[v] != u) {\n par[u] = v\n CS[c].add(u)\n S.add(u shl 1 or 1)\n }\n } else {\n if(v != 0) {\n val u = par[v]\n sub[u] += sub[v]\n CS[C[u]].pop()\n }\n }\n }\n }\n\n val ntr = n.tr\n\n fun dfs2(k: Int): Long {\n var ans = ntr\n val S = IntList()\n S.add(0)\n while(S.isNotEmpty()) {\n val v = S.pop()\n var con = sub[v]\n H[k][v]?.let { h ->\n for (u in h) {\n con -= sub[u]\n for (t in G[u]) if (par[t] == u) S.add(t)\n }\n }\n ans -= con.tr\n }\n return ans\n }\n\n init {\n dfs()\n for(i in 0 until n) {\n val ans = dfs2(i)\n println(ans)\n }\n }\n }\n}\n\ndata class StackEntry(val v: Int, val in_: Boolean)\nfun MutableList.pop() = removeAt(lastIndex)\n\nval Int.tr get() = toLong() * plus(1) / 2\n\nfun HashMap.add(u: Int, v: Int) {\n getOrPut(u) { IntList() }.add(v)\n}\n\nclass IntList(initialCapacity: Int = 12) {\n private var _arr = IntArray(initialCapacity)\n private val capacity get() = _arr.size\n var size = 0\n private set\n inline val lastIndex get() = size - 1\n inline val indices get() = 0 until size\n\n constructor(copyFrom: IntArray): this(copyFrom.size) { copyFrom.copyInto(_arr) }\n constructor(copyFrom: Collection): this(copyFrom.size) { _arr = copyFrom.toIntArray() }\n\n fun contentEquals(other: IntList): Boolean {\n return this === other || size == other.size && indices.all { this[it] == other[it] }\n }\n\n private fun grow(minCapacity: Int = 8) {\n val newCapacity = maxOf(minCapacity, capacity + (capacity shr 1))\n _arr = _arr.copyOf(newCapacity)\n }\n\n fun ensureCapacity(minCapacity: Int) { if(capacity < minCapacity) grow(minCapacity) }\n\n operator fun get(index: Int): Int {\n require(index in 0 until size)\n return _arr[index]\n }\n\n operator fun set(index: Int, value: Int) {\n require(index in 0 until size)\n _arr[index] = value\n }\n\n fun add(value: Int) {\n if(size == capacity) grow()\n _arr[size++] = value\n }\n\n fun add(index: Int, element: Int) {\n if(size == capacity) grow()\n _arr.copyInto(_arr, index + 1, index, size)\n size++\n set(index, element)\n }\n\n fun clear() { size = 0 }\n\n fun removeAt(index: Int): Int {\n val e = get(index)\n _arr.copyInto(_arr, index, index + 1, size)\n size--\n return e\n }\n\n operator fun iterator() = object: IntIterator() {\n private var pos = 0\n override fun hasNext() = pos < size\n override fun nextInt() = get(pos++)\n }\n\n inline fun isEmpty() = size == 0\n inline fun isNotEmpty() = size != 0\n\n fun pop() = _arr[--size]\n\n fun swap(i: Int, j: Int) { this[i] = this[j].also { this[j] = this[i]} }\n fun reverse() {\n for(i in 0 until size / 2) swap(i, lastIndex - i)\n }\n\n fun shuffle(rnd: Random = random) = _shuffle(rnd, _arr::get, _arr::set, size)\n fun sort() { shuffle(); _arr._sort(0, size) }\n fun sortDescending() { sort(); reverse() }\n\n fun joinToString(separator: String) = if(size == 0) \"\" else let {\n buildString {\n append(it[0])\n for (i in 1 until size) {\n append(separator).append(it[i])\n }\n }\n }\n\n override fun toString() = \"[\" + joinToString(\", \") + \"]\"\n\n fun toIntArray() = _arr.copyOf(size)\n fun toList() = List(size, ::get)\n\n inline fun first() = get(0)\n inline fun last() = get(lastIndex)\n}\n\ninline fun IntList(size: Int, init: (Int) -> Int) = IntList(size).apply {\n for(i in 0 until size) { add(init(i)) }\n}\ninline fun IntArray.toIntList() = IntList(this)\ninline fun Collection.toIntList() = IntList(this)\n\nfun IntList.max() = (1 until size).fold(this[0]) { acc, i -> max(acc, this[i]) }\nfun IntList.min() = (1 until size).fold(this[0]) { acc, i -> min(acc, this[i]) }\nfun IntList.getOrNull(i: Int) = if(i in indices) get(i) else null\ninline fun IntList.count(predicate: (Int) -> Boolean) = indices.count { predicate(this[it]) }\n\n/** IO code start */\n//@JvmField val INPUT = File(\"input.txt\").inputStream()\n//@JvmField val OUTPUT = File(\"output.txt\").outputStream()\n@JvmField val INPUT = System.`in`\n@JvmField val OUTPUT = System.out\n\n@JvmField val _reader = INPUT.bufferedReader()\nfun readLine(): String? = _reader.readLine()\nfun readLn() = _reader.readLine()!!\n@JvmField var _ln = \"\"\n@JvmField var _lnPtr = 0\nfun read(): String {\n while (_lnPtr >= _ln.length) {\n _ln = readLine() ?: return \"\"\n _lnPtr = 0\n }\n var j = _ln.indexOf(' ', _lnPtr)\n if(j < 0) j = _ln.length\n val res = _ln.substring(_lnPtr, j)\n _lnPtr = j + 1\n return res\n}\nfun readRem(): String /* reads remainder of current line */ =\n _ln.substring(min(_lnPtr, _ln.length)).also { _lnPtr = _ln.length }\nfun readInt() = read().toInt()\nfun readDouble() = read().toDouble()\nfun readLong() = read().toLong()\nfun readStrings(n: Int) = List(n) { read() }\nfun readLines(n: Int) = List(n) { readLn() }\nfun readInts(n: Int) = List(n) { read().toInt() }\nfun readIntArray(n: Int) = IntArray(n) { read().toInt() }\nfun readDoubles(n: Int) = List(n) { read().toDouble() }\nfun readDoubleArray(n: Int) = DoubleArray(n) { read().toDouble() }\nfun readLongs(n: Int) = List(n) { read().toLong() }\nfun readLongArray(n: Int) = LongArray(n) { read().toLong() }\n\n@JvmField val _writer = PrintWriter(OUTPUT, false)\n\n/** shuffles and sort overrides to avoid quicksort attacks */\nprivate inline fun _shuffle(rnd: Random, get: (Int) -> T, set: (Int, T) -> Unit, size: Int) {\n // Fisher-Yates shuffle algorithm\n for (i in size - 1 downTo 1) {\n val j = rnd.nextInt(i + 1)\n val temp = get(i)\n set(i, get(j))\n set(j, temp)\n }\n}\n\n@JvmField var _random: Random? = null\nval random get() = _random ?: Random(0x594E215C123 * System.nanoTime()).also { _random = it }\n\nfun IntArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\nfun IntArray.sort() { shuffle(); _sort() }\nfun IntArray.sortDescending() { shuffle(); _sortDescending() }\n\nfun LongArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\nfun LongArray.sort() { shuffle(); _sort() }\nfun LongArray.sortDescending() { shuffle(); _sortDescending() }\n\nfun DoubleArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\nfun DoubleArray.sort() { shuffle(); _sort() }\nfun DoubleArray.sortDescending() { shuffle(); _sortDescending() }\n\nfun CharArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\ninline fun CharArray.sort() { _sort() }\ninline fun CharArray.sortDescending() { _sortDescending() }\n\ninline fun > Array.sort() = _sort()\ninline fun > Array.sortDescending() = _sortDescending()\ninline fun > MutableList.sort() = _sort()\ninline fun > MutableList.sortDescending() = _sortDescending()\n\nfun `please stop removing these imports IntelliJ`() {\n iprintln(max(1, 2))\n}", "language": "Kotlin", "metadata": {"date": 1587510393, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02710.html", "problem_id": "p02710", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02710/input.txt", "sample_output_relpath": "derived/input_output/data/p02710/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02710/Kotlin/s042664776.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s042664776", "user_id": "u596111103"}, "prompt_components": {"gold_output": "5\n4\n0\n", "input_to_evaluate": "@file:Suppress(\"NOTHING_TO_INLINE\", \"EXPERIMENTAL_FEATURE_WARNING\", \"OVERRIDE_BY_INLINE\")\n\nimport java.io.PrintWriter\nimport kotlin.math.*\nimport kotlin.random.Random\nimport kotlin.collections.sort as _sort\nimport kotlin.collections.sortDescending as _sortDescending\nimport kotlin.io.println as iprintln\n\n/** @author Spheniscine */\nfun main() { _writer.solve(); _writer.flush() }\nfun PrintWriter.solve() {\n object {\n val n = readInt()\n val C = IntArray(n) { readInt()-1 }\n val G = Array(n) { IntList() }.also { G ->\n repeat(n-1) {\n val u = readInt()-1\n val v = readInt()-1\n G[u].add(v)\n G[v].add(u)\n }\n }\n\n val sub = IntArray(n)\n val par = IntArray(n) { -1 }\n val H = Array(n) { HashMap() }\n\n fun dfs() {\n val S = IntList()\n S.add(1)\n val CS = Array(n) { IntList().also { it.add(0) } }\n\n while(S.isNotEmpty()) {\n val s = S.pop()\n val v = s ushr 1\n val in_ = s and 1 == 1\n if(in_) {\n sub[v] = 1\n val c = C[v]\n H[c].add(CS[c].last(), v)\n S.add(v shl 1)\n for(u in G[v]) if(par[v] != u) {\n par[u] = v\n CS[c].add(u)\n S.add(u shl 1 or 1)\n }\n } else {\n if(v != 0) {\n val u = par[v]\n sub[u] += sub[v]\n CS[C[u]].pop()\n }\n }\n }\n }\n\n val ntr = n.tr\n\n fun dfs2(k: Int): Long {\n var ans = ntr\n val S = IntList()\n S.add(0)\n while(S.isNotEmpty()) {\n val v = S.pop()\n var con = sub[v]\n H[k][v]?.let { h ->\n for (u in h) {\n con -= sub[u]\n for (t in G[u]) if (par[t] == u) S.add(t)\n }\n }\n ans -= con.tr\n }\n return ans\n }\n\n init {\n dfs()\n for(i in 0 until n) {\n val ans = dfs2(i)\n println(ans)\n }\n }\n }\n}\n\ndata class StackEntry(val v: Int, val in_: Boolean)\nfun MutableList.pop() = removeAt(lastIndex)\n\nval Int.tr get() = toLong() * plus(1) / 2\n\nfun HashMap.add(u: Int, v: Int) {\n getOrPut(u) { IntList() }.add(v)\n}\n\nclass IntList(initialCapacity: Int = 12) {\n private var _arr = IntArray(initialCapacity)\n private val capacity get() = _arr.size\n var size = 0\n private set\n inline val lastIndex get() = size - 1\n inline val indices get() = 0 until size\n\n constructor(copyFrom: IntArray): this(copyFrom.size) { copyFrom.copyInto(_arr) }\n constructor(copyFrom: Collection): this(copyFrom.size) { _arr = copyFrom.toIntArray() }\n\n fun contentEquals(other: IntList): Boolean {\n return this === other || size == other.size && indices.all { this[it] == other[it] }\n }\n\n private fun grow(minCapacity: Int = 8) {\n val newCapacity = maxOf(minCapacity, capacity + (capacity shr 1))\n _arr = _arr.copyOf(newCapacity)\n }\n\n fun ensureCapacity(minCapacity: Int) { if(capacity < minCapacity) grow(minCapacity) }\n\n operator fun get(index: Int): Int {\n require(index in 0 until size)\n return _arr[index]\n }\n\n operator fun set(index: Int, value: Int) {\n require(index in 0 until size)\n _arr[index] = value\n }\n\n fun add(value: Int) {\n if(size == capacity) grow()\n _arr[size++] = value\n }\n\n fun add(index: Int, element: Int) {\n if(size == capacity) grow()\n _arr.copyInto(_arr, index + 1, index, size)\n size++\n set(index, element)\n }\n\n fun clear() { size = 0 }\n\n fun removeAt(index: Int): Int {\n val e = get(index)\n _arr.copyInto(_arr, index, index + 1, size)\n size--\n return e\n }\n\n operator fun iterator() = object: IntIterator() {\n private var pos = 0\n override fun hasNext() = pos < size\n override fun nextInt() = get(pos++)\n }\n\n inline fun isEmpty() = size == 0\n inline fun isNotEmpty() = size != 0\n\n fun pop() = _arr[--size]\n\n fun swap(i: Int, j: Int) { this[i] = this[j].also { this[j] = this[i]} }\n fun reverse() {\n for(i in 0 until size / 2) swap(i, lastIndex - i)\n }\n\n fun shuffle(rnd: Random = random) = _shuffle(rnd, _arr::get, _arr::set, size)\n fun sort() { shuffle(); _arr._sort(0, size) }\n fun sortDescending() { sort(); reverse() }\n\n fun joinToString(separator: String) = if(size == 0) \"\" else let {\n buildString {\n append(it[0])\n for (i in 1 until size) {\n append(separator).append(it[i])\n }\n }\n }\n\n override fun toString() = \"[\" + joinToString(\", \") + \"]\"\n\n fun toIntArray() = _arr.copyOf(size)\n fun toList() = List(size, ::get)\n\n inline fun first() = get(0)\n inline fun last() = get(lastIndex)\n}\n\ninline fun IntList(size: Int, init: (Int) -> Int) = IntList(size).apply {\n for(i in 0 until size) { add(init(i)) }\n}\ninline fun IntArray.toIntList() = IntList(this)\ninline fun Collection.toIntList() = IntList(this)\n\nfun IntList.max() = (1 until size).fold(this[0]) { acc, i -> max(acc, this[i]) }\nfun IntList.min() = (1 until size).fold(this[0]) { acc, i -> min(acc, this[i]) }\nfun IntList.getOrNull(i: Int) = if(i in indices) get(i) else null\ninline fun IntList.count(predicate: (Int) -> Boolean) = indices.count { predicate(this[it]) }\n\n/** IO code start */\n//@JvmField val INPUT = File(\"input.txt\").inputStream()\n//@JvmField val OUTPUT = File(\"output.txt\").outputStream()\n@JvmField val INPUT = System.`in`\n@JvmField val OUTPUT = System.out\n\n@JvmField val _reader = INPUT.bufferedReader()\nfun readLine(): String? = _reader.readLine()\nfun readLn() = _reader.readLine()!!\n@JvmField var _ln = \"\"\n@JvmField var _lnPtr = 0\nfun read(): String {\n while (_lnPtr >= _ln.length) {\n _ln = readLine() ?: return \"\"\n _lnPtr = 0\n }\n var j = _ln.indexOf(' ', _lnPtr)\n if(j < 0) j = _ln.length\n val res = _ln.substring(_lnPtr, j)\n _lnPtr = j + 1\n return res\n}\nfun readRem(): String /* reads remainder of current line */ =\n _ln.substring(min(_lnPtr, _ln.length)).also { _lnPtr = _ln.length }\nfun readInt() = read().toInt()\nfun readDouble() = read().toDouble()\nfun readLong() = read().toLong()\nfun readStrings(n: Int) = List(n) { read() }\nfun readLines(n: Int) = List(n) { readLn() }\nfun readInts(n: Int) = List(n) { read().toInt() }\nfun readIntArray(n: Int) = IntArray(n) { read().toInt() }\nfun readDoubles(n: Int) = List(n) { read().toDouble() }\nfun readDoubleArray(n: Int) = DoubleArray(n) { read().toDouble() }\nfun readLongs(n: Int) = List(n) { read().toLong() }\nfun readLongArray(n: Int) = LongArray(n) { read().toLong() }\n\n@JvmField val _writer = PrintWriter(OUTPUT, false)\n\n/** shuffles and sort overrides to avoid quicksort attacks */\nprivate inline fun _shuffle(rnd: Random, get: (Int) -> T, set: (Int, T) -> Unit, size: Int) {\n // Fisher-Yates shuffle algorithm\n for (i in size - 1 downTo 1) {\n val j = rnd.nextInt(i + 1)\n val temp = get(i)\n set(i, get(j))\n set(j, temp)\n }\n}\n\n@JvmField var _random: Random? = null\nval random get() = _random ?: Random(0x594E215C123 * System.nanoTime()).also { _random = it }\n\nfun IntArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\nfun IntArray.sort() { shuffle(); _sort() }\nfun IntArray.sortDescending() { shuffle(); _sortDescending() }\n\nfun LongArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\nfun LongArray.sort() { shuffle(); _sort() }\nfun LongArray.sortDescending() { shuffle(); _sortDescending() }\n\nfun DoubleArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\nfun DoubleArray.sort() { shuffle(); _sort() }\nfun DoubleArray.sortDescending() { shuffle(); _sortDescending() }\n\nfun CharArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\ninline fun CharArray.sort() { _sort() }\ninline fun CharArray.sortDescending() { _sortDescending() }\n\ninline fun > Array.sort() = _sort()\ninline fun > Array.sortDescending() = _sortDescending()\ninline fun > MutableList.sort() = _sort()\ninline fun > MutableList.sortDescending() = _sortDescending()\n\nfun `please stop removing these imports IntelliJ`() {\n iprintln(max(1, 2))\n}", "problem_context": "Score : 600 points\n\nProblem Statement\n\nWe have a tree with N vertices numbered 1 to N. The i-th edge in this tree connects Vertex a_i and b_i.\nAdditionally, each vertex is painted in a color, and the color of Vertex i is c_i. Here, the color of each vertex is represented by an integer between 1 and N (inclusive). The same integer corresponds to the same color; different integers correspond to different colors.\n\nFor each k=1, 2, ..., N, solve the following problem:\n\nFind the number of simple paths that visit a vertex painted in the color k one or more times.\n\nNote: The simple paths from Vertex u to v and from v to u are not distinguished.\n\nConstraints\n\n1 \\leq N \\leq 2 \\times 10^5\n\n1 \\leq c_i \\leq N\n\n1 \\leq a_i,b_i \\leq N\n\nThe given graph is a tree.\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 ... c_N\na_1 b_1\n:\na_{N-1} b_{N-1}\n\nOutput\n\nPrint the answers for k = 1, 2, ..., N in order, each in its own line.\n\nSample Input 1\n\n3\n1 2 1\n1 2\n2 3\n\nSample Output 1\n\n5\n4\n0\n\nLet P_{i,j} denote the simple path connecting Vertex i and j.\n\nThere are 5 simple paths that visit a vertex painted in the color 1 one or more times:\n\nP_{1,1}\\,,\\,\nP_{1,2}\\,,\\,\nP_{1,3}\\,,\\,\nP_{2,3}\\,,\\,\nP_{3,3}\n\nThere are 4 simple paths that visit a vertex painted in the color 2 one or more times:\n\nP_{1,2}\\,,\\,\nP_{1,3}\\,,\\,\nP_{2,2}\\,,\\,\nP_{2,3}\n\nThere are no simple paths that visit a vertex painted in the color 3 one or more times.\n\nSample Input 2\n\n1\n1\n\nSample Output 2\n\n1\n\nSample Input 3\n\n2\n1 2\n1 2\n\nSample Output 3\n\n2\n2\n\nSample Input 4\n\n5\n1 2 3 4 5\n1 2\n2 3\n3 4\n3 5\n\nSample Output 4\n\n5\n8\n10\n5\n5\n\nSample Input 5\n\n8\n2 7 2 5 4 1 7 5\n3 1\n1 2\n2 7\n4 5\n5 6\n6 8\n7 8\n\nSample Output 5\n\n18\n15\n0\n14\n23\n0\n23\n0", "sample_input": "3\n1 2 1\n1 2\n2 3\n"}, "reference_outputs": ["5\n4\n0\n"], "source_document_id": "p02710", "source_text": "Score : 600 points\n\nProblem Statement\n\nWe have a tree with N vertices numbered 1 to N. The i-th edge in this tree connects Vertex a_i and b_i.\nAdditionally, each vertex is painted in a color, and the color of Vertex i is c_i. Here, the color of each vertex is represented by an integer between 1 and N (inclusive). The same integer corresponds to the same color; different integers correspond to different colors.\n\nFor each k=1, 2, ..., N, solve the following problem:\n\nFind the number of simple paths that visit a vertex painted in the color k one or more times.\n\nNote: The simple paths from Vertex u to v and from v to u are not distinguished.\n\nConstraints\n\n1 \\leq N \\leq 2 \\times 10^5\n\n1 \\leq c_i \\leq N\n\n1 \\leq a_i,b_i \\leq N\n\nThe given graph is a tree.\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 ... c_N\na_1 b_1\n:\na_{N-1} b_{N-1}\n\nOutput\n\nPrint the answers for k = 1, 2, ..., N in order, each in its own line.\n\nSample Input 1\n\n3\n1 2 1\n1 2\n2 3\n\nSample Output 1\n\n5\n4\n0\n\nLet P_{i,j} denote the simple path connecting Vertex i and j.\n\nThere are 5 simple paths that visit a vertex painted in the color 1 one or more times:\n\nP_{1,1}\\,,\\,\nP_{1,2}\\,,\\,\nP_{1,3}\\,,\\,\nP_{2,3}\\,,\\,\nP_{3,3}\n\nThere are 4 simple paths that visit a vertex painted in the color 2 one or more times:\n\nP_{1,2}\\,,\\,\nP_{1,3}\\,,\\,\nP_{2,2}\\,,\\,\nP_{2,3}\n\nThere are no simple paths that visit a vertex painted in the color 3 one or more times.\n\nSample Input 2\n\n1\n1\n\nSample Output 2\n\n1\n\nSample Input 3\n\n2\n1 2\n1 2\n\nSample Output 3\n\n2\n2\n\nSample Input 4\n\n5\n1 2 3 4 5\n1 2\n2 3\n3 4\n3 5\n\nSample Output 4\n\n5\n8\n10\n5\n5\n\nSample Input 5\n\n8\n2 7 2 5 4 1 7 5\n3 1\n1 2\n2 7\n4 5\n5 6\n6 8\n7 8\n\nSample Output 5\n\n18\n15\n0\n14\n23\n0\n23\n0", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 8777, "cpu_time_ms": 1279, "memory_kb": 163508}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s831424932", "group_id": "codeNet:p02710", "input_text": "@file:Suppress(\"NOTHING_TO_INLINE\", \"EXPERIMENTAL_FEATURE_WARNING\", \"OVERRIDE_BY_INLINE\")\n\nimport java.io.PrintWriter\nimport kotlin.math.*\nimport kotlin.random.Random\nimport kotlin.collections.sort as _sort\nimport kotlin.collections.sortDescending as _sortDescending\nimport kotlin.io.println as iprintln\n\n/** @author Spheniscine */\nfun main() { _writer.solve(); _writer.flush() }\nfun PrintWriter.solve() {\n object {\n val n = readInt()\n val C = IntArray(n) { readInt()-1 }\n val G = Array(n) { IntList() }.also { G ->\n repeat(n-1) {\n val u = readInt()-1\n val v = readInt()-1\n G[u].add(v)\n G[v].add(u)\n }\n }\n\n val sub = IntArray(n)\n val par = IntArray(n) { -1 }\n val H = Array(n) { HashMap() }\n\n fun dfs() {\n val S = IntList()\n S.add(1)\n val CS = Array(n) { IntList().also { it.add(0) } }\n\n while(S.isNotEmpty()) {\n val s = S.pop()\n val v = s ushr 1\n val in_ = s and 1 == 1\n if(in_) {\n sub[v] = 1\n val c = C[v]\n H[c].add(CS[c].last(), v)\n S.add(v shl 1)\n for(u in G[v]) if(par[v] != u) {\n par[u] = v\n CS[c].add(u)\n S.add(u shl 1 or 1)\n }\n } else {\n if(v != 0) {\n val u = par[v]\n sub[u] += sub[v]\n CS[C[u]].pop()\n }\n }\n }\n }\n\n val nms2 = n.ms2\n var ans = 0L\n\n fun dfs2(k: Int) {\n val S = IntList()\n S.add(0)\n while(S.isNotEmpty()) {\n val v = S.pop()\n var con = sub[v]\n H[k][v]?.let { h ->\n for (u in h) {\n con -= sub[u]\n for (t in G[u]) if (par[t] == u) S.add(t)\n }\n }\n ans -= con.ms2\n }\n }\n\n init {\n dfs()\n for(i in 0 until n) {\n ans = nms2\n dfs2(i)\n println(ans)\n }\n }\n }\n}\n\ndata class StackEntry(val v: Int, val in_: Boolean)\nfun MutableList.pop() = removeAt(lastIndex)\n\nval Int.ms2 get() = toLong() * minus(1) / 2 + this\n\nfun HashMap.add(u: Int, v: Int) {\n getOrPut(u) { IntList() }.add(v)\n}\n\nclass IntList(initialCapacity: Int = 12) {\n private var _arr = IntArray(initialCapacity)\n private val capacity get() = _arr.size\n var size = 0\n private set\n inline val lastIndex get() = size - 1\n inline val indices get() = 0 until size\n\n constructor(copyFrom: IntArray): this(copyFrom.size) { copyFrom.copyInto(_arr) }\n constructor(copyFrom: Collection): this(copyFrom.size) { _arr = copyFrom.toIntArray() }\n\n fun contentEquals(other: IntList): Boolean {\n return this === other || size == other.size && indices.all { this[it] == other[it] }\n }\n\n private fun grow(minCapacity: Int = 8) {\n val newCapacity = maxOf(minCapacity, capacity + (capacity shr 1))\n _arr = _arr.copyOf(newCapacity)\n }\n\n fun ensureCapacity(minCapacity: Int) { if(capacity < minCapacity) grow(minCapacity) }\n\n operator fun get(index: Int): Int {\n require(index in 0 until size)\n return _arr[index]\n }\n\n operator fun set(index: Int, value: Int) {\n require(index in 0 until size)\n _arr[index] = value\n }\n\n fun add(value: Int) {\n if(size == capacity) grow()\n _arr[size++] = value\n }\n\n fun add(index: Int, element: Int) {\n if(size == capacity) grow()\n _arr.copyInto(_arr, index + 1, index, size)\n size++\n set(index, element)\n }\n\n fun clear() { size = 0 }\n\n fun removeAt(index: Int): Int {\n val e = get(index)\n _arr.copyInto(_arr, index, index + 1, size)\n size--\n return e\n }\n\n operator fun iterator() = object: IntIterator() {\n private var pos = 0\n override fun hasNext() = pos < size\n override fun nextInt() = get(pos++)\n }\n\n inline fun isEmpty() = size == 0\n inline fun isNotEmpty() = size != 0\n\n fun pop() = _arr[--size]\n\n fun swap(i: Int, j: Int) { this[i] = this[j].also { this[j] = this[i]} }\n fun reverse() {\n for(i in 0 until size / 2) swap(i, lastIndex - i)\n }\n\n fun shuffle(rnd: Random = random) = _shuffle(rnd, _arr::get, _arr::set, size)\n fun sort() { shuffle(); _arr._sort(0, size) }\n fun sortDescending() { sort(); reverse() }\n\n fun joinToString(separator: String) = if(size == 0) \"\" else let {\n buildString {\n append(it[0])\n for (i in 1 until size) {\n append(separator).append(it[i])\n }\n }\n }\n\n override fun toString() = \"[\" + joinToString(\", \") + \"]\"\n\n fun toIntArray() = _arr.copyOf(size)\n fun toList() = List(size, ::get)\n\n inline fun first() = get(0)\n inline fun last() = get(lastIndex)\n}\n\ninline fun IntList(size: Int, init: (Int) -> Int) = IntList(size).apply {\n for(i in 0 until size) { add(init(i)) }\n}\ninline fun IntArray.toIntList() = IntList(this)\ninline fun Collection.toIntList() = IntList(this)\n\nfun IntList.max() = (1 until size).fold(this[0]) { acc, i -> max(acc, this[i]) }\nfun IntList.min() = (1 until size).fold(this[0]) { acc, i -> min(acc, this[i]) }\nfun IntList.getOrNull(i: Int) = if(i in indices) get(i) else null\ninline fun IntList.count(predicate: (Int) -> Boolean) = indices.count { predicate(this[it]) }\n\n/** IO code start */\n//@JvmField val INPUT = File(\"input.txt\").inputStream()\n//@JvmField val OUTPUT = File(\"output.txt\").outputStream()\n@JvmField val INPUT = System.`in`\n@JvmField val OUTPUT = System.out\n\n@JvmField val _reader = INPUT.bufferedReader()\nfun readLine(): String? = _reader.readLine()\nfun readLn() = _reader.readLine()!!\n@JvmField var _ln = \"\"\n@JvmField var _lnPtr = 0\nfun read(): String {\n while (_lnPtr >= _ln.length) {\n _ln = readLine() ?: return \"\"\n _lnPtr = 0\n }\n var j = _ln.indexOf(' ', _lnPtr)\n if(j < 0) j = _ln.length\n val res = _ln.substring(_lnPtr, j)\n _lnPtr = j + 1\n return res\n}\nfun readRem(): String /* reads remainder of current line */ =\n _ln.substring(min(_lnPtr, _ln.length)).also { _lnPtr = _ln.length }\nfun readInt() = read().toInt()\nfun readDouble() = read().toDouble()\nfun readLong() = read().toLong()\nfun readStrings(n: Int) = List(n) { read() }\nfun readLines(n: Int) = List(n) { readLn() }\nfun readInts(n: Int) = List(n) { read().toInt() }\nfun readIntArray(n: Int) = IntArray(n) { read().toInt() }\nfun readDoubles(n: Int) = List(n) { read().toDouble() }\nfun readDoubleArray(n: Int) = DoubleArray(n) { read().toDouble() }\nfun readLongs(n: Int) = List(n) { read().toLong() }\nfun readLongArray(n: Int) = LongArray(n) { read().toLong() }\n\n@JvmField val _writer = PrintWriter(OUTPUT, false)\n\n/** shuffles and sort overrides to avoid quicksort attacks */\nprivate inline fun _shuffle(rnd: Random, get: (Int) -> T, set: (Int, T) -> Unit, size: Int) {\n // Fisher-Yates shuffle algorithm\n for (i in size - 1 downTo 1) {\n val j = rnd.nextInt(i + 1)\n val temp = get(i)\n set(i, get(j))\n set(j, temp)\n }\n}\n\n@JvmField var _random: Random? = null\nval random get() = _random ?: Random(0x594E215C123 * System.nanoTime()).also { _random = it }\n\nfun IntArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\nfun IntArray.sort() { shuffle(); _sort() }\nfun IntArray.sortDescending() { shuffle(); _sortDescending() }\n\nfun LongArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\nfun LongArray.sort() { shuffle(); _sort() }\nfun LongArray.sortDescending() { shuffle(); _sortDescending() }\n\nfun DoubleArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\nfun DoubleArray.sort() { shuffle(); _sort() }\nfun DoubleArray.sortDescending() { shuffle(); _sortDescending() }\n\nfun CharArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\ninline fun CharArray.sort() { _sort() }\ninline fun CharArray.sortDescending() { _sortDescending() }\n\ninline fun > Array.sort() = _sort()\ninline fun > Array.sortDescending() = _sortDescending()\ninline fun > MutableList.sort() = _sort()\ninline fun > MutableList.sortDescending() = _sortDescending()\n\nfun `please stop removing these imports IntelliJ`() {\n iprintln(max(1, 2))\n}", "language": "Kotlin", "metadata": {"date": 1587504339, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02710.html", "problem_id": "p02710", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02710/input.txt", "sample_output_relpath": "derived/input_output/data/p02710/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02710/Kotlin/s831424932.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s831424932", "user_id": "u596111103"}, "prompt_components": {"gold_output": "5\n4\n0\n", "input_to_evaluate": "@file:Suppress(\"NOTHING_TO_INLINE\", \"EXPERIMENTAL_FEATURE_WARNING\", \"OVERRIDE_BY_INLINE\")\n\nimport java.io.PrintWriter\nimport kotlin.math.*\nimport kotlin.random.Random\nimport kotlin.collections.sort as _sort\nimport kotlin.collections.sortDescending as _sortDescending\nimport kotlin.io.println as iprintln\n\n/** @author Spheniscine */\nfun main() { _writer.solve(); _writer.flush() }\nfun PrintWriter.solve() {\n object {\n val n = readInt()\n val C = IntArray(n) { readInt()-1 }\n val G = Array(n) { IntList() }.also { G ->\n repeat(n-1) {\n val u = readInt()-1\n val v = readInt()-1\n G[u].add(v)\n G[v].add(u)\n }\n }\n\n val sub = IntArray(n)\n val par = IntArray(n) { -1 }\n val H = Array(n) { HashMap() }\n\n fun dfs() {\n val S = IntList()\n S.add(1)\n val CS = Array(n) { IntList().also { it.add(0) } }\n\n while(S.isNotEmpty()) {\n val s = S.pop()\n val v = s ushr 1\n val in_ = s and 1 == 1\n if(in_) {\n sub[v] = 1\n val c = C[v]\n H[c].add(CS[c].last(), v)\n S.add(v shl 1)\n for(u in G[v]) if(par[v] != u) {\n par[u] = v\n CS[c].add(u)\n S.add(u shl 1 or 1)\n }\n } else {\n if(v != 0) {\n val u = par[v]\n sub[u] += sub[v]\n CS[C[u]].pop()\n }\n }\n }\n }\n\n val nms2 = n.ms2\n var ans = 0L\n\n fun dfs2(k: Int) {\n val S = IntList()\n S.add(0)\n while(S.isNotEmpty()) {\n val v = S.pop()\n var con = sub[v]\n H[k][v]?.let { h ->\n for (u in h) {\n con -= sub[u]\n for (t in G[u]) if (par[t] == u) S.add(t)\n }\n }\n ans -= con.ms2\n }\n }\n\n init {\n dfs()\n for(i in 0 until n) {\n ans = nms2\n dfs2(i)\n println(ans)\n }\n }\n }\n}\n\ndata class StackEntry(val v: Int, val in_: Boolean)\nfun MutableList.pop() = removeAt(lastIndex)\n\nval Int.ms2 get() = toLong() * minus(1) / 2 + this\n\nfun HashMap.add(u: Int, v: Int) {\n getOrPut(u) { IntList() }.add(v)\n}\n\nclass IntList(initialCapacity: Int = 12) {\n private var _arr = IntArray(initialCapacity)\n private val capacity get() = _arr.size\n var size = 0\n private set\n inline val lastIndex get() = size - 1\n inline val indices get() = 0 until size\n\n constructor(copyFrom: IntArray): this(copyFrom.size) { copyFrom.copyInto(_arr) }\n constructor(copyFrom: Collection): this(copyFrom.size) { _arr = copyFrom.toIntArray() }\n\n fun contentEquals(other: IntList): Boolean {\n return this === other || size == other.size && indices.all { this[it] == other[it] }\n }\n\n private fun grow(minCapacity: Int = 8) {\n val newCapacity = maxOf(minCapacity, capacity + (capacity shr 1))\n _arr = _arr.copyOf(newCapacity)\n }\n\n fun ensureCapacity(minCapacity: Int) { if(capacity < minCapacity) grow(minCapacity) }\n\n operator fun get(index: Int): Int {\n require(index in 0 until size)\n return _arr[index]\n }\n\n operator fun set(index: Int, value: Int) {\n require(index in 0 until size)\n _arr[index] = value\n }\n\n fun add(value: Int) {\n if(size == capacity) grow()\n _arr[size++] = value\n }\n\n fun add(index: Int, element: Int) {\n if(size == capacity) grow()\n _arr.copyInto(_arr, index + 1, index, size)\n size++\n set(index, element)\n }\n\n fun clear() { size = 0 }\n\n fun removeAt(index: Int): Int {\n val e = get(index)\n _arr.copyInto(_arr, index, index + 1, size)\n size--\n return e\n }\n\n operator fun iterator() = object: IntIterator() {\n private var pos = 0\n override fun hasNext() = pos < size\n override fun nextInt() = get(pos++)\n }\n\n inline fun isEmpty() = size == 0\n inline fun isNotEmpty() = size != 0\n\n fun pop() = _arr[--size]\n\n fun swap(i: Int, j: Int) { this[i] = this[j].also { this[j] = this[i]} }\n fun reverse() {\n for(i in 0 until size / 2) swap(i, lastIndex - i)\n }\n\n fun shuffle(rnd: Random = random) = _shuffle(rnd, _arr::get, _arr::set, size)\n fun sort() { shuffle(); _arr._sort(0, size) }\n fun sortDescending() { sort(); reverse() }\n\n fun joinToString(separator: String) = if(size == 0) \"\" else let {\n buildString {\n append(it[0])\n for (i in 1 until size) {\n append(separator).append(it[i])\n }\n }\n }\n\n override fun toString() = \"[\" + joinToString(\", \") + \"]\"\n\n fun toIntArray() = _arr.copyOf(size)\n fun toList() = List(size, ::get)\n\n inline fun first() = get(0)\n inline fun last() = get(lastIndex)\n}\n\ninline fun IntList(size: Int, init: (Int) -> Int) = IntList(size).apply {\n for(i in 0 until size) { add(init(i)) }\n}\ninline fun IntArray.toIntList() = IntList(this)\ninline fun Collection.toIntList() = IntList(this)\n\nfun IntList.max() = (1 until size).fold(this[0]) { acc, i -> max(acc, this[i]) }\nfun IntList.min() = (1 until size).fold(this[0]) { acc, i -> min(acc, this[i]) }\nfun IntList.getOrNull(i: Int) = if(i in indices) get(i) else null\ninline fun IntList.count(predicate: (Int) -> Boolean) = indices.count { predicate(this[it]) }\n\n/** IO code start */\n//@JvmField val INPUT = File(\"input.txt\").inputStream()\n//@JvmField val OUTPUT = File(\"output.txt\").outputStream()\n@JvmField val INPUT = System.`in`\n@JvmField val OUTPUT = System.out\n\n@JvmField val _reader = INPUT.bufferedReader()\nfun readLine(): String? = _reader.readLine()\nfun readLn() = _reader.readLine()!!\n@JvmField var _ln = \"\"\n@JvmField var _lnPtr = 0\nfun read(): String {\n while (_lnPtr >= _ln.length) {\n _ln = readLine() ?: return \"\"\n _lnPtr = 0\n }\n var j = _ln.indexOf(' ', _lnPtr)\n if(j < 0) j = _ln.length\n val res = _ln.substring(_lnPtr, j)\n _lnPtr = j + 1\n return res\n}\nfun readRem(): String /* reads remainder of current line */ =\n _ln.substring(min(_lnPtr, _ln.length)).also { _lnPtr = _ln.length }\nfun readInt() = read().toInt()\nfun readDouble() = read().toDouble()\nfun readLong() = read().toLong()\nfun readStrings(n: Int) = List(n) { read() }\nfun readLines(n: Int) = List(n) { readLn() }\nfun readInts(n: Int) = List(n) { read().toInt() }\nfun readIntArray(n: Int) = IntArray(n) { read().toInt() }\nfun readDoubles(n: Int) = List(n) { read().toDouble() }\nfun readDoubleArray(n: Int) = DoubleArray(n) { read().toDouble() }\nfun readLongs(n: Int) = List(n) { read().toLong() }\nfun readLongArray(n: Int) = LongArray(n) { read().toLong() }\n\n@JvmField val _writer = PrintWriter(OUTPUT, false)\n\n/** shuffles and sort overrides to avoid quicksort attacks */\nprivate inline fun _shuffle(rnd: Random, get: (Int) -> T, set: (Int, T) -> Unit, size: Int) {\n // Fisher-Yates shuffle algorithm\n for (i in size - 1 downTo 1) {\n val j = rnd.nextInt(i + 1)\n val temp = get(i)\n set(i, get(j))\n set(j, temp)\n }\n}\n\n@JvmField var _random: Random? = null\nval random get() = _random ?: Random(0x594E215C123 * System.nanoTime()).also { _random = it }\n\nfun IntArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\nfun IntArray.sort() { shuffle(); _sort() }\nfun IntArray.sortDescending() { shuffle(); _sortDescending() }\n\nfun LongArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\nfun LongArray.sort() { shuffle(); _sort() }\nfun LongArray.sortDescending() { shuffle(); _sortDescending() }\n\nfun DoubleArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\nfun DoubleArray.sort() { shuffle(); _sort() }\nfun DoubleArray.sortDescending() { shuffle(); _sortDescending() }\n\nfun CharArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\ninline fun CharArray.sort() { _sort() }\ninline fun CharArray.sortDescending() { _sortDescending() }\n\ninline fun > Array.sort() = _sort()\ninline fun > Array.sortDescending() = _sortDescending()\ninline fun > MutableList.sort() = _sort()\ninline fun > MutableList.sortDescending() = _sortDescending()\n\nfun `please stop removing these imports IntelliJ`() {\n iprintln(max(1, 2))\n}", "problem_context": "Score : 600 points\n\nProblem Statement\n\nWe have a tree with N vertices numbered 1 to N. The i-th edge in this tree connects Vertex a_i and b_i.\nAdditionally, each vertex is painted in a color, and the color of Vertex i is c_i. Here, the color of each vertex is represented by an integer between 1 and N (inclusive). The same integer corresponds to the same color; different integers correspond to different colors.\n\nFor each k=1, 2, ..., N, solve the following problem:\n\nFind the number of simple paths that visit a vertex painted in the color k one or more times.\n\nNote: The simple paths from Vertex u to v and from v to u are not distinguished.\n\nConstraints\n\n1 \\leq N \\leq 2 \\times 10^5\n\n1 \\leq c_i \\leq N\n\n1 \\leq a_i,b_i \\leq N\n\nThe given graph is a tree.\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 ... c_N\na_1 b_1\n:\na_{N-1} b_{N-1}\n\nOutput\n\nPrint the answers for k = 1, 2, ..., N in order, each in its own line.\n\nSample Input 1\n\n3\n1 2 1\n1 2\n2 3\n\nSample Output 1\n\n5\n4\n0\n\nLet P_{i,j} denote the simple path connecting Vertex i and j.\n\nThere are 5 simple paths that visit a vertex painted in the color 1 one or more times:\n\nP_{1,1}\\,,\\,\nP_{1,2}\\,,\\,\nP_{1,3}\\,,\\,\nP_{2,3}\\,,\\,\nP_{3,3}\n\nThere are 4 simple paths that visit a vertex painted in the color 2 one or more times:\n\nP_{1,2}\\,,\\,\nP_{1,3}\\,,\\,\nP_{2,2}\\,,\\,\nP_{2,3}\n\nThere are no simple paths that visit a vertex painted in the color 3 one or more times.\n\nSample Input 2\n\n1\n1\n\nSample Output 2\n\n1\n\nSample Input 3\n\n2\n1 2\n1 2\n\nSample Output 3\n\n2\n2\n\nSample Input 4\n\n5\n1 2 3 4 5\n1 2\n2 3\n3 4\n3 5\n\nSample Output 4\n\n5\n8\n10\n5\n5\n\nSample Input 5\n\n8\n2 7 2 5 4 1 7 5\n3 1\n1 2\n2 7\n4 5\n5 6\n6 8\n7 8\n\nSample Output 5\n\n18\n15\n0\n14\n23\n0\n23\n0", "sample_input": "3\n1 2 1\n1 2\n2 3\n"}, "reference_outputs": ["5\n4\n0\n"], "source_document_id": "p02710", "source_text": "Score : 600 points\n\nProblem Statement\n\nWe have a tree with N vertices numbered 1 to N. The i-th edge in this tree connects Vertex a_i and b_i.\nAdditionally, each vertex is painted in a color, and the color of Vertex i is c_i. Here, the color of each vertex is represented by an integer between 1 and N (inclusive). The same integer corresponds to the same color; different integers correspond to different colors.\n\nFor each k=1, 2, ..., N, solve the following problem:\n\nFind the number of simple paths that visit a vertex painted in the color k one or more times.\n\nNote: The simple paths from Vertex u to v and from v to u are not distinguished.\n\nConstraints\n\n1 \\leq N \\leq 2 \\times 10^5\n\n1 \\leq c_i \\leq N\n\n1 \\leq a_i,b_i \\leq N\n\nThe given graph is a tree.\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 ... c_N\na_1 b_1\n:\na_{N-1} b_{N-1}\n\nOutput\n\nPrint the answers for k = 1, 2, ..., N in order, each in its own line.\n\nSample Input 1\n\n3\n1 2 1\n1 2\n2 3\n\nSample Output 1\n\n5\n4\n0\n\nLet P_{i,j} denote the simple path connecting Vertex i and j.\n\nThere are 5 simple paths that visit a vertex painted in the color 1 one or more times:\n\nP_{1,1}\\,,\\,\nP_{1,2}\\,,\\,\nP_{1,3}\\,,\\,\nP_{2,3}\\,,\\,\nP_{3,3}\n\nThere are 4 simple paths that visit a vertex painted in the color 2 one or more times:\n\nP_{1,2}\\,,\\,\nP_{1,3}\\,,\\,\nP_{2,2}\\,,\\,\nP_{2,3}\n\nThere are no simple paths that visit a vertex painted in the color 3 one or more times.\n\nSample Input 2\n\n1\n1\n\nSample Output 2\n\n1\n\nSample Input 3\n\n2\n1 2\n1 2\n\nSample Output 3\n\n2\n2\n\nSample Input 4\n\n5\n1 2 3 4 5\n1 2\n2 3\n3 4\n3 5\n\nSample Output 4\n\n5\n8\n10\n5\n5\n\nSample Input 5\n\n8\n2 7 2 5 4 1 7 5\n3 1\n1 2\n2 7\n4 5\n5 6\n6 8\n7 8\n\nSample Output 5\n\n18\n15\n0\n14\n23\n0\n23\n0", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 8772, "cpu_time_ms": 1364, "memory_kb": 166808}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s460346191", "group_id": "codeNet:p02712", "input_text": "fun main(args: Array) {\n var n = readLine()!!.toInt()\n var ans = 0\n for (i in 1..n) {\n if (i%3 * i%5 > 0){\n ans += i\n }\n }\n println(ans)\n}\n", "language": "Kotlin", "metadata": {"date": 1588204602, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02712.html", "problem_id": "p02712", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02712/input.txt", "sample_output_relpath": "derived/input_output/data/p02712/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02712/Kotlin/s460346191.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s460346191", "user_id": "u906501980"}, "prompt_components": {"gold_output": "60\n", "input_to_evaluate": "fun main(args: Array) {\n var n = readLine()!!.toInt()\n var ans = 0\n for (i in 1..n) {\n if (i%3 * i%5 > 0){\n ans += i\n }\n }\n println(ans)\n}\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nLet us define the FizzBuzz sequence a_1,a_2,... as follows:\n\nIf both 3 and 5 divides i, a_i=\\mbox{FizzBuzz}.\n\nIf the above does not hold but 3 divides i, a_i=\\mbox{Fizz}.\n\nIf none of the above holds but 5 divides i, a_i=\\mbox{Buzz}.\n\nIf none of the above holds, a_i=i.\n\nFind the sum of all numbers among the first N terms of the FizzBuzz sequence.\n\nConstraints\n\n1 \\leq N \\leq 10^6\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the sum of all numbers among the first N terms of the FizzBuzz sequence.\n\nSample Input 1\n\n15\n\nSample Output 1\n\n60\n\nThe first 15 terms of the FizzBuzz sequence are:\n\n1,2,\\mbox{Fizz},4,\\mbox{Buzz},\\mbox{Fizz},7,8,\\mbox{Fizz},\\mbox{Buzz},11,\\mbox{Fizz},13,14,\\mbox{FizzBuzz}\n\nAmong them, numbers are 1,2,4,7,8,11,13,14, and the sum of them is 60.\n\nSample Input 2\n\n1000000\n\nSample Output 2\n\n266666333332\n\nWatch out for overflow.", "sample_input": "15\n"}, "reference_outputs": ["60\n"], "source_document_id": "p02712", "source_text": "Score : 200 points\n\nProblem Statement\n\nLet us define the FizzBuzz sequence a_1,a_2,... as follows:\n\nIf both 3 and 5 divides i, a_i=\\mbox{FizzBuzz}.\n\nIf the above does not hold but 3 divides i, a_i=\\mbox{Fizz}.\n\nIf none of the above holds but 5 divides i, a_i=\\mbox{Buzz}.\n\nIf none of the above holds, a_i=i.\n\nFind the sum of all numbers among the first N terms of the FizzBuzz sequence.\n\nConstraints\n\n1 \\leq N \\leq 10^6\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the sum of all numbers among the first N terms of the FizzBuzz sequence.\n\nSample Input 1\n\n15\n\nSample Output 1\n\n60\n\nThe first 15 terms of the FizzBuzz sequence are:\n\n1,2,\\mbox{Fizz},4,\\mbox{Buzz},\\mbox{Fizz},7,8,\\mbox{Fizz},\\mbox{Buzz},11,\\mbox{Fizz},13,14,\\mbox{FizzBuzz}\n\nAmong them, numbers are 1,2,4,7,8,11,13,14, and the sum of them is 60.\n\nSample Input 2\n\n1000000\n\nSample Output 2\n\n266666333332\n\nWatch out for overflow.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 86, "memory_kb": 34468}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s865959191", "group_id": "codeNet:p02712", "input_text": "fun main()=println((1..readLine()!!.toLong()).filter{it%3*(it%5)>0}.sum())", "language": "Kotlin", "metadata": {"date": 1586906677, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02712.html", "problem_id": "p02712", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02712/input.txt", "sample_output_relpath": "derived/input_output/data/p02712/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02712/Kotlin/s865959191.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s865959191", "user_id": "u059234158"}, "prompt_components": {"gold_output": "60\n", "input_to_evaluate": "fun main()=println((1..readLine()!!.toLong()).filter{it%3*(it%5)>0}.sum())", "problem_context": "Score : 200 points\n\nProblem Statement\n\nLet us define the FizzBuzz sequence a_1,a_2,... as follows:\n\nIf both 3 and 5 divides i, a_i=\\mbox{FizzBuzz}.\n\nIf the above does not hold but 3 divides i, a_i=\\mbox{Fizz}.\n\nIf none of the above holds but 5 divides i, a_i=\\mbox{Buzz}.\n\nIf none of the above holds, a_i=i.\n\nFind the sum of all numbers among the first N terms of the FizzBuzz sequence.\n\nConstraints\n\n1 \\leq N \\leq 10^6\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the sum of all numbers among the first N terms of the FizzBuzz sequence.\n\nSample Input 1\n\n15\n\nSample Output 1\n\n60\n\nThe first 15 terms of the FizzBuzz sequence are:\n\n1,2,\\mbox{Fizz},4,\\mbox{Buzz},\\mbox{Fizz},7,8,\\mbox{Fizz},\\mbox{Buzz},11,\\mbox{Fizz},13,14,\\mbox{FizzBuzz}\n\nAmong them, numbers are 1,2,4,7,8,11,13,14, and the sum of them is 60.\n\nSample Input 2\n\n1000000\n\nSample Output 2\n\n266666333332\n\nWatch out for overflow.", "sample_input": "15\n"}, "reference_outputs": ["60\n"], "source_document_id": "p02712", "source_text": "Score : 200 points\n\nProblem Statement\n\nLet us define the FizzBuzz sequence a_1,a_2,... as follows:\n\nIf both 3 and 5 divides i, a_i=\\mbox{FizzBuzz}.\n\nIf the above does not hold but 3 divides i, a_i=\\mbox{Fizz}.\n\nIf none of the above holds but 5 divides i, a_i=\\mbox{Buzz}.\n\nIf none of the above holds, a_i=i.\n\nFind the sum of all numbers among the first N terms of the FizzBuzz sequence.\n\nConstraints\n\n1 \\leq N \\leq 10^6\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the sum of all numbers among the first N terms of the FizzBuzz sequence.\n\nSample Input 1\n\n15\n\nSample Output 1\n\n60\n\nThe first 15 terms of the FizzBuzz sequence are:\n\n1,2,\\mbox{Fizz},4,\\mbox{Buzz},\\mbox{Fizz},7,8,\\mbox{Fizz},\\mbox{Buzz},11,\\mbox{Fizz},13,14,\\mbox{FizzBuzz}\n\nAmong them, numbers are 1,2,4,7,8,11,13,14, and the sum of them is 60.\n\nSample Input 2\n\n1000000\n\nSample Output 2\n\n266666333332\n\nWatch out for overflow.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 145, "memory_kb": 59088}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s528619263", "group_id": "codeNet:p02719", "input_text": "import java.lang.Long.min\nimport java.lang.Math.abs\n\n\nfun main (args:Array) {\n var (N, K) = readLine()!!.split(\" \").map(String::toLong)\n var minResult = N\n if (N > K) {\n N = N % K\n minResult = N\n }\n while (true) {\n N = abs(N - K)\n if (minResult == N) {\n break\n }\n minResult = min(N, minResult)\n }\n print(minResult)\n}\n", "language": "Kotlin", "metadata": {"date": 1593280474, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02719.html", "problem_id": "p02719", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02719/input.txt", "sample_output_relpath": "derived/input_output/data/p02719/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02719/Kotlin/s528619263.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s528619263", "user_id": "u838133978"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "import java.lang.Long.min\nimport java.lang.Math.abs\n\n\nfun main (args:Array) {\n var (N, K) = readLine()!!.split(\" \").map(String::toLong)\n var minResult = N\n if (N > K) {\n N = N % K\n minResult = N\n }\n while (true) {\n N = abs(N - K)\n if (minResult == N) {\n break\n }\n minResult = min(N, minResult)\n }\n print(minResult)\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nGiven any integer x, Aoki can do the operation below.\n\nOperation: Replace x with the absolute difference of x and K.\n\nYou are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.\n\nConstraints\n\n0 ≤ N ≤ 10^{18}\n\n1 ≤ K ≤ 10^{18}\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 value taken by N after Aoki does the operation zero or more times.\n\nSample Input 1\n\n7 4\n\nSample Output 1\n\n1\n\nInitially, N=7.\n\nAfter one operation, N becomes |7-4| = 3.\n\nAfter two operations, N becomes |3-4| = 1, which is the minimum value taken by N.\n\nSample Input 2\n\n2 6\n\nSample Output 2\n\n2\n\nN=2 after zero operations is the minimum.\n\nSample Input 3\n\n1000000000000000000 1\n\nSample Output 3\n\n0", "sample_input": "7 4\n"}, "reference_outputs": ["1\n"], "source_document_id": "p02719", "source_text": "Score : 300 points\n\nProblem Statement\n\nGiven any integer x, Aoki can do the operation below.\n\nOperation: Replace x with the absolute difference of x and K.\n\nYou are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.\n\nConstraints\n\n0 ≤ N ≤ 10^{18}\n\n1 ≤ K ≤ 10^{18}\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 value taken by N after Aoki does the operation zero or more times.\n\nSample Input 1\n\n7 4\n\nSample Output 1\n\n1\n\nInitially, N=7.\n\nAfter one operation, N becomes |7-4| = 3.\n\nAfter two operations, N becomes |3-4| = 1, which is the minimum value taken by N.\n\nSample Input 2\n\n2 6\n\nSample Output 2\n\n2\n\nN=2 after zero operations is the minimum.\n\nSample Input 3\n\n1000000000000000000 1\n\nSample Output 3\n\n0", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 399, "cpu_time_ms": 112, "memory_kb": 36468}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s150361844", "group_id": "codeNet:p02719", "input_text": "fun main(args: Array) {\n val (n, k) = readLine()!!.split(\" \").map { it.toLong() }\n if (n == 0L || n == 1L || k == 1L) {\n println(0)\n return\n }\n if ((n / k) <= 0) {\n val ans1 = Math.abs(n - k)\n val ans2 = Math.abs(k - ans1)\n val result = Math.min(n, Math.min(ans1, ans2))\n println(result)\n return\n }\n\n val ans1 = n % k\n val ans2 = k % ans1\n val result = Math.min(ans1, ans2)\n println(result)\n}", "language": "Kotlin", "metadata": {"date": 1586051803, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02719.html", "problem_id": "p02719", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02719/input.txt", "sample_output_relpath": "derived/input_output/data/p02719/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02719/Kotlin/s150361844.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s150361844", "user_id": "u897579945"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "fun main(args: Array) {\n val (n, k) = readLine()!!.split(\" \").map { it.toLong() }\n if (n == 0L || n == 1L || k == 1L) {\n println(0)\n return\n }\n if ((n / k) <= 0) {\n val ans1 = Math.abs(n - k)\n val ans2 = Math.abs(k - ans1)\n val result = Math.min(n, Math.min(ans1, ans2))\n println(result)\n return\n }\n\n val ans1 = n % k\n val ans2 = k % ans1\n val result = Math.min(ans1, ans2)\n println(result)\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nGiven any integer x, Aoki can do the operation below.\n\nOperation: Replace x with the absolute difference of x and K.\n\nYou are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.\n\nConstraints\n\n0 ≤ N ≤ 10^{18}\n\n1 ≤ K ≤ 10^{18}\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 value taken by N after Aoki does the operation zero or more times.\n\nSample Input 1\n\n7 4\n\nSample Output 1\n\n1\n\nInitially, N=7.\n\nAfter one operation, N becomes |7-4| = 3.\n\nAfter two operations, N becomes |3-4| = 1, which is the minimum value taken by N.\n\nSample Input 2\n\n2 6\n\nSample Output 2\n\n2\n\nN=2 after zero operations is the minimum.\n\nSample Input 3\n\n1000000000000000000 1\n\nSample Output 3\n\n0", "sample_input": "7 4\n"}, "reference_outputs": ["1\n"], "source_document_id": "p02719", "source_text": "Score : 300 points\n\nProblem Statement\n\nGiven any integer x, Aoki can do the operation below.\n\nOperation: Replace x with the absolute difference of x and K.\n\nYou are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.\n\nConstraints\n\n0 ≤ N ≤ 10^{18}\n\n1 ≤ K ≤ 10^{18}\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 value taken by N after Aoki does the operation zero or more times.\n\nSample Input 1\n\n7 4\n\nSample Output 1\n\n1\n\nInitially, N=7.\n\nAfter one operation, N becomes |7-4| = 3.\n\nAfter two operations, N becomes |3-4| = 1, which is the minimum value taken by N.\n\nSample Input 2\n\n2 6\n\nSample Output 2\n\n2\n\nN=2 after zero operations is the minimum.\n\nSample Input 3\n\n1000000000000000000 1\n\nSample Output 3\n\n0", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 476, "cpu_time_ms": 244, "memory_kb": 35980}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s900389401", "group_id": "codeNet:p02719", "input_text": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val n = sc.nextLong()\n val k = sc.nextLong()\n println(problem161c(n, k))\n}\n\nfun problem161c(n: Long, k: Long): Long {\n if (n == k) return 0\n var x = n\n if (x > k) {\n if (x % k == 0L) return 0\n var tmp = x\n var count = 0\n while (tmp > k) {\n tmp /= k\n count++\n// debugLog(\"a\", x)\n }\n x /= count\n var prev = Long.MAX_VALUE\n while (true) {\n prev = x\n x = Math.abs(x - k)\n// debugLog(\"b\", x)\n if (prev <= x) break\n }\n return prev\n }\n\n var prev: Long\n while (true) {\n prev = x\n x = Math.abs(x - k)\n if (prev <= x) {\n break\n }\n }\n return prev\n}", "language": "Kotlin", "metadata": {"date": 1586051309, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02719.html", "problem_id": "p02719", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02719/input.txt", "sample_output_relpath": "derived/input_output/data/p02719/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02719/Kotlin/s900389401.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s900389401", "user_id": "u073232808"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val n = sc.nextLong()\n val k = sc.nextLong()\n println(problem161c(n, k))\n}\n\nfun problem161c(n: Long, k: Long): Long {\n if (n == k) return 0\n var x = n\n if (x > k) {\n if (x % k == 0L) return 0\n var tmp = x\n var count = 0\n while (tmp > k) {\n tmp /= k\n count++\n// debugLog(\"a\", x)\n }\n x /= count\n var prev = Long.MAX_VALUE\n while (true) {\n prev = x\n x = Math.abs(x - k)\n// debugLog(\"b\", x)\n if (prev <= x) break\n }\n return prev\n }\n\n var prev: Long\n while (true) {\n prev = x\n x = Math.abs(x - k)\n if (prev <= x) {\n break\n }\n }\n return prev\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nGiven any integer x, Aoki can do the operation below.\n\nOperation: Replace x with the absolute difference of x and K.\n\nYou are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.\n\nConstraints\n\n0 ≤ N ≤ 10^{18}\n\n1 ≤ K ≤ 10^{18}\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 value taken by N after Aoki does the operation zero or more times.\n\nSample Input 1\n\n7 4\n\nSample Output 1\n\n1\n\nInitially, N=7.\n\nAfter one operation, N becomes |7-4| = 3.\n\nAfter two operations, N becomes |3-4| = 1, which is the minimum value taken by N.\n\nSample Input 2\n\n2 6\n\nSample Output 2\n\n2\n\nN=2 after zero operations is the minimum.\n\nSample Input 3\n\n1000000000000000000 1\n\nSample Output 3\n\n0", "sample_input": "7 4\n"}, "reference_outputs": ["1\n"], "source_document_id": "p02719", "source_text": "Score : 300 points\n\nProblem Statement\n\nGiven any integer x, Aoki can do the operation below.\n\nOperation: Replace x with the absolute difference of x and K.\n\nYou are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.\n\nConstraints\n\n0 ≤ N ≤ 10^{18}\n\n1 ≤ K ≤ 10^{18}\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 value taken by N after Aoki does the operation zero or more times.\n\nSample Input 1\n\n7 4\n\nSample Output 1\n\n1\n\nInitially, N=7.\n\nAfter one operation, N becomes |7-4| = 3.\n\nAfter two operations, N becomes |3-4| = 1, which is the minimum value taken by N.\n\nSample Input 2\n\n2 6\n\nSample Output 2\n\n2\n\nN=2 after zero operations is the minimum.\n\nSample Input 3\n\n1000000000000000000 1\n\nSample Output 3\n\n0", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 843, "cpu_time_ms": 2111, "memory_kb": 31268}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s182939658", "group_id": "codeNet:p02719", "input_text": "fun main(args: Array) {\n val (n, k) = readLine()!!.split(\" \").map { it.toLong() }\n if (n == 0L || n == 1L || k == 1L) {\n println(0)\n return\n }\n\n if (n % k == 0L) {\n println(0)\n return\n }\n\n val items = mutableSetOf(n)\n var x = n\n while (true) {\n x = Math.abs(x - k)\n if (items.contains(x)) {\n break\n }\n items.add(x)\n }\n val result = items.sorted()[0]\n println(result)\n}", "language": "Kotlin", "metadata": {"date": 1586051046, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02719.html", "problem_id": "p02719", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02719/input.txt", "sample_output_relpath": "derived/input_output/data/p02719/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02719/Kotlin/s182939658.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s182939658", "user_id": "u897579945"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "fun main(args: Array) {\n val (n, k) = readLine()!!.split(\" \").map { it.toLong() }\n if (n == 0L || n == 1L || k == 1L) {\n println(0)\n return\n }\n\n if (n % k == 0L) {\n println(0)\n return\n }\n\n val items = mutableSetOf(n)\n var x = n\n while (true) {\n x = Math.abs(x - k)\n if (items.contains(x)) {\n break\n }\n items.add(x)\n }\n val result = items.sorted()[0]\n println(result)\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nGiven any integer x, Aoki can do the operation below.\n\nOperation: Replace x with the absolute difference of x and K.\n\nYou are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.\n\nConstraints\n\n0 ≤ N ≤ 10^{18}\n\n1 ≤ K ≤ 10^{18}\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 value taken by N after Aoki does the operation zero or more times.\n\nSample Input 1\n\n7 4\n\nSample Output 1\n\n1\n\nInitially, N=7.\n\nAfter one operation, N becomes |7-4| = 3.\n\nAfter two operations, N becomes |3-4| = 1, which is the minimum value taken by N.\n\nSample Input 2\n\n2 6\n\nSample Output 2\n\n2\n\nN=2 after zero operations is the minimum.\n\nSample Input 3\n\n1000000000000000000 1\n\nSample Output 3\n\n0", "sample_input": "7 4\n"}, "reference_outputs": ["1\n"], "source_document_id": "p02719", "source_text": "Score : 300 points\n\nProblem Statement\n\nGiven any integer x, Aoki can do the operation below.\n\nOperation: Replace x with the absolute difference of x and K.\n\nYou are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.\n\nConstraints\n\n0 ≤ N ≤ 10^{18}\n\n1 ≤ K ≤ 10^{18}\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 value taken by N after Aoki does the operation zero or more times.\n\nSample Input 1\n\n7 4\n\nSample Output 1\n\n1\n\nInitially, N=7.\n\nAfter one operation, N becomes |7-4| = 3.\n\nAfter two operations, N becomes |3-4| = 1, which is the minimum value taken by N.\n\nSample Input 2\n\n2 6\n\nSample Output 2\n\n2\n\nN=2 after zero operations is the minimum.\n\nSample Input 3\n\n1000000000000000000 1\n\nSample Output 3\n\n0", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 476, "cpu_time_ms": 2115, "memory_kb": 257852}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s410802537", "group_id": "codeNet:p02719", "input_text": "private fun readLn() = readLine()!! // string line\nprivate fun readInt() = readLn().toInt() // single int\nprivate fun readLong() = readLn().toLong() // single long\nprivate fun readStrings() = readLn().split(\" \") // list of strings\nprivate fun readInts() = readStrings().map(String::toInt) // list of ints\nprivate fun readLongs() = readStrings().map(String::toLong) // list of longs\n\nfun main(args: Array) {\n val (n, k) = readLongs()\n var r = n % k\n println(Math.min(r, Math.abs(r - k)))\n}\n", "language": "Kotlin", "metadata": {"date": 1586049423, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02719.html", "problem_id": "p02719", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02719/input.txt", "sample_output_relpath": "derived/input_output/data/p02719/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02719/Kotlin/s410802537.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s410802537", "user_id": "u059223549"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "private fun readLn() = readLine()!! // string line\nprivate fun readInt() = readLn().toInt() // single int\nprivate fun readLong() = readLn().toLong() // single long\nprivate fun readStrings() = readLn().split(\" \") // list of strings\nprivate fun readInts() = readStrings().map(String::toInt) // list of ints\nprivate fun readLongs() = readStrings().map(String::toLong) // list of longs\n\nfun main(args: Array) {\n val (n, k) = readLongs()\n var r = n % k\n println(Math.min(r, Math.abs(r - k)))\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nGiven any integer x, Aoki can do the operation below.\n\nOperation: Replace x with the absolute difference of x and K.\n\nYou are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.\n\nConstraints\n\n0 ≤ N ≤ 10^{18}\n\n1 ≤ K ≤ 10^{18}\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 value taken by N after Aoki does the operation zero or more times.\n\nSample Input 1\n\n7 4\n\nSample Output 1\n\n1\n\nInitially, N=7.\n\nAfter one operation, N becomes |7-4| = 3.\n\nAfter two operations, N becomes |3-4| = 1, which is the minimum value taken by N.\n\nSample Input 2\n\n2 6\n\nSample Output 2\n\n2\n\nN=2 after zero operations is the minimum.\n\nSample Input 3\n\n1000000000000000000 1\n\nSample Output 3\n\n0", "sample_input": "7 4\n"}, "reference_outputs": ["1\n"], "source_document_id": "p02719", "source_text": "Score : 300 points\n\nProblem Statement\n\nGiven any integer x, Aoki can do the operation below.\n\nOperation: Replace x with the absolute difference of x and K.\n\nYou are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.\n\nConstraints\n\n0 ≤ N ≤ 10^{18}\n\n1 ≤ K ≤ 10^{18}\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 value taken by N after Aoki does the operation zero or more times.\n\nSample Input 1\n\n7 4\n\nSample Output 1\n\n1\n\nInitially, N=7.\n\nAfter one operation, N becomes |7-4| = 3.\n\nAfter two operations, N becomes |3-4| = 1, which is the minimum value taken by N.\n\nSample Input 2\n\n2 6\n\nSample Output 2\n\n2\n\nN=2 after zero operations is the minimum.\n\nSample Input 3\n\n1000000000000000000 1\n\nSample Output 3\n\n0", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 506, "cpu_time_ms": 270, "memory_kb": 37776}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s380230470", "group_id": "codeNet:p02722", "input_text": "fun main(args: Array) {\n val N = nextLong()\n var ans = 0\n divisor(N).drop(1).forEach { x ->\n var w = N\n while (w % x == 0L) w /= x\n if (w % x == 1L) ans += 1\n }\n ans += divisor(N - 1).drop(1).size\n println(ans)\n}\n\nfun divisor(value: Long) =\n (1 .. Math.sqrt(value.toDouble()).toLong())\n .filter { value % it == 0L }\n .map { listOf(it, value / it) }\n .flatten()\n .distinct()\n .sorted()\n\n\nfun next() = readLine()!!\nfun nextLong() = next().toLong()\n\n", "language": "Kotlin", "metadata": {"date": 1586089158, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02722.html", "problem_id": "p02722", "resource_group": "medium_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/Kotlin/s380230470.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s380230470", "user_id": "u408242391"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "fun main(args: Array) {\n val N = nextLong()\n var ans = 0\n divisor(N).drop(1).forEach { x ->\n var w = N\n while (w % x == 0L) w /= x\n if (w % x == 1L) ans += 1\n }\n ans += divisor(N - 1).drop(1).size\n println(ans)\n}\n\nfun divisor(value: Long) =\n (1 .. Math.sqrt(value.toDouble()).toLong())\n .filter { value % it == 0L }\n .map { listOf(it, value / it) }\n .flatten()\n .distinct()\n .sorted()\n\n\nfun next() = readLine()!!\nfun nextLong() = next().toLong()\n\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 532, "cpu_time_ms": 361, "memory_kb": 48504}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s318184140", "group_id": "codeNet:p02724", "input_text": "fun main(args: Array) {\n // Your code here!\n val FF = 500\n val F = 5\n var x = readLine()!!.toInt()\n var point:Int = 0\n \n point = 1000 * (x / FF) \n x -= (x / FF) * FF\n \n point += 5 * (x / F)\n println(point)\n \n}\n", "language": "Kotlin", "metadata": {"date": 1585761054, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02724.html", "problem_id": "p02724", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02724/input.txt", "sample_output_relpath": "derived/input_output/data/p02724/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02724/Kotlin/s318184140.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s318184140", "user_id": "u808976884"}, "prompt_components": {"gold_output": "2020\n", "input_to_evaluate": "fun main(args: Array) {\n // Your code here!\n val FF = 500\n val F = 5\n var x = readLine()!!.toInt()\n var point:Int = 0\n \n point = 1000 * (x / FF) \n x -= (x / FF) * FF\n \n point += 5 * (x / F)\n println(point)\n \n}\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nTakahashi loves gold coins. He gains 1000 happiness points for each 500-yen coin he has and gains 5 happiness points for each 5-yen coin he has. (Yen is the currency of Japan.)\n\nTakahashi has X yen. If he exchanges his money so that he will gain the most happiness points, how many happiness points will he earn?\n\n(We assume that there are six kinds of coins available: 500-yen, 100-yen, 50-yen, 10-yen, 5-yen, and 1-yen coins.)\n\nConstraints\n\n0 \\leq X \\leq 10^9\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 maximum number of happiness points that can be earned.\n\nSample Input 1\n\n1024\n\nSample Output 1\n\n2020\n\nBy exchanging his money so that he gets two 500-yen coins and four 5-yen coins, he gains 2020 happiness points, which is the maximum number of happiness points that can be earned.\n\nSample Input 2\n\n0\n\nSample Output 2\n\n0\n\nHe is penniless - or yenless.\n\nSample Input 3\n\n1000000000\n\nSample Output 3\n\n2000000000\n\nHe is a billionaire - in yen.", "sample_input": "1024\n"}, "reference_outputs": ["2020\n"], "source_document_id": "p02724", "source_text": "Score : 200 points\n\nProblem Statement\n\nTakahashi loves gold coins. He gains 1000 happiness points for each 500-yen coin he has and gains 5 happiness points for each 5-yen coin he has. (Yen is the currency of Japan.)\n\nTakahashi has X yen. If he exchanges his money so that he will gain the most happiness points, how many happiness points will he earn?\n\n(We assume that there are six kinds of coins available: 500-yen, 100-yen, 50-yen, 10-yen, 5-yen, and 1-yen coins.)\n\nConstraints\n\n0 \\leq X \\leq 10^9\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 maximum number of happiness points that can be earned.\n\nSample Input 1\n\n1024\n\nSample Output 1\n\n2020\n\nBy exchanging his money so that he gets two 500-yen coins and four 5-yen coins, he gains 2020 happiness points, which is the maximum number of happiness points that can be earned.\n\nSample Input 2\n\n0\n\nSample Output 2\n\n0\n\nHe is penniless - or yenless.\n\nSample Input 3\n\n1000000000\n\nSample Output 3\n\n2000000000\n\nHe is a billionaire - in yen.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 254, "cpu_time_ms": 202, "memory_kb": 31832}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s355037939", "group_id": "codeNet:p02724", "input_text": "fun main(args: Array) {\n val price = readLine()!!.toInt()\n val result = (price / 500) * 1000 + ((price % 500) / 5) * 5\n println(result)\n}", "language": "Kotlin", "metadata": {"date": 1585444061, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02724.html", "problem_id": "p02724", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02724/input.txt", "sample_output_relpath": "derived/input_output/data/p02724/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02724/Kotlin/s355037939.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s355037939", "user_id": "u897579945"}, "prompt_components": {"gold_output": "2020\n", "input_to_evaluate": "fun main(args: Array) {\n val price = readLine()!!.toInt()\n val result = (price / 500) * 1000 + ((price % 500) / 5) * 5\n println(result)\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nTakahashi loves gold coins. He gains 1000 happiness points for each 500-yen coin he has and gains 5 happiness points for each 5-yen coin he has. (Yen is the currency of Japan.)\n\nTakahashi has X yen. If he exchanges his money so that he will gain the most happiness points, how many happiness points will he earn?\n\n(We assume that there are six kinds of coins available: 500-yen, 100-yen, 50-yen, 10-yen, 5-yen, and 1-yen coins.)\n\nConstraints\n\n0 \\leq X \\leq 10^9\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 maximum number of happiness points that can be earned.\n\nSample Input 1\n\n1024\n\nSample Output 1\n\n2020\n\nBy exchanging his money so that he gets two 500-yen coins and four 5-yen coins, he gains 2020 happiness points, which is the maximum number of happiness points that can be earned.\n\nSample Input 2\n\n0\n\nSample Output 2\n\n0\n\nHe is penniless - or yenless.\n\nSample Input 3\n\n1000000000\n\nSample Output 3\n\n2000000000\n\nHe is a billionaire - in yen.", "sample_input": "1024\n"}, "reference_outputs": ["2020\n"], "source_document_id": "p02724", "source_text": "Score : 200 points\n\nProblem Statement\n\nTakahashi loves gold coins. He gains 1000 happiness points for each 500-yen coin he has and gains 5 happiness points for each 5-yen coin he has. (Yen is the currency of Japan.)\n\nTakahashi has X yen. If he exchanges his money so that he will gain the most happiness points, how many happiness points will he earn?\n\n(We assume that there are six kinds of coins available: 500-yen, 100-yen, 50-yen, 10-yen, 5-yen, and 1-yen coins.)\n\nConstraints\n\n0 \\leq X \\leq 10^9\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 maximum number of happiness points that can be earned.\n\nSample Input 1\n\n1024\n\nSample Output 1\n\n2020\n\nBy exchanging his money so that he gets two 500-yen coins and four 5-yen coins, he gains 2020 happiness points, which is the maximum number of happiness points that can be earned.\n\nSample Input 2\n\n0\n\nSample Output 2\n\n0\n\nHe is penniless - or yenless.\n\nSample Input 3\n\n1000000000\n\nSample Output 3\n\n2000000000\n\nHe is a billionaire - in yen.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 275, "memory_kb": 31652}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s534691196", "group_id": "codeNet:p02725", "input_text": "import java.io.BufferedReader\nimport java.io.InputStreamReader\nimport java.io.PrintWriter\nimport java.util.*\n\nfun main(args: Array) = test2()\n\nfun test2() = FastIO().exec {\n val (k, n) = readLine()!!.split(' ').map { it.toInt() }\n val aList = readLine()!!.split(' ').map { it.toLong() }\n\n val diff = LongArray(n)\n diff[0] = k - aList.last() + aList.first()\n\n for (i in 0 until n - 1) {\n diff[i + 1] = aList[i + 1] - aList[i]\n }\n\n val answer = diff.sum() - diff.max()!!\n\n println(answer)\n}\n\n// region\n\n@Suppress(\"unused\")\nclass FastIO {\n private val br = BufferedReader(InputStreamReader(System.`in`))\n private var st = StringTokenizer(\"\")\n val pw = PrintWriter(System.out)\n\n fun string(): String {\n if (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())\n return st.nextToken()\n }\n\n fun int() = Integer.parseInt(string())\n fun long() = java.lang.Long.parseLong(string())\n fun double() = java.lang.Double.parseDouble(string())\n fun nextLine() = br.readLine()!!\n fun println() = pw.println()\n fun print(o: T) = pw.print(o)\n fun println(o: T) = pw.println(o)\n\n inline fun exec(code: FastIO.() -> Unit) {\n code()\n pw.flush()\n }\n}\n// endregion\n", "language": "Kotlin", "metadata": {"date": 1586671389, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02725.html", "problem_id": "p02725", "resource_group": "medium_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/Kotlin/s534691196.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s534691196", "user_id": "u139478771"}, "prompt_components": {"gold_output": "10\n", "input_to_evaluate": "import java.io.BufferedReader\nimport java.io.InputStreamReader\nimport java.io.PrintWriter\nimport java.util.*\n\nfun main(args: Array) = test2()\n\nfun test2() = FastIO().exec {\n val (k, n) = readLine()!!.split(' ').map { it.toInt() }\n val aList = readLine()!!.split(' ').map { it.toLong() }\n\n val diff = LongArray(n)\n diff[0] = k - aList.last() + aList.first()\n\n for (i in 0 until n - 1) {\n diff[i + 1] = aList[i + 1] - aList[i]\n }\n\n val answer = diff.sum() - diff.max()!!\n\n println(answer)\n}\n\n// region\n\n@Suppress(\"unused\")\nclass FastIO {\n private val br = BufferedReader(InputStreamReader(System.`in`))\n private var st = StringTokenizer(\"\")\n val pw = PrintWriter(System.out)\n\n fun string(): String {\n if (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())\n return st.nextToken()\n }\n\n fun int() = Integer.parseInt(string())\n fun long() = java.lang.Long.parseLong(string())\n fun double() = java.lang.Double.parseDouble(string())\n fun nextLine() = br.readLine()!!\n fun println() = pw.println()\n fun print(o: T) = pw.print(o)\n fun println(o: T) = pw.println(o)\n\n inline fun exec(code: FastIO.() -> Unit) {\n code()\n pw.flush()\n }\n}\n// endregion\n", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1261, "cpu_time_ms": 627, "memory_kb": 81088}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s398193187", "group_id": "codeNet:p02725", "input_text": "fun main(arg: Array) {\n val (K, N) = listOfInt()\n val A = listOfInt().toMutableList()\n A.add(A[0] + K)\n val C = IntArray(N)\n for (n in 0 until N) C[n] = A[n + 1] - A[n]\n//System.err.println(C.joinToString())\n var ans = K - C.max()!!\n println(ans)\n}\n\nfun next() = readLine()!!\nfun nextInt(delta: Int = 0) = Integer.parseInt(next()) + delta\nfun nextLong() = next().toLong()\nfun nextDouble() = next().toDouble()\nfun listOfString() = next().split(\" \")\nfun listOfInt(delta: Int = 0) = listOfString().map { Integer.parseInt(it) + delta }\nfun listOfLong(delta: Long = 0L) = listOfString().map { java.lang.Long.parseLong(it) + delta }\nfun listOfDouble(delta: Double = 0.0) = listOfString().map { java.lang.Double.parseDouble(it) + delta }\nfun listOfInt() = listOfString().map(String::toInt)\nfun listOfLong() = listOfString().map(String::toLong)\nfun listOfDouble() = listOfString().map(String::toDouble)\n", "language": "Kotlin", "metadata": {"date": 1585453733, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02725.html", "problem_id": "p02725", "resource_group": "medium_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/Kotlin/s398193187.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s398193187", "user_id": "u043150661"}, "prompt_components": {"gold_output": "10\n", "input_to_evaluate": "fun main(arg: Array) {\n val (K, N) = listOfInt()\n val A = listOfInt().toMutableList()\n A.add(A[0] + K)\n val C = IntArray(N)\n for (n in 0 until N) C[n] = A[n + 1] - A[n]\n//System.err.println(C.joinToString())\n var ans = K - C.max()!!\n println(ans)\n}\n\nfun next() = readLine()!!\nfun nextInt(delta: Int = 0) = Integer.parseInt(next()) + delta\nfun nextLong() = next().toLong()\nfun nextDouble() = next().toDouble()\nfun listOfString() = next().split(\" \")\nfun listOfInt(delta: Int = 0) = listOfString().map { Integer.parseInt(it) + delta }\nfun listOfLong(delta: Long = 0L) = listOfString().map { java.lang.Long.parseLong(it) + delta }\nfun listOfDouble(delta: Double = 0.0) = listOfString().map { java.lang.Double.parseDouble(it) + delta }\nfun listOfInt() = listOfString().map(String::toInt)\nfun listOfLong() = listOfString().map(String::toLong)\nfun listOfDouble() = listOfString().map(String::toDouble)\n", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 651, "memory_kb": 82924}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s886062655", "group_id": "codeNet:p02725", "input_text": "fun main(args: Array) {\n val kn = readLine()!!.split(\" \")\n val K = kn[0].toInt()\n val N = kn[1].toInt()\n\n val AI = readLine()!!.split(\" \")\n\n //家間の距離のリストを作成\n var arr: Array = Array(N) { 0 }\n for (i in AI.indices) {\n if (i == 0) {\n arr[i] = K - AI[N - 1].toInt() + AI[i].toInt()\n } else {\n arr[i] = AI[i].toInt() - AI[i - 1].toInt()\n }\n }\n\n arr.sortBy { it * -1 }\n println(K - arr[0])\n}\n", "language": "Kotlin", "metadata": {"date": 1585447986, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02725.html", "problem_id": "p02725", "resource_group": "medium_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/Kotlin/s886062655.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s886062655", "user_id": "u033219682"}, "prompt_components": {"gold_output": "10\n", "input_to_evaluate": "fun main(args: Array) {\n val kn = readLine()!!.split(\" \")\n val K = kn[0].toInt()\n val N = kn[1].toInt()\n\n val AI = readLine()!!.split(\" \")\n\n //家間の距離のリストを作成\n var arr: Array = Array(N) { 0 }\n for (i in AI.indices) {\n if (i == 0) {\n arr[i] = K - AI[N - 1].toInt() + AI[i].toInt()\n } else {\n arr[i] = AI[i].toInt() - AI[i - 1].toInt()\n }\n }\n\n arr.sortBy { it * -1 }\n println(K - arr[0])\n}\n", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 495, "cpu_time_ms": 978, "memory_kb": 77512}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s347225243", "group_id": "codeNet:p02725", "input_text": "fun main(args: Array) {\n val (K, N) = readLine()!!.split(\" \").map(String::toInt)\n val AN = readLine()!!.split(\" \").map(String::toInt)\n\n var ans = K\n for (i in 0 until N) {\n val start = AN[i]\n val goal = AN[(N - 1 + i) % N].let {\n if (it < start) {\n it + K\n } else {\n it\n }\n }\n\n ans = Math.min(ans, goal - start)\n }\n println(ans)\n\n}\n\n\n\n", "language": "Kotlin", "metadata": {"date": 1585444952, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02725.html", "problem_id": "p02725", "resource_group": "medium_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/Kotlin/s347225243.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s347225243", "user_id": "u085288971"}, "prompt_components": {"gold_output": "10\n", "input_to_evaluate": "fun main(args: Array) {\n val (K, N) = readLine()!!.split(\" \").map(String::toInt)\n val AN = readLine()!!.split(\" \").map(String::toInt)\n\n var ans = K\n for (i in 0 until N) {\n val start = AN[i]\n val goal = AN[(N - 1 + i) % N].let {\n if (it < start) {\n it + K\n } else {\n it\n }\n }\n\n ans = Math.min(ans, goal - start)\n }\n println(ans)\n\n}\n\n\n\n", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 452, "cpu_time_ms": 604, "memory_kb": 82640}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s213876695", "group_id": "codeNet:p02726", "input_text": "fun main(args: Array) {\n var (n, x, y) = readLine()!!.split(\" \").map{ it.toInt() }\n x -= 1\n y -= 1\n var dis = Array(n){0}.toMutableList()\n for (i in 0..n-2) {\n for (j in i+1..n-1) {\n dis[Math.min(Math.abs(i-j), Math.abs(i-x)+Math.abs(j-y)+1)] += 1\n }\n }\n println(dis.slice(1..n-1).joinToString(separator=\"\\n\"))\n}\n", "language": "Kotlin", "metadata": {"date": 1588100341, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02726.html", "problem_id": "p02726", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02726/input.txt", "sample_output_relpath": "derived/input_output/data/p02726/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02726/Kotlin/s213876695.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s213876695", "user_id": "u906501980"}, "prompt_components": {"gold_output": "5\n4\n1\n0\n", "input_to_evaluate": "fun main(args: Array) {\n var (n, x, y) = readLine()!!.split(\" \").map{ it.toInt() }\n x -= 1\n y -= 1\n var dis = Array(n){0}.toMutableList()\n for (i in 0..n-2) {\n for (j in i+1..n-1) {\n dis[Math.min(Math.abs(i-j), Math.abs(i-x)+Math.abs(j-y)+1)] += 1\n }\n }\n println(dis.slice(1..n-1).joinToString(separator=\"\\n\"))\n}\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nWe have an undirected graph G with N vertices numbered 1 to N and N edges as follows:\n\nFor each i=1,2,...,N-1, there is an edge between Vertex i and Vertex i+1.\n\nThere is an edge between Vertex X and Vertex Y.\n\nFor each k=1,2,...,N-1, solve the problem below:\n\nFind the number of pairs of integers (i,j) (1 \\leq i < j \\leq N) such that the shortest distance between Vertex i and Vertex j in G is k.\n\nConstraints\n\n3 \\leq N \\leq 2 \\times 10^3\n\n1 \\leq X,Y \\leq N\n\nX+1 < Y\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN X Y\n\nOutput\n\nFor each k=1, 2, ..., N-1 in this order, print a line containing the answer to the problem.\n\nSample Input 1\n\n5 2 4\n\nSample Output 1\n\n5\n4\n1\n0\n\nThe graph in this input is as follows:\n\nThere are five pairs (i,j) (1 \\leq i < j \\leq N) such that the shortest distance between Vertex i and Vertex j is 1: (1,2)\\,,(2,3)\\,,(2,4)\\,,(3,4)\\,,(4,5).\n\nThere are four pairs (i,j) (1 \\leq i < j \\leq N) such that the shortest distance between Vertex i and Vertex j is 2: (1,3)\\,,(1,4)\\,,(2,5)\\,,(3,5).\n\nThere is one pair (i,j) (1 \\leq i < j \\leq N) such that the shortest distance between Vertex i and Vertex j is 3: (1,5).\n\nThere are no pairs (i,j) (1 \\leq i < j \\leq N) such that the shortest distance between Vertex i and Vertex j is 4.\n\nSample Input 2\n\n3 1 3\n\nSample Output 2\n\n3\n0\n\nThe graph in this input is as follows:\n\nSample Input 3\n\n7 3 7\n\nSample Output 3\n\n7\n8\n4\n2\n0\n0\n\nSample Input 4\n\n10 4 8\n\nSample Output 4\n\n10\n12\n10\n8\n4\n1\n0\n0\n0", "sample_input": "5 2 4\n"}, "reference_outputs": ["5\n4\n1\n0\n"], "source_document_id": "p02726", "source_text": "Score : 400 points\n\nProblem Statement\n\nWe have an undirected graph G with N vertices numbered 1 to N and N edges as follows:\n\nFor each i=1,2,...,N-1, there is an edge between Vertex i and Vertex i+1.\n\nThere is an edge between Vertex X and Vertex Y.\n\nFor each k=1,2,...,N-1, solve the problem below:\n\nFind the number of pairs of integers (i,j) (1 \\leq i < j \\leq N) such that the shortest distance between Vertex i and Vertex j in G is k.\n\nConstraints\n\n3 \\leq N \\leq 2 \\times 10^3\n\n1 \\leq X,Y \\leq N\n\nX+1 < Y\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN X Y\n\nOutput\n\nFor each k=1, 2, ..., N-1 in this order, print a line containing the answer to the problem.\n\nSample Input 1\n\n5 2 4\n\nSample Output 1\n\n5\n4\n1\n0\n\nThe graph in this input is as follows:\n\nThere are five pairs (i,j) (1 \\leq i < j \\leq N) such that the shortest distance between Vertex i and Vertex j is 1: (1,2)\\,,(2,3)\\,,(2,4)\\,,(3,4)\\,,(4,5).\n\nThere are four pairs (i,j) (1 \\leq i < j \\leq N) such that the shortest distance between Vertex i and Vertex j is 2: (1,3)\\,,(1,4)\\,,(2,5)\\,,(3,5).\n\nThere is one pair (i,j) (1 \\leq i < j \\leq N) such that the shortest distance between Vertex i and Vertex j is 3: (1,5).\n\nThere are no pairs (i,j) (1 \\leq i < j \\leq N) such that the shortest distance between Vertex i and Vertex j is 4.\n\nSample Input 2\n\n3 1 3\n\nSample Output 2\n\n3\n0\n\nThe graph in this input is as follows:\n\nSample Input 3\n\n7 3 7\n\nSample Output 3\n\n7\n8\n4\n2\n0\n0\n\nSample Input 4\n\n10 4 8\n\nSample Output 4\n\n10\n12\n10\n8\n4\n1\n0\n0\n0", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 319, "memory_kb": 43488}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s056902094", "group_id": "codeNet:p02728", "input_text": "import java.util.*\n\nfun main(args:Array) {\n\n val mod = 1000000007L\n val n = readLine()!!.toInt()\n val dp = LongArray(n)\n val factorial = LongArray(n+1)\n val edges = Array(n){HashSet()}\n val s = Array(n){0}\n val visited = BooleanArray(n)\n\n factorial[0] = 1\n factorial[1] = 1\n\n for(i in 2 ..n) {\n factorial[i] = (factorial[i-1] * i) % mod\n }\n\n for(i in 0 until n - 1) {\n var (a,b) = readLine()!!.split(\" \").map { it.toInt() }\n a--\n b--\n edges[a].add(b)\n edges[b].add(a)\n }\n\n fun dfs(cur:Int): Int {\n var cnt = 0\n visited[cur] = true\n for(adj in edges[cur]) {\n if(visited[adj]) continue\n cnt += dfs(adj)\n }\n visited[cur] = false\n s[cur] = cnt + 1\n dp[cur] = (factorial[s[cur] - 1])\n for(adj in edges[cur]) {\n if(visited[adj]) {\n continue\n }\n dp[cur] = (dp[cur] * dp[adj] / factorial[s[adj]]) % mod\n dp[cur] %= mod\n }\n while (dp[cur]==0L) {\n\n }\n\n //dp[i] = (s[cur] - 1)! * dp[\n return s[cur]\n }\n\n fun dfs2(root:Int) {\n visited[root] = true\n for(child in edges[root]) {\n if(visited[child]) continue\n //dp[child] = dp[cur] * s[child] / factorial[ n - s[child] ]\n// dp[child] = dp[root] * s[child] / factorial [ n - s[child]]\n val v = (n - s[child]).toLong()\n dp[child] = (dp[root] * s[child]) % mod\n\n while (dp[child] % v != 0L) {\n dp[child] += mod\n }\n \n dp[child] = dp[child] / v\n /*\n if(dp[child] / v == 0L) {\n dp[child] = (dp[child] + mod) / v\n if(dp[child]==0L) {\n while (true){\n }\n }\n } else {\n dp[child] = dp[child] / v\n }\n */\n dp[child] %= mod\n dfs2(child)\n }\n visited[root] = false\n }\n dfs(0)\n dfs2(0)\n\n for(i in 0 until n) {\n println(dp[i])\n }\n}", "language": "Kotlin", "metadata": {"date": 1585686603, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02728.html", "problem_id": "p02728", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02728/input.txt", "sample_output_relpath": "derived/input_output/data/p02728/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02728/Kotlin/s056902094.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s056902094", "user_id": "u682597394"}, "prompt_components": {"gold_output": "2\n1\n1\n", "input_to_evaluate": "import java.util.*\n\nfun main(args:Array) {\n\n val mod = 1000000007L\n val n = readLine()!!.toInt()\n val dp = LongArray(n)\n val factorial = LongArray(n+1)\n val edges = Array(n){HashSet()}\n val s = Array(n){0}\n val visited = BooleanArray(n)\n\n factorial[0] = 1\n factorial[1] = 1\n\n for(i in 2 ..n) {\n factorial[i] = (factorial[i-1] * i) % mod\n }\n\n for(i in 0 until n - 1) {\n var (a,b) = readLine()!!.split(\" \").map { it.toInt() }\n a--\n b--\n edges[a].add(b)\n edges[b].add(a)\n }\n\n fun dfs(cur:Int): Int {\n var cnt = 0\n visited[cur] = true\n for(adj in edges[cur]) {\n if(visited[adj]) continue\n cnt += dfs(adj)\n }\n visited[cur] = false\n s[cur] = cnt + 1\n dp[cur] = (factorial[s[cur] - 1])\n for(adj in edges[cur]) {\n if(visited[adj]) {\n continue\n }\n dp[cur] = (dp[cur] * dp[adj] / factorial[s[adj]]) % mod\n dp[cur] %= mod\n }\n while (dp[cur]==0L) {\n\n }\n\n //dp[i] = (s[cur] - 1)! * dp[\n return s[cur]\n }\n\n fun dfs2(root:Int) {\n visited[root] = true\n for(child in edges[root]) {\n if(visited[child]) continue\n //dp[child] = dp[cur] * s[child] / factorial[ n - s[child] ]\n// dp[child] = dp[root] * s[child] / factorial [ n - s[child]]\n val v = (n - s[child]).toLong()\n dp[child] = (dp[root] * s[child]) % mod\n\n while (dp[child] % v != 0L) {\n dp[child] += mod\n }\n \n dp[child] = dp[child] / v\n /*\n if(dp[child] / v == 0L) {\n dp[child] = (dp[child] + mod) / v\n if(dp[child]==0L) {\n while (true){\n }\n }\n } else {\n dp[child] = dp[child] / v\n }\n */\n dp[child] %= mod\n dfs2(child)\n }\n visited[root] = false\n }\n dfs(0)\n dfs2(0)\n\n for(i in 0 until n) {\n println(dp[i])\n }\n}", "problem_context": "Score : 600 points\n\nProblem Statement\n\nWe have a tree with N vertices numbered 1 to N. The i-th edge in this tree connects Vertex a_i and b_i.\nFor each k=1, ..., N, solve the problem below:\n\nConsider writing a number on each vertex in the tree in the following manner:\n\nFirst, write 1 on Vertex k.\n\nThen, for each of the numbers 2, ..., N in this order, write the number on the vertex chosen as follows:\n\nChoose a vertex that still does not have a number written on it and is adjacent to a vertex with a number already written on it. If there are multiple such vertices, choose one of them at random.\n\nFind the number of ways in which we can write the numbers on the vertices, modulo (10^9+7).\n\nConstraints\n\n2 \\leq N \\leq 2 \\times 10^5\n\n1 \\leq a_i,b_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\na_1 b_1\n:\na_{N-1} b_{N-1}\n\nOutput\n\nFor each k=1, 2, ..., N in this order, print a line containing the answer to the problem.\n\nSample Input 1\n\n3\n1 2\n1 3\n\nSample Output 1\n\n2\n1\n1\n\nThe graph in this input is as follows:\n\nFor k=1, there are two ways in which we can write the numbers on the vertices, as follows:\n\nWriting 1, 2, 3 on Vertex 1, 2, 3, respectively\n\nWriting 1, 3, 2 on Vertex 1, 2, 3, respectively\n\nSample Input 2\n\n2\n1 2\n\nSample Output 2\n\n1\n1\n\nThe graph in this input is as follows:\n\nSample Input 3\n\n5\n1 2\n2 3\n3 4\n3 5\n\nSample Output 3\n\n2\n8\n12\n3\n3\n\nThe graph in this input is as follows:\n\nSample Input 4\n\n8\n1 2\n2 3\n3 4\n3 5\n3 6\n6 7\n6 8\n\nSample Output 4\n\n40\n280\n840\n120\n120\n504\n72\n72\n\nThe graph in this input is as follows:", "sample_input": "3\n1 2\n1 3\n"}, "reference_outputs": ["2\n1\n1\n"], "source_document_id": "p02728", "source_text": "Score : 600 points\n\nProblem Statement\n\nWe have a tree with N vertices numbered 1 to N. The i-th edge in this tree connects Vertex a_i and b_i.\nFor each k=1, ..., N, solve the problem below:\n\nConsider writing a number on each vertex in the tree in the following manner:\n\nFirst, write 1 on Vertex k.\n\nThen, for each of the numbers 2, ..., N in this order, write the number on the vertex chosen as follows:\n\nChoose a vertex that still does not have a number written on it and is adjacent to a vertex with a number already written on it. If there are multiple such vertices, choose one of them at random.\n\nFind the number of ways in which we can write the numbers on the vertices, modulo (10^9+7).\n\nConstraints\n\n2 \\leq N \\leq 2 \\times 10^5\n\n1 \\leq a_i,b_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\na_1 b_1\n:\na_{N-1} b_{N-1}\n\nOutput\n\nFor each k=1, 2, ..., N in this order, print a line containing the answer to the problem.\n\nSample Input 1\n\n3\n1 2\n1 3\n\nSample Output 1\n\n2\n1\n1\n\nThe graph in this input is as follows:\n\nFor k=1, there are two ways in which we can write the numbers on the vertices, as follows:\n\nWriting 1, 2, 3 on Vertex 1, 2, 3, respectively\n\nWriting 1, 3, 2 on Vertex 1, 2, 3, respectively\n\nSample Input 2\n\n2\n1 2\n\nSample Output 2\n\n1\n1\n\nThe graph in this input is as follows:\n\nSample Input 3\n\n5\n1 2\n2 3\n3 4\n3 5\n\nSample Output 3\n\n2\n8\n12\n3\n3\n\nThe graph in this input is as follows:\n\nSample Input 4\n\n8\n1 2\n2 3\n3 4\n3 5\n3 6\n6 7\n6 8\n\nSample Output 4\n\n40\n280\n840\n120\n120\n504\n72\n72\n\nThe graph in this input is as follows:", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2163, "cpu_time_ms": 3163, "memory_kb": 160104}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s215839892", "group_id": "codeNet:p02729", "input_text": "fun main(args: Array){\n val n = readLine()!!.toInt()\n val m = readLine()!!.toInt()\n print(n+m) \n}", "language": "Kotlin", "metadata": {"date": 1584926711, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02729.html", "problem_id": "p02729", "resource_group": "medium_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/Kotlin/s215839892.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s215839892", "user_id": "u531770859"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "fun main(args: Array){\n val n = readLine()!!.toInt()\n val m = readLine()!!.toInt()\n print(n+m) \n}", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 203, "memory_kb": 31400}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s281408972", "group_id": "codeNet:p02730", "input_text": "fun main(){\n val s = readLine()!!.toString()\n val n = s.length\n\n fun palindrome(s: String): Boolean{\n// println(s)\n// println(s.length)\n for(i in 0 .. (s.length-1)/2){\n if(s[i] != s[s.length - 1 - i])\n return false\n }\n return true\n }\n\n //substring; 終了インデックスの1つ前までで切る\n if(\n palindrome(s) &&\n palindrome(s.substring(0, (n - 1)/2)) &&\n palindrome(s.substring((n + 3)/2 - 1 , n))\n ) println(\"Yes\")\n else println(\"No\")\n}", "language": "Kotlin", "metadata": {"date": 1593883240, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02730.html", "problem_id": "p02730", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02730/input.txt", "sample_output_relpath": "derived/input_output/data/p02730/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02730/Kotlin/s281408972.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s281408972", "user_id": "u209053759"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "fun main(){\n val s = readLine()!!.toString()\n val n = s.length\n\n fun palindrome(s: String): Boolean{\n// println(s)\n// println(s.length)\n for(i in 0 .. (s.length-1)/2){\n if(s[i] != s[s.length - 1 - i])\n return false\n }\n return true\n }\n\n //substring; 終了インデックスの1つ前までで切る\n if(\n palindrome(s) &&\n palindrome(s.substring(0, (n - 1)/2)) &&\n palindrome(s.substring((n + 3)/2 - 1 , n))\n ) println(\"Yes\")\n else println(\"No\")\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nA string S of an odd length is said to be a strong palindrome if and only if all of the following conditions are satisfied:\n\nS is a palindrome.\n\nLet N be the length of S. The string formed by the 1-st through ((N-1)/2)-th characters of S is a palindrome.\n\nThe string consisting of the (N+3)/2-st through N-th characters of S is a palindrome.\n\nDetermine whether S is a strong palindrome.\n\nConstraints\n\nS consists of lowercase English letters.\n\nThe length of S is an odd number between 3 and 99 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nIf S is a strong palindrome, print Yes;\notherwise, print No.\n\nSample Input 1\n\nakasaka\n\nSample Output 1\n\nYes\n\nS is akasaka.\n\nThe string formed by the 1-st through the 3-rd characters is aka.\n\nThe string formed by the 5-th through the 7-th characters is aka.\nAll of these are palindromes, so S is a strong palindrome.\n\nSample Input 2\n\nlevel\n\nSample Output 2\n\nNo\n\nSample Input 3\n\natcoder\n\nSample Output 3\n\nNo", "sample_input": "akasaka\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p02730", "source_text": "Score : 200 points\n\nProblem Statement\n\nA string S of an odd length is said to be a strong palindrome if and only if all of the following conditions are satisfied:\n\nS is a palindrome.\n\nLet N be the length of S. The string formed by the 1-st through ((N-1)/2)-th characters of S is a palindrome.\n\nThe string consisting of the (N+3)/2-st through N-th characters of S is a palindrome.\n\nDetermine whether S is a strong palindrome.\n\nConstraints\n\nS consists of lowercase English letters.\n\nThe length of S is an odd number between 3 and 99 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nIf S is a strong palindrome, print Yes;\notherwise, print No.\n\nSample Input 1\n\nakasaka\n\nSample Output 1\n\nYes\n\nS is akasaka.\n\nThe string formed by the 1-st through the 3-rd characters is aka.\n\nThe string formed by the 5-th through the 7-th characters is aka.\nAll of these are palindromes, so S is a strong palindrome.\n\nSample Input 2\n\nlevel\n\nSample Output 2\n\nNo\n\nSample Input 3\n\natcoder\n\nSample Output 3\n\nNo", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 569, "cpu_time_ms": 101, "memory_kb": 34504}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s507804290", "group_id": "codeNet:p02730", "input_text": "fun main(args: Array) {\n val s = readString()\n if (\n s.isPalindrome() &&\n s.substring(0 until (s.length - 1) / 2).isPalindrome() &&\n s.substring((s.length + 3) / 2 - 1 until s.length).isPalindrome()\n ) {\n println(\"Yes\")\n } else {\n println(\"No\")\n }\n}\n\nfun String.isPalindrome(): Boolean {\n return if (this.length % 2 == 0) {\n val x = this.substring(0 until this.length / 2)\n val y = this.substring(this.length / 2 until this.length).reversed()\n x == y\n } else {\n val x = this.substring(0 until (this.length - 1) / 2)\n val y = this.substring((this.length + 3) / 2 - 1 until this.length).reversed()\n x == y\n }\n}\n\n// Tools\nfun readString() = readLine()!!\nfun readInt() = readLine()!!.toInt()\nfun readLong() = readLine()!!.toLong()\nfun readStringList() = readLine()!!.split(\" \")\nfun readIntList() = readLine()!!.split(\" \").map(String::toInt)\nfun readLongList() = readLine()!!.split(\" \").map(String::toLong)", "language": "Kotlin", "metadata": {"date": 1591056920, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02730.html", "problem_id": "p02730", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02730/input.txt", "sample_output_relpath": "derived/input_output/data/p02730/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02730/Kotlin/s507804290.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s507804290", "user_id": "u697467902"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "fun main(args: Array) {\n val s = readString()\n if (\n s.isPalindrome() &&\n s.substring(0 until (s.length - 1) / 2).isPalindrome() &&\n s.substring((s.length + 3) / 2 - 1 until s.length).isPalindrome()\n ) {\n println(\"Yes\")\n } else {\n println(\"No\")\n }\n}\n\nfun String.isPalindrome(): Boolean {\n return if (this.length % 2 == 0) {\n val x = this.substring(0 until this.length / 2)\n val y = this.substring(this.length / 2 until this.length).reversed()\n x == y\n } else {\n val x = this.substring(0 until (this.length - 1) / 2)\n val y = this.substring((this.length + 3) / 2 - 1 until this.length).reversed()\n x == y\n }\n}\n\n// Tools\nfun readString() = readLine()!!\nfun readInt() = readLine()!!.toInt()\nfun readLong() = readLine()!!.toLong()\nfun readStringList() = readLine()!!.split(\" \")\nfun readIntList() = readLine()!!.split(\" \").map(String::toInt)\nfun readLongList() = readLine()!!.split(\" \").map(String::toLong)", "problem_context": "Score : 200 points\n\nProblem Statement\n\nA string S of an odd length is said to be a strong palindrome if and only if all of the following conditions are satisfied:\n\nS is a palindrome.\n\nLet N be the length of S. The string formed by the 1-st through ((N-1)/2)-th characters of S is a palindrome.\n\nThe string consisting of the (N+3)/2-st through N-th characters of S is a palindrome.\n\nDetermine whether S is a strong palindrome.\n\nConstraints\n\nS consists of lowercase English letters.\n\nThe length of S is an odd number between 3 and 99 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nIf S is a strong palindrome, print Yes;\notherwise, print No.\n\nSample Input 1\n\nakasaka\n\nSample Output 1\n\nYes\n\nS is akasaka.\n\nThe string formed by the 1-st through the 3-rd characters is aka.\n\nThe string formed by the 5-th through the 7-th characters is aka.\nAll of these are palindromes, so S is a strong palindrome.\n\nSample Input 2\n\nlevel\n\nSample Output 2\n\nNo\n\nSample Input 3\n\natcoder\n\nSample Output 3\n\nNo", "sample_input": "akasaka\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p02730", "source_text": "Score : 200 points\n\nProblem Statement\n\nA string S of an odd length is said to be a strong palindrome if and only if all of the following conditions are satisfied:\n\nS is a palindrome.\n\nLet N be the length of S. The string formed by the 1-st through ((N-1)/2)-th characters of S is a palindrome.\n\nThe string consisting of the (N+3)/2-st through N-th characters of S is a palindrome.\n\nDetermine whether S is a strong palindrome.\n\nConstraints\n\nS consists of lowercase English letters.\n\nThe length of S is an odd number between 3 and 99 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nIf S is a strong palindrome, print Yes;\notherwise, print No.\n\nSample Input 1\n\nakasaka\n\nSample Output 1\n\nYes\n\nS is akasaka.\n\nThe string formed by the 1-st through the 3-rd characters is aka.\n\nThe string formed by the 5-th through the 7-th characters is aka.\nAll of these are palindromes, so S is a strong palindrome.\n\nSample Input 2\n\nlevel\n\nSample Output 2\n\nNo\n\nSample Input 3\n\natcoder\n\nSample Output 3\n\nNo", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1010, "cpu_time_ms": 213, "memory_kb": 33784}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s774818066", "group_id": "codeNet:p02730", "input_text": " fun main(args: Array) {\n val s = readLine()!!.toString()\n\n if (s != s.reversed()) {\n println(\"No\")\n }\n\n val a = s.substring(0, (s.length - 1) / 2)\n if (a != a.reversed()) {\n println(\"No\")\n }\n\n val b = s.substring(((s.length + 3) / 2) - 1, s.length)\n if (b != b.reversed()) {\n println(\"No\")\n }\n\n println(\"Yes\")\n }\n", "language": "Kotlin", "metadata": {"date": 1587244141, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02730.html", "problem_id": "p02730", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02730/input.txt", "sample_output_relpath": "derived/input_output/data/p02730/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02730/Kotlin/s774818066.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s774818066", "user_id": "u366280250"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": " fun main(args: Array) {\n val s = readLine()!!.toString()\n\n if (s != s.reversed()) {\n println(\"No\")\n }\n\n val a = s.substring(0, (s.length - 1) / 2)\n if (a != a.reversed()) {\n println(\"No\")\n }\n\n val b = s.substring(((s.length + 3) / 2) - 1, s.length)\n if (b != b.reversed()) {\n println(\"No\")\n }\n\n println(\"Yes\")\n }\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nA string S of an odd length is said to be a strong palindrome if and only if all of the following conditions are satisfied:\n\nS is a palindrome.\n\nLet N be the length of S. The string formed by the 1-st through ((N-1)/2)-th characters of S is a palindrome.\n\nThe string consisting of the (N+3)/2-st through N-th characters of S is a palindrome.\n\nDetermine whether S is a strong palindrome.\n\nConstraints\n\nS consists of lowercase English letters.\n\nThe length of S is an odd number between 3 and 99 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nIf S is a strong palindrome, print Yes;\notherwise, print No.\n\nSample Input 1\n\nakasaka\n\nSample Output 1\n\nYes\n\nS is akasaka.\n\nThe string formed by the 1-st through the 3-rd characters is aka.\n\nThe string formed by the 5-th through the 7-th characters is aka.\nAll of these are palindromes, so S is a strong palindrome.\n\nSample Input 2\n\nlevel\n\nSample Output 2\n\nNo\n\nSample Input 3\n\natcoder\n\nSample Output 3\n\nNo", "sample_input": "akasaka\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p02730", "source_text": "Score : 200 points\n\nProblem Statement\n\nA string S of an odd length is said to be a strong palindrome if and only if all of the following conditions are satisfied:\n\nS is a palindrome.\n\nLet N be the length of S. The string formed by the 1-st through ((N-1)/2)-th characters of S is a palindrome.\n\nThe string consisting of the (N+3)/2-st through N-th characters of S is a palindrome.\n\nDetermine whether S is a strong palindrome.\n\nConstraints\n\nS consists of lowercase English letters.\n\nThe length of S is an odd number between 3 and 99 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nIf S is a strong palindrome, print Yes;\notherwise, print No.\n\nSample Input 1\n\nakasaka\n\nSample Output 1\n\nYes\n\nS is akasaka.\n\nThe string formed by the 1-st through the 3-rd characters is aka.\n\nThe string formed by the 5-th through the 7-th characters is aka.\nAll of these are palindromes, so S is a strong palindrome.\n\nSample Input 2\n\nlevel\n\nSample Output 2\n\nNo\n\nSample Input 3\n\natcoder\n\nSample Output 3\n\nNo", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 208, "memory_kb": 33656}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s512774149", "group_id": "codeNet:p02730", "input_text": "fun main(args: Array) {\n val str = readLine()?.orEmpty()\n var result = \"No\"\n val sLength = str!!.length\n\n val strLeft = str.substring(0,((sLength - 1) / 2))\n val strRight = str.substring(((sLength + 1) / 2),sLength)\n\n if(judgeGram(str) && judgeGram(strLeft) && judgeGram(strRight)){\n result = \"Yes\"\n }\n\n \n println(result)\n}\n\nfun judgeGram(s:String):Boolean{\n var result = false\n val sLength = s.length\n\n var sLeft = \"\"\n var sRight = \"\"\n\n if(sLength % 2 == 0){\n sLeft = s.substring(0,sLength / 2)\n sRight = s.substring(sLength / 2,sLength)\n\n }else{\n sLeft = s.substring(0,((sLength - 1) / 2))\n sRight = s.substring(((sLength + 1) / 2),sLength)\n }\n\n val sRR = sRight.reversed()\n if(sLeft == sRR){\n result = true\n }\n return result\n}", "language": "Kotlin", "metadata": {"date": 1584929751, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02730.html", "problem_id": "p02730", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02730/input.txt", "sample_output_relpath": "derived/input_output/data/p02730/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02730/Kotlin/s512774149.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s512774149", "user_id": "u430710262"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "fun main(args: Array) {\n val str = readLine()?.orEmpty()\n var result = \"No\"\n val sLength = str!!.length\n\n val strLeft = str.substring(0,((sLength - 1) / 2))\n val strRight = str.substring(((sLength + 1) / 2),sLength)\n\n if(judgeGram(str) && judgeGram(strLeft) && judgeGram(strRight)){\n result = \"Yes\"\n }\n\n \n println(result)\n}\n\nfun judgeGram(s:String):Boolean{\n var result = false\n val sLength = s.length\n\n var sLeft = \"\"\n var sRight = \"\"\n\n if(sLength % 2 == 0){\n sLeft = s.substring(0,sLength / 2)\n sRight = s.substring(sLength / 2,sLength)\n\n }else{\n sLeft = s.substring(0,((sLength - 1) / 2))\n sRight = s.substring(((sLength + 1) / 2),sLength)\n }\n\n val sRR = sRight.reversed()\n if(sLeft == sRR){\n result = true\n }\n return result\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nA string S of an odd length is said to be a strong palindrome if and only if all of the following conditions are satisfied:\n\nS is a palindrome.\n\nLet N be the length of S. The string formed by the 1-st through ((N-1)/2)-th characters of S is a palindrome.\n\nThe string consisting of the (N+3)/2-st through N-th characters of S is a palindrome.\n\nDetermine whether S is a strong palindrome.\n\nConstraints\n\nS consists of lowercase English letters.\n\nThe length of S is an odd number between 3 and 99 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nIf S is a strong palindrome, print Yes;\notherwise, print No.\n\nSample Input 1\n\nakasaka\n\nSample Output 1\n\nYes\n\nS is akasaka.\n\nThe string formed by the 1-st through the 3-rd characters is aka.\n\nThe string formed by the 5-th through the 7-th characters is aka.\nAll of these are palindromes, so S is a strong palindrome.\n\nSample Input 2\n\nlevel\n\nSample Output 2\n\nNo\n\nSample Input 3\n\natcoder\n\nSample Output 3\n\nNo", "sample_input": "akasaka\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p02730", "source_text": "Score : 200 points\n\nProblem Statement\n\nA string S of an odd length is said to be a strong palindrome if and only if all of the following conditions are satisfied:\n\nS is a palindrome.\n\nLet N be the length of S. The string formed by the 1-st through ((N-1)/2)-th characters of S is a palindrome.\n\nThe string consisting of the (N+3)/2-st through N-th characters of S is a palindrome.\n\nDetermine whether S is a strong palindrome.\n\nConstraints\n\nS consists of lowercase English letters.\n\nThe length of S is an odd number between 3 and 99 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nIf S is a strong palindrome, print Yes;\notherwise, print No.\n\nSample Input 1\n\nakasaka\n\nSample Output 1\n\nYes\n\nS is akasaka.\n\nThe string formed by the 1-st through the 3-rd characters is aka.\n\nThe string formed by the 5-th through the 7-th characters is aka.\nAll of these are palindromes, so S is a strong palindrome.\n\nSample Input 2\n\nlevel\n\nSample Output 2\n\nNo\n\nSample Input 3\n\natcoder\n\nSample Output 3\n\nNo", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 840, "cpu_time_ms": 212, "memory_kb": 33788}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s850257455", "group_id": "codeNet:p02730", "input_text": "fun main(args: Array) {\n val input = readLine()!!\n if (input.isKaibun() && input.isKaibun2() && input.isKaibun3()) {\n \"Yes\"\n } else {\n \"No\"\n }.let { println(it) }\n}\nfun String.zenhan() = substring(0, length / 2)\nfun String.kouhan() = substring((length / 2) + 1)\nfun String.isKaibun() = zenhan() == kouhan().reversed()\nfun String.isKaibun2() = zenhan().isKaibun()\nfun String.isKaibun3() = substring(((length + 3) / 2) - 1, length).isKaibun()", "language": "Kotlin", "metadata": {"date": 1584927845, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02730.html", "problem_id": "p02730", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02730/input.txt", "sample_output_relpath": "derived/input_output/data/p02730/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02730/Kotlin/s850257455.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s850257455", "user_id": "u784615990"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "fun main(args: Array) {\n val input = readLine()!!\n if (input.isKaibun() && input.isKaibun2() && input.isKaibun3()) {\n \"Yes\"\n } else {\n \"No\"\n }.let { println(it) }\n}\nfun String.zenhan() = substring(0, length / 2)\nfun String.kouhan() = substring((length / 2) + 1)\nfun String.isKaibun() = zenhan() == kouhan().reversed()\nfun String.isKaibun2() = zenhan().isKaibun()\nfun String.isKaibun3() = substring(((length + 3) / 2) - 1, length).isKaibun()", "problem_context": "Score : 200 points\n\nProblem Statement\n\nA string S of an odd length is said to be a strong palindrome if and only if all of the following conditions are satisfied:\n\nS is a palindrome.\n\nLet N be the length of S. The string formed by the 1-st through ((N-1)/2)-th characters of S is a palindrome.\n\nThe string consisting of the (N+3)/2-st through N-th characters of S is a palindrome.\n\nDetermine whether S is a strong palindrome.\n\nConstraints\n\nS consists of lowercase English letters.\n\nThe length of S is an odd number between 3 and 99 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nIf S is a strong palindrome, print Yes;\notherwise, print No.\n\nSample Input 1\n\nakasaka\n\nSample Output 1\n\nYes\n\nS is akasaka.\n\nThe string formed by the 1-st through the 3-rd characters is aka.\n\nThe string formed by the 5-th through the 7-th characters is aka.\nAll of these are palindromes, so S is a strong palindrome.\n\nSample Input 2\n\nlevel\n\nSample Output 2\n\nNo\n\nSample Input 3\n\natcoder\n\nSample Output 3\n\nNo", "sample_input": "akasaka\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p02730", "source_text": "Score : 200 points\n\nProblem Statement\n\nA string S of an odd length is said to be a strong palindrome if and only if all of the following conditions are satisfied:\n\nS is a palindrome.\n\nLet N be the length of S. The string formed by the 1-st through ((N-1)/2)-th characters of S is a palindrome.\n\nThe string consisting of the (N+3)/2-st through N-th characters of S is a palindrome.\n\nDetermine whether S is a strong palindrome.\n\nConstraints\n\nS consists of lowercase English letters.\n\nThe length of S is an odd number between 3 and 99 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nIf S is a strong palindrome, print Yes;\notherwise, print No.\n\nSample Input 1\n\nakasaka\n\nSample Output 1\n\nYes\n\nS is akasaka.\n\nThe string formed by the 1-st through the 3-rd characters is aka.\n\nThe string formed by the 5-th through the 7-th characters is aka.\nAll of these are palindromes, so S is a strong palindrome.\n\nSample Input 2\n\nlevel\n\nSample Output 2\n\nNo\n\nSample Input 3\n\natcoder\n\nSample Output 3\n\nNo", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 205, "memory_kb": 33856}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s772528331", "group_id": "codeNet:p02731", "input_text": "fun main(args: Array) {\n val L = readInt()\n println(Math.pow(L/3.0, 3.0))\n}\n\nfun readString() = readLine()!!\nfun readInt() = readLine()!!.toInt()", "language": "Kotlin", "metadata": {"date": 1584926409, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02731.html", "problem_id": "p02731", "resource_group": "medium_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/Kotlin/s772528331.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s772528331", "user_id": "u043557308"}, "prompt_components": {"gold_output": "1.000000000000\n", "input_to_evaluate": "fun main(args: Array) {\n val L = readInt()\n println(Math.pow(L/3.0, 3.0))\n}\n\nfun readString() = readLine()!!\nfun readInt() = readLine()!!.toInt()", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 222, "memory_kb": 29812}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s723944505", "group_id": "codeNet:p02732", "input_text": "fun main(args: Array) {\n val N = readLine()!!.toInt()\n val AN = readLine()!!.split(\" \").map(String::toInt)\n val countMap = AN.groupBy { it }.mapValues { it.value.size }\n val sum = countMap.map { it.value * (it.value - 1) / 2 }.sum()\n\n fun nC2(n: Int): Int {\n return n * (n - 1) / 2\n }\n for (i in 0 until N) {\n val count = countMap[AN[i]]!!\n println(sum - nC2(count) + nC2(count - 1))\n }\n}\n\n\n\n", "language": "Kotlin", "metadata": {"date": 1584967006, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02732.html", "problem_id": "p02732", "resource_group": "medium_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/Kotlin/s723944505.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s723944505", "user_id": "u085288971"}, "prompt_components": {"gold_output": "2\n2\n3\n2\n3\n", "input_to_evaluate": "fun main(args: Array) {\n val N = readLine()!!.toInt()\n val AN = readLine()!!.split(\" \").map(String::toInt)\n val countMap = AN.groupBy { it }.mapValues { it.value.size }\n val sum = countMap.map { it.value * (it.value - 1) / 2 }.sum()\n\n fun nC2(n: Int): Int {\n return n * (n - 1) / 2\n }\n for (i in 0 until N) {\n val count = countMap[AN[i]]!!\n println(sum - nC2(count) + nC2(count - 1))\n }\n}\n\n\n\n", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 445, "cpu_time_ms": 1892, "memory_kb": 104728}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s058124214", "group_id": "codeNet:p02732", "input_text": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val n = sc.nextInt()\n val mp = IntArray(n+1){0}\n val ap = LongArray(n+1)\n val minusp = LongArray(n+1)\n val aArr = IntArray(n)\n\n var sum = 0L\n repeat(n) {\n val a = sc.nextInt()\n aArr[it] = a\n if (mp[a] != 0) {\n mp[a] = mp[a] + 1\n if (mp[a] == 2) {\n ap[a] = 1\n minusp[a] = 1\n sum += 1\n } else {\n val oldap = ap[a]\n val newap = ap[a] * mp[a] / (mp[a]-2)\n ap[a] = newap\n minusp[a] = newap - oldap\n sum += newap - oldap\n }\n } else {\n mp[a] = 1\n ap[a] = 0\n minusp[a] = 0\n }\n }\n\n repeat(n) { cnt ->\n val k = aArr[cnt]\n println(sum - minusp[k])\n }\n}\n", "language": "Kotlin", "metadata": {"date": 1584930084, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02732.html", "problem_id": "p02732", "resource_group": "medium_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/Kotlin/s058124214.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s058124214", "user_id": "u288435405"}, "prompt_components": {"gold_output": "2\n2\n3\n2\n3\n", "input_to_evaluate": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val n = sc.nextInt()\n val mp = IntArray(n+1){0}\n val ap = LongArray(n+1)\n val minusp = LongArray(n+1)\n val aArr = IntArray(n)\n\n var sum = 0L\n repeat(n) {\n val a = sc.nextInt()\n aArr[it] = a\n if (mp[a] != 0) {\n mp[a] = mp[a] + 1\n if (mp[a] == 2) {\n ap[a] = 1\n minusp[a] = 1\n sum += 1\n } else {\n val oldap = ap[a]\n val newap = ap[a] * mp[a] / (mp[a]-2)\n ap[a] = newap\n minusp[a] = newap - oldap\n sum += newap - oldap\n }\n } else {\n mp[a] = 1\n ap[a] = 0\n minusp[a] = 0\n }\n }\n\n repeat(n) { cnt ->\n val k = aArr[cnt]\n println(sum - minusp[k])\n }\n}\n", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 905, "cpu_time_ms": 1644, "memory_kb": 89896}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s742931279", "group_id": "codeNet:p02732", "input_text": "import java.util.*\n\nfun main(args: Array) = ABC159D.main()\n\nobject ABC159D {\n fun readInt() = readLine()!!.toInt()\n fun readInts() = readLine()!!.split(\" \").map { it.toInt() }\n\n val N: Int\n val A: List\n\n // n -> nがかかれたボールの個数\n val numGroups: Map\n\n init {\n N = readInt()\n A = readInts()\n numGroups = A.groupBy { it }.mapValues { it.value.size }\n }\n\n fun solve(k: Int): Long {\n\n // n -> nがかかれたボールの個数\n val nums = HashMap(numGroups)\n val all = nums[A[k-1]] ?: 1\n nums[A[k-1]] = all - 1\n\n return nums.values.map { n ->\n (n * (n - 1) / 2).toLong()\n }.sum()\n }\n\n fun main() {\n val results = (1..N).map { k ->\n solve(k)\n }\n println(results.joinToString(\"\\n\"))\n }\n}", "language": "Kotlin", "metadata": {"date": 1584928026, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02732.html", "problem_id": "p02732", "resource_group": "medium_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/Kotlin/s742931279.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s742931279", "user_id": "u981616728"}, "prompt_components": {"gold_output": "2\n2\n3\n2\n3\n", "input_to_evaluate": "import java.util.*\n\nfun main(args: Array) = ABC159D.main()\n\nobject ABC159D {\n fun readInt() = readLine()!!.toInt()\n fun readInts() = readLine()!!.split(\" \").map { it.toInt() }\n\n val N: Int\n val A: List\n\n // n -> nがかかれたボールの個数\n val numGroups: Map\n\n init {\n N = readInt()\n A = readInts()\n numGroups = A.groupBy { it }.mapValues { it.value.size }\n }\n\n fun solve(k: Int): Long {\n\n // n -> nがかかれたボールの個数\n val nums = HashMap(numGroups)\n val all = nums[A[k-1]] ?: 1\n nums[A[k-1]] = all - 1\n\n return nums.values.map { n ->\n (n * (n - 1) / 2).toLong()\n }.sum()\n }\n\n fun main() {\n val results = (1..N).map { k ->\n solve(k)\n }\n println(results.joinToString(\"\\n\"))\n }\n}", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 864, "cpu_time_ms": 2111, "memory_kb": 153948}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s043010190", "group_id": "codeNet:p02735", "input_text": "fun main(args: Array) {\n var range: String? = readLine()\n var param = range!!.split(\" \")\n var height: Int = param[0].toInt()\n var width: Int = param[1].toInt()\n var row : String? = \"\"\n var field: Array = emptyArray()\n for(i in 0 until height){\n row = readLine()\n field += row!!\n }\n var loopFlg:Boolean = true\n var x:Int = 0\n var y:Int = 0\n var ini = arrayOf(0,0,0)\n var len = height + width - 1\n var route = Array>(len,{it -> ini})\n var check = '.'\n var min = 0\n var sut = '.'\n var view = len\n var last = -1\n while(loopFlg){\n sut = field[x][y]\n if(sut == '#' && sut != check) min++\n check = sut\n if(x + 1 < height){\n if(y + 1 < width){\n last++\n route[last] = arrayOf(x,y,min)\n }\n x++\n }else if(y + 1 < width){\n y++\n }else{\n if(min < view) view = min\n check = '.'\n if(last<0 ){\n loopFlg = false\n }else{\n x = route[last][0]\n y = route[last][1] + 1\n min = route[last][2]\n route[last] = arrayOf(len,len,0)\n last--\n }\n }\n }\n println(view)\n}", "language": "Kotlin", "metadata": {"date": 1585325900, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02735.html", "problem_id": "p02735", "resource_group": "medium_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/Kotlin/s043010190.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s043010190", "user_id": "u791668159"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "fun main(args: Array) {\n var range: String? = readLine()\n var param = range!!.split(\" \")\n var height: Int = param[0].toInt()\n var width: Int = param[1].toInt()\n var row : String? = \"\"\n var field: Array = emptyArray()\n for(i in 0 until height){\n row = readLine()\n field += row!!\n }\n var loopFlg:Boolean = true\n var x:Int = 0\n var y:Int = 0\n var ini = arrayOf(0,0,0)\n var len = height + width - 1\n var route = Array>(len,{it -> ini})\n var check = '.'\n var min = 0\n var sut = '.'\n var view = len\n var last = -1\n while(loopFlg){\n sut = field[x][y]\n if(sut == '#' && sut != check) min++\n check = sut\n if(x + 1 < height){\n if(y + 1 < width){\n last++\n route[last] = arrayOf(x,y,min)\n }\n x++\n }else if(y + 1 < width){\n y++\n }else{\n if(min < view) view = min\n check = '.'\n if(last<0 ){\n loopFlg = false\n }else{\n x = route[last][0]\n y = route[last][1] + 1\n min = route[last][2]\n route[last] = arrayOf(len,len,0)\n last--\n }\n }\n }\n println(view)\n}", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1117, "cpu_time_ms": 2111, "memory_kb": 116316}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s890701831", "group_id": "codeNet:p02735", "input_text": "fun main(args: Array) {\n val (h, w) = readLine()!!.split(\" \").map { it.toInt() }\n val items = (0 until h).map {\n readLine()!!.toCharArray().map {\n when (it) {\n '.' -> true\n '#' -> false\n else -> throw IllegalStateException()\n }\n }\n }\n\n val map = mutableMapOf()\n for (i in (h - 1) downTo 0) {\n for (j in (w - 1) downTo 0) {\n val isGood = items[i][j]\n if (i == (h - 1) && j == (w - 1)) {\n map[\"$i-$j\"] = if (isGood) 0 else 1\n continue\n }\n\n val fromDown = if (i != (h - 1)) {\n map[\"${i + 1}-$j\"]!! + if (isGood && isGood != items[i + 1][j]) 1 else 0\n } else {\n Int.MAX_VALUE\n }\n val fromEnd = if (j != (w - 1)) {\n map[\"$i-${j + 1}\"]!! + if (isGood && isGood != items[i][j + 1]) 1 else 0\n } else {\n Int.MAX_VALUE\n }\n map[\"$i-$j\"] = Math.min(fromDown, fromEnd)\n }\n }\n\n val result = map[\"0-0\"]!! + if (!items[0][0] && items[h - 1][w - 1]) 1 else 0\n println(result)\n}", "language": "Kotlin", "metadata": {"date": 1585147710, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02735.html", "problem_id": "p02735", "resource_group": "medium_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/Kotlin/s890701831.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s890701831", "user_id": "u897579945"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "fun main(args: Array) {\n val (h, w) = readLine()!!.split(\" \").map { it.toInt() }\n val items = (0 until h).map {\n readLine()!!.toCharArray().map {\n when (it) {\n '.' -> true\n '#' -> false\n else -> throw IllegalStateException()\n }\n }\n }\n\n val map = mutableMapOf()\n for (i in (h - 1) downTo 0) {\n for (j in (w - 1) downTo 0) {\n val isGood = items[i][j]\n if (i == (h - 1) && j == (w - 1)) {\n map[\"$i-$j\"] = if (isGood) 0 else 1\n continue\n }\n\n val fromDown = if (i != (h - 1)) {\n map[\"${i + 1}-$j\"]!! + if (isGood && isGood != items[i + 1][j]) 1 else 0\n } else {\n Int.MAX_VALUE\n }\n val fromEnd = if (j != (w - 1)) {\n map[\"$i-${j + 1}\"]!! + if (isGood && isGood != items[i][j + 1]) 1 else 0\n } else {\n Int.MAX_VALUE\n }\n map[\"$i-$j\"] = Math.min(fromDown, fromEnd)\n }\n }\n\n val result = map[\"0-0\"]!! + if (!items[0][0] && items[h - 1][w - 1]) 1 else 0\n println(result)\n}", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1200, "cpu_time_ms": 349, "memory_kb": 40552}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s330564293", "group_id": "codeNet:p02736", "input_text": "fun main(args: Array) {\n val N = readLine()!!.toInt();\n val a = IntArray(N)\n val num = readLine()!!.toCharArray()\n for (i in 0 until N) {\n a[i] = num[i] - '0'\n }\n if (N == 2) {\n println(Math.abs(a[0] - a[1]))\n return\n }\n for (i in 0 until N) {\n if (a[i] == 2) {\n a[i] = 0\n } else if (a[i] == 1) {\n a[i] = -1\n } else {\n a[i] = 1\n }\n }\n val b = IntArray(N - 1)\n for (i in 0 until N - 1) {\n b[i] = (a[i] + a[i + 1]) % 2\n }\n val MAX = 1000000\n val MOD = 3\n val fac = LongArray(MAX)\n val finv = LongArray(MAX)\n val inv = LongArray(MAX)\n fac[1] = 1\n fac[0] = fac[1]\n finv[1] = 1\n finv[0] = finv[1]\n inv[1] = 1\n for (i in 2 until MAX) {\n fac[i] = fac[i - 1] * i % MOD\n inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD\n finv[i] = finv[i - 1] * inv[i] % MOD\n }\n var sum = 0\n for (i in 0 until N - 1) {\n sum += (b[i] * ncr(fac, finv, N - 2, i, MOD)).toInt()\n sum %= 3\n }\n println(sum)\n}\n\nfun ncr(fac: LongArray, finv: LongArray, n: Int, k: Int, MOD: Int): Long {\n if (n < k) return 0\n return if (n < 0 || k < 0) 0 else fac[n] * (finv[k] * finv[n - k] % MOD) % MOD\n}\n", "language": "Kotlin", "metadata": {"date": 1584846850, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02736.html", "problem_id": "p02736", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02736/input.txt", "sample_output_relpath": "derived/input_output/data/p02736/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02736/Kotlin/s330564293.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s330564293", "user_id": "u465133507"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "fun main(args: Array) {\n val N = readLine()!!.toInt();\n val a = IntArray(N)\n val num = readLine()!!.toCharArray()\n for (i in 0 until N) {\n a[i] = num[i] - '0'\n }\n if (N == 2) {\n println(Math.abs(a[0] - a[1]))\n return\n }\n for (i in 0 until N) {\n if (a[i] == 2) {\n a[i] = 0\n } else if (a[i] == 1) {\n a[i] = -1\n } else {\n a[i] = 1\n }\n }\n val b = IntArray(N - 1)\n for (i in 0 until N - 1) {\n b[i] = (a[i] + a[i + 1]) % 2\n }\n val MAX = 1000000\n val MOD = 3\n val fac = LongArray(MAX)\n val finv = LongArray(MAX)\n val inv = LongArray(MAX)\n fac[1] = 1\n fac[0] = fac[1]\n finv[1] = 1\n finv[0] = finv[1]\n inv[1] = 1\n for (i in 2 until MAX) {\n fac[i] = fac[i - 1] * i % MOD\n inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD\n finv[i] = finv[i - 1] * inv[i] % MOD\n }\n var sum = 0\n for (i in 0 until N - 1) {\n sum += (b[i] * ncr(fac, finv, N - 2, i, MOD)).toInt()\n sum %= 3\n }\n println(sum)\n}\n\nfun ncr(fac: LongArray, finv: LongArray, n: Int, k: Int, MOD: Int): Long {\n if (n < k) return 0\n return if (n < 0 || k < 0) 0 else fac[n] * (finv[k] * finv[n - k] % MOD) % MOD\n}\n", "problem_context": "Score : 700 points\n\nProblem Statement\n\nGiven is a sequence of N digits a_1a_2\\ldots a_N, where each element is 1, 2, or 3.\nLet x_{i,j} defined as follows:\n\nx_{1,j} := a_j \\quad (1 \\leq j \\leq N)\n\nx_{i,j} := | x_{i-1,j} - x_{i-1,j+1} | \\quad (2 \\leq i \\leq N and 1 \\leq j \\leq N+1-i)\n\nFind x_{N,1}.\n\nConstraints\n\n2 \\leq N \\leq 10^6\n\na_i = 1,2,3 (1 \\leq i \\leq N)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1a_2\\ldotsa_N\n\nOutput\n\nPrint x_{N,1}.\n\nSample Input 1\n\n4\n1231\n\nSample Output 1\n\n1\n\nx_{1,1},x_{1,2},x_{1,3},x_{1,4} are respectively 1,2,3,1.\n\nx_{2,1},x_{2,2},x_{2,3} are respectively |1-2| = 1,|2-3| = 1,|3-1| = 2.\n\nx_{3,1},x_{3,2} are respectively |1-1| = 0,|1-2| = 1.\n\nFinally, x_{4,1} = |0-1| = 1, so the answer is 1.\n\nSample Input 2\n\n10\n2311312312\n\nSample Output 2\n\n0", "sample_input": "4\n1231\n"}, "reference_outputs": ["1\n"], "source_document_id": "p02736", "source_text": "Score : 700 points\n\nProblem Statement\n\nGiven is a sequence of N digits a_1a_2\\ldots a_N, where each element is 1, 2, or 3.\nLet x_{i,j} defined as follows:\n\nx_{1,j} := a_j \\quad (1 \\leq j \\leq N)\n\nx_{i,j} := | x_{i-1,j} - x_{i-1,j+1} | \\quad (2 \\leq i \\leq N and 1 \\leq j \\leq N+1-i)\n\nFind x_{N,1}.\n\nConstraints\n\n2 \\leq N \\leq 10^6\n\na_i = 1,2,3 (1 \\leq i \\leq N)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1a_2\\ldotsa_N\n\nOutput\n\nPrint x_{N,1}.\n\nSample Input 1\n\n4\n1231\n\nSample Output 1\n\n1\n\nx_{1,1},x_{1,2},x_{1,3},x_{1,4} are respectively 1,2,3,1.\n\nx_{2,1},x_{2,2},x_{2,3} are respectively |1-2| = 1,|2-3| = 1,|3-1| = 2.\n\nx_{3,1},x_{3,2} are respectively |1-1| = 0,|1-2| = 1.\n\nFinally, x_{4,1} = |0-1| = 1, so the answer is 1.\n\nSample Input 2\n\n10\n2311312312\n\nSample Output 2\n\n0", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1275, "cpu_time_ms": 406, "memory_kb": 73792}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s419205978", "group_id": "codeNet:p02736", "input_text": "import java.lang.Math\n\nfun main(args: Array) {\n val N = readInputLine().toInt()\n val a = readInputLine().toCharArray()\n\n val conCat = IntArray(N - 1)\n\n for (i in 0 until N - 1) {\n conCat[i] = Math.abs(a[i] - a[i + 1])\n }\n\n if (N == 2) {\n println(conCat[0])\n return\n }\n\n var ans = 0\n\n for (i in 0 until N - 2) {\n ans = Math.abs(ans - Math.abs(conCat[i] - conCat[i + 1]))\n }\n\n println(ans)\n}\n\nfun readInputLine(): String {\n return readLine()!!\n}\n", "language": "Kotlin", "metadata": {"date": 1584842785, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02736.html", "problem_id": "p02736", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02736/input.txt", "sample_output_relpath": "derived/input_output/data/p02736/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02736/Kotlin/s419205978.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s419205978", "user_id": "u505558493"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "import java.lang.Math\n\nfun main(args: Array) {\n val N = readInputLine().toInt()\n val a = readInputLine().toCharArray()\n\n val conCat = IntArray(N - 1)\n\n for (i in 0 until N - 1) {\n conCat[i] = Math.abs(a[i] - a[i + 1])\n }\n\n if (N == 2) {\n println(conCat[0])\n return\n }\n\n var ans = 0\n\n for (i in 0 until N - 2) {\n ans = Math.abs(ans - Math.abs(conCat[i] - conCat[i + 1]))\n }\n\n println(ans)\n}\n\nfun readInputLine(): String {\n return readLine()!!\n}\n", "problem_context": "Score : 700 points\n\nProblem Statement\n\nGiven is a sequence of N digits a_1a_2\\ldots a_N, where each element is 1, 2, or 3.\nLet x_{i,j} defined as follows:\n\nx_{1,j} := a_j \\quad (1 \\leq j \\leq N)\n\nx_{i,j} := | x_{i-1,j} - x_{i-1,j+1} | \\quad (2 \\leq i \\leq N and 1 \\leq j \\leq N+1-i)\n\nFind x_{N,1}.\n\nConstraints\n\n2 \\leq N \\leq 10^6\n\na_i = 1,2,3 (1 \\leq i \\leq N)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1a_2\\ldotsa_N\n\nOutput\n\nPrint x_{N,1}.\n\nSample Input 1\n\n4\n1231\n\nSample Output 1\n\n1\n\nx_{1,1},x_{1,2},x_{1,3},x_{1,4} are respectively 1,2,3,1.\n\nx_{2,1},x_{2,2},x_{2,3} are respectively |1-2| = 1,|2-3| = 1,|3-1| = 2.\n\nx_{3,1},x_{3,2} are respectively |1-1| = 0,|1-2| = 1.\n\nFinally, x_{4,1} = |0-1| = 1, so the answer is 1.\n\nSample Input 2\n\n10\n2311312312\n\nSample Output 2\n\n0", "sample_input": "4\n1231\n"}, "reference_outputs": ["1\n"], "source_document_id": "p02736", "source_text": "Score : 700 points\n\nProblem Statement\n\nGiven is a sequence of N digits a_1a_2\\ldots a_N, where each element is 1, 2, or 3.\nLet x_{i,j} defined as follows:\n\nx_{1,j} := a_j \\quad (1 \\leq j \\leq N)\n\nx_{i,j} := | x_{i-1,j} - x_{i-1,j+1} | \\quad (2 \\leq i \\leq N and 1 \\leq j \\leq N+1-i)\n\nFind x_{N,1}.\n\nConstraints\n\n2 \\leq N \\leq 10^6\n\na_i = 1,2,3 (1 \\leq i \\leq N)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1a_2\\ldotsa_N\n\nOutput\n\nPrint x_{N,1}.\n\nSample Input 1\n\n4\n1231\n\nSample Output 1\n\n1\n\nx_{1,1},x_{1,2},x_{1,3},x_{1,4} are respectively 1,2,3,1.\n\nx_{2,1},x_{2,2},x_{2,3} are respectively |1-2| = 1,|2-3| = 1,|3-1| = 2.\n\nx_{3,1},x_{3,2} are respectively |1-1| = 0,|1-2| = 1.\n\nFinally, x_{4,1} = |0-1| = 1, so the answer is 1.\n\nSample Input 2\n\n10\n2311312312\n\nSample Output 2\n\n0", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 301, "memory_kb": 43576}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s220154868", "group_id": "codeNet:p02741", "input_text": "fun main(args: Array) {\n val a = arrayOf(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)\n val i = getInt()\n println(a[i - 1])\n}\n\nfun getInt() = readLine()!!.toInt()", "language": "Kotlin", "metadata": {"date": 1584234371, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02741.html", "problem_id": "p02741", "resource_group": "medium_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/Kotlin/s220154868.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s220154868", "user_id": "u895858420"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "fun main(args: Array) {\n val a = arrayOf(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)\n val i = getInt()\n println(a[i - 1])\n}\n\nfun getInt() = readLine()!!.toInt()", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 206, "memory_kb": 33712}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s936598526", "group_id": "codeNet:p02742", "input_text": "import java.io.BufferedReader\nimport java.io.InputStream\nimport java.io.InputStreamReader\nimport java.lang.StringBuilder\nimport java.util.*\n\nfun main(args: Array) {\n val sc = FastScanner(System.`in`)\n val h = sc.nextLong()\n val w = sc.nextLong()\n if (h % 2 == 0L || w % 2 == 0L) {\n println(h * w / 2L)\n } else {\n println(h * w / 2L + 1L)\n }\n}\n\nclass FastScanner(s: InputStream) {\n private var st = StringTokenizer(\"\")\n private val br = BufferedReader(InputStreamReader(s))\n\n fun next(): String {\n while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())\n\n return st.nextToken()\n }\n\n fun nextInt() = next().toInt()\n fun nextLong() = next().toLong()\n fun nextLine() = br.readLine()\n fun nextDouble() = next().toDouble()\n fun ready() = br.ready()\n}\n", "language": "Kotlin", "metadata": {"date": 1584236158, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02742.html", "problem_id": "p02742", "resource_group": "medium_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/Kotlin/s936598526.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s936598526", "user_id": "u190507186"}, "prompt_components": {"gold_output": "10\n", "input_to_evaluate": "import java.io.BufferedReader\nimport java.io.InputStream\nimport java.io.InputStreamReader\nimport java.lang.StringBuilder\nimport java.util.*\n\nfun main(args: Array) {\n val sc = FastScanner(System.`in`)\n val h = sc.nextLong()\n val w = sc.nextLong()\n if (h % 2 == 0L || w % 2 == 0L) {\n println(h * w / 2L)\n } else {\n println(h * w / 2L + 1L)\n }\n}\n\nclass FastScanner(s: InputStream) {\n private var st = StringTokenizer(\"\")\n private val br = BufferedReader(InputStreamReader(s))\n\n fun next(): String {\n while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())\n\n return st.nextToken()\n }\n\n fun nextInt() = next().toInt()\n fun nextLong() = next().toLong()\n fun nextLine() = br.readLine()\n fun nextDouble() = next().toDouble()\n fun ready() = br.ready()\n}\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 834, "cpu_time_ms": 169, "memory_kb": 29344}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s777905884", "group_id": "codeNet:p02742", "input_text": "fun main(args: Array) {\n val hw = readLine()!!.split(\" \").map { it.toLong() }\n\n if (hw[1] % 2 == 0.toLong()) {\n print(hw[1]*hw[0]/2)\n } else {\n print((hw[1]/2)*hw[0] + hw[0]/2 + hw[0] % 2)\n }\n}\n", "language": "Kotlin", "metadata": {"date": 1584234912, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02742.html", "problem_id": "p02742", "resource_group": "medium_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/Kotlin/s777905884.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s777905884", "user_id": "u069766151"}, "prompt_components": {"gold_output": "10\n", "input_to_evaluate": "fun main(args: Array) {\n val hw = readLine()!!.split(\" \").map { it.toLong() }\n\n if (hw[1] % 2 == 0.toLong()) {\n print(hw[1]*hw[0]/2)\n } else {\n print((hw[1]/2)*hw[0] + hw[0]/2 + hw[0] % 2)\n }\n}\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 278, "memory_kb": 38012}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s960685017", "group_id": "codeNet:p02742", "input_text": "fun main(args: Array) {\n var tmp = readLine()!!.split(\" \").map(String::toLong);\n val h = tmp[0];\n val w = tmp[1];\n val bool = h % 2 == 1L || w % 2 == 1L\n var t = h * w / 2\n if (bool) {\n t++\n }\n println(t);\n}\n", "language": "Kotlin", "metadata": {"date": 1584234540, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02742.html", "problem_id": "p02742", "resource_group": "medium_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/Kotlin/s960685017.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s960685017", "user_id": "u324739185"}, "prompt_components": {"gold_output": "10\n", "input_to_evaluate": "fun main(args: Array) {\n var tmp = readLine()!!.split(\" \").map(String::toLong);\n val h = tmp[0];\n val w = tmp[1];\n val bool = h % 2 == 1L || w % 2 == 1L\n var t = h * w / 2\n if (bool) {\n t++\n }\n println(t);\n}\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 258, "memory_kb": 37692}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s147014717", "group_id": "codeNet:p02744", "input_text": "import java.io.BufferedReader\nimport java.io.InputStream\nimport java.io.InputStreamReader\nimport java.util.*\n\nfun main(args: Array) {\n val sc = FastScanner(System.`in`)\n val n = sc.nextInt()\n\n dfs(n, LinkedList(), 0)\n\n}\n\nfun dfs(n: Int, res: LinkedList, max:Int) {\n if (res.size == n) {\n println(res.joinToString(\"\") { ('a' + it).toString() })\n return\n }\n for (c in 0..max) {\n res.add(c)\n dfs(n, res, if (c == max) max + 1 else max)\n res.pollLast()\n }\n}\n\nclass FastScanner(s: InputStream) {\n private var st = StringTokenizer(\"\")\n private val br = BufferedReader(InputStreamReader(s))\n\n fun next(): String {\n while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())\n\n return st.nextToken()\n }\n\n fun nextInt() = next().toInt()\n fun nextLong() = next().toLong()\n fun nextLine() = br.readLine()\n fun nextDouble() = next().toDouble()\n fun ready() = br.ready()\n}", "language": "Kotlin", "metadata": {"date": 1584401403, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02744.html", "problem_id": "p02744", "resource_group": "medium_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/Kotlin/s147014717.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s147014717", "user_id": "u178770699"}, "prompt_components": {"gold_output": "a\n", "input_to_evaluate": "import java.io.BufferedReader\nimport java.io.InputStream\nimport java.io.InputStreamReader\nimport java.util.*\n\nfun main(args: Array) {\n val sc = FastScanner(System.`in`)\n val n = sc.nextInt()\n\n dfs(n, LinkedList(), 0)\n\n}\n\nfun dfs(n: Int, res: LinkedList, max:Int) {\n if (res.size == n) {\n println(res.joinToString(\"\") { ('a' + it).toString() })\n return\n }\n for (c in 0..max) {\n res.add(c)\n dfs(n, res, if (c == max) max + 1 else max)\n res.pollLast()\n }\n}\n\nclass FastScanner(s: InputStream) {\n private var st = StringTokenizer(\"\")\n private val br = BufferedReader(InputStreamReader(s))\n\n fun next(): String {\n while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())\n\n return st.nextToken()\n }\n\n fun nextInt() = next().toInt()\n fun nextLong() = next().toLong()\n fun nextLine() = br.readLine()\n fun nextDouble() = next().toDouble()\n fun ready() = br.ready()\n}", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 978, "cpu_time_ms": 962, "memory_kb": 40820}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s435196154", "group_id": "codeNet:p02744", "input_text": "fun main(args: Array) = panasonic2020d()\n\nfun panasonic2020d() {\n val n = readLine()!!.toInt()\n\n val answer = mutableListOf()\n\n for (i in 0 until n) {\n answer.add(\"a\".repeat(n - i) + \"b\".repeat(i))\n }\n\n println(answer.joinToString(System.lineSeparator()))\n}\n", "language": "Kotlin", "metadata": {"date": 1584239760, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02744.html", "problem_id": "p02744", "resource_group": "medium_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/Kotlin/s435196154.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s435196154", "user_id": "u139478771"}, "prompt_components": {"gold_output": "a\n", "input_to_evaluate": "fun main(args: Array) = panasonic2020d()\n\nfun panasonic2020d() {\n val n = readLine()!!.toInt()\n\n val answer = mutableListOf()\n\n for (i in 0 until n) {\n answer.add(\"a\".repeat(n - i) + \"b\".repeat(i))\n }\n\n println(answer.joinToString(System.lineSeparator()))\n}\n", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 296, "cpu_time_ms": 217, "memory_kb": 33608}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s537725398", "group_id": "codeNet:p02745", "input_text": "fun main(args: Array) {\n val s0 = Array(3) { next() }.sorted()\n val s = Array(3) { s0[it] }\n val MX = 2001\n var ans = MX * 3\n val d = Array(3) { Array(3) { BooleanArray(MX) } }\n do {\n for (i in 0 until 3) for (j in 0 until 3) for (k in 0 until s[i].length) {\n if (i >= j) continue\n var ok = true\n for (ni in k until s[i].length) {\n val nj = ni - k\n if (nj >= s[j].length) break\n if (s[i][ni] == '?' || s[j][nj] == '?') continue\n if (s[i][ni] != s[j][nj]) ok = false\n }\n d[i][j][k] = ok\n }\n fun f(i: Int, j: Int, k: Int) = if (k >= s[i].length) true else d[i][j][k]\n for (x in 0 until MX) for (y in 0 until MX) {\n if (!f(0, 1, x)) continue\n if (!f(1, 2, y)) continue\n if (!f(0, 2, x + y)) continue\n val now = listOf(s[0].length, x + s[0].length, x + y + s[2].length).max()!!\n ans = Math.min(ans, now)\n }\n } while (nextPermutation(s))\n println(ans)\n}\nfun nextPermutation(a: Array): Boolean {\n for (i in a.size - 1 downTo 1) {\n if (a[i - 1] < a[i]) {\n val swapIndex = find(a[i - 1], a, i, a.size - 1)\n val temp: String = a[swapIndex]\n a[swapIndex] = a[i - 1]\n a[i - 1] = temp\n a.sort(i, a.size)\n return true\n }\n }\n return false\n}\nprivate fun find(dest: String, a: Array, s: Int, e: Int): Int {\n if (s == e) {\n return s\n }\n val m = (s + e + 1) / 2\n return if (a[m] <= dest) find(dest, a, s, m - 1) else find(dest, a, m, e)\n}\n\nfun next() = readLine()!!\n", "language": "Kotlin", "metadata": {"date": 1584276275, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02745.html", "problem_id": "p02745", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02745/input.txt", "sample_output_relpath": "derived/input_output/data/p02745/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02745/Kotlin/s537725398.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s537725398", "user_id": "u043150661"}, "prompt_components": {"gold_output": "7\n", "input_to_evaluate": "fun main(args: Array) {\n val s0 = Array(3) { next() }.sorted()\n val s = Array(3) { s0[it] }\n val MX = 2001\n var ans = MX * 3\n val d = Array(3) { Array(3) { BooleanArray(MX) } }\n do {\n for (i in 0 until 3) for (j in 0 until 3) for (k in 0 until s[i].length) {\n if (i >= j) continue\n var ok = true\n for (ni in k until s[i].length) {\n val nj = ni - k\n if (nj >= s[j].length) break\n if (s[i][ni] == '?' || s[j][nj] == '?') continue\n if (s[i][ni] != s[j][nj]) ok = false\n }\n d[i][j][k] = ok\n }\n fun f(i: Int, j: Int, k: Int) = if (k >= s[i].length) true else d[i][j][k]\n for (x in 0 until MX) for (y in 0 until MX) {\n if (!f(0, 1, x)) continue\n if (!f(1, 2, y)) continue\n if (!f(0, 2, x + y)) continue\n val now = listOf(s[0].length, x + s[0].length, x + y + s[2].length).max()!!\n ans = Math.min(ans, now)\n }\n } while (nextPermutation(s))\n println(ans)\n}\nfun nextPermutation(a: Array): Boolean {\n for (i in a.size - 1 downTo 1) {\n if (a[i - 1] < a[i]) {\n val swapIndex = find(a[i - 1], a, i, a.size - 1)\n val temp: String = a[swapIndex]\n a[swapIndex] = a[i - 1]\n a[i - 1] = temp\n a.sort(i, a.size)\n return true\n }\n }\n return false\n}\nprivate fun find(dest: String, a: Array, s: Int, e: Int): Int {\n if (s == e) {\n return s\n }\n val m = (s + e + 1) / 2\n return if (a[m] <= dest) find(dest, a, s, m - 1) else find(dest, a, m, e)\n}\n\nfun next() = readLine()!!\n", "problem_context": "Score : 500 points\n\nProblem Statement\n\nSnuke has a string s.\nFrom this string, Anuke, Bnuke, and Cnuke obtained strings a, b, and c, respectively, as follows:\n\nChoose a non-empty (contiguous) substring of s (possibly s itself). Then, replace some characters (possibly all or none) in it with ?s.\n\nFor example, if s is mississippi, we can choose the substring ssissip and replace its 1-st and 3-rd characters with ? to obtain ?s?ssip.\n\nYou are given the strings a, b, and c.\nFind the minimum possible length of s.\n\nConstraints\n\n1 \\leq |a|, |b|, |c| \\leq 2000\n\na, b, and c consists of lowercase English letters and ?s.\n\nInput\n\nInput is given from Standard Input in the following format:\n\na\nb\nc\n\nOutput\n\nPrint the minimum possible length of s.\n\nSample Input 1\n\na?c\nder\ncod\n\nSample Output 1\n\n7\n\nFor example, s could be atcoder.\n\nSample Input 2\n\natcoder\natcoder\n???????\n\nSample Output 2\n\n7\n\na, b, and c may not be distinct.", "sample_input": "a?c\nder\ncod\n"}, "reference_outputs": ["7\n"], "source_document_id": "p02745", "source_text": "Score : 500 points\n\nProblem Statement\n\nSnuke has a string s.\nFrom this string, Anuke, Bnuke, and Cnuke obtained strings a, b, and c, respectively, as follows:\n\nChoose a non-empty (contiguous) substring of s (possibly s itself). Then, replace some characters (possibly all or none) in it with ?s.\n\nFor example, if s is mississippi, we can choose the substring ssissip and replace its 1-st and 3-rd characters with ? to obtain ?s?ssip.\n\nYou are given the strings a, b, and c.\nFind the minimum possible length of s.\n\nConstraints\n\n1 \\leq |a|, |b|, |c| \\leq 2000\n\na, b, and c consists of lowercase English letters and ?s.\n\nInput\n\nInput is given from Standard Input in the following format:\n\na\nb\nc\n\nOutput\n\nPrint the minimum possible length of s.\n\nSample Input 1\n\na?c\nder\ncod\n\nSample Output 1\n\n7\n\nFor example, s could be atcoder.\n\nSample Input 2\n\natcoder\natcoder\n???????\n\nSample Output 2\n\n7\n\na, b, and c may not be distinct.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1725, "cpu_time_ms": 1372, "memory_kb": 120320}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s541145791", "group_id": "codeNet:p02753", "input_text": "fun solve(S: String) {\n val s = S.split(\"\")\n var ans = \"No\"\n for (i in 1..2){\n if (s[i] != s[i + 1]) {\n ans = \"Yes\"\n break\n }\n }\n println(ans)\n}\n\nfun main() {\n val S = readLine()!!\n// val N = readLine()!!.toInt()\n// val (N, M) = readLine()!!.split(\" \").map { it.toInt() }\n// val A = readLine()!!.split(\" \").map { it.toInt() }\n solve(S)\n}", "language": "Kotlin", "metadata": {"date": 1595626823, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02753.html", "problem_id": "p02753", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02753/input.txt", "sample_output_relpath": "derived/input_output/data/p02753/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02753/Kotlin/s541145791.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s541145791", "user_id": "u945228737"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "fun solve(S: String) {\n val s = S.split(\"\")\n var ans = \"No\"\n for (i in 1..2){\n if (s[i] != s[i + 1]) {\n ans = \"Yes\"\n break\n }\n }\n println(ans)\n}\n\nfun main() {\n val S = readLine()!!\n// val N = readLine()!!.toInt()\n// val (N, M) = readLine()!!.split(\" \").map { it.toInt() }\n// val A = readLine()!!.split(\" \").map { it.toInt() }\n solve(S)\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nIn AtCoder City, there are three stations numbered 1, 2, and 3.\n\nEach of these stations is operated by one of the two railway companies, A and B. A string S of length 3 represents which company operates each station. If S_i is A, Company A operates Station i; if S_i is B, Company B operates Station i.\n\nTo improve the transportation condition, for each pair of a station operated by Company A and one operated by Company B, there will be a bus service connecting them.\n\nDetermine if there is a pair of stations that will be connected by a bus service.\n\nConstraints\n\nEach character of S is A or B.\n\n|S| = 3\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nIf there is a pair of stations that will be connected by a bus service, print Yes; otherwise, print No.\n\nSample Input 1\n\nABA\n\nSample Output 1\n\nYes\n\nCompany A operates Station 1 and 3, while Company B operates Station 2.\n\nThere will be a bus service between Station 1 and 2, and between Station 2 and 3, so print Yes.\n\nSample Input 2\n\nBBA\n\nSample Output 2\n\nYes\n\nCompany B operates Station 1 and 2, while Company A operates Station 3.\n\nThere will be a bus service between Station 1 and 3, and between Station 2 and 3, so print Yes.\n\nSample Input 3\n\nBBB\n\nSample Output 3\n\nNo\n\nCompany B operates all the stations. Thus, there will be no bus service, so print No.", "sample_input": "ABA\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p02753", "source_text": "Score : 100 points\n\nProblem Statement\n\nIn AtCoder City, there are three stations numbered 1, 2, and 3.\n\nEach of these stations is operated by one of the two railway companies, A and B. A string S of length 3 represents which company operates each station. If S_i is A, Company A operates Station i; if S_i is B, Company B operates Station i.\n\nTo improve the transportation condition, for each pair of a station operated by Company A and one operated by Company B, there will be a bus service connecting them.\n\nDetermine if there is a pair of stations that will be connected by a bus service.\n\nConstraints\n\nEach character of S is A or B.\n\n|S| = 3\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nIf there is a pair of stations that will be connected by a bus service, print Yes; otherwise, print No.\n\nSample Input 1\n\nABA\n\nSample Output 1\n\nYes\n\nCompany A operates Station 1 and 3, while Company B operates Station 2.\n\nThere will be a bus service between Station 1 and 2, and between Station 2 and 3, so print Yes.\n\nSample Input 2\n\nBBA\n\nSample Output 2\n\nYes\n\nCompany B operates Station 1 and 2, while Company A operates Station 3.\n\nThere will be a bus service between Station 1 and 3, and between Station 2 and 3, so print Yes.\n\nSample Input 3\n\nBBB\n\nSample Output 3\n\nNo\n\nCompany B operates all the stations. Thus, there will be no bus service, so print No.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 403, "cpu_time_ms": 135, "memory_kb": 39964}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s863486718", "group_id": "codeNet:p02753", "input_text": "fun main(args:Array){\n val a=readLine()!!\n if(a[0]==a[1] && a[1]==a[2]){\n println(\"Yes\")\n }else {\n println(\"No\")\n }\n}", "language": "Kotlin", "metadata": {"date": 1586276661, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02753.html", "problem_id": "p02753", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02753/input.txt", "sample_output_relpath": "derived/input_output/data/p02753/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02753/Kotlin/s863486718.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s863486718", "user_id": "u387080888"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "fun main(args:Array){\n val a=readLine()!!\n if(a[0]==a[1] && a[1]==a[2]){\n println(\"Yes\")\n }else {\n println(\"No\")\n }\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nIn AtCoder City, there are three stations numbered 1, 2, and 3.\n\nEach of these stations is operated by one of the two railway companies, A and B. A string S of length 3 represents which company operates each station. If S_i is A, Company A operates Station i; if S_i is B, Company B operates Station i.\n\nTo improve the transportation condition, for each pair of a station operated by Company A and one operated by Company B, there will be a bus service connecting them.\n\nDetermine if there is a pair of stations that will be connected by a bus service.\n\nConstraints\n\nEach character of S is A or B.\n\n|S| = 3\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nIf there is a pair of stations that will be connected by a bus service, print Yes; otherwise, print No.\n\nSample Input 1\n\nABA\n\nSample Output 1\n\nYes\n\nCompany A operates Station 1 and 3, while Company B operates Station 2.\n\nThere will be a bus service between Station 1 and 2, and between Station 2 and 3, so print Yes.\n\nSample Input 2\n\nBBA\n\nSample Output 2\n\nYes\n\nCompany B operates Station 1 and 2, while Company A operates Station 3.\n\nThere will be a bus service between Station 1 and 3, and between Station 2 and 3, so print Yes.\n\nSample Input 3\n\nBBB\n\nSample Output 3\n\nNo\n\nCompany B operates all the stations. Thus, there will be no bus service, so print No.", "sample_input": "ABA\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p02753", "source_text": "Score : 100 points\n\nProblem Statement\n\nIn AtCoder City, there are three stations numbered 1, 2, and 3.\n\nEach of these stations is operated by one of the two railway companies, A and B. A string S of length 3 represents which company operates each station. If S_i is A, Company A operates Station i; if S_i is B, Company B operates Station i.\n\nTo improve the transportation condition, for each pair of a station operated by Company A and one operated by Company B, there will be a bus service connecting them.\n\nDetermine if there is a pair of stations that will be connected by a bus service.\n\nConstraints\n\nEach character of S is A or B.\n\n|S| = 3\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nIf there is a pair of stations that will be connected by a bus service, print Yes; otherwise, print No.\n\nSample Input 1\n\nABA\n\nSample Output 1\n\nYes\n\nCompany A operates Station 1 and 3, while Company B operates Station 2.\n\nThere will be a bus service between Station 1 and 2, and between Station 2 and 3, so print Yes.\n\nSample Input 2\n\nBBA\n\nSample Output 2\n\nYes\n\nCompany B operates Station 1 and 2, while Company A operates Station 3.\n\nThere will be a bus service between Station 1 and 3, and between Station 2 and 3, so print Yes.\n\nSample Input 3\n\nBBB\n\nSample Output 3\n\nNo\n\nCompany B operates all the stations. Thus, there will be no bus service, so print No.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 207, "memory_kb": 31744}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s627929369", "group_id": "codeNet:p02753", "input_text": "import java.util.*\n\nfun main(args: Array) {\n var result :Int = 0\n\n val n = readLine()!!\n\n for(moji in n){\n if(moji == 'A') result += 1\n else result -= 1\n }\n\n when (result){\n -3 -> print(\"No\")\n 3 -> print(\"No\")\n else -> print(\"Yes\")\n }\n\n}", "language": "Kotlin", "metadata": {"date": 1583633629, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02753.html", "problem_id": "p02753", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02753/input.txt", "sample_output_relpath": "derived/input_output/data/p02753/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02753/Kotlin/s627929369.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s627929369", "user_id": "u068599036"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "import java.util.*\n\nfun main(args: Array) {\n var result :Int = 0\n\n val n = readLine()!!\n\n for(moji in n){\n if(moji == 'A') result += 1\n else result -= 1\n }\n\n when (result){\n -3 -> print(\"No\")\n 3 -> print(\"No\")\n else -> print(\"Yes\")\n }\n\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nIn AtCoder City, there are three stations numbered 1, 2, and 3.\n\nEach of these stations is operated by one of the two railway companies, A and B. A string S of length 3 represents which company operates each station. If S_i is A, Company A operates Station i; if S_i is B, Company B operates Station i.\n\nTo improve the transportation condition, for each pair of a station operated by Company A and one operated by Company B, there will be a bus service connecting them.\n\nDetermine if there is a pair of stations that will be connected by a bus service.\n\nConstraints\n\nEach character of S is A or B.\n\n|S| = 3\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nIf there is a pair of stations that will be connected by a bus service, print Yes; otherwise, print No.\n\nSample Input 1\n\nABA\n\nSample Output 1\n\nYes\n\nCompany A operates Station 1 and 3, while Company B operates Station 2.\n\nThere will be a bus service between Station 1 and 2, and between Station 2 and 3, so print Yes.\n\nSample Input 2\n\nBBA\n\nSample Output 2\n\nYes\n\nCompany B operates Station 1 and 2, while Company A operates Station 3.\n\nThere will be a bus service between Station 1 and 3, and between Station 2 and 3, so print Yes.\n\nSample Input 3\n\nBBB\n\nSample Output 3\n\nNo\n\nCompany B operates all the stations. Thus, there will be no bus service, so print No.", "sample_input": "ABA\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p02753", "source_text": "Score : 100 points\n\nProblem Statement\n\nIn AtCoder City, there are three stations numbered 1, 2, and 3.\n\nEach of these stations is operated by one of the two railway companies, A and B. A string S of length 3 represents which company operates each station. If S_i is A, Company A operates Station i; if S_i is B, Company B operates Station i.\n\nTo improve the transportation condition, for each pair of a station operated by Company A and one operated by Company B, there will be a bus service connecting them.\n\nDetermine if there is a pair of stations that will be connected by a bus service.\n\nConstraints\n\nEach character of S is A or B.\n\n|S| = 3\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nIf there is a pair of stations that will be connected by a bus service, print Yes; otherwise, print No.\n\nSample Input 1\n\nABA\n\nSample Output 1\n\nYes\n\nCompany A operates Station 1 and 3, while Company B operates Station 2.\n\nThere will be a bus service between Station 1 and 2, and between Station 2 and 3, so print Yes.\n\nSample Input 2\n\nBBA\n\nSample Output 2\n\nYes\n\nCompany B operates Station 1 and 2, while Company A operates Station 3.\n\nThere will be a bus service between Station 1 and 3, and between Station 2 and 3, so print Yes.\n\nSample Input 3\n\nBBB\n\nSample Output 3\n\nNo\n\nCompany B operates all the stations. Thus, there will be no bus service, so print No.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 298, "cpu_time_ms": 209, "memory_kb": 33688}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s951160320", "group_id": "codeNet:p02753", "input_text": "fun main(s: Array) {\n val k = readLine()!!\n println(if (k.all { it == k[0] }) \"No\" else \"Yes\")\n}", "language": "Kotlin", "metadata": {"date": 1583632985, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02753.html", "problem_id": "p02753", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02753/input.txt", "sample_output_relpath": "derived/input_output/data/p02753/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02753/Kotlin/s951160320.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s951160320", "user_id": "u370564845"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "fun main(s: Array) {\n val k = readLine()!!\n println(if (k.all { it == k[0] }) \"No\" else \"Yes\")\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nIn AtCoder City, there are three stations numbered 1, 2, and 3.\n\nEach of these stations is operated by one of the two railway companies, A and B. A string S of length 3 represents which company operates each station. If S_i is A, Company A operates Station i; if S_i is B, Company B operates Station i.\n\nTo improve the transportation condition, for each pair of a station operated by Company A and one operated by Company B, there will be a bus service connecting them.\n\nDetermine if there is a pair of stations that will be connected by a bus service.\n\nConstraints\n\nEach character of S is A or B.\n\n|S| = 3\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nIf there is a pair of stations that will be connected by a bus service, print Yes; otherwise, print No.\n\nSample Input 1\n\nABA\n\nSample Output 1\n\nYes\n\nCompany A operates Station 1 and 3, while Company B operates Station 2.\n\nThere will be a bus service between Station 1 and 2, and between Station 2 and 3, so print Yes.\n\nSample Input 2\n\nBBA\n\nSample Output 2\n\nYes\n\nCompany B operates Station 1 and 2, while Company A operates Station 3.\n\nThere will be a bus service between Station 1 and 3, and between Station 2 and 3, so print Yes.\n\nSample Input 3\n\nBBB\n\nSample Output 3\n\nNo\n\nCompany B operates all the stations. Thus, there will be no bus service, so print No.", "sample_input": "ABA\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p02753", "source_text": "Score : 100 points\n\nProblem Statement\n\nIn AtCoder City, there are three stations numbered 1, 2, and 3.\n\nEach of these stations is operated by one of the two railway companies, A and B. A string S of length 3 represents which company operates each station. If S_i is A, Company A operates Station i; if S_i is B, Company B operates Station i.\n\nTo improve the transportation condition, for each pair of a station operated by Company A and one operated by Company B, there will be a bus service connecting them.\n\nDetermine if there is a pair of stations that will be connected by a bus service.\n\nConstraints\n\nEach character of S is A or B.\n\n|S| = 3\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nIf there is a pair of stations that will be connected by a bus service, print Yes; otherwise, print No.\n\nSample Input 1\n\nABA\n\nSample Output 1\n\nYes\n\nCompany A operates Station 1 and 3, while Company B operates Station 2.\n\nThere will be a bus service between Station 1 and 2, and between Station 2 and 3, so print Yes.\n\nSample Input 2\n\nBBA\n\nSample Output 2\n\nYes\n\nCompany B operates Station 1 and 2, while Company A operates Station 3.\n\nThere will be a bus service between Station 1 and 3, and between Station 2 and 3, so print Yes.\n\nSample Input 3\n\nBBB\n\nSample Output 3\n\nNo\n\nCompany B operates all the stations. Thus, there will be no bus service, so print No.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 221, "memory_kb": 31960}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s846336354", "group_id": "codeNet:p02754", "input_text": "fun main (args:Array) {\n var (allBalls, bBall, rBall) = readLine()!!.split(\" \").map(String::toLong)\n val brBall = bBall + rBall\n\n if(brBall == allBalls){\n print(bBall)\n return\n }\n if(brBall > allBalls){\n if(bBall <= allBalls){\n print(bBall)\n return\n }\n else{\n print(allBalls)\n return\n }\n }\n if(bBall == 0L){\n print(0L)\n return\n }\n if(brBall < allBalls){\n if(allBalls % brBall == 0L){\n print(allBalls / brBall * bBall)\n }\n else{\n print((allBalls / brBall * bBall) + (allBalls % brBall))\n }\n }\n}", "language": "Kotlin", "metadata": {"date": 1594404106, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02754.html", "problem_id": "p02754", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02754/input.txt", "sample_output_relpath": "derived/input_output/data/p02754/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02754/Kotlin/s846336354.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s846336354", "user_id": "u800824593"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "fun main (args:Array) {\n var (allBalls, bBall, rBall) = readLine()!!.split(\" \").map(String::toLong)\n val brBall = bBall + rBall\n\n if(brBall == allBalls){\n print(bBall)\n return\n }\n if(brBall > allBalls){\n if(bBall <= allBalls){\n print(bBall)\n return\n }\n else{\n print(allBalls)\n return\n }\n }\n if(bBall == 0L){\n print(0L)\n return\n }\n if(brBall < allBalls){\n if(allBalls % brBall == 0L){\n print(allBalls / brBall * bBall)\n }\n else{\n print((allBalls / brBall * bBall) + (allBalls % brBall))\n }\n }\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nTakahashi has many red balls and blue balls. Now, he will place them in a row.\n\nInitially, there is no ball placed.\n\nTakahashi, who is very patient, will do the following operation 10^{100} times:\n\nPlace A blue balls at the end of the row of balls already placed. Then, place B red balls at the end of the row.\n\nHow many blue balls will be there among the first N balls in the row of balls made this way?\n\nConstraints\n\n1 \\leq N \\leq 10^{18}\n\nA, B \\geq 0\n\n0 < A + B \\leq 10^{18}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN A B\n\nOutput\n\nPrint the number of blue balls that will be there among the first N balls in the row of balls.\n\nSample Input 1\n\n8 3 4\n\nSample Output 1\n\n4\n\nLet b denote a blue ball, and r denote a red ball. The first eight balls in the row will be bbbrrrrb, among which there are four blue balls.\n\nSample Input 2\n\n8 0 4\n\nSample Output 2\n\n0\n\nHe placed only red balls from the beginning.\n\nSample Input 3\n\n6 2 4\n\nSample Output 3\n\n2\n\nAmong bbrrrr, there are two blue balls.", "sample_input": "8 3 4\n"}, "reference_outputs": ["4\n"], "source_document_id": "p02754", "source_text": "Score : 200 points\n\nProblem Statement\n\nTakahashi has many red balls and blue balls. Now, he will place them in a row.\n\nInitially, there is no ball placed.\n\nTakahashi, who is very patient, will do the following operation 10^{100} times:\n\nPlace A blue balls at the end of the row of balls already placed. Then, place B red balls at the end of the row.\n\nHow many blue balls will be there among the first N balls in the row of balls made this way?\n\nConstraints\n\n1 \\leq N \\leq 10^{18}\n\nA, B \\geq 0\n\n0 < A + B \\leq 10^{18}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN A B\n\nOutput\n\nPrint the number of blue balls that will be there among the first N balls in the row of balls.\n\nSample Input 1\n\n8 3 4\n\nSample Output 1\n\n4\n\nLet b denote a blue ball, and r denote a red ball. The first eight balls in the row will be bbbrrrrb, among which there are four blue balls.\n\nSample Input 2\n\n8 0 4\n\nSample Output 2\n\n0\n\nHe placed only red balls from the beginning.\n\nSample Input 3\n\n6 2 4\n\nSample Output 3\n\n2\n\nAmong bbrrrr, there are two blue balls.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 681, "cpu_time_ms": 115, "memory_kb": 36536}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s183371698", "group_id": "codeNet:p02754", "input_text": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val n = sc.nextLong()\n val a = sc.nextLong()\n val b = sc.nextLong()\n val div = n / (a + b)\n val rem = n - div * (a + b)\n println(div * a + Math.min(a, rem))\n}", "language": "Kotlin", "metadata": {"date": 1584152314, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02754.html", "problem_id": "p02754", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02754/input.txt", "sample_output_relpath": "derived/input_output/data/p02754/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02754/Kotlin/s183371698.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s183371698", "user_id": "u733811860"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val n = sc.nextLong()\n val a = sc.nextLong()\n val b = sc.nextLong()\n val div = n / (a + b)\n val rem = n - div * (a + b)\n println(div * a + Math.min(a, rem))\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nTakahashi has many red balls and blue balls. Now, he will place them in a row.\n\nInitially, there is no ball placed.\n\nTakahashi, who is very patient, will do the following operation 10^{100} times:\n\nPlace A blue balls at the end of the row of balls already placed. Then, place B red balls at the end of the row.\n\nHow many blue balls will be there among the first N balls in the row of balls made this way?\n\nConstraints\n\n1 \\leq N \\leq 10^{18}\n\nA, B \\geq 0\n\n0 < A + B \\leq 10^{18}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN A B\n\nOutput\n\nPrint the number of blue balls that will be there among the first N balls in the row of balls.\n\nSample Input 1\n\n8 3 4\n\nSample Output 1\n\n4\n\nLet b denote a blue ball, and r denote a red ball. The first eight balls in the row will be bbbrrrrb, among which there are four blue balls.\n\nSample Input 2\n\n8 0 4\n\nSample Output 2\n\n0\n\nHe placed only red balls from the beginning.\n\nSample Input 3\n\n6 2 4\n\nSample Output 3\n\n2\n\nAmong bbrrrr, there are two blue balls.", "sample_input": "8 3 4\n"}, "reference_outputs": ["4\n"], "source_document_id": "p02754", "source_text": "Score : 200 points\n\nProblem Statement\n\nTakahashi has many red balls and blue balls. Now, he will place them in a row.\n\nInitially, there is no ball placed.\n\nTakahashi, who is very patient, will do the following operation 10^{100} times:\n\nPlace A blue balls at the end of the row of balls already placed. Then, place B red balls at the end of the row.\n\nHow many blue balls will be there among the first N balls in the row of balls made this way?\n\nConstraints\n\n1 \\leq N \\leq 10^{18}\n\nA, B \\geq 0\n\n0 < A + B \\leq 10^{18}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN A B\n\nOutput\n\nPrint the number of blue balls that will be there among the first N balls in the row of balls.\n\nSample Input 1\n\n8 3 4\n\nSample Output 1\n\n4\n\nLet b denote a blue ball, and r denote a red ball. The first eight balls in the row will be bbbrrrrb, among which there are four blue balls.\n\nSample Input 2\n\n8 0 4\n\nSample Output 2\n\n0\n\nHe placed only red balls from the beginning.\n\nSample Input 3\n\n6 2 4\n\nSample Output 3\n\n2\n\nAmong bbrrrr, there are two blue balls.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 263, "cpu_time_ms": 186, "memory_kb": 31268}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s874390027", "group_id": "codeNet:p02754", "input_text": "fun main(args: Array) {\n val inLine = readLine()?.split(\" \").orEmpty()\n\n val n = inLine[0].toLong()\n val a = inLine[1].toLong()\n val b = inLine[2].toLong()\n\n val tmp1 = n / (a + b)\n val tmp2 = n % (a + b)\n\n if(tmp2 <= a) {\n println((tmp1 * a) + tmp2)\n }else{\n println((tmp1 * a) + a)\n }\n}", "language": "Kotlin", "metadata": {"date": 1583639073, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02754.html", "problem_id": "p02754", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02754/input.txt", "sample_output_relpath": "derived/input_output/data/p02754/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02754/Kotlin/s874390027.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s874390027", "user_id": "u430710262"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "fun main(args: Array) {\n val inLine = readLine()?.split(\" \").orEmpty()\n\n val n = inLine[0].toLong()\n val a = inLine[1].toLong()\n val b = inLine[2].toLong()\n\n val tmp1 = n / (a + b)\n val tmp2 = n % (a + b)\n\n if(tmp2 <= a) {\n println((tmp1 * a) + tmp2)\n }else{\n println((tmp1 * a) + a)\n }\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nTakahashi has many red balls and blue balls. Now, he will place them in a row.\n\nInitially, there is no ball placed.\n\nTakahashi, who is very patient, will do the following operation 10^{100} times:\n\nPlace A blue balls at the end of the row of balls already placed. Then, place B red balls at the end of the row.\n\nHow many blue balls will be there among the first N balls in the row of balls made this way?\n\nConstraints\n\n1 \\leq N \\leq 10^{18}\n\nA, B \\geq 0\n\n0 < A + B \\leq 10^{18}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN A B\n\nOutput\n\nPrint the number of blue balls that will be there among the first N balls in the row of balls.\n\nSample Input 1\n\n8 3 4\n\nSample Output 1\n\n4\n\nLet b denote a blue ball, and r denote a red ball. The first eight balls in the row will be bbbrrrrb, among which there are four blue balls.\n\nSample Input 2\n\n8 0 4\n\nSample Output 2\n\n0\n\nHe placed only red balls from the beginning.\n\nSample Input 3\n\n6 2 4\n\nSample Output 3\n\n2\n\nAmong bbrrrr, there are two blue balls.", "sample_input": "8 3 4\n"}, "reference_outputs": ["4\n"], "source_document_id": "p02754", "source_text": "Score : 200 points\n\nProblem Statement\n\nTakahashi has many red balls and blue balls. Now, he will place them in a row.\n\nInitially, there is no ball placed.\n\nTakahashi, who is very patient, will do the following operation 10^{100} times:\n\nPlace A blue balls at the end of the row of balls already placed. Then, place B red balls at the end of the row.\n\nHow many blue balls will be there among the first N balls in the row of balls made this way?\n\nConstraints\n\n1 \\leq N \\leq 10^{18}\n\nA, B \\geq 0\n\n0 < A + B \\leq 10^{18}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN A B\n\nOutput\n\nPrint the number of blue balls that will be there among the first N balls in the row of balls.\n\nSample Input 1\n\n8 3 4\n\nSample Output 1\n\n4\n\nLet b denote a blue ball, and r denote a red ball. The first eight balls in the row will be bbbrrrrb, among which there are four blue balls.\n\nSample Input 2\n\n8 0 4\n\nSample Output 2\n\n0\n\nHe placed only red balls from the beginning.\n\nSample Input 3\n\n6 2 4\n\nSample Output 3\n\n2\n\nAmong bbrrrr, there are two blue balls.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 337, "cpu_time_ms": 296, "memory_kb": 38004}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s405119244", "group_id": "codeNet:p02754", "input_text": "fun main(args: Array) {\n val inLine = readLine()?.split(\" \").orEmpty()\n\n val n = inLine[0].toInt()\n val a = inLine[1].toInt()\n val b = inLine[2].toInt()\n var ball = \"\"\n var ballLine = \"\"\n var i = 0\n while(i < a){\n ball += \"b\"\n i++\n }\n i = 0\n while(i < b){\n ball += \"r\"\n i++\n }\n\n var count = 1\n i = 0\n run loop@{\n while (i < 100){\n if(count * (a + b) > n){\n return@loop\n }\n count *= 10\n i++\n }\n }\n i = 0\n while(i < count){\n ballLine += ball\n i++\n }\n\n val result = ballLine.dropLast(ballLine.length - n).replace(\"r\",\"\")\n println(result.length)\n\n\n}", "language": "Kotlin", "metadata": {"date": 1583635647, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02754.html", "problem_id": "p02754", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02754/input.txt", "sample_output_relpath": "derived/input_output/data/p02754/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02754/Kotlin/s405119244.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s405119244", "user_id": "u430710262"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "fun main(args: Array) {\n val inLine = readLine()?.split(\" \").orEmpty()\n\n val n = inLine[0].toInt()\n val a = inLine[1].toInt()\n val b = inLine[2].toInt()\n var ball = \"\"\n var ballLine = \"\"\n var i = 0\n while(i < a){\n ball += \"b\"\n i++\n }\n i = 0\n while(i < b){\n ball += \"r\"\n i++\n }\n\n var count = 1\n i = 0\n run loop@{\n while (i < 100){\n if(count * (a + b) > n){\n return@loop\n }\n count *= 10\n i++\n }\n }\n i = 0\n while(i < count){\n ballLine += ball\n i++\n }\n\n val result = ballLine.dropLast(ballLine.length - n).replace(\"r\",\"\")\n println(result.length)\n\n\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nTakahashi has many red balls and blue balls. Now, he will place them in a row.\n\nInitially, there is no ball placed.\n\nTakahashi, who is very patient, will do the following operation 10^{100} times:\n\nPlace A blue balls at the end of the row of balls already placed. Then, place B red balls at the end of the row.\n\nHow many blue balls will be there among the first N balls in the row of balls made this way?\n\nConstraints\n\n1 \\leq N \\leq 10^{18}\n\nA, B \\geq 0\n\n0 < A + B \\leq 10^{18}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN A B\n\nOutput\n\nPrint the number of blue balls that will be there among the first N balls in the row of balls.\n\nSample Input 1\n\n8 3 4\n\nSample Output 1\n\n4\n\nLet b denote a blue ball, and r denote a red ball. The first eight balls in the row will be bbbrrrrb, among which there are four blue balls.\n\nSample Input 2\n\n8 0 4\n\nSample Output 2\n\n0\n\nHe placed only red balls from the beginning.\n\nSample Input 3\n\n6 2 4\n\nSample Output 3\n\n2\n\nAmong bbrrrr, there are two blue balls.", "sample_input": "8 3 4\n"}, "reference_outputs": ["4\n"], "source_document_id": "p02754", "source_text": "Score : 200 points\n\nProblem Statement\n\nTakahashi has many red balls and blue balls. Now, he will place them in a row.\n\nInitially, there is no ball placed.\n\nTakahashi, who is very patient, will do the following operation 10^{100} times:\n\nPlace A blue balls at the end of the row of balls already placed. Then, place B red balls at the end of the row.\n\nHow many blue balls will be there among the first N balls in the row of balls made this way?\n\nConstraints\n\n1 \\leq N \\leq 10^{18}\n\nA, B \\geq 0\n\n0 < A + B \\leq 10^{18}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN A B\n\nOutput\n\nPrint the number of blue balls that will be there among the first N balls in the row of balls.\n\nSample Input 1\n\n8 3 4\n\nSample Output 1\n\n4\n\nLet b denote a blue ball, and r denote a red ball. The first eight balls in the row will be bbbrrrrb, among which there are four blue balls.\n\nSample Input 2\n\n8 0 4\n\nSample Output 2\n\n0\n\nHe placed only red balls from the beginning.\n\nSample Input 3\n\n6 2 4\n\nSample Output 3\n\n2\n\nAmong bbrrrr, there are two blue balls.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 731, "cpu_time_ms": 240, "memory_kb": 37780}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s277595492", "group_id": "codeNet:p02754", "input_text": "import java.io.BufferedReader\nimport java.io.InputStream\nimport java.io.InputStreamReader\nimport java.lang.StringBuilder\nimport java.util.*\n\nfun main(args: Array) {\n val sc = FastScanner(System.`in`)\n val n = sc.nextLong()\n val a = sc.nextLong()\n val b = sc.nextLong()\n println((n / (a + b)) * a + Math.min(a, n % (a + b)))\n}\n\nclass FastScanner(s: InputStream) {\n private var st = StringTokenizer(\"\")\n private val br = BufferedReader(InputStreamReader(s))\n\n fun next(): String {\n while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())\n\n return st.nextToken()\n }\n\n fun nextInt() = next().toInt()\n fun nextLong() = next().toLong()\n fun nextLine() = br.readLine()\n fun nextDouble() = next().toDouble()\n fun ready() = br.ready()\n}\n", "language": "Kotlin", "metadata": {"date": 1583633033, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02754.html", "problem_id": "p02754", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02754/input.txt", "sample_output_relpath": "derived/input_output/data/p02754/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02754/Kotlin/s277595492.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s277595492", "user_id": "u190507186"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "import java.io.BufferedReader\nimport java.io.InputStream\nimport java.io.InputStreamReader\nimport java.lang.StringBuilder\nimport java.util.*\n\nfun main(args: Array) {\n val sc = FastScanner(System.`in`)\n val n = sc.nextLong()\n val a = sc.nextLong()\n val b = sc.nextLong()\n println((n / (a + b)) * a + Math.min(a, n % (a + b)))\n}\n\nclass FastScanner(s: InputStream) {\n private var st = StringTokenizer(\"\")\n private val br = BufferedReader(InputStreamReader(s))\n\n fun next(): String {\n while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())\n\n return st.nextToken()\n }\n\n fun nextInt() = next().toInt()\n fun nextLong() = next().toLong()\n fun nextLine() = br.readLine()\n fun nextDouble() = next().toDouble()\n fun ready() = br.ready()\n}\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nTakahashi has many red balls and blue balls. Now, he will place them in a row.\n\nInitially, there is no ball placed.\n\nTakahashi, who is very patient, will do the following operation 10^{100} times:\n\nPlace A blue balls at the end of the row of balls already placed. Then, place B red balls at the end of the row.\n\nHow many blue balls will be there among the first N balls in the row of balls made this way?\n\nConstraints\n\n1 \\leq N \\leq 10^{18}\n\nA, B \\geq 0\n\n0 < A + B \\leq 10^{18}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN A B\n\nOutput\n\nPrint the number of blue balls that will be there among the first N balls in the row of balls.\n\nSample Input 1\n\n8 3 4\n\nSample Output 1\n\n4\n\nLet b denote a blue ball, and r denote a red ball. The first eight balls in the row will be bbbrrrrb, among which there are four blue balls.\n\nSample Input 2\n\n8 0 4\n\nSample Output 2\n\n0\n\nHe placed only red balls from the beginning.\n\nSample Input 3\n\n6 2 4\n\nSample Output 3\n\n2\n\nAmong bbrrrr, there are two blue balls.", "sample_input": "8 3 4\n"}, "reference_outputs": ["4\n"], "source_document_id": "p02754", "source_text": "Score : 200 points\n\nProblem Statement\n\nTakahashi has many red balls and blue balls. Now, he will place them in a row.\n\nInitially, there is no ball placed.\n\nTakahashi, who is very patient, will do the following operation 10^{100} times:\n\nPlace A blue balls at the end of the row of balls already placed. Then, place B red balls at the end of the row.\n\nHow many blue balls will be there among the first N balls in the row of balls made this way?\n\nConstraints\n\n1 \\leq N \\leq 10^{18}\n\nA, B \\geq 0\n\n0 < A + B \\leq 10^{18}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN A B\n\nOutput\n\nPrint the number of blue balls that will be there among the first N balls in the row of balls.\n\nSample Input 1\n\n8 3 4\n\nSample Output 1\n\n4\n\nLet b denote a blue ball, and r denote a red ball. The first eight balls in the row will be bbbrrrrb, among which there are four blue balls.\n\nSample Input 2\n\n8 0 4\n\nSample Output 2\n\n0\n\nHe placed only red balls from the beginning.\n\nSample Input 3\n\n6 2 4\n\nSample Output 3\n\n2\n\nAmong bbrrrr, there are two blue balls.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 800, "cpu_time_ms": 194, "memory_kb": 31388}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s132592199", "group_id": "codeNet:p02755", "input_text": "fun main(args: Array) {\n \tval (a, b) = readLine()!!.split(\" \").map { it.toInt() }\n \n println(\n (0..1010).filter {\n (it * 0.08).toInt() == a && (it * 0.10).toInt() == b\n }.min() ?: \"-1\"\n )\n}", "language": "Kotlin", "metadata": {"date": 1584912880, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02755.html", "problem_id": "p02755", "resource_group": "medium_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/Kotlin/s132592199.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s132592199", "user_id": "u072846720"}, "prompt_components": {"gold_output": "25\n", "input_to_evaluate": "fun main(args: Array) {\n \tval (a, b) = readLine()!!.split(\" \").map { it.toInt() }\n \n println(\n (0..1010).filter {\n (it * 0.08).toInt() == a && (it * 0.10).toInt() == b\n }.min() ?: \"-1\"\n )\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 238, "memory_kb": 38068}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s359858554", "group_id": "codeNet:p02755", "input_text": "import java.lang.Math.floor\n\nfun main(args: Array) = abc158c()\n\nfun abc158c() {\n val (a, b) = readLine()!!.split(' ').map { it.toLong() }\n\n val aRange = (a / 0.08).toLong()..((a / 0.08).toLong() + 12)\n val bRange = (b * 10)..(b * 10 + 9)\n\n val answer = bRange.intersect(aRange).min() ?: -1\n\n println(answer)\n}\n", "language": "Kotlin", "metadata": {"date": 1583699203, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02755.html", "problem_id": "p02755", "resource_group": "medium_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/Kotlin/s359858554.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s359858554", "user_id": "u139478771"}, "prompt_components": {"gold_output": "25\n", "input_to_evaluate": "import java.lang.Math.floor\n\nfun main(args: Array) = abc158c()\n\nfun abc158c() {\n val (a, b) = readLine()!!.split(' ').map { it.toLong() }\n\n val aRange = (a / 0.08).toLong()..((a / 0.08).toLong() + 12)\n val bRange = (b * 10)..(b * 10 + 9)\n\n val answer = bRange.intersect(aRange).min() ?: -1\n\n println(answer)\n}\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 245, "memory_kb": 38304}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s954901991", "group_id": "codeNet:p02755", "input_text": "import java.io.PrintWriter\nimport java.util.*\n\nval pw = PrintWriter(System.out)\nval sc = Scanner(System.`in`)\n\n\nfun main(args: Array) {\n val A = sc.nextInt()\n val B = sc.nextInt()\n\n var ans = -1\n for(i in 1..1000){\n if(Math.floor(i*0.08) == A.toDouble() && Math.floor(i*0.1) == B.toDouble()){\n ans = i\n break\n }\n }\n\n println(ans)\n}\n\nfun next() = readLine()!!\nfun nextInt() = next().toInt()\nfun nextLong() = next().toLong()\nfun nextDouble() = next().toDouble()\nfun nextListOfString() = next().split(\" \")\nfun nextListOfInt() = nextListOfString().map { it.toInt() }\nfun nextListOfLong() = nextListOfString().map { it.toLong() }\nfun nextListOfDouble() = nextListOfString().map { it.toDouble() }\n\n", "language": "Kotlin", "metadata": {"date": 1583637672, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02755.html", "problem_id": "p02755", "resource_group": "medium_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/Kotlin/s954901991.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s954901991", "user_id": "u240901574"}, "prompt_components": {"gold_output": "25\n", "input_to_evaluate": "import java.io.PrintWriter\nimport java.util.*\n\nval pw = PrintWriter(System.out)\nval sc = Scanner(System.`in`)\n\n\nfun main(args: Array) {\n val A = sc.nextInt()\n val B = sc.nextInt()\n\n var ans = -1\n for(i in 1..1000){\n if(Math.floor(i*0.08) == A.toDouble() && Math.floor(i*0.1) == B.toDouble()){\n ans = i\n break\n }\n }\n\n println(ans)\n}\n\nfun next() = readLine()!!\nfun nextInt() = next().toInt()\nfun nextLong() = next().toLong()\nfun nextDouble() = next().toDouble()\nfun nextListOfString() = next().split(\" \")\nfun nextListOfInt() = nextListOfString().map { it.toInt() }\nfun nextListOfLong() = nextListOfString().map { it.toLong() }\nfun nextListOfDouble() = nextListOfString().map { it.toDouble() }\n\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 754, "cpu_time_ms": 189, "memory_kb": 31400}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s732250570", "group_id": "codeNet:p02755", "input_text": "import java.lang.Math.floor\nimport java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n\n val a = sc.nextDouble() // 8\n val b = sc.nextDouble() // 10\n\n val ar = floor(a / 0.08)\n val bt = floor(ar * 0.1)\n\n if(b == bt){\n println(ar.toInt())\n }else {\n println(-1)\n }\n}", "language": "Kotlin", "metadata": {"date": 1583635874, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02755.html", "problem_id": "p02755", "resource_group": "medium_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/Kotlin/s732250570.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s732250570", "user_id": "u079781329"}, "prompt_components": {"gold_output": "25\n", "input_to_evaluate": "import java.lang.Math.floor\nimport java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n\n val a = sc.nextDouble() // 8\n val b = sc.nextDouble() // 10\n\n val ar = floor(a / 0.08)\n val bt = floor(ar * 0.1)\n\n if(b == bt){\n println(ar.toInt())\n }else {\n println(-1)\n }\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 224, "memory_kb": 31400}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s261146495", "group_id": "codeNet:p02755", "input_text": "fun main(args: Array) {\n val (A, B) = readInputLine().split(\" \").map { it.toInt() }\n\n for (i in 1..100000) {\n if (i * 8 / 100 == A && i * 10 / 100 == B) {\n println(i)\n return\n }\n }\n\n println(-1)\n}\n\nfun readInputLine(): String {\n return readLine()!!\n}\n", "language": "Kotlin", "metadata": {"date": 1583633481, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02755.html", "problem_id": "p02755", "resource_group": "medium_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/Kotlin/s261146495.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s261146495", "user_id": "u505558493"}, "prompt_components": {"gold_output": "25\n", "input_to_evaluate": "fun main(args: Array) {\n val (A, B) = readInputLine().split(\" \").map { it.toInt() }\n\n for (i in 1..100000) {\n if (i * 8 / 100 == A && i * 10 / 100 == B) {\n println(i)\n return\n }\n }\n\n println(-1)\n}\n\nfun readInputLine(): String {\n return readLine()!!\n}\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 310, "cpu_time_ms": 256, "memory_kb": 38040}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s903718525", "group_id": "codeNet:p02756", "input_text": "import java.util.*\n\nfun main(args: Array) {\n val s = readLine() ?: return\n val q = readLine()?.toInt() ?: return\n var isReversed = false\n val result = LinkedList()\n result.apply {\n add(s)\n repeat(q) {\n val query = readLine()?.split(\" \") ?: return\n when (query[0].toInt()) {\n 1 -> {\n isReversed = !isReversed\n }\n 2 -> {\n val operationType = query.getOrNull(1)?.toInt() ?: return\n val c = query.getOrNull(2) ?: return\n when (operationType) {\n 1 -> {\n if (isReversed) {\n addLast(c)\n } else {\n addFirst(c)\n }\n }\n 2 -> {\n if (isReversed) {\n addFirst(c)\n } else {\n addLast(c)\n }\n }\n }\n }\n }\n }\n }\n println(result.joinToString(\"\"))\n}\n\n", "language": "Kotlin", "metadata": {"date": 1586706079, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02756.html", "problem_id": "p02756", "resource_group": "medium_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/Kotlin/s903718525.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s903718525", "user_id": "u979429407"}, "prompt_components": {"gold_output": "cpa\n", "input_to_evaluate": "import java.util.*\n\nfun main(args: Array) {\n val s = readLine() ?: return\n val q = readLine()?.toInt() ?: return\n var isReversed = false\n val result = LinkedList()\n result.apply {\n add(s)\n repeat(q) {\n val query = readLine()?.split(\" \") ?: return\n when (query[0].toInt()) {\n 1 -> {\n isReversed = !isReversed\n }\n 2 -> {\n val operationType = query.getOrNull(1)?.toInt() ?: return\n val c = query.getOrNull(2) ?: return\n when (operationType) {\n 1 -> {\n if (isReversed) {\n addLast(c)\n } else {\n addFirst(c)\n }\n }\n 2 -> {\n if (isReversed) {\n addFirst(c)\n } else {\n addLast(c)\n }\n }\n }\n }\n }\n }\n }\n println(result.joinToString(\"\"))\n}\n\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 782, "memory_kb": 83080}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s724661233", "group_id": "codeNet:p02756", "input_text": "fun main(args: Array) {\n val S = next()\n val first = mutableListOf()\n val last = mutableListOf()\n val Q = nextInt()\n var reverse = false\n repeat(Q) {\n val query = listOfString()\n when (query[0]) {\n \"1\" -> {\n reverse = !reverse\n }\n \"2\" -> {\n when (query[1]) {\n \"1\" -> {\n if (reverse)\n last.add(query[2][0])\n else\n first.add(query[2][0])\n }\n \"2\" -> {\n if (reverse)\n first.add(query[2][0])\n else\n last.add(query[2][0])\n }\n }\n }\n }\n }\n val ans = first.reversed().joinToString(separator = \"\") + S + last.joinToString(separator = \"\")\n println(if (reverse) ans.reversed() else ans)\n}\nfun next() = readLine()!!\nfun listOfString() = next().split(\" \")\nfun listOfInt() = listOfString().map(String::toInt)\nfun nextInt(delta: Int = 0) = Integer.parseInt(next()) + delta\n", "language": "Kotlin", "metadata": {"date": 1583641786, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02756.html", "problem_id": "p02756", "resource_group": "medium_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/Kotlin/s724661233.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s724661233", "user_id": "u043150661"}, "prompt_components": {"gold_output": "cpa\n", "input_to_evaluate": "fun main(args: Array) {\n val S = next()\n val first = mutableListOf()\n val last = mutableListOf()\n val Q = nextInt()\n var reverse = false\n repeat(Q) {\n val query = listOfString()\n when (query[0]) {\n \"1\" -> {\n reverse = !reverse\n }\n \"2\" -> {\n when (query[1]) {\n \"1\" -> {\n if (reverse)\n last.add(query[2][0])\n else\n first.add(query[2][0])\n }\n \"2\" -> {\n if (reverse)\n first.add(query[2][0])\n else\n last.add(query[2][0])\n }\n }\n }\n }\n }\n val ans = first.reversed().joinToString(separator = \"\") + S + last.joinToString(separator = \"\")\n println(if (reverse) ans.reversed() else ans)\n}\nfun next() = readLine()!!\nfun listOfString() = next().split(\" \")\nfun listOfInt() = listOfString().map(String::toInt)\nfun nextInt(delta: Int = 0) = Integer.parseInt(next()) + delta\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1190, "cpu_time_ms": 813, "memory_kb": 74568}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s121898553", "group_id": "codeNet:p02756", "input_text": "import java.lang.StringBuilder\nimport java.util.*\n\ndata class Query(val q: Int, val f: Int = 0, val c: String = \"\")\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val s = sc.next()\n val q = sc.nextInt()\n val queries = (0 until q).map {\n val q = sc.next().toInt()\n if (q == 1) Query(q) else Query(q, sc.nextInt(), sc.next())\n }\n println(problem158d(s, q, queries))\n}\n\nfun problem158d(s: String, q: Int, queries: List): String {\n var sb = StringBuilder(s)\n val count = queries.count { it.q == 1 }\n val reverse = (count % 2 == 0)\n val last = queries.indexOfLast { it.q == 1 || it.f == 1 }\n for (i in 0 until q) {\n val qi = queries[i]\n if (qi.q != 1) {\n sb.append(qi.c)\n }\n if (i == last) {\n if (reverse) {\n sb = sb.reverse()\n }\n }\n }\n return sb.toString()\n}", "language": "Kotlin", "metadata": {"date": 1583638418, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02756.html", "problem_id": "p02756", "resource_group": "medium_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/Kotlin/s121898553.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s121898553", "user_id": "u073232808"}, "prompt_components": {"gold_output": "cpa\n", "input_to_evaluate": "import java.lang.StringBuilder\nimport java.util.*\n\ndata class Query(val q: Int, val f: Int = 0, val c: String = \"\")\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val s = sc.next()\n val q = sc.nextInt()\n val queries = (0 until q).map {\n val q = sc.next().toInt()\n if (q == 1) Query(q) else Query(q, sc.nextInt(), sc.next())\n }\n println(problem158d(s, q, queries))\n}\n\nfun problem158d(s: String, q: Int, queries: List): String {\n var sb = StringBuilder(s)\n val count = queries.count { it.q == 1 }\n val reverse = (count % 2 == 0)\n val last = queries.indexOfLast { it.q == 1 || it.f == 1 }\n for (i in 0 until q) {\n val qi = queries[i]\n if (qi.q != 1) {\n sb.append(qi.c)\n }\n if (i == last) {\n if (reverse) {\n sb = sb.reverse()\n }\n }\n }\n return sb.toString()\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 915, "cpu_time_ms": 984, "memory_kb": 123128}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s986915067", "group_id": "codeNet:p02757", "input_text": "import java.io.BufferedReader\nimport java.io.InputStream\nimport java.io.InputStreamReader\nimport java.lang.StringBuilder\nimport java.util.*\n\nfun main(args: Array) {\n val sc = FastScanner(System.`in`)\n val n = sc.nextInt()\n val p = sc.nextInt()\n val s = sc.nextLine()\n var rem = Array(p) { 0 }\n var ans = 0L\n for (i in 0 until n) {\n val d = s[i].toString().toInt()\n val tmp = Array(p) { 0 }\n for (j in 0 until p) {\n tmp[(10*j+d) % p] += rem[j]\n }\n tmp[d % p] += 1\n ans += tmp[0]\n rem = tmp\n }\n println(ans)\n}\n\nclass FastScanner(s: InputStream) {\n private var st = StringTokenizer(\"\")\n private val br = BufferedReader(InputStreamReader(s))\n\n fun next(): String {\n while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())\n\n return st.nextToken()\n }\n\n fun nextInt() = next().toInt()\n fun nextLong() = next().toLong()\n fun nextLine() = br.readLine()\n fun nextDouble() = next().toDouble()\n fun ready() = br.ready()\n}\n", "language": "Kotlin", "metadata": {"date": 1583637041, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02757.html", "problem_id": "p02757", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02757/input.txt", "sample_output_relpath": "derived/input_output/data/p02757/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02757/Kotlin/s986915067.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s986915067", "user_id": "u190507186"}, "prompt_components": {"gold_output": "6\n", "input_to_evaluate": "import java.io.BufferedReader\nimport java.io.InputStream\nimport java.io.InputStreamReader\nimport java.lang.StringBuilder\nimport java.util.*\n\nfun main(args: Array) {\n val sc = FastScanner(System.`in`)\n val n = sc.nextInt()\n val p = sc.nextInt()\n val s = sc.nextLine()\n var rem = Array(p) { 0 }\n var ans = 0L\n for (i in 0 until n) {\n val d = s[i].toString().toInt()\n val tmp = Array(p) { 0 }\n for (j in 0 until p) {\n tmp[(10*j+d) % p] += rem[j]\n }\n tmp[d % p] += 1\n ans += tmp[0]\n rem = tmp\n }\n println(ans)\n}\n\nclass FastScanner(s: InputStream) {\n private var st = StringTokenizer(\"\")\n private val br = BufferedReader(InputStreamReader(s))\n\n fun next(): String {\n while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())\n\n return st.nextToken()\n }\n\n fun nextInt() = next().toInt()\n fun nextLong() = next().toLong()\n fun nextLine() = br.readLine()\n fun nextDouble() = next().toDouble()\n fun ready() = br.ready()\n}\n", "problem_context": "Score : 500 points\n\nProblem Statement\n\nTakahashi has a string S of length N consisting of digits from 0 through 9.\n\nHe loves the prime number P. He wants to know how many non-empty (contiguous) substrings of S - there are N \\times (N + 1) / 2 of them - are divisible by P when regarded as integers written in base ten.\n\nHere substrings starting with a 0 also count, and substrings originated from different positions in S are distinguished, even if they are equal as strings or integers.\n\nCompute this count to help Takahashi.\n\nConstraints\n\n1 \\leq N \\leq 2 \\times 10^5\n\nS consists of digits.\n\n|S| = N\n\n2 \\leq P \\leq 10000\n\nP is a prime number.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN P\nS\n\nOutput\n\nPrint the number of non-empty (contiguous) substrings of S that are divisible by P when regarded as an integer written in base ten.\n\nSample Input 1\n\n4 3\n3543\n\nSample Output 1\n\n6\n\nHere S = 3543. There are ten non-empty (contiguous) substrings of S:\n\n3: divisible by 3.\n\n35: not divisible by 3.\n\n354: divisible by 3.\n\n3543: divisible by 3.\n\n5: not divisible by 3.\n\n54: divisible by 3.\n\n543: divisible by 3.\n\n4: not divisible by 3.\n\n43: not divisible by 3.\n\n3: divisible by 3.\n\nSix of these are divisible by 3, so print 6.\n\nSample Input 2\n\n4 2\n2020\n\nSample Output 2\n\n10\n\nHere S = 2020. There are ten non-empty (contiguous) substrings of S, all of which are divisible by 2, so print 10.\n\nNote that substrings beginning with a 0 also count.\n\nSample Input 3\n\n20 11\n33883322005544116655\n\nSample Output 3\n\n68", "sample_input": "4 3\n3543\n"}, "reference_outputs": ["6\n"], "source_document_id": "p02757", "source_text": "Score : 500 points\n\nProblem Statement\n\nTakahashi has a string S of length N consisting of digits from 0 through 9.\n\nHe loves the prime number P. He wants to know how many non-empty (contiguous) substrings of S - there are N \\times (N + 1) / 2 of them - are divisible by P when regarded as integers written in base ten.\n\nHere substrings starting with a 0 also count, and substrings originated from different positions in S are distinguished, even if they are equal as strings or integers.\n\nCompute this count to help Takahashi.\n\nConstraints\n\n1 \\leq N \\leq 2 \\times 10^5\n\nS consists of digits.\n\n|S| = N\n\n2 \\leq P \\leq 10000\n\nP is a prime number.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN P\nS\n\nOutput\n\nPrint the number of non-empty (contiguous) substrings of S that are divisible by P when regarded as an integer written in base ten.\n\nSample Input 1\n\n4 3\n3543\n\nSample Output 1\n\n6\n\nHere S = 3543. There are ten non-empty (contiguous) substrings of S:\n\n3: divisible by 3.\n\n35: not divisible by 3.\n\n354: divisible by 3.\n\n3543: divisible by 3.\n\n5: not divisible by 3.\n\n54: divisible by 3.\n\n543: divisible by 3.\n\n4: not divisible by 3.\n\n43: not divisible by 3.\n\n3: divisible by 3.\n\nSix of these are divisible by 3, so print 6.\n\nSample Input 2\n\n4 2\n2020\n\nSample Output 2\n\n10\n\nHere S = 2020. There are ten non-empty (contiguous) substrings of S, all of which are divisible by 2, so print 10.\n\nNote that substrings beginning with a 0 also count.\n\nSample Input 3\n\n20 11\n33883322005544116655\n\nSample Output 3\n\n68", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1054, "cpu_time_ms": 2111, "memory_kb": 116900}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s192233693", "group_id": "codeNet:p02759", "input_text": "fun main(args: Array) {\n val sc = java.util.Scanner(System.`in`)\n val N = sc.nextInt()\n\n println((N + 1) / 2)\n}\n", "language": "Kotlin", "metadata": {"date": 1583811364, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02759.html", "problem_id": "p02759", "resource_group": "medium_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/Kotlin/s192233693.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s192233693", "user_id": "u297767059"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "fun main(args: Array) {\n val sc = java.util.Scanner(System.`in`)\n val N = sc.nextInt()\n\n println((N + 1) / 2)\n}\n", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 186, "memory_kb": 31396}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s642306914", "group_id": "codeNet:p02759", "input_text": "import java.math.BigInteger\n\nfun main(args: Array) {\n val sc = java.util.Scanner(System.`in`)\n val n = sc.nextInt()\n\n print((n + 1) / 2)\n}\n", "language": "Kotlin", "metadata": {"date": 1583115075, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02759.html", "problem_id": "p02759", "resource_group": "medium_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/Kotlin/s642306914.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s642306914", "user_id": "u059223549"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "import java.math.BigInteger\n\nfun main(args: Array) {\n val sc = java.util.Scanner(System.`in`)\n val n = sc.nextInt()\n\n print((n + 1) / 2)\n}\n", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 246, "memory_kb": 31012}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s307805381", "group_id": "codeNet:p02760", "input_text": "fun main(args: Array) {\n val aArray = Array(3) { readIntegerList().map { Pair(it, false) }.toTypedArray() }\n val n = readInteger()\n repeat(n) {\n val b = readInteger()\n for (i in aArray.indices) {\n for (j in aArray[i].indices) {\n if (aArray[i][j].first == b) {\n aArray[i][j] = Pair(aArray[i][j].first, true)\n }\n }\n }\n }\n\n var hasBingo = false\n for (i in 0..2) {\n val trueCount = aArray[i].count { it.second }\n if (trueCount == 3) {\n println(\"Yes\")\n return\n }\n }\n\n for (i in 0..2) {\n var trueCount = 0\n for (j in 0..2) {\n if (aArray[j][i].second) {\n trueCount++\n }\n }\n\n if (trueCount == 3) {\n println(\"Yes\")\n return\n }\n }\n\n if (aArray[0][0].second && aArray[1][1].second && aArray[2][2].second) {\n println(\"Yes\")\n return\n }\n\n if (aArray[0][3].second && aArray[1][2].second && aArray[2][1].second) {\n println(\"Yes\")\n return\n }\n\n\n\n println(\"No\")\n}\n\nfun readInteger() = readLine()!!.toInt()\nfun readLong() = readLine()!!.toLong()\nfun readStringList() = readLine()!!.split(\" \")\nfun readIntegerList() = readStringList().map(String::toInt)\nfun readLongList() = readStringList().map(String::toLong)\n", "language": "Kotlin", "metadata": {"date": 1583681350, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02760.html", "problem_id": "p02760", "resource_group": "medium_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/Kotlin/s307805381.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s307805381", "user_id": "u784448849"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "fun main(args: Array) {\n val aArray = Array(3) { readIntegerList().map { Pair(it, false) }.toTypedArray() }\n val n = readInteger()\n repeat(n) {\n val b = readInteger()\n for (i in aArray.indices) {\n for (j in aArray[i].indices) {\n if (aArray[i][j].first == b) {\n aArray[i][j] = Pair(aArray[i][j].first, true)\n }\n }\n }\n }\n\n var hasBingo = false\n for (i in 0..2) {\n val trueCount = aArray[i].count { it.second }\n if (trueCount == 3) {\n println(\"Yes\")\n return\n }\n }\n\n for (i in 0..2) {\n var trueCount = 0\n for (j in 0..2) {\n if (aArray[j][i].second) {\n trueCount++\n }\n }\n\n if (trueCount == 3) {\n println(\"Yes\")\n return\n }\n }\n\n if (aArray[0][0].second && aArray[1][1].second && aArray[2][2].second) {\n println(\"Yes\")\n return\n }\n\n if (aArray[0][3].second && aArray[1][2].second && aArray[2][1].second) {\n println(\"Yes\")\n return\n }\n\n\n\n println(\"No\")\n}\n\nfun readInteger() = readLine()!!.toInt()\nfun readLong() = readLine()!!.toLong()\nfun readStringList() = readLine()!!.split(\" \")\nfun readIntegerList() = readStringList().map(String::toInt)\nfun readLongList() = readStringList().map(String::toLong)\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1397, "cpu_time_ms": 241, "memory_kb": 37904}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s820453495", "group_id": "codeNet:p02762", "input_text": "import java.util.*\n\nfun main(args : Array) {\n val (n, m, k) = readLine()!!.split(' ').map(String::toInt)\n val friends = HashMap>()\n val blocks = HashMap>()\n (1..m).forEach {\n val (a, b) = readLine()!!.split(' ').map(String::toInt)\n if (friends[a] == null) friends[a] = HashSet()\n if (friends[b] == null) friends[b] = HashSet()\n friends[a]!! += b\n friends[b]!! += a\n }\n (1..k).forEach {\n val (c, d) = readLine()!!.split(' ').map(String::toInt)\n if (blocks[c] == null) blocks[c] = HashSet()\n if (blocks[d] == null) blocks[d] = HashSet()\n blocks[c]!! += d\n blocks[d]!! += c\n }\n (1..n).forEach { i ->\n val que = ArrayDeque()\n val blk = blocks[i]\n val dis = HashMap()\n val dtr = BooleanArray(n + 1)\n var cnt = 0\n dis[i] = 0\n dtr[i] = true\n que += i\n while (que.isNotEmpty()) {\n val cur = que.remove()\n if (friends[cur] == null) continue\n for (fr in friends[cur]!!) {\n if (dtr[fr]) continue\n dis[fr] = dis[cur]!! + 1\n if (blk != null && blk.contains(fr)) continue\n dtr[fr] = true\n que += fr\n if (dis[fr]!! != 1) cnt++\n }\n }\n print(cnt)\n print(' ')\n }\n println()\n}\n", "language": "Kotlin", "metadata": {"date": 1583120316, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02762.html", "problem_id": "p02762", "resource_group": "medium_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/Kotlin/s820453495.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s820453495", "user_id": "u051841332"}, "prompt_components": {"gold_output": "0 1 0 1\n", "input_to_evaluate": "import java.util.*\n\nfun main(args : Array) {\n val (n, m, k) = readLine()!!.split(' ').map(String::toInt)\n val friends = HashMap>()\n val blocks = HashMap>()\n (1..m).forEach {\n val (a, b) = readLine()!!.split(' ').map(String::toInt)\n if (friends[a] == null) friends[a] = HashSet()\n if (friends[b] == null) friends[b] = HashSet()\n friends[a]!! += b\n friends[b]!! += a\n }\n (1..k).forEach {\n val (c, d) = readLine()!!.split(' ').map(String::toInt)\n if (blocks[c] == null) blocks[c] = HashSet()\n if (blocks[d] == null) blocks[d] = HashSet()\n blocks[c]!! += d\n blocks[d]!! += c\n }\n (1..n).forEach { i ->\n val que = ArrayDeque()\n val blk = blocks[i]\n val dis = HashMap()\n val dtr = BooleanArray(n + 1)\n var cnt = 0\n dis[i] = 0\n dtr[i] = true\n que += i\n while (que.isNotEmpty()) {\n val cur = que.remove()\n if (friends[cur] == null) continue\n for (fr in friends[cur]!!) {\n if (dtr[fr]) continue\n dis[fr] = dis[cur]!! + 1\n if (blk != null && blk.contains(fr)) continue\n dtr[fr] = true\n que += fr\n if (dis[fr]!! != 1) cnt++\n }\n }\n print(cnt)\n print(' ')\n }\n println()\n}\n", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 2112, "memory_kb": 178228}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s513969123", "group_id": "codeNet:p02763", "input_text": "class IntSegmentTree(n: Int) {\n private var size = 1\n\n init {\n while (size < n) {\n size *= 2\n }\n }\n\n private val segTree = IntArray(size * 2 - 1) { 0 }\n\n fun update(x: Int, value: Int) {\n var tmp = x + size - 1\n\n segTree[tmp] = value\n while (tmp > 0) {\n tmp = (tmp - 1) / 2\n segTree[tmp] = segTree[2 * tmp + 1] + segTree[2 * tmp + 2]\n }\n }\n\n fun getSum(a: Int, b: Int, k: Int = 0, l: Int = 0, r: Int = size): Int {\n if (r <= a || b <= l) {\n return 0\n }\n if (a <= l && r <= b) {\n return segTree[k]\n }\n\n val vl = getSum(a, b, 2 * k + 1, l, (l + r) / 2)\n val vr = getSum(a, b, 2 * k + 2, (l + r) / 2, r)\n\n return vl + vr\n }\n}\n\nfun main(args: Array) {\n val N = readInputLine().toInt()\n val S = readInputLine().toCharArray()\n val Q = readInputLine().toInt()\n\n val segTree = Array(26) { IntSegmentTree(N) }\n\n for (i in 0 until N) {\n segTree[S[i] - 'a'].update(i, 1)\n }\n\n for (i in 0 until Q) {\n val (q, p1, p2) = readInputLine().split(\" \")\n if (q == \"1\") {\n val index = p1.toInt() - 1\n val ch = p2.first()\n\n segTree[S[index] - 'a'].update(index, 0)\n segTree[ch - 'a'].update(index, 1)\n S[index] = ch\n } else {\n val l = p1.toInt() - 1\n val r = p2.toInt() - 1\n\n var cnt = 0\n for (k in 0 until 26) {\n if (segTree[k].getSum(l, r + 1) != 0) {\n cnt++\n }\n }\n\n println(cnt)\n }\n }\n}\n\nfun readInputLine(): String {\n return readLine()!!\n}\n", "language": "Kotlin", "metadata": {"date": 1583123204, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02763.html", "problem_id": "p02763", "resource_group": "medium_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/Kotlin/s513969123.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s513969123", "user_id": "u505558493"}, "prompt_components": {"gold_output": "3\n1\n5\n", "input_to_evaluate": "class IntSegmentTree(n: Int) {\n private var size = 1\n\n init {\n while (size < n) {\n size *= 2\n }\n }\n\n private val segTree = IntArray(size * 2 - 1) { 0 }\n\n fun update(x: Int, value: Int) {\n var tmp = x + size - 1\n\n segTree[tmp] = value\n while (tmp > 0) {\n tmp = (tmp - 1) / 2\n segTree[tmp] = segTree[2 * tmp + 1] + segTree[2 * tmp + 2]\n }\n }\n\n fun getSum(a: Int, b: Int, k: Int = 0, l: Int = 0, r: Int = size): Int {\n if (r <= a || b <= l) {\n return 0\n }\n if (a <= l && r <= b) {\n return segTree[k]\n }\n\n val vl = getSum(a, b, 2 * k + 1, l, (l + r) / 2)\n val vr = getSum(a, b, 2 * k + 2, (l + r) / 2, r)\n\n return vl + vr\n }\n}\n\nfun main(args: Array) {\n val N = readInputLine().toInt()\n val S = readInputLine().toCharArray()\n val Q = readInputLine().toInt()\n\n val segTree = Array(26) { IntSegmentTree(N) }\n\n for (i in 0 until N) {\n segTree[S[i] - 'a'].update(i, 1)\n }\n\n for (i in 0 until Q) {\n val (q, p1, p2) = readInputLine().split(\" \")\n if (q == \"1\") {\n val index = p1.toInt() - 1\n val ch = p2.first()\n\n segTree[S[index] - 'a'].update(index, 0)\n segTree[ch - 'a'].update(index, 1)\n S[index] = ch\n } else {\n val l = p1.toInt() - 1\n val r = p2.toInt() - 1\n\n var cnt = 0\n for (k in 0 until 26) {\n if (segTree[k].getSum(l, r + 1) != 0) {\n cnt++\n }\n }\n\n println(cnt)\n }\n }\n}\n\nfun readInputLine(): String {\n return readLine()!!\n}\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1732, "cpu_time_ms": 1105, "memory_kb": 180004}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s005500684", "group_id": "codeNet:p02766", "input_text": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n\n var n = sc.nextInt()\n val k = sc.nextInt()\n println(Integer.toString(n, k).length)\n}\n", "language": "Kotlin", "metadata": {"date": 1584500868, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02766.html", "problem_id": "p02766", "resource_group": "medium_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/Kotlin/s005500684.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s005500684", "user_id": "u794753968"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n\n var n = sc.nextInt()\n val k = sc.nextInt()\n println(Integer.toString(n, k).length)\n}\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 182, "cpu_time_ms": 184, "memory_kb": 31264}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s460160297", "group_id": "codeNet:p02766", "input_text": "import java.lang.Math.pow\n\nfun main(args: Array) {\n val (N, K) = readLine()!!.split(' ').map(String::toDouble)\n\n for(d in 1..30) {\n if( pow(K, d .toDouble()) < N &&\n N <= pow(K, (d+1).toDouble())) {\n println(d+1)\n break\n }\n }\n}\n", "language": "Kotlin", "metadata": {"date": 1583190702, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02766.html", "problem_id": "p02766", "resource_group": "medium_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/Kotlin/s460160297.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s460160297", "user_id": "u168136994"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "import java.lang.Math.pow\n\nfun main(args: Array) {\n val (N, K) = readLine()!!.split(' ').map(String::toDouble)\n\n for(d in 1..30) {\n if( pow(K, d .toDouble()) < N &&\n N <= pow(K, (d+1).toDouble())) {\n println(d+1)\n break\n }\n }\n}\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 298, "cpu_time_ms": 240, "memory_kb": 38236}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s369608777", "group_id": "codeNet:p02767", "input_text": "fun main(args: Array) {\n //val people_count = 7\n //val coordinates = arrayOf(14, 14, 2, 13, 56, 2, 37).sorted()\n val people_count = readLine()!!.toInt()\n val coordinates = readLine()!!.split(\" \").map { it.toInt() }\n\n val answer = (coordinates.first()..coordinates.last()).map { temp_p ->\n println(\"$temp_p\")\n coordinates.map { (it - temp_p) * (it - temp_p) }.sum()\n }.min()\n\n println(\"$answer\")\n}", "language": "Kotlin", "metadata": {"date": 1597118123, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02767.html", "problem_id": "p02767", "resource_group": "medium_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/Kotlin/s369608777.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s369608777", "user_id": "u393104209"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "fun main(args: Array) {\n //val people_count = 7\n //val coordinates = arrayOf(14, 14, 2, 13, 56, 2, 37).sorted()\n val people_count = readLine()!!.toInt()\n val coordinates = readLine()!!.split(\" \").map { it.toInt() }\n\n val answer = (coordinates.first()..coordinates.last()).map { temp_p ->\n println(\"$temp_p\")\n coordinates.map { (it - temp_p) * (it - temp_p) }.sum()\n }.min()\n\n println(\"$answer\")\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 439, "cpu_time_ms": 125, "memory_kb": 36824}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s301806672", "group_id": "codeNet:p02767", "input_text": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val n = sc.nextInt()\n val x = (1..n).map {\n sc.nextInt()\n }\n\n println(abc156c(n, x))\n}\n\nprivate fun abc156c(n: Int, x: List): Int {\n val p = x.sum() / n\n\n val a = x.map { calc(it, p) }.sum()\n val b = x.map { calc(it, p + 1) }.sum()\n \n return Math.min(a, b)\n}\n\nprivate fun calc(xi: Int, p: Int): Int {\n var temp = xi - p\n return Math.pow(temp.toDouble(), 2.0).toInt()\n}", "language": "Kotlin", "metadata": {"date": 1582425681, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02767.html", "problem_id": "p02767", "resource_group": "medium_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/Kotlin/s301806672.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s301806672", "user_id": "u323522006"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val n = sc.nextInt()\n val x = (1..n).map {\n sc.nextInt()\n }\n\n println(abc156c(n, x))\n}\n\nprivate fun abc156c(n: Int, x: List): Int {\n val p = x.sum() / n\n\n val a = x.map { calc(it, p) }.sum()\n val b = x.map { calc(it, p + 1) }.sum()\n \n return Math.min(a, b)\n}\n\nprivate fun calc(xi: Int, p: Int): Int {\n var temp = xi - p\n return Math.pow(temp.toDouble(), 2.0).toInt()\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 500, "cpu_time_ms": 210, "memory_kb": 31512}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s756495980", "group_id": "codeNet:p02767", "input_text": "fun main(args: Array) = abc156c()\n\nfun abc156c() {\n val n = readLine()!!.toInt()\n val xList = readLine()!!.split(' ').map { it.toLong() }\n\n var answer = Long.MAX_VALUE / 10\n\n for (i in 1..100) {\n val sum = xList.map { (i - it) * (i - it) }.sum()\n answer = Math.min(answer, sum)\n }\n\n println(answer)\n}\n", "language": "Kotlin", "metadata": {"date": 1582423720, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02767.html", "problem_id": "p02767", "resource_group": "medium_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/Kotlin/s756495980.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s756495980", "user_id": "u139478771"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "fun main(args: Array) = abc156c()\n\nfun abc156c() {\n val n = readLine()!!.toInt()\n val xList = readLine()!!.split(' ').map { it.toLong() }\n\n var answer = Long.MAX_VALUE / 10\n\n for (i in 1..100) {\n val sum = xList.map { (i - it) * (i - it) }.sum()\n answer = Math.min(answer, sum)\n }\n\n println(answer)\n}\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 260, "memory_kb": 36512}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s816884353", "group_id": "codeNet:p02768", "input_text": "fun main(args: Array) = abc156d()\n\nfun abc156d() {\n val (n, a, b) = readLine()!!.split(' ').map { it.toInt() }\n\n var answer = Mint(2).modPow(n.toLong())\n answer -= 1\n answer -= comb(n, a)\n answer -= comb(n, b)\n\n println(answer)\n}\n\nprivate const val MOD = (1e9 + 7).toLong()\n\nprivate fun modPow(n: Long, p: Long, m: Long = MOD): Long {\n var x = n\n var y = p\n var result = 1L\n\n x %= m\n while (y > 0) {\n if (y % 2 == 1L)\n result = (result * x) % m\n y = y shr 1\n x = (x * x) % m\n }\n\n return result\n}\n\n// useful for big N, and small K\nprivate fun comb(n: Int, k: Int, m: Long = MOD): Long {\n if (n < k) return 0\n\n val min = Math.min(k, n - k)\n var value = 1L\n\n for (i in 1L..min) {\n value *= n - i + 1\n value %= m\n value *= modPow(i, m - 2, m)\n value %= m\n }\n return value\n}\n\nprivate class Mint(value: Long = 0L) {\n constructor(other: Mint) : this(other.value)\n\n private val value = if (value < 0) (value % MOD) + MOD else value % MOD\n operator fun unaryPlus() = this\n operator fun unaryMinus() = Mint(MOD - this.value)\n operator fun inc() = this.plus(1)\n operator fun dec() = this.minus(1)\n operator fun plus(other: Long) = Mint(this.value + other)\n operator fun plus(other: Mint) = this.plus(other.value)\n operator fun minus(other: Long) = Mint(this.value - other)\n operator fun minus(other: Mint) = this.plus(-other)\n operator fun times(other: Long) = Mint(this.value * other)\n operator fun times(other: Mint) = this.times(other.value)\n operator fun div(other: Long) = this.times(Mod.modPow(other, MOD - 2, MOD))\n operator fun div(other: Mint) = this.div(other.value)\n fun modPow(other: Long) = Mint(Mod.modPow(this.value, other, MOD))\n override fun toString() = this.value.toString()\n override fun hashCode() = value.hashCode()\n override fun equals(other: Any?): Boolean {\n if (this === other) return true\n if (javaClass != other?.javaClass) return false\n other as Mint\n return value == other.value\n }\n\n companion object Mod {\n private fun modPow(n: Long, p: Long, m: Long = MOD): Long {\n var x = n\n var y = p\n var result = 1L\n x %= m\n while (y > 0) {\n if (y % 2 == 1L) result = (result * x) % m\n y = y shr 1\n x = (x * x) % m\n }\n return result\n }\n }\n}\n", "language": "Kotlin", "metadata": {"date": 1582468981, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02768.html", "problem_id": "p02768", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02768/input.txt", "sample_output_relpath": "derived/input_output/data/p02768/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02768/Kotlin/s816884353.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s816884353", "user_id": "u139478771"}, "prompt_components": {"gold_output": "7\n", "input_to_evaluate": "fun main(args: Array) = abc156d()\n\nfun abc156d() {\n val (n, a, b) = readLine()!!.split(' ').map { it.toInt() }\n\n var answer = Mint(2).modPow(n.toLong())\n answer -= 1\n answer -= comb(n, a)\n answer -= comb(n, b)\n\n println(answer)\n}\n\nprivate const val MOD = (1e9 + 7).toLong()\n\nprivate fun modPow(n: Long, p: Long, m: Long = MOD): Long {\n var x = n\n var y = p\n var result = 1L\n\n x %= m\n while (y > 0) {\n if (y % 2 == 1L)\n result = (result * x) % m\n y = y shr 1\n x = (x * x) % m\n }\n\n return result\n}\n\n// useful for big N, and small K\nprivate fun comb(n: Int, k: Int, m: Long = MOD): Long {\n if (n < k) return 0\n\n val min = Math.min(k, n - k)\n var value = 1L\n\n for (i in 1L..min) {\n value *= n - i + 1\n value %= m\n value *= modPow(i, m - 2, m)\n value %= m\n }\n return value\n}\n\nprivate class Mint(value: Long = 0L) {\n constructor(other: Mint) : this(other.value)\n\n private val value = if (value < 0) (value % MOD) + MOD else value % MOD\n operator fun unaryPlus() = this\n operator fun unaryMinus() = Mint(MOD - this.value)\n operator fun inc() = this.plus(1)\n operator fun dec() = this.minus(1)\n operator fun plus(other: Long) = Mint(this.value + other)\n operator fun plus(other: Mint) = this.plus(other.value)\n operator fun minus(other: Long) = Mint(this.value - other)\n operator fun minus(other: Mint) = this.plus(-other)\n operator fun times(other: Long) = Mint(this.value * other)\n operator fun times(other: Mint) = this.times(other.value)\n operator fun div(other: Long) = this.times(Mod.modPow(other, MOD - 2, MOD))\n operator fun div(other: Mint) = this.div(other.value)\n fun modPow(other: Long) = Mint(Mod.modPow(this.value, other, MOD))\n override fun toString() = this.value.toString()\n override fun hashCode() = value.hashCode()\n override fun equals(other: Any?): Boolean {\n if (this === other) return true\n if (javaClass != other?.javaClass) return false\n other as Mint\n return value == other.value\n }\n\n companion object Mod {\n private fun modPow(n: Long, p: Long, m: Long = MOD): Long {\n var x = n\n var y = p\n var result = 1L\n x %= m\n while (y > 0) {\n if (y % 2 == 1L) result = (result * x) % m\n y = y shr 1\n x = (x * x) % m\n }\n return result\n }\n }\n}\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nAkari has n kinds of flowers, one of each kind.\n\nShe is going to choose one or more of these flowers to make a bouquet.\n\nHowever, she hates two numbers a and b, so the number of flowers in the bouquet cannot be a or b.\n\nHow many different bouquets are there that Akari can make?\n\nFind the count modulo (10^9 + 7).\n\nHere, two bouquets are considered different when there is a flower that is used in one of the bouquets but not in the other bouquet.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq n \\leq 10^9\n\n1 \\leq a < b \\leq \\textrm{min}(n, 2 \\times 10^5)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nn a b\n\nOutput\n\nPrint the number of bouquets that Akari can make, modulo (10^9 + 7). (If there are no such bouquets, print 0.)\n\nSample Input 1\n\n4 1 3\n\nSample Output 1\n\n7\n\nIn this case, Akari can choose 2 or 4 flowers to make the bouquet.\n\nThere are 6 ways to choose 2 out of the 4 flowers, and 1 way to choose 4, so there are a total of 7 different bouquets that Akari can make.\n\nSample Input 2\n\n1000000000 141421 173205\n\nSample Output 2\n\n34076506\n\nPrint the count modulo (10^9 + 7).", "sample_input": "4 1 3\n"}, "reference_outputs": ["7\n"], "source_document_id": "p02768", "source_text": "Score : 400 points\n\nProblem Statement\n\nAkari has n kinds of flowers, one of each kind.\n\nShe is going to choose one or more of these flowers to make a bouquet.\n\nHowever, she hates two numbers a and b, so the number of flowers in the bouquet cannot be a or b.\n\nHow many different bouquets are there that Akari can make?\n\nFind the count modulo (10^9 + 7).\n\nHere, two bouquets are considered different when there is a flower that is used in one of the bouquets but not in the other bouquet.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq n \\leq 10^9\n\n1 \\leq a < b \\leq \\textrm{min}(n, 2 \\times 10^5)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nn a b\n\nOutput\n\nPrint the number of bouquets that Akari can make, modulo (10^9 + 7). (If there are no such bouquets, print 0.)\n\nSample Input 1\n\n4 1 3\n\nSample Output 1\n\n7\n\nIn this case, Akari can choose 2 or 4 flowers to make the bouquet.\n\nThere are 6 ways to choose 2 out of the 4 flowers, and 1 way to choose 4, so there are a total of 7 different bouquets that Akari can make.\n\nSample Input 2\n\n1000000000 141421 173205\n\nSample Output 2\n\n34076506\n\nPrint the count modulo (10^9 + 7).", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2503, "cpu_time_ms": 511, "memory_kb": 38052}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s471225735", "group_id": "codeNet:p02768", "input_text": "fun main(args: Array) {\n val (N, A, B) = readLine()!!.split(\" \").map(String::toInt)\n val combi = Combination(N, A, B)\n val ans = MInt(2).pow(N) - MInt(1) - combi.A() - combi.B()\n println(ans)\n}\n\nclass MInt {\n private val MOD = 1000000007L\n var v: Long\n\n constructor(v: Long) {\n this.v = v % MOD\n }\n\n constructor(v: Int) {\n this.v = v.toLong() % MOD\n }\n\n operator fun plus(b: MInt): MInt {\n val a = MInt(v)\n a += b\n return a\n }\n\n operator fun minus(b: MInt): MInt {\n val a = MInt(v)\n a -= b\n return a\n }\n\n operator fun times(b: MInt): MInt {\n val a = MInt(v)\n a *= b\n return a\n }\n\n operator fun div(b: MInt): MInt {\n val a = MInt(v)\n a /= b\n return a\n }\n\n operator fun plusAssign(b: MInt) {\n v += b.v\n if (v >= MOD) v -= MOD\n }\n\n operator fun minusAssign(b: MInt) {\n v -= b.v\n if (v < 0) v += MOD\n }\n\n operator fun timesAssign(b: MInt) {\n v *= b.v\n v %= MOD\n }\n\n operator fun divAssign(b: MInt) {\n this *= b.inv()\n }\n\n fun inv(): MInt {\n var a = v\n var b = MOD\n var u = 1L\n var w = 0L\n while (b != 0L) {\n val t = a / b\n a -= t * b\n u -= t * w\n var tmp = a\n a = b\n b = tmp\n tmp = u\n u = w\n w = tmp\n }\n u %= MOD\n if (u < 0) u += MOD\n return MInt(u)\n }\n\n fun pow(n: Int): MInt {\n var a = MInt(1)\n for (i in 1..n) a = a * this\n return a\n }\n\n override fun toString(): String {\n return v.toString()\n }\n}\n\nclass Combination(N: Int, A: Int, B: Int) {\n private var factN = MInt(1)\n private var factA = MInt(1)\n private var factAI = MInt(1)\n private var factB = MInt(1)\n private var factBI = MInt(1)\n\n init {\n var fact = MInt(1)\n (1..N).forEach { i ->\n fact = fact * MInt(i)\n if (i == N) factN = fact\n if (i == A) factA = fact\n if (i == B) factB = fact\n if (i == N - A) factAI = fact\n if (i == N - B) factBI = fact\n }\n }\n\n fun A() = factN / (factA * factAI)\n fun B() = factN / (factB * factBI)\n}", "language": "Kotlin", "metadata": {"date": 1582405682, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02768.html", "problem_id": "p02768", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02768/input.txt", "sample_output_relpath": "derived/input_output/data/p02768/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02768/Kotlin/s471225735.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s471225735", "user_id": "u860789370"}, "prompt_components": {"gold_output": "7\n", "input_to_evaluate": "fun main(args: Array) {\n val (N, A, B) = readLine()!!.split(\" \").map(String::toInt)\n val combi = Combination(N, A, B)\n val ans = MInt(2).pow(N) - MInt(1) - combi.A() - combi.B()\n println(ans)\n}\n\nclass MInt {\n private val MOD = 1000000007L\n var v: Long\n\n constructor(v: Long) {\n this.v = v % MOD\n }\n\n constructor(v: Int) {\n this.v = v.toLong() % MOD\n }\n\n operator fun plus(b: MInt): MInt {\n val a = MInt(v)\n a += b\n return a\n }\n\n operator fun minus(b: MInt): MInt {\n val a = MInt(v)\n a -= b\n return a\n }\n\n operator fun times(b: MInt): MInt {\n val a = MInt(v)\n a *= b\n return a\n }\n\n operator fun div(b: MInt): MInt {\n val a = MInt(v)\n a /= b\n return a\n }\n\n operator fun plusAssign(b: MInt) {\n v += b.v\n if (v >= MOD) v -= MOD\n }\n\n operator fun minusAssign(b: MInt) {\n v -= b.v\n if (v < 0) v += MOD\n }\n\n operator fun timesAssign(b: MInt) {\n v *= b.v\n v %= MOD\n }\n\n operator fun divAssign(b: MInt) {\n this *= b.inv()\n }\n\n fun inv(): MInt {\n var a = v\n var b = MOD\n var u = 1L\n var w = 0L\n while (b != 0L) {\n val t = a / b\n a -= t * b\n u -= t * w\n var tmp = a\n a = b\n b = tmp\n tmp = u\n u = w\n w = tmp\n }\n u %= MOD\n if (u < 0) u += MOD\n return MInt(u)\n }\n\n fun pow(n: Int): MInt {\n var a = MInt(1)\n for (i in 1..n) a = a * this\n return a\n }\n\n override fun toString(): String {\n return v.toString()\n }\n}\n\nclass Combination(N: Int, A: Int, B: Int) {\n private var factN = MInt(1)\n private var factA = MInt(1)\n private var factAI = MInt(1)\n private var factB = MInt(1)\n private var factBI = MInt(1)\n\n init {\n var fact = MInt(1)\n (1..N).forEach { i ->\n fact = fact * MInt(i)\n if (i == N) factN = fact\n if (i == A) factA = fact\n if (i == B) factB = fact\n if (i == N - A) factAI = fact\n if (i == N - B) factBI = fact\n }\n }\n\n fun A() = factN / (factA * factAI)\n fun B() = factN / (factB * factBI)\n}", "problem_context": "Score : 400 points\n\nProblem Statement\n\nAkari has n kinds of flowers, one of each kind.\n\nShe is going to choose one or more of these flowers to make a bouquet.\n\nHowever, she hates two numbers a and b, so the number of flowers in the bouquet cannot be a or b.\n\nHow many different bouquets are there that Akari can make?\n\nFind the count modulo (10^9 + 7).\n\nHere, two bouquets are considered different when there is a flower that is used in one of the bouquets but not in the other bouquet.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq n \\leq 10^9\n\n1 \\leq a < b \\leq \\textrm{min}(n, 2 \\times 10^5)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nn a b\n\nOutput\n\nPrint the number of bouquets that Akari can make, modulo (10^9 + 7). (If there are no such bouquets, print 0.)\n\nSample Input 1\n\n4 1 3\n\nSample Output 1\n\n7\n\nIn this case, Akari can choose 2 or 4 flowers to make the bouquet.\n\nThere are 6 ways to choose 2 out of the 4 flowers, and 1 way to choose 4, so there are a total of 7 different bouquets that Akari can make.\n\nSample Input 2\n\n1000000000 141421 173205\n\nSample Output 2\n\n34076506\n\nPrint the count modulo (10^9 + 7).", "sample_input": "4 1 3\n"}, "reference_outputs": ["7\n"], "source_document_id": "p02768", "source_text": "Score : 400 points\n\nProblem Statement\n\nAkari has n kinds of flowers, one of each kind.\n\nShe is going to choose one or more of these flowers to make a bouquet.\n\nHowever, she hates two numbers a and b, so the number of flowers in the bouquet cannot be a or b.\n\nHow many different bouquets are there that Akari can make?\n\nFind the count modulo (10^9 + 7).\n\nHere, two bouquets are considered different when there is a flower that is used in one of the bouquets but not in the other bouquet.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq n \\leq 10^9\n\n1 \\leq a < b \\leq \\textrm{min}(n, 2 \\times 10^5)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nn a b\n\nOutput\n\nPrint the number of bouquets that Akari can make, modulo (10^9 + 7). (If there are no such bouquets, print 0.)\n\nSample Input 1\n\n4 1 3\n\nSample Output 1\n\n7\n\nIn this case, Akari can choose 2 or 4 flowers to make the bouquet.\n\nThere are 6 ways to choose 2 out of the 4 flowers, and 1 way to choose 4, so there are a total of 7 different bouquets that Akari can make.\n\nSample Input 2\n\n1000000000 141421 173205\n\nSample Output 2\n\n34076506\n\nPrint the count modulo (10^9 + 7).", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2339, "cpu_time_ms": 2111, "memory_kb": 116396}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s819917423", "group_id": "codeNet:p02772", "input_text": "fun main(args: Array) {\n val n = readInteger()\n val alist = readIntegerList().filter { it % 2 == 0 }\n for (a in alist) {\n if (a % 3 != 0 && a % 5 != 0) {\n println(\"DENIED\")\n return\n }\n }\n\n println(\"APPROVED\")\n}\n\nfun readInteger() = readLine()!!.toInt()\nfun readLong() = readLine()!!.toLong()\nfun readStringList() = readLine()!!.split(\" \")\nfun readIntegerList() = readStringList().map(String::toInt)\nfun readLongList() = readStringList().map(String::toLong)\n", "language": "Kotlin", "metadata": {"date": 1583098379, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02772.html", "problem_id": "p02772", "resource_group": "medium_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/Kotlin/s819917423.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s819917423", "user_id": "u784448849"}, "prompt_components": {"gold_output": "APPROVED\n", "input_to_evaluate": "fun main(args: Array) {\n val n = readInteger()\n val alist = readIntegerList().filter { it % 2 == 0 }\n for (a in alist) {\n if (a % 3 != 0 && a % 5 != 0) {\n println(\"DENIED\")\n return\n }\n }\n\n println(\"APPROVED\")\n}\n\nfun readInteger() = readLine()!!.toInt()\nfun readLong() = readLine()!!.toLong()\nfun readStringList() = readLine()!!.split(\" \")\nfun readIntegerList() = readStringList().map(String::toInt)\nfun readLongList() = readStringList().map(String::toLong)\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 258, "memory_kb": 37904}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s347887392", "group_id": "codeNet:p02775", "input_text": "fun main(args: Array) {\n val N = readLine()!!.map { it - '0' }\n val l = N.size\n val dp = Array(l + 1) { IntArray(2) {0} }\n\n dp[0][1] = 1\n\n for (i in 0 until l) {\n dp[i + 1][0] = Math.min(dp[i][0] + N[i], dp[i][1] + 10 - N[i])\n dp[i + 1][1] = dp[i][1] + 9 - N[i]\n if (N[i] < 9) {\n dp[i + 1][1] = Math.min(dp[i + 1][1], dp[i][0] + N[i] + 1)\n }\n }\n println(dp[l][0])\n}\n", "language": "Kotlin", "metadata": {"date": 1587501579, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02775.html", "problem_id": "p02775", "resource_group": "medium_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/Kotlin/s347887392.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s347887392", "user_id": "u183530284"}, "prompt_components": {"gold_output": "8\n", "input_to_evaluate": "fun main(args: Array) {\n val N = readLine()!!.map { it - '0' }\n val l = N.size\n val dp = Array(l + 1) { IntArray(2) {0} }\n\n dp[0][1] = 1\n\n for (i in 0 until l) {\n dp[i + 1][0] = Math.min(dp[i][0] + N[i], dp[i][1] + 10 - N[i])\n dp[i + 1][1] = dp[i][1] + 9 - N[i]\n if (N[i] < 9) {\n dp[i + 1][1] = Math.min(dp[i + 1][1], dp[i][0] + N[i] + 1)\n }\n }\n println(dp[l][0])\n}\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 705, "memory_kb": 83348}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s620132013", "group_id": "codeNet:p02775", "input_text": "fun main(args: Array) {\n var nums= readLine()!!.toString()\n var countList= mutableListOf()\n var ans:Long=0L\n for(num in nums){\n if (Character.getNumericValue(num) < 6) {\n ans+=Character.getNumericValue(num).toLong()\n } else {\n ans++\n ans+=10-Character.getNumericValue(num).toLong()\n }\n\n }\n println(ans)\n}", "language": "Kotlin", "metadata": {"date": 1581887376, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02775.html", "problem_id": "p02775", "resource_group": "medium_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/Kotlin/s620132013.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s620132013", "user_id": "u456173040"}, "prompt_components": {"gold_output": "8\n", "input_to_evaluate": "fun main(args: Array) {\n var nums= readLine()!!.toString()\n var countList= mutableListOf()\n var ans:Long=0L\n for(num in nums){\n if (Character.getNumericValue(num) < 6) {\n ans+=Character.getNumericValue(num).toLong()\n } else {\n ans++\n ans+=10-Character.getNumericValue(num).toLong()\n }\n\n }\n println(ans)\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 390, "cpu_time_ms": 274, "memory_kb": 39048}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s675312419", "group_id": "codeNet:p02777", "input_text": "fun main(args:Array){\n val a=readLine()!!.split( \" \")\n val b=readLine()!!.split( \" \").map{it.toInt()}\n val c=readLine()!!\n if (a[0]==c){\n when {\n b[0]-1>=1 && b[1]>=1 ->{ println(\"${a[0]} ${a[1]}\")}\n b[0]-1>=1 && b[1]==0 ->{ println(\"${a[0]}\")}\n b[0]-1==0 && b[1]>=1 ->{ println(\"${a[1]}\")}\n }\n }else if (a[1]==c){\n when {\n b[0] >= 1 && b[1] - 1 >= 1 -> {\n println(\"${a[0]} ${a[1]}\")\n }\n b[0] >= 1 && b[1] - 1 == 0 -> {\n println(\"${a[0]}\")\n }\n b[0] == 0 && b[1] - 1 >= 1 -> {\n println(\"${a[1]}\")\n }\n }\n }\n}", "language": "Kotlin", "metadata": {"date": 1586602613, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02777.html", "problem_id": "p02777", "resource_group": "medium_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/Kotlin/s675312419.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s675312419", "user_id": "u387080888"}, "prompt_components": {"gold_output": "2 4\n", "input_to_evaluate": "fun main(args:Array){\n val a=readLine()!!.split( \" \")\n val b=readLine()!!.split( \" \").map{it.toInt()}\n val c=readLine()!!\n if (a[0]==c){\n when {\n b[0]-1>=1 && b[1]>=1 ->{ println(\"${a[0]} ${a[1]}\")}\n b[0]-1>=1 && b[1]==0 ->{ println(\"${a[0]}\")}\n b[0]-1==0 && b[1]>=1 ->{ println(\"${a[1]}\")}\n }\n }else if (a[1]==c){\n when {\n b[0] >= 1 && b[1] - 1 >= 1 -> {\n println(\"${a[0]} ${a[1]}\")\n }\n b[0] >= 1 && b[1] - 1 == 0 -> {\n println(\"${a[0]}\")\n }\n b[0] == 0 && b[1] - 1 >= 1 -> {\n println(\"${a[1]}\")\n }\n }\n }\n}", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 238, "memory_kb": 37776}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s922300006", "group_id": "codeNet:p02779", "input_text": "fun main(args: Array) {\n val n = readLine()!!.toInt()\n val a = readLine()!!.split(' ').map { it.toInt() }.toSet()\n println(if (a.size == n) \"Yes\" else \"No\")\n}\n", "language": "Kotlin", "metadata": {"date": 1581278699, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02779.html", "problem_id": "p02779", "resource_group": "medium_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/Kotlin/s922300006.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s922300006", "user_id": "u863309603"}, "prompt_components": {"gold_output": "YES\n", "input_to_evaluate": "fun main(args: Array) {\n val n = readLine()!!.toInt()\n val a = readLine()!!.split(' ').map { it.toInt() }.toSet()\n println(if (a.size == n) \"Yes\" else \"No\")\n}\n", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 176, "cpu_time_ms": 590, "memory_kb": 80732}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s626435639", "group_id": "codeNet:p02780", "input_text": "var kitaiti: Array = arrayOfNulls(1001)\nfun getval(){\n for(x in 1..1000){\n kitaiti[x]=0.0;\n for(y in 1..x){\n kitaiti[x] = kitaiti[x]?.plus(y.toDouble()/x.toDouble());\n }\n }\n\n}\n\n\nfun main(args: Array) {\n val (a,b) = readLine()!!.split(\" \").map(String::toInt)\n val list= readLine()!!.split(\" \").map(String::toInt)\n var max :Double=0.0;\n getval()\n for(x in 0..a-b){\n var buf:Double=0.0;\n for (y in 0 until b){\n buf+= kitaiti[list[x+y]]!!\n }\n if(max = arrayOfNulls(1001)\nfun getval(){\n for(x in 1..1000){\n kitaiti[x]=0.0;\n for(y in 1..x){\n kitaiti[x] = kitaiti[x]?.plus(y.toDouble()/x.toDouble());\n }\n }\n\n}\n\n\nfun main(args: Array) {\n val (a,b) = readLine()!!.split(\" \").map(String::toInt)\n val list= readLine()!!.split(\" \").map(String::toInt)\n var max :Double=0.0;\n getval()\n for(x in 0..a-b){\n var buf:Double=0.0;\n for (y in 0 until b){\n buf+= kitaiti[list[x+y]]!!\n }\n if(max) {\n val (N, K) = readLine()!!.split(\" \").map(String::toInt)\n val PN = readLine()!!.split(\" \").map(String::toInt)\n\n val e = PN.map { (it + 1) / 2.0 }\n\n var ans = 0.0\n var tmp = 0.0\n\n for (i in 0 until K) {\n tmp += e[i]\n }\n for (i in K until N) {\n tmp = tmp - e[i - K] + e[i]\n ans = Math.max(ans, tmp)\n }\n\n println(ans)\n}\n\n", "language": "Kotlin", "metadata": {"date": 1581354230, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02780.html", "problem_id": "p02780", "resource_group": "medium_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/Kotlin/s466332617.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s466332617", "user_id": "u085288971"}, "prompt_components": {"gold_output": "7.000000000000\n", "input_to_evaluate": "fun main(args: Array) {\n val (N, K) = readLine()!!.split(\" \").map(String::toInt)\n val PN = readLine()!!.split(\" \").map(String::toInt)\n\n val e = PN.map { (it + 1) / 2.0 }\n\n var ans = 0.0\n var tmp = 0.0\n\n for (i in 0 until K) {\n tmp += e[i]\n }\n for (i in K until N) {\n tmp = tmp - e[i - K] + e[i]\n ans = Math.max(ans, tmp)\n }\n\n println(ans)\n}\n\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 401, "cpu_time_ms": 534, "memory_kb": 63776}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s024787310", "group_id": "codeNet:p02780", "input_text": "import java.math.BigDecimal\nimport java.math.RoundingMode\nimport java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val n = sc.nextInt()\n val k = sc.nextInt()\n val p = (0 until n).map { sc.next().toLong() }\n println(problem153d(n, k, p))\n}\n\nfun problem153d(n: Int, k: Int, p: List): String {\n fun computeFactorial(n: Long): Long {\n var sum = 0L\n for (i in 1..n) {\n sum += i\n }\n return sum\n }\n val list = Array(n + 1) { BigDecimal(0) }\n for (i in 1 until n) {\n val pi = p[i]\n list[i + 1] = list[i].add(BigDecimal(computeFactorial(pi)).divide(BigDecimal(pi), 8, RoundingMode.DOWN))\n }\n var res = BigDecimal(1)\n for (i in 0..n - k) {\n val v = list[k + i] - list[i]\n if (res < v) res = v\n }\n return res.toString()\n}", "language": "Kotlin", "metadata": {"date": 1581282810, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02780.html", "problem_id": "p02780", "resource_group": "medium_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/Kotlin/s024787310.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s024787310", "user_id": "u073232808"}, "prompt_components": {"gold_output": "7.000000000000\n", "input_to_evaluate": "import java.math.BigDecimal\nimport java.math.RoundingMode\nimport java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val n = sc.nextInt()\n val k = sc.nextInt()\n val p = (0 until n).map { sc.next().toLong() }\n println(problem153d(n, k, p))\n}\n\nfun problem153d(n: Int, k: Int, p: List): String {\n fun computeFactorial(n: Long): Long {\n var sum = 0L\n for (i in 1..n) {\n sum += i\n }\n return sum\n }\n val list = Array(n + 1) { BigDecimal(0) }\n for (i in 1 until n) {\n val pi = p[i]\n list[i + 1] = list[i].add(BigDecimal(computeFactorial(pi)).divide(BigDecimal(pi), 8, RoundingMode.DOWN))\n }\n var res = BigDecimal(1)\n for (i in 0..n - k) {\n val v = list[k + i] - list[i]\n if (res < v) res = v\n }\n return res.toString()\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 852, "cpu_time_ms": 1018, "memory_kb": 88084}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s846235656", "group_id": "codeNet:p02780", "input_text": "import java.math.BigDecimal\nimport java.math.RoundingMode\nimport java.util.*\n\nfun main(args: Array) {\n val (N,K) = readLine()!!.split(\" \").map(String::toInt)\n val P = readLine()!!.split(\" \").map(String::toDouble)\n\n var plus = 0.0\n var queue = ArrayDeque()\n\n for(i in 0 until K-1){\n var current = 0.5 * (P[i]+1)\n plus += current\n queue.offer(current)\n }\n\n var max = plus\n\n for(i in K-1 until N){\n var current = 0.5 * (P[i]+1)\n\n plus += current\n max = Math.max(plus,max)\n queue.offer(current)\n plus -= queue.poll()\n }\n\n var big = BigDecimal(max).divide(BigDecimal.ONE,13,RoundingMode.HALF_UP)\n println(big)\n}", "language": "Kotlin", "metadata": {"date": 1581280913, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02780.html", "problem_id": "p02780", "resource_group": "medium_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/Kotlin/s846235656.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s846235656", "user_id": "u388106450"}, "prompt_components": {"gold_output": "7.000000000000\n", "input_to_evaluate": "import java.math.BigDecimal\nimport java.math.RoundingMode\nimport java.util.*\n\nfun main(args: Array) {\n val (N,K) = readLine()!!.split(\" \").map(String::toInt)\n val P = readLine()!!.split(\" \").map(String::toDouble)\n\n var plus = 0.0\n var queue = ArrayDeque()\n\n for(i in 0 until K-1){\n var current = 0.5 * (P[i]+1)\n plus += current\n queue.offer(current)\n }\n\n var max = plus\n\n for(i in K-1 until N){\n var current = 0.5 * (P[i]+1)\n\n plus += current\n max = Math.max(plus,max)\n queue.offer(current)\n plus -= queue.poll()\n }\n\n var big = BigDecimal(max).divide(BigDecimal.ONE,13,RoundingMode.HALF_UP)\n println(big)\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 711, "cpu_time_ms": 682, "memory_kb": 81088}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s289494575", "group_id": "codeNet:p02783", "input_text": "import java.util.*\n\nfun main(args:Array){\n val (h,a) = readLine()!!.split(\" \").map{it.toInt()}\n println((h + a - 1) / a)\n}\n", "language": "Kotlin", "metadata": {"date": 1581252356, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02783.html", "problem_id": "p02783", "resource_group": "medium_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/Kotlin/s289494575.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s289494575", "user_id": "u480831358"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "import java.util.*\n\nfun main(args:Array){\n val (h,a) = readLine()!!.split(\" \").map{it.toInt()}\n println((h + a - 1) / a)\n}\n", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 238, "memory_kb": 37904}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s306274638", "group_id": "codeNet:p02783", "input_text": "fun main(args: Array) {\n val (H, A) = readLine()!!.split(\" \").map(String::toDouble)\n println(Math.ceil(H/A).toInt())\n}", "language": "Kotlin", "metadata": {"date": 1580305827, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02783.html", "problem_id": "p02783", "resource_group": "medium_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/Kotlin/s306274638.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s306274638", "user_id": "u388106450"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "fun main(args: Array) {\n val (H, A) = readLine()!!.split(\" \").map(String::toDouble)\n println(Math.ceil(H/A).toInt())\n}", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 235, "memory_kb": 37924}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s988605710", "group_id": "codeNet:p02783", "input_text": "fun main(args: Array) {\n val (h, a) = readLine()!!.split(\" \").map { it.toInt() }\n var H = h\n var count = 0\n while (H > 0) {\n H -= a\n count++\n }\n println(count)\n}", "language": "Kotlin", "metadata": {"date": 1580069372, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02783.html", "problem_id": "p02783", "resource_group": "medium_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/Kotlin/s988605710.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s988605710", "user_id": "u088342491"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "fun main(args: Array) {\n val (h, a) = readLine()!!.split(\" \").map { it.toInt() }\n var H = h\n var count = 0\n while (H > 0) {\n H -= a\n count++\n }\n println(count)\n}", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 235, "memory_kb": 36012}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s056047937", "group_id": "codeNet:p02785", "input_text": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val n = sc.nextInt()\n val k = sc.nextInt()\n val h = (0 until n).map {\n sc.next().toLong()\n }\n\n println(abc153c(k, h))\n}\n\nfun abc153c(k: Int, h: List): Long {\n var hs = h.sorted().reversed()\n var ans = 0L\n for (i in 0..hs.size - 1) {\n if (i < k) {\n continue \n }\n ans += hs.get(i)\n }\n\n return ans\n}", "language": "Kotlin", "metadata": {"date": 1581113775, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02785.html", "problem_id": "p02785", "resource_group": "medium_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/Kotlin/s056047937.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s056047937", "user_id": "u323522006"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val n = sc.nextInt()\n val k = sc.nextInt()\n val h = (0 until n).map {\n sc.next().toLong()\n }\n\n println(abc153c(k, h))\n}\n\nfun abc153c(k: Int, h: List): Long {\n var hs = h.sorted().reversed()\n var ans = 0L\n for (i in 0..hs.size - 1) {\n if (i < k) {\n continue \n }\n ans += hs.get(i)\n }\n\n return ans\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 457, "cpu_time_ms": 1177, "memory_kb": 62152}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s635596882", "group_id": "codeNet:p02786", "input_text": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val h = sc.nextLong()\n println(problem154d(h))\n}\n\nfun problem154d(h: Long): Long {\n var count = 1L\n var h2 = h\n while (h2 != 0L) {\n count *= 2\n h2 /= 2\n }\n return count - 1\n}", "language": "Kotlin", "metadata": {"date": 1580071204, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02786.html", "problem_id": "p02786", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02786/input.txt", "sample_output_relpath": "derived/input_output/data/p02786/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02786/Kotlin/s635596882.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s635596882", "user_id": "u073232808"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val h = sc.nextLong()\n println(problem154d(h))\n}\n\nfun problem154d(h: Long): Long {\n var count = 1L\n var h2 = h\n while (h2 != 0L) {\n count *= 2\n h2 /= 2\n }\n return count - 1\n}", "problem_context": "Score : 400 points\n\nProblem Statement\n\nCaracal is fighting with a monster.\n\nThe health of the monster is H.\n\nCaracal can attack by choosing one monster. When a monster is attacked, depending on that monster's health, the following happens:\n\nIf the monster's health is 1, it drops to 0.\n\nIf the monster's health, X, is greater than 1, that monster disappears. Then, two new monsters appear, each with the health of \\lfloor X/2 \\rfloor.\n\n(\\lfloor r \\rfloor denotes the greatest integer not exceeding r.)\n\nCaracal wins when the healths of all existing monsters become 0 or below.\n\nFind the minimum number of attacks Caracal needs to make before winning.\n\nConstraints\n\n1 \\leq H \\leq 10^{12}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH\n\nOutput\n\nFind the minimum number of attacks Caracal needs to make before winning.\n\nSample Input 1\n\n2\n\nSample Output 1\n\n3\n\nWhen Caracal attacks the initial monster, it disappears, and two monsters appear, each with the health of 1.\n\nThen, Caracal can attack each of these new monsters once and win with a total of three attacks.\n\nSample Input 2\n\n4\n\nSample Output 2\n\n7\n\nSample Input 3\n\n1000000000000\n\nSample Output 3\n\n1099511627775", "sample_input": "2\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02786", "source_text": "Score : 400 points\n\nProblem Statement\n\nCaracal is fighting with a monster.\n\nThe health of the monster is H.\n\nCaracal can attack by choosing one monster. When a monster is attacked, depending on that monster's health, the following happens:\n\nIf the monster's health is 1, it drops to 0.\n\nIf the monster's health, X, is greater than 1, that monster disappears. Then, two new monsters appear, each with the health of \\lfloor X/2 \\rfloor.\n\n(\\lfloor r \\rfloor denotes the greatest integer not exceeding r.)\n\nCaracal wins when the healths of all existing monsters become 0 or below.\n\nFind the minimum number of attacks Caracal needs to make before winning.\n\nConstraints\n\n1 \\leq H \\leq 10^{12}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH\n\nOutput\n\nFind the minimum number of attacks Caracal needs to make before winning.\n\nSample Input 1\n\n2\n\nSample Output 1\n\n3\n\nWhen Caracal attacks the initial monster, it disappears, and two monsters appear, each with the health of 1.\n\nThen, Caracal can attack each of these new monsters once and win with a total of three attacks.\n\nSample Input 2\n\n4\n\nSample Output 2\n\n7\n\nSample Input 3\n\n1000000000000\n\nSample Output 3\n\n1099511627775", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 296, "cpu_time_ms": 187, "memory_kb": 31392}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s546605039", "group_id": "codeNet:p02788", "input_text": "@file:Suppress(\"NOTHING_TO_INLINE\", \"EXPERIMENTAL_FEATURE_WARNING\", \"OVERRIDE_BY_INLINE\")\n//@file:OptIn(ExperimentalStdlibApi::class)\n\nimport java.io.PrintWriter\nimport java.util.ArrayDeque\nimport java.util.PriorityQueue\nimport kotlin.math.*\nimport kotlin.random.Random\nimport kotlin.collections.sort as _sort\nimport kotlin.collections.sortDescending as _sortDescending\nimport kotlin.io.println as iprintln\n\n/** @author Spheniscine */\nfun main() { _writer.solve(); _writer.flush() }\n\nfun PrintWriter.solve() {\n// val startTime = System.nanoTime()\n\n val numCases = 1//readInt()\n case@ for(case in 1..numCases) {\n //print(\"Case #$case: \")\n\n val n = readInt()\n val d = readInt()\n val a = readInt()\n\n val M = Array(n) {\n Monster(readInt(), readInt())\n }\n\n M.sortBy { it.x }\n\n val R = IntArray(n)\n var dam = 0\n var ans = 0L\n var j = 0\n\n for(i in 0 until n) {\n val (x, h) = M[i]\n while(j < i && M[j].x+d < x-d) {\n dam -= R[j++]\n }\n\n if(h > dam) {\n val k = h-dam divCeil a\n ans += k\n dam += k*a\n R[i] = k*a\n }\n }\n\n println(ans)\n }\n\n// iprintln(\"Time: ${(System.nanoTime() - startTime) / 1000000} ms\")\n}\n\ndata class Monster(val x: Int, val h: Int)\ndata class RB(val x: Int, val d: Int)\ninfix fun Int.divCeil(other: Int) =\n (this / other).let { if(xor(other) >= 0 && it * other != this) it+1 else it }\n\n/** IO */\n//@JvmField val INPUT = File(\"input.txt\").inputStream()\n//@JvmField val OUTPUT = File(\"output.txt\").outputStream()\n@JvmField val INPUT = System.`in`\n@JvmField val OUTPUT = System.out\n\nconst val _BUFFER_SIZE = 1 shl 16\n@JvmField val _buffer = ByteArray(_BUFFER_SIZE)\n@JvmField var _bufferPt = 0\n@JvmField var _bytesRead = 0\n\ntailrec fun readChar(): Char {\n if(_bufferPt == _bytesRead) {\n _bufferPt = 0\n _bytesRead = INPUT.read(_buffer, 0, _BUFFER_SIZE)\n }\n return if(_bytesRead < 0) Char.MIN_VALUE\n else {\n val c = _buffer[_bufferPt++].toChar()\n if (c == '\\r') readChar()\n else c\n }\n}\n\nfun readLine(): String? {\n var c = readChar()\n return if(c == Char.MIN_VALUE) null\n else buildString {\n while(c != '\\n' && c != Char.MIN_VALUE) {\n append(c)\n c = readChar()\n }\n }\n}\nfun readLn() = readLine()!!\n\nfun read() = buildString {\n var c = readChar()\n while(c <= ' ') {\n if(c == Char.MIN_VALUE) return@buildString\n c = readChar()\n }\n do {\n append(c)\n c = readChar()\n } while(c > ' ')\n}\nfun readInt() = read().toInt()\nfun readDouble() = read().toDouble()\nfun readLong() = read().toLong()\nfun readStrings(n: Int) = List(n) { read() }\nfun readLines(n: Int) = List(n) { readLn() }\nfun readInts(n: Int) = List(n) { read().toInt() }\nfun readIntArray(n: Int) = IntArray(n) { read().toInt() }\nfun readDoubles(n: Int) = List(n) { read().toDouble() }\nfun readDoubleArray(n: Int) = DoubleArray(n) { read().toDouble() }\nfun readLongs(n: Int) = List(n) { read().toLong() }\nfun readLongArray(n: Int) = LongArray(n) { read().toLong() }\n\n@JvmField val _writer = PrintWriter(OUTPUT, false)\n\n/** shuffles and sort overrides to avoid quicksort attacks */\nprivate inline fun _shuffle(rnd: Random, get: (Int) -> T, set: (Int, T) -> Unit, size: Int) {\n // Fisher-Yates shuffle algorithm\n for (i in size - 1 downTo 1) {\n val j = rnd.nextInt(i + 1)\n val temp = get(i)\n set(i, get(j))\n set(j, temp)\n }\n}\n\n@JvmField var _random: Random? = null\nval random get() = _random ?: Random(0x594E215C123 * System.nanoTime()).also { _random = it }\n\nfun IntArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\nfun IntArray.sort() { shuffle(); _sort() }\nfun IntArray.sortDescending() { shuffle(); _sortDescending() }\n\nfun LongArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\nfun LongArray.sort() { shuffle(); _sort() }\nfun LongArray.sortDescending() { shuffle(); _sortDescending() }\n\nfun DoubleArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\nfun DoubleArray.sort() { shuffle(); _sort() }\nfun DoubleArray.sortDescending() { shuffle(); _sortDescending() }\n\nfun CharArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\ninline fun CharArray.sort() { _sort() }\ninline fun CharArray.sortDescending() { _sortDescending() }\n\ninline fun > Array.sort() = _sort()\ninline fun > Array.sortDescending() = _sortDescending()\ninline fun > MutableList.sort() = _sort()\ninline fun > MutableList.sortDescending() = _sortDescending()\n\nfun `please stop removing these imports IntelliJ`() { iprintln(max(1, 2)) }\n\n/** additional commons */\ninline fun Iterable.sumByLong(func: (T) -> Long) = fold(0L) { acc, t -> acc + func(t) }\ninline fun Sequence.sumByLong(func: (T) -> Long) = fold(0L) { acc, t -> acc + func(t) }\ninline fun Array.sumByLong(func: (T) -> Long) = fold(0L) { acc, t -> acc + func(t) }\nfun IntArray.sumLong() = fold(0L, Long::plus)\n", "language": "Kotlin", "metadata": {"date": 1593512559, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02788.html", "problem_id": "p02788", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02788/input.txt", "sample_output_relpath": "derived/input_output/data/p02788/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02788/Kotlin/s546605039.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s546605039", "user_id": "u596111103"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "@file:Suppress(\"NOTHING_TO_INLINE\", \"EXPERIMENTAL_FEATURE_WARNING\", \"OVERRIDE_BY_INLINE\")\n//@file:OptIn(ExperimentalStdlibApi::class)\n\nimport java.io.PrintWriter\nimport java.util.ArrayDeque\nimport java.util.PriorityQueue\nimport kotlin.math.*\nimport kotlin.random.Random\nimport kotlin.collections.sort as _sort\nimport kotlin.collections.sortDescending as _sortDescending\nimport kotlin.io.println as iprintln\n\n/** @author Spheniscine */\nfun main() { _writer.solve(); _writer.flush() }\n\nfun PrintWriter.solve() {\n// val startTime = System.nanoTime()\n\n val numCases = 1//readInt()\n case@ for(case in 1..numCases) {\n //print(\"Case #$case: \")\n\n val n = readInt()\n val d = readInt()\n val a = readInt()\n\n val M = Array(n) {\n Monster(readInt(), readInt())\n }\n\n M.sortBy { it.x }\n\n val R = IntArray(n)\n var dam = 0\n var ans = 0L\n var j = 0\n\n for(i in 0 until n) {\n val (x, h) = M[i]\n while(j < i && M[j].x+d < x-d) {\n dam -= R[j++]\n }\n\n if(h > dam) {\n val k = h-dam divCeil a\n ans += k\n dam += k*a\n R[i] = k*a\n }\n }\n\n println(ans)\n }\n\n// iprintln(\"Time: ${(System.nanoTime() - startTime) / 1000000} ms\")\n}\n\ndata class Monster(val x: Int, val h: Int)\ndata class RB(val x: Int, val d: Int)\ninfix fun Int.divCeil(other: Int) =\n (this / other).let { if(xor(other) >= 0 && it * other != this) it+1 else it }\n\n/** IO */\n//@JvmField val INPUT = File(\"input.txt\").inputStream()\n//@JvmField val OUTPUT = File(\"output.txt\").outputStream()\n@JvmField val INPUT = System.`in`\n@JvmField val OUTPUT = System.out\n\nconst val _BUFFER_SIZE = 1 shl 16\n@JvmField val _buffer = ByteArray(_BUFFER_SIZE)\n@JvmField var _bufferPt = 0\n@JvmField var _bytesRead = 0\n\ntailrec fun readChar(): Char {\n if(_bufferPt == _bytesRead) {\n _bufferPt = 0\n _bytesRead = INPUT.read(_buffer, 0, _BUFFER_SIZE)\n }\n return if(_bytesRead < 0) Char.MIN_VALUE\n else {\n val c = _buffer[_bufferPt++].toChar()\n if (c == '\\r') readChar()\n else c\n }\n}\n\nfun readLine(): String? {\n var c = readChar()\n return if(c == Char.MIN_VALUE) null\n else buildString {\n while(c != '\\n' && c != Char.MIN_VALUE) {\n append(c)\n c = readChar()\n }\n }\n}\nfun readLn() = readLine()!!\n\nfun read() = buildString {\n var c = readChar()\n while(c <= ' ') {\n if(c == Char.MIN_VALUE) return@buildString\n c = readChar()\n }\n do {\n append(c)\n c = readChar()\n } while(c > ' ')\n}\nfun readInt() = read().toInt()\nfun readDouble() = read().toDouble()\nfun readLong() = read().toLong()\nfun readStrings(n: Int) = List(n) { read() }\nfun readLines(n: Int) = List(n) { readLn() }\nfun readInts(n: Int) = List(n) { read().toInt() }\nfun readIntArray(n: Int) = IntArray(n) { read().toInt() }\nfun readDoubles(n: Int) = List(n) { read().toDouble() }\nfun readDoubleArray(n: Int) = DoubleArray(n) { read().toDouble() }\nfun readLongs(n: Int) = List(n) { read().toLong() }\nfun readLongArray(n: Int) = LongArray(n) { read().toLong() }\n\n@JvmField val _writer = PrintWriter(OUTPUT, false)\n\n/** shuffles and sort overrides to avoid quicksort attacks */\nprivate inline fun _shuffle(rnd: Random, get: (Int) -> T, set: (Int, T) -> Unit, size: Int) {\n // Fisher-Yates shuffle algorithm\n for (i in size - 1 downTo 1) {\n val j = rnd.nextInt(i + 1)\n val temp = get(i)\n set(i, get(j))\n set(j, temp)\n }\n}\n\n@JvmField var _random: Random? = null\nval random get() = _random ?: Random(0x594E215C123 * System.nanoTime()).also { _random = it }\n\nfun IntArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\nfun IntArray.sort() { shuffle(); _sort() }\nfun IntArray.sortDescending() { shuffle(); _sortDescending() }\n\nfun LongArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\nfun LongArray.sort() { shuffle(); _sort() }\nfun LongArray.sortDescending() { shuffle(); _sortDescending() }\n\nfun DoubleArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\nfun DoubleArray.sort() { shuffle(); _sort() }\nfun DoubleArray.sortDescending() { shuffle(); _sortDescending() }\n\nfun CharArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\ninline fun CharArray.sort() { _sort() }\ninline fun CharArray.sortDescending() { _sortDescending() }\n\ninline fun > Array.sort() = _sort()\ninline fun > Array.sortDescending() = _sortDescending()\ninline fun > MutableList.sort() = _sort()\ninline fun > MutableList.sortDescending() = _sortDescending()\n\nfun `please stop removing these imports IntelliJ`() { iprintln(max(1, 2)) }\n\n/** additional commons */\ninline fun Iterable.sumByLong(func: (T) -> Long) = fold(0L) { acc, t -> acc + func(t) }\ninline fun Sequence.sumByLong(func: (T) -> Long) = fold(0L) { acc, t -> acc + func(t) }\ninline fun Array.sumByLong(func: (T) -> Long) = fold(0L) { acc, t -> acc + func(t) }\nfun IntArray.sumLong() = fold(0L, Long::plus)\n", "problem_context": "Score : 600 points\n\nProblem Statement\n\nSilver Fox is fighting with N monsters.\n\nThe monsters are standing in a row, and we can assume them to be standing on a number line. The i-th monster, standing at the coordinate X_i, has the health of H_i.\n\nSilver Fox can use bombs to attack the monsters.\nUsing a bomb at the coordinate x decreases the healths of all monsters between the coordinates x-D and x+D (inclusive) by A.\nThere is no way other than bombs to decrease the monster's health.\n\nSilver Fox wins when all the monsters' healths become 0 or below.\n\nFind the minimum number of bombs needed to win.\n\nConstraints\n\n1 \\leq N \\leq 2 \\times 10^5\n\n0 \\leq D \\leq 10^9\n\n1 \\leq A \\leq 10^9\n\n0 \\leq X_i \\leq 10^9\n\n1 \\leq H_i \\leq 10^9\n\nX_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 D A\nX_1 H_1\n:\nX_N H_N\n\nOutput\n\nPrint the minimum number of bombs needed to win.\n\nSample Input 1\n\n3 3 2\n1 2\n5 4\n9 2\n\nSample Output 1\n\n2\n\nFirst, let us use a bomb at the coordinate 4 to decrease the first and second monsters' health by 2.\n\nThen, use a bomb at the coordinate 6 to decrease the second and third monsters' health by 2.\n\nNow, all the monsters' healths are 0.\nWe cannot make all the monsters' health drop to 0 or below with just one bomb.\n\nSample Input 2\n\n9 4 1\n1 5\n2 4\n3 3\n4 2\n5 1\n6 2\n7 3\n8 4\n9 5\n\nSample Output 2\n\n5\n\nWe should use five bombs at the coordinate 5.\n\nSample Input 3\n\n3 0 1\n300000000 1000000000\n100000000 1000000000\n200000000 1000000000\n\nSample Output 3\n\n3000000000\n\nWatch out for overflow.", "sample_input": "3 3 2\n1 2\n5 4\n9 2\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02788", "source_text": "Score : 600 points\n\nProblem Statement\n\nSilver Fox is fighting with N monsters.\n\nThe monsters are standing in a row, and we can assume them to be standing on a number line. The i-th monster, standing at the coordinate X_i, has the health of H_i.\n\nSilver Fox can use bombs to attack the monsters.\nUsing a bomb at the coordinate x decreases the healths of all monsters between the coordinates x-D and x+D (inclusive) by A.\nThere is no way other than bombs to decrease the monster's health.\n\nSilver Fox wins when all the monsters' healths become 0 or below.\n\nFind the minimum number of bombs needed to win.\n\nConstraints\n\n1 \\leq N \\leq 2 \\times 10^5\n\n0 \\leq D \\leq 10^9\n\n1 \\leq A \\leq 10^9\n\n0 \\leq X_i \\leq 10^9\n\n1 \\leq H_i \\leq 10^9\n\nX_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 D A\nX_1 H_1\n:\nX_N H_N\n\nOutput\n\nPrint the minimum number of bombs needed to win.\n\nSample Input 1\n\n3 3 2\n1 2\n5 4\n9 2\n\nSample Output 1\n\n2\n\nFirst, let us use a bomb at the coordinate 4 to decrease the first and second monsters' health by 2.\n\nThen, use a bomb at the coordinate 6 to decrease the second and third monsters' health by 2.\n\nNow, all the monsters' healths are 0.\nWe cannot make all the monsters' health drop to 0 or below with just one bomb.\n\nSample Input 2\n\n9 4 1\n1 5\n2 4\n3 3\n4 2\n5 1\n6 2\n7 3\n8 4\n9 5\n\nSample Output 2\n\n5\n\nWe should use five bombs at the coordinate 5.\n\nSample Input 3\n\n3 0 1\n300000000 1000000000\n100000000 1000000000\n200000000 1000000000\n\nSample Output 3\n\n3000000000\n\nWatch out for overflow.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 5222, "cpu_time_ms": 534, "memory_kb": 65436}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s447331046", "group_id": "codeNet:p02790", "input_text": "fun main(args: Array) {\n val (a, b) = readInts()\n var aStr = \"\"\n var bStr = \"\"\n for (i in 0 until b) {\n aStr += a\n }\n for (i in 0 until a) {\n bStr += b\n }\n println(if (aStr < bStr) aStr else bStr)\n}\n\nfun readString() = readLine()!!\nfun readStrings() = readString().split(\" \")\nfun readInt() = readString().toInt()\nfun readInts() = readStrings().map { it.toInt() }\nfun readLongs() = readStrings().map { it.toLong() }\n", "language": "Kotlin", "metadata": {"date": 1579463638, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02790.html", "problem_id": "p02790", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02790/input.txt", "sample_output_relpath": "derived/input_output/data/p02790/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02790/Kotlin/s447331046.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s447331046", "user_id": "u979004569"}, "prompt_components": {"gold_output": "3333\n", "input_to_evaluate": "fun main(args: Array) {\n val (a, b) = readInts()\n var aStr = \"\"\n var bStr = \"\"\n for (i in 0 until b) {\n aStr += a\n }\n for (i in 0 until a) {\n bStr += b\n }\n println(if (aStr < bStr) aStr else bStr)\n}\n\nfun readString() = readLine()!!\nfun readStrings() = readString().split(\" \")\nfun readInt() = readString().toInt()\nfun readInts() = readStrings().map { it.toInt() }\nfun readLongs() = readStrings().map { it.toLong() }\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nGiven are 1-digit positive integers a and b. Consider these two strings: the concatenation of b copies of the digit a, and the concatenation of a copies of the digit b. Which of these is lexicographically smaller?\n\nConstraints\n\n1 \\leq a \\leq 9\n\n1 \\leq b \\leq 9\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\nPrint the lexicographically smaller of the two strings. (If the two strings are equal, print one of them.)\n\nSample Input 1\n\n4 3\n\nSample Output 1\n\n3333\n\nWe have two strings 444 and 3333. Between them, 3333 is the lexicographically smaller.\n\nSample Input 2\n\n7 7\n\nSample Output 2\n\n7777777", "sample_input": "4 3\n"}, "reference_outputs": ["3333\n"], "source_document_id": "p02790", "source_text": "Score : 200 points\n\nProblem Statement\n\nGiven are 1-digit positive integers a and b. Consider these two strings: the concatenation of b copies of the digit a, and the concatenation of a copies of the digit b. Which of these is lexicographically smaller?\n\nConstraints\n\n1 \\leq a \\leq 9\n\n1 \\leq b \\leq 9\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\nPrint the lexicographically smaller of the two strings. (If the two strings are equal, print one of them.)\n\nSample Input 1\n\n4 3\n\nSample Output 1\n\n3333\n\nWe have two strings 444 and 3333. Between them, 3333 is the lexicographically smaller.\n\nSample Input 2\n\n7 7\n\nSample Output 2\n\n7777777", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 244, "memory_kb": 36060}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s923017251", "group_id": "codeNet:p02791", "input_text": "fun main(args: Array) {\n // Your code here!\n var n = readLine()!!.toInt()\n var juns = readLine()!!.split(\" \").map{it.toInt()}\n var min = juns[0]\n var cnt = 0.until(n).count{ \n i -> val pi = juns[i]\n if(pi <= min){\n min = pi\n true\n }else{\n false\n }\n }\n \n print(cnt)\n} ", "language": "Kotlin", "metadata": {"date": 1586515531, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02791.html", "problem_id": "p02791", "resource_group": "medium_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/Kotlin/s923017251.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s923017251", "user_id": "u808976884"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "fun main(args: Array) {\n // Your code here!\n var n = readLine()!!.toInt()\n var juns = readLine()!!.split(\" \").map{it.toInt()}\n var min = juns[0]\n var cnt = 0.until(n).count{ \n i -> val pi = juns[i]\n if(pi <= min){\n min = pi\n true\n }else{\n false\n }\n }\n \n print(cnt)\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 348, "cpu_time_ms": 667, "memory_kb": 80932}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s346262887", "group_id": "codeNet:p02791", "input_text": "import java.io.PrintWriter\nimport java.util.*\nimport java.math.*\nimport java.lang.*\nimport kotlin.comparisons.*\n\nval pw = PrintWriter(System.out)\nval MOD: Long = (1e+9 + 7).toLong()\n\nfun main(args: Array) {\n val n = readInt()\n val pList = readListOfInt()\n val minList = Array(n) { 0 }.toMutableList()\n minList[0] = pList[0]\n for(i in 1 until n) {\n minList[i] = Math.min(minList[i-1], pList[i])\n }\n\n var cnt = 0\n for(i in 0 until n) {\n if(pList[i] <= minList[i]) {\n cnt++\n }\n }\n println(cnt)\n pw.flush()\n}\n\n/****** Declared Functions and Data Structures ******/\n// IO\nfun read() = readLine()!!\nfun readInt() = read().toInt()\nfun readLong() = read().toLong()\nfun readDouble() = read().toDouble()\nfun readListOfString() = read().split(\" \")\nfun readListOfInt() = readListOfString().map { it.toInt() }\nfun readListOfLong() = readListOfString().map { it.toLong() }\nfun readListOfDouble() = readListOfString().map { it.toDouble() }\n\nfun Double.format(digits: Int) = String.format(\"%.${digits}f\", this)\nfun Float.format(digits: Int) = String.format(\"%.${digits}f\", this)\n\nfun print(value: Any) { pw.print(value) }\nfun println(value : Any) { pw.println(value) }\n\n// Extensions\nfun List.toBuckets(): Map\n\t= this.groupBy { it }.mapValues { it.value.size }\n\nfun> List.upperBound(element: T, fromIndex: Int=0, toIndex: Int=this.size): Int {\n\tvar l = fromIndex\n\tvar r = toIndex\n\twhile(l < r) {\n\t\tval mid = (l+r) / 2\n\t\tif(element >= this[mid]) { \n\t\t\tl = mid + 1\n\t\t} else {\n\t\t\tr = mid\n\t\t}\n\t}\n\treturn l\n}\n\nfun> List.lowerBound(element: T, fromIndex: Int=0, toIndex: Int=this.size): Int {\n\tvar l = fromIndex\n\tvar r = toIndex\n\twhile(l < r) {\n\t\tval mid = (l+r) / 2\n\t\tif(element <= this[mid]) { \n\t\t\tr = mid\n\t\t} else {\n\t\t\tl = mid + 1\n\t\t}\n\t}\n\treturn r \n}\n\nfun Map.toMutableMap(): MutableMap = HashMap(this)\n\n// Util Functions\nfun Long.makeDivisors(): List {\n\tval divisors = mutableListOf()\n\tfor(i in 1L .. Math.sqrt(this.toDouble()).toLong()+1L) {\n\t\tif(this % i == 0L) {\n\t\t\tdivisors.add(i)\n\t\t\tif(i != this/i) {\n\t\t\t\tdivisors.add(this/i)\n\t\t\t}\n\t\t}\n\t}\n\treturn divisors.distinct().sorted()\n}\n\nfun Long.isPrime(): Boolean {\n\tif(this==1L) return false\n\tfor(i in 2L .. Math.sqrt(this.toDouble()).toLong() + 1L) {\n\t\tif(this % i == 0L && this != i) {\n\t\t\treturn false\n\t\t}\n\t}\n\treturn true\n}\n\n\nfun permutations(src: List): List> {\n\tif(src.size == 1) return listOf(src)\n\tval perms = mutableListOf>()\n\tval insertElement = src[0]\n\tpermutations(src.drop(1)).forEach { perm ->\n\t\tfor(i in 0..perm.size) {\n\t\t\tval newPerm = perm.toMutableList()\n\t\t\tnewPerm.add(i, insertElement)\n\t\t\tperms.add(newPerm.toList())\n\t\t}\n\t}\n\treturn perms\n}\n\n// return nCr, if you want nCr, please access v[n][r]\nfun combinations(n: Long): List> {\n\tval v = (0..n).map { (0..n).map{0L}.toMutableList() }.toMutableList()\n\tfor(i in 0 until v.size) {\n\t\tv[i][0] = 1L\n\t\tv[i][i] = 1L\n\t}\n\tfor(i in 0 until v.size) {\n\t\tfor(j in 1 until i) {\n\t\t\tv[i][j] = (v[i-1][j-1] + v[i-1][j]) % MOD\n\t\t}\n\t}\n\treturn v.map { it.toList() }.toList()\n}\n\n// return nCr % MOD\nfun modCombinations(n: Int, k: Int, mod: Long): Long {\n\tval factorials = Array(n+1) { 0L }.apply {\n\t\tthis[0] = 1L\n\t\tif(this.size > 1) this[1] = 1L\n\t}\n\tval inverses = Array(n+1) { 0L }.apply {\n\t\tthis[0] = 1L\n\t\tif(this.size > 1) this[1] = 1L\n\t}\n\tval factorialInverses = Array(n+1) { 0L }.apply {\n\t\tthis[0] = 1L\n\t\tif(this.size > 1) this[1] = 1L\n\t}\n\tfor(i in 2 .. n) {\n\t\tfactorials[i] = (factorials[i-1] * i.toLong() % mod)\n\t\tinverses[i] = (mod - inverses[mod.toInt() % i] * (mod / i.toLong()) % mod)\n\t\tfactorialInverses[i] = (factorialInverses[i-1] * inverses[i] % mod)\n\t}\n\n\treturn factorials[n] % mod * (factorialInverses[k] * factorialInverses[n-k] % mod) % mod\n}\n\n// should be a >= b\nfun gcd(a: Long, b: Long): Long = \n\tif(b == 0L) a else gcd(b, a % b)\n\n// shoud be a >= b\nfun lcm(a: Long, b: Long): Long = \n\ta / gcd(a, b) * b\n\nfun sumDigits(num_: Long): Long {\n\tvar num = num_\n\tvar rtn: Long = 0\n\twhile(num != 0.toLong()) {\n\t\tval tmp = num % 10\n\t\trtn += tmp\n\t\tnum /= 10\n\t}\n\treturn rtn\n}\n\nfun Double.isDecimal(): Boolean = ((this - Math.floor(this)) != 0.0)\n\n// Data Structures\nclass Stack(private var st: MutableList = mutableListOf()) {\n\tfun isEmpty() = st.isEmpty()\n\tfun top(): T = st.last()\n\tfun push(e: T) { st.add(e) }\n\tfun pop() { st = st.dropLast(1).toMutableList() }\n}\n\nclass Queue(private var que: MutableList = mutableListOf()) {\n\tfun isEmpty() = que.isEmpty()\n\tfun top(): T = que.first()\n\tfun push(e: T) { que.add(e) }\n\tfun pop() { que = que.drop(1).toMutableList() }\n}\n", "language": "Kotlin", "metadata": {"date": 1579464146, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02791.html", "problem_id": "p02791", "resource_group": "medium_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/Kotlin/s346262887.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s346262887", "user_id": "u026686258"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "import java.io.PrintWriter\nimport java.util.*\nimport java.math.*\nimport java.lang.*\nimport kotlin.comparisons.*\n\nval pw = PrintWriter(System.out)\nval MOD: Long = (1e+9 + 7).toLong()\n\nfun main(args: Array) {\n val n = readInt()\n val pList = readListOfInt()\n val minList = Array(n) { 0 }.toMutableList()\n minList[0] = pList[0]\n for(i in 1 until n) {\n minList[i] = Math.min(minList[i-1], pList[i])\n }\n\n var cnt = 0\n for(i in 0 until n) {\n if(pList[i] <= minList[i]) {\n cnt++\n }\n }\n println(cnt)\n pw.flush()\n}\n\n/****** Declared Functions and Data Structures ******/\n// IO\nfun read() = readLine()!!\nfun readInt() = read().toInt()\nfun readLong() = read().toLong()\nfun readDouble() = read().toDouble()\nfun readListOfString() = read().split(\" \")\nfun readListOfInt() = readListOfString().map { it.toInt() }\nfun readListOfLong() = readListOfString().map { it.toLong() }\nfun readListOfDouble() = readListOfString().map { it.toDouble() }\n\nfun Double.format(digits: Int) = String.format(\"%.${digits}f\", this)\nfun Float.format(digits: Int) = String.format(\"%.${digits}f\", this)\n\nfun print(value: Any) { pw.print(value) }\nfun println(value : Any) { pw.println(value) }\n\n// Extensions\nfun List.toBuckets(): Map\n\t= this.groupBy { it }.mapValues { it.value.size }\n\nfun> List.upperBound(element: T, fromIndex: Int=0, toIndex: Int=this.size): Int {\n\tvar l = fromIndex\n\tvar r = toIndex\n\twhile(l < r) {\n\t\tval mid = (l+r) / 2\n\t\tif(element >= this[mid]) { \n\t\t\tl = mid + 1\n\t\t} else {\n\t\t\tr = mid\n\t\t}\n\t}\n\treturn l\n}\n\nfun> List.lowerBound(element: T, fromIndex: Int=0, toIndex: Int=this.size): Int {\n\tvar l = fromIndex\n\tvar r = toIndex\n\twhile(l < r) {\n\t\tval mid = (l+r) / 2\n\t\tif(element <= this[mid]) { \n\t\t\tr = mid\n\t\t} else {\n\t\t\tl = mid + 1\n\t\t}\n\t}\n\treturn r \n}\n\nfun Map.toMutableMap(): MutableMap = HashMap(this)\n\n// Util Functions\nfun Long.makeDivisors(): List {\n\tval divisors = mutableListOf()\n\tfor(i in 1L .. Math.sqrt(this.toDouble()).toLong()+1L) {\n\t\tif(this % i == 0L) {\n\t\t\tdivisors.add(i)\n\t\t\tif(i != this/i) {\n\t\t\t\tdivisors.add(this/i)\n\t\t\t}\n\t\t}\n\t}\n\treturn divisors.distinct().sorted()\n}\n\nfun Long.isPrime(): Boolean {\n\tif(this==1L) return false\n\tfor(i in 2L .. Math.sqrt(this.toDouble()).toLong() + 1L) {\n\t\tif(this % i == 0L && this != i) {\n\t\t\treturn false\n\t\t}\n\t}\n\treturn true\n}\n\n\nfun permutations(src: List): List> {\n\tif(src.size == 1) return listOf(src)\n\tval perms = mutableListOf>()\n\tval insertElement = src[0]\n\tpermutations(src.drop(1)).forEach { perm ->\n\t\tfor(i in 0..perm.size) {\n\t\t\tval newPerm = perm.toMutableList()\n\t\t\tnewPerm.add(i, insertElement)\n\t\t\tperms.add(newPerm.toList())\n\t\t}\n\t}\n\treturn perms\n}\n\n// return nCr, if you want nCr, please access v[n][r]\nfun combinations(n: Long): List> {\n\tval v = (0..n).map { (0..n).map{0L}.toMutableList() }.toMutableList()\n\tfor(i in 0 until v.size) {\n\t\tv[i][0] = 1L\n\t\tv[i][i] = 1L\n\t}\n\tfor(i in 0 until v.size) {\n\t\tfor(j in 1 until i) {\n\t\t\tv[i][j] = (v[i-1][j-1] + v[i-1][j]) % MOD\n\t\t}\n\t}\n\treturn v.map { it.toList() }.toList()\n}\n\n// return nCr % MOD\nfun modCombinations(n: Int, k: Int, mod: Long): Long {\n\tval factorials = Array(n+1) { 0L }.apply {\n\t\tthis[0] = 1L\n\t\tif(this.size > 1) this[1] = 1L\n\t}\n\tval inverses = Array(n+1) { 0L }.apply {\n\t\tthis[0] = 1L\n\t\tif(this.size > 1) this[1] = 1L\n\t}\n\tval factorialInverses = Array(n+1) { 0L }.apply {\n\t\tthis[0] = 1L\n\t\tif(this.size > 1) this[1] = 1L\n\t}\n\tfor(i in 2 .. n) {\n\t\tfactorials[i] = (factorials[i-1] * i.toLong() % mod)\n\t\tinverses[i] = (mod - inverses[mod.toInt() % i] * (mod / i.toLong()) % mod)\n\t\tfactorialInverses[i] = (factorialInverses[i-1] * inverses[i] % mod)\n\t}\n\n\treturn factorials[n] % mod * (factorialInverses[k] * factorialInverses[n-k] % mod) % mod\n}\n\n// should be a >= b\nfun gcd(a: Long, b: Long): Long = \n\tif(b == 0L) a else gcd(b, a % b)\n\n// shoud be a >= b\nfun lcm(a: Long, b: Long): Long = \n\ta / gcd(a, b) * b\n\nfun sumDigits(num_: Long): Long {\n\tvar num = num_\n\tvar rtn: Long = 0\n\twhile(num != 0.toLong()) {\n\t\tval tmp = num % 10\n\t\trtn += tmp\n\t\tnum /= 10\n\t}\n\treturn rtn\n}\n\nfun Double.isDecimal(): Boolean = ((this - Math.floor(this)) != 0.0)\n\n// Data Structures\nclass Stack(private var st: MutableList = mutableListOf()) {\n\tfun isEmpty() = st.isEmpty()\n\tfun top(): T = st.last()\n\tfun push(e: T) { st.add(e) }\n\tfun pop() { st = st.dropLast(1).toMutableList() }\n}\n\nclass Queue(private var que: MutableList = mutableListOf()) {\n\tfun isEmpty() = que.isEmpty()\n\tfun top(): T = que.first()\n\tfun push(e: T) { que.add(e) }\n\tfun pop() { que = que.drop(1).toMutableList() }\n}\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 4667, "cpu_time_ms": 685, "memory_kb": 80900}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s212574815", "group_id": "codeNet:p02792", "input_text": "fun main(args: Array) {\n val n = readLine()!!.toInt()\n\n var ketasu = n.toString().length - 2\n val top = n.toString().first().toString().toInt()\n val bottom = n % 10\n\n var p1 = 0\n var p2 = 0\n var p3 = 0\n if (ketasu >= 1) {\n p1 = Math.pow(10.0, ketasu.toDouble()).toInt()\n p2 = Math.pow(10.0, ketasu - 1.0).toInt()\n p3 = n.toString().substring(1, ketasu + 1).toInt()\n }\n if (p2 == 1) { p2 = 0 }\n\n var count = 0\n\n for (i in 1..n) {\n val chars = i.toString()\n val sentou = chars.first().toString().toInt()\n val matubi = chars.last().toString().toInt()\n\n if (matubi == 0) continue\n\n if (matubi < top) {\n var temp = 10\n while (temp <= p1) {\n count += temp\n temp *= 10\n }\n } else if (matubi > top) {\n var temp = 10\n while (temp <= p2) {\n count += temp\n temp *= 10\n }\n } else {\n count += p3\n \n var temp = 10\n while (temp <= p2) {\n count += temp\n temp *= 10\n }\n if (sentou <= bottom) {\n count += 1\n }\n }\n\n\n if ((matubi.toString() + sentou.toString()).toInt() < n) {\n count += 1\n }\n\n if (sentou == matubi) {\n count += 1\n }\n }\n\n print(count)\n\n}", "language": "Kotlin", "metadata": {"date": 1579470024, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02792.html", "problem_id": "p02792", "resource_group": "medium_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/Kotlin/s212574815.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s212574815", "user_id": "u069766151"}, "prompt_components": {"gold_output": "17\n", "input_to_evaluate": "fun main(args: Array) {\n val n = readLine()!!.toInt()\n\n var ketasu = n.toString().length - 2\n val top = n.toString().first().toString().toInt()\n val bottom = n % 10\n\n var p1 = 0\n var p2 = 0\n var p3 = 0\n if (ketasu >= 1) {\n p1 = Math.pow(10.0, ketasu.toDouble()).toInt()\n p2 = Math.pow(10.0, ketasu - 1.0).toInt()\n p3 = n.toString().substring(1, ketasu + 1).toInt()\n }\n if (p2 == 1) { p2 = 0 }\n\n var count = 0\n\n for (i in 1..n) {\n val chars = i.toString()\n val sentou = chars.first().toString().toInt()\n val matubi = chars.last().toString().toInt()\n\n if (matubi == 0) continue\n\n if (matubi < top) {\n var temp = 10\n while (temp <= p1) {\n count += temp\n temp *= 10\n }\n } else if (matubi > top) {\n var temp = 10\n while (temp <= p2) {\n count += temp\n temp *= 10\n }\n } else {\n count += p3\n \n var temp = 10\n while (temp <= p2) {\n count += temp\n temp *= 10\n }\n if (sentou <= bottom) {\n count += 1\n }\n }\n\n\n if ((matubi.toString() + sentou.toString()).toInt() < n) {\n count += 1\n }\n\n if (sentou == matubi) {\n count += 1\n }\n }\n\n print(count)\n\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1456, "cpu_time_ms": 471, "memory_kb": 50852}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s059256239", "group_id": "codeNet:p02796", "input_text": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val n = sc.nextInt()\n val xl = (0 until n).map { sc.next().toLong() to sc.next().toLong() }\n println(problem2020b(n, xl))\n}\n\nfun problem2020b(n: Int, xl: List>): Int {\n val xl = xl.sortedBy { it.first }\n var count = 0\n var removedCount = 0\n for (i in 1 until n) {\n val prev = xl[i - 1 - removedCount].first + xl[i - 1 - removedCount].second\n val current = xl[i].first - xl[i].second\n if (prev > current) {\n count++\n removedCount++\n } else {\n removedCount = 0\n }\n }\n return n - count\n}", "language": "Kotlin", "metadata": {"date": 1579378656, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02796.html", "problem_id": "p02796", "resource_group": "medium_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/Kotlin/s059256239.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s059256239", "user_id": "u073232808"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val n = sc.nextInt()\n val xl = (0 until n).map { sc.next().toLong() to sc.next().toLong() }\n println(problem2020b(n, xl))\n}\n\nfun problem2020b(n: Int, xl: List>): Int {\n val xl = xl.sortedBy { it.first }\n var count = 0\n var removedCount = 0\n for (i in 1 until n) {\n val prev = xl[i - 1 - removedCount].first + xl[i - 1 - removedCount].second\n val current = xl[i].first - xl[i].second\n if (prev > current) {\n count++\n removedCount++\n } else {\n removedCount = 0\n }\n }\n return n - count\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 683, "cpu_time_ms": 898, "memory_kb": 89316}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s776647566", "group_id": "codeNet:p02797", "input_text": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val n = sc.nextInt()\n val k = sc.nextInt()\n val s = sc.nextLong()\n\n\n val list = mutableListOf()\n for (i in 0 until n) {\n if (i < k) {\n list.add(s)\n } else {\n list.add(s+1)\n }\n }\n\n println(list.joinToString(\" \"))\n\n}", "language": "Kotlin", "metadata": {"date": 1597517672, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02797.html", "problem_id": "p02797", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02797/input.txt", "sample_output_relpath": "derived/input_output/data/p02797/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02797/Kotlin/s776647566.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s776647566", "user_id": "u323522006"}, "prompt_components": {"gold_output": "1 2 3 4\n", "input_to_evaluate": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val n = sc.nextInt()\n val k = sc.nextInt()\n val s = sc.nextLong()\n\n\n val list = mutableListOf()\n for (i in 0 until n) {\n if (i < k) {\n list.add(s)\n } else {\n list.add(s+1)\n }\n }\n\n println(list.joinToString(\" \"))\n\n}", "problem_context": "Score : 400 points\n\nProblem Statement\n\nGiven are three integers N, K, and S.\n\nFind a sequence A_1, A_2, ..., A_N of N integers between 1 and 10^9 (inclusive) that satisfies the condition below.\nWe can prove that, under the conditions in Constraints, such a sequence always exists.\n\nThere are exactly K pairs (l, r) of integers such that 1 \\leq l \\leq r \\leq N and A_l + A_{l + 1} + \\cdots + A_r = S.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n0 \\leq K \\leq N\n\n1 \\leq S \\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 S\n\nOutput\n\nPrint a sequence satisfying the condition, in the following format:\n\nA_1 A_2 ... A_N\n\nSample Input 1\n\n4 2 3\n\nSample Output 1\n\n1 2 3 4\n\nTwo pairs (l, r) = (1, 2) and (3, 3) satisfy the condition in the statement.\n\nSample Input 2\n\n5 3 100\n\nSample Output 2\n\n50 50 50 30 70", "sample_input": "4 2 3\n"}, "reference_outputs": ["1 2 3 4\n"], "source_document_id": "p02797", "source_text": "Score : 400 points\n\nProblem Statement\n\nGiven are three integers N, K, and S.\n\nFind a sequence A_1, A_2, ..., A_N of N integers between 1 and 10^9 (inclusive) that satisfies the condition below.\nWe can prove that, under the conditions in Constraints, such a sequence always exists.\n\nThere are exactly K pairs (l, r) of integers such that 1 \\leq l \\leq r \\leq N and A_l + A_{l + 1} + \\cdots + A_r = S.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n0 \\leq K \\leq N\n\n1 \\leq S \\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 S\n\nOutput\n\nPrint a sequence satisfying the condition, in the following format:\n\nA_1 A_2 ... A_N\n\nSample Input 1\n\n4 2 3\n\nSample Output 1\n\n1 2 3 4\n\nTwo pairs (l, r) = (1, 2) and (3, 3) satisfy the condition in the statement.\n\nSample Input 2\n\n5 3 100\n\nSample Output 2\n\n50 50 50 30 70", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 244, "memory_kb": 53588}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s265011674", "group_id": "codeNet:p02798", "input_text": "import kotlin.system.exitProcess\nvar A: List = emptyList()\nvar B: List = emptyList()\nvar L: List = emptyList()\nvar ANS: Int = 0\nfun main(args: Array) {\n val N = nextInt()\n A = listOfInt()\n B = listOfInt()\n L = (0 .. (N-1)).map { it }\n ANS = Int.MAX_VALUE\n permutation(L, emptyList())\n println(if (ANS == Int.MAX_VALUE) -1 else ANS - 1)\n}\nfun next() = readLine()!!\nfun nextInt(delta: Int = 0) = Integer.parseInt(next()) + delta\nfun listOfString() = next().split(\" \")\nfun listOfInt(delta: Int = 0) = listOfString().map { Integer.parseInt(it) + delta }\nfun make(ans: List) {\n var n = 0\n val a = Array(ans.size) {\n if (it == ans[it]) {\n A[it]\n } else {\n n += 1\n if (Math.abs(it - ans[it]) % 2 == 0) A[ans[it]] else B[ans[it]]\n }\n }\n var max = Int.MIN_VALUE\n val bood = a.all { if (max <= it) {\n max = it\n true\n } else false\n }\n if (bood) {\n if (n == 0) {\n println(0)\n exitProcess(0)\n }\n if (ANS > n) ANS = n\n }\n}\nfun permutation(q: List, ans: List) {\n if (q.size <= 1) {\n //println(ans + q)\n make(ans + q)\n } else {\n for (i in 0 until q.size) {\n permutation(\n q.subList(0, i) + q.subList(i + 1, q.size),\n ans + q[i]\n )\n }\n }\n}", "language": "Kotlin", "metadata": {"date": 1579422716, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02798.html", "problem_id": "p02798", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02798/input.txt", "sample_output_relpath": "derived/input_output/data/p02798/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02798/Kotlin/s265011674.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s265011674", "user_id": "u043150661"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "import kotlin.system.exitProcess\nvar A: List = emptyList()\nvar B: List = emptyList()\nvar L: List = emptyList()\nvar ANS: Int = 0\nfun main(args: Array) {\n val N = nextInt()\n A = listOfInt()\n B = listOfInt()\n L = (0 .. (N-1)).map { it }\n ANS = Int.MAX_VALUE\n permutation(L, emptyList())\n println(if (ANS == Int.MAX_VALUE) -1 else ANS - 1)\n}\nfun next() = readLine()!!\nfun nextInt(delta: Int = 0) = Integer.parseInt(next()) + delta\nfun listOfString() = next().split(\" \")\nfun listOfInt(delta: Int = 0) = listOfString().map { Integer.parseInt(it) + delta }\nfun make(ans: List) {\n var n = 0\n val a = Array(ans.size) {\n if (it == ans[it]) {\n A[it]\n } else {\n n += 1\n if (Math.abs(it - ans[it]) % 2 == 0) A[ans[it]] else B[ans[it]]\n }\n }\n var max = Int.MIN_VALUE\n val bood = a.all { if (max <= it) {\n max = it\n true\n } else false\n }\n if (bood) {\n if (n == 0) {\n println(0)\n exitProcess(0)\n }\n if (ANS > n) ANS = n\n }\n}\nfun permutation(q: List, ans: List) {\n if (q.size <= 1) {\n //println(ans + q)\n make(ans + q)\n } else {\n for (i in 0 until q.size) {\n permutation(\n q.subList(0, i) + q.subList(i + 1, q.size),\n ans + q[i]\n )\n }\n }\n}", "problem_context": "Score : 700 points\n\nProblem Statement\n\nWe have N cards numbered 1, 2, ..., N.\nCard i (1 \\leq i \\leq N) has an integer A_i written in red ink on one side and an integer B_i written in blue ink on the other side.\nInitially, these cards are arranged from left to right in the order from Card 1 to Card N, with the red numbers facing up.\n\nDetermine whether it is possible to have a non-decreasing sequence facing up from left to right (that is, for each i (1 \\leq i \\leq N - 1), the integer facing up on the (i+1)-th card from the left is not less than the integer facing up on the i-th card from the left) by repeating the operation below. If the answer is yes, find the minimum number of operations required to achieve it.\n\nChoose an integer i (1 \\leq i \\leq N - 1).\nSwap the i-th and (i+1)-th cards from the left, then flip these two cards.\n\nConstraints\n\n1 \\leq N \\leq 18\n\n1 \\leq A_i, B_i \\leq 50 (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\nA_1 A_2 ... A_N\nB_1 B_2 ... B_N\n\nOutput\n\nIf it is impossible to have a non-decreasing sequence, print -1.\nIf it is possible, print the minimum number of operations required to achieve it.\n\nSample Input 1\n\n3\n3 4 3\n3 2 3\n\nSample Output 1\n\n1\n\nBy doing the operation once with i = 1, we have a sequence [2, 3, 3] facing up, which is non-decreasing.\n\nSample Input 2\n\n2\n2 1\n1 2\n\nSample Output 2\n\n-1\n\nAfter any number of operations, we have the sequence [2, 1] facing up, which is not non-decreasing.\n\nSample Input 3\n\n4\n1 2 3 4\n5 6 7 8\n\nSample Output 3\n\n0\n\nNo operation may be required.\n\nSample Input 4\n\n5\n28 15 22 43 31\n20 22 43 33 32\n\nSample Output 4\n\n-1\n\nSample Input 5\n\n5\n4 46 6 38 43\n33 15 18 27 37\n\nSample Output 5\n\n3", "sample_input": "3\n3 4 3\n3 2 3\n"}, "reference_outputs": ["1\n"], "source_document_id": "p02798", "source_text": "Score : 700 points\n\nProblem Statement\n\nWe have N cards numbered 1, 2, ..., N.\nCard i (1 \\leq i \\leq N) has an integer A_i written in red ink on one side and an integer B_i written in blue ink on the other side.\nInitially, these cards are arranged from left to right in the order from Card 1 to Card N, with the red numbers facing up.\n\nDetermine whether it is possible to have a non-decreasing sequence facing up from left to right (that is, for each i (1 \\leq i \\leq N - 1), the integer facing up on the (i+1)-th card from the left is not less than the integer facing up on the i-th card from the left) by repeating the operation below. If the answer is yes, find the minimum number of operations required to achieve it.\n\nChoose an integer i (1 \\leq i \\leq N - 1).\nSwap the i-th and (i+1)-th cards from the left, then flip these two cards.\n\nConstraints\n\n1 \\leq N \\leq 18\n\n1 \\leq A_i, B_i \\leq 50 (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\nA_1 A_2 ... A_N\nB_1 B_2 ... B_N\n\nOutput\n\nIf it is impossible to have a non-decreasing sequence, print -1.\nIf it is possible, print the minimum number of operations required to achieve it.\n\nSample Input 1\n\n3\n3 4 3\n3 2 3\n\nSample Output 1\n\n1\n\nBy doing the operation once with i = 1, we have a sequence [2, 3, 3] facing up, which is non-decreasing.\n\nSample Input 2\n\n2\n2 1\n1 2\n\nSample Output 2\n\n-1\n\nAfter any number of operations, we have the sequence [2, 1] facing up, which is not non-decreasing.\n\nSample Input 3\n\n4\n1 2 3 4\n5 6 7 8\n\nSample Output 3\n\n0\n\nNo operation may be required.\n\nSample Input 4\n\n5\n28 15 22 43 31\n20 22 43 33 32\n\nSample Output 4\n\n-1\n\nSample Input 5\n\n5\n4 46 6 38 43\n33 15 18 27 37\n\nSample Output 5\n\n3", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 2111, "memory_kb": 130724}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s321525246", "group_id": "codeNet:p02798", "input_text": "import java.util.*\n\nfun main(args: Array) {\n keyence2020d()\n}\n\nfun keyence2020d() {\n val n = readLine()!!.toInt()\n val aList = readLine()!!.split(' ').map { it.toInt() }.toIntArray()\n val bList = readLine()!!.split(' ').map { it.toInt() }.toIntArray()\n\n val inf = Int.MAX_VALUE / 10\n var answer = inf\n\n for (i in 0L until (1L shl (n - 1))) {\n val bitSet = BitSet.valueOf(longArrayOf(i))\n val front = aList.copyOf()\n val back = bList.copyOf()\n\n (0 until n - 1).forEach {\n if (bitSet[it]) {\n val tempFront = front[it]\n val tempBack = back[it]\n front[it] = back[it + 1]\n back[it] = front[it + 1]\n front[it + 1] = tempBack\n back[it + 1] = tempFront\n }\n }\n\n if ((0 until n - 1).all { front[it] <= front[it + 1] }) {\n answer = Math.min(answer, bitSet.cardinality())\n }\n }\n\n if (answer == inf) answer = -1\n\n println(answer)\n}\n", "language": "Kotlin", "metadata": {"date": 1579382636, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02798.html", "problem_id": "p02798", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02798/input.txt", "sample_output_relpath": "derived/input_output/data/p02798/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02798/Kotlin/s321525246.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s321525246", "user_id": "u139478771"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "import java.util.*\n\nfun main(args: Array) {\n keyence2020d()\n}\n\nfun keyence2020d() {\n val n = readLine()!!.toInt()\n val aList = readLine()!!.split(' ').map { it.toInt() }.toIntArray()\n val bList = readLine()!!.split(' ').map { it.toInt() }.toIntArray()\n\n val inf = Int.MAX_VALUE / 10\n var answer = inf\n\n for (i in 0L until (1L shl (n - 1))) {\n val bitSet = BitSet.valueOf(longArrayOf(i))\n val front = aList.copyOf()\n val back = bList.copyOf()\n\n (0 until n - 1).forEach {\n if (bitSet[it]) {\n val tempFront = front[it]\n val tempBack = back[it]\n front[it] = back[it + 1]\n back[it] = front[it + 1]\n front[it + 1] = tempBack\n back[it + 1] = tempFront\n }\n }\n\n if ((0 until n - 1).all { front[it] <= front[it + 1] }) {\n answer = Math.min(answer, bitSet.cardinality())\n }\n }\n\n if (answer == inf) answer = -1\n\n println(answer)\n}\n", "problem_context": "Score : 700 points\n\nProblem Statement\n\nWe have N cards numbered 1, 2, ..., N.\nCard i (1 \\leq i \\leq N) has an integer A_i written in red ink on one side and an integer B_i written in blue ink on the other side.\nInitially, these cards are arranged from left to right in the order from Card 1 to Card N, with the red numbers facing up.\n\nDetermine whether it is possible to have a non-decreasing sequence facing up from left to right (that is, for each i (1 \\leq i \\leq N - 1), the integer facing up on the (i+1)-th card from the left is not less than the integer facing up on the i-th card from the left) by repeating the operation below. If the answer is yes, find the minimum number of operations required to achieve it.\n\nChoose an integer i (1 \\leq i \\leq N - 1).\nSwap the i-th and (i+1)-th cards from the left, then flip these two cards.\n\nConstraints\n\n1 \\leq N \\leq 18\n\n1 \\leq A_i, B_i \\leq 50 (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\nA_1 A_2 ... A_N\nB_1 B_2 ... B_N\n\nOutput\n\nIf it is impossible to have a non-decreasing sequence, print -1.\nIf it is possible, print the minimum number of operations required to achieve it.\n\nSample Input 1\n\n3\n3 4 3\n3 2 3\n\nSample Output 1\n\n1\n\nBy doing the operation once with i = 1, we have a sequence [2, 3, 3] facing up, which is non-decreasing.\n\nSample Input 2\n\n2\n2 1\n1 2\n\nSample Output 2\n\n-1\n\nAfter any number of operations, we have the sequence [2, 1] facing up, which is not non-decreasing.\n\nSample Input 3\n\n4\n1 2 3 4\n5 6 7 8\n\nSample Output 3\n\n0\n\nNo operation may be required.\n\nSample Input 4\n\n5\n28 15 22 43 31\n20 22 43 33 32\n\nSample Output 4\n\n-1\n\nSample Input 5\n\n5\n4 46 6 38 43\n33 15 18 27 37\n\nSample Output 5\n\n3", "sample_input": "3\n3 4 3\n3 2 3\n"}, "reference_outputs": ["1\n"], "source_document_id": "p02798", "source_text": "Score : 700 points\n\nProblem Statement\n\nWe have N cards numbered 1, 2, ..., N.\nCard i (1 \\leq i \\leq N) has an integer A_i written in red ink on one side and an integer B_i written in blue ink on the other side.\nInitially, these cards are arranged from left to right in the order from Card 1 to Card N, with the red numbers facing up.\n\nDetermine whether it is possible to have a non-decreasing sequence facing up from left to right (that is, for each i (1 \\leq i \\leq N - 1), the integer facing up on the (i+1)-th card from the left is not less than the integer facing up on the i-th card from the left) by repeating the operation below. If the answer is yes, find the minimum number of operations required to achieve it.\n\nChoose an integer i (1 \\leq i \\leq N - 1).\nSwap the i-th and (i+1)-th cards from the left, then flip these two cards.\n\nConstraints\n\n1 \\leq N \\leq 18\n\n1 \\leq A_i, B_i \\leq 50 (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\nA_1 A_2 ... A_N\nB_1 B_2 ... B_N\n\nOutput\n\nIf it is impossible to have a non-decreasing sequence, print -1.\nIf it is possible, print the minimum number of operations required to achieve it.\n\nSample Input 1\n\n3\n3 4 3\n3 2 3\n\nSample Output 1\n\n1\n\nBy doing the operation once with i = 1, we have a sequence [2, 3, 3] facing up, which is non-decreasing.\n\nSample Input 2\n\n2\n2 1\n1 2\n\nSample Output 2\n\n-1\n\nAfter any number of operations, we have the sequence [2, 1] facing up, which is not non-decreasing.\n\nSample Input 3\n\n4\n1 2 3 4\n5 6 7 8\n\nSample Output 3\n\n0\n\nNo operation may be required.\n\nSample Input 4\n\n5\n28 15 22 43 31\n20 22 43 33 32\n\nSample Output 4\n\n-1\n\nSample Input 5\n\n5\n4 46 6 38 43\n33 15 18 27 37\n\nSample Output 5\n\n3", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 362, "memory_kb": 50316}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s439662689", "group_id": "codeNet:p02801", "input_text": "fun main(args:Array){\n val a=readLine()!!\n val b=\"abcdefghijklmnopqrstuvwxyz\"\n for (i in 0..25){\n if (a == b[i].toString()){\n println(\"${b[i+1]}\")\n }\n }\n}", "language": "Kotlin", "metadata": {"date": 1586858551, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02801.html", "problem_id": "p02801", "resource_group": "medium_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/Kotlin/s439662689.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s439662689", "user_id": "u387080888"}, "prompt_components": {"gold_output": "b\n", "input_to_evaluate": "fun main(args:Array){\n val a=readLine()!!\n val b=\"abcdefghijklmnopqrstuvwxyz\"\n for (i in 0..25){\n if (a == b[i].toString()){\n println(\"${b[i+1]}\")\n }\n }\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 204, "memory_kb": 31832}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s364194607", "group_id": "codeNet:p02801", "input_text": "fun main(s:Array){println(readLine()!![0].toChar()+1)}", "language": "Kotlin", "metadata": {"date": 1580252045, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02801.html", "problem_id": "p02801", "resource_group": "medium_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/Kotlin/s364194607.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s364194607", "user_id": "u370564845"}, "prompt_components": {"gold_output": "b\n", "input_to_evaluate": "fun main(s:Array){println(readLine()!![0].toChar()+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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 199, "memory_kb": 31768}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s138187602", "group_id": "codeNet:p02802", "input_text": "import java.util.HashSet;\nimport java.util.Scanner;\n\nfun main (args : Array ) {\n val input = Scanner(System.`in`)\n \n while (input.hasNext()) {\n val N = input.nextInt()\n val M = input.nextInt()\n val penalty = IntArray(N + 1)\n val ACProb = HashSet()\n \n for (i in 1..M) {\n val p = input.nextInt()\n val S = input.next()\n \n if (S.equals(\"WA\") && ACProb.contains(p) == false) {\n ++penalty[p]\n } else if (S.equals(\"AC\")) {\n ACProb.add(p)\n }\n }\n \n println(\"${ACProb.size} ${penalty.sum()}\")\n }\n}", "language": "Kotlin", "metadata": {"date": 1596594653, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02802.html", "problem_id": "p02802", "resource_group": "medium_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/Kotlin/s138187602.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s138187602", "user_id": "u920836104"}, "prompt_components": {"gold_output": "2 2\n", "input_to_evaluate": "import java.util.HashSet;\nimport java.util.Scanner;\n\nfun main (args : Array ) {\n val input = Scanner(System.`in`)\n \n while (input.hasNext()) {\n val N = input.nextInt()\n val M = input.nextInt()\n val penalty = IntArray(N + 1)\n val ACProb = HashSet()\n \n for (i in 1..M) {\n val p = input.nextInt()\n val S = input.next()\n \n if (S.equals(\"WA\") && ACProb.contains(p) == false) {\n ++penalty[p]\n } else if (S.equals(\"AC\")) {\n ACProb.add(p)\n }\n }\n \n println(\"${ACProb.size} ${penalty.sum()}\")\n }\n}", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 575, "cpu_time_ms": 554, "memory_kb": 67560}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s698795274", "group_id": "codeNet:p02802", "input_text": "fun main(args: Array) {\n data class Submit(val n: Int, val result: String)\n val (n, m) = readLine()?.split(\" \")?.map(String::toInt) ?: return\n 0.until(m)\n .map {\n readLine()?.split(\" \")?.let {\n Submit(it[0].toInt(), it[1])\n } ?: return\n }\n .groupBy { it.n }\n .map {\n val submitList = it.value\n Pair(\n // AC\n if (submitList.any { it.result == \"AC\" }) {\n 1\n } else {\n 0\n },\n // WA\n submitList.indexOfFirst { it.result == \"AC\" }.let {\n if (it == -1) {\n 0\n } else {\n it\n }\n }\n )\n }\n .let {\n println(\"${it.sumBy { it.first }} ${it.sumBy { it.second }}\")\n }\n}\n\n", "language": "Kotlin", "metadata": {"date": 1586220933, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02802.html", "problem_id": "p02802", "resource_group": "medium_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/Kotlin/s698795274.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s698795274", "user_id": "u979429407"}, "prompt_components": {"gold_output": "2 2\n", "input_to_evaluate": "fun main(args: Array) {\n data class Submit(val n: Int, val result: String)\n val (n, m) = readLine()?.split(\" \")?.map(String::toInt) ?: return\n 0.until(m)\n .map {\n readLine()?.split(\" \")?.let {\n Submit(it[0].toInt(), it[1])\n } ?: return\n }\n .groupBy { it.n }\n .map {\n val submitList = it.value\n Pair(\n // AC\n if (submitList.any { it.result == \"AC\" }) {\n 1\n } else {\n 0\n },\n // WA\n submitList.indexOfFirst { it.result == \"AC\" }.let {\n if (it == -1) {\n 0\n } else {\n it\n }\n }\n )\n }\n .let {\n println(\"${it.sumBy { it.first }} ${it.sumBy { it.second }}\")\n }\n}\n\n", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 948, "cpu_time_ms": 775, "memory_kb": 64752}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s584139547", "group_id": "codeNet:p02802", "input_text": "import java.util.*\n\nfun main(args: Array) {\n val scn = Scanner(System.`in`)\n val N = scn.nextInt()\n val M = scn.nextInt()\n\n var WA = 0\n var AC = 0\n //var answer = mutableListOf()\n var answer = Array(N,{0})\n\n for(i in 1 .. M){\n var p = scn.nextInt()\n val S = scn.next()\n\n if(p>N) continue\n\n if(S==\"AC\" && answer[p-1]==0){\n AC++\n answer[p-1] = 1\n }else if(S==\"WA\" && answer[p-1]==0){\n WA++\n }\n }\n\n println(\"$AC $WA\")\n}", "language": "Kotlin", "metadata": {"date": 1578884966, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02802.html", "problem_id": "p02802", "resource_group": "medium_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/Kotlin/s584139547.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s584139547", "user_id": "u598554142"}, "prompt_components": {"gold_output": "2 2\n", "input_to_evaluate": "import java.util.*\n\nfun main(args: Array) {\n val scn = Scanner(System.`in`)\n val N = scn.nextInt()\n val M = scn.nextInt()\n\n var WA = 0\n var AC = 0\n //var answer = mutableListOf()\n var answer = Array(N,{0})\n\n for(i in 1 .. M){\n var p = scn.nextInt()\n val S = scn.next()\n\n if(p>N) continue\n\n if(S==\"AC\" && answer[p-1]==0){\n AC++\n answer[p-1] = 1\n }else if(S==\"WA\" && answer[p-1]==0){\n WA++\n }\n }\n\n println(\"$AC $WA\")\n}", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 550, "memory_kb": 68132}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s957334497", "group_id": "codeNet:p02802", "input_text": "fun main(args: Array) {\n val (n, m) = readLine()!!.split(' ').map(String::toInt)\n val psList = mutableListOf>()\n (1..m).forEach {\n val (p, s) = readLine()!!.split(' ')\n psList.add(Pair(p.toInt(), s))\n }\n psList.sortBy { it.first }\n val acList = IntArray(n+1){0}\n val waList = IntArray(n+1){0}\n for(i in 0 until m){\n val (p,s) = psList[i]\n if(s==\"AC\" && acList[p]==0){\n acList[p]=1\n }\n if(s ==\"WA\" && acList[p]==0){\n waList[p]++\n }\n }\n\n var acCount = 0L\n var waCount = 0L\n for(i in 1..n){\n if(acList[i]>0){\n acCount++\n waCount+=waList[i]\n }\n }\n println(\"$acCount $waCount\")\n}", "language": "Kotlin", "metadata": {"date": 1578882373, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02802.html", "problem_id": "p02802", "resource_group": "medium_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/Kotlin/s957334497.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s957334497", "user_id": "u099066216"}, "prompt_components": {"gold_output": "2 2\n", "input_to_evaluate": "fun main(args: Array) {\n val (n, m) = readLine()!!.split(' ').map(String::toInt)\n val psList = mutableListOf>()\n (1..m).forEach {\n val (p, s) = readLine()!!.split(' ')\n psList.add(Pair(p.toInt(), s))\n }\n psList.sortBy { it.first }\n val acList = IntArray(n+1){0}\n val waList = IntArray(n+1){0}\n for(i in 0 until m){\n val (p,s) = psList[i]\n if(s==\"AC\" && acList[p]==0){\n acList[p]=1\n }\n if(s ==\"WA\" && acList[p]==0){\n waList[p]++\n }\n }\n\n var acCount = 0L\n var waCount = 0L\n for(i in 1..n){\n if(acList[i]>0){\n acCount++\n waCount+=waList[i]\n }\n }\n println(\"$acCount $waCount\")\n}", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 889, "memory_kb": 80384}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s565085452", "group_id": "codeNet:p02803", "input_text": "fun main(args: Array) {\n val dx = listOf(1, 0, -1, 0)\n val dy = listOf(0, 1, 0, -1)\n val (H, W) = listOfInt()\n val maze = Array(H) { next() }\n fun dfs(sh: Int, sw: Int): Int {\n var result = 0\n var Q = Queue>()\n var visit = Array(H) { IntArray(W) { -1 } }\n Q.enqueue(Triple(sh, sw, 0))\n visit[sh][sw] = 0\n while (!Q.isEmpty()) {\n val (h, w, k) = Q.dequeue()!!\n visit[h][w] = k\n if (result < k) result = k\n for (n in 0 .. 3) {\n val nh = h + dx[n]\n val nw = w + dy[n]\n if (nh < 0 || nh >= H || nw < 0 || nw >= W) continue\n if (maze[nh][nw] == '#') continue\n if (visit[nh][nw] != -1) continue\n Q.enqueue(Triple(nh, nw, k + 1))\n }\n }\n return result\n }\n var ans = 0\n for (h in 0 until H) {\n for (w in 0 until W) {\n if (maze[h][w] == '#') continue\n ans = Math.max(ans, dfs(h, w))\n }\n }\n println(ans)\n}\nfun next() = readLine()!!\nfun listOfString() = next().split(\" \")\nfun listOfInt(delta: Int = 0) = listOfString().map { Integer.parseInt(it) + delta }\nclass Queue {\n val elements = mutableListOf()\n fun isEmpty() = elements.isEmpty()\n fun enqueue(item: T) = elements.add(item)\n fun dequeue() = if (!isEmpty()) elements.removeAt(0) else null\n override fun toString(): String = elements.toString()\n}", "language": "Kotlin", "metadata": {"date": 1579132316, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02803.html", "problem_id": "p02803", "resource_group": "medium_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/Kotlin/s565085452.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s565085452", "user_id": "u043150661"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "fun main(args: Array) {\n val dx = listOf(1, 0, -1, 0)\n val dy = listOf(0, 1, 0, -1)\n val (H, W) = listOfInt()\n val maze = Array(H) { next() }\n fun dfs(sh: Int, sw: Int): Int {\n var result = 0\n var Q = Queue>()\n var visit = Array(H) { IntArray(W) { -1 } }\n Q.enqueue(Triple(sh, sw, 0))\n visit[sh][sw] = 0\n while (!Q.isEmpty()) {\n val (h, w, k) = Q.dequeue()!!\n visit[h][w] = k\n if (result < k) result = k\n for (n in 0 .. 3) {\n val nh = h + dx[n]\n val nw = w + dy[n]\n if (nh < 0 || nh >= H || nw < 0 || nw >= W) continue\n if (maze[nh][nw] == '#') continue\n if (visit[nh][nw] != -1) continue\n Q.enqueue(Triple(nh, nw, k + 1))\n }\n }\n return result\n }\n var ans = 0\n for (h in 0 until H) {\n for (w in 0 until W) {\n if (maze[h][w] == '#') continue\n ans = Math.max(ans, dfs(h, w))\n }\n }\n println(ans)\n}\nfun next() = readLine()!!\nfun listOfString() = next().split(\" \")\nfun listOfInt(delta: Int = 0) = listOfString().map { Integer.parseInt(it) + delta }\nclass Queue {\n val elements = mutableListOf()\n fun isEmpty() = elements.isEmpty()\n fun enqueue(item: T) = elements.add(item)\n fun dequeue() = if (!isEmpty()) elements.removeAt(0) else null\n override fun toString(): String = elements.toString()\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1525, "cpu_time_ms": 2111, "memory_kb": 40128}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s156081476", "group_id": "codeNet:p02804", "input_text": "import java.io.*\nimport java.util.*\n\nconst val MOD = 1000000007L\nfun solve(N: Int, K: Int, A: LongArray) {\n // Sum[i in 0..N-1, j in i+k..N-1](Aj - Ai) * j-i-1 C k-2\n // j-i=pを固定する p in k..N-k-1\n if (K == 1) {\n println(0)\n return\n }\n A.sort()\n val accSum = A.toList().scanLeft(0L) { a, b -> a + b }.toList()\n val invs = calcModInvs(N, MOD)\n val binomials = LongArray(N) // i C K-2\n binomials[K - 2] = 1L\n for (i in K - 1 until N) {\n // i C k - 2 = i-1 C k-2 * i/(i - k + 2)\n binomials[i] = (((binomials[i - 1] * i) % MOD) * invs[i - K + 2]) % MOD\n }\n // println(invs.toList())\n // println(binomials.toList())\n var ans = 0L\n for (p in K - 1 until N) {\n val ret = ((accSum[N - 1] - accSum.getOrElse(p - 1) { 0L } - accSum.getOrElse(N - p - 1) { 0L }) % MOD) * binomials[p - 1]\n ans = (ans + ret % MOD) % MOD\n }\n println(ans)\n return\n}\n\nfun calcModInvs(num: Int, mod: Long): LongArray {\n // num以下のmodで割った余りの逆元を計算\n val invs = LongArray(num + 1)\n invs[1] = 1L\n for (i in 2L..num.toLong()) {\n invs[i.toInt()] = (invs[(mod % i).toInt()] * (mod - mod / i)) % mod\n }\n return invs\n}\n\nfun Iterable.scanLeft(initial: R, operation: (acc: R, T) -> R): Sequence {\n var last = initial\n return this.asSequence().map { last = operation(last, it); last }\n}\nfun Long.modPow(x: Long, mod: Long): Long {\n // this ^ x % mod\n tailrec fun binModPow(a: Long, exp: Long): Long = when (exp) {\n // a ^ (2^(exp)) % mod\n 0L -> a % mod\n else -> binModPow(a * a % mod, exp - 1)\n }\n return (0..63).asSequence()\n .map { (x shr it) and 1 }\n .withIndex()\n .filter { it.value > 0 }\n .map { binModPow(this, it.index.toLong()) }\n .reduce { a, b -> a * b % mod }\n}\n\n// 1 / x % mod (x ⊥ mod)\nfun Long.modInv(mod: Long): Long = this.modPow(mod - 2, mod)\n\nfun binomialMod(n: Int, k: Int, mod: Long): Long = when (k) {\n // nCk % mod\n 0, n -> 1L\n else -> {\n val numer = (n downTo n - k + 1)\n .map { it.toLong() }\n .reduce { a, b -> (a * b) % mod }\n val denom = (1..k)\n .map { it.toLong() }\n .reduce { a, b -> (a * b) % mod }\n (numer * denom.modInv(mod)) % mod\n }\n}\n\nfun main(args: Array) {\n fun StringArray(size: Int, init: (Int) -> String = { \"\\u0000\" }): Array {\n return Array(size, init)\n }\n class Scanner(stream: InputStream) {\n private val reader = BufferedInputStream(stream).bufferedReader()\n private var st: StringTokenizer? = null\n fun next(): String {\n while (!(st?.hasMoreTokens() ?: false)) st = StringTokenizer(reader.readLine())\n return st!!.nextToken()\n }\n }\n val sc = Scanner(System.`in`)\n val N = sc.next().toInt()\n val K = sc.next().toInt()\n val A = LongArray(N.toInt())\n for (i in 0 until N.toInt()) {\n A[i] = sc.next().toLong()\n }\n solve(N, K, A)\n}\n", "language": "Kotlin", "metadata": {"date": 1579132051, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02804.html", "problem_id": "p02804", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02804/input.txt", "sample_output_relpath": "derived/input_output/data/p02804/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02804/Kotlin/s156081476.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s156081476", "user_id": "u329232967"}, "prompt_components": {"gold_output": "11\n", "input_to_evaluate": "import java.io.*\nimport java.util.*\n\nconst val MOD = 1000000007L\nfun solve(N: Int, K: Int, A: LongArray) {\n // Sum[i in 0..N-1, j in i+k..N-1](Aj - Ai) * j-i-1 C k-2\n // j-i=pを固定する p in k..N-k-1\n if (K == 1) {\n println(0)\n return\n }\n A.sort()\n val accSum = A.toList().scanLeft(0L) { a, b -> a + b }.toList()\n val invs = calcModInvs(N, MOD)\n val binomials = LongArray(N) // i C K-2\n binomials[K - 2] = 1L\n for (i in K - 1 until N) {\n // i C k - 2 = i-1 C k-2 * i/(i - k + 2)\n binomials[i] = (((binomials[i - 1] * i) % MOD) * invs[i - K + 2]) % MOD\n }\n // println(invs.toList())\n // println(binomials.toList())\n var ans = 0L\n for (p in K - 1 until N) {\n val ret = ((accSum[N - 1] - accSum.getOrElse(p - 1) { 0L } - accSum.getOrElse(N - p - 1) { 0L }) % MOD) * binomials[p - 1]\n ans = (ans + ret % MOD) % MOD\n }\n println(ans)\n return\n}\n\nfun calcModInvs(num: Int, mod: Long): LongArray {\n // num以下のmodで割った余りの逆元を計算\n val invs = LongArray(num + 1)\n invs[1] = 1L\n for (i in 2L..num.toLong()) {\n invs[i.toInt()] = (invs[(mod % i).toInt()] * (mod - mod / i)) % mod\n }\n return invs\n}\n\nfun Iterable.scanLeft(initial: R, operation: (acc: R, T) -> R): Sequence {\n var last = initial\n return this.asSequence().map { last = operation(last, it); last }\n}\nfun Long.modPow(x: Long, mod: Long): Long {\n // this ^ x % mod\n tailrec fun binModPow(a: Long, exp: Long): Long = when (exp) {\n // a ^ (2^(exp)) % mod\n 0L -> a % mod\n else -> binModPow(a * a % mod, exp - 1)\n }\n return (0..63).asSequence()\n .map { (x shr it) and 1 }\n .withIndex()\n .filter { it.value > 0 }\n .map { binModPow(this, it.index.toLong()) }\n .reduce { a, b -> a * b % mod }\n}\n\n// 1 / x % mod (x ⊥ mod)\nfun Long.modInv(mod: Long): Long = this.modPow(mod - 2, mod)\n\nfun binomialMod(n: Int, k: Int, mod: Long): Long = when (k) {\n // nCk % mod\n 0, n -> 1L\n else -> {\n val numer = (n downTo n - k + 1)\n .map { it.toLong() }\n .reduce { a, b -> (a * b) % mod }\n val denom = (1..k)\n .map { it.toLong() }\n .reduce { a, b -> (a * b) % mod }\n (numer * denom.modInv(mod)) % mod\n }\n}\n\nfun main(args: Array) {\n fun StringArray(size: Int, init: (Int) -> String = { \"\\u0000\" }): Array {\n return Array(size, init)\n }\n class Scanner(stream: InputStream) {\n private val reader = BufferedInputStream(stream).bufferedReader()\n private var st: StringTokenizer? = null\n fun next(): String {\n while (!(st?.hasMoreTokens() ?: false)) st = StringTokenizer(reader.readLine())\n return st!!.nextToken()\n }\n }\n val sc = Scanner(System.`in`)\n val N = sc.next().toInt()\n val K = sc.next().toInt()\n val A = LongArray(N.toInt())\n for (i in 0 until N.toInt()) {\n A[i] = sc.next().toLong()\n }\n solve(N, K, A)\n}\n", "problem_context": "Score : 500 points\n\nProblem Statement\n\nFor a finite set of integers X, let f(X)=\\max X - \\min X.\n\nGiven are N integers A_1,...,A_N.\n\nWe will choose K of them and let S be the set of the integers chosen. If we distinguish elements with different indices even when their values are the same, there are {}_N C_K ways to make this choice. Find the sum of f(S) over all those ways.\n\nSince the answer can be enormous, print it \\bmod (10^9+7).\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n1 \\leq K \\leq N\n\n|A_i| \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nA_1 ... A_N\n\nOutput\n\nPrint the answer \\bmod (10^9+7).\n\nSample Input 1\n\n4 2\n1 1 3 4\n\nSample Output 1\n\n11\n\nThere are six ways to choose S: \\{1,1\\},\\{1,3\\},\\{1,4\\},\\{1,3\\},\\{1,4\\}, \\{3,4\\} (we distinguish the two 1s). The value of f(S) for these choices are 0,2,3,2,3,1, respectively, for the total of 11.\n\nSample Input 2\n\n6 3\n10 10 10 -10 -10 -10\n\nSample Output 2\n\n360\n\nThere are 20 ways to choose S. In 18 of them, f(S)=20, and in 2 of them, f(S)=0.\n\nSample Input 3\n\n3 1\n1 1 1\n\nSample Output 3\n\n0\n\nSample Input 4\n\n10 6\n1000000000 1000000000 1000000000 1000000000 1000000000 0 0 0 0 0\n\nSample Output 4\n\n999998537\n\nPrint the sum \\bmod (10^9+7).", "sample_input": "4 2\n1 1 3 4\n"}, "reference_outputs": ["11\n"], "source_document_id": "p02804", "source_text": "Score : 500 points\n\nProblem Statement\n\nFor a finite set of integers X, let f(X)=\\max X - \\min X.\n\nGiven are N integers A_1,...,A_N.\n\nWe will choose K of them and let S be the set of the integers chosen. If we distinguish elements with different indices even when their values are the same, there are {}_N C_K ways to make this choice. Find the sum of f(S) over all those ways.\n\nSince the answer can be enormous, print it \\bmod (10^9+7).\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n1 \\leq K \\leq N\n\n|A_i| \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nA_1 ... A_N\n\nOutput\n\nPrint the answer \\bmod (10^9+7).\n\nSample Input 1\n\n4 2\n1 1 3 4\n\nSample Output 1\n\n11\n\nThere are six ways to choose S: \\{1,1\\},\\{1,3\\},\\{1,4\\},\\{1,3\\},\\{1,4\\}, \\{3,4\\} (we distinguish the two 1s). The value of f(S) for these choices are 0,2,3,2,3,1, respectively, for the total of 11.\n\nSample Input 2\n\n6 3\n10 10 10 -10 -10 -10\n\nSample Output 2\n\n360\n\nThere are 20 ways to choose S. In 18 of them, f(S)=20, and in 2 of them, f(S)=0.\n\nSample Input 3\n\n3 1\n1 1 1\n\nSample Output 3\n\n0\n\nSample Input 4\n\n10 6\n1000000000 1000000000 1000000000 1000000000 1000000000 0 0 0 0 0\n\nSample Output 4\n\n999998537\n\nPrint the sum \\bmod (10^9+7).", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 3071, "cpu_time_ms": 553, "memory_kb": 54844}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s020220538", "group_id": "codeNet:p02806", "input_text": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val n = sc.nextInt()\n val st = (0 until n).map { sc.next() to sc.next().toInt() }\n val x = sc.next()\n println(problem006a(n, st, x))\n}\n\nfun problem006a(n: Int, st: List>, x: String): Int {\n var sum = 0\n var start = false\n for (i in 0 until n) {\n if (start) {\n sum += st[i].second\n }\n if (st[i].first == x) start = true\n }\n return sum\n}", "language": "Kotlin", "metadata": {"date": 1578791059, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02806.html", "problem_id": "p02806", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02806/input.txt", "sample_output_relpath": "derived/input_output/data/p02806/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02806/Kotlin/s020220538.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s020220538", "user_id": "u073232808"}, "prompt_components": {"gold_output": "30\n", "input_to_evaluate": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val n = sc.nextInt()\n val st = (0 until n).map { sc.next() to sc.next().toInt() }\n val x = sc.next()\n println(problem006a(n, st, x))\n}\n\nfun problem006a(n: Int, st: List>, x: String): Int {\n var sum = 0\n var start = false\n for (i in 0 until n) {\n if (start) {\n sum += st[i].second\n }\n if (st[i].first == x) start = true\n }\n return sum\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nNiwango created a playlist of N songs.\nThe title and the duration of the i-th song are s_i and t_i seconds, respectively.\nIt is guaranteed that s_1,\\ldots,s_N are all distinct.\n\nNiwango was doing some work while playing this playlist. (That is, all the songs were played once, in the order they appear in the playlist, without any pause in between.)\nHowever, he fell asleep during his work, and he woke up after all the songs were played.\nAccording to his record, it turned out that he fell asleep at the very end of the song titled X.\n\nFind the duration of time when some song was played while Niwango was asleep.\n\nConstraints\n\n1 \\leq N \\leq 50\n\ns_i and X are strings of length between 1 and 100 (inclusive) consisting of lowercase English letters.\n\ns_1,\\ldots,s_N are distinct.\n\nThere exists an integer i such that s_i = X.\n\n1 \\leq t_i \\leq 1000\n\nt_i is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\ns_1 t_1\n\\vdots\ns_{N} t_N\nX\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n3\ndwango 2\nsixth 5\nprelims 25\ndwango\n\nSample Output 1\n\n30\n\nWhile Niwango was asleep, two songs were played: sixth and prelims.\n\nThe answer is the total duration of these songs, 30.\n\nSample Input 2\n\n1\nabcde 1000\nabcde\n\nSample Output 2\n\n0\n\nNo songs were played while Niwango was asleep.\n\nIn such a case, the total duration of songs is 0.\n\nSample Input 3\n\n15\nypnxn 279\nkgjgwx 464\nqquhuwq 327\nrxing 549\npmuduhznoaqu 832\ndagktgdarveusju 595\nwunfagppcoi 200\ndhavrncwfw 720\njpcmigg 658\nwrczqxycivdqn 639\nmcmkkbnjfeod 992\nhtqvkgkbhtytsz 130\ntwflegsjz 467\ndswxxrxuzzfhkp 989\nszfwtzfpnscgue 958\npmuduhznoaqu\n\nSample Output 3\n\n6348", "sample_input": "3\ndwango 2\nsixth 5\nprelims 25\ndwango\n"}, "reference_outputs": ["30\n"], "source_document_id": "p02806", "source_text": "Score : 200 points\n\nProblem Statement\n\nNiwango created a playlist of N songs.\nThe title and the duration of the i-th song are s_i and t_i seconds, respectively.\nIt is guaranteed that s_1,\\ldots,s_N are all distinct.\n\nNiwango was doing some work while playing this playlist. (That is, all the songs were played once, in the order they appear in the playlist, without any pause in between.)\nHowever, he fell asleep during his work, and he woke up after all the songs were played.\nAccording to his record, it turned out that he fell asleep at the very end of the song titled X.\n\nFind the duration of time when some song was played while Niwango was asleep.\n\nConstraints\n\n1 \\leq N \\leq 50\n\ns_i and X are strings of length between 1 and 100 (inclusive) consisting of lowercase English letters.\n\ns_1,\\ldots,s_N are distinct.\n\nThere exists an integer i such that s_i = X.\n\n1 \\leq t_i \\leq 1000\n\nt_i is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\ns_1 t_1\n\\vdots\ns_{N} t_N\nX\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n3\ndwango 2\nsixth 5\nprelims 25\ndwango\n\nSample Output 1\n\n30\n\nWhile Niwango was asleep, two songs were played: sixth and prelims.\n\nThe answer is the total duration of these songs, 30.\n\nSample Input 2\n\n1\nabcde 1000\nabcde\n\nSample Output 2\n\n0\n\nNo songs were played while Niwango was asleep.\n\nIn such a case, the total duration of songs is 0.\n\nSample Input 3\n\n15\nypnxn 279\nkgjgwx 464\nqquhuwq 327\nrxing 549\npmuduhznoaqu 832\ndagktgdarveusju 595\nwunfagppcoi 200\ndhavrncwfw 720\njpcmigg 658\nwrczqxycivdqn 639\nmcmkkbnjfeod 992\nhtqvkgkbhtytsz 130\ntwflegsjz 467\ndswxxrxuzzfhkp 989\nszfwtzfpnscgue 958\npmuduhznoaqu\n\nSample Output 3\n\n6348", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 500, "cpu_time_ms": 215, "memory_kb": 31512}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s906669907", "group_id": "codeNet:p02807", "input_text": "import java.math.BigDecimal\n\nfun main(args: Array) {\n dwacon6thPrelimsB()\n}\n\nfun dwacon6thPrelimsB() {\n val n = readLine()!!.toInt()\n val xList = readLine()!!.split(' ').map { it.toLong() }.toLongArray()\n\n val diffs = Array(n - 1) { BigDecimal.valueOf(xList[it + 1] - xList[it]) }\n\n var answer = BigDecimal.ZERO\n\n var c = BigDecimal.valueOf(1.0)\n\n for (i in diffs.indices) {\n answer += diffs[i] * c\n answer %= MOD\n c += BigDecimal.valueOf(1.0 / (i + 2))\n }\n\n for (i in 2L until n) answer = (answer * BigDecimal.valueOf(i)) % MOD\n\n println(Math.ceil(answer.toDouble()).toLong() % (Math.pow(10.0, 9.0) + 7).toLong())\n}\n\nprivate val MOD by lazy { BigDecimal.valueOf((Math.pow(10.0, 9.0) + 7).toLong()) }\n", "language": "Kotlin", "metadata": {"date": 1578806571, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02807.html", "problem_id": "p02807", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02807/input.txt", "sample_output_relpath": "derived/input_output/data/p02807/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02807/Kotlin/s906669907.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s906669907", "user_id": "u139478771"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "import java.math.BigDecimal\n\nfun main(args: Array) {\n dwacon6thPrelimsB()\n}\n\nfun dwacon6thPrelimsB() {\n val n = readLine()!!.toInt()\n val xList = readLine()!!.split(' ').map { it.toLong() }.toLongArray()\n\n val diffs = Array(n - 1) { BigDecimal.valueOf(xList[it + 1] - xList[it]) }\n\n var answer = BigDecimal.ZERO\n\n var c = BigDecimal.valueOf(1.0)\n\n for (i in diffs.indices) {\n answer += diffs[i] * c\n answer %= MOD\n c += BigDecimal.valueOf(1.0 / (i + 2))\n }\n\n for (i in 2L until n) answer = (answer * BigDecimal.valueOf(i)) % MOD\n\n println(Math.ceil(answer.toDouble()).toLong() % (Math.pow(10.0, 9.0) + 7).toLong())\n}\n\nprivate val MOD by lazy { BigDecimal.valueOf((Math.pow(10.0, 9.0) + 7).toLong()) }\n", "problem_context": "Score : 600 points\n\nProblem Statement\n\nThere are N slimes standing on a number line.\nThe i-th slime from the left is at position x_i.\n\nIt is guaruanteed that 1 \\leq x_1 < x_2 < \\ldots < x_N \\leq 10^{9}.\n\nNiwango will perform N-1 operations. The i-th operation consists of the following procedures:\n\nChoose an integer k between 1 and N-i (inclusive) with equal probability.\n\nMove the k-th slime from the left, to the position of the neighboring slime to the right.\n\nFuse the two slimes at the same position into one slime.\n\nFind the total distance traveled by the slimes multiplied by (N-1)! (we can show that this value is an integer), modulo (10^{9}+7). If a slime is born by a fuse and that slime moves, we count it as just one slime.\n\nConstraints\n\n2 \\leq N \\leq 10^{5}\n\n1 \\leq x_1 < x_2 < \\ldots < x_N \\leq 10^{9}\n\nx_i is an integer.\n\nSubtasks\n\n400 points will be awarded for passing the test cases satisfying N \\leq 2000.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nx_1 x_2 \\ldots x_N\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n3\n1 2 3\n\nSample Output 1\n\n5\n\nWith probability \\frac{1}{2}, the leftmost slime is chosen in the first operation, in which case the total distance traveled is 2.\n\nWith probability \\frac{1}{2}, the middle slime is chosen in the first operation, in which case the total distance traveled is 3.\n\nThe answer is the expected total distance traveled, 2.5, multiplied by 2!, which is 5.\n\nSample Input 2\n\n12\n161735902 211047202 430302156 450968417 628894325 707723857 731963982 822804784 880895728 923078537 971407775 982631932\n\nSample Output 2\n\n750927044\n\nFind the expected value multiplied by (N-1)!, modulo (10^9+7).", "sample_input": "3\n1 2 3\n"}, "reference_outputs": ["5\n"], "source_document_id": "p02807", "source_text": "Score : 600 points\n\nProblem Statement\n\nThere are N slimes standing on a number line.\nThe i-th slime from the left is at position x_i.\n\nIt is guaruanteed that 1 \\leq x_1 < x_2 < \\ldots < x_N \\leq 10^{9}.\n\nNiwango will perform N-1 operations. The i-th operation consists of the following procedures:\n\nChoose an integer k between 1 and N-i (inclusive) with equal probability.\n\nMove the k-th slime from the left, to the position of the neighboring slime to the right.\n\nFuse the two slimes at the same position into one slime.\n\nFind the total distance traveled by the slimes multiplied by (N-1)! (we can show that this value is an integer), modulo (10^{9}+7). If a slime is born by a fuse and that slime moves, we count it as just one slime.\n\nConstraints\n\n2 \\leq N \\leq 10^{5}\n\n1 \\leq x_1 < x_2 < \\ldots < x_N \\leq 10^{9}\n\nx_i is an integer.\n\nSubtasks\n\n400 points will be awarded for passing the test cases satisfying N \\leq 2000.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nx_1 x_2 \\ldots x_N\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n3\n1 2 3\n\nSample Output 1\n\n5\n\nWith probability \\frac{1}{2}, the leftmost slime is chosen in the first operation, in which case the total distance traveled is 2.\n\nWith probability \\frac{1}{2}, the middle slime is chosen in the first operation, in which case the total distance traveled is 3.\n\nThe answer is the expected total distance traveled, 2.5, multiplied by 2!, which is 5.\n\nSample Input 2\n\n12\n161735902 211047202 430302156 450968417 628894325 707723857 731963982 822804784 880895728 923078537 971407775 982631932\n\nSample Output 2\n\n750927044\n\nFind the expected value multiplied by (N-1)!, modulo (10^9+7).", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 2498, "memory_kb": 138112}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s512363703", "group_id": "codeNet:p02811", "input_text": "fun main(args: Array) {\n val (K, X) = listOfInt()\n println(if (K * 500 >= X) \"Yes\" else \"No\")\n}\nfun next() = readLine()!!\nfun listOfString() = next().split(\" \")\nfun listOfInt() = listOfString().map { Integer.parseInt(it) }", "language": "Kotlin", "metadata": {"date": 1578708932, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02811.html", "problem_id": "p02811", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02811/input.txt", "sample_output_relpath": "derived/input_output/data/p02811/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02811/Kotlin/s512363703.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s512363703", "user_id": "u043150661"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "fun main(args: Array) {\n val (K, X) = listOfInt()\n println(if (K * 500 >= X) \"Yes\" else \"No\")\n}\nfun next() = readLine()!!\nfun listOfString() = next().split(\" \")\nfun listOfInt() = listOfString().map { Integer.parseInt(it) }", "problem_context": "Score : 100 points\n\nProblem Statement\n\nTakahashi has K 500-yen coins. (Yen is the currency of Japan.)\nIf these coins add up to X yen or more, print Yes; otherwise, print No.\n\nConstraints\n\n1 \\leq K \\leq 100\n\n1 \\leq X \\leq 10^5\n\nInput\n\nInput is given from Standard Input in the following format:\n\nK X\n\nOutput\n\nIf the coins add up to X yen or more, print Yes; otherwise, print No.\n\nSample Input 1\n\n2 900\n\nSample Output 1\n\nYes\n\nTwo 500-yen coins add up to 1000 yen, which is not less than X = 900 yen.\n\nSample Input 2\n\n1 501\n\nSample Output 2\n\nNo\n\nOne 500-yen coin is worth 500 yen, which is less than X = 501 yen.\n\nSample Input 3\n\n4 2000\n\nSample Output 3\n\nYes\n\nFour 500-yen coins add up to 2000 yen, which is not less than X = 2000 yen.", "sample_input": "2 900\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p02811", "source_text": "Score : 100 points\n\nProblem Statement\n\nTakahashi has K 500-yen coins. (Yen is the currency of Japan.)\nIf these coins add up to X yen or more, print Yes; otherwise, print No.\n\nConstraints\n\n1 \\leq K \\leq 100\n\n1 \\leq X \\leq 10^5\n\nInput\n\nInput is given from Standard Input in the following format:\n\nK X\n\nOutput\n\nIf the coins add up to X yen or more, print Yes; otherwise, print No.\n\nSample Input 1\n\n2 900\n\nSample Output 1\n\nYes\n\nTwo 500-yen coins add up to 1000 yen, which is not less than X = 900 yen.\n\nSample Input 2\n\n1 501\n\nSample Output 2\n\nNo\n\nOne 500-yen coin is worth 500 yen, which is less than X = 501 yen.\n\nSample Input 3\n\n4 2000\n\nSample Output 3\n\nYes\n\nFour 500-yen coins add up to 2000 yen, which is not less than X = 2000 yen.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 247, "memory_kb": 36056}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s468516389", "group_id": "codeNet:p02811", "input_text": "import java.util.*\n\nfun main(args: Array) {\n val scn = Scanner(System.`in`)\n val K = scn.nextInt()\n val X = scn.nextInt()\n\n if(K*500>=X) {\n println(\"Yes\")\n }else{\n println(\"No\")\n }\n}", "language": "Kotlin", "metadata": {"date": 1578708357, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02811.html", "problem_id": "p02811", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02811/input.txt", "sample_output_relpath": "derived/input_output/data/p02811/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02811/Kotlin/s468516389.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s468516389", "user_id": "u598554142"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "import java.util.*\n\nfun main(args: Array) {\n val scn = Scanner(System.`in`)\n val K = scn.nextInt()\n val X = scn.nextInt()\n\n if(K*500>=X) {\n println(\"Yes\")\n }else{\n println(\"No\")\n }\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nTakahashi has K 500-yen coins. (Yen is the currency of Japan.)\nIf these coins add up to X yen or more, print Yes; otherwise, print No.\n\nConstraints\n\n1 \\leq K \\leq 100\n\n1 \\leq X \\leq 10^5\n\nInput\n\nInput is given from Standard Input in the following format:\n\nK X\n\nOutput\n\nIf the coins add up to X yen or more, print Yes; otherwise, print No.\n\nSample Input 1\n\n2 900\n\nSample Output 1\n\nYes\n\nTwo 500-yen coins add up to 1000 yen, which is not less than X = 900 yen.\n\nSample Input 2\n\n1 501\n\nSample Output 2\n\nNo\n\nOne 500-yen coin is worth 500 yen, which is less than X = 501 yen.\n\nSample Input 3\n\n4 2000\n\nSample Output 3\n\nYes\n\nFour 500-yen coins add up to 2000 yen, which is not less than X = 2000 yen.", "sample_input": "2 900\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p02811", "source_text": "Score : 100 points\n\nProblem Statement\n\nTakahashi has K 500-yen coins. (Yen is the currency of Japan.)\nIf these coins add up to X yen or more, print Yes; otherwise, print No.\n\nConstraints\n\n1 \\leq K \\leq 100\n\n1 \\leq X \\leq 10^5\n\nInput\n\nInput is given from Standard Input in the following format:\n\nK X\n\nOutput\n\nIf the coins add up to X yen or more, print Yes; otherwise, print No.\n\nSample Input 1\n\n2 900\n\nSample Output 1\n\nYes\n\nTwo 500-yen coins add up to 1000 yen, which is not less than X = 900 yen.\n\nSample Input 2\n\n1 501\n\nSample Output 2\n\nNo\n\nOne 500-yen coin is worth 500 yen, which is less than X = 501 yen.\n\nSample Input 3\n\n4 2000\n\nSample Output 3\n\nYes\n\nFour 500-yen coins add up to 2000 yen, which is not less than X = 2000 yen.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 187, "memory_kb": 31392}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s964177423", "group_id": "codeNet:p02811", "input_text": "fun main(args: Array) {\n val (K, X) = readLine()!!.split(\" \").map { it.toInt() }\n println((if (500 * K >= X) \"Yes\" else \"No\"))\n}", "language": "Kotlin", "metadata": {"date": 1578708335, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02811.html", "problem_id": "p02811", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02811/input.txt", "sample_output_relpath": "derived/input_output/data/p02811/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02811/Kotlin/s964177423.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s964177423", "user_id": "u771276989"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "fun main(args: Array) {\n val (K, X) = readLine()!!.split(\" \").map { it.toInt() }\n println((if (500 * K >= X) \"Yes\" else \"No\"))\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nTakahashi has K 500-yen coins. (Yen is the currency of Japan.)\nIf these coins add up to X yen or more, print Yes; otherwise, print No.\n\nConstraints\n\n1 \\leq K \\leq 100\n\n1 \\leq X \\leq 10^5\n\nInput\n\nInput is given from Standard Input in the following format:\n\nK X\n\nOutput\n\nIf the coins add up to X yen or more, print Yes; otherwise, print No.\n\nSample Input 1\n\n2 900\n\nSample Output 1\n\nYes\n\nTwo 500-yen coins add up to 1000 yen, which is not less than X = 900 yen.\n\nSample Input 2\n\n1 501\n\nSample Output 2\n\nNo\n\nOne 500-yen coin is worth 500 yen, which is less than X = 501 yen.\n\nSample Input 3\n\n4 2000\n\nSample Output 3\n\nYes\n\nFour 500-yen coins add up to 2000 yen, which is not less than X = 2000 yen.", "sample_input": "2 900\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p02811", "source_text": "Score : 100 points\n\nProblem Statement\n\nTakahashi has K 500-yen coins. (Yen is the currency of Japan.)\nIf these coins add up to X yen or more, print Yes; otherwise, print No.\n\nConstraints\n\n1 \\leq K \\leq 100\n\n1 \\leq X \\leq 10^5\n\nInput\n\nInput is given from Standard Input in the following format:\n\nK X\n\nOutput\n\nIf the coins add up to X yen or more, print Yes; otherwise, print No.\n\nSample Input 1\n\n2 900\n\nSample Output 1\n\nYes\n\nTwo 500-yen coins add up to 1000 yen, which is not less than X = 900 yen.\n\nSample Input 2\n\n1 501\n\nSample Output 2\n\nNo\n\nOne 500-yen coin is worth 500 yen, which is less than X = 501 yen.\n\nSample Input 3\n\n4 2000\n\nSample Output 3\n\nYes\n\nFour 500-yen coins add up to 2000 yen, which is not less than X = 2000 yen.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 250, "memory_kb": 36016}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s887155978", "group_id": "codeNet:p02812", "input_text": "fun main(args: Array) = println(run {\n val n = readLine()!!.toInt()\n val s = readLine()!!\n \n Regex(\"(ABC)\").findAll(s).count()\n})", "language": "Kotlin", "metadata": {"date": 1588456603, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02812.html", "problem_id": "p02812", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02812/input.txt", "sample_output_relpath": "derived/input_output/data/p02812/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02812/Kotlin/s887155978.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s887155978", "user_id": "u563556491"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "fun main(args: Array) = println(run {\n val n = readLine()!!.toInt()\n val s = readLine()!!\n \n Regex(\"(ABC)\").findAll(s).count()\n})", "problem_context": "Score : 200 points\n\nProblem Statement\n\nWe have a string S of length N consisting of uppercase English letters.\n\nHow many times does ABC occur in S as contiguous subsequences (see Sample Inputs and Outputs)?\n\nConstraints\n\n3 \\leq N \\leq 50\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 number of occurrences of ABC in S as contiguous subsequences.\n\nSample Input 1\n\n10\nZABCDBABCQ\n\nSample Output 1\n\n2\n\nTwo contiguous subsequences of S are equal to ABC: the 2-nd through 4-th characters, and the 7-th through 9-th characters.\n\nSample Input 2\n\n19\nTHREEONEFOURONEFIVE\n\nSample Output 2\n\n0\n\nNo contiguous subsequences of S are equal to ABC.\n\nSample Input 3\n\n33\nABCCABCBABCCABACBCBBABCBCBCBCABCB\n\nSample Output 3\n\n5", "sample_input": "10\nZABCDBABCQ\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02812", "source_text": "Score : 200 points\n\nProblem Statement\n\nWe have a string S of length N consisting of uppercase English letters.\n\nHow many times does ABC occur in S as contiguous subsequences (see Sample Inputs and Outputs)?\n\nConstraints\n\n3 \\leq N \\leq 50\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 number of occurrences of ABC in S as contiguous subsequences.\n\nSample Input 1\n\n10\nZABCDBABCQ\n\nSample Output 1\n\n2\n\nTwo contiguous subsequences of S are equal to ABC: the 2-nd through 4-th characters, and the 7-th through 9-th characters.\n\nSample Input 2\n\n19\nTHREEONEFOURONEFIVE\n\nSample Output 2\n\n0\n\nNo contiguous subsequences of S are equal to ABC.\n\nSample Input 3\n\n33\nABCCABCBABCCABACBCBBABCBCBCBCABCB\n\nSample Output 3\n\n5", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 217, "memory_kb": 33776}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s240078222", "group_id": "codeNet:p02812", "input_text": "fun main(args: Array) = println(run {\n val n = readLine()!!.toInt()\n val s = readLine()!!\n\n (0..n-3).filter { s.substring(it..it+2) == \"ABC\" }.count()\n})", "language": "Kotlin", "metadata": {"date": 1588455182, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02812.html", "problem_id": "p02812", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02812/input.txt", "sample_output_relpath": "derived/input_output/data/p02812/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02812/Kotlin/s240078222.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s240078222", "user_id": "u563556491"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "fun main(args: Array) = println(run {\n val n = readLine()!!.toInt()\n val s = readLine()!!\n\n (0..n-3).filter { s.substring(it..it+2) == \"ABC\" }.count()\n})", "problem_context": "Score : 200 points\n\nProblem Statement\n\nWe have a string S of length N consisting of uppercase English letters.\n\nHow many times does ABC occur in S as contiguous subsequences (see Sample Inputs and Outputs)?\n\nConstraints\n\n3 \\leq N \\leq 50\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 number of occurrences of ABC in S as contiguous subsequences.\n\nSample Input 1\n\n10\nZABCDBABCQ\n\nSample Output 1\n\n2\n\nTwo contiguous subsequences of S are equal to ABC: the 2-nd through 4-th characters, and the 7-th through 9-th characters.\n\nSample Input 2\n\n19\nTHREEONEFOURONEFIVE\n\nSample Output 2\n\n0\n\nNo contiguous subsequences of S are equal to ABC.\n\nSample Input 3\n\n33\nABCCABCBABCCABACBCBBABCBCBCBCABCB\n\nSample Output 3\n\n5", "sample_input": "10\nZABCDBABCQ\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02812", "source_text": "Score : 200 points\n\nProblem Statement\n\nWe have a string S of length N consisting of uppercase English letters.\n\nHow many times does ABC occur in S as contiguous subsequences (see Sample Inputs and Outputs)?\n\nConstraints\n\n3 \\leq N \\leq 50\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 number of occurrences of ABC in S as contiguous subsequences.\n\nSample Input 1\n\n10\nZABCDBABCQ\n\nSample Output 1\n\n2\n\nTwo contiguous subsequences of S are equal to ABC: the 2-nd through 4-th characters, and the 7-th through 9-th characters.\n\nSample Input 2\n\n19\nTHREEONEFOURONEFIVE\n\nSample Output 2\n\n0\n\nNo contiguous subsequences of S are equal to ABC.\n\nSample Input 3\n\n33\nABCCABCBABCCABACBCBBABCBCBCBCABCB\n\nSample Output 3\n\n5", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 220, "memory_kb": 33632}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s620849977", "group_id": "codeNet:p02812", "input_text": "fun main(args: Array) {\n\n val N = readLine()!!.toInt()\n val Z = readLine()!!\n\n val A = 'A'\n val B = 'B'\n val C = 'C'\n\n var i = 0\n var answer = 0\n\n if(N < 3){\n println(\"0\")\n return\n }\n\n while(true){\n if(Z[i] == A && Z[i+1] == B && Z[i+2] == C){\n answer++\n i+=3\n }else{\n i++\n }\n\n if(i >= N-1)break\n }\n\n println(answer)\n}", "language": "Kotlin", "metadata": {"date": 1580853428, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02812.html", "problem_id": "p02812", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02812/input.txt", "sample_output_relpath": "derived/input_output/data/p02812/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02812/Kotlin/s620849977.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s620849977", "user_id": "u388106450"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "fun main(args: Array) {\n\n val N = readLine()!!.toInt()\n val Z = readLine()!!\n\n val A = 'A'\n val B = 'B'\n val C = 'C'\n\n var i = 0\n var answer = 0\n\n if(N < 3){\n println(\"0\")\n return\n }\n\n while(true){\n if(Z[i] == A && Z[i+1] == B && Z[i+2] == C){\n answer++\n i+=3\n }else{\n i++\n }\n\n if(i >= N-1)break\n }\n\n println(answer)\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nWe have a string S of length N consisting of uppercase English letters.\n\nHow many times does ABC occur in S as contiguous subsequences (see Sample Inputs and Outputs)?\n\nConstraints\n\n3 \\leq N \\leq 50\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 number of occurrences of ABC in S as contiguous subsequences.\n\nSample Input 1\n\n10\nZABCDBABCQ\n\nSample Output 1\n\n2\n\nTwo contiguous subsequences of S are equal to ABC: the 2-nd through 4-th characters, and the 7-th through 9-th characters.\n\nSample Input 2\n\n19\nTHREEONEFOURONEFIVE\n\nSample Output 2\n\n0\n\nNo contiguous subsequences of S are equal to ABC.\n\nSample Input 3\n\n33\nABCCABCBABCCABACBCBBABCBCBCBCABCB\n\nSample Output 3\n\n5", "sample_input": "10\nZABCDBABCQ\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02812", "source_text": "Score : 200 points\n\nProblem Statement\n\nWe have a string S of length N consisting of uppercase English letters.\n\nHow many times does ABC occur in S as contiguous subsequences (see Sample Inputs and Outputs)?\n\nConstraints\n\n3 \\leq N \\leq 50\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 number of occurrences of ABC in S as contiguous subsequences.\n\nSample Input 1\n\n10\nZABCDBABCQ\n\nSample Output 1\n\n2\n\nTwo contiguous subsequences of S are equal to ABC: the 2-nd through 4-th characters, and the 7-th through 9-th characters.\n\nSample Input 2\n\n19\nTHREEONEFOURONEFIVE\n\nSample Output 2\n\n0\n\nNo contiguous subsequences of S are equal to ABC.\n\nSample Input 3\n\n33\nABCCABCBABCCABACBCBBABCBCBCBCABCB\n\nSample Output 3\n\n5", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 207, "memory_kb": 31744}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s137052749", "group_id": "codeNet:p02812", "input_text": "fun main(s: Array) {\n readLine()\n val k = readLine()!!\n var c = 0\n for (i in 0 until k.length - 1) {\n if (k.substring(i, i + 2) == \"ABC\") {\n c++\n }\n }\n println(c)\n}", "language": "Kotlin", "metadata": {"date": 1578713757, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02812.html", "problem_id": "p02812", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02812/input.txt", "sample_output_relpath": "derived/input_output/data/p02812/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02812/Kotlin/s137052749.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s137052749", "user_id": "u370564845"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "fun main(s: Array) {\n readLine()\n val k = readLine()!!\n var c = 0\n for (i in 0 until k.length - 1) {\n if (k.substring(i, i + 2) == \"ABC\") {\n c++\n }\n }\n println(c)\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nWe have a string S of length N consisting of uppercase English letters.\n\nHow many times does ABC occur in S as contiguous subsequences (see Sample Inputs and Outputs)?\n\nConstraints\n\n3 \\leq N \\leq 50\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 number of occurrences of ABC in S as contiguous subsequences.\n\nSample Input 1\n\n10\nZABCDBABCQ\n\nSample Output 1\n\n2\n\nTwo contiguous subsequences of S are equal to ABC: the 2-nd through 4-th characters, and the 7-th through 9-th characters.\n\nSample Input 2\n\n19\nTHREEONEFOURONEFIVE\n\nSample Output 2\n\n0\n\nNo contiguous subsequences of S are equal to ABC.\n\nSample Input 3\n\n33\nABCCABCBABCCABACBCBBABCBCBCBCABCB\n\nSample Output 3\n\n5", "sample_input": "10\nZABCDBABCQ\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02812", "source_text": "Score : 200 points\n\nProblem Statement\n\nWe have a string S of length N consisting of uppercase English letters.\n\nHow many times does ABC occur in S as contiguous subsequences (see Sample Inputs and Outputs)?\n\nConstraints\n\n3 \\leq N \\leq 50\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 number of occurrences of ABC in S as contiguous subsequences.\n\nSample Input 1\n\n10\nZABCDBABCQ\n\nSample Output 1\n\n2\n\nTwo contiguous subsequences of S are equal to ABC: the 2-nd through 4-th characters, and the 7-th through 9-th characters.\n\nSample Input 2\n\n19\nTHREEONEFOURONEFIVE\n\nSample Output 2\n\n0\n\nNo contiguous subsequences of S are equal to ABC.\n\nSample Input 3\n\n33\nABCCABCBABCCABACBCBBABCBCBCBCABCB\n\nSample Output 3\n\n5", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 210, "memory_kb": 31872}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s700654121", "group_id": "codeNet:p02812", "input_text": "fun main() {\n readLine()\n val S = readLine()!!.toCharArray()\n var cnt = 0\n for (i in 0..S.size-3) {\n if (S[i] == 'A' && S[i+1] == 'B' && S[i+2] == 'C' ) cnt++\n }\n println(cnt)\n}", "language": "Kotlin", "metadata": {"date": 1578710209, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02812.html", "problem_id": "p02812", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02812/input.txt", "sample_output_relpath": "derived/input_output/data/p02812/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02812/Kotlin/s700654121.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s700654121", "user_id": "u860789370"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "fun main() {\n readLine()\n val S = readLine()!!.toCharArray()\n var cnt = 0\n for (i in 0..S.size-3) {\n if (S[i] == 'A' && S[i+1] == 'B' && S[i+2] == 'C' ) cnt++\n }\n println(cnt)\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nWe have a string S of length N consisting of uppercase English letters.\n\nHow many times does ABC occur in S as contiguous subsequences (see Sample Inputs and Outputs)?\n\nConstraints\n\n3 \\leq N \\leq 50\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 number of occurrences of ABC in S as contiguous subsequences.\n\nSample Input 1\n\n10\nZABCDBABCQ\n\nSample Output 1\n\n2\n\nTwo contiguous subsequences of S are equal to ABC: the 2-nd through 4-th characters, and the 7-th through 9-th characters.\n\nSample Input 2\n\n19\nTHREEONEFOURONEFIVE\n\nSample Output 2\n\n0\n\nNo contiguous subsequences of S are equal to ABC.\n\nSample Input 3\n\n33\nABCCABCBABCCABACBCBBABCBCBCBCABCB\n\nSample Output 3\n\n5", "sample_input": "10\nZABCDBABCQ\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02812", "source_text": "Score : 200 points\n\nProblem Statement\n\nWe have a string S of length N consisting of uppercase English letters.\n\nHow many times does ABC occur in S as contiguous subsequences (see Sample Inputs and Outputs)?\n\nConstraints\n\n3 \\leq N \\leq 50\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 number of occurrences of ABC in S as contiguous subsequences.\n\nSample Input 1\n\n10\nZABCDBABCQ\n\nSample Output 1\n\n2\n\nTwo contiguous subsequences of S are equal to ABC: the 2-nd through 4-th characters, and the 7-th through 9-th characters.\n\nSample Input 2\n\n19\nTHREEONEFOURONEFIVE\n\nSample Output 2\n\n0\n\nNo contiguous subsequences of S are equal to ABC.\n\nSample Input 3\n\n33\nABCCABCBABCCABACBCBBABCBCBCBCABCB\n\nSample Output 3\n\n5", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 202, "cpu_time_ms": 158, "memory_kb": 31256}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s420637749", "group_id": "codeNet:p02813", "input_text": "fun permutation(sortedList: List): List> {\n val queue = mutableListOf>()\n queue += arrayListOf()\n val permutations = mutableListOf>()\n while (queue.isNotEmpty()) {\n val p = queue.removeAt(0)\n\n if (p.size == sortedList.size) {\n permutations += p\n continue\n }\n\n for (item in (sortedList - p)) {\n queue += (p + item)\n }\n }\n\n return permutations\n}\n\nfun main(args: Array) {\n val n = readInteger()\n val p = readIntegerList().joinToString(\"\")\n val q = readIntegerList().joinToString(\"\")\n\n val per = permutation((1..n).toList()).map { it.joinToString(\"\") }\n Math.abs(per.indexOf(p) - per.indexOf(q)).let(::println)\n}\n\nfun readInteger() = readLine()!!.toInt()\nfun readLong() = readLine()!!.toLong()\nfun readStringList() = readLine()!!.split(\" \")\nfun readIntegerList() = readStringList().map(String::toInt)\nfun readLongList() = readStringList().map(String::toLong)\n", "language": "Kotlin", "metadata": {"date": 1581820067, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02813.html", "problem_id": "p02813", "resource_group": "medium_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/Kotlin/s420637749.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s420637749", "user_id": "u784448849"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "fun permutation(sortedList: List): List> {\n val queue = mutableListOf>()\n queue += arrayListOf()\n val permutations = mutableListOf>()\n while (queue.isNotEmpty()) {\n val p = queue.removeAt(0)\n\n if (p.size == sortedList.size) {\n permutations += p\n continue\n }\n\n for (item in (sortedList - p)) {\n queue += (p + item)\n }\n }\n\n return permutations\n}\n\nfun main(args: Array) {\n val n = readInteger()\n val p = readIntegerList().joinToString(\"\")\n val q = readIntegerList().joinToString(\"\")\n\n val per = permutation((1..n).toList()).map { it.joinToString(\"\") }\n Math.abs(per.indexOf(p) - per.indexOf(q)).let(::println)\n}\n\nfun readInteger() = readLine()!!.toInt()\nfun readLong() = readLine()!!.toLong()\nfun readStringList() = readLine()!!.split(\" \")\nfun readIntegerList() = readStringList().map(String::toInt)\nfun readLongList() = readStringList().map(String::toLong)\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 998, "cpu_time_ms": 1063, "memory_kb": 59508}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s615682251", "group_id": "codeNet:p02813", "input_text": "import java.util.*\n\nfun main(args: Array) {\n val n = readLine()!!.toInt()\n val p = readLine()!!.split(\" \").map { it.toInt() }.reversed()\n val q = readLine()!!.split(\" \").map { it.toInt() }.reversed()\n val pn = calc(p)\n val qn = calc(q)\n// println(pn)\n// println(qn)\n println(Math.abs(pn - qn))\n\n}\n\nprivate fun calc(list: List): Long {\n var n = 0L\n val que = ArrayDeque(list)\n while (que.isNotEmpty()) {\n val i = que.removeLast()\n val size = que.filter { it < i }.size\n val f = size * factorial(que.size)\n // println(\"$i $que ($size * ${factorial(que.size)})=$f\")\n n += f\n }\n return n + 1\n}\n\nprivate fun factorial(n: Int): Long {\n var sum = 1L\n for (i in (1..n)) {\n sum *= i\n }\n return sum\n}\n", "language": "Kotlin", "metadata": {"date": 1578713486, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02813.html", "problem_id": "p02813", "resource_group": "medium_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/Kotlin/s615682251.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s615682251", "user_id": "u225381909"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "import java.util.*\n\nfun main(args: Array) {\n val n = readLine()!!.toInt()\n val p = readLine()!!.split(\" \").map { it.toInt() }.reversed()\n val q = readLine()!!.split(\" \").map { it.toInt() }.reversed()\n val pn = calc(p)\n val qn = calc(q)\n// println(pn)\n// println(qn)\n println(Math.abs(pn - qn))\n\n}\n\nprivate fun calc(list: List): Long {\n var n = 0L\n val que = ArrayDeque(list)\n while (que.isNotEmpty()) {\n val i = que.removeLast()\n val size = que.filter { it < i }.size\n val f = size * factorial(que.size)\n // println(\"$i $que ($size * ${factorial(que.size)})=$f\")\n n += f\n }\n return n + 1\n}\n\nprivate fun factorial(n: Int): Long {\n var sum = 1L\n for (i in (1..n)) {\n sum *= i\n }\n return sum\n}\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 797, "cpu_time_ms": 250, "memory_kb": 37740}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s508898554", "group_id": "codeNet:p02817", "input_text": "fun main(args: Array) {\n val list = readLine()!!.split(\" \")\n val S = list[0]\n val T = list[1]\n println(T + S)\n}", "language": "Kotlin", "metadata": {"date": 1580072453, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02817.html", "problem_id": "p02817", "resource_group": "medium_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/Kotlin/s508898554.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s508898554", "user_id": "u979282295"}, "prompt_components": {"gold_output": "atcoder\n", "input_to_evaluate": "fun main(args: Array) {\n val list = readLine()!!.split(\" \")\n val S = list[0]\n val T = list[1]\n println(T + S)\n}", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 233, "memory_kb": 37964}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s131759226", "group_id": "codeNet:p02817", "input_text": "//DFSテンプレート\nfun main(args: Array) {\n var (S, T) = listOfString()\n println(T + S)\n}\nfun next() = readLine()!!\nfun listOfString() = next().split(\" \")", "language": "Kotlin", "metadata": {"date": 1577670937, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02817.html", "problem_id": "p02817", "resource_group": "medium_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/Kotlin/s131759226.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s131759226", "user_id": "u043150661"}, "prompt_components": {"gold_output": "atcoder\n", "input_to_evaluate": "//DFSテンプレート\nfun main(args: Array) {\n var (S, T) = listOfString()\n println(T + S)\n}\nfun next() = readLine()!!\nfun listOfString() = next().split(\" \")", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 240, "memory_kb": 36076}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s581775449", "group_id": "codeNet:p02817", "input_text": "fun main(args: Array) {\n val (s, t) = readLine()!!.split(\" \")\n println(\"$t$s\")\n}", "language": "Kotlin", "metadata": {"date": 1577669040, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02817.html", "problem_id": "p02817", "resource_group": "medium_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/Kotlin/s581775449.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s581775449", "user_id": "u225381909"}, "prompt_components": {"gold_output": "atcoder\n", "input_to_evaluate": "fun main(args: Array) {\n val (s, t) = readLine()!!.split(\" \")\n println(\"$t$s\")\n}", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 239, "memory_kb": 37740}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s448612494", "group_id": "codeNet:p02818", "input_text": "fun main(args: Array) {\n val (a, b, k) = readLine()?.split(\" \")?.map(String::toLong) ?: return\n val aRemain = if (a <= k) {\n 0\n } else {\n a - k\n }\n val remain = k - a\n val bRemain = if (b <= remain) {\n 0\n } else {\n b - remain\n }\n println(\"$aRemain $bRemain\")\n}", "language": "Kotlin", "metadata": {"date": 1586488525, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02818.html", "problem_id": "p02818", "resource_group": "medium_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/Kotlin/s448612494.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s448612494", "user_id": "u979429407"}, "prompt_components": {"gold_output": "0 2\n", "input_to_evaluate": "fun main(args: Array) {\n val (a, b, k) = readLine()?.split(\" \")?.map(String::toLong) ?: return\n val aRemain = if (a <= k) {\n 0\n } else {\n a - k\n }\n val remain = k - a\n val bRemain = if (b <= remain) {\n 0\n } else {\n b - remain\n }\n println(\"$aRemain $bRemain\")\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 323, "cpu_time_ms": 236, "memory_kb": 37868}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s935612478", "group_id": "codeNet:p02818", "input_text": "import java.io.BufferedReader\nimport java.io.InputStream\nimport java.io.InputStreamReader\nimport java.util.*\n\nfun main(args: Array) {\n val sc = FastScanner(System.`in`)\n\n var a = sc.nextLong()\n var b = sc.nextLong()\n var k = sc.nextLong()\n\n if( k > a) {\n k -= a\n a = 0\n\n if(k > b) {\n k-= b\n b = 0\n }\n else {\n b-= k\n }\n }\n else {\n a-=k\n }\n\n println(\"$a $b\")\n\n\n}\n\nclass FastScanner(s: InputStream) {\n private var st = StringTokenizer(\"\")\n private val br = BufferedReader(InputStreamReader(s))\n\n fun next(): String {\n while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())\n\n return st.nextToken()\n }\n\n fun nextInt() = next().toInt()\n fun nextLong() = next().toLong()\n fun nextLine() = br.readLine()\n fun nextDouble() = next().toDouble()\n fun ready() = br.ready()\n}\n\n\n\n", "language": "Kotlin", "metadata": {"date": 1580792285, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02818.html", "problem_id": "p02818", "resource_group": "medium_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/Kotlin/s935612478.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s935612478", "user_id": "u178770699"}, "prompt_components": {"gold_output": "0 2\n", "input_to_evaluate": "import java.io.BufferedReader\nimport java.io.InputStream\nimport java.io.InputStreamReader\nimport java.util.*\n\nfun main(args: Array) {\n val sc = FastScanner(System.`in`)\n\n var a = sc.nextLong()\n var b = sc.nextLong()\n var k = sc.nextLong()\n\n if( k > a) {\n k -= a\n a = 0\n\n if(k > b) {\n k-= b\n b = 0\n }\n else {\n b-= k\n }\n }\n else {\n a-=k\n }\n\n println(\"$a $b\")\n\n\n}\n\nclass FastScanner(s: InputStream) {\n private var st = StringTokenizer(\"\")\n private val br = BufferedReader(InputStreamReader(s))\n\n fun next(): String {\n while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())\n\n return st.nextToken()\n }\n\n fun nextInt() = next().toInt()\n fun nextLong() = next().toLong()\n fun nextLine() = br.readLine()\n fun nextDouble() = next().toDouble()\n fun ready() = br.ready()\n}\n\n\n\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 161, "memory_kb": 31136}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s883346764", "group_id": "codeNet:p02818", "input_text": "fun main(args: Array) {\n val (A,B,K) = readLine()!!.split(\" \").map(String::toInt)\n if (A-K >= 0) {\n println(\"${A-K} $B\")\n } else if (A-K < 0 && B-(K-A) >= 0) {\n println(\"0 ${B-(K-A)}\")\n } else {\n println(\"0 0\")\n }\n}", "language": "Kotlin", "metadata": {"date": 1578341144, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02818.html", "problem_id": "p02818", "resource_group": "medium_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/Kotlin/s883346764.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s883346764", "user_id": "u808160425"}, "prompt_components": {"gold_output": "0 2\n", "input_to_evaluate": "fun main(args: Array) {\n val (A,B,K) = readLine()!!.split(\" \").map(String::toInt)\n if (A-K >= 0) {\n println(\"${A-K} $B\")\n } else if (A-K < 0 && B-(K-A) >= 0) {\n println(\"0 ${B-(K-A)}\")\n } else {\n println(\"0 0\")\n }\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 242, "memory_kb": 37928}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s069765991", "group_id": "codeNet:p02819", "input_text": "fun main(args: Array) {\n val x = readLine()!!.toInt()\n val max = (1.5 * x).toInt()\n val list = Array(max + 1) { i -> true }\n for (i in (2..max).step(2)) {\n list[i] = false\n }\n\n for (i in (3..max).step(2)) {\n val v = list[i]\n if (v) {\n for (n in ((i + i)..max).step(i)) {\n list[n] = false\n }\n }\n }\n list[2] = true\n for (i in (x..max)) {\n if (list[i]) {\n println(i)\n return\n }\n }\n}\n", "language": "Kotlin", "metadata": {"date": 1577671655, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02819.html", "problem_id": "p02819", "resource_group": "medium_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/Kotlin/s069765991.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s069765991", "user_id": "u225381909"}, "prompt_components": {"gold_output": "23\n", "input_to_evaluate": "fun main(args: Array) {\n val x = readLine()!!.toInt()\n val max = (1.5 * x).toInt()\n val list = Array(max + 1) { i -> true }\n for (i in (2..max).step(2)) {\n list[i] = false\n }\n\n for (i in (3..max).step(2)) {\n val v = list[i]\n if (v) {\n for (n in ((i + i)..max).step(i)) {\n list[n] = false\n }\n }\n }\n list[2] = true\n for (i in (x..max)) {\n if (list[i]) {\n println(i)\n return\n }\n }\n}\n", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 254, "memory_kb": 33896}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s420606983", "group_id": "codeNet:p02829", "input_text": "fun main(args: Array) {\n var ans = mutableListOf(1,2,3)\n ans.remove(readLine()!!.toInt())\n ans.remove(readLine()!!.toInt())\n println(ans[0])\n}", "language": "Kotlin", "metadata": {"date": 1577248635, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02829.html", "problem_id": "p02829", "resource_group": "medium_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/Kotlin/s420606983.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s420606983", "user_id": "u396701320"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "fun main(args: Array) {\n var ans = mutableListOf(1,2,3)\n ans.remove(readLine()!!.toInt())\n ans.remove(readLine()!!.toInt())\n println(ans[0])\n}", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 207, "memory_kb": 31868}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s745944678", "group_id": "codeNet:p02829", "input_text": "import java.io.PrintWriter\nimport java.util.*\nimport java.math.*\nimport java.lang.*\nimport kotlin.comparisons.*\n\nval pw = PrintWriter(System.out)\nval MOD: Long = (1e+9 + 7).toLong()\n\nfun main(args: Array) {\n\tval a = readInt()\n\tval b = readInt()\n\n\tval cands = mutableListOf(1, 2, 3)\n\tcands.remove(a)\n\tcands.remove(b)\n\n\tprintln(cands[0])\n\tpw.flush()\n}\n\n/****** Declared Functions and Data Structures ******/\n// IO\nfun read() = readLine()!!\nfun readInt() = read().toInt()\nfun readLong() = read().toLong()\nfun readDouble() = read().toDouble()\nfun readListOfString() = read().split(\" \")\nfun readListOfInt() = readListOfString().map { it.toInt() }\nfun readListOfLong() = readListOfString().map { it.toLong() }\nfun readListOfDouble() = readListOfString().map { it.toDouble() }\n\nfun Double.format(digits: Int) = String.format(\"%.${digits}f\", this)\nfun Float.format(digits: Int) = String.format(\"%.${digits}f\", this)\n\nfun print(value: Any) { pw.print(value) }\nfun println(value : Any) { pw.println(value) }\n\n// Extensions\nfun List.toBuckets(): Map\n\t= this.groupBy { it }.mapValues { it.value.size }\n\nfun> List.upperBound(element: T, fromIndex: Int=0, toIndex: Int=this.size): Int {\n\tvar l = fromIndex\n\tvar r = toIndex\n\twhile(l < r) {\n\t\tval mid = (l+r) / 2\n\t\tif(element >= this[mid]) { \n\t\t\tl = mid + 1\n\t\t} else {\n\t\t\tr = mid\n\t\t}\n\t}\n\treturn l\n}\n\nfun> List.lowerBound(element: T, fromIndex: Int=0, toIndex: Int=this.size): Int {\n\tvar l = fromIndex\n\tvar r = toIndex\n\twhile(l < r) {\n\t\tval mid = (l+r) / 2\n\t\tif(element <= this[mid]) { \n\t\t\tr = mid\n\t\t} else {\n\t\t\tl = mid + 1\n\t\t}\n\t}\n\treturn r \n}\n\nfun Map.toMutableMap(): MutableMap = HashMap(this)\n\n// Util Functions\nfun Long.makeDivisors(): List {\n\tval divisors = mutableListOf()\n\tfor(i in 1L .. Math.sqrt(this.toDouble()).toLong()+1L) {\n\t\tif(this % i == 0L) {\n\t\t\tdivisors.add(i)\n\t\t\tif(i != this/i) {\n\t\t\t\tdivisors.add(this/i)\n\t\t\t}\n\t\t}\n\t}\n\treturn divisors.distinct().sorted()\n}\n\nfun Long.isPrime(): Boolean {\n\tif(this==1L) return false\n\tfor(i in 2L .. Math.sqrt(this.toDouble()).toLong() + 1L) {\n\t\tif(this % i == 0L && this != i) {\n\t\t\treturn false\n\t\t}\n\t}\n\treturn true\n}\n\n\nfun permutations(src: List): List> {\n\tif(src.size == 1) return listOf(src)\n\tval perms = mutableListOf>()\n\tval insertElement = src[0]\n\tpermutations(src.drop(1)).forEach { perm ->\n\t\tfor(i in 0..perm.size) {\n\t\t\tval newPerm = perm.toMutableList()\n\t\t\tnewPerm.add(i, insertElement)\n\t\t\tperms.add(newPerm.toList())\n\t\t}\n\t}\n\treturn perms\n}\n\n// return nCr, if you want nCr, please access v[n][r]\nfun combinations(n: Long): List> {\n\tval v = (0..n).map { (0..n).map{0L}.toMutableList() }.toMutableList()\n\tfor(i in 0 until v.size) {\n\t\tv[i][0] = 1L\n\t\tv[i][i] = 1L\n\t}\n\tfor(i in 0 until v.size) {\n\t\tfor(j in 1 until i) {\n\t\t\tv[i][j] = (v[i-1][j-1] + v[i-1][j]) % MOD\n\t\t}\n\t}\n\treturn v.map { it.toList() }.toList()\n}\n\n// should be a >= b\nfun gcd(a: Long, b: Long): Long = \n\tif(b == 0L) a else gcd(b, a % b)\n\n// shoud be a >= b\nfun lcm(a: Long, b: Long): Long = \n\ta / gcd(a, b) * b\n\nfun sumDigits(num_: Long): Long {\n\tvar num = num_\n\tvar rtn: Long = 0\n\twhile(num != 0.toLong()) {\n\t\tval tmp = num % 10\n\t\trtn += tmp\n\t\tnum /= 10\n\t}\n\treturn rtn\n}\n\nfun Double.isDecimal(): Boolean = ((this - Math.floor(this)) != 0.0)\n\n// Data Structures\nclass Stack(private var st: MutableList = mutableListOf()) {\n\tfun isEmpty() = st.isEmpty()\n\tfun top(): T = st.last()\n\tfun push(e: T) { st.add(e) }\n\tfun pop() { st = st.dropLast(1).toMutableList() }\n}\n\nclass Queue(private var que: MutableList = mutableListOf()) {\n\tfun isEmpty() = que.isEmpty()\n\tfun top(): T = que.first()\n\tfun push(e: T) { que.add(e) }\n\tfun pop() { que = que.drop(1).toMutableList() }\n}\n", "language": "Kotlin", "metadata": {"date": 1577066524, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02829.html", "problem_id": "p02829", "resource_group": "medium_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/Kotlin/s745944678.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s745944678", "user_id": "u026686258"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import java.io.PrintWriter\nimport java.util.*\nimport java.math.*\nimport java.lang.*\nimport kotlin.comparisons.*\n\nval pw = PrintWriter(System.out)\nval MOD: Long = (1e+9 + 7).toLong()\n\nfun main(args: Array) {\n\tval a = readInt()\n\tval b = readInt()\n\n\tval cands = mutableListOf(1, 2, 3)\n\tcands.remove(a)\n\tcands.remove(b)\n\n\tprintln(cands[0])\n\tpw.flush()\n}\n\n/****** Declared Functions and Data Structures ******/\n// IO\nfun read() = readLine()!!\nfun readInt() = read().toInt()\nfun readLong() = read().toLong()\nfun readDouble() = read().toDouble()\nfun readListOfString() = read().split(\" \")\nfun readListOfInt() = readListOfString().map { it.toInt() }\nfun readListOfLong() = readListOfString().map { it.toLong() }\nfun readListOfDouble() = readListOfString().map { it.toDouble() }\n\nfun Double.format(digits: Int) = String.format(\"%.${digits}f\", this)\nfun Float.format(digits: Int) = String.format(\"%.${digits}f\", this)\n\nfun print(value: Any) { pw.print(value) }\nfun println(value : Any) { pw.println(value) }\n\n// Extensions\nfun List.toBuckets(): Map\n\t= this.groupBy { it }.mapValues { it.value.size }\n\nfun> List.upperBound(element: T, fromIndex: Int=0, toIndex: Int=this.size): Int {\n\tvar l = fromIndex\n\tvar r = toIndex\n\twhile(l < r) {\n\t\tval mid = (l+r) / 2\n\t\tif(element >= this[mid]) { \n\t\t\tl = mid + 1\n\t\t} else {\n\t\t\tr = mid\n\t\t}\n\t}\n\treturn l\n}\n\nfun> List.lowerBound(element: T, fromIndex: Int=0, toIndex: Int=this.size): Int {\n\tvar l = fromIndex\n\tvar r = toIndex\n\twhile(l < r) {\n\t\tval mid = (l+r) / 2\n\t\tif(element <= this[mid]) { \n\t\t\tr = mid\n\t\t} else {\n\t\t\tl = mid + 1\n\t\t}\n\t}\n\treturn r \n}\n\nfun Map.toMutableMap(): MutableMap = HashMap(this)\n\n// Util Functions\nfun Long.makeDivisors(): List {\n\tval divisors = mutableListOf()\n\tfor(i in 1L .. Math.sqrt(this.toDouble()).toLong()+1L) {\n\t\tif(this % i == 0L) {\n\t\t\tdivisors.add(i)\n\t\t\tif(i != this/i) {\n\t\t\t\tdivisors.add(this/i)\n\t\t\t}\n\t\t}\n\t}\n\treturn divisors.distinct().sorted()\n}\n\nfun Long.isPrime(): Boolean {\n\tif(this==1L) return false\n\tfor(i in 2L .. Math.sqrt(this.toDouble()).toLong() + 1L) {\n\t\tif(this % i == 0L && this != i) {\n\t\t\treturn false\n\t\t}\n\t}\n\treturn true\n}\n\n\nfun permutations(src: List): List> {\n\tif(src.size == 1) return listOf(src)\n\tval perms = mutableListOf>()\n\tval insertElement = src[0]\n\tpermutations(src.drop(1)).forEach { perm ->\n\t\tfor(i in 0..perm.size) {\n\t\t\tval newPerm = perm.toMutableList()\n\t\t\tnewPerm.add(i, insertElement)\n\t\t\tperms.add(newPerm.toList())\n\t\t}\n\t}\n\treturn perms\n}\n\n// return nCr, if you want nCr, please access v[n][r]\nfun combinations(n: Long): List> {\n\tval v = (0..n).map { (0..n).map{0L}.toMutableList() }.toMutableList()\n\tfor(i in 0 until v.size) {\n\t\tv[i][0] = 1L\n\t\tv[i][i] = 1L\n\t}\n\tfor(i in 0 until v.size) {\n\t\tfor(j in 1 until i) {\n\t\t\tv[i][j] = (v[i-1][j-1] + v[i-1][j]) % MOD\n\t\t}\n\t}\n\treturn v.map { it.toList() }.toList()\n}\n\n// should be a >= b\nfun gcd(a: Long, b: Long): Long = \n\tif(b == 0L) a else gcd(b, a % b)\n\n// shoud be a >= b\nfun lcm(a: Long, b: Long): Long = \n\ta / gcd(a, b) * b\n\nfun sumDigits(num_: Long): Long {\n\tvar num = num_\n\tvar rtn: Long = 0\n\twhile(num != 0.toLong()) {\n\t\tval tmp = num % 10\n\t\trtn += tmp\n\t\tnum /= 10\n\t}\n\treturn rtn\n}\n\nfun Double.isDecimal(): Boolean = ((this - Math.floor(this)) != 0.0)\n\n// Data Structures\nclass Stack(private var st: MutableList = mutableListOf()) {\n\tfun isEmpty() = st.isEmpty()\n\tfun top(): T = st.last()\n\tfun push(e: T) { st.add(e) }\n\tfun pop() { st = st.dropLast(1).toMutableList() }\n}\n\nclass Queue(private var que: MutableList = mutableListOf()) {\n\tfun isEmpty() = que.isEmpty()\n\tfun top(): T = que.first()\n\tfun push(e: T) { que.add(e) }\n\tfun pop() { que = que.drop(1).toMutableList() }\n}\n", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 3763, "cpu_time_ms": 209, "memory_kb": 31724}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s503120973", "group_id": "codeNet:p02830", "input_text": "fun main (args : Array) {\n\tval n = readLine()!!\n\tval (s, t) = readLine()!!.split(\" \")\n\tvar sList : MutableList = mutableListOf()\n\tvar tList : MutableList = mutableListOf()\n\tvar result : String = \"\"\n\tfor (i in s) {\n\t\tsList.add(i.toString())\n\t}\n\tfor (i in t) {\n\t\ttList.add(i.toString())\n\t}\n\tfor (i in 0..(n.toInt() * 2) - 1) {\n\t\tif ((i % 2) == 0) {\n\t\t\tresult += sList[0]\n\t\t\tsList.removeAt(0)\n\t\t} else {\n\t\t\tresult += tList[0]\n\t\t\ttList.removeAt(0)\n\t\t}\n\t}\n\tprintln(\"${result}\")\n}", "language": "Kotlin", "metadata": {"date": 1579383022, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02830.html", "problem_id": "p02830", "resource_group": "medium_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/Kotlin/s503120973.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s503120973", "user_id": "u651257341"}, "prompt_components": {"gold_output": "icpc\n", "input_to_evaluate": "fun main (args : Array) {\n\tval n = readLine()!!\n\tval (s, t) = readLine()!!.split(\" \")\n\tvar sList : MutableList = mutableListOf()\n\tvar tList : MutableList = mutableListOf()\n\tvar result : String = \"\"\n\tfor (i in s) {\n\t\tsList.add(i.toString())\n\t}\n\tfor (i in t) {\n\t\ttList.add(i.toString())\n\t}\n\tfor (i in 0..(n.toInt() * 2) - 1) {\n\t\tif ((i % 2) == 0) {\n\t\t\tresult += sList[0]\n\t\t\tsList.removeAt(0)\n\t\t} else {\n\t\t\tresult += tList[0]\n\t\t\ttList.removeAt(0)\n\t\t}\n\t}\n\tprintln(\"${result}\")\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 498, "cpu_time_ms": 237, "memory_kb": 38156}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s876450540", "group_id": "codeNet:p02830", "input_text": "import java.lang.Math\n\nval MOD: Int = 1000000000 + 7\nval MODL: Long = MOD.toLong()\n\nfun main(args: Array)\n{\n val n = read().toInt()\n val (s, t) = read().split(\" \").map{it.toCharArray()}\n\n var ans: String = \"\"\n for (i in 0 until n) {\n ans += s[i]\n ans += t[i]\n }\n\n println(ans)\n}\n\nfun read(): String = readLine()!!\n", "language": "Kotlin", "metadata": {"date": 1578745861, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02830.html", "problem_id": "p02830", "resource_group": "medium_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/Kotlin/s876450540.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s876450540", "user_id": "u118477733"}, "prompt_components": {"gold_output": "icpc\n", "input_to_evaluate": "import java.lang.Math\n\nval MOD: Int = 1000000000 + 7\nval MODL: Long = MOD.toLong()\n\nfun main(args: Array)\n{\n val n = read().toInt()\n val (s, t) = read().split(\" \").map{it.toCharArray()}\n\n var ans: String = \"\"\n for (i in 0 until n) {\n ans += s[i]\n ans += t[i]\n }\n\n println(ans)\n}\n\nfun read(): String = readLine()!!\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 237, "memory_kb": 37892}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s282338620", "group_id": "codeNet:p02831", "input_text": "fun main(args: Array) {\n val (a, b) = readLine()!!.split(\" \").map{it.toLong()}\n println(a*b/gcd(a, b))\n}\n\nfun gcd(a: Long, b: Long) : Long {\n return if (b == 0L) a else gcd(b, a % b)\n}", "language": "Kotlin", "metadata": {"date": 1577671565, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02831.html", "problem_id": "p02831", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02831/input.txt", "sample_output_relpath": "derived/input_output/data/p02831/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02831/Kotlin/s282338620.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s282338620", "user_id": "u777283665"}, "prompt_components": {"gold_output": "6\n", "input_to_evaluate": "fun main(args: Array) {\n val (a, b) = readLine()!!.split(\" \").map{it.toLong()}\n println(a*b/gcd(a, b))\n}\n\nfun gcd(a: Long, b: Long) : Long {\n return if (b == 0L) a else gcd(b, a % b)\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nTakahashi is organizing a party.\n\nAt the party, each guest will receive one or more snack pieces.\n\nTakahashi predicts that the number of guests at this party will be A or B.\n\nFind the minimum number of pieces that can be evenly distributed to the guests in both of the cases predicted.\n\nWe assume that a piece cannot be divided and distributed to multiple guests.\n\nConstraints\n\n1 \\leq A, B \\leq 10^5\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 B\n\nOutput\n\nPrint the minimum number of pieces that can be evenly distributed to the guests in both of the cases with A guests and B guests.\n\nSample Input 1\n\n2 3\n\nSample Output 1\n\n6\n\nWhen we have six snack pieces, each guest can take three pieces if we have two guests, and each guest can take two if we have three guests.\n\nSample Input 2\n\n123 456\n\nSample Output 2\n\n18696\n\nSample Input 3\n\n100000 99999\n\nSample Output 3\n\n9999900000", "sample_input": "2 3\n"}, "reference_outputs": ["6\n"], "source_document_id": "p02831", "source_text": "Score : 300 points\n\nProblem Statement\n\nTakahashi is organizing a party.\n\nAt the party, each guest will receive one or more snack pieces.\n\nTakahashi predicts that the number of guests at this party will be A or B.\n\nFind the minimum number of pieces that can be evenly distributed to the guests in both of the cases predicted.\n\nWe assume that a piece cannot be divided and distributed to multiple guests.\n\nConstraints\n\n1 \\leq A, B \\leq 10^5\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 B\n\nOutput\n\nPrint the minimum number of pieces that can be evenly distributed to the guests in both of the cases with A guests and B guests.\n\nSample Input 1\n\n2 3\n\nSample Output 1\n\n6\n\nWhen we have six snack pieces, each guest can take three pieces if we have two guests, and each guest can take two if we have three guests.\n\nSample Input 2\n\n123 456\n\nSample Output 2\n\n18696\n\nSample Input 3\n\n100000 99999\n\nSample Output 3\n\n9999900000", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 245, "memory_kb": 38032}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s714397909", "group_id": "codeNet:p02832", "input_text": "import java.util.Scanner;\n\nfun main (args : Array) {\n val input = Scanner(System.`in`)\n \n while (input.hasNext()) {\n val N = input.nextInt()\n var target = 1;\n var breakCount = 0;\n \n for (i in 1..N) {\n val a = input.nextInt()\n \n if (a != target) {\n ++breakCount\n } else {\n ++target\n }\n }\n \n if (target == 1) {\n println(-1)\n } else {\n println(breakCount)\n }\n }\n}", "language": "Kotlin", "metadata": {"date": 1595383400, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02832.html", "problem_id": "p02832", "resource_group": "medium_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/Kotlin/s714397909.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s714397909", "user_id": "u920836104"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "import java.util.Scanner;\n\nfun main (args : Array) {\n val input = Scanner(System.`in`)\n \n while (input.hasNext()) {\n val N = input.nextInt()\n var target = 1;\n var breakCount = 0;\n \n for (i in 1..N) {\n val a = input.nextInt()\n \n if (a != target) {\n ++breakCount\n } else {\n ++target\n }\n }\n \n if (target == 1) {\n println(-1)\n } else {\n println(breakCount)\n }\n }\n}", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 451, "cpu_time_ms": 530, "memory_kb": 59568}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s996338018", "group_id": "codeNet:p02832", "input_text": "fun main(args: Array) {\n val N = readLine()!!.toInt()\n val a = readLine()!!.split(\" \").map{it.toInt()}\n\n var cnt = 0\n\n for (v in a) {\n if (v == cnt + 1) {\n cnt++\n }\n }\n\n if (cnt == 0) {\n println(-1)\n } else {\n println(N - cnt)\n }\n}\n", "language": "Kotlin", "metadata": {"date": 1577143044, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02832.html", "problem_id": "p02832", "resource_group": "medium_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/Kotlin/s996338018.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s996338018", "user_id": "u183530284"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "fun main(args: Array) {\n val N = readLine()!!.toInt()\n val a = readLine()!!.split(\" \").map{it.toInt()}\n\n var cnt = 0\n\n for (v in a) {\n if (v == cnt + 1) {\n cnt++\n }\n }\n\n if (cnt == 0) {\n println(-1)\n } else {\n println(N - cnt)\n }\n}\n", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 651, "memory_kb": 84708}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s952414149", "group_id": "codeNet:p02832", "input_text": "fun main(args: Array) {\n val n = readLine()!!.toInt()\n val a = readLine()!!.split(\" \").map { it.toInt() }.toMutableList()\n val max = a.max() ?: 1000000000\n\n for (target in max downTo 1) {\n var lastIndex = a.size\n val success = (target downTo 1).all {\n val filter = a.filterIndexed { index, i -> index < lastIndex }\n val index = filter.lastIndexOf(it)\n lastIndex = index\n index != -1\n }\n if(success) {\n println(a.size - target)\n return\n }\n }\n println(\"-1\")\n}\n", "language": "Kotlin", "metadata": {"date": 1577070000, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02832.html", "problem_id": "p02832", "resource_group": "medium_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/Kotlin/s952414149.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s952414149", "user_id": "u020105701"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "fun main(args: Array) {\n val n = readLine()!!.toInt()\n val a = readLine()!!.split(\" \").map { it.toInt() }.toMutableList()\n val max = a.max() ?: 1000000000\n\n for (target in max downTo 1) {\n var lastIndex = a.size\n val success = (target downTo 1).all {\n val filter = a.filterIndexed { index, i -> index < lastIndex }\n val index = filter.lastIndexOf(it)\n lastIndex = index\n index != -1\n }\n if(success) {\n println(a.size - target)\n return\n }\n }\n println(\"-1\")\n}\n", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 2111, "memory_kb": 144552}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s665401221", "group_id": "codeNet:p02833", "input_text": "fun main(args: Array) {\n val N = readLine()!!.toLong()\n\n if (N % 2 == 1L) {\n println(0)\n return\n }\n\n if (N == 0L) {\n println(1)\n return\n }\n\n val a = func(N, 2L)\n val b = func2(N, 5L)\n\n println(Math.min(a, b))\n}\n\nprivate fun func(N: Long, p: Long): Long {\n var res = 0L\n var a = p\n\n while (a <= N) {\n res += N / a\n a *= p\n }\n return res\n}\n\nprivate fun func2(N: Long, p: Long): Long {\n var res = 0L\n var a = p * 2L\n\n while (a <= N) {\n res += N / a\n a *= p\n }\n return res\n}\n", "language": "Kotlin", "metadata": {"date": 1577143718, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02833.html", "problem_id": "p02833", "resource_group": "medium_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/Kotlin/s665401221.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s665401221", "user_id": "u183530284"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "fun main(args: Array) {\n val N = readLine()!!.toLong()\n\n if (N % 2 == 1L) {\n println(0)\n return\n }\n\n if (N == 0L) {\n println(1)\n return\n }\n\n val a = func(N, 2L)\n val b = func2(N, 5L)\n\n println(Math.min(a, b))\n}\n\nprivate fun func(N: Long, p: Long): Long {\n var res = 0L\n var a = p\n\n while (a <= N) {\n res += N / a\n a *= p\n }\n return res\n}\n\nprivate fun func2(N: Long, p: Long): Long {\n var res = 0L\n var a = p * 2L\n\n while (a <= N) {\n res += N / a\n a *= p\n }\n return res\n}\n", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 207, "memory_kb": 33556}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s182944458", "group_id": "codeNet:p02833", "input_text": "fun main(args: Array) {\n val N = readInputLine().toLong()\n\n if (N % 2 == 1L) {\n println(0)\n } else {\n var ans = 0L\n var div = 10L\n while (div <= N) {\n ans += N / div\n div *= 5L\n }\n println(ans)\n }\n}\n\nfun readInputLine(): String {\n return readLine()!!\n}\n\n", "language": "Kotlin", "metadata": {"date": 1577073887, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02833.html", "problem_id": "p02833", "resource_group": "medium_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/Kotlin/s182944458.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s182944458", "user_id": "u505558493"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "fun main(args: Array) {\n val N = readInputLine().toLong()\n\n if (N % 2 == 1L) {\n println(0)\n } else {\n var ans = 0L\n var div = 10L\n while (div <= N) {\n ans += N / div\n div *= 5L\n }\n println(ans)\n }\n}\n\nfun readInputLine(): String {\n return readLine()!!\n}\n\n", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 206, "memory_kb": 33756}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s828867988", "group_id": "codeNet:p02834", "input_text": "import java.util.*\n\nclass State(val pos: Int, val cost: Int)\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n\n val n = sc.nextInt()\n val u = sc.nextInt() - 1\n val v = sc.nextInt() - 1\n\n val g = Array(n) { mutableListOf() }\n\n repeat(n - 1) {\n val a = sc.nextInt() - 1\n val b = sc.nextInt() - 1\n g[a].add(b)\n g[b].add(a)\n }\n\n // 青木くんからの最短距離を出す\n val aokiCost = IntArray(n) { -1 }\n val aokiQue = LinkedList()\n aokiQue.add(State(v, 0))\n aokiCost[v] = 0\n while (aokiQue.isNotEmpty()) {\n val st = aokiQue.poll()\n for (to in g[st.pos]) {\n if (aokiCost[to] == -1) {\n aokiCost[to] = st.cost + 1\n aokiQue.add(State(to, st.cost + 1))\n }\n }\n }\n\n // 高橋くんが出発してから青木くんより早く到達できるノードにだけ進む\n var ans = 0\n val takaCost = IntArray(n) { -1 }\n val takaQue = LinkedList()\n takaQue.add(State(u, 0))\n takaCost[u] = 0\n while (takaQue.isNotEmpty()) {\n val st = takaQue.poll()\n val nextCost = st.cost + 1\n for (to in g[st.pos]) {\n if (takaCost[to] == -1 && nextCost < aokiCost[to]) {\n takaCost[to] = nextCost\n takaQue.add(State(to, nextCost))\n ans = Math.max(ans, nextCost)\n } else if (nextCost == aokiCost[to]) {\n // ちょうど青木くんと同じタイミングで踏んでしまう場合\n ans = Math.max(ans, nextCost)\n }\n }\n }\n\n println(ans)\n}", "language": "Kotlin", "metadata": {"date": 1593820756, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02834.html", "problem_id": "p02834", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02834/input.txt", "sample_output_relpath": "derived/input_output/data/p02834/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02834/Kotlin/s828867988.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s828867988", "user_id": "u611013822"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import java.util.*\n\nclass State(val pos: Int, val cost: Int)\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n\n val n = sc.nextInt()\n val u = sc.nextInt() - 1\n val v = sc.nextInt() - 1\n\n val g = Array(n) { mutableListOf() }\n\n repeat(n - 1) {\n val a = sc.nextInt() - 1\n val b = sc.nextInt() - 1\n g[a].add(b)\n g[b].add(a)\n }\n\n // 青木くんからの最短距離を出す\n val aokiCost = IntArray(n) { -1 }\n val aokiQue = LinkedList()\n aokiQue.add(State(v, 0))\n aokiCost[v] = 0\n while (aokiQue.isNotEmpty()) {\n val st = aokiQue.poll()\n for (to in g[st.pos]) {\n if (aokiCost[to] == -1) {\n aokiCost[to] = st.cost + 1\n aokiQue.add(State(to, st.cost + 1))\n }\n }\n }\n\n // 高橋くんが出発してから青木くんより早く到達できるノードにだけ進む\n var ans = 0\n val takaCost = IntArray(n) { -1 }\n val takaQue = LinkedList()\n takaQue.add(State(u, 0))\n takaCost[u] = 0\n while (takaQue.isNotEmpty()) {\n val st = takaQue.poll()\n val nextCost = st.cost + 1\n for (to in g[st.pos]) {\n if (takaCost[to] == -1 && nextCost < aokiCost[to]) {\n takaCost[to] = nextCost\n takaQue.add(State(to, nextCost))\n ans = Math.max(ans, nextCost)\n } else if (nextCost == aokiCost[to]) {\n // ちょうど青木くんと同じタイミングで踏んでしまう場合\n ans = Math.max(ans, nextCost)\n }\n }\n }\n\n println(ans)\n}", "problem_context": "Score : 600 points\n\nProblem Statement\n\nWe have a tree with N vertices. The i-th edge connects Vertex A_i and B_i bidirectionally.\n\nTakahashi is standing at Vertex u, and Aoki is standing at Vertex v.\n\nNow, they will play a game of tag as follows:\n\n1. If Takahashi and Aoki are standing at the same vertex, the game ends. Otherwise, Takahashi moves to a vertex of his choice that is adjacent to his current vertex.\n\n2. If Takahashi and Aoki are standing at the same vertex, the game ends. Otherwise, Aoki moves to a vertex of his choice that is adjacent to his current vertex.\n\n3. Go back to step 1.\n\nTakahashi performs his moves so that the game ends as late as possible, while Aoki performs his moves so that the game ends as early as possible.\n\nFind the number of moves Aoki will perform before the end of the game if both Takahashi and Aoki know each other's position and strategy.\n\nIt can be proved that the game is bound to end.\n\nConstraints\n\n2 \\leq N \\leq 10^5\n\n1 \\leq u,v \\leq N\n\nu \\neq v\n\n1 \\leq A_i,B_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 u v\nA_1 B_1\n:\nA_{N-1} B_{N-1}\n\nOutput\n\nPrint the number of moves Aoki will perform before the end of the game.\n\nSample Input 1\n\n5 4 1\n1 2\n2 3\n3 4\n3 5\n\nSample Output 1\n\n2\n\nIf both players play optimally, the game will progress as follows:\n\nTakahashi moves to Vertex 3.\n\nAoki moves to Vertex 2.\n\nTakahashi moves to Vertex 5.\n\nAoki moves to Vertex 3.\n\nTakahashi moves to Vertex 3.\n\nHere, Aoki performs two moves.\n\nNote that, in each move, it is prohibited to stay at the current vertex.\n\nSample Input 2\n\n5 4 5\n1 2\n1 3\n1 4\n1 5\n\nSample Output 2\n\n1\n\nSample Input 3\n\n2 1 2\n1 2\n\nSample Output 3\n\n0\n\nSample Input 4\n\n9 6 1\n1 2\n2 3\n3 4\n4 5\n5 6\n4 7\n7 8\n8 9\n\nSample Output 4\n\n5", "sample_input": "5 4 1\n1 2\n2 3\n3 4\n3 5\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02834", "source_text": "Score : 600 points\n\nProblem Statement\n\nWe have a tree with N vertices. The i-th edge connects Vertex A_i and B_i bidirectionally.\n\nTakahashi is standing at Vertex u, and Aoki is standing at Vertex v.\n\nNow, they will play a game of tag as follows:\n\n1. If Takahashi and Aoki are standing at the same vertex, the game ends. Otherwise, Takahashi moves to a vertex of his choice that is adjacent to his current vertex.\n\n2. If Takahashi and Aoki are standing at the same vertex, the game ends. Otherwise, Aoki moves to a vertex of his choice that is adjacent to his current vertex.\n\n3. Go back to step 1.\n\nTakahashi performs his moves so that the game ends as late as possible, while Aoki performs his moves so that the game ends as early as possible.\n\nFind the number of moves Aoki will perform before the end of the game if both Takahashi and Aoki know each other's position and strategy.\n\nIt can be proved that the game is bound to end.\n\nConstraints\n\n2 \\leq N \\leq 10^5\n\n1 \\leq u,v \\leq N\n\nu \\neq v\n\n1 \\leq A_i,B_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 u v\nA_1 B_1\n:\nA_{N-1} B_{N-1}\n\nOutput\n\nPrint the number of moves Aoki will perform before the end of the game.\n\nSample Input 1\n\n5 4 1\n1 2\n2 3\n3 4\n3 5\n\nSample Output 1\n\n2\n\nIf both players play optimally, the game will progress as follows:\n\nTakahashi moves to Vertex 3.\n\nAoki moves to Vertex 2.\n\nTakahashi moves to Vertex 5.\n\nAoki moves to Vertex 3.\n\nTakahashi moves to Vertex 3.\n\nHere, Aoki performs two moves.\n\nNote that, in each move, it is prohibited to stay at the current vertex.\n\nSample Input 2\n\n5 4 5\n1 2\n1 3\n1 4\n1 5\n\nSample Output 2\n\n1\n\nSample Input 3\n\n2 1 2\n1 2\n\nSample Output 3\n\n0\n\nSample Input 4\n\n9 6 1\n1 2\n2 3\n3 4\n4 5\n5 6\n4 7\n7 8\n8 9\n\nSample Output 4\n\n5", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 704, "memory_kb": 75140}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s793918918", "group_id": "codeNet:p02835", "input_text": "fun main (args:Array) {\n val (a1, a2, a3) = readLine()!!.split(\" \").map(String::toInt)\n if(a1 + a2 + a3 >= 22) print(\"bust\")\n else print(\"win\")\n}", "language": "Kotlin", "metadata": {"date": 1595440702, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02835.html", "problem_id": "p02835", "resource_group": "medium_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/Kotlin/s793918918.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s793918918", "user_id": "u800824593"}, "prompt_components": {"gold_output": "win\n", "input_to_evaluate": "fun main (args:Array) {\n val (a1, a2, a3) = readLine()!!.split(\" \").map(String::toInt)\n if(a1 + a2 + a3 >= 22) print(\"bust\")\n else print(\"win\")\n}", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 115, "memory_kb": 36420}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s031653004", "group_id": "codeNet:p02835", "input_text": "fun main(args: Array) {\n val list = readLine()!!.split(\" \").map(String::toInt)\n val A = list[0]\n val B = list[1]\n val C = list[2]\n\n val D = list[0] + list[1] + list[2]\n\n if(D < 22) {\n println(\"win\")\n } else {\n println(\"bust\")\n }\n}", "language": "Kotlin", "metadata": {"date": 1580075012, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02835.html", "problem_id": "p02835", "resource_group": "medium_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/Kotlin/s031653004.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s031653004", "user_id": "u979282295"}, "prompt_components": {"gold_output": "win\n", "input_to_evaluate": "fun main(args: Array) {\n val list = readLine()!!.split(\" \").map(String::toInt)\n val A = list[0]\n val B = list[1]\n val C = list[2]\n\n val D = list[0] + list[1] + list[2]\n\n if(D < 22) {\n println(\"win\")\n } else {\n println(\"bust\")\n }\n}", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 240, "memory_kb": 37928}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s815569278", "group_id": "codeNet:p02835", "input_text": "fun main(args: Array){\n readLine()!!.split(\" \").map{ it.toInt() }.sum().let{\n if (it >= 22) println(\"bust\")\n else println(\"win\") \n }\n}", "language": "Kotlin", "metadata": {"date": 1578276217, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02835.html", "problem_id": "p02835", "resource_group": "medium_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/Kotlin/s815569278.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s815569278", "user_id": "u329232967"}, "prompt_components": {"gold_output": "win\n", "input_to_evaluate": "fun main(args: Array){\n readLine()!!.split(\" \").map{ it.toInt() }.sum().let{\n if (it >= 22) println(\"bust\")\n else println(\"win\") \n }\n}", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 239, "memory_kb": 36072}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s804889589", "group_id": "codeNet:p02835", "input_text": "fun main(args: Array) {\n val s = readLine()!!.split(\" \").map(String::toInt)\n solver9(s)\n}\n\nfun solver9(s: List) {\n val ans = if (s.reduce { acc, i -> acc + i } > 21 ) \"bust\" else \"win\"\n println(ans)\n}", "language": "Kotlin", "metadata": {"date": 1576102929, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02835.html", "problem_id": "p02835", "resource_group": "medium_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/Kotlin/s804889589.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s804889589", "user_id": "u509162259"}, "prompt_components": {"gold_output": "win\n", "input_to_evaluate": "fun main(args: Array) {\n val s = readLine()!!.split(\" \").map(String::toInt)\n solver9(s)\n}\n\nfun solver9(s: List) {\n val ans = if (s.reduce { acc, i -> acc + i } > 21 ) \"bust\" else \"win\"\n println(ans)\n}", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 225, "cpu_time_ms": 234, "memory_kb": 37668}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s436794370", "group_id": "codeNet:p02835", "input_text": "fun main(args: Array) {\n if (readLine()!!.split(\" \").map(String::toInt).sum() > 21) {\n println(\"bust\")\n } else {\n println(\"win\")\n }\n}\n\n\n", "language": "Kotlin", "metadata": {"date": 1575856904, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02835.html", "problem_id": "p02835", "resource_group": "medium_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/Kotlin/s436794370.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s436794370", "user_id": "u085288971"}, "prompt_components": {"gold_output": "win\n", "input_to_evaluate": "fun main(args: Array) {\n if (readLine()!!.split(\" \").map(String::toInt).sum() > 21) {\n println(\"bust\")\n } else {\n println(\"win\")\n }\n}\n\n\n", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 274, "memory_kb": 37932}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s604598547", "group_id": "codeNet:p02835", "input_text": "fun main(args: Array) {\n val (a, b, c) = readLine()!!.split(' ').map(String::toLong)\n\n if (a+b+c>21) {\n println(\"bust\")\n } else {\n println(\"win\")\n }\n}", "language": "Kotlin", "metadata": {"date": 1575856832, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02835.html", "problem_id": "p02835", "resource_group": "medium_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/Kotlin/s604598547.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s604598547", "user_id": "u099066216"}, "prompt_components": {"gold_output": "win\n", "input_to_evaluate": "fun main(args: Array) {\n val (a, b, c) = readLine()!!.split(' ').map(String::toLong)\n\n if (a+b+c>21) {\n println(\"bust\")\n } else {\n println(\"win\")\n }\n}", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 184, "cpu_time_ms": 236, "memory_kb": 38176}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s954718413", "group_id": "codeNet:p02838", "input_text": "import java.io.PrintWriter\n\nfun next() = readLine()!!\nfun nextInt() = next().toInt()\nfun nextLong() = next().toLong()\nfun nextDouble() = next().toDouble()\nfun nextList() = next().split(\" \")\nfun nextIntList() = nextList().map(String::toInt)\nfun nextLongList() = nextList().map(String::toLong)\nfun nextDoubleList() = nextList().map(String::toDouble)\n\nval pw = PrintWriter(System.out)\nfun print(s: Any = \"\") = pw.print(s)\nfun println(s: Any = \"\") = pw.println(s)\n\nfun Iterable.join(separator: CharSequence = \", \", prefix: CharSequence = \"\", postfix: CharSequence = \"\") = joinToString(separator, prefix, postfix)\nfun Array.join(separator: CharSequence = \", \", prefix: CharSequence = \"\", postfix: CharSequence = \"\") = joinToString(separator, prefix, postfix)\n\nfun main(args: Array) {\n main()\n pw.flush()\n}\n\nfun main() {\n val N = nextInt()\n val A = nextLongList().toMutableList()\n var ans = MInt2(0)\n var base = MInt2(1)\n for (d in 1..60) {\n var one = 0L\n var zero = 0L\n for (i in A.indices) {\n if (A[i] and 1 == 0L) {\n zero++\n } else {\n one++\n }\n A[i] = A[i] shr 1\n }\n ans += base * (MInt2(one) * zero)\n base *= 2\n }\n println(ans)\n}\n\nclass MInt2 {\n private val MOD = 1000000007L\n var v: Long\n\n constructor(v: Long) {\n this.v = v % MOD\n }\n\n constructor(v: Int) {\n this.v = v.toLong() % MOD\n }\n\n operator fun plus(b: MInt2): MInt2 {\n val a = MInt2(v)\n a.v += b.v\n if (a.v >= MOD) a.v -= MOD\n return a\n }\n\n operator fun plus(b: Int) = plus(MInt2(b))\n operator fun plus(b: Long) = plus(MInt2(b))\n\n operator fun minus(b: MInt2): MInt2 {\n val a = MInt2(v)\n a.v -= b.v\n if (a.v < 0) a.v += MOD\n return a\n }\n\n operator fun minus(b: Int) = minus(MInt2(b))\n operator fun minus(b: Long) = minus(MInt2(b))\n\n operator fun times(b: Long) = times(MInt2(b))\n operator fun times(b: MInt2): MInt2 {\n val a = MInt2(v)\n a.v *= b.v\n a.v %= MOD\n return a\n }\n\n fun pow(N: Int) = pow(N.toLong())\n\n fun pow(N: Long): MInt2 {\n var ans = MInt2(1)\n var a = this\n var n = N\n while (n > 0) {\n if (n.and(1) == 1L) {\n ans *= a\n }\n a *= a\n n = n.shr(1)\n }\n return ans\n }\n\n override fun toString(): String {\n return v.toString()\n }\n}", "language": "Kotlin", "metadata": {"date": 1593322356, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02838.html", "problem_id": "p02838", "resource_group": "medium_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/Kotlin/s954718413.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s954718413", "user_id": "u860789370"}, "prompt_components": {"gold_output": "6\n", "input_to_evaluate": "import java.io.PrintWriter\n\nfun next() = readLine()!!\nfun nextInt() = next().toInt()\nfun nextLong() = next().toLong()\nfun nextDouble() = next().toDouble()\nfun nextList() = next().split(\" \")\nfun nextIntList() = nextList().map(String::toInt)\nfun nextLongList() = nextList().map(String::toLong)\nfun nextDoubleList() = nextList().map(String::toDouble)\n\nval pw = PrintWriter(System.out)\nfun print(s: Any = \"\") = pw.print(s)\nfun println(s: Any = \"\") = pw.println(s)\n\nfun Iterable.join(separator: CharSequence = \", \", prefix: CharSequence = \"\", postfix: CharSequence = \"\") = joinToString(separator, prefix, postfix)\nfun Array.join(separator: CharSequence = \", \", prefix: CharSequence = \"\", postfix: CharSequence = \"\") = joinToString(separator, prefix, postfix)\n\nfun main(args: Array) {\n main()\n pw.flush()\n}\n\nfun main() {\n val N = nextInt()\n val A = nextLongList().toMutableList()\n var ans = MInt2(0)\n var base = MInt2(1)\n for (d in 1..60) {\n var one = 0L\n var zero = 0L\n for (i in A.indices) {\n if (A[i] and 1 == 0L) {\n zero++\n } else {\n one++\n }\n A[i] = A[i] shr 1\n }\n ans += base * (MInt2(one) * zero)\n base *= 2\n }\n println(ans)\n}\n\nclass MInt2 {\n private val MOD = 1000000007L\n var v: Long\n\n constructor(v: Long) {\n this.v = v % MOD\n }\n\n constructor(v: Int) {\n this.v = v.toLong() % MOD\n }\n\n operator fun plus(b: MInt2): MInt2 {\n val a = MInt2(v)\n a.v += b.v\n if (a.v >= MOD) a.v -= MOD\n return a\n }\n\n operator fun plus(b: Int) = plus(MInt2(b))\n operator fun plus(b: Long) = plus(MInt2(b))\n\n operator fun minus(b: MInt2): MInt2 {\n val a = MInt2(v)\n a.v -= b.v\n if (a.v < 0) a.v += MOD\n return a\n }\n\n operator fun minus(b: Int) = minus(MInt2(b))\n operator fun minus(b: Long) = minus(MInt2(b))\n\n operator fun times(b: Long) = times(MInt2(b))\n operator fun times(b: MInt2): MInt2 {\n val a = MInt2(v)\n a.v *= b.v\n a.v %= MOD\n return a\n }\n\n fun pow(N: Int) = pow(N.toLong())\n\n fun pow(N: Long): MInt2 {\n var ans = MInt2(1)\n var a = this\n var n = N\n while (n > 0) {\n if (n.and(1) == 1L) {\n ans *= a\n }\n a *= a\n n = n.shr(1)\n }\n return ans\n }\n\n override fun toString(): String {\n return v.toString()\n }\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2531, "cpu_time_ms": 1064, "memory_kb": 102432}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s733175174", "group_id": "codeNet:p02838", "input_text": "import java.util.*\n\nfun main(args: Array) {\n val result = solve(Scanner(System.`in`))\n if (result.isNotEmpty()) println(result)\n}\n\nfun solve(`in`: String) = solve(Scanner(`in`))\n\nfun solve(sc: Scanner): String {\n val N = sc.nextInt()\n val A = (1..N).map { sc.nextLong() }\n val nA = A.count()\n val MOD = 1000000007L\n\n var ans: Long = 0L\n for (b in 0..60) {\n val bn = 1L shl b\n val n0 = A.count { it and bn == 0L }.toLong()\n ans += (bn % MOD) * (n0 * (nA - n0) % MOD)\n ans %= MOD\n }\n\n return ans.toString()\n}\n", "language": "Kotlin", "metadata": {"date": 1584053297, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02838.html", "problem_id": "p02838", "resource_group": "medium_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/Kotlin/s733175174.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s733175174", "user_id": "u297767059"}, "prompt_components": {"gold_output": "6\n", "input_to_evaluate": "import java.util.*\n\nfun main(args: Array) {\n val result = solve(Scanner(System.`in`))\n if (result.isNotEmpty()) println(result)\n}\n\nfun solve(`in`: String) = solve(Scanner(`in`))\n\nfun solve(sc: Scanner): String {\n val N = sc.nextInt()\n val A = (1..N).map { sc.nextLong() }\n val nA = A.count()\n val MOD = 1000000007L\n\n var ans: Long = 0L\n for (b in 0..60) {\n val bn = 1L shl b\n val n0 = A.count { it and bn == 0L }.toLong()\n ans += (bn % MOD) * (n0 * (nA - n0) % MOD)\n ans %= MOD\n }\n\n return ans.toString()\n}\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 573, "cpu_time_ms": 949, "memory_kb": 115636}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s404351821", "group_id": "codeNet:p02841", "input_text": "\nfun main(args:Array) {\n val mdmd = (0..1).map { readLine()!!.split(\" \").map { it.toInt() } }\n if(mdmd[0][0] == mdmd[1][0]) {\n println(0)\n } else {\n println(1)\n }\n}\n", "language": "Kotlin", "metadata": {"date": 1591667848, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02841.html", "problem_id": "p02841", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02841/input.txt", "sample_output_relpath": "derived/input_output/data/p02841/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02841/Kotlin/s404351821.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s404351821", "user_id": "u269969976"}, "prompt_components": {"gold_output": "0\n", "input_to_evaluate": "\nfun main(args:Array) {\n val mdmd = (0..1).map { readLine()!!.split(\" \").map { it.toInt() } }\n if(mdmd[0][0] == mdmd[1][0]) {\n println(0)\n } else {\n println(1)\n }\n}\n", "problem_context": "Score: 100 points\n\nProblem Statement\n\nIn this problem, a date is written as Y-M-D. For example, 2019-11-30 means November 30, 2019.\n\nIntegers M_1, D_1, M_2, and D_2 will be given as input.\n\nIt is known that the date 2019-M_2-D_2 follows 2019-M_1-D_1.\n\nDetermine whether the date 2019-M_1-D_1 is the last day of a month.\n\nConstraints\n\nBoth 2019-M_1-D_1 and 2019-M_2-D_2 are valid dates in the Gregorian calendar.\n\nThe date 2019-M_2-D_2 follows 2019-M_1-D_1.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nM_1 D_1\nM_2 D_2\n\nOutput\n\nIf the date 2019-M_1-D_1 is the last day of a month, print 1; otherwise, print 0.\n\nSample Input 1\n\n11 16\n11 17\n\nSample Output 1\n\n0\n\nNovember 16 is not the last day of a month.\n\nSample Input 2\n\n11 30\n12 1\n\nSample Output 2\n\n1\n\nNovember 30 is the last day of November.", "sample_input": "11 16\n11 17\n"}, "reference_outputs": ["0\n"], "source_document_id": "p02841", "source_text": "Score: 100 points\n\nProblem Statement\n\nIn this problem, a date is written as Y-M-D. For example, 2019-11-30 means November 30, 2019.\n\nIntegers M_1, D_1, M_2, and D_2 will be given as input.\n\nIt is known that the date 2019-M_2-D_2 follows 2019-M_1-D_1.\n\nDetermine whether the date 2019-M_1-D_1 is the last day of a month.\n\nConstraints\n\nBoth 2019-M_1-D_1 and 2019-M_2-D_2 are valid dates in the Gregorian calendar.\n\nThe date 2019-M_2-D_2 follows 2019-M_1-D_1.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nM_1 D_1\nM_2 D_2\n\nOutput\n\nIf the date 2019-M_1-D_1 is the last day of a month, print 1; otherwise, print 0.\n\nSample Input 1\n\n11 16\n11 17\n\nSample Output 1\n\n0\n\nNovember 16 is not the last day of a month.\n\nSample Input 2\n\n11 30\n12 1\n\nSample Output 2\n\n1\n\nNovember 30 is the last day of November.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 240, "memory_kb": 37968}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s637580014", "group_id": "codeNet:p02842", "input_text": "fun main(args: Array) {\n\n val n = readLine()!!.toInt()\n\n val answer = (0..n).filter { Math.floor(it * 1.08).toInt() == n }\n\n if (answer.size == 0) println(\":(\") else println(answer.first())\n}", "language": "Kotlin", "metadata": {"date": 1575258517, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02842.html", "problem_id": "p02842", "resource_group": "medium_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/Kotlin/s637580014.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s637580014", "user_id": "u108272327"}, "prompt_components": {"gold_output": "400\n", "input_to_evaluate": "fun main(args: Array) {\n\n val n = readLine()!!.toInt()\n\n val answer = (0..n).filter { Math.floor(it * 1.08).toInt() == n }\n\n if (answer.size == 0) println(\":(\") else println(answer.first())\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 235, "memory_kb": 33864}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s397429209", "group_id": "codeNet:p02845", "input_text": "fun intList() = readLine()?.split(\" \")?.map(String::toInt) ?: TODO()\nfun main() {\n val n = readLine()?.toInt() ?: return\n val a = intList()\n val m = 1000000007L\n var t = 3L\n if (a.first() != 0) {\n println(\"0\")\n return\n }\n val numbers = hashMapOf()\n numbers[0] = 1\n a.drop(1).forEach {\n val b = numbers.getOrPut(it) { 0 }\n numbers[it] = b + 1\n if (it == 0) {\n t = t * (3 - b) % m\n } else {\n t = t * (numbers.getOrDefault(it - 1, 1) - b) % m\n }\n }\n println(t.toString())\n}\n", "language": "Kotlin", "metadata": {"date": 1599345531, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02845.html", "problem_id": "p02845", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02845/input.txt", "sample_output_relpath": "derived/input_output/data/p02845/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02845/Kotlin/s397429209.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s397429209", "user_id": "u979429407"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "fun intList() = readLine()?.split(\" \")?.map(String::toInt) ?: TODO()\nfun main() {\n val n = readLine()?.toInt() ?: return\n val a = intList()\n val m = 1000000007L\n var t = 3L\n if (a.first() != 0) {\n println(\"0\")\n return\n }\n val numbers = hashMapOf()\n numbers[0] = 1\n a.drop(1).forEach {\n val b = numbers.getOrPut(it) { 0 }\n numbers[it] = b + 1\n if (it == 0) {\n t = t * (3 - b) % m\n } else {\n t = t * (numbers.getOrDefault(it - 1, 1) - b) % m\n }\n }\n println(t.toString())\n}\n", "problem_context": "Score: 500 points\n\nProblem Statement\n\nN people are standing in a queue, numbered 1, 2, 3, ..., N from front to back. Each person wears a hat, which is red, blue, or green.\n\nThe person numbered i says:\n\n\"In front of me, exactly A_i people are wearing hats with the same color as mine.\"\n\nAssuming that all these statements are correct, find the number of possible combinations of colors of the N people's hats.\n\nSince the count can be enormous, compute it modulo 1000000007.\n\nConstraints\n\n1 \\leq N \\leq 100000\n\n0 \\leq A_i \\leq N-1\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 the number of possible combinations of colors of the N people's hats, modulo 1000000007.\n\nSample Input 1\n\n6\n0 1 2 3 4 5\n\nSample Output 1\n\n3\n\nWe have three possible combinations, as follows:\n\nRed, Red, Red, Red, Red, Red\n\nBlue, Blue, Blue, Blue, Blue, Blue\n\nGreen, Green, Green, Green, Green, Green\n\nSample Input 2\n\n3\n0 0 0\n\nSample Output 2\n\n6\n\nSample Input 3\n\n54\n0 0 1 0 1 2 1 2 3 2 3 3 4 4 5 4 6 5 7 8 5 6 6 7 7 8 8 9 9 10 10 11 9 12 10 13 14 11 11 12 12 13 13 14 14 15 15 15 16 16 16 17 17 17\n\nSample Output 3\n\n115295190", "sample_input": "6\n0 1 2 3 4 5\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02845", "source_text": "Score: 500 points\n\nProblem Statement\n\nN people are standing in a queue, numbered 1, 2, 3, ..., N from front to back. Each person wears a hat, which is red, blue, or green.\n\nThe person numbered i says:\n\n\"In front of me, exactly A_i people are wearing hats with the same color as mine.\"\n\nAssuming that all these statements are correct, find the number of possible combinations of colors of the N people's hats.\n\nSince the count can be enormous, compute it modulo 1000000007.\n\nConstraints\n\n1 \\leq N \\leq 100000\n\n0 \\leq A_i \\leq N-1\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 the number of possible combinations of colors of the N people's hats, modulo 1000000007.\n\nSample Input 1\n\n6\n0 1 2 3 4 5\n\nSample Output 1\n\n3\n\nWe have three possible combinations, as follows:\n\nRed, Red, Red, Red, Red, Red\n\nBlue, Blue, Blue, Blue, Blue, Blue\n\nGreen, Green, Green, Green, Green, Green\n\nSample Input 2\n\n3\n0 0 0\n\nSample Output 2\n\n6\n\nSample Input 3\n\n54\n0 0 1 0 1 2 1 2 3 2 3 3 4 4 5 4 6 5 7 8 5 6 6 7 7 8 8 9 9 10 10 11 9 12 10 13 14 11 11 12 12 13 13 14 14 15 15 15 16 16 16 17 17 17\n\nSample Output 3\n\n115295190", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 382, "memory_kb": 59872}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s819369035", "group_id": "codeNet:p02847", "input_text": "import java.lang.Math\n\nfun main(args: Array)\n{\n val MOD: Long = 1000000007L // (1e+9)+7\n\n val s = readLine()!!\n when (s) {\n \"SUN\" -> {println(7)}\n \"MON\" -> {println(6)}\n \"TUE\" -> {println(5)}\n \"WED\" -> {println(4)}\n \"THU\" -> {println(3)}\n \"FRI\" -> {println(2)}\n \"SAT\" -> {println(1)}\n }\n}\n", "language": "Kotlin", "metadata": {"date": 1578486917, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02847.html", "problem_id": "p02847", "resource_group": "medium_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/Kotlin/s819369035.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s819369035", "user_id": "u118477733"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "import java.lang.Math\n\nfun main(args: Array)\n{\n val MOD: Long = 1000000007L // (1e+9)+7\n\n val s = readLine()!!\n when (s) {\n \"SUN\" -> {println(7)}\n \"MON\" -> {println(6)}\n \"TUE\" -> {println(5)}\n \"WED\" -> {println(4)}\n \"THU\" -> {println(3)}\n \"FRI\" -> {println(2)}\n \"SAT\" -> {println(1)}\n }\n}\n", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 199, "memory_kb": 31796}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s364472177", "group_id": "codeNet:p02847", "input_text": "fun main() {\n when (readLine()!!) {\n \"MON\" -> println(6)\n \"TUE\" -> println(5)\n \"WED\" -> println(4)\n \"THU\" -> println(3)\n \"FRI\" -> println(2)\n \"SAT\" -> println(1)\n \"SUN\" -> println(7)\n else -> println(-1)\n }\n}", "language": "Kotlin", "metadata": {"date": 1575508720, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02847.html", "problem_id": "p02847", "resource_group": "medium_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/Kotlin/s364472177.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s364472177", "user_id": "u669420827"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "fun main() {\n when (readLine()!!) {\n \"MON\" -> println(6)\n \"TUE\" -> println(5)\n \"WED\" -> println(4)\n \"THU\" -> println(3)\n \"FRI\" -> println(2)\n \"SAT\" -> println(1)\n \"SUN\" -> println(7)\n else -> println(-1)\n }\n}", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 158, "memory_kb": 31008}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s204007057", "group_id": "codeNet:p02848", "input_text": "import java.util.*\n\nfun main(args: Array) {\n val read = Scanner(System.`in`)\n\n val alphabetList = \"abcdefghijklmnopqrstuvwxyz\".toUpperCase()\n val n = read.nextInt()\n val s = read.next()\n var o :String = \"\"\n\n for(i in s.split(\"\").filter { it != \"\" }) {\n var originIndex = alphabetList.indexOf(i)\n var nextIndex = (originIndex + n) % 26\n o += (alphabetList[nextIndex])\n }\n\n println(o)\n}", "language": "Kotlin", "metadata": {"date": 1574650120, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02848.html", "problem_id": "p02848", "resource_group": "medium_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/Kotlin/s204007057.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s204007057", "user_id": "u240901574"}, "prompt_components": {"gold_output": "CDEZAB\n", "input_to_evaluate": "import java.util.*\n\nfun main(args: Array) {\n val read = Scanner(System.`in`)\n\n val alphabetList = \"abcdefghijklmnopqrstuvwxyz\".toUpperCase()\n val n = read.nextInt()\n val s = read.next()\n var o :String = \"\"\n\n for(i in s.split(\"\").filter { it != \"\" }) {\n var originIndex = alphabetList.indexOf(i)\n var nextIndex = (originIndex + n) % 26\n o += (alphabetList[nextIndex])\n }\n\n println(o)\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 541, "memory_kb": 120412}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s197116447", "group_id": "codeNet:p02848", "input_text": "fun main(args: Array) {\n val n = readLine()!!.toInt()\n val s = readLine()!!.toCharArray()\n\n var result = \"\"\n for (i in 0 until s.size) {\n var a = (((s[i].toInt() - 65 + n) % 26) + 65).toChar()\n result += a.toString()\n }\n println(result)\n}", "language": "Kotlin", "metadata": {"date": 1574648181, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02848.html", "problem_id": "p02848", "resource_group": "medium_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/Kotlin/s197116447.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s197116447", "user_id": "u388719350"}, "prompt_components": {"gold_output": "CDEZAB\n", "input_to_evaluate": "fun main(args: Array) {\n val n = readLine()!!.toInt()\n val s = readLine()!!.toCharArray()\n\n var result = \"\"\n for (i in 0 until s.size) {\n var a = (((s[i].toInt() - 65 + n) % 26) + 65).toChar()\n result += a.toString()\n }\n println(result)\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 357, "memory_kb": 114132}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s586876635", "group_id": "codeNet:p02850", "input_text": "fun main(args: Array) {\n val n = readLine()?.toInt() ?: return\n val vertex = Array(n + 1) { mutableListOf() }\n\n var colorCount = 0\n val result = buildString {\n repeat(n - 1) {\n val (a, b) = readLine()?.split(\" \")?.map(String::toInt) ?: return\n val va = vertex[a]\n val vb = vertex[b]\n val count = Math.max(va.size, vb.size)\n if (colorCount <= count) {\n colorCount = count + 1\n va.add(colorCount)\n vb.add(colorCount)\n appendln(colorCount)\n } else {\n val candidates = (va + vb).distinct()\n val color = (1.rangeTo(colorCount) - candidates).min()!!\n va.add(color)\n vb.add(color)\n appendln(color)\n }\n }\n }\n println(colorCount.toString())\n println(result)\n}", "language": "Kotlin", "metadata": {"date": 1587696659, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02850.html", "problem_id": "p02850", "resource_group": "medium_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/Kotlin/s586876635.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s586876635", "user_id": "u979429407"}, "prompt_components": {"gold_output": "2\n1\n2\n", "input_to_evaluate": "fun main(args: Array) {\n val n = readLine()?.toInt() ?: return\n val vertex = Array(n + 1) { mutableListOf() }\n\n var colorCount = 0\n val result = buildString {\n repeat(n - 1) {\n val (a, b) = readLine()?.split(\" \")?.map(String::toInt) ?: return\n val va = vertex[a]\n val vb = vertex[b]\n val count = Math.max(va.size, vb.size)\n if (colorCount <= count) {\n colorCount = count + 1\n va.add(colorCount)\n vb.add(colorCount)\n appendln(colorCount)\n } else {\n val candidates = (va + vb).distinct()\n val color = (1.rangeTo(colorCount) - candidates).min()!!\n va.add(color)\n vb.add(color)\n appendln(color)\n }\n }\n }\n println(colorCount.toString())\n println(result)\n}", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 2111, "memory_kb": 129536}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s764665801", "group_id": "codeNet:p02850", "input_text": "//DFSテンプレート\nfun main(args: Array) {\n val N = nextInt()\n val visit = Array(N) { false }\n val G = Array>(N) { mutableListOf() }\n val P = Array>(N-1) { Pair(0, 0) }\n repeat(N-1) {\n val (a, b) = listOfInt(-1)\n G[a].add(b)\n G[b].add(a)\n P[it] = Pair(a, b)\n }\n fun dfs(v: Int) {\n visit[v] = true\n for (next_v in G[v]) {\n if (visit[next_v]) continue\n dfs(next_v)\n }\n }\n var K = 0\n for (g in G) K = Math.max(K, g.count())\n println(K)\n val C = Array(N) { 0 }\n for (p in P) {\n println(C[p.first] + 1)\n C[p.first] += 1\n C[p.second] += 1\n }\n dfs(0)\n}\nfun next() = readLine()!!\nfun nextInt() = Integer.parseInt(next())\nfun listOfString() = next().split(\" \")\nfun listOfInt(delta: Int = 0) = listOfString().map { Integer.parseInt(it) + delta }\nfun printErr(value: Any) = System.err.println(value)", "language": "Kotlin", "metadata": {"date": 1574653583, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02850.html", "problem_id": "p02850", "resource_group": "medium_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/Kotlin/s764665801.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s764665801", "user_id": "u911700901"}, "prompt_components": {"gold_output": "2\n1\n2\n", "input_to_evaluate": "//DFSテンプレート\nfun main(args: Array) {\n val N = nextInt()\n val visit = Array(N) { false }\n val G = Array>(N) { mutableListOf() }\n val P = Array>(N-1) { Pair(0, 0) }\n repeat(N-1) {\n val (a, b) = listOfInt(-1)\n G[a].add(b)\n G[b].add(a)\n P[it] = Pair(a, b)\n }\n fun dfs(v: Int) {\n visit[v] = true\n for (next_v in G[v]) {\n if (visit[next_v]) continue\n dfs(next_v)\n }\n }\n var K = 0\n for (g in G) K = Math.max(K, g.count())\n println(K)\n val C = Array(N) { 0 }\n for (p in P) {\n println(C[p.first] + 1)\n C[p.first] += 1\n C[p.second] += 1\n }\n dfs(0)\n}\nfun next() = readLine()!!\nfun nextInt() = Integer.parseInt(next())\nfun listOfString() = next().split(\" \")\nfun listOfInt(delta: Int = 0) = listOfString().map { Integer.parseInt(it) + delta }\nfun printErr(value: Any) = System.err.println(value)", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1548, "memory_kb": 100912}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s091362312", "group_id": "codeNet:p02850", "input_text": "fun main(args: Array) {\n val N = nextInt()\n val visit = Array(N) { false }\n val G = Array>(N) { mutableListOf() }\n val P = Array>(N-1) { Pair(0, 0) }\n repeat(N-1) {\n val (a, b) = listOfInt(-1)\n G[a].add(b)\n G[b].add(a)\n P[it] = Pair(a, b)\n }\n var K = 0\n for (g in G) K = Math.max(K, g.count())\n println(K)\n val C = Array(N) { 0 }\n for (p in P) {\n println(C[p.first] + 1)\n C[p.first] += 1\n C[p.second] += 1\n }\n}\nfun next() = readLine()!!\nfun nextInt() = Integer.parseInt(next())\nfun listOfString() = next().split(\" \")\nfun listOfInt(delta: Int = 0) = listOfString().map { Integer.parseInt(it) + delta }\nfun printErr(value: Any) = System.err.println(value)", "language": "Kotlin", "metadata": {"date": 1574651989, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02850.html", "problem_id": "p02850", "resource_group": "medium_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/Kotlin/s091362312.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s091362312", "user_id": "u911700901"}, "prompt_components": {"gold_output": "2\n1\n2\n", "input_to_evaluate": "fun main(args: Array) {\n val N = nextInt()\n val visit = Array(N) { false }\n val G = Array>(N) { mutableListOf() }\n val P = Array>(N-1) { Pair(0, 0) }\n repeat(N-1) {\n val (a, b) = listOfInt(-1)\n G[a].add(b)\n G[b].add(a)\n P[it] = Pair(a, b)\n }\n var K = 0\n for (g in G) K = Math.max(K, g.count())\n println(K)\n val C = Array(N) { 0 }\n for (p in P) {\n println(C[p.first] + 1)\n C[p.first] += 1\n C[p.second] += 1\n }\n}\nfun next() = readLine()!!\nfun nextInt() = Integer.parseInt(next())\nfun listOfString() = next().split(\" \")\nfun listOfInt(delta: Int = 0) = listOfString().map { Integer.parseInt(it) + delta }\nfun printErr(value: Any) = System.err.println(value)", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 797, "cpu_time_ms": 1539, "memory_kb": 98972}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s911462480", "group_id": "codeNet:p02850", "input_text": "import java.math.*\n\nfun main(args: Array) {\n val N = readInputLine().toInt()\n // 双方向エッジ\n val edges = Array(N) { mutableListOf>() }\n \n for (i in 0 until N - 1) {\n val (a, b) = readInputLine().split(\" \").map { it.toInt() - 1 }\n edges[a].add(Pair(i, b))\n edges[b].add(Pair(i, a))\n }\n \n var color = 0\n \n for (i in 0 until N) {\n color = Math.max(color, edges[i].size)\n }\n \n println(color)\n \n val nodeColor = IntArray(N)\n val ans = IntArray(N - 1)\n\n for (i in 0 until N - 1) {\n var nowColor = 1\n for (e in edges[i]) {\n if (ans[e.first] != 0) {\n continue\n }\n if (nowColor == nodeColor[i]) {\n ans[e.first] = nowColor + 1\n nodeColor[e.second] = nowColor + 1\n nowColor += 2\n } else {\n ans[e.first] = nowColor\n nodeColor[e.second] = nowColor\n nowColor++\n }\n }\n }\n\n for (c in ans) {\n println(c)\n }\n}\n\nfun readInputLine(): String {\n return readLine()!!\n}\n", "language": "Kotlin", "metadata": {"date": 1574649566, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02850.html", "problem_id": "p02850", "resource_group": "medium_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/Kotlin/s911462480.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s911462480", "user_id": "u505558493"}, "prompt_components": {"gold_output": "2\n1\n2\n", "input_to_evaluate": "import java.math.*\n\nfun main(args: Array) {\n val N = readInputLine().toInt()\n // 双方向エッジ\n val edges = Array(N) { mutableListOf>() }\n \n for (i in 0 until N - 1) {\n val (a, b) = readInputLine().split(\" \").map { it.toInt() - 1 }\n edges[a].add(Pair(i, b))\n edges[b].add(Pair(i, a))\n }\n \n var color = 0\n \n for (i in 0 until N) {\n color = Math.max(color, edges[i].size)\n }\n \n println(color)\n \n val nodeColor = IntArray(N)\n val ans = IntArray(N - 1)\n\n for (i in 0 until N - 1) {\n var nowColor = 1\n for (e in edges[i]) {\n if (ans[e.first] != 0) {\n continue\n }\n if (nowColor == nodeColor[i]) {\n ans[e.first] = nowColor + 1\n nodeColor[e.second] = nowColor + 1\n nowColor += 2\n } else {\n ans[e.first] = nowColor\n nodeColor[e.second] = nowColor\n nowColor++\n }\n }\n }\n\n for (c in ans) {\n println(c)\n }\n}\n\nfun readInputLine(): String {\n return readLine()!!\n}\n", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1156, "cpu_time_ms": 1559, "memory_kb": 94508}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s218256648", "group_id": "codeNet:p02851", "input_text": "fun main(args: Array) = yorukatsu14f()\n\nfun yorukatsu14f() {\n val (n, k) = readLine()!!.split(' ').map { it.toInt() }\n val aList = readLine()!!.split(' ').map { it.toLong() - 1 }.toLongArray()\n\n val cSumMod = LongArray(n + 1)\n for (i in 0 until n) cSumMod[i + 1] = (cSumMod[i] + aList[i]) % k\n\n var answer = 0L\n val curr = mutableMapOf()\n\n for ((index, cs) in cSumMod.withIndex()) {\n answer += curr[cs] ?: 0\n curr[cs] = (curr[cs] ?: 0) + 1\n if (index + 1 >= k)\n curr[cSumMod[index + 1 - k]] = curr[cSumMod[index + 1 - k]]!! - 1\n }\n\n println(answer)\n}\n", "language": "Kotlin", "metadata": {"date": 1587014861, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02851.html", "problem_id": "p02851", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02851/input.txt", "sample_output_relpath": "derived/input_output/data/p02851/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02851/Kotlin/s218256648.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s218256648", "user_id": "u139478771"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "fun main(args: Array) = yorukatsu14f()\n\nfun yorukatsu14f() {\n val (n, k) = readLine()!!.split(' ').map { it.toInt() }\n val aList = readLine()!!.split(' ').map { it.toLong() - 1 }.toLongArray()\n\n val cSumMod = LongArray(n + 1)\n for (i in 0 until n) cSumMod[i + 1] = (cSumMod[i] + aList[i]) % k\n\n var answer = 0L\n val curr = mutableMapOf()\n\n for ((index, cs) in cSumMod.withIndex()) {\n answer += curr[cs] ?: 0\n curr[cs] = (curr[cs] ?: 0) + 1\n if (index + 1 >= k)\n curr[cSumMod[index + 1 - k]] = curr[cSumMod[index + 1 - k]]!! - 1\n }\n\n println(answer)\n}\n", "problem_context": "Score : 500 points\n\nProblem Statement\n\nGiven are a sequence of N positive integers A_1, A_2, \\ldots, A_N, and a positive integer K.\n\nFind the number of non-empty contiguous subsequences in A such that the remainder when dividing the sum of its elements by K is equal to the number of its elements. We consider two subsequences different if they are taken from different positions, even if they are equal sequences.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 2\\times 10^5\n\n1 \\leq K \\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 K\nA_1 A_2 \\cdots A_N\n\nOutput\n\nPrint the number of subsequences that satisfy the condition.\n\nSample Input 1\n\n5 4\n1 4 2 3 5\n\nSample Output 1\n\n4\n\nFour sequences satisfy the condition: (1), (4,2), (1,4,2), and (5).\n\nSample Input 2\n\n8 4\n4 2 4 2 4 2 4 2\n\nSample Output 2\n\n7\n\n(4,2) is counted four times, and (2,4) is counted three times.\n\nSample Input 3\n\n10 7\n14 15 92 65 35 89 79 32 38 46\n\nSample Output 3\n\n8", "sample_input": "5 4\n1 4 2 3 5\n"}, "reference_outputs": ["4\n"], "source_document_id": "p02851", "source_text": "Score : 500 points\n\nProblem Statement\n\nGiven are a sequence of N positive integers A_1, A_2, \\ldots, A_N, and a positive integer K.\n\nFind the number of non-empty contiguous subsequences in A such that the remainder when dividing the sum of its elements by K is equal to the number of its elements. We consider two subsequences different if they are taken from different positions, even if they are equal sequences.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 2\\times 10^5\n\n1 \\leq K \\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 K\nA_1 A_2 \\cdots A_N\n\nOutput\n\nPrint the number of subsequences that satisfy the condition.\n\nSample Input 1\n\n5 4\n1 4 2 3 5\n\nSample Output 1\n\n4\n\nFour sequences satisfy the condition: (1), (4,2), (1,4,2), and (5).\n\nSample Input 2\n\n8 4\n4 2 4 2 4 2 4 2\n\nSample Output 2\n\n7\n\n(4,2) is counted four times, and (2,4) is counted three times.\n\nSample Input 3\n\n10 7\n14 15 92 65 35 89 79 32 38 46\n\nSample Output 3\n\n8", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 630, "cpu_time_ms": 810, "memory_kb": 104240}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s575142840", "group_id": "codeNet:p02852", "input_text": "import java.util.*\n\nfun main(args: Array) {\n val (N, M) = readLine()!!.split(\" \").map{it.toInt()}\n val S = readLine()!!.toCharArray()\n val safe = TreeSet()\n\n for (i in S.indices) {\n if (S[i] == '0') {\n safe.add(i)\n }\n }\n\n val steps = ArrayList()\n\n var p = N\n\n while (p > 0) {\n val q = safe.ceiling(p - M)!!\n if (p == q) {\n println(-1)\n return\n }\n steps.add(p - q)\n p = q\n }\n\n steps.reverse()\n println(steps.joinToString(\" \"))\n}\n", "language": "Kotlin", "metadata": {"date": 1574652905, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02852.html", "problem_id": "p02852", "resource_group": "medium_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/Kotlin/s575142840.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s575142840", "user_id": "u183530284"}, "prompt_components": {"gold_output": "1 3 2 3\n", "input_to_evaluate": "import java.util.*\n\nfun main(args: Array) {\n val (N, M) = readLine()!!.split(\" \").map{it.toInt()}\n val S = readLine()!!.toCharArray()\n val safe = TreeSet()\n\n for (i in S.indices) {\n if (S[i] == '0') {\n safe.add(i)\n }\n }\n\n val steps = ArrayList()\n\n var p = N\n\n while (p > 0) {\n val q = safe.ceiling(p - M)!!\n if (p == q) {\n println(-1)\n return\n }\n steps.add(p - q)\n p = q\n }\n\n steps.reverse()\n println(steps.joinToString(\" \"))\n}\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 435, "memory_kb": 50724}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s905330141", "group_id": "codeNet:p02853", "input_text": "fun main(args: Array) {\n ddcc2020quala()\n}\n\nfun ddcc2020quala() {\n val xy = readLine()!!.split(' ').map { it.toInt() }\n\n val list = listOf(300000, 200000, 100000)\n val answer = if (xy.all { it == 1 }) 1000000 else xy.map { if (it in 1..3) list[it - 1] else 0 }.sum()\n \n println(answer)\n}\n", "language": "Kotlin", "metadata": {"date": 1574561066, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02853.html", "problem_id": "p02853", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02853/input.txt", "sample_output_relpath": "derived/input_output/data/p02853/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02853/Kotlin/s905330141.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s905330141", "user_id": "u139478771"}, "prompt_components": {"gold_output": "1000000\n", "input_to_evaluate": "fun main(args: Array) {\n ddcc2020quala()\n}\n\nfun ddcc2020quala() {\n val xy = readLine()!!.split(' ').map { it.toInt() }\n\n val list = listOf(300000, 200000, 100000)\n val answer = if (xy.all { it == 1 }) 1000000 else xy.map { if (it in 1..3) list[it - 1] else 0 }.sum()\n \n println(answer)\n}\n", "problem_context": "Score: 100 points\n\nProblem Statement\n\nWe held two competitions: Coding Contest and Robot Maneuver.\n\nIn each competition, the contestants taking the 3-rd, 2-nd, and 1-st places receive 100000, 200000, and 300000 yen (the currency of Japan), respectively. Furthermore, a contestant taking the first place in both competitions receives an additional 400000 yen.\n\nDISCO-Kun took the X-th place in Coding Contest and the Y-th place in Robot Maneuver.\nFind the total amount of money he earned.\n\nConstraints\n\n1 \\leq X \\leq 205\n\n1 \\leq Y \\leq 205\n\nX and Y are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX Y\n\nOutput\n\nPrint the amount of money DISCO-Kun earned, as an integer.\n\nSample Input 1\n\n1 1\n\nSample Output 1\n\n1000000\n\nIn this case, he earned 300000 yen in Coding Contest and another 300000 yen in Robot Maneuver. Furthermore, as he won both competitions, he got an additional 400000 yen.\nIn total, he made 300000 + 300000 + 400000 = 1000000 yen.\n\nSample Input 2\n\n3 101\n\nSample Output 2\n\n100000\n\nIn this case, he earned 100000 yen in Coding Contest.\n\nSample Input 3\n\n4 4\n\nSample Output 3\n\n0\n\nIn this case, unfortunately, he was the highest-ranked contestant without prize money in both competitions.", "sample_input": "1 1\n"}, "reference_outputs": ["1000000\n"], "source_document_id": "p02853", "source_text": "Score: 100 points\n\nProblem Statement\n\nWe held two competitions: Coding Contest and Robot Maneuver.\n\nIn each competition, the contestants taking the 3-rd, 2-nd, and 1-st places receive 100000, 200000, and 300000 yen (the currency of Japan), respectively. Furthermore, a contestant taking the first place in both competitions receives an additional 400000 yen.\n\nDISCO-Kun took the X-th place in Coding Contest and the Y-th place in Robot Maneuver.\nFind the total amount of money he earned.\n\nConstraints\n\n1 \\leq X \\leq 205\n\n1 \\leq Y \\leq 205\n\nX and Y are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX Y\n\nOutput\n\nPrint the amount of money DISCO-Kun earned, as an integer.\n\nSample Input 1\n\n1 1\n\nSample Output 1\n\n1000000\n\nIn this case, he earned 300000 yen in Coding Contest and another 300000 yen in Robot Maneuver. Furthermore, as he won both competitions, he got an additional 400000 yen.\nIn total, he made 300000 + 300000 + 400000 = 1000000 yen.\n\nSample Input 2\n\n3 101\n\nSample Output 2\n\n100000\n\nIn this case, he earned 100000 yen in Coding Contest.\n\nSample Input 3\n\n4 4\n\nSample Output 3\n\n0\n\nIn this case, unfortunately, he was the highest-ranked contestant without prize money in both competitions.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 314, "cpu_time_ms": 242, "memory_kb": 38260}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s120858462", "group_id": "codeNet:p02854", "input_text": "import java.io.BufferedReader\nimport java.io.InputStream\nimport java.io.InputStreamReader\nimport java.util.*\n\nfun main(args: Array) {\n val sc = FastScanner(System.`in`)\n\n val n = sc.nextInt()\n val a = Array(n) { sc.nextLong() }\n\n val sums = Array(n + 1) { 0L }\n for (i in 1..n) {\n sums[i] += sums[i - 1] + a[i - 1]\n }\n\n var best = -1L\n for (k in 1 until n) {\n val L = sums[k]\n var R = sums[n] - sums[k]\n var ans = L - R\n if (ans < 0) ans = -ans\n\n if(best == -1L || best > ans) best = ans\n }\n\n println(best)\n\n}\n\nclass FastScanner(s: InputStream) {\n private var st = StringTokenizer(\"\")\n private val br = BufferedReader(InputStreamReader(s))\n\n fun next(): String {\n while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())\n\n return st.nextToken()\n }\n\n fun nextInt() = next().toInt()\n fun nextLong() = next().toLong()\n fun nextLine() = br.readLine()\n fun nextDouble() = next().toDouble()\n fun ready() = br.ready()\n}\n", "language": "Kotlin", "metadata": {"date": 1580863131, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02854.html", "problem_id": "p02854", "resource_group": "medium_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/Kotlin/s120858462.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s120858462", "user_id": "u178770699"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "import java.io.BufferedReader\nimport java.io.InputStream\nimport java.io.InputStreamReader\nimport java.util.*\n\nfun main(args: Array) {\n val sc = FastScanner(System.`in`)\n\n val n = sc.nextInt()\n val a = Array(n) { sc.nextLong() }\n\n val sums = Array(n + 1) { 0L }\n for (i in 1..n) {\n sums[i] += sums[i - 1] + a[i - 1]\n }\n\n var best = -1L\n for (k in 1 until n) {\n val L = sums[k]\n var R = sums[n] - sums[k]\n var ans = L - R\n if (ans < 0) ans = -ans\n\n if(best == -1L || best > ans) best = ans\n }\n\n println(best)\n\n}\n\nclass FastScanner(s: InputStream) {\n private var st = StringTokenizer(\"\")\n private val br = BufferedReader(InputStreamReader(s))\n\n fun next(): String {\n while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())\n\n return st.nextToken()\n }\n\n fun nextInt() = next().toInt()\n fun nextLong() = next().toLong()\n fun nextLine() = br.readLine()\n fun nextDouble() = next().toDouble()\n fun ready() = br.ready()\n}\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1041, "cpu_time_ms": 465, "memory_kb": 80188}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s480194462", "group_id": "codeNet:p02856", "input_text": "import java.io.BufferedReader\nimport java.io.InputStream\nimport java.io.InputStreamReader\nimport java.io.PrintWriter\nimport java.lang.StringBuilder\nimport java.util.*\n\nfun PrintWriter.solve(sc: FastScanner) {\n val m = sc.nextInt()\n val d = Array(m) { 0 }\n val c = Array(m) { 0L }\n for (i in 0 until m) {\n d[i] = sc.nextInt()\n c[i] = sc.nextLong()\n }\n var digits = 0L\n var sum = 0L\n for (i in 0 until m) {\n digits += c[i]\n sum += d[i] * c[i]\n }\n println(digits + sum / 9 - 1)\n}\n\nfun main(args: Array) {\n val writer = PrintWriter(System.out, false)\n writer.solve(FastScanner(System.`in`))\n writer.flush()\n}\n\nclass FastScanner(s: InputStream) {\n private var st = StringTokenizer(\"\")\n private val br = BufferedReader(InputStreamReader(s))\n\n fun next(): String {\n while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())\n\n return st.nextToken()\n }\n\n fun nextInt() = next().toInt()\n fun nextLong() = next().toLong()\n fun nextLine() = br.readLine()\n fun nextDouble() = next().toDouble()\n fun ready() = br.ready()\n}\n", "language": "Kotlin", "metadata": {"date": 1587729564, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02856.html", "problem_id": "p02856", "resource_group": "medium_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/Kotlin/s480194462.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s480194462", "user_id": "u190507186"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "import java.io.BufferedReader\nimport java.io.InputStream\nimport java.io.InputStreamReader\nimport java.io.PrintWriter\nimport java.lang.StringBuilder\nimport java.util.*\n\nfun PrintWriter.solve(sc: FastScanner) {\n val m = sc.nextInt()\n val d = Array(m) { 0 }\n val c = Array(m) { 0L }\n for (i in 0 until m) {\n d[i] = sc.nextInt()\n c[i] = sc.nextLong()\n }\n var digits = 0L\n var sum = 0L\n for (i in 0 until m) {\n digits += c[i]\n sum += d[i] * c[i]\n }\n println(digits + sum / 9 - 1)\n}\n\nfun main(args: Array) {\n val writer = PrintWriter(System.out, false)\n writer.solve(FastScanner(System.`in`))\n writer.flush()\n}\n\nclass FastScanner(s: InputStream) {\n private var st = StringTokenizer(\"\")\n private val br = BufferedReader(InputStreamReader(s))\n\n fun next(): String {\n while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())\n\n return st.nextToken()\n }\n\n fun nextInt() = next().toInt()\n fun nextLong() = next().toLong()\n fun nextLine() = br.readLine()\n fun nextDouble() = next().toDouble()\n fun ready() = br.ready()\n}\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1131, "cpu_time_ms": 445, "memory_kb": 56736}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s824666162", "group_id": "codeNet:p02856", "input_text": "import java.util.*\n\nfun main(args: Array) {\n var sum = 0L\n var res = 0L\n\n val M = readLine()!!.toInt()\n\n for (i in 1 .. M) {\n val (d, c) = readLine()!!.split(\" \").map{it.toLong()}\n\n sum += d * c\n res += c\n }\n\n res--\n\n while(sum >= 10) {\n res += sum / 9\n sum -= sum / 9 * 9\n }\n\n println(res)\n}\n", "language": "Kotlin", "metadata": {"date": 1574570256, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02856.html", "problem_id": "p02856", "resource_group": "medium_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/Kotlin/s824666162.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s824666162", "user_id": "u183530284"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "import java.util.*\n\nfun main(args: Array) {\n var sum = 0L\n var res = 0L\n\n val M = readLine()!!.toInt()\n\n for (i in 1 .. M) {\n val (d, c) = readLine()!!.split(\" \").map{it.toLong()}\n\n sum += d * c\n res += c\n }\n\n res--\n\n while(sum >= 10) {\n res += sum / 9\n sum -= sum / 9 * 9\n }\n\n println(res)\n}\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 607, "memory_kb": 72608}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s648053621", "group_id": "codeNet:p02859", "input_text": "fun main(args: Array) {\n val r = readLine()!!.toInt()\n println(r*r)\n}", "language": "Kotlin", "metadata": {"date": 1575762934, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02859.html", "problem_id": "p02859", "resource_group": "medium_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/Kotlin/s648053621.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s648053621", "user_id": "u777283665"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "fun main(args: Array) {\n val r = readLine()!!.toInt()\n println(r*r)\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 202, "memory_kb": 31844}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s948760057", "group_id": "codeNet:p02860", "input_text": "fun main(args: Array){\n var count = 0\n val r = readLine()!!.toInt()\n val s = readLine()!!.split(\"\").filter { it != \"\"}\n var result = \"No\"\n if (r % 2 == 0) {\n if (s.size == r) {\n var a = 0\n for (i in a..r / 2 - 1) {\n if (s[i] != s[r / 2 + i]) {\n count++\n }\n }\n if (count == 0) {\n println(\"Yes\")\n return\n }\n }\n }\n println(result)\n}", "language": "Kotlin", "metadata": {"date": 1586971013, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02860.html", "problem_id": "p02860", "resource_group": "medium_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/Kotlin/s948760057.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s948760057", "user_id": "u446699896"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "fun main(args: Array){\n var count = 0\n val r = readLine()!!.toInt()\n val s = readLine()!!.split(\"\").filter { it != \"\"}\n var result = \"No\"\n if (r % 2 == 0) {\n if (s.size == r) {\n var a = 0\n for (i in a..r / 2 - 1) {\n if (s[i] != s[r / 2 + i]) {\n count++\n }\n }\n if (count == 0) {\n println(\"Yes\")\n return\n }\n }\n }\n println(result)\n}", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 506, "cpu_time_ms": 246, "memory_kb": 37864}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s780663318", "group_id": "codeNet:p02860", "input_text": "fun main(args: Array){\n var count = 0\n val r = readLine()!!.toInt()\n val s = readLine()!!.split(\"\").filter { it != \"\"}\n if (r % 2 == 0) {\n if (s.size == r) {\n var i = 0\n for ( i in i..r/2-1) {\n if (s[i] != s[r/2+i]) {\n count ++\n }\n }\n if (count == 0) {\n print(\"YES\")\n } else {\n print(\"NO\")\n }\n } else {\n print(\"NO\")\n }\n } else {\n print(\"NO\")\n }\n}", "language": "Kotlin", "metadata": {"date": 1586491336, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02860.html", "problem_id": "p02860", "resource_group": "medium_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/Kotlin/s780663318.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s780663318", "user_id": "u446699896"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "fun main(args: Array){\n var count = 0\n val r = readLine()!!.toInt()\n val s = readLine()!!.split(\"\").filter { it != \"\"}\n if (r % 2 == 0) {\n if (s.size == r) {\n var i = 0\n for ( i in i..r/2-1) {\n if (s[i] != s[r/2+i]) {\n count ++\n }\n }\n if (count == 0) {\n print(\"YES\")\n } else {\n print(\"NO\")\n }\n } else {\n print(\"NO\")\n }\n } else {\n print(\"NO\")\n }\n}", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 556, "cpu_time_ms": 233, "memory_kb": 37868}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s340910597", "group_id": "codeNet:p02860", "input_text": "fun main(args: Array) {\n val n = readLine()!!.toInt()\n val s = readLine()!!\n val ans = if (s.slice(0 until n / 2) == s.slice(n / 2 until n)) {\n \"Yes\"\n } else {\n \"No\"\n }\n println(ans)\n}\n", "language": "Kotlin", "metadata": {"date": 1581208448, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02860.html", "problem_id": "p02860", "resource_group": "medium_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/Kotlin/s340910597.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s340910597", "user_id": "u863309603"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "fun main(args: Array) {\n val n = readLine()!!.toInt()\n val s = readLine()!!\n val ans = if (s.slice(0 until n / 2) == s.slice(n / 2 until n)) {\n \"Yes\"\n } else {\n \"No\"\n }\n println(ans)\n}\n", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 225, "cpu_time_ms": 226, "memory_kb": 31872}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s120574158", "group_id": "codeNet:p02861", "input_text": "fun main(args: Array) {\n val N = readLine()!!.toInt()\n val P = Array(N) {\n val (x, y) = readLine()!!.split(\" \").map(String::toDouble)\n V(x, y)\n }\n// val distances = P.toPairs().map { it.first.distanceTo(it.second) }\n// val pairs = mutableListOf>()\n// for (i in 0 until P.size - 1) {\n// for (j in i + 1 until P.size) {\n// pairs += Pair(P[i], P[j])\n// }\n// }\n// val distances = pairs.map { it.first.distanceTo(it.second) }\n// val ans = distances.sum() * fact(N - 1) * 2 / fact(N)\n val ans = 0\n println(ans)\n}\n\ndata class V(val x: Double, val y: Double) {\n fun distanceTo(o: V) = Math.sqrt((x - o.x) * (x - o.x) + (y - o.y) * (y - o.y))\n}\n\nfun fact(n: Int) = (1..n).reduce { i, j -> i * j }\n\n//fun Array.toPairs(): Array> {\n// val ret = mutableListOf>()\n// for (i in 0 until this.size - 1) {\n// for (j in i + 1 until this.size) {\n// ret += Pair(this[i], this[j])\n// }\n// }\n// return ret.toTypedArray()\n//}", "language": "Kotlin", "metadata": {"date": 1590215272, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02861.html", "problem_id": "p02861", "resource_group": "medium_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/Kotlin/s120574158.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s120574158", "user_id": "u860789370"}, "prompt_components": {"gold_output": "2.2761423749\n", "input_to_evaluate": "fun main(args: Array) {\n val N = readLine()!!.toInt()\n val P = Array(N) {\n val (x, y) = readLine()!!.split(\" \").map(String::toDouble)\n V(x, y)\n }\n// val distances = P.toPairs().map { it.first.distanceTo(it.second) }\n// val pairs = mutableListOf>()\n// for (i in 0 until P.size - 1) {\n// for (j in i + 1 until P.size) {\n// pairs += Pair(P[i], P[j])\n// }\n// }\n// val distances = pairs.map { it.first.distanceTo(it.second) }\n// val ans = distances.sum() * fact(N - 1) * 2 / fact(N)\n val ans = 0\n println(ans)\n}\n\ndata class V(val x: Double, val y: Double) {\n fun distanceTo(o: V) = Math.sqrt((x - o.x) * (x - o.x) + (y - o.y) * (y - o.y))\n}\n\nfun fact(n: Int) = (1..n).reduce { i, j -> i * j }\n\n//fun Array.toPairs(): Array> {\n// val ret = mutableListOf>()\n// for (i in 0 until this.size - 1) {\n// for (j in i + 1 until this.size) {\n// ret += Pair(this[i], this[j])\n// }\n// }\n// return ret.toTypedArray()\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1062, "cpu_time_ms": 238, "memory_kb": 37896}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s654105207", "group_id": "codeNet:p02863", "input_text": "import java.math.*\n\nfun main(args: Array) {\n val (N, T) = readInputLine().split(\" \").map { it.toInt() }\n \n val dishes = Array(N) { Pair(0, 0) }\n\n for (i in 0 until N) {\n val (A, B) = readInputLine().split(\" \").map { it.toInt() }\n dishes[i] = Pair(A, B)\n }\n \n val dp1 = Array(N) { IntArray(T) }\n val dp2 = Array(N) { IntArray(T) }\n \n for (i in 1 until T) {\n for (j in 0 until N) {\n if (j == 0) {\n if (dishes[0].first <= i) {\n dp1[0][i] = dishes[0].second\n }\n if (dishes[N - 1].second <= i) {\n dp2[N - 1][i] = dishes[N - 1].second\n }\n } else {\n if (dishes[j].first <= i) {\n dp1[j][i] = Math.max(dp1[j - 1][i], dp1[j - 1][i - dishes[j].first] + dishes[j].second)\n } else {\n dp1[j][i] = dp1[j - 1][i]\n }\n \n if (dishes[N - j - 1].first <= i) {\n dp2[N - j - 1][i] = Math.max(dp2[N - j][i], dp2[N - j][i - dishes[N - j - 1].first] + dishes[N - j - 1].second)\n } else {\n dp2[N - j - 1][i] = dp2[N - j][i]\n }\n }\n }\n }\n\n var ans = 0\n\n for (i in 0 until N) {\n if (i == 0) {\n ans = Math.max(ans, dp2[i + 1][T - 1] + dishes[0].second)\n } else if (i == N - 1) {\n ans = Math.max(ans, dp1[i - 1][T - 1] + dishes[N - 1].second)\n } else {\n ans = Math.max(ans, Math.max(dp1[i - 1][T - 1], dp2[i + 1][T - 1]) + dishes[i].second)\n }\n }\n\n println(ans)\n}\n\nfun readInputLine(): String {\n return readLine()!!\n}\n\n", "language": "Kotlin", "metadata": {"date": 1573965185, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02863.html", "problem_id": "p02863", "resource_group": "medium_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/Kotlin/s654105207.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s654105207", "user_id": "u505558493"}, "prompt_components": {"gold_output": "110\n", "input_to_evaluate": "import java.math.*\n\nfun main(args: Array) {\n val (N, T) = readInputLine().split(\" \").map { it.toInt() }\n \n val dishes = Array(N) { Pair(0, 0) }\n\n for (i in 0 until N) {\n val (A, B) = readInputLine().split(\" \").map { it.toInt() }\n dishes[i] = Pair(A, B)\n }\n \n val dp1 = Array(N) { IntArray(T) }\n val dp2 = Array(N) { IntArray(T) }\n \n for (i in 1 until T) {\n for (j in 0 until N) {\n if (j == 0) {\n if (dishes[0].first <= i) {\n dp1[0][i] = dishes[0].second\n }\n if (dishes[N - 1].second <= i) {\n dp2[N - 1][i] = dishes[N - 1].second\n }\n } else {\n if (dishes[j].first <= i) {\n dp1[j][i] = Math.max(dp1[j - 1][i], dp1[j - 1][i - dishes[j].first] + dishes[j].second)\n } else {\n dp1[j][i] = dp1[j - 1][i]\n }\n \n if (dishes[N - j - 1].first <= i) {\n dp2[N - j - 1][i] = Math.max(dp2[N - j][i], dp2[N - j][i - dishes[N - j - 1].first] + dishes[N - j - 1].second)\n } else {\n dp2[N - j - 1][i] = dp2[N - j][i]\n }\n }\n }\n }\n\n var ans = 0\n\n for (i in 0 until N) {\n if (i == 0) {\n ans = Math.max(ans, dp2[i + 1][T - 1] + dishes[0].second)\n } else if (i == N - 1) {\n ans = Math.max(ans, dp1[i - 1][T - 1] + dishes[N - 1].second)\n } else {\n ans = Math.max(ans, Math.max(dp1[i - 1][T - 1], dp2[i + 1][T - 1]) + dishes[i].second)\n }\n }\n\n println(ans)\n}\n\nfun readInputLine(): String {\n return readLine()!!\n}\n\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1744, "cpu_time_ms": 748, "memory_kb": 131680}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s276136155", "group_id": "codeNet:p02866", "input_text": "val MOD = 998244353\n\nfun main(args : Array) {\n val n = readLine()!!.toInt()\n val dd = readLine()!!.split(\" \").map{it.toInt()}\n\n if (dd[0] != 0) {\n println(0)\n return\n }\n\n val groups = mutableMapOf()\n var max = 0\n dd.forEach {\n groups[it] = (groups[it] ?: 0) + 1\n if (it > max) max = it\n }\n\n var sum = 1L\n for (i in max downTo 1) {\n val cnt = groups[i] ?: 0\n val nextCnt = groups[i-1] ?: 0\n if (cnt == 0 || nextCnt == 0) {\n println(0)\n return\n }\n\n sum *= modPow(nextCnt, cnt)\n sum %= MOD\n }\n\n println(sum % MOD)\n}\n\nfun modPow(base: Int, pow: Int): Long {\n var ans = 1L\n repeat(pow) {\n ans *= base\n ans %= MOD\n }\n return ans\n}", "language": "Kotlin", "metadata": {"date": 1573355915, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02866.html", "problem_id": "p02866", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02866/input.txt", "sample_output_relpath": "derived/input_output/data/p02866/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02866/Kotlin/s276136155.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s276136155", "user_id": "u262403099"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "val MOD = 998244353\n\nfun main(args : Array) {\n val n = readLine()!!.toInt()\n val dd = readLine()!!.split(\" \").map{it.toInt()}\n\n if (dd[0] != 0) {\n println(0)\n return\n }\n\n val groups = mutableMapOf()\n var max = 0\n dd.forEach {\n groups[it] = (groups[it] ?: 0) + 1\n if (it > max) max = it\n }\n\n var sum = 1L\n for (i in max downTo 1) {\n val cnt = groups[i] ?: 0\n val nextCnt = groups[i-1] ?: 0\n if (cnt == 0 || nextCnt == 0) {\n println(0)\n return\n }\n\n sum *= modPow(nextCnt, cnt)\n sum %= MOD\n }\n\n println(sum % MOD)\n}\n\nfun modPow(base: Int, pow: Int): Long {\n var ans = 1L\n repeat(pow) {\n ans *= base\n ans %= MOD\n }\n return ans\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nGiven is an integer sequence D_1,...,D_N of N elements. Find the number, modulo 998244353, of trees with N vertices numbered 1 to N that satisfy the following condition:\n\nFor every integer i from 1 to N, the distance between Vertex 1 and Vertex i is D_i.\n\nNotes\n\nA tree of N vertices is a connected undirected graph with N vertices and N-1 edges, and the distance between two vertices are the number of edges in the shortest path between them.\n\nTwo trees are considered different if and only if there are two vertices x and y such that there is an edge between x and y in one of those trees and not in the other.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n0 \\leq D_i \\leq N-1\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nD_1 D_2 ... D_N\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n4\n0 1 1 2\n\nSample Output 1\n\n2\n\nFor example, a tree with edges (1,2), (1,3), and (2,4) satisfies the condition.\n\nSample Input 2\n\n4\n1 1 1 1\n\nSample Output 2\n\n0\n\nSample Input 3\n\n7\n0 3 2 1 2 2 1\n\nSample Output 3\n\n24", "sample_input": "4\n0 1 1 2\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02866", "source_text": "Score : 300 points\n\nProblem Statement\n\nGiven is an integer sequence D_1,...,D_N of N elements. Find the number, modulo 998244353, of trees with N vertices numbered 1 to N that satisfy the following condition:\n\nFor every integer i from 1 to N, the distance between Vertex 1 and Vertex i is D_i.\n\nNotes\n\nA tree of N vertices is a connected undirected graph with N vertices and N-1 edges, and the distance between two vertices are the number of edges in the shortest path between them.\n\nTwo trees are considered different if and only if there are two vertices x and y such that there is an edge between x and y in one of those trees and not in the other.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n0 \\leq D_i \\leq N-1\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nD_1 D_2 ... D_N\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n4\n0 1 1 2\n\nSample Output 1\n\n2\n\nFor example, a tree with edges (1,2), (1,3), and (2,4) satisfies the condition.\n\nSample Input 2\n\n4\n1 1 1 1\n\nSample Output 2\n\n0\n\nSample Input 3\n\n7\n0 3 2 1 2 2 1\n\nSample Output 3\n\n24", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 796, "cpu_time_ms": 605, "memory_kb": 57992}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s472417029", "group_id": "codeNet:p02866", "input_text": "fun main(args: Array) {\n val n = readLine()!!.toInt()\n val ds = Array(1000000) { 0 }\n val dTmp = readIntegers()\n for (i in 1..n) {\n val d = dTmp[i - 1]\n ds[d]++\n\n if (i == 1 && d != 0) {\n println(0)\n return\n }\n\n if (i != 1 && d == 0) {\n println(0)\n return\n }\n }\n\n var ans = 1L\n val mod = 998244353L\n for (i in 1 until (1000000 - 1)) {\n var pow = 1L\n for (j in 1..ds[i + 1]) {\n pow = (pow * ds[i]) % mod\n }\n ans = (ans * pow) % mod\n }\n println(ans)\n}\n\nfun readStrings() = readLine()!!.split(\" \")\nfun readIntegers() = readStrings().map(String::toInt)\n", "language": "Kotlin", "metadata": {"date": 1573353364, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02866.html", "problem_id": "p02866", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02866/input.txt", "sample_output_relpath": "derived/input_output/data/p02866/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02866/Kotlin/s472417029.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s472417029", "user_id": "u784448849"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "fun main(args: Array) {\n val n = readLine()!!.toInt()\n val ds = Array(1000000) { 0 }\n val dTmp = readIntegers()\n for (i in 1..n) {\n val d = dTmp[i - 1]\n ds[d]++\n\n if (i == 1 && d != 0) {\n println(0)\n return\n }\n\n if (i != 1 && d == 0) {\n println(0)\n return\n }\n }\n\n var ans = 1L\n val mod = 998244353L\n for (i in 1 until (1000000 - 1)) {\n var pow = 1L\n for (j in 1..ds[i + 1]) {\n pow = (pow * ds[i]) % mod\n }\n ans = (ans * pow) % mod\n }\n println(ans)\n}\n\nfun readStrings() = readLine()!!.split(\" \")\nfun readIntegers() = readStrings().map(String::toInt)\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nGiven is an integer sequence D_1,...,D_N of N elements. Find the number, modulo 998244353, of trees with N vertices numbered 1 to N that satisfy the following condition:\n\nFor every integer i from 1 to N, the distance between Vertex 1 and Vertex i is D_i.\n\nNotes\n\nA tree of N vertices is a connected undirected graph with N vertices and N-1 edges, and the distance between two vertices are the number of edges in the shortest path between them.\n\nTwo trees are considered different if and only if there are two vertices x and y such that there is an edge between x and y in one of those trees and not in the other.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n0 \\leq D_i \\leq N-1\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nD_1 D_2 ... D_N\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n4\n0 1 1 2\n\nSample Output 1\n\n2\n\nFor example, a tree with edges (1,2), (1,3), and (2,4) satisfies the condition.\n\nSample Input 2\n\n4\n1 1 1 1\n\nSample Output 2\n\n0\n\nSample Input 3\n\n7\n0 3 2 1 2 2 1\n\nSample Output 3\n\n24", "sample_input": "4\n0 1 1 2\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02866", "source_text": "Score : 300 points\n\nProblem Statement\n\nGiven is an integer sequence D_1,...,D_N of N elements. Find the number, modulo 998244353, of trees with N vertices numbered 1 to N that satisfy the following condition:\n\nFor every integer i from 1 to N, the distance between Vertex 1 and Vertex i is D_i.\n\nNotes\n\nA tree of N vertices is a connected undirected graph with N vertices and N-1 edges, and the distance between two vertices are the number of edges in the shortest path between them.\n\nTwo trees are considered different if and only if there are two vertices x and y such that there is an edge between x and y in one of those trees and not in the other.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n0 \\leq D_i \\leq N-1\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nD_1 D_2 ... D_N\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n4\n0 1 1 2\n\nSample Output 1\n\n2\n\nFor example, a tree with edges (1,2), (1,3), and (2,4) satisfies the condition.\n\nSample Input 2\n\n4\n1 1 1 1\n\nSample Output 2\n\n0\n\nSample Input 3\n\n7\n0 3 2 1 2 2 1\n\nSample Output 3\n\n24", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 712, "cpu_time_ms": 541, "memory_kb": 62300}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s704659456", "group_id": "codeNet:p02868", "input_text": "import java.math.*\n\nfun main(args: Array) {\n val (N, M) = readInputLine().split(\" \").map { it.toInt() }\n \n val route = mutableListOf>()\n \n for (i in 1..M) {\n val (L, R, C) = readInputLine().split(\" \").map { it.toInt() }\n route.add(Triple(L - 1, R - 1, C.toLong()))\n }\n \n route.sortBy { it.second }\n route.sortBy { it.first }\n \n var size = 1\n while (size < N) {\n size *= 2\n }\n \n val segTree = LongArray(size * 2 - 1) { Long.MAX_VALUE }\n \n fun update(x: Int, value: Long) {\n var tmp = x + size - 1\n \n segTree[tmp] = value\n while (tmp > 0) {\n tmp = (tmp - 1) / 2\n segTree[tmp] = Math.min(segTree[2 * tmp + 1], segTree[2 * tmp + 2])\n }\n }\n \n fun getMin(a: Int, b: Int, k: Int = 0, l: Int = 0, r: Int = size): Long {\n if (r <= a || b <= l) {\n return Long.MAX_VALUE\n }\n if (a <= l && r <= b) {\n return segTree[k]\n }\n \n val vl = getMin(a, b, 2 * k + 1, l, (l + r) / 2)\n val vr = getMin(a, b, 2 * k + 2, (l + r) / 2, r)\n \n return Math.min(vl, vr)\n }\n \n update(0, 0L)\n\n for (r in route) {\n val (L, R, C) = r\n\n val nowCost = getMin(L, R + 1)\n \n if (nowCost == Long.MAX_VALUE) {\n break\n }\n\n if (segTree[R + size - 1] > nowCost + C) {\n update(R, nowCost + C)\n }\n }\n\n if (segTree[size - 1] == Long.MAX_VALUE) {\n println(-1)\n } else {\n println(segTree[(N - 1) + size - 1])\n }\n}\n\nfun readInputLine(): String {\n return readLine()!!\n}\n", "language": "Kotlin", "metadata": {"date": 1573358594, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02868.html", "problem_id": "p02868", "resource_group": "medium_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/Kotlin/s704659456.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s704659456", "user_id": "u505558493"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "import java.math.*\n\nfun main(args: Array) {\n val (N, M) = readInputLine().split(\" \").map { it.toInt() }\n \n val route = mutableListOf>()\n \n for (i in 1..M) {\n val (L, R, C) = readInputLine().split(\" \").map { it.toInt() }\n route.add(Triple(L - 1, R - 1, C.toLong()))\n }\n \n route.sortBy { it.second }\n route.sortBy { it.first }\n \n var size = 1\n while (size < N) {\n size *= 2\n }\n \n val segTree = LongArray(size * 2 - 1) { Long.MAX_VALUE }\n \n fun update(x: Int, value: Long) {\n var tmp = x + size - 1\n \n segTree[tmp] = value\n while (tmp > 0) {\n tmp = (tmp - 1) / 2\n segTree[tmp] = Math.min(segTree[2 * tmp + 1], segTree[2 * tmp + 2])\n }\n }\n \n fun getMin(a: Int, b: Int, k: Int = 0, l: Int = 0, r: Int = size): Long {\n if (r <= a || b <= l) {\n return Long.MAX_VALUE\n }\n if (a <= l && r <= b) {\n return segTree[k]\n }\n \n val vl = getMin(a, b, 2 * k + 1, l, (l + r) / 2)\n val vr = getMin(a, b, 2 * k + 2, (l + r) / 2, r)\n \n return Math.min(vl, vr)\n }\n \n update(0, 0L)\n\n for (r in route) {\n val (L, R, C) = r\n\n val nowCost = getMin(L, R + 1)\n \n if (nowCost == Long.MAX_VALUE) {\n break\n }\n\n if (segTree[R + size - 1] > nowCost + C) {\n update(R, nowCost + C)\n }\n }\n\n if (segTree[size - 1] == Long.MAX_VALUE) {\n println(-1)\n } else {\n println(segTree[(N - 1) + size - 1])\n }\n}\n\nfun readInputLine(): String {\n return readLine()!!\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1684, "cpu_time_ms": 1212, "memory_kb": 109440}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s773980055", "group_id": "codeNet:p02868", "input_text": "import java.math.*\n\nfun main(args: Array) {\n val (N, M) = readInputLine().split(\" \").map { it.toInt() }\n \n val route = mutableListOf>()\n \n for (i in 1..M) {\n val (L, R, C) = readInputLine().split(\" \").map { it.toInt() }\n route.add(Triple(L - 1, R - 1, C.toLong()))\n }\n \n route.sortBy { it.first }\n route.sortByDescending { it.second }\n \n var size = 1\n while (size < N) {\n size *= 2\n }\n \n val segTree = LongArray(size * 2 - 1) { Long.MAX_VALUE }\n \n fun update(x: Int, value: Long) {\n var tmp = x + size - 1\n \n segTree[tmp] = value\n while (tmp > 0) {\n tmp = (tmp - 1) / 2\n segTree[tmp] = Math.min(segTree[2 * tmp + 1], segTree[2 * tmp + 2])\n }\n }\n \n fun getMin(a: Int, b: Int, k: Int = 0, l: Int = 0, r: Int = size): Long {\n if (r <= a || b <= l) {\n return Long.MAX_VALUE\n }\n if (a <= l && r <= b) {\n return segTree[k]\n }\n \n val vl = getMin(a, b, 2 * k + 1, l, (l + r) / 2)\n val vr = getMin(a, b, 2 * k + 2, (l + r) / 2, r)\n \n return Math.min(vl, vr)\n }\n \n update(N - 1, 0L)\n\n for (r in route) {\n val (L, R, C) = r\n\n val nowCost = getMin(L, R + 1)\n \n if (nowCost == Long.MAX_VALUE) {\n break\n }\n\n if (segTree[L + size - 1] > nowCost + C) {\n update(L, nowCost + C)\n }\n }\n\n if (segTree[size - 1] == Long.MAX_VALUE) {\n println(-1)\n } else {\n println(segTree[size - 1])\n }\n}\n\nfun readInputLine(): String {\n return readLine()!!\n}\n", "language": "Kotlin", "metadata": {"date": 1573357519, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02868.html", "problem_id": "p02868", "resource_group": "medium_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/Kotlin/s773980055.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s773980055", "user_id": "u505558493"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "import java.math.*\n\nfun main(args: Array) {\n val (N, M) = readInputLine().split(\" \").map { it.toInt() }\n \n val route = mutableListOf>()\n \n for (i in 1..M) {\n val (L, R, C) = readInputLine().split(\" \").map { it.toInt() }\n route.add(Triple(L - 1, R - 1, C.toLong()))\n }\n \n route.sortBy { it.first }\n route.sortByDescending { it.second }\n \n var size = 1\n while (size < N) {\n size *= 2\n }\n \n val segTree = LongArray(size * 2 - 1) { Long.MAX_VALUE }\n \n fun update(x: Int, value: Long) {\n var tmp = x + size - 1\n \n segTree[tmp] = value\n while (tmp > 0) {\n tmp = (tmp - 1) / 2\n segTree[tmp] = Math.min(segTree[2 * tmp + 1], segTree[2 * tmp + 2])\n }\n }\n \n fun getMin(a: Int, b: Int, k: Int = 0, l: Int = 0, r: Int = size): Long {\n if (r <= a || b <= l) {\n return Long.MAX_VALUE\n }\n if (a <= l && r <= b) {\n return segTree[k]\n }\n \n val vl = getMin(a, b, 2 * k + 1, l, (l + r) / 2)\n val vr = getMin(a, b, 2 * k + 2, (l + r) / 2, r)\n \n return Math.min(vl, vr)\n }\n \n update(N - 1, 0L)\n\n for (r in route) {\n val (L, R, C) = r\n\n val nowCost = getMin(L, R + 1)\n \n if (nowCost == Long.MAX_VALUE) {\n break\n }\n\n if (segTree[L + size - 1] > nowCost + C) {\n update(L, nowCost + C)\n }\n }\n\n if (segTree[size - 1] == Long.MAX_VALUE) {\n println(-1)\n } else {\n println(segTree[size - 1])\n }\n}\n\nfun readInputLine(): String {\n return readLine()!!\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1688, "cpu_time_ms": 1376, "memory_kb": 110360}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s357157784", "group_id": "codeNet:p02873", "input_text": "import java.io.*\nimport java.util.*\nimport java.lang.*\nimport java.lang.Math.*\n\n\nfun solve() {\n val S = rd.readString()\n val N = S.length\n\n data class LR(var left: Int, var right: Int)\n var X = Array(N+1){LR(0,0)}\n var i = 0\n while (i < N) {\n var j = i\n var ln = 1\n while (j < N && S[j] == '<') {\n X[j + 1].left = ln++\n j++\n }\n if (i') {\n X[j].right = ln++\n j--\n }\n if (j\n sum + max(lr.left, lr.right)\n }\n println(ans)\n}\n\n\n//val rd = debug.Reader(\"agc\", \"040\", \"a\", \"sample-2\")\nval rd = Reader()\n\n\nfun main(args: Array) {\n try {\n var exception: Throwable? = null\n val sth = Thread(null, SolveThread(), \"solveThread\", 128 * 1024 * 1024)\n sth.setUncaughtExceptionHandler { _, e -> exception = e }\n sth.start(); sth.join()\n if (exception != null) throw exception!! }\n catch (e: Exception) { throw e }\n finally { rd.close() }\n}\nconst val MOD = 1_000_000_007L; const val INF = Int.MAX_VALUE/2; const val LINF = Long.MAX_VALUE/2\ndata class IntPair(val first: Int, val second: Int)\nval errPrintln: (Any) -> Unit = { msg -> System.err.println(msg) }\nfun rAssert(exp: Boolean, lazyMsg: () -> String = {\"\"}) {\n if (!exp) { val msg = lazyMsg(); errPrintln(\"EAssert Error: $msg\"); throw Error(msg) }\n}\nfun tAssert(exp: Boolean, lazyMsg: () -> String = {\"\"}) {\n if (!exp) { val msg = lazyMsg(); errPrintln(\"TAssert Error: $msg\"); Thread.sleep(3000) }\n}\nclass SolveThread : Runnable {\n override fun run() { solve() }\n}\nclass Reader {\n private val br = BufferedReader(InputStreamReader(System.`in`))\n val readString: () -> String = { br.readLine() }\n val readInt: () -> Int = { br.readLine().toInt() }\n val readLong: () -> Long = { br.readLine().toLong() }\n val readIntArray: () -> IntArray = { br.readLine().split(' ').map { it.toInt() }.toIntArray() }\n val readLongArray: () -> LongArray = { br.readLine().split(' ').map { it.toLong() }.toLongArray() }\n val readListInt: () -> List = { br.readLine().split(' ').map { it.toInt() } }\n val readListLong: () -> List = { br.readLine().split(' ').map { it.toLong() } }\n val readListIntCol: (Int) -> List = { N -> (0 until N).map { readInt() } }\n val readListIntCols: (Int) -> List> = { N -> (0 until N).map { br.readLine().split(' ').map { it.toInt() } } }\n val readListLongCol: (Int) -> List = { N -> (0 until N).map { readLong() } }\n val readListLongCols: (Int) -> List> = { N -> (0 until N).map { br.readLine().split(' ').map { it.toLong() } } }\n val close: () -> Unit = { br.close() }\n protected fun finalize() { close() }\n}\n", "language": "Kotlin", "metadata": {"date": 1598551491, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02873.html", "problem_id": "p02873", "resource_group": "medium_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/Kotlin/s357157784.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s357157784", "user_id": "u404244809"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "import java.io.*\nimport java.util.*\nimport java.lang.*\nimport java.lang.Math.*\n\n\nfun solve() {\n val S = rd.readString()\n val N = S.length\n\n data class LR(var left: Int, var right: Int)\n var X = Array(N+1){LR(0,0)}\n var i = 0\n while (i < N) {\n var j = i\n var ln = 1\n while (j < N && S[j] == '<') {\n X[j + 1].left = ln++\n j++\n }\n if (i') {\n X[j].right = ln++\n j--\n }\n if (j\n sum + max(lr.left, lr.right)\n }\n println(ans)\n}\n\n\n//val rd = debug.Reader(\"agc\", \"040\", \"a\", \"sample-2\")\nval rd = Reader()\n\n\nfun main(args: Array) {\n try {\n var exception: Throwable? = null\n val sth = Thread(null, SolveThread(), \"solveThread\", 128 * 1024 * 1024)\n sth.setUncaughtExceptionHandler { _, e -> exception = e }\n sth.start(); sth.join()\n if (exception != null) throw exception!! }\n catch (e: Exception) { throw e }\n finally { rd.close() }\n}\nconst val MOD = 1_000_000_007L; const val INF = Int.MAX_VALUE/2; const val LINF = Long.MAX_VALUE/2\ndata class IntPair(val first: Int, val second: Int)\nval errPrintln: (Any) -> Unit = { msg -> System.err.println(msg) }\nfun rAssert(exp: Boolean, lazyMsg: () -> String = {\"\"}) {\n if (!exp) { val msg = lazyMsg(); errPrintln(\"EAssert Error: $msg\"); throw Error(msg) }\n}\nfun tAssert(exp: Boolean, lazyMsg: () -> String = {\"\"}) {\n if (!exp) { val msg = lazyMsg(); errPrintln(\"TAssert Error: $msg\"); Thread.sleep(3000) }\n}\nclass SolveThread : Runnable {\n override fun run() { solve() }\n}\nclass Reader {\n private val br = BufferedReader(InputStreamReader(System.`in`))\n val readString: () -> String = { br.readLine() }\n val readInt: () -> Int = { br.readLine().toInt() }\n val readLong: () -> Long = { br.readLine().toLong() }\n val readIntArray: () -> IntArray = { br.readLine().split(' ').map { it.toInt() }.toIntArray() }\n val readLongArray: () -> LongArray = { br.readLine().split(' ').map { it.toLong() }.toLongArray() }\n val readListInt: () -> List = { br.readLine().split(' ').map { it.toInt() } }\n val readListLong: () -> List = { br.readLine().split(' ').map { it.toLong() } }\n val readListIntCol: (Int) -> List = { N -> (0 until N).map { readInt() } }\n val readListIntCols: (Int) -> List> = { N -> (0 until N).map { br.readLine().split(' ').map { it.toInt() } } }\n val readListLongCol: (Int) -> List = { N -> (0 until N).map { readLong() } }\n val readListLongCols: (Int) -> List> = { N -> (0 until N).map { br.readLine().split(' ').map { it.toLong() } } }\n val close: () -> Unit = { br.close() }\n protected fun finalize() { close() }\n}\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 3016, "cpu_time_ms": 257, "memory_kb": 67236}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s759021835", "group_id": "codeNet:p02881", "input_text": "fun main(args: Array) {\n val N = readLine()!!.toLong()\n val n = Math.sqrt(N.toDouble()).toLong()\n var ans = Long.MAX_VALUE\n (1L..n).forEach { a ->\n if (N % a != 0L) return@forEach\n val b = N / a\n ans = Math.min(ans, a + b - 2)\n }\n println(ans)\n}", "language": "Kotlin", "metadata": {"date": 1590220733, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02881.html", "problem_id": "p02881", "resource_group": "medium_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/Kotlin/s759021835.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s759021835", "user_id": "u860789370"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "fun main(args: Array) {\n val N = readLine()!!.toLong()\n val n = Math.sqrt(N.toDouble()).toLong()\n var ans = Long.MAX_VALUE\n (1L..n).forEach { a ->\n if (N % a != 0L) return@forEach\n val b = N / a\n ans = Math.min(ans, a + b - 2)\n }\n println(ans)\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 292, "cpu_time_ms": 233, "memory_kb": 33792}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s227879551", "group_id": "codeNet:p02881", "input_text": "fun main(args: Array) {\n val n = readLine()?.toLong() ?: return\n fun isPrime(n: Long): Boolean {\n if (n == 2L) {\n return true\n }\n if (n % 2L == 0L) {\n return false\n }\n for (i in 3L until Math.sqrt(n.toDouble()).toLong() + 1 step 2L) {\n if (n % i == 0L) {\n return false\n }\n }\n return true\n }\n\n fun listFactors(n: Long): List {\n var number = n\n val factors = mutableListOf(1)\n while (number % 2 == 0L) {\n factors.add(2)\n number /= 2\n }\n var factor = 3L\n while (number > 1) {\n if (number % factor == 0L) {\n factors.add(factor)\n number /= factor\n } else {\n factor += 2L\n }\n }\n return factors\n }\n if (isPrime(n)) {\n println(\"${n - 1}\")\n return\n }\n var factors = listFactors(n).toMutableList()\n while (factors.size > 2) {\n val next = mutableListOf()\n 0.until(factors.size / 2).forEach {\n val a = factors[it]\n val b = factors[factors.size - 1 - it]\n next.add(a * b)\n }\n if (factors.size % 2 == 1) {\n next.add(factors[factors.size / 2])\n }\n next.sort()\n factors = next\n }\n println(\"${factors[0] - 1 + factors[1] - 1}\")\n}", "language": "Kotlin", "metadata": {"date": 1587919441, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02881.html", "problem_id": "p02881", "resource_group": "medium_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/Kotlin/s227879551.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s227879551", "user_id": "u979429407"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "fun main(args: Array) {\n val n = readLine()?.toLong() ?: return\n fun isPrime(n: Long): Boolean {\n if (n == 2L) {\n return true\n }\n if (n % 2L == 0L) {\n return false\n }\n for (i in 3L until Math.sqrt(n.toDouble()).toLong() + 1 step 2L) {\n if (n % i == 0L) {\n return false\n }\n }\n return true\n }\n\n fun listFactors(n: Long): List {\n var number = n\n val factors = mutableListOf(1)\n while (number % 2 == 0L) {\n factors.add(2)\n number /= 2\n }\n var factor = 3L\n while (number > 1) {\n if (number % factor == 0L) {\n factors.add(factor)\n number /= factor\n } else {\n factor += 2L\n }\n }\n return factors\n }\n if (isPrime(n)) {\n println(\"${n - 1}\")\n return\n }\n var factors = listFactors(n).toMutableList()\n while (factors.size > 2) {\n val next = mutableListOf()\n 0.until(factors.size / 2).forEach {\n val a = factors[it]\n val b = factors[factors.size - 1 - it]\n next.add(a * b)\n }\n if (factors.size % 2 == 1) {\n next.add(factors[factors.size / 2])\n }\n next.sort()\n factors = next\n }\n println(\"${factors[0] - 1 + factors[1] - 1}\")\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1442, "cpu_time_ms": 2111, "memory_kb": 33600}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s448724875", "group_id": "codeNet:p02883", "input_text": "fun main(args: Array) {\n val (n, k) = readLine()!!.split(' ').let {\n it[0].toInt() to it[1].toLong()\n }\n val a = readLine()!!.split(' ').map { it.toLong() }.sorted().toLongArray()\n val f = readLine()!!.split(' ').map { it.toLong() }.sortedDescending().toLongArray()\n\n var l = 0L\n var r = 1e12.toLong()\n while (l < r) {\n val m = l + (r - l) / 2\n\n var x = 0L\n for (i in 0 until n) {\n x += Math.max(a[i] - (m / f[i]), 0)\n }\n\n if (x <= k) {\n r = m\n } else {\n l = m + 1\n }\n }\n\n println(l)\n}\n", "language": "Kotlin", "metadata": {"date": 1590626867, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02883.html", "problem_id": "p02883", "resource_group": "medium_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/Kotlin/s448724875.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s448724875", "user_id": "u863309603"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "fun main(args: Array) {\n val (n, k) = readLine()!!.split(' ').let {\n it[0].toInt() to it[1].toLong()\n }\n val a = readLine()!!.split(' ').map { it.toLong() }.sorted().toLongArray()\n val f = readLine()!!.split(' ').map { it.toLong() }.sortedDescending().toLongArray()\n\n var l = 0L\n var r = 1e12.toLong()\n while (l < r) {\n val m = l + (r - l) / 2\n\n var x = 0L\n for (i in 0 until n) {\n x += Math.max(a[i] - (m / f[i]), 0)\n }\n\n if (x <= k) {\n r = m\n } else {\n l = m + 1\n }\n }\n\n println(l)\n}\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 610, "cpu_time_ms": 1529, "memory_kb": 112816}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s975676015", "group_id": "codeNet:p02883", "input_text": "fun main(args: Array) {\n val (n, k) = readLine()!!.split(' ').map(String::toLong)\n val aList = readLine()!!.split(' ').map(String::toLong).sortedDescending()\n val fList = readLine()!!.split(' ').map(String::toLong).sorted()\n if (aList.sum() <= k) {\n println(0)\n return\n }\n val fScoreList = (0 until n.toInt()).map { fList[it] to aList[it] * fList[it] }.sortedByDescending { it.second }.toTypedArray()\n\n fun checkCanReach(targetScore: Long): Boolean {\n var totalCost = 0L\n for (fScore in fScoreList) {\n val (f, score) = fScore\n val diff = (score - targetScore)\n if (diff > 0) {\n totalCost += diff / f + if (diff % f == 0L) 0 else 1\n if (totalCost > k) return false\n } else return true\n }\n return true\n }\n\n var left = -1L\n var right = fScoreList.maxBy { it.second }!!.second\n while (true) {\n val targetScore = (left + right) / 2\n val canReach = checkCanReach(targetScore)\n if (left + 1 == right) {\n if (canReach) {\n if (checkCanReach(targetScore - 1)) {\n println(targetScore - 1)\n } else {\n println(targetScore)\n }\n } else {\n println(targetScore + 1)\n }\n return\n } else {\n if (canReach) {\n right = targetScore\n } else {\n left = targetScore\n }\n }\n }\n}", "language": "Kotlin", "metadata": {"date": 1572395285, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02883.html", "problem_id": "p02883", "resource_group": "medium_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/Kotlin/s975676015.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s975676015", "user_id": "u099066216"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "fun main(args: Array) {\n val (n, k) = readLine()!!.split(' ').map(String::toLong)\n val aList = readLine()!!.split(' ').map(String::toLong).sortedDescending()\n val fList = readLine()!!.split(' ').map(String::toLong).sorted()\n if (aList.sum() <= k) {\n println(0)\n return\n }\n val fScoreList = (0 until n.toInt()).map { fList[it] to aList[it] * fList[it] }.sortedByDescending { it.second }.toTypedArray()\n\n fun checkCanReach(targetScore: Long): Boolean {\n var totalCost = 0L\n for (fScore in fScoreList) {\n val (f, score) = fScore\n val diff = (score - targetScore)\n if (diff > 0) {\n totalCost += diff / f + if (diff % f == 0L) 0 else 1\n if (totalCost > k) return false\n } else return true\n }\n return true\n }\n\n var left = -1L\n var right = fScoreList.maxBy { it.second }!!.second\n while (true) {\n val targetScore = (left + right) / 2\n val canReach = checkCanReach(targetScore)\n if (left + 1 == right) {\n if (canReach) {\n if (checkCanReach(targetScore - 1)) {\n println(targetScore - 1)\n } else {\n println(targetScore)\n }\n } else {\n println(targetScore + 1)\n }\n return\n } else {\n if (canReach) {\n right = targetScore\n } else {\n left = targetScore\n }\n }\n }\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1548, "cpu_time_ms": 2075, "memory_kb": 164468}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s293340052", "group_id": "codeNet:p02883", "input_text": "fun main(args: Array) {\n val (n, k) = readLine()!!.split(' ').map(String::toLong)\n val aList = readLine()!!.split(' ').map(String::toLong).sortedDescending()\n val fList = readLine()!!.split(' ').map(String::toLong).sorted()\n if (fList.sum() <= k) {\n println(0)\n return\n }\n val fScoreList = (0 until n.toInt()).map { fList[it] to aList[it] * fList[it] }.sortedByDescending { it.second }.toTypedArray()\n\n fun checkCanReach(targetScore: Long): Boolean {\n var totalCost = 0L\n for (fScore in fScoreList) {\n val (f, score) = fScore\n val diff = (score - targetScore)\n if (diff > 0) {\n totalCost += diff / f + if (diff % f == 0L) 0 else 1\n if (totalCost > k) return false\n } else return true\n }\n return true\n }\n\n var left = -1L\n var right = fScoreList.maxBy { it.second }!!.second\n while (true) {\n val targetScore = (left + right) / 2\n val canReach = checkCanReach(targetScore)\n if (left + 1 == right) {\n if (canReach) {\n if (checkCanReach(targetScore - 1)) {\n println(targetScore - 1)\n } else {\n println(targetScore)\n }\n } else {\n println(targetScore + 1)\n }\n return\n } else {\n if (canReach) {\n right = targetScore\n } else {\n left = targetScore\n }\n }\n }\n}", "language": "Kotlin", "metadata": {"date": 1572236581, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02883.html", "problem_id": "p02883", "resource_group": "medium_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/Kotlin/s293340052.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s293340052", "user_id": "u099066216"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "fun main(args: Array) {\n val (n, k) = readLine()!!.split(' ').map(String::toLong)\n val aList = readLine()!!.split(' ').map(String::toLong).sortedDescending()\n val fList = readLine()!!.split(' ').map(String::toLong).sorted()\n if (fList.sum() <= k) {\n println(0)\n return\n }\n val fScoreList = (0 until n.toInt()).map { fList[it] to aList[it] * fList[it] }.sortedByDescending { it.second }.toTypedArray()\n\n fun checkCanReach(targetScore: Long): Boolean {\n var totalCost = 0L\n for (fScore in fScoreList) {\n val (f, score) = fScore\n val diff = (score - targetScore)\n if (diff > 0) {\n totalCost += diff / f + if (diff % f == 0L) 0 else 1\n if (totalCost > k) return false\n } else return true\n }\n return true\n }\n\n var left = -1L\n var right = fScoreList.maxBy { it.second }!!.second\n while (true) {\n val targetScore = (left + right) / 2\n val canReach = checkCanReach(targetScore)\n if (left + 1 == right) {\n if (canReach) {\n if (checkCanReach(targetScore - 1)) {\n println(targetScore - 1)\n } else {\n println(targetScore)\n }\n } else {\n println(targetScore + 1)\n }\n return\n } else {\n if (canReach) {\n right = targetScore\n } else {\n left = targetScore\n }\n }\n }\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1548, "cpu_time_ms": 2111, "memory_kb": 158028}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s246351759", "group_id": "codeNet:p02883", "input_text": "fun main(args: Array) {\n val (n, k) = readLine()!!.split(' ').map(String::toLong)\n val aList = readLine()!!.split(' ').map(String::toLong).sortedDescending()\n val fList = readLine()!!.split(' ').map(String::toLong).sorted()\n if(fList.sum()<=k){\n println(0)\n return\n }\n val fScoreList = (0 until n.toInt()).map { fList[it] to aList[it] * fList[it] }.sortedBy { it.second }\n var left = 0L\n var right = aList.max()!!* fList.max()!!\n while (true) {\n var canReach = true\n val targetScore = (left + right) / 2\n var totalCost = 0L\n for (fScore in fScoreList) {\n val (f, score) = fScore\n if (score > targetScore) {\n totalCost += Math.ceil((score - targetScore).toDouble() / f.toDouble()).toLong()\n if(totalCost>k){\n canReach = false\n break\n }\n }\n }\n if(canReach){\n if(left+1==right){\n println(targetScore)\n return\n }else{\n right = targetScore\n }\n }else{\n if(left+1==right){\n println(targetScore+1)\n return\n }else{\n left = targetScore\n }\n }\n }\n}", "language": "Kotlin", "metadata": {"date": 1572229702, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02883.html", "problem_id": "p02883", "resource_group": "medium_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/Kotlin/s246351759.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s246351759", "user_id": "u099066216"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "fun main(args: Array) {\n val (n, k) = readLine()!!.split(' ').map(String::toLong)\n val aList = readLine()!!.split(' ').map(String::toLong).sortedDescending()\n val fList = readLine()!!.split(' ').map(String::toLong).sorted()\n if(fList.sum()<=k){\n println(0)\n return\n }\n val fScoreList = (0 until n.toInt()).map { fList[it] to aList[it] * fList[it] }.sortedBy { it.second }\n var left = 0L\n var right = aList.max()!!* fList.max()!!\n while (true) {\n var canReach = true\n val targetScore = (left + right) / 2\n var totalCost = 0L\n for (fScore in fScoreList) {\n val (f, score) = fScore\n if (score > targetScore) {\n totalCost += Math.ceil((score - targetScore).toDouble() / f.toDouble()).toLong()\n if(totalCost>k){\n canReach = false\n break\n }\n }\n }\n if(canReach){\n if(left+1==right){\n println(targetScore)\n return\n }else{\n right = targetScore\n }\n }else{\n if(left+1==right){\n println(targetScore+1)\n return\n }else{\n left = targetScore\n }\n }\n }\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1316, "cpu_time_ms": 2111, "memory_kb": 146368}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s811294117", "group_id": "codeNet:p02885", "input_text": "fun main(args: Array) {\n val (a, b) = readLine()!!.split(\" \").map(String::toInt)\n val result = a - b * 2\n println(if (result <= 0) 0 else result)\n}", "language": "Kotlin", "metadata": {"date": 1571624763, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02885.html", "problem_id": "p02885", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02885/input.txt", "sample_output_relpath": "derived/input_output/data/p02885/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02885/Kotlin/s811294117.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s811294117", "user_id": "u683212779"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "fun main(args: Array) {\n val (a, b) = readLine()!!.split(\" \").map(String::toInt)\n val result = a - b * 2\n println(if (result <= 0) 0 else result)\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nThe window of Takahashi's room has a width of A. There are two curtains hung over the window, each of which has a horizontal length of B. (Vertically, the curtains are long enough to cover the whole window.)\n\nWe will close the window so as to minimize the total horizontal length of the uncovered part of the window.\nFind the total horizontal length of the uncovered parts of the window then.\n\nConstraints\n\n1 \\leq A \\leq 100\n\n1 \\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\nPrint the total horizontal length of the uncovered parts of the window.\n\nSample Input 1\n\n12 4\n\nSample Output 1\n\n4\n\nWe have a window with a horizontal length of 12, and two curtains, each of length 4, that cover both ends of the window, for example. The uncovered part has a horizontal length of 4.\n\nSample Input 2\n\n20 15\n\nSample Output 2\n\n0\n\nIf the window is completely covered, print 0.\n\nSample Input 3\n\n20 30\n\nSample Output 3\n\n0\n\nEach curtain may be longer than the window.", "sample_input": "12 4\n"}, "reference_outputs": ["4\n"], "source_document_id": "p02885", "source_text": "Score : 100 points\n\nProblem Statement\n\nThe window of Takahashi's room has a width of A. There are two curtains hung over the window, each of which has a horizontal length of B. (Vertically, the curtains are long enough to cover the whole window.)\n\nWe will close the window so as to minimize the total horizontal length of the uncovered part of the window.\nFind the total horizontal length of the uncovered parts of the window then.\n\nConstraints\n\n1 \\leq A \\leq 100\n\n1 \\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\nPrint the total horizontal length of the uncovered parts of the window.\n\nSample Input 1\n\n12 4\n\nSample Output 1\n\n4\n\nWe have a window with a horizontal length of 12, and two curtains, each of length 4, that cover both ends of the window, for example. The uncovered part has a horizontal length of 4.\n\nSample Input 2\n\n20 15\n\nSample Output 2\n\n0\n\nIf the window is completely covered, print 0.\n\nSample Input 3\n\n20 30\n\nSample Output 3\n\n0\n\nEach curtain may be longer than the window.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 241, "memory_kb": 36084}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s691452742", "group_id": "codeNet:p02885", "input_text": "fun main(args: Array) {\n val (a, b) = readLine()!!.split(\" \").map { it.toInt() }\n println(Math.max(0, a - 2 * b))\n}", "language": "Kotlin", "metadata": {"date": 1571533300, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02885.html", "problem_id": "p02885", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02885/input.txt", "sample_output_relpath": "derived/input_output/data/p02885/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02885/Kotlin/s691452742.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s691452742", "user_id": "u719622470"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "fun main(args: Array) {\n val (a, b) = readLine()!!.split(\" \").map { it.toInt() }\n println(Math.max(0, a - 2 * b))\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nThe window of Takahashi's room has a width of A. There are two curtains hung over the window, each of which has a horizontal length of B. (Vertically, the curtains are long enough to cover the whole window.)\n\nWe will close the window so as to minimize the total horizontal length of the uncovered part of the window.\nFind the total horizontal length of the uncovered parts of the window then.\n\nConstraints\n\n1 \\leq A \\leq 100\n\n1 \\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\nPrint the total horizontal length of the uncovered parts of the window.\n\nSample Input 1\n\n12 4\n\nSample Output 1\n\n4\n\nWe have a window with a horizontal length of 12, and two curtains, each of length 4, that cover both ends of the window, for example. The uncovered part has a horizontal length of 4.\n\nSample Input 2\n\n20 15\n\nSample Output 2\n\n0\n\nIf the window is completely covered, print 0.\n\nSample Input 3\n\n20 30\n\nSample Output 3\n\n0\n\nEach curtain may be longer than the window.", "sample_input": "12 4\n"}, "reference_outputs": ["4\n"], "source_document_id": "p02885", "source_text": "Score : 100 points\n\nProblem Statement\n\nThe window of Takahashi's room has a width of A. There are two curtains hung over the window, each of which has a horizontal length of B. (Vertically, the curtains are long enough to cover the whole window.)\n\nWe will close the window so as to minimize the total horizontal length of the uncovered part of the window.\nFind the total horizontal length of the uncovered parts of the window then.\n\nConstraints\n\n1 \\leq A \\leq 100\n\n1 \\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\nPrint the total horizontal length of the uncovered parts of the window.\n\nSample Input 1\n\n12 4\n\nSample Output 1\n\n4\n\nWe have a window with a horizontal length of 12, and two curtains, each of length 4, that cover both ends of the window, for example. The uncovered part has a horizontal length of 4.\n\nSample Input 2\n\n20 15\n\nSample Output 2\n\n0\n\nIf the window is completely covered, print 0.\n\nSample Input 3\n\n20 30\n\nSample Output 3\n\n0\n\nEach curtain may be longer than the window.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 312, "memory_kb": 37872}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s043005518", "group_id": "codeNet:p02886", "input_text": "fun main(a:Array){\n val n = readLine()!!.toInt()\n val d = readLine()!!.split(\" \").map { it.toInt() }\n var sum = 0\n for (i in 0 until n){\n for (j in i+1 until n){\n sum += d[i] * d[j]\n }\n }\n println(sum)\n}", "language": "Kotlin", "metadata": {"date": 1573066468, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02886.html", "problem_id": "p02886", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02886/input.txt", "sample_output_relpath": "derived/input_output/data/p02886/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02886/Kotlin/s043005518.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s043005518", "user_id": "u520434261"}, "prompt_components": {"gold_output": "11\n", "input_to_evaluate": "fun main(a:Array){\n val n = readLine()!!.toInt()\n val d = readLine()!!.split(\" \").map { it.toInt() }\n var sum = 0\n for (i in 0 until n){\n for (j in i+1 until n){\n sum += d[i] * d[j]\n }\n }\n println(sum)\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nIt's now the season of TAKOYAKI FESTIVAL!\n\nThis year, N takoyaki (a ball-shaped food with a piece of octopus inside) will be served. The deliciousness of the i-th takoyaki is d_i.\n\nAs is commonly known, when you eat two takoyaki of deliciousness x and y together, you restore x \\times y health points.\n\nThere are \\frac{N \\times (N - 1)}{2} ways to choose two from the N takoyaki served in the festival. For each of these choices, find the health points restored from eating the two takoyaki, then compute the sum of these \\frac{N \\times (N - 1)}{2} values.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 50\n\n0 \\leq d_i \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nd_1 d_2 ... d_N\n\nOutput\n\nPrint the sum of the health points restored from eating two takoyaki over all possible choices of two takoyaki from the N takoyaki served.\n\nSample Input 1\n\n3\n3 1 2\n\nSample Output 1\n\n11\n\nThere are three possible choices:\n\nEat the first and second takoyaki. You will restore 3 health points.\n\nEat the second and third takoyaki. You will restore 2 health points.\n\nEat the first and third takoyaki. You will restore 6 health points.\n\nThe sum of these values is 11.\n\nSample Input 2\n\n7\n5 0 7 8 3 3 2\n\nSample Output 2\n\n312", "sample_input": "3\n3 1 2\n"}, "reference_outputs": ["11\n"], "source_document_id": "p02886", "source_text": "Score : 200 points\n\nProblem Statement\n\nIt's now the season of TAKOYAKI FESTIVAL!\n\nThis year, N takoyaki (a ball-shaped food with a piece of octopus inside) will be served. The deliciousness of the i-th takoyaki is d_i.\n\nAs is commonly known, when you eat two takoyaki of deliciousness x and y together, you restore x \\times y health points.\n\nThere are \\frac{N \\times (N - 1)}{2} ways to choose two from the N takoyaki served in the festival. For each of these choices, find the health points restored from eating the two takoyaki, then compute the sum of these \\frac{N \\times (N - 1)}{2} values.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 50\n\n0 \\leq d_i \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nd_1 d_2 ... d_N\n\nOutput\n\nPrint the sum of the health points restored from eating two takoyaki over all possible choices of two takoyaki from the N takoyaki served.\n\nSample Input 1\n\n3\n3 1 2\n\nSample Output 1\n\n11\n\nThere are three possible choices:\n\nEat the first and second takoyaki. You will restore 3 health points.\n\nEat the second and third takoyaki. You will restore 2 health points.\n\nEat the first and third takoyaki. You will restore 6 health points.\n\nThe sum of these values is 11.\n\nSample Input 2\n\n7\n5 0 7 8 3 3 2\n\nSample Output 2\n\n312", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 254, "cpu_time_ms": 234, "memory_kb": 37800}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s736878013", "group_id": "codeNet:p02886", "input_text": "fun main(args: Array) {\n val n = readLine()!!.toInt()\n val d = readLine()!!.split(\" \").map(String::toInt)\n\n var health = 0\n for (i in 0 until n - 1) {\n for (j in i + 1 until n) {\n health += d[i] * d[j]\n }\n }\n println(health)\n}", "language": "Kotlin", "metadata": {"date": 1571534008, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02886.html", "problem_id": "p02886", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02886/input.txt", "sample_output_relpath": "derived/input_output/data/p02886/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02886/Kotlin/s736878013.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s736878013", "user_id": "u938650438"}, "prompt_components": {"gold_output": "11\n", "input_to_evaluate": "fun main(args: Array) {\n val n = readLine()!!.toInt()\n val d = readLine()!!.split(\" \").map(String::toInt)\n\n var health = 0\n for (i in 0 until n - 1) {\n for (j in i + 1 until n) {\n health += d[i] * d[j]\n }\n }\n println(health)\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nIt's now the season of TAKOYAKI FESTIVAL!\n\nThis year, N takoyaki (a ball-shaped food with a piece of octopus inside) will be served. The deliciousness of the i-th takoyaki is d_i.\n\nAs is commonly known, when you eat two takoyaki of deliciousness x and y together, you restore x \\times y health points.\n\nThere are \\frac{N \\times (N - 1)}{2} ways to choose two from the N takoyaki served in the festival. For each of these choices, find the health points restored from eating the two takoyaki, then compute the sum of these \\frac{N \\times (N - 1)}{2} values.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 50\n\n0 \\leq d_i \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nd_1 d_2 ... d_N\n\nOutput\n\nPrint the sum of the health points restored from eating two takoyaki over all possible choices of two takoyaki from the N takoyaki served.\n\nSample Input 1\n\n3\n3 1 2\n\nSample Output 1\n\n11\n\nThere are three possible choices:\n\nEat the first and second takoyaki. You will restore 3 health points.\n\nEat the second and third takoyaki. You will restore 2 health points.\n\nEat the first and third takoyaki. You will restore 6 health points.\n\nThe sum of these values is 11.\n\nSample Input 2\n\n7\n5 0 7 8 3 3 2\n\nSample Output 2\n\n312", "sample_input": "3\n3 1 2\n"}, "reference_outputs": ["11\n"], "source_document_id": "p02886", "source_text": "Score : 200 points\n\nProblem Statement\n\nIt's now the season of TAKOYAKI FESTIVAL!\n\nThis year, N takoyaki (a ball-shaped food with a piece of octopus inside) will be served. The deliciousness of the i-th takoyaki is d_i.\n\nAs is commonly known, when you eat two takoyaki of deliciousness x and y together, you restore x \\times y health points.\n\nThere are \\frac{N \\times (N - 1)}{2} ways to choose two from the N takoyaki served in the festival. For each of these choices, find the health points restored from eating the two takoyaki, then compute the sum of these \\frac{N \\times (N - 1)}{2} values.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 50\n\n0 \\leq d_i \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nd_1 d_2 ... d_N\n\nOutput\n\nPrint the sum of the health points restored from eating two takoyaki over all possible choices of two takoyaki from the N takoyaki served.\n\nSample Input 1\n\n3\n3 1 2\n\nSample Output 1\n\n11\n\nThere are three possible choices:\n\nEat the first and second takoyaki. You will restore 3 health points.\n\nEat the second and third takoyaki. You will restore 2 health points.\n\nEat the first and third takoyaki. You will restore 6 health points.\n\nThe sum of these values is 11.\n\nSample Input 2\n\n7\n5 0 7 8 3 3 2\n\nSample Output 2\n\n312", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 279, "memory_kb": 37940}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s397679554", "group_id": "codeNet:p02887", "input_text": "fun main(args: Array) {\n val n = readInt()\n val s = readString()\n\n var c = s[0]\n var ans = 1\n for (i in 1 until n) {\n if (s[i] != c) {\n ans++\n c = s[i]\n }\n }\n println(ans)\n}\n\n// Tools\nfun readString() = readLine()!!\nfun readInt() = readLine()!!.toInt()\nfun readLong() = readLine()!!.toLong()\nfun readStringList() = readLine()!!.split(\" \")\nfun readIntList() = readLine()!!.split(\" \").map(String::toInt)\nfun readLongList() = readLine()!!.split(\" \").map(String::toLong)", "language": "Kotlin", "metadata": {"date": 1593048557, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02887.html", "problem_id": "p02887", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02887/input.txt", "sample_output_relpath": "derived/input_output/data/p02887/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02887/Kotlin/s397679554.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s397679554", "user_id": "u697467902"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "fun main(args: Array) {\n val n = readInt()\n val s = readString()\n\n var c = s[0]\n var ans = 1\n for (i in 1 until n) {\n if (s[i] != c) {\n ans++\n c = s[i]\n }\n }\n println(ans)\n}\n\n// Tools\nfun readString() = readLine()!!\nfun readInt() = readLine()!!.toInt()\nfun readLong() = readLine()!!.toLong()\nfun readStringList() = readLine()!!.split(\" \")\nfun readIntList() = readLine()!!.split(\" \").map(String::toInt)\nfun readLongList() = readLine()!!.split(\" \").map(String::toLong)", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere are N slimes lining up from left to right. The colors of these slimes will be given as a string S of length N consisting of lowercase English letters. The i-th slime from the left has the color that corresponds to the i-th character of S.\n\nAdjacent slimes with the same color will fuse into one larger slime without changing the color. If there were a slime adjacent to this group of slimes before fusion, that slime is now adjacent to the new larger slime.\n\nUltimately, how many slimes will be there?\n\nConstraints\n\n1 \\leq N \\leq 10^5\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 final number of slimes.\n\nSample Input 1\n\n10\naabbbbaaca\n\nSample Output 1\n\n5\n\nUltimately, these slimes will fuse into abaca.\n\nSample Input 2\n\n5\naaaaa\n\nSample Output 2\n\n1\n\nAll the slimes will fuse into one.\n\nSample Input 3\n\n20\nxxzaffeeeeddfkkkkllq\n\nSample Output 3\n\n10", "sample_input": "10\naabbbbaaca\n"}, "reference_outputs": ["5\n"], "source_document_id": "p02887", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere are N slimes lining up from left to right. The colors of these slimes will be given as a string S of length N consisting of lowercase English letters. The i-th slime from the left has the color that corresponds to the i-th character of S.\n\nAdjacent slimes with the same color will fuse into one larger slime without changing the color. If there were a slime adjacent to this group of slimes before fusion, that slime is now adjacent to the new larger slime.\n\nUltimately, how many slimes will be there?\n\nConstraints\n\n1 \\leq N \\leq 10^5\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 final number of slimes.\n\nSample Input 1\n\n10\naabbbbaaca\n\nSample Output 1\n\n5\n\nUltimately, these slimes will fuse into abaca.\n\nSample Input 2\n\n5\naaaaa\n\nSample Output 2\n\n1\n\nAll the slimes will fuse into one.\n\nSample Input 3\n\n20\nxxzaffeeeeddfkkkkllq\n\nSample Output 3\n\n10", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 179, "memory_kb": 36792}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s526662570", "group_id": "codeNet:p02887", "input_text": "fun main(args: Array) {\n val N = readLine()!!.toInt()\n\tprintln(weiwei(readLine()!!)+1)\n}\n \ntailrec fun weiwei(list :String, c :Int = 0) : Int {\n if (list.length == 1) {\n return c\n }\n\n val v = if (list[0] == list[1]) {\n 0\n }\n else {\n 1\n }\n return weiwei(list.drop(1), c + v)\n}", "language": "Kotlin", "metadata": {"date": 1572299246, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02887.html", "problem_id": "p02887", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02887/input.txt", "sample_output_relpath": "derived/input_output/data/p02887/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02887/Kotlin/s526662570.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s526662570", "user_id": "u731245195"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "fun main(args: Array) {\n val N = readLine()!!.toInt()\n\tprintln(weiwei(readLine()!!)+1)\n}\n \ntailrec fun weiwei(list :String, c :Int = 0) : Int {\n if (list.length == 1) {\n return c\n }\n\n val v = if (list[0] == list[1]) {\n 0\n }\n else {\n 1\n }\n return weiwei(list.drop(1), c + v)\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere are N slimes lining up from left to right. The colors of these slimes will be given as a string S of length N consisting of lowercase English letters. The i-th slime from the left has the color that corresponds to the i-th character of S.\n\nAdjacent slimes with the same color will fuse into one larger slime without changing the color. If there were a slime adjacent to this group of slimes before fusion, that slime is now adjacent to the new larger slime.\n\nUltimately, how many slimes will be there?\n\nConstraints\n\n1 \\leq N \\leq 10^5\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 final number of slimes.\n\nSample Input 1\n\n10\naabbbbaaca\n\nSample Output 1\n\n5\n\nUltimately, these slimes will fuse into abaca.\n\nSample Input 2\n\n5\naaaaa\n\nSample Output 2\n\n1\n\nAll the slimes will fuse into one.\n\nSample Input 3\n\n20\nxxzaffeeeeddfkkkkllq\n\nSample Output 3\n\n10", "sample_input": "10\naabbbbaaca\n"}, "reference_outputs": ["5\n"], "source_document_id": "p02887", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere are N slimes lining up from left to right. The colors of these slimes will be given as a string S of length N consisting of lowercase English letters. The i-th slime from the left has the color that corresponds to the i-th character of S.\n\nAdjacent slimes with the same color will fuse into one larger slime without changing the color. If there were a slime adjacent to this group of slimes before fusion, that slime is now adjacent to the new larger slime.\n\nUltimately, how many slimes will be there?\n\nConstraints\n\n1 \\leq N \\leq 10^5\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 final number of slimes.\n\nSample Input 1\n\n10\naabbbbaaca\n\nSample Output 1\n\n5\n\nUltimately, these slimes will fuse into abaca.\n\nSample Input 2\n\n5\naaaaa\n\nSample Output 2\n\n1\n\nAll the slimes will fuse into one.\n\nSample Input 3\n\n20\nxxzaffeeeeddfkkkkllq\n\nSample Output 3\n\n10", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 328, "cpu_time_ms": 1713, "memory_kb": 116808}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s923836040", "group_id": "codeNet:p02887", "input_text": "fun main(args: Array) {\n val n = readLine()!!.toInt()\n val str = readLine()!!\n\n var check = str[0]\n var count = 0\n for (c in str) {\n if (check == c) {\n continue\n }\n count++\n check = c\n }\n println(count + 1)\n}", "language": "Kotlin", "metadata": {"date": 1571692319, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02887.html", "problem_id": "p02887", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02887/input.txt", "sample_output_relpath": "derived/input_output/data/p02887/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02887/Kotlin/s923836040.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s923836040", "user_id": "u225381909"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "fun main(args: Array) {\n val n = readLine()!!.toInt()\n val str = readLine()!!\n\n var check = str[0]\n var count = 0\n for (c in str) {\n if (check == c) {\n continue\n }\n count++\n check = c\n }\n println(count + 1)\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere are N slimes lining up from left to right. The colors of these slimes will be given as a string S of length N consisting of lowercase English letters. The i-th slime from the left has the color that corresponds to the i-th character of S.\n\nAdjacent slimes with the same color will fuse into one larger slime without changing the color. If there were a slime adjacent to this group of slimes before fusion, that slime is now adjacent to the new larger slime.\n\nUltimately, how many slimes will be there?\n\nConstraints\n\n1 \\leq N \\leq 10^5\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 final number of slimes.\n\nSample Input 1\n\n10\naabbbbaaca\n\nSample Output 1\n\n5\n\nUltimately, these slimes will fuse into abaca.\n\nSample Input 2\n\n5\naaaaa\n\nSample Output 2\n\n1\n\nAll the slimes will fuse into one.\n\nSample Input 3\n\n20\nxxzaffeeeeddfkkkkllq\n\nSample Output 3\n\n10", "sample_input": "10\naabbbbaaca\n"}, "reference_outputs": ["5\n"], "source_document_id": "p02887", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere are N slimes lining up from left to right. The colors of these slimes will be given as a string S of length N consisting of lowercase English letters. The i-th slime from the left has the color that corresponds to the i-th character of S.\n\nAdjacent slimes with the same color will fuse into one larger slime without changing the color. If there were a slime adjacent to this group of slimes before fusion, that slime is now adjacent to the new larger slime.\n\nUltimately, how many slimes will be there?\n\nConstraints\n\n1 \\leq N \\leq 10^5\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 final number of slimes.\n\nSample Input 1\n\n10\naabbbbaaca\n\nSample Output 1\n\n5\n\nUltimately, these slimes will fuse into abaca.\n\nSample Input 2\n\n5\naaaaa\n\nSample Output 2\n\n1\n\nAll the slimes will fuse into one.\n\nSample Input 3\n\n20\nxxzaffeeeeddfkkkkllq\n\nSample Output 3\n\n10", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 252, "memory_kb": 32560}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s036875768", "group_id": "codeNet:p02888", "input_text": "fun main(args : Array) {\n val n = readLine()!!.toInt()\n val ll = readLine()!!.split(\" \").map { it.toInt() }.sorted().toIntArray()\n\n var cnt = 0L\n for (i in 0..n-3) {\n for (j in i+1..n-2) {\n val idx = lowerBound(ll, ll[i]+ll[j], j+1, n-1)\n cnt += idx-(j+1)\n }\n }\n\n println(cnt)\n}\n\nfun lowerBound(list: IntArray, key: Int, start: Int, end: Int): Int {\n var minIdx = start-1\n var maxIdx = end+1\n\n while (maxIdx - minIdx > 1) {\n val mid = minIdx + (maxIdx - minIdx)/2\n if (list[mid] >= key) {\n maxIdx = mid\n } else {\n minIdx = mid\n }\n }\n\n return maxIdx\n}", "language": "Kotlin", "metadata": {"date": 1586688416, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02888.html", "problem_id": "p02888", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02888/input.txt", "sample_output_relpath": "derived/input_output/data/p02888/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02888/Kotlin/s036875768.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s036875768", "user_id": "u262403099"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "fun main(args : Array) {\n val n = readLine()!!.toInt()\n val ll = readLine()!!.split(\" \").map { it.toInt() }.sorted().toIntArray()\n\n var cnt = 0L\n for (i in 0..n-3) {\n for (j in i+1..n-2) {\n val idx = lowerBound(ll, ll[i]+ll[j], j+1, n-1)\n cnt += idx-(j+1)\n }\n }\n\n println(cnt)\n}\n\nfun lowerBound(list: IntArray, key: Int, start: Int, end: Int): Int {\n var minIdx = start-1\n var maxIdx = end+1\n\n while (maxIdx - minIdx > 1) {\n val mid = minIdx + (maxIdx - minIdx)/2\n if (list[mid] >= key) {\n maxIdx = mid\n } else {\n minIdx = mid\n }\n }\n\n return maxIdx\n}", "problem_context": "Score : 400 points\n\nProblem Statement\n\nTakahashi has N sticks that are distinguishable from each other. The length of the i-th stick is L_i.\n\nHe is going to form a triangle using three of these sticks. Let a, b, and c be the lengths of the three sticks used. Here, all of the following conditions must be satisfied:\n\na < b + c\n\nb < c + a\n\nc < a + b\n\nHow many different triangles can be formed? Two triangles are considered different when there is a stick used in only one of them.\n\nConstraints\n\nAll values in input are integers.\n\n3 \\leq N \\leq 2 \\times 10^3\n\n1 \\leq L_i \\leq 10^3\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nL_1 L_2 ... L_N\n\nConstraints\n\nPrint the number of different triangles that can be formed.\n\nSample Input 1\n\n4\n3 4 2 1\n\nSample Output 1\n\n1\n\nOnly one triangle can be formed: the triangle formed by the first, second, and third sticks.\n\nSample Input 2\n\n3\n1 1000 1\n\nSample Output 2\n\n0\n\nNo triangles can be formed.\n\nSample Input 3\n\n7\n218 786 704 233 645 728 389\n\nSample Output 3\n\n23", "sample_input": "4\n3 4 2 1\n"}, "reference_outputs": ["1\n"], "source_document_id": "p02888", "source_text": "Score : 400 points\n\nProblem Statement\n\nTakahashi has N sticks that are distinguishable from each other. The length of the i-th stick is L_i.\n\nHe is going to form a triangle using three of these sticks. Let a, b, and c be the lengths of the three sticks used. Here, all of the following conditions must be satisfied:\n\na < b + c\n\nb < c + a\n\nc < a + b\n\nHow many different triangles can be formed? Two triangles are considered different when there is a stick used in only one of them.\n\nConstraints\n\nAll values in input are integers.\n\n3 \\leq N \\leq 2 \\times 10^3\n\n1 \\leq L_i \\leq 10^3\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nL_1 L_2 ... L_N\n\nConstraints\n\nPrint the number of different triangles that can be formed.\n\nSample Input 1\n\n4\n3 4 2 1\n\nSample Output 1\n\n1\n\nOnly one triangle can be formed: the triangle formed by the first, second, and third sticks.\n\nSample Input 2\n\n3\n1 1000 1\n\nSample Output 2\n\n0\n\nNo triangles can be formed.\n\nSample Input 3\n\n7\n218 786 704 233 645 728 389\n\nSample Output 3\n\n23", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 347, "memory_kb": 37924}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s713936592", "group_id": "codeNet:p02888", "input_text": "fun main(args: Array) {\n val N = nextInt()\n val L = listOfInt().sorted()\n var ans = 0\n for (i in 0 until N - 2) {\n for (j in i + 1 until N - 1) {\n // k in j + 1 until N\n val k = j + 1\n val P = L[i] + L[j] // > L[k]\n var r = L.binarySearch(P, k, N)\n if (r < 0) r = r.inv() - 1\n if (k <= r && P > L[r]) ans += (r - j)\n }\n }\n println(ans)\n}\nfun next() = readLine()!!\nfun nextInt(delta: Int = 0) = Integer.parseInt(next()) + delta\nfun listOfString() = next().split(\" \")\nfun listOfInt(delta: Int = 0) = listOfString().map { Integer.parseInt(it) + delta }", "language": "Kotlin", "metadata": {"date": 1579552459, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02888.html", "problem_id": "p02888", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02888/input.txt", "sample_output_relpath": "derived/input_output/data/p02888/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02888/Kotlin/s713936592.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s713936592", "user_id": "u043150661"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "fun main(args: Array) {\n val N = nextInt()\n val L = listOfInt().sorted()\n var ans = 0\n for (i in 0 until N - 2) {\n for (j in i + 1 until N - 1) {\n // k in j + 1 until N\n val k = j + 1\n val P = L[i] + L[j] // > L[k]\n var r = L.binarySearch(P, k, N)\n if (r < 0) r = r.inv() - 1\n if (k <= r && P > L[r]) ans += (r - j)\n }\n }\n println(ans)\n}\nfun next() = readLine()!!\nfun nextInt(delta: Int = 0) = Integer.parseInt(next()) + delta\nfun listOfString() = next().split(\" \")\nfun listOfInt(delta: Int = 0) = listOfString().map { Integer.parseInt(it) + delta }", "problem_context": "Score : 400 points\n\nProblem Statement\n\nTakahashi has N sticks that are distinguishable from each other. The length of the i-th stick is L_i.\n\nHe is going to form a triangle using three of these sticks. Let a, b, and c be the lengths of the three sticks used. Here, all of the following conditions must be satisfied:\n\na < b + c\n\nb < c + a\n\nc < a + b\n\nHow many different triangles can be formed? Two triangles are considered different when there is a stick used in only one of them.\n\nConstraints\n\nAll values in input are integers.\n\n3 \\leq N \\leq 2 \\times 10^3\n\n1 \\leq L_i \\leq 10^3\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nL_1 L_2 ... L_N\n\nConstraints\n\nPrint the number of different triangles that can be formed.\n\nSample Input 1\n\n4\n3 4 2 1\n\nSample Output 1\n\n1\n\nOnly one triangle can be formed: the triangle formed by the first, second, and third sticks.\n\nSample Input 2\n\n3\n1 1000 1\n\nSample Output 2\n\n0\n\nNo triangles can be formed.\n\nSample Input 3\n\n7\n218 786 704 233 645 728 389\n\nSample Output 3\n\n23", "sample_input": "4\n3 4 2 1\n"}, "reference_outputs": ["1\n"], "source_document_id": "p02888", "source_text": "Score : 400 points\n\nProblem Statement\n\nTakahashi has N sticks that are distinguishable from each other. The length of the i-th stick is L_i.\n\nHe is going to form a triangle using three of these sticks. Let a, b, and c be the lengths of the three sticks used. Here, all of the following conditions must be satisfied:\n\na < b + c\n\nb < c + a\n\nc < a + b\n\nHow many different triangles can be formed? Two triangles are considered different when there is a stick used in only one of them.\n\nConstraints\n\nAll values in input are integers.\n\n3 \\leq N \\leq 2 \\times 10^3\n\n1 \\leq L_i \\leq 10^3\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nL_1 L_2 ... L_N\n\nConstraints\n\nPrint the number of different triangles that can be formed.\n\nSample Input 1\n\n4\n3 4 2 1\n\nSample Output 1\n\n1\n\nOnly one triangle can be formed: the triangle formed by the first, second, and third sticks.\n\nSample Input 2\n\n3\n1 1000 1\n\nSample Output 2\n\n0\n\nNo triangles can be formed.\n\nSample Input 3\n\n7\n218 786 704 233 645 728 389\n\nSample Output 3\n\n23", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 391, "memory_kb": 46676}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s817108630", "group_id": "codeNet:p02888", "input_text": "fun List.indexOfFirstBinary(value: Int): Int {\n var low = 0\n var high = lastIndex\n if (value > get(high)) return size\n if (value <= get(low)) return 0\n\n while (low <= high) {\n val mid = (low + high).ushr(1) // safe from overflows\n val midVal = get(mid)\n val cmp = midVal - value\n if (cmp < 0)\n low = mid + 1\n else (cmp >= 0)\n high = mid - 1\n }\n return low\n}\n\nfun calc143D(Ls: List): Int {\n val sorted = Ls.sorted()\n var ans = 0\n for (i in 0..sorted.lastIndex) {\n for (j in (i + 1)..sorted.lastIndex) {\n val subList = sorted.subList(j + 1, sorted.size)\n if (subList.isEmpty()) continue\n val count = subList.indexOfFirstBinary(sorted[i] + sorted[j])\n ans += count\n }\n }\n return ans\n}\n\nfun main(args: Array) {\n val N = readLine()!!\n val s = readLine()!!.split(\" \").map { it.toInt() }\n println(calc143D(s))\n}\n", "language": "Kotlin", "metadata": {"date": 1572138169, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02888.html", "problem_id": "p02888", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02888/input.txt", "sample_output_relpath": "derived/input_output/data/p02888/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02888/Kotlin/s817108630.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s817108630", "user_id": "u846520687"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "fun List.indexOfFirstBinary(value: Int): Int {\n var low = 0\n var high = lastIndex\n if (value > get(high)) return size\n if (value <= get(low)) return 0\n\n while (low <= high) {\n val mid = (low + high).ushr(1) // safe from overflows\n val midVal = get(mid)\n val cmp = midVal - value\n if (cmp < 0)\n low = mid + 1\n else (cmp >= 0)\n high = mid - 1\n }\n return low\n}\n\nfun calc143D(Ls: List): Int {\n val sorted = Ls.sorted()\n var ans = 0\n for (i in 0..sorted.lastIndex) {\n for (j in (i + 1)..sorted.lastIndex) {\n val subList = sorted.subList(j + 1, sorted.size)\n if (subList.isEmpty()) continue\n val count = subList.indexOfFirstBinary(sorted[i] + sorted[j])\n ans += count\n }\n }\n return ans\n}\n\nfun main(args: Array) {\n val N = readLine()!!\n val s = readLine()!!.split(\" \").map { it.toInt() }\n println(calc143D(s))\n}\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nTakahashi has N sticks that are distinguishable from each other. The length of the i-th stick is L_i.\n\nHe is going to form a triangle using three of these sticks. Let a, b, and c be the lengths of the three sticks used. Here, all of the following conditions must be satisfied:\n\na < b + c\n\nb < c + a\n\nc < a + b\n\nHow many different triangles can be formed? Two triangles are considered different when there is a stick used in only one of them.\n\nConstraints\n\nAll values in input are integers.\n\n3 \\leq N \\leq 2 \\times 10^3\n\n1 \\leq L_i \\leq 10^3\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nL_1 L_2 ... L_N\n\nConstraints\n\nPrint the number of different triangles that can be formed.\n\nSample Input 1\n\n4\n3 4 2 1\n\nSample Output 1\n\n1\n\nOnly one triangle can be formed: the triangle formed by the first, second, and third sticks.\n\nSample Input 2\n\n3\n1 1000 1\n\nSample Output 2\n\n0\n\nNo triangles can be formed.\n\nSample Input 3\n\n7\n218 786 704 233 645 728 389\n\nSample Output 3\n\n23", "sample_input": "4\n3 4 2 1\n"}, "reference_outputs": ["1\n"], "source_document_id": "p02888", "source_text": "Score : 400 points\n\nProblem Statement\n\nTakahashi has N sticks that are distinguishable from each other. The length of the i-th stick is L_i.\n\nHe is going to form a triangle using three of these sticks. Let a, b, and c be the lengths of the three sticks used. Here, all of the following conditions must be satisfied:\n\na < b + c\n\nb < c + a\n\nc < a + b\n\nHow many different triangles can be formed? Two triangles are considered different when there is a stick used in only one of them.\n\nConstraints\n\nAll values in input are integers.\n\n3 \\leq N \\leq 2 \\times 10^3\n\n1 \\leq L_i \\leq 10^3\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nL_1 L_2 ... L_N\n\nConstraints\n\nPrint the number of different triangles that can be formed.\n\nSample Input 1\n\n4\n3 4 2 1\n\nSample Output 1\n\n1\n\nOnly one triangle can be formed: the triangle formed by the first, second, and third sticks.\n\nSample Input 2\n\n3\n1 1000 1\n\nSample Output 2\n\n0\n\nNo triangles can be formed.\n\nSample Input 3\n\n7\n218 786 704 233 645 728 389\n\nSample Output 3\n\n23", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 983, "cpu_time_ms": 361, "memory_kb": 48464}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s745756138", "group_id": "codeNet:p02888", "input_text": "fun main(args: Array) {\n val n = readLine()!!.toInt()\n val ds = readLine()!!.split(\" \").take(n).map { it.toInt() }.sorted().toIntArray()\n\n var count = 0\n for (ai in (0 until ds.size - 2)) {\n for (bi in (ai + 1 until ds.size - 1)) {\n count += search(ds, ds[ai] + ds[bi], (bi + 1), ds.size - 1)\n }\n }\n\n print(count)\n}\n\nfun search(array: IntArray, key: Int, from: Int, to: Int): Int {\n var low = from\n var high = to\n if (array[from] >= key) {\n println(\"${array[from]} < $key\")\n return 0\n }\n\n while (low < high) {\n val mid = (low + high) / 2 + 1\n val midVal = array[mid]\n\n if (midVal < key)\n low = mid\n else if (midVal >= key)\n high = mid - 1\n\n }\n return low - from + 1\n\n}", "language": "Kotlin", "metadata": {"date": 1571691714, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02888.html", "problem_id": "p02888", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02888/input.txt", "sample_output_relpath": "derived/input_output/data/p02888/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02888/Kotlin/s745756138.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s745756138", "user_id": "u225381909"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "fun main(args: Array) {\n val n = readLine()!!.toInt()\n val ds = readLine()!!.split(\" \").take(n).map { it.toInt() }.sorted().toIntArray()\n\n var count = 0\n for (ai in (0 until ds.size - 2)) {\n for (bi in (ai + 1 until ds.size - 1)) {\n count += search(ds, ds[ai] + ds[bi], (bi + 1), ds.size - 1)\n }\n }\n\n print(count)\n}\n\nfun search(array: IntArray, key: Int, from: Int, to: Int): Int {\n var low = from\n var high = to\n if (array[from] >= key) {\n println(\"${array[from]} < $key\")\n return 0\n }\n\n while (low < high) {\n val mid = (low + high) / 2 + 1\n val midVal = array[mid]\n\n if (midVal < key)\n low = mid\n else if (midVal >= key)\n high = mid - 1\n\n }\n return low - from + 1\n\n}", "problem_context": "Score : 400 points\n\nProblem Statement\n\nTakahashi has N sticks that are distinguishable from each other. The length of the i-th stick is L_i.\n\nHe is going to form a triangle using three of these sticks. Let a, b, and c be the lengths of the three sticks used. Here, all of the following conditions must be satisfied:\n\na < b + c\n\nb < c + a\n\nc < a + b\n\nHow many different triangles can be formed? Two triangles are considered different when there is a stick used in only one of them.\n\nConstraints\n\nAll values in input are integers.\n\n3 \\leq N \\leq 2 \\times 10^3\n\n1 \\leq L_i \\leq 10^3\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nL_1 L_2 ... L_N\n\nConstraints\n\nPrint the number of different triangles that can be formed.\n\nSample Input 1\n\n4\n3 4 2 1\n\nSample Output 1\n\n1\n\nOnly one triangle can be formed: the triangle formed by the first, second, and third sticks.\n\nSample Input 2\n\n3\n1 1000 1\n\nSample Output 2\n\n0\n\nNo triangles can be formed.\n\nSample Input 3\n\n7\n218 786 704 233 645 728 389\n\nSample Output 3\n\n23", "sample_input": "4\n3 4 2 1\n"}, "reference_outputs": ["1\n"], "source_document_id": "p02888", "source_text": "Score : 400 points\n\nProblem Statement\n\nTakahashi has N sticks that are distinguishable from each other. The length of the i-th stick is L_i.\n\nHe is going to form a triangle using three of these sticks. Let a, b, and c be the lengths of the three sticks used. Here, all of the following conditions must be satisfied:\n\na < b + c\n\nb < c + a\n\nc < a + b\n\nHow many different triangles can be formed? Two triangles are considered different when there is a stick used in only one of them.\n\nConstraints\n\nAll values in input are integers.\n\n3 \\leq N \\leq 2 \\times 10^3\n\n1 \\leq L_i \\leq 10^3\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nL_1 L_2 ... L_N\n\nConstraints\n\nPrint the number of different triangles that can be formed.\n\nSample Input 1\n\n4\n3 4 2 1\n\nSample Output 1\n\n1\n\nOnly one triangle can be formed: the triangle formed by the first, second, and third sticks.\n\nSample Input 2\n\n3\n1 1000 1\n\nSample Output 2\n\n0\n\nNo triangles can be formed.\n\nSample Input 3\n\n7\n218 786 704 233 645 728 389\n\nSample Output 3\n\n23", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 804, "cpu_time_ms": 467, "memory_kb": 40588}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s134454555", "group_id": "codeNet:p02888", "input_text": "fun main(args: Array) {\n val n = readLine()!!.toInt()\n val a = readLine()!!.split(\" \").map { it.toInt() }.toIntArray().sorted()\n var ans = 0\n for (i in 0 until n - 2) {\n for (j in i + 1 until n - 1) {\n val sum = a[i] + a[j]\n for (k in j + 1 until n) {\n if (sum > a[k]) {\n ans++\n } else {\n break\n }\n }\n }\n }\n println(ans)\n}", "language": "Kotlin", "metadata": {"date": 1571596232, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02888.html", "problem_id": "p02888", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02888/input.txt", "sample_output_relpath": "derived/input_output/data/p02888/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02888/Kotlin/s134454555.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s134454555", "user_id": "u719622470"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "fun main(args: Array) {\n val n = readLine()!!.toInt()\n val a = readLine()!!.split(\" \").map { it.toInt() }.toIntArray().sorted()\n var ans = 0\n for (i in 0 until n - 2) {\n for (j in i + 1 until n - 1) {\n val sum = a[i] + a[j]\n for (k in j + 1 until n) {\n if (sum > a[k]) {\n ans++\n } else {\n break\n }\n }\n }\n }\n println(ans)\n}", "problem_context": "Score : 400 points\n\nProblem Statement\n\nTakahashi has N sticks that are distinguishable from each other. The length of the i-th stick is L_i.\n\nHe is going to form a triangle using three of these sticks. Let a, b, and c be the lengths of the three sticks used. Here, all of the following conditions must be satisfied:\n\na < b + c\n\nb < c + a\n\nc < a + b\n\nHow many different triangles can be formed? Two triangles are considered different when there is a stick used in only one of them.\n\nConstraints\n\nAll values in input are integers.\n\n3 \\leq N \\leq 2 \\times 10^3\n\n1 \\leq L_i \\leq 10^3\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nL_1 L_2 ... L_N\n\nConstraints\n\nPrint the number of different triangles that can be formed.\n\nSample Input 1\n\n4\n3 4 2 1\n\nSample Output 1\n\n1\n\nOnly one triangle can be formed: the triangle formed by the first, second, and third sticks.\n\nSample Input 2\n\n3\n1 1000 1\n\nSample Output 2\n\n0\n\nNo triangles can be formed.\n\nSample Input 3\n\n7\n218 786 704 233 645 728 389\n\nSample Output 3\n\n23", "sample_input": "4\n3 4 2 1\n"}, "reference_outputs": ["1\n"], "source_document_id": "p02888", "source_text": "Score : 400 points\n\nProblem Statement\n\nTakahashi has N sticks that are distinguishable from each other. The length of the i-th stick is L_i.\n\nHe is going to form a triangle using three of these sticks. Let a, b, and c be the lengths of the three sticks used. Here, all of the following conditions must be satisfied:\n\na < b + c\n\nb < c + a\n\nc < a + b\n\nHow many different triangles can be formed? Two triangles are considered different when there is a stick used in only one of them.\n\nConstraints\n\nAll values in input are integers.\n\n3 \\leq N \\leq 2 \\times 10^3\n\n1 \\leq L_i \\leq 10^3\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nL_1 L_2 ... L_N\n\nConstraints\n\nPrint the number of different triangles that can be formed.\n\nSample Input 1\n\n4\n3 4 2 1\n\nSample Output 1\n\n1\n\nOnly one triangle can be formed: the triangle formed by the first, second, and third sticks.\n\nSample Input 2\n\n3\n1 1000 1\n\nSample Output 2\n\n0\n\nNo triangles can be formed.\n\nSample Input 3\n\n7\n218 786 704 233 645 728 389\n\nSample Output 3\n\n23", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1742, "memory_kb": 48588}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s756164956", "group_id": "codeNet:p02890", "input_text": "import java.util.Scanner\n\nfun main(args: Array) {\n\tval scn = Scanner(System.`in`)\n\tval n = scn.nextInt()\n\tval cnts = mutableMapOf()\n\trepeat(n){\n\t\tval a = scn.nextInt()\n\t\tcnts[a] = cnts.getOrElse(a){0} + 1\n\t}\n\tval keys = cnts.keys.sortedBy { cnts[it] }\n\tfor (i in 1..n){\n\t\tif (cnts.size\n\t\t\tif (l<=Cs.size-i) {\n\t\t\t\tans += c\n\t\t\t\tfor (p in l + 1 until l + i) Cs[p] -= c\n\t\t\t}\n\t\t}\n\t\tprintln(ans)\n\t}\n}", "language": "Kotlin", "metadata": {"date": 1571538856, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02890.html", "problem_id": "p02890", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02890/input.txt", "sample_output_relpath": "derived/input_output/data/p02890/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02890/Kotlin/s756164956.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s756164956", "user_id": "u914590612"}, "prompt_components": {"gold_output": "3\n1\n0\n", "input_to_evaluate": "import java.util.Scanner\n\nfun main(args: Array) {\n\tval scn = Scanner(System.`in`)\n\tval n = scn.nextInt()\n\tval cnts = mutableMapOf()\n\trepeat(n){\n\t\tval a = scn.nextInt()\n\t\tcnts[a] = cnts.getOrElse(a){0} + 1\n\t}\n\tval keys = cnts.keys.sortedBy { cnts[it] }\n\tfor (i in 1..n){\n\t\tif (cnts.size\n\t\t\tif (l<=Cs.size-i) {\n\t\t\t\tans += c\n\t\t\t\tfor (p in l + 1 until l + i) Cs[p] -= c\n\t\t\t}\n\t\t}\n\t\tprintln(ans)\n\t}\n}", "problem_context": "Score : 600 points\n\nProblem Statement\n\nTakahashi has N cards. The i-th of these cards has an integer A_i written on it.\n\nTakahashi will choose an integer K, and then repeat the following operation some number of times:\n\nChoose exactly K cards such that the integers written on them are all different, and eat those cards. (The eaten cards disappear.)\n\nFor each K = 1,2, \\ldots, N, find the maximum number of times Takahashi can do the operation.\n\nConstraints\n\n1 \\le N \\le 3 \\times 10^5\n\n1 \\le A_i \\le 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 \\ldots A_N\n\nOutput\n\nPrint N integers.\nThe t-th (1 \\le t \\le N) of them should be the answer for the case K=t.\n\nSample Input 1\n\n3\n2 1 2\n\nSample Output 1\n\n3\n1\n0\n\nFor K = 1, we can do the operation as follows:\n\nChoose the first card to eat.\n\nChoose the second card to eat.\n\nChoose the third card to eat.\n\nFor K = 2, we can do the operation as follows:\n\nChoose the first and second cards to eat.\n\nFor K = 3, we cannot do the operation at all. Note that we cannot choose the first and third cards at the same time.\n\nSample Input 2\n\n5\n1 2 3 4 5\n\nSample Output 2\n\n5\n2\n1\n1\n1\n\nSample Input 3\n\n4\n1 3 3 3\n\nSample Output 3\n\n4\n1\n0\n0", "sample_input": "3\n2 1 2\n"}, "reference_outputs": ["3\n1\n0\n"], "source_document_id": "p02890", "source_text": "Score : 600 points\n\nProblem Statement\n\nTakahashi has N cards. The i-th of these cards has an integer A_i written on it.\n\nTakahashi will choose an integer K, and then repeat the following operation some number of times:\n\nChoose exactly K cards such that the integers written on them are all different, and eat those cards. (The eaten cards disappear.)\n\nFor each K = 1,2, \\ldots, N, find the maximum number of times Takahashi can do the operation.\n\nConstraints\n\n1 \\le N \\le 3 \\times 10^5\n\n1 \\le A_i \\le 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 \\ldots A_N\n\nOutput\n\nPrint N integers.\nThe t-th (1 \\le t \\le N) of them should be the answer for the case K=t.\n\nSample Input 1\n\n3\n2 1 2\n\nSample Output 1\n\n3\n1\n0\n\nFor K = 1, we can do the operation as follows:\n\nChoose the first card to eat.\n\nChoose the second card to eat.\n\nChoose the third card to eat.\n\nFor K = 2, we can do the operation as follows:\n\nChoose the first and second cards to eat.\n\nFor K = 3, we cannot do the operation at all. Note that we cannot choose the first and third cards at the same time.\n\nSample Input 2\n\n5\n1 2 3 4 5\n\nSample Output 2\n\n5\n2\n1\n1\n1\n\nSample Input 3\n\n4\n1 3 3 3\n\nSample Output 3\n\n4\n1\n0\n0", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 542, "cpu_time_ms": 2111, "memory_kb": 140256}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s184987333", "group_id": "codeNet:p02897", "input_text": "import java.math.BigDecimal\nimport java.math.MathContext\n\nfun main(args : Array) {\n val result = Begginer20190928A.exec(readLine()!!.toInt())\n println(result)\n}\n\n\nobject Begginer20190928A {\n fun exec(input : Int) : String {\n val isOdd = input % 2 == 1\n\n val oddCount = if (isOdd) {\n (input - 1) / 2 + 1\n } else {\n (input) / 2\n }\n\n println(oddCount)\n\n return BigDecimal(oddCount)\n .divide(BigDecimal(input), MathContext(10))\n .toString()\n }\n}", "language": "Kotlin", "metadata": {"date": 1570591131, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02897.html", "problem_id": "p02897", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02897/input.txt", "sample_output_relpath": "derived/input_output/data/p02897/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02897/Kotlin/s184987333.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s184987333", "user_id": "u849916047"}, "prompt_components": {"gold_output": "0.5000000000\n", "input_to_evaluate": "import java.math.BigDecimal\nimport java.math.MathContext\n\nfun main(args : Array) {\n val result = Begginer20190928A.exec(readLine()!!.toInt())\n println(result)\n}\n\n\nobject Begginer20190928A {\n fun exec(input : Int) : String {\n val isOdd = input % 2 == 1\n\n val oddCount = if (isOdd) {\n (input - 1) / 2 + 1\n } else {\n (input) / 2\n }\n\n println(oddCount)\n\n return BigDecimal(oddCount)\n .divide(BigDecimal(input), MathContext(10))\n .toString()\n }\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nGiven is an integer N.\n\nTakahashi chooses an integer a from the positive integers not greater than N with equal probability.\n\nFind the probability that a is odd.\n\nConstraints\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 probability that a is odd.\nYour output will be considered correct when its absolute or relative error from the judge's output is at most 10^{-6}.\n\nSample Input 1\n\n4\n\nSample Output 1\n\n0.5000000000\n\nThere are four positive integers not greater than 4: 1, 2, 3, and 4. Among them, we have two odd numbers: 1 and 3. Thus, the answer is \\frac{2}{4} = 0.5.\n\nSample Input 2\n\n5\n\nSample Output 2\n\n0.6000000000\n\nSample Input 3\n\n1\n\nSample Output 3\n\n1.0000000000", "sample_input": "4\n"}, "reference_outputs": ["0.5000000000\n"], "source_document_id": "p02897", "source_text": "Score : 100 points\n\nProblem Statement\n\nGiven is an integer N.\n\nTakahashi chooses an integer a from the positive integers not greater than N with equal probability.\n\nFind the probability that a is odd.\n\nConstraints\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 probability that a is odd.\nYour output will be considered correct when its absolute or relative error from the judge's output is at most 10^{-6}.\n\nSample Input 1\n\n4\n\nSample Output 1\n\n0.5000000000\n\nThere are four positive integers not greater than 4: 1, 2, 3, and 4. Among them, we have two odd numbers: 1 and 3. Thus, the answer is \\frac{2}{4} = 0.5.\n\nSample Input 2\n\n5\n\nSample Output 2\n\n0.6000000000\n\nSample Input 3\n\n1\n\nSample Output 3\n\n1.0000000000", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 204, "memory_kb": 31868}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s572238770", "group_id": "codeNet:p02897", "input_text": "fun main (args : Array) {\n\tval n = readLine()\n\tval N : Double = n!!.toDouble()\n\tvar count : Double = 0.0\n\tvar result : Double = 0.0\n\tfor (i in 1..N.toInt()) {\n\t\tif (i % 2 == 1) {\n\t\t\tcount += 1.0\n\t\t}\n\t}\n\tresult = count / N\n\tprintln(\"${result}\")\n}", "language": "Kotlin", "metadata": {"date": 1570570226, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02897.html", "problem_id": "p02897", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02897/input.txt", "sample_output_relpath": "derived/input_output/data/p02897/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02897/Kotlin/s572238770.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s572238770", "user_id": "u651257341"}, "prompt_components": {"gold_output": "0.5000000000\n", "input_to_evaluate": "fun main (args : Array) {\n\tval n = readLine()\n\tval N : Double = n!!.toDouble()\n\tvar count : Double = 0.0\n\tvar result : Double = 0.0\n\tfor (i in 1..N.toInt()) {\n\t\tif (i % 2 == 1) {\n\t\t\tcount += 1.0\n\t\t}\n\t}\n\tresult = count / N\n\tprintln(\"${result}\")\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nGiven is an integer N.\n\nTakahashi chooses an integer a from the positive integers not greater than N with equal probability.\n\nFind the probability that a is odd.\n\nConstraints\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 probability that a is odd.\nYour output will be considered correct when its absolute or relative error from the judge's output is at most 10^{-6}.\n\nSample Input 1\n\n4\n\nSample Output 1\n\n0.5000000000\n\nThere are four positive integers not greater than 4: 1, 2, 3, and 4. Among them, we have two odd numbers: 1 and 3. Thus, the answer is \\frac{2}{4} = 0.5.\n\nSample Input 2\n\n5\n\nSample Output 2\n\n0.6000000000\n\nSample Input 3\n\n1\n\nSample Output 3\n\n1.0000000000", "sample_input": "4\n"}, "reference_outputs": ["0.5000000000\n"], "source_document_id": "p02897", "source_text": "Score : 100 points\n\nProblem Statement\n\nGiven is an integer N.\n\nTakahashi chooses an integer a from the positive integers not greater than N with equal probability.\n\nFind the probability that a is odd.\n\nConstraints\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 probability that a is odd.\nYour output will be considered correct when its absolute or relative error from the judge's output is at most 10^{-6}.\n\nSample Input 1\n\n4\n\nSample Output 1\n\n0.5000000000\n\nThere are four positive integers not greater than 4: 1, 2, 3, and 4. Among them, we have two odd numbers: 1 and 3. Thus, the answer is \\frac{2}{4} = 0.5.\n\nSample Input 2\n\n5\n\nSample Output 2\n\n0.6000000000\n\nSample Input 3\n\n1\n\nSample Output 3\n\n1.0000000000", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 253, "cpu_time_ms": 199, "memory_kb": 31736}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s904812858", "group_id": "codeNet:p02899", "input_text": "import java.util.*\n\nfun main(args: Array) {\n val N = readLine()!!.toInt()\n val A = readLine()!!.split(\" \").mapIndexed{ index, value -> \n Pair(index, value.toInt())\n }.toMutableList().apply {\n sortBy {it.second}\n forEach { print(\"${it.first + 1} \") }\n }\n}", "language": "Kotlin", "metadata": {"date": 1570630233, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02899.html", "problem_id": "p02899", "resource_group": "medium_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/Kotlin/s904812858.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s904812858", "user_id": "u796228844"}, "prompt_components": {"gold_output": "3 1 2\n", "input_to_evaluate": "import java.util.*\n\nfun main(args: Array) {\n val N = readLine()!!.toInt()\n val A = readLine()!!.split(\" \").mapIndexed{ index, value -> \n Pair(index, value.toInt())\n }.toMutableList().apply {\n sortBy {it.second}\n forEach { print(\"${it.first + 1} \") }\n }\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1323, "memory_kb": 84928}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s984044784", "group_id": "codeNet:p02899", "input_text": "fun main(args: Array){\n val n = readLine()!!.toInt()\n val a = readLine()!!.split(\" \")\n val result = IntArray(n)\n for( (i, v) in a.withIndex() )\n result[v.toInt()-1] = i+1\n\n println(result.joinToString(separator=\" \"))\n}\n", "language": "Kotlin", "metadata": {"date": 1569719684, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02899.html", "problem_id": "p02899", "resource_group": "medium_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/Kotlin/s984044784.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s984044784", "user_id": "u657065743"}, "prompt_components": {"gold_output": "3 1 2\n", "input_to_evaluate": "fun main(args: Array){\n val n = readLine()!!.toInt()\n val a = readLine()!!.split(\" \")\n val result = IntArray(n)\n for( (i, v) in a.withIndex() )\n result[v.toInt()-1] = i+1\n\n println(result.joinToString(separator=\" \"))\n}\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 571, "memory_kb": 62320}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s606392031", "group_id": "codeNet:p02900", "input_text": "fun main(args: Array) {\n val (a, b) = readLine()!!.split(' ').map { it.toLong() }\n\n fun f(x: Long): Set {\n val set = mutableSetOf(1L)\n var t = x\n var i = 2L\n\n while (t > 1 && i < Math.sqrt(x.toDouble())) {\n if (t % i == 0L) {\n set.add(i)\n t /= i\n continue\n }\n\n i++\n }\n\n if (t == x) {\n set.add(x)\n }\n\n return set\n }\n\n println(f(a).intersect(f(b)).size)\n}\n", "language": "Kotlin", "metadata": {"date": 1569790118, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02900.html", "problem_id": "p02900", "resource_group": "medium_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/Kotlin/s606392031.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s606392031", "user_id": "u863309603"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "fun main(args: Array) {\n val (a, b) = readLine()!!.split(' ').map { it.toLong() }\n\n fun f(x: Long): Set {\n val set = mutableSetOf(1L)\n var t = x\n var i = 2L\n\n while (t > 1 && i < Math.sqrt(x.toDouble())) {\n if (t % i == 0L) {\n set.add(i)\n t /= i\n continue\n }\n\n i++\n }\n\n if (t == x) {\n set.add(x)\n }\n\n return set\n }\n\n println(f(a).intersect(f(b)).size)\n}\n", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 525, "cpu_time_ms": 273, "memory_kb": 38248}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s165287973", "group_id": "codeNet:p02900", "input_text": "fun main(args: Array) {\n val (a,b) = readLine()!!.split(\" \").map(String::toLong)\n val x = gcd(a,b)\n val list = decom(x)\n println(list.size + 1)\n}\n\nfun decom(x: Long) : MutableList {\n var value = x\n val list: MutableList = mutableListOf()\n if (value % 2L == 0L) {\n list.add(2L)\n while (value % 2L == 0L) {\n value /= 2L\n }\n }\n var i = 3L\n while (i <= value) {\n if ( value % i == 0L) {\n list.add(i)\n while (value % i == 0L) {\n value /= i\n }\n } else {\n i += 2L\n }\n }\n return list\n}\n\nfun gcd(a : Long, b : Long) : Long {\n return if (a % b == 0L) b else gcd(b, a % b)\n}", "language": "Kotlin", "metadata": {"date": 1569723813, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02900.html", "problem_id": "p02900", "resource_group": "medium_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/Kotlin/s165287973.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s165287973", "user_id": "u388719350"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "fun main(args: Array) {\n val (a,b) = readLine()!!.split(\" \").map(String::toLong)\n val x = gcd(a,b)\n val list = decom(x)\n println(list.size + 1)\n}\n\nfun decom(x: Long) : MutableList {\n var value = x\n val list: MutableList = mutableListOf()\n if (value % 2L == 0L) {\n list.add(2L)\n while (value % 2L == 0L) {\n value /= 2L\n }\n }\n var i = 3L\n while (i <= value) {\n if ( value % i == 0L) {\n list.add(i)\n while (value % i == 0L) {\n value /= i\n }\n } else {\n i += 2L\n }\n }\n return list\n}\n\nfun gcd(a : Long, b : Long) : Long {\n return if (a % b == 0L) b else gcd(b, a % b)\n}", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 734, "cpu_time_ms": 2111, "memory_kb": 37864}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s889552235", "group_id": "codeNet:p02901", "input_text": "fun main(args: Array) = yorukatsu9e()\n\nfun yorukatsu9e() {\n val (n, m) = readLine()!!.split(' ').map { it.toInt() }\n val keys = Array(m) {\n val (a, b) = readLine()!!.split(' ').map { it.toInt() }\n val cList = readLine()!!.split(' ').map { it.toInt() }\n val canOpen = cList.reduce { acc, i -> acc + (1 shl (i - 1)) }\n Key(a, canOpen)\n }\n\n val inf = Int.MAX_VALUE.toLong()\n val dp = LongArray(1 shl n) { inf }\n dp[0] = 0\n\n for (box in 0 until (1 shl n)) {\n for ((price, canOpen) in keys) {\n val or = box or canOpen\n dp[or] = Math.min(dp[or], dp[box] + price)\n }\n }\n\n val answer = dp.last().let { if (it != inf) it else -1 }\n\n println(answer)\n}\n\nprivate data class Key(val price: Int, val canOpen: Int)\n", "language": "Kotlin", "metadata": {"date": 1586311477, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02901.html", "problem_id": "p02901", "resource_group": "medium_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/Kotlin/s889552235.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s889552235", "user_id": "u139478771"}, "prompt_components": {"gold_output": "25\n", "input_to_evaluate": "fun main(args: Array) = yorukatsu9e()\n\nfun yorukatsu9e() {\n val (n, m) = readLine()!!.split(' ').map { it.toInt() }\n val keys = Array(m) {\n val (a, b) = readLine()!!.split(' ').map { it.toInt() }\n val cList = readLine()!!.split(' ').map { it.toInt() }\n val canOpen = cList.reduce { acc, i -> acc + (1 shl (i - 1)) }\n Key(a, canOpen)\n }\n\n val inf = Int.MAX_VALUE.toLong()\n val dp = LongArray(1 shl n) { inf }\n dp[0] = 0\n\n for (box in 0 until (1 shl n)) {\n for ((price, canOpen) in keys) {\n val or = box or canOpen\n dp[or] = Math.min(dp[or], dp[box] + price)\n }\n }\n\n val answer = dp.last().let { if (it != inf) it else -1 }\n\n println(answer)\n}\n\nprivate data class Key(val price: Int, val canOpen: Int)\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 802, "cpu_time_ms": 458, "memory_kb": 41236}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s448025406", "group_id": "codeNet:p02904", "input_text": "import java.io.IOException\nimport java.util.*\n\nfun main(args: Array) {\n val sc = FastScanner()\n val n = sc.nextInt()\n val k = sc.nextInt()\n val p = (0 until n).map { sc.next().toInt() }\n println(problem038b(n, k, p))\n}\n\nfun problem038b(n: Int, k: Int, p: List): Int {\n var count = 0\n val dp = (0 until n).map { listOf() }.toMutableList()\n if (n == k) return 1\n dp[0] = p.subList(0, k)\n for (i in 1 until n - k + 1) {\n dp[i] = p.subList(i, i + k)\n if (dp[i] != dp[i - 1]) count++\n }\n return count\n}\n\nclass FastScanner {\n private val `in` = System.`in`\n private val buffer = ByteArray(1024)\n private var ptr = 0\n private var buflen = 0\n private fun hasNextByte(): Boolean {\n if (ptr < buflen) {\n return true\n } else {\n ptr = 0\n try {\n buflen = `in`.read(buffer)\n } catch (e: IOException) {\n e.printStackTrace()\n }\n\n if (buflen <= 0) {\n return false\n }\n }\n return true\n }\n\n private fun readByte(): Int {\n return if (hasNextByte()) buffer[ptr++].toInt() else -1\n }\n\n private fun isPrintableChar(c: Int): Boolean {\n return c in 33..126\n }\n\n operator fun hasNext(): Boolean {\n while (hasNextByte() && !isPrintableChar(buffer[ptr].toInt())) ptr++\n return hasNextByte()\n }\n\n operator fun next(): String {\n if (!hasNext()) throw NoSuchElementException()\n val sb = StringBuilder()\n var b = readByte()\n while (isPrintableChar(b)) {\n sb.appendCodePoint(b)\n b = readByte()\n }\n return sb.toString()\n }\n\n fun nextLong(): Long {\n if (!hasNext()) throw NoSuchElementException()\n var n: Long = 0\n var minus = false\n var b = readByte()\n if (b == '-'.toInt()) {\n minus = true\n b = readByte()\n }\n if (b < '0'.toInt() || '9'.toInt() < b) {\n throw NumberFormatException()\n }\n while (true) {\n if ('0'.toInt() <= b && b <= '9'.toInt()) {\n n *= 10\n n += (b - '0'.toInt()).toLong()\n } else return if (b == -1 || !isPrintableChar(b)) {\n if (minus) -n else n\n } else {\n throw NumberFormatException()\n }\n b = readByte()\n }\n }\n\n fun nextInt(): Int {\n val nl = nextLong()\n if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw NumberFormatException()\n return nl.toInt()\n }\n\n fun nextDouble(): Double {\n return java.lang.Double.parseDouble(next())\n }\n}", "language": "Kotlin", "metadata": {"date": 1569120530, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02904.html", "problem_id": "p02904", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02904/input.txt", "sample_output_relpath": "derived/input_output/data/p02904/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02904/Kotlin/s448025406.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s448025406", "user_id": "u073232808"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import java.io.IOException\nimport java.util.*\n\nfun main(args: Array) {\n val sc = FastScanner()\n val n = sc.nextInt()\n val k = sc.nextInt()\n val p = (0 until n).map { sc.next().toInt() }\n println(problem038b(n, k, p))\n}\n\nfun problem038b(n: Int, k: Int, p: List): Int {\n var count = 0\n val dp = (0 until n).map { listOf() }.toMutableList()\n if (n == k) return 1\n dp[0] = p.subList(0, k)\n for (i in 1 until n - k + 1) {\n dp[i] = p.subList(i, i + k)\n if (dp[i] != dp[i - 1]) count++\n }\n return count\n}\n\nclass FastScanner {\n private val `in` = System.`in`\n private val buffer = ByteArray(1024)\n private var ptr = 0\n private var buflen = 0\n private fun hasNextByte(): Boolean {\n if (ptr < buflen) {\n return true\n } else {\n ptr = 0\n try {\n buflen = `in`.read(buffer)\n } catch (e: IOException) {\n e.printStackTrace()\n }\n\n if (buflen <= 0) {\n return false\n }\n }\n return true\n }\n\n private fun readByte(): Int {\n return if (hasNextByte()) buffer[ptr++].toInt() else -1\n }\n\n private fun isPrintableChar(c: Int): Boolean {\n return c in 33..126\n }\n\n operator fun hasNext(): Boolean {\n while (hasNextByte() && !isPrintableChar(buffer[ptr].toInt())) ptr++\n return hasNextByte()\n }\n\n operator fun next(): String {\n if (!hasNext()) throw NoSuchElementException()\n val sb = StringBuilder()\n var b = readByte()\n while (isPrintableChar(b)) {\n sb.appendCodePoint(b)\n b = readByte()\n }\n return sb.toString()\n }\n\n fun nextLong(): Long {\n if (!hasNext()) throw NoSuchElementException()\n var n: Long = 0\n var minus = false\n var b = readByte()\n if (b == '-'.toInt()) {\n minus = true\n b = readByte()\n }\n if (b < '0'.toInt() || '9'.toInt() < b) {\n throw NumberFormatException()\n }\n while (true) {\n if ('0'.toInt() <= b && b <= '9'.toInt()) {\n n *= 10\n n += (b - '0'.toInt()).toLong()\n } else return if (b == -1 || !isPrintableChar(b)) {\n if (minus) -n else n\n } else {\n throw NumberFormatException()\n }\n b = readByte()\n }\n }\n\n fun nextInt(): Int {\n val nl = nextLong()\n if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw NumberFormatException()\n return nl.toInt()\n }\n\n fun nextDouble(): Double {\n return java.lang.Double.parseDouble(next())\n }\n}", "problem_context": "Score : 700 points\n\nProblem Statement\n\nSnuke has a permutation (P_0,P_1,\\cdots,P_{N-1}) of (0,1,\\cdots,N-1).\n\nNow, he will perform the following operation exactly once:\n\nChoose K consecutive elements in P and sort them in ascending order.\n\nFind the number of permutations that can be produced as P after the operation.\n\nConstraints\n\n2 \\leq N \\leq 200000\n\n2 \\leq K \\leq N\n\n0 \\leq P_i \\leq N-1\n\nP_0,P_1,\\cdots,P_{N-1} 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 K\nP_0 P_1 \\cdots P_{N-1}\n\nOutput\n\nPrint the number of permutations that can be produced as P after the operation.\n\nSample Input 1\n\n5 3\n0 2 1 4 3\n\nSample Output 1\n\n2\n\nTwo permutations can be produced as P after the operation: (0,1,2,4,3) and (0,2,1,3,4).\n\nSample Input 2\n\n4 4\n0 1 2 3\n\nSample Output 2\n\n1\n\nSample Input 3\n\n10 4\n2 0 1 3 7 5 4 6 8 9\n\nSample Output 3\n\n6", "sample_input": "5 3\n0 2 1 4 3\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02904", "source_text": "Score : 700 points\n\nProblem Statement\n\nSnuke has a permutation (P_0,P_1,\\cdots,P_{N-1}) of (0,1,\\cdots,N-1).\n\nNow, he will perform the following operation exactly once:\n\nChoose K consecutive elements in P and sort them in ascending order.\n\nFind the number of permutations that can be produced as P after the operation.\n\nConstraints\n\n2 \\leq N \\leq 200000\n\n2 \\leq K \\leq N\n\n0 \\leq P_i \\leq N-1\n\nP_0,P_1,\\cdots,P_{N-1} 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 K\nP_0 P_1 \\cdots P_{N-1}\n\nOutput\n\nPrint the number of permutations that can be produced as P after the operation.\n\nSample Input 1\n\n5 3\n0 2 1 4 3\n\nSample Output 1\n\n2\n\nTwo permutations can be produced as P after the operation: (0,1,2,4,3) and (0,2,1,3,4).\n\nSample Input 2\n\n4 4\n0 1 2 3\n\nSample Output 2\n\n1\n\nSample Input 3\n\n10 4\n2 0 1 3 7 5 4 6 8 9\n\nSample Output 3\n\n6", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2741, "cpu_time_ms": 440, "memory_kb": 56968}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s303305715", "group_id": "codeNet:p02909", "input_text": "fun main(args: Array) {\n val S = readLine()!!\n val map = mapOf(\"Sunny\" to \"Cloudy\", \"Cloudy\" to \"Rainy\", \"Rainy\" to \"Sunny\")\n println(map[S])\n}", "language": "Kotlin", "metadata": {"date": 1589694396, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02909.html", "problem_id": "p02909", "resource_group": "medium_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/Kotlin/s303305715.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s303305715", "user_id": "u860789370"}, "prompt_components": {"gold_output": "Cloudy\n", "input_to_evaluate": "fun main(args: Array) {\n val S = readLine()!!\n val map = mapOf(\"Sunny\" to \"Cloudy\", \"Cloudy\" to \"Rainy\", \"Rainy\" to \"Sunny\")\n println(map[S])\n}", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 203, "memory_kb": 31816}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s569136327", "group_id": "codeNet:p02909", "input_text": "import java.util.*\n\nfun main(args: Array){\n\tval sc = Scanner(System.`in`)\n \tval today = sc.next()\n \tprint(when(today){\n \"Sunny\" -> \"Cloudy\"\n \"Cloudy\" -> \"Rainy\"\n\t \"Rainy\" -> \"Sunny\"\n else -> \"unreachable\"\n })\n}\n", "language": "Kotlin", "metadata": {"date": 1573056114, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02909.html", "problem_id": "p02909", "resource_group": "medium_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/Kotlin/s569136327.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s569136327", "user_id": "u324881146"}, "prompt_components": {"gold_output": "Cloudy\n", "input_to_evaluate": "import java.util.*\n\nfun main(args: Array){\n\tval sc = Scanner(System.`in`)\n \tval today = sc.next()\n \tprint(when(today){\n \"Sunny\" -> \"Cloudy\"\n \"Cloudy\" -> \"Rainy\"\n\t \"Rainy\" -> \"Sunny\"\n else -> \"unreachable\"\n })\n}\n", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 173, "memory_kb": 29480}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s445330419", "group_id": "codeNet:p02909", "input_text": "import java.io.PrintWriter\nval pw = PrintWriter(System.out)\n\nfun main(args : Array) {\n func()\n pw.flush()\n}\n\nfun func() {\n val n = next()\n println(when(n) {\n \"Sunny\" -> \"Cloudy\"\n \"Cloudy\" -> \"Rainy\"\n \"Rainy\" -> \"Sunny\"\n else -> \"\"\n })\n}\n\nfun next() = readLine()!!\n\nfun println(value : Any) {\n pw.println(value)\n}", "language": "Kotlin", "metadata": {"date": 1568595962, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02909.html", "problem_id": "p02909", "resource_group": "medium_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/Kotlin/s445330419.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s445330419", "user_id": "u262403099"}, "prompt_components": {"gold_output": "Cloudy\n", "input_to_evaluate": "import java.io.PrintWriter\nval pw = PrintWriter(System.out)\n\nfun main(args : Array) {\n func()\n pw.flush()\n}\n\nfun func() {\n val n = next()\n println(when(n) {\n \"Sunny\" -> \"Cloudy\"\n \"Cloudy\" -> \"Rainy\"\n \"Rainy\" -> \"Sunny\"\n else -> \"\"\n })\n}\n\nfun next() = readLine()!!\n\nfun println(value : Any) {\n pw.println(value)\n}", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 206, "memory_kb": 31620}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s134062322", "group_id": "codeNet:p02910", "input_text": "fun main(args: Array){\n val S = readLine()!!\n for( i in S.indices ){\n if( S[i] == 'U' || S[i] == 'D' || i%2 == 1 && S[i] == 'L' || i%2 == 0 && S[i] == 'R')\n continue\n println(\"No\")\n return\n }\n println(\"Yes\")\n}\n", "language": "Kotlin", "metadata": {"date": 1568596047, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02910.html", "problem_id": "p02910", "resource_group": "medium_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/Kotlin/s134062322.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s134062322", "user_id": "u657065743"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "fun main(args: Array){\n val S = readLine()!!\n for( i in S.indices ){\n if( S[i] == 'U' || S[i] == 'D' || i%2 == 1 && S[i] == 'L' || i%2 == 0 && S[i] == 'R')\n continue\n println(\"No\")\n return\n }\n println(\"Yes\")\n}\n", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 217, "memory_kb": 33852}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s043668027", "group_id": "codeNet:p02910", "input_text": "import java.io.PrintWriter\nval pw = PrintWriter(System.out)\n\nfun main(args : Array) {\n func()\n pw.flush()\n}\n\nfun func() {\n val ss = next()\n\n for (i in 0 until ss.length) {\n val s = ss[i]\n if (i % 2 == 0) {\n // odd\n if (s != 'R' && s != 'U' && s != 'D') {\n println(\"No\")\n return\n }\n } else {\n // even\n if (s != 'L' && s != 'U' && s != 'D') {\n println(\"No\")\n return\n }\n }\n }\n println(\"Yes\")\n}\n\nfun next() = readLine()!!\n\nfun println(value : Any) {\n pw.println(value)\n}", "language": "Kotlin", "metadata": {"date": 1568595866, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02910.html", "problem_id": "p02910", "resource_group": "medium_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/Kotlin/s043668027.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s043668027", "user_id": "u262403099"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "import java.io.PrintWriter\nval pw = PrintWriter(System.out)\n\nfun main(args : Array) {\n func()\n pw.flush()\n}\n\nfun func() {\n val ss = next()\n\n for (i in 0 until ss.length) {\n val s = ss[i]\n if (i % 2 == 0) {\n // odd\n if (s != 'R' && s != 'U' && s != 'D') {\n println(\"No\")\n return\n }\n } else {\n // even\n if (s != 'L' && s != 'U' && s != 'D') {\n println(\"No\")\n return\n }\n }\n }\n println(\"Yes\")\n}\n\nfun next() = readLine()!!\n\nfun println(value : Any) {\n pw.println(value)\n}", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 203, "memory_kb": 33744}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s714179376", "group_id": "codeNet:p02911", "input_text": "fun main(args: Array) {\n val (n, k, q) = readIntList()\n val a = List(q) { readInt() }\n val p = MutableList(n) { k }\n a.forEach {\n p[it-1]++\n }\n p.forEach {\n if (it-q > 0) println(\"Yes\")\n else println(\"No\")\n }\n}\n\n// Tools\nfun readString() = readLine()!!\nfun readInt() = readLine()!!.toInt()\nfun readLong() = readLine()!!.toLong()\nfun readStringList() = readLine()!!.split(\" \")\nfun readIntList() = readLine()!!.split(\" \").map(String::toInt)\nfun readLongList() = readLine()!!.split(\" \").map(String::toLong)", "language": "Kotlin", "metadata": {"date": 1593296838, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02911.html", "problem_id": "p02911", "resource_group": "medium_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/Kotlin/s714179376.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s714179376", "user_id": "u697467902"}, "prompt_components": {"gold_output": "No\nNo\nYes\nNo\nNo\nNo\n", "input_to_evaluate": "fun main(args: Array) {\n val (n, k, q) = readIntList()\n val a = List(q) { readInt() }\n val p = MutableList(n) { k }\n a.forEach {\n p[it-1]++\n }\n p.forEach {\n if (it-q > 0) println(\"Yes\")\n else println(\"No\")\n }\n}\n\n// Tools\nfun readString() = readLine()!!\nfun readInt() = readLine()!!.toInt()\nfun readLong() = readLine()!!.toLong()\nfun readStringList() = readLine()!!.split(\" \")\nfun readIntList() = readLine()!!.split(\" \").map(String::toInt)\nfun readLongList() = readLine()!!.split(\" \").map(String::toLong)", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 553, "cpu_time_ms": 769, "memory_kb": 64224}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s297584536", "group_id": "codeNet:p02911", "input_text": "import java.io.PrintWriter\nimport java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val n = sc.nextInt()\n val k = sc.nextLong()\n val q = sc.nextInt()\n val a = (0 until q).map { sc.next().toInt() }\n problem141c(n, q, k, a)\n}\n\nfun problem141c(n: Int, q: Int, k: Long, a: List): String {\n val dp = (0 until q).map { 0 }.toMutableList()\n for (i in 0 until q) {\n val winner = a[i]\n dp[winner - 1] = dp[winner - 1] + 1\n }\n val out = PrintWriter(System.out)\n for (element in dp) {\n out.println(if (q - k >= element) \"No\" else \"Yes\")\n }\n return \"\"\n}", "language": "Kotlin", "metadata": {"date": 1568602371, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02911.html", "problem_id": "p02911", "resource_group": "medium_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/Kotlin/s297584536.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s297584536", "user_id": "u073232808"}, "prompt_components": {"gold_output": "No\nNo\nYes\nNo\nNo\nNo\n", "input_to_evaluate": "import java.io.PrintWriter\nimport java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val n = sc.nextInt()\n val k = sc.nextLong()\n val q = sc.nextInt()\n val a = (0 until q).map { sc.next().toInt() }\n problem141c(n, q, k, a)\n}\n\nfun problem141c(n: Int, q: Int, k: Long, a: List): String {\n val dp = (0 until q).map { 0 }.toMutableList()\n for (i in 0 until q) {\n val winner = a[i]\n dp[winner - 1] = dp[winner - 1] + 1\n }\n val out = PrintWriter(System.out)\n for (element in dp) {\n out.println(if (q - k >= element) \"No\" else \"Yes\")\n }\n return \"\"\n}", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 633, "cpu_time_ms": 823, "memory_kb": 51800}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s950465280", "group_id": "codeNet:p02911", "input_text": "fun main(args: Array) {\n val (n, k, q) = readLine()!!.split(' ').map(String::toLong)\n val aList = mutableListOf()\n val ansCount = Array(n.toInt() + 1) { 0 }\n (1..q).forEach {\n val a = readLine()!!.toLong()\n aList.add(a)\n ansCount[a.toInt()] = ansCount[a.toInt()] + 1\n }\n\n for (i in 1..n.toInt()) {\n val p = k - q + ansCount[i]\n if (p > 0) {\n println(\"Yes\")\n } else {\n println(\"No\")\n }\n }\n}", "language": "Kotlin", "metadata": {"date": 1568596280, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02911.html", "problem_id": "p02911", "resource_group": "medium_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/Kotlin/s950465280.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s950465280", "user_id": "u099066216"}, "prompt_components": {"gold_output": "No\nNo\nYes\nNo\nNo\nNo\n", "input_to_evaluate": "fun main(args: Array) {\n val (n, k, q) = readLine()!!.split(' ').map(String::toLong)\n val aList = mutableListOf()\n val ansCount = Array(n.toInt() + 1) { 0 }\n (1..q).forEach {\n val a = readLine()!!.toLong()\n aList.add(a)\n ansCount[a.toInt()] = ansCount[a.toInt()] + 1\n }\n\n for (i in 1..n.toInt()) {\n val p = k - q + ansCount[i]\n if (p > 0) {\n println(\"Yes\")\n } else {\n println(\"No\")\n }\n }\n}", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 495, "cpu_time_ms": 968, "memory_kb": 48100}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s087675856", "group_id": "codeNet:p02915", "input_text": "fun main(arr:Array) {\n val n = readLine()!!.toInt()\n println(n*n*n)\n}\n", "language": "Kotlin", "metadata": {"date": 1583803908, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02915.html", "problem_id": "p02915", "resource_group": "medium_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/Kotlin/s087675856.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s087675856", "user_id": "u269969976"}, "prompt_components": {"gold_output": "8\n", "input_to_evaluate": "fun main(arr:Array) {\n val n = readLine()!!.toInt()\n println(n*n*n)\n}\n", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 206, "memory_kb": 29904}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s856972995", "group_id": "codeNet:p02915", "input_text": "fun main (args: Array) {\n val n = readLine()!!.toInt()\n println(n*n*n)\n}\n", "language": "Kotlin", "metadata": {"date": 1569805721, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02915.html", "problem_id": "p02915", "resource_group": "medium_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/Kotlin/s856972995.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s856972995", "user_id": "u454524105"}, "prompt_components": {"gold_output": "8\n", "input_to_evaluate": "fun main (args: Array) {\n val n = readLine()!!.toInt()\n println(n*n*n)\n}\n", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 199, "memory_kb": 29868}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s414103605", "group_id": "codeNet:p02916", "input_text": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val n = sc.nextInt()\n val a = (1..n).map { sc.nextInt() - 1 }\n val b = (1..n).map { sc.nextInt() }\n val c = (1 until n).map { sc.nextInt() }\n var ans = 0\n repeat(n) {\n ans += b[a[it]]\n if (0 < it && a[it] == a[it - 1] + 1) {\n ans += c[a[it - 1]]\n }\n }\n println(ans)\n}", "language": "Kotlin", "metadata": {"date": 1583207039, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02916.html", "problem_id": "p02916", "resource_group": "medium_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/Kotlin/s414103605.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s414103605", "user_id": "u733811860"}, "prompt_components": {"gold_output": "14\n", "input_to_evaluate": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val n = sc.nextInt()\n val a = (1..n).map { sc.nextInt() - 1 }\n val b = (1..n).map { sc.nextInt() }\n val c = (1 until n).map { sc.nextInt() }\n var ans = 0\n repeat(n) {\n ans += b[a[it]]\n if (0 < it && a[it] == a[it - 1] + 1) {\n ans += c[a[it - 1]]\n }\n }\n println(ans)\n}", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 410, "cpu_time_ms": 195, "memory_kb": 29480}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s617685822", "group_id": "codeNet:p02916", "input_text": "import java.io.*\nimport java.util.*\n\nfun solve(N: Int, A: IntArray, B: IntArray, C: IntArray){\n var ans = B[A[0] - 1]\n for (i in 1 until N){\n ans += B[A[i] - 1]\n if(A[i] == A[i-1] + 1) ans += C[A[i-1]-1]\n }\n println(ans)\n return\n}\n\n\nfun main(args: Array) {\n fun StringArray(size: Int, init: (Int) -> String = { \"\\u0000\" }): Array {\n return Array(size, init)\n }\n class Scanner(stream: InputStream) {\n private val reader = BufferedInputStream(stream).bufferedReader()\n private var st: StringTokenizer? = null\n fun next(): String {\n while (!(st?.hasMoreTokens() ?: false)) st = StringTokenizer(reader.readLine())\n return st!!.nextToken()\n }\n }\n val sc = Scanner(System.`in`)\n val N = sc.next().toInt()\n val A = IntArray(N)\n for (i in 0 until N) {\n A[i] = sc.next().toInt()\n }\n val B = IntArray(N)\n for (i in 0 until N) {\n B[i] = sc.next().toInt()\n }\n val C = IntArray((N-1))\n for (i in 0 until (N-1)) {\n C[i] = sc.next().toInt()\n }\n solve(N, A, B, C)\n}\n\n", "language": "Kotlin", "metadata": {"date": 1568819990, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02916.html", "problem_id": "p02916", "resource_group": "medium_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/Kotlin/s617685822.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s617685822", "user_id": "u329232967"}, "prompt_components": {"gold_output": "14\n", "input_to_evaluate": "import java.io.*\nimport java.util.*\n\nfun solve(N: Int, A: IntArray, B: IntArray, C: IntArray){\n var ans = B[A[0] - 1]\n for (i in 1 until N){\n ans += B[A[i] - 1]\n if(A[i] == A[i-1] + 1) ans += C[A[i-1]-1]\n }\n println(ans)\n return\n}\n\n\nfun main(args: Array) {\n fun StringArray(size: Int, init: (Int) -> String = { \"\\u0000\" }): Array {\n return Array(size, init)\n }\n class Scanner(stream: InputStream) {\n private val reader = BufferedInputStream(stream).bufferedReader()\n private var st: StringTokenizer? = null\n fun next(): String {\n while (!(st?.hasMoreTokens() ?: false)) st = StringTokenizer(reader.readLine())\n return st!!.nextToken()\n }\n }\n val sc = Scanner(System.`in`)\n val N = sc.next().toInt()\n val A = IntArray(N)\n for (i in 0 until N) {\n A[i] = sc.next().toInt()\n }\n val B = IntArray(N)\n for (i in 0 until N) {\n B[i] = sc.next().toInt()\n }\n val C = IntArray((N-1))\n for (i in 0 until (N-1)) {\n C[i] = sc.next().toInt()\n }\n solve(N, A, B, C)\n}\n\n", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1130, "cpu_time_ms": 189, "memory_kb": 31400}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s757103359", "group_id": "codeNet:p02917", "input_text": "\nfun main(args:Array) {\n val n = readLine()!!.toInt()\n val bList = readLine()!!.split(\" \").map { it.toInt() }\n val aList = mutableListOf()\n aList.add(bList.first())\n\n for(i in (1 .. bList.lastIndex)) {\n val tmp = Math.min(bList[i-1], bList[i])\n aList.add(tmp)\n }\n aList.add(bList.last())\n println(aList.sum())\n\n}\n", "language": "Kotlin", "metadata": {"date": 1581091337, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02917.html", "problem_id": "p02917", "resource_group": "medium_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/Kotlin/s757103359.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s757103359", "user_id": "u269969976"}, "prompt_components": {"gold_output": "9\n", "input_to_evaluate": "\nfun main(args:Array) {\n val n = readLine()!!.toInt()\n val bList = readLine()!!.split(\" \").map { it.toInt() }\n val aList = mutableListOf()\n aList.add(bList.first())\n\n for(i in (1 .. bList.lastIndex)) {\n val tmp = Math.min(bList[i-1], bList[i])\n aList.add(tmp)\n }\n aList.add(bList.last())\n println(aList.sum())\n\n}\n", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 235, "memory_kb": 38112}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s637589387", "group_id": "codeNet:p02917", "input_text": "fun main(args: Array) {\n val n = readLine()!!.toInt()\n val bList = readLine()!!.split(' ').map(String::toLong)\n val aList = Array(n) { 0L }\n aList[n - 1] = bList.last()\n aList[0] = bList.first()\n (n - 2 downTo 1).forEach {\n aList[it]=Math.min(bList[it],bList[it-1])\n }\n println(aList.sum())\n}", "language": "Kotlin", "metadata": {"date": 1567904976, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02917.html", "problem_id": "p02917", "resource_group": "medium_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/Kotlin/s637589387.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s637589387", "user_id": "u099066216"}, "prompt_components": {"gold_output": "9\n", "input_to_evaluate": "fun main(args: Array) {\n val n = readLine()!!.toInt()\n val bList = readLine()!!.split(' ').map(String::toLong)\n val aList = Array(n) { 0L }\n aList[n - 1] = bList.last()\n aList[0] = bList.first()\n (n - 2 downTo 1).forEach {\n aList[it]=Math.min(bList[it],bList[it-1])\n }\n println(aList.sum())\n}", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 249, "memory_kb": 36524}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s822149438", "group_id": "codeNet:p02918", "input_text": "fun main(args: Array) {\n\n val (n, k) = readLine()!!.split(\" \").map(String::toInt)\n val s = readLine()!!\n\n println(abc140d(n, k, s))\n}\n\n\nfun abc140d(n: Int, k: Int, s: String): Any? {\n\n val initScore = countHappy(s)\n\n return Math.min(initScore + 2 * k, s.length - 1)\n}\n\nfun countHappy(s: String): Int {\n var count = 0\n for (i in s.indices) {\n\n // 右端と左端は特別\n if (i == 0) {\n\n if (s[i] == 'L') {\n continue\n }\n\n if (s.length < 2) {\n continue\n }\n\n if (s[i + 1] == 'R') {\n count++\n }\n continue\n }\n if (i == s.length - 1) {\n if (s[i] == 'R') {\n continue\n }\n\n if (s[i - 1] == 'L') {\n count++\n }\n continue\n }\n\n if (s[i] == 'L') {\n if (s[i] == s[i - 1]) {\n count++\n }\n } else {\n if (s[i] == s[i + 1]) {\n count++\n }\n }\n }\n\n return count\n}\n", "language": "Kotlin", "metadata": {"date": 1567972772, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02918.html", "problem_id": "p02918", "resource_group": "medium_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/Kotlin/s822149438.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s822149438", "user_id": "u536308232"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "fun main(args: Array) {\n\n val (n, k) = readLine()!!.split(\" \").map(String::toInt)\n val s = readLine()!!\n\n println(abc140d(n, k, s))\n}\n\n\nfun abc140d(n: Int, k: Int, s: String): Any? {\n\n val initScore = countHappy(s)\n\n return Math.min(initScore + 2 * k, s.length - 1)\n}\n\nfun countHappy(s: String): Int {\n var count = 0\n for (i in s.indices) {\n\n // 右端と左端は特別\n if (i == 0) {\n\n if (s[i] == 'L') {\n continue\n }\n\n if (s.length < 2) {\n continue\n }\n\n if (s[i + 1] == 'R') {\n count++\n }\n continue\n }\n if (i == s.length - 1) {\n if (s[i] == 'R') {\n continue\n }\n\n if (s[i - 1] == 'L') {\n count++\n }\n continue\n }\n\n if (s[i] == 'L') {\n if (s[i] == s[i - 1]) {\n count++\n }\n } else {\n if (s[i] == s[i + 1]) {\n count++\n }\n }\n }\n\n return count\n}\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1114, "cpu_time_ms": 280, "memory_kb": 37868}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s269752272", "group_id": "codeNet:p02920", "input_text": "import java.util.*\n\nfun readList() = readLine()!!.split(\" \").map{it.toInt()}\nfun main(args:Array){\n val N = readLine()!!.toInt()\n val S = readList()\n val T = TreeMap()\n for(i in S){\n if(T.containsKey(i))T.put(i,T.get(i)!!+1) else T.put(i,1)\n }\n val l = T.lastKey()\n val P = mutableListOf(l)\n if(T[l] == 1)T.remove(l) else T.put(l,T[l]!!-1)\n var answer = true\n var k:Int\n var m = 1\n for(i in 0 until N-1){\n for(j in 0 until m){\n k = T.lowerKey(P[j])\n if(k == null){\n answer=false\n break\n }\n P += k\n if(T.get(k) == 1)T.remove(k) else T.put(k,T[k]!!-1)\n }\n m *= 2\n if(!answer)break\n }\n println(if(answer)\"Yes\" else \"No\")\n}", "language": "Kotlin", "metadata": {"date": 1568457277, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02920.html", "problem_id": "p02920", "resource_group": "medium_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/Kotlin/s269752272.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s269752272", "user_id": "u171144226"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "import java.util.*\n\nfun readList() = readLine()!!.split(\" \").map{it.toInt()}\nfun main(args:Array){\n val N = readLine()!!.toInt()\n val S = readList()\n val T = TreeMap()\n for(i in S){\n if(T.containsKey(i))T.put(i,T.get(i)!!+1) else T.put(i,1)\n }\n val l = T.lastKey()\n val P = mutableListOf(l)\n if(T[l] == 1)T.remove(l) else T.put(l,T[l]!!-1)\n var answer = true\n var k:Int\n var m = 1\n for(i in 0 until N-1){\n for(j in 0 until m){\n k = T.lowerKey(P[j])\n if(k == null){\n answer=false\n break\n }\n P += k\n if(T.get(k) == 1)T.remove(k) else T.put(k,T[k]!!-1)\n }\n m *= 2\n if(!answer)break\n }\n println(if(answer)\"Yes\" else \"No\")\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 709, "cpu_time_ms": 1162, "memory_kb": 111488}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s441342431", "group_id": "codeNet:p02921", "input_text": "import java.util.*\n\nfun main(args: Array) {\n val s = readNext().split(\"\")\n val t = readNext().split(\"\")\n\n var resultCount = 0\n if (s.get(1).equals(t.get(1))) {\n\n resultCount++\n }\n if (s.get(2).equals( t.get(2))) {\n resultCount++\n }\n if (s.get(3).equals( t.get(3))) {\n resultCount++\n }\n println(resultCount)\n}\n\n fun readNext(): String {\n return readLine()!!\n }\n", "language": "Kotlin", "metadata": {"date": 1567364804, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02921.html", "problem_id": "p02921", "resource_group": "medium_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/Kotlin/s441342431.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s441342431", "user_id": "u376174428"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import java.util.*\n\nfun main(args: Array) {\n val s = readNext().split(\"\")\n val t = readNext().split(\"\")\n\n var resultCount = 0\n if (s.get(1).equals(t.get(1))) {\n\n resultCount++\n }\n if (s.get(2).equals( t.get(2))) {\n resultCount++\n }\n if (s.get(3).equals( t.get(3))) {\n resultCount++\n }\n println(resultCount)\n}\n\n fun readNext(): String {\n return readLine()!!\n }\n", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 242, "memory_kb": 36080}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s642570079", "group_id": "codeNet:p02921", "input_text": "fun main(args: Array) {\n val s = readLine()!!\n val t = readLine()!!\n var cnt = 0\n for ( i in 0..2) {\n if(s[i] == t[i]){\n cnt+=1\n }\n }\n\n println(cnt)\n\n}", "language": "Kotlin", "metadata": {"date": 1567364564, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02921.html", "problem_id": "p02921", "resource_group": "medium_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/Kotlin/s642570079.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s642570079", "user_id": "u889750959"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "fun main(args: Array) {\n val s = readLine()!!\n val t = readLine()!!\n var cnt = 0\n for ( i in 0..2) {\n if(s[i] == t[i]){\n cnt+=1\n }\n }\n\n println(cnt)\n\n}", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 202, "cpu_time_ms": 217, "memory_kb": 31832}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s963635302", "group_id": "codeNet:p02922", "input_text": "import java.util.Scanner;\n\nfun main (args : Array) {\n val input = Scanner(System.`in`);\n \n while (input.hasNext()) {\n val A = input.nextInt()\n val B = input.nextInt()\n var socket = A\n var num = 1\n \n while (socket < B) {\n ++num\n socket += A - 1 \n }\n \n println(num)\n }\n}", "language": "Kotlin", "metadata": {"date": 1595879654, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02922.html", "problem_id": "p02922", "resource_group": "medium_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/Kotlin/s963635302.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s963635302", "user_id": "u920836104"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "import java.util.Scanner;\n\nfun main (args : Array) {\n val input = Scanner(System.`in`);\n \n while (input.hasNext()) {\n val A = input.nextInt()\n val B = input.nextInt()\n var socket = A\n var num = 1\n \n while (socket < B) {\n ++num\n socket += A - 1 \n }\n \n println(num)\n }\n}", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 122, "memory_kb": 36360}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s237703133", "group_id": "codeNet:p02922", "input_text": "import java.util.Scanner;\n\nfun main (args : Array) {\n val input = Scanner(System.`in`);\n \n while (input.hasNext()) {\n val A = input.nextInt()\n val B = input.nextInt()\n var num = (B - 1) / (A - 1) + if ((B - 1) % (A - 1) != 0) 1 else 0\n \n if (num == 0) {\n ++num\n }\n \n println(num)\n }\n}", "language": "Kotlin", "metadata": {"date": 1595879394, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02922.html", "problem_id": "p02922", "resource_group": "medium_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/Kotlin/s237703133.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s237703133", "user_id": "u920836104"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "import java.util.Scanner;\n\nfun main (args : Array) {\n val input = Scanner(System.`in`);\n \n while (input.hasNext()) {\n val A = input.nextInt()\n val B = input.nextInt()\n var num = (B - 1) / (A - 1) + if ((B - 1) % (A - 1) != 0) 1 else 0\n \n if (num == 0) {\n ++num\n }\n \n println(num)\n }\n}", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 325, "cpu_time_ms": 129, "memory_kb": 36292}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s800258175", "group_id": "codeNet:p02922", "input_text": "fun main(args:Array){\n val (a,b) = readLine()!!.split(\" \").map{it.toInt()}\n var ans = 0\n var num = 1\n while(num <= b){\n if(num == 1) num += a\n else num += a - 1\n ans++\n }\n println(ans)\n}\n", "language": "Kotlin", "metadata": {"date": 1578063787, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02922.html", "problem_id": "p02922", "resource_group": "medium_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/Kotlin/s800258175.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s800258175", "user_id": "u480831358"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "fun main(args:Array){\n val (a,b) = readLine()!!.split(\" \").map{it.toInt()}\n var ans = 0\n var num = 1\n while(num <= b){\n if(num == 1) num += a\n else num += a - 1\n ans++\n }\n println(ans)\n}\n", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 238, "memory_kb": 37844}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s088382415", "group_id": "codeNet:p02922", "input_text": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val a = sc.nextInt()\n val b = sc.nextInt()\n println(problem139b(a, b))\n}\n\nfun problem139b(a: Int, b: Int): Int {\n var sum = 1\n var count = 0\n for (i in 1..20) {\n if (sum >= b) break\n sum += a - 1\n count++\n }\n return count\n}", "language": "Kotlin", "metadata": {"date": 1567365085, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02922.html", "problem_id": "p02922", "resource_group": "medium_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/Kotlin/s088382415.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s088382415", "user_id": "u073232808"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val a = sc.nextInt()\n val b = sc.nextInt()\n println(problem139b(a, b))\n}\n\nfun problem139b(a: Int, b: Int): Int {\n var sum = 1\n var count = 0\n for (i in 1..20) {\n if (sum >= b) break\n sum += a - 1\n count++\n }\n return count\n}", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 355, "cpu_time_ms": 195, "memory_kb": 31396}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s242991819", "group_id": "codeNet:p02922", "input_text": "fun main(args: Array) {\n val (a, b) = readLine()!!.split(\" \").map { it.toInt() }\n var now = 1\n var count = 0\n val add = a - 1\n while (now < b) {\n now += add\n count++\n }\n print(count)\n}\n", "language": "Kotlin", "metadata": {"date": 1567364811, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02922.html", "problem_id": "p02922", "resource_group": "medium_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/Kotlin/s242991819.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s242991819", "user_id": "u111718424"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "fun main(args: Array) {\n val (a, b) = readLine()!!.split(\" \").map { it.toInt() }\n var now = 1\n var count = 0\n val add = a - 1\n while (now < b) {\n now += add\n count++\n }\n print(count)\n}\n", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 242, "memory_kb": 38000}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s889926111", "group_id": "codeNet:p02922", "input_text": "fun main(args: Array) {\n val (a, b) = readLine()!!.split(\" \").map { it.toInt() }\n if (a == b) println(1)\n else println((b / a) + 1)\n}\n", "language": "Kotlin", "metadata": {"date": 1567364643, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02922.html", "problem_id": "p02922", "resource_group": "medium_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/Kotlin/s889926111.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s889926111", "user_id": "u122997134"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "fun main(args: Array) {\n val (a, b) = readLine()!!.split(\" \").map { it.toInt() }\n if (a == b) println(1)\n else println((b / a) + 1)\n}\n", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 272, "memory_kb": 37900}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s874280223", "group_id": "codeNet:p02924", "input_text": "fun main() {\n val n = readLine()!!.toLong()\n println(n * (n - 1) / 2)\n}\n", "language": "Kotlin", "metadata": {"date": 1594243142, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02924.html", "problem_id": "p02924", "resource_group": "medium_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/Kotlin/s874280223.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s874280223", "user_id": "u863309603"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "fun main() {\n val n = readLine()!!.toLong()\n println(n * (n - 1) / 2)\n}\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 102, "memory_kb": 34496}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s290759916", "group_id": "codeNet:p02924", "input_text": "fun main(args: Array) {\n val n = readLine()!!.toLong()\n println((n - 1) * n / 2)\n}\n", "language": "Kotlin", "metadata": {"date": 1567371191, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02924.html", "problem_id": "p02924", "resource_group": "medium_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/Kotlin/s290759916.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s290759916", "user_id": "u938650438"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "fun main(args: Array) {\n val n = readLine()!!.toLong()\n println((n - 1) * n / 2)\n}\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 205, "memory_kb": 29916}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s646601629", "group_id": "codeNet:p02928", "input_text": "fun main(args : Array) {\n val (N, K) = readLine()!!.split(\" \").map { it.toLong() }\n val A = readLine()!!.split(\" \").map { it.toLong() }.toLongArray()\n\n var n = N.toInt()\n\n\n val all = LongArray(n, { 0 })\n val onlyAfter = LongArray(n, { 0 })\n\n val MOD = 10000000007L\n var answer = 0L\n\n (0 until n).forEach { i ->\n (0 until n).forEach { j ->\n if (A[i] > A[j]) {\n if (j >= i) {\n onlyAfter[i] = (onlyAfter[i] + 1) % MOD\n }\n all[i] = (all[i] + 1) % MOD\n }\n }\n }\n\n (0 until n).forEach { i ->\n var local = 0L\n // For K\n local = (local + (onlyAfter[i] * K)) % MOD\n local = (local + (K * ((all[i] * (K-1))) / 2)) % MOD\n answer = (answer + local).mod(MOD)\n }\n\n println(answer)\n}", "language": "Kotlin", "metadata": {"date": 1566698473, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02928.html", "problem_id": "p02928", "resource_group": "medium_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/Kotlin/s646601629.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s646601629", "user_id": "u861095163"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "fun main(args : Array) {\n val (N, K) = readLine()!!.split(\" \").map { it.toLong() }\n val A = readLine()!!.split(\" \").map { it.toLong() }.toLongArray()\n\n var n = N.toInt()\n\n\n val all = LongArray(n, { 0 })\n val onlyAfter = LongArray(n, { 0 })\n\n val MOD = 10000000007L\n var answer = 0L\n\n (0 until n).forEach { i ->\n (0 until n).forEach { j ->\n if (A[i] > A[j]) {\n if (j >= i) {\n onlyAfter[i] = (onlyAfter[i] + 1) % MOD\n }\n all[i] = (all[i] + 1) % MOD\n }\n }\n }\n\n (0 until n).forEach { i ->\n var local = 0L\n // For K\n local = (local + (onlyAfter[i] * K)) % MOD\n local = (local + (K * ((all[i] * (K-1))) / 2)) % MOD\n answer = (answer + local).mod(MOD)\n }\n\n println(answer)\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 846, "cpu_time_ms": 361, "memory_kb": 40680}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s779836054", "group_id": "codeNet:p02934", "input_text": "fun main(args: Array) {\n val N = readLine()!!.toInt()\n val A = readLine()!!.split(\" \").map(String::toDouble)\n\n var sum = 0.0\n for(i in 0 until A.size) {\n sum += 1.0 / A[i]\n }\n println(1.0 / sum)\n}", "language": "Kotlin", "metadata": {"date": 1566177002, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02934.html", "problem_id": "p02934", "resource_group": "medium_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/Kotlin/s779836054.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s779836054", "user_id": "u388719350"}, "prompt_components": {"gold_output": "7.5\n", "input_to_evaluate": "fun main(args: Array) {\n val N = readLine()!!.toInt()\n val A = readLine()!!.split(\" \").map(String::toDouble)\n\n var sum = 0.0\n for(i in 0 until A.size) {\n sum += 1.0 / A[i]\n }\n println(1.0 / sum)\n}", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 256, "memory_kb": 38000}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s058159438", "group_id": "codeNet:p02934", "input_text": "import java.io.PrintWriter\nval pw = PrintWriter(System.out)\n\nfun main(args : Array) {\n func()\n pw.flush()\n}\n\nfun func() {\n val n = nextFloat()\n val aa = listOfFloat()\n\n var tmp = 0f\n for (a in aa) {\n tmp += (1f / a)\n }\n\n println(1f / tmp)\n}\n\nfun next() = readLine()!!\nfun nextFloat() = next().toFloat()\nfun listOfString() = next().split(\" \")\nfun listOfFloat() = listOfString().map { it.toFloat() }\n\nfun println(value : Any) {\n pw.println(value)\n}", "language": "Kotlin", "metadata": {"date": 1566176727, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02934.html", "problem_id": "p02934", "resource_group": "medium_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/Kotlin/s058159438.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s058159438", "user_id": "u262403099"}, "prompt_components": {"gold_output": "7.5\n", "input_to_evaluate": "import java.io.PrintWriter\nval pw = PrintWriter(System.out)\n\nfun main(args : Array) {\n func()\n pw.flush()\n}\n\nfun func() {\n val n = nextFloat()\n val aa = listOfFloat()\n\n var tmp = 0f\n for (a in aa) {\n tmp += (1f / a)\n }\n\n println(1f / tmp)\n}\n\nfun next() = readLine()!!\nfun nextFloat() = next().toFloat()\nfun listOfString() = next().split(\" \")\nfun listOfFloat() = listOfString().map { it.toFloat() }\n\nfun println(value : Any) {\n pw.println(value)\n}", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 488, "cpu_time_ms": 239, "memory_kb": 36056}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s700548812", "group_id": "codeNet:p02935", "input_text": "import java.util.*\n\nfun main(arr:Array) {\n val n = readLine()!!.toInt()\n val numbers = readLine()!!.split(\" \").map { it.toInt() }.sorted()\n val queue = PriorityQueue()\n queue.addAll(numbers.map { it.toDouble() })\n while (queue.count() > 2) {\n val current = (queue.poll() + queue.poll())/2\n queue.add(current)\n }\n val ans = (queue.poll() + queue.poll()) / 2\n println(ans)\n}\n", "language": "Kotlin", "metadata": {"date": 1583720286, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02935.html", "problem_id": "p02935", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02935/input.txt", "sample_output_relpath": "derived/input_output/data/p02935/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02935/Kotlin/s700548812.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s700548812", "user_id": "u269969976"}, "prompt_components": {"gold_output": "3.5\n", "input_to_evaluate": "import java.util.*\n\nfun main(arr:Array) {\n val n = readLine()!!.toInt()\n val numbers = readLine()!!.split(\" \").map { it.toInt() }.sorted()\n val queue = PriorityQueue()\n queue.addAll(numbers.map { it.toDouble() })\n while (queue.count() > 2) {\n val current = (queue.poll() + queue.poll())/2\n queue.add(current)\n }\n val ans = (queue.poll() + queue.poll()) / 2\n println(ans)\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nYou have a pot and N ingredients. Each ingredient has a real number parameter called value, and the value of the i-th ingredient (1 \\leq i \\leq N) is v_i.\n\nWhen you put two ingredients in the pot, they will vanish and result in the formation of a new ingredient. The value of the new ingredient will be (x + y) / 2 where x and y are the values of the ingredients consumed, and you can put this ingredient again in the pot.\n\nAfter you compose ingredients in this way N-1 times, you will end up with one ingredient. Find the maximum possible value of this ingredient.\n\nConstraints\n\n2 \\leq N \\leq 50\n\n1 \\leq v_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\nv_1 v_2 \\ldots v_N\n\nOutput\n\nPrint a decimal number (or an integer) representing the maximum possible value of the last ingredient remaining.\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\n3 4\n\nSample Output 1\n\n3.5\n\nIf you start with two ingredients, the only choice is to put both of them in the pot. The value of the ingredient resulting from the ingredients of values 3 and 4 is (3 + 4) / 2 = 3.5.\n\nPrinting 3.50001, 3.49999, and so on will also be accepted.\n\nSample Input 2\n\n3\n500 300 200\n\nSample Output 2\n\n375\n\nYou start with three ingredients this time, and you can choose what to use in the first composition. There are three possible choices:\n\nUse the ingredients of values 500 and 300 to produce an ingredient of value (500 + 300) / 2 = 400. The next composition will use this ingredient and the ingredient of value 200, resulting in an ingredient of value (400 + 200) / 2 = 300.\n\nUse the ingredients of values 500 and 200 to produce an ingredient of value (500 + 200) / 2 = 350. The next composition will use this ingredient and the ingredient of value 300, resulting in an ingredient of value (350 + 300) / 2 = 325.\n\nUse the ingredients of values 300 and 200 to produce an ingredient of value (300 + 200) / 2 = 250. The next composition will use this ingredient and the ingredient of value 500, resulting in an ingredient of value (250 + 500) / 2 = 375.\n\nThus, the maximum possible value of the last ingredient remaining is 375.\n\nPrinting 375.0 and so on will also be accepted.\n\nSample Input 3\n\n5\n138 138 138 138 138\n\nSample Output 3\n\n138", "sample_input": "2\n3 4\n"}, "reference_outputs": ["3.5\n"], "source_document_id": "p02935", "source_text": "Score : 300 points\n\nProblem Statement\n\nYou have a pot and N ingredients. Each ingredient has a real number parameter called value, and the value of the i-th ingredient (1 \\leq i \\leq N) is v_i.\n\nWhen you put two ingredients in the pot, they will vanish and result in the formation of a new ingredient. The value of the new ingredient will be (x + y) / 2 where x and y are the values of the ingredients consumed, and you can put this ingredient again in the pot.\n\nAfter you compose ingredients in this way N-1 times, you will end up with one ingredient. Find the maximum possible value of this ingredient.\n\nConstraints\n\n2 \\leq N \\leq 50\n\n1 \\leq v_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\nv_1 v_2 \\ldots v_N\n\nOutput\n\nPrint a decimal number (or an integer) representing the maximum possible value of the last ingredient remaining.\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\n3 4\n\nSample Output 1\n\n3.5\n\nIf you start with two ingredients, the only choice is to put both of them in the pot. The value of the ingredient resulting from the ingredients of values 3 and 4 is (3 + 4) / 2 = 3.5.\n\nPrinting 3.50001, 3.49999, and so on will also be accepted.\n\nSample Input 2\n\n3\n500 300 200\n\nSample Output 2\n\n375\n\nYou start with three ingredients this time, and you can choose what to use in the first composition. There are three possible choices:\n\nUse the ingredients of values 500 and 300 to produce an ingredient of value (500 + 300) / 2 = 400. The next composition will use this ingredient and the ingredient of value 200, resulting in an ingredient of value (400 + 200) / 2 = 300.\n\nUse the ingredients of values 500 and 200 to produce an ingredient of value (500 + 200) / 2 = 350. The next composition will use this ingredient and the ingredient of value 300, resulting in an ingredient of value (350 + 300) / 2 = 325.\n\nUse the ingredients of values 300 and 200 to produce an ingredient of value (300 + 200) / 2 = 250. The next composition will use this ingredient and the ingredient of value 500, resulting in an ingredient of value (250 + 500) / 2 = 375.\n\nThus, the maximum possible value of the last ingredient remaining is 375.\n\nPrinting 375.0 and so on will also be accepted.\n\nSample Input 3\n\n5\n138 138 138 138 138\n\nSample Output 3\n\n138", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 427, "cpu_time_ms": 270, "memory_kb": 37792}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s315668593", "group_id": "codeNet:p02935", "input_text": "fun main(args: Array) {\n val N = readInputLine().toInt()\n val vs = readInputLine().split(\" \").map { it.toDouble() }.toDoubleArray()\n \n vs.sort()\n \n for (i in 1 until N) {\n vs[i] = (vs[i] + vs[i - 1]) / 2.0\n }\n\n println(vs[N - 1])\n}\n\nfun readInputLine(): String {\n return readLine()!!\n}\n", "language": "Kotlin", "metadata": {"date": 1566177141, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02935.html", "problem_id": "p02935", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02935/input.txt", "sample_output_relpath": "derived/input_output/data/p02935/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02935/Kotlin/s315668593.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s315668593", "user_id": "u505558493"}, "prompt_components": {"gold_output": "3.5\n", "input_to_evaluate": "fun main(args: Array) {\n val N = readInputLine().toInt()\n val vs = readInputLine().split(\" \").map { it.toDouble() }.toDoubleArray()\n \n vs.sort()\n \n for (i in 1 until N) {\n vs[i] = (vs[i] + vs[i - 1]) / 2.0\n }\n\n println(vs[N - 1])\n}\n\nfun readInputLine(): String {\n return readLine()!!\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nYou have a pot and N ingredients. Each ingredient has a real number parameter called value, and the value of the i-th ingredient (1 \\leq i \\leq N) is v_i.\n\nWhen you put two ingredients in the pot, they will vanish and result in the formation of a new ingredient. The value of the new ingredient will be (x + y) / 2 where x and y are the values of the ingredients consumed, and you can put this ingredient again in the pot.\n\nAfter you compose ingredients in this way N-1 times, you will end up with one ingredient. Find the maximum possible value of this ingredient.\n\nConstraints\n\n2 \\leq N \\leq 50\n\n1 \\leq v_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\nv_1 v_2 \\ldots v_N\n\nOutput\n\nPrint a decimal number (or an integer) representing the maximum possible value of the last ingredient remaining.\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\n3 4\n\nSample Output 1\n\n3.5\n\nIf you start with two ingredients, the only choice is to put both of them in the pot. The value of the ingredient resulting from the ingredients of values 3 and 4 is (3 + 4) / 2 = 3.5.\n\nPrinting 3.50001, 3.49999, and so on will also be accepted.\n\nSample Input 2\n\n3\n500 300 200\n\nSample Output 2\n\n375\n\nYou start with three ingredients this time, and you can choose what to use in the first composition. There are three possible choices:\n\nUse the ingredients of values 500 and 300 to produce an ingredient of value (500 + 300) / 2 = 400. The next composition will use this ingredient and the ingredient of value 200, resulting in an ingredient of value (400 + 200) / 2 = 300.\n\nUse the ingredients of values 500 and 200 to produce an ingredient of value (500 + 200) / 2 = 350. The next composition will use this ingredient and the ingredient of value 300, resulting in an ingredient of value (350 + 300) / 2 = 325.\n\nUse the ingredients of values 300 and 200 to produce an ingredient of value (300 + 200) / 2 = 250. The next composition will use this ingredient and the ingredient of value 500, resulting in an ingredient of value (250 + 500) / 2 = 375.\n\nThus, the maximum possible value of the last ingredient remaining is 375.\n\nPrinting 375.0 and so on will also be accepted.\n\nSample Input 3\n\n5\n138 138 138 138 138\n\nSample Output 3\n\n138", "sample_input": "2\n3 4\n"}, "reference_outputs": ["3.5\n"], "source_document_id": "p02935", "source_text": "Score : 300 points\n\nProblem Statement\n\nYou have a pot and N ingredients. Each ingredient has a real number parameter called value, and the value of the i-th ingredient (1 \\leq i \\leq N) is v_i.\n\nWhen you put two ingredients in the pot, they will vanish and result in the formation of a new ingredient. The value of the new ingredient will be (x + y) / 2 where x and y are the values of the ingredients consumed, and you can put this ingredient again in the pot.\n\nAfter you compose ingredients in this way N-1 times, you will end up with one ingredient. Find the maximum possible value of this ingredient.\n\nConstraints\n\n2 \\leq N \\leq 50\n\n1 \\leq v_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\nv_1 v_2 \\ldots v_N\n\nOutput\n\nPrint a decimal number (or an integer) representing the maximum possible value of the last ingredient remaining.\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\n3 4\n\nSample Output 1\n\n3.5\n\nIf you start with two ingredients, the only choice is to put both of them in the pot. The value of the ingredient resulting from the ingredients of values 3 and 4 is (3 + 4) / 2 = 3.5.\n\nPrinting 3.50001, 3.49999, and so on will also be accepted.\n\nSample Input 2\n\n3\n500 300 200\n\nSample Output 2\n\n375\n\nYou start with three ingredients this time, and you can choose what to use in the first composition. There are three possible choices:\n\nUse the ingredients of values 500 and 300 to produce an ingredient of value (500 + 300) / 2 = 400. The next composition will use this ingredient and the ingredient of value 200, resulting in an ingredient of value (400 + 200) / 2 = 300.\n\nUse the ingredients of values 500 and 200 to produce an ingredient of value (500 + 200) / 2 = 350. The next composition will use this ingredient and the ingredient of value 300, resulting in an ingredient of value (350 + 300) / 2 = 325.\n\nUse the ingredients of values 300 and 200 to produce an ingredient of value (300 + 200) / 2 = 250. The next composition will use this ingredient and the ingredient of value 500, resulting in an ingredient of value (250 + 500) / 2 = 375.\n\nThus, the maximum possible value of the last ingredient remaining is 375.\n\nPrinting 375.0 and so on will also be accepted.\n\nSample Input 3\n\n5\n138 138 138 138 138\n\nSample Output 3\n\n138", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 328, "cpu_time_ms": 242, "memory_kb": 37952}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s997130699", "group_id": "codeNet:p02937", "input_text": "import java.util.HashMap\nfun main(args: Array) {\n val S = readLine()!!\n val T = readLine()!!\n val SL = S.length\n val TL = T.length\n val M = hashMapOf>()\n S.forEachIndexed{ index, char ->\n val e = M[char]\n if (e == null) M.put(char, mutableListOf(index, index + SL)) else e.addAll(listOf(index, index + SL))\n }\n for ((k, v) in M) v.sort()\n var sn = 0\n var tn = 0\n while (tn < TL) {\n val e = M[T[tn]]\n if (e == null) {\n println(-1)\n return //exit\n }\n val b = e.binarySearch(sn % SL)\n val p = if (b < 0) e[b.inv()] else e[b]\n sn += (p - sn % SL + 1)\n tn += 1\n }\n println(sn)\n}", "language": "Kotlin", "metadata": {"date": 1566229740, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02937.html", "problem_id": "p02937", "resource_group": "medium_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/Kotlin/s997130699.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s997130699", "user_id": "u043150661"}, "prompt_components": {"gold_output": "10\n", "input_to_evaluate": "import java.util.HashMap\nfun main(args: Array) {\n val S = readLine()!!\n val T = readLine()!!\n val SL = S.length\n val TL = T.length\n val M = hashMapOf>()\n S.forEachIndexed{ index, char ->\n val e = M[char]\n if (e == null) M.put(char, mutableListOf(index, index + SL)) else e.addAll(listOf(index, index + SL))\n }\n for ((k, v) in M) v.sort()\n var sn = 0\n var tn = 0\n while (tn < TL) {\n val e = M[T[tn]]\n if (e == null) {\n println(-1)\n return //exit\n }\n val b = e.binarySearch(sn % SL)\n val p = if (b < 0) e[b.inv()] else e[b]\n sn += (p - sn % SL + 1)\n tn += 1\n }\n println(sn)\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 562, "memory_kb": 46696}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s192831266", "group_id": "codeNet:p02937", "input_text": "import java.util.*\n\nfun main(args: Array) {\n val s = readLine()!!\n val t = readLine()!!\n val map = HashMap>()\n s.toCharArray().forEachIndexed { index, c ->\n if (map[c] == null) {\n map[c] = arrayListOf(index + 1, index + 1 + s.length)\n } else {\n map[c]!!.add(index + 1)\n map[c]!!.add(index + 1 + s.length)\n }\n }\n var i = 0\n var ans = 0L\n t.toCharArray().forEach { c ->\n if (map[c] == null) {\n println(\"-1\")\n return\n }\n val list = map[c]!!\n var returnIndex = list.binarySearch(i)\n if(returnIndex < 0) returnIndex = returnIndex.inv()\n ans += list[returnIndex] - i\n i = list[returnIndex]\n if(i > s.length) i -= s.length\n }\n println(ans)\n}", "language": "Kotlin", "metadata": {"date": 1566194061, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02937.html", "problem_id": "p02937", "resource_group": "medium_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/Kotlin/s192831266.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s192831266", "user_id": "u719622470"}, "prompt_components": {"gold_output": "10\n", "input_to_evaluate": "import java.util.*\n\nfun main(args: Array) {\n val s = readLine()!!\n val t = readLine()!!\n val map = HashMap>()\n s.toCharArray().forEachIndexed { index, c ->\n if (map[c] == null) {\n map[c] = arrayListOf(index + 1, index + 1 + s.length)\n } else {\n map[c]!!.add(index + 1)\n map[c]!!.add(index + 1 + s.length)\n }\n }\n var i = 0\n var ans = 0L\n t.toCharArray().forEach { c ->\n if (map[c] == null) {\n println(\"-1\")\n return\n }\n val list = map[c]!!\n var returnIndex = list.binarySearch(i)\n if(returnIndex < 0) returnIndex = returnIndex.inv()\n ans += list[returnIndex] - i\n i = list[returnIndex]\n if(i > s.length) i -= s.length\n }\n println(ans)\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 825, "cpu_time_ms": 373, "memory_kb": 41432}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s949256487", "group_id": "codeNet:p02940", "input_text": "import java.lang.Math.*\n\nprivate fun readln() = readLine()!!.trim()\nprivate fun readlnInt() = readln().toInt()\nprivate fun readlnStrings() = readln().split(' ')\nprivate fun readlnInts() = readlnStrings().map { it.toInt() }\nprivate fun readlnLongs() = readlnStrings().map { it.toLong() }\n\nfun check(A:Long, B:Long, C:Long): Long{\n val s = min(B, C)\n val l = max(B, C)\n if (A <= s) {\n return s - A\n } else if (A <= l){\n return l - A\n } else {\n return 0\n }\n}\n\nfun solve() {\n val N = readlnInt()\n val S = readln()\n var cntA = 0L\n var cntB = 0L\n var cntC = 0L\n var ttl = 1L\n val MOD = 998244353\n for (i in 0 until 3*N){\n val ch = S[i]\n if (ch=='R'){\n cntA += 1\n val r = check(cntA, cntB, cntC)\n ttl = ttl * (r+1) % MOD\n } else if (ch=='G') {\n cntB += 1\n val r = check(cntB, cntA, cntC)\n ttl = ttl * (r+1) % MOD\n } else {\n cntC += 1\n val r = check(cntC, cntA, cntB)\n ttl = ttl * (r+1) % MOD\n }\n }\n for (i in 1..N){\n ttl = ttl * i % MOD\n }\n println(ttl)\n}\n\n\nfun main(args: Array) {\n// val queryNum = readlnInt()\n// for (queryIdx in 1..queryNum) {\n// println(\"Case #$queryIdx:\")\n solve()\n// }\n}\n", "language": "Kotlin", "metadata": {"date": 1566095923, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02940.html", "problem_id": "p02940", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02940/input.txt", "sample_output_relpath": "derived/input_output/data/p02940/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02940/Kotlin/s949256487.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s949256487", "user_id": "u541568482"}, "prompt_components": {"gold_output": "216\n", "input_to_evaluate": "import java.lang.Math.*\n\nprivate fun readln() = readLine()!!.trim()\nprivate fun readlnInt() = readln().toInt()\nprivate fun readlnStrings() = readln().split(' ')\nprivate fun readlnInts() = readlnStrings().map { it.toInt() }\nprivate fun readlnLongs() = readlnStrings().map { it.toLong() }\n\nfun check(A:Long, B:Long, C:Long): Long{\n val s = min(B, C)\n val l = max(B, C)\n if (A <= s) {\n return s - A\n } else if (A <= l){\n return l - A\n } else {\n return 0\n }\n}\n\nfun solve() {\n val N = readlnInt()\n val S = readln()\n var cntA = 0L\n var cntB = 0L\n var cntC = 0L\n var ttl = 1L\n val MOD = 998244353\n for (i in 0 until 3*N){\n val ch = S[i]\n if (ch=='R'){\n cntA += 1\n val r = check(cntA, cntB, cntC)\n ttl = ttl * (r+1) % MOD\n } else if (ch=='G') {\n cntB += 1\n val r = check(cntB, cntA, cntC)\n ttl = ttl * (r+1) % MOD\n } else {\n cntC += 1\n val r = check(cntC, cntA, cntB)\n ttl = ttl * (r+1) % MOD\n }\n }\n for (i in 1..N){\n ttl = ttl * i % MOD\n }\n println(ttl)\n}\n\n\nfun main(args: Array) {\n// val queryNum = readlnInt()\n// for (queryIdx in 1..queryNum) {\n// println(\"Case #$queryIdx:\")\n solve()\n// }\n}\n", "problem_context": "Score : 800 points\n\nProblem Statement\n\nWe have 3N colored balls with IDs from 1 to 3N.\nA string S of length 3N represents the colors of the balls. The color of Ball i is red if S_i is R, green if S_i is G, and blue if S_i is B. There are N red balls, N green balls, and N blue balls.\n\nTakahashi will distribute these 3N balls to N people so that each person gets one red ball, one blue ball, and one green ball.\nThe people want balls with IDs close to each other, so he will additionally satisfy the following condition:\n\nLet a_j < b_j < c_j be the IDs of the balls received by the j-th person in ascending order.\n\nThen, \\sum_j (c_j-a_j) should be as small as possible.\n\nFind the number of ways in which Takahashi can distribute the balls. Since the answer can be enormous, compute it modulo 998244353.\nWe consider two ways to distribute the balls different if and only if there is a person who receives different sets of balls.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n|S|=3N\n\nS consists of R, G, and B, and each of these characters occurs N times in S.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS\n\nOutput\n\nPrint the number of ways in which Takahashi can distribute the balls, modulo 998244353.\n\nSample Input 1\n\n3\nRRRGGGBBB\n\nSample Output 1\n\n216\n\nThe minimum value of \\sum_j (c_j-a_j) is 18 when the balls are, for example, distributed as follows:\n\nThe first person gets Ball 1, 5, and 9.\n\nThe second person gets Ball 2, 4, and 8.\n\nThe third person gets Ball 3, 6, and 7.\n\nSample Input 2\n\n5\nBBRGRRGRGGRBBGB\n\nSample Output 2\n\n960", "sample_input": "3\nRRRGGGBBB\n"}, "reference_outputs": ["216\n"], "source_document_id": "p02940", "source_text": "Score : 800 points\n\nProblem Statement\n\nWe have 3N colored balls with IDs from 1 to 3N.\nA string S of length 3N represents the colors of the balls. The color of Ball i is red if S_i is R, green if S_i is G, and blue if S_i is B. There are N red balls, N green balls, and N blue balls.\n\nTakahashi will distribute these 3N balls to N people so that each person gets one red ball, one blue ball, and one green ball.\nThe people want balls with IDs close to each other, so he will additionally satisfy the following condition:\n\nLet a_j < b_j < c_j be the IDs of the balls received by the j-th person in ascending order.\n\nThen, \\sum_j (c_j-a_j) should be as small as possible.\n\nFind the number of ways in which Takahashi can distribute the balls. Since the answer can be enormous, compute it modulo 998244353.\nWe consider two ways to distribute the balls different if and only if there is a person who receives different sets of balls.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n|S|=3N\n\nS consists of R, G, and B, and each of these characters occurs N times in S.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS\n\nOutput\n\nPrint the number of ways in which Takahashi can distribute the balls, modulo 998244353.\n\nSample Input 1\n\n3\nRRRGGGBBB\n\nSample Output 1\n\n216\n\nThe minimum value of \\sum_j (c_j-a_j) is 18 when the balls are, for example, distributed as follows:\n\nThe first person gets Ball 1, 5, and 9.\n\nThe second person gets Ball 2, 4, and 8.\n\nThe third person gets Ball 3, 6, and 7.\n\nSample Input 2\n\n5\nBBRGRRGRGGRBBGB\n\nSample Output 2\n\n960", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1335, "cpu_time_ms": 272, "memory_kb": 36696}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s965178883", "group_id": "codeNet:p02945", "input_text": "import java.util.Scanner\n\nfun main(args: Array){\n val scanner = Scanner(System.`in`)\n val sa = scanner.next()\n val sb = scanner.next()\n val a = Integer.parseInt(sa)\n val b = Integer.parseInt(sb)\n var c = a + b\n var d = a * b\n var e = a - b\n if (c < d){ \n c == d\n }\n if (c < e){\n println(e)\n } else {\n println(c)\n }\n}", "language": "Kotlin", "metadata": {"date": 1581466889, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02945.html", "problem_id": "p02945", "resource_group": "medium_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/Kotlin/s965178883.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s965178883", "user_id": "u385678999"}, "prompt_components": {"gold_output": "-10\n", "input_to_evaluate": "import java.util.Scanner\n\nfun main(args: Array){\n val scanner = Scanner(System.`in`)\n val sa = scanner.next()\n val sb = scanner.next()\n val a = Integer.parseInt(sa)\n val b = Integer.parseInt(sb)\n var c = a + b\n var d = a * b\n var e = a - b\n if (c < d){ \n c == d\n }\n if (c < e){\n println(e)\n } else {\n println(c)\n }\n}", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 384, "cpu_time_ms": 181, "memory_kb": 29476}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s134685358", "group_id": "codeNet:p02947", "input_text": "fun main(args: Array) {\n val n = readInt()\n val found = mutableMapOf()\n var cnt = 0L\n repeat(n) {\n val s = readLine()!!.toCharArray().sorted().toString()\n if (found.contains(s)) {\n cnt += found[s]!!\n found[s] = found[s]!! + 1L\n } else {\n found[s] = 1L\n }\n }\n println(cnt)\n}\n\n// Tools\nfun readString() = readLine()!!\nfun readInt() = readLine()!!.toInt()\nfun readLong() = readLine()!!.toLong()\nfun readStringList() = readLine()!!.split(\" \")\nfun readIntList() = readLine()!!.split(\" \").map(String::toInt)\nfun readLongList() = readLine()!!.split(\" \").map(String::toLong)", "language": "Kotlin", "metadata": {"date": 1593912594, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02947.html", "problem_id": "p02947", "resource_group": "medium_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/Kotlin/s134685358.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s134685358", "user_id": "u697467902"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "fun main(args: Array) {\n val n = readInt()\n val found = mutableMapOf()\n var cnt = 0L\n repeat(n) {\n val s = readLine()!!.toCharArray().sorted().toString()\n if (found.contains(s)) {\n cnt += found[s]!!\n found[s] = found[s]!! + 1L\n } else {\n found[s] = 1L\n }\n }\n println(cnt)\n}\n\n// Tools\nfun readString() = readLine()!!\nfun readInt() = readLine()!!.toInt()\nfun readLong() = readLine()!!.toLong()\nfun readStringList() = readLine()!!.split(\" \")\nfun readIntList() = readLine()!!.split(\" \").map(String::toInt)\nfun readLongList() = readLine()!!.split(\" \").map(String::toLong)", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 685, "memory_kb": 72260}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s340574467", "group_id": "codeNet:p02948", "input_text": "import java.util.PriorityQueue\nimport kotlin.comparisons.compareByDescending\nfun main(arg: Array) {\n val (N, M) = listOfInt()\n val jobs = Array(M) { mutableListOf() }\n repeat(N) {\n val (A, B) = listOfInt()\n if (A <= M) jobs[M - A].add(B)\n }\n var ans = 0L\n val q = PriorityQueue(N, compareByDescending { it })\n for (n in (0 until M).reversed()) {\n jobs[n].forEach { q.add(it) }\n if (q.size > 0) {\n ans += q.poll()!!\n }\n }\n println(ans)\n}\nfun next() = readLine()!!\nfun listOfString() = next().split(\" \")\nfun listOfInt(delta: Int = 0) = listOfString().map { Integer.parseInt(it) + delta }\n", "language": "Kotlin", "metadata": {"date": 1581371193, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02948.html", "problem_id": "p02948", "resource_group": "medium_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/Kotlin/s340574467.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s340574467", "user_id": "u043150661"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "import java.util.PriorityQueue\nimport kotlin.comparisons.compareByDescending\nfun main(arg: Array) {\n val (N, M) = listOfInt()\n val jobs = Array(M) { mutableListOf() }\n repeat(N) {\n val (A, B) = listOfInt()\n if (A <= M) jobs[M - A].add(B)\n }\n var ans = 0L\n val q = PriorityQueue(N, compareByDescending { it })\n for (n in (0 until M).reversed()) {\n jobs[n].forEach { q.add(it) }\n if (q.size > 0) {\n ans += q.poll()!!\n }\n }\n println(ans)\n}\nfun next() = readLine()!!\nfun listOfString() = next().split(\" \")\nfun listOfInt(delta: Int = 0) = listOfString().map { Integer.parseInt(it) + delta }\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 770, "memory_kb": 69772}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s869616937", "group_id": "codeNet:p02951", "input_text": "import java.io.PrintWriter\nimport java.util.*\nimport java.math.*\nimport java.lang.*\n\nval pw = PrintWriter(System.out)\nval MOD: Long = (1e+9 + 7).toLong()\n\nfun main(args: Array) {\n val (a, b, c) = readListOfInt()\n val ans = c - Math.min(a-b, c)\n println(ans)\n \n pw.flush()\n}\n\n/****** Declared Functions and Data Structures ******/\n// IO\nfun read() = readLine()!!\nfun readInt() = read().toInt()\nfun readLong() = read().toLong()\nfun readDouble() = read().toDouble()\nfun readListOfString() = read().split(\" \")\nfun readListOfInt() = readListOfString().map { it.toInt() }\nfun readListOfLong() = readListOfString().map { it.toLong() }\nfun readListOfDouble() = readListOfString().map { it.toDouble() }\n\nfun Double.format(digits: Int) = String.format(\"%.${digits}f\", this)\nfun Float.format(digits: Int) = String.format(\"%.${digits}f\", this)\n\nfun print(value: Any) { pw.print(value) }\nfun println(value : Any) { pw.println(value) }\n\nfun permutations(src: List): List> {\n if(src.size == 1) return listOf(src)\n val perms = mutableListOf>()\n val insertElement = src[0]\n permutations(src.drop(1)).forEach { perm ->\n for(i in 0..perm.size) {\n val newPerm = perm.toMutableList()\n newPerm.add(i, insertElement)\n perms.add(newPerm.toList())\n }\n }\n return perms\n}\n\n// return nCr, if you want nCr, please access v[n][r]\nfun combinations(n: Long): List> {\n val v = (0..n).map { (0..n).map{0L}.toMutableList() }.toMutableList()\n for(i in 0 until v.size) {\n v[i][0] = 1L\n v[i][i] = 1L\n }\n for(i in 0 until v.size) {\n for(j in 1 until i) {\n v[i][j] = (v[i-1][j-1] + v[i-1][j]) % MOD\n }\n }\n return v.map { it.toList() }.toList()\n}\n\n// should be a >= b\nfun gcd(a: Long, b: Long): Long = \n if(b == 0L) a else gcd(b, a % b)\n\n// shoud be a >= b\nfun lcm(a: Long, b: Long): Long = \n a / gcd(a, b) * b\n\nfun sumDigits(num_: Long): Long {\n var num = num_\n var rtn: Long = 0\n while(num != 0.toLong()) {\n val tmp = num % 10\n rtn += tmp\n num /= 10\n }\n return rtn\n}\n\nfun isDecimal(v: Double): Boolean = ((v - Math.floor(v)) != 0.0)\n\n// Data Structures\nclass Stack(private var st: MutableList = mutableListOf()) {\n fun isEmpty() = st.isEmpty()\n fun top(): T = st.last()\n fun push(e: T) { st.add(e) }\n fun pop() { st = st.dropLast(1).toMutableList() }\n}\n\nclass Queue(private var que: MutableList = mutableListOf()) {\n fun isEmpty() = que.isEmpty()\n fun top(): T = que.first()\n fun push(e: T) { que.add(e) }\n fun pop() { que = que.drop(1).toMutableList() }\n}\n", "language": "Kotlin", "metadata": {"date": 1564966928, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02951.html", "problem_id": "p02951", "resource_group": "medium_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/Kotlin/s869616937.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s869616937", "user_id": "u026686258"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "import java.io.PrintWriter\nimport java.util.*\nimport java.math.*\nimport java.lang.*\n\nval pw = PrintWriter(System.out)\nval MOD: Long = (1e+9 + 7).toLong()\n\nfun main(args: Array) {\n val (a, b, c) = readListOfInt()\n val ans = c - Math.min(a-b, c)\n println(ans)\n \n pw.flush()\n}\n\n/****** Declared Functions and Data Structures ******/\n// IO\nfun read() = readLine()!!\nfun readInt() = read().toInt()\nfun readLong() = read().toLong()\nfun readDouble() = read().toDouble()\nfun readListOfString() = read().split(\" \")\nfun readListOfInt() = readListOfString().map { it.toInt() }\nfun readListOfLong() = readListOfString().map { it.toLong() }\nfun readListOfDouble() = readListOfString().map { it.toDouble() }\n\nfun Double.format(digits: Int) = String.format(\"%.${digits}f\", this)\nfun Float.format(digits: Int) = String.format(\"%.${digits}f\", this)\n\nfun print(value: Any) { pw.print(value) }\nfun println(value : Any) { pw.println(value) }\n\nfun permutations(src: List): List> {\n if(src.size == 1) return listOf(src)\n val perms = mutableListOf>()\n val insertElement = src[0]\n permutations(src.drop(1)).forEach { perm ->\n for(i in 0..perm.size) {\n val newPerm = perm.toMutableList()\n newPerm.add(i, insertElement)\n perms.add(newPerm.toList())\n }\n }\n return perms\n}\n\n// return nCr, if you want nCr, please access v[n][r]\nfun combinations(n: Long): List> {\n val v = (0..n).map { (0..n).map{0L}.toMutableList() }.toMutableList()\n for(i in 0 until v.size) {\n v[i][0] = 1L\n v[i][i] = 1L\n }\n for(i in 0 until v.size) {\n for(j in 1 until i) {\n v[i][j] = (v[i-1][j-1] + v[i-1][j]) % MOD\n }\n }\n return v.map { it.toList() }.toList()\n}\n\n// should be a >= b\nfun gcd(a: Long, b: Long): Long = \n if(b == 0L) a else gcd(b, a % b)\n\n// shoud be a >= b\nfun lcm(a: Long, b: Long): Long = \n a / gcd(a, b) * b\n\nfun sumDigits(num_: Long): Long {\n var num = num_\n var rtn: Long = 0\n while(num != 0.toLong()) {\n val tmp = num % 10\n rtn += tmp\n num /= 10\n }\n return rtn\n}\n\nfun isDecimal(v: Double): Boolean = ((v - Math.floor(v)) != 0.0)\n\n// Data Structures\nclass Stack(private var st: MutableList = mutableListOf()) {\n fun isEmpty() = st.isEmpty()\n fun top(): T = st.last()\n fun push(e: T) { st.add(e) }\n fun pop() { st = st.dropLast(1).toMutableList() }\n}\n\nclass Queue(private var que: MutableList = mutableListOf()) {\n fun isEmpty() = que.isEmpty()\n fun top(): T = que.first()\n fun push(e: T) { que.add(e) }\n fun pop() { que = que.drop(1).toMutableList() }\n}\n", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2680, "cpu_time_ms": 235, "memory_kb": 38000}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s485910449", "group_id": "codeNet:p02952", "input_text": "\nfun main(args:Array) {\n val n = readLine()!!.toInt()\n val ans = (1..n).map { it.toString().length }.filter { it%2!=0 }.size\n println(ans)\n}", "language": "Kotlin", "metadata": {"date": 1590158709, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02952.html", "problem_id": "p02952", "resource_group": "medium_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/Kotlin/s485910449.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s485910449", "user_id": "u269969976"}, "prompt_components": {"gold_output": "9\n", "input_to_evaluate": "\nfun main(args:Array) {\n val n = readLine()!!.toInt()\n val ans = (1..n).map { it.toString().length }.filter { it%2!=0 }.size\n println(ans)\n}", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 157, "cpu_time_ms": 292, "memory_kb": 38488}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s188197764", "group_id": "codeNet:p02952", "input_text": "import java.util.Scanner\nfun main(args:Array){\n val reader = Scanner(System.`in`);\n var N = reader.nextInt()\n var ans = 0\n for(i in 1..N)\n if((i.toString().length)%2==1)\n ++ans\n println(\"${ans}\")\n}", "language": "Kotlin", "metadata": {"date": 1565027162, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02952.html", "problem_id": "p02952", "resource_group": "medium_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/Kotlin/s188197764.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s188197764", "user_id": "u264304509"}, "prompt_components": {"gold_output": "9\n", "input_to_evaluate": "import java.util.Scanner\nfun main(args:Array){\n val reader = Scanner(System.`in`);\n var N = reader.nextInt()\n var ans = 0\n for(i in 1..N)\n if((i.toString().length)%2==1)\n ++ans\n println(\"${ans}\")\n}", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 218, "cpu_time_ms": 222, "memory_kb": 34184}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s216240496", "group_id": "codeNet:p02954", "input_text": "@file:Suppress(\"DuplicatedCode\")\n\nimport java.io.IOException\nimport java.io.InputStream\nimport java.io.PrintWriter\nimport java.util.NoSuchElementException\n\nfun main(args: Array) {\n PrintWriter(System.out).use { out ->\n D.solve(D.FastScanner(), out)\n out.flush()\n }\n}\n\nprivate fun D.solve(sc: D.FastScanner, out: PrintWriter) {\n val result = IntArray(100000)\n\n var flag = false\n var lastL = -1\n var lastR = 0\n var i = 0\n for (c in sc.toCharIterator()) {\n if (c == 'R') {\n if (flag) {\n flag = false\n lastL = i - 1\n val diff = i - lastR - 1\n result[lastR] += diff / 2\n result[lastR + 1] += (diff + 1) / 2\n }\n } else {\n if (!flag) {\n flag = true\n lastR = i - 1\n val diff = i - lastL - 1\n result[i - 1] += (diff + 1) / 2\n result[i] += diff / 2\n }\n }\n i++\n }\n\n run {\n val diff = i - 1 - lastR\n result[lastR] += diff / 2\n result[lastR + 1] += (diff + 1) / 2\n }\n\n buildString {\n append(result[0])\n for (i in 1 until i) {\n append(' ')\n append(result[i])\n }\n }.let {\n println(it)\n }\n}\n\n@Suppress(\"MemberVisibilityCanBePrivate\")\nprivate object D {\n private const val zeroCode = '0'.toInt()\n private const val nineCode = '9'.toInt()\n\n class FastScanner {\n private val `in`: InputStream = System.`in`\n private val buffer = ByteArray(2048)\n private var ptr = 0\n private var buflen = 0\n\n private fun hasNextByte(): Boolean {\n if (ptr < buflen) {\n return true\n } else {\n ptr = 0\n try {\n buflen = `in`.read(buffer)\n } catch (e: IOException) {\n e.printStackTrace()\n }\n if (buflen <= 0) {\n return false\n }\n }\n return true\n }\n\n private fun readByte(): Byte = if (hasNextByte()) buffer[ptr++] else -1\n\n private fun readByteAsInt(): Int = if (hasNextByte()) buffer[ptr++].toInt() else -1\n\n operator fun hasNext(): Boolean {\n while (hasNextByte() && !isPrintableChar(buffer[ptr].toInt())) ptr++\n return hasNextByte()\n }\n\n operator fun next(): String {\n if (!hasNext()) throw NoSuchElementException()\n\n return buildString {\n var b = readByteAsInt()\n\n while (isPrintableChar(b)) {\n appendCodePoint(b)\n b = readByteAsInt()\n }\n }\n }\n\n fun toCharIterator(): CharIterator = object: CharIterator() {\n private var nextByte: Byte = readByte()\n\n override fun hasNext(): Boolean = isPrintableChar(nextByte)\n\n override fun nextChar(): Char {\n val res = nextByte\n nextByte = readByte()\n return res.toChar()\n }\n\n }\n\n fun nextLong(): Long {\n if (!hasNext()) throw NoSuchElementException()\n var n: Long = 0\n var minus = false\n var b = readByteAsInt()\n\n if (b == '-'.toInt()) {\n minus = true\n b = readByteAsInt()\n }\n\n if (b !in zeroCode..nineCode) {\n throw NumberFormatException()\n }\n\n while (true) {\n if (b in zeroCode..nineCode) {\n n *= 10\n n += b - zeroCode.toLong()\n } else if (b == -1 || !isPrintableChar(b)) {\n return if (minus) -n else n\n } else {\n throw NumberFormatException()\n }\n\n b = readByteAsInt()\n }\n }\n\n fun nextInt(): Int {\n val nl = nextLong()\n if (nl < Int.MIN_VALUE || nl > Int.MAX_VALUE) throw NumberFormatException()\n return nl.toInt()\n }\n\n fun nextDouble(): Double {\n return next().toDouble()\n }\n\n fun readIntArray(n: Int): IntArray {\n val arr = IntArray(n)\n\n for (i in 0 until n) {\n arr[i] = nextInt()\n }\n\n return arr\n }\n\n fun readBigInt(capacity: Int): IntArray {\n if (!hasNext()) throw NoSuchElementException()\n\n val arr = IntArray(capacity)\n var len = 0\n arr[0] = readByteAsInt() - zeroCode\n while (arr[len] in 0..9) {\n len++\n arr[len] = readByteAsInt() - zeroCode\n }\n\n return arr.sliceArray(0 until len)\n }\n\n companion object {\n private inline fun isPrintableChar(c: Int): Boolean {\n return c in 33..126\n }\n\n private inline fun isPrintableChar(c: Byte): Boolean {\n return c in 33..126\n }\n }\n }\n}\n", "language": "Kotlin", "metadata": {"date": 1589666298, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02954.html", "problem_id": "p02954", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02954/input.txt", "sample_output_relpath": "derived/input_output/data/p02954/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02954/Kotlin/s216240496.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s216240496", "user_id": "u996672406"}, "prompt_components": {"gold_output": "0 1 2 1 1\n", "input_to_evaluate": "@file:Suppress(\"DuplicatedCode\")\n\nimport java.io.IOException\nimport java.io.InputStream\nimport java.io.PrintWriter\nimport java.util.NoSuchElementException\n\nfun main(args: Array) {\n PrintWriter(System.out).use { out ->\n D.solve(D.FastScanner(), out)\n out.flush()\n }\n}\n\nprivate fun D.solve(sc: D.FastScanner, out: PrintWriter) {\n val result = IntArray(100000)\n\n var flag = false\n var lastL = -1\n var lastR = 0\n var i = 0\n for (c in sc.toCharIterator()) {\n if (c == 'R') {\n if (flag) {\n flag = false\n lastL = i - 1\n val diff = i - lastR - 1\n result[lastR] += diff / 2\n result[lastR + 1] += (diff + 1) / 2\n }\n } else {\n if (!flag) {\n flag = true\n lastR = i - 1\n val diff = i - lastL - 1\n result[i - 1] += (diff + 1) / 2\n result[i] += diff / 2\n }\n }\n i++\n }\n\n run {\n val diff = i - 1 - lastR\n result[lastR] += diff / 2\n result[lastR + 1] += (diff + 1) / 2\n }\n\n buildString {\n append(result[0])\n for (i in 1 until i) {\n append(' ')\n append(result[i])\n }\n }.let {\n println(it)\n }\n}\n\n@Suppress(\"MemberVisibilityCanBePrivate\")\nprivate object D {\n private const val zeroCode = '0'.toInt()\n private const val nineCode = '9'.toInt()\n\n class FastScanner {\n private val `in`: InputStream = System.`in`\n private val buffer = ByteArray(2048)\n private var ptr = 0\n private var buflen = 0\n\n private fun hasNextByte(): Boolean {\n if (ptr < buflen) {\n return true\n } else {\n ptr = 0\n try {\n buflen = `in`.read(buffer)\n } catch (e: IOException) {\n e.printStackTrace()\n }\n if (buflen <= 0) {\n return false\n }\n }\n return true\n }\n\n private fun readByte(): Byte = if (hasNextByte()) buffer[ptr++] else -1\n\n private fun readByteAsInt(): Int = if (hasNextByte()) buffer[ptr++].toInt() else -1\n\n operator fun hasNext(): Boolean {\n while (hasNextByte() && !isPrintableChar(buffer[ptr].toInt())) ptr++\n return hasNextByte()\n }\n\n operator fun next(): String {\n if (!hasNext()) throw NoSuchElementException()\n\n return buildString {\n var b = readByteAsInt()\n\n while (isPrintableChar(b)) {\n appendCodePoint(b)\n b = readByteAsInt()\n }\n }\n }\n\n fun toCharIterator(): CharIterator = object: CharIterator() {\n private var nextByte: Byte = readByte()\n\n override fun hasNext(): Boolean = isPrintableChar(nextByte)\n\n override fun nextChar(): Char {\n val res = nextByte\n nextByte = readByte()\n return res.toChar()\n }\n\n }\n\n fun nextLong(): Long {\n if (!hasNext()) throw NoSuchElementException()\n var n: Long = 0\n var minus = false\n var b = readByteAsInt()\n\n if (b == '-'.toInt()) {\n minus = true\n b = readByteAsInt()\n }\n\n if (b !in zeroCode..nineCode) {\n throw NumberFormatException()\n }\n\n while (true) {\n if (b in zeroCode..nineCode) {\n n *= 10\n n += b - zeroCode.toLong()\n } else if (b == -1 || !isPrintableChar(b)) {\n return if (minus) -n else n\n } else {\n throw NumberFormatException()\n }\n\n b = readByteAsInt()\n }\n }\n\n fun nextInt(): Int {\n val nl = nextLong()\n if (nl < Int.MIN_VALUE || nl > Int.MAX_VALUE) throw NumberFormatException()\n return nl.toInt()\n }\n\n fun nextDouble(): Double {\n return next().toDouble()\n }\n\n fun readIntArray(n: Int): IntArray {\n val arr = IntArray(n)\n\n for (i in 0 until n) {\n arr[i] = nextInt()\n }\n\n return arr\n }\n\n fun readBigInt(capacity: Int): IntArray {\n if (!hasNext()) throw NoSuchElementException()\n\n val arr = IntArray(capacity)\n var len = 0\n arr[0] = readByteAsInt() - zeroCode\n while (arr[len] in 0..9) {\n len++\n arr[len] = readByteAsInt() - zeroCode\n }\n\n return arr.sliceArray(0 until len)\n }\n\n companion object {\n private inline fun isPrintableChar(c: Int): Boolean {\n return c in 33..126\n }\n\n private inline fun isPrintableChar(c: Byte): Boolean {\n return c in 33..126\n }\n }\n }\n}\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nGiven is a string S consisting of L and R.\n\nLet N be the length of S. There are N squares arranged from left to right, and the i-th character of S from the left is written on the i-th square from the left.\n\nThe character written on the leftmost square is always R, and the character written on the rightmost square is always L.\n\nInitially, one child is standing on each square.\n\nEach child will perform the move below 10^{100} times:\n\nMove one square in the direction specified by the character written in the square on which the child is standing. L denotes left, and R denotes right.\n\nFind the number of children standing on each square after the children performed the moves.\n\nConstraints\n\nS is a string of length between 2 and 10^5 (inclusive).\n\nEach character of S is L or R.\n\nThe first and last characters of S are R and L, respectively.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the number of children standing on each square after the children performed the moves, in order from left to right.\n\nSample Input 1\n\nRRLRL\n\nSample Output 1\n\n0 1 2 1 1\n\nAfter each child performed one move, the number of children standing on each square is 0, 2, 1, 1, 1 from left to right.\n\nAfter each child performed two moves, the number of children standing on each square is 0, 1, 2, 1, 1 from left to right.\n\nAfter each child performed 10^{100} moves, the number of children standing on each square is 0, 1, 2, 1, 1 from left to right.\n\nSample Input 2\n\nRRLLLLRLRRLL\n\nSample Output 2\n\n0 3 3 0 0 0 1 1 0 2 2 0\n\nSample Input 3\n\nRRRLLRLLRRRLLLLL\n\nSample Output 3\n\n0 0 3 2 0 2 1 0 0 0 4 4 0 0 0 0", "sample_input": "RRLRL\n"}, "reference_outputs": ["0 1 2 1 1\n"], "source_document_id": "p02954", "source_text": "Score : 400 points\n\nProblem Statement\n\nGiven is a string S consisting of L and R.\n\nLet N be the length of S. There are N squares arranged from left to right, and the i-th character of S from the left is written on the i-th square from the left.\n\nThe character written on the leftmost square is always R, and the character written on the rightmost square is always L.\n\nInitially, one child is standing on each square.\n\nEach child will perform the move below 10^{100} times:\n\nMove one square in the direction specified by the character written in the square on which the child is standing. L denotes left, and R denotes right.\n\nFind the number of children standing on each square after the children performed the moves.\n\nConstraints\n\nS is a string of length between 2 and 10^5 (inclusive).\n\nEach character of S is L or R.\n\nThe first and last characters of S are R and L, respectively.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the number of children standing on each square after the children performed the moves, in order from left to right.\n\nSample Input 1\n\nRRLRL\n\nSample Output 1\n\n0 1 2 1 1\n\nAfter each child performed one move, the number of children standing on each square is 0, 2, 1, 1, 1 from left to right.\n\nAfter each child performed two moves, the number of children standing on each square is 0, 1, 2, 1, 1 from left to right.\n\nAfter each child performed 10^{100} moves, the number of children standing on each square is 0, 1, 2, 1, 1 from left to right.\n\nSample Input 2\n\nRRLLLLRLRRLL\n\nSample Output 2\n\n0 3 3 0 0 0 1 1 0 2 2 0\n\nSample Input 3\n\nRRRLLRLLRRRLLLLL\n\nSample Output 3\n\n0 0 3 2 0 2 1 0 0 0 4 4 0 0 0 0", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 5157, "cpu_time_ms": 251, "memory_kb": 33776}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s363666530", "group_id": "codeNet:p02954", "input_text": "@file:Suppress(\"DuplicatedCode\")\n\nimport java.io.IOException\nimport java.io.InputStream\nimport java.io.PrintWriter\nimport java.util.NoSuchElementException\n\nfun main(args: Array) {\n PrintWriter(System.out).use { out ->\n D.solve(D.FastScanner(), out)\n out.flush()\n }\n}\n\nprivate fun D.solve(sc: D.FastScanner, out: PrintWriter) {\n val result = IntArray(100000)\n\n var flag = false\n var lastL = -1\n var lastR = 0\n for ((i, c) in sc.toCharIterator().withIndex()) {\n if (c == 'R') {\n if (flag) {\n flag = false\n val diff = i - lastR - 1\n result[lastR] += diff / 2\n result[lastR + 1] += (diff + 1) / 2\n }\n lastR = i\n } else {\n if (!flag) {\n flag = true\n val diff = i - lastL - 1\n result[i - 1] += (diff + 1) / 2\n result[i] += diff / 2\n }\n lastL = i\n }\n }\n\n run {\n val diff = lastL - lastR\n result[lastR] += diff / 2\n result[lastR + 1] += (diff + 1) / 2\n }\n\n out.print(result[0])\n for (i in 1..lastL) {\n out.print(' ')\n out.print(result[i])\n }\n out.println()\n}\n\n@Suppress(\"MemberVisibilityCanBePrivate\")\nprivate object D {\n private const val zeroCode = '0'.toInt()\n private const val nineCode = '9'.toInt()\n\n class FastScanner {\n private val `in`: InputStream = System.`in`\n private val buffer = ByteArray(1024)\n private var ptr = 0\n private var buflen = 0\n\n private fun hasNextByte(): Boolean {\n if (ptr < buflen) {\n return true\n } else {\n ptr = 0\n try {\n buflen = `in`.read(buffer)\n } catch (e: IOException) {\n e.printStackTrace()\n }\n if (buflen <= 0) {\n return false\n }\n }\n return true\n }\n\n private fun readByte(): Byte = if (hasNextByte()) buffer[ptr++] else -1\n\n private fun readByteAsInt(): Int = if (hasNextByte()) buffer[ptr++].toInt() else -1\n\n operator fun hasNext(): Boolean {\n while (hasNextByte() && !isPrintableChar(buffer[ptr].toInt())) ptr++\n return hasNextByte()\n }\n\n operator fun next(): String {\n if (!hasNext()) throw NoSuchElementException()\n\n return buildString {\n var b = readByteAsInt()\n\n while (isPrintableChar(b)) {\n appendCodePoint(b)\n b = readByteAsInt()\n }\n }\n }\n\n fun toCharIterator(): CharIterator = object: CharIterator() {\n private var nextByte: Byte = readByte()\n\n override fun hasNext(): Boolean = isPrintableChar(nextByte)\n\n override fun nextChar(): Char {\n val res = nextByte\n nextByte = readByte()\n return res.toChar()\n }\n\n }\n\n fun nextLong(): Long {\n if (!hasNext()) throw NoSuchElementException()\n var n: Long = 0\n var minus = false\n var b = readByteAsInt()\n\n if (b == '-'.toInt()) {\n minus = true\n b = readByteAsInt()\n }\n\n if (b !in zeroCode..nineCode) {\n throw NumberFormatException()\n }\n\n while (true) {\n if (b in zeroCode..nineCode) {\n n *= 10\n n += b - zeroCode.toLong()\n } else if (b == -1 || !isPrintableChar(b)) {\n return if (minus) -n else n\n } else {\n throw NumberFormatException()\n }\n\n b = readByteAsInt()\n }\n }\n\n fun nextInt(): Int {\n val nl = nextLong()\n if (nl < Int.MIN_VALUE || nl > Int.MAX_VALUE) throw NumberFormatException()\n return nl.toInt()\n }\n\n fun nextDouble(): Double {\n return next().toDouble()\n }\n\n fun readIntArray(n: Int): IntArray {\n val arr = IntArray(n)\n\n for (i in 0 until n) {\n arr[i] = nextInt()\n }\n\n return arr\n }\n\n fun readBigInt(capacity: Int): IntArray {\n if (!hasNext()) throw NoSuchElementException()\n\n val arr = IntArray(capacity)\n var len = 0\n arr[0] = readByteAsInt() - zeroCode\n while (arr[len] in 0..9) {\n len++\n arr[len] = readByteAsInt() - zeroCode\n }\n\n return arr.sliceArray(0 until len)\n }\n\n companion object {\n private fun isPrintableChar(c: Int): Boolean {\n return c in 33..126\n }\n\n private fun isPrintableChar(c: Byte): Boolean {\n return c in 33..126\n }\n }\n }\n}\n", "language": "Kotlin", "metadata": {"date": 1589665147, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02954.html", "problem_id": "p02954", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02954/input.txt", "sample_output_relpath": "derived/input_output/data/p02954/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02954/Kotlin/s363666530.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s363666530", "user_id": "u996672406"}, "prompt_components": {"gold_output": "0 1 2 1 1\n", "input_to_evaluate": "@file:Suppress(\"DuplicatedCode\")\n\nimport java.io.IOException\nimport java.io.InputStream\nimport java.io.PrintWriter\nimport java.util.NoSuchElementException\n\nfun main(args: Array) {\n PrintWriter(System.out).use { out ->\n D.solve(D.FastScanner(), out)\n out.flush()\n }\n}\n\nprivate fun D.solve(sc: D.FastScanner, out: PrintWriter) {\n val result = IntArray(100000)\n\n var flag = false\n var lastL = -1\n var lastR = 0\n for ((i, c) in sc.toCharIterator().withIndex()) {\n if (c == 'R') {\n if (flag) {\n flag = false\n val diff = i - lastR - 1\n result[lastR] += diff / 2\n result[lastR + 1] += (diff + 1) / 2\n }\n lastR = i\n } else {\n if (!flag) {\n flag = true\n val diff = i - lastL - 1\n result[i - 1] += (diff + 1) / 2\n result[i] += diff / 2\n }\n lastL = i\n }\n }\n\n run {\n val diff = lastL - lastR\n result[lastR] += diff / 2\n result[lastR + 1] += (diff + 1) / 2\n }\n\n out.print(result[0])\n for (i in 1..lastL) {\n out.print(' ')\n out.print(result[i])\n }\n out.println()\n}\n\n@Suppress(\"MemberVisibilityCanBePrivate\")\nprivate object D {\n private const val zeroCode = '0'.toInt()\n private const val nineCode = '9'.toInt()\n\n class FastScanner {\n private val `in`: InputStream = System.`in`\n private val buffer = ByteArray(1024)\n private var ptr = 0\n private var buflen = 0\n\n private fun hasNextByte(): Boolean {\n if (ptr < buflen) {\n return true\n } else {\n ptr = 0\n try {\n buflen = `in`.read(buffer)\n } catch (e: IOException) {\n e.printStackTrace()\n }\n if (buflen <= 0) {\n return false\n }\n }\n return true\n }\n\n private fun readByte(): Byte = if (hasNextByte()) buffer[ptr++] else -1\n\n private fun readByteAsInt(): Int = if (hasNextByte()) buffer[ptr++].toInt() else -1\n\n operator fun hasNext(): Boolean {\n while (hasNextByte() && !isPrintableChar(buffer[ptr].toInt())) ptr++\n return hasNextByte()\n }\n\n operator fun next(): String {\n if (!hasNext()) throw NoSuchElementException()\n\n return buildString {\n var b = readByteAsInt()\n\n while (isPrintableChar(b)) {\n appendCodePoint(b)\n b = readByteAsInt()\n }\n }\n }\n\n fun toCharIterator(): CharIterator = object: CharIterator() {\n private var nextByte: Byte = readByte()\n\n override fun hasNext(): Boolean = isPrintableChar(nextByte)\n\n override fun nextChar(): Char {\n val res = nextByte\n nextByte = readByte()\n return res.toChar()\n }\n\n }\n\n fun nextLong(): Long {\n if (!hasNext()) throw NoSuchElementException()\n var n: Long = 0\n var minus = false\n var b = readByteAsInt()\n\n if (b == '-'.toInt()) {\n minus = true\n b = readByteAsInt()\n }\n\n if (b !in zeroCode..nineCode) {\n throw NumberFormatException()\n }\n\n while (true) {\n if (b in zeroCode..nineCode) {\n n *= 10\n n += b - zeroCode.toLong()\n } else if (b == -1 || !isPrintableChar(b)) {\n return if (minus) -n else n\n } else {\n throw NumberFormatException()\n }\n\n b = readByteAsInt()\n }\n }\n\n fun nextInt(): Int {\n val nl = nextLong()\n if (nl < Int.MIN_VALUE || nl > Int.MAX_VALUE) throw NumberFormatException()\n return nl.toInt()\n }\n\n fun nextDouble(): Double {\n return next().toDouble()\n }\n\n fun readIntArray(n: Int): IntArray {\n val arr = IntArray(n)\n\n for (i in 0 until n) {\n arr[i] = nextInt()\n }\n\n return arr\n }\n\n fun readBigInt(capacity: Int): IntArray {\n if (!hasNext()) throw NoSuchElementException()\n\n val arr = IntArray(capacity)\n var len = 0\n arr[0] = readByteAsInt() - zeroCode\n while (arr[len] in 0..9) {\n len++\n arr[len] = readByteAsInt() - zeroCode\n }\n\n return arr.sliceArray(0 until len)\n }\n\n companion object {\n private fun isPrintableChar(c: Int): Boolean {\n return c in 33..126\n }\n\n private fun isPrintableChar(c: Byte): Boolean {\n return c in 33..126\n }\n }\n }\n}\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nGiven is a string S consisting of L and R.\n\nLet N be the length of S. There are N squares arranged from left to right, and the i-th character of S from the left is written on the i-th square from the left.\n\nThe character written on the leftmost square is always R, and the character written on the rightmost square is always L.\n\nInitially, one child is standing on each square.\n\nEach child will perform the move below 10^{100} times:\n\nMove one square in the direction specified by the character written in the square on which the child is standing. L denotes left, and R denotes right.\n\nFind the number of children standing on each square after the children performed the moves.\n\nConstraints\n\nS is a string of length between 2 and 10^5 (inclusive).\n\nEach character of S is L or R.\n\nThe first and last characters of S are R and L, respectively.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the number of children standing on each square after the children performed the moves, in order from left to right.\n\nSample Input 1\n\nRRLRL\n\nSample Output 1\n\n0 1 2 1 1\n\nAfter each child performed one move, the number of children standing on each square is 0, 2, 1, 1, 1 from left to right.\n\nAfter each child performed two moves, the number of children standing on each square is 0, 1, 2, 1, 1 from left to right.\n\nAfter each child performed 10^{100} moves, the number of children standing on each square is 0, 1, 2, 1, 1 from left to right.\n\nSample Input 2\n\nRRLLLLRLRRLL\n\nSample Output 2\n\n0 3 3 0 0 0 1 1 0 2 2 0\n\nSample Input 3\n\nRRRLLRLLRRRLLLLL\n\nSample Output 3\n\n0 0 3 2 0 2 1 0 0 0 4 4 0 0 0 0", "sample_input": "RRLRL\n"}, "reference_outputs": ["0 1 2 1 1\n"], "source_document_id": "p02954", "source_text": "Score : 400 points\n\nProblem Statement\n\nGiven is a string S consisting of L and R.\n\nLet N be the length of S. There are N squares arranged from left to right, and the i-th character of S from the left is written on the i-th square from the left.\n\nThe character written on the leftmost square is always R, and the character written on the rightmost square is always L.\n\nInitially, one child is standing on each square.\n\nEach child will perform the move below 10^{100} times:\n\nMove one square in the direction specified by the character written in the square on which the child is standing. L denotes left, and R denotes right.\n\nFind the number of children standing on each square after the children performed the moves.\n\nConstraints\n\nS is a string of length between 2 and 10^5 (inclusive).\n\nEach character of S is L or R.\n\nThe first and last characters of S are R and L, respectively.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the number of children standing on each square after the children performed the moves, in order from left to right.\n\nSample Input 1\n\nRRLRL\n\nSample Output 1\n\n0 1 2 1 1\n\nAfter each child performed one move, the number of children standing on each square is 0, 2, 1, 1, 1 from left to right.\n\nAfter each child performed two moves, the number of children standing on each square is 0, 1, 2, 1, 1 from left to right.\n\nAfter each child performed 10^{100} moves, the number of children standing on each square is 0, 1, 2, 1, 1 from left to right.\n\nSample Input 2\n\nRRLLLLRLRRLL\n\nSample Output 2\n\n0 3 3 0 0 0 1 1 0 2 2 0\n\nSample Input 3\n\nRRRLLRLLRRRLLLLL\n\nSample Output 3\n\n0 0 3 2 0 2 1 0 0 0 4 4 0 0 0 0", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 5068, "cpu_time_ms": 324, "memory_kb": 36748}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s895874807", "group_id": "codeNet:p02954", "input_text": "fun main(args: Array) {\n val cList = readLine()!!.toList()\n val n = cList.size\n val rMap = mutableMapOf()\n val lMap = mutableMapOf()\n for (i in 1 until n) {\n val c = cList[i]\n if (c == 'L') {\n val lNum = lMap[i - 1]\n if (lNum == null) {\n lMap[i] = 1\n } else {\n lMap[i] = lNum + 1\n }\n }\n }\n for (i in n - 2 downTo 0) {\n val c = cList[i]\n if (c == 'R') {\n val rNum = rMap[i + 1]\n if (rNum == null) {\n rMap[i] = 1\n } else {\n rMap[i] = rNum + 1\n }\n }\n }\n val ansList = (1..n).map { 0 }.toMutableList()\n for (i in 0 until n) {\n val c = cList[i]\n if (c == 'R') {\n val r = rMap[i]!!\n if (r % 2 == 0) {\n ansList[i + r]++\n } else {\n ansList[i + r - 1]++\n }\n } else {\n val l = lMap[i]!!\n if (l % 2 == 0) {\n ansList[i - l]++\n } else {\n ansList[i - l + 1]++\n }\n }\n }\n println(ansList.joinToString(separator = \" \"))\n}\n\n", "language": "Kotlin", "metadata": {"date": 1564971494, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02954.html", "problem_id": "p02954", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02954/input.txt", "sample_output_relpath": "derived/input_output/data/p02954/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02954/Kotlin/s895874807.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s895874807", "user_id": "u979004569"}, "prompt_components": {"gold_output": "0 1 2 1 1\n", "input_to_evaluate": "fun main(args: Array) {\n val cList = readLine()!!.toList()\n val n = cList.size\n val rMap = mutableMapOf()\n val lMap = mutableMapOf()\n for (i in 1 until n) {\n val c = cList[i]\n if (c == 'L') {\n val lNum = lMap[i - 1]\n if (lNum == null) {\n lMap[i] = 1\n } else {\n lMap[i] = lNum + 1\n }\n }\n }\n for (i in n - 2 downTo 0) {\n val c = cList[i]\n if (c == 'R') {\n val rNum = rMap[i + 1]\n if (rNum == null) {\n rMap[i] = 1\n } else {\n rMap[i] = rNum + 1\n }\n }\n }\n val ansList = (1..n).map { 0 }.toMutableList()\n for (i in 0 until n) {\n val c = cList[i]\n if (c == 'R') {\n val r = rMap[i]!!\n if (r % 2 == 0) {\n ansList[i + r]++\n } else {\n ansList[i + r - 1]++\n }\n } else {\n val l = lMap[i]!!\n if (l % 2 == 0) {\n ansList[i - l]++\n } else {\n ansList[i - l + 1]++\n }\n }\n }\n println(ansList.joinToString(separator = \" \"))\n}\n\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nGiven is a string S consisting of L and R.\n\nLet N be the length of S. There are N squares arranged from left to right, and the i-th character of S from the left is written on the i-th square from the left.\n\nThe character written on the leftmost square is always R, and the character written on the rightmost square is always L.\n\nInitially, one child is standing on each square.\n\nEach child will perform the move below 10^{100} times:\n\nMove one square in the direction specified by the character written in the square on which the child is standing. L denotes left, and R denotes right.\n\nFind the number of children standing on each square after the children performed the moves.\n\nConstraints\n\nS is a string of length between 2 and 10^5 (inclusive).\n\nEach character of S is L or R.\n\nThe first and last characters of S are R and L, respectively.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the number of children standing on each square after the children performed the moves, in order from left to right.\n\nSample Input 1\n\nRRLRL\n\nSample Output 1\n\n0 1 2 1 1\n\nAfter each child performed one move, the number of children standing on each square is 0, 2, 1, 1, 1 from left to right.\n\nAfter each child performed two moves, the number of children standing on each square is 0, 1, 2, 1, 1 from left to right.\n\nAfter each child performed 10^{100} moves, the number of children standing on each square is 0, 1, 2, 1, 1 from left to right.\n\nSample Input 2\n\nRRLLLLRLRRLL\n\nSample Output 2\n\n0 3 3 0 0 0 1 1 0 2 2 0\n\nSample Input 3\n\nRRRLLRLLRRRLLLLL\n\nSample Output 3\n\n0 0 3 2 0 2 1 0 0 0 4 4 0 0 0 0", "sample_input": "RRLRL\n"}, "reference_outputs": ["0 1 2 1 1\n"], "source_document_id": "p02954", "source_text": "Score : 400 points\n\nProblem Statement\n\nGiven is a string S consisting of L and R.\n\nLet N be the length of S. There are N squares arranged from left to right, and the i-th character of S from the left is written on the i-th square from the left.\n\nThe character written on the leftmost square is always R, and the character written on the rightmost square is always L.\n\nInitially, one child is standing on each square.\n\nEach child will perform the move below 10^{100} times:\n\nMove one square in the direction specified by the character written in the square on which the child is standing. L denotes left, and R denotes right.\n\nFind the number of children standing on each square after the children performed the moves.\n\nConstraints\n\nS is a string of length between 2 and 10^5 (inclusive).\n\nEach character of S is L or R.\n\nThe first and last characters of S are R and L, respectively.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the number of children standing on each square after the children performed the moves, in order from left to right.\n\nSample Input 1\n\nRRLRL\n\nSample Output 1\n\n0 1 2 1 1\n\nAfter each child performed one move, the number of children standing on each square is 0, 2, 1, 1, 1 from left to right.\n\nAfter each child performed two moves, the number of children standing on each square is 0, 1, 2, 1, 1 from left to right.\n\nAfter each child performed 10^{100} moves, the number of children standing on each square is 0, 1, 2, 1, 1 from left to right.\n\nSample Input 2\n\nRRLLLLRLRRLL\n\nSample Output 2\n\n0 3 3 0 0 0 1 1 0 2 2 0\n\nSample Input 3\n\nRRRLLRLLRRRLLLLL\n\nSample Output 3\n\n0 0 3 2 0 2 1 0 0 0 4 4 0 0 0 0", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1012, "cpu_time_ms": 568, "memory_kb": 52716}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s000957295", "group_id": "codeNet:p02955", "input_text": "import java.io.*\nimport java.util.*\n\nval pw = PrintWriter(System.out)\nconst val MOD = 1000000007L\nconst val INF = 2147483647\nconst val LINF = 9223372036854775807L\n\nfun main(args: Array) {\n solve()\n pw.flush()\n}\n\nfun solve() {\n val tmp = nextIntList()\n val k = tmp[1]\n val a = nextIntList()\n val s = a.sum()\n val div: MutableList = mutableListOf()\n for (i in 1..s) {\n if(i * i > s) break\n if(s % i == 0){\n div.add(i)\n div.add(s / i)\n }\n }\n\n var ans = 1\n for (d in div){\n val sp: MutableList = mutableListOf()\n for (i in a){\n sp.add(i % d)\n }\n sp.sortDescending()\n if(sp.sum() / 2 <= k){\n ans = max(ans, d)\n }\n }\n\n println(ans)\n\n}\n\n\nfun println(v: String) {\n pw.println(v)\n}\n\nfun print(v: String) {\n pw.print(v)\n}\n\nfun next() = readLine()!!\nfun nextInt() = next().toInt()\nfun nextLong() = next().toLong()\nfun nextDouble() = next().toDouble()\nfun nextList() = next().split(\" \").toMutableList()\nfun nextIntList(index: Int = 0) = next().split(\" \").map { it.toInt() + index }.toMutableList()\nfun nextLongList(index: Long = 0L) = next().split(\" \").map { it.toLong() + index }.toMutableList()\nfun nextDoubleList() = next().split(\" \").map { it.toDouble() }.toMutableList()\n\nfun ary(n: Int, init: String = \"\") = Array(n) { init }\nfun intAry(n: Int, init: Int = 0) = IntArray(n) { init }\nfun longAry(n: Int, init: Long = 0L) = LongArray(n) { init }\nfun doubleAry(n: Int, init: Double = 0.0) = DoubleArray(n) { init }\nfun ary2(n: Int, m: Int, init: String = \"\") = Array(n) { Array(m) { init } }\nfun intAry2(n: Int, m: Int, init: Int = 0) = Array(n) { IntArray(m) { init } }\nfun longAry2(n: Int, m: Int, init: Long = 0) = Array(n) { LongArray(m) { init } }\nfun doubleAry2(n: Int, m: Int, init: Double = 0.0) = Array(n) { DoubleArray(m) { init } }\nfun ary3(n: Int, m: Int, k: Int, init: String = \"\") = Array(n) { Array(m) { Array(k) { init } } }\nfun intAry3(n: Int, m: Int, k: Int, init: Int = 0) = Array(n) { Array(m) { IntArray(k) { init } } }\nfun longAry3(n: Int, m: Int, k: Int, init: Long = 0L) = Array(n) { Array(m) { LongArray(k) { init } } }\nfun doubleAry3(n: Int, m: Int, k: Int, init: Double = 0.0) = Array(n) { Array(m) { DoubleArray(k) { init } } }\n\nfun abs(n: Int): Int = Math.abs(n)\nfun abs(n: Long): Long = Math.abs(n)\nfun abs(n: Double): Double = Math.abs(n)\nfun max(a: Int = -INF, b: Int = -INF, c: Int = -INF, d: Int = -INF, e: Int = -INF): Int = listOf(a, b, c, d, e).max()!!\nfun max(a: Long = -LINF, b: Long = -LINF, c: Long = -LINF, d: Long = -LINF, e: Long = -LINF): Long =\n listOf(a, b, c, d, e).max()!!.toLong()\n\nfun min(a: Int = INF, b: Int = INF, c: Int = INF, d: Int = INF, e: Int = INF): Int = listOf(a, b, c, d, e).min()!!\nfun min(a: Long = LINF, b: Long = LINF, c: Long = LINF, d: Long = LINF, e: Long = LINF): Long =\n listOf(a, b, c, d, e).min()!!.toLong()\n", "language": "Kotlin", "metadata": {"date": 1585955759, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02955.html", "problem_id": "p02955", "resource_group": "medium_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/Kotlin/s000957295.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s000957295", "user_id": "u581625805"}, "prompt_components": {"gold_output": "7\n", "input_to_evaluate": "import java.io.*\nimport java.util.*\n\nval pw = PrintWriter(System.out)\nconst val MOD = 1000000007L\nconst val INF = 2147483647\nconst val LINF = 9223372036854775807L\n\nfun main(args: Array) {\n solve()\n pw.flush()\n}\n\nfun solve() {\n val tmp = nextIntList()\n val k = tmp[1]\n val a = nextIntList()\n val s = a.sum()\n val div: MutableList = mutableListOf()\n for (i in 1..s) {\n if(i * i > s) break\n if(s % i == 0){\n div.add(i)\n div.add(s / i)\n }\n }\n\n var ans = 1\n for (d in div){\n val sp: MutableList = mutableListOf()\n for (i in a){\n sp.add(i % d)\n }\n sp.sortDescending()\n if(sp.sum() / 2 <= k){\n ans = max(ans, d)\n }\n }\n\n println(ans)\n\n}\n\n\nfun println(v: String) {\n pw.println(v)\n}\n\nfun print(v: String) {\n pw.print(v)\n}\n\nfun next() = readLine()!!\nfun nextInt() = next().toInt()\nfun nextLong() = next().toLong()\nfun nextDouble() = next().toDouble()\nfun nextList() = next().split(\" \").toMutableList()\nfun nextIntList(index: Int = 0) = next().split(\" \").map { it.toInt() + index }.toMutableList()\nfun nextLongList(index: Long = 0L) = next().split(\" \").map { it.toLong() + index }.toMutableList()\nfun nextDoubleList() = next().split(\" \").map { it.toDouble() }.toMutableList()\n\nfun ary(n: Int, init: String = \"\") = Array(n) { init }\nfun intAry(n: Int, init: Int = 0) = IntArray(n) { init }\nfun longAry(n: Int, init: Long = 0L) = LongArray(n) { init }\nfun doubleAry(n: Int, init: Double = 0.0) = DoubleArray(n) { init }\nfun ary2(n: Int, m: Int, init: String = \"\") = Array(n) { Array(m) { init } }\nfun intAry2(n: Int, m: Int, init: Int = 0) = Array(n) { IntArray(m) { init } }\nfun longAry2(n: Int, m: Int, init: Long = 0) = Array(n) { LongArray(m) { init } }\nfun doubleAry2(n: Int, m: Int, init: Double = 0.0) = Array(n) { DoubleArray(m) { init } }\nfun ary3(n: Int, m: Int, k: Int, init: String = \"\") = Array(n) { Array(m) { Array(k) { init } } }\nfun intAry3(n: Int, m: Int, k: Int, init: Int = 0) = Array(n) { Array(m) { IntArray(k) { init } } }\nfun longAry3(n: Int, m: Int, k: Int, init: Long = 0L) = Array(n) { Array(m) { LongArray(k) { init } } }\nfun doubleAry3(n: Int, m: Int, k: Int, init: Double = 0.0) = Array(n) { Array(m) { DoubleArray(k) { init } } }\n\nfun abs(n: Int): Int = Math.abs(n)\nfun abs(n: Long): Long = Math.abs(n)\nfun abs(n: Double): Double = Math.abs(n)\nfun max(a: Int = -INF, b: Int = -INF, c: Int = -INF, d: Int = -INF, e: Int = -INF): Int = listOf(a, b, c, d, e).max()!!\nfun max(a: Long = -LINF, b: Long = -LINF, c: Long = -LINF, d: Long = -LINF, e: Long = -LINF): Long =\n listOf(a, b, c, d, e).max()!!.toLong()\n\nfun min(a: Int = INF, b: Int = INF, c: Int = INF, d: Int = INF, e: Int = INF): Int = listOf(a, b, c, d, e).min()!!\nfun min(a: Long = LINF, b: Long = LINF, c: Long = LINF, d: Long = LINF, e: Long = LINF): Long =\n listOf(a, b, c, d, e).min()!!.toLong()\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2951, "cpu_time_ms": 565, "memory_kb": 45556}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s202021441", "group_id": "codeNet:p02955", "input_text": "fun main(args: Array) {\n fun divisor(n: Long): List {\n val list = mutableListOf()\n var i = 1L\n while (i * i <= n) {\n if (n % i == 0L) {\n list.add(i)\n if (i != n / i) {\n list.add(n / i)\n }\n }\n i++\n }\n return list.sortedDescending()\n }\n\n val (n, k) = readLine()!!.split(' ').map(String::toLong)\n val aList = readLine()!!.split(' ').map(String::toLong)\n val divList = divisor(aList.sum())\n\n for (div in divList) {\n var moveCountM = 0L\n var moveCountP = 0L\n for (i in 0 until n.toInt()) {\n val a = aList[i]\n val move = a % div\n if (div / 2 > move) {\n moveCountM += move\n if (moveCountM > k) {\n moveCountM -= move\n moveCountP += div - move\n }\n } else {\n moveCountP += div - move\n if (moveCountP > k) {\n moveCountP -= div - move\n moveCountM += move\n }\n }\n if (moveCountM > k || moveCountP > k) {\n break\n }\n }\n if (moveCountM > k || moveCountP > k) {\n continue\n } else {\n println(div)\n return\n }\n }\n println(1)\n}", "language": "Kotlin", "metadata": {"date": 1564971293, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02955.html", "problem_id": "p02955", "resource_group": "medium_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/Kotlin/s202021441.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s202021441", "user_id": "u099066216"}, "prompt_components": {"gold_output": "7\n", "input_to_evaluate": "fun main(args: Array) {\n fun divisor(n: Long): List {\n val list = mutableListOf()\n var i = 1L\n while (i * i <= n) {\n if (n % i == 0L) {\n list.add(i)\n if (i != n / i) {\n list.add(n / i)\n }\n }\n i++\n }\n return list.sortedDescending()\n }\n\n val (n, k) = readLine()!!.split(' ').map(String::toLong)\n val aList = readLine()!!.split(' ').map(String::toLong)\n val divList = divisor(aList.sum())\n\n for (div in divList) {\n var moveCountM = 0L\n var moveCountP = 0L\n for (i in 0 until n.toInt()) {\n val a = aList[i]\n val move = a % div\n if (div / 2 > move) {\n moveCountM += move\n if (moveCountM > k) {\n moveCountM -= move\n moveCountP += div - move\n }\n } else {\n moveCountP += div - move\n if (moveCountP > k) {\n moveCountP -= div - move\n moveCountM += move\n }\n }\n if (moveCountM > k || moveCountP > k) {\n break\n }\n }\n if (moveCountM > k || moveCountP > k) {\n continue\n } else {\n println(div)\n return\n }\n }\n println(1)\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1421, "cpu_time_ms": 263, "memory_kb": 38444}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s842385040", "group_id": "codeNet:p02957", "input_text": "fun main(arr:Array) {\n val (a,b) = readLine()!!.split(\" \").map { it.toLong() }.sortedByDescending { it }\n if((a+b)%2L == 0L) {\n println((a+b)/2)\n } else{\n println(\"IMPOSSIBLE\")\n }\n\n}\n", "language": "Kotlin", "metadata": {"date": 1566859602, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02957.html", "problem_id": "p02957", "resource_group": "medium_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/Kotlin/s842385040.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s842385040", "user_id": "u269969976"}, "prompt_components": {"gold_output": "9\n", "input_to_evaluate": "fun main(arr:Array) {\n val (a,b) = readLine()!!.split(\" \").map { it.toLong() }.sortedByDescending { it }\n if((a+b)%2L == 0L) {\n println((a+b)/2)\n } else{\n println(\"IMPOSSIBLE\")\n }\n\n}\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 217, "cpu_time_ms": 237, "memory_kb": 38048}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s346642081", "group_id": "codeNet:p02957", "input_text": "fun main(argas: Array) {\n val n = readLine()!!.toInt()\n val values = readLine()!!.split(\" \").map(String::toInt)\n\n var pairs = mutableListOf>();\n\n for (i in 0 until n-1) {\n if (values[i] > values[i+1]) {\n pairs.add(Pair(i, values[i]))\n break\n }\n }\n\n for (j in n-1 downTo 1) {\n if (values[j] < values[j-1]) {\n pairs.add(Pair(j, values[j]))\n break\n }\n }\n\n if (pairs.size != 2) {\n println(\"YES\")\n return\n }\n\n var a = pairs.first()\n var b = pairs.last()\n\n if (a.second >= values[b.first-1] && b.second <= values[a.first+1]) {\n println(\"YES\")\n } else {\n println(\"NO\")\n }\n}", "language": "Kotlin", "metadata": {"date": 1564880587, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02957.html", "problem_id": "p02957", "resource_group": "medium_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/Kotlin/s346642081.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s346642081", "user_id": "u004938108"}, "prompt_components": {"gold_output": "9\n", "input_to_evaluate": "fun main(argas: Array) {\n val n = readLine()!!.toInt()\n val values = readLine()!!.split(\" \").map(String::toInt)\n\n var pairs = mutableListOf>();\n\n for (i in 0 until n-1) {\n if (values[i] > values[i+1]) {\n pairs.add(Pair(i, values[i]))\n break\n }\n }\n\n for (j in n-1 downTo 1) {\n if (values[j] < values[j-1]) {\n pairs.add(Pair(j, values[j]))\n break\n }\n }\n\n if (pairs.size != 2) {\n println(\"YES\")\n return\n }\n\n var a = pairs.first()\n var b = pairs.last()\n\n if (a.second >= values[b.first-1] && b.second <= values[a.first+1]) {\n println(\"YES\")\n } else {\n println(\"NO\")\n }\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 731, "cpu_time_ms": 215, "memory_kb": 31620}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s826973672", "group_id": "codeNet:p02957", "input_text": "import java.util.*\n\nfun main(vararg args: String) {\n val scanner = Scanner(System.`in`)\n val a = scanner.nextInt()\n val b = scanner.nextInt()\n val diff = Math.abs(a - b)\n if (diff % 2 == 1) {\n println(\"IMPOSSIBLE\")\n return\n }\n val k = Math.min(a, b) + diff / 2\n println(k)\n}\n", "language": "Kotlin", "metadata": {"date": 1564872299, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02957.html", "problem_id": "p02957", "resource_group": "medium_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/Kotlin/s826973672.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s826973672", "user_id": "u329692035"}, "prompt_components": {"gold_output": "9\n", "input_to_evaluate": "import java.util.*\n\nfun main(vararg args: String) {\n val scanner = Scanner(System.`in`)\n val a = scanner.nextInt()\n val b = scanner.nextInt()\n val diff = Math.abs(a - b)\n if (diff % 2 == 1) {\n println(\"IMPOSSIBLE\")\n return\n }\n val k = Math.min(a, b) + diff / 2\n println(k)\n}\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 313, "cpu_time_ms": 185, "memory_kb": 31276}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s221707988", "group_id": "codeNet:p02957", "input_text": "fun main(args: Array) {\n val (a, b) = readLine()!!.split(\" \").map { it.toInt() }\n\n if((a + b) % 2 == 0){\n println((a + b) / 2)\n }else {\n println(\"IMPOSSIBLE\")\n }\n}", "language": "Kotlin", "metadata": {"date": 1564276065, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02957.html", "problem_id": "p02957", "resource_group": "medium_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/Kotlin/s221707988.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s221707988", "user_id": "u108272327"}, "prompt_components": {"gold_output": "9\n", "input_to_evaluate": "fun main(args: Array) {\n val (a, b) = readLine()!!.split(\" \").map { it.toInt() }\n\n if((a + b) % 2 == 0){\n println((a + b) / 2)\n }else {\n println(\"IMPOSSIBLE\")\n }\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 237, "memory_kb": 35948}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s947999877", "group_id": "codeNet:p02957", "input_text": "import java.util.*\n \nfun main(args: Array) {\n \n var line = readLine()!!.split(\" \")!!\n var a = line[0].toInt()!!\n var b = line[1].toInt()!!\n\n if ((a+b)%2 == 0){\n println((a+b)/2)\n }else {\n println(\"IMPOSSIBLE\")\n }\n \n}", "language": "Kotlin", "metadata": {"date": 1564275924, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02957.html", "problem_id": "p02957", "resource_group": "medium_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/Kotlin/s947999877.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s947999877", "user_id": "u394420840"}, "prompt_components": {"gold_output": "9\n", "input_to_evaluate": "import java.util.*\n \nfun main(args: Array) {\n \n var line = readLine()!!.split(\" \")!!\n var a = line[0].toInt()!!\n var b = line[1].toInt()!!\n\n if ((a+b)%2 == 0){\n println((a+b)/2)\n }else {\n println(\"IMPOSSIBLE\")\n }\n \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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 238, "memory_kb": 37736}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s405825157", "group_id": "codeNet:p02957", "input_text": "import java.io.PrintWriter\nimport java.util.*\nimport java.math.*\nimport java.lang.*\n\nval pw = PrintWriter(System.out)\nval MOD: Long = (1e+9 + 7).toLong()\n\nfun main(args: Array) {\n val (a, b) = readListOfInt() \n val ans = Math.abs(b-a) / 2 + Math.min(a, b)\n println(if(Math.abs(b-a) % 2 == 0) ans else \"IMPOSSIBLE\")\n pw.flush()\n}\n\n/****** Decrared Functions and Data Structures ******/\n// IO\nfun read() = readLine()!!\nfun readInt() = read().toInt()\nfun readLong() = read().toLong()\nfun readDouble() = read().toDouble()\nfun readListOfString() = read().split(\" \")\nfun readListOfInt() = readListOfString().map { it.toInt() }\nfun readListOfLong() = readListOfString().map { it.toLong() }\nfun readListOfDouble() = readListOfString().map { it.toDouble() }\n\nfun Double.format(digits: Int) = String.format(\"%.${digits}f\", this)\nfun Float.format(digits: Int) = String.format(\"%.${digits}f\", this)\n\nfun print(value: Any) { pw.print(value) }\nfun println(value : Any) { pw.println(value) }\n\nfun permutations(src: List): List> {\n if(src.size == 1) return listOf(src)\n val perms = mutableListOf>()\n val insertElement = src[0]\n permutations(src.drop(1)).forEach { perm ->\n for(i in 0..perm.size) {\n val newPerm = perm.toMutableList()\n newPerm.add(i, insertElement)\n perms.add(newPerm.toList())\n }\n }\n return perms\n}\n\n// return nCr, if you want nCr, please access v[n][r]\nfun combinations(n: Long): List> {\n val v = (0..n).map { (0..n).map{0L}.toMutableList() }.toMutableList()\n for(i in 0 until v.size) {\n v[i][0] = 1L\n v[i][i] = 1L\n }\n for(i in 0 until v.size) {\n for(j in 1 until i) {\n v[i][j] = (v[i-1][j-1] + v[i-1][j] % MOD)\n }\n }\n return v.map { it.toList() }.toList()\n}\n\nfun gcd(a: Long, b: Long): Long = \n if(b != 0L) a else gcd(b, a % b)\n\nfun lcm(a: Long, b: Long) = \n (a * b) / gcd(a, b)\n\nfun sumDigits(num_: Long): Long {\n var num = num_\n var rtn: Long = 0\n while(num != 0.toLong()) {\n val tmp = num % 10\n rtn += tmp\n num /= 10\n }\n return rtn\n}\n\nfun isDecimal(v: Double): Boolean = ((v - Math.floor(v)) != 0.0)\n\n// Data Structures\nclass Stack(private var st: MutableList = mutableListOf()) {\n fun isEmpty() = st.isEmpty()\n fun top(): T = st.last()\n fun push(e: T) { st.add(e) }\n fun pop() { st = st.dropLast(1).toMutableList() }\n}\n\nclass Queue(private var que: MutableList = mutableListOf()) {\n fun isEmpty() = que.isEmpty()\n fun top(): T = que.first()\n fun push(e: T) { que.add(e) }\n fun pop() { que = que.drop(1).toMutableList() }\n}\n", "language": "Kotlin", "metadata": {"date": 1564275775, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02957.html", "problem_id": "p02957", "resource_group": "medium_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/Kotlin/s405825157.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s405825157", "user_id": "u026686258"}, "prompt_components": {"gold_output": "9\n", "input_to_evaluate": "import java.io.PrintWriter\nimport java.util.*\nimport java.math.*\nimport java.lang.*\n\nval pw = PrintWriter(System.out)\nval MOD: Long = (1e+9 + 7).toLong()\n\nfun main(args: Array) {\n val (a, b) = readListOfInt() \n val ans = Math.abs(b-a) / 2 + Math.min(a, b)\n println(if(Math.abs(b-a) % 2 == 0) ans else \"IMPOSSIBLE\")\n pw.flush()\n}\n\n/****** Decrared Functions and Data Structures ******/\n// IO\nfun read() = readLine()!!\nfun readInt() = read().toInt()\nfun readLong() = read().toLong()\nfun readDouble() = read().toDouble()\nfun readListOfString() = read().split(\" \")\nfun readListOfInt() = readListOfString().map { it.toInt() }\nfun readListOfLong() = readListOfString().map { it.toLong() }\nfun readListOfDouble() = readListOfString().map { it.toDouble() }\n\nfun Double.format(digits: Int) = String.format(\"%.${digits}f\", this)\nfun Float.format(digits: Int) = String.format(\"%.${digits}f\", this)\n\nfun print(value: Any) { pw.print(value) }\nfun println(value : Any) { pw.println(value) }\n\nfun permutations(src: List): List> {\n if(src.size == 1) return listOf(src)\n val perms = mutableListOf>()\n val insertElement = src[0]\n permutations(src.drop(1)).forEach { perm ->\n for(i in 0..perm.size) {\n val newPerm = perm.toMutableList()\n newPerm.add(i, insertElement)\n perms.add(newPerm.toList())\n }\n }\n return perms\n}\n\n// return nCr, if you want nCr, please access v[n][r]\nfun combinations(n: Long): List> {\n val v = (0..n).map { (0..n).map{0L}.toMutableList() }.toMutableList()\n for(i in 0 until v.size) {\n v[i][0] = 1L\n v[i][i] = 1L\n }\n for(i in 0 until v.size) {\n for(j in 1 until i) {\n v[i][j] = (v[i-1][j-1] + v[i-1][j] % MOD)\n }\n }\n return v.map { it.toList() }.toList()\n}\n\nfun gcd(a: Long, b: Long): Long = \n if(b != 0L) a else gcd(b, a % b)\n\nfun lcm(a: Long, b: Long) = \n (a * b) / gcd(a, b)\n\nfun sumDigits(num_: Long): Long {\n var num = num_\n var rtn: Long = 0\n while(num != 0.toLong()) {\n val tmp = num % 10\n rtn += tmp\n num /= 10\n }\n return rtn\n}\n\nfun isDecimal(v: Double): Boolean = ((v - Math.floor(v)) != 0.0)\n\n// Data Structures\nclass Stack(private var st: MutableList = mutableListOf()) {\n fun isEmpty() = st.isEmpty()\n fun top(): T = st.last()\n fun push(e: T) { st.add(e) }\n fun pop() { st = st.dropLast(1).toMutableList() }\n}\n\nclass Queue(private var que: MutableList = mutableListOf()) {\n fun isEmpty() = que.isEmpty()\n fun top(): T = que.first()\n fun push(e: T) { que.add(e) }\n fun pop() { que = que.drop(1).toMutableList() }\n}\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2683, "cpu_time_ms": 242, "memory_kb": 37820}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s568871997", "group_id": "codeNet:p02958", "input_text": "fun main(args: Array) {\n val N = readLine()!!.toInt()\n val p = readLine()!!.split(\" \").map(String::toInt)\n val miss = (1..N).count { it != p[it - 1] }\n println(if (miss <= 2) \"YES\" else \"NO\")\n}", "language": "Kotlin", "metadata": {"date": 1589699094, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02958.html", "problem_id": "p02958", "resource_group": "medium_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/Kotlin/s568871997.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s568871997", "user_id": "u860789370"}, "prompt_components": {"gold_output": "YES\n", "input_to_evaluate": "fun main(args: Array) {\n val N = readLine()!!.toInt()\n val p = readLine()!!.split(\" \").map(String::toInt)\n val miss = (1..N).count { it != p[it - 1] }\n println(if (miss <= 2) \"YES\" else \"NO\")\n}", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 213, "cpu_time_ms": 236, "memory_kb": 37932}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s510744746", "group_id": "codeNet:p02958", "input_text": "fun main(args:Array){\n val n = readLine()!!.toInt()\n val p = readLine()!!.split(\" \").map{it.toInt()}\n val k = p.zip((1 .. n)).filter{it.first != it.second}.size\n println(if(k == 2 || k == 0) \"YES\" else \"NO\")\n}\n", "language": "Kotlin", "metadata": {"date": 1578088703, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02958.html", "problem_id": "p02958", "resource_group": "medium_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/Kotlin/s510744746.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s510744746", "user_id": "u480831358"}, "prompt_components": {"gold_output": "YES\n", "input_to_evaluate": "fun main(args:Array){\n val n = readLine()!!.toInt()\n val p = readLine()!!.split(\" \").map{it.toInt()}\n val k = p.zip((1 .. n)).filter{it.first != it.second}.size\n println(if(k == 2 || k == 0) \"YES\" else \"NO\")\n}\n", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 242, "memory_kb": 37744}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s514383265", "group_id": "codeNet:p02958", "input_text": "fun main(args: Array) {\n val n = readLine()!!.toInt()\n val ps = readLine()!!.split(\" \").map { it.toInt() }\n val flags = mutableListOf()\n for (i in 1..n) {\n if (i != ps[i-1]) {\n flags.add(i)\n }\n }\n if (flags.size > 2) {\n println(\"No\")\n }\n else if (flags.isEmpty()) {\n println(\"YES\")\n }\n else {\n if (flags[0] == ps[flags[1] - 1] && flags[1] == ps[flags[0] - 1]) {\n println(\"YES\")\n }\n else {\n println(\"NO\")\n }\n }\n}", "language": "Kotlin", "metadata": {"date": 1564278086, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02958.html", "problem_id": "p02958", "resource_group": "medium_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/Kotlin/s514383265.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s514383265", "user_id": "u295621316"}, "prompt_components": {"gold_output": "YES\n", "input_to_evaluate": "fun main(args: Array) {\n val n = readLine()!!.toInt()\n val ps = readLine()!!.split(\" \").map { it.toInt() }\n val flags = mutableListOf()\n for (i in 1..n) {\n if (i != ps[i-1]) {\n flags.add(i)\n }\n }\n if (flags.size > 2) {\n println(\"No\")\n }\n else if (flags.isEmpty()) {\n println(\"YES\")\n }\n else {\n if (flags[0] == ps[flags[1] - 1] && flags[1] == ps[flags[0] - 1]) {\n println(\"YES\")\n }\n else {\n println(\"NO\")\n }\n }\n}", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 546, "cpu_time_ms": 233, "memory_kb": 37860}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s747026389", "group_id": "codeNet:p02959", "input_text": "import java.util.*\n\nfun main(args:Array){\n val n = readLine()!!.toInt()\n var a = readLine()!!.split(\" \").map{it.toInt()}.toIntArray()\n val b = readLine()!!.split(\" \").map{it.toInt()}\n var ans = 0L\n for(i in 0 until n){\n var k = Math.min(a[i], b[i])\n ans += k\n k = b[i] - k\n if(k > 0){\n k = Math.min(a[i + 1], k)\n ans += k\n a[i + 1] -= k\n }\n }\n println(ans)\n}", "language": "Kotlin", "metadata": {"date": 1578260239, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02959.html", "problem_id": "p02959", "resource_group": "medium_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/Kotlin/s747026389.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s747026389", "user_id": "u480831358"}, "prompt_components": {"gold_output": "9\n", "input_to_evaluate": "import java.util.*\n\nfun main(args:Array){\n val n = readLine()!!.toInt()\n var a = readLine()!!.split(\" \").map{it.toInt()}.toIntArray()\n val b = readLine()!!.split(\" \").map{it.toInt()}\n var ans = 0L\n for(i in 0 until n){\n var k = Math.min(a[i], b[i])\n ans += k\n k = b[i] - k\n if(k > 0){\n k = Math.min(a[i + 1], k)\n ans += k\n a[i + 1] -= k\n }\n }\n println(ans)\n}", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 712, "memory_kb": 86688}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s263592569", "group_id": "codeNet:p02959", "input_text": "fun main (args : Array) {\n\tval n = readLine()\n\tvar N : Int = n!!.toInt()\n\tval a = readLine()!!.split(\" \")\n\tval b = readLine()!!.split(\" \")\n\tvar aList : MutableList = mutableListOf()\n\tvar bList : MutableList = mutableListOf()\n\tvar result : Int = 0\n\tfor (i in a) {\n\t\taList.add(i.toInt())\n\t}\n\tfor (i in b) {\n\t\tbList.add(i.toInt())\n\t}\n\tfor (i in 0..N - 1) {\n\t\tif (bList[i] <= aList[i]) {\n\t\t\tresult += bList[i]\n\t\t} else if (bList[i] > aList[i]) {\n\t\t\tif (bList[i] >= (aList[i] + aList[i + 1])) {\n\t\t\t\tresult += (aList[i] + aList[i + 1])\n\t\t\t} else if (bList[i] < (aList[i] + aList[i + 1])) {\n\t\t\t\tresult += bList[i]\n\t\t\t\taList[i + 1] = (aList[i + 1] - (bList[i] - aList[i]))\n\t\t\t}\n\t\t}\n\t}\n\tprintln(\"${result}\")\n}", "language": "Kotlin", "metadata": {"date": 1567626900, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02959.html", "problem_id": "p02959", "resource_group": "medium_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/Kotlin/s263592569.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s263592569", "user_id": "u651257341"}, "prompt_components": {"gold_output": "9\n", "input_to_evaluate": "fun main (args : Array) {\n\tval n = readLine()\n\tvar N : Int = n!!.toInt()\n\tval a = readLine()!!.split(\" \")\n\tval b = readLine()!!.split(\" \")\n\tvar aList : MutableList = mutableListOf()\n\tvar bList : MutableList = mutableListOf()\n\tvar result : Int = 0\n\tfor (i in a) {\n\t\taList.add(i.toInt())\n\t}\n\tfor (i in b) {\n\t\tbList.add(i.toInt())\n\t}\n\tfor (i in 0..N - 1) {\n\t\tif (bList[i] <= aList[i]) {\n\t\t\tresult += bList[i]\n\t\t} else if (bList[i] > aList[i]) {\n\t\t\tif (bList[i] >= (aList[i] + aList[i + 1])) {\n\t\t\t\tresult += (aList[i] + aList[i + 1])\n\t\t\t} else if (bList[i] < (aList[i] + aList[i + 1])) {\n\t\t\t\tresult += bList[i]\n\t\t\t\taList[i + 1] = (aList[i + 1] - (bList[i] - aList[i]))\n\t\t\t}\n\t\t}\n\t}\n\tprintln(\"${result}\")\n}", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 718, "cpu_time_ms": 715, "memory_kb": 83008}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s110912926", "group_id": "codeNet:p02959", "input_text": "fun main(args: Array) {\n val N = readLine()!!.toInt()\n val A = readLine()!!.split(' ').map { it.toLong() }\n val B = readLine()!!.split(' ').map { it.toLong() }\n var rest = LongArray(N)\n var score = LongArray(N + 1)\n for (i in 0 until N + 1) {\n when (i) {\n 0 -> {\n if (A[i] < B[i]) {\n score[i] = A[i]\n rest[i] = B[i] - A[i]\n } else {\n score[i] = B[i]\n rest[i] = 0L\n }\n }\n N -> {\n score[i] = Math.min(A[i], rest[i - 1])\n }\n else -> {\n if ((A[i] - rest[i - 1]) < B[i]) {\n score[i] = A[i]\n rest[i] = Math.min(B[i] - A[i] + rest[i - 1], B[i])\n } else {\n score[i] = B[i] + rest[i - 1]\n rest[i] = 0L\n }\n }\n }\n }\n var total = 0L\n for (i in 0 until N + 1) {\n total += score[i]\n }\n println(total)\n}", "language": "Kotlin", "metadata": {"date": 1564755728, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02959.html", "problem_id": "p02959", "resource_group": "medium_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/Kotlin/s110912926.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s110912926", "user_id": "u562388762"}, "prompt_components": {"gold_output": "9\n", "input_to_evaluate": "fun main(args: Array) {\n val N = readLine()!!.toInt()\n val A = readLine()!!.split(' ').map { it.toLong() }\n val B = readLine()!!.split(' ').map { it.toLong() }\n var rest = LongArray(N)\n var score = LongArray(N + 1)\n for (i in 0 until N + 1) {\n when (i) {\n 0 -> {\n if (A[i] < B[i]) {\n score[i] = A[i]\n rest[i] = B[i] - A[i]\n } else {\n score[i] = B[i]\n rest[i] = 0L\n }\n }\n N -> {\n score[i] = Math.min(A[i], rest[i - 1])\n }\n else -> {\n if ((A[i] - rest[i - 1]) < B[i]) {\n score[i] = A[i]\n rest[i] = Math.min(B[i] - A[i] + rest[i - 1], B[i])\n } else {\n score[i] = B[i] + rest[i - 1]\n rest[i] = 0L\n }\n }\n }\n }\n var total = 0L\n for (i in 0 until N + 1) {\n total += score[i]\n }\n println(total)\n}", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1073, "cpu_time_ms": 708, "memory_kb": 86612}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s961231688", "group_id": "codeNet:p02959", "input_text": "fun main(args: Array) {\n val n = readLine()!!.toInt()\n val a = readLine()!!.split(\" \").map { it.toInt() }\n val b = readLine()!!.split(\" \").map { it.toInt() }\n var monster = 0\n for (i in 0 until n) {\n monster += if ((a[i] + a[i+1]) > b[i]) b[i] else a[i] + a[i+1]\n }\n println(monster)\n}", "language": "Kotlin", "metadata": {"date": 1564278922, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02959.html", "problem_id": "p02959", "resource_group": "medium_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/Kotlin/s961231688.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s961231688", "user_id": "u295621316"}, "prompt_components": {"gold_output": "9\n", "input_to_evaluate": "fun main(args: Array) {\n val n = readLine()!!.toInt()\n val a = readLine()!!.split(\" \").map { it.toInt() }\n val b = readLine()!!.split(\" \").map { it.toInt() }\n var monster = 0\n for (i in 0 until n) {\n monster += if ((a[i] + a[i+1]) > b[i]) b[i] else a[i] + a[i+1]\n }\n println(monster)\n}", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 730, "memory_kb": 82500}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s998620922", "group_id": "codeNet:p02959", "input_text": "import java.util.*\n\nfun main(args: Array) {\n val scanner = Scanner(System.`in`)\n val n = scanner.nextInt()\n val enemy = Array(n+1, {0})\n val brave = Array(n, {0})\n var sum = 0\n for(i in 0..n){\n enemy[i] = scanner.nextInt()\n }\n for(i in 0..n-1){\n brave[i] = scanner.nextInt()\n }\n for(i in 0..n-1){\n if(enemy[i] >= brave[i]){\n sum += brave[i]\n }\n else if(enemy[i]+enemy[i+1] >= brave[i]){\n sum += brave[i]\n enemy[i+1] -= (brave[i]-enemy[i])\n }\n else{\n sum += (enemy[i]+enemy[i+1])\n enemy[i+1] = 0\n }\n }\n println(sum)\n}", "language": "Kotlin", "metadata": {"date": 1564277933, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02959.html", "problem_id": "p02959", "resource_group": "medium_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/Kotlin/s998620922.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s998620922", "user_id": "u046105273"}, "prompt_components": {"gold_output": "9\n", "input_to_evaluate": "import java.util.*\n\nfun main(args: Array) {\n val scanner = Scanner(System.`in`)\n val n = scanner.nextInt()\n val enemy = Array(n+1, {0})\n val brave = Array(n, {0})\n var sum = 0\n for(i in 0..n){\n enemy[i] = scanner.nextInt()\n }\n for(i in 0..n-1){\n brave[i] = scanner.nextInt()\n }\n for(i in 0..n-1){\n if(enemy[i] >= brave[i]){\n sum += brave[i]\n }\n else if(enemy[i]+enemy[i+1] >= brave[i]){\n sum += brave[i]\n enemy[i+1] -= (brave[i]-enemy[i])\n }\n else{\n sum += (enemy[i]+enemy[i+1])\n enemy[i+1] = 0\n }\n }\n println(sum)\n}", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 639, "memory_kb": 76692}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s388662184", "group_id": "codeNet:p02959", "input_text": "import java.io.*\nimport java.util.*\n\nfun solve(N: Long, A: LongArray, B: LongArray){\n val n = N.toInt()\n var ans = 0L\n var rest = 0L\n for ( i in 0 until n+1){\n var b = B.getOrElse(i){0} + rest\n if (A[i] > b){\n ans += b\n rest = 0\n }else{\n ans += A[i]\n rest = b-A[i]\n }\n }\n println(ans)\n return\n}\n\n\nfun main(args: Array) {\n fun StringArray(size: Int, init: (Int) -> String = { \"\\u0000\" }): Array {\n return Array(size, init)\n }\n class Scanner(stream: InputStream) {\n private val reader = BufferedInputStream(stream).bufferedReader()\n private var st: StringTokenizer? = null\n fun next(): String {\n while (!(st?.hasMoreTokens() ?: false)) st = StringTokenizer(reader.readLine())\n return st!!.nextToken()\n }\n }\n val sc = Scanner(System.`in`)\n val N = sc.next().toLong()\n val A = LongArray((N+1).toInt())\n for (i in 0 until (N+1).toInt()) {\n A[i] = sc.next().toLong()\n }\n val B = LongArray(N.toInt())\n for (i in 0 until N.toInt()) {\n B[i] = sc.next().toLong()\n }\n solve(N, A, B)\n}\n\n", "language": "Kotlin", "metadata": {"date": 1564276706, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02959.html", "problem_id": "p02959", "resource_group": "medium_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/Kotlin/s388662184.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s388662184", "user_id": "u329232967"}, "prompt_components": {"gold_output": "9\n", "input_to_evaluate": "import java.io.*\nimport java.util.*\n\nfun solve(N: Long, A: LongArray, B: LongArray){\n val n = N.toInt()\n var ans = 0L\n var rest = 0L\n for ( i in 0 until n+1){\n var b = B.getOrElse(i){0} + rest\n if (A[i] > b){\n ans += b\n rest = 0\n }else{\n ans += A[i]\n rest = b-A[i]\n }\n }\n println(ans)\n return\n}\n\n\nfun main(args: Array) {\n fun StringArray(size: Int, init: (Int) -> String = { \"\\u0000\" }): Array {\n return Array(size, init)\n }\n class Scanner(stream: InputStream) {\n private val reader = BufferedInputStream(stream).bufferedReader()\n private var st: StringTokenizer? = null\n fun next(): String {\n while (!(st?.hasMoreTokens() ?: false)) st = StringTokenizer(reader.readLine())\n return st!!.nextToken()\n }\n }\n val sc = Scanner(System.`in`)\n val N = sc.next().toLong()\n val A = LongArray((N+1).toInt())\n for (i in 0 until (N+1).toInt()) {\n A[i] = sc.next().toLong()\n }\n val B = LongArray(N.toInt())\n for (i in 0 until N.toInt()) {\n B[i] = sc.next().toLong()\n }\n solve(N, A, B)\n}\n\n", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1202, "cpu_time_ms": 462, "memory_kb": 54340}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s253867114", "group_id": "codeNet:p02960", "input_text": "import java.io.PrintWriter\n\nfun main() {\n PrintWriter(System.out).use { out ->\n solve(out)\n out.flush()\n }\n}\n\nfun solve(out: PrintWriter) {\n val MOD = 1000000007\n val s = readLine()!!.reversed()\n // dp[i][j]: 入力の右からi番目まででj余る\n val dp = Array(s.length + 1) { LongArray(13) }\n dp[0][0] = 1\n var ten = 1\n for (i in s.indices) {\n if (s[i] == '?') {\n for (j in 0..9) {\n val num = (j * ten) % 13\n for (k in 0 until 13) {\n dp[i + 1][(k + num) % 13] = (dp[i + 1][(k + num) % 13] + dp[i][k]) % MOD\n }\n }\n } else {\n val num = ((s[i] - '0') * ten) % 13\n for (j in 0 until 13) {\n dp[i + 1][(j + num) % 13] = (dp[i + 1][(j + num) % 13] + dp[i][j]) % MOD\n }\n }\n\n ten = (ten * 10) % 13\n }\n println(dp[s.length][5])\n}\n\nfun readInteger() = readLine()!!.toInt()\nfun readLong() = readLine()!!.toLong()\nfun readStringList() = readLine()!!.split(\" \")\nfun readIntegerList() = readStringList().map(String::toInt)\nfun readLongList() = readStringList().map(String::toLong)\nfun readDoubleList() = readStringList().map(String::toDouble)\n", "language": "Kotlin", "metadata": {"date": 1592876709, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02960.html", "problem_id": "p02960", "resource_group": "medium_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/Kotlin/s253867114.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s253867114", "user_id": "u784448849"}, "prompt_components": {"gold_output": "768\n", "input_to_evaluate": "import java.io.PrintWriter\n\nfun main() {\n PrintWriter(System.out).use { out ->\n solve(out)\n out.flush()\n }\n}\n\nfun solve(out: PrintWriter) {\n val MOD = 1000000007\n val s = readLine()!!.reversed()\n // dp[i][j]: 入力の右からi番目まででj余る\n val dp = Array(s.length + 1) { LongArray(13) }\n dp[0][0] = 1\n var ten = 1\n for (i in s.indices) {\n if (s[i] == '?') {\n for (j in 0..9) {\n val num = (j * ten) % 13\n for (k in 0 until 13) {\n dp[i + 1][(k + num) % 13] = (dp[i + 1][(k + num) % 13] + dp[i][k]) % MOD\n }\n }\n } else {\n val num = ((s[i] - '0') * ten) % 13\n for (j in 0 until 13) {\n dp[i + 1][(j + num) % 13] = (dp[i + 1][(j + num) % 13] + dp[i][j]) % MOD\n }\n }\n\n ten = (ten * 10) % 13\n }\n println(dp[s.length][5])\n}\n\nfun readInteger() = readLine()!!.toInt()\nfun readLong() = readLine()!!.toLong()\nfun readStringList() = readLine()!!.split(\" \")\nfun readIntegerList() = readStringList().map(String::toInt)\nfun readLongList() = readStringList().map(String::toLong)\nfun readDoubleList() = readStringList().map(String::toDouble)\n", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1244, "cpu_time_ms": 325, "memory_kb": 50632}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s879094566", "group_id": "codeNet:p02963", "input_text": "import java.io.*\nimport java.lang.*\nimport java.math.BigDecimal\nimport java.math.MathContext\nimport java.util.*\n\n// Constant\nval sc = FastScanner()\nval pw = PrintWriter(System.out)\nconst val MOD = 1000000007L\nconst val INF = 9223372036854775807L\n\n// Main\nfun main(args: Array) {\n solve()\n pw.flush()\n}\n\nfun solve() {\n val s = nextLong()\n val tmp = 1000000000L\n val x = (tmp - s % tmp) % tmp\n val y = (s + x) / tmp\n\n println(\"0 0 1000000000 1 $x $y\")\n\n\n}\n\n\n\n// Rule\noperator fun String.get(index: Long): Char {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun CharArray.get(index: Long): Char {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun CharArray.set(index: Long, value: Char) {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n this[index.toInt()] = value\n}\noperator fun LongArray.get(index: Long): Long {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun LongArray.set(index: Long, value: Long) {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n this[index.toInt()] = value\n}\noperator fun DoubleArray.get(index: Long): Double {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun DoubleArray.set(index: Long, value: Double) {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n this[index.toInt()] = value\n}\noperator fun Array.get(index: Long): T {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun Array.set(index: Long, value: T) {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n this[index.toInt()] = value\n}\noperator fun MutableList.get(index: Long): T {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun MutableList.set(index: Long, value: T) {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n this[index.toInt()] = value\n}\n\nval LongArray.siz: Long\n get() = size.toLong()\nval Array.siz: Long\n get() = size.toLong()\nval MutableList.siz: Long\n get() = size.toLong()\nval MutableSet.siz: Long\n get() = size.toLong()\nval String.len: Long\n get() = length.toLong()\n\n// Output\nfun println(v: String) {\n pw.println(v)\n}\nfun print(v: String) {\n pw.print(v)\n}\n\n// Input\nfun next() = sc.next()\nfun nextLong() = sc.nextLong()\nfun nextDouble() = next().toDouble()\nfun nextAry(n: Long): Array {\n val ary = ary(n)\n for (i in 0 until n) ary[i] = next()\n return ary\n}\nfun nextLongAry(n: Long): LongArray {\n val ary = longAry(n)\n for (i in 0 until n) ary[i] = nextLong()\n return ary\n}\nfun nextDoubleAry(n: Long): DoubleArray {\n val ary = doubleAry(n)\n for (i in 0 until n) ary[i] = nextDouble()\n return ary\n}\n\n// Statement\nfun ary(n: Long, init: String = \"\") = Array(n.toInt()) { init }\nfun longAry(n: Long, init: Long = 0L) = LongArray(n.toInt()) { init }\nfun doubleAry(n: Long, init: Double = 0.0) = DoubleArray(n.toInt()) { init }\nfun boolAry(n: Long, init: Boolean = false) = Array(n.toInt()) { init }\nfun ary2(n: Long, m: Long, init: String = \"\") = Array(n.toInt()) { ary(m, init) }\nfun longAry2(n: Long, m: Long, init: Long = 0) = Array(n.toInt()) { longAry(m, init) }\nfun doubleAry2(n: Long, m: Long, init: Double = 0.0) = Array(n.toInt()) { doubleAry(m, init) }\nfun boolAry2(n: Long, m: Long, init: Boolean = false) = Array(n.toInt()) { boolAry(m, init) }\nfun ary3(n: Long, m: Long, k: Long, init: String = \"\") = Array(n.toInt()) { ary2(m, k, init) }\nfun longAry3(n: Long, m: Long, k: Long, init: Long = 0L) = Array(n.toInt()) { longAry2(m, k, init) }\nfun doubleAry3(n: Long, m: Long, k: Long, init: Double = 0.0) = Array(n.toInt()) { doubleAry2(m, k, init) }\nfun boolAry3(n: Long, m: Long, k: Long, init: Boolean = false) = Array(n.toInt()) { boolAry2(m, k, init) }\nfun list() = mutableListOf()\nfun longList() = mutableListOf()\nfun doubleList() = mutableListOf()\nfun strSet() = mutableSetOf()\nfun longSet() = mutableSetOf()\nfun doubleSet() = mutableSetOf()\nfun map() = mutableMapOf()\n\n// Monoid\nval addFunc = {a: Long, b: Long -> a + b}\nval mulFunc = {a: Long, b: Long -> a * b}\nval maxFunc = {a: Long, b: Long -> max(a, b)}\nval minFunc = {a: Long, b: Long -> min(a, b)}\nval gcdFunc = {a: Long, b: Long -> gcd(a, b)}\nval lcmFunc = {a: Long, b: Long -> lcm(a, b)}\nval xorFunc = {a: Long, b: Long -> a xor b}\nfun calc(a: Long, b: Long, op: (Long, Long) -> Long) = op(a, b)\n\n// Extension\nfun LongArray.lowerBound(n: Long): Long {\n var ok = this.size.toLong()\n var ng = -1L\n while (abs(ok - ng) > 1) {\n val mid = (ok + ng) / 2\n if (this[mid] >= n) ok = mid\n else ng = mid\n }\n return ok\n}\nfun DoubleArray.lowerBound(n: Double): Long {\n var ok = this.size.toLong()\n var ng = -1L\n while (abs(ok - ng) > 1) {\n val mid = (ok + ng) / 2\n if (this[mid] >= n) ok = mid\n else ng = mid\n }\n return ok\n}\nfun MutableList.longLowerBound(n: Long): Long {\n var ok = this.size.toLong()\n var ng = -1L\n while (abs(ok - ng) > 1) {\n val mid = (ok + ng) / 2\n if (this[mid] >= n) ok = mid\n else ng = mid\n }\n return ok\n}\nfun MutableList.doubleLowerBound(n: Double): Long {\n var ok = this.size.toLong()\n var ng = -1L\n while (abs(ok - ng) > 1) {\n val mid = (ok + ng) / 2\n if (this[mid] >= n) ok = mid\n else ng = mid\n }\n return ok\n}\nfun LongArray.cumsum(op: (Long, Long) -> Long): LongArray {\n val s = longAry(this.size + 1L)\n s[1] = this[0]\n for (i in 1 until this.size) s[i + 1] = calc(s[i], this[i], op)\n return s\n}\nfun MutableMap.counting(n: Long) {\n repeat(n.toInt()) {\n val a = next()\n if (this.containsKey(a)) this[a] = this[a]!! + 1\n else this[a] = 1\n }\n}\nfun MutableMap.longCounting(n: Long) {\n repeat(n.toInt()) {\n val a = nextLong()\n if (this.containsKey(a)) this[a] = this[a]!! + 1\n else this[a] = 1\n }\n}\n\n// Mathematics\nfun abs(n: Long): Long = Math.abs(n)\nfun abs(n: Double): Double = Math.abs(n)\nfun max(vararg values: Long) = if (values.isEmpty()) -INF else values.max()!!\nfun min(vararg values: Long) = if (values.isEmpty()) INF else values.min()!!\ntailrec fun gcd(a: Long, b: Long): Long = if (b == 0L) a else if (a % b == 0L) b else gcd(b, (a % b))\nfun lcm(a: Long, b: Long): Long = a / gcd(a, b) * b\nfun modpow(a: Long, n: Long, p: Long = MOD): Long {\n var res = 1L\n var ar = a\n var nr = n\n while (nr > 0) {\n if ((nr and 1) == 1L) res = res * ar % p\n ar = ar * ar % p\n nr = nr shr 1\n }\n return res\n}\nfun modinv(a: Long, p: Long = MOD): Long = modpow(a, p - 2, p)\nfun ncr(n: Long, r: Long): Long {\n var a = 1L\n var b = 1L\n for (i in 1..r) {\n a = a * (n + 1 - i) % MOD\n b = b * i % MOD\n }\n return modinv(b, MOD) * a % MOD\n}\n\nclass Combination(private val max: Long) {\n private val fac = longAry(max)\n private val finv = longAry(max)\n private val inv = longAry(max)\n private val p = MOD\n fun init() {\n fac[0] = 1\n fac[1] = 1\n finv[0] = 1\n finv[1] = 1\n inv[1] = 1\n for (i in 2 until max) {\n fac[i] = fac[i - 1] * i % p\n inv[i] = p - inv[p % i] * (p / i) % p;\n finv[i] = finv[i - 1] * inv[i] % p\n }\n }\n\n fun com(n: Long, r: Long): Long = if (n < r || (n < 0 || r < 0)) 0L else fac[n] * (finv[r] * finv[n - r] % p) % p\n}\n\nclass Permutation(private val n: Long, private var searched: Long = 0L, private var nextIndex: Long = 0L) {\n private val size = fact(n)\n private val permList = longAry2(size, n)\n\n private tailrec fun fact(n: Long, ans: Long = 1L): Long {\n return if (n == 0L) ans\n else fact(n - 1, ans * n)\n }\n\n fun init() {\n create(0, longAry(n), boolAry(n))\n }\n\n private fun create(num: Long, list: LongArray, flag: Array) {\n if (num == n) {\n permList[searched] = list.copyOf()\n searched++\n }\n for (i in 0 until n) {\n if (flag[i]) continue\n list[num] = i\n flag[i] = true\n create(num + 1, list, flag)\n flag[i] = false\n }\n }\n\n fun hasNext(): Boolean {\n return if (nextIndex < size) {\n true\n } else {\n nextIndex = 0\n false\n }\n }\n\n fun nextPerm(): LongArray = permList[nextIndex++]\n}\n\n// Graph\ndata class Node(val id: Long, var past: Long = -1, val edges: MutableList = mutableListOf())\ndata class Edge(val from: Long, val to: Long, val cost: Long = 1L)\n\nfun dfs(nodes: Array, now: Long, seen: Array) {\n seen[now] = true\n for (edge in nodes[now].edges) {\n if (seen[edge.to]) continue\n dfs(nodes, edge.to, seen)\n }\n}\n\nfun bfs(nodes: Array, start: Long): LongArray {\n val queue = ArrayDeque()\n queue.add(start)\n val dist = longAry(nodes.size.toLong(), -1L)\n dist[start] = 0L\n while (queue.isNotEmpty()) {\n val now = queue.poll()\n for (edge in nodes[now].edges) {\n if (dist[edge.to] != -1L) continue\n dist[edge.to] = dist[now] + 1\n queue.add(edge.to)\n }\n }\n return dist\n}\n\nfun dijkstra(nodes: Array, start: Long): LongArray {\n val queue = PriorityQueue(16) { e1: Edge, e2: Edge ->\n return@PriorityQueue when {\n e1.cost < e2.cost -> -1\n e2.cost > e1.cost -> 1\n else -> 0\n }\n }\n queue.add(Edge(start, start, 0L))\n val dist = longAry(nodes.size.toLong(), INF / 2)\n dist[start] = 0\n while (queue.isNotEmpty()) {\n val now = queue.poll()\n if (dist[now.to] < now.cost) continue;\n for (edge in nodes[now.to].edges) {\n if (dist[edge.to] <= dist[edge.from] + edge.cost) continue\n dist[edge.to] = dist[edge.from] + edge.cost\n queue.add(Edge(edge.from, edge.to, dist[edge.to]))\n nodes[edge.to].past = edge.from\n }\n }\n return dist\n}\n\n// Data Structure\nclass UnionFind(size: Long) {\n private val par = LongArray(size.toInt()) { it.toLong() }\n private val size = longAry(size, 1L)\n fun root(x: Long): Long {\n return if (par[x] == x) {\n x\n } else {\n par[x] = root(par[x])\n par[x]\n }\n }\n\n fun same(x: Long, y: Long): Boolean = root(x) == root(y)\n fun unite(x: Long, y: Long) {\n var a = root(x)\n var b = root(y)\n if (a == b) return\n if (size[a] < size[b]) {\n var tmp = a\n a = b\n b = tmp\n }\n size[a] += size[b]\n par[b] = a\n }\n\n fun size(x: Long): Long = size[root(x)]\n}\n\nclass SegmentTree(\n private val a: LongArray,\n private val op: (Long, Long) -> Long,\n private val def: Long = 0,\n private val size: Int = a.size,\n private val n: Int = Integer.highestOneBit(size) shl 1\n) {\n private val nodes = longAry(2L * n - 1, def)\n\n fun init() {\n for (i in 0 until size) nodes[i + n - 1] = a[i]\n for (i in n - 2 downTo 0) nodes[i] = calc(nodes[2 * i + 1], nodes[2 * i + 2], op)\n }\n\n fun update(x: Long, value: Long) {\n var index = x + n - 1\n nodes[index] = value\n while (index > 0) {\n index = (index - 1) / 2\n nodes[index] = calc(nodes[2 * index + 1], nodes[2 * index + 2], op)\n }\n }\n\n fun get(a: Long, b: Long) = getSub(a, b, 0L, 0L, n.toLong())\n private fun getSub(a: Long, b: Long, k: Long, l: Long, r: Long): Long {\n return when {\n r <= a || b <= l -> def\n a <= l && r <= b -> nodes[k]\n else -> {\n val vl = getSub(a, b, k * 2 + 1, l, (l + r) / 2)\n val vr = getSub(a, b, k * 2 + 2, (l + r) / 2, r)\n calc(vl, vr, op)\n }\n }\n }\n\n fun joinToString(separator: String) = nodes.drop(n - 1).take(size).joinToString(separator)\n}\n\n// Scanner\nclass FastScanner {\n private val sin: InputStream = System.`in`\n private val buffer: ByteArray = ByteArray(1024) { 0 }\n private var ptr = 0\n private var buflen = 0\n\n private fun hasNextByte(): Boolean {\n return when {\n ptr < buflen -> true\n else -> {\n ptr = 0\n buflen = sin.read(buffer)\n buflen > 0\n }\n }\n }\n\n private fun readByte(): Int {\n return when {\n hasNextByte() -> buffer[ptr++].toInt()\n else -> -1\n }\n }\n\n private fun isPrintableChar(c: Int) = c in 33..126\n\n fun hasNext(): Boolean {\n while (hasNextByte() && !isPrintableChar(buffer[ptr].toInt())) ptr++\n return hasNextByte()\n }\n\n fun next(): String {\n if (!hasNext()) throw NoSuchElementException()\n val sb = StringBuilder()\n var b = readByte()\n while (isPrintableChar(b)) {\n sb.appendCodePoint(b)\n b = readByte()\n }\n return sb.toString()\n }\n\n fun nextLong(): Long {\n if (!hasNext()) throw NoSuchElementException()\n var n = 0L\n var minus = false\n var b = readByte()\n if (b.toChar() == '-') {\n minus = true\n b = readByte()\n }\n if (b.toChar() !in '0'..'9') throw NumberFormatException()\n while (true) {\n when {\n b.toChar() in '0'..'9' -> {\n n *= 10\n n += b.toChar() - '0'\n }\n b == -1 || !isPrintableChar(b) -> return if (minus) -n else n\n else -> throw NumberFormatException()\n }\n b = readByte()\n }\n }\n\n// \"The world doesn't need you.\"\n//\n// fun nextInt(): Int {\n// val nl = nextLong()\n// if (nl !in Int.MIN_VALUE..Int.MAX_VALUE) throw NumberFormatException()\n// return nl.toInt()\n// }\n}", "language": "Kotlin", "metadata": {"date": 1588702282, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02963.html", "problem_id": "p02963", "resource_group": "medium_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/Kotlin/s879094566.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s879094566", "user_id": "u581625805"}, "prompt_components": {"gold_output": "1 0 2 2 0 1\n", "input_to_evaluate": "import java.io.*\nimport java.lang.*\nimport java.math.BigDecimal\nimport java.math.MathContext\nimport java.util.*\n\n// Constant\nval sc = FastScanner()\nval pw = PrintWriter(System.out)\nconst val MOD = 1000000007L\nconst val INF = 9223372036854775807L\n\n// Main\nfun main(args: Array) {\n solve()\n pw.flush()\n}\n\nfun solve() {\n val s = nextLong()\n val tmp = 1000000000L\n val x = (tmp - s % tmp) % tmp\n val y = (s + x) / tmp\n\n println(\"0 0 1000000000 1 $x $y\")\n\n\n}\n\n\n\n// Rule\noperator fun String.get(index: Long): Char {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun CharArray.get(index: Long): Char {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun CharArray.set(index: Long, value: Char) {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n this[index.toInt()] = value\n}\noperator fun LongArray.get(index: Long): Long {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun LongArray.set(index: Long, value: Long) {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n this[index.toInt()] = value\n}\noperator fun DoubleArray.get(index: Long): Double {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun DoubleArray.set(index: Long, value: Double) {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n this[index.toInt()] = value\n}\noperator fun Array.get(index: Long): T {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun Array.set(index: Long, value: T) {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n this[index.toInt()] = value\n}\noperator fun MutableList.get(index: Long): T {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun MutableList.set(index: Long, value: T) {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n this[index.toInt()] = value\n}\n\nval LongArray.siz: Long\n get() = size.toLong()\nval Array.siz: Long\n get() = size.toLong()\nval MutableList.siz: Long\n get() = size.toLong()\nval MutableSet.siz: Long\n get() = size.toLong()\nval String.len: Long\n get() = length.toLong()\n\n// Output\nfun println(v: String) {\n pw.println(v)\n}\nfun print(v: String) {\n pw.print(v)\n}\n\n// Input\nfun next() = sc.next()\nfun nextLong() = sc.nextLong()\nfun nextDouble() = next().toDouble()\nfun nextAry(n: Long): Array {\n val ary = ary(n)\n for (i in 0 until n) ary[i] = next()\n return ary\n}\nfun nextLongAry(n: Long): LongArray {\n val ary = longAry(n)\n for (i in 0 until n) ary[i] = nextLong()\n return ary\n}\nfun nextDoubleAry(n: Long): DoubleArray {\n val ary = doubleAry(n)\n for (i in 0 until n) ary[i] = nextDouble()\n return ary\n}\n\n// Statement\nfun ary(n: Long, init: String = \"\") = Array(n.toInt()) { init }\nfun longAry(n: Long, init: Long = 0L) = LongArray(n.toInt()) { init }\nfun doubleAry(n: Long, init: Double = 0.0) = DoubleArray(n.toInt()) { init }\nfun boolAry(n: Long, init: Boolean = false) = Array(n.toInt()) { init }\nfun ary2(n: Long, m: Long, init: String = \"\") = Array(n.toInt()) { ary(m, init) }\nfun longAry2(n: Long, m: Long, init: Long = 0) = Array(n.toInt()) { longAry(m, init) }\nfun doubleAry2(n: Long, m: Long, init: Double = 0.0) = Array(n.toInt()) { doubleAry(m, init) }\nfun boolAry2(n: Long, m: Long, init: Boolean = false) = Array(n.toInt()) { boolAry(m, init) }\nfun ary3(n: Long, m: Long, k: Long, init: String = \"\") = Array(n.toInt()) { ary2(m, k, init) }\nfun longAry3(n: Long, m: Long, k: Long, init: Long = 0L) = Array(n.toInt()) { longAry2(m, k, init) }\nfun doubleAry3(n: Long, m: Long, k: Long, init: Double = 0.0) = Array(n.toInt()) { doubleAry2(m, k, init) }\nfun boolAry3(n: Long, m: Long, k: Long, init: Boolean = false) = Array(n.toInt()) { boolAry2(m, k, init) }\nfun list() = mutableListOf()\nfun longList() = mutableListOf()\nfun doubleList() = mutableListOf()\nfun strSet() = mutableSetOf()\nfun longSet() = mutableSetOf()\nfun doubleSet() = mutableSetOf()\nfun map() = mutableMapOf()\n\n// Monoid\nval addFunc = {a: Long, b: Long -> a + b}\nval mulFunc = {a: Long, b: Long -> a * b}\nval maxFunc = {a: Long, b: Long -> max(a, b)}\nval minFunc = {a: Long, b: Long -> min(a, b)}\nval gcdFunc = {a: Long, b: Long -> gcd(a, b)}\nval lcmFunc = {a: Long, b: Long -> lcm(a, b)}\nval xorFunc = {a: Long, b: Long -> a xor b}\nfun calc(a: Long, b: Long, op: (Long, Long) -> Long) = op(a, b)\n\n// Extension\nfun LongArray.lowerBound(n: Long): Long {\n var ok = this.size.toLong()\n var ng = -1L\n while (abs(ok - ng) > 1) {\n val mid = (ok + ng) / 2\n if (this[mid] >= n) ok = mid\n else ng = mid\n }\n return ok\n}\nfun DoubleArray.lowerBound(n: Double): Long {\n var ok = this.size.toLong()\n var ng = -1L\n while (abs(ok - ng) > 1) {\n val mid = (ok + ng) / 2\n if (this[mid] >= n) ok = mid\n else ng = mid\n }\n return ok\n}\nfun MutableList.longLowerBound(n: Long): Long {\n var ok = this.size.toLong()\n var ng = -1L\n while (abs(ok - ng) > 1) {\n val mid = (ok + ng) / 2\n if (this[mid] >= n) ok = mid\n else ng = mid\n }\n return ok\n}\nfun MutableList.doubleLowerBound(n: Double): Long {\n var ok = this.size.toLong()\n var ng = -1L\n while (abs(ok - ng) > 1) {\n val mid = (ok + ng) / 2\n if (this[mid] >= n) ok = mid\n else ng = mid\n }\n return ok\n}\nfun LongArray.cumsum(op: (Long, Long) -> Long): LongArray {\n val s = longAry(this.size + 1L)\n s[1] = this[0]\n for (i in 1 until this.size) s[i + 1] = calc(s[i], this[i], op)\n return s\n}\nfun MutableMap.counting(n: Long) {\n repeat(n.toInt()) {\n val a = next()\n if (this.containsKey(a)) this[a] = this[a]!! + 1\n else this[a] = 1\n }\n}\nfun MutableMap.longCounting(n: Long) {\n repeat(n.toInt()) {\n val a = nextLong()\n if (this.containsKey(a)) this[a] = this[a]!! + 1\n else this[a] = 1\n }\n}\n\n// Mathematics\nfun abs(n: Long): Long = Math.abs(n)\nfun abs(n: Double): Double = Math.abs(n)\nfun max(vararg values: Long) = if (values.isEmpty()) -INF else values.max()!!\nfun min(vararg values: Long) = if (values.isEmpty()) INF else values.min()!!\ntailrec fun gcd(a: Long, b: Long): Long = if (b == 0L) a else if (a % b == 0L) b else gcd(b, (a % b))\nfun lcm(a: Long, b: Long): Long = a / gcd(a, b) * b\nfun modpow(a: Long, n: Long, p: Long = MOD): Long {\n var res = 1L\n var ar = a\n var nr = n\n while (nr > 0) {\n if ((nr and 1) == 1L) res = res * ar % p\n ar = ar * ar % p\n nr = nr shr 1\n }\n return res\n}\nfun modinv(a: Long, p: Long = MOD): Long = modpow(a, p - 2, p)\nfun ncr(n: Long, r: Long): Long {\n var a = 1L\n var b = 1L\n for (i in 1..r) {\n a = a * (n + 1 - i) % MOD\n b = b * i % MOD\n }\n return modinv(b, MOD) * a % MOD\n}\n\nclass Combination(private val max: Long) {\n private val fac = longAry(max)\n private val finv = longAry(max)\n private val inv = longAry(max)\n private val p = MOD\n fun init() {\n fac[0] = 1\n fac[1] = 1\n finv[0] = 1\n finv[1] = 1\n inv[1] = 1\n for (i in 2 until max) {\n fac[i] = fac[i - 1] * i % p\n inv[i] = p - inv[p % i] * (p / i) % p;\n finv[i] = finv[i - 1] * inv[i] % p\n }\n }\n\n fun com(n: Long, r: Long): Long = if (n < r || (n < 0 || r < 0)) 0L else fac[n] * (finv[r] * finv[n - r] % p) % p\n}\n\nclass Permutation(private val n: Long, private var searched: Long = 0L, private var nextIndex: Long = 0L) {\n private val size = fact(n)\n private val permList = longAry2(size, n)\n\n private tailrec fun fact(n: Long, ans: Long = 1L): Long {\n return if (n == 0L) ans\n else fact(n - 1, ans * n)\n }\n\n fun init() {\n create(0, longAry(n), boolAry(n))\n }\n\n private fun create(num: Long, list: LongArray, flag: Array) {\n if (num == n) {\n permList[searched] = list.copyOf()\n searched++\n }\n for (i in 0 until n) {\n if (flag[i]) continue\n list[num] = i\n flag[i] = true\n create(num + 1, list, flag)\n flag[i] = false\n }\n }\n\n fun hasNext(): Boolean {\n return if (nextIndex < size) {\n true\n } else {\n nextIndex = 0\n false\n }\n }\n\n fun nextPerm(): LongArray = permList[nextIndex++]\n}\n\n// Graph\ndata class Node(val id: Long, var past: Long = -1, val edges: MutableList = mutableListOf())\ndata class Edge(val from: Long, val to: Long, val cost: Long = 1L)\n\nfun dfs(nodes: Array, now: Long, seen: Array) {\n seen[now] = true\n for (edge in nodes[now].edges) {\n if (seen[edge.to]) continue\n dfs(nodes, edge.to, seen)\n }\n}\n\nfun bfs(nodes: Array, start: Long): LongArray {\n val queue = ArrayDeque()\n queue.add(start)\n val dist = longAry(nodes.size.toLong(), -1L)\n dist[start] = 0L\n while (queue.isNotEmpty()) {\n val now = queue.poll()\n for (edge in nodes[now].edges) {\n if (dist[edge.to] != -1L) continue\n dist[edge.to] = dist[now] + 1\n queue.add(edge.to)\n }\n }\n return dist\n}\n\nfun dijkstra(nodes: Array, start: Long): LongArray {\n val queue = PriorityQueue(16) { e1: Edge, e2: Edge ->\n return@PriorityQueue when {\n e1.cost < e2.cost -> -1\n e2.cost > e1.cost -> 1\n else -> 0\n }\n }\n queue.add(Edge(start, start, 0L))\n val dist = longAry(nodes.size.toLong(), INF / 2)\n dist[start] = 0\n while (queue.isNotEmpty()) {\n val now = queue.poll()\n if (dist[now.to] < now.cost) continue;\n for (edge in nodes[now.to].edges) {\n if (dist[edge.to] <= dist[edge.from] + edge.cost) continue\n dist[edge.to] = dist[edge.from] + edge.cost\n queue.add(Edge(edge.from, edge.to, dist[edge.to]))\n nodes[edge.to].past = edge.from\n }\n }\n return dist\n}\n\n// Data Structure\nclass UnionFind(size: Long) {\n private val par = LongArray(size.toInt()) { it.toLong() }\n private val size = longAry(size, 1L)\n fun root(x: Long): Long {\n return if (par[x] == x) {\n x\n } else {\n par[x] = root(par[x])\n par[x]\n }\n }\n\n fun same(x: Long, y: Long): Boolean = root(x) == root(y)\n fun unite(x: Long, y: Long) {\n var a = root(x)\n var b = root(y)\n if (a == b) return\n if (size[a] < size[b]) {\n var tmp = a\n a = b\n b = tmp\n }\n size[a] += size[b]\n par[b] = a\n }\n\n fun size(x: Long): Long = size[root(x)]\n}\n\nclass SegmentTree(\n private val a: LongArray,\n private val op: (Long, Long) -> Long,\n private val def: Long = 0,\n private val size: Int = a.size,\n private val n: Int = Integer.highestOneBit(size) shl 1\n) {\n private val nodes = longAry(2L * n - 1, def)\n\n fun init() {\n for (i in 0 until size) nodes[i + n - 1] = a[i]\n for (i in n - 2 downTo 0) nodes[i] = calc(nodes[2 * i + 1], nodes[2 * i + 2], op)\n }\n\n fun update(x: Long, value: Long) {\n var index = x + n - 1\n nodes[index] = value\n while (index > 0) {\n index = (index - 1) / 2\n nodes[index] = calc(nodes[2 * index + 1], nodes[2 * index + 2], op)\n }\n }\n\n fun get(a: Long, b: Long) = getSub(a, b, 0L, 0L, n.toLong())\n private fun getSub(a: Long, b: Long, k: Long, l: Long, r: Long): Long {\n return when {\n r <= a || b <= l -> def\n a <= l && r <= b -> nodes[k]\n else -> {\n val vl = getSub(a, b, k * 2 + 1, l, (l + r) / 2)\n val vr = getSub(a, b, k * 2 + 2, (l + r) / 2, r)\n calc(vl, vr, op)\n }\n }\n }\n\n fun joinToString(separator: String) = nodes.drop(n - 1).take(size).joinToString(separator)\n}\n\n// Scanner\nclass FastScanner {\n private val sin: InputStream = System.`in`\n private val buffer: ByteArray = ByteArray(1024) { 0 }\n private var ptr = 0\n private var buflen = 0\n\n private fun hasNextByte(): Boolean {\n return when {\n ptr < buflen -> true\n else -> {\n ptr = 0\n buflen = sin.read(buffer)\n buflen > 0\n }\n }\n }\n\n private fun readByte(): Int {\n return when {\n hasNextByte() -> buffer[ptr++].toInt()\n else -> -1\n }\n }\n\n private fun isPrintableChar(c: Int) = c in 33..126\n\n fun hasNext(): Boolean {\n while (hasNextByte() && !isPrintableChar(buffer[ptr].toInt())) ptr++\n return hasNextByte()\n }\n\n fun next(): String {\n if (!hasNext()) throw NoSuchElementException()\n val sb = StringBuilder()\n var b = readByte()\n while (isPrintableChar(b)) {\n sb.appendCodePoint(b)\n b = readByte()\n }\n return sb.toString()\n }\n\n fun nextLong(): Long {\n if (!hasNext()) throw NoSuchElementException()\n var n = 0L\n var minus = false\n var b = readByte()\n if (b.toChar() == '-') {\n minus = true\n b = readByte()\n }\n if (b.toChar() !in '0'..'9') throw NumberFormatException()\n while (true) {\n when {\n b.toChar() in '0'..'9' -> {\n n *= 10\n n += b.toChar() - '0'\n }\n b == -1 || !isPrintableChar(b) -> return if (minus) -n else n\n else -> throw NumberFormatException()\n }\n b = readByte()\n }\n }\n\n// \"The world doesn't need you.\"\n//\n// fun nextInt(): Int {\n// val nl = nextLong()\n// if (nl !in Int.MIN_VALUE..Int.MAX_VALUE) throw NumberFormatException()\n// return nl.toInt()\n// }\n}", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 14334, "cpu_time_ms": 186, "memory_kb": 31404}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s165944213", "group_id": "codeNet:p02963", "input_text": "import java.util.NoSuchElementException\nimport java.io.IOException\n\nfun main(args : Array) {\n val scanner = FastScanner()\n val S = scanner.nextLong()\n val ap = S + 1L\n var i = (Math.sqrt(ap.toDouble())).toLong()\n var a = 0L\n var p = 0L\n while (i >= 1) {\n if (ap % i == 0L) {\n a = i\n p = ap/ i\n break\n }\n i--\n }\n println(\"0 0 \" + a.toString() + \" 1 1 \" + p.toString())\n}\n\ninternal class FastScanner {\n private val `in` = System.`in`\n private val buffer = ByteArray(1024)\n private var ptr = 0\n private var buflen = 0\n private fun hasNextByte(): Boolean {\n if (ptr < buflen) {\n return true\n } else {\n ptr = 0\n try {\n buflen = `in`.read(buffer)\n } catch (e: IOException) {\n e.printStackTrace()\n }\n\n if (buflen <= 0) {\n return false\n }\n }\n return true\n }\n\n private fun readByte(): Int {\n return if (hasNextByte()) buffer[ptr++].toInt() else -1\n }\n\n private fun isPrintableChar(c: Int): Boolean {\n return 33 <= c && c <= 126\n }\n\n private fun skipUnprintable() {\n while (hasNextByte() && !isPrintableChar(buffer[ptr].toInt())) ptr++\n }\n\n operator fun hasNext(): Boolean {\n skipUnprintable()\n return hasNextByte()\n }\n\n operator fun next(): String {\n if (!hasNext()) throw NoSuchElementException()\n val sb = StringBuilder()\n var b = readByte()\n while (isPrintableChar(b)) {\n sb.appendCodePoint(b)\n b = readByte()\n }\n return sb.toString()\n }\n\n fun nextLong(): Long {\n if (!hasNext()) throw NoSuchElementException()\n var n: Long = 0\n var minus = false\n var b = readByte()\n if (b == '-'.toInt()) {\n minus = true\n b = readByte()\n }\n if (b < '0'.toInt() || '9'.toInt() < b) {\n throw NumberFormatException()\n }\n while (true) {\n if ('0'.toInt() <= b && b <= '9'.toInt()) {\n n *= 10\n n += (b - '0'.toInt()).toLong()\n } else return if (b == -1 || !isPrintableChar(b)) {\n if (minus) -n else n\n } else {\n throw NumberFormatException()\n }\n b = readByte()\n }\n }\n}", "language": "Kotlin", "metadata": {"date": 1563763175, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02963.html", "problem_id": "p02963", "resource_group": "medium_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/Kotlin/s165944213.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s165944213", "user_id": "u465133507"}, "prompt_components": {"gold_output": "1 0 2 2 0 1\n", "input_to_evaluate": "import java.util.NoSuchElementException\nimport java.io.IOException\n\nfun main(args : Array) {\n val scanner = FastScanner()\n val S = scanner.nextLong()\n val ap = S + 1L\n var i = (Math.sqrt(ap.toDouble())).toLong()\n var a = 0L\n var p = 0L\n while (i >= 1) {\n if (ap % i == 0L) {\n a = i\n p = ap/ i\n break\n }\n i--\n }\n println(\"0 0 \" + a.toString() + \" 1 1 \" + p.toString())\n}\n\ninternal class FastScanner {\n private val `in` = System.`in`\n private val buffer = ByteArray(1024)\n private var ptr = 0\n private var buflen = 0\n private fun hasNextByte(): Boolean {\n if (ptr < buflen) {\n return true\n } else {\n ptr = 0\n try {\n buflen = `in`.read(buffer)\n } catch (e: IOException) {\n e.printStackTrace()\n }\n\n if (buflen <= 0) {\n return false\n }\n }\n return true\n }\n\n private fun readByte(): Int {\n return if (hasNextByte()) buffer[ptr++].toInt() else -1\n }\n\n private fun isPrintableChar(c: Int): Boolean {\n return 33 <= c && c <= 126\n }\n\n private fun skipUnprintable() {\n while (hasNextByte() && !isPrintableChar(buffer[ptr].toInt())) ptr++\n }\n\n operator fun hasNext(): Boolean {\n skipUnprintable()\n return hasNextByte()\n }\n\n operator fun next(): String {\n if (!hasNext()) throw NoSuchElementException()\n val sb = StringBuilder()\n var b = readByte()\n while (isPrintableChar(b)) {\n sb.appendCodePoint(b)\n b = readByte()\n }\n return sb.toString()\n }\n\n fun nextLong(): Long {\n if (!hasNext()) throw NoSuchElementException()\n var n: Long = 0\n var minus = false\n var b = readByte()\n if (b == '-'.toInt()) {\n minus = true\n b = readByte()\n }\n if (b < '0'.toInt() || '9'.toInt() < b) {\n throw NumberFormatException()\n }\n while (true) {\n if ('0'.toInt() <= b && b <= '9'.toInt()) {\n n *= 10\n n += (b - '0'.toInt()).toLong()\n } else return if (b == -1 || !isPrintableChar(b)) {\n if (minus) -n else n\n } else {\n throw NumberFormatException()\n }\n b = readByte()\n }\n }\n}", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2452, "cpu_time_ms": 2111, "memory_kb": 31396}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s995602393", "group_id": "codeNet:p02969", "input_text": "fun main(args: Array) {\n val r = readLine()!!.toInt()\n println(3 * r * r)\n}\n", "language": "Kotlin", "metadata": {"date": 1563670868, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02969.html", "problem_id": "p02969", "resource_group": "medium_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/Kotlin/s995602393.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s995602393", "user_id": "u051841332"}, "prompt_components": {"gold_output": "48\n", "input_to_evaluate": "fun main(args: Array) {\n val r = readLine()!!.toInt()\n println(3 * r * r)\n}\n", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 219, "memory_kb": 31704}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s856393668", "group_id": "codeNet:p02969", "input_text": "fun main(args: Array) {\n val r = readInputLine().toInt()\n \n println(3 * r * r)\n}\n\nfun readInputLine(): String {\n return readLine()!!\n}\n", "language": "Kotlin", "metadata": {"date": 1563670849, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02969.html", "problem_id": "p02969", "resource_group": "medium_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/Kotlin/s856393668.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s856393668", "user_id": "u505558493"}, "prompt_components": {"gold_output": "48\n", "input_to_evaluate": "fun main(args: Array) {\n val r = readInputLine().toInt()\n \n println(3 * r * r)\n}\n\nfun readInputLine(): String {\n return readLine()!!\n}\n", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 218, "memory_kb": 31740}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s186589984", "group_id": "codeNet:p02970", "input_text": "fun main(args:Array){\n var (a,b) = readLine()!!.split(\" \").map{it.toInt()}\n var ans = a/(2*b+1)\n var key = a%(2*b+1)\n if(key==0)println(ans)\n else println(ans+1)\n}\n ", "language": "Kotlin", "metadata": {"date": 1570809865, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02970.html", "problem_id": "p02970", "resource_group": "medium_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/Kotlin/s186589984.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s186589984", "user_id": "u648912196"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "fun main(args:Array){\n var (a,b) = readLine()!!.split(\" \").map{it.toInt()}\n var ans = a/(2*b+1)\n var key = a%(2*b+1)\n if(key==0)println(ans)\n else println(ans+1)\n}\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 233, "memory_kb": 37776}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s614836814", "group_id": "codeNet:p02971", "input_text": "fun main(args: Array) {\n val n = readLine()?.toInt() ?: return\n val a = 0.until(n).map {\n readLine()?.toInt() ?: return\n }\n val aa = a.sortedDescending()\n val f = aa[0]\n val s = aa[1]\n buildString {\n a.forEach {\n if (it == f) {\n appendln(s.toString())\n } else {\n appendln(f.toString())\n }\n }\n }.let {\n println(it.trimIndent())\n }\n}\n", "language": "Kotlin", "metadata": {"date": 1592072380, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02971.html", "problem_id": "p02971", "resource_group": "medium_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/Kotlin/s614836814.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s614836814", "user_id": "u979429407"}, "prompt_components": {"gold_output": "4\n3\n4\n", "input_to_evaluate": "fun main(args: Array) {\n val n = readLine()?.toInt() ?: return\n val a = 0.until(n).map {\n readLine()?.toInt() ?: return\n }\n val aa = a.sortedDescending()\n val f = aa[0]\n val s = aa[1]\n buildString {\n a.forEach {\n if (it == f) {\n appendln(s.toString())\n } else {\n appendln(f.toString())\n }\n }\n }.let {\n println(it.trimIndent())\n }\n}\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 458, "cpu_time_ms": 1150, "memory_kb": 106028}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s695578984", "group_id": "codeNet:p02971", "input_text": "fun main(args: Array){\n val n = readLine()!!.toInt()\n var a = arrayListOf()\n for (i in 0 until n){\n a.add(readLine()!!.toInt())\n }\n val m_1 = a.max()\n val s = a.filter{ it == m_1 }.size\n if (s >= 2) for (i in 0 until n) println(m_1)\n if (s == 1) {\n val idx = a.indexOf(m_1)\n var b = a.toMutableList()\n b.removeAt(idx)\n val m_2 = b.max()\n for (i in 0 until n) {\n if (i == idx) println(m_2) else println(m_1)\n }\n }\n}\n", "language": "Kotlin", "metadata": {"date": 1569890859, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02971.html", "problem_id": "p02971", "resource_group": "medium_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/Kotlin/s695578984.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s695578984", "user_id": "u454524105"}, "prompt_components": {"gold_output": "4\n3\n4\n", "input_to_evaluate": "fun main(args: Array){\n val n = readLine()!!.toInt()\n var a = arrayListOf()\n for (i in 0 until n){\n a.add(readLine()!!.toInt())\n }\n val m_1 = a.max()\n val s = a.filter{ it == m_1 }.size\n if (s >= 2) for (i in 0 until n) println(m_1)\n if (s == 1) {\n val idx = a.indexOf(m_1)\n var b = a.toMutableList()\n b.removeAt(idx)\n val m_2 = b.max()\n for (i in 0 until n) {\n if (i == idx) println(m_2) else println(m_1)\n }\n }\n}\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 515, "cpu_time_ms": 1430, "memory_kb": 59376}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s814359150", "group_id": "codeNet:p02971", "input_text": "fun main(args: Array) {\n val N = readLine()!!.toInt()\n val A = Array(N) {readLine()!!.toInt()}\n val (max0,max1) = A.sortedDescending().take(2)\n val list = mutableListOf()\n for (a in A)\n list.add(if(max0 != a) max0 else max1)\n println(list.joinToString(\"\\n\"))\n}", "language": "Kotlin", "metadata": {"date": 1568066151, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02971.html", "problem_id": "p02971", "resource_group": "medium_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/Kotlin/s814359150.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s814359150", "user_id": "u491462774"}, "prompt_components": {"gold_output": "4\n3\n4\n", "input_to_evaluate": "fun main(args: Array) {\n val N = readLine()!!.toInt()\n val A = Array(N) {readLine()!!.toInt()}\n val (max0,max1) = A.sortedDescending().take(2)\n val list = mutableListOf()\n for (a in A)\n list.add(if(max0 != a) max0 else max1)\n println(list.joinToString(\"\\n\"))\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 298, "cpu_time_ms": 898, "memory_kb": 64924}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s307339159", "group_id": "codeNet:p02971", "input_text": "import java.util.Scanner\n\nfun main(args:Array) {\n val sc = Scanner(System.`in`)\n val n = sc.nextInt()\n val leftmax = IntArray(n)\n val rightmax = IntArray(n)\n val num = IntArray(n)\n leftmax[0] = 0\n rightmax[n - 1] = 0\n for (i in 0 until n) {\n num[i] = sc.nextInt()\n }\n for (i in 1 until n) {\n leftmax[i] = Math.max(leftmax[i - 1], num[i - 1])\n }\n for (i in n - 1 downTo 1) {\n rightmax[i - 1] = Math.max(rightmax[i], num[i])\n }\n for (i in 0 until n) {\n println(Math.max(leftmax[i], rightmax[i]))\n }\n}\n", "language": "Kotlin", "metadata": {"date": 1565758900, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02971.html", "problem_id": "p02971", "resource_group": "medium_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/Kotlin/s307339159.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s307339159", "user_id": "u913110564"}, "prompt_components": {"gold_output": "4\n3\n4\n", "input_to_evaluate": "import java.util.Scanner\n\nfun main(args:Array) {\n val sc = Scanner(System.`in`)\n val n = sc.nextInt()\n val leftmax = IntArray(n)\n val rightmax = IntArray(n)\n val num = IntArray(n)\n leftmax[0] = 0\n rightmax[n - 1] = 0\n for (i in 0 until n) {\n num[i] = sc.nextInt()\n }\n for (i in 1 until n) {\n leftmax[i] = Math.max(leftmax[i - 1], num[i - 1])\n }\n for (i in n - 1 downTo 1) {\n rightmax[i - 1] = Math.max(rightmax[i], num[i])\n }\n for (i in 0 until n) {\n println(Math.max(leftmax[i], rightmax[i]))\n }\n}\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 580, "cpu_time_ms": 1571, "memory_kb": 83168}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s621857545", "group_id": "codeNet:p02971", "input_text": "import java.io.PrintWriter\nval pw = PrintWriter(System.out)\nfun main(args : Array) {\n func()\n pw.flush()\n}\n\n fun func() {\n val n = nextInt()\n var index = 0\n var max = 0\n var oldMax = 0\n var count = 0\n for(i in 0 until n){\n val a = nextInt()\n if(a>max){\n index = i\n oldMax = max\n max = a\n count = 1\n }else{\n if(a == max){\n count = 2\n }\n }\n }\n for(i in 0 until n){\n if(count > 1){\n println(max)\n }else{\n if(i!=index){\n println(max)\n }else{\n println(oldMax)\n }\n }\n }\n }\n\n// 入力取得\nfun next() = readLine()!!\nfun nextInt() = next().toInt()\nfun nextLong() = next().toLong()\nfun nextDouble() = next().toDouble()\nfun listOfString() = next().split(\" \")\nfun listOfInt() =listOfString().map { it.toInt() }\nfun listOfLong() =listOfString().map { it.toLong() }\nfun listOfDouble() =listOfString().map { it.toDouble() }\n\n// 約数のList\nfun divisor(value : Long) : List {\n val max = Math.sqrt(value.toDouble()).toLong()\n return (1..max)\n .filter { value % it == 0L }\n .map { listOf(it, value / it) }\n .flatten()\n .sorted()\n}\n\n// 範囲内の素数を取得\n// fromだけ指定すると戻り値の個数で素数判定ができる\nfun prime(from : Long, to : Long = from) : List {\n return (from..to).filter { i ->\n val max = Math.sqrt(i.toDouble()).toLong()\n (2..max).all { j -> i % j != 0L }\n }\n}\n\n// 素因数分解\nfun decom(value : Long) : List{\n if (value == 1L) return listOf(1)\n val max = Math.sqrt(value.toDouble()).toLong()\n return prime(2, max).filter { value % it == 0L }\n}\n\n// 最大公約数\nfun gcd(a : Long, b : Long) : Long {\n return if (a % b == 0L) b else gcd(b, a % b)\n}\n\n// 文字列を入れ替え\nfun swap(base : String, a : String, b : String) : String {\n return base.map {\n when (it) {\n a.toCharArray()[0] -> b\n b.toCharArray()[0] -> a\n else -> it.toString()\n }\n }.joinToString()\n}\n\nfun println(value : Any) {\n pw.println(value)\n}\n", "language": "Kotlin", "metadata": {"date": 1563673322, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02971.html", "problem_id": "p02971", "resource_group": "medium_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/Kotlin/s621857545.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s621857545", "user_id": "u957679320"}, "prompt_components": {"gold_output": "4\n3\n4\n", "input_to_evaluate": "import java.io.PrintWriter\nval pw = PrintWriter(System.out)\nfun main(args : Array) {\n func()\n pw.flush()\n}\n\n fun func() {\n val n = nextInt()\n var index = 0\n var max = 0\n var oldMax = 0\n var count = 0\n for(i in 0 until n){\n val a = nextInt()\n if(a>max){\n index = i\n oldMax = max\n max = a\n count = 1\n }else{\n if(a == max){\n count = 2\n }\n }\n }\n for(i in 0 until n){\n if(count > 1){\n println(max)\n }else{\n if(i!=index){\n println(max)\n }else{\n println(oldMax)\n }\n }\n }\n }\n\n// 入力取得\nfun next() = readLine()!!\nfun nextInt() = next().toInt()\nfun nextLong() = next().toLong()\nfun nextDouble() = next().toDouble()\nfun listOfString() = next().split(\" \")\nfun listOfInt() =listOfString().map { it.toInt() }\nfun listOfLong() =listOfString().map { it.toLong() }\nfun listOfDouble() =listOfString().map { it.toDouble() }\n\n// 約数のList\nfun divisor(value : Long) : List {\n val max = Math.sqrt(value.toDouble()).toLong()\n return (1..max)\n .filter { value % it == 0L }\n .map { listOf(it, value / it) }\n .flatten()\n .sorted()\n}\n\n// 範囲内の素数を取得\n// fromだけ指定すると戻り値の個数で素数判定ができる\nfun prime(from : Long, to : Long = from) : List {\n return (from..to).filter { i ->\n val max = Math.sqrt(i.toDouble()).toLong()\n (2..max).all { j -> i % j != 0L }\n }\n}\n\n// 素因数分解\nfun decom(value : Long) : List{\n if (value == 1L) return listOf(1)\n val max = Math.sqrt(value.toDouble()).toLong()\n return prime(2, max).filter { value % it == 0L }\n}\n\n// 最大公約数\nfun gcd(a : Long, b : Long) : Long {\n return if (a % b == 0L) b else gcd(b, a % b)\n}\n\n// 文字列を入れ替え\nfun swap(base : String, a : String, b : String) : String {\n return base.map {\n when (it) {\n a.toCharArray()[0] -> b\n b.toCharArray()[0] -> a\n else -> it.toString()\n }\n }.joinToString()\n}\n\nfun println(value : Any) {\n pw.println(value)\n}\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2355, "cpu_time_ms": 430, "memory_kb": 44064}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s845330361", "group_id": "codeNet:p02971", "input_text": "import java.io.PrintWriter\nimport java.util.*\nimport java.math.*\nimport java.lang.*\n\nval pw = PrintWriter(System.out)\nval MOD: Long = (1e+9 + 7).toLong()\n\nfun main(args: Array) {\n val n = readInt()\n val a = mutableListOf()\n for(i in 0 until n) {\n a.add(readInt())\n }\n val sortedA = a.sorted().reversed()\n for(i in 0 until n) {\n val ans = if(a[i] != sortedA[0]) sortedA[0] else sortedA[1]\n println(ans)\n }\n\n pw.flush()\n}\n\n/****** Decrared Functions and Data Structures ******/\n// IO\nfun read() = readLine()!!\nfun readInt() = read().toInt()\nfun readLong() = read().toLong()\nfun readDouble() = read().toDouble()\nfun readListOfString() = read().split(\" \")\nfun readListOfInt() = readListOfString().map { it.toInt() }\nfun readListOfLong() = readListOfString().map { it.toLong() }\nfun readListOfDouble() = readListOfString().map { it.toDouble() }\n\nfun Double.format(digits: Int) = String.format(\"%.${digits}f\", this)\n\nfun print(value: Any) { pw.print(value) }\nfun println(value : Any) { pw.println(value) }\n\nfun permutations(src: List): List> {\n if(src.size == 1) return listOf(src)\n val perms = mutableListOf>()\n val insertElement = src[0]\n permutations(src.drop(1)).forEach { perm ->\n for(i in 0..perm.size) {\n val newPerm = perm.toMutableList()\n newPerm.add(i, insertElement)\n perms.add(newPerm.toList())\n }\n }\n return perms\n}\n\n// return nCr, if you want nCr, please access v[n][r]\nfun combinations(n: Long): List> {\n val v = (0..n).map { (0..n).map{0L}.toMutableList() }.toMutableList()\n for(i in 0 until v.size) {\n v[i][0] = 1L\n v[i][i] = 1L\n }\n for(i in 0 until v.size) {\n for(j in 1 until i) {\n v[i][j] = (v[i-1][j-1] + v[i-1][j] % MOD)\n }\n }\n val rtn = v.map { it.toList() }.toList()\n return rtn \n}\n\nfun gcd(a: Long, b: Long): Long = \nif(b != 0L) a else gcd(b, a % b)\n\nfun lcm(a: Long, b: Long) = \nif(b==0L) a else gcd(b, a % b)\n\nfun sumDigits(num_: Long): Long {\n var num = num_\n var rtn: Long = 0\n while(num != 0.toLong()) {\n val tmp = num % 10\n rtn += tmp\n num /= 10\n }\n return rtn\n}\n\nfun isDecimal(v: Double): Boolean = ((v - Math.floor(v)) != 0.0)\n\n// Data Structures\nclass Stack(private var st: MutableList = mutableListOf()) {\n fun isEmpty() = st.isEmpty()\n fun top(): T = st.last()\n fun push(e: T) { st.add(e) }\n fun pop() { st = st.dropLast(1).toMutableList() }\n}\n\nclass Queue(private var que: MutableList = mutableListOf()) {\n fun isEmpty() = que.isEmpty()\n fun top(): T = que.first()\n fun push(e: T) { que.add(e) }\n fun pop() { que = que.drop(1).toMutableList() }\n}\n", "language": "Kotlin", "metadata": {"date": 1563671316, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02971.html", "problem_id": "p02971", "resource_group": "medium_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/Kotlin/s845330361.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s845330361", "user_id": "u026686258"}, "prompt_components": {"gold_output": "4\n3\n4\n", "input_to_evaluate": "import java.io.PrintWriter\nimport java.util.*\nimport java.math.*\nimport java.lang.*\n\nval pw = PrintWriter(System.out)\nval MOD: Long = (1e+9 + 7).toLong()\n\nfun main(args: Array) {\n val n = readInt()\n val a = mutableListOf()\n for(i in 0 until n) {\n a.add(readInt())\n }\n val sortedA = a.sorted().reversed()\n for(i in 0 until n) {\n val ans = if(a[i] != sortedA[0]) sortedA[0] else sortedA[1]\n println(ans)\n }\n\n pw.flush()\n}\n\n/****** Decrared Functions and Data Structures ******/\n// IO\nfun read() = readLine()!!\nfun readInt() = read().toInt()\nfun readLong() = read().toLong()\nfun readDouble() = read().toDouble()\nfun readListOfString() = read().split(\" \")\nfun readListOfInt() = readListOfString().map { it.toInt() }\nfun readListOfLong() = readListOfString().map { it.toLong() }\nfun readListOfDouble() = readListOfString().map { it.toDouble() }\n\nfun Double.format(digits: Int) = String.format(\"%.${digits}f\", this)\n\nfun print(value: Any) { pw.print(value) }\nfun println(value : Any) { pw.println(value) }\n\nfun permutations(src: List): List> {\n if(src.size == 1) return listOf(src)\n val perms = mutableListOf>()\n val insertElement = src[0]\n permutations(src.drop(1)).forEach { perm ->\n for(i in 0..perm.size) {\n val newPerm = perm.toMutableList()\n newPerm.add(i, insertElement)\n perms.add(newPerm.toList())\n }\n }\n return perms\n}\n\n// return nCr, if you want nCr, please access v[n][r]\nfun combinations(n: Long): List> {\n val v = (0..n).map { (0..n).map{0L}.toMutableList() }.toMutableList()\n for(i in 0 until v.size) {\n v[i][0] = 1L\n v[i][i] = 1L\n }\n for(i in 0 until v.size) {\n for(j in 1 until i) {\n v[i][j] = (v[i-1][j-1] + v[i-1][j] % MOD)\n }\n }\n val rtn = v.map { it.toList() }.toList()\n return rtn \n}\n\nfun gcd(a: Long, b: Long): Long = \nif(b != 0L) a else gcd(b, a % b)\n\nfun lcm(a: Long, b: Long) = \nif(b==0L) a else gcd(b, a % b)\n\nfun sumDigits(num_: Long): Long {\n var num = num_\n var rtn: Long = 0\n while(num != 0.toLong()) {\n val tmp = num % 10\n rtn += tmp\n num /= 10\n }\n return rtn\n}\n\nfun isDecimal(v: Double): Boolean = ((v - Math.floor(v)) != 0.0)\n\n// Data Structures\nclass Stack(private var st: MutableList = mutableListOf()) {\n fun isEmpty() = st.isEmpty()\n fun top(): T = st.last()\n fun push(e: T) { st.add(e) }\n fun pop() { st = st.dropLast(1).toMutableList() }\n}\n\nclass Queue(private var que: MutableList = mutableListOf()) {\n fun isEmpty() = que.isEmpty()\n fun top(): T = que.first()\n fun push(e: T) { que.add(e) }\n fun pop() { que = que.drop(1).toMutableList() }\n}\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2772, "cpu_time_ms": 848, "memory_kb": 57628}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s152097782", "group_id": "codeNet:p02972", "input_text": "fun main() {\n abc134d()\n}\n\nfun abc134d() {\n val n = readLine()!!.toInt()\n // 各桁について、1ならiの倍数が奇数個になるようにするという意味\n val a = BooleanArray(n + 1) { false }\n for ((i, s) in readLine()!!.split(\" \").withIndex()) {\n a[i + 1] = s == \"1\"\n }\n val ans = mutableSetOf()\n var i = n\n while (i > 1) {\n var j = i\n while (j * j > i) {\n val k = j * 2\n val isOdd = k in ans\n if (a[j]) {\n if (!isOdd) ans.add(j)\n } else {\n if (isOdd) ans.add(j)\n }\n j--\n }\n i = j\n }\n if (a[1]) {\n if (ans.size % 2 == 0) ans.add(1)\n } else {\n if (ans.size % 2 == 1) ans.add(1)\n }\n println(ans.size)\n println(ans.joinToString(\" \"))\n}", "language": "Kotlin", "metadata": {"date": 1593948478, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02972.html", "problem_id": "p02972", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02972/input.txt", "sample_output_relpath": "derived/input_output/data/p02972/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02972/Kotlin/s152097782.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s152097782", "user_id": "u628907033"}, "prompt_components": {"gold_output": "1\n1\n", "input_to_evaluate": "fun main() {\n abc134d()\n}\n\nfun abc134d() {\n val n = readLine()!!.toInt()\n // 各桁について、1ならiの倍数が奇数個になるようにするという意味\n val a = BooleanArray(n + 1) { false }\n for ((i, s) in readLine()!!.split(\" \").withIndex()) {\n a[i + 1] = s == \"1\"\n }\n val ans = mutableSetOf()\n var i = n\n while (i > 1) {\n var j = i\n while (j * j > i) {\n val k = j * 2\n val isOdd = k in ans\n if (a[j]) {\n if (!isOdd) ans.add(j)\n } else {\n if (isOdd) ans.add(j)\n }\n j--\n }\n i = j\n }\n if (a[1]) {\n if (ans.size % 2 == 0) ans.add(1)\n } else {\n if (ans.size % 2 == 1) ans.add(1)\n }\n println(ans.size)\n println(ans.joinToString(\" \"))\n}", "problem_context": "Score : 400 points\n\nProblem Statement\n\nThere are N empty boxes arranged in a row from left to right.\nThe integer i is written on the i-th box from the left (1 \\leq i \\leq N).\n\nFor each of these boxes, Snuke can choose either to put a ball in it or to put nothing in it.\n\nWe say a set of choices to put a ball or not in the boxes is good when the following condition is satisfied:\n\nFor every integer i between 1 and N (inclusive), the total number of balls contained in the boxes with multiples of i written on them is congruent to a_i modulo 2.\n\nDoes there exist a good set of choices? If the answer is yes, find one good set of choices.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 2 \\times 10^5\n\na_i is 0 or 1.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 ... a_N\n\nOutput\n\nIf a good set of choices does not exist, print -1.\n\nIf a good set of choices exists, print one such set of choices in the following format:\n\nM\nb_1 b_2 ... b_M\n\nwhere M denotes the number of boxes that will contain a ball, and b_1,\\ b_2,\\ ...,\\ b_M are the integers written on these boxes, in any order.\n\nSample Input 1\n\n3\n1 0 0\n\nSample Output 1\n\n1\n1\n\nConsider putting a ball only in the box with 1 written on it.\n\nThere are three boxes with multiples of 1 written on them: the boxes with 1, 2, and 3. The total number of balls contained in these boxes is 1.\n\nThere is only one box with a multiple of 2 written on it: the box with 2. The total number of balls contained in these boxes is 0.\n\nThere is only one box with a multiple of 3 written on it: the box with 3. The total number of balls contained in these boxes is 0.\n\nThus, the condition is satisfied, so this set of choices is good.\n\nSample Input 2\n\n5\n0 0 0 0 0\n\nSample Output 2\n\n0\n\nPutting nothing in the boxes can be a good set of choices.", "sample_input": "3\n1 0 0\n"}, "reference_outputs": ["1\n1\n"], "source_document_id": "p02972", "source_text": "Score : 400 points\n\nProblem Statement\n\nThere are N empty boxes arranged in a row from left to right.\nThe integer i is written on the i-th box from the left (1 \\leq i \\leq N).\n\nFor each of these boxes, Snuke can choose either to put a ball in it or to put nothing in it.\n\nWe say a set of choices to put a ball or not in the boxes is good when the following condition is satisfied:\n\nFor every integer i between 1 and N (inclusive), the total number of balls contained in the boxes with multiples of i written on them is congruent to a_i modulo 2.\n\nDoes there exist a good set of choices? If the answer is yes, find one good set of choices.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 2 \\times 10^5\n\na_i is 0 or 1.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 ... a_N\n\nOutput\n\nIf a good set of choices does not exist, print -1.\n\nIf a good set of choices exists, print one such set of choices in the following format:\n\nM\nb_1 b_2 ... b_M\n\nwhere M denotes the number of boxes that will contain a ball, and b_1,\\ b_2,\\ ...,\\ b_M are the integers written on these boxes, in any order.\n\nSample Input 1\n\n3\n1 0 0\n\nSample Output 1\n\n1\n1\n\nConsider putting a ball only in the box with 1 written on it.\n\nThere are three boxes with multiples of 1 written on them: the boxes with 1, 2, and 3. The total number of balls contained in these boxes is 1.\n\nThere is only one box with a multiple of 2 written on it: the box with 2. The total number of balls contained in these boxes is 0.\n\nThere is only one box with a multiple of 3 written on it: the box with 3. The total number of balls contained in these boxes is 0.\n\nThus, the condition is satisfied, so this set of choices is good.\n\nSample Input 2\n\n5\n0 0 0 0 0\n\nSample Output 2\n\n0\n\nPutting nothing in the boxes can be a good set of choices.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 842, "cpu_time_ms": 2207, "memory_kb": 54972}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s173455889", "group_id": "codeNet:p02973", "input_text": "fun main(args: Array) {\n val N = readLine()!!.toInt()\n val C = IntArray(N) { 0 }\n var count = 1\n C[0] = readLine()!!.toInt()\n\n a@ for (i in 1 until N) {\n val A = readLine()!!.toInt()\n for (j in 0 until count) {\n if (C[j] < A) {\n C[j] = A\n continue@a\n }\n }\n C[count] = A\n count++\n }\n\n println(count)\n}", "language": "Kotlin", "metadata": {"date": 1563674676, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02973.html", "problem_id": "p02973", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02973/input.txt", "sample_output_relpath": "derived/input_output/data/p02973/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02973/Kotlin/s173455889.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s173455889", "user_id": "u771276989"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "fun main(args: Array) {\n val N = readLine()!!.toInt()\n val C = IntArray(N) { 0 }\n var count = 1\n C[0] = readLine()!!.toInt()\n\n a@ for (i in 1 until N) {\n val A = readLine()!!.toInt()\n for (j in 0 until count) {\n if (C[j] < A) {\n C[j] = A\n continue@a\n }\n }\n C[count] = A\n count++\n }\n\n println(count)\n}", "problem_context": "Score : 500 points\n\nProblem Statement\n\nYou are given a sequence with N integers: A = \\{ A_1, A_2, \\cdots, A_N \\}.\nFor each of these N integers, we will choose a color and paint the integer with that color. Here the following condition must be satisfied:\n\nIf A_i and A_j (i < j) are painted with the same color, A_i < A_j.\n\nFind the minimum number of colors required to satisfy the condition.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n0 \\leq A_i \\leq 10^9\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 minimum number of colors required to satisfy the condition.\n\nSample Input 1\n\n5\n2\n1\n4\n5\n3\n\nSample Output 1\n\n2\n\nWe can satisfy the condition with two colors by, for example, painting 2 and 3 red and painting 1, 4, and 5 blue.\n\nSample Input 2\n\n4\n0\n0\n0\n0\n\nSample Output 2\n\n4\n\nWe have to paint all the integers with distinct colors.", "sample_input": "5\n2\n1\n4\n5\n3\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02973", "source_text": "Score : 500 points\n\nProblem Statement\n\nYou are given a sequence with N integers: A = \\{ A_1, A_2, \\cdots, A_N \\}.\nFor each of these N integers, we will choose a color and paint the integer with that color. Here the following condition must be satisfied:\n\nIf A_i and A_j (i < j) are painted with the same color, A_i < A_j.\n\nFind the minimum number of colors required to satisfy the condition.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n0 \\leq A_i \\leq 10^9\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 minimum number of colors required to satisfy the condition.\n\nSample Input 1\n\n5\n2\n1\n4\n5\n3\n\nSample Output 1\n\n2\n\nWe can satisfy the condition with two colors by, for example, painting 2 and 3 red and painting 1, 4, and 5 blue.\n\nSample Input 2\n\n4\n0\n0\n0\n0\n\nSample Output 2\n\n4\n\nWe have to paint all the integers with distinct colors.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 2111, "memory_kb": 39368}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s018768146", "group_id": "codeNet:p02975", "input_text": "fun main(args: Array) {\n val n = readLine()!!.toInt()\n val aList = readLine()!!.split(' ').map(String::toLong)\n\n if (aList.all { it == 0L }) {\n println(\"Yes\")\n return\n }\n if (n % 3 != 0) {\n println(\"No\")\n return\n }\n\n val aGroup = aList.groupBy { it }\n if (aGroup.size == 2 && aGroup[0]!!.size == n / 3) {\n println(\"Yes\")\n return\n }\n if (aGroup.size == 3) {\n val (k1, k2, k3) = aGroup.keys.toList()\n if ((k1 xor k2 xor k3) == 0L\n && aGroup[k1]!!.size == aGroup[k2]!!.size\n && aGroup[k1]!!.size == aGroup[k3]!!.size) {\n println(\"Yes\")\n return\n }\n }\n println(\"No\")\n}", "language": "Kotlin", "metadata": {"date": 1563818964, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02975.html", "problem_id": "p02975", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02975/input.txt", "sample_output_relpath": "derived/input_output/data/p02975/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02975/Kotlin/s018768146.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s018768146", "user_id": "u099066216"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "fun main(args: Array) {\n val n = readLine()!!.toInt()\n val aList = readLine()!!.split(' ').map(String::toLong)\n\n if (aList.all { it == 0L }) {\n println(\"Yes\")\n return\n }\n if (n % 3 != 0) {\n println(\"No\")\n return\n }\n\n val aGroup = aList.groupBy { it }\n if (aGroup.size == 2 && aGroup[0]!!.size == n / 3) {\n println(\"Yes\")\n return\n }\n if (aGroup.size == 3) {\n val (k1, k2, k3) = aGroup.keys.toList()\n if ((k1 xor k2 xor k3) == 0L\n && aGroup[k1]!!.size == aGroup[k2]!!.size\n && aGroup[k1]!!.size == aGroup[k3]!!.size) {\n println(\"Yes\")\n return\n }\n }\n println(\"No\")\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nSnuke has N hats. The i-th hat has an integer a_i written on it.\n\nThere are N camels standing in a circle.\nSnuke will put one of his hats on each of these camels.\n\nIf there exists a way to distribute the hats to the camels such that the following condition is satisfied for every camel, print Yes; otherwise, print No.\n\nThe bitwise XOR of the numbers written on the hats on both adjacent camels is equal to the number on the hat on itself.\n\nWhat is XOR?\n\nThe bitwise XOR x_1 \\oplus x_2 \\oplus \\ldots \\oplus x_n of n non-negative integers x_1, x_2, \\ldots, x_n is defined as follows:\n\n- When x_1 \\oplus x_2 \\oplus \\ldots \\oplus 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 \\oplus 5 = 6.\n\nConstraints\n\nAll values in input are integers.\n\n3 \\leq N \\leq 10^{5}\n\n0 \\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 answer.\n\nSample Input 1\n\n3\n1 2 3\n\nSample Output 1\n\nYes\n\nIf we put the hats with 1, 2, and 3 in this order, clockwise, the condition will be satisfied for every camel, so the answer is Yes.\n\nSample Input 2\n\n4\n1 2 4 8\n\nSample Output 2\n\nNo\n\nThere is no such way to distribute the hats; the answer is No.", "sample_input": "3\n1 2 3\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p02975", "source_text": "Score : 300 points\n\nProblem Statement\n\nSnuke has N hats. The i-th hat has an integer a_i written on it.\n\nThere are N camels standing in a circle.\nSnuke will put one of his hats on each of these camels.\n\nIf there exists a way to distribute the hats to the camels such that the following condition is satisfied for every camel, print Yes; otherwise, print No.\n\nThe bitwise XOR of the numbers written on the hats on both adjacent camels is equal to the number on the hat on itself.\n\nWhat is XOR?\n\nThe bitwise XOR x_1 \\oplus x_2 \\oplus \\ldots \\oplus x_n of n non-negative integers x_1, x_2, \\ldots, x_n is defined as follows:\n\n- When x_1 \\oplus x_2 \\oplus \\ldots \\oplus 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 \\oplus 5 = 6.\n\nConstraints\n\nAll values in input are integers.\n\n3 \\leq N \\leq 10^{5}\n\n0 \\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 answer.\n\nSample Input 1\n\n3\n1 2 3\n\nSample Output 1\n\nYes\n\nIf we put the hats with 1, 2, and 3 in this order, clockwise, the condition will be satisfied for every camel, so the answer is Yes.\n\nSample Input 2\n\n4\n1 2 4 8\n\nSample Output 2\n\nNo\n\nThere is no such way to distribute the hats; the answer is No.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 722, "cpu_time_ms": 536, "memory_kb": 60080}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s927244956", "group_id": "codeNet:p02975", "input_text": "import java.util.*\nfun main(args: Array) {\n val N = nextInt()\n val A = listOfInt()\n val AS = HashSet(); AS.addAll(A)\n var ans = 0\n for (n in 0 until N) {\n for (m in 0 until N) {\n if (n == m) continue\n if ((A[n] xor A[m]) !in AS) continue\n ans++\n break\n }\n }\n if (ans >= N) println(\"Yes\")\n else println(\"No\")\n}\nfun next() = readLine()!!\nfun nextInt() = Integer.parseInt(next())\nfun listOfString() = next().split(\" \")\nfun listOfInt() = listOfString().map { Integer.parseInt(it) }\n", "language": "Kotlin", "metadata": {"date": 1563158755, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02975.html", "problem_id": "p02975", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02975/input.txt", "sample_output_relpath": "derived/input_output/data/p02975/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02975/Kotlin/s927244956.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s927244956", "user_id": "u911700901"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "import java.util.*\nfun main(args: Array) {\n val N = nextInt()\n val A = listOfInt()\n val AS = HashSet(); AS.addAll(A)\n var ans = 0\n for (n in 0 until N) {\n for (m in 0 until N) {\n if (n == m) continue\n if ((A[n] xor A[m]) !in AS) continue\n ans++\n break\n }\n }\n if (ans >= N) println(\"Yes\")\n else println(\"No\")\n}\nfun next() = readLine()!!\nfun nextInt() = Integer.parseInt(next())\nfun listOfString() = next().split(\" \")\nfun listOfInt() = listOfString().map { Integer.parseInt(it) }\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nSnuke has N hats. The i-th hat has an integer a_i written on it.\n\nThere are N camels standing in a circle.\nSnuke will put one of his hats on each of these camels.\n\nIf there exists a way to distribute the hats to the camels such that the following condition is satisfied for every camel, print Yes; otherwise, print No.\n\nThe bitwise XOR of the numbers written on the hats on both adjacent camels is equal to the number on the hat on itself.\n\nWhat is XOR?\n\nThe bitwise XOR x_1 \\oplus x_2 \\oplus \\ldots \\oplus x_n of n non-negative integers x_1, x_2, \\ldots, x_n is defined as follows:\n\n- When x_1 \\oplus x_2 \\oplus \\ldots \\oplus 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 \\oplus 5 = 6.\n\nConstraints\n\nAll values in input are integers.\n\n3 \\leq N \\leq 10^{5}\n\n0 \\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 answer.\n\nSample Input 1\n\n3\n1 2 3\n\nSample Output 1\n\nYes\n\nIf we put the hats with 1, 2, and 3 in this order, clockwise, the condition will be satisfied for every camel, so the answer is Yes.\n\nSample Input 2\n\n4\n1 2 4 8\n\nSample Output 2\n\nNo\n\nThere is no such way to distribute the hats; the answer is No.", "sample_input": "3\n1 2 3\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p02975", "source_text": "Score : 300 points\n\nProblem Statement\n\nSnuke has N hats. The i-th hat has an integer a_i written on it.\n\nThere are N camels standing in a circle.\nSnuke will put one of his hats on each of these camels.\n\nIf there exists a way to distribute the hats to the camels such that the following condition is satisfied for every camel, print Yes; otherwise, print No.\n\nThe bitwise XOR of the numbers written on the hats on both adjacent camels is equal to the number on the hat on itself.\n\nWhat is XOR?\n\nThe bitwise XOR x_1 \\oplus x_2 \\oplus \\ldots \\oplus x_n of n non-negative integers x_1, x_2, \\ldots, x_n is defined as follows:\n\n- When x_1 \\oplus x_2 \\oplus \\ldots \\oplus 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 \\oplus 5 = 6.\n\nConstraints\n\nAll values in input are integers.\n\n3 \\leq N \\leq 10^{5}\n\n0 \\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 answer.\n\nSample Input 1\n\n3\n1 2 3\n\nSample Output 1\n\nYes\n\nIf we put the hats with 1, 2, and 3 in this order, clockwise, the condition will be satisfied for every camel, so the answer is Yes.\n\nSample Input 2\n\n4\n1 2 4 8\n\nSample Output 2\n\nNo\n\nThere is no such way to distribute the hats; the answer is No.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 2111, "memory_kb": 116744}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s259765157", "group_id": "codeNet:p02981", "input_text": "fun main(arr:Array) {\n val (n,a,b) = readLine()!!.split(\" \").map { it.toInt() }\n val ans = Math.min(n*a, b)\n println(ans)\n}\n", "language": "Kotlin", "metadata": {"date": 1568064806, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02981.html", "problem_id": "p02981", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02981/input.txt", "sample_output_relpath": "derived/input_output/data/p02981/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02981/Kotlin/s259765157.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s259765157", "user_id": "u269969976"}, "prompt_components": {"gold_output": "8\n", "input_to_evaluate": "fun main(arr:Array) {\n val (n,a,b) = readLine()!!.split(\" \").map { it.toInt() }\n val ans = Math.min(n*a, b)\n println(ans)\n}\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nN of us are going on a trip, by train or taxi.\n\nThe train will cost each of us A yen (the currency of Japan).\n\nThe taxi will cost us a total of B yen.\n\nHow much is our minimum total travel expense?\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 20\n\n1 \\leq A \\leq 50\n\n1 \\leq B \\leq 50\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN A B\n\nOutput\n\nPrint an integer representing the minimum total travel expense.\n\nSample Input 1\n\n4 2 9\n\nSample Output 1\n\n8\n\nThe train will cost us 4 \\times 2 = 8 yen, and the taxi will cost us 9 yen, so the minimum total travel expense is 8 yen.\n\nSample Input 2\n\n4 2 7\n\nSample Output 2\n\n7\n\nSample Input 3\n\n4 2 8\n\nSample Output 3\n\n8", "sample_input": "4 2 9\n"}, "reference_outputs": ["8\n"], "source_document_id": "p02981", "source_text": "Score : 100 points\n\nProblem Statement\n\nN of us are going on a trip, by train or taxi.\n\nThe train will cost each of us A yen (the currency of Japan).\n\nThe taxi will cost us a total of B yen.\n\nHow much is our minimum total travel expense?\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 20\n\n1 \\leq A \\leq 50\n\n1 \\leq B \\leq 50\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN A B\n\nOutput\n\nPrint an integer representing the minimum total travel expense.\n\nSample Input 1\n\n4 2 9\n\nSample Output 1\n\n8\n\nThe train will cost us 4 \\times 2 = 8 yen, and the taxi will cost us 9 yen, so the minimum total travel expense is 8 yen.\n\nSample Input 2\n\n4 2 7\n\nSample Output 2\n\n7\n\nSample Input 3\n\n4 2 8\n\nSample Output 3\n\n8", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 238, "memory_kb": 37588}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s822116258", "group_id": "codeNet:p02981", "input_text": "import java.util.*\n\nfun main(args : Array) {\n val sc = Scanner(System.`in`)\n val n = sc.nextInt()\n val a = sc.nextInt()\n val b = sc.nextInt()\n\n println(Math.min(a * n, b))\n}", "language": "Kotlin", "metadata": {"date": 1564009373, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02981.html", "problem_id": "p02981", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02981/input.txt", "sample_output_relpath": "derived/input_output/data/p02981/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02981/Kotlin/s822116258.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s822116258", "user_id": "u073232808"}, "prompt_components": {"gold_output": "8\n", "input_to_evaluate": "import java.util.*\n\nfun main(args : Array) {\n val sc = Scanner(System.`in`)\n val n = sc.nextInt()\n val a = sc.nextInt()\n val b = sc.nextInt()\n\n println(Math.min(a * n, b))\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nN of us are going on a trip, by train or taxi.\n\nThe train will cost each of us A yen (the currency of Japan).\n\nThe taxi will cost us a total of B yen.\n\nHow much is our minimum total travel expense?\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 20\n\n1 \\leq A \\leq 50\n\n1 \\leq B \\leq 50\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN A B\n\nOutput\n\nPrint an integer representing the minimum total travel expense.\n\nSample Input 1\n\n4 2 9\n\nSample Output 1\n\n8\n\nThe train will cost us 4 \\times 2 = 8 yen, and the taxi will cost us 9 yen, so the minimum total travel expense is 8 yen.\n\nSample Input 2\n\n4 2 7\n\nSample Output 2\n\n7\n\nSample Input 3\n\n4 2 8\n\nSample Output 3\n\n8", "sample_input": "4 2 9\n"}, "reference_outputs": ["8\n"], "source_document_id": "p02981", "source_text": "Score : 100 points\n\nProblem Statement\n\nN of us are going on a trip, by train or taxi.\n\nThe train will cost each of us A yen (the currency of Japan).\n\nThe taxi will cost us a total of B yen.\n\nHow much is our minimum total travel expense?\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 20\n\n1 \\leq A \\leq 50\n\n1 \\leq B \\leq 50\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN A B\n\nOutput\n\nPrint an integer representing the minimum total travel expense.\n\nSample Input 1\n\n4 2 9\n\nSample Output 1\n\n8\n\nThe train will cost us 4 \\times 2 = 8 yen, and the taxi will cost us 9 yen, so the minimum total travel expense is 8 yen.\n\nSample Input 2\n\n4 2 7\n\nSample Output 2\n\n7\n\nSample Input 3\n\n4 2 8\n\nSample Output 3\n\n8", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 178, "memory_kb": 29596}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s364726201", "group_id": "codeNet:p02981", "input_text": "fun main(args: Array) {\n val (n, a, b) = readLine()!!.split(\" \").map(String::toInt)\n println(Math.min(a * n, b))\n}", "language": "Kotlin", "metadata": {"date": 1562548244, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02981.html", "problem_id": "p02981", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02981/input.txt", "sample_output_relpath": "derived/input_output/data/p02981/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02981/Kotlin/s364726201.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s364726201", "user_id": "u938650438"}, "prompt_components": {"gold_output": "8\n", "input_to_evaluate": "fun main(args: Array) {\n val (n, a, b) = readLine()!!.split(\" \").map(String::toInt)\n println(Math.min(a * n, b))\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nN of us are going on a trip, by train or taxi.\n\nThe train will cost each of us A yen (the currency of Japan).\n\nThe taxi will cost us a total of B yen.\n\nHow much is our minimum total travel expense?\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 20\n\n1 \\leq A \\leq 50\n\n1 \\leq B \\leq 50\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN A B\n\nOutput\n\nPrint an integer representing the minimum total travel expense.\n\nSample Input 1\n\n4 2 9\n\nSample Output 1\n\n8\n\nThe train will cost us 4 \\times 2 = 8 yen, and the taxi will cost us 9 yen, so the minimum total travel expense is 8 yen.\n\nSample Input 2\n\n4 2 7\n\nSample Output 2\n\n7\n\nSample Input 3\n\n4 2 8\n\nSample Output 3\n\n8", "sample_input": "4 2 9\n"}, "reference_outputs": ["8\n"], "source_document_id": "p02981", "source_text": "Score : 100 points\n\nProblem Statement\n\nN of us are going on a trip, by train or taxi.\n\nThe train will cost each of us A yen (the currency of Japan).\n\nThe taxi will cost us a total of B yen.\n\nHow much is our minimum total travel expense?\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 20\n\n1 \\leq A \\leq 50\n\n1 \\leq B \\leq 50\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN A B\n\nOutput\n\nPrint an integer representing the minimum total travel expense.\n\nSample Input 1\n\n4 2 9\n\nSample Output 1\n\n8\n\nThe train will cost us 4 \\times 2 = 8 yen, and the taxi will cost us 9 yen, so the minimum total travel expense is 8 yen.\n\nSample Input 2\n\n4 2 7\n\nSample Output 2\n\n7\n\nSample Input 3\n\n4 2 8\n\nSample Output 3\n\n8", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 238, "memory_kb": 36152}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s649422652", "group_id": "codeNet:p02981", "input_text": "import java.lang.Math.min\n\nfun main(args: Array) {\n val (n, a, b) = readLine()!!.split(' ').map(String::toInt)\n print(min(n* a, b))\n}", "language": "Kotlin", "metadata": {"date": 1562547696, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02981.html", "problem_id": "p02981", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02981/input.txt", "sample_output_relpath": "derived/input_output/data/p02981/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02981/Kotlin/s649422652.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s649422652", "user_id": "u526818046"}, "prompt_components": {"gold_output": "8\n", "input_to_evaluate": "import java.lang.Math.min\n\nfun main(args: Array) {\n val (n, a, b) = readLine()!!.split(' ').map(String::toInt)\n print(min(n* a, b))\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nN of us are going on a trip, by train or taxi.\n\nThe train will cost each of us A yen (the currency of Japan).\n\nThe taxi will cost us a total of B yen.\n\nHow much is our minimum total travel expense?\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 20\n\n1 \\leq A \\leq 50\n\n1 \\leq B \\leq 50\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN A B\n\nOutput\n\nPrint an integer representing the minimum total travel expense.\n\nSample Input 1\n\n4 2 9\n\nSample Output 1\n\n8\n\nThe train will cost us 4 \\times 2 = 8 yen, and the taxi will cost us 9 yen, so the minimum total travel expense is 8 yen.\n\nSample Input 2\n\n4 2 7\n\nSample Output 2\n\n7\n\nSample Input 3\n\n4 2 8\n\nSample Output 3\n\n8", "sample_input": "4 2 9\n"}, "reference_outputs": ["8\n"], "source_document_id": "p02981", "source_text": "Score : 100 points\n\nProblem Statement\n\nN of us are going on a trip, by train or taxi.\n\nThe train will cost each of us A yen (the currency of Japan).\n\nThe taxi will cost us a total of B yen.\n\nHow much is our minimum total travel expense?\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 20\n\n1 \\leq A \\leq 50\n\n1 \\leq B \\leq 50\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN A B\n\nOutput\n\nPrint an integer representing the minimum total travel expense.\n\nSample Input 1\n\n4 2 9\n\nSample Output 1\n\n8\n\nThe train will cost us 4 \\times 2 = 8 yen, and the taxi will cost us 9 yen, so the minimum total travel expense is 8 yen.\n\nSample Input 2\n\n4 2 7\n\nSample Output 2\n\n7\n\nSample Input 3\n\n4 2 8\n\nSample Output 3\n\n8", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 236, "memory_kb": 38084}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s495756722", "group_id": "codeNet:p02982", "input_text": "fun main(arr: Array) {\n val (n,d) = readLine()!!.split(\" \").map { it.toInt() }\n val pos = (1..n).map { readLine()!!.split(\" \").map { it.toInt() } }\n val ans = pos.indices.map{ idx-> pos.indices.count { idx2 -> (idx!=idx2) && (isSquare(getDist(pos[idx], pos[idx2]))) } }.sum()\n println(ans/2)\n}\n\nfun getDist(pos1:List, pos2:List):Int {\n return pos1.indices.map { (pos1[it]-pos2[it])*(pos1[it]-pos2[it]) }.sum()\n}\nfun isSquare(num:Int):Boolean {\n for(i in (1..num)) {\n val tmp = i*i\n if(tmp == num) {\n return true\n }\n if(tmp > num) {\n break\n }\n }\n return false\n}\n", "language": "Kotlin", "metadata": {"date": 1596785515, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02982.html", "problem_id": "p02982", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02982/input.txt", "sample_output_relpath": "derived/input_output/data/p02982/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02982/Kotlin/s495756722.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s495756722", "user_id": "u269969976"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "fun main(arr: Array) {\n val (n,d) = readLine()!!.split(\" \").map { it.toInt() }\n val pos = (1..n).map { readLine()!!.split(\" \").map { it.toInt() } }\n val ans = pos.indices.map{ idx-> pos.indices.count { idx2 -> (idx!=idx2) && (isSquare(getDist(pos[idx], pos[idx2]))) } }.sum()\n println(ans/2)\n}\n\nfun getDist(pos1:List, pos2:List):Int {\n return pos1.indices.map { (pos1[it]-pos2[it])*(pos1[it]-pos2[it]) }.sum()\n}\nfun isSquare(num:Int):Boolean {\n for(i in (1..num)) {\n val tmp = i*i\n if(tmp == num) {\n return true\n }\n if(tmp > num) {\n break\n }\n }\n return false\n}\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nThere are N points in a D-dimensional space.\n\nThe coordinates of the i-th point are (X_{i1}, X_{i2}, ..., X_{iD}).\n\nThe distance between two points with coordinates (y_1, y_2, ..., y_D) and (z_1, z_2, ..., z_D) is \\sqrt{(y_1 - z_1)^2 + (y_2 - z_2)^2 + ... + (y_D - z_D)^2}.\n\nHow many pairs (i, j) (i < j) are there such that the distance between the i-th point and the j-th point is an integer?\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 10\n\n1 \\leq D \\leq 10\n\n-20 \\leq X_{ij} \\leq 20\n\nNo two given points have the same coordinates. That is, if i \\neq j, there exists k such that X_{ik} \\neq X_{jk}.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN D\nX_{11} X_{12} ... X_{1D}\nX_{21} X_{22} ... X_{2D}\n\\vdots\nX_{N1} X_{N2} ... X_{ND}\n\nOutput\n\nPrint the number of pairs (i, j) (i < j) such that the distance between the i-th point and the j-th point is an integer.\n\nSample Input 1\n\n3 2\n1 2\n5 5\n-2 8\n\nSample Output 1\n\n1\n\nThe number of pairs with an integer distance is one, as follows:\n\nThe distance between the first point and the second point is \\sqrt{|1-5|^2 + |2-5|^2} = 5, which is an integer.\n\nThe distance between the second point and the third point is \\sqrt{|5-(-2)|^2 + |5-8|^2} = \\sqrt{58}, which is not an integer.\n\nThe distance between the third point and the first point is \\sqrt{|-2-1|^2+|8-2|^2} = 3\\sqrt{5}, which is not an integer.\n\nSample Input 2\n\n3 4\n-3 7 8 2\n-12 1 10 2\n-2 8 9 3\n\nSample Output 2\n\n2\n\nSample Input 3\n\n5 1\n1\n2\n3\n4\n5\n\nSample Output 3\n\n10", "sample_input": "3 2\n1 2\n5 5\n-2 8\n"}, "reference_outputs": ["1\n"], "source_document_id": "p02982", "source_text": "Score : 200 points\n\nProblem Statement\n\nThere are N points in a D-dimensional space.\n\nThe coordinates of the i-th point are (X_{i1}, X_{i2}, ..., X_{iD}).\n\nThe distance between two points with coordinates (y_1, y_2, ..., y_D) and (z_1, z_2, ..., z_D) is \\sqrt{(y_1 - z_1)^2 + (y_2 - z_2)^2 + ... + (y_D - z_D)^2}.\n\nHow many pairs (i, j) (i < j) are there such that the distance between the i-th point and the j-th point is an integer?\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 10\n\n1 \\leq D \\leq 10\n\n-20 \\leq X_{ij} \\leq 20\n\nNo two given points have the same coordinates. That is, if i \\neq j, there exists k such that X_{ik} \\neq X_{jk}.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN D\nX_{11} X_{12} ... X_{1D}\nX_{21} X_{22} ... X_{2D}\n\\vdots\nX_{N1} X_{N2} ... X_{ND}\n\nOutput\n\nPrint the number of pairs (i, j) (i < j) such that the distance between the i-th point and the j-th point is an integer.\n\nSample Input 1\n\n3 2\n1 2\n5 5\n-2 8\n\nSample Output 1\n\n1\n\nThe number of pairs with an integer distance is one, as follows:\n\nThe distance between the first point and the second point is \\sqrt{|1-5|^2 + |2-5|^2} = 5, which is an integer.\n\nThe distance between the second point and the third point is \\sqrt{|5-(-2)|^2 + |5-8|^2} = \\sqrt{58}, which is not an integer.\n\nThe distance between the third point and the first point is \\sqrt{|-2-1|^2+|8-2|^2} = 3\\sqrt{5}, which is not an integer.\n\nSample Input 2\n\n3 4\n-3 7 8 2\n-12 1 10 2\n-2 8 9 3\n\nSample Output 2\n\n2\n\nSample Input 3\n\n5 1\n1\n2\n3\n4\n5\n\nSample Output 3\n\n10", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 660, "cpu_time_ms": 127, "memory_kb": 36684}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s448033710", "group_id": "codeNet:p02982", "input_text": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val n = sc.nextInt()\n val d = sc.nextInt()\n\n val x = Array(n) { Array(d) { 0 } }\n for (i in 0 until n) {\n for (j in 0 until d) {\n x[i][j] = sc.nextInt()\n }\n }\n\n var count = 0\n for (i in 0 until n) {\n val xi = x[i]\n for (j in i until n) {\n if (i == j) continue\n val xj = x[j]\n var sum = 0\n for (di in 0 until d) {\n val tmp = xi[di] - xj[di]\n sum += tmp * tmp\n }\n val sqrt = Math.sqrt(sum.toDouble()).toInt()\n if (sqrt * sqrt == sum) count++\n }\n }\n\n println(count)\n\n}\n", "language": "Kotlin", "metadata": {"date": 1591064828, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02982.html", "problem_id": "p02982", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02982/input.txt", "sample_output_relpath": "derived/input_output/data/p02982/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02982/Kotlin/s448033710.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s448033710", "user_id": "u323522006"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val n = sc.nextInt()\n val d = sc.nextInt()\n\n val x = Array(n) { Array(d) { 0 } }\n for (i in 0 until n) {\n for (j in 0 until d) {\n x[i][j] = sc.nextInt()\n }\n }\n\n var count = 0\n for (i in 0 until n) {\n val xi = x[i]\n for (j in i until n) {\n if (i == j) continue\n val xj = x[j]\n var sum = 0\n for (di in 0 until d) {\n val tmp = xi[di] - xj[di]\n sum += tmp * tmp\n }\n val sqrt = Math.sqrt(sum.toDouble()).toInt()\n if (sqrt * sqrt == sum) count++\n }\n }\n\n println(count)\n\n}\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nThere are N points in a D-dimensional space.\n\nThe coordinates of the i-th point are (X_{i1}, X_{i2}, ..., X_{iD}).\n\nThe distance between two points with coordinates (y_1, y_2, ..., y_D) and (z_1, z_2, ..., z_D) is \\sqrt{(y_1 - z_1)^2 + (y_2 - z_2)^2 + ... + (y_D - z_D)^2}.\n\nHow many pairs (i, j) (i < j) are there such that the distance between the i-th point and the j-th point is an integer?\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 10\n\n1 \\leq D \\leq 10\n\n-20 \\leq X_{ij} \\leq 20\n\nNo two given points have the same coordinates. That is, if i \\neq j, there exists k such that X_{ik} \\neq X_{jk}.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN D\nX_{11} X_{12} ... X_{1D}\nX_{21} X_{22} ... X_{2D}\n\\vdots\nX_{N1} X_{N2} ... X_{ND}\n\nOutput\n\nPrint the number of pairs (i, j) (i < j) such that the distance between the i-th point and the j-th point is an integer.\n\nSample Input 1\n\n3 2\n1 2\n5 5\n-2 8\n\nSample Output 1\n\n1\n\nThe number of pairs with an integer distance is one, as follows:\n\nThe distance between the first point and the second point is \\sqrt{|1-5|^2 + |2-5|^2} = 5, which is an integer.\n\nThe distance between the second point and the third point is \\sqrt{|5-(-2)|^2 + |5-8|^2} = \\sqrt{58}, which is not an integer.\n\nThe distance between the third point and the first point is \\sqrt{|-2-1|^2+|8-2|^2} = 3\\sqrt{5}, which is not an integer.\n\nSample Input 2\n\n3 4\n-3 7 8 2\n-12 1 10 2\n-2 8 9 3\n\nSample Output 2\n\n2\n\nSample Input 3\n\n5 1\n1\n2\n3\n4\n5\n\nSample Output 3\n\n10", "sample_input": "3 2\n1 2\n5 5\n-2 8\n"}, "reference_outputs": ["1\n"], "source_document_id": "p02982", "source_text": "Score : 200 points\n\nProblem Statement\n\nThere are N points in a D-dimensional space.\n\nThe coordinates of the i-th point are (X_{i1}, X_{i2}, ..., X_{iD}).\n\nThe distance between two points with coordinates (y_1, y_2, ..., y_D) and (z_1, z_2, ..., z_D) is \\sqrt{(y_1 - z_1)^2 + (y_2 - z_2)^2 + ... + (y_D - z_D)^2}.\n\nHow many pairs (i, j) (i < j) are there such that the distance between the i-th point and the j-th point is an integer?\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 10\n\n1 \\leq D \\leq 10\n\n-20 \\leq X_{ij} \\leq 20\n\nNo two given points have the same coordinates. That is, if i \\neq j, there exists k such that X_{ik} \\neq X_{jk}.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN D\nX_{11} X_{12} ... X_{1D}\nX_{21} X_{22} ... X_{2D}\n\\vdots\nX_{N1} X_{N2} ... X_{ND}\n\nOutput\n\nPrint the number of pairs (i, j) (i < j) such that the distance between the i-th point and the j-th point is an integer.\n\nSample Input 1\n\n3 2\n1 2\n5 5\n-2 8\n\nSample Output 1\n\n1\n\nThe number of pairs with an integer distance is one, as follows:\n\nThe distance between the first point and the second point is \\sqrt{|1-5|^2 + |2-5|^2} = 5, which is an integer.\n\nThe distance between the second point and the third point is \\sqrt{|5-(-2)|^2 + |5-8|^2} = \\sqrt{58}, which is not an integer.\n\nThe distance between the third point and the first point is \\sqrt{|-2-1|^2+|8-2|^2} = 3\\sqrt{5}, which is not an integer.\n\nSample Input 2\n\n3 4\n-3 7 8 2\n-12 1 10 2\n-2 8 9 3\n\nSample Output 2\n\n2\n\nSample Input 3\n\n5 1\n1\n2\n3\n4\n5\n\nSample Output 3\n\n10", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 200, "memory_kb": 29480}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s217870600", "group_id": "codeNet:p02982", "input_text": "fun main(args: Array){\n val (n, d) = readLine()!!.split(\" \").map { it.toInt() }\n var count = 0\n var xx = Array(n, { listOf(d) }).toList().toMutableList()\n for (i in 0 until n){\n xx[i] = readLine()!!.split(\" \").map { it.toInt() }\n }\n for (i in 0 until n){\n for (j in i+1 until n){\n var distance = 0\n for (k in 0 until d){\n val a = xx[i][k] - xx[j][k]\n distance += a * a\n }\n for (k in 0 until 127){\n if (distance == k * k){\n count++\n break\n }\n }\n }\n }\n println(count)\n}", "language": "Kotlin", "metadata": {"date": 1588199088, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02982.html", "problem_id": "p02982", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02982/input.txt", "sample_output_relpath": "derived/input_output/data/p02982/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02982/Kotlin/s217870600.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s217870600", "user_id": "u385678999"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "fun main(args: Array){\n val (n, d) = readLine()!!.split(\" \").map { it.toInt() }\n var count = 0\n var xx = Array(n, { listOf(d) }).toList().toMutableList()\n for (i in 0 until n){\n xx[i] = readLine()!!.split(\" \").map { it.toInt() }\n }\n for (i in 0 until n){\n for (j in i+1 until n){\n var distance = 0\n for (k in 0 until d){\n val a = xx[i][k] - xx[j][k]\n distance += a * a\n }\n for (k in 0 until 127){\n if (distance == k * k){\n count++\n break\n }\n }\n }\n }\n println(count)\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nThere are N points in a D-dimensional space.\n\nThe coordinates of the i-th point are (X_{i1}, X_{i2}, ..., X_{iD}).\n\nThe distance between two points with coordinates (y_1, y_2, ..., y_D) and (z_1, z_2, ..., z_D) is \\sqrt{(y_1 - z_1)^2 + (y_2 - z_2)^2 + ... + (y_D - z_D)^2}.\n\nHow many pairs (i, j) (i < j) are there such that the distance between the i-th point and the j-th point is an integer?\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 10\n\n1 \\leq D \\leq 10\n\n-20 \\leq X_{ij} \\leq 20\n\nNo two given points have the same coordinates. That is, if i \\neq j, there exists k such that X_{ik} \\neq X_{jk}.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN D\nX_{11} X_{12} ... X_{1D}\nX_{21} X_{22} ... X_{2D}\n\\vdots\nX_{N1} X_{N2} ... X_{ND}\n\nOutput\n\nPrint the number of pairs (i, j) (i < j) such that the distance between the i-th point and the j-th point is an integer.\n\nSample Input 1\n\n3 2\n1 2\n5 5\n-2 8\n\nSample Output 1\n\n1\n\nThe number of pairs with an integer distance is one, as follows:\n\nThe distance between the first point and the second point is \\sqrt{|1-5|^2 + |2-5|^2} = 5, which is an integer.\n\nThe distance between the second point and the third point is \\sqrt{|5-(-2)|^2 + |5-8|^2} = \\sqrt{58}, which is not an integer.\n\nThe distance between the third point and the first point is \\sqrt{|-2-1|^2+|8-2|^2} = 3\\sqrt{5}, which is not an integer.\n\nSample Input 2\n\n3 4\n-3 7 8 2\n-12 1 10 2\n-2 8 9 3\n\nSample Output 2\n\n2\n\nSample Input 3\n\n5 1\n1\n2\n3\n4\n5\n\nSample Output 3\n\n10", "sample_input": "3 2\n1 2\n5 5\n-2 8\n"}, "reference_outputs": ["1\n"], "source_document_id": "p02982", "source_text": "Score : 200 points\n\nProblem Statement\n\nThere are N points in a D-dimensional space.\n\nThe coordinates of the i-th point are (X_{i1}, X_{i2}, ..., X_{iD}).\n\nThe distance between two points with coordinates (y_1, y_2, ..., y_D) and (z_1, z_2, ..., z_D) is \\sqrt{(y_1 - z_1)^2 + (y_2 - z_2)^2 + ... + (y_D - z_D)^2}.\n\nHow many pairs (i, j) (i < j) are there such that the distance between the i-th point and the j-th point is an integer?\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 10\n\n1 \\leq D \\leq 10\n\n-20 \\leq X_{ij} \\leq 20\n\nNo two given points have the same coordinates. That is, if i \\neq j, there exists k such that X_{ik} \\neq X_{jk}.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN D\nX_{11} X_{12} ... X_{1D}\nX_{21} X_{22} ... X_{2D}\n\\vdots\nX_{N1} X_{N2} ... X_{ND}\n\nOutput\n\nPrint the number of pairs (i, j) (i < j) such that the distance between the i-th point and the j-th point is an integer.\n\nSample Input 1\n\n3 2\n1 2\n5 5\n-2 8\n\nSample Output 1\n\n1\n\nThe number of pairs with an integer distance is one, as follows:\n\nThe distance between the first point and the second point is \\sqrt{|1-5|^2 + |2-5|^2} = 5, which is an integer.\n\nThe distance between the second point and the third point is \\sqrt{|5-(-2)|^2 + |5-8|^2} = \\sqrt{58}, which is not an integer.\n\nThe distance between the third point and the first point is \\sqrt{|-2-1|^2+|8-2|^2} = 3\\sqrt{5}, which is not an integer.\n\nSample Input 2\n\n3 4\n-3 7 8 2\n-12 1 10 2\n-2 8 9 3\n\nSample Output 2\n\n2\n\nSample Input 3\n\n5 1\n1\n2\n3\n4\n5\n\nSample Output 3\n\n10", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 673, "cpu_time_ms": 243, "memory_kb": 37688}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s376908800", "group_id": "codeNet:p02982", "input_text": "fun main(args: Array) {\n val (x, y) = readLine()!!.split(\" \").map { it.toInt() }\n var a = 0\n val l = mutableListOf>()\n val newl = Array(y,{0})\n for (i in 0 until x) {\n l.add(readLine()!!.split(\" \").map{ it.toInt()})\n }\n for(i in 0 until x - 1)for (j in i + 1 until x) {\n for (k in 0 until y) {\n newl[k] = Math.pow((l[i][k] - l[j][k]).toDouble(), 2.0).toInt()\n }\n if (Math.sqrt(newl.sum().toDouble()) % 1.0 == 0.0) a += 1\n }\n println(a)\n}", "language": "Kotlin", "metadata": {"date": 1562549812, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02982.html", "problem_id": "p02982", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02982/input.txt", "sample_output_relpath": "derived/input_output/data/p02982/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02982/Kotlin/s376908800.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s376908800", "user_id": "u227189389"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "fun main(args: Array) {\n val (x, y) = readLine()!!.split(\" \").map { it.toInt() }\n var a = 0\n val l = mutableListOf>()\n val newl = Array(y,{0})\n for (i in 0 until x) {\n l.add(readLine()!!.split(\" \").map{ it.toInt()})\n }\n for(i in 0 until x - 1)for (j in i + 1 until x) {\n for (k in 0 until y) {\n newl[k] = Math.pow((l[i][k] - l[j][k]).toDouble(), 2.0).toInt()\n }\n if (Math.sqrt(newl.sum().toDouble()) % 1.0 == 0.0) a += 1\n }\n println(a)\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nThere are N points in a D-dimensional space.\n\nThe coordinates of the i-th point are (X_{i1}, X_{i2}, ..., X_{iD}).\n\nThe distance between two points with coordinates (y_1, y_2, ..., y_D) and (z_1, z_2, ..., z_D) is \\sqrt{(y_1 - z_1)^2 + (y_2 - z_2)^2 + ... + (y_D - z_D)^2}.\n\nHow many pairs (i, j) (i < j) are there such that the distance between the i-th point and the j-th point is an integer?\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 10\n\n1 \\leq D \\leq 10\n\n-20 \\leq X_{ij} \\leq 20\n\nNo two given points have the same coordinates. That is, if i \\neq j, there exists k such that X_{ik} \\neq X_{jk}.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN D\nX_{11} X_{12} ... X_{1D}\nX_{21} X_{22} ... X_{2D}\n\\vdots\nX_{N1} X_{N2} ... X_{ND}\n\nOutput\n\nPrint the number of pairs (i, j) (i < j) such that the distance between the i-th point and the j-th point is an integer.\n\nSample Input 1\n\n3 2\n1 2\n5 5\n-2 8\n\nSample Output 1\n\n1\n\nThe number of pairs with an integer distance is one, as follows:\n\nThe distance between the first point and the second point is \\sqrt{|1-5|^2 + |2-5|^2} = 5, which is an integer.\n\nThe distance between the second point and the third point is \\sqrt{|5-(-2)|^2 + |5-8|^2} = \\sqrt{58}, which is not an integer.\n\nThe distance between the third point and the first point is \\sqrt{|-2-1|^2+|8-2|^2} = 3\\sqrt{5}, which is not an integer.\n\nSample Input 2\n\n3 4\n-3 7 8 2\n-12 1 10 2\n-2 8 9 3\n\nSample Output 2\n\n2\n\nSample Input 3\n\n5 1\n1\n2\n3\n4\n5\n\nSample Output 3\n\n10", "sample_input": "3 2\n1 2\n5 5\n-2 8\n"}, "reference_outputs": ["1\n"], "source_document_id": "p02982", "source_text": "Score : 200 points\n\nProblem Statement\n\nThere are N points in a D-dimensional space.\n\nThe coordinates of the i-th point are (X_{i1}, X_{i2}, ..., X_{iD}).\n\nThe distance between two points with coordinates (y_1, y_2, ..., y_D) and (z_1, z_2, ..., z_D) is \\sqrt{(y_1 - z_1)^2 + (y_2 - z_2)^2 + ... + (y_D - z_D)^2}.\n\nHow many pairs (i, j) (i < j) are there such that the distance between the i-th point and the j-th point is an integer?\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 10\n\n1 \\leq D \\leq 10\n\n-20 \\leq X_{ij} \\leq 20\n\nNo two given points have the same coordinates. That is, if i \\neq j, there exists k such that X_{ik} \\neq X_{jk}.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN D\nX_{11} X_{12} ... X_{1D}\nX_{21} X_{22} ... X_{2D}\n\\vdots\nX_{N1} X_{N2} ... X_{ND}\n\nOutput\n\nPrint the number of pairs (i, j) (i < j) such that the distance between the i-th point and the j-th point is an integer.\n\nSample Input 1\n\n3 2\n1 2\n5 5\n-2 8\n\nSample Output 1\n\n1\n\nThe number of pairs with an integer distance is one, as follows:\n\nThe distance between the first point and the second point is \\sqrt{|1-5|^2 + |2-5|^2} = 5, which is an integer.\n\nThe distance between the second point and the third point is \\sqrt{|5-(-2)|^2 + |5-8|^2} = \\sqrt{58}, which is not an integer.\n\nThe distance between the third point and the first point is \\sqrt{|-2-1|^2+|8-2|^2} = 3\\sqrt{5}, which is not an integer.\n\nSample Input 2\n\n3 4\n-3 7 8 2\n-12 1 10 2\n-2 8 9 3\n\nSample Output 2\n\n2\n\nSample Input 3\n\n5 1\n1\n2\n3\n4\n5\n\nSample Output 3\n\n10", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 526, "cpu_time_ms": 244, "memory_kb": 37920}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s427851184", "group_id": "codeNet:p02987", "input_text": "fun main(args: Array) {\n val s = readLine()!!\n val m = s.groupBy { it }\n val ans = if (m.size == 2 && m.all { it.value.size == 2 }) {\n \"Yes\"\n } else {\n \"No\"\n }\n println(ans)\n}", "language": "Kotlin", "metadata": {"date": 1562897217, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02987.html", "problem_id": "p02987", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02987/input.txt", "sample_output_relpath": "derived/input_output/data/p02987/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02987/Kotlin/s427851184.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s427851184", "user_id": "u863309603"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "fun main(args: Array) {\n val s = readLine()!!\n val m = s.groupBy { it }\n val ans = if (m.size == 2 && m.all { it.value.size == 2 }) {\n \"Yes\"\n } else {\n \"No\"\n }\n println(ans)\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nYou are given a 4-character string S consisting of uppercase English letters.\nDetermine if S consists of exactly two kinds of characters which both appear twice in S.\n\nConstraints\n\nThe length of S is 4.\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 consists of exactly two kinds of characters which both appear twice in S, print Yes; otherwise, print No.\n\nSample Input 1\n\nASSA\n\nSample Output 1\n\nYes\n\nS consists of A and S which both appear twice in S.\n\nSample Input 2\n\nSTOP\n\nSample Output 2\n\nNo\n\nSample Input 3\n\nFFEE\n\nSample Output 3\n\nYes\n\nSample Input 4\n\nFREE\n\nSample Output 4\n\nNo", "sample_input": "ASSA\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p02987", "source_text": "Score : 100 points\n\nProblem Statement\n\nYou are given a 4-character string S consisting of uppercase English letters.\nDetermine if S consists of exactly two kinds of characters which both appear twice in S.\n\nConstraints\n\nThe length of S is 4.\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 consists of exactly two kinds of characters which both appear twice in S, print Yes; otherwise, print No.\n\nSample Input 1\n\nASSA\n\nSample Output 1\n\nYes\n\nS consists of A and S which both appear twice in S.\n\nSample Input 2\n\nSTOP\n\nSample Output 2\n\nNo\n\nSample Input 3\n\nFFEE\n\nSample Output 3\n\nYes\n\nSample Input 4\n\nFREE\n\nSample Output 4\n\nNo", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 206, "memory_kb": 33784}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s713772738", "group_id": "codeNet:p02988", "input_text": "fun main(arr: Array) {\n val n = readLine()!!.toInt()\n val p = readLine()!!.split(\" \").map { it.toInt() }\n val ans = (1 until p.lastIndex).filter { listOf(p[it-1], p[it], p[it+1]).sorted()[1] == p[it] }\n println(ans.size)\n}\n", "language": "Kotlin", "metadata": {"date": 1595587294, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02988.html", "problem_id": "p02988", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02988/input.txt", "sample_output_relpath": "derived/input_output/data/p02988/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02988/Kotlin/s713772738.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s713772738", "user_id": "u269969976"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "fun main(arr: Array) {\n val n = readLine()!!.toInt()\n val p = readLine()!!.split(\" \").map { it.toInt() }\n val ans = (1 until p.lastIndex).filter { listOf(p[it-1], p[it], p[it+1]).sorted()[1] == p[it] }\n println(ans.size)\n}\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nWe have a permutation p = {p_1,\\ p_2,\\ ...,\\ p_n} of {1,\\ 2,\\ ...,\\ n}.\n\nPrint the number of elements p_i (1 < i < n) that satisfy the following condition:\n\np_i is the second smallest number among the three numbers p_{i - 1}, p_i, and p_{i + 1}.\n\nConstraints\n\nAll values in input are integers.\n\n3 \\leq n \\leq 20\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 the number of elements p_i (1 < i < n) that satisfy the condition.\n\nSample Input 1\n\n5\n1 3 5 4 2\n\nSample Output 1\n\n2\n\np_2 = 3 is the second smallest number among p_1 = 1, p_2 = 3, and p_3 = 5. Also, p_4 = 4 is the second smallest number among p_3 = 5, p_4 = 4, and p_5 = 2. These two elements satisfy the condition.\n\nSample Input 2\n\n9\n9 6 3 2 5 8 7 4 1\n\nSample Output 2\n\n5", "sample_input": "5\n1 3 5 4 2\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02988", "source_text": "Score : 200 points\n\nProblem Statement\n\nWe have a permutation p = {p_1,\\ p_2,\\ ...,\\ p_n} of {1,\\ 2,\\ ...,\\ n}.\n\nPrint the number of elements p_i (1 < i < n) that satisfy the following condition:\n\np_i is the second smallest number among the three numbers p_{i - 1}, p_i, and p_{i + 1}.\n\nConstraints\n\nAll values in input are integers.\n\n3 \\leq n \\leq 20\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 the number of elements p_i (1 < i < n) that satisfy the condition.\n\nSample Input 1\n\n5\n1 3 5 4 2\n\nSample Output 1\n\n2\n\np_2 = 3 is the second smallest number among p_1 = 1, p_2 = 3, and p_3 = 5. Also, p_4 = 4 is the second smallest number among p_3 = 5, p_4 = 4, and p_5 = 2. These two elements satisfy the condition.\n\nSample Input 2\n\n9\n9 6 3 2 5 8 7 4 1\n\nSample Output 2\n\n5", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 131, "memory_kb": 39340}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s424930306", "group_id": "codeNet:p02989", "input_text": "fun main(args: Array) {\n val N = readLine()!!.toInt()\n val D = readLine()!!.split(\" \").map(String::toInt)\n\n val map = D.groupBy{ it }.mapValues { it.value.size }.toSortedMap()\n\n\n val avgPreIndex = N / 2\n var sum = 0\n var avgPreNumber = 0\n var avgNextNumber = 0\n for ((k, v) in map) {\n sum += v\n\n if (avgPreNumber != 0) {\n avgNextNumber = k\n break\n }\n if (sum == avgPreIndex) {\n avgPreNumber = k\n\n }\n if (sum > avgPreIndex) {\n println(0)\n return\n }\n }\n\n println(avgNextNumber - avgPreNumber)\n\n\n}", "language": "Kotlin", "metadata": {"date": 1568164109, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02989.html", "problem_id": "p02989", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02989/input.txt", "sample_output_relpath": "derived/input_output/data/p02989/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02989/Kotlin/s424930306.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s424930306", "user_id": "u085288971"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "fun main(args: Array) {\n val N = readLine()!!.toInt()\n val D = readLine()!!.split(\" \").map(String::toInt)\n\n val map = D.groupBy{ it }.mapValues { it.value.size }.toSortedMap()\n\n\n val avgPreIndex = N / 2\n var sum = 0\n var avgPreNumber = 0\n var avgNextNumber = 0\n for ((k, v) in map) {\n sum += v\n\n if (avgPreNumber != 0) {\n avgNextNumber = k\n break\n }\n if (sum == avgPreIndex) {\n avgPreNumber = k\n\n }\n if (sum > avgPreIndex) {\n println(0)\n return\n }\n }\n\n println(avgNextNumber - avgPreNumber)\n\n\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nTakahashi made N problems for competitive programming.\nThe problems are numbered 1 to N, and the difficulty of Problem i is represented as an integer d_i (the higher, the harder).\n\nHe is dividing the problems into two categories by choosing an integer K, as follows:\n\nA problem with difficulty K or higher will be for ARCs.\n\nA problem with difficulty lower than K will be for ABCs.\n\nHow many choices of the integer K make the number of problems for ARCs and the number of problems for ABCs the same?\n\nProblem Statement\n\n2 \\leq N \\leq 10^5\n\nN is an even number.\n\n1 \\leq d_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\nd_1 d_2 ... d_N\n\nOutput\n\nPrint the number of choices of the integer K that make the number of problems for ARCs and the number of problems for ABCs the same.\n\nSample Input 1\n\n6\n9 1 4 4 6 7\n\nSample Output 1\n\n2\n\nIf we choose K=5 or 6, Problem 1, 5, and 6 will be for ARCs, Problem 2, 3, and 4 will be for ABCs, and the objective is achieved.\nThus, the answer is 2.\n\nSample Input 2\n\n8\n9 1 14 5 5 4 4 14\n\nSample Output 2\n\n0\n\nThere may be no choice of the integer K that make the number of problems for ARCs and the number of problems for ABCs the same.\n\nSample Input 3\n\n14\n99592 10342 29105 78532 83018 11639 92015 77204 30914 21912 34519 80835 100000 1\n\nSample Output 3\n\n42685", "sample_input": "6\n9 1 4 4 6 7\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02989", "source_text": "Score : 300 points\n\nProblem Statement\n\nTakahashi made N problems for competitive programming.\nThe problems are numbered 1 to N, and the difficulty of Problem i is represented as an integer d_i (the higher, the harder).\n\nHe is dividing the problems into two categories by choosing an integer K, as follows:\n\nA problem with difficulty K or higher will be for ARCs.\n\nA problem with difficulty lower than K will be for ABCs.\n\nHow many choices of the integer K make the number of problems for ARCs and the number of problems for ABCs the same?\n\nProblem Statement\n\n2 \\leq N \\leq 10^5\n\nN is an even number.\n\n1 \\leq d_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\nd_1 d_2 ... d_N\n\nOutput\n\nPrint the number of choices of the integer K that make the number of problems for ARCs and the number of problems for ABCs the same.\n\nSample Input 1\n\n6\n9 1 4 4 6 7\n\nSample Output 1\n\n2\n\nIf we choose K=5 or 6, Problem 1, 5, and 6 will be for ARCs, Problem 2, 3, and 4 will be for ABCs, and the objective is achieved.\nThus, the answer is 2.\n\nSample Input 2\n\n8\n9 1 14 5 5 4 4 14\n\nSample Output 2\n\n0\n\nThere may be no choice of the integer K that make the number of problems for ARCs and the number of problems for ABCs the same.\n\nSample Input 3\n\n14\n99592 10342 29105 78532 83018 11639 92015 77204 30914 21912 34519 80835 100000 1\n\nSample Output 3\n\n42685", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 636, "cpu_time_ms": 713, "memory_kb": 60268}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s171456793", "group_id": "codeNet:p02989", "input_text": "fun main(args: Array) {\n val n = readLine()!!\n val dList = readLine()!!.split(\" \").map { it.toInt() }\n val sortedList = dList.sorted()\n val dLeft = sortedList[dList.size/2 - 1]\n val dRight = sortedList[dList.size/2]\n println(dRight - dLeft)\n}", "language": "Kotlin", "metadata": {"date": 1562557240, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02989.html", "problem_id": "p02989", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02989/input.txt", "sample_output_relpath": "derived/input_output/data/p02989/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02989/Kotlin/s171456793.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s171456793", "user_id": "u979004569"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "fun main(args: Array) {\n val n = readLine()!!\n val dList = readLine()!!.split(\" \").map { it.toInt() }\n val sortedList = dList.sorted()\n val dLeft = sortedList[dList.size/2 - 1]\n val dRight = sortedList[dList.size/2]\n println(dRight - dLeft)\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nTakahashi made N problems for competitive programming.\nThe problems are numbered 1 to N, and the difficulty of Problem i is represented as an integer d_i (the higher, the harder).\n\nHe is dividing the problems into two categories by choosing an integer K, as follows:\n\nA problem with difficulty K or higher will be for ARCs.\n\nA problem with difficulty lower than K will be for ABCs.\n\nHow many choices of the integer K make the number of problems for ARCs and the number of problems for ABCs the same?\n\nProblem Statement\n\n2 \\leq N \\leq 10^5\n\nN is an even number.\n\n1 \\leq d_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\nd_1 d_2 ... d_N\n\nOutput\n\nPrint the number of choices of the integer K that make the number of problems for ARCs and the number of problems for ABCs the same.\n\nSample Input 1\n\n6\n9 1 4 4 6 7\n\nSample Output 1\n\n2\n\nIf we choose K=5 or 6, Problem 1, 5, and 6 will be for ARCs, Problem 2, 3, and 4 will be for ABCs, and the objective is achieved.\nThus, the answer is 2.\n\nSample Input 2\n\n8\n9 1 14 5 5 4 4 14\n\nSample Output 2\n\n0\n\nThere may be no choice of the integer K that make the number of problems for ARCs and the number of problems for ABCs the same.\n\nSample Input 3\n\n14\n99592 10342 29105 78532 83018 11639 92015 77204 30914 21912 34519 80835 100000 1\n\nSample Output 3\n\n42685", "sample_input": "6\n9 1 4 4 6 7\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02989", "source_text": "Score : 300 points\n\nProblem Statement\n\nTakahashi made N problems for competitive programming.\nThe problems are numbered 1 to N, and the difficulty of Problem i is represented as an integer d_i (the higher, the harder).\n\nHe is dividing the problems into two categories by choosing an integer K, as follows:\n\nA problem with difficulty K or higher will be for ARCs.\n\nA problem with difficulty lower than K will be for ABCs.\n\nHow many choices of the integer K make the number of problems for ARCs and the number of problems for ABCs the same?\n\nProblem Statement\n\n2 \\leq N \\leq 10^5\n\nN is an even number.\n\n1 \\leq d_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\nd_1 d_2 ... d_N\n\nOutput\n\nPrint the number of choices of the integer K that make the number of problems for ARCs and the number of problems for ABCs the same.\n\nSample Input 1\n\n6\n9 1 4 4 6 7\n\nSample Output 1\n\n2\n\nIf we choose K=5 or 6, Problem 1, 5, and 6 will be for ARCs, Problem 2, 3, and 4 will be for ABCs, and the objective is achieved.\nThus, the answer is 2.\n\nSample Input 2\n\n8\n9 1 14 5 5 4 4 14\n\nSample Output 2\n\n0\n\nThere may be no choice of the integer K that make the number of problems for ARCs and the number of problems for ABCs the same.\n\nSample Input 3\n\n14\n99592 10342 29105 78532 83018 11639 92015 77204 30914 21912 34519 80835 100000 1\n\nSample Output 3\n\n42685", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 801, "memory_kb": 53812}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s535007754", "group_id": "codeNet:p02989", "input_text": "fun main(args: Array) {\n val n = readLine()!!.toInt()\n val d = readLine()!!.split(\" \").sortedBy { it.toInt() }\n print(d[n/2].toInt() - d[n/2 - 1].toInt())\n}\n", "language": "Kotlin", "metadata": {"date": 1561858444, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02989.html", "problem_id": "p02989", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02989/input.txt", "sample_output_relpath": "derived/input_output/data/p02989/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02989/Kotlin/s535007754.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s535007754", "user_id": "u520434261"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "fun main(args: Array) {\n val n = readLine()!!.toInt()\n val d = readLine()!!.split(\" \").sortedBy { it.toInt() }\n print(d[n/2].toInt() - d[n/2 - 1].toInt())\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nTakahashi made N problems for competitive programming.\nThe problems are numbered 1 to N, and the difficulty of Problem i is represented as an integer d_i (the higher, the harder).\n\nHe is dividing the problems into two categories by choosing an integer K, as follows:\n\nA problem with difficulty K or higher will be for ARCs.\n\nA problem with difficulty lower than K will be for ABCs.\n\nHow many choices of the integer K make the number of problems for ARCs and the number of problems for ABCs the same?\n\nProblem Statement\n\n2 \\leq N \\leq 10^5\n\nN is an even number.\n\n1 \\leq d_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\nd_1 d_2 ... d_N\n\nOutput\n\nPrint the number of choices of the integer K that make the number of problems for ARCs and the number of problems for ABCs the same.\n\nSample Input 1\n\n6\n9 1 4 4 6 7\n\nSample Output 1\n\n2\n\nIf we choose K=5 or 6, Problem 1, 5, and 6 will be for ARCs, Problem 2, 3, and 4 will be for ABCs, and the objective is achieved.\nThus, the answer is 2.\n\nSample Input 2\n\n8\n9 1 14 5 5 4 4 14\n\nSample Output 2\n\n0\n\nThere may be no choice of the integer K that make the number of problems for ARCs and the number of problems for ABCs the same.\n\nSample Input 3\n\n14\n99592 10342 29105 78532 83018 11639 92015 77204 30914 21912 34519 80835 100000 1\n\nSample Output 3\n\n42685", "sample_input": "6\n9 1 4 4 6 7\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02989", "source_text": "Score : 300 points\n\nProblem Statement\n\nTakahashi made N problems for competitive programming.\nThe problems are numbered 1 to N, and the difficulty of Problem i is represented as an integer d_i (the higher, the harder).\n\nHe is dividing the problems into two categories by choosing an integer K, as follows:\n\nA problem with difficulty K or higher will be for ARCs.\n\nA problem with difficulty lower than K will be for ABCs.\n\nHow many choices of the integer K make the number of problems for ARCs and the number of problems for ABCs the same?\n\nProblem Statement\n\n2 \\leq N \\leq 10^5\n\nN is an even number.\n\n1 \\leq d_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\nd_1 d_2 ... d_N\n\nOutput\n\nPrint the number of choices of the integer K that make the number of problems for ARCs and the number of problems for ABCs the same.\n\nSample Input 1\n\n6\n9 1 4 4 6 7\n\nSample Output 1\n\n2\n\nIf we choose K=5 or 6, Problem 1, 5, and 6 will be for ARCs, Problem 2, 3, and 4 will be for ABCs, and the objective is achieved.\nThus, the answer is 2.\n\nSample Input 2\n\n8\n9 1 14 5 5 4 4 14\n\nSample Output 2\n\n0\n\nThere may be no choice of the integer K that make the number of problems for ARCs and the number of problems for ABCs the same.\n\nSample Input 3\n\n14\n99592 10342 29105 78532 83018 11639 92015 77204 30914 21912 34519 80835 100000 1\n\nSample Output 3\n\n42685", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 712, "memory_kb": 69160}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s703694299", "group_id": "codeNet:p02989", "input_text": "fun main(args: Array) {\n val n = readLine()!!.toInt()\n val d = readLine()!!.split(\" \").sorted()\n print(d[n/2].toInt() - d[n/2 - 1].toInt())\n}", "language": "Kotlin", "metadata": {"date": 1561857670, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02989.html", "problem_id": "p02989", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02989/input.txt", "sample_output_relpath": "derived/input_output/data/p02989/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02989/Kotlin/s703694299.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s703694299", "user_id": "u520434261"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "fun main(args: Array) {\n val n = readLine()!!.toInt()\n val d = readLine()!!.split(\" \").sorted()\n print(d[n/2].toInt() - d[n/2 - 1].toInt())\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nTakahashi made N problems for competitive programming.\nThe problems are numbered 1 to N, and the difficulty of Problem i is represented as an integer d_i (the higher, the harder).\n\nHe is dividing the problems into two categories by choosing an integer K, as follows:\n\nA problem with difficulty K or higher will be for ARCs.\n\nA problem with difficulty lower than K will be for ABCs.\n\nHow many choices of the integer K make the number of problems for ARCs and the number of problems for ABCs the same?\n\nProblem Statement\n\n2 \\leq N \\leq 10^5\n\nN is an even number.\n\n1 \\leq d_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\nd_1 d_2 ... d_N\n\nOutput\n\nPrint the number of choices of the integer K that make the number of problems for ARCs and the number of problems for ABCs the same.\n\nSample Input 1\n\n6\n9 1 4 4 6 7\n\nSample Output 1\n\n2\n\nIf we choose K=5 or 6, Problem 1, 5, and 6 will be for ARCs, Problem 2, 3, and 4 will be for ABCs, and the objective is achieved.\nThus, the answer is 2.\n\nSample Input 2\n\n8\n9 1 14 5 5 4 4 14\n\nSample Output 2\n\n0\n\nThere may be no choice of the integer K that make the number of problems for ARCs and the number of problems for ABCs the same.\n\nSample Input 3\n\n14\n99592 10342 29105 78532 83018 11639 92015 77204 30914 21912 34519 80835 100000 1\n\nSample Output 3\n\n42685", "sample_input": "6\n9 1 4 4 6 7\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02989", "source_text": "Score : 300 points\n\nProblem Statement\n\nTakahashi made N problems for competitive programming.\nThe problems are numbered 1 to N, and the difficulty of Problem i is represented as an integer d_i (the higher, the harder).\n\nHe is dividing the problems into two categories by choosing an integer K, as follows:\n\nA problem with difficulty K or higher will be for ARCs.\n\nA problem with difficulty lower than K will be for ABCs.\n\nHow many choices of the integer K make the number of problems for ARCs and the number of problems for ABCs the same?\n\nProblem Statement\n\n2 \\leq N \\leq 10^5\n\nN is an even number.\n\n1 \\leq d_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\nd_1 d_2 ... d_N\n\nOutput\n\nPrint the number of choices of the integer K that make the number of problems for ARCs and the number of problems for ABCs the same.\n\nSample Input 1\n\n6\n9 1 4 4 6 7\n\nSample Output 1\n\n2\n\nIf we choose K=5 or 6, Problem 1, 5, and 6 will be for ARCs, Problem 2, 3, and 4 will be for ABCs, and the objective is achieved.\nThus, the answer is 2.\n\nSample Input 2\n\n8\n9 1 14 5 5 4 4 14\n\nSample Output 2\n\n0\n\nThere may be no choice of the integer K that make the number of problems for ARCs and the number of problems for ABCs the same.\n\nSample Input 3\n\n14\n99592 10342 29105 78532 83018 11639 92015 77204 30914 21912 34519 80835 100000 1\n\nSample Output 3\n\n42685", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 832, "memory_kb": 52224}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s722001521", "group_id": "codeNet:p02989", "input_text": "import java.util.*\nfun main(args: Array){\n\tval cin = Scanner(System.`in`)\n val n = cin.nextInt()\n val r: MutableList = mutableListOf()\n for (i in 0..n-1) {\n r.add(cin.nextInt())\n }\n val r_sorted = r.sorted()\n val upper_bottom_idx = n/2\n println(r_sorted[upper_bottom_idx] - r_sorted[upper_bottom_idx - 1])\n}", "language": "Kotlin", "metadata": {"date": 1561857301, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02989.html", "problem_id": "p02989", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02989/input.txt", "sample_output_relpath": "derived/input_output/data/p02989/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02989/Kotlin/s722001521.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s722001521", "user_id": "u111421568"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import java.util.*\nfun main(args: Array){\n\tval cin = Scanner(System.`in`)\n val n = cin.nextInt()\n val r: MutableList = mutableListOf()\n for (i in 0..n-1) {\n r.add(cin.nextInt())\n }\n val r_sorted = r.sorted()\n val upper_bottom_idx = n/2\n println(r_sorted[upper_bottom_idx] - r_sorted[upper_bottom_idx - 1])\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nTakahashi made N problems for competitive programming.\nThe problems are numbered 1 to N, and the difficulty of Problem i is represented as an integer d_i (the higher, the harder).\n\nHe is dividing the problems into two categories by choosing an integer K, as follows:\n\nA problem with difficulty K or higher will be for ARCs.\n\nA problem with difficulty lower than K will be for ABCs.\n\nHow many choices of the integer K make the number of problems for ARCs and the number of problems for ABCs the same?\n\nProblem Statement\n\n2 \\leq N \\leq 10^5\n\nN is an even number.\n\n1 \\leq d_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\nd_1 d_2 ... d_N\n\nOutput\n\nPrint the number of choices of the integer K that make the number of problems for ARCs and the number of problems for ABCs the same.\n\nSample Input 1\n\n6\n9 1 4 4 6 7\n\nSample Output 1\n\n2\n\nIf we choose K=5 or 6, Problem 1, 5, and 6 will be for ARCs, Problem 2, 3, and 4 will be for ABCs, and the objective is achieved.\nThus, the answer is 2.\n\nSample Input 2\n\n8\n9 1 14 5 5 4 4 14\n\nSample Output 2\n\n0\n\nThere may be no choice of the integer K that make the number of problems for ARCs and the number of problems for ABCs the same.\n\nSample Input 3\n\n14\n99592 10342 29105 78532 83018 11639 92015 77204 30914 21912 34519 80835 100000 1\n\nSample Output 3\n\n42685", "sample_input": "6\n9 1 4 4 6 7\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02989", "source_text": "Score : 300 points\n\nProblem Statement\n\nTakahashi made N problems for competitive programming.\nThe problems are numbered 1 to N, and the difficulty of Problem i is represented as an integer d_i (the higher, the harder).\n\nHe is dividing the problems into two categories by choosing an integer K, as follows:\n\nA problem with difficulty K or higher will be for ARCs.\n\nA problem with difficulty lower than K will be for ABCs.\n\nHow many choices of the integer K make the number of problems for ARCs and the number of problems for ABCs the same?\n\nProblem Statement\n\n2 \\leq N \\leq 10^5\n\nN is an even number.\n\n1 \\leq d_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\nd_1 d_2 ... d_N\n\nOutput\n\nPrint the number of choices of the integer K that make the number of problems for ARCs and the number of problems for ABCs the same.\n\nSample Input 1\n\n6\n9 1 4 4 6 7\n\nSample Output 1\n\n2\n\nIf we choose K=5 or 6, Problem 1, 5, and 6 will be for ARCs, Problem 2, 3, and 4 will be for ABCs, and the objective is achieved.\nThus, the answer is 2.\n\nSample Input 2\n\n8\n9 1 14 5 5 4 4 14\n\nSample Output 2\n\n0\n\nThere may be no choice of the integer K that make the number of problems for ARCs and the number of problems for ABCs the same.\n\nSample Input 3\n\n14\n99592 10342 29105 78532 83018 11639 92015 77204 30914 21912 34519 80835 100000 1\n\nSample Output 3\n\n42685", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 348, "cpu_time_ms": 849, "memory_kb": 58784}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s201659063", "group_id": "codeNet:p02993", "input_text": " fun main(args: Array) {\n var result: String = \"Good\"\n val n = readNext()\n val lst = n.split(\"\")\n if(lst.get(0) == lst.get(1) ||\n lst.get(1) == lst.get(2) ||\n lst.get(2) == lst.get(3)){\n result = \"Bad\"\n }\n println(result)\n }\n\n\n fun readNext(): String {\n return readLine()!!\n }", "language": "Kotlin", "metadata": {"date": 1564635093, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02993.html", "problem_id": "p02993", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02993/input.txt", "sample_output_relpath": "derived/input_output/data/p02993/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02993/Kotlin/s201659063.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s201659063", "user_id": "u376174428"}, "prompt_components": {"gold_output": "Bad\n", "input_to_evaluate": " fun main(args: Array) {\n var result: String = \"Good\"\n val n = readNext()\n val lst = n.split(\"\")\n if(lst.get(0) == lst.get(1) ||\n lst.get(1) == lst.get(2) ||\n lst.get(2) == lst.get(3)){\n result = \"Bad\"\n }\n println(result)\n }\n\n\n fun readNext(): String {\n return readLine()!!\n }", "problem_context": "Score : 100 points\n\nProblem Statement\n\nThe door of Snuke's laboratory is locked with a security code.\n\nThe security code is a 4-digit number. We say the security code is hard to enter when it contains two consecutive digits that are the same.\n\nYou are given the current security code S. If S is hard to enter, print Bad; otherwise, print Good.\n\nConstraints\n\nS is a 4-character string consisting of digits.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nIf S is hard to enter, print Bad; otherwise, print Good.\n\nSample Input 1\n\n3776\n\nSample Output 1\n\nBad\n\nThe second and third digits are the same, so 3776 is hard to enter.\n\nSample Input 2\n\n8080\n\nSample Output 2\n\nGood\n\nThere are no two consecutive digits that are the same, so 8080 is not hard to enter.\n\nSample Input 3\n\n1333\n\nSample Output 3\n\nBad\n\nSample Input 4\n\n0024\n\nSample Output 4\n\nBad", "sample_input": "3776\n"}, "reference_outputs": ["Bad\n"], "source_document_id": "p02993", "source_text": "Score : 100 points\n\nProblem Statement\n\nThe door of Snuke's laboratory is locked with a security code.\n\nThe security code is a 4-digit number. We say the security code is hard to enter when it contains two consecutive digits that are the same.\n\nYou are given the current security code S. If S is hard to enter, print Bad; otherwise, print Good.\n\nConstraints\n\nS is a 4-character string consisting of digits.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nIf S is hard to enter, print Bad; otherwise, print Good.\n\nSample Input 1\n\n3776\n\nSample Output 1\n\nBad\n\nThe second and third digits are the same, so 3776 is hard to enter.\n\nSample Input 2\n\n8080\n\nSample Output 2\n\nGood\n\nThere are no two consecutive digits that are the same, so 8080 is not hard to enter.\n\nSample Input 3\n\n1333\n\nSample Output 3\n\nBad\n\nSample Input 4\n\n0024\n\nSample Output 4\n\nBad", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 233, "memory_kb": 37884}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s304573396", "group_id": "codeNet:p02993", "input_text": "fun main(args: Array) {\n val S = readLine()!!\n val list = S.toList()\n println(if (list.distinct().size == 4) \"Good\" else \"Bad\")\n}", "language": "Kotlin", "metadata": {"date": 1561251985, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02993.html", "problem_id": "p02993", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02993/input.txt", "sample_output_relpath": "derived/input_output/data/p02993/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02993/Kotlin/s304573396.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s304573396", "user_id": "u249910602"}, "prompt_components": {"gold_output": "Bad\n", "input_to_evaluate": "fun main(args: Array) {\n val S = readLine()!!\n val list = S.toList()\n println(if (list.distinct().size == 4) \"Good\" else \"Bad\")\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nThe door of Snuke's laboratory is locked with a security code.\n\nThe security code is a 4-digit number. We say the security code is hard to enter when it contains two consecutive digits that are the same.\n\nYou are given the current security code S. If S is hard to enter, print Bad; otherwise, print Good.\n\nConstraints\n\nS is a 4-character string consisting of digits.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nIf S is hard to enter, print Bad; otherwise, print Good.\n\nSample Input 1\n\n3776\n\nSample Output 1\n\nBad\n\nThe second and third digits are the same, so 3776 is hard to enter.\n\nSample Input 2\n\n8080\n\nSample Output 2\n\nGood\n\nThere are no two consecutive digits that are the same, so 8080 is not hard to enter.\n\nSample Input 3\n\n1333\n\nSample Output 3\n\nBad\n\nSample Input 4\n\n0024\n\nSample Output 4\n\nBad", "sample_input": "3776\n"}, "reference_outputs": ["Bad\n"], "source_document_id": "p02993", "source_text": "Score : 100 points\n\nProblem Statement\n\nThe door of Snuke's laboratory is locked with a security code.\n\nThe security code is a 4-digit number. We say the security code is hard to enter when it contains two consecutive digits that are the same.\n\nYou are given the current security code S. If S is hard to enter, print Bad; otherwise, print Good.\n\nConstraints\n\nS is a 4-character string consisting of digits.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nIf S is hard to enter, print Bad; otherwise, print Good.\n\nSample Input 1\n\n3776\n\nSample Output 1\n\nBad\n\nThe second and third digits are the same, so 3776 is hard to enter.\n\nSample Input 2\n\n8080\n\nSample Output 2\n\nGood\n\nThere are no two consecutive digits that are the same, so 8080 is not hard to enter.\n\nSample Input 3\n\n1333\n\nSample Output 3\n\nBad\n\nSample Input 4\n\n0024\n\nSample Output 4\n\nBad", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 218, "memory_kb": 31992}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s427946137", "group_id": "codeNet:p02994", "input_text": "import java.util.*\n\nfun main(args: Array) {\n val scanner = Scanner(System.`in`)\n val n = scanner.nextInt()\n val l = scanner.nextInt()\n var sum = 0\n var sub = 0\n var check = false\n for(i in 1..n) {\n if(l+i-1 === 0) check = true\n sum += (l+i-1)\n }\n if(l+n-1 < 0) sub = l+n-1\n else sub = l\n if(check) println(sum)\n else println(sum-sub)\n}", "language": "Kotlin", "metadata": {"date": 1561253264, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02994.html", "problem_id": "p02994", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02994/input.txt", "sample_output_relpath": "derived/input_output/data/p02994/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02994/Kotlin/s427946137.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s427946137", "user_id": "u046105273"}, "prompt_components": {"gold_output": "18\n", "input_to_evaluate": "import java.util.*\n\nfun main(args: Array) {\n val scanner = Scanner(System.`in`)\n val n = scanner.nextInt()\n val l = scanner.nextInt()\n var sum = 0\n var sub = 0\n var check = false\n for(i in 1..n) {\n if(l+i-1 === 0) check = true\n sum += (l+i-1)\n }\n if(l+n-1 < 0) sub = l+n-1\n else sub = l\n if(check) println(sum)\n else println(sum-sub)\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nYou have N apples, called Apple 1, Apple 2, Apple 3, ..., Apple N. The flavor of Apple i is L+i-1, which can be negative.\n\nYou can make an apple pie using one or more of the apples. The flavor of the apple pie will be the sum of the flavors of the apples used.\n\nYou planned to make an apple pie using all of the apples, but being hungry tempts you to eat one of them, which can no longer be used to make the apple pie.\n\nYou want to make an apple pie that is as similar as possible to the one that you planned to make. Thus, you will choose the apple to eat so that the flavor of the apple pie made of the remaining N-1 apples will have the smallest possible absolute difference from the flavor of the apple pie made of all the N apples.\n\nFind the flavor of the apple pie made of the remaining N-1 apples when you choose the apple to eat as above.\n\nWe can prove that this value is uniquely determined.\n\nConstraints\n\n2 \\leq N \\leq 200\n\n-100 \\leq L \\leq 100\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN L\n\nOutput\n\nFind the flavor of the apple pie made of the remaining N-1 apples when you optimally choose the apple to eat.\n\nSample Input 1\n\n5 2\n\nSample Output 1\n\n18\n\nThe flavors of Apple 1, 2, 3, 4, and 5 are 2, 3, 4, 5, and 6, respectively. The optimal choice is to eat Apple 1, so the answer is 3+4+5+6=18.\n\nSample Input 2\n\n3 -1\n\nSample Output 2\n\n0\n\nThe flavors of Apple 1, 2, and 3 are -1, 0, and 1, respectively. The optimal choice is to eat Apple 2, so the answer is (-1)+1=0.\n\nSample Input 3\n\n30 -50\n\nSample Output 3\n\n-1044", "sample_input": "5 2\n"}, "reference_outputs": ["18\n"], "source_document_id": "p02994", "source_text": "Score : 200 points\n\nProblem Statement\n\nYou have N apples, called Apple 1, Apple 2, Apple 3, ..., Apple N. The flavor of Apple i is L+i-1, which can be negative.\n\nYou can make an apple pie using one or more of the apples. The flavor of the apple pie will be the sum of the flavors of the apples used.\n\nYou planned to make an apple pie using all of the apples, but being hungry tempts you to eat one of them, which can no longer be used to make the apple pie.\n\nYou want to make an apple pie that is as similar as possible to the one that you planned to make. Thus, you will choose the apple to eat so that the flavor of the apple pie made of the remaining N-1 apples will have the smallest possible absolute difference from the flavor of the apple pie made of all the N apples.\n\nFind the flavor of the apple pie made of the remaining N-1 apples when you choose the apple to eat as above.\n\nWe can prove that this value is uniquely determined.\n\nConstraints\n\n2 \\leq N \\leq 200\n\n-100 \\leq L \\leq 100\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN L\n\nOutput\n\nFind the flavor of the apple pie made of the remaining N-1 apples when you optimally choose the apple to eat.\n\nSample Input 1\n\n5 2\n\nSample Output 1\n\n18\n\nThe flavors of Apple 1, 2, 3, 4, and 5 are 2, 3, 4, 5, and 6, respectively. The optimal choice is to eat Apple 1, so the answer is 3+4+5+6=18.\n\nSample Input 2\n\n3 -1\n\nSample Output 2\n\n0\n\nThe flavors of Apple 1, 2, and 3 are -1, 0, and 1, respectively. The optimal choice is to eat Apple 2, so the answer is (-1)+1=0.\n\nSample Input 3\n\n30 -50\n\nSample Output 3\n\n-1044", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 393, "cpu_time_ms": 191, "memory_kb": 31392}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s525124077", "group_id": "codeNet:p02994", "input_text": "\nfun main(args:Array) {\n val (N,L) = readLine()!!.split(\" \").map(String::toInt)\n val tastes = (1..N).map {\n L + it - 1\n }\n\n val total = tastes.fold(0) {sum,ele -> sum+ele}\n\n tastes.indices.minBy {\n val ts = tastes[it]\n Math.abs(ts)\n }!!.let {\n total - tastes[it]\n }.run(::println)\n}\n ", "language": "Kotlin", "metadata": {"date": 1561252585, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02994.html", "problem_id": "p02994", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02994/input.txt", "sample_output_relpath": "derived/input_output/data/p02994/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02994/Kotlin/s525124077.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s525124077", "user_id": "u181807786"}, "prompt_components": {"gold_output": "18\n", "input_to_evaluate": "\nfun main(args:Array) {\n val (N,L) = readLine()!!.split(\" \").map(String::toInt)\n val tastes = (1..N).map {\n L + it - 1\n }\n\n val total = tastes.fold(0) {sum,ele -> sum+ele}\n\n tastes.indices.minBy {\n val ts = tastes[it]\n Math.abs(ts)\n }!!.let {\n total - tastes[it]\n }.run(::println)\n}\n ", "problem_context": "Score : 200 points\n\nProblem Statement\n\nYou have N apples, called Apple 1, Apple 2, Apple 3, ..., Apple N. The flavor of Apple i is L+i-1, which can be negative.\n\nYou can make an apple pie using one or more of the apples. The flavor of the apple pie will be the sum of the flavors of the apples used.\n\nYou planned to make an apple pie using all of the apples, but being hungry tempts you to eat one of them, which can no longer be used to make the apple pie.\n\nYou want to make an apple pie that is as similar as possible to the one that you planned to make. Thus, you will choose the apple to eat so that the flavor of the apple pie made of the remaining N-1 apples will have the smallest possible absolute difference from the flavor of the apple pie made of all the N apples.\n\nFind the flavor of the apple pie made of the remaining N-1 apples when you choose the apple to eat as above.\n\nWe can prove that this value is uniquely determined.\n\nConstraints\n\n2 \\leq N \\leq 200\n\n-100 \\leq L \\leq 100\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN L\n\nOutput\n\nFind the flavor of the apple pie made of the remaining N-1 apples when you optimally choose the apple to eat.\n\nSample Input 1\n\n5 2\n\nSample Output 1\n\n18\n\nThe flavors of Apple 1, 2, 3, 4, and 5 are 2, 3, 4, 5, and 6, respectively. The optimal choice is to eat Apple 1, so the answer is 3+4+5+6=18.\n\nSample Input 2\n\n3 -1\n\nSample Output 2\n\n0\n\nThe flavors of Apple 1, 2, and 3 are -1, 0, and 1, respectively. The optimal choice is to eat Apple 2, so the answer is (-1)+1=0.\n\nSample Input 3\n\n30 -50\n\nSample Output 3\n\n-1044", "sample_input": "5 2\n"}, "reference_outputs": ["18\n"], "source_document_id": "p02994", "source_text": "Score : 200 points\n\nProblem Statement\n\nYou have N apples, called Apple 1, Apple 2, Apple 3, ..., Apple N. The flavor of Apple i is L+i-1, which can be negative.\n\nYou can make an apple pie using one or more of the apples. The flavor of the apple pie will be the sum of the flavors of the apples used.\n\nYou planned to make an apple pie using all of the apples, but being hungry tempts you to eat one of them, which can no longer be used to make the apple pie.\n\nYou want to make an apple pie that is as similar as possible to the one that you planned to make. Thus, you will choose the apple to eat so that the flavor of the apple pie made of the remaining N-1 apples will have the smallest possible absolute difference from the flavor of the apple pie made of all the N apples.\n\nFind the flavor of the apple pie made of the remaining N-1 apples when you choose the apple to eat as above.\n\nWe can prove that this value is uniquely determined.\n\nConstraints\n\n2 \\leq N \\leq 200\n\n-100 \\leq L \\leq 100\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN L\n\nOutput\n\nFind the flavor of the apple pie made of the remaining N-1 apples when you optimally choose the apple to eat.\n\nSample Input 1\n\n5 2\n\nSample Output 1\n\n18\n\nThe flavors of Apple 1, 2, 3, 4, and 5 are 2, 3, 4, 5, and 6, respectively. The optimal choice is to eat Apple 1, so the answer is 3+4+5+6=18.\n\nSample Input 2\n\n3 -1\n\nSample Output 2\n\n0\n\nThe flavors of Apple 1, 2, and 3 are -1, 0, and 1, respectively. The optimal choice is to eat Apple 2, so the answer is (-1)+1=0.\n\nSample Input 3\n\n30 -50\n\nSample Output 3\n\n-1044", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 244, "memory_kb": 37616}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s358293881", "group_id": "codeNet:p02994", "input_text": "fun main(args: Array) {\n val (N, L) = readLine()!!.split(\" \").map { Integer.parseInt(it) }\n val tasteList = mutableListOf()\n for (i in 1 until N + 1) {\n tasteList.add(L + i - 1)\n }\n val tasteListAbs = tasteList.map { Math.abs(it) }\n tasteList.removeAt(tasteListAbs.indexOf(tasteListAbs.min()!!))\n print(tasteList.sum())\n\n}\n", "language": "Kotlin", "metadata": {"date": 1561252240, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02994.html", "problem_id": "p02994", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02994/input.txt", "sample_output_relpath": "derived/input_output/data/p02994/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02994/Kotlin/s358293881.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s358293881", "user_id": "u039197338"}, "prompt_components": {"gold_output": "18\n", "input_to_evaluate": "fun main(args: Array) {\n val (N, L) = readLine()!!.split(\" \").map { Integer.parseInt(it) }\n val tasteList = mutableListOf()\n for (i in 1 until N + 1) {\n tasteList.add(L + i - 1)\n }\n val tasteListAbs = tasteList.map { Math.abs(it) }\n tasteList.removeAt(tasteListAbs.indexOf(tasteListAbs.min()!!))\n print(tasteList.sum())\n\n}\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nYou have N apples, called Apple 1, Apple 2, Apple 3, ..., Apple N. The flavor of Apple i is L+i-1, which can be negative.\n\nYou can make an apple pie using one or more of the apples. The flavor of the apple pie will be the sum of the flavors of the apples used.\n\nYou planned to make an apple pie using all of the apples, but being hungry tempts you to eat one of them, which can no longer be used to make the apple pie.\n\nYou want to make an apple pie that is as similar as possible to the one that you planned to make. Thus, you will choose the apple to eat so that the flavor of the apple pie made of the remaining N-1 apples will have the smallest possible absolute difference from the flavor of the apple pie made of all the N apples.\n\nFind the flavor of the apple pie made of the remaining N-1 apples when you choose the apple to eat as above.\n\nWe can prove that this value is uniquely determined.\n\nConstraints\n\n2 \\leq N \\leq 200\n\n-100 \\leq L \\leq 100\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN L\n\nOutput\n\nFind the flavor of the apple pie made of the remaining N-1 apples when you optimally choose the apple to eat.\n\nSample Input 1\n\n5 2\n\nSample Output 1\n\n18\n\nThe flavors of Apple 1, 2, 3, 4, and 5 are 2, 3, 4, 5, and 6, respectively. The optimal choice is to eat Apple 1, so the answer is 3+4+5+6=18.\n\nSample Input 2\n\n3 -1\n\nSample Output 2\n\n0\n\nThe flavors of Apple 1, 2, and 3 are -1, 0, and 1, respectively. The optimal choice is to eat Apple 2, so the answer is (-1)+1=0.\n\nSample Input 3\n\n30 -50\n\nSample Output 3\n\n-1044", "sample_input": "5 2\n"}, "reference_outputs": ["18\n"], "source_document_id": "p02994", "source_text": "Score : 200 points\n\nProblem Statement\n\nYou have N apples, called Apple 1, Apple 2, Apple 3, ..., Apple N. The flavor of Apple i is L+i-1, which can be negative.\n\nYou can make an apple pie using one or more of the apples. The flavor of the apple pie will be the sum of the flavors of the apples used.\n\nYou planned to make an apple pie using all of the apples, but being hungry tempts you to eat one of them, which can no longer be used to make the apple pie.\n\nYou want to make an apple pie that is as similar as possible to the one that you planned to make. Thus, you will choose the apple to eat so that the flavor of the apple pie made of the remaining N-1 apples will have the smallest possible absolute difference from the flavor of the apple pie made of all the N apples.\n\nFind the flavor of the apple pie made of the remaining N-1 apples when you choose the apple to eat as above.\n\nWe can prove that this value is uniquely determined.\n\nConstraints\n\n2 \\leq N \\leq 200\n\n-100 \\leq L \\leq 100\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN L\n\nOutput\n\nFind the flavor of the apple pie made of the remaining N-1 apples when you optimally choose the apple to eat.\n\nSample Input 1\n\n5 2\n\nSample Output 1\n\n18\n\nThe flavors of Apple 1, 2, 3, 4, and 5 are 2, 3, 4, 5, and 6, respectively. The optimal choice is to eat Apple 1, so the answer is 3+4+5+6=18.\n\nSample Input 2\n\n3 -1\n\nSample Output 2\n\n0\n\nThe flavors of Apple 1, 2, and 3 are -1, 0, and 1, respectively. The optimal choice is to eat Apple 2, so the answer is (-1)+1=0.\n\nSample Input 3\n\n30 -50\n\nSample Output 3\n\n-1044", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 247, "memory_kb": 37932}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s690955758", "group_id": "codeNet:p02995", "input_text": "fun main(args: Array){\n val (a, b, c, d) = readLine()!!.split(\" \").map { it.toLong() }\n val divC = (b / c) - (a - 1) / c\n val divD = (b / d) - (a - 1) / d\n val divCD = (b / (c * d)) - (a - 1) / (c * d)\n val count = b - (a - 1)\n\n println(count - (divC + divD - divCD))\n}", "language": "Kotlin", "metadata": {"date": 1589224665, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02995.html", "problem_id": "p02995", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02995/input.txt", "sample_output_relpath": "derived/input_output/data/p02995/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02995/Kotlin/s690955758.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s690955758", "user_id": "u531770859"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "fun main(args: Array){\n val (a, b, c, d) = readLine()!!.split(\" \").map { it.toLong() }\n val divC = (b / c) - (a - 1) / c\n val divD = (b / d) - (a - 1) / d\n val divCD = (b / (c * d)) - (a - 1) / (c * d)\n val count = b - (a - 1)\n\n println(count - (divC + divD - divCD))\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nYou are given four integers A, B, C, and D. Find the number of integers between A and B (inclusive) that can be evenly divided by neither C nor D.\n\nConstraints\n\n1\\leq A\\leq B\\leq 10^{18}\n\n1\\leq C,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 number of integers between A and B (inclusive) that can be evenly divided by neither C nor D.\n\nSample Input 1\n\n4 9 2 3\n\nSample Output 1\n\n2\n\n5 and 7 satisfy the condition.\n\nSample Input 2\n\n10 40 6 8\n\nSample Output 2\n\n23\n\nSample Input 3\n\n314159265358979323 846264338327950288 419716939 937510582\n\nSample Output 3\n\n532105071133627368", "sample_input": "4 9 2 3\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02995", "source_text": "Score : 300 points\n\nProblem Statement\n\nYou are given four integers A, B, C, and D. Find the number of integers between A and B (inclusive) that can be evenly divided by neither C nor D.\n\nConstraints\n\n1\\leq A\\leq B\\leq 10^{18}\n\n1\\leq C,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 number of integers between A and B (inclusive) that can be evenly divided by neither C nor D.\n\nSample Input 1\n\n4 9 2 3\n\nSample Output 1\n\n2\n\n5 and 7 satisfy the condition.\n\nSample Input 2\n\n10 40 6 8\n\nSample Output 2\n\n23\n\nSample Input 3\n\n314159265358979323 846264338327950288 419716939 937510582\n\nSample Output 3\n\n532105071133627368", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 241, "memory_kb": 37776}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s919954761", "group_id": "codeNet:p02995", "input_text": "fun main(args: Array) {\n val (a,b,c,d) = readLine()!!.split(' ').map { s -> s.toLong() }\n //val (n,x) = readLine()!!.split(\" \").map { s -> s.toLong() }\n //val L = readLine()!!.split(\" \").map { s -> s.toLong() }\n val result = countNumber(b,c,d) - countNumber(a-1L,c,d)\n println(countNumber(b,c,d))\n}\n\nfun countNumber(x: Long, c: Long, d: Long): Long {\n var c_cnt = (x / c).toLong()\n var d_cnt = (x / d).toLong()\n var cd_cnt = (x / lcm(c,d)).toLong()\n return(x - c_cnt - d_cnt + cd_cnt)\n}\n\nfun gcd(a: Long, b: Long): Long = if(a < b) gcd(b, a) else if(b == 0L) a else gcd(b, a % b)\nfun lcm(a: Long, b: Long): Long = (a * b) / gcd(a, b)", "language": "Kotlin", "metadata": {"date": 1588517935, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02995.html", "problem_id": "p02995", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02995/input.txt", "sample_output_relpath": "derived/input_output/data/p02995/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02995/Kotlin/s919954761.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s919954761", "user_id": "u994064513"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "fun main(args: Array) {\n val (a,b,c,d) = readLine()!!.split(' ').map { s -> s.toLong() }\n //val (n,x) = readLine()!!.split(\" \").map { s -> s.toLong() }\n //val L = readLine()!!.split(\" \").map { s -> s.toLong() }\n val result = countNumber(b,c,d) - countNumber(a-1L,c,d)\n println(countNumber(b,c,d))\n}\n\nfun countNumber(x: Long, c: Long, d: Long): Long {\n var c_cnt = (x / c).toLong()\n var d_cnt = (x / d).toLong()\n var cd_cnt = (x / lcm(c,d)).toLong()\n return(x - c_cnt - d_cnt + cd_cnt)\n}\n\nfun gcd(a: Long, b: Long): Long = if(a < b) gcd(b, a) else if(b == 0L) a else gcd(b, a % b)\nfun lcm(a: Long, b: Long): Long = (a * b) / gcd(a, b)", "problem_context": "Score : 300 points\n\nProblem Statement\n\nYou are given four integers A, B, C, and D. Find the number of integers between A and B (inclusive) that can be evenly divided by neither C nor D.\n\nConstraints\n\n1\\leq A\\leq B\\leq 10^{18}\n\n1\\leq C,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 number of integers between A and B (inclusive) that can be evenly divided by neither C nor D.\n\nSample Input 1\n\n4 9 2 3\n\nSample Output 1\n\n2\n\n5 and 7 satisfy the condition.\n\nSample Input 2\n\n10 40 6 8\n\nSample Output 2\n\n23\n\nSample Input 3\n\n314159265358979323 846264338327950288 419716939 937510582\n\nSample Output 3\n\n532105071133627368", "sample_input": "4 9 2 3\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02995", "source_text": "Score : 300 points\n\nProblem Statement\n\nYou are given four integers A, B, C, and D. Find the number of integers between A and B (inclusive) that can be evenly divided by neither C nor D.\n\nConstraints\n\n1\\leq A\\leq B\\leq 10^{18}\n\n1\\leq C,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 number of integers between A and B (inclusive) that can be evenly divided by neither C nor D.\n\nSample Input 1\n\n4 9 2 3\n\nSample Output 1\n\n2\n\n5 and 7 satisfy the condition.\n\nSample Input 2\n\n10 40 6 8\n\nSample Output 2\n\n23\n\nSample Input 3\n\n314159265358979323 846264338327950288 419716939 937510582\n\nSample Output 3\n\n532105071133627368", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 668, "cpu_time_ms": 232, "memory_kb": 38304}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s594324419", "group_id": "codeNet:p02995", "input_text": "fun main(args: Array) = println(run {\n val (a,b,c,d) = readLine()!!.split(\" \").map { it.toLong() }\n fun count(x: Long) = x - x/c - x/d + x/((c*d)/gcd(c,d))\n count(b)-count(a-1)\n})\n\ntailrec fun gcd(a: Long, b: Long): Long = if (b == 0L) a else gcd(b, a % b)\n", "language": "Kotlin", "metadata": {"date": 1588507420, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02995.html", "problem_id": "p02995", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02995/input.txt", "sample_output_relpath": "derived/input_output/data/p02995/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02995/Kotlin/s594324419.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s594324419", "user_id": "u563556491"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "fun main(args: Array) = println(run {\n val (a,b,c,d) = readLine()!!.split(\" \").map { it.toLong() }\n fun count(x: Long) = x - x/c - x/d + x/((c*d)/gcd(c,d))\n count(b)-count(a-1)\n})\n\ntailrec fun gcd(a: Long, b: Long): Long = if (b == 0L) a else gcd(b, a % b)\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nYou are given four integers A, B, C, and D. Find the number of integers between A and B (inclusive) that can be evenly divided by neither C nor D.\n\nConstraints\n\n1\\leq A\\leq B\\leq 10^{18}\n\n1\\leq C,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 number of integers between A and B (inclusive) that can be evenly divided by neither C nor D.\n\nSample Input 1\n\n4 9 2 3\n\nSample Output 1\n\n2\n\n5 and 7 satisfy the condition.\n\nSample Input 2\n\n10 40 6 8\n\nSample Output 2\n\n23\n\nSample Input 3\n\n314159265358979323 846264338327950288 419716939 937510582\n\nSample Output 3\n\n532105071133627368", "sample_input": "4 9 2 3\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02995", "source_text": "Score : 300 points\n\nProblem Statement\n\nYou are given four integers A, B, C, and D. Find the number of integers between A and B (inclusive) that can be evenly divided by neither C nor D.\n\nConstraints\n\n1\\leq A\\leq B\\leq 10^{18}\n\n1\\leq C,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 number of integers between A and B (inclusive) that can be evenly divided by neither C nor D.\n\nSample Input 1\n\n4 9 2 3\n\nSample Output 1\n\n2\n\n5 and 7 satisfy the condition.\n\nSample Input 2\n\n10 40 6 8\n\nSample Output 2\n\n23\n\nSample Input 3\n\n314159265358979323 846264338327950288 419716939 937510582\n\nSample Output 3\n\n532105071133627368", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 236, "memory_kb": 37968}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s371389606", "group_id": "codeNet:p02995", "input_text": "fun main(args: Array) {\n fun gcd(a: Long, b: Long): Long {\n return if (b > 0) gcd(b, a % b) else a\n }\n val (a, b, c, d) = readLine()!!.split(' ').map(String::toLong)\n var total = b - a + 1\n total -= b / c\n total += (a - 1) / c\n total -= b / d\n total += (a - 1) / d\n total += b / (d * c / gcd(d,c))\n total -= (a - 1) / (d * c / gcd(d,c))\n\n println(total)\n}\n", "language": "Kotlin", "metadata": {"date": 1561230994, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02995.html", "problem_id": "p02995", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02995/input.txt", "sample_output_relpath": "derived/input_output/data/p02995/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02995/Kotlin/s371389606.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s371389606", "user_id": "u099066216"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "fun main(args: Array) {\n fun gcd(a: Long, b: Long): Long {\n return if (b > 0) gcd(b, a % b) else a\n }\n val (a, b, c, d) = readLine()!!.split(' ').map(String::toLong)\n var total = b - a + 1\n total -= b / c\n total += (a - 1) / c\n total -= b / d\n total += (a - 1) / d\n total += b / (d * c / gcd(d,c))\n total -= (a - 1) / (d * c / gcd(d,c))\n\n println(total)\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nYou are given four integers A, B, C, and D. Find the number of integers between A and B (inclusive) that can be evenly divided by neither C nor D.\n\nConstraints\n\n1\\leq A\\leq B\\leq 10^{18}\n\n1\\leq C,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 number of integers between A and B (inclusive) that can be evenly divided by neither C nor D.\n\nSample Input 1\n\n4 9 2 3\n\nSample Output 1\n\n2\n\n5 and 7 satisfy the condition.\n\nSample Input 2\n\n10 40 6 8\n\nSample Output 2\n\n23\n\nSample Input 3\n\n314159265358979323 846264338327950288 419716939 937510582\n\nSample Output 3\n\n532105071133627368", "sample_input": "4 9 2 3\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02995", "source_text": "Score : 300 points\n\nProblem Statement\n\nYou are given four integers A, B, C, and D. Find the number of integers between A and B (inclusive) that can be evenly divided by neither C nor D.\n\nConstraints\n\n1\\leq A\\leq B\\leq 10^{18}\n\n1\\leq C,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 number of integers between A and B (inclusive) that can be evenly divided by neither C nor D.\n\nSample Input 1\n\n4 9 2 3\n\nSample Output 1\n\n2\n\n5 and 7 satisfy the condition.\n\nSample Input 2\n\n10 40 6 8\n\nSample Output 2\n\n23\n\nSample Input 3\n\n314159265358979323 846264338327950288 419716939 937510582\n\nSample Output 3\n\n532105071133627368", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 404, "cpu_time_ms": 242, "memory_kb": 36428}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s576450087", "group_id": "codeNet:p02996", "input_text": "fun main(args: Array){\n val n = readLine()!!.toInt()\n val a = mutableListOf>()\n for (i in 0 until n){\n readLine()!!.split(\" \").map { it.toInt() }.let {\n a.add(Pair(it[0], it[1]))\n }\n }\n a.sortBy { it.second }\n\n var i = 0\n a.forEach {\n i += it.first\n if(i >= it.second){\n println(\"No\")\n return\n }\n }\n println(\"YES\")\n}", "language": "Kotlin", "metadata": {"date": 1588880364, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02996.html", "problem_id": "p02996", "resource_group": "medium_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/Kotlin/s576450087.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s576450087", "user_id": "u531770859"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "fun main(args: Array){\n val n = readLine()!!.toInt()\n val a = mutableListOf>()\n for (i in 0 until n){\n readLine()!!.split(\" \").map { it.toInt() }.let {\n a.add(Pair(it[0], it[1]))\n }\n }\n a.sortBy { it.second }\n\n var i = 0\n a.forEach {\n i += it.first\n if(i >= it.second){\n println(\"No\")\n return\n }\n }\n println(\"YES\")\n}", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1028, "memory_kb": 127420}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s862768329", "group_id": "codeNet:p02996", "input_text": "fun main(args: Array) {\n val N = nextInt()\n fun listOfIntToPair(p: List): Pair = Pair(p[0], p[1])\n val AB = Array>(N, { listOfIntToPair(listOfInt()) }).sortedBy { it.second }\n var ans = true\n var t = 0\n repeat(N) {\n t += AB[it].first\n if (t > AB[it].second) ans = false\n }\n println(\"${if (ans) \"Yes\" else \"No\"}\")\n}\nfun next() = readLine()!!\nfun nextInt() = Integer.parseInt(next())\nfun listOfString() = next().split(\" \")\nfun listOfInt() = listOfString().map { Integer.parseInt(it) }\n", "language": "Kotlin", "metadata": {"date": 1561286583, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02996.html", "problem_id": "p02996", "resource_group": "medium_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/Kotlin/s862768329.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s862768329", "user_id": "u043150661"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "fun main(args: Array) {\n val N = nextInt()\n fun listOfIntToPair(p: List): Pair = Pair(p[0], p[1])\n val AB = Array>(N, { listOfIntToPair(listOfInt()) }).sortedBy { it.second }\n var ans = true\n var t = 0\n repeat(N) {\n t += AB[it].first\n if (t > AB[it].second) ans = false\n }\n println(\"${if (ans) \"Yes\" else \"No\"}\")\n}\nfun next() = readLine()!!\nfun nextInt() = Integer.parseInt(next())\nfun listOfString() = next().split(\" \")\nfun listOfInt() = listOfString().map { Integer.parseInt(it) }\n", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1265, "memory_kb": 129124}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s716154446", "group_id": "codeNet:p02996", "input_text": "fun main(args: Array) {\n val n = readLine()!!.toInt()\n val abList = mutableListOf>()\n (1..n).forEach {\n val (a, b) = readLine()!!.split(' ').map(String::toLong)\n abList.add(Pair(a, b))\n }\n abList.sortBy { it.second }\n\n var sum = 0L\n for (i in 0 until n) {\n sum += abList[i].first\n if (sum > abList[i].second) {\n println(\"No\")\n return\n }\n }\n println(\"Yes\")\n}", "language": "Kotlin", "metadata": {"date": 1561231256, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02996.html", "problem_id": "p02996", "resource_group": "medium_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/Kotlin/s716154446.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s716154446", "user_id": "u099066216"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "fun main(args: Array) {\n val n = readLine()!!.toInt()\n val abList = mutableListOf>()\n (1..n).forEach {\n val (a, b) = readLine()!!.split(' ').map(String::toLong)\n abList.add(Pair(a, b))\n }\n abList.sortBy { it.second }\n\n var sum = 0L\n for (i in 0 until n) {\n sum += abList[i].first\n if (sum > abList[i].second) {\n println(\"No\")\n return\n }\n }\n println(\"Yes\")\n}", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 466, "cpu_time_ms": 1035, "memory_kb": 135332}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s758896253", "group_id": "codeNet:p02999", "input_text": "import java.util.*\n\nfun main(args: Array) {\n val scanner = Scanner(System.`in`)\n\n val x = scanner.nextInt()\n val a = scanner.nextInt()\n\n println(if (x < a) 0 else 10)\n\n}\n", "language": "Kotlin", "metadata": {"date": 1561144838, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02999.html", "problem_id": "p02999", "resource_group": "medium_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/Kotlin/s758896253.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s758896253", "user_id": "u632369368"}, "prompt_components": {"gold_output": "0\n", "input_to_evaluate": "import java.util.*\n\nfun main(args: Array) {\n val scanner = Scanner(System.`in`)\n\n val x = scanner.nextInt()\n val a = scanner.nextInt()\n\n println(if (x < a) 0 else 10)\n\n}\n", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 189, "memory_kb": 29600}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s966200061", "group_id": "codeNet:p02999", "input_text": "fun main(args: Array) {\n val (x,a) = readLine()!!.split(\" \").map { it.toInt() }\n if(x) {\n val (x,a) = readLine()!!.split(\" \").map { it.toInt() }\n if(x){\n\tval cin = Scanner(System.`in`)\n val x = cin.nextInt()\n val a = cin.nextInt()\n if (a > x) {\n println(\"0\")\n } else {\n println(\"10\")\n }\n \n}", "language": "Kotlin", "metadata": {"date": 1560711692, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02999.html", "problem_id": "p02999", "resource_group": "medium_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/Kotlin/s798159807.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s798159807", "user_id": "u111421568"}, "prompt_components": {"gold_output": "0\n", "input_to_evaluate": "import java.util.*\nfun main(args: Array){\n\tval cin = Scanner(System.`in`)\n val x = cin.nextInt()\n val a = cin.nextInt()\n if (a > x) {\n println(\"0\")\n } else {\n println(\"10\")\n }\n \n}", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 186, "memory_kb": 31392}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s015894517", "group_id": "codeNet:p03001", "input_text": "fun main(args: Array) {\n val (W, H, x, y) = readLine()!!.split(' ').map { it.toLong() }\n val ans = H * W / 2\n if (W == x * 2 && H == y * 2) {\n println(\"$ans 1\")\n } else {\n println(\"$ans 0\")\n }\n}", "language": "Kotlin", "metadata": {"date": 1564758899, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03001.html", "problem_id": "p03001", "resource_group": "medium_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/Kotlin/s015894517.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s015894517", "user_id": "u562388762"}, "prompt_components": {"gold_output": "3.000000 0\n", "input_to_evaluate": "fun main(args: Array) {\n val (W, H, x, y) = readLine()!!.split(' ').map { it.toLong() }\n val ans = H * W / 2\n if (W == x * 2 && H == y * 2) {\n println(\"$ans 1\")\n } else {\n println(\"$ans 0\")\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 234, "memory_kb": 38052}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s342872268", "group_id": "codeNet:p03001", "input_text": "fun main(args: Array) {\n val (W, H, x, y) = readLine()!!.split(' ').map { it.toLong() }\n val rec0 = x * (H - y)\n val rec1 = (W - x) * (H - y)\n val rec2 = x * y\n val rec3 = (W - x) * y\n val maxRec = arrayOf(rec0 + rec1, rec0 + rec2, rec1 + rec3, rec2 + rec3).max()\n var ans = 0L\n when (maxRec) {\n rec0 + rec1 -> ans = arrayOf(rec2 + rec3, rec1 + rec3, rec0 + rec2).max()!!.toLong()\n rec0 + rec2 -> ans = arrayOf(rec0 + rec1, rec1 + rec3, rec2 + rec3).max()!!.toLong()\n rec1 + rec3 -> ans = arrayOf(rec0 + rec1, rec0 + rec2, rec2 + rec3).max()!!.toLong()\n rec2 + rec3 -> ans = arrayOf(rec0 + rec1, rec0 + rec2, rec1 + rec3).max()!!.toLong()\n }\n if (W == x * 2 && H == y * 2) {\n println(\"$ans 1\")\n } else {\n println(\"$ans 0\")\n }\n}", "language": "Kotlin", "metadata": {"date": 1564754935, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03001.html", "problem_id": "p03001", "resource_group": "medium_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/Kotlin/s342872268.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s342872268", "user_id": "u562388762"}, "prompt_components": {"gold_output": "3.000000 0\n", "input_to_evaluate": "fun main(args: Array) {\n val (W, H, x, y) = readLine()!!.split(' ').map { it.toLong() }\n val rec0 = x * (H - y)\n val rec1 = (W - x) * (H - y)\n val rec2 = x * y\n val rec3 = (W - x) * y\n val maxRec = arrayOf(rec0 + rec1, rec0 + rec2, rec1 + rec3, rec2 + rec3).max()\n var ans = 0L\n when (maxRec) {\n rec0 + rec1 -> ans = arrayOf(rec2 + rec3, rec1 + rec3, rec0 + rec2).max()!!.toLong()\n rec0 + rec2 -> ans = arrayOf(rec0 + rec1, rec1 + rec3, rec2 + rec3).max()!!.toLong()\n rec1 + rec3 -> ans = arrayOf(rec0 + rec1, rec0 + rec2, rec2 + rec3).max()!!.toLong()\n rec2 + rec3 -> ans = arrayOf(rec0 + rec1, rec0 + rec2, rec1 + rec3).max()!!.toLong()\n }\n if (W == x * 2 && H == y * 2) {\n println(\"$ans 1\")\n } else {\n println(\"$ans 0\")\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 813, "cpu_time_ms": 235, "memory_kb": 38300}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s632288359", "group_id": "codeNet:p03006", "input_text": "fun main(args: Array) {\n diverta20192b()\n}\n\nprivate data class Coordinate(val x: Long, val y: Long)\n\nfun diverta20192b() {\n val n = readLine()!!.toInt()\n val coordinates = (1..n).map { readLine()!!.split(' ').map { it.toLong() } }\n .map { Coordinate(it[0], it[1]) }\n\n if (n == 1) return println(1)\n\n val diffMap = mutableMapOf()\n\n for (i1 in 0 until coordinates.lastIndex) {\n for (i2 in i1 + 1..coordinates.lastIndex) {\n val c1 = coordinates[i1]\n val c2 = coordinates[i2]\n val diffX = c1.x - c2.x\n val diffY = c1.y - c2.y\n val diff = if (diffX >= 0) Coordinate(diffX, diffY) else Coordinate(-diffX, -diffY)\n diffMap.put(diff, diffMap.getOrElse(diff, { 0 }) + 1)\n }\n }\n\n val max = diffMap.map { it.value }.max()!!\n\n val answer = n - max\n\n println(answer)\n}\n", "language": "Kotlin", "metadata": {"date": 1578047324, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03006.html", "problem_id": "p03006", "resource_group": "medium_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/Kotlin/s632288359.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s632288359", "user_id": "u139478771"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "fun main(args: Array) {\n diverta20192b()\n}\n\nprivate data class Coordinate(val x: Long, val y: Long)\n\nfun diverta20192b() {\n val n = readLine()!!.toInt()\n val coordinates = (1..n).map { readLine()!!.split(' ').map { it.toLong() } }\n .map { Coordinate(it[0], it[1]) }\n\n if (n == 1) return println(1)\n\n val diffMap = mutableMapOf()\n\n for (i1 in 0 until coordinates.lastIndex) {\n for (i2 in i1 + 1..coordinates.lastIndex) {\n val c1 = coordinates[i1]\n val c2 = coordinates[i2]\n val diffX = c1.x - c2.x\n val diffY = c1.y - c2.y\n val diff = if (diffX >= 0) Coordinate(diffX, diffY) else Coordinate(-diffX, -diffY)\n diffMap.put(diff, diffMap.getOrElse(diff, { 0 }) + 1)\n }\n }\n\n val max = diffMap.map { it.value }.max()!!\n\n val answer = n - max\n\n println(answer)\n}\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 898, "cpu_time_ms": 245, "memory_kb": 38176}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s340561507", "group_id": "codeNet:p03006", "input_text": "fun main(args: Array) {\n val n = Integer.parseInt(readInputLine())\n val pos: MutableList> = mutableListOf()\n for (i in 1..n) {\n val inputs = readInputLine().split(\" \").map { it.toLong() }\n val x = inputs[0]\n val y = inputs[1]\n \n pos.add(Pair(x, y))\n }\n \n // 取得したボール座標をマンハッタン距離でソート(負方向は負の距離とする)\n pos.sortBy { it -> it.first + it.second }\n\n val firstPos = pos[0]\n val distances: MutableList> = mutableListOf()\n for (i in 1 until n) {\n distances.add(Pair(firstPos.first - pos[i].first, firstPos.second - pos[i].second))\n }\n\n val res = distances.toList().fold(\n Int.MAX_VALUE,\n { r, t -> \n val tmp = solve(pos, t)\n if (tmp < r) tmp else r})\n\n println(\"$res\")\n}\n \nfun readInputLine(): String {\n return readLine()!!\n}\n\nfun solve(list: List>, distance: Pair): Int {\n if (list.size == 0) {\n return 0\n }\n if (list.size == 1) {\n return 1\n } else {\n var newList = list.toList()\n newList = newList.drop(1)\n var drop = 1\n var pos = list[0]\n while (newList.size != 0 && pos.first - newList[0].first == distance.first && pos.second - newList[0].second == distance.second) {\n drop++\n pos = newList[0]\n newList = newList.drop(1)\n }\n \n return solve(newList, distance) + 1\n }\n}\n", "language": "Kotlin", "metadata": {"date": 1560651231, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03006.html", "problem_id": "p03006", "resource_group": "medium_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/Kotlin/s340561507.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s340561507", "user_id": "u505558493"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "fun main(args: Array) {\n val n = Integer.parseInt(readInputLine())\n val pos: MutableList> = mutableListOf()\n for (i in 1..n) {\n val inputs = readInputLine().split(\" \").map { it.toLong() }\n val x = inputs[0]\n val y = inputs[1]\n \n pos.add(Pair(x, y))\n }\n \n // 取得したボール座標をマンハッタン距離でソート(負方向は負の距離とする)\n pos.sortBy { it -> it.first + it.second }\n\n val firstPos = pos[0]\n val distances: MutableList> = mutableListOf()\n for (i in 1 until n) {\n distances.add(Pair(firstPos.first - pos[i].first, firstPos.second - pos[i].second))\n }\n\n val res = distances.toList().fold(\n Int.MAX_VALUE,\n { r, t -> \n val tmp = solve(pos, t)\n if (tmp < r) tmp else r})\n\n println(\"$res\")\n}\n \nfun readInputLine(): String {\n return readLine()!!\n}\n\nfun solve(list: List>, distance: Pair): Int {\n if (list.size == 0) {\n return 0\n }\n if (list.size == 1) {\n return 1\n } else {\n var newList = list.toList()\n newList = newList.drop(1)\n var drop = 1\n var pos = list[0]\n while (newList.size != 0 && pos.first - newList[0].first == distance.first && pos.second - newList[0].second == distance.second) {\n drop++\n pos = newList[0]\n newList = newList.drop(1)\n }\n \n return solve(newList, distance) + 1\n }\n}\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1534, "cpu_time_ms": 275, "memory_kb": 40460}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s149854539", "group_id": "codeNet:p03007", "input_text": "fun main(args: Array) {\n val n = Integer.parseInt(readInputLine())\n var a: MutableList = mutableListOf()\n \n val inputs = readInputLine().split(\" \").map { it.toLong() }\n for (i in 0 until n) {\n a.add(inputs[i])\n }\n\n a.sort()\n \n val b: MutableList> = mutableListOf()\n \n while (a.size != 2) {\n val x = a.removeAt(0)\n val y = a.removeAt(a.size - 2)\n a.add(0, x - y)\n b.add(Pair(x, y))\n }\n \n b.add(Pair(a[1], a[0]))\n \n println(\"${a[1] - a[0]}\")\n \n for (elem in b) {\n println(\"${elem.first} ${elem.second}\")\n }\n}\n \nfun readInputLine(): String {\n return readLine()!!\n}\n", "language": "Kotlin", "metadata": {"date": 1560652923, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03007.html", "problem_id": "p03007", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03007/input.txt", "sample_output_relpath": "derived/input_output/data/p03007/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03007/Kotlin/s149854539.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s149854539", "user_id": "u505558493"}, "prompt_components": {"gold_output": "4\n-1 1\n2 -2\n", "input_to_evaluate": "fun main(args: Array) {\n val n = Integer.parseInt(readInputLine())\n var a: MutableList = mutableListOf()\n \n val inputs = readInputLine().split(\" \").map { it.toLong() }\n for (i in 0 until n) {\n a.add(inputs[i])\n }\n\n a.sort()\n \n val b: MutableList> = mutableListOf()\n \n while (a.size != 2) {\n val x = a.removeAt(0)\n val y = a.removeAt(a.size - 2)\n a.add(0, x - y)\n b.add(Pair(x, y))\n }\n \n b.add(Pair(a[1], a[0]))\n \n println(\"${a[1] - a[0]}\")\n \n for (elem in b) {\n println(\"${elem.first} ${elem.second}\")\n }\n}\n \nfun readInputLine(): String {\n return readLine()!!\n}\n", "problem_context": "Score : 500 points\n\nProblem Statement\n\nThere are N integers, A_1, A_2, ..., A_N, written on a blackboard.\n\nWe will repeat the following operation N-1 times so that we have only one integer on the blackboard.\n\nChoose two integers x and y on the blackboard and erase these two integers. Then, write a new integer x-y.\n\nFind the maximum possible value of the final integer on the blackboard and a sequence of operations that maximizes the final integer.\n\nConstraints\n\n2 \\leq N \\leq 10^5\n\n-10^4 \\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\nN\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the maximum possible value M of the final integer on the blackboard, and a sequence of operations x_i, y_i that maximizes the final integer, in the format below.\n\nHere x_i and y_i represent the integers x and y chosen in the i-th operation, respectively.\n\nIf there are multiple sequences of operations that maximize the final integer, any of them will be accepted.\n\nM\nx_1 y_1\n:\nx_{N-1} y_{N-1}\n\nSample Input 1\n\n3\n1 -1 2\n\nSample Output 1\n\n4\n-1 1\n2 -2\n\nIf we choose x = -1 and y = 1 in the first operation, the set of integers written on the blackboard becomes (-2, 2).\n\nThen, if we choose x = 2 and y = -2 in the second operation, the set of integers written on the blackboard becomes (4).\n\nIn this case, we have 4 as the final integer. We cannot end with a greater integer, so the answer is 4.\n\nSample Input 2\n\n3\n1 1 1\n\nSample Output 2\n\n1\n1 1\n1 0", "sample_input": "3\n1 -1 2\n"}, "reference_outputs": ["4\n-1 1\n2 -2\n"], "source_document_id": "p03007", "source_text": "Score : 500 points\n\nProblem Statement\n\nThere are N integers, A_1, A_2, ..., A_N, written on a blackboard.\n\nWe will repeat the following operation N-1 times so that we have only one integer on the blackboard.\n\nChoose two integers x and y on the blackboard and erase these two integers. Then, write a new integer x-y.\n\nFind the maximum possible value of the final integer on the blackboard and a sequence of operations that maximizes the final integer.\n\nConstraints\n\n2 \\leq N \\leq 10^5\n\n-10^4 \\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\nN\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the maximum possible value M of the final integer on the blackboard, and a sequence of operations x_i, y_i that maximizes the final integer, in the format below.\n\nHere x_i and y_i represent the integers x and y chosen in the i-th operation, respectively.\n\nIf there are multiple sequences of operations that maximize the final integer, any of them will be accepted.\n\nM\nx_1 y_1\n:\nx_{N-1} y_{N-1}\n\nSample Input 1\n\n3\n1 -1 2\n\nSample Output 1\n\n4\n-1 1\n2 -2\n\nIf we choose x = -1 and y = 1 in the first operation, the set of integers written on the blackboard becomes (-2, 2).\n\nThen, if we choose x = 2 and y = -2 in the second operation, the set of integers written on the blackboard becomes (4).\n\nIn this case, we have 4 as the final integer. We cannot end with a greater integer, so the answer is 4.\n\nSample Input 2\n\n3\n1 1 1\n\nSample Output 2\n\n1\n1 1\n1 0", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 695, "cpu_time_ms": 2111, "memory_kb": 59820}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s040883119", "group_id": "codeNet:p03008", "input_text": "import java.io.PrintWriter\nval pw = PrintWriter(System.out)\nfun main(args: Array) {\n func()\n pw.flush()\n}\nfun print(value: Any) { pw.print(value) }\nfun println(value: Any) { pw.println(value) }\n\nfun func() {\n val N = nextInt()\n val A = listOfInt()\n val B = listOfInt()\n\n var max = 0\n for (x in 0 .. 6) {\n val gsb = intArrayOf(0, 0, 0)\n val d1 = f(A, N, x and 3, gsb, x and 4)\n for (y in 0 .. 6) {\n val d2 = f(B, d1, y and 3, gsb, y and 4)\n for (z in 0 .. 6) {\n val d3 = f(A, d2, z and 3, gsb, z and 4)\n max = Math.max(d3, max)\n }\n }\n }\n\n println(\"${max}\")\n}\n\nfun f(AB: List, d: Int, i: Int, gsb: IntArray, uk: Int): Int {\n if (i > 2) return d\n var res = d\n if (uk == 0) {\n gsb[i] += res / AB[i]\n res %= AB[i]\n } else {\n res += gsb[i] * AB[i]\n gsb[i] = 0\n }\n return res\n}\n\nfun next() = readLine()!!\nfun nextInt() = Integer.parseInt(next())\nfun listOfString() = next().split(\" \")\nfun listOfInt() = listOfString().map { Integer.parseInt(it) }\n", "language": "Kotlin", "metadata": {"date": 1560650858, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03008.html", "problem_id": "p03008", "resource_group": "medium_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/Kotlin/s040883119.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s040883119", "user_id": "u911700901"}, "prompt_components": {"gold_output": "46\n", "input_to_evaluate": "import java.io.PrintWriter\nval pw = PrintWriter(System.out)\nfun main(args: Array) {\n func()\n pw.flush()\n}\nfun print(value: Any) { pw.print(value) }\nfun println(value: Any) { pw.println(value) }\n\nfun func() {\n val N = nextInt()\n val A = listOfInt()\n val B = listOfInt()\n\n var max = 0\n for (x in 0 .. 6) {\n val gsb = intArrayOf(0, 0, 0)\n val d1 = f(A, N, x and 3, gsb, x and 4)\n for (y in 0 .. 6) {\n val d2 = f(B, d1, y and 3, gsb, y and 4)\n for (z in 0 .. 6) {\n val d3 = f(A, d2, z and 3, gsb, z and 4)\n max = Math.max(d3, max)\n }\n }\n }\n\n println(\"${max}\")\n}\n\nfun f(AB: List, d: Int, i: Int, gsb: IntArray, uk: Int): Int {\n if (i > 2) return d\n var res = d\n if (uk == 0) {\n gsb[i] += res / AB[i]\n res %= AB[i]\n } else {\n res += gsb[i] * AB[i]\n gsb[i] = 0\n }\n return res\n}\n\nfun next() = readLine()!!\nfun nextInt() = Integer.parseInt(next())\nfun listOfString() = next().split(\" \")\nfun listOfInt() = listOfString().map { Integer.parseInt(it) }\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1117, "cpu_time_ms": 249, "memory_kb": 37904}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s889662580", "group_id": "codeNet:p03017", "input_text": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val n = sc.nextInt()\n val a = sc.nextInt()\n val b = sc.nextInt()\n val c = sc.nextInt()\n val d = sc.nextInt()\n val s = sc.next()\n\n val sub = s.subSequence(a, d)\n var ok = true\n if (c < d) {\n if (sub.contains(\"##\")) ok = false\n } else {\n ok = false\n\n if (sub.contains(\"...\")) ok = true\n if (s[d-2] == '.' && s[d] == '.') ok = true\n if (sub.contains(\"##\")) ok = false\n }\n\n\n if (ok) {\n println(\"Yes\")\n return\n }\n println(\"No\")\n\n}", "language": "Kotlin", "metadata": {"date": 1597885677, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p03017.html", "problem_id": "p03017", "resource_group": "medium_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/Kotlin/s889662580.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s889662580", "user_id": "u323522006"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val n = sc.nextInt()\n val a = sc.nextInt()\n val b = sc.nextInt()\n val c = sc.nextInt()\n val d = sc.nextInt()\n val s = sc.next()\n\n val sub = s.subSequence(a, d)\n var ok = true\n if (c < d) {\n if (sub.contains(\"##\")) ok = false\n } else {\n ok = false\n\n if (sub.contains(\"...\")) ok = true\n if (s[d-2] == '.' && s[d] == '.') ok = true\n if (sub.contains(\"##\")) ok = false\n }\n\n\n if (ok) {\n println(\"Yes\")\n return\n }\n println(\"No\")\n\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 545, "cpu_time_ms": 222, "memory_kb": 42120}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s020460370", "group_id": "codeNet:p03017", "input_text": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val n = sc.nextInt()\n val a = sc.nextInt()\n val b = sc.nextInt()\n val c = sc.nextInt()\n val d = sc.nextInt()\n val s = sc.next()\n println(problem034a(n, a, b, c, d, s))\n}\n\nfun problem034a(n: Int, a: Int, b: Int, c: Int, d: Int, s: String): String {\n var sunuke = a\n var funuke = b\n var isSunukeMoved = true\n var isFunukeMoved = true\n val canReplace = (\"x{3,}?\".toRegex().containsMatchIn(s.replace(\".\", \"x\")))\n loop@ while (isSunukeMoved || isFunukeMoved) {\n if (sunuke == c && funuke == d) {\n return \"Yes\"\n }\n when {\n sunuke > c -> {\n if (sunuke - 1 == c && (canReplace || sunuke - 1 != funuke)) {\n sunuke--\n isSunukeMoved = true\n continue@loop\n }\n if ((canReplace || sunuke - 2 != funuke) && s[sunuke - 1 - 2] != '#') {\n sunuke -= 2\n isSunukeMoved = true\n continue@loop\n }\n if ((canReplace || sunuke - 1 != funuke) && s[sunuke - 1 - 2] != '#') {\n sunuke--\n isSunukeMoved = true\n continue@loop\n }\n }\n sunuke < c -> {\n if (sunuke + 1 == c && (canReplace || sunuke + 1 != funuke)) {\n sunuke++\n isSunukeMoved = true\n continue@loop\n }\n if ((canReplace || sunuke + 2 != funuke) && s[sunuke - 1 + 2] != '#') {\n sunuke += 2\n isSunukeMoved = true\n continue@loop\n }\n if ((canReplace || sunuke + 1 != funuke) && s[sunuke - 1 + 1] != '#') {\n sunuke++\n isSunukeMoved = true\n continue@loop\n }\n }\n sunuke == c -> {\n isSunukeMoved = false\n }\n }\n when {\n funuke > d -> {\n if (funuke - 1 == d && (canReplace || funuke - 1 != sunuke)) {\n funuke--\n isFunukeMoved = true\n continue@loop\n }\n if ((canReplace || funuke - 2 != sunuke) && s[funuke - 1 - 2] != '#') {\n funuke -= 2\n isFunukeMoved = true\n continue@loop\n }\n if ((canReplace || funuke - 1 != sunuke) && s[funuke - 1 - 2] != '#') {\n funuke--\n isFunukeMoved = true\n continue@loop\n }\n }\n funuke < d -> {\n if (funuke + 1 == d && (canReplace || funuke + 1 != sunuke)) {\n funuke++\n isFunukeMoved = true\n continue@loop\n }\n if ((canReplace || funuke + 2 != sunuke) && s[funuke - 1 + 2] != '#') {\n funuke += 2\n isFunukeMoved = true\n continue@loop\n }\n if ((canReplace || funuke + 1 != sunuke) && s[funuke - 1 + 1] != '#') {\n funuke++\n isFunukeMoved = true\n continue@loop\n }\n }\n }\n isFunukeMoved = false\n isSunukeMoved = false\n }\n return \"No\"\n}", "language": "Kotlin", "metadata": {"date": 1591833984, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03017.html", "problem_id": "p03017", "resource_group": "medium_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/Kotlin/s020460370.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s020460370", "user_id": "u073232808"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val n = sc.nextInt()\n val a = sc.nextInt()\n val b = sc.nextInt()\n val c = sc.nextInt()\n val d = sc.nextInt()\n val s = sc.next()\n println(problem034a(n, a, b, c, d, s))\n}\n\nfun problem034a(n: Int, a: Int, b: Int, c: Int, d: Int, s: String): String {\n var sunuke = a\n var funuke = b\n var isSunukeMoved = true\n var isFunukeMoved = true\n val canReplace = (\"x{3,}?\".toRegex().containsMatchIn(s.replace(\".\", \"x\")))\n loop@ while (isSunukeMoved || isFunukeMoved) {\n if (sunuke == c && funuke == d) {\n return \"Yes\"\n }\n when {\n sunuke > c -> {\n if (sunuke - 1 == c && (canReplace || sunuke - 1 != funuke)) {\n sunuke--\n isSunukeMoved = true\n continue@loop\n }\n if ((canReplace || sunuke - 2 != funuke) && s[sunuke - 1 - 2] != '#') {\n sunuke -= 2\n isSunukeMoved = true\n continue@loop\n }\n if ((canReplace || sunuke - 1 != funuke) && s[sunuke - 1 - 2] != '#') {\n sunuke--\n isSunukeMoved = true\n continue@loop\n }\n }\n sunuke < c -> {\n if (sunuke + 1 == c && (canReplace || sunuke + 1 != funuke)) {\n sunuke++\n isSunukeMoved = true\n continue@loop\n }\n if ((canReplace || sunuke + 2 != funuke) && s[sunuke - 1 + 2] != '#') {\n sunuke += 2\n isSunukeMoved = true\n continue@loop\n }\n if ((canReplace || sunuke + 1 != funuke) && s[sunuke - 1 + 1] != '#') {\n sunuke++\n isSunukeMoved = true\n continue@loop\n }\n }\n sunuke == c -> {\n isSunukeMoved = false\n }\n }\n when {\n funuke > d -> {\n if (funuke - 1 == d && (canReplace || funuke - 1 != sunuke)) {\n funuke--\n isFunukeMoved = true\n continue@loop\n }\n if ((canReplace || funuke - 2 != sunuke) && s[funuke - 1 - 2] != '#') {\n funuke -= 2\n isFunukeMoved = true\n continue@loop\n }\n if ((canReplace || funuke - 1 != sunuke) && s[funuke - 1 - 2] != '#') {\n funuke--\n isFunukeMoved = true\n continue@loop\n }\n }\n funuke < d -> {\n if (funuke + 1 == d && (canReplace || funuke + 1 != sunuke)) {\n funuke++\n isFunukeMoved = true\n continue@loop\n }\n if ((canReplace || funuke + 2 != sunuke) && s[funuke - 1 + 2] != '#') {\n funuke += 2\n isFunukeMoved = true\n continue@loop\n }\n if ((canReplace || funuke + 1 != sunuke) && s[funuke - 1 + 1] != '#') {\n funuke++\n isFunukeMoved = true\n continue@loop\n }\n }\n }\n isFunukeMoved = false\n isSunukeMoved = false\n }\n return \"No\"\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 3537, "cpu_time_ms": 623, "memory_kb": 44144}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s874397557", "group_id": "codeNet:p03017", "input_text": "fun main(args: Array) {\n agc034a()\n}\n\nfun agc034a() {\n val (n, a, b, c, d) = readLine()!!.split(\" \").map { it.toInt() - 1 }\n val road = readLine()!!.map { it == '.' }.toBooleanArray()\n\n if (road.slice(a until Math.max(c, d)).withIndex().any { !it.value && !road[it.index - 1] }) return println(\"No\")\n\n if (c < d) return println(\"Yes\")\n\n return if (road.slice(b + 1..c - 2).withIndex().any { it.value && road[it.index + 1] && road[it.index + 2] }) {\n println(\"Yes\")\n } else println(\"No\")\n}\n", "language": "Kotlin", "metadata": {"date": 1573108480, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03017.html", "problem_id": "p03017", "resource_group": "medium_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/Kotlin/s874397557.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s874397557", "user_id": "u139478771"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "fun main(args: Array) {\n agc034a()\n}\n\nfun agc034a() {\n val (n, a, b, c, d) = readLine()!!.split(\" \").map { it.toInt() - 1 }\n val road = readLine()!!.map { it == '.' }.toBooleanArray()\n\n if (road.slice(a until Math.max(c, d)).withIndex().any { !it.value && !road[it.index - 1] }) return println(\"No\")\n\n if (c < d) return println(\"Yes\")\n\n return if (road.slice(b + 1..c - 2).withIndex().any { it.value && road[it.index + 1] && road[it.index + 2] }) {\n println(\"Yes\")\n } else println(\"No\")\n}\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 525, "cpu_time_ms": 333, "memory_kb": 41480}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s539890689", "group_id": "codeNet:p03017", "input_text": "fun main(args: Array) {\n\n var (n ,a, b, c, d) = readLine()!!.split(\" \").map { it.toInt() }\n a -= 1\n b -= 1\n c -= 1\n d -= 1\n val inputs = readLine()!!.toString()\n\n // 岩が連続してる場合 かつ一番遠いゴールがそれよりも先の場合\n if (inputs.indexOf(\"##\") != -1 && inputs.indexOf(\"##\") <= Math.max(c, d)) {\n println(\"No\")\n return\n }\n\n // 岩が存在するが,すべてゴールより先にある場合 or 岩が存在しない場合\n if (inputs.indexOf(\"#\") == -1 || inputs.indexOf(\"#\") >= Math.max(c, d)) {\n println(\"Yes\")\n return\n }\n\n // C < D の場合 で B が先に D へ行ってしまえば良いので可能\n if (c < d) {\n println(\"Yes\")\n return\n }\n\n /**\n * C > D でかつ,Dが岩の隣りにあって かつ 抜かせない場合\n */\n\n // C>D でかつ岩の隣に D がある(左右) か���, A が Bを抜かせる場所がゴールよりも前にないとき\n // AをBより先に行かせられないとき\n\n fun isDNextToStone(): Boolean{\n if (d == inputs.lastIndex) {\n return inputs[d-1] == '#'\n }\n\n if (d == 0) {\n return inputs[d+1] == '#'\n }\n\n return inputs[d-1] == '#' || inputs[d+1] == '#'\n }\n\n fun canAovertakeB(): Boolean {\n if (inputs.subSequence(b-1, d).indexOf(\"...\") == -1){\n return false\n }\n\n return true\n }\n\n // D の隣に岩がない場合\n if (inputs[d-1]=='.' && inputs[d+1]=='.') {\n println(\"Yes\")\n return\n }\n\n // D の両側が岩の場合\n if (inputs[d-1]=='#' && inputs[d+1]=='#') {\n println(\"No\")\n return\n }\n\n // C>D でかつ岩の隣に D がある(左右) かつ,A が B を抜かせる場所が B, D 内に無い\n if (isDNextToStone() && !canAovertakeB()) {\n println(\"No\")\n return\n }\n\n // D が岩の隣ない\n println(\"Yes\")\n}", "language": "Kotlin", "metadata": {"date": 1559528244, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03017.html", "problem_id": "p03017", "resource_group": "medium_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/Kotlin/s539890689.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s539890689", "user_id": "u889750959"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "fun main(args: Array) {\n\n var (n ,a, b, c, d) = readLine()!!.split(\" \").map { it.toInt() }\n a -= 1\n b -= 1\n c -= 1\n d -= 1\n val inputs = readLine()!!.toString()\n\n // 岩が連続してる場合 かつ一番遠いゴールがそれよりも先の場合\n if (inputs.indexOf(\"##\") != -1 && inputs.indexOf(\"##\") <= Math.max(c, d)) {\n println(\"No\")\n return\n }\n\n // 岩が存在するが,すべてゴールより先にある場合 or 岩が存在しない場合\n if (inputs.indexOf(\"#\") == -1 || inputs.indexOf(\"#\") >= Math.max(c, d)) {\n println(\"Yes\")\n return\n }\n\n // C < D の場合 で B が先に D へ行ってしまえば良いので可能\n if (c < d) {\n println(\"Yes\")\n return\n }\n\n /**\n * C > D でかつ,Dが岩の隣りにあって かつ 抜かせない場合\n */\n\n // C>D でかつ岩の隣に D がある(左右) かつ, A が Bを抜かせる場所がゴールよりも前にないとき\n // AをBより先に行かせられないとき\n\n fun isDNextToStone(): Boolean{\n if (d == inputs.lastIndex) {\n return inputs[d-1] == '#'\n }\n\n if (d == 0) {\n return inputs[d+1] == '#'\n }\n\n return inputs[d-1] == '#' || inputs[d+1] == '#'\n }\n\n fun canAovertakeB(): Boolean {\n if (inputs.subSequence(b-1, d).indexOf(\"...\") == -1){\n return false\n }\n\n return true\n }\n\n // D の隣に岩がない場合\n if (inputs[d-1]=='.' && inputs[d+1]=='.') {\n println(\"Yes\")\n return\n }\n\n // D の両側が岩の場合\n if (inputs[d-1]=='#' && inputs[d+1]=='#') {\n println(\"No\")\n return\n }\n\n // C>D でかつ岩の隣に D がある(左右) かつ,A が B を抜かせる場所が B, D 内に無い\n if (isDNextToStone() && !canAovertakeB()) {\n println(\"No\")\n return\n }\n\n // D が岩の隣ない\n println(\"Yes\")\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1995, "cpu_time_ms": 290, "memory_kb": 41540}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s549563890", "group_id": "codeNet:p03017", "input_text": "fun main(arg: Array){\n val (N, A, B, C, D) = readLine()!!.split(\" \").map(String::toInt)\n val S = readLine()!!\n val A_last = S.substring(A - 1, listOf(C, D).max()!!)\n val common_S = S.substring(listOf(A, B).max()!! - 1, listOf(C, D).min()!!)\n\n if(A_last.contains(\"##\")){\n System.err.println(\"double ##\")\n println(\"No\")\n }else{\n if(C < D){\n System.err.println(\"C < D\")\n println(\"Yes\")\n }else{\n System.err.println(\"S[D - 2]: ${S[D - 2]}, S[D} = ${S[D]}\")\n val sideX = S[D - 2] == '#' || if(D <= N) '#' == S[D] else false\n if(sideX && !common_S.contains(\"...\")){\n System.err.println(\"cannot cross\")\n println(\"No\")\n }else{\n System.err.println(\"sideX: ${sideX}\")\n println(\"Yes\")\n }\n }\n }\n\n}\n", "language": "Kotlin", "metadata": {"date": 1559525638, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03017.html", "problem_id": "p03017", "resource_group": "medium_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/Kotlin/s549563890.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s549563890", "user_id": "u716826907"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "fun main(arg: Array){\n val (N, A, B, C, D) = readLine()!!.split(\" \").map(String::toInt)\n val S = readLine()!!\n val A_last = S.substring(A - 1, listOf(C, D).max()!!)\n val common_S = S.substring(listOf(A, B).max()!! - 1, listOf(C, D).min()!!)\n\n if(A_last.contains(\"##\")){\n System.err.println(\"double ##\")\n println(\"No\")\n }else{\n if(C < D){\n System.err.println(\"C < D\")\n println(\"Yes\")\n }else{\n System.err.println(\"S[D - 2]: ${S[D - 2]}, S[D} = ${S[D]}\")\n val sideX = S[D - 2] == '#' || if(D <= N) '#' == S[D] else false\n if(sideX && !common_S.contains(\"...\")){\n System.err.println(\"cannot cross\")\n println(\"No\")\n }else{\n System.err.println(\"sideX: ${sideX}\")\n println(\"Yes\")\n }\n }\n }\n\n}\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 886, "cpu_time_ms": 288, "memory_kb": 39600}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s186866886", "group_id": "codeNet:p03025", "input_text": "fun main(args: Array) {\n\n /**\n * A : B : C = 勝ち : 負け : 引き分け の確率の時に N 回どちらかが勝つまで勝負を続けるとした時の勝負回数の期待値\n * 組み合わせの計算は事前に配列にO(N) で計算しておいて必要な時に O(1) で取り出せるようにしておく必要がある\n */\n\n val (n, a, b, c) = readLine()!!.split(\" \").map { it.toLong() }\n val modVal = (1e9 + 7).toLong()\n\n // mod 値テーブルを初期化\n initTable(modVal)\n\n // 引き分けが存在しない場合での期待値を求める ( 引き分けが入る場合は,求めた期待値を引き分けの割合分,足してあげれば良い\n\n // 片方が n 回勝つまでに もう片方が i 回かつ場合の期待値\n fun calc_n回勝つまでにもう片方がi回かつ場合の期待値(i: Long): Long {\n\n val patternNum = combinationModWithTable(n-1 + i, i, modVal)\n\n // 逆元Mod計算 // おそらく計算の組み合わせ方法が違うので再���が必要\n\n powMod(inv[100], 4, modVal)\n\n val probAwinMod = modTimes(listOf(powMod(a, n, modVal), powMod(inv[(a+b).toInt()], n, modVal), powMod(b, i, modVal), powMod(inv[(a+b).toInt()], i, modVal)), modVal)\n val probBwinMod = modTimes(listOf(powMod(b, n, modVal), powMod(inv[(a+b).toInt()], n, modVal), powMod(a, i, modVal), powMod(inv[(a+b).toInt()], i, modVal)), modVal)\n\n // この部分 OverFlowしてそう\n return modTimes(listOf(patternNum, (probAwinMod + probBwinMod), n + i), modVal)\n }\n\n var ans = 0L\n for (i in 0 until n) {\n ans = (ans + calc_n回勝つまでにもう片方がi回かつ場合の期待値(i)) % modVal\n }\n\n // c% 引き分けが入るの -> c / a + b + c = c/100 で引き分け -> 勝負がつく回数は (100-c) / 100 -> 全体の勝負回数は 100 / (100-c) になる (増える)\n println((ans * 100 / (100 - c) % modVal))\n}\n\n/**\n * プロコンで頻出の mod 計算を定義したクラス\n *\n * 参考 : https://qiita.com/drken/items/3b4fdf0a78e7a138cd9a\n */\n\n// 階乗の mod 並びに 逆元の mod を格納するための配列を初期化\nprivate const val MAX = 1e7.toInt() // MAX は求める必要がある階乗の部分の計算に対してのみ求める\nprivate val fact = LongArray(MAX+1){-1} // n 番目は n! の mod\nprivate val finv = LongArray(MAX+1){-1} // n 番目は n! の逆元\nprivate val inv = LongArray(MAX+1){-1} // n 番目は n! の逆元\n\n\n/**\n * 階乗のmod 並びに 逆元 テーブルを初期化\n * それぞれの計算には漸化式を用いており,各逆元の計算は O(1) で行われる.フェルマーの小定理も,拡張Euclid の互除法も必要ない OMG\n * mod値が 1e9+7 だと,途中計算で mod を求める前に Long最大値 を超えるので LongArray を使用\n *\n * テーブル全体(N)ではなく,単体で逆元計算を行うときには上記定理を用いた計算を実行すると O(N) -> O(log modVal) に計算量を削減できる\n *\n * <注意>\n * nCk mod p の計算に用いる際の暗黙の前提 : p > n かつ k! (k<=n) のどれとも p が一致しない -> 「p が n より大きい素数」 だと条件が満たされやすい\n * 例えば modVal 以上の 階乗のmod値は 0 になるので注意 5C2 mod 3 とかを計算しようとすると分子の階乗部分が 0 になって正しく計算できないので注意\n * 正しくは (5*4 / 2*1) mod 3 = 1 だが,この方式だと (5*4*3*2*1 / 2*1*3*2*1) mod 3 = 0 となってしまう\n */\nfun initTable(modVal: Long) {\n\n //初期値設定\n fact[0] = 1\n fact[1] = 1\n inv[0] = 1 //?\n inv[1] = 1\n\n for ( i in 2..MAX) {\n\n // 階乗の mod については普通に掛け算 & mod 計算でOK\n fact[i] = fact[i-1] * i % modVal\n\n // 各 i に対する逆元を求めて格納しておく (finv 確認 or 直接計算 )\n\n // 実装上の工夫\n // 1.modVal を足しているのは inv[i] を常に正の値にするため ( inv[i] は常に modVal を前提とした計算で用いるので modVal が加えられていても影響は無い)\n // 2. 新たな inv[i] を求める時に % modVal をしているのは 値のオーバーフローを避けるため & inv[i] は常にm modVal を前提とした計算で 掛け算に用いられるため どの段階で %modVal をとっても影響は無い\n\n inv[i] = modVal - inv[(modVal % i).toInt()] * (modVal / i) % modVal\n\n // inv[i] の結果を finv[i-1] に掛け合わせて mod を取った結果が finv[i] ( 逆元の累乗 ) 累乗の逆元 = 逆元の総積\n finv[i] = finv[i-1] * inv[i] % modVal\n }\n}\n\n\n/**\n * 事前に計算した逆元テーブルから nCk mod modVal を計算\n */\nfun combinationModWithTable(n: Long, k: Long, modVal: Long): Long {\n val numeTerm = fact[n.toInt()]\n val denomTerm = finv[k.toInt()] * finv[(n-k).toInt()] % modVal\n\n return (numeTerm * denomTerm % modVal)\n}\n\n\n/**\n * nCk mod modVal を計算する\n *\n * 分子部分は O(N) で計算\n * 分母を考える際に 割り算に対する mod を定義する必要がある\n */\n@Deprecated(message = \"This Implementation might be wrong. Use combinationModWithTable\")\nfun combinationMod(n: Long, k: Long, modVal: Long): Long {\n\n // O(N)\n val nume = factMod(n, modVal)\n\n // これは実は間違っている\n // 累乗の modVal 後の 逆元 と 累乗の逆元は異なる 式的には\n // r! = q (mod p の場合) でも (r!)^-1 = q^-1 (mod p の場合) は成り立たないということ, いや成り立つかはわからないので使わないほうがbetter\n val denom = (factMod(k, modVal) * factMod(n - k, modVal)) % modVal\n\n // -> この方針だと OverFlow を避けるために, k! の逆元を求めるために 1 ~ k の各値の逆元を計算しなくてはいけない O(k log K?) は必要なので辛い?\n\n return modDiv(nume, denom, modVal)\n}\n\nprivate fun factMod(n: Long, modVal: Long): Long {\n var ans = 1L\n for (i in 1..n) {\n ans = (ans * i) % modVal\n }\n\n return ans\n}\n\n\nfun modTimes(inputs: List, modVal: Long): Long {\n return inputs.reduce { acc, i -> (acc % modVal) * (i % modVal) % modVal }\n}\n\n/**\n * mod の世界での割り算を実装\n *\n * a/b mod p を求めたい場合 mod p における b の逆元(b^-1)を求めて (a * b^-1) mod p とする\n */\n\nfun modDiv(numerator: Long, denominator: Long, modVal: Long): Long {\n\n // 拡張Euclidの互除法を用いた 逆元計算の実装では 負の 値が返ってくることもあるので ( + modVal) % modVal をする\n val invMod = (invModEuclid(denominator, modVal).first + modVal) % modVal\n\n return (numerator * invMod) % modVal\n}\n\n/**\n * mod modVal の世界での逆元を求める O(log modVal)\n *\n * 定義 a * b mod modVal = 1 となるとき b を mod modVal の世界での逆元と呼ぶ\n *\n * -> x / a mod modVal = x * b mod modVal と書き換える事ができる\n * -> mod の掛け算は逐次計算できるので OverFlow を避けられる (嬉しい)\n *\n * フェルマーの小定理を元にした実装, modVal は素数である必要がある\n */\nfun invModFermat(a: Long, modVal: Long): Long {\n return powMod(a, modVal - 2, modVal)\n}\n\n\n/**\n * mod b の世界での a の逆元を求める\n * ユークリッドの互除法に類似した計算を行うので 最悪 O(log modVal) (ユークリッドの互除法の計算量は log modVal 以下になる)\n * -> 平均的には フェルマーの小定理を用いた逆元計算よりも計算量が少なくなる (あちらは 累乗計算で 必ず log(modVal-2) 必要\n *\n * a と modVal は互いに素 である必要がある\n * <-> a , modVal が互いに素 でないとしたら?\n *\n * ax + by = c を満たす整数 x, y が存在する必要十分条件は c = k gcd(a,b) を満たす k が存在すること (そうでなければ整数解は存在しない)\n *\n * ->\n *\n * ax + by = gcd(a,b) を満たす x, y は存在する\n *\n * ->\n *\n * a, b が互いに素 であれば\n *\n * ax + by = 1 を満たす x, y は存在する といえる\n *\n * ->\n *\n * つまり逆元が存在する -> ユークリッドの互除法で解を求める\n *\n * ※ 「mod p において a の逆元が存在する」 と 「ax + py = 1 となる 整数解 x,y が存在する」 は等価なので\n * 「mod p において a の逆元が存在する」 ための必要十分条件は 「p と a が互いに素」\n *\n * 丁寧に再帰計算で実装する,, アドレスを渡して,グローバル変数のようにみなして計算するのは賢すぎるので変数で渡していくことを考える\n * -> 2つの値を受け取って2つの値を返す実装に\n *\n * なお,最終的に用いる値は 返された値の第一要素なので注意 (使いづらい?)また,負の値が返ってくるかもしれないことには注意\n */\nfun invModEuclid(a: Long, b: Long) : Pair {\n\n // 互除法同様, 渡されたあまりが 0 になったら再帰を終了する\n if (b == 0L) {\n return Pair(1, 0)\n }\n\n // 1つ下の b, a%b に対する計算結果から a, b についての結果を計算する\n val (s, t) = invModEuclid(b, a%b)\n\n return Pair(t, s - a/b * t)\n}\n\n/**\n * a^n mod modVal を計算する\n * 二分累乗法で累乗計算を O(logN) で行いつつ,OverFlow を避けるため適宜 mod 計算を行う\n */\nfun powMod(a: Long, n: Long, modVal: Long, ans: Long = 1): Long {\n\n if (n == 0L) {\n return ans\n }\n\n // ビット演算の結果 2^0 の桁が 0 の場合は ans に掛けずに次の桁へ\n if (n.and(1L) == 0L) {\n return powMod(a * a % modVal, n.shr(1), modVal, ans)\n }\n\n // ビット演算の結果 2^9 の毛型 1 の場合は ans を更新\n return powMod(a * a % modVal, n.shr(1), modVal, ans * a % modVal)\n}\n\n\n/**\n * 二分累乗法の実装 a^N を O(logN) で計算\n * 指数部分を2進数で考える -> 指数が2^n になっていなくても問題ない\n */\nprivate fun pow(a: Long, n: Long, ans: Long = 1): Long {\n\n if (n == 0L) {\n return ans\n }\n\n // ビット演算の結果 2^0 の桁が 0 の場合は ans に掛けずに次の桁へ\n if (n.and(1L) == 0L) {\n return pow(a * a, n.shr(1), ans)\n }\n\n // ビット演算の結果 2^9 の毛型 1 の場合は ans を更新\n return pow(a * a, n.shr(1), ans * a)\n}", "language": "Kotlin", "metadata": {"date": 1560108034, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03025.html", "problem_id": "p03025", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03025/input.txt", "sample_output_relpath": "derived/input_output/data/p03025/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03025/Kotlin/s186866886.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s186866886", "user_id": "u889750959"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "fun main(args: Array) {\n\n /**\n * A : B : C = 勝ち : 負け : 引き分け の確率の時に N 回どちらかが勝つまで勝負を続けるとした時の勝負回数の期待値\n * 組み合わせの計算は事前に配列にO(N) で計算しておいて必要な時に O(1) で取り出せるようにしておく必要がある\n */\n\n val (n, a, b, c) = readLine()!!.split(\" \").map { it.toLong() }\n val modVal = (1e9 + 7).toLong()\n\n // mod 値テーブルを初期化\n initTable(modVal)\n\n // 引き分けが存在しない場合での期待値を求める ( 引き分けが入る場合は,求めた期待値を引き分けの割合分,足してあげれば良い\n\n // 片方が n 回勝つまでに もう片方が i 回かつ場合の期待値\n fun calc_n回勝つまでにもう片方がi回かつ場合の期待値(i: Long): Long {\n\n val patternNum = combinationModWithTable(n-1 + i, i, modVal)\n\n // 逆元Mod計算 // おそらく計算の組み合わせ方法が違うので再考が必要\n\n powMod(inv[100], 4, modVal)\n\n val probAwinMod = modTimes(listOf(powMod(a, n, modVal), powMod(inv[(a+b).toInt()], n, modVal), powMod(b, i, modVal), powMod(inv[(a+b).toInt()], i, modVal)), modVal)\n val probBwinMod = modTimes(listOf(powMod(b, n, modVal), powMod(inv[(a+b).toInt()], n, modVal), powMod(a, i, modVal), powMod(inv[(a+b).toInt()], i, modVal)), modVal)\n\n // この部分 OverFlowしてそう\n return modTimes(listOf(patternNum, (probAwinMod + probBwinMod), n + i), modVal)\n }\n\n var ans = 0L\n for (i in 0 until n) {\n ans = (ans + calc_n回勝つまでにもう片方がi回かつ場合の期待値(i)) % modVal\n }\n\n // c% 引き分けが入るの -> c / a + b + c = c/100 で引き分け -> 勝負がつく回数は (100-c) / 100 -> 全体の勝負回数は 100 / (100-c) になる (増える)\n println((ans * 100 / (100 - c) % modVal))\n}\n\n/**\n * プロコンで頻出の mod 計算を定義したクラス\n *\n * 参考 : https://qiita.com/drken/items/3b4fdf0a78e7a138cd9a\n */\n\n// 階乗の mod 並びに 逆元の mod を格納するための配列を初期化\nprivate const val MAX = 1e7.toInt() // MAX は求める必要がある階乗の部分の計算に対してのみ求める\nprivate val fact = LongArray(MAX+1){-1} // n 番目は n! の mod\nprivate val finv = LongArray(MAX+1){-1} // n 番目は n! の逆元\nprivate val inv = LongArray(MAX+1){-1} // n 番目は n! の逆元\n\n\n/**\n * 階乗のmod 並びに 逆元 テーブルを初期化\n * それぞれの計算には漸化式を用いており,各逆元の計算は O(1) で行われる.フェルマーの小定理も,拡張Euclid の互除法も必要ない OMG\n * mod値が 1e9+7 だと,途中計算で mod を求める前に Long最大値 を超えるので LongArray を使用\n *\n * テーブル全体(N)ではなく,単体で逆元計算を行うときには上記定理を用いた計算を実行すると O(N) -> O(log modVal) に計算量を削減できる\n *\n * <注意>\n * nCk mod p の計算に用いる際の暗黙の前提 : p > n かつ k! (k<=n) のどれとも p が一致しない -> 「p が n より大きい素数」 だと条件が満たされやすい\n * 例えば modVal 以上の 階乗のmod値は 0 になるので注意 5C2 mod 3 とかを計算しようとすると分子の階乗部分が 0 になって正しく計算できないので注意\n * 正しくは (5*4 / 2*1) mod 3 = 1 だが,この方式だと (5*4*3*2*1 / 2*1*3*2*1) mod 3 = 0 となってしまう\n */\nfun initTable(modVal: Long) {\n\n //初期値設定\n fact[0] = 1\n fact[1] = 1\n inv[0] = 1 //?\n inv[1] = 1\n\n for ( i in 2..MAX) {\n\n // 階乗の mod については普通に掛け算 & mod 計算でOK\n fact[i] = fact[i-1] * i % modVal\n\n // 各 i に対する逆元を求めて格納しておく (finv 確認 or 直接計算 )\n\n // 実装上の工夫\n // 1.modVal を足しているのは inv[i] を常に正の値にするため ( inv[i] は常に modVal を前提とした計算で用いるので modVal が加えられていても影響は無い)\n // 2. 新たな inv[i] を求める時に % modVal をしているのは 値のオーバーフローを避けるため & inv[i] は常にm modVal を前提とした計算で 掛け算に用いられるため どの段階で %modVal をとっても影響は無い\n\n inv[i] = modVal - inv[(modVal % i).toInt()] * (modVal / i) % modVal\n\n // inv[i] の結果を finv[i-1] に掛け合わせて mod を取った結果が finv[i] ( 逆元の累乗 ) 累乗の逆元 = 逆元の総積\n finv[i] = finv[i-1] * inv[i] % modVal\n }\n}\n\n\n/**\n * 事前に計算した逆元テーブルから nCk mod modVal を計算\n */\nfun combinationModWithTable(n: Long, k: Long, modVal: Long): Long {\n val numeTerm = fact[n.toInt()]\n val denomTerm = finv[k.toInt()] * finv[(n-k).toInt()] % modVal\n\n return (numeTerm * denomTerm % modVal)\n}\n\n\n/**\n * nCk mod modVal を計算する\n *\n * 分子部分は O(N) で計算\n * 分母を考える際に 割り算に対する mod を定義する必要がある\n */\n@Deprecated(message = \"This Implementation might be wrong. Use combinationModWithTable\")\nfun combinationMod(n: Long, k: Long, modVal: Long): Long {\n\n // O(N)\n val nume = factMod(n, modVal)\n\n // これは実は間違っている\n // 累乗の modVal 後の 逆元 と 累乗の逆元は異なる 式的には\n // r! = q (mod p の場合) でも (r!)^-1 = q^-1 (mod p の場合) は成り立たないということ, いや成り立つかはわからないので使わないほうがbetter\n val denom = (factMod(k, modVal) * factMod(n - k, modVal)) % modVal\n\n // -> この方針だと OverFlow を避けるために, k! の逆元を求めるために 1 ~ k の各値の逆元を計算しなくてはいけない O(k log K?) は必要なので辛い?\n\n return modDiv(nume, denom, modVal)\n}\n\nprivate fun factMod(n: Long, modVal: Long): Long {\n var ans = 1L\n for (i in 1..n) {\n ans = (ans * i) % modVal\n }\n\n return ans\n}\n\n\nfun modTimes(inputs: List, modVal: Long): Long {\n return inputs.reduce { acc, i -> (acc % modVal) * (i % modVal) % modVal }\n}\n\n/**\n * mod の世界での割り算を実装\n *\n * a/b mod p を求めたい場合 mod p における b の逆元(b^-1)を求めて (a * b^-1) mod p とする\n */\n\nfun modDiv(numerator: Long, denominator: Long, modVal: Long): Long {\n\n // 拡張Euclidの互除法を用いた 逆元計算の実装では 負の 値が返ってくることもあるので ( + modVal) % modVal をする\n val invMod = (invModEuclid(denominator, modVal).first + modVal) % modVal\n\n return (numerator * invMod) % modVal\n}\n\n/**\n * mod modVal の世界での逆元を求める O(log modVal)\n *\n * 定義 a * b mod modVal = 1 となるとき b を mod modVal の世界での逆元と呼ぶ\n *\n * -> x / a mod modVal = x * b mod modVal と書き換える事ができる\n * -> mod の掛け算は逐次計算できるので OverFlow を避けられる (嬉しい)\n *\n * フェルマーの小定理を元にした実装, modVal は素数である必要がある\n */\nfun invModFermat(a: Long, modVal: Long): Long {\n return powMod(a, modVal - 2, modVal)\n}\n\n\n/**\n * mod b の世界での a の逆元を求める\n * ユークリッドの互除法に類似した計算を行うので 最悪 O(log modVal) (ユークリッドの互除法の計算量は log modVal 以下になる)\n * -> 平均的には フェルマーの小定理を用いた逆元計算よりも計算量が少なくなる (あちらは 累乗計算で 必ず log(modVal-2) 必要\n *\n * a と modVal は互いに素 である必要がある\n * <-> a , modVal が互いに素 でないとしたら?\n *\n * ax + by = c を満たす整数 x, y が存在する必要十分条件は c = k gcd(a,b) を満たす k が存在すること (そうでなければ整数解は存在しない)\n *\n * ->\n *\n * ax + by = gcd(a,b) を満たす x, y は存在する\n *\n * ->\n *\n * a, b が互いに素 であれば\n *\n * ax + by = 1 を満たす x, y は存在する といえる\n *\n * ->\n *\n * つまり逆元が存在する -> ユークリッドの互除法で解を求める\n *\n * ※ 「mod p において a の逆元が存在する」 と 「ax + py = 1 となる 整数解 x,y が存在する」 は等価なので\n * 「mod p において a の逆元が存在する」 ための必要十分条件は 「p と a が互いに素」\n *\n * 丁寧に再帰計算で実装する,, アドレスを渡して,グローバル変数のようにみなして計算するのは賢すぎるので変数で渡していくことを考える\n * -> 2つの値を受け取って2つの値を返す実装に\n *\n * なお,最終的に用いる値は 返された値の第一要素なので注意 (使いづらい?)また,負の値が返ってくるかもしれないことには注意\n */\nfun invModEuclid(a: Long, b: Long) : Pair {\n\n // 互除法同様, 渡されたあまりが 0 になったら再帰を終了する\n if (b == 0L) {\n return Pair(1, 0)\n }\n\n // 1つ下の b, a%b に対する計算結果から a, b についての結果を計算する\n val (s, t) = invModEuclid(b, a%b)\n\n return Pair(t, s - a/b * t)\n}\n\n/**\n * a^n mod modVal を計算する\n * 二分累乗法で累乗計算を O(logN) で行いつつ,OverFlow を避けるため適宜 mod 計算を行う\n */\nfun powMod(a: Long, n: Long, modVal: Long, ans: Long = 1): Long {\n\n if (n == 0L) {\n return ans\n }\n\n // ビット演算の結果 2^0 の桁が 0 の場合は ans に掛けずに次の桁へ\n if (n.and(1L) == 0L) {\n return powMod(a * a % modVal, n.shr(1), modVal, ans)\n }\n\n // ビット演算の結果 2^9 の毛型 1 の場合は ans を更新\n return powMod(a * a % modVal, n.shr(1), modVal, ans * a % modVal)\n}\n\n\n/**\n * 二分累乗法の実装 a^N を O(logN) で計算\n * 指数部分を2進数で考える -> 指数が2^n になっていなくても問題ない\n */\nprivate fun pow(a: Long, n: Long, ans: Long = 1): Long {\n\n if (n == 0L) {\n return ans\n }\n\n // ビット演算の結果 2^0 の桁が 0 の場合は ans に掛けずに次の桁へ\n if (n.and(1L) == 0L) {\n return pow(a * a, n.shr(1), ans)\n }\n\n // ビット演算の結果 2^9 の毛型 1 の場合は ans を更新\n return pow(a * a, n.shr(1), ans * a)\n}", "problem_context": "Score : 500 points\n\nProblem Statement\n\nTakahashi and Aoki will play a game. They will repeatedly play it until one of them have N wins in total.\n\nWhen they play the game once, Takahashi wins with probability A %, Aoki wins with probability B %, and the game ends in a draw (that is, nobody wins) with probability C %.\nFind the expected number of games that will be played, and print it as follows.\n\nWe can represent the expected value as P/Q with coprime integers P and Q.\nPrint the integer R between 0 and 10^9+6 (inclusive) such that R \\times Q \\equiv P\\pmod {10^9+7}.\n(Such an integer R always uniquely exists under the constraints of this problem.)\n\nConstraints\n\n1 \\leq N \\leq 100000\n\n0 \\leq A,B,C \\leq 100\n\n1 \\leq A+B\n\nA+B+C=100\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\n\nOutput\n\nPrint the expected number of games that will be played, in the manner specified in the statement.\n\nSample Input 1\n\n1 25 25 50\n\nSample Output 1\n\n2\n\nSince N=1, they will repeat the game until one of them wins.\nThe expected number of games played is 2.\n\nSample Input 2\n\n4 50 50 0\n\nSample Output 2\n\n312500008\n\nC may be 0.\n\nSample Input 3\n\n1 100 0 0\n\nSample Output 3\n\n1\n\nB may also be 0.\n\nSample Input 4\n\n100000 31 41 28\n\nSample Output 4\n\n104136146", "sample_input": "1 25 25 50\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03025", "source_text": "Score : 500 points\n\nProblem Statement\n\nTakahashi and Aoki will play a game. They will repeatedly play it until one of them have N wins in total.\n\nWhen they play the game once, Takahashi wins with probability A %, Aoki wins with probability B %, and the game ends in a draw (that is, nobody wins) with probability C %.\nFind the expected number of games that will be played, and print it as follows.\n\nWe can represent the expected value as P/Q with coprime integers P and Q.\nPrint the integer R between 0 and 10^9+6 (inclusive) such that R \\times Q \\equiv P\\pmod {10^9+7}.\n(Such an integer R always uniquely exists under the constraints of this problem.)\n\nConstraints\n\n1 \\leq N \\leq 100000\n\n0 \\leq A,B,C \\leq 100\n\n1 \\leq A+B\n\nA+B+C=100\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\n\nOutput\n\nPrint the expected number of games that will be played, in the manner specified in the statement.\n\nSample Input 1\n\n1 25 25 50\n\nSample Output 1\n\n2\n\nSince N=1, they will repeat the game until one of them wins.\nThe expected number of games played is 2.\n\nSample Input 2\n\n4 50 50 0\n\nSample Output 2\n\n312500008\n\nC may be 0.\n\nSample Input 3\n\n1 100 0 0\n\nSample Output 3\n\n1\n\nB may also be 0.\n\nSample Input 4\n\n100000 31 41 28\n\nSample Output 4\n\n104136146", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 10610, "cpu_time_ms": 259, "memory_kb": 205328}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s251229155", "group_id": "codeNet:p03029", "input_text": "\nfun main(args:Array) {\n val (a, p) = readLine()!!.split(\" \").map { it.toInt() }\n println((a*3+p)/2)\n}\n\n", "language": "Kotlin", "metadata": {"date": 1569877968, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03029.html", "problem_id": "p03029", "resource_group": "medium_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/Kotlin/s251229155.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s251229155", "user_id": "u269969976"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "\nfun main(args:Array) {\n val (a, p) = readLine()!!.split(\" \").map { it.toInt() }\n println((a*3+p)/2)\n}\n\n", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 118, "cpu_time_ms": 243, "memory_kb": 37912}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s516769131", "group_id": "codeNet:p03029", "input_text": "import java.lang.Math\n\nfun main(args: Array)\n{\n val (a, p) = readInts()\n\n val m = 3 * a + p\n val pie = m / 2\n println(pie)\n}\n\nfun readInts(): List = readLine()!!.split(\" \").map(String::toInt)\nfun readLongs(): List = readLine()!!.split(\" \").map(String::toLong)\n\nfun readIntArr(): IntArray = readLine()!!.split(\" \").map(String::toInt).toIntArray()\nfun readLongArr(): LongArray = readLine()!!.split(\" \").map(String::toLong).toLongArray()\n\nfun readIntArrS(): IntArray = readLine()!!.split(\" \").map(String::toInt).toIntArray().sortedArray()\nfun readLongArrS(): LongArray = readLine()!!.split(\" \").map(String::toLong).toLongArray().sortedArray()\n\nfun readIntArrSD(): IntArray = readLine()!!.split(\" \").map(String::toInt).toIntArray().sortedArrayDescending()\nfun readLongArrSD(): LongArray = readLine()!!.split(\" \").map(String::toLong).toLongArray().sortedArrayDescending()\n\nfun readString() = readLine()!!\n", "language": "Kotlin", "metadata": {"date": 1566996836, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03029.html", "problem_id": "p03029", "resource_group": "medium_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/Kotlin/s516769131.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s516769131", "user_id": "u118477733"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "import java.lang.Math\n\nfun main(args: Array)\n{\n val (a, p) = readInts()\n\n val m = 3 * a + p\n val pie = m / 2\n println(pie)\n}\n\nfun readInts(): List = readLine()!!.split(\" \").map(String::toInt)\nfun readLongs(): List = readLine()!!.split(\" \").map(String::toLong)\n\nfun readIntArr(): IntArray = readLine()!!.split(\" \").map(String::toInt).toIntArray()\nfun readLongArr(): LongArray = readLine()!!.split(\" \").map(String::toLong).toLongArray()\n\nfun readIntArrS(): IntArray = readLine()!!.split(\" \").map(String::toInt).toIntArray().sortedArray()\nfun readLongArrS(): LongArray = readLine()!!.split(\" \").map(String::toLong).toLongArray().sortedArray()\n\nfun readIntArrSD(): IntArray = readLine()!!.split(\" \").map(String::toInt).toIntArray().sortedArrayDescending()\nfun readLongArrSD(): LongArray = readLine()!!.split(\" \").map(String::toLong).toLongArray().sortedArrayDescending()\n\nfun readString() = readLine()!!\n", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 931, "cpu_time_ms": 237, "memory_kb": 36148}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s688997311", "group_id": "codeNet:p03029", "input_text": "import java.util.*\n\nfun main(args: Array) {\n\n val scanner = Scanner(System.`in`)\n println((scanner.nextInt() * 3 + scanner. nextInt()) / 2)\n scanner.close()\n\n}", "language": "Kotlin", "metadata": {"date": 1558919123, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03029.html", "problem_id": "p03029", "resource_group": "medium_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/Kotlin/s688997311.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s688997311", "user_id": "u992174257"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "import java.util.*\n\nfun main(args: Array) {\n\n val scanner = Scanner(System.`in`)\n println((scanner.nextInt() * 3 + scanner. nextInt()) / 2)\n scanner.close()\n\n}", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 185, "memory_kb": 31260}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s012331250", "group_id": "codeNet:p03030", "input_text": "fun main(args: Array) = println(run {\n val n = readLine()!!.toInt()\n val res = (1..n).map {\n (\"\"+it+\" \"+readLine()!!).split(\" \")\n }\n\n res.sortedByDescending { it[2].toInt() }.sortedBy { it[1] }.joinToString(\"\\n\") { it[0] }\n})\n\n", "language": "Kotlin", "metadata": {"date": 1588623466, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03030.html", "problem_id": "p03030", "resource_group": "medium_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/Kotlin/s012331250.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s012331250", "user_id": "u563556491"}, "prompt_components": {"gold_output": "3\n4\n6\n1\n5\n2\n", "input_to_evaluate": "fun main(args: Array) = println(run {\n val n = readLine()!!.toInt()\n val res = (1..n).map {\n (\"\"+it+\" \"+readLine()!!).split(\" \")\n }\n\n res.sortedByDescending { it[2].toInt() }.sortedBy { it[1] }.joinToString(\"\\n\") { it[0] }\n})\n\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 254, "cpu_time_ms": 249, "memory_kb": 36036}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s178041422", "group_id": "codeNet:p03031", "input_text": "import java.util.*\nimport kotlin.comparisons.*\n\nfun main(args : Array) {\n val (n, m) = readLine()!!.split(' ').map(String::toInt)\n val ss = (1..m).map { readLine()!!.split(' ').drop(1).map { it.toInt() - 1 } }\n val pp = readLine()!!.split(' ').map(String::toInt)\n\n val t = Math.pow(2.0, n.toDouble()).toInt()\n val ans = (0..t).count { i ->\n ss.withIndex().all { s ->\n pp[s.index] == s.value.map { (i shr it) and 1 }.sum() % 2\n }\n }\n println(ans)\n}\n", "language": "Kotlin", "metadata": {"date": 1587094892, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03031.html", "problem_id": "p03031", "resource_group": "medium_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/Kotlin/s178041422.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s178041422", "user_id": "u051841332"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "import java.util.*\nimport kotlin.comparisons.*\n\nfun main(args : Array) {\n val (n, m) = readLine()!!.split(' ').map(String::toInt)\n val ss = (1..m).map { readLine()!!.split(' ').drop(1).map { it.toInt() - 1 } }\n val pp = readLine()!!.split(' ').map(String::toInt)\n\n val t = Math.pow(2.0, n.toDouble()).toInt()\n val ans = (0..t).count { i ->\n ss.withIndex().all { s ->\n pp[s.index] == s.value.map { (i shr it) and 1 }.sum() % 2\n }\n }\n println(ans)\n}\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 309, "memory_kb": 39616}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s842853968", "group_id": "codeNet:p03031", "input_text": "fun main(args: Array) {\n val (N, M) = listOfInt()\n val SW = (0 until M).map { listOfInt().drop(1).map { 1 shl (it - 1) } }\n val P = listOfInt()\n var ans = 0\n for (n in 0 until (1 shl N)) {\n//System.err.println(java.lang.Integer.toBinaryString(n))\n var d = 0\n SW.forEachIndexed { index, list ->\n var c = 0\n list.forEach {\n//System.err.print(\"$index ${java.lang.Integer.toBinaryString(it)}\")\n if (n and it != 0) c += 1\n//System.err.println(\" $c\")\n }\n if (c > 0 && c % 2 == P[index]) d += 1\n }\n//System.err.println(\" d:$d\")\n if (d == M) ans += 1\n }\n println(ans)\n}\nfun next() = readLine()!!\nfun listOfString() = next().split(\" \")\nfun listOfInt() = listOfString().map(String::toInt)", "language": "Kotlin", "metadata": {"date": 1580935252, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03031.html", "problem_id": "p03031", "resource_group": "medium_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/Kotlin/s842853968.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s842853968", "user_id": "u043150661"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "fun main(args: Array) {\n val (N, M) = listOfInt()\n val SW = (0 until M).map { listOfInt().drop(1).map { 1 shl (it - 1) } }\n val P = listOfInt()\n var ans = 0\n for (n in 0 until (1 shl N)) {\n//System.err.println(java.lang.Integer.toBinaryString(n))\n var d = 0\n SW.forEachIndexed { index, list ->\n var c = 0\n list.forEach {\n//System.err.print(\"$index ${java.lang.Integer.toBinaryString(it)}\")\n if (n and it != 0) c += 1\n//System.err.println(\" $c\")\n }\n if (c > 0 && c % 2 == P[index]) d += 1\n }\n//System.err.println(\" d:$d\")\n if (d == M) ans += 1\n }\n println(ans)\n}\nfun next() = readLine()!!\nfun listOfString() = next().split(\" \")\nfun listOfInt() = listOfString().map(String::toInt)", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 794, "cpu_time_ms": 296, "memory_kb": 38148}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s634783764", "group_id": "codeNet:p03032", "input_text": "import java.util.*\n\nfun main() {\n val (N, K) = readLine()!!.split(\" \").map(String::toInt)\n val V = readLine()!!.split(\" \").map(String::toLong).toList()\n var ans = 0L\n\n for (l in 0..K) {\n for (r in 0..K-l) {\n val list = mutableListOf()\n list.addAll(V.subList(0,l))\n list.addAll(V.subList(N-r,N))\n val ng = list.count{it<0}\n list.sort()\n val sum = list.drop(Math.min(ng,K-l-r)).sum()\n ans = Math.max(ans,sum)\n }\n }\n println(ans)\n}", "language": "Kotlin", "metadata": {"date": 1559064449, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03032.html", "problem_id": "p03032", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03032/input.txt", "sample_output_relpath": "derived/input_output/data/p03032/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03032/Kotlin/s634783764.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s634783764", "user_id": "u043557308"}, "prompt_components": {"gold_output": "14\n", "input_to_evaluate": "import java.util.*\n\nfun main() {\n val (N, K) = readLine()!!.split(\" \").map(String::toInt)\n val V = readLine()!!.split(\" \").map(String::toLong).toList()\n var ans = 0L\n\n for (l in 0..K) {\n for (r in 0..K-l) {\n val list = mutableListOf()\n list.addAll(V.subList(0,l))\n list.addAll(V.subList(N-r,N))\n val ng = list.count{it<0}\n list.sort()\n val sum = list.drop(Math.min(ng,K-l-r)).sum()\n ans = Math.max(ans,sum)\n }\n }\n println(ans)\n}", "problem_context": "Score : 400 points\n\nProblem Statement\n\nYour friend gave you a dequeue D as a birthday present.\n\nD is a horizontal cylinder that contains a row of N jewels.\n\nThe values of the jewels are V_1, V_2, ..., V_N from left to right. There may be jewels with negative values.\n\nIn the beginning, you have no jewel in your hands.\n\nYou can perform at most K operations on D, chosen from the following, at most K times (possibly zero):\n\nOperation A: Take out the leftmost jewel contained in D and have it in your hand. You cannot do this operation when D is empty.\n\nOperation B: Take out the rightmost jewel contained in D and have it in your hand. You cannot do this operation when D is empty.\n\nOperation C: Choose a jewel in your hands and insert it to the left end of D. You cannot do this operation when you have no jewel in your hand.\n\nOperation D: Choose a jewel in your hands and insert it to the right end of D. You cannot do this operation when you have no jewel in your hand.\n\nFind the maximum possible sum of the values of jewels in your hands after the operations.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 50\n\n1 \\leq K \\leq 100\n\n-10^7 \\leq V_i \\leq 10^7\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nV_1 V_2 ... V_N\n\nOutput\n\nPrint the maximum possible sum of the values of jewels in your hands after the operations.\n\nSample Input 1\n\n6 4\n-10 8 2 1 2 6\n\nSample Output 1\n\n14\n\nAfter the following sequence of operations, you have two jewels of values 8 and 6 in your hands for a total of 14, which is the maximum result.\n\nDo operation A. You take out the jewel of value -10 from the left end of D.\n\nDo operation B. You take out the jewel of value 6 from the right end of D.\n\nDo operation A. You take out the jewel of value 8 from the left end of D.\n\nDo operation D. You insert the jewel of value -10 to the right end of D.\n\nSample Input 2\n\n6 4\n-6 -100 50 -2 -5 -3\n\nSample Output 2\n\n44\n\nSample Input 3\n\n6 3\n-6 -100 50 -2 -5 -3\n\nSample Output 3\n\n0\n\nIt is optimal to do no operation.", "sample_input": "6 4\n-10 8 2 1 2 6\n"}, "reference_outputs": ["14\n"], "source_document_id": "p03032", "source_text": "Score : 400 points\n\nProblem Statement\n\nYour friend gave you a dequeue D as a birthday present.\n\nD is a horizontal cylinder that contains a row of N jewels.\n\nThe values of the jewels are V_1, V_2, ..., V_N from left to right. There may be jewels with negative values.\n\nIn the beginning, you have no jewel in your hands.\n\nYou can perform at most K operations on D, chosen from the following, at most K times (possibly zero):\n\nOperation A: Take out the leftmost jewel contained in D and have it in your hand. You cannot do this operation when D is empty.\n\nOperation B: Take out the rightmost jewel contained in D and have it in your hand. You cannot do this operation when D is empty.\n\nOperation C: Choose a jewel in your hands and insert it to the left end of D. You cannot do this operation when you have no jewel in your hand.\n\nOperation D: Choose a jewel in your hands and insert it to the right end of D. You cannot do this operation when you have no jewel in your hand.\n\nFind the maximum possible sum of the values of jewels in your hands after the operations.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 50\n\n1 \\leq K \\leq 100\n\n-10^7 \\leq V_i \\leq 10^7\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nV_1 V_2 ... V_N\n\nOutput\n\nPrint the maximum possible sum of the values of jewels in your hands after the operations.\n\nSample Input 1\n\n6 4\n-10 8 2 1 2 6\n\nSample Output 1\n\n14\n\nAfter the following sequence of operations, you have two jewels of values 8 and 6 in your hands for a total of 14, which is the maximum result.\n\nDo operation A. You take out the jewel of value -10 from the left end of D.\n\nDo operation B. You take out the jewel of value 6 from the right end of D.\n\nDo operation A. You take out the jewel of value 8 from the left end of D.\n\nDo operation D. You insert the jewel of value -10 to the right end of D.\n\nSample Input 2\n\n6 4\n-6 -100 50 -2 -5 -3\n\nSample Output 2\n\n44\n\nSample Input 3\n\n6 3\n-6 -100 50 -2 -5 -3\n\nSample Output 3\n\n0\n\nIt is optimal to do no operation.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 157, "memory_kb": 29476}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s442584951", "group_id": "codeNet:p03033", "input_text": "import java.util.*\n\nfun main() {\n val (N, Q) = readLine()!!.split(\" \").map(String::toInt)\n\n val set = mutableSetOf()\n val list = mutableListOf>()\n for (i in 0 until N) {\n val (S, T, X) = readLine()!!.split(\" \").map(String::toLong)\n list.add(Triple(S-X, X, true))\n list.add(Triple(T-X, X, false))\n }\n list.sortBy { it.first }\n\n val D = LongArray(Q){readLine()!!.toLong()}\n D.sort()\n\n var t = 0L\n var l = 0\n for (d in D) {\n while (l != list.size) {\n var q = list[l]\n if (q.first > d)\n break\n when(q.third){\n true->set.add(q.second)\n false->set.remove(q.second)\n }\n l++\n }\n println(set.min()?:-1)\n }\n}", "language": "Kotlin", "metadata": {"date": 1559321975, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03033.html", "problem_id": "p03033", "resource_group": "medium_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/Kotlin/s442584951.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s442584951", "user_id": "u043557308"}, "prompt_components": {"gold_output": "2\n2\n10\n-1\n13\n-1\n", "input_to_evaluate": "import java.util.*\n\nfun main() {\n val (N, Q) = readLine()!!.split(\" \").map(String::toInt)\n\n val set = mutableSetOf()\n val list = mutableListOf>()\n for (i in 0 until N) {\n val (S, T, X) = readLine()!!.split(\" \").map(String::toLong)\n list.add(Triple(S-X, X, true))\n list.add(Triple(T-X, X, false))\n }\n list.sortBy { it.first }\n\n val D = LongArray(Q){readLine()!!.toLong()}\n D.sort()\n\n var t = 0L\n var l = 0\n for (d in D) {\n while (l != list.size) {\n var q = list[l]\n if (q.first > d)\n break\n when(q.third){\n true->set.add(q.second)\n false->set.remove(q.second)\n }\n l++\n }\n println(set.min()?:-1)\n }\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 810, "cpu_time_ms": 155, "memory_kb": 31268}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s525660443", "group_id": "codeNet:p03033", "input_text": "import java.util.*\n\nconst val MOD: Long = (1e9+7).toLong()\nfun Double.format(digits: Int) = String.format(\"%.${digits}f\", this)\nfun > Iterable.argmax(): Int? = withIndex().maxBy{it.value}?.index\nfun > Iterable.argmin(): Int? = withIndex().minBy{it.value}?.index\n\nfun main(args: Array) {\n val reader = System.`in`.bufferedReader()\n val (n, q) = reader.readLine()!!.split(\" \").map{it.toInt()}\n var x = Array(n, {\n val (s, t, x) = reader.readLine()!!.split(\" \").map{it.toInt()}\n Triple(s-x, t-x, x)\n })\n val d = Array(q, {reader.readLine()!!.toInt()})\n\n val events = ArrayList>()\n for ((s, t, y) in x) {\n events.add(Triple(s, 1, y))\n events.add(Triple(t, -1, y))\n }\n events.sortBy {it.first}\n\n val set = TreeSet()\n\n var index = 0\n for ((t, f, y) in events) {\n while (index < q && d[index] < t) {\n if (set.isEmpty()) {\n println(-1)\n } else {\n println(set.first())\n }\n index++\n }\n\n if (f == 1) {\n set.add(y)\n } else {\n set.remove(y)\n }\n }\n while (index < q) {\n if (set.isEmpty()) {\n println(-1)\n } else {\n println(set.first())\n }\n index++\n }\n}\n", "language": "Kotlin", "metadata": {"date": 1558930917, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03033.html", "problem_id": "p03033", "resource_group": "medium_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/Kotlin/s525660443.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s525660443", "user_id": "u868099754"}, "prompt_components": {"gold_output": "2\n2\n10\n-1\n13\n-1\n", "input_to_evaluate": "import java.util.*\n\nconst val MOD: Long = (1e9+7).toLong()\nfun Double.format(digits: Int) = String.format(\"%.${digits}f\", this)\nfun > Iterable.argmax(): Int? = withIndex().maxBy{it.value}?.index\nfun > Iterable.argmin(): Int? = withIndex().minBy{it.value}?.index\n\nfun main(args: Array) {\n val reader = System.`in`.bufferedReader()\n val (n, q) = reader.readLine()!!.split(\" \").map{it.toInt()}\n var x = Array(n, {\n val (s, t, x) = reader.readLine()!!.split(\" \").map{it.toInt()}\n Triple(s-x, t-x, x)\n })\n val d = Array(q, {reader.readLine()!!.toInt()})\n\n val events = ArrayList>()\n for ((s, t, y) in x) {\n events.add(Triple(s, 1, y))\n events.add(Triple(t, -1, y))\n }\n events.sortBy {it.first}\n\n val set = TreeSet()\n\n var index = 0\n for ((t, f, y) in events) {\n while (index < q && d[index] < t) {\n if (set.isEmpty()) {\n println(-1)\n } else {\n println(set.first())\n }\n index++\n }\n\n if (f == 1) {\n set.add(y)\n } else {\n set.remove(y)\n }\n }\n while (index < q) {\n if (set.isEmpty()) {\n println(-1)\n } else {\n println(set.first())\n }\n index++\n }\n}\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1370, "cpu_time_ms": 2111, "memory_kb": 170608}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s617280469", "group_id": "codeNet:p03035", "input_text": "import java.util.*\n\nfun main(){\n \tval sc = Scanner(System.`in`)\n val a = sc.nextInt()\n val b = sc.nextInt()\n\n when (a) {\n in 0..5 -> println(\"0\")\n in 6..12 -> println(\"${b/2}\")\n else -> println(\"$b\")\n }\n}", "language": "Kotlin", "metadata": {"date": 1573695159, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03035.html", "problem_id": "p03035", "resource_group": "medium_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/Kotlin/s617280469.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s617280469", "user_id": "u589734885"}, "prompt_components": {"gold_output": "100\n", "input_to_evaluate": "import java.util.*\n\nfun main(){\n \tval sc = Scanner(System.`in`)\n val a = sc.nextInt()\n val b = sc.nextInt()\n\n when (a) {\n in 0..5 -> println(\"0\")\n in 6..12 -> println(\"${b/2}\")\n else -> println(\"$b\")\n }\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 238, "cpu_time_ms": 158, "memory_kb": 31264}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s665699788", "group_id": "codeNet:p03036", "input_text": "fun main(args: Array) {\n val (r, D, x0) = readLine()!!.split(\" \").map(String::toLong)\n var x = x0\n repeat(10) {\n x = r * x - D\n println(x)\n }\n}", "language": "Kotlin", "metadata": {"date": 1589946032, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03036.html", "problem_id": "p03036", "resource_group": "medium_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/Kotlin/s665699788.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s665699788", "user_id": "u860789370"}, "prompt_components": {"gold_output": "30\n50\n90\n170\n330\n650\n1290\n2570\n5130\n10250\n", "input_to_evaluate": "fun main(args: Array) {\n val (r, D, x0) = readLine()!!.split(\" \").map(String::toLong)\n var x = x0\n repeat(10) {\n x = r * x - D\n println(x)\n }\n}", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 242, "memory_kb": 35952}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s560534872", "group_id": "codeNet:p03036", "input_text": "fun main(args: Array) {\n var (r, d, x) = readInputLine().split(\" \").map{it.toInt()}\n \n for (i in 1..10) {\n x = r * x - d\n println(x)\n }\n}\n\nfun readInputLine(): String {\n return readLine()!!\n}\n", "language": "Kotlin", "metadata": {"date": 1564780265, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03036.html", "problem_id": "p03036", "resource_group": "medium_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/Kotlin/s560534872.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s560534872", "user_id": "u505558493"}, "prompt_components": {"gold_output": "30\n50\n90\n170\n330\n650\n1290\n2570\n5130\n10250\n", "input_to_evaluate": "fun main(args: Array) {\n var (r, d, x) = readInputLine().split(\" \").map{it.toInt()}\n \n for (i in 1..10) {\n x = r * x - d\n println(x)\n }\n}\n\nfun readInputLine(): String {\n return readLine()!!\n}\n", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 236, "memory_kb": 36036}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s944930163", "group_id": "codeNet:p03036", "input_text": "import java.io.PrintWriter\nimport java.io.Console\n\n\n\nval pw = PrintWriter(System.out)\nfun main(args: Array) {\n func()\n pw.flush()\n}\nfun println(value: Any) { pw.println(value) }\n\nfun func() {\n val (r, D, x2000) = listOfLong()\n var ans = x2000\n for (n in 1..10) {\n ans = r * ans - D\n println(ans)\n }\n}\n\nfun next() = readLine()!!\nfun listOfString() = next().split(\" \")\nfun listOfLong() = listOfString().map { it.toLong() }\n", "language": "Kotlin", "metadata": {"date": 1560054513, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03036.html", "problem_id": "p03036", "resource_group": "medium_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/Kotlin/s944930163.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s944930163", "user_id": "u043150661"}, "prompt_components": {"gold_output": "30\n50\n90\n170\n330\n650\n1290\n2570\n5130\n10250\n", "input_to_evaluate": "import java.io.PrintWriter\nimport java.io.Console\n\n\n\nval pw = PrintWriter(System.out)\nfun main(args: Array) {\n func()\n pw.flush()\n}\nfun println(value: Any) { pw.println(value) }\n\nfun func() {\n val (r, D, x2000) = listOfLong()\n var ans = x2000\n for (n in 1..10) {\n ans = r * ans - D\n println(ans)\n }\n}\n\nfun next() = readLine()!!\nfun listOfString() = next().split(\" \")\nfun listOfLong() = listOfString().map { it.toLong() }\n", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 461, "cpu_time_ms": 234, "memory_kb": 36072}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s513889710", "group_id": "codeNet:p03036", "input_text": "fun main(args:Array){\n val line = readLine()!!.split(\" \").map{it.toInt()}\n val r = line[0]\n val d = line[1]\n var x = line[2]\n for(i in 1..10){\n x = r*x-d\n println(x)\n }\n}", "language": "Kotlin", "metadata": {"date": 1558832976, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03036.html", "problem_id": "p03036", "resource_group": "medium_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/Kotlin/s513889710.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s513889710", "user_id": "u943726499"}, "prompt_components": {"gold_output": "30\n50\n90\n170\n330\n650\n1290\n2570\n5130\n10250\n", "input_to_evaluate": "fun main(args:Array){\n val line = readLine()!!.split(\" \").map{it.toInt()}\n val r = line[0]\n val d = line[1]\n var x = line[2]\n for(i in 1..10){\n x = r*x-d\n println(x)\n }\n}", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 240, "memory_kb": 36164}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s368944247", "group_id": "codeNet:p03036", "input_text": "import java.util.*\n\nfun main(args: Array) {\n val scanner = Scanner(System.`in`)\n val r = scanner.nextInt()\n val d = scanner.nextInt()\n val x2t = scanner.nextInt()\n var xi = x2t\n (1..10).forEach {\n xi = r * xi - d\n println(xi)\n }\n}\n", "language": "Kotlin", "metadata": {"date": 1558832962, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03036.html", "problem_id": "p03036", "resource_group": "medium_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/Kotlin/s368944247.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s368944247", "user_id": "u111718424"}, "prompt_components": {"gold_output": "30\n50\n90\n170\n330\n650\n1290\n2570\n5130\n10250\n", "input_to_evaluate": "import java.util.*\n\nfun main(args: Array) {\n val scanner = Scanner(System.`in`)\n val r = scanner.nextInt()\n val d = scanner.nextInt()\n val x2t = scanner.nextInt()\n var xi = x2t\n (1..10).forEach {\n xi = r * xi - d\n println(xi)\n }\n}\n", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 202, "memory_kb": 29588}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s307386649", "group_id": "codeNet:p03037", "input_text": "fun main(args: Array) = println(run {\n val (n, m) = readLine()!!.split(\" \").map { it.toInt() }\n val lr = (1..m).map { readLine()!!.split(\" \").map { it.toInt() } }\n\n val imos = IntArray(n+2)\n lr.forEach {\n val (l, r) = it\n imos[l]++\n imos[r+1]--\n }\n val count = imos.toList().accumulated()\n val max = count.max()!!\n count.count{ it == max }\n\n})\n\nfun List.accumulated(): List { var sum = 0L; return this.map { sum += it; sum } }\n", "language": "Kotlin", "metadata": {"date": 1588536078, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03037.html", "problem_id": "p03037", "resource_group": "medium_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/Kotlin/s307386649.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s307386649", "user_id": "u563556491"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "fun main(args: Array) = println(run {\n val (n, m) = readLine()!!.split(\" \").map { it.toInt() }\n val lr = (1..m).map { readLine()!!.split(\" \").map { it.toInt() } }\n\n val imos = IntArray(n+2)\n lr.forEach {\n val (l, r) = it\n imos[l]++\n imos[r+1]--\n }\n val count = imos.toList().accumulated()\n val max = count.max()!!\n count.count{ it == max }\n\n})\n\nfun List.accumulated(): List { var sum = 0L; return this.map { sum += it; sum } }\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 709, "memory_kb": 63496}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s259978566", "group_id": "codeNet:p03037", "input_text": "import java.util.Scanner\n\nfun main(args : Array) {\n val scn = Scanner(System.`in`)\n val N = scn.nextInt()\n val M = scn.nextInt()\n\n var L = Int.MIN_VALUE\n var R = Int.MAX_VALUE\n\n for (i in 1..M) {\n val lm = scn.nextInt()\n val rm = scn.nextInt()\n L = if (L < lm) lm else L\n R = if (rm < R) rm else R\n }\n val ans = R - L + 1\n if (ans > 0) {\n println(ans)\n }\n else {\n println(0)\n }\n}\n", "language": "Kotlin", "metadata": {"date": 1560061295, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03037.html", "problem_id": "p03037", "resource_group": "medium_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/Kotlin/s259978566.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s259978566", "user_id": "u696729148"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import java.util.Scanner\n\nfun main(args : Array) {\n val scn = Scanner(System.`in`)\n val N = scn.nextInt()\n val M = scn.nextInt()\n\n var L = Int.MIN_VALUE\n var R = Int.MAX_VALUE\n\n for (i in 1..M) {\n val lm = scn.nextInt()\n val rm = scn.nextInt()\n L = if (L < lm) lm else L\n R = if (rm < R) rm else R\n }\n val ans = R - L + 1\n if (ans > 0) {\n println(ans)\n }\n else {\n println(0)\n }\n}\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 562, "cpu_time_ms": 554, "memory_kb": 71056}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s458446525", "group_id": "codeNet:p03037", "input_text": "fun main(args: Array) {\n val (n, m) = readLine()!!.split(\" \").map { it.toInt() }\n val ll = mutableListOf()\n val rl = mutableListOf()\n for (i in 0 until m) {\n val (l, r) = readLine()!!.split(\" \").map { it.toInt() }\n ll.add(l)\n rl.add(r)\n }\n println(rl.min()!! - ll.max()!! + 1)\n}\n", "language": "Kotlin", "metadata": {"date": 1558834403, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03037.html", "problem_id": "p03037", "resource_group": "medium_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/Kotlin/s458446525.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s458446525", "user_id": "u122997134"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "fun main(args: Array) {\n val (n, m) = readLine()!!.split(\" \").map { it.toInt() }\n val ll = mutableListOf()\n val rl = mutableListOf()\n for (i in 0 until m) {\n val (l, r) = readLine()!!.split(\" \").map { it.toInt() }\n ll.add(l)\n rl.add(r)\n }\n println(rl.min()!! - ll.max()!! + 1)\n}\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 336, "cpu_time_ms": 613, "memory_kb": 59036}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s135766154", "group_id": "codeNet:p03037", "input_text": "fun main(args: Array) {\n\n val (n, m) = readLine()!!.split(\" \").map { it.toInt() }\n\n var lMax = 0\n var RMin = Int.MAX_VALUE\n\n for (i in 0 until m) {\n val (l, r) = readLine()!!.split(\" \").map { it.toInt() }\n\n if (l > lMax) {\n lMax = l\n }\n\n if (r < RMin) {\n RMin = r\n }\n }\n\n if (RMin - lMax < 0) println(0) else println(RMin - lMax + 1)\n\n}", "language": "Kotlin", "metadata": {"date": 1558833045, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03037.html", "problem_id": "p03037", "resource_group": "medium_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/Kotlin/s135766154.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s135766154", "user_id": "u889750959"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "fun main(args: Array) {\n\n val (n, m) = readLine()!!.split(\" \").map { it.toInt() }\n\n var lMax = 0\n var RMin = Int.MAX_VALUE\n\n for (i in 0 until m) {\n val (l, r) = readLine()!!.split(\" \").map { it.toInt() }\n\n if (l > lMax) {\n lMax = l\n }\n\n if (r < RMin) {\n RMin = r\n }\n }\n\n if (RMin - lMax < 0) println(0) else println(RMin - lMax + 1)\n\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 568, "memory_kb": 55808}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s494957110", "group_id": "codeNet:p03038", "input_text": "import java.util.*\n\nfun main(args: Array) {\n abc127d()\n}\n\nfun abc127d() {\n val (n, m) = readLine()!!.split(\" \").map { it.toInt() }\n val a = readLine()!!.split(\" \").map { it.toLong() }.toMutableList()\n // 愚直にやるとTLE 最悪のケースでO(N^2)で10^10になるので\n // var total = a.sum()\n // val heap = PriorityQueue()\n // heap.addAll(a)\n // repeat (m) {\n // val (b, c) = readLine()!!.split(\" \").map { it.toLong() }\n // for (j in 0 until b) {\n // if (heap.peek() < c) {\n // val origin = heap.poll()\n // total += c - origin\n // heap.add(c)\n // } else {\n // break\n // }\n // }\n // }\n // println(total)\n // 単純に配列に全部ぶっこめばいけるかと思ったが、こっちの方が効率悪いな\n // 最悪のケースだと10^5回10^5個の要素を追加することになるので、配列の長さがやばいことになる\n // val box = mutableListOf(*a.toTypedArray())\n // repeat(m) {\n // val (b, c) = readLine()!!.split(\" \").map { it.toLong() }\n // repeat(b.toInt()) {\n // box.add(c)\n // }\n // }\n // box.sortDescending()\n // var total = 0L\n // for (i in 0 until n) {\n // total += box[i]\n // }\n // println(total)\n val operation = mutableListOf>()\n repeat(m) {\n val (b, c) = readLine()!!.split(\" \").map { it.toLong() }\n operation.add(b.toInt() to c)\n }\n operation.sortByDescending { it.second }\n a.sortedDescending()\n var operationCount = 0\n for ((i, v) in operation) {\n if (i < operationCount) continue\n for (j in n -i until n) {\n if (a[j] < v) {\n a[j] = v\n } else {\n break\n }\n }\n operationCount = i\n }\n println(a.sum())\n}", "language": "Kotlin", "metadata": {"date": 1590097704, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03038.html", "problem_id": "p03038", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03038/input.txt", "sample_output_relpath": "derived/input_output/data/p03038/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03038/Kotlin/s494957110.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s494957110", "user_id": "u628907033"}, "prompt_components": {"gold_output": "14\n", "input_to_evaluate": "import java.util.*\n\nfun main(args: Array) {\n abc127d()\n}\n\nfun abc127d() {\n val (n, m) = readLine()!!.split(\" \").map { it.toInt() }\n val a = readLine()!!.split(\" \").map { it.toLong() }.toMutableList()\n // 愚直にやるとTLE 最悪のケースでO(N^2)で10^10になるので\n // var total = a.sum()\n // val heap = PriorityQueue()\n // heap.addAll(a)\n // repeat (m) {\n // val (b, c) = readLine()!!.split(\" \").map { it.toLong() }\n // for (j in 0 until b) {\n // if (heap.peek() < c) {\n // val origin = heap.poll()\n // total += c - origin\n // heap.add(c)\n // } else {\n // break\n // }\n // }\n // }\n // println(total)\n // 単純に配列に全部ぶっこめばいけるかと思ったが、こっちの方が効率悪いな\n // 最悪のケースだと10^5回10^5個の要素を追加することになるので、配列の長さがやばいことになる\n // val box = mutableListOf(*a.toTypedArray())\n // repeat(m) {\n // val (b, c) = readLine()!!.split(\" \").map { it.toLong() }\n // repeat(b.toInt()) {\n // box.add(c)\n // }\n // }\n // box.sortDescending()\n // var total = 0L\n // for (i in 0 until n) {\n // total += box[i]\n // }\n // println(total)\n val operation = mutableListOf>()\n repeat(m) {\n val (b, c) = readLine()!!.split(\" \").map { it.toLong() }\n operation.add(b.toInt() to c)\n }\n operation.sortByDescending { it.second }\n a.sortedDescending()\n var operationCount = 0\n for ((i, v) in operation) {\n if (i < operationCount) continue\n for (j in n -i until n) {\n if (a[j] < v) {\n a[j] = v\n } else {\n break\n }\n }\n operationCount = i\n }\n println(a.sum())\n}", "problem_context": "Score : 400 points\n\nProblem Statement\n\nYou have N cards. On the i-th card, an integer A_i is written.\n\nFor each j = 1, 2, ..., M in this order, you will perform the following operation once:\n\nOperation: Choose at most B_j cards (possibly zero). Replace the integer written on each chosen card with C_j.\n\nFind the maximum possible sum of the integers written on the N cards after the M operations.\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, C_i \\leq 10^9\n\n1 \\leq B_i \\leq N\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nA_1 A_2 ... A_N\nB_1 C_1\nB_2 C_2\n\\vdots\nB_M C_M\n\nOutput\n\nPrint the maximum possible sum of the integers written on the N cards after the M operations.\n\nSample Input 1\n\n3 2\n5 1 4\n2 3\n1 5\n\nSample Output 1\n\n14\n\nBy replacing the integer on the second card with 5, the sum of the integers written on the three cards becomes 5 + 5 + 4 = 14, which is the maximum result.\n\nSample Input 2\n\n10 3\n1 8 5 7 100 4 52 33 13 5\n3 10\n4 30\n1 4\n\nSample Output 2\n\n338\n\nSample Input 3\n\n3 2\n100 100 100\n3 99\n3 99\n\nSample Output 3\n\n300\n\nSample Input 4\n\n11 3\n1 1 1 1 1 1 1 1 1 1 1\n3 1000000000\n4 1000000000\n3 1000000000\n\nSample Output 4\n\n10000000001\n\nThe output may not fit into a 32-bit integer type.", "sample_input": "3 2\n5 1 4\n2 3\n1 5\n"}, "reference_outputs": ["14\n"], "source_document_id": "p03038", "source_text": "Score : 400 points\n\nProblem Statement\n\nYou have N cards. On the i-th card, an integer A_i is written.\n\nFor each j = 1, 2, ..., M in this order, you will perform the following operation once:\n\nOperation: Choose at most B_j cards (possibly zero). Replace the integer written on each chosen card with C_j.\n\nFind the maximum possible sum of the integers written on the N cards after the M operations.\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, C_i \\leq 10^9\n\n1 \\leq B_i \\leq N\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nA_1 A_2 ... A_N\nB_1 C_1\nB_2 C_2\n\\vdots\nB_M C_M\n\nOutput\n\nPrint the maximum possible sum of the integers written on the N cards after the M operations.\n\nSample Input 1\n\n3 2\n5 1 4\n2 3\n1 5\n\nSample Output 1\n\n14\n\nBy replacing the integer on the second card with 5, the sum of the integers written on the three cards becomes 5 + 5 + 4 = 14, which is the maximum result.\n\nSample Input 2\n\n10 3\n1 8 5 7 100 4 52 33 13 5\n3 10\n4 30\n1 4\n\nSample Output 2\n\n338\n\nSample Input 3\n\n3 2\n100 100 100\n3 99\n3 99\n\nSample Output 3\n\n300\n\nSample Input 4\n\n11 3\n1 1 1 1 1 1 1 1 1 1 1\n3 1000000000\n4 1000000000\n3 1000000000\n\nSample Output 4\n\n10000000001\n\nThe output may not fit into a 32-bit integer type.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2016, "cpu_time_ms": 1138, "memory_kb": 102204}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s233998505", "group_id": "codeNet:p03038", "input_text": "import java.util.*\nimport java.math.*\n\nfun main(args: Array) {\n\n var (N, M) = readLine()!!.split(\" \").map { it.toInt() }\n// var N = readLine()!!.toLong()\n// val S = readLine()!!\n// val D = readLine()!!.split(\" \").map { it.toLong() }\n val A = readLine()!!.split(\" \").map { it.toLong() }.toLongArray()\n val mod = 1000000007L\n\n A.sort()\n A.reverse()\n val BC = mutableMapOf()\n for (i in 0 until M) {\n var (B, C) = readLine()!!.split(\" \").map { it.toLong() }\n BC[C] = B + (BC[C]?:0)\n }\n\n val list = BC.toList().sortedBy { -it.first }\n\n var ans = mutableListOf()\n\n var a = 0\n var l = 0\n var sc = 0L\n\n while (ans.size < N) {\n var ad = 0L\n if (l >= list.size || A[a] >= list[l].first) {\n ad = A[a]\n a++\n }else {\n ad = list[l].first\n sc++\n if (list[l].second == sc) {\n l++\n sc = 0\n }\n }\n ans.add(ad)\n }\n\n print(ans.sum())\n}", "language": "Kotlin", "metadata": {"date": 1558835323, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03038.html", "problem_id": "p03038", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03038/input.txt", "sample_output_relpath": "derived/input_output/data/p03038/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03038/Kotlin/s233998505.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s233998505", "user_id": "u043557308"}, "prompt_components": {"gold_output": "14\n", "input_to_evaluate": "import java.util.*\nimport java.math.*\n\nfun main(args: Array) {\n\n var (N, M) = readLine()!!.split(\" \").map { it.toInt() }\n// var N = readLine()!!.toLong()\n// val S = readLine()!!\n// val D = readLine()!!.split(\" \").map { it.toLong() }\n val A = readLine()!!.split(\" \").map { it.toLong() }.toLongArray()\n val mod = 1000000007L\n\n A.sort()\n A.reverse()\n val BC = mutableMapOf()\n for (i in 0 until M) {\n var (B, C) = readLine()!!.split(\" \").map { it.toLong() }\n BC[C] = B + (BC[C]?:0)\n }\n\n val list = BC.toList().sortedBy { -it.first }\n\n var ans = mutableListOf()\n\n var a = 0\n var l = 0\n var sc = 0L\n\n while (ans.size < N) {\n var ad = 0L\n if (l >= list.size || A[a] >= list[l].first) {\n ad = A[a]\n a++\n }else {\n ad = list[l].first\n sc++\n if (list[l].second == sc) {\n l++\n sc = 0\n }\n }\n ans.add(ad)\n }\n\n print(ans.sum())\n}", "problem_context": "Score : 400 points\n\nProblem Statement\n\nYou have N cards. On the i-th card, an integer A_i is written.\n\nFor each j = 1, 2, ..., M in this order, you will perform the following operation once:\n\nOperation: Choose at most B_j cards (possibly zero). Replace the integer written on each chosen card with C_j.\n\nFind the maximum possible sum of the integers written on the N cards after the M operations.\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, C_i \\leq 10^9\n\n1 \\leq B_i \\leq N\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nA_1 A_2 ... A_N\nB_1 C_1\nB_2 C_2\n\\vdots\nB_M C_M\n\nOutput\n\nPrint the maximum possible sum of the integers written on the N cards after the M operations.\n\nSample Input 1\n\n3 2\n5 1 4\n2 3\n1 5\n\nSample Output 1\n\n14\n\nBy replacing the integer on the second card with 5, the sum of the integers written on the three cards becomes 5 + 5 + 4 = 14, which is the maximum result.\n\nSample Input 2\n\n10 3\n1 8 5 7 100 4 52 33 13 5\n3 10\n4 30\n1 4\n\nSample Output 2\n\n338\n\nSample Input 3\n\n3 2\n100 100 100\n3 99\n3 99\n\nSample Output 3\n\n300\n\nSample Input 4\n\n11 3\n1 1 1 1 1 1 1 1 1 1 1\n3 1000000000\n4 1000000000\n3 1000000000\n\nSample Output 4\n\n10000000001\n\nThe output may not fit into a 32-bit integer type.", "sample_input": "3 2\n5 1 4\n2 3\n1 5\n"}, "reference_outputs": ["14\n"], "source_document_id": "p03038", "source_text": "Score : 400 points\n\nProblem Statement\n\nYou have N cards. On the i-th card, an integer A_i is written.\n\nFor each j = 1, 2, ..., M in this order, you will perform the following operation once:\n\nOperation: Choose at most B_j cards (possibly zero). Replace the integer written on each chosen card with C_j.\n\nFind the maximum possible sum of the integers written on the N cards after the M operations.\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, C_i \\leq 10^9\n\n1 \\leq B_i \\leq N\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nA_1 A_2 ... A_N\nB_1 C_1\nB_2 C_2\n\\vdots\nB_M C_M\n\nOutput\n\nPrint the maximum possible sum of the integers written on the N cards after the M operations.\n\nSample Input 1\n\n3 2\n5 1 4\n2 3\n1 5\n\nSample Output 1\n\n14\n\nBy replacing the integer on the second card with 5, the sum of the integers written on the three cards becomes 5 + 5 + 4 = 14, which is the maximum result.\n\nSample Input 2\n\n10 3\n1 8 5 7 100 4 52 33 13 5\n3 10\n4 30\n1 4\n\nSample Output 2\n\n338\n\nSample Input 3\n\n3 2\n100 100 100\n3 99\n3 99\n\nSample Output 3\n\n300\n\nSample Input 4\n\n11 3\n1 1 1 1 1 1 1 1 1 1 1\n3 1000000000\n4 1000000000\n3 1000000000\n\nSample Output 4\n\n10000000001\n\nThe output may not fit into a 32-bit integer type.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1041, "cpu_time_ms": 1226, "memory_kb": 115400}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s696549200", "group_id": "codeNet:p03039", "input_text": "val fact = Array(200010) { 1L }\nval invfact = Array(200010) { 1L }\n\nval MOD = 1000000007L;\n\nfun comb(n: Long, m: Long): Long {\n if ( n < m )\n return 0L\n\n return fact[n.toInt()] * invfact[(n - m).toInt()] % MOD * invfact[m.toInt()] % MOD\n}\n\nfun powMod(n: Long, l: Long): Long {\n var k = l\n var a = 1L;\n var m = n\n while (k > 0) {\n if (k % 2 == 1L) {\n a = (a * m) % MOD;\n }\n m = (m * m) % MOD;\n k /= 2L\n }\n\n return a\n}\n\nfun invMod(n: Long): Long {\n return powMod(n, MOD - 2)\n}\n\nfun f(n: Long, m: Long): Long {\n var res = 0L\n val p = invMod(comb(n * m, 2))\n\n for (i in 1L until n) {\n res += (n - i) * i % MOD * m % MOD * m % MOD * p % MOD\n }\n\n return res\n}\n\nfun main(args: Array) {\n val (N, M, K) = readLine()!!.split(\" \").map { s -> s.toLong() }\n\n for(i in 1 until 20010) {\n fact[i] = fact[i - 1] * i % MOD\n invfact[i] = invfact[i - 1] * invMod(i.toLong()) % MOD\n }\n\n val a = K * (K - 1) % MOD * invMod(2) % MOD\n val b = f(N, M) * a % MOD\n val c = f(M, N) * a % MOD\n\n val res = (b + c) * comb(N * M, K) % MOD\n\n println(res)\n}", "language": "Kotlin", "metadata": {"date": 1570414220, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03039.html", "problem_id": "p03039", "resource_group": "medium_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/Kotlin/s696549200.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s696549200", "user_id": "u183530284"}, "prompt_components": {"gold_output": "8\n", "input_to_evaluate": "val fact = Array(200010) { 1L }\nval invfact = Array(200010) { 1L }\n\nval MOD = 1000000007L;\n\nfun comb(n: Long, m: Long): Long {\n if ( n < m )\n return 0L\n\n return fact[n.toInt()] * invfact[(n - m).toInt()] % MOD * invfact[m.toInt()] % MOD\n}\n\nfun powMod(n: Long, l: Long): Long {\n var k = l\n var a = 1L;\n var m = n\n while (k > 0) {\n if (k % 2 == 1L) {\n a = (a * m) % MOD;\n }\n m = (m * m) % MOD;\n k /= 2L\n }\n\n return a\n}\n\nfun invMod(n: Long): Long {\n return powMod(n, MOD - 2)\n}\n\nfun f(n: Long, m: Long): Long {\n var res = 0L\n val p = invMod(comb(n * m, 2))\n\n for (i in 1L until n) {\n res += (n - i) * i % MOD * m % MOD * m % MOD * p % MOD\n }\n\n return res\n}\n\nfun main(args: Array) {\n val (N, M, K) = readLine()!!.split(\" \").map { s -> s.toLong() }\n\n for(i in 1 until 20010) {\n fact[i] = fact[i - 1] * i % MOD\n invfact[i] = invfact[i - 1] * invMod(i.toLong()) % MOD\n }\n\n val a = K * (K - 1) % MOD * invMod(2) % MOD\n val b = f(N, M) * a % MOD\n val c = f(M, N) * a % MOD\n\n val res = (b + c) * comb(N * M, K) % MOD\n\n println(res)\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1164, "cpu_time_ms": 287, "memory_kb": 40692}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s225542055", "group_id": "codeNet:p03041", "input_text": "fun main(args: Array) {\n val (x, y) = readLine()!!.split(\" \").map { it.toInt() }\n val s = readLine()!!.toMutableList()\n when(s[y - 1]){\n 'A' -> s[y - 1] = 'a'\n 'B' -> s[y - 1] = 'b'\n 'C' -> s[y - 1] = 'c'\n }\n for(i in 0 until x){\n print(s[i])\n }\n}", "language": "Kotlin", "metadata": {"date": 1558314543, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03041.html", "problem_id": "p03041", "resource_group": "medium_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/Kotlin/s225542055.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s225542055", "user_id": "u227189389"}, "prompt_components": {"gold_output": "aBC\n", "input_to_evaluate": "fun main(args: Array) {\n val (x, y) = readLine()!!.split(\" \").map { it.toInt() }\n val s = readLine()!!.toMutableList()\n when(s[y - 1]){\n 'A' -> s[y - 1] = 'a'\n 'B' -> s[y - 1] = 'b'\n 'C' -> s[y - 1] = 'c'\n }\n for(i in 0 until x){\n print(s[i])\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 247, "memory_kb": 36144}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s465667456", "group_id": "codeNet:p03042", "input_text": "import java.util.*\n\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n\n var S: Long\n S = sc.nextLong()\n solve(S)\n}\n\nfun f(n: Long) = n in 1..12\n\nfun solve(S: Long) {\n val a = S / 100\n val b = S % 100\n\n if (f(a) && f(b)) {\n println(\"AMBIGUOUS\")\n } else if (f(a)) {\n println(\"MMYY\")\n } else if (f(b)) {\n println(\"YYMM\")\n } else {\n println(\"NA\")\n }\n}\n", "language": "Kotlin", "metadata": {"date": 1571273826, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03042.html", "problem_id": "p03042", "resource_group": "medium_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/Kotlin/s465667456.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s465667456", "user_id": "u183530284"}, "prompt_components": {"gold_output": "YYMM\n", "input_to_evaluate": "import java.util.*\n\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n\n var S: Long\n S = sc.nextLong()\n solve(S)\n}\n\nfun f(n: Long) = n in 1..12\n\nfun solve(S: Long) {\n val a = S / 100\n val b = S % 100\n\n if (f(a) && f(b)) {\n println(\"AMBIGUOUS\")\n } else if (f(a)) {\n println(\"MMYY\")\n } else if (f(b)) {\n println(\"YYMM\")\n } else {\n println(\"NA\")\n }\n}\n", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 180, "memory_kb": 31260}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s119322803", "group_id": "codeNet:p03042", "input_text": "import com.sun.org.apache.xpath.internal.operations.Bool\nimport java.lang.Math.*\n\nconst val MOD = 1000000007L\n\nfun main(args: Array) {\n val s = readList().first()\n\n val former = s.substring(0, 2).toInt()\n val latter = s.substring(2, 4).toInt()\n\n fun isY(int: Int): Boolean {\n return int > 12 || int == 0\n }\n\n fun mayM(int: Int): Boolean {\n return int in 1..12\n }\n\n if (mayM(former) && mayM(latter)) {\n println(\"AMBIGUOUS\")\n } else if (mayM(former)) {\n println(\"MMYY\")\n } else if (mayM(latter)) {\n println(\"YYMM\")\n } else {\n println(\"NA\")\n }\n\n}\n\n\nfun readList() = readLine()!!.split(' ')\nfun readInt() = readLine()!!.split(' ').map(String::toInt).first()\nfun readIntList() = readList().map(String::toInt)\nfun readLongList() = readList().map(String::toLong)\nfun readDoubleList() = readList().map(String::toDouble)\n\nfun readPair(): Pair {\n val splite = readLine()!!.split(' ')\n return Pair(splite[0], splite[1])\n}\n\nfun List.copy() = this.map { it }\n\n// 速度のためforEachは避ける\ninline fun Int.rep(start: Int = 0, shiftLast: Boolean = false, body: (Int) -> Unit) {\n for (i in start until if (shiftLast) this + start else this) {\n body(i)\n }\n}\n\ninline fun Long.rep(start: Long = 0, shiftLast: Boolean = false, body: (Long) -> Unit) {\n for (i in start until if (shiftLast) this + start else this) {\n body(i)\n }\n}\n\n// 約数のList\nfun divisor(value: Long): List {\n val max = sqrt(value.toDouble()).toLong()\n val former = mutableListOf()\n val latter = mutableListOf()\n (1..max).filter { value % it == 0L }\n .forEach {\n former.add(it)\n latter.add(value / it)\n }\n former.addAll(latter.reversed())\n return former\n}\n\n// 範囲内の素数を取得\n// fromだけ指定すると戻り値の個数で素数判定ができる\nfun prime(from: Long, to: Long = from): List {\n return (from..to).filter { i ->\n val max = Math.sqrt(i.toDouble()).toLong()\n (2..max).all { j -> i % j != 0L }\n }\n}\n\n// 素因数分解\nfun decom(value: Long): List {\n if (value == 1L) return listOf(1)\n val max = Math.sqrt(value.toDouble()).toLong()\n return prime(2, max).filter { value % it == 0L }\n}\n\n// 最大公約数\nfun gcd(a: Long, b: Long): Long {\n return if (a % b == 0L) b else gcd(b, a % b)\n}\n\n// 文字列を入れ替え\nfun swap(base: String, a: String, b: String): String {\n return base.map {\n when (it) {\n a.toCharArray()[0] -> b\n b.toCharArray()[0] -> a\n else -> it.toString()\n }\n }.joinToString()\n}\n\n// 二分探索\nfun Array.binarySearch(target: Long, _start: Int = 0, _end: Int = this.size): Int {\n var start = (_start - 1).toLong()\n var end = _end.toLong()\n while (end - start > 1) {\n val mid = (start + end) / 2\n if (this[mid.toInt()] < target) {\n start = mid\n } else {\n end = mid\n }\n }\n return end.toInt()\n}\n\n// bit全探索\ninline fun Int.bitAllSearch(body: (Array) -> Unit) {\n for (bit in 0 until (1 shl this)) {\n val s = mutableListOf()\n for (i in 0 until this) {\n if ((bit and (1 shl i)) shr i == 1) { // i が bit に入るかどうか\n s.add(i)\n }\n }\n body(s.toTypedArray())\n }\n}", "language": "Kotlin", "metadata": {"date": 1565317043, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03042.html", "problem_id": "p03042", "resource_group": "medium_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/Kotlin/s119322803.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s119322803", "user_id": "u718935188"}, "prompt_components": {"gold_output": "YYMM\n", "input_to_evaluate": "import com.sun.org.apache.xpath.internal.operations.Bool\nimport java.lang.Math.*\n\nconst val MOD = 1000000007L\n\nfun main(args: Array) {\n val s = readList().first()\n\n val former = s.substring(0, 2).toInt()\n val latter = s.substring(2, 4).toInt()\n\n fun isY(int: Int): Boolean {\n return int > 12 || int == 0\n }\n\n fun mayM(int: Int): Boolean {\n return int in 1..12\n }\n\n if (mayM(former) && mayM(latter)) {\n println(\"AMBIGUOUS\")\n } else if (mayM(former)) {\n println(\"MMYY\")\n } else if (mayM(latter)) {\n println(\"YYMM\")\n } else {\n println(\"NA\")\n }\n\n}\n\n\nfun readList() = readLine()!!.split(' ')\nfun readInt() = readLine()!!.split(' ').map(String::toInt).first()\nfun readIntList() = readList().map(String::toInt)\nfun readLongList() = readList().map(String::toLong)\nfun readDoubleList() = readList().map(String::toDouble)\n\nfun readPair(): Pair {\n val splite = readLine()!!.split(' ')\n return Pair(splite[0], splite[1])\n}\n\nfun List.copy() = this.map { it }\n\n// 速度のためforEachは避ける\ninline fun Int.rep(start: Int = 0, shiftLast: Boolean = false, body: (Int) -> Unit) {\n for (i in start until if (shiftLast) this + start else this) {\n body(i)\n }\n}\n\ninline fun Long.rep(start: Long = 0, shiftLast: Boolean = false, body: (Long) -> Unit) {\n for (i in start until if (shiftLast) this + start else this) {\n body(i)\n }\n}\n\n// 約数のList\nfun divisor(value: Long): List {\n val max = sqrt(value.toDouble()).toLong()\n val former = mutableListOf()\n val latter = mutableListOf()\n (1..max).filter { value % it == 0L }\n .forEach {\n former.add(it)\n latter.add(value / it)\n }\n former.addAll(latter.reversed())\n return former\n}\n\n// 範囲内の素数を取得\n// fromだけ指定すると戻り値の個数で素数判定ができる\nfun prime(from: Long, to: Long = from): List {\n return (from..to).filter { i ->\n val max = Math.sqrt(i.toDouble()).toLong()\n (2..max).all { j -> i % j != 0L }\n }\n}\n\n// 素因数分解\nfun decom(value: Long): List {\n if (value == 1L) return listOf(1)\n val max = Math.sqrt(value.toDouble()).toLong()\n return prime(2, max).filter { value % it == 0L }\n}\n\n// 最大公約数\nfun gcd(a: Long, b: Long): Long {\n return if (a % b == 0L) b else gcd(b, a % b)\n}\n\n// 文字列を入れ替え\nfun swap(base: String, a: String, b: String): String {\n return base.map {\n when (it) {\n a.toCharArray()[0] -> b\n b.toCharArray()[0] -> a\n else -> it.toString()\n }\n }.joinToString()\n}\n\n// 二分探索\nfun Array.binarySearch(target: Long, _start: Int = 0, _end: Int = this.size): Int {\n var start = (_start - 1).toLong()\n var end = _end.toLong()\n while (end - start > 1) {\n val mid = (start + end) / 2\n if (this[mid.toInt()] < target) {\n start = mid\n } else {\n end = mid\n }\n }\n return end.toInt()\n}\n\n// bit全探索\ninline fun Int.bitAllSearch(body: (Array) -> Unit) {\n for (bit in 0 until (1 shl this)) {\n val s = mutableListOf()\n for (i in 0 until this) {\n if ((bit and (1 shl i)) shr i == 1) { // i が bit に入るかどうか\n s.add(i)\n }\n }\n body(s.toTypedArray())\n }\n}", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 3438, "cpu_time_ms": 235, "memory_kb": 38328}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s932229928", "group_id": "codeNet:p03042", "input_text": "import java.io.*\nimport java.util.*\n\nval pw = PrintWriter(System.out)\nfun solve(S: Int){\n val a = S / 100\n val b = S % 100\n if (1<= a && a<= 12){\n if (1<= b && b<= 12){\n println(\"AMBIGUOUS\")\n return\n }\n println(\"MMYY\")\n return\n }\n if (1<= b && b<= 12){\n println(\"YYMM\")\n return\n }\n println(\"NA\")\n return\n return\n}\n\n\nfun main(args: Array) {\n fun StringArray(size: Int, init: (Int) -> String = { \"\\u0000\" }): Array {\n return Array(size, init)\n }\n class Scanner(stream: InputStream) {\n private val reader = BufferedInputStream(stream).bufferedReader()\n private var st: StringTokenizer? = null\n fun next(): String {\n while (!(st?.hasMoreTokens() ?: false)) st = StringTokenizer(reader.readLine())\n return st!!.nextToken()\n }\n }\n val sc = Scanner(System.`in`)\n val S = sc.next().toInt()\n solve(S)\n}\n\n", "language": "Kotlin", "metadata": {"date": 1562869971, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03042.html", "problem_id": "p03042", "resource_group": "medium_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/Kotlin/s932229928.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s932229928", "user_id": "u329232967"}, "prompt_components": {"gold_output": "YYMM\n", "input_to_evaluate": "import java.io.*\nimport java.util.*\n\nval pw = PrintWriter(System.out)\nfun solve(S: Int){\n val a = S / 100\n val b = S % 100\n if (1<= a && a<= 12){\n if (1<= b && b<= 12){\n println(\"AMBIGUOUS\")\n return\n }\n println(\"MMYY\")\n return\n }\n if (1<= b && b<= 12){\n println(\"YYMM\")\n return\n }\n println(\"NA\")\n return\n return\n}\n\n\nfun main(args: Array) {\n fun StringArray(size: Int, init: (Int) -> String = { \"\\u0000\" }): Array {\n return Array(size, init)\n }\n class Scanner(stream: InputStream) {\n private val reader = BufferedInputStream(stream).bufferedReader()\n private var st: StringTokenizer? = null\n fun next(): String {\n while (!(st?.hasMoreTokens() ?: false)) st = StringTokenizer(reader.readLine())\n return st!!.nextToken()\n }\n }\n val sc = Scanner(System.`in`)\n val S = sc.next().toInt()\n solve(S)\n}\n\n", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1004, "cpu_time_ms": 190, "memory_kb": 31380}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s812519050", "group_id": "codeNet:p03042", "input_text": "fun main(args: Array) {\n\n val s = readLine()!!.split(\"\").toTypedArray()\n\n val mm = listOf(\"01\", \"02\", \"03\", \"04\", \"05\", \"06\", \"07\", \"08\", \"09\", \"10\", \"11\", \"12\")\n val yy = (1..99).map { if (it in (1..9)) \"0$it\" else it.toString() }\n\n val l = (s[1] + s[2])\n val r = (s[3] + s[4])\n\n if(l in yy && r in mm && l in mm && r in yy){\n println(\"AMBIGUOUS\")\n return\n }\n\n // 左がMMかつ右がYYの場合\n if (l in mm && r in yy) {\n println(\"MMYY\")\n return\n }\n\n // 左がYYかつ右がMMの場合\n if (l in yy && r in mm) {\n println(\"YYMM\")\n return\n }\n\n println(\"NA\")\n}", "language": "Kotlin", "metadata": {"date": 1558318229, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03042.html", "problem_id": "p03042", "resource_group": "medium_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/Kotlin/s812519050.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s812519050", "user_id": "u108272327"}, "prompt_components": {"gold_output": "YYMM\n", "input_to_evaluate": "fun main(args: Array) {\n\n val s = readLine()!!.split(\"\").toTypedArray()\n\n val mm = listOf(\"01\", \"02\", \"03\", \"04\", \"05\", \"06\", \"07\", \"08\", \"09\", \"10\", \"11\", \"12\")\n val yy = (1..99).map { if (it in (1..9)) \"0$it\" else it.toString() }\n\n val l = (s[1] + s[2])\n val r = (s[3] + s[4])\n\n if(l in yy && r in mm && l in mm && r in yy){\n println(\"AMBIGUOUS\")\n return\n }\n\n // 左がMMかつ右がYYの場合\n if (l in mm && r in yy) {\n println(\"MMYY\")\n return\n }\n\n // 左がYYかつ右がMMの場合\n if (l in yy && r in mm) {\n println(\"YYMM\")\n return\n }\n\n println(\"NA\")\n}", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 653, "cpu_time_ms": 241, "memory_kb": 36156}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s284475871", "group_id": "codeNet:p03042", "input_text": "fun main(args: Array) {\n val s = readLine()!!\n\n val a = s.take(2).toInt()\n val b = s.takeLast(2).toInt()\n\n val ans = if (a == 0 || b == 0) {\n \"NA\"\n } else if (a in (1..12) && b > 12) {\n \"MMYY\"\n } else if (b in (1..12) && a > 12) {\n \"YYMM\"\n } else {\n \"AMBIGUOUS\"\n }\n\n println(ans)\n}\n", "language": "Kotlin", "metadata": {"date": 1558314393, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03042.html", "problem_id": "p03042", "resource_group": "medium_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/Kotlin/s284475871.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s284475871", "user_id": "u863309603"}, "prompt_components": {"gold_output": "YYMM\n", "input_to_evaluate": "fun main(args: Array) {\n val s = readLine()!!\n\n val a = s.take(2).toInt()\n val b = s.takeLast(2).toInt()\n\n val ans = if (a == 0 || b == 0) {\n \"NA\"\n } else if (a in (1..12) && b > 12) {\n \"MMYY\"\n } else if (b in (1..12) && a > 12) {\n \"YYMM\"\n } else {\n \"AMBIGUOUS\"\n }\n\n println(ans)\n}\n", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 207, "memory_kb": 32040}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s516989150", "group_id": "codeNet:p03043", "input_text": "fun main(args: Array) {\n val (n, k) = readLine()!!.split(\" \").map{it.toInt()}\n var res = 0.0\n for (i in 1..n) {\n var den = n\n var num = i\n while (num < k) {\n den *= 2\n num *= 2\n }\n res += 1.0/den\n }\n\n println(res)\n}", "language": "Kotlin", "metadata": {"date": 1569464463, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03043.html", "problem_id": "p03043", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03043/input.txt", "sample_output_relpath": "derived/input_output/data/p03043/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03043/Kotlin/s516989150.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s516989150", "user_id": "u108648546"}, "prompt_components": {"gold_output": "0.145833333333\n", "input_to_evaluate": "fun main(args: Array) {\n val (n, k) = readLine()!!.split(\" \").map{it.toInt()}\n var res = 0.0\n for (i in 1..n) {\n var den = n\n var num = i\n while (num < k) {\n den *= 2\n num *= 2\n }\n res += 1.0/den\n }\n\n println(res)\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nSnuke has a fair N-sided die that shows the integers from 1 to N with equal probability and a fair coin. He will play the following game with them:\n\nThrow the die. The current score is the result of the die.\n\nAs long as the score is between 1 and K-1 (inclusive), keep flipping the coin. The score is doubled each time the coin lands heads up, and the score becomes 0 if the coin lands tails up.\n\nThe game ends when the score becomes 0 or becomes K or above. Snuke wins if the score is K or above, and loses if the score is 0.\n\nYou are given N and K. Find the probability that Snuke wins the game.\n\nConstraints\n\n1 ≤ N ≤ 10^5\n\n1 ≤ K ≤ 10^5\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 probability that Snuke wins the game. The output is considered correct when the absolute or relative error is at most 10^{-9}.\n\nSample Input 1\n\n3 10\n\nSample Output 1\n\n0.145833333333\n\nIf the die shows 1, Snuke needs to get four consecutive heads from four coin flips to obtain a score of 10 or above. The probability of this happening is \\frac{1}{3} \\times (\\frac{1}{2})^4 = \\frac{1}{48}.\n\nIf the die shows 2, Snuke needs to get three consecutive heads from three coin flips to obtain a score of 10 or above. The probability of this happening is \\frac{1}{3} \\times (\\frac{1}{2})^3 = \\frac{1}{24}.\n\nIf the die shows 3, Snuke needs to get two consecutive heads from two coin flips to obtain a score of 10 or above. The probability of this happening is \\frac{1}{3} \\times (\\frac{1}{2})^2 = \\frac{1}{12}.\n\nThus, the probability that Snuke wins is \\frac{1}{48} + \\frac{1}{24} + \\frac{1}{12} = \\frac{7}{48} \\simeq 0.1458333333.\n\nSample Input 2\n\n100000 5\n\nSample Output 2\n\n0.999973749998", "sample_input": "3 10\n"}, "reference_outputs": ["0.145833333333\n"], "source_document_id": "p03043", "source_text": "Score : 300 points\n\nProblem Statement\n\nSnuke has a fair N-sided die that shows the integers from 1 to N with equal probability and a fair coin. He will play the following game with them:\n\nThrow the die. The current score is the result of the die.\n\nAs long as the score is between 1 and K-1 (inclusive), keep flipping the coin. The score is doubled each time the coin lands heads up, and the score becomes 0 if the coin lands tails up.\n\nThe game ends when the score becomes 0 or becomes K or above. Snuke wins if the score is K or above, and loses if the score is 0.\n\nYou are given N and K. Find the probability that Snuke wins the game.\n\nConstraints\n\n1 ≤ N ≤ 10^5\n\n1 ≤ K ≤ 10^5\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 probability that Snuke wins the game. The output is considered correct when the absolute or relative error is at most 10^{-9}.\n\nSample Input 1\n\n3 10\n\nSample Output 1\n\n0.145833333333\n\nIf the die shows 1, Snuke needs to get four consecutive heads from four coin flips to obtain a score of 10 or above. The probability of this happening is \\frac{1}{3} \\times (\\frac{1}{2})^4 = \\frac{1}{48}.\n\nIf the die shows 2, Snuke needs to get three consecutive heads from three coin flips to obtain a score of 10 or above. The probability of this happening is \\frac{1}{3} \\times (\\frac{1}{2})^3 = \\frac{1}{24}.\n\nIf the die shows 3, Snuke needs to get two consecutive heads from two coin flips to obtain a score of 10 or above. The probability of this happening is \\frac{1}{3} \\times (\\frac{1}{2})^2 = \\frac{1}{12}.\n\nThus, the probability that Snuke wins is \\frac{1}{48} + \\frac{1}{24} + \\frac{1}{12} = \\frac{7}{48} \\simeq 0.1458333333.\n\nSample Input 2\n\n100000 5\n\nSample Output 2\n\n0.999973749998", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 247, "memory_kb": 36028}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s175880592", "group_id": "codeNet:p03044", "input_text": "import java.util.*\n\nfun main() {\n val N = readInt()\n val edges = Array(N) { hashMapOf() }\n repeat(N - 1) {\n val (u, v, w) = readInts()\n edges[u - 1][v - 1] = w\n edges[v - 1][u - 1] = w\n }\n val colors = Array(N) { 0 }\n val queue = LinkedList()\n queue.add(0)\n while (queue.isNotEmpty()) {\n val n = queue.pop()\n edges[n].forEach {\n colors[it.key] = if (it.value % 2 == 0) colors[n] else (colors[n] + 1) % 2\n queue.add(it.key)\n edges[it.key].remove(n)\n }\n }\n println(colors.joinToString(\"\\n\"))\n}\n\nfun gcd(a: Int, b: Int): Int = if (a < b) gcd(b, a) else if (b == 0) a else gcd(b, a % b)\nfun gcd(a: Long, b: Long): Long = if (a < b) gcd(b, a) else if (b == 0L) a else gcd(b, a % b)\nfun lcm(a: Int, b: Int): Int = (a * b) / gcd(a, b)\nfun lcm(a: Long, b: Long): Long = (a * b) / gcd(a, b)\n\nfun readString() = readLine()!!\nfun readStrings() = readLine()!!.split(\" \")\nfun readInt() = readLine()!!.toInt()\nfun readLong() = readLine()!!.toLong()\nfun readInts() = readLine()!!.split(\" \").map { it.toInt() }\nfun readLongs() = readLine()!!.split(\" \").map { it.toLong() }\n\nfun myBinarySearch(begin: Int, end: Int, isOk: (key: Int) -> Boolean): Int {\n var ng = begin\n var ok = end\n\n while (Math.abs(ok - ng) > 1) {\n val mid = (ok + ng) / 2\n if (isOk(mid)) {\n ok = mid\n } else {\n ng = mid\n }\n }\n\n return ok\n}\n\nfun List.myBinarySearch(isOk: (T) -> Boolean): Int {\n return myBinarySearch(-1, size) { index -> isOk(get(index)) }\n}\n\nfun Array.myBinarySearch(isOk: (T) -> Boolean): Int {\n return myBinarySearch(-1, size) { index -> isOk(get(index)) }\n}\n", "language": "Kotlin", "metadata": {"date": 1596345368, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p03044.html", "problem_id": "p03044", "resource_group": "medium_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/Kotlin/s175880592.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s175880592", "user_id": "u979004569"}, "prompt_components": {"gold_output": "0\n0\n1\n", "input_to_evaluate": "import java.util.*\n\nfun main() {\n val N = readInt()\n val edges = Array(N) { hashMapOf() }\n repeat(N - 1) {\n val (u, v, w) = readInts()\n edges[u - 1][v - 1] = w\n edges[v - 1][u - 1] = w\n }\n val colors = Array(N) { 0 }\n val queue = LinkedList()\n queue.add(0)\n while (queue.isNotEmpty()) {\n val n = queue.pop()\n edges[n].forEach {\n colors[it.key] = if (it.value % 2 == 0) colors[n] else (colors[n] + 1) % 2\n queue.add(it.key)\n edges[it.key].remove(n)\n }\n }\n println(colors.joinToString(\"\\n\"))\n}\n\nfun gcd(a: Int, b: Int): Int = if (a < b) gcd(b, a) else if (b == 0) a else gcd(b, a % b)\nfun gcd(a: Long, b: Long): Long = if (a < b) gcd(b, a) else if (b == 0L) a else gcd(b, a % b)\nfun lcm(a: Int, b: Int): Int = (a * b) / gcd(a, b)\nfun lcm(a: Long, b: Long): Long = (a * b) / gcd(a, b)\n\nfun readString() = readLine()!!\nfun readStrings() = readLine()!!.split(\" \")\nfun readInt() = readLine()!!.toInt()\nfun readLong() = readLine()!!.toLong()\nfun readInts() = readLine()!!.split(\" \").map { it.toInt() }\nfun readLongs() = readLine()!!.split(\" \").map { it.toLong() }\n\nfun myBinarySearch(begin: Int, end: Int, isOk: (key: Int) -> Boolean): Int {\n var ng = begin\n var ok = end\n\n while (Math.abs(ok - ng) > 1) {\n val mid = (ok + ng) / 2\n if (isOk(mid)) {\n ok = mid\n } else {\n ng = mid\n }\n }\n\n return ok\n}\n\nfun List.myBinarySearch(isOk: (T) -> Boolean): Int {\n return myBinarySearch(-1, size) { index -> isOk(get(index)) }\n}\n\nfun Array.myBinarySearch(isOk: (T) -> Boolean): Int {\n return myBinarySearch(-1, size) { index -> isOk(get(index)) }\n}\n", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1632, "cpu_time_ms": 860, "memory_kb": 87812}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s258016227", "group_id": "codeNet:p03044", "input_text": "import java.util.Arrays\nimport java.util.ArrayList\n\nconst val MOD: Long = (1e9+7).toLong()\nfun Double.format(digits: Int) = String.format(\"%.${digits}f\", this)\nfun > Iterable.argmax(): Int? = withIndex().maxBy{it.value}?.index\nfun > Iterable.argmin(): Int? = withIndex().minBy{it.value}?.index\n\nclass UFT(val n: Int) {\n val par = Array(n, {it})\n val rank = Array(n, {0})\n\n fun root(x: Int): Int {\n if (par[x] == x) {\n return x\n }\n par[x] = root(par[x])\n return par[x]\n }\n\n fun isSame(x: Int, y: Int): Boolean {\n return root(x) == root(y)\n }\n\n fun unite(x: Int, y: Int): Unit {\n val x2 = root(x)\n val y2 = root(y)\n if (x2 == y2) return\n\n if (rank[x2] < rank[y2]) {\n par[x2] = y2\n } else {\n par[y2] = x2\n if (rank[x2] == rank[y2]) rank[x2]++\n }\n }\n}\n\nfun main(args: Array) {\n val reader = System.`in`.bufferedReader()\n val n = reader.readLine()!!.toInt()\n\n val e = Array(n-1, {\n val (u, v, w) = reader.readLine()!!.split(\" \").map{it.toInt()}\n Triple(u-1, v-1, w)\n })\n\n val t = UFT(n)\n val res = Array(n, {-1})\n for (i in 0..n-2) {\n val (u, v, w) = e[i]\n if (w%2 == 1) {\n continue\n }\n t.unite(u, v)\n }\n for (i in 0..n-2) {\n val (u, v, w) = e[i]\n if (w%2 == 0) {\n continue\n }\n if (res[u] != -1) {\n res[v] = (res[u] + 1) %2\n res[t.root(v)] = res[v]\n } else if (res[v] != -1) {\n res[u] = (res[v] + 1) %2\n res[t.root(u)] = res[u]\n } else {\n res[u] = 0\n res[t.root(u)] = 0\n res[v] = 1\n res[t.root(v)] = 1\n }\n }\n for (i in 0..n-1) {\n if (res[i] == -1 && res[t.root(i)] == -1) {\n res[i] = 0\n res[t.root(i)] = 0\n }\n }\n\n for ((index, i) in res.withIndex()) {\n println(if (i != -1) i else res[t.root(index)])\n }\n}\n", "language": "Kotlin", "metadata": {"date": 1558317416, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03044.html", "problem_id": "p03044", "resource_group": "medium_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/Kotlin/s258016227.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s258016227", "user_id": "u868099754"}, "prompt_components": {"gold_output": "0\n0\n1\n", "input_to_evaluate": "import java.util.Arrays\nimport java.util.ArrayList\n\nconst val MOD: Long = (1e9+7).toLong()\nfun Double.format(digits: Int) = String.format(\"%.${digits}f\", this)\nfun > Iterable.argmax(): Int? = withIndex().maxBy{it.value}?.index\nfun > Iterable.argmin(): Int? = withIndex().minBy{it.value}?.index\n\nclass UFT(val n: Int) {\n val par = Array(n, {it})\n val rank = Array(n, {0})\n\n fun root(x: Int): Int {\n if (par[x] == x) {\n return x\n }\n par[x] = root(par[x])\n return par[x]\n }\n\n fun isSame(x: Int, y: Int): Boolean {\n return root(x) == root(y)\n }\n\n fun unite(x: Int, y: Int): Unit {\n val x2 = root(x)\n val y2 = root(y)\n if (x2 == y2) return\n\n if (rank[x2] < rank[y2]) {\n par[x2] = y2\n } else {\n par[y2] = x2\n if (rank[x2] == rank[y2]) rank[x2]++\n }\n }\n}\n\nfun main(args: Array) {\n val reader = System.`in`.bufferedReader()\n val n = reader.readLine()!!.toInt()\n\n val e = Array(n-1, {\n val (u, v, w) = reader.readLine()!!.split(\" \").map{it.toInt()}\n Triple(u-1, v-1, w)\n })\n\n val t = UFT(n)\n val res = Array(n, {-1})\n for (i in 0..n-2) {\n val (u, v, w) = e[i]\n if (w%2 == 1) {\n continue\n }\n t.unite(u, v)\n }\n for (i in 0..n-2) {\n val (u, v, w) = e[i]\n if (w%2 == 0) {\n continue\n }\n if (res[u] != -1) {\n res[v] = (res[u] + 1) %2\n res[t.root(v)] = res[v]\n } else if (res[v] != -1) {\n res[u] = (res[v] + 1) %2\n res[t.root(u)] = res[u]\n } else {\n res[u] = 0\n res[t.root(u)] = 0\n res[v] = 1\n res[t.root(v)] = 1\n }\n }\n for (i in 0..n-1) {\n if (res[i] == -1 && res[t.root(i)] == -1) {\n res[i] = 0\n res[t.root(i)] = 0\n }\n }\n\n for ((index, i) in res.withIndex()) {\n println(if (i != -1) i else res[t.root(index)])\n }\n}\n", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2082, "cpu_time_ms": 1265, "memory_kb": 80828}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s128647769", "group_id": "codeNet:p03045", "input_text": "fun main(args: Array){\n val (n, m) = readLine()!!.split(\" \").map { it.toInt() }\n val zyx = Array(m){ readLine()!!.split(\" \").map { it.toInt() }.let { Triple(it[0], it[1], it[2]) }}\n\n val tree = UnionFind(n)\n zyx.forEach {\n tree.unite(it.first - 1, it.second - 1)\n }\n println(tree.size())\n}\n\nclass UnionFind(n: Int) {\n\n private val parent = IntArray(n){ i -> i }\n\n fun root(x: Int): Int{\n if(parent[x] == x){\n return x\n }else{\n parent[x] = root(parent[x])\n return parent[x]\n }\n }\n\n fun unite(x: Int, y: Int){\n val rx = root(x)\n val ry = root(y)\n if(rx != ry){\n parent[rx] = ry\n }\n }\n\n fun size(): Int{\n return (parent.indices).map { root(it) }.distinct().size\n }\n}", "language": "Kotlin", "metadata": {"date": 1590200373, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03045.html", "problem_id": "p03045", "resource_group": "medium_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/Kotlin/s128647769.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s128647769", "user_id": "u531770859"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "fun main(args: Array){\n val (n, m) = readLine()!!.split(\" \").map { it.toInt() }\n val zyx = Array(m){ readLine()!!.split(\" \").map { it.toInt() }.let { Triple(it[0], it[1], it[2]) }}\n\n val tree = UnionFind(n)\n zyx.forEach {\n tree.unite(it.first - 1, it.second - 1)\n }\n println(tree.size())\n}\n\nclass UnionFind(n: Int) {\n\n private val parent = IntArray(n){ i -> i }\n\n fun root(x: Int): Int{\n if(parent[x] == x){\n return x\n }else{\n parent[x] = root(parent[x])\n return parent[x]\n }\n }\n\n fun unite(x: Int, y: Int){\n val rx = root(x)\n val ry = root(y)\n if(rx != ry){\n parent[rx] = ry\n }\n }\n\n fun size(): Int{\n return (parent.indices).map { root(it) }.distinct().size\n }\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 817, "cpu_time_ms": 725, "memory_kb": 83256}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s697279053", "group_id": "codeNet:p03048", "input_text": "fun main(args : Array) {\n val (r, g, b, n) = readLine()!!.split(\" \").map { it.toInt() }\n\n var cnt = 0\n\n for (i in 0..n) {\n for (j in 0..n) {\n val rest = n - (i * r) - (j * g)\n if (rest >= 0 && rest % b == 0) cnt++\n }\n }\n\n println(cnt)\n}", "language": "Kotlin", "metadata": {"date": 1587115173, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03048.html", "problem_id": "p03048", "resource_group": "medium_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/Kotlin/s697279053.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s697279053", "user_id": "u262403099"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "fun main(args : Array) {\n val (r, g, b, n) = readLine()!!.split(\" \").map { it.toInt() }\n\n var cnt = 0\n\n for (i in 0..n) {\n for (j in 0..n) {\n val rest = n - (i * r) - (j * g)\n if (rest >= 0 && rest % b == 0) cnt++\n }\n }\n\n println(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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 265, "memory_kb": 36072}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s795296865", "group_id": "codeNet:p03059", "input_text": "fun main(args: Array) {\n val (a, b, t) = readLine()!!.split(\" \").map { Integer.parseInt(it) }\n println((t/a)*b)\n}", "language": "Kotlin", "metadata": {"date": 1556413534, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03059.html", "problem_id": "p03059", "resource_group": "medium_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/Kotlin/s795296865.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s795296865", "user_id": "u039197338"}, "prompt_components": {"gold_output": "10\n", "input_to_evaluate": "fun main(args: Array) {\n val (a, b, t) = readLine()!!.split(\" \").map { Integer.parseInt(it) }\n println((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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 305, "memory_kb": 37872}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s611927054", "group_id": "codeNet:p03060", "input_text": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val n = sc.nextInt()\n val v = (0 until n).map { sc.next().toInt() }\n val c = (0 until n).map { sc.next().toInt() }\n println(problem125b(n, v, c))\n}\n\nfun problem125b(n: Int, v: List, c: List): Int {\n var sum = 0\n for (i in 0 until n) {\n if (v[i] > c[i]) sum += v[i] - c[i]\n }\n return sum\n}", "language": "Kotlin", "metadata": {"date": 1591919713, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03060.html", "problem_id": "p03060", "resource_group": "medium_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/Kotlin/s611927054.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s611927054", "user_id": "u073232808"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val n = sc.nextInt()\n val v = (0 until n).map { sc.next().toInt() }\n val c = (0 until n).map { sc.next().toInt() }\n println(problem125b(n, v, c))\n}\n\nfun problem125b(n: Int, v: List, c: List): Int {\n var sum = 0\n for (i in 0 until n) {\n if (v[i] > c[i]) sum += v[i] - c[i]\n }\n return 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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 204, "memory_kb": 29472}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s152126952", "group_id": "codeNet:p03060", "input_text": "fun main(args: Array){\n\n val n = readLine()!!.toInt()\n val v = readLine()!!.split(\" \")\n val c = readLine()!!.split(\" \")\n \n val diff = mutableListOf()\n\n var ans = 0\n\n for(i in 0.. n-1){\n diff.add(v[i].toInt()-c[i].toInt())\n\n if(diff[i] > 0){\n ans += diff[i]\n }\n }\n println(ans)\n\n\n\n\n}", "language": "Kotlin", "metadata": {"date": 1556413839, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03060.html", "problem_id": "p03060", "resource_group": "medium_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/Kotlin/s152126952.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s152126952", "user_id": "u151176417"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "fun main(args: Array){\n\n val n = readLine()!!.toInt()\n val v = readLine()!!.split(\" \")\n val c = readLine()!!.split(\" \")\n \n val diff = mutableListOf()\n\n var ans = 0\n\n for(i in 0.. n-1){\n diff.add(v[i].toInt()-c[i].toInt())\n\n if(diff[i] > 0){\n ans += diff[i]\n }\n }\n println(ans)\n\n\n\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 233, "memory_kb": 37872}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s544033173", "group_id": "codeNet:p03060", "input_text": "fun main(args: Array) {\n val n = Integer.parseInt(readInputLine())\n val vs = readInputLine().split(\" \").map { it -> Integer.parseInt(it) }\n val cs = readInputLine().split(\" \").map { it -> Integer.parseInt(it) }\n \n var res = 0\n \n for (i in 0..(n-1)) {\n val value = vs[i] - cs[i]\n if (value > 0) {\n res += value\n }\n }\n\n println(res)\n}\n \nfun readInputLine(): String {\n return readLine()!!\n}\n", "language": "Kotlin", "metadata": {"date": 1556413742, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03060.html", "problem_id": "p03060", "resource_group": "medium_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/Kotlin/s544033173.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s544033173", "user_id": "u505558493"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "fun main(args: Array) {\n val n = Integer.parseInt(readInputLine())\n val vs = readInputLine().split(\" \").map { it -> Integer.parseInt(it) }\n val cs = readInputLine().split(\" \").map { it -> Integer.parseInt(it) }\n \n var res = 0\n \n for (i in 0..(n-1)) {\n val value = vs[i] - cs[i]\n if (value > 0) {\n res += value\n }\n }\n\n println(res)\n}\n \nfun readInputLine(): String {\n return readLine()!!\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 458, "cpu_time_ms": 252, "memory_kb": 37748}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s043398634", "group_id": "codeNet:p03062", "input_text": "fun main(args: Array) {\n readLine()!!.toInt()\n val a = readLine()!!.split(\" \").map(String::toLong)\n val sum = a.map { Math.abs(it) }.sum()\n val min = Math.abs(a.minBy { Math.abs(it) }!!)\n val hasMinus = a.count { it < 0 } % 2 == 1\n println(if (hasMinus) sum - min * 2 else sum)\n}\n", "language": "Kotlin", "metadata": {"date": 1557414212, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03062.html", "problem_id": "p03062", "resource_group": "medium_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/Kotlin/s043398634.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s043398634", "user_id": "u099066216"}, "prompt_components": {"gold_output": "19\n", "input_to_evaluate": "fun main(args: Array) {\n readLine()!!.toInt()\n val a = readLine()!!.split(\" \").map(String::toLong)\n val sum = a.map { Math.abs(it) }.sum()\n val min = Math.abs(a.minBy { Math.abs(it) }!!)\n val hasMinus = a.count { it < 0 } % 2 == 1\n println(if (hasMinus) sum - min * 2 else sum)\n}\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 536, "memory_kb": 61552}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s524518123", "group_id": "codeNet:p03062", "input_text": "fun main(args: Array) {\n val n = readLine()!!.toInt()\n val an = readLine()!!.split(\" \").map(String::toInt)\n\n var count = 0\n for (i in 0..(n - 1)) {\n if (an[i] < 0) {\n count++\n }\n }\n\n val abs = an.map(Math::abs)\n val min = abs.min()!!\n val ans = if (count % 2 == 0) {\n abs.sum()\n } else {\n abs.sum() - min * 2\n }\n\n if (ans == 1410065408 || ans < 0) {\n println(10000000000)\n } else {\n println(ans)\n }\n}\n", "language": "Kotlin", "metadata": {"date": 1556419192, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03062.html", "problem_id": "p03062", "resource_group": "medium_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/Kotlin/s524518123.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s524518123", "user_id": "u072992150"}, "prompt_components": {"gold_output": "19\n", "input_to_evaluate": "fun main(args: Array) {\n val n = readLine()!!.toInt()\n val an = readLine()!!.split(\" \").map(String::toInt)\n\n var count = 0\n for (i in 0..(n - 1)) {\n if (an[i] < 0) {\n count++\n }\n }\n\n val abs = an.map(Math::abs)\n val min = abs.min()!!\n val ans = if (count % 2 == 0) {\n abs.sum()\n } else {\n abs.sum() - min * 2\n }\n\n if (ans == 1410065408 || ans < 0) {\n println(10000000000)\n } else {\n println(ans)\n }\n}\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 531, "memory_kb": 61808}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s207827220", "group_id": "codeNet:p03064", "input_text": "fun main(args: Array) {\n val n = readLine()!!.toInt()\n val a = Array(n) {\n readLine()!!.toInt()\n }\n val suma = a.sum()\n val suma2 = suma / 2\n val mod = 998244353L\n val dp1 = Array(suma2 + 1) { i ->\n if (i == 0) 3L else 0L\n }\n val dp2 = Array(suma2 + 1) { i ->\n if (i == 0) 3L else 0L\n }\n a.map { ai ->\n (suma2 downTo ai).map { j ->\n dp1[j] = (dp1[j] + dp1[j - ai] * 2) % mod\n dp2[j] = (dp2[j] + dp2[j - ai] ) % mod\n }\n }\n val pow3 = (1 .. n).fold(1L) { x, dummy ->\n (x * 3) % mod\n }\n val ret = dp1.fold(pow3) { x, dp ->\n (x + mod - dp) % mod\n }\n val half = if (suma % 2 == 0) dp2[suma2] else 0\n print(\"${(ret + half) % mod}\")\n}", "language": "Kotlin", "metadata": {"date": 1555947148, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03064.html", "problem_id": "p03064", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03064/input.txt", "sample_output_relpath": "derived/input_output/data/p03064/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03064/Kotlin/s207827220.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s207827220", "user_id": "u816872429"}, "prompt_components": {"gold_output": "18\n", "input_to_evaluate": "fun main(args: Array) {\n val n = readLine()!!.toInt()\n val a = Array(n) {\n readLine()!!.toInt()\n }\n val suma = a.sum()\n val suma2 = suma / 2\n val mod = 998244353L\n val dp1 = Array(suma2 + 1) { i ->\n if (i == 0) 3L else 0L\n }\n val dp2 = Array(suma2 + 1) { i ->\n if (i == 0) 3L else 0L\n }\n a.map { ai ->\n (suma2 downTo ai).map { j ->\n dp1[j] = (dp1[j] + dp1[j - ai] * 2) % mod\n dp2[j] = (dp2[j] + dp2[j - ai] ) % mod\n }\n }\n val pow3 = (1 .. n).fold(1L) { x, dummy ->\n (x * 3) % mod\n }\n val ret = dp1.fold(pow3) { x, dp ->\n (x + mod - dp) % mod\n }\n val half = if (suma % 2 == 0) dp2[suma2] else 0\n print(\"${(ret + half) % mod}\")\n}", "problem_context": "Score : 600 points\n\nProblem Statement\n\nYou are given N integers. The i-th integer is a_i.\nFind the number, modulo 998244353, of ways to paint each of the integers red, green or blue so that the following condition is satisfied:\n\nLet R, G and B be the sums of the integers painted red, green and blue, respectively. There exists a triangle with positive area whose sides have lengths R, G and B.\n\nConstraints\n\n3 \\leq N \\leq 300\n\n1 \\leq a_i \\leq 300(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\na_1\n:\na_N\n\nOutput\n\nPrint the number, modulo 998244353, of ways to paint each of the integers red, green or blue so that the condition is satisfied.\n\nSample Input 1\n\n4\n1\n1\n1\n2\n\nSample Output 1\n\n18\n\nWe can only paint the integers so that the lengths of the sides of the triangle will be 1, 2 and 2, and there are 18 such ways.\n\nSample Input 2\n\n6\n1\n3\n2\n3\n5\n2\n\nSample Output 2\n\n150\n\nSample Input 3\n\n20\n3\n1\n4\n1\n5\n9\n2\n6\n5\n3\n5\n8\n9\n7\n9\n3\n2\n3\n8\n4\n\nSample Output 3\n\n563038556", "sample_input": "4\n1\n1\n1\n2\n"}, "reference_outputs": ["18\n"], "source_document_id": "p03064", "source_text": "Score : 600 points\n\nProblem Statement\n\nYou are given N integers. The i-th integer is a_i.\nFind the number, modulo 998244353, of ways to paint each of the integers red, green or blue so that the following condition is satisfied:\n\nLet R, G and B be the sums of the integers painted red, green and blue, respectively. There exists a triangle with positive area whose sides have lengths R, G and B.\n\nConstraints\n\n3 \\leq N \\leq 300\n\n1 \\leq a_i \\leq 300(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\na_1\n:\na_N\n\nOutput\n\nPrint the number, modulo 998244353, of ways to paint each of the integers red, green or blue so that the condition is satisfied.\n\nSample Input 1\n\n4\n1\n1\n1\n2\n\nSample Output 1\n\n18\n\nWe can only paint the integers so that the lengths of the sides of the triangle will be 1, 2 and 2, and there are 18 such ways.\n\nSample Input 2\n\n6\n1\n3\n2\n3\n5\n2\n\nSample Output 2\n\n150\n\nSample Input 3\n\n20\n3\n1\n4\n1\n5\n9\n2\n6\n5\n3\n5\n8\n9\n7\n9\n3\n2\n3\n8\n4\n\nSample Output 3\n\n563038556", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1933, "memory_kb": 172596}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s662836722", "group_id": "codeNet:p03069", "input_text": "fun main(args: Array) {\n tenka12019beginnerc()\n}\n\nfun tenka12019beginnerc() {\n val n = readLine()!!.toInt()\n val s = readLine()!!\n\n var answer = Int.MAX_VALUE\n for (i in 0..s.lastIndex) {\n val count = s.slice(0..i).count { it == '#' } + s.slice(i + 1..s.lastIndex).count { it == '.' }\n answer = Math.min(answer, count)\n }\n\n println(answer)\n}\n", "language": "Kotlin", "metadata": {"date": 1574315201, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03069.html", "problem_id": "p03069", "resource_group": "medium_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/Kotlin/s662836722.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s662836722", "user_id": "u139478771"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "fun main(args: Array) {\n tenka12019beginnerc()\n}\n\nfun tenka12019beginnerc() {\n val n = readLine()!!.toInt()\n val s = readLine()!!\n\n var answer = Int.MAX_VALUE\n for (i in 0..s.lastIndex) {\n val count = s.slice(0..i).count { it == '#' } + s.slice(i + 1..s.lastIndex).count { it == '.' }\n answer = Math.min(answer, count)\n }\n\n println(answer)\n}\n", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 385, "cpu_time_ms": 2111, "memory_kb": 117204}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s176370886", "group_id": "codeNet:p03069", "input_text": "fun main(args: Array) {\n val n = readLine()!!.toInt()\n var a = readLine()!!\n var cnt = 0\n for (i in 0 until n - 2) {\n if (a[i] == '#' && a[i + 1] == '.') {\n cnt ++\n }\n }\n if (a[n - 2] == '#' && a[n - 1] == '.') {\n cnt ++\n }\n println(cnt)\n}", "language": "Kotlin", "metadata": {"date": 1561483753, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03069.html", "problem_id": "p03069", "resource_group": "medium_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/Kotlin/s176370886.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s176370886", "user_id": "u227189389"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "fun main(args: Array) {\n val n = readLine()!!.toInt()\n var a = readLine()!!\n var cnt = 0\n for (i in 0 until n - 2) {\n if (a[i] == '#' && a[i + 1] == '.') {\n cnt ++\n }\n }\n if (a[n - 2] == '#' && a[n - 1] == '.') {\n cnt ++\n }\n println(cnt)\n}", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 248, "memory_kb": 34732}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s225417259", "group_id": "codeNet:p03069", "input_text": "import java.lang.Math.min\n\nfun Boolean.toInt() = if (this) 1 else 0\n\nfun main(args: Array) {\n val n = readLine()!!.toInt()\n val s = readLine()!!.reversed()\n var dp = Array(2) {\n Array(n + 1) { 0 }\n }\n for (i in listOf(0, 1)) {\n for (j in 0 until n) {\n dp[0][j + 1] = dp[0][j] + (s[j] == '.').toInt()\n dp[1][j + 1] = min(dp[0][j], dp[1][j] + (s[j] == '#').toInt())\n }\n }\n println(min(dp[0][n], dp[1][n]))\n}", "language": "Kotlin", "metadata": {"date": 1555906148, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03069.html", "problem_id": "p03069", "resource_group": "medium_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/Kotlin/s225417259.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s225417259", "user_id": "u858748695"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "import java.lang.Math.min\n\nfun Boolean.toInt() = if (this) 1 else 0\n\nfun main(args: Array) {\n val n = readLine()!!.toInt()\n val s = readLine()!!.reversed()\n var dp = Array(2) {\n Array(n + 1) { 0 }\n }\n for (i in listOf(0, 1)) {\n for (j in 0 until n) {\n dp[0][j + 1] = dp[0][j] + (s[j] == '.').toInt()\n dp[1][j + 1] = min(dp[0][j], dp[1][j] + (s[j] == '#').toInt())\n }\n }\n println(min(dp[0][n], dp[1][n]))\n}", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 353, "memory_kb": 55968}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s626322651", "group_id": "codeNet:p03069", "input_text": "fun main(args: Array){\n val n = readLine()!!.toInt()\n var s = readLine()!!\n var min = 99999\n var sum = 0\n var cnt = 0\n\n for(i in 0..n-1){\n if(s[i] == '.'){\n cnt++\n }\n }\n\n min = cnt\n\n for(i in 1..n/2){\n var cnts = 0\n var cntp = 0\n for(j in 0..i-1){\n if(s[j] == '#'){\n cnts++\n }\n }\n for(j in n-1 downTo i){\n if(s[j] == '.'){\n cntp++\n }\n }\n sum = cntp + cnts\n \n if(min > sum){\n min = sum\n }\n }\n println(min)\n}", "language": "Kotlin", "metadata": {"date": 1555814312, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03069.html", "problem_id": "p03069", "resource_group": "medium_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/Kotlin/s626322651.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s626322651", "user_id": "u151176417"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "fun main(args: Array){\n val n = readLine()!!.toInt()\n var s = readLine()!!\n var min = 99999\n var sum = 0\n var cnt = 0\n\n for(i in 0..n-1){\n if(s[i] == '.'){\n cnt++\n }\n }\n\n min = cnt\n\n for(i in 1..n/2){\n var cnts = 0\n var cntp = 0\n for(j in 0..i-1){\n if(s[j] == '#'){\n cnts++\n }\n }\n for(j in n-1 downTo i){\n if(s[j] == '.'){\n cntp++\n }\n }\n sum = cntp + cnts\n \n if(min > sum){\n min = sum\n }\n }\n println(min)\n}", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 627, "cpu_time_ms": 2111, "memory_kb": 34564}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s208184128", "group_id": "codeNet:p03071", "input_text": "import java.util.*\n\nfun main(args: Array) {\n\tval scanner = Scanner(System.`in`)\n\tval A = scanner.nextInt()\n\tval B = scanner.nextInt()\n\tprintln(\n\t\t\twhen {\n\t\t\t\tA > B -> A * 2 - 1\n\t\t\t\tA < B -> B * 2 - 1\n\t\t\t\telse -> A + B\n\t\t\t}\n\t)\n\tscanner.close()\n}\n", "language": "Kotlin", "metadata": {"date": 1555182426, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03071.html", "problem_id": "p03071", "resource_group": "medium_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/Kotlin/s208184128.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s208184128", "user_id": "u992174257"}, "prompt_components": {"gold_output": "9\n", "input_to_evaluate": "import java.util.*\n\nfun main(args: Array) {\n\tval scanner = Scanner(System.`in`)\n\tval A = scanner.nextInt()\n\tval B = scanner.nextInt()\n\tprintln(\n\t\t\twhen {\n\t\t\t\tA > B -> A * 2 - 1\n\t\t\t\tA < B -> B * 2 - 1\n\t\t\t\telse -> A + B\n\t\t\t}\n\t)\n\tscanner.close()\n}\n", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 253, "cpu_time_ms": 185, "memory_kb": 31012}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s241700615", "group_id": "codeNet:p03071", "input_text": "import java.util.Scanner\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val a = sc.nextInt()\n val b = sc.nextInt()\n val result = press(0, a, b)\n println(result)\n}\n\nprivate fun press(coin: Int, buttonSizeA: Int, buttonSizeB: Int, pressCount: Int = 0): Int {\n if (pressCount >= 2) {\n return coin\n }\n return when (buttonSizeA > buttonSizeB) {\n true -> press(coin + buttonSizeA, buttonSizeA - 1, buttonSizeB, pressCount + 1)\n false -> press(coin + buttonSizeB, buttonSizeA, buttonSizeB - 1, pressCount + 1)\n }\n}\n", "language": "Kotlin", "metadata": {"date": 1555182381, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03071.html", "problem_id": "p03071", "resource_group": "medium_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/Kotlin/s241700615.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s241700615", "user_id": "u354554173"}, "prompt_components": {"gold_output": "9\n", "input_to_evaluate": "import java.util.Scanner\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val a = sc.nextInt()\n val b = sc.nextInt()\n val result = press(0, a, b)\n println(result)\n}\n\nprivate fun press(coin: Int, buttonSizeA: Int, buttonSizeB: Int, pressCount: Int = 0): Int {\n if (pressCount >= 2) {\n return coin\n }\n return when (buttonSizeA > buttonSizeB) {\n true -> press(coin + buttonSizeA, buttonSizeA - 1, buttonSizeB, pressCount + 1)\n false -> press(coin + buttonSizeB, buttonSizeA, buttonSizeB - 1, pressCount + 1)\n }\n}\n", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 188, "memory_kb": 31256}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s298932174", "group_id": "codeNet:p03071", "input_text": "fun main(args: Array) {\n val (a, b) = readLine()!!.split(' ').map(String::toInt)\n val ans = Math.max(a + b, 2 * Math.max(a, b) - 1)\n println(ans)\n}\n", "language": "Kotlin", "metadata": {"date": 1555182283, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03071.html", "problem_id": "p03071", "resource_group": "medium_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/Kotlin/s298932174.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s298932174", "user_id": "u051841332"}, "prompt_components": {"gold_output": "9\n", "input_to_evaluate": "fun main(args: Array) {\n val (a, b) = readLine()!!.split(' ').map(String::toInt)\n val ans = Math.max(a + b, 2 * Math.max(a, b) - 1)\n println(ans)\n}\n", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 235, "memory_kb": 38484}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s794530083", "group_id": "codeNet:p03072", "input_text": "fun main(args:Array) {\n val hotelCount = readLine()!!.toInt()\n val hotelList = readLine()!!.split(\" \").map { it.toInt() }\n var max = 0\n var ans = 0\n for(i in hotelList) {\n if(i >= max) {\n ans++\n max = i\n }\n }\n println(ans)\n}\n\n", "language": "Kotlin", "metadata": {"date": 1579687081, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03072.html", "problem_id": "p03072", "resource_group": "medium_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/Kotlin/s794530083.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s794530083", "user_id": "u269969976"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "fun main(args:Array) {\n val hotelCount = readLine()!!.toInt()\n val hotelList = readLine()!!.split(\" \").map { it.toInt() }\n var max = 0\n var ans = 0\n for(i in hotelList) {\n if(i >= max) {\n ans++\n max = i\n }\n }\n println(ans)\n}\n\n", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 234, "memory_kb": 38036}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s322220437", "group_id": "codeNet:p03074", "input_text": "import kotlin.math.max\n\n//\n\nfun main() {\n abc124d()\n}\n\nfun abc124d() {\n val (n, k) = readLine()!!.split(\" \").map { it.toInt() }\n val s = readLine()!!\n val table = List(2) { IntArray(n + 1) { 0 } }\n val startZero = s[0] == '0'\n var z = 0\n var o = 0\n var performZero = startZero\n for (c in s) {\n if (c == '0') {\n if (!performZero) {\n // 連続する1が途切れたので1のindexをすすめる\n performZero = true\n o++\n }\n table[0][z]++\n } else {\n if (performZero) {\n // 連続する0が途切れたので、ゼロのindexをすすめる\n performZero = false\n z++\n }\n table[1][o]++\n }\n }\n var count = 0\n for (i in 0 until k) {\n count += table[0][i] + table[1][i]\n if (table[0][i] == 0 && table[1][i] == 0) break\n }\n if (!startZero) {\n count += table[1][k]\n }\n var maxCount = count\n for (i in k until n - k) {\n if (table[0][i] == 0 && table[1][i] == 0) break\n count -= table[0][i - k]\n count -= if (startZero && i - k - 1 > 0) table[1][i - k - 1] else table[1][i - k]\n count += table[0][i]\n count += if (startZero) table[1][i] else table[1][i + 1]\n maxCount = max(count, maxCount)\n }\n println(maxCount)\n}", "language": "Kotlin", "metadata": {"date": 1597414542, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p03074.html", "problem_id": "p03074", "resource_group": "medium_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/Kotlin/s322220437.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s322220437", "user_id": "u628907033"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "import kotlin.math.max\n\n//\n\nfun main() {\n abc124d()\n}\n\nfun abc124d() {\n val (n, k) = readLine()!!.split(\" \").map { it.toInt() }\n val s = readLine()!!\n val table = List(2) { IntArray(n + 1) { 0 } }\n val startZero = s[0] == '0'\n var z = 0\n var o = 0\n var performZero = startZero\n for (c in s) {\n if (c == '0') {\n if (!performZero) {\n // 連続する1が途切れたので1のindexをすすめる\n performZero = true\n o++\n }\n table[0][z]++\n } else {\n if (performZero) {\n // 連続する0が途切れたので、ゼロのindexをすすめる\n performZero = false\n z++\n }\n table[1][o]++\n }\n }\n var count = 0\n for (i in 0 until k) {\n count += table[0][i] + table[1][i]\n if (table[0][i] == 0 && table[1][i] == 0) break\n }\n if (!startZero) {\n count += table[1][k]\n }\n var maxCount = count\n for (i in k until n - k) {\n if (table[0][i] == 0 && table[1][i] == 0) break\n count -= table[0][i - k]\n count -= if (startZero && i - k - 1 > 0) table[1][i - k - 1] else table[1][i - k]\n count += table[0][i]\n count += if (startZero) table[1][i] else table[1][i + 1]\n maxCount = max(count, maxCount)\n }\n println(maxCount)\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1400, "cpu_time_ms": 209, "memory_kb": 40484}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s144734139", "group_id": "codeNet:p03074", "input_text": "import java.util.*\nfun main(args: Array) {\n\n val (N, K) = readLine()!!.split(\" \").map(String::toInt)\n val S = readLine()!!\n\n if (2 * K + 1 >= N) {\n print(N)\n return\n }\n var n = 0\n val list = mutableListOf()\n var isOder = false\n for (c in S) {\n if (isOder) {\n if (c == '1') {\n isOder = false\n list.add(n)\n n = 0\n }\n n++\n } else {\n if (c == '0') {\n isOder = true\n list.add(n)\n n = 0\n }\n n++\n }\n }\n if (n != 0) list.add(n)\n\n var ans = 0\n var tmp = mutableListOf()\n var k = K\n\n for ((i, l) in list.withIndex()) {\n //println(\"$i $tmp\")\n if (i % 2 == 0) {\n tmp.add(l)\n if (k == 0) {\n ans = Math.max(ans, tmp.sum())\n tmp = tmp.drop(2).toMutableList()\n k++\n }\n } else {\n k--\n tmp.add(l)\n }\n }\n\n //println(list)\n println(ans)\n}", "language": "Kotlin", "metadata": {"date": 1555186119, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03074.html", "problem_id": "p03074", "resource_group": "medium_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/Kotlin/s144734139.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s144734139", "user_id": "u043557308"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "import java.util.*\nfun main(args: Array) {\n\n val (N, K) = readLine()!!.split(\" \").map(String::toInt)\n val S = readLine()!!\n\n if (2 * K + 1 >= N) {\n print(N)\n return\n }\n var n = 0\n val list = mutableListOf()\n var isOder = false\n for (c in S) {\n if (isOder) {\n if (c == '1') {\n isOder = false\n list.add(n)\n n = 0\n }\n n++\n } else {\n if (c == '0') {\n isOder = true\n list.add(n)\n n = 0\n }\n n++\n }\n }\n if (n != 0) list.add(n)\n\n var ans = 0\n var tmp = mutableListOf()\n var k = K\n\n for ((i, l) in list.withIndex()) {\n //println(\"$i $tmp\")\n if (i % 2 == 0) {\n tmp.add(l)\n if (k == 0) {\n ans = Math.max(ans, tmp.sum())\n tmp = tmp.drop(2).toMutableList()\n k++\n }\n } else {\n k--\n tmp.add(l)\n }\n }\n\n //println(list)\n println(ans)\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1106, "cpu_time_ms": 2111, "memory_kb": 120300}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s307169007", "group_id": "codeNet:p03076", "input_text": "import java.util.*\nfun main(args: Array) {\n\n val sc = Scanner(System.`in`)\n val a = sc.nextInt()\n val b = sc.nextInt()\n val c = sc.nextInt()\n val d = sc.nextInt()\n val e = sc.nextInt()\n var ok = true\n val A = a-a%10+ if (a%10 == 0) 0 else 10\n val B = b-b%10+ if (b%10 == 0) 0 else 10\n val C = c-c%10+ if (c%10 == 0) 0 else 10\n val D = d-d%10+ if (d%10 == 0) 0 else 10\n val E = e-e%10+ if (e%10 == 0) 0 else 10\n\n // println(\"$A $B $C $D $E\")\n var ar = intArrayOf(a,b,c,d,e)\n val min = ar.minBy { (it-1)%10 }\n var t = min!!%10\n if (t == 0) t = 10\n //val (N,K) = readLine()!!.split(\" \").map{it.toInt()}\n //for (i in 0 until N) {\n //}\n\n println(A+B+C+D+E+t-10)\n}\n", "language": "Kotlin", "metadata": {"date": 1554579415, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03076.html", "problem_id": "p03076", "resource_group": "medium_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/Kotlin/s307169007.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s307169007", "user_id": "u043557308"}, "prompt_components": {"gold_output": "215\n", "input_to_evaluate": "import java.util.*\nfun main(args: Array) {\n\n val sc = Scanner(System.`in`)\n val a = sc.nextInt()\n val b = sc.nextInt()\n val c = sc.nextInt()\n val d = sc.nextInt()\n val e = sc.nextInt()\n var ok = true\n val A = a-a%10+ if (a%10 == 0) 0 else 10\n val B = b-b%10+ if (b%10 == 0) 0 else 10\n val C = c-c%10+ if (c%10 == 0) 0 else 10\n val D = d-d%10+ if (d%10 == 0) 0 else 10\n val E = e-e%10+ if (e%10 == 0) 0 else 10\n\n // println(\"$A $B $C $D $E\")\n var ar = intArrayOf(a,b,c,d,e)\n val min = ar.minBy { (it-1)%10 }\n var t = min!!%10\n if (t == 0) t = 10\n //val (N,K) = readLine()!!.split(\" \").map{it.toInt()}\n //for (i in 0 until N) {\n //}\n\n println(A+B+C+D+E+t-10)\n}\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 734, "cpu_time_ms": 194, "memory_kb": 34124}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s633589111", "group_id": "codeNet:p03076", "input_text": "\nfun main(args : Array) {\n val list = mutableListOf()\n (0..4).forEach {\n list.add(readLine()!!.toInt())\n }\n\n\n\n list.sortBy {\n val lastDigit = it.mod(10)\n\n if (lastDigit == 0) {\n -10\n } else {\n lastDigit * -1\n }\n }\n\n var sum = 0\n list.forEachIndexed { index, value ->\n if (index == list.size - 1) {\n sum += value\n } else {\n val mod = value.mod(10)\n\n if (mod == 0) {\n sum += value\n } else {\n sum += value + (10 - mod)\n }\n }\n }\n\n println(sum)\n}\n", "language": "Kotlin", "metadata": {"date": 1554578481, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03076.html", "problem_id": "p03076", "resource_group": "medium_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/Kotlin/s633589111.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s633589111", "user_id": "u861095163"}, "prompt_components": {"gold_output": "215\n", "input_to_evaluate": "\nfun main(args : Array) {\n val list = mutableListOf()\n (0..4).forEach {\n list.add(readLine()!!.toInt())\n }\n\n\n\n list.sortBy {\n val lastDigit = it.mod(10)\n\n if (lastDigit == 0) {\n -10\n } else {\n lastDigit * -1\n }\n }\n\n var sum = 0\n list.forEachIndexed { index, value ->\n if (index == list.size - 1) {\n sum += value\n } else {\n val mod = value.mod(10)\n\n if (mod == 0) {\n sum += value\n } else {\n sum += value + (10 - mod)\n }\n }\n }\n\n println(sum)\n}\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 644, "cpu_time_ms": 207, "memory_kb": 33492}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s097349115", "group_id": "codeNet:p03078", "input_text": "import java.io.*\nimport java.lang.*\nimport java.math.*\nimport java.util.*\n\n// Constant\nval sc = FastScanner()\nval pw = PrintWriter(System.out)\nconst val MOD = 1000000007L\nconst val INF = 9223372036854775807L\n\n// Main\nfun main(args: Array) {\n solve()\n pw.flush()\n}\n\n\nfun solve() {\n val x = nextLong()\n val y = nextLong()\n val z = nextLong()\n val k = nextLong()\n val a = nextLongAry(x)\n val b = nextLongAry(y)\n val c = nextLongAry(z)\n\n val list1 = longList()\n for (i in a.indices) {\n for (j in b.indices) {\n list1.add(a[i] + b[j])\n }\n }\n list1.sortDescending()\n val list2 = longList()\n for (i in 0 until min(k, list1.siz)) {\n for (j in c.indices) {\n list2.add(list1[i] + c[j])\n }\n }\n list2.sortDescending()\n println(list2.take(k.toInt()).joinToString(\"\\n\"))\n\n\n\n\n}\n\n\n\n// Rule\noperator fun String.get(index: Long): Char {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun CharArray.get(index: Long): Char {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun CharArray.set(index: Long, value: Char) {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n this[index.toInt()] = value\n}\noperator fun IntArray.get(index: Long): Int {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun IntArray.set(index: Long, value: Int) {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n this[index.toInt()] = value\n}\noperator fun LongArray.get(index: Long): Long {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun LongArray.set(index: Long, value: Long) {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n this[index.toInt()] = value\n}\noperator fun DoubleArray.get(index: Long): Double {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun DoubleArray.set(index: Long, value: Double) {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n this[index.toInt()] = value\n}\noperator fun Array.get(index: Long): T {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun Array.set(index: Long, value: T) {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n this[index.toInt()] = value\n}\noperator fun MutableList.get(index: Long): T {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun MutableList.set(index: Long, value: T) {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n this[index.toInt()] = value\n}\n\nval LongArray.siz: Long\n get() = size.toLong()\nval Array.siz: Long\n get() = size.toLong()\nval MutableList.siz: Long\n get() = size.toLong()\nval MutableSet.siz: Long\n get() = size.toLong()\nval String.len: Long\n get() = length.toLong()\n\n// Output\nfun println(v: String) {\n pw.println(v)\n}\nfun print(v: String) {\n pw.print(v)\n}\n\n// Input\nfun next() = sc.next()\nfun nextLong() = sc.nextLong()\nfun nextDouble() = next().toDouble()\nfun nextAry(n: Long): Array {\n val ary = ary(n)\n for (i in 0 until n) ary[i] = next()\n return ary\n}\nfun nextLongAry(n: Long): LongArray {\n val ary = longAry(n)\n for (i in 0 until n) ary[i] = nextLong()\n return ary\n}\nfun nextDoubleAry(n: Long): DoubleArray {\n val ary = doubleAry(n)\n for (i in 0 until n) ary[i] = nextDouble()\n return ary\n}\n\n// Statement\nfun ary(n: Long, init: String = \"\") = Array(n.toInt()) { init }\nfun longAry(n: Long, init: Long = 0L) = LongArray(n.toInt()) { init }\nfun doubleAry(n: Long, init: Double = 0.0) = DoubleArray(n.toInt()) { init }\nfun boolAry(n: Long, init: Boolean = false) = Array(n.toInt()) { init }\nfun nodeAry(n: Long) = Array(n.toInt()) { Node(it.toLong()) }\nfun ary2(n: Long, m: Long, init: String = \"\") = Array(n.toInt()) { ary(m, init) }\nfun longAry2(n: Long, m: Long, init: Long = 0) = Array(n.toInt()) { longAry(m, init) }\nfun doubleAry2(n: Long, m: Long, init: Double = 0.0) = Array(n.toInt()) { doubleAry(m, init) }\nfun boolAry2(n: Long, m: Long, init: Boolean = false) = Array(n.toInt()) { boolAry(m, init) }\nfun ary3(n: Long, m: Long, k: Long, init: String = \"\") = Array(n.toInt()) { ary2(m, k, init) }\nfun longAry3(n: Long, m: Long, k: Long, init: Long = 0L) = Array(n.toInt()) { longAry2(m, k, init) }\nfun doubleAry3(n: Long, m: Long, k: Long, init: Double = 0.0) = Array(n.toInt()) { doubleAry2(m, k, init) }\nfun boolAry3(n: Long, m: Long, k: Long, init: Boolean = false) = Array(n.toInt()) { boolAry2(m, k, init) }\nfun list() = mutableListOf()\nfun longList() = mutableListOf()\nfun doubleList() = mutableListOf()\nfun strSet() = mutableSetOf()\nfun longSet() = mutableSetOf()\nfun doubleSet() = mutableSetOf()\nfun map() = mutableMapOf()\n\n// Monoid\nval addFunc = {a: Long, b: Long -> a + b}\nval mulFunc = {a: Long, b: Long -> a * b}\nval maxFunc = {a: Long, b: Long -> max(a, b)}\nval minFunc = {a: Long, b: Long -> min(a, b)}\nval gcdFunc = {a: Long, b: Long -> gcd(a, b)}\nval lcmFunc = {a: Long, b: Long -> lcm(a, b)}\nval xorFunc = {a: Long, b: Long -> a xor b}\nfun calc(a: Long, b: Long, op: (Long, Long) -> Long) = op(a, b)\n\n// Extension\nfun LongArray.lowerBound(n: Long): Long {\n var ok = this.size.toLong()\n var ng = -1L\n while (abs(ok - ng) > 1) {\n val mid = (ok + ng) / 2\n if (this[mid] >= n) ok = mid\n else ng = mid\n }\n return ok\n}\nfun DoubleArray.lowerBound(n: Double): Long {\n var ok = this.size.toLong()\n var ng = -1L\n while (abs(ok - ng) > 1) {\n val mid = (ok + ng) / 2\n if (this[mid] >= n) ok = mid\n else ng = mid\n }\n return ok\n}\nfun MutableList.longLowerBound(n: Long): Long {\n var ok = this.size.toLong()\n var ng = -1L\n while (abs(ok - ng) > 1) {\n val mid = (ok + ng) / 2\n if (this[mid] >= n) ok = mid\n else ng = mid\n }\n return ok\n}\nfun MutableList.doubleLowerBound(n: Double): Long {\n var ok = this.size.toLong()\n var ng = -1L\n while (abs(ok - ng) > 1) {\n val mid = (ok + ng) / 2\n if (this[mid] >= n) ok = mid\n else ng = mid\n }\n return ok\n}\nfun LongArray.cumsum(op: (Long, Long) -> Long): LongArray {\n val s = longAry(this.size + 1L)\n s[1] = this[0]\n for (i in 1 until this.size) s[i + 1] = calc(s[i], this[i], op)\n return s\n}\nfun MutableMap.counting(n: Long) {\n repeat(n.toInt()) {\n val a = next()\n if (this.containsKey(a)) this[a] = this[a]!! + 1\n else this[a] = 1\n }\n}\nfun MutableMap.longCounting(n: Long) {\n repeat(n.toInt()) {\n val a = nextLong()\n if (this.containsKey(a)) this[a] = this[a]!! + 1\n else this[a] = 1\n }\n}\n\n// Mathematics\nfun abs(n: Long): Long = Math.abs(n)\nfun abs(n: Double): Double = Math.abs(n)\nfun max(vararg values: Long) = if (values.isEmpty()) -INF else values.max()!!\nfun min(vararg values: Long) = if (values.isEmpty()) INF else values.min()!!\ntailrec fun gcd(a: Long, b: Long): Long = if (b == 0L) a else if (a % b == 0L) b else gcd(b, (a % b))\nfun lcm(a: Long, b: Long): Long = a / gcd(a, b) * b\nfun erathos(n: Long): LongArray {\n val res = LongArray(n.toInt() + 1) { it.toLong() }\n for (i in 2..n) {\n if(i * i > n) break\n for (j in i * i..n step i) {\n if(res[j] == j) res[j] = i\n }\n }\n res[0] = -1L\n res[1] = -1L\n return res\n}\nfun modAdd(a: Long, b: Long) = if(a + b >= MOD) a + b - MOD else a + b\nfun modpow(a: Long, n: Long, p: Long = MOD): Long {\n var res = 1L\n var ar = a\n var nr = n\n while (nr > 0) {\n if ((nr and 1) == 1L) res = res * ar % p\n ar = ar * ar % p\n nr = nr shr 1\n }\n return res\n}\nfun modinv(a: Long, p: Long = MOD): Long = modpow(a, p - 2, p)\nfun ncr(n: Long, r: Long): Long {\n var a = 1L\n var b = 1L\n for (i in 1..r) {\n a = a * (n + 1 - i) % MOD\n b = b * i % MOD\n }\n return modinv(b, MOD) * a % MOD\n}\n\nclass Combination(private val max: Long) {\n private val fac = longAry(max)\n private val finv = longAry(max)\n private val inv = longAry(max)\n private val p = MOD\n fun init() {\n fac[0] = 1\n fac[1] = 1\n finv[0] = 1\n finv[1] = 1\n inv[1] = 1\n for (i in 2 until max) {\n fac[i] = fac[i - 1] * i % p\n inv[i] = p - inv[p % i] * (p / i) % p;\n finv[i] = finv[i - 1] * inv[i] % p\n }\n }\n\n fun com(n: Long, r: Long): Long = if (n < r || (n < 0 || r < 0)) 0L else fac[n] * (finv[r] * finv[n - r] % p) % p\n}\n\nclass Permutation(private val n: Long, private var searched: Long = 0L, private var nextIndex: Long = 0L) {\n private val size = fact(n)\n private val permList = longAry2(size, n)\n\n private tailrec fun fact(n: Long, ans: Long = 1L): Long {\n return if (n == 0L) ans\n else fact(n - 1, ans * n)\n }\n\n fun init() {\n create(0, longAry(n), boolAry(n))\n }\n\n private fun create(num: Long, list: LongArray, flag: Array) {\n if (num == n) {\n permList[searched] = list.copyOf()\n searched++\n }\n for (i in 0 until n) {\n if (flag[i]) continue\n list[num] = i\n flag[i] = true\n create(num + 1, list, flag)\n flag[i] = false\n }\n }\n\n fun hasNext(): Boolean {\n return if (nextIndex < size) {\n true\n } else {\n nextIndex = 0\n false\n }\n }\n\n fun nextPerm(): LongArray = permList[nextIndex++]\n}\n\n// Graph\ndata class Node(val id: Long, var past: Long = -1, val edges: MutableList = mutableListOf())\ndata class Edge(val from: Long, val to: Long, val cost: Long = 1L)\n\nfun dfs(nodes: Array, now: Long, seen: Array) {\n seen[now] = true\n for (edge in nodes[now].edges) {\n if (seen[edge.to]) continue\n dfs(nodes, edge.to, seen)\n }\n}\n\nfun bfs(nodes: Array, start: Long): LongArray {\n val queue = ArrayDeque()\n queue.add(start)\n val dist = longAry(nodes.size.toLong(), -1L)\n dist[start] = 0L\n while (queue.isNotEmpty()) {\n val now = queue.poll()\n for (edge in nodes[now].edges) {\n if (dist[edge.to] != -1L) continue\n dist[edge.to] = dist[now] + 1\n queue.add(edge.to)\n }\n }\n return dist\n}\n\nfun dijkstra(nodes: Array, start: Long): LongArray {\n val queue = PriorityQueue(16) { e1: Edge, e2: Edge ->\n return@PriorityQueue when {\n e1.cost < e2.cost -> -1\n e2.cost > e1.cost -> 1\n else -> 0\n }\n }\n queue.add(Edge(start, start, 0L))\n val dist = longAry(nodes.size.toLong(), INF / 2)\n dist[start] = 0\n while (queue.isNotEmpty()) {\n val now = queue.poll()\n if (dist[now.to] < now.cost) continue;\n for (edge in nodes[now.to].edges) {\n if (dist[edge.to] <= dist[edge.from] + edge.cost) continue\n dist[edge.to] = dist[edge.from] + edge.cost\n queue.add(Edge(edge.from, edge.to, dist[edge.to]))\n nodes[edge.to].past = edge.from\n }\n }\n return dist\n}\n\nclass GridGraph(\n private val h: Long,\n private val w: Long,\n val nodes: Array = Array((h * w).toInt()) { Node(it.toLong()) },\n private val edges: IntArray = IntArray((h * w).toInt()) { 0 }\n) {\n private val up = 1\n private val right = 2\n private val down = 4\n private val left = 8\n private val queue: ArrayDeque = ArrayDeque()\n private val startPos = longList()\n\n private fun pos(y: Long, x: Long) = y * w + x\n fun canUp(v: Long) = (edges[v] and 1) == 1\n fun canRight(v: Long) = ((edges[v] shr 1) and 1) == 1\n fun canDown(v: Long) = ((edges[v] shr 2) and 1) == 1\n fun canLeft(v: Long) = ((edges[v] shr 3) and 1) == 1\n\n fun init(s: Array, check: Char = '.', road: Char = '.', start: Char = 'S') {\n for (i in 0 until h) {\n for (j in 0 until w) {\n if(s[i][j] != check && s[i][j] != start) continue\n if(i > 0 && s[i - 1][j] == road) edges[pos(i, j)] += up\n if(i < h - 1 && s[i + 1][j] == road) edges[pos(i, j)] += down\n if(j > 0 && s[i][j - 1] == road) edges[pos(i, j)] += left\n if(j < w - 1 && s[i][j + 1] == road) edges[pos(i, j)] += right\n if(s[i][j] == start) {\n queue.add(pos(i, j))\n startPos.add(pos(i, j))\n }\n }\n }\n }\n fun addStart(y: Long, x: Long) {\n startPos.add(pos(y, x))\n queue.add(pos(y, x))\n }\n\n fun bfs(): LongArray {\n val dist = longAry(h * w, -1L)\n for (i in startPos) {\n dist[i] = 0L\n }\n while (queue.isNotEmpty()) {\n val v = queue.poll()\n if(canUp(v) && dist[v - w] == -1L) {\n queue.add(v - w)\n dist[v - w] = dist[v] + 1L\n }\n if(canDown(v) && dist[v + w] == -1L) {\n queue.add(v + w)\n dist[v + w] = dist[v] + 1L\n }\n if(canLeft(v) && dist[v - 1] == -1L) {\n queue.add(v - 1)\n dist[v - 1] = dist[v] + 1L\n }\n if(canRight(v) && dist[v + 1] == -1L) {\n queue.add(v + 1)\n dist[v + 1] = dist[v] + 1L\n }\n }\n return dist\n }\n\n}\n\n// Data Structure\n\nclass UnionFind(size: Long) {\n private val par = LongArray(size.toInt()) { it.toLong() }\n private val size = longAry(size, 1L)\n private val diffWeight = longAry(size, 0L)\n fun root(x: Long): Long {\n return if (par[x] == x) {\n x\n } else {\n val r = root(par[x])\n diffWeight[x] += diffWeight[par[x]]\n par[x] = r\n par[x]\n }\n }\n fun weight(x: Long): Long {\n root(x)\n return diffWeight[x]\n }\n fun diff(x: Long, y: Long) = abs(weight(y) - weight(x))\n\n fun same(x: Long, y: Long): Boolean = root(x) == root(y)\n fun unite(x: Long, y: Long, d: Long) {\n var w = d\n w += weight(x)\n w -= weight(y)\n var a = root(x)\n var b = root(y)\n if (a == b) return\n if (size[a] < size[b]) {\n var tmp = a\n a = b\n b = tmp\n w = -w\n }\n size[a] += size[b]\n par[b] = a\n diffWeight[b] = w\n }\n\n fun size(x: Long): Long = size[root(x)]\n}\n\nclass SegmentTree(\n private val a: LongArray,\n private val op: (Long, Long) -> Long,\n private val def: Long = 0,\n private val size: Int = a.size,\n private val n: Int = Integer.highestOneBit(size) shl 1\n) {\n private val nodes = longAry(2L * n - 1, def)\n\n fun init() {\n for (i in 0 until size) nodes[i + n - 1] = a[i]\n for (i in n - 2 downTo 0) nodes[i] = calc(nodes[2 * i + 1], nodes[2 * i + 2], op)\n }\n\n fun update(x: Long, value: Long) {\n var index = x + n - 1\n nodes[index] = value\n while (index > 0) {\n index = (index - 1) / 2\n nodes[index] = calc(nodes[2 * index + 1], nodes[2 * index + 2], op)\n }\n }\n\n fun get(a: Long, b: Long) = getSub(a, b, 0L, 0L, n.toLong())\n private fun getSub(a: Long, b: Long, k: Long, l: Long, r: Long): Long {\n return when {\n r <= a || b <= l -> def\n a <= l && r <= b -> nodes[k]\n else -> {\n val vl = getSub(a, b, k * 2 + 1, l, (l + r) / 2)\n val vr = getSub(a, b, k * 2 + 2, (l + r) / 2, r)\n calc(vl, vr, op)\n }\n }\n }\n\n fun joinToString(separator: String) = nodes.drop(n - 1).take(size).joinToString(separator)\n}\n\n// Scanner\n\nclass FastScanner {\n private val sin: InputStream = System.`in`\n private val buffer: ByteArray = ByteArray(1024) { 0 }\n private var ptr = 0\n private var buflen = 0\n\n private fun hasNextByte(): Boolean {\n return when {\n ptr < buflen -> true\n else -> {\n ptr = 0\n buflen = sin.read(buffer)\n buflen > 0\n }\n }\n }\n\n private fun readByte(): Int {\n return when {\n hasNextByte() -> buffer[ptr++].toInt()\n else -> -1\n }\n }\n\n private fun isPrintableChar(c: Int) = c in 33..126\n\n fun hasNext(): Boolean {\n while (hasNextByte() && !isPrintableChar(buffer[ptr].toInt())) ptr++\n return hasNextByte()\n }\n\n fun next(): String {\n if (!hasNext()) throw NoSuchElementException()\n val sb = StringBuilder()\n var b = readByte()\n while (isPrintableChar(b)) {\n sb.appendCodePoint(b)\n b = readByte()\n }\n return sb.toString()\n }\n\n fun nextLong(): Long {\n if (!hasNext()) throw NoSuchElementException()\n var n = 0L\n var minus = false\n var b = readByte()\n if (b.toChar() == '-') {\n minus = true\n b = readByte()\n }\n if (b.toChar() !in '0'..'9') throw NumberFormatException()\n while (true) {\n when {\n b.toChar() in '0'..'9' -> {\n n *= 10\n n += b.toChar() - '0'\n }\n b == -1 || !isPrintableChar(b) -> return if (minus) -n else n\n else -> throw NumberFormatException()\n }\n b = readByte()\n }\n }\n\n// \"The world doesn't need you.\"\n//\n// fun nextInt(): Int {\n// val nl = nextLong()\n// if (nl !in Int.MIN_VALUE..Int.MAX_VALUE) throw NumberFormatException()\n// return nl.toInt()\n// }\n}\n", "language": "Kotlin", "metadata": {"date": 1590083019, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03078.html", "problem_id": "p03078", "resource_group": "medium_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/Kotlin/s097349115.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s097349115", "user_id": "u581625805"}, "prompt_components": {"gold_output": "19\n17\n15\n14\n13\n12\n10\n8\n", "input_to_evaluate": "import java.io.*\nimport java.lang.*\nimport java.math.*\nimport java.util.*\n\n// Constant\nval sc = FastScanner()\nval pw = PrintWriter(System.out)\nconst val MOD = 1000000007L\nconst val INF = 9223372036854775807L\n\n// Main\nfun main(args: Array) {\n solve()\n pw.flush()\n}\n\n\nfun solve() {\n val x = nextLong()\n val y = nextLong()\n val z = nextLong()\n val k = nextLong()\n val a = nextLongAry(x)\n val b = nextLongAry(y)\n val c = nextLongAry(z)\n\n val list1 = longList()\n for (i in a.indices) {\n for (j in b.indices) {\n list1.add(a[i] + b[j])\n }\n }\n list1.sortDescending()\n val list2 = longList()\n for (i in 0 until min(k, list1.siz)) {\n for (j in c.indices) {\n list2.add(list1[i] + c[j])\n }\n }\n list2.sortDescending()\n println(list2.take(k.toInt()).joinToString(\"\\n\"))\n\n\n\n\n}\n\n\n\n// Rule\noperator fun String.get(index: Long): Char {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun CharArray.get(index: Long): Char {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun CharArray.set(index: Long, value: Char) {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n this[index.toInt()] = value\n}\noperator fun IntArray.get(index: Long): Int {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun IntArray.set(index: Long, value: Int) {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n this[index.toInt()] = value\n}\noperator fun LongArray.get(index: Long): Long {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun LongArray.set(index: Long, value: Long) {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n this[index.toInt()] = value\n}\noperator fun DoubleArray.get(index: Long): Double {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun DoubleArray.set(index: Long, value: Double) {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n this[index.toInt()] = value\n}\noperator fun Array.get(index: Long): T {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun Array.set(index: Long, value: T) {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n this[index.toInt()] = value\n}\noperator fun MutableList.get(index: Long): T {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun MutableList.set(index: Long, value: T) {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n this[index.toInt()] = value\n}\n\nval LongArray.siz: Long\n get() = size.toLong()\nval Array.siz: Long\n get() = size.toLong()\nval MutableList.siz: Long\n get() = size.toLong()\nval MutableSet.siz: Long\n get() = size.toLong()\nval String.len: Long\n get() = length.toLong()\n\n// Output\nfun println(v: String) {\n pw.println(v)\n}\nfun print(v: String) {\n pw.print(v)\n}\n\n// Input\nfun next() = sc.next()\nfun nextLong() = sc.nextLong()\nfun nextDouble() = next().toDouble()\nfun nextAry(n: Long): Array {\n val ary = ary(n)\n for (i in 0 until n) ary[i] = next()\n return ary\n}\nfun nextLongAry(n: Long): LongArray {\n val ary = longAry(n)\n for (i in 0 until n) ary[i] = nextLong()\n return ary\n}\nfun nextDoubleAry(n: Long): DoubleArray {\n val ary = doubleAry(n)\n for (i in 0 until n) ary[i] = nextDouble()\n return ary\n}\n\n// Statement\nfun ary(n: Long, init: String = \"\") = Array(n.toInt()) { init }\nfun longAry(n: Long, init: Long = 0L) = LongArray(n.toInt()) { init }\nfun doubleAry(n: Long, init: Double = 0.0) = DoubleArray(n.toInt()) { init }\nfun boolAry(n: Long, init: Boolean = false) = Array(n.toInt()) { init }\nfun nodeAry(n: Long) = Array(n.toInt()) { Node(it.toLong()) }\nfun ary2(n: Long, m: Long, init: String = \"\") = Array(n.toInt()) { ary(m, init) }\nfun longAry2(n: Long, m: Long, init: Long = 0) = Array(n.toInt()) { longAry(m, init) }\nfun doubleAry2(n: Long, m: Long, init: Double = 0.0) = Array(n.toInt()) { doubleAry(m, init) }\nfun boolAry2(n: Long, m: Long, init: Boolean = false) = Array(n.toInt()) { boolAry(m, init) }\nfun ary3(n: Long, m: Long, k: Long, init: String = \"\") = Array(n.toInt()) { ary2(m, k, init) }\nfun longAry3(n: Long, m: Long, k: Long, init: Long = 0L) = Array(n.toInt()) { longAry2(m, k, init) }\nfun doubleAry3(n: Long, m: Long, k: Long, init: Double = 0.0) = Array(n.toInt()) { doubleAry2(m, k, init) }\nfun boolAry3(n: Long, m: Long, k: Long, init: Boolean = false) = Array(n.toInt()) { boolAry2(m, k, init) }\nfun list() = mutableListOf()\nfun longList() = mutableListOf()\nfun doubleList() = mutableListOf()\nfun strSet() = mutableSetOf()\nfun longSet() = mutableSetOf()\nfun doubleSet() = mutableSetOf()\nfun map() = mutableMapOf()\n\n// Monoid\nval addFunc = {a: Long, b: Long -> a + b}\nval mulFunc = {a: Long, b: Long -> a * b}\nval maxFunc = {a: Long, b: Long -> max(a, b)}\nval minFunc = {a: Long, b: Long -> min(a, b)}\nval gcdFunc = {a: Long, b: Long -> gcd(a, b)}\nval lcmFunc = {a: Long, b: Long -> lcm(a, b)}\nval xorFunc = {a: Long, b: Long -> a xor b}\nfun calc(a: Long, b: Long, op: (Long, Long) -> Long) = op(a, b)\n\n// Extension\nfun LongArray.lowerBound(n: Long): Long {\n var ok = this.size.toLong()\n var ng = -1L\n while (abs(ok - ng) > 1) {\n val mid = (ok + ng) / 2\n if (this[mid] >= n) ok = mid\n else ng = mid\n }\n return ok\n}\nfun DoubleArray.lowerBound(n: Double): Long {\n var ok = this.size.toLong()\n var ng = -1L\n while (abs(ok - ng) > 1) {\n val mid = (ok + ng) / 2\n if (this[mid] >= n) ok = mid\n else ng = mid\n }\n return ok\n}\nfun MutableList.longLowerBound(n: Long): Long {\n var ok = this.size.toLong()\n var ng = -1L\n while (abs(ok - ng) > 1) {\n val mid = (ok + ng) / 2\n if (this[mid] >= n) ok = mid\n else ng = mid\n }\n return ok\n}\nfun MutableList.doubleLowerBound(n: Double): Long {\n var ok = this.size.toLong()\n var ng = -1L\n while (abs(ok - ng) > 1) {\n val mid = (ok + ng) / 2\n if (this[mid] >= n) ok = mid\n else ng = mid\n }\n return ok\n}\nfun LongArray.cumsum(op: (Long, Long) -> Long): LongArray {\n val s = longAry(this.size + 1L)\n s[1] = this[0]\n for (i in 1 until this.size) s[i + 1] = calc(s[i], this[i], op)\n return s\n}\nfun MutableMap.counting(n: Long) {\n repeat(n.toInt()) {\n val a = next()\n if (this.containsKey(a)) this[a] = this[a]!! + 1\n else this[a] = 1\n }\n}\nfun MutableMap.longCounting(n: Long) {\n repeat(n.toInt()) {\n val a = nextLong()\n if (this.containsKey(a)) this[a] = this[a]!! + 1\n else this[a] = 1\n }\n}\n\n// Mathematics\nfun abs(n: Long): Long = Math.abs(n)\nfun abs(n: Double): Double = Math.abs(n)\nfun max(vararg values: Long) = if (values.isEmpty()) -INF else values.max()!!\nfun min(vararg values: Long) = if (values.isEmpty()) INF else values.min()!!\ntailrec fun gcd(a: Long, b: Long): Long = if (b == 0L) a else if (a % b == 0L) b else gcd(b, (a % b))\nfun lcm(a: Long, b: Long): Long = a / gcd(a, b) * b\nfun erathos(n: Long): LongArray {\n val res = LongArray(n.toInt() + 1) { it.toLong() }\n for (i in 2..n) {\n if(i * i > n) break\n for (j in i * i..n step i) {\n if(res[j] == j) res[j] = i\n }\n }\n res[0] = -1L\n res[1] = -1L\n return res\n}\nfun modAdd(a: Long, b: Long) = if(a + b >= MOD) a + b - MOD else a + b\nfun modpow(a: Long, n: Long, p: Long = MOD): Long {\n var res = 1L\n var ar = a\n var nr = n\n while (nr > 0) {\n if ((nr and 1) == 1L) res = res * ar % p\n ar = ar * ar % p\n nr = nr shr 1\n }\n return res\n}\nfun modinv(a: Long, p: Long = MOD): Long = modpow(a, p - 2, p)\nfun ncr(n: Long, r: Long): Long {\n var a = 1L\n var b = 1L\n for (i in 1..r) {\n a = a * (n + 1 - i) % MOD\n b = b * i % MOD\n }\n return modinv(b, MOD) * a % MOD\n}\n\nclass Combination(private val max: Long) {\n private val fac = longAry(max)\n private val finv = longAry(max)\n private val inv = longAry(max)\n private val p = MOD\n fun init() {\n fac[0] = 1\n fac[1] = 1\n finv[0] = 1\n finv[1] = 1\n inv[1] = 1\n for (i in 2 until max) {\n fac[i] = fac[i - 1] * i % p\n inv[i] = p - inv[p % i] * (p / i) % p;\n finv[i] = finv[i - 1] * inv[i] % p\n }\n }\n\n fun com(n: Long, r: Long): Long = if (n < r || (n < 0 || r < 0)) 0L else fac[n] * (finv[r] * finv[n - r] % p) % p\n}\n\nclass Permutation(private val n: Long, private var searched: Long = 0L, private var nextIndex: Long = 0L) {\n private val size = fact(n)\n private val permList = longAry2(size, n)\n\n private tailrec fun fact(n: Long, ans: Long = 1L): Long {\n return if (n == 0L) ans\n else fact(n - 1, ans * n)\n }\n\n fun init() {\n create(0, longAry(n), boolAry(n))\n }\n\n private fun create(num: Long, list: LongArray, flag: Array) {\n if (num == n) {\n permList[searched] = list.copyOf()\n searched++\n }\n for (i in 0 until n) {\n if (flag[i]) continue\n list[num] = i\n flag[i] = true\n create(num + 1, list, flag)\n flag[i] = false\n }\n }\n\n fun hasNext(): Boolean {\n return if (nextIndex < size) {\n true\n } else {\n nextIndex = 0\n false\n }\n }\n\n fun nextPerm(): LongArray = permList[nextIndex++]\n}\n\n// Graph\ndata class Node(val id: Long, var past: Long = -1, val edges: MutableList = mutableListOf())\ndata class Edge(val from: Long, val to: Long, val cost: Long = 1L)\n\nfun dfs(nodes: Array, now: Long, seen: Array) {\n seen[now] = true\n for (edge in nodes[now].edges) {\n if (seen[edge.to]) continue\n dfs(nodes, edge.to, seen)\n }\n}\n\nfun bfs(nodes: Array, start: Long): LongArray {\n val queue = ArrayDeque()\n queue.add(start)\n val dist = longAry(nodes.size.toLong(), -1L)\n dist[start] = 0L\n while (queue.isNotEmpty()) {\n val now = queue.poll()\n for (edge in nodes[now].edges) {\n if (dist[edge.to] != -1L) continue\n dist[edge.to] = dist[now] + 1\n queue.add(edge.to)\n }\n }\n return dist\n}\n\nfun dijkstra(nodes: Array, start: Long): LongArray {\n val queue = PriorityQueue(16) { e1: Edge, e2: Edge ->\n return@PriorityQueue when {\n e1.cost < e2.cost -> -1\n e2.cost > e1.cost -> 1\n else -> 0\n }\n }\n queue.add(Edge(start, start, 0L))\n val dist = longAry(nodes.size.toLong(), INF / 2)\n dist[start] = 0\n while (queue.isNotEmpty()) {\n val now = queue.poll()\n if (dist[now.to] < now.cost) continue;\n for (edge in nodes[now.to].edges) {\n if (dist[edge.to] <= dist[edge.from] + edge.cost) continue\n dist[edge.to] = dist[edge.from] + edge.cost\n queue.add(Edge(edge.from, edge.to, dist[edge.to]))\n nodes[edge.to].past = edge.from\n }\n }\n return dist\n}\n\nclass GridGraph(\n private val h: Long,\n private val w: Long,\n val nodes: Array = Array((h * w).toInt()) { Node(it.toLong()) },\n private val edges: IntArray = IntArray((h * w).toInt()) { 0 }\n) {\n private val up = 1\n private val right = 2\n private val down = 4\n private val left = 8\n private val queue: ArrayDeque = ArrayDeque()\n private val startPos = longList()\n\n private fun pos(y: Long, x: Long) = y * w + x\n fun canUp(v: Long) = (edges[v] and 1) == 1\n fun canRight(v: Long) = ((edges[v] shr 1) and 1) == 1\n fun canDown(v: Long) = ((edges[v] shr 2) and 1) == 1\n fun canLeft(v: Long) = ((edges[v] shr 3) and 1) == 1\n\n fun init(s: Array, check: Char = '.', road: Char = '.', start: Char = 'S') {\n for (i in 0 until h) {\n for (j in 0 until w) {\n if(s[i][j] != check && s[i][j] != start) continue\n if(i > 0 && s[i - 1][j] == road) edges[pos(i, j)] += up\n if(i < h - 1 && s[i + 1][j] == road) edges[pos(i, j)] += down\n if(j > 0 && s[i][j - 1] == road) edges[pos(i, j)] += left\n if(j < w - 1 && s[i][j + 1] == road) edges[pos(i, j)] += right\n if(s[i][j] == start) {\n queue.add(pos(i, j))\n startPos.add(pos(i, j))\n }\n }\n }\n }\n fun addStart(y: Long, x: Long) {\n startPos.add(pos(y, x))\n queue.add(pos(y, x))\n }\n\n fun bfs(): LongArray {\n val dist = longAry(h * w, -1L)\n for (i in startPos) {\n dist[i] = 0L\n }\n while (queue.isNotEmpty()) {\n val v = queue.poll()\n if(canUp(v) && dist[v - w] == -1L) {\n queue.add(v - w)\n dist[v - w] = dist[v] + 1L\n }\n if(canDown(v) && dist[v + w] == -1L) {\n queue.add(v + w)\n dist[v + w] = dist[v] + 1L\n }\n if(canLeft(v) && dist[v - 1] == -1L) {\n queue.add(v - 1)\n dist[v - 1] = dist[v] + 1L\n }\n if(canRight(v) && dist[v + 1] == -1L) {\n queue.add(v + 1)\n dist[v + 1] = dist[v] + 1L\n }\n }\n return dist\n }\n\n}\n\n// Data Structure\n\nclass UnionFind(size: Long) {\n private val par = LongArray(size.toInt()) { it.toLong() }\n private val size = longAry(size, 1L)\n private val diffWeight = longAry(size, 0L)\n fun root(x: Long): Long {\n return if (par[x] == x) {\n x\n } else {\n val r = root(par[x])\n diffWeight[x] += diffWeight[par[x]]\n par[x] = r\n par[x]\n }\n }\n fun weight(x: Long): Long {\n root(x)\n return diffWeight[x]\n }\n fun diff(x: Long, y: Long) = abs(weight(y) - weight(x))\n\n fun same(x: Long, y: Long): Boolean = root(x) == root(y)\n fun unite(x: Long, y: Long, d: Long) {\n var w = d\n w += weight(x)\n w -= weight(y)\n var a = root(x)\n var b = root(y)\n if (a == b) return\n if (size[a] < size[b]) {\n var tmp = a\n a = b\n b = tmp\n w = -w\n }\n size[a] += size[b]\n par[b] = a\n diffWeight[b] = w\n }\n\n fun size(x: Long): Long = size[root(x)]\n}\n\nclass SegmentTree(\n private val a: LongArray,\n private val op: (Long, Long) -> Long,\n private val def: Long = 0,\n private val size: Int = a.size,\n private val n: Int = Integer.highestOneBit(size) shl 1\n) {\n private val nodes = longAry(2L * n - 1, def)\n\n fun init() {\n for (i in 0 until size) nodes[i + n - 1] = a[i]\n for (i in n - 2 downTo 0) nodes[i] = calc(nodes[2 * i + 1], nodes[2 * i + 2], op)\n }\n\n fun update(x: Long, value: Long) {\n var index = x + n - 1\n nodes[index] = value\n while (index > 0) {\n index = (index - 1) / 2\n nodes[index] = calc(nodes[2 * index + 1], nodes[2 * index + 2], op)\n }\n }\n\n fun get(a: Long, b: Long) = getSub(a, b, 0L, 0L, n.toLong())\n private fun getSub(a: Long, b: Long, k: Long, l: Long, r: Long): Long {\n return when {\n r <= a || b <= l -> def\n a <= l && r <= b -> nodes[k]\n else -> {\n val vl = getSub(a, b, k * 2 + 1, l, (l + r) / 2)\n val vr = getSub(a, b, k * 2 + 2, (l + r) / 2, r)\n calc(vl, vr, op)\n }\n }\n }\n\n fun joinToString(separator: String) = nodes.drop(n - 1).take(size).joinToString(separator)\n}\n\n// Scanner\n\nclass FastScanner {\n private val sin: InputStream = System.`in`\n private val buffer: ByteArray = ByteArray(1024) { 0 }\n private var ptr = 0\n private var buflen = 0\n\n private fun hasNextByte(): Boolean {\n return when {\n ptr < buflen -> true\n else -> {\n ptr = 0\n buflen = sin.read(buffer)\n buflen > 0\n }\n }\n }\n\n private fun readByte(): Int {\n return when {\n hasNextByte() -> buffer[ptr++].toInt()\n else -> -1\n }\n }\n\n private fun isPrintableChar(c: Int) = c in 33..126\n\n fun hasNext(): Boolean {\n while (hasNextByte() && !isPrintableChar(buffer[ptr].toInt())) ptr++\n return hasNextByte()\n }\n\n fun next(): String {\n if (!hasNext()) throw NoSuchElementException()\n val sb = StringBuilder()\n var b = readByte()\n while (isPrintableChar(b)) {\n sb.appendCodePoint(b)\n b = readByte()\n }\n return sb.toString()\n }\n\n fun nextLong(): Long {\n if (!hasNext()) throw NoSuchElementException()\n var n = 0L\n var minus = false\n var b = readByte()\n if (b.toChar() == '-') {\n minus = true\n b = readByte()\n }\n if (b.toChar() !in '0'..'9') throw NumberFormatException()\n while (true) {\n when {\n b.toChar() in '0'..'9' -> {\n n *= 10\n n += b.toChar() - '0'\n }\n b == -1 || !isPrintableChar(b) -> return if (minus) -n else n\n else -> throw NumberFormatException()\n }\n b = readByte()\n }\n }\n\n// \"The world doesn't need you.\"\n//\n// fun nextInt(): Int {\n// val nl = nextLong()\n// if (nl !in Int.MIN_VALUE..Int.MAX_VALUE) throw NumberFormatException()\n// return nl.toInt()\n// }\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 18107, "cpu_time_ms": 2115, "memory_kb": 234372}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s141665385", "group_id": "codeNet:p03078", "input_text": "fun main(args: Array) {\n val (X, Y, Z, K) = listOfInt()\n val A = listOfLong().sortedDescending()\n val B = listOfLong().sortedDescending()\n val C = listOfLong().sortedDescending()\n val D = mutableListOf()\n for (x in 0 until X) {\n for (y in 0 until Y) {\n if ((x + 1) * (y + 1) > K) break\n for (z in 0 until Z) {\n if ((x + 1) * (y + 1) * (z + 1) > K) break\n D.add(A[x] + B[y] + C[z])\n }\n }\n }\n val ans = D.sortedDescending()\n for (k in 0 until K) println(ans[k])\n}\nfun next() = readLine()!!\nfun listOfString() = next().split(\" \")\nfun listOfInt() = listOfString().map(String::toInt)\nfun listOfLong() = listOfString().map(String::toLong)", "language": "Kotlin", "metadata": {"date": 1580723152, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03078.html", "problem_id": "p03078", "resource_group": "medium_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/Kotlin/s141665385.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s141665385", "user_id": "u043150661"}, "prompt_components": {"gold_output": "19\n17\n15\n14\n13\n12\n10\n8\n", "input_to_evaluate": "fun main(args: Array) {\n val (X, Y, Z, K) = listOfInt()\n val A = listOfLong().sortedDescending()\n val B = listOfLong().sortedDescending()\n val C = listOfLong().sortedDescending()\n val D = mutableListOf()\n for (x in 0 until X) {\n for (y in 0 until Y) {\n if ((x + 1) * (y + 1) > K) break\n for (z in 0 until Z) {\n if ((x + 1) * (y + 1) * (z + 1) > K) break\n D.add(A[x] + B[y] + C[z])\n }\n }\n }\n val ans = D.sortedDescending()\n for (k in 0 until K) println(ans[k])\n}\nfun next() = readLine()!!\nfun listOfString() = next().split(\" \")\nfun listOfInt() = listOfString().map(String::toInt)\nfun listOfLong() = listOfString().map(String::toLong)", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 750, "cpu_time_ms": 661, "memory_kb": 44100}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s836798072", "group_id": "codeNet:p03078", "input_text": "import java.util.Arrays\nimport java.util.Scanner\n\nobject Main {\n\t@JvmStatic\n\tfun main(args: Array) {\n\t\tval scanner = Scanner(System.`in`)\n\t\tval x = scanner.nextInt()\n\t\tval y = scanner.nextInt()\n\t\tval z = scanner.nextInt()\n\t\tval k = scanner.nextInt()\n\t\tval a = LongArray(x)\n\t\tval b = LongArray(y)\n\t\tval c = LongArray(z)\n\t\tfor (i in 0 .. x-1) a[i] = scanner.nextLong()\n\t\tfor (i in 0 .. y-1) b[i] = scanner.nextLong()\n\t\tfor (i in 0 .. z-1) c[i] = scanner.nextLong()\n\n\t\tArrays.sort(a)\n\t\tArrays.sort(b)\n\t\tArrays.sort(c)\n\n\t\tval map = mutableMapOf()\n\t\tfor (i in x-1 downTo x-Math.min(k,x)){\n\t\t\tfor (j in y-1 downTo y-Math.min(k-(x-i), y)) {\n\t\t\t\tfor (l in z-1 downTo z-Math.min(k-(x-i)-(y-j), z)){\n\t\t\t\t\tval v = a[i]+b[j]+c[l]\n\t\t\t\t\tmap[v] = map[v]?.plus(1) ?: 1\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tval keys = map.keys.sortedDescending()\n\t\tvar cnt = 0\n\t\tkeys.forEach {\n\t\t\tval times = Math.min(k-cnt, map[it]!!)\n\t\t\tfor (i in 1..times) println(it)\n\t\t\tcnt += times\n\t\t}\n\n\t}\n}", "language": "Kotlin", "metadata": {"date": 1554583954, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03078.html", "problem_id": "p03078", "resource_group": "medium_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/Kotlin/s836798072.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s836798072", "user_id": "u914590612"}, "prompt_components": {"gold_output": "19\n17\n15\n14\n13\n12\n10\n8\n", "input_to_evaluate": "import java.util.Arrays\nimport java.util.Scanner\n\nobject Main {\n\t@JvmStatic\n\tfun main(args: Array) {\n\t\tval scanner = Scanner(System.`in`)\n\t\tval x = scanner.nextInt()\n\t\tval y = scanner.nextInt()\n\t\tval z = scanner.nextInt()\n\t\tval k = scanner.nextInt()\n\t\tval a = LongArray(x)\n\t\tval b = LongArray(y)\n\t\tval c = LongArray(z)\n\t\tfor (i in 0 .. x-1) a[i] = scanner.nextLong()\n\t\tfor (i in 0 .. y-1) b[i] = scanner.nextLong()\n\t\tfor (i in 0 .. z-1) c[i] = scanner.nextLong()\n\n\t\tArrays.sort(a)\n\t\tArrays.sort(b)\n\t\tArrays.sort(c)\n\n\t\tval map = mutableMapOf()\n\t\tfor (i in x-1 downTo x-Math.min(k,x)){\n\t\t\tfor (j in y-1 downTo y-Math.min(k-(x-i), y)) {\n\t\t\t\tfor (l in z-1 downTo z-Math.min(k-(x-i)-(y-j), z)){\n\t\t\t\t\tval v = a[i]+b[j]+c[l]\n\t\t\t\t\tmap[v] = map[v]?.plus(1) ?: 1\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tval keys = map.keys.sortedDescending()\n\t\tvar cnt = 0\n\t\tkeys.forEach {\n\t\t\tval times = Math.min(k-cnt, map[it]!!)\n\t\t\tfor (i in 1..times) println(it)\n\t\t\tcnt += times\n\t\t}\n\n\t}\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 961, "cpu_time_ms": 154, "memory_kb": 31260}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s109416982", "group_id": "codeNet:p03078", "input_text": "fun main(args: Array) {\n\tval (x, y, z, k) = (readLine() ?: return).split(\" \").map { it.toInt() }.toIntArray()\n\tval a = (readLine() ?: return).split(\" \").map { it.toLong() }.toLongArray()\n\tval b = (readLine() ?: return).split(\" \").map { it.toLong() }.toLongArray()\n\tval c = (readLine() ?: return).split(\" \").map { it.toLong() }.toLongArray()\n\n\tval a2 = a.sortedArrayDescending().filterIndexed { index, i -> index < k }\n\tval b2 = b.sortedArrayDescending().filterIndexed { index, i -> index < k }\n\tval c2 = c.sortedArrayDescending().filterIndexed { index, i -> index < k }\n\n\tval eva = LongArray(a2.size * b2.size * c2.size)\n\tvar count = 0\n\tfor (da in a2) for (db in b2) for (dc in c2) {\n\t\teva[count] = da + db + dc\n\t\tcount++\n\t}\n\n\teva.sortDescending()\n\tfor (i in 0 until k) println(eva[i])\n}", "language": "Kotlin", "metadata": {"date": 1554582820, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03078.html", "problem_id": "p03078", "resource_group": "medium_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/Kotlin/s109416982.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s109416982", "user_id": "u801173061"}, "prompt_components": {"gold_output": "19\n17\n15\n14\n13\n12\n10\n8\n", "input_to_evaluate": "fun main(args: Array) {\n\tval (x, y, z, k) = (readLine() ?: return).split(\" \").map { it.toInt() }.toIntArray()\n\tval a = (readLine() ?: return).split(\" \").map { it.toLong() }.toLongArray()\n\tval b = (readLine() ?: return).split(\" \").map { it.toLong() }.toLongArray()\n\tval c = (readLine() ?: return).split(\" \").map { it.toLong() }.toLongArray()\n\n\tval a2 = a.sortedArrayDescending().filterIndexed { index, i -> index < k }\n\tval b2 = b.sortedArrayDescending().filterIndexed { index, i -> index < k }\n\tval c2 = c.sortedArrayDescending().filterIndexed { index, i -> index < k }\n\n\tval eva = LongArray(a2.size * b2.size * c2.size)\n\tvar count = 0\n\tfor (da in a2) for (db in b2) for (dc in c2) {\n\t\teva[count] = da + db + dc\n\t\tcount++\n\t}\n\n\teva.sortDescending()\n\tfor (i in 0 until k) println(eva[i])\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 795, "cpu_time_ms": 370, "memory_kb": 54604}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s103245052", "group_id": "codeNet:p03079", "input_text": "import java.util.*\n\n/**\n * Created on 2019/03/03.\n */\n\n\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val a = sc.next().toInt()\n val b = sc.next().toInt()\n val c = sc.next().toInt()\n val list = listOf(a, b, c).sorted()\n if (list[0] == list[2]) println(\"Yes\") else println(\"No\")\n}\n", "language": "Kotlin", "metadata": {"date": 1553976377, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03079.html", "problem_id": "p03079", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03079/input.txt", "sample_output_relpath": "derived/input_output/data/p03079/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03079/Kotlin/s103245052.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s103245052", "user_id": "u996672406"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "import java.util.*\n\n/**\n * Created on 2019/03/03.\n */\n\n\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val a = sc.next().toInt()\n val b = sc.next().toInt()\n val c = sc.next().toInt()\n val list = listOf(a, b, c).sorted()\n if (list[0] == list[2]) println(\"Yes\") else println(\"No\")\n}\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nYou are given three integers A, B and C.\n\nDetermine if there exists an equilateral triangle whose sides have lengths A, B and C.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq A,B,C \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C\n\nOutput\n\nIf there exists an equilateral triangle whose sides have lengths A, B and C, print Yes; otherwise, print No.\n\nSample Input 1\n\n2 2 2\n\nSample Output 1\n\nYes\n\nThere exists an equilateral triangle whose sides have lengths 2, 2 and 2.\n\nSample Input 2\n\n3 4 5\n\nSample Output 2\n\nNo\n\nThere is no equilateral triangle whose sides have lengths 3, 4 and 5.", "sample_input": "2 2 2\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03079", "source_text": "Score : 100 points\n\nProblem Statement\n\nYou are given three integers A, B and C.\n\nDetermine if there exists an equilateral triangle whose sides have lengths A, B and C.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq A,B,C \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C\n\nOutput\n\nIf there exists an equilateral triangle whose sides have lengths A, B and C, print Yes; otherwise, print No.\n\nSample Input 1\n\n2 2 2\n\nSample Output 1\n\nYes\n\nThere exists an equilateral triangle whose sides have lengths 2, 2 and 2.\n\nSample Input 2\n\n3 4 5\n\nSample Output 2\n\nNo\n\nThere is no equilateral triangle whose sides have lengths 3, 4 and 5.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 204, "memory_kb": 34120}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s924199439", "group_id": "codeNet:p03080", "input_text": "fun main(args: Array) {\n val n = readLine()!!.toInt()\n val s = readLine()!!\n println(if(s.count { it == 'R' } > n / 2) \"Yes\" else \"No\")\n}", "language": "Kotlin", "metadata": {"date": 1553976493, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03080.html", "problem_id": "p03080", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03080/input.txt", "sample_output_relpath": "derived/input_output/data/p03080/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03080/Kotlin/s924199439.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s924199439", "user_id": "u903745185"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "fun main(args: Array) {\n val n = readLine()!!.toInt()\n val s = readLine()!!\n println(if(s.count { it == 'R' } > n / 2) \"Yes\" else \"No\")\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nThere are N people numbered 1 to N. Each person wears a red hat or a blue hat.\n\nYou are given a string s representing the colors of the people. Person i wears a red hat if s_i is R, and a blue hat if s_i is B.\n\nDetermine if there are more people wearing a red hat than people wearing a blue hat.\n\nConstraints\n\n1 \\leq N \\leq 100\n\n|s| = N\n\ns_i is R or B.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\ns\n\nOutput\n\nIf there are more people wearing a red hat than there are people wearing a blue hat, print Yes; otherwise, print No.\n\nSample Input 1\n\n4\nRRBR\n\nSample Output 1\n\nYes\n\nThere are three people wearing a red hat, and one person wearing a blue hat.\n\nSince there are more people wearing a red hat than people wearing a blue hat, the answer is Yes.\n\nSample Input 2\n\n4\nBRBR\n\nSample Output 2\n\nNo\n\nThere are two people wearing a red hat, and two people wearing a blue hat.\n\nSince there are as many people wearing a red hat as people wearing a blue hat, the answer is No.", "sample_input": "4\nRRBR\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03080", "source_text": "Score : 200 points\n\nProblem Statement\n\nThere are N people numbered 1 to N. Each person wears a red hat or a blue hat.\n\nYou are given a string s representing the colors of the people. Person i wears a red hat if s_i is R, and a blue hat if s_i is B.\n\nDetermine if there are more people wearing a red hat than people wearing a blue hat.\n\nConstraints\n\n1 \\leq N \\leq 100\n\n|s| = N\n\ns_i is R or B.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\ns\n\nOutput\n\nIf there are more people wearing a red hat than there are people wearing a blue hat, print Yes; otherwise, print No.\n\nSample Input 1\n\n4\nRRBR\n\nSample Output 1\n\nYes\n\nThere are three people wearing a red hat, and one person wearing a blue hat.\n\nSince there are more people wearing a red hat than people wearing a blue hat, the answer is Yes.\n\nSample Input 2\n\n4\nBRBR\n\nSample Output 2\n\nNo\n\nThere are two people wearing a red hat, and two people wearing a blue hat.\n\nSince there are as many people wearing a red hat as people wearing a blue hat, the answer is No.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 238, "memory_kb": 33776}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s804448376", "group_id": "codeNet:p03081", "input_text": "fun main(args: Array) {\n val (n,q) = readLine()!!.split(\" \").map{it.toInt()}\n val s =readLine()!!\n val td = Array(q){readLine()!!.split(\" \").map { s->s[0] }}\n var min = 0\n var max = n-1\n for(i in q-1 downTo 0){\n if(min>max)break\n\n if(td[i][1]=='L'){\n if(s[min]==td[i][0]){\n min+=1\n }\n if(max) {\n val (n,q) = readLine()!!.split(\" \").map{it.toInt()}\n val s =readLine()!!\n val td = Array(q){readLine()!!.split(\" \").map { s->s[0] }}\n var min = 0\n var max = n-1\n for(i in q-1 downTo 0){\n if(min>max)break\n\n if(td[i][1]=='L'){\n if(s[min]==td[i][0]){\n min+=1\n }\n if(max) {\n\tval input = (readLine() ?: return).split(\" \")\n\tval n = input[0].toInt()\n\tval q = input[1].toInt()\n\tval s = (readLine() ?: return).toCharArray()\n\n\tval cache = Array>(26) { LinkedList() }\n\tfor (i in 0 until n) cache[s[i]-'A'].add(i)\n\n\tval golem = IntArray(n) { 1 }\n\tvar sum = n\n\tfor (i in 0 until q) {\n\t\tval line = (readLine() ?: return)\n\t\tval t = cache[line[0]-'A']\n\t\tif (line[2] == 'L') {\n\t\t\tfor (j in 0 until t.size) {\n\t\t\t\tval p = t[j]\n\t\t\t\tif (p == 0) {\n\t\t\t\t\tsum -= golem[p]\n\t\t\t\t\tgolem[p] = 0\n\t\t\t\t} else {\n\t\t\t\t\tgolem[p - 1] += golem[p]\n\t\t\t\t\tgolem[p] = 0\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfor (j in t.size - 1 downTo 0) {\n\t\t\t\tval p = t[j]\n\t\t\t\tif (p == n - 1) {\n\t\t\t\t\tsum -= golem[p]\n\t\t\t\t\tgolem[p] = 0\n\t\t\t\t} else {\n\t\t\t\t\tgolem[p + 1] += golem[p]\n\t\t\t\t\tgolem[p] = 0\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tprintln(sum)\n}", "language": "Kotlin", "metadata": {"date": 1553979122, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03081.html", "problem_id": "p03081", "resource_group": "medium_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/Kotlin/s448819515.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s448819515", "user_id": "u801173061"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import java.util.*\n\nfun main(args: Array) {\n\tval input = (readLine() ?: return).split(\" \")\n\tval n = input[0].toInt()\n\tval q = input[1].toInt()\n\tval s = (readLine() ?: return).toCharArray()\n\n\tval cache = Array>(26) { LinkedList() }\n\tfor (i in 0 until n) cache[s[i]-'A'].add(i)\n\n\tval golem = IntArray(n) { 1 }\n\tvar sum = n\n\tfor (i in 0 until q) {\n\t\tval line = (readLine() ?: return)\n\t\tval t = cache[line[0]-'A']\n\t\tif (line[2] == 'L') {\n\t\t\tfor (j in 0 until t.size) {\n\t\t\t\tval p = t[j]\n\t\t\t\tif (p == 0) {\n\t\t\t\t\tsum -= golem[p]\n\t\t\t\t\tgolem[p] = 0\n\t\t\t\t} else {\n\t\t\t\t\tgolem[p - 1] += golem[p]\n\t\t\t\t\tgolem[p] = 0\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfor (j in t.size - 1 downTo 0) {\n\t\t\t\tval p = t[j]\n\t\t\t\tif (p == n - 1) {\n\t\t\t\t\tsum -= golem[p]\n\t\t\t\t\tgolem[p] = 0\n\t\t\t\t} else {\n\t\t\t\t\tgolem[p + 1] += golem[p]\n\t\t\t\t\tgolem[p] = 0\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tprintln(sum)\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 2111, "memory_kb": 53852}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s235082027", "group_id": "codeNet:p03085", "input_text": "fun main(args: Array) {\n val b = readLine()!!\n println(\n when (b) {\n \"A\" -> \"T\"\n \"T\" -> \"A\"\n \"C\" -> \"G\"\n else -> \"C\"\n }\n )\n}\n", "language": "Kotlin", "metadata": {"date": 1579902954, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03085.html", "problem_id": "p03085", "resource_group": "medium_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/Kotlin/s235082027.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s235082027", "user_id": "u396701320"}, "prompt_components": {"gold_output": "T\n", "input_to_evaluate": "fun main(args: Array) {\n val b = readLine()!!\n println(\n when (b) {\n \"A\" -> \"T\"\n \"T\" -> \"A\"\n \"C\" -> \"G\"\n else -> \"C\"\n }\n )\n}\n", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 202, "memory_kb": 31716}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s945291020", "group_id": "codeNet:p03085", "input_text": "fun main(args:Array){\n val b = readLine()!!\n println(when(b) {\n \"A\" -> \"T\"\n \"T\"->\"A\"\n \"G\"->\"C\"\n else->\"G\"\n })\n}", "language": "Kotlin", "metadata": {"date": 1576101947, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03085.html", "problem_id": "p03085", "resource_group": "medium_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/Kotlin/s945291020.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s945291020", "user_id": "u183530284"}, "prompt_components": {"gold_output": "T\n", "input_to_evaluate": "fun main(args:Array){\n val b = readLine()!!\n println(when(b) {\n \"A\" -> \"T\"\n \"T\"->\"A\"\n \"G\"->\"C\"\n else->\"G\"\n })\n}", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 202, "memory_kb": 31684}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s597416650", "group_id": "codeNet:p03085", "input_text": "fun main(args: Array) {\n //A->T C->G\n println(\"b\")\n val b: String? = readLine()\n\n print(when(b){\n \"A\"->\"T\"\n \"T\"->\"A\"\n \"G\"->\"C\"\n \"c\"->\"G\"\n else->\"Invalid\"\n })\n\n}", "language": "Kotlin", "metadata": {"date": 1554471372, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03085.html", "problem_id": "p03085", "resource_group": "medium_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/Kotlin/s597416650.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s597416650", "user_id": "u606213752"}, "prompt_components": {"gold_output": "T\n", "input_to_evaluate": "fun main(args: Array) {\n //A->T C->G\n println(\"b\")\n val b: String? = readLine()\n\n print(when(b){\n \"A\"->\"T\"\n \"T\"->\"A\"\n \"G\"->\"C\"\n \"c\"->\"G\"\n else->\"Invalid\"\n })\n\n}", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 218, "cpu_time_ms": 199, "memory_kb": 33688}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s307115593", "group_id": "codeNet:p03085", "input_text": "fun main() {\n var b: String = readLine()!!\n when (b) {\n \"A\" -> {\n print(\"T\")\n }\n \"T\" -> {\n print(\"A\")\n }\n \"C\" -> {\n print(\"G\")\n }\n \"G\" -> {\n print(\"C\")\n }\n }\n}", "language": "Kotlin", "metadata": {"date": 1554143820, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03085.html", "problem_id": "p03085", "resource_group": "medium_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/Kotlin/s307115593.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s307115593", "user_id": "u118518526"}, "prompt_components": {"gold_output": "T\n", "input_to_evaluate": "fun main() {\n var b: String = readLine()!!\n when (b) {\n \"A\" -> {\n print(\"T\")\n }\n \"T\" -> {\n print(\"A\")\n }\n \"C\" -> {\n print(\"G\")\n }\n \"G\" -> {\n print(\"C\")\n }\n }\n}", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 268, "cpu_time_ms": 159, "memory_kb": 29340}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s539197220", "group_id": "codeNet:p03085", "input_text": "fun main(args: Array) {\n val map = hashMapOf(\"A\" to \"T\", \"C\" to \"G\", \"T\" to \"A\", \"G\" to \"C\")\n val (i) = readLine()!!.split(\" \")\n println(map[i])\n}", "language": "Kotlin", "metadata": {"date": 1553623816, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03085.html", "problem_id": "p03085", "resource_group": "medium_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/Kotlin/s539197220.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s539197220", "user_id": "u562388762"}, "prompt_components": {"gold_output": "T\n", "input_to_evaluate": "fun main(args: Array) {\n val map = hashMapOf(\"A\" to \"T\", \"C\" to \"G\", \"T\" to \"A\", \"G\" to \"C\")\n val (i) = readLine()!!.split(\" \")\n println(map[i])\n}", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 234, "memory_kb": 35980}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s725522579", "group_id": "codeNet:p03086", "input_text": "import java.io.BufferedReader\nimport java.io.InputStreamReader\nimport java.io.PrintWriter\n\nval br = BufferedReader(InputStreamReader(System.`in`))\nval out = PrintWriter(System.out)\n\nfun main() {\n br.use { out.use {\n solve()\n out.flush()\n } }\n}\n\nfun solve() {\n val s = br.readLine()!!\n val acgtSet = setOf('A', 'C', 'G', 'T')\n val ans = (s.indices).map {\n var tmp = 0\n for (i in it until s.length) {\n if (acgtSet.contains(s[i]) == false) break\n tmp++\n }\n tmp\n }.max()!!\n out.println(ans)\n}\n\nfun readInteger() = Integer.parseInt(br.readLine())\nfun readLong() = java.lang.Long.parseLong(br.readLine())\nfun readStringList() = br.readLine()!!.split(' ')\nfun readIntegerList() = readStringList().map(Integer::parseInt)\nfun readLongList() = readStringList().map(java.lang.Long::parseLong)\nfun readDoubleList() = readStringList().map(java.lang.Double::parseDouble)\n", "language": "Kotlin", "metadata": {"date": 1599332784, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p03086.html", "problem_id": "p03086", "resource_group": "medium_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/Kotlin/s725522579.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s725522579", "user_id": "u784448849"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "import java.io.BufferedReader\nimport java.io.InputStreamReader\nimport java.io.PrintWriter\n\nval br = BufferedReader(InputStreamReader(System.`in`))\nval out = PrintWriter(System.out)\n\nfun main() {\n br.use { out.use {\n solve()\n out.flush()\n } }\n}\n\nfun solve() {\n val s = br.readLine()!!\n val acgtSet = setOf('A', 'C', 'G', 'T')\n val ans = (s.indices).map {\n var tmp = 0\n for (i in it until s.length) {\n if (acgtSet.contains(s[i]) == false) break\n tmp++\n }\n tmp\n }.max()!!\n out.println(ans)\n}\n\nfun readInteger() = Integer.parseInt(br.readLine())\nfun readLong() = java.lang.Long.parseLong(br.readLine())\nfun readStringList() = br.readLine()!!.split(' ')\nfun readIntegerList() = readStringList().map(Integer::parseInt)\nfun readLongList() = readStringList().map(java.lang.Long::parseLong)\nfun readDoubleList() = readStringList().map(java.lang.Double::parseDouble)\n", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 942, "cpu_time_ms": 141, "memory_kb": 40572}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s326022980", "group_id": "codeNet:p03086", "input_text": "const val MOD: Long = (1e9+7).toLong()\n\nfun main(args: Array) {\n val s = readLine()!!\n\n val x = s.map{\n (it == 'A') or (it == 'T') or (it == 'C') or (it == 'G')\n }\n\n var max = 0\n var stmax = -1\n var enmax = -1\n var a = 0\n var st = -1\n var en = -1\n for ((i, y) in x.withIndex()) {\n if (y) {\n if (a == 0) {\n st = i\n }\n a += 1\n } else {\n if (a > max) {\n max = a\n stmax = st\n enmax = i-1\n }\n a = 0\n }\n }\n if (a > max) {\n max = a\n stmax = st\n enmax = s.length-1\n }\n\n println(max)\n}\n", "language": "Kotlin", "metadata": {"date": 1553458179, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03086.html", "problem_id": "p03086", "resource_group": "medium_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/Kotlin/s326022980.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s326022980", "user_id": "u868099754"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "const val MOD: Long = (1e9+7).toLong()\n\nfun main(args: Array) {\n val s = readLine()!!\n\n val x = s.map{\n (it == 'A') or (it == 'T') or (it == 'C') or (it == 'G')\n }\n\n var max = 0\n var stmax = -1\n var enmax = -1\n var a = 0\n var st = -1\n var en = -1\n for ((i, y) in x.withIndex()) {\n if (y) {\n if (a == 0) {\n st = i\n }\n a += 1\n } else {\n if (a > max) {\n max = a\n stmax = st\n enmax = i-1\n }\n a = 0\n }\n }\n if (a > max) {\n max = a\n stmax = st\n enmax = s.length-1\n }\n\n println(max)\n}\n", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 233, "memory_kb": 33472}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s033923473", "group_id": "codeNet:p03087", "input_text": "fun main(args: Array) {\n\tval q = (readLine() ?: return).split(\" \")[1].toInt()\n\tval s = readLine() ?: return\n\n\tval s2 = s.replace(\"AC\", \"XY\")\n\n\tfor (i in 0 until q) {\n\t\tval quest = (readLine() ?: return).split(\" \")\n\t\tval l = quest[0].toInt()\n\t\tval r = quest[1].toInt()\n\n\t\tvar count = 0\n\t\tfor (j in l - 1 until r - 1) if (s2[j] == 'X') count++\n\t\tprintln(count)\n\t}\n}", "language": "Kotlin", "metadata": {"date": 1553460170, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03087.html", "problem_id": "p03087", "resource_group": "medium_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/Kotlin/s033923473.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s033923473", "user_id": "u801173061"}, "prompt_components": {"gold_output": "2\n0\n3\n", "input_to_evaluate": "fun main(args: Array) {\n\tval q = (readLine() ?: return).split(\" \")[1].toInt()\n\tval s = readLine() ?: return\n\n\tval s2 = s.replace(\"AC\", \"XY\")\n\n\tfor (i in 0 until q) {\n\t\tval quest = (readLine() ?: return).split(\" \")\n\t\tval l = quest[0].toInt()\n\t\tval r = quest[1].toInt()\n\n\t\tvar count = 0\n\t\tfor (j in l - 1 until r - 1) if (s2[j] == 'X') count++\n\t\tprintln(count)\n\t}\n}", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 2111, "memory_kb": 51712}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s543801083", "group_id": "codeNet:p03087", "input_text": "import java.io.BufferedReader\nimport java.io.InputStreamReader\nimport java.io.PrintWriter\n\nval br = BufferedReader(InputStreamReader(System.`in`))\nval pw = PrintWriter(System.out)\nfun main(args : Array) {\n func()\n pw.flush()\n}\n\nfun func() {\n // 回答をここに書く\n val (n, q) = listOfInt()\n val s = next()\n val list = (1..q).map {\n listOfInt()\n }\n list.map {\n val target = s.substring(it.component1() - 1,it.component2())\n val ret = target.replace(\"AC\", \"\")\n println((target.length - ret.length) / 2)\n }\n}\n\n// 入力取得\nfun next() = br.readLine()!!\nfun nextInt() = next().toInt()\nfun nextLong() = next().toLong()\nfun nextDouble() = next().toDouble()\nfun listOfString() = next().split(\" \")\nfun listOfInt() =listOfString().map { it.toInt() }\nfun listOfLong() =listOfString().map { it.toLong() }\nfun listOfDouble() =listOfString().map { it.toDouble() }\n\n// 約数のList\nfun divisor(value : Long) : List {\n val max = Math.sqrt(value.toDouble()).toLong()\n return (1..max)\n .filter { value % it == 0L }\n .map { listOf(it, value / it) }\n .flatten()\n .sorted()\n}\n\n// 範囲内の素数を取得\n// fromだけ指定すると戻り値の個数で素数判定ができる\nfun prime(from : Long, to : Long = from) : List {\n return (from..to).filter { i ->\n val max = Math.sqrt(i.toDouble()).toLong()\n (2..max).all { j -> i % j != 0L }\n }\n}\n\n// 素因数分解\nfun decom(value : Long) : List{\n if (value == 1L) return listOf(1)\n val max = Math.sqrt(value.toDouble()).toLong()\n return prime(2, max).filter { value % it == 0L }\n}\n\n// 最大公約数\nfun gcd(a : Long, b : Long) : Long {\n return if (a % b == 0L) b else gcd(b, a % b)\n}\n\n// 文字列を入れ替え\nfun swap(base : String, a : String, b : String) : String {\n return base.map {\n when (it) {\n a.toCharArray()[0] -> b\n b.toCharArray()[0] -> a\n else -> it.toString()\n }\n }.joinToString()\n}\n\nfun println(value : Any) {\n pw.println(value)\n}", "language": "Kotlin", "metadata": {"date": 1553459876, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03087.html", "problem_id": "p03087", "resource_group": "medium_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/Kotlin/s543801083.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s543801083", "user_id": "u375901682"}, "prompt_components": {"gold_output": "2\n0\n3\n", "input_to_evaluate": "import java.io.BufferedReader\nimport java.io.InputStreamReader\nimport java.io.PrintWriter\n\nval br = BufferedReader(InputStreamReader(System.`in`))\nval pw = PrintWriter(System.out)\nfun main(args : Array) {\n func()\n pw.flush()\n}\n\nfun func() {\n // 回答をここに書く\n val (n, q) = listOfInt()\n val s = next()\n val list = (1..q).map {\n listOfInt()\n }\n list.map {\n val target = s.substring(it.component1() - 1,it.component2())\n val ret = target.replace(\"AC\", \"\")\n println((target.length - ret.length) / 2)\n }\n}\n\n// 入力取得\nfun next() = br.readLine()!!\nfun nextInt() = next().toInt()\nfun nextLong() = next().toLong()\nfun nextDouble() = next().toDouble()\nfun listOfString() = next().split(\" \")\nfun listOfInt() =listOfString().map { it.toInt() }\nfun listOfLong() =listOfString().map { it.toLong() }\nfun listOfDouble() =listOfString().map { it.toDouble() }\n\n// 約数のList\nfun divisor(value : Long) : List {\n val max = Math.sqrt(value.toDouble()).toLong()\n return (1..max)\n .filter { value % it == 0L }\n .map { listOf(it, value / it) }\n .flatten()\n .sorted()\n}\n\n// 範囲内の素数を取得\n// fromだけ指定すると戻り値の個数で素数判定ができる\nfun prime(from : Long, to : Long = from) : List {\n return (from..to).filter { i ->\n val max = Math.sqrt(i.toDouble()).toLong()\n (2..max).all { j -> i % j != 0L }\n }\n}\n\n// 素因数分解\nfun decom(value : Long) : List{\n if (value == 1L) return listOf(1)\n val max = Math.sqrt(value.toDouble()).toLong()\n return prime(2, max).filter { value % it == 0L }\n}\n\n// 最大公約数\nfun gcd(a : Long, b : Long) : Long {\n return if (a % b == 0L) b else gcd(b, a % b)\n}\n\n// 文字列を入れ替え\nfun swap(base : String, a : String, b : String) : String {\n return base.map {\n when (it) {\n a.toCharArray()[0] -> b\n b.toCharArray()[0] -> a\n else -> it.toString()\n }\n }.joinToString()\n}\n\nfun println(value : Any) {\n pw.println(value)\n}", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2114, "cpu_time_ms": 2111, "memory_kb": 129600}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s214148887", "group_id": "codeNet:p03088", "input_text": "fun main(args: Array) {\n val N = readLine()!!.toInt()\n var a = mutableMapOf()\n var b = mutableMapOf()\n\n a[\"TTTT\"]=1\n\n repeat(N){ i ->\n a.forEach{\n \"ACGT\".forEach { c ->\n val s = it.key.drop(1) + c\n if(ok4(s)) b[s] = ( (b[s]?:0) + it.value) % 1000000007\n }\n }\n a = b\n b = mutableMapOf()\n }\n\n val ans = a.map { it.value }.reduce { a,b -> (a+b)%1000000007 }\n println(ans)\n}\n\nfun ok4(s:String):Boolean = listOf(\n s.matches(Regex(\"[ATGC]AGC\")),\n s.matches(Regex(\"A[ATGC]GC\")),\n s.matches(Regex(\"AG[ATGC]C\")),\n s.matches(Regex(\"[ATGC]ACG\")),\n s.matches(Regex(\"[ATGC]GAC\")) ).none{ it }", "language": "Kotlin", "metadata": {"date": 1557497412, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03088.html", "problem_id": "p03088", "resource_group": "medium_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/Kotlin/s214148887.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s214148887", "user_id": "u914096045"}, "prompt_components": {"gold_output": "61\n", "input_to_evaluate": "fun main(args: Array) {\n val N = readLine()!!.toInt()\n var a = mutableMapOf()\n var b = mutableMapOf()\n\n a[\"TTTT\"]=1\n\n repeat(N){ i ->\n a.forEach{\n \"ACGT\".forEach { c ->\n val s = it.key.drop(1) + c\n if(ok4(s)) b[s] = ( (b[s]?:0) + it.value) % 1000000007\n }\n }\n a = b\n b = mutableMapOf()\n }\n\n val ans = a.map { it.value }.reduce { a,b -> (a+b)%1000000007 }\n println(ans)\n}\n\nfun ok4(s:String):Boolean = listOf(\n s.matches(Regex(\"[ATGC]AGC\")),\n s.matches(Regex(\"A[ATGC]GC\")),\n s.matches(Regex(\"AG[ATGC]C\")),\n s.matches(Regex(\"[ATGC]ACG\")),\n s.matches(Regex(\"[ATGC]GAC\")) ).none{ it }", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 750, "cpu_time_ms": 1007, "memory_kb": 127516}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s295260087", "group_id": "codeNet:p03088", "input_text": "fun initList(lmChar : MutableList>>>>){\n val l3 = mutableListOf>>>()\n for(b3 in 0..3) {\n val l2 = mutableListOf>>()\n for (b2 in 0..3) {\n val l1 = mutableListOf>()\n for (b1 in 0..3) {\n val l0 = mutableListOf()\n for (b0 in 0..3) {\n if(b0 + b1 + b2 + b3 == 0) l0.add(1L)\n else l0.add(0L)\n }\n l1.add(l0)\n }\n l2.add(l1)\n }\n l3.add(l2)\n }\n lmChar.add(l3)\n}\n\nfun nextStep(lmChar : MutableList>>>>, i : Int){\n val l3 = mutableListOf>>>()\n for(b3 in 0..3) {\n val l2 = mutableListOf>>()\n for (b2 in 0..3) {\n val l1 = mutableListOf>()\n for (b1 in 0..3) {\n val l0 = mutableListOf()\n for (b0 in 0..3) {\n val flag = calculator(listOf(b3, b2, b1, b0))\n val value =\n lmChar[i - 1][1][b3][b2][b1] + lmChar[i - 1][2][b3][b2][b1] + lmChar[i - 1][3][b3][b2][b1] + lmChar[i - 1][0][b3][b2][b1]\n l0.add((value % 1000000007L) * flag)\n }\n l1.add(l0)\n }\n l2.add(l1)\n }\n l3.add(l2)\n }\n lmChar.add(l3)\n}\n\nfun calculator(l : List) : Long{\n if(l[0] == 1 && l[1] == 2 && l[2] == 3) return 0L\n if(l[0] == 2 && l[1] == 1 && l[2] == 3) return 0L\n if(l[0] == 1 && l[1] == 3 && l[2] == 2) return 0L\n if(l[1] == 1 && l[2] == 2 && l[3] == 3) return 0L\n if(l[1] == 2 && l[2] == 1 && l[3] == 3) return 0L\n if(l[1] == 1 && l[2] == 3 && l[3] == 2) return 0L\n if(l[0] == 1 && l[2] == 2 && l[3] == 3) return 0L\n if(l[0] == 1 && l[1] == 2 && l[3] == 3) return 0L\n return 1L\n}\n\nfun main(args: Array){\n val n = readLine()!!.toInt()\n val lmChar = mutableListOf>>>>()\n initList(lmChar)\n for(i in 1..n) nextStep(lmChar, i)\n var retValue = 0L\n for(b3 in 0..3){\n for(b2 in 0..3){\n for(b1 in 0..3){\n for(b0 in 0..3){\n retValue += lmChar[n][b3][b2][b1][b0]\n retValue %= 1000000007L\n }\n }\n }\n }\n println(retValue)\n}", "language": "Kotlin", "metadata": {"date": 1554059308, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03088.html", "problem_id": "p03088", "resource_group": "medium_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/Kotlin/s295260087.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s295260087", "user_id": "u712822150"}, "prompt_components": {"gold_output": "61\n", "input_to_evaluate": "fun initList(lmChar : MutableList>>>>){\n val l3 = mutableListOf>>>()\n for(b3 in 0..3) {\n val l2 = mutableListOf>>()\n for (b2 in 0..3) {\n val l1 = mutableListOf>()\n for (b1 in 0..3) {\n val l0 = mutableListOf()\n for (b0 in 0..3) {\n if(b0 + b1 + b2 + b3 == 0) l0.add(1L)\n else l0.add(0L)\n }\n l1.add(l0)\n }\n l2.add(l1)\n }\n l3.add(l2)\n }\n lmChar.add(l3)\n}\n\nfun nextStep(lmChar : MutableList>>>>, i : Int){\n val l3 = mutableListOf>>>()\n for(b3 in 0..3) {\n val l2 = mutableListOf>>()\n for (b2 in 0..3) {\n val l1 = mutableListOf>()\n for (b1 in 0..3) {\n val l0 = mutableListOf()\n for (b0 in 0..3) {\n val flag = calculator(listOf(b3, b2, b1, b0))\n val value =\n lmChar[i - 1][1][b3][b2][b1] + lmChar[i - 1][2][b3][b2][b1] + lmChar[i - 1][3][b3][b2][b1] + lmChar[i - 1][0][b3][b2][b1]\n l0.add((value % 1000000007L) * flag)\n }\n l1.add(l0)\n }\n l2.add(l1)\n }\n l3.add(l2)\n }\n lmChar.add(l3)\n}\n\nfun calculator(l : List) : Long{\n if(l[0] == 1 && l[1] == 2 && l[2] == 3) return 0L\n if(l[0] == 2 && l[1] == 1 && l[2] == 3) return 0L\n if(l[0] == 1 && l[1] == 3 && l[2] == 2) return 0L\n if(l[1] == 1 && l[2] == 2 && l[3] == 3) return 0L\n if(l[1] == 2 && l[2] == 1 && l[3] == 3) return 0L\n if(l[1] == 1 && l[2] == 3 && l[3] == 2) return 0L\n if(l[0] == 1 && l[2] == 2 && l[3] == 3) return 0L\n if(l[0] == 1 && l[1] == 2 && l[3] == 3) return 0L\n return 1L\n}\n\nfun main(args: Array){\n val n = readLine()!!.toInt()\n val lmChar = mutableListOf>>>>()\n initList(lmChar)\n for(i in 1..n) nextStep(lmChar, i)\n var retValue = 0L\n for(b3 in 0..3){\n for(b2 in 0..3){\n for(b1 in 0..3){\n for(b0 in 0..3){\n retValue += lmChar[n][b3][b2][b1][b0]\n retValue %= 1000000007L\n }\n }\n }\n }\n println(retValue)\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2589, "cpu_time_ms": 336, "memory_kb": 40888}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s753962114", "group_id": "codeNet:p03089", "input_text": "import java.io.PrintWriter\nimport java.util.*\nimport kotlin.math.pow\n\nfun next() = readLine()!!\nfun nextInt() = next().toInt()\nfun nextLong() = next().toLong()\nfun nextDouble() = next().toDouble()\nfun nextList() = next().split(\" \")\nfun nextIntList() = nextList().map(String::toInt)\nfun nextLongList() = nextList().map(String::toLong)\nfun nextDoubleList() = nextList().map(String::toDouble)\n\nval pw = PrintWriter(System.out)\nfun print(s: Any = \"\") = pw.print(s)\nfun println(s: Any = \"\") = pw.println(s)\n\nfun Iterable.join(separator: CharSequence = \", \", prefix: CharSequence = \"\", postfix: CharSequence = \"\") = joinToString(separator, prefix, postfix)\nfun Array.join(separator: CharSequence = \", \", prefix: CharSequence = \"\", postfix: CharSequence = \"\") = joinToString(separator, prefix, postfix)\nfun Int.pow(n: Int) = pow(n.toLong())\nfun Int.pow(n: Long) = toDouble().pow(n.toDouble()).toLong()\nfun Long.pow(n: Int) = pow(n.toLong())\nfun Long.pow(n: Long) = toDouble().pow(n.toDouble()).toLong()\n\nfun main(args: Array) {\n main()\n pw.flush()\n}\n\nfun main() {\n val N = nextInt()\n val B = nextIntList().toMutableList()\n val A = ArrayDeque()\n var i = N - 1\n while (B.isNotEmpty() && i >= 0) {\n if (B[i] == i + 1) {\n A.push(i + 1)\n B.removeAt(i)\n i = B.size - 1\n } else {\n i--\n }\n }\n println(if (B.isEmpty()) A.joinToString(\"\\n\") else -1)\n}\n", "language": "Kotlin", "metadata": {"date": 1594775769, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p03089.html", "problem_id": "p03089", "resource_group": "medium_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/Kotlin/s753962114.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s753962114", "user_id": "u860789370"}, "prompt_components": {"gold_output": "1\n1\n2\n", "input_to_evaluate": "import java.io.PrintWriter\nimport java.util.*\nimport kotlin.math.pow\n\nfun next() = readLine()!!\nfun nextInt() = next().toInt()\nfun nextLong() = next().toLong()\nfun nextDouble() = next().toDouble()\nfun nextList() = next().split(\" \")\nfun nextIntList() = nextList().map(String::toInt)\nfun nextLongList() = nextList().map(String::toLong)\nfun nextDoubleList() = nextList().map(String::toDouble)\n\nval pw = PrintWriter(System.out)\nfun print(s: Any = \"\") = pw.print(s)\nfun println(s: Any = \"\") = pw.println(s)\n\nfun Iterable.join(separator: CharSequence = \", \", prefix: CharSequence = \"\", postfix: CharSequence = \"\") = joinToString(separator, prefix, postfix)\nfun Array.join(separator: CharSequence = \", \", prefix: CharSequence = \"\", postfix: CharSequence = \"\") = joinToString(separator, prefix, postfix)\nfun Int.pow(n: Int) = pow(n.toLong())\nfun Int.pow(n: Long) = toDouble().pow(n.toDouble()).toLong()\nfun Long.pow(n: Int) = pow(n.toLong())\nfun Long.pow(n: Long) = toDouble().pow(n.toDouble()).toLong()\n\nfun main(args: Array) {\n main()\n pw.flush()\n}\n\nfun main() {\n val N = nextInt()\n val B = nextIntList().toMutableList()\n val A = ArrayDeque()\n var i = N - 1\n while (B.isNotEmpty() && i >= 0) {\n if (B[i] == i + 1) {\n A.push(i + 1)\n B.removeAt(i)\n i = B.size - 1\n } else {\n i--\n }\n }\n println(if (B.isEmpty()) A.joinToString(\"\\n\") else -1)\n}\n", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1454, "cpu_time_ms": 124, "memory_kb": 36520}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s744335712", "group_id": "codeNet:p03089", "input_text": "const val MOD: Long = (1e9+7).toLong()\n\nfun main(args: Array) {\n val n = readLine()!!.toInt()\n /* val b = ArrayList(readLine()!!.split(' ').map{it.toInt()-1}) */\n val b = arrayListOf(*readLine()!!.split(' ').map{it.toInt()-1}.toTypedArray())\n\n val l = arrayListOf(0)\n l.removeAt(0)\n /* val l: ArrayList = arrayListOf() */\n while (b.size > 1) {\n var f = false\n for ((i, x) in b.withIndex().reversed()) {\n if (i == 0) continue\n if (i == x) {\n l.add(x+1)\n b.removeAt(i)\n f = true\n break\n }\n }\n\n if (!f) {\n if (b[0] == 0) {\n l.add(1)\n b.removeAt(0)\n continue\n }\n\n println(-1)\n return\n }\n }\n if (b[0] != 0) {\n println(-1)\n return\n } else {\n println(1)\n for (x in l.reversed()) {\n println(x)\n }\n }\n}\n", "language": "Kotlin", "metadata": {"date": 1553378743, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03089.html", "problem_id": "p03089", "resource_group": "medium_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/Kotlin/s744335712.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s744335712", "user_id": "u868099754"}, "prompt_components": {"gold_output": "1\n1\n2\n", "input_to_evaluate": "const val MOD: Long = (1e9+7).toLong()\n\nfun main(args: Array) {\n val n = readLine()!!.toInt()\n /* val b = ArrayList(readLine()!!.split(' ').map{it.toInt()-1}) */\n val b = arrayListOf(*readLine()!!.split(' ').map{it.toInt()-1}.toTypedArray())\n\n val l = arrayListOf(0)\n l.removeAt(0)\n /* val l: ArrayList = arrayListOf() */\n while (b.size > 1) {\n var f = false\n for ((i, x) in b.withIndex().reversed()) {\n if (i == 0) continue\n if (i == x) {\n l.add(x+1)\n b.removeAt(i)\n f = true\n break\n }\n }\n\n if (!f) {\n if (b[0] == 0) {\n l.add(1)\n b.removeAt(0)\n continue\n }\n\n println(-1)\n return\n }\n }\n if (b[0] != 0) {\n println(-1)\n return\n } else {\n println(1)\n for (x in l.reversed()) {\n println(x)\n }\n }\n}\n", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 249, "memory_kb": 38172}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s923341898", "group_id": "codeNet:p03095", "input_text": "import java.util.*\n\nfun main(args: Array) {\n\n val sc = Scanner(System.`in`)\n val N = sc.nextInt()\n val S = sc.next()\n val map = mutableMapOf()\n for (c in S)\n map[c] = (map[c] ?: 0) +1\n var ans = 0L\n \n val cmap = mutableMapOf,Long>()\n\n fun calc(c:Char, n:Int) :Long{\n //println(\"$n $c:${map[c]}\")\n if (cmap[c to n] != null) return cmap[c to n]!!\n else if (n == 1) {\n return map[c]?.toLong()?:0\n } else {\n var res = 0L\n if (!map.any { it.key.toChar() in c+1 .. 'z'}) return 0L\n for (ci in c+1..'z') {\n if (ci !in map.keys) continue\n res += map[c]!!*calc(ci,n-1)\n }\n cmap[c to n] = res\n //println(\"return$res\")\n return res\n }\n }\n\n for (n in 1 .. map.size) {\n for (c in 'a'..'z') {\n if (c !in map.keys) continue\n ans += calc(c,n)\n //println(\"$n $ans\")\n }\n }\n println(ans%(1000000007L))\n}", "language": "Kotlin", "metadata": {"date": 1552776237, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03095.html", "problem_id": "p03095", "resource_group": "medium_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/Kotlin/s923341898.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s923341898", "user_id": "u043557308"}, "prompt_components": {"gold_output": "15\n", "input_to_evaluate": "import java.util.*\n\nfun main(args: Array) {\n\n val sc = Scanner(System.`in`)\n val N = sc.nextInt()\n val S = sc.next()\n val map = mutableMapOf()\n for (c in S)\n map[c] = (map[c] ?: 0) +1\n var ans = 0L\n \n val cmap = mutableMapOf,Long>()\n\n fun calc(c:Char, n:Int) :Long{\n //println(\"$n $c:${map[c]}\")\n if (cmap[c to n] != null) return cmap[c to n]!!\n else if (n == 1) {\n return map[c]?.toLong()?:0\n } else {\n var res = 0L\n if (!map.any { it.key.toChar() in c+1 .. 'z'}) return 0L\n for (ci in c+1..'z') {\n if (ci !in map.keys) continue\n res += map[c]!!*calc(ci,n-1)\n }\n cmap[c to n] = res\n //println(\"return$res\")\n return res\n }\n }\n\n for (n in 1 .. map.size) {\n for (c in 'a'..'z') {\n if (c !in map.keys) continue\n ans += calc(c,n)\n //println(\"$n $ans\")\n }\n }\n println(ans%(1000000007L))\n}", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1062, "cpu_time_ms": 374, "memory_kb": 36228}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s143380881", "group_id": "codeNet:p03096", "input_text": "fun main(args: Array) {\n val n= readLine()!!.toInt()\n val c = Array(n){readLine()!!.toLong()}\n val result = Array(n){0}\n result[0]=1\n if(n>1)result[1]=1\n for (i in 2 until n){\n result[i]+=result[i-1]\n result[i] %=1000000007.toLong()\n if(c[i]!=c[i-1])\n for(j in i-2 downTo 0){\n if(c[j]==c[i]){\n result[i]+=result[j]\n break\n }\n }\n result[i] %=1000000007.toLong()\n }\n print(result[n-1])\n}", "language": "Kotlin", "metadata": {"date": 1552769456, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03096.html", "problem_id": "p03096", "resource_group": "medium_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/Kotlin/s143380881.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s143380881", "user_id": "u586526576"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "fun main(args: Array) {\n val n= readLine()!!.toInt()\n val c = Array(n){readLine()!!.toLong()}\n val result = Array(n){0}\n result[0]=1\n if(n>1)result[1]=1\n for (i in 2 until n){\n result[i]+=result[i-1]\n result[i] %=1000000007.toLong()\n if(c[i]!=c[i-1])\n for(j in i-2 downTo 0){\n if(c[j]==c[i]){\n result[i]+=result[j]\n break\n }\n }\n result[i] %=1000000007.toLong()\n }\n print(result[n-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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 2111, "memory_kb": 59152}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s792200586", "group_id": "codeNet:p03101", "input_text": "fun main(args: Array) {\n abc121a()\n}\n\nfun abc121a() {\n val (h1, w1) = readLine()!!.split(\" \").map { it.toInt() }\n val (h2, w2) = readLine()!!.split(\" \").map { it.toInt() }\n\n val totalArea = h1 * w1\n\n val verticalBlackArea = h2 * w1\n val horizontalBlackArea = w2 * h1\n val totalBlackArea = verticalBlackArea + horizontalBlackArea - (h2 * w2)\n\n val totalWhiteArea = totalArea - totalBlackArea\n println(totalWhiteArea)\n}\n", "language": "Kotlin", "metadata": {"date": 1567626045, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03101.html", "problem_id": "p03101", "resource_group": "medium_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/Kotlin/s792200586.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s792200586", "user_id": "u139478771"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "fun main(args: Array) {\n abc121a()\n}\n\nfun abc121a() {\n val (h1, w1) = readLine()!!.split(\" \").map { it.toInt() }\n val (h2, w2) = readLine()!!.split(\" \").map { it.toInt() }\n\n val totalArea = h1 * w1\n\n val verticalBlackArea = h2 * w1\n val horizontalBlackArea = w2 * h1\n val totalBlackArea = verticalBlackArea + horizontalBlackArea - (h2 * w2)\n\n val totalWhiteArea = totalArea - totalBlackArea\n println(totalWhiteArea)\n}\n", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 453, "cpu_time_ms": 246, "memory_kb": 37792}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s832502965", "group_id": "codeNet:p03101", "input_text": "import java.util.*\nfun main(args: Array){\n\tval cin = Scanner(System.`in`)\n val h = cin.nextInt()\n val w = cin.nextInt()\n\n val h_d = cin.nextInt()\n val w_d = cin.nextInt()\n\n println(h*w - h_d*w - w_d*h + h_d*w_d)\n \n \n}", "language": "Kotlin", "metadata": {"date": 1552163046, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03101.html", "problem_id": "p03101", "resource_group": "medium_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/Kotlin/s832502965.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s832502965", "user_id": "u111421568"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "import java.util.*\nfun main(args: Array){\n\tval cin = Scanner(System.`in`)\n val h = cin.nextInt()\n val w = cin.nextInt()\n\n val h_d = cin.nextInt()\n val w_d = cin.nextInt()\n\n println(h*w - h_d*w - w_d*h + h_d*w_d)\n \n \n}", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 208, "memory_kb": 31276}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s745153422", "group_id": "codeNet:p03102", "input_text": "fun main(args: Array) {\n \n val (n, m, c) = readLine()!!.split(\" \").map { it.toInt() }\n val b = readLine()!!.split(\" \").map { it.toInt() }\n val a = (1..n).map { readLine()!!.split(\" \").map { it.toInt() } }\n \n\n /*\n val (n, m, c) = Triple(2, 3, -10)\n val b = listOf(1, 2, 3)\n val a = listOf(\n listOf(3, 2, 1),\n listOf(1, 2, 2)\n )\n */\n\n val result = a.map { codes ->\n codes.foldIndexed(0, { index, acc, i -> acc + i * b[index] }) + c\n }.count { it > 0 }\n\n println(\"$result\")\n}\n", "language": "Kotlin", "metadata": {"date": 1597269276, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p03102.html", "problem_id": "p03102", "resource_group": "medium_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/Kotlin/s745153422.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s745153422", "user_id": "u393104209"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "fun main(args: Array) {\n \n val (n, m, c) = readLine()!!.split(\" \").map { it.toInt() }\n val b = readLine()!!.split(\" \").map { it.toInt() }\n val a = (1..n).map { readLine()!!.split(\" \").map { it.toInt() } }\n \n\n /*\n val (n, m, c) = Triple(2, 3, -10)\n val b = listOf(1, 2, 3)\n val a = listOf(\n listOf(3, 2, 1),\n listOf(1, 2, 2)\n )\n */\n\n val result = a.map { codes ->\n codes.foldIndexed(0, { index, acc, i -> acc + i * b[index] }) + c\n }.count { it > 0 }\n\n println(\"$result\")\n}\n", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 550, "cpu_time_ms": 132, "memory_kb": 38156}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s271617614", "group_id": "codeNet:p03102", "input_text": "fun main(arr:Array) {\n val (n,m,c) = readLine()!!.split(\" \").map { it.toInt() }\n val bList = readLine()!!.split(\" \").map { it.toInt() }\n val aList = (1..n).map { readLine()!!.split(\" \").map { it.toInt() } }\n val ans = aList.map { list->list.indices.map { bList[it] * list[it] }.sum() + c > 0 }.filter { it }\n println(ans.size)\n}", "language": "Kotlin", "metadata": {"date": 1592362574, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03102.html", "problem_id": "p03102", "resource_group": "medium_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/Kotlin/s271617614.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s271617614", "user_id": "u269969976"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "fun main(arr:Array) {\n val (n,m,c) = readLine()!!.split(\" \").map { it.toInt() }\n val bList = readLine()!!.split(\" \").map { it.toInt() }\n val aList = (1..n).map { readLine()!!.split(\" \").map { it.toInt() } }\n val ans = aList.map { list->list.indices.map { bList[it] * list[it] }.sum() + c > 0 }.filter { it }\n println(ans.size)\n}", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 351, "cpu_time_ms": 239, "memory_kb": 37932}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s698981076", "group_id": "codeNet:p03103", "input_text": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val n = sc.nextInt()\n val m = sc.nextInt()\n val t = (1..n).map { Pair(sc.nextLong(), sc.nextLong()) }.sortedBy { it.first }\n\n var ans = 0L\n var sumB = 0L\n for (i in t.indices) {\n val add = Math.min(t[i].second, m - sumB)\n sumB += add\n ans += add * t[i].first\n }\n println(ans)\n}", "language": "Kotlin", "metadata": {"date": 1583350184, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03103.html", "problem_id": "p03103", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03103/input.txt", "sample_output_relpath": "derived/input_output/data/p03103/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03103/Kotlin/s698981076.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s698981076", "user_id": "u733811860"}, "prompt_components": {"gold_output": "12\n", "input_to_evaluate": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val n = sc.nextInt()\n val m = sc.nextInt()\n val t = (1..n).map { Pair(sc.nextLong(), sc.nextLong()) }.sortedBy { it.first }\n\n var ans = 0L\n var sumB = 0L\n for (i in t.indices) {\n val add = Math.min(t[i].second, m - sumB)\n sumB += add\n ans += add * t[i].first\n }\n println(ans)\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nHearing that energy drinks increase rating in those sites, Takahashi decides to buy up M cans of energy drinks.\n\nThere are N stores that sell energy drinks. In the i-th store, he can buy at most B_i cans of energy drinks for A_i yen (the currency of Japan) each.\n\nWhat is the minimum amount of money with which he can buy M cans of energy drinks?\n\nIt is guaranteed that, in the given inputs, a sufficient amount of money can always buy M cans of energy drinks.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N, M \\leq 10^5\n\n1 \\leq A_i \\leq 10^9\n\n1 \\leq B_i \\leq 10^5\n\nB_1 + ... + B_N \\geq M\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 minimum amount of money with which Takahashi can buy M cans of energy drinks.\n\nSample Input 1\n\n2 5\n4 9\n2 4\n\nSample Output 1\n\n12\n\nWith 12 yen, we can buy one drink at the first store and four drinks at the second store, for the total of five drinks. However, we cannot buy 5 drinks with 11 yen or less.\n\nSample Input 2\n\n4 30\n6 18\n2 5\n3 10\n7 9\n\nSample Output 2\n\n130\n\nSample Input 3\n\n1 100000\n1000000000 100000\n\nSample Output 3\n\n100000000000000\n\nThe output may not fit into a 32-bit integer type.", "sample_input": "2 5\n4 9\n2 4\n"}, "reference_outputs": ["12\n"], "source_document_id": "p03103", "source_text": "Score : 300 points\n\nProblem Statement\n\nHearing that energy drinks increase rating in those sites, Takahashi decides to buy up M cans of energy drinks.\n\nThere are N stores that sell energy drinks. In the i-th store, he can buy at most B_i cans of energy drinks for A_i yen (the currency of Japan) each.\n\nWhat is the minimum amount of money with which he can buy M cans of energy drinks?\n\nIt is guaranteed that, in the given inputs, a sufficient amount of money can always buy M cans of energy drinks.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N, M \\leq 10^5\n\n1 \\leq A_i \\leq 10^9\n\n1 \\leq B_i \\leq 10^5\n\nB_1 + ... + B_N \\geq M\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 minimum amount of money with which Takahashi can buy M cans of energy drinks.\n\nSample Input 1\n\n2 5\n4 9\n2 4\n\nSample Output 1\n\n12\n\nWith 12 yen, we can buy one drink at the first store and four drinks at the second store, for the total of five drinks. However, we cannot buy 5 drinks with 11 yen or less.\n\nSample Input 2\n\n4 30\n6 18\n2 5\n3 10\n7 9\n\nSample Output 2\n\n130\n\nSample Input 3\n\n1 100000\n1000000000 100000\n\nSample Output 3\n\n100000000000000\n\nThe output may not fit into a 32-bit integer type.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 409, "cpu_time_ms": 863, "memory_kb": 118648}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s195112779", "group_id": "codeNet:p03103", "input_text": "import java.util.Scanner\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val shopCount = sc.nextInt()\n val drinkCount = sc.nextInt()\n val shops = parseList(sc, shopCount)\n val result = buy(drinkCount, shops)\n println(result)\n}\n\nprivate fun parseList(scanner: Scanner, length: Int): List> {\n return (0 until length).map {\n val price = scanner.nextInt()\n val size = scanner.nextInt()\n price to size\n }.sortedByDescending { it.first }\n}\n\nprivate tailrec fun buy(targetDrinkCount: Int, shops: List>, cost: Long = 0, drinkCount: Long = 0): Long {\n val minShop = shops.last()\n val shouldBuyCount = targetDrinkCount - drinkCount\n return when {\n shouldBuyCount > minShop.second -> {\n // 全て買う\n val tempCost = minShop.first * minShop.second\n buy(targetDrinkCount, shops.dropLast(1), cost + tempCost, drinkCount + minShop.second)\n }\n else -> {\n // 買う個数が決まってる\n val tempCost = minShop.first * shouldBuyCount\n cost + tempCost\n }\n }\n}\n", "language": "Kotlin", "metadata": {"date": 1552167471, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03103.html", "problem_id": "p03103", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03103/input.txt", "sample_output_relpath": "derived/input_output/data/p03103/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03103/Kotlin/s195112779.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s195112779", "user_id": "u354554173"}, "prompt_components": {"gold_output": "12\n", "input_to_evaluate": "import java.util.Scanner\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val shopCount = sc.nextInt()\n val drinkCount = sc.nextInt()\n val shops = parseList(sc, shopCount)\n val result = buy(drinkCount, shops)\n println(result)\n}\n\nprivate fun parseList(scanner: Scanner, length: Int): List> {\n return (0 until length).map {\n val price = scanner.nextInt()\n val size = scanner.nextInt()\n price to size\n }.sortedByDescending { it.first }\n}\n\nprivate tailrec fun buy(targetDrinkCount: Int, shops: List>, cost: Long = 0, drinkCount: Long = 0): Long {\n val minShop = shops.last()\n val shouldBuyCount = targetDrinkCount - drinkCount\n return when {\n shouldBuyCount > minShop.second -> {\n // 全て買う\n val tempCost = minShop.first * minShop.second\n buy(targetDrinkCount, shops.dropLast(1), cost + tempCost, drinkCount + minShop.second)\n }\n else -> {\n // 買う個数が決まってる\n val tempCost = minShop.first * shouldBuyCount\n cost + tempCost\n }\n }\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nHearing that energy drinks increase rating in those sites, Takahashi decides to buy up M cans of energy drinks.\n\nThere are N stores that sell energy drinks. In the i-th store, he can buy at most B_i cans of energy drinks for A_i yen (the currency of Japan) each.\n\nWhat is the minimum amount of money with which he can buy M cans of energy drinks?\n\nIt is guaranteed that, in the given inputs, a sufficient amount of money can always buy M cans of energy drinks.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N, M \\leq 10^5\n\n1 \\leq A_i \\leq 10^9\n\n1 \\leq B_i \\leq 10^5\n\nB_1 + ... + B_N \\geq M\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 minimum amount of money with which Takahashi can buy M cans of energy drinks.\n\nSample Input 1\n\n2 5\n4 9\n2 4\n\nSample Output 1\n\n12\n\nWith 12 yen, we can buy one drink at the first store and four drinks at the second store, for the total of five drinks. However, we cannot buy 5 drinks with 11 yen or less.\n\nSample Input 2\n\n4 30\n6 18\n2 5\n3 10\n7 9\n\nSample Output 2\n\n130\n\nSample Input 3\n\n1 100000\n1000000000 100000\n\nSample Output 3\n\n100000000000000\n\nThe output may not fit into a 32-bit integer type.", "sample_input": "2 5\n4 9\n2 4\n"}, "reference_outputs": ["12\n"], "source_document_id": "p03103", "source_text": "Score : 300 points\n\nProblem Statement\n\nHearing that energy drinks increase rating in those sites, Takahashi decides to buy up M cans of energy drinks.\n\nThere are N stores that sell energy drinks. In the i-th store, he can buy at most B_i cans of energy drinks for A_i yen (the currency of Japan) each.\n\nWhat is the minimum amount of money with which he can buy M cans of energy drinks?\n\nIt is guaranteed that, in the given inputs, a sufficient amount of money can always buy M cans of energy drinks.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N, M \\leq 10^5\n\n1 \\leq A_i \\leq 10^9\n\n1 \\leq B_i \\leq 10^5\n\nB_1 + ... + B_N \\geq M\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 minimum amount of money with which Takahashi can buy M cans of energy drinks.\n\nSample Input 1\n\n2 5\n4 9\n2 4\n\nSample Output 1\n\n12\n\nWith 12 yen, we can buy one drink at the first store and four drinks at the second store, for the total of five drinks. However, we cannot buy 5 drinks with 11 yen or less.\n\nSample Input 2\n\n4 30\n6 18\n2 5\n3 10\n7 9\n\nSample Output 2\n\n130\n\nSample Input 3\n\n1 100000\n1000000000 100000\n\nSample Output 3\n\n100000000000000\n\nThe output may not fit into a 32-bit integer type.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1146, "cpu_time_ms": 2111, "memory_kb": 122272}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s528124950", "group_id": "codeNet:p03107", "input_text": "import java.util.*\n\nfun main(args: Array) {\n val S = readLine()!!\n\n var res = 0\n val st = ArrayDeque()\n\n for (c in S.toCharArray()) {\n if (st.isNotEmpty() && st.last != c) {\n st.pollLast()\n res += 2\n } else {\n st.addLast(c)\n }\n }\n\n println(res)\n}", "language": "Kotlin", "metadata": {"date": 1574965722, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03107.html", "problem_id": "p03107", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03107/input.txt", "sample_output_relpath": "derived/input_output/data/p03107/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03107/Kotlin/s528124950.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s528124950", "user_id": "u183530284"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "import java.util.*\n\nfun main(args: Array) {\n val S = readLine()!!\n\n var res = 0\n val st = ArrayDeque()\n\n for (c in S.toCharArray()) {\n if (st.isNotEmpty() && st.last != c) {\n st.pollLast()\n res += 2\n } else {\n st.addLast(c)\n }\n }\n\n println(res)\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere are N cubes stacked vertically on a desk.\n\nYou are given a string S of length N. The color of the i-th cube from the bottom is red if the i-th character in S is 0, and blue if that character is 1.\n\nYou can perform the following operation any number of times: choose a red cube and a blue cube that are adjacent, and remove them. Here, the cubes that were stacked on the removed cubes will fall down onto the object below them.\n\nAt most how many cubes can be removed?\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n|S| = N\n\nEach character in S is 0 or 1.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the maximum number of cubes that can be removed.\n\nSample Input 1\n\n0011\n\nSample Output 1\n\n4\n\nAll four cubes can be removed, by performing the operation as follows:\n\nRemove the second and third cubes from the bottom. Then, the fourth cube drops onto the first cube.\n\nRemove the first and second cubes from the bottom.\n\nSample Input 2\n\n11011010001011\n\nSample Output 2\n\n12\n\nSample Input 3\n\n0\n\nSample Output 3\n\n0", "sample_input": "0011\n"}, "reference_outputs": ["4\n"], "source_document_id": "p03107", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere are N cubes stacked vertically on a desk.\n\nYou are given a string S of length N. The color of the i-th cube from the bottom is red if the i-th character in S is 0, and blue if that character is 1.\n\nYou can perform the following operation any number of times: choose a red cube and a blue cube that are adjacent, and remove them. Here, the cubes that were stacked on the removed cubes will fall down onto the object below them.\n\nAt most how many cubes can be removed?\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n|S| = N\n\nEach character in S is 0 or 1.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the maximum number of cubes that can be removed.\n\nSample Input 1\n\n0011\n\nSample Output 1\n\n4\n\nAll four cubes can be removed, by performing the operation as follows:\n\nRemove the second and third cubes from the bottom. Then, the fourth cube drops onto the first cube.\n\nRemove the first and second cubes from the bottom.\n\nSample Input 2\n\n11011010001011\n\nSample Output 2\n\n12\n\nSample Input 3\n\n0\n\nSample Output 3\n\n0", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 332, "cpu_time_ms": 260, "memory_kb": 34284}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s957953128", "group_id": "codeNet:p03108", "input_text": "fun main(args: Array) {\n val (n, m) = readLine()!!.split(\" \").map { it.toInt() }\n val list = (1..m).map { readLine()!!.split(\" \").map { it.toInt() } }.reversed()\n\n val ans = mutableListOf()\n val uf = UnionFind(n)\n\n var cur = (n.toLong() * (n.toLong() - 1)) / 2\n\n for (ab in list) {\n ans.add(cur)\n\n val a = ab[0] - 1\n val b = ab[1] - 1\n\n if (uf.isSame(a, b)) {\n continue\n }\n\n val sizeA = uf.size(a)\n val sizeB = uf.size(b)\n cur -= sizeA * sizeB\n\n uf.merge(a, b)\n }\n\n ans.reversed().forEach{ println(it) }\n}\n\nprivate class UnionFind(n: Int) {\n val parent = Array(n) { -1 }\n\n fun root(x: Int): Int {\n return if (parent[x] < 0) {\n x\n } else {\n parent[x] = root(parent[x])\n parent[x]\n }\n }\n\n fun isSame(x: Int, y: Int): Boolean {\n return root(x) == root(y)\n }\n\n fun merge(x: Int, y: Int): Boolean {\n var xRoot = root(x)\n var yRoot = root(y)\n if (xRoot == yRoot) {\n return false\n }\n\n // merge technique\n if (parent[xRoot] > parent[yRoot]) {\n val tmp = yRoot\n yRoot = xRoot\n xRoot = tmp\n }\n\n parent[xRoot] += parent[yRoot];\n parent[yRoot] = xRoot\n return true\n }\n\n fun size(x: Int): Int {\n return -parent[root(x)]\n }\n}\n", "language": "Kotlin", "metadata": {"date": 1551807784, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03108.html", "problem_id": "p03108", "resource_group": "medium_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/Kotlin/s957953128.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s957953128", "user_id": "u367259152"}, "prompt_components": {"gold_output": "0\n0\n4\n5\n6\n", "input_to_evaluate": "fun main(args: Array) {\n val (n, m) = readLine()!!.split(\" \").map { it.toInt() }\n val list = (1..m).map { readLine()!!.split(\" \").map { it.toInt() } }.reversed()\n\n val ans = mutableListOf()\n val uf = UnionFind(n)\n\n var cur = (n.toLong() * (n.toLong() - 1)) / 2\n\n for (ab in list) {\n ans.add(cur)\n\n val a = ab[0] - 1\n val b = ab[1] - 1\n\n if (uf.isSame(a, b)) {\n continue\n }\n\n val sizeA = uf.size(a)\n val sizeB = uf.size(b)\n cur -= sizeA * sizeB\n\n uf.merge(a, b)\n }\n\n ans.reversed().forEach{ println(it) }\n}\n\nprivate class UnionFind(n: Int) {\n val parent = Array(n) { -1 }\n\n fun root(x: Int): Int {\n return if (parent[x] < 0) {\n x\n } else {\n parent[x] = root(parent[x])\n parent[x]\n }\n }\n\n fun isSame(x: Int, y: Int): Boolean {\n return root(x) == root(y)\n }\n\n fun merge(x: Int, y: Int): Boolean {\n var xRoot = root(x)\n var yRoot = root(y)\n if (xRoot == yRoot) {\n return false\n }\n\n // merge technique\n if (parent[xRoot] > parent[yRoot]) {\n val tmp = yRoot\n yRoot = xRoot\n xRoot = tmp\n }\n\n parent[xRoot] += parent[yRoot];\n parent[yRoot] = xRoot\n return true\n }\n\n fun size(x: Int): Int {\n return -parent[root(x)]\n }\n}\n", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1433, "cpu_time_ms": 1401, "memory_kb": 81708}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s972540335", "group_id": "codeNet:p03108", "input_text": "class Bridge(val a : Int, val b : Int)\nclass Island(var group : Int)\n\nfun moveGroup(s : MutableList, t : MutableList, lIsland : MutableList, group : Int){\n for(i in 0..(s.size - 1)){\n t.add(s[0])\n lIsland[s[0]].group = group\n s.removeAt(0)\n }\n}\n\nfun main(args: Array){\n val (n, m) = readLine()!!.split(\" \").map(String::toInt)\n var lIsland = mutableListOf()\n var lGroup : MutableList> = mutableListOf()\n for(i in 0..(n - 1)){\n lIsland.add(Island(i))\n val iLGroup = mutableListOf(i)\n lGroup.add(iLGroup)\n }\n var lBridge = mutableListOf()\n for(i in 0..(m - 1)){\n val(a, b) = readLine()!!.split(\" \").map(String::toInt)\n lBridge.add(Bridge(a - 1, b - 1))\n }\n var lRet = mutableListOf()\n lRet.add(n * (n - 1) / 2L)\n for(i in (m - 1) downTo 1){\n val groupA = lIsland[lBridge[i].a].group\n val groupB = lIsland[lBridge[i].b].group\n if(groupA == groupB){\n lRet.add(lRet[(m - 1) - i])\n }else{\n lRet.add(lRet[(m - 1) - i] - (lGroup[groupA].size * lGroup[groupB].size))\n if(lGroup[groupA].size >= lGroup[groupB].size) moveGroup(lGroup[groupB], lGroup[groupA], lIsland, groupA)\n else moveGroup(lGroup[groupA], lGroup[groupB], lIsland, groupB)\n }\n }\n for(i in (m - 1) downTo 0){\n println(lRet[i])\n }\n}", "language": "Kotlin", "metadata": {"date": 1551767829, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03108.html", "problem_id": "p03108", "resource_group": "medium_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/Kotlin/s972540335.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s972540335", "user_id": "u712822150"}, "prompt_components": {"gold_output": "0\n0\n4\n5\n6\n", "input_to_evaluate": "class Bridge(val a : Int, val b : Int)\nclass Island(var group : Int)\n\nfun moveGroup(s : MutableList, t : MutableList, lIsland : MutableList, group : Int){\n for(i in 0..(s.size - 1)){\n t.add(s[0])\n lIsland[s[0]].group = group\n s.removeAt(0)\n }\n}\n\nfun main(args: Array){\n val (n, m) = readLine()!!.split(\" \").map(String::toInt)\n var lIsland = mutableListOf()\n var lGroup : MutableList> = mutableListOf()\n for(i in 0..(n - 1)){\n lIsland.add(Island(i))\n val iLGroup = mutableListOf(i)\n lGroup.add(iLGroup)\n }\n var lBridge = mutableListOf()\n for(i in 0..(m - 1)){\n val(a, b) = readLine()!!.split(\" \").map(String::toInt)\n lBridge.add(Bridge(a - 1, b - 1))\n }\n var lRet = mutableListOf()\n lRet.add(n * (n - 1) / 2L)\n for(i in (m - 1) downTo 1){\n val groupA = lIsland[lBridge[i].a].group\n val groupB = lIsland[lBridge[i].b].group\n if(groupA == groupB){\n lRet.add(lRet[(m - 1) - i])\n }else{\n lRet.add(lRet[(m - 1) - i] - (lGroup[groupA].size * lGroup[groupB].size))\n if(lGroup[groupA].size >= lGroup[groupB].size) moveGroup(lGroup[groupB], lGroup[groupA], lIsland, groupA)\n else moveGroup(lGroup[groupA], lGroup[groupB], lIsland, groupB)\n }\n }\n for(i in (m - 1) downTo 0){\n println(lRet[i])\n }\n}", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1441, "cpu_time_ms": 1784, "memory_kb": 97964}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s205308502", "group_id": "codeNet:p03110", "input_text": "fun main(args: Array) {\n val N = readLine()!!.toInt()\n val x = (1..N).map{\n val v = readLine()!!.split(\" \").map{it.toString()}\n if(v.get(1) == \"JPY\") {\n v.get(0).toDouble()\n } else {\n v.get(0).toDouble() * 380000\n }\n }\n println(x.sum())\n}", "language": "Kotlin", "metadata": {"date": 1562174698, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03110.html", "problem_id": "p03110", "resource_group": "medium_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/Kotlin/s205308502.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s205308502", "user_id": "u169088512"}, "prompt_components": {"gold_output": "48000.0\n", "input_to_evaluate": "fun main(args: Array) {\n val N = readLine()!!.toInt()\n val x = (1..N).map{\n val v = readLine()!!.split(\" \").map{it.toString()}\n if(v.get(1) == \"JPY\") {\n v.get(0).toDouble()\n } else {\n v.get(0).toDouble() * 380000\n }\n }\n println(x.sum())\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 239, "memory_kb": 36104}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s035286848", "group_id": "codeNet:p03110", "input_text": "fun main(args: Array) {\n val giftNums = Integer.parseInt(readLine())\n\n var giftsPrice = 0.0\n for(i in 1..giftNums) {\n val inputs = readLine()?.split(\" \")!!\n var priceNum = inputs[0].toDouble()\n val type = inputs[1]\n if (type == \"BTC\") {\n priceNum *= 380000.0\n }\n giftsPrice+=priceNum\n }\n System.out.println(giftsPrice)\n}\n", "language": "Kotlin", "metadata": {"date": 1553903926, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03110.html", "problem_id": "p03110", "resource_group": "medium_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/Kotlin/s035286848.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s035286848", "user_id": "u631198699"}, "prompt_components": {"gold_output": "48000.0\n", "input_to_evaluate": "fun main(args: Array) {\n val giftNums = Integer.parseInt(readLine())\n\n var giftsPrice = 0.0\n for(i in 1..giftNums) {\n val inputs = readLine()?.split(\" \")!!\n var priceNum = inputs[0].toDouble()\n val type = inputs[1]\n if (type == \"BTC\") {\n priceNum *= 380000.0\n }\n giftsPrice+=priceNum\n }\n System.out.println(giftsPrice)\n}\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 397, "cpu_time_ms": 235, "memory_kb": 35968}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s506922658", "group_id": "codeNet:p03110", "input_text": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val n = sc.nextInt()\n\n var total: Long = 0\n val btc = 380000.0\n for (i in 0 until n) {\n val suji: Double = sc.nextDouble()\n val unit: String = sc.next()\n\n if (unit == \"JPY\") {\n total += suji.toLong()\n } else {\n total += (suji * btc).toLong()\n }\n }\n print(total)\n}", "language": "Kotlin", "metadata": {"date": 1551039440, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03110.html", "problem_id": "p03110", "resource_group": "medium_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/Kotlin/s506922658.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s506922658", "user_id": "u459956391"}, "prompt_components": {"gold_output": "48000.0\n", "input_to_evaluate": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val n = sc.nextInt()\n\n var total: Long = 0\n val btc = 380000.0\n for (i in 0 until n) {\n val suji: Double = sc.nextDouble()\n val unit: String = sc.next()\n\n if (unit == \"JPY\") {\n total += suji.toLong()\n } else {\n total += (suji * btc).toLong()\n }\n }\n print(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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 425, "cpu_time_ms": 189, "memory_kb": 29476}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s922629073", "group_id": "codeNet:p03111", "input_text": "import java.io.PrintWriter\nimport java.util.*\nimport java.math.*\nimport java.lang.*\n\n\nval pw = PrintWriter(System.out)\nval MOD: Long = (1e+9 + 7).toLong()\n\nclass Dfs(val N: Int, val A: Int, val B: Int, val C: Int,\n val bamboos: List) {\n fun dfs(i: Int, a: Int, b: Int, c: Int): Int {\n if(i == N) {\n if(listOf(a, b, c).min()!! == 0) return 10000000\n else {\n val rtn = Math.abs(a-A) + Math.abs(b-B) + Math.abs(c-C) - 30\n return rtn\n }\n }\n else {\n val ret0 = dfs(i+1, a, b, c)\n val ret1 = dfs(i+1, a+bamboos[i], b, c) + 10\n val ret2 = dfs(i+1, a, b+bamboos[i], c) + 10\n val ret3 = dfs(i+1, a, b, c+bamboos[i]) + 10\n return listOf(ret0, ret1, ret2, ret3).min()!!\n }\n }\n}\n\nfun main(args: Array) {\n val (n, a, b, c) = readListOfInt()\n val bamboos = mutableListOf()\n for(i in 0 until n) {\n bamboos.add(readInt())\n }\n println(Int.MAX_VALUE)\n val mp = Dfs(n, a, b, c, bamboos).dfs(0, 0, 0, 0)\n println(mp)\n \n\n pw.flush()\n}\n\n/****** Decrared Functions and Data Structures ******/\n// IO\nfun read() = readLine()!!\nfun readInt() = read().toInt()\nfun readLong() = read().toLong()\nfun readDouble() = read().toDouble()\nfun readListOfString() = read().split(\" \")\nfun readListOfInt() = readListOfString().map { it.toInt() }\nfun readListOfLong() = readListOfString().map { it.toLong() }\nfun readListOfDouble() = readListOfString().map { it.toDouble() }\n\nfun Double.format(digits: Int) = String.format(\"%.${digits}f\", this)\n\nfun print(value: Any) { pw.print(value) }\nfun println(value : Any) { pw.println(value) }\n\nfun permutations(src: List): List> {\n if(src.size == 1) return listOf(src)\n val perms = mutableListOf>()\n val insertElement = src[0]\n permutations(src.drop(1)).forEach { perm ->\n for(i in 0..perm.size) {\n val newPerm = perm.toMutableList()\n newPerm.add(i, insertElement)\n perms.add(newPerm.toList())\n }\n }\n return perms\n}\n\n// return nCr, if you want nCr, please access v[n][r]\nfun combination(n: Long): List> {\n val v = (0..n).map { (0..n).map{0L}.toMutableList() }.toMutableList()\n for(i in 0 until v.size) {\n v[i][0] = 1L\n v[i][i] = 1L\n }\n for(i in 0 until v.size) {\n for(j in 1 until i) {\n v[i][j] = (v[i-1][j-1] + v[i-1][j] % MOD)\n }\n }\n val rtn = v.map { it.toList() }.toList()\n return rtn \n}\n\nfun gcd(a: Long, b: Long): Long = \nif(b != 0L) a else gcd(b, a % b)\n\nfun lcm(a: Long, b: Long) = \nif(b==0L) a else gcd(b, a % b)\n\nfun sumDigits(num_: Long): Long {\n var num = num_\n var rtn: Long = 0\n while(num != 0.toLong()) {\n val tmp = num % 10\n rtn += tmp\n num /= 10\n }\n return rtn\n}\n\n// Data Structures\nclass Stack(private var st: MutableList = mutableListOf()) {\n fun isEmpty() = st.isEmpty()\n fun top(): T = st.last()\n fun push(e: T) { st.add(e) }\n fun pop() { st = st.dropLast(1).toMutableList() }\n}\n\nclass Queue(private var que: MutableList = mutableListOf()) {\n fun isEmpty() = que.isEmpty()\n fun top(): T = que.first()\n fun push(e: T) { que.add(e) }\n fun pop() { que = que.drop(1).toMutableList() }\n}\n", "language": "Kotlin", "metadata": {"date": 1563459464, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03111.html", "problem_id": "p03111", "resource_group": "medium_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/Kotlin/s922629073.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s922629073", "user_id": "u026686258"}, "prompt_components": {"gold_output": "23\n", "input_to_evaluate": "import java.io.PrintWriter\nimport java.util.*\nimport java.math.*\nimport java.lang.*\n\n\nval pw = PrintWriter(System.out)\nval MOD: Long = (1e+9 + 7).toLong()\n\nclass Dfs(val N: Int, val A: Int, val B: Int, val C: Int,\n val bamboos: List) {\n fun dfs(i: Int, a: Int, b: Int, c: Int): Int {\n if(i == N) {\n if(listOf(a, b, c).min()!! == 0) return 10000000\n else {\n val rtn = Math.abs(a-A) + Math.abs(b-B) + Math.abs(c-C) - 30\n return rtn\n }\n }\n else {\n val ret0 = dfs(i+1, a, b, c)\n val ret1 = dfs(i+1, a+bamboos[i], b, c) + 10\n val ret2 = dfs(i+1, a, b+bamboos[i], c) + 10\n val ret3 = dfs(i+1, a, b, c+bamboos[i]) + 10\n return listOf(ret0, ret1, ret2, ret3).min()!!\n }\n }\n}\n\nfun main(args: Array) {\n val (n, a, b, c) = readListOfInt()\n val bamboos = mutableListOf()\n for(i in 0 until n) {\n bamboos.add(readInt())\n }\n println(Int.MAX_VALUE)\n val mp = Dfs(n, a, b, c, bamboos).dfs(0, 0, 0, 0)\n println(mp)\n \n\n pw.flush()\n}\n\n/****** Decrared Functions and Data Structures ******/\n// IO\nfun read() = readLine()!!\nfun readInt() = read().toInt()\nfun readLong() = read().toLong()\nfun readDouble() = read().toDouble()\nfun readListOfString() = read().split(\" \")\nfun readListOfInt() = readListOfString().map { it.toInt() }\nfun readListOfLong() = readListOfString().map { it.toLong() }\nfun readListOfDouble() = readListOfString().map { it.toDouble() }\n\nfun Double.format(digits: Int) = String.format(\"%.${digits}f\", this)\n\nfun print(value: Any) { pw.print(value) }\nfun println(value : Any) { pw.println(value) }\n\nfun permutations(src: List): List> {\n if(src.size == 1) return listOf(src)\n val perms = mutableListOf>()\n val insertElement = src[0]\n permutations(src.drop(1)).forEach { perm ->\n for(i in 0..perm.size) {\n val newPerm = perm.toMutableList()\n newPerm.add(i, insertElement)\n perms.add(newPerm.toList())\n }\n }\n return perms\n}\n\n// return nCr, if you want nCr, please access v[n][r]\nfun combination(n: Long): List> {\n val v = (0..n).map { (0..n).map{0L}.toMutableList() }.toMutableList()\n for(i in 0 until v.size) {\n v[i][0] = 1L\n v[i][i] = 1L\n }\n for(i in 0 until v.size) {\n for(j in 1 until i) {\n v[i][j] = (v[i-1][j-1] + v[i-1][j] % MOD)\n }\n }\n val rtn = v.map { it.toList() }.toList()\n return rtn \n}\n\nfun gcd(a: Long, b: Long): Long = \nif(b != 0L) a else gcd(b, a % b)\n\nfun lcm(a: Long, b: Long) = \nif(b==0L) a else gcd(b, a % b)\n\nfun sumDigits(num_: Long): Long {\n var num = num_\n var rtn: Long = 0\n while(num != 0.toLong()) {\n val tmp = num % 10\n rtn += tmp\n num /= 10\n }\n return rtn\n}\n\n// Data Structures\nclass Stack(private var st: MutableList = mutableListOf()) {\n fun isEmpty() = st.isEmpty()\n fun top(): T = st.last()\n fun push(e: T) { st.add(e) }\n fun pop() { st = st.dropLast(1).toMutableList() }\n}\n\nclass Queue(private var que: MutableList = mutableListOf()) {\n fun isEmpty() = que.isEmpty()\n fun top(): T = que.first()\n fun push(e: T) { que.add(e) }\n fun pop() { que = que.drop(1).toMutableList() }\n}\n", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 3349, "cpu_time_ms": 390, "memory_kb": 45388}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s517725357", "group_id": "codeNet:p03125", "input_text": "fun main(args: Array) {\n\n val (a, b) = readLine()!!.split(\" \").map(String::toInt)\n\n if (b % a == 0) {\n println(a + b)\n } else {\n println(b - a)\n }\n}", "language": "Kotlin", "metadata": {"date": 1565129931, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03125.html", "problem_id": "p03125", "resource_group": "medium_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/Kotlin/s517725357.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s517725357", "user_id": "u085288971"}, "prompt_components": {"gold_output": "16\n", "input_to_evaluate": "fun main(args: Array) {\n\n val (a, b) = readLine()!!.split(\" \").map(String::toInt)\n\n if (b % a == 0) {\n println(a + b)\n } else {\n println(b - a)\n }\n}", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 182, "cpu_time_ms": 239, "memory_kb": 37944}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s130278283", "group_id": "codeNet:p03125", "input_text": "fun main(args: Array) {\n val (a,b) = readLine()!!.split(' ').map(String::toInt)\n println(\n if (b % a == 0) a + b else b - a\n )\n}", "language": "Kotlin", "metadata": {"date": 1550369491, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03125.html", "problem_id": "p03125", "resource_group": "medium_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/Kotlin/s130278283.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s130278283", "user_id": "u166163326"}, "prompt_components": {"gold_output": "16\n", "input_to_evaluate": "fun main(args: Array) {\n val (a,b) = readLine()!!.split(' ').map(String::toInt)\n println(\n if (b % a == 0) a + b else b - a\n )\n}", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 236, "memory_kb": 38304}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s825949799", "group_id": "codeNet:p03126", "input_text": "fun main(args: Array) {\n val (n, m) = readLine()!!.split(' ').map(String::toInt)\n val argList = (1..n).map {\n val tmp = readLine()!!.split(' ')\n tmp.subList(1, tmp.lastIndex + 1).map(String::toInt)\n }\n val count = (1..m).filter { num ->\n argList.all { it.contains(num) }\n }.count()\n println(count)\n}", "language": "Kotlin", "metadata": {"date": 1550369577, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03126.html", "problem_id": "p03126", "resource_group": "medium_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/Kotlin/s825949799.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s825949799", "user_id": "u166163326"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "fun main(args: Array) {\n val (n, m) = readLine()!!.split(' ').map(String::toInt)\n val argList = (1..n).map {\n val tmp = readLine()!!.split(' ')\n tmp.subList(1, tmp.lastIndex + 1).map(String::toInt)\n }\n val count = (1..m).filter { num ->\n argList.all { it.contains(num) }\n }.count()\n println(count)\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 346, "cpu_time_ms": 254, "memory_kb": 38304}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s101272198", "group_id": "codeNet:p03127", "input_text": "fun main(args: Array) {\n val n = readInputLine()\n val aList = readInputLine().split(\" \").map { it.toLong() }\n \n var gcd = aList[0]\n \n for (a in aList) {\n gcd = if (gcd > a) gcd(gcd, a) else gcd(a, gcd)\n }\n\n println(gcd)\n}\n\nfun readInputLine(): String {\n return readLine()!!\n}\n\nfun gcd(a: Long, b: Long): Long {\n // a >= b とする\n if (b == 0L) {\n return a\n }\n return gcd(b, a % b)\n}\n", "language": "Kotlin", "metadata": {"date": 1562386598, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03127.html", "problem_id": "p03127", "resource_group": "medium_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/Kotlin/s101272198.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s101272198", "user_id": "u505558493"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "fun main(args: Array) {\n val n = readInputLine()\n val aList = readInputLine().split(\" \").map { it.toLong() }\n \n var gcd = aList[0]\n \n for (a in aList) {\n gcd = if (gcd > a) gcd(gcd, a) else gcd(a, gcd)\n }\n\n println(gcd)\n}\n\nfun readInputLine(): String {\n return readLine()!!\n}\n\nfun gcd(a: Long, b: Long): Long {\n // a >= b とする\n if (b == 0L) {\n return a\n }\n return gcd(b, a % b)\n}\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 485, "memory_kb": 51860}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s745034413", "group_id": "codeNet:p03129", "input_text": "import java.util.*\n\nfun main(args: Array){\n val sc:Scanner= Scanner(System.`in`)\n\n var N=sc.nextInt()\n var K=sc.nextInt()\n\n if((N+1)/2>=K) println(\"YES\")\n else println(\"NO\")\n}", "language": "Kotlin", "metadata": {"date": 1550118793, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03129.html", "problem_id": "p03129", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03129/input.txt", "sample_output_relpath": "derived/input_output/data/p03129/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03129/Kotlin/s745034413.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s745034413", "user_id": "u548877759"}, "prompt_components": {"gold_output": "YES\n", "input_to_evaluate": "import java.util.*\n\nfun main(args: Array){\n val sc:Scanner= Scanner(System.`in`)\n\n var N=sc.nextInt()\n var K=sc.nextInt()\n\n if((N+1)/2>=K) println(\"YES\")\n else println(\"NO\")\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nDetermine if we can choose K different integers between 1 and N (inclusive) so that no two of them differ by 1.\n\nConstraints\n\n1\\leq N,K\\leq 100\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\nIf we can choose K integers as above, print YES; otherwise, print NO.\n\nSample Input 1\n\n3 2\n\nSample Output 1\n\nYES\n\nWe can choose 1 and 3.\n\nSample Input 2\n\n5 5\n\nSample Output 2\n\nNO\n\nSample Input 3\n\n31 10\n\nSample Output 3\n\nYES\n\nSample Input 4\n\n10 90\n\nSample Output 4\n\nNO", "sample_input": "3 2\n"}, "reference_outputs": ["YES\n"], "source_document_id": "p03129", "source_text": "Score : 100 points\n\nProblem Statement\n\nDetermine if we can choose K different integers between 1 and N (inclusive) so that no two of them differ by 1.\n\nConstraints\n\n1\\leq N,K\\leq 100\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\nIf we can choose K integers as above, print YES; otherwise, print NO.\n\nSample Input 1\n\n3 2\n\nSample Output 1\n\nYES\n\nWe can choose 1 and 3.\n\nSample Input 2\n\n5 5\n\nSample Output 2\n\nNO\n\nSample Input 3\n\n31 10\n\nSample Output 3\n\nYES\n\nSample Input 4\n\n10 90\n\nSample Output 4\n\nNO", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 176, "memory_kb": 31012}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s266154568", "group_id": "codeNet:p03129", "input_text": "fun main(args: Array) {\n val (n, k) = readLine()!!.split(' ').map(String::toLong)\n if (Math.ceil(n.toDouble() / 2).toLong() >= k) {\n println(\"YES\")\n } else {\n println(\"NO\")\n }\n}\n", "language": "Kotlin", "metadata": {"date": 1549764270, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03129.html", "problem_id": "p03129", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03129/input.txt", "sample_output_relpath": "derived/input_output/data/p03129/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03129/Kotlin/s266154568.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s266154568", "user_id": "u099066216"}, "prompt_components": {"gold_output": "YES\n", "input_to_evaluate": "fun main(args: Array) {\n val (n, k) = readLine()!!.split(' ').map(String::toLong)\n if (Math.ceil(n.toDouble() / 2).toLong() >= k) {\n println(\"YES\")\n } else {\n println(\"NO\")\n }\n}\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nDetermine if we can choose K different integers between 1 and N (inclusive) so that no two of them differ by 1.\n\nConstraints\n\n1\\leq N,K\\leq 100\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\nIf we can choose K integers as above, print YES; otherwise, print NO.\n\nSample Input 1\n\n3 2\n\nSample Output 1\n\nYES\n\nWe can choose 1 and 3.\n\nSample Input 2\n\n5 5\n\nSample Output 2\n\nNO\n\nSample Input 3\n\n31 10\n\nSample Output 3\n\nYES\n\nSample Input 4\n\n10 90\n\nSample Output 4\n\nNO", "sample_input": "3 2\n"}, "reference_outputs": ["YES\n"], "source_document_id": "p03129", "source_text": "Score : 100 points\n\nProblem Statement\n\nDetermine if we can choose K different integers between 1 and N (inclusive) so that no two of them differ by 1.\n\nConstraints\n\n1\\leq N,K\\leq 100\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\nIf we can choose K integers as above, print YES; otherwise, print NO.\n\nSample Input 1\n\n3 2\n\nSample Output 1\n\nYES\n\nWe can choose 1 and 3.\n\nSample Input 2\n\n5 5\n\nSample Output 2\n\nNO\n\nSample Input 3\n\n31 10\n\nSample Output 3\n\nYES\n\nSample Input 4\n\n10 90\n\nSample Output 4\n\nNO", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 236, "memory_kb": 38440}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s447640692", "group_id": "codeNet:p03131", "input_text": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val k = sc.nextLong()\n val a = sc.nextLong()\n val b = sc.nextLong()\n\n val kMax = 1 + k\n\n val tmp = Math.max(0, (k-(a-1L))/2L)\n val tmpMax = 1 + a + (b-a) * tmp\n\n\n val max = Math.max(kMax, tmpMax)\n println(max)\n}", "language": "Kotlin", "metadata": {"date": 1595996552, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p03131.html", "problem_id": "p03131", "resource_group": "medium_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/Kotlin/s447640692.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s447640692", "user_id": "u323522006"}, "prompt_components": {"gold_output": "7\n", "input_to_evaluate": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val k = sc.nextLong()\n val a = sc.nextLong()\n val b = sc.nextLong()\n\n val kMax = 1 + k\n\n val tmp = Math.max(0, (k-(a-1L))/2L)\n val tmpMax = 1 + a + (b-a) * tmp\n\n\n val max = Math.max(kMax, tmpMax)\n println(max)\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 304, "cpu_time_ms": 127, "memory_kb": 36396}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s494154786", "group_id": "codeNet:p03131", "input_text": "fun main(args:Array){\n val(k,a,b)= readLine()!!.split(\" \").map{\n it.toLong()\n }\n if(a>=b-2){\n println(k+1)\n }\n else{\n if(k<=a){\n println(k+1)\n }\n else{\n if((k-a)%2==1L){\n println(((k-a)/2+1)*b-(k-a)/2*a)\n }\n else{\n println(((k-a)/2)*b-((k-a)/2-1)*a+1)\n }\n }\n }\n}\n", "language": "Kotlin", "metadata": {"date": 1580528852, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03131.html", "problem_id": "p03131", "resource_group": "medium_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/Kotlin/s494154786.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s494154786", "user_id": "u928536113"}, "prompt_components": {"gold_output": "7\n", "input_to_evaluate": "fun main(args:Array){\n val(k,a,b)= readLine()!!.split(\" \").map{\n it.toLong()\n }\n if(a>=b-2){\n println(k+1)\n }\n else{\n if(k<=a){\n println(k+1)\n }\n else{\n if((k-a)%2==1L){\n println(((k-a)/2+1)*b-(k-a)/2*a)\n }\n else{\n println(((k-a)/2)*b-((k-a)/2-1)*a+1)\n }\n }\n }\n}\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 237, "memory_kb": 37924}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s671523800", "group_id": "codeNet:p03135", "input_text": "\nfun main(args:Array) {\n val (T,X) = readLine()!!.split(\" \").map(String::toDouble)\n println(T/X) \n}\n\n", "language": "Kotlin", "metadata": {"date": 1549245699, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03135.html", "problem_id": "p03135", "resource_group": "medium_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/Kotlin/s671523800.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s671523800", "user_id": "u181807786"}, "prompt_components": {"gold_output": "2.6666666667\n", "input_to_evaluate": "\nfun main(args:Array) {\n val (T,X) = readLine()!!.split(\" \").map(String::toDouble)\n println(T/X) \n}\n\n", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 240, "memory_kb": 37788}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s067310616", "group_id": "codeNet:p03140", "input_text": "import java.io.PrintWriter\nimport java.util.*\nimport java.math.*\nimport java.lang.*\nimport kotlin.comparisons.*\n\nval pw = PrintWriter(System.out)\nval MOD: Long = (1e+9 + 7).toLong()\n\nfun main(args: Array) {\n val n =readInt() \n val a = read()\n val b = read()\n val c = read()\n\n var count = 0\n for(i in 0 until n) {\n val currentList = listOf(a[i], b[i], c[i]).distinct()\n count += when(currentList.size) {\n 1 -> 0\n 2 -> 1\n else -> 2\n }\n }\n println(count)\n pw.flush()\n}\n\n/****** Declared Functions and Data Structures ******/\n// IO\nfun read() = readLine()!!\nfun readInt() = read().toInt()\nfun readLong() = read().toLong()\nfun readDouble() = read().toDouble()\nfun readListOfString() = read().split(\" \")\nfun readListOfInt() = readListOfString().map { it.toInt() }\nfun readListOfLong() = readListOfString().map { it.toLong() }\nfun readListOfDouble() = readListOfString().map { it.toDouble() }\n\nfun Double.format(digits: Int) = String.format(\"%.${digits}f\", this)\nfun Float.format(digits: Int) = String.format(\"%.${digits}f\", this)\n\nfun print(value: Any) { pw.print(value) }\nfun println(value : Any) { pw.println(value) }\n\n\n// Extensions\nfun List.toBuckets(bucketKeys: List): Map {\n val buckets = bucketKeys.associate { t -> Pair(t, 0) }.toMutableMap()\n this.forEach { t ->\n buckets[t] = buckets[t]!! + 1\n }\n return buckets\n}\n\nfun Map.toMutableMap(): MutableMap = HashMap(this)\n\n// Util Functions\nfun permutations(src: List): List> {\n if(src.size == 1) return listOf(src)\n val perms = mutableListOf>()\n val insertElement = src[0]\n permutations(src.drop(1)).forEach { perm ->\n for(i in 0..perm.size) {\n val newPerm = perm.toMutableList()\n newPerm.add(i, insertElement)\n perms.add(newPerm.toList())\n }\n }\n return perms\n}\n\n// return nCr, if you want nCr, please access v[n][r]\nfun combinations(n: Long): List> {\n val v = (0..n).map { (0..n).map{0L}.toMutableList() }.toMutableList()\n for(i in 0 until v.size) {\n v[i][0] = 1L\n v[i][i] = 1L\n }\n for(i in 0 until v.size) {\n for(j in 1 until i) {\n v[i][j] = (v[i-1][j-1] + v[i-1][j]) % MOD\n }\n }\n return v.map { it.toList() }.toList()\n}\n\n// should be a >= b\nfun gcd(a: Long, b: Long): Long = \n if(b == 0L) a else gcd(b, a % b)\n\n// shoud be a >= b\nfun lcm(a: Long, b: Long): Long = \n a / gcd(a, b) * b\n\nfun sumDigits(num_: Long): Long {\n var num = num_\n var rtn: Long = 0\n while(num != 0.toLong()) {\n val tmp = num % 10\n rtn += tmp\n num /= 10\n }\n return rtn\n}\n\nfun isDecimal(v: Double): Boolean = ((v - Math.floor(v)) != 0.0)\n\n// Data Structures\nclass Stack(private var st: MutableList = mutableListOf()) {\n fun isEmpty() = st.isEmpty()\n fun top(): T = st.last()\n fun push(e: T) { st.add(e) }\n fun pop() { st = st.dropLast(1).toMutableList() }\n}\n\nclass Queue(private var que: MutableList = mutableListOf()) {\n fun isEmpty() = que.isEmpty()\n fun top(): T = que.first()\n fun push(e: T) { que.add(e) }\n fun pop() { que = que.drop(1).toMutableList() }\n}\n", "language": "Kotlin", "metadata": {"date": 1566841689, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03140.html", "problem_id": "p03140", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03140/input.txt", "sample_output_relpath": "derived/input_output/data/p03140/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03140/Kotlin/s067310616.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s067310616", "user_id": "u026686258"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "import java.io.PrintWriter\nimport java.util.*\nimport java.math.*\nimport java.lang.*\nimport kotlin.comparisons.*\n\nval pw = PrintWriter(System.out)\nval MOD: Long = (1e+9 + 7).toLong()\n\nfun main(args: Array) {\n val n =readInt() \n val a = read()\n val b = read()\n val c = read()\n\n var count = 0\n for(i in 0 until n) {\n val currentList = listOf(a[i], b[i], c[i]).distinct()\n count += when(currentList.size) {\n 1 -> 0\n 2 -> 1\n else -> 2\n }\n }\n println(count)\n pw.flush()\n}\n\n/****** Declared Functions and Data Structures ******/\n// IO\nfun read() = readLine()!!\nfun readInt() = read().toInt()\nfun readLong() = read().toLong()\nfun readDouble() = read().toDouble()\nfun readListOfString() = read().split(\" \")\nfun readListOfInt() = readListOfString().map { it.toInt() }\nfun readListOfLong() = readListOfString().map { it.toLong() }\nfun readListOfDouble() = readListOfString().map { it.toDouble() }\n\nfun Double.format(digits: Int) = String.format(\"%.${digits}f\", this)\nfun Float.format(digits: Int) = String.format(\"%.${digits}f\", this)\n\nfun print(value: Any) { pw.print(value) }\nfun println(value : Any) { pw.println(value) }\n\n\n// Extensions\nfun List.toBuckets(bucketKeys: List): Map {\n val buckets = bucketKeys.associate { t -> Pair(t, 0) }.toMutableMap()\n this.forEach { t ->\n buckets[t] = buckets[t]!! + 1\n }\n return buckets\n}\n\nfun Map.toMutableMap(): MutableMap = HashMap(this)\n\n// Util Functions\nfun permutations(src: List): List> {\n if(src.size == 1) return listOf(src)\n val perms = mutableListOf>()\n val insertElement = src[0]\n permutations(src.drop(1)).forEach { perm ->\n for(i in 0..perm.size) {\n val newPerm = perm.toMutableList()\n newPerm.add(i, insertElement)\n perms.add(newPerm.toList())\n }\n }\n return perms\n}\n\n// return nCr, if you want nCr, please access v[n][r]\nfun combinations(n: Long): List> {\n val v = (0..n).map { (0..n).map{0L}.toMutableList() }.toMutableList()\n for(i in 0 until v.size) {\n v[i][0] = 1L\n v[i][i] = 1L\n }\n for(i in 0 until v.size) {\n for(j in 1 until i) {\n v[i][j] = (v[i-1][j-1] + v[i-1][j]) % MOD\n }\n }\n return v.map { it.toList() }.toList()\n}\n\n// should be a >= b\nfun gcd(a: Long, b: Long): Long = \n if(b == 0L) a else gcd(b, a % b)\n\n// shoud be a >= b\nfun lcm(a: Long, b: Long): Long = \n a / gcd(a, b) * b\n\nfun sumDigits(num_: Long): Long {\n var num = num_\n var rtn: Long = 0\n while(num != 0.toLong()) {\n val tmp = num % 10\n rtn += tmp\n num /= 10\n }\n return rtn\n}\n\nfun isDecimal(v: Double): Boolean = ((v - Math.floor(v)) != 0.0)\n\n// Data Structures\nclass Stack(private var st: MutableList = mutableListOf()) {\n fun isEmpty() = st.isEmpty()\n fun top(): T = st.last()\n fun push(e: T) { st.add(e) }\n fun pop() { st = st.dropLast(1).toMutableList() }\n}\n\nclass Queue(private var que: MutableList = mutableListOf()) {\n fun isEmpty() = que.isEmpty()\n fun top(): T = que.first()\n fun push(e: T) { que.add(e) }\n fun pop() { que = que.drop(1).toMutableList() }\n}\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nYou are given three strings A, B and C. Each of these is a string of length N consisting of lowercase English letters.\n\nOur objective is to make all these three strings equal. For that, you can repeatedly perform the following operation:\n\nOperation: Choose one of the strings A, B and C, and specify an integer i between 1 and N (inclusive). Change the i-th character from the beginning of the chosen string to some other lowercase English letter.\n\nWhat is the minimum number of operations required to achieve the objective?\n\nConstraints\n\n1 \\leq N \\leq 100\n\nEach of the strings A, B and C is a string of length N.\n\nEach character in each of the strings A, B and C is a lowercase English letter.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA\nB\nC\n\nOutput\n\nPrint the minimum number of operations required.\n\nSample Input 1\n\n4\nwest\neast\nwait\n\nSample Output 1\n\n3\n\nIn this sample, initially A = west、B = east、C = wait. We can achieve the objective in the minimum number of operations by performing three operations as follows:\n\nChange the second character in A to a. A is now wast.\n\nChange the first character in B to w. B is now wast.\n\nChange the third character in C to s. C is now wast.\n\nSample Input 2\n\n9\ndifferent\ndifferent\ndifferent\n\nSample Output 2\n\n0\n\nIf A, B and C are already equal in the beginning, the number of operations required is 0.\n\nSample Input 3\n\n7\nzenkoku\ntouitsu\nprogram\n\nSample Output 3\n\n13", "sample_input": "4\nwest\neast\nwait\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03140", "source_text": "Score : 200 points\n\nProblem Statement\n\nYou are given three strings A, B and C. Each of these is a string of length N consisting of lowercase English letters.\n\nOur objective is to make all these three strings equal. For that, you can repeatedly perform the following operation:\n\nOperation: Choose one of the strings A, B and C, and specify an integer i between 1 and N (inclusive). Change the i-th character from the beginning of the chosen string to some other lowercase English letter.\n\nWhat is the minimum number of operations required to achieve the objective?\n\nConstraints\n\n1 \\leq N \\leq 100\n\nEach of the strings A, B and C is a string of length N.\n\nEach character in each of the strings A, B and C is a lowercase English letter.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA\nB\nC\n\nOutput\n\nPrint the minimum number of operations required.\n\nSample Input 1\n\n4\nwest\neast\nwait\n\nSample Output 1\n\n3\n\nIn this sample, initially A = west、B = east、C = wait. We can achieve the objective in the minimum number of operations by performing three operations as follows:\n\nChange the second character in A to a. A is now wast.\n\nChange the first character in B to w. B is now wast.\n\nChange the third character in C to s. C is now wast.\n\nSample Input 2\n\n9\ndifferent\ndifferent\ndifferent\n\nSample Output 2\n\n0\n\nIf A, B and C are already equal in the beginning, the number of operations required is 0.\n\nSample Input 3\n\n7\nzenkoku\ntouitsu\nprogram\n\nSample Output 3\n\n13", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 3267, "cpu_time_ms": 230, "memory_kb": 36016}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s403530917", "group_id": "codeNet:p03140", "input_text": "fun main(args: Array){\n val n = readLine()!!.toInt()\n val a = readLine()!!\n val b = readLine()!!\n val c = readLine()!!\n var cnt = 0\n for(i in 0..(n - 1)){\n if(a[i] != b[i]){\n cnt++\n if(b[i] != c[i] && c[i] != a[i]) cnt++\n }else if(b[i] != c[i] || c[i] != a[i]) cnt++\n }\n println(cnt)\n}", "language": "Kotlin", "metadata": {"date": 1553016622, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03140.html", "problem_id": "p03140", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03140/input.txt", "sample_output_relpath": "derived/input_output/data/p03140/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03140/Kotlin/s403530917.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s403530917", "user_id": "u712822150"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "fun main(args: Array){\n val n = readLine()!!.toInt()\n val a = readLine()!!\n val b = readLine()!!\n val c = readLine()!!\n var cnt = 0\n for(i in 0..(n - 1)){\n if(a[i] != b[i]){\n cnt++\n if(b[i] != c[i] && c[i] != a[i]) cnt++\n }else if(b[i] != c[i] || c[i] != a[i]) cnt++\n }\n println(cnt)\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nYou are given three strings A, B and C. Each of these is a string of length N consisting of lowercase English letters.\n\nOur objective is to make all these three strings equal. For that, you can repeatedly perform the following operation:\n\nOperation: Choose one of the strings A, B and C, and specify an integer i between 1 and N (inclusive). Change the i-th character from the beginning of the chosen string to some other lowercase English letter.\n\nWhat is the minimum number of operations required to achieve the objective?\n\nConstraints\n\n1 \\leq N \\leq 100\n\nEach of the strings A, B and C is a string of length N.\n\nEach character in each of the strings A, B and C is a lowercase English letter.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA\nB\nC\n\nOutput\n\nPrint the minimum number of operations required.\n\nSample Input 1\n\n4\nwest\neast\nwait\n\nSample Output 1\n\n3\n\nIn this sample, initially A = west、B = east、C = wait. We can achieve the objective in the minimum number of operations by performing three operations as follows:\n\nChange the second character in A to a. A is now wast.\n\nChange the first character in B to w. B is now wast.\n\nChange the third character in C to s. C is now wast.\n\nSample Input 2\n\n9\ndifferent\ndifferent\ndifferent\n\nSample Output 2\n\n0\n\nIf A, B and C are already equal in the beginning, the number of operations required is 0.\n\nSample Input 3\n\n7\nzenkoku\ntouitsu\nprogram\n\nSample Output 3\n\n13", "sample_input": "4\nwest\neast\nwait\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03140", "source_text": "Score : 200 points\n\nProblem Statement\n\nYou are given three strings A, B and C. Each of these is a string of length N consisting of lowercase English letters.\n\nOur objective is to make all these three strings equal. For that, you can repeatedly perform the following operation:\n\nOperation: Choose one of the strings A, B and C, and specify an integer i between 1 and N (inclusive). Change the i-th character from the beginning of the chosen string to some other lowercase English letter.\n\nWhat is the minimum number of operations required to achieve the objective?\n\nConstraints\n\n1 \\leq N \\leq 100\n\nEach of the strings A, B and C is a string of length N.\n\nEach character in each of the strings A, B and C is a lowercase English letter.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA\nB\nC\n\nOutput\n\nPrint the minimum number of operations required.\n\nSample Input 1\n\n4\nwest\neast\nwait\n\nSample Output 1\n\n3\n\nIn this sample, initially A = west、B = east、C = wait. We can achieve the objective in the minimum number of operations by performing three operations as follows:\n\nChange the second character in A to a. A is now wast.\n\nChange the first character in B to w. B is now wast.\n\nChange the third character in C to s. C is now wast.\n\nSample Input 2\n\n9\ndifferent\ndifferent\ndifferent\n\nSample Output 2\n\n0\n\nIf A, B and C are already equal in the beginning, the number of operations required is 0.\n\nSample Input 3\n\n7\nzenkoku\ntouitsu\nprogram\n\nSample Output 3\n\n13", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 204, "memory_kb": 31764}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s683320223", "group_id": "codeNet:p03146", "input_text": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val s = sc.nextInt()\n\n println(abc116b(s))\n}\n\nprivate fun abc116b(s: Int): Int {\n val set = mutableSetOf()\n set.add(s)\n\n var tmp = f(s)\n var count = 1\n while (!set.contains(tmp)) {\n set.add(tmp)\n tmp = f(tmp)\n count++\n }\n\n return count + 1\n}\n\nprivate fun f(n: Int): Int {\n if (n % 2 == 0) return n / 2\n\n return 3 * n + 1\n}\n", "language": "Kotlin", "metadata": {"date": 1590610002, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03146.html", "problem_id": "p03146", "resource_group": "medium_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/Kotlin/s683320223.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s683320223", "user_id": "u323522006"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val s = sc.nextInt()\n\n println(abc116b(s))\n}\n\nprivate fun abc116b(s: Int): Int {\n val set = mutableSetOf()\n set.add(s)\n\n var tmp = f(s)\n var count = 1\n while (!set.contains(tmp)) {\n set.add(tmp)\n tmp = f(tmp)\n count++\n }\n\n return count + 1\n}\n\nprivate fun f(n: Int): Int {\n if (n % 2 == 0) return n / 2\n\n return 3 * n + 1\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 433, "cpu_time_ms": 198, "memory_kb": 35564}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s418647735", "group_id": "codeNet:p03146", "input_text": "fun main(args: Array) {\n val s = readLine()!!.toInt()\n println(re(s, 1, ::f))\n}\n\nfun re(s: Int, n: Int, f: (Int) -> Int): Int {\n val k = f(s)\n if(k == 4) {\n return n + 1 + 3\n } else {\n return re(k, n + 1, f)\n }\n}\n\nfun f(n: Int): Int {\n if(n % 2 == 0) {\n return n / 2\n } else {\n return 3 * n + 1\n }\n}\n", "language": "Kotlin", "metadata": {"date": 1548969509, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03146.html", "problem_id": "p03146", "resource_group": "medium_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/Kotlin/s418647735.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s418647735", "user_id": "u660599622"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "fun main(args: Array) {\n val s = readLine()!!.toInt()\n println(re(s, 1, ::f))\n}\n\nfun re(s: Int, n: Int, f: (Int) -> Int): Int {\n val k = f(s)\n if(k == 4) {\n return n + 1 + 3\n } else {\n return re(k, n + 1, f)\n }\n}\n\nfun f(n: Int): Int {\n if(n % 2 == 0) {\n return n / 2\n } else {\n return 3 * n + 1\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 205, "memory_kb": 31520}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s794222656", "group_id": "codeNet:p03147", "input_text": "fun main(args: Array) {\n val n = readInt()\n val h = readIntList().toMutableList()\n\n var l = 0\n var r = 0\n var ans = 0\n\n while (true) {\n l = h.indexOfFirst { it != 0 }\n if (l == -1) {\n break\n }\n r = l + 1\n while (r < n && h[r] != 0) {\n r++\n }\n r--\n for (i in l..r) {\n h[i]--\n }\n ans++\n }\n println(ans)\n}\n\n// Tools\nfun readString() = readLine()!!\nfun readInt() = readLine()!!.toInt()\nfun readLong() = readLine()!!.toLong()\nfun readStringList() = readLine()!!.split(\" \")\nfun readIntList() = readLine()!!.split(\" \").map(String::toInt)", "language": "Kotlin", "metadata": {"date": 1596224491, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p03147.html", "problem_id": "p03147", "resource_group": "medium_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/Kotlin/s794222656.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s794222656", "user_id": "u697467902"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "fun main(args: Array) {\n val n = readInt()\n val h = readIntList().toMutableList()\n\n var l = 0\n var r = 0\n var ans = 0\n\n while (true) {\n l = h.indexOfFirst { it != 0 }\n if (l == -1) {\n break\n }\n r = l + 1\n while (r < n && h[r] != 0) {\n r++\n }\n r--\n for (i in l..r) {\n h[i]--\n }\n ans++\n }\n println(ans)\n}\n\n// Tools\nfun readString() = readLine()!!\nfun readInt() = readLine()!!.toInt()\nfun readLong() = readLine()!!.toLong()\nfun readStringList() = readLine()!!.split(\" \")\nfun readIntList() = readLine()!!.split(\" \").map(String::toInt)", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 665, "cpu_time_ms": 139, "memory_kb": 38168}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s483937470", "group_id": "codeNet:p03147", "input_text": "fun main(args: Array) {\n\n\n val n = readLine()!!.toInt()\n val hn = readLine()!!.split(\" \").map(String::toInt).toTypedArray()\n\n var count = 0\n hn.fold(0) { a, b ->\n if (b > a) {\n count += b - a\n }\n b\n }\n println(count)\n\n}", "language": "Kotlin", "metadata": {"date": 1570033923, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03147.html", "problem_id": "p03147", "resource_group": "medium_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/Kotlin/s483937470.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s483937470", "user_id": "u085288971"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "fun main(args: Array) {\n\n\n val n = readLine()!!.toInt()\n val hn = readLine()!!.split(\" \").map(String::toInt).toTypedArray()\n\n var count = 0\n hn.fold(0) { a, b ->\n if (b > a) {\n count += b - a\n }\n b\n }\n println(count)\n\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 241, "memory_kb": 37820}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s592353202", "group_id": "codeNet:p03150", "input_text": "fun main(args: Array) {\n val s = readLine()!!\n val keyence = \"keyence\"\n\n if (s.startsWith(keyence) || s.endsWith(keyence)) {\n println(\"YES\")\n return\n }\n\n for (i in (1..6)) {\n val head = keyence.substring(0, i)\n val tail = keyence.subSequence(i, keyence.length)\n\n if (s.startsWith(head) && s.endsWith(tail)) {\n println(\"YES\")\n return\n }\n }\n\n println(\"NO\")\n}", "language": "Kotlin", "metadata": {"date": 1547504286, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03150.html", "problem_id": "p03150", "resource_group": "medium_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/Kotlin/s592353202.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s592353202", "user_id": "u367259152"}, "prompt_components": {"gold_output": "YES\n", "input_to_evaluate": "fun main(args: Array) {\n val s = readLine()!!\n val keyence = \"keyence\"\n\n if (s.startsWith(keyence) || s.endsWith(keyence)) {\n println(\"YES\")\n return\n }\n\n for (i in (1..6)) {\n val head = keyence.substring(0, i)\n val tail = keyence.subSequence(i, keyence.length)\n\n if (s.startsWith(head) && s.endsWith(tail)) {\n println(\"YES\")\n return\n }\n }\n\n println(\"NO\")\n}", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 213, "memory_kb": 33608}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s287143791", "group_id": "codeNet:p03155", "input_text": "fun main(args: Array) {\n val n = readLine()!!.toInt()\n val h = readLine()!!.toInt()\n val w = readLine()!!.toInt()\n println((n - w + 1) * (n - h + 1))\n}\n", "language": "Kotlin", "metadata": {"date": 1547323311, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03155.html", "problem_id": "p03155", "resource_group": "medium_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/Kotlin/s287143791.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s287143791", "user_id": "u099066216"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "fun main(args: Array) {\n val n = readLine()!!.toInt()\n val h = readLine()!!.toInt()\n val w = readLine()!!.toInt()\n println((n - w + 1) * (n - h + 1))\n}\n", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 172, "cpu_time_ms": 241, "memory_kb": 29976}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s278036222", "group_id": "codeNet:p03156", "input_text": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val n = sc.nextInt()\n val a = sc.nextInt()\n val b = sc.nextInt()\n val p = (1..n).map {\n val P = sc.nextInt()\n when {\n P <= a -> \"A\"\n P <= b -> \"B\"\n else -> \"C\"\n }\n }\n val countA = p.count{it == \"A\"}\n val countB = p.count{it == \"B\"}\n val countC = p.count{it == \"C\"}\n println(Math.min(countA, Math.min(countB, countC)))\n}", "language": "Kotlin", "metadata": {"date": 1582976360, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03156.html", "problem_id": "p03156", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03156/input.txt", "sample_output_relpath": "derived/input_output/data/p03156/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03156/Kotlin/s278036222.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s278036222", "user_id": "u733811860"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val n = sc.nextInt()\n val a = sc.nextInt()\n val b = sc.nextInt()\n val p = (1..n).map {\n val P = sc.nextInt()\n when {\n P <= a -> \"A\"\n P <= b -> \"B\"\n else -> \"C\"\n }\n }\n val countA = p.count{it == \"A\"}\n val countB = p.count{it == \"B\"}\n val countC = p.count{it == \"C\"}\n println(Math.min(countA, Math.min(countB, countC)))\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nYou have written N problems to hold programming contests.\nThe i-th problem will have a score of P_i points if used in a contest.\n\nWith these problems, you would like to hold as many contests as possible under the following condition:\n\nA contest has three problems. The first problem has a score not greater than A points, the second has a score between A + 1 and B points (inclusive), and the third has a score not less than B + 1 points.\n\nThe same problem should not be used in multiple contests.\nAt most how many contests can be held?\n\nConstraints\n\n3 \\leq N \\leq 100\n\n1 \\leq P_i \\leq 20 (1 \\leq i \\leq N)\n\n1 \\leq A < B < 20\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA B\nP_1 P_2 ... P_N\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n7\n5 15\n1 10 16 2 7 20 12\n\nSample Output 1\n\n2\n\nTwo contests can be held by putting the first, second, third problems and the fourth, fifth, sixth problems together.\n\nSample Input 2\n\n8\n3 8\n5 5 5 10 10 10 15 20\n\nSample Output 2\n\n0\n\nNo contest can be held, because there is no problem with a score of A = 3 or less.\n\nSample Input 3\n\n3\n5 6\n5 6 10\n\nSample Output 3\n\n1", "sample_input": "7\n5 15\n1 10 16 2 7 20 12\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03156", "source_text": "Score : 200 points\n\nProblem Statement\n\nYou have written N problems to hold programming contests.\nThe i-th problem will have a score of P_i points if used in a contest.\n\nWith these problems, you would like to hold as many contests as possible under the following condition:\n\nA contest has three problems. The first problem has a score not greater than A points, the second has a score between A + 1 and B points (inclusive), and the third has a score not less than B + 1 points.\n\nThe same problem should not be used in multiple contests.\nAt most how many contests can be held?\n\nConstraints\n\n3 \\leq N \\leq 100\n\n1 \\leq P_i \\leq 20 (1 \\leq i \\leq N)\n\n1 \\leq A < B < 20\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA B\nP_1 P_2 ... P_N\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n7\n5 15\n1 10 16 2 7 20 12\n\nSample Output 1\n\n2\n\nTwo contests can be held by putting the first, second, third problems and the fourth, fifth, sixth problems together.\n\nSample Input 2\n\n8\n3 8\n5 5 5 10 10 10 15 20\n\nSample Output 2\n\n0\n\nNo contest can be held, because there is no problem with a score of A = 3 or less.\n\nSample Input 3\n\n3\n5 6\n5 6 10\n\nSample Output 3\n\n1", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 202, "memory_kb": 29476}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s108269611", "group_id": "codeNet:p03157", "input_text": "import java.io.*\nimport java.util.*\nimport java.lang.*\nimport java.lang.Math.*\n\n\ndata class Pos(val x: Int, val y: Int)\n\nclass GridBfs(val G: List) {\n val H = G.size\n val W = G[0].length\n private val dx = intArrayOf(0,1,0,-1)\n private val dy = intArrayOf(1,0,-1,0)\n\n val goalNum = Array(H){IntArray(W){0}}\n\n fun countGoals(SX: Int, SY: Int): Int {\n val que = ArrayDeque()\n que.addLast(Pos(SX, SY))\n val goal = Array(H){IntArray(W){0}}\n val vis = Array(H){BooleanArray(W){false}}\n while (que.isNotEmpty()) {\n val (x, y) = que.removeFirst()\n\n vis[x][y] = true\n\n for(i in dx.indices) {\n val nx = x + dx[i]; val ny = y + dy[i]\n if (nx<0 || H<=nx || ny<0 || W<=ny) {\n continue\n }\n if (G[nx][ny] == G[x][y]) {\n continue\n }\n\n if (G[nx][ny] == '.') {\n goal[nx][ny] = 1\n }\n\n if (!vis[nx][ny]) {\n que.push(Pos(nx, ny))\n }\n }\n }\n\n val res = goal.map{ it.sum() }.sum()\n\n for (i in 0 until H) {\n for (j in 0 until W) {\n if (vis[i][j]) goalNum[i][j] = res\n }\n }\n\n return res\n }\n}\n\nfun solve() {\n val (H, W) = rd.readListInt()\n val G = (0 until H).map { rd.readString() }\n\n val gbfs = GridBfs(G)\n\n val starts = ArrayList()\n for (i in 0 until H) {\n for (j in 0 until W) {\n if (G[i][j] == '#') {\n val up = if (i>0) G[i-1][j] else '#'\n val right = if (j0) {\n ans += gbfs.goalNum[s.x][s.y]\n } else {\n ans += gbfs.countGoals(s.x, s.y)\n }\n }\n\n println(ans)\n}\n\n\n//val rd = debug.Reader(\"etc\", \"aising2019\", \"c\", \"sample-1\")\nval rd = Reader()\n\n\nfun main(args: Array) {\n try {\n var exception: Throwable? = null\n val sth = Thread(null, SolveThread(), \"solveThread\", 128 * 1024 * 1024)\n sth.setUncaughtExceptionHandler { _, e -> exception = e }\n sth.start(); sth.join()\n if (exception != null) throw exception!! }\n catch (e: Exception) { throw e }\n finally { rd.close() }\n}\nconst val MOD = 1_000_000_007L; const val INF = Int.MAX_VALUE/2; const val LINF = Long.MAX_VALUE/2\nconst val EPS = 1e-9; fun DBLEQ(a: Double, b: Double): Boolean {return abs(a - b) < EPS}\ndata class IntPair(val first: Int, val second: Int)\ndata class To(val idx: Int, val cost: Long)\ntypealias ALI = ArrayList\nfun edge(V: Int): Array> { return Array(V){ArrayList()} }\nval errPrintln: (Any) -> Unit = { msg -> System.err.println(msg) }\nfun rAssert(exp: Boolean, lazyMsg: () -> String = {\"\"}) {\n if (!exp) { val msg = lazyMsg(); errPrintln(\"EAssert Error: $msg\"); throw Error(msg) }\n}\nfun tAssert(exp: Boolean, lazyMsg: () -> String = {\"\"}) {\n if (!exp) { val msg = lazyMsg(); errPrintln(\"TAssert Error: $msg\"); Thread.sleep(3000) }\n}\nclass SolveThread : Runnable {\n override fun run() { solve() }\n}\nclass Reader {\n private val br = BufferedReader(InputStreamReader(System.`in`))\n val readString: () -> String = { br.readLine() }\n val readInt: () -> Int = { br.readLine().toInt() }\n val readLong: () -> Long = { br.readLine().toLong() }\n val readIntArray: () -> IntArray = { br.readLine().split(' ').map { it.toInt() }.toIntArray() }\n val readLongArray: () -> LongArray = { br.readLine().split(' ').map { it.toLong() }.toLongArray() }\n val readListInt: () -> List = { br.readLine().split(' ').map { it.toInt() } }\n val readListLong: () -> List = { br.readLine().split(' ').map { it.toLong() } }\n val readListIntCol: (Int) -> List = { N -> (0 until N).map { readInt() } }\n val readListIntCols: (Int) -> List> = { N -> (0 until N).map { br.readLine().split(' ').map { it.toInt() } } }\n val readListLongCol: (Int) -> List = { N -> (0 until N).map { readLong() } }\n val readListLongCols: (Int) -> List> = { N -> (0 until N).map { br.readLine().split(' ').map { it.toLong() } } }\n val close: () -> Unit = { br.close() }\n protected fun finalize() { close() }\n}\n", "language": "Kotlin", "metadata": {"date": 1599564713, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p03157.html", "problem_id": "p03157", "resource_group": "medium_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/Kotlin/s108269611.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s108269611", "user_id": "u404244809"}, "prompt_components": {"gold_output": "10\n", "input_to_evaluate": "import java.io.*\nimport java.util.*\nimport java.lang.*\nimport java.lang.Math.*\n\n\ndata class Pos(val x: Int, val y: Int)\n\nclass GridBfs(val G: List) {\n val H = G.size\n val W = G[0].length\n private val dx = intArrayOf(0,1,0,-1)\n private val dy = intArrayOf(1,0,-1,0)\n\n val goalNum = Array(H){IntArray(W){0}}\n\n fun countGoals(SX: Int, SY: Int): Int {\n val que = ArrayDeque()\n que.addLast(Pos(SX, SY))\n val goal = Array(H){IntArray(W){0}}\n val vis = Array(H){BooleanArray(W){false}}\n while (que.isNotEmpty()) {\n val (x, y) = que.removeFirst()\n\n vis[x][y] = true\n\n for(i in dx.indices) {\n val nx = x + dx[i]; val ny = y + dy[i]\n if (nx<0 || H<=nx || ny<0 || W<=ny) {\n continue\n }\n if (G[nx][ny] == G[x][y]) {\n continue\n }\n\n if (G[nx][ny] == '.') {\n goal[nx][ny] = 1\n }\n\n if (!vis[nx][ny]) {\n que.push(Pos(nx, ny))\n }\n }\n }\n\n val res = goal.map{ it.sum() }.sum()\n\n for (i in 0 until H) {\n for (j in 0 until W) {\n if (vis[i][j]) goalNum[i][j] = res\n }\n }\n\n return res\n }\n}\n\nfun solve() {\n val (H, W) = rd.readListInt()\n val G = (0 until H).map { rd.readString() }\n\n val gbfs = GridBfs(G)\n\n val starts = ArrayList()\n for (i in 0 until H) {\n for (j in 0 until W) {\n if (G[i][j] == '#') {\n val up = if (i>0) G[i-1][j] else '#'\n val right = if (j0) {\n ans += gbfs.goalNum[s.x][s.y]\n } else {\n ans += gbfs.countGoals(s.x, s.y)\n }\n }\n\n println(ans)\n}\n\n\n//val rd = debug.Reader(\"etc\", \"aising2019\", \"c\", \"sample-1\")\nval rd = Reader()\n\n\nfun main(args: Array) {\n try {\n var exception: Throwable? = null\n val sth = Thread(null, SolveThread(), \"solveThread\", 128 * 1024 * 1024)\n sth.setUncaughtExceptionHandler { _, e -> exception = e }\n sth.start(); sth.join()\n if (exception != null) throw exception!! }\n catch (e: Exception) { throw e }\n finally { rd.close() }\n}\nconst val MOD = 1_000_000_007L; const val INF = Int.MAX_VALUE/2; const val LINF = Long.MAX_VALUE/2\nconst val EPS = 1e-9; fun DBLEQ(a: Double, b: Double): Boolean {return abs(a - b) < EPS}\ndata class IntPair(val first: Int, val second: Int)\ndata class To(val idx: Int, val cost: Long)\ntypealias ALI = ArrayList\nfun edge(V: Int): Array> { return Array(V){ArrayList()} }\nval errPrintln: (Any) -> Unit = { msg -> System.err.println(msg) }\nfun rAssert(exp: Boolean, lazyMsg: () -> String = {\"\"}) {\n if (!exp) { val msg = lazyMsg(); errPrintln(\"EAssert Error: $msg\"); throw Error(msg) }\n}\nfun tAssert(exp: Boolean, lazyMsg: () -> String = {\"\"}) {\n if (!exp) { val msg = lazyMsg(); errPrintln(\"TAssert Error: $msg\"); Thread.sleep(3000) }\n}\nclass SolveThread : Runnable {\n override fun run() { solve() }\n}\nclass Reader {\n private val br = BufferedReader(InputStreamReader(System.`in`))\n val readString: () -> String = { br.readLine() }\n val readInt: () -> Int = { br.readLine().toInt() }\n val readLong: () -> Long = { br.readLine().toLong() }\n val readIntArray: () -> IntArray = { br.readLine().split(' ').map { it.toInt() }.toIntArray() }\n val readLongArray: () -> LongArray = { br.readLine().split(' ').map { it.toLong() }.toLongArray() }\n val readListInt: () -> List = { br.readLine().split(' ').map { it.toInt() } }\n val readListLong: () -> List = { br.readLine().split(' ').map { it.toLong() } }\n val readListIntCol: (Int) -> List = { N -> (0 until N).map { readInt() } }\n val readListIntCols: (Int) -> List> = { N -> (0 until N).map { br.readLine().split(' ').map { it.toInt() } } }\n val readListLongCol: (Int) -> List = { N -> (0 until N).map { readLong() } }\n val readListLongCols: (Int) -> List> = { N -> (0 until N).map { br.readLine().split(' ').map { it.toLong() } } }\n val close: () -> Unit = { br.close() }\n protected fun finalize() { close() }\n}\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 4679, "cpu_time_ms": 2207, "memory_kb": 66548}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s873905401", "group_id": "codeNet:p03162", "input_text": "import java.util.*\n\nfun main(args: Array) {\n\n val sc = Scanner(System.`in`)\n val N = sc.nextInt()\n\n data class abc(val a:Long, val b:Long, val c:Long) {\n fun max() = Math.max(Math.max(a,b),c)\n }\n\n val DP = Array(N){abc(0L,0L,0L)}//abcを選んだ時の最大幸福度\n val a = sc.nextLong()\n val b = sc.nextLong()\n val c = sc.nextLong()\n DP[0] = abc(a,b,c)\n for (i in 1 until N) {\n val a = sc.nextLong() + Math.max(DP[i-1].b, DP[i-1].c)\n val b = sc.nextLong() + Math.max(DP[i-1].c, DP[i-1].a)\n val c = sc.nextLong() + Math.max(DP[i-1].a, DP[i-1].b)\n\n DP[i] = abc(a,b,c)\n }\n //for ((n,h) in DP) print(\"$n \")\n println(DP[N-1].max())\n}", "language": "Kotlin", "metadata": {"date": 1552985248, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03162.html", "problem_id": "p03162", "resource_group": "medium_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/Kotlin/s873905401.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s873905401", "user_id": "u043557308"}, "prompt_components": {"gold_output": "210\n", "input_to_evaluate": "import java.util.*\n\nfun main(args: Array) {\n\n val sc = Scanner(System.`in`)\n val N = sc.nextInt()\n\n data class abc(val a:Long, val b:Long, val c:Long) {\n fun max() = Math.max(Math.max(a,b),c)\n }\n\n val DP = Array(N){abc(0L,0L,0L)}//abcを選んだ時の最大幸福度\n val a = sc.nextLong()\n val b = sc.nextLong()\n val c = sc.nextLong()\n DP[0] = abc(a,b,c)\n for (i in 1 until N) {\n val a = sc.nextLong() + Math.max(DP[i-1].b, DP[i-1].c)\n val b = sc.nextLong() + Math.max(DP[i-1].c, DP[i-1].a)\n val c = sc.nextLong() + Math.max(DP[i-1].a, DP[i-1].b)\n\n DP[i] = abc(a,b,c)\n }\n //for ((n,h) in DP) print(\"$n \")\n println(DP[N-1].max())\n}", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 714, "cpu_time_ms": 658, "memory_kb": 118884}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s229781041", "group_id": "codeNet:p03164", "input_text": "fun main(args: Array) {\n\n var (N,W) = readLine()!!.split(\" \").map{it.toInt()}\n\n var maxVal = 1000000;\n\n var dp = Array(N){LongArray(maxVal+1){ Long.MAX_VALUE/2}}\n var w = IntArray(N)\n var v = IntArray(N)\n\n for(i in 0 until N){\n val(wi,vi) = readLine()!!.split(\" \").map{it.toInt()}\n w[i] = wi;\n v[i] = vi;\n }\n\n for(j in 0..v[0]){\n dp[0][j] = w[0].toLong()\n\n }\n var ans = 0;\n\n for(i in 1 until N){\n for(j in 0..maxVal){\n if(v[i] >= j) {\n dp[i][j] = Math.min(dp[i-1][j],w[i].toLong());\n } else {\n dp[i][j] = Math.min(dp[i-1][j],dp[i-1][j-v[i]] + w[i])\n }\n\n\n\n }\n\n }\n for(i in 0 until N){\n for(j in 0 until maxVal+1){\n //print(dp[i][j])\n //print(\" \")\n if(dp[i][j] <= W){\n ans = Math.max(ans,j)\n }\n }\n\n // println()\n }\n\n println(ans)\n\n}", "language": "Kotlin", "metadata": {"date": 1583531827, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03164.html", "problem_id": "p03164", "resource_group": "medium_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/Kotlin/s229781041.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s229781041", "user_id": "u579455624"}, "prompt_components": {"gold_output": "90\n", "input_to_evaluate": "fun main(args: Array) {\n\n var (N,W) = readLine()!!.split(\" \").map{it.toInt()}\n\n var maxVal = 1000000;\n\n var dp = Array(N){LongArray(maxVal+1){ Long.MAX_VALUE/2}}\n var w = IntArray(N)\n var v = IntArray(N)\n\n for(i in 0 until N){\n val(wi,vi) = readLine()!!.split(\" \").map{it.toInt()}\n w[i] = wi;\n v[i] = vi;\n }\n\n for(j in 0..v[0]){\n dp[0][j] = w[0].toLong()\n\n }\n var ans = 0;\n\n for(i in 1 until N){\n for(j in 0..maxVal){\n if(v[i] >= j) {\n dp[i][j] = Math.min(dp[i-1][j],w[i].toLong());\n } else {\n dp[i][j] = Math.min(dp[i-1][j],dp[i-1][j-v[i]] + w[i])\n }\n\n\n\n }\n\n }\n for(i in 0 until N){\n for(j in 0 until maxVal+1){\n //print(dp[i][j])\n //print(\" \")\n if(dp[i][j] <= W){\n ans = Math.max(ans,j)\n }\n }\n\n // println()\n }\n\n println(ans)\n\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 971, "cpu_time_ms": 470, "memory_kb": 279044}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s055269855", "group_id": "codeNet:p03164", "input_text": "fun main(args: Array) {\n\n var (N,W) = readLine()!!.split(\" \").map{it.toInt()}\n\n\n var dp = Array(N){LongArray(W+1){0}}\n var w = IntArray(N)\n var v = IntArray(N)\n\n for(i in 0 until N){\n val(wi,vi) = readLine()!!.split(\" \").map{it.toInt()}\n w[i] = wi;\n v[i] = vi;\n }\n\n for(j in 0..W){\n if(w[0] <= j){\n dp[0][j] = v[0].toLong()\n }\n }\n\n for(i in 1 until N){\n for(j in 0..W){\n if(w[i] > j) {\n dp[i][j] = dp[i-1][j]\n } else {\n dp[i][j] = Math.max(dp[i-1][j],dp[i-1][j-w[i]] + v[i])\n }\n }\n }\n\n println(dp[N-1][W])\n\n}\n", "language": "Kotlin", "metadata": {"date": 1583523401, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03164.html", "problem_id": "p03164", "resource_group": "medium_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/Kotlin/s055269855.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s055269855", "user_id": "u579455624"}, "prompt_components": {"gold_output": "90\n", "input_to_evaluate": "fun main(args: Array) {\n\n var (N,W) = readLine()!!.split(\" \").map{it.toInt()}\n\n\n var dp = Array(N){LongArray(W+1){0}}\n var w = IntArray(N)\n var v = IntArray(N)\n\n for(i in 0 until N){\n val(wi,vi) = readLine()!!.split(\" \").map{it.toInt()}\n w[i] = wi;\n v[i] = vi;\n }\n\n for(j in 0..W){\n if(w[0] <= j){\n dp[0][j] = v[0].toLong()\n }\n }\n\n for(i in 1 until N){\n for(j in 0..W){\n if(w[i] > j) {\n dp[i][j] = dp[i-1][j]\n } else {\n dp[i][j] = Math.max(dp[i-1][j],dp[i-1][j-w[i]] + v[i])\n }\n }\n }\n\n println(dp[N-1][W])\n\n}\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 268, "memory_kb": 53996}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s037334877", "group_id": "codeNet:p03167", "input_text": "import java.util.*\n\n\nfun countPath(matrix: Array, h: Int, w: Int): Int {\n val dp = Array(h) { IntArray(w) { -1 } }\n\n fun go(n: Int, m: Int): Int {\n if (n >= h || m >= w) return 0\n if (n == h - 1 || m == w - 1) return 1\n\n val result = if (dp[n][m] != -1) dp[n][m]\n else {\n when (matrix[n][m]) {\n '#' -> 0\n else -> {\n val r = go(n + 1, m)\n val d = go(n, m + 1)\n r + d\n }\n }\n }\n\n dp[n][m] = result\n return result\n }\n\n\n return (go(0, 0) - 1) % (1000000000 + 7)\n}\n\nfun main(args: Array) {\n val result = with(Scanner(System.`in`)) {\n val (h, w) = nextLine().split(' ').map { it.toInt() }\n\n val list = mutableListOf()\n\n for (i in 0 until h) {\n val row = nextLine()\n .toCharArray()\n\n list.add(row)\n }\n\n countPath(list.toTypedArray(), h, w)\n }\n\n println(result)\n}\n", "language": "Kotlin", "metadata": {"date": 1578523847, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03167.html", "problem_id": "p03167", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03167/input.txt", "sample_output_relpath": "derived/input_output/data/p03167/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03167/Kotlin/s037334877.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s037334877", "user_id": "u012823956"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "import java.util.*\n\n\nfun countPath(matrix: Array, h: Int, w: Int): Int {\n val dp = Array(h) { IntArray(w) { -1 } }\n\n fun go(n: Int, m: Int): Int {\n if (n >= h || m >= w) return 0\n if (n == h - 1 || m == w - 1) return 1\n\n val result = if (dp[n][m] != -1) dp[n][m]\n else {\n when (matrix[n][m]) {\n '#' -> 0\n else -> {\n val r = go(n + 1, m)\n val d = go(n, m + 1)\n r + d\n }\n }\n }\n\n dp[n][m] = result\n return result\n }\n\n\n return (go(0, 0) - 1) % (1000000000 + 7)\n}\n\nfun main(args: Array) {\n val result = with(Scanner(System.`in`)) {\n val (h, w) = nextLine().split(' ').map { it.toInt() }\n\n val list = mutableListOf()\n\n for (i in 0 until h) {\n val row = nextLine()\n .toCharArray()\n\n list.add(row)\n }\n\n countPath(list.toTypedArray(), h, w)\n }\n\n println(result)\n}\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nThere is a grid with H horizontal rows and W vertical columns.\nLet (i, j) denote the square at the i-th row from the top and the j-th column from the left.\n\nFor each i and j (1 \\leq i \\leq H, 1 \\leq j \\leq W), Square (i, j) is described by a character a_{i, j}.\nIf a_{i, j} is ., Square (i, j) is an empty square; if a_{i, j} is #, Square (i, j) is a wall square.\nIt is guaranteed that Squares (1, 1) and (H, W) are empty squares.\n\nTaro will start from Square (1, 1) and reach (H, W) by repeatedly moving right or down to an adjacent empty square.\n\nFind the number of Taro's paths from Square (1, 1) to (H, W).\nAs the answer can be extremely large, find the count modulo 10^9 + 7.\n\nConstraints\n\nH and W are integers.\n\n2 \\leq H, W \\leq 1000\n\na_{i, j} is . or #.\n\nSquares (1, 1) and (H, W) are empty squares.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\na_{1, 1}\\ldotsa_{1, W}\n:\na_{H, 1}\\ldotsa_{H, W}\n\nOutput\n\nPrint the number of Taro's paths from Square (1, 1) to (H, W), modulo 10^9 + 7.\n\nSample Input 1\n\n3 4\n...#\n.#..\n....\n\nSample Output 1\n\n3\n\nThere are three paths as follows:\n\nSample Input 2\n\n5 2\n..\n#.\n..\n.#\n..\n\nSample Output 2\n\n0\n\nThere may be no paths.\n\nSample Input 3\n\n5 5\n..#..\n.....\n#...#\n.....\n..#..\n\nSample Output 3\n\n24\n\nSample Input 4\n\n20 20\n....................\n....................\n....................\n....................\n....................\n....................\n....................\n....................\n....................\n....................\n....................\n....................\n....................\n....................\n....................\n....................\n....................\n....................\n....................\n....................\n\nSample Output 4\n\n345263555\n\nBe sure to print the count modulo 10^9 + 7.", "sample_input": "3 4\n...#\n.#..\n....\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03167", "source_text": "Score : 100 points\n\nProblem Statement\n\nThere is a grid with H horizontal rows and W vertical columns.\nLet (i, j) denote the square at the i-th row from the top and the j-th column from the left.\n\nFor each i and j (1 \\leq i \\leq H, 1 \\leq j \\leq W), Square (i, j) is described by a character a_{i, j}.\nIf a_{i, j} is ., Square (i, j) is an empty square; if a_{i, j} is #, Square (i, j) is a wall square.\nIt is guaranteed that Squares (1, 1) and (H, W) are empty squares.\n\nTaro will start from Square (1, 1) and reach (H, W) by repeatedly moving right or down to an adjacent empty square.\n\nFind the number of Taro's paths from Square (1, 1) to (H, W).\nAs the answer can be extremely large, find the count modulo 10^9 + 7.\n\nConstraints\n\nH and W are integers.\n\n2 \\leq H, W \\leq 1000\n\na_{i, j} is . or #.\n\nSquares (1, 1) and (H, W) are empty squares.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\na_{1, 1}\\ldotsa_{1, W}\n:\na_{H, 1}\\ldotsa_{H, W}\n\nOutput\n\nPrint the number of Taro's paths from Square (1, 1) to (H, W), modulo 10^9 + 7.\n\nSample Input 1\n\n3 4\n...#\n.#..\n....\n\nSample Output 1\n\n3\n\nThere are three paths as follows:\n\nSample Input 2\n\n5 2\n..\n#.\n..\n.#\n..\n\nSample Output 2\n\n0\n\nThere may be no paths.\n\nSample Input 3\n\n5 5\n..#..\n.....\n#...#\n.....\n..#..\n\nSample Output 3\n\n24\n\nSample Input 4\n\n20 20\n....................\n....................\n....................\n....................\n....................\n....................\n....................\n....................\n....................\n....................\n....................\n....................\n....................\n....................\n....................\n....................\n....................\n....................\n....................\n....................\n\nSample Output 4\n\n345263555\n\nBe sure to print the count modulo 10^9 + 7.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1057, "cpu_time_ms": 377, "memory_kb": 46324}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s470508202", "group_id": "codeNet:p03193", "input_text": "import java.math.BigInteger\n\nfun main(args: Array) {\n val (n, h, w) = readLine()!!.split(\" \").map { it.toInt() }\n println((1..n).count {\n val (a, b) = readLine()!!.split(\" \").map { it.toInt() }\n a >= h && b >= w\n })\n}", "language": "Kotlin", "metadata": {"date": 1584577328, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03193.html", "problem_id": "p03193", "resource_group": "medium_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/Kotlin/s470508202.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s470508202", "user_id": "u733811860"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import java.math.BigInteger\n\nfun main(args: Array) {\n val (n, h, w) = readLine()!!.split(\" \").map { it.toInt() }\n println((1..n).count {\n val (a, b) = readLine()!!.split(\" \").map { it.toInt() }\n a >= h && b >= w\n })\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 310, "memory_kb": 38192}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s295476686", "group_id": "codeNet:p03196", "input_text": "fun main(args: Array) {\n caddi2018c()\n}\n\nprivate fun primeFactorization(n: Long): Map {\n val factors = mutableMapOf()\n var temp = n\n var i = 2L\n while (i * i <= temp) {\n while (temp % i == 0L) {\n factors[i] = (factors[i] ?: 0) + 1\n temp /= i\n }\n i++\n }\n if (temp > 1) factors[temp] = 1\n return factors\n}\n\nfun caddi2018c() {\n val (n, p) = readLine()!!.split(\" \").map { it.toLong() }\n\n val primes = primeFactorization(p)\n\n val answer = primes\n .map { Math.max(1, Math.pow(it.key.toDouble(), (it.value / n).toDouble()).toLong()) }\n .fold(1L) { acc, l -> acc * l }\n\n println(answer)\n}\n", "language": "Kotlin", "metadata": {"date": 1574058078, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03196.html", "problem_id": "p03196", "resource_group": "medium_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/Kotlin/s295476686.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s295476686", "user_id": "u139478771"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "fun main(args: Array) {\n caddi2018c()\n}\n\nprivate fun primeFactorization(n: Long): Map {\n val factors = mutableMapOf()\n var temp = n\n var i = 2L\n while (i * i <= temp) {\n while (temp % i == 0L) {\n factors[i] = (factors[i] ?: 0) + 1\n temp /= i\n }\n i++\n }\n if (temp > 1) factors[temp] = 1\n return factors\n}\n\nfun caddi2018c() {\n val (n, p) = readLine()!!.split(\" \").map { it.toLong() }\n\n val primes = primeFactorization(p)\n\n val answer = primes\n .map { Math.max(1, Math.pow(it.key.toDouble(), (it.value / n).toDouble()).toLong()) }\n .fold(1L) { acc, l -> acc * l }\n\n println(answer)\n}\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 706, "cpu_time_ms": 249, "memory_kb": 37776}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s700032058", "group_id": "codeNet:p03196", "input_text": "fun main(args: Array) {\n caddi2018c()\n}\n\nfun caddi2018c() {\n val (n, p) = readLine()!!.split(\" \").map { it.toLong() }\n\n val primes = primeFactorization(p)\n\n var answer = 1L\n for (prime in primes) {\n for (i in 0 until prime.value / n) answer *= prime.key\n }\n\n println(answer)\n}\n\n//素因数分解\nprivate fun primeFactorization(n: Long): Map {\n val factors = mutableMapOf()\n var temp = n\n var i = 2L\n while (i * i <= temp) {\n while (temp % i == 0L) {\n factors[i] = (factors[i] ?: 0) + 1\n temp /= i\n }\n i++\n }\n // 素数が残った場合、それも含めるように(1は素数でないので含めない)\n if (temp > 1) factors[temp] = 1\n return factors\n}\n", "language": "Kotlin", "metadata": {"date": 1574057577, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03196.html", "problem_id": "p03196", "resource_group": "medium_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/Kotlin/s700032058.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s700032058", "user_id": "u139478771"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "fun main(args: Array) {\n caddi2018c()\n}\n\nfun caddi2018c() {\n val (n, p) = readLine()!!.split(\" \").map { it.toLong() }\n\n val primes = primeFactorization(p)\n\n var answer = 1L\n for (prime in primes) {\n for (i in 0 until prime.value / n) answer *= prime.key\n }\n\n println(answer)\n}\n\n//素因数分解\nprivate fun primeFactorization(n: Long): Map {\n val factors = mutableMapOf()\n var temp = n\n var i = 2L\n while (i * i <= temp) {\n while (temp % i == 0L) {\n factors[i] = (factors[i] ?: 0) + 1\n temp /= i\n }\n i++\n }\n // 素数が残った場合、それも含めるように(1は素数でないので含めない)\n if (temp > 1) factors[temp] = 1\n return factors\n}\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 784, "cpu_time_ms": 245, "memory_kb": 37896}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s170631592", "group_id": "codeNet:p03197", "input_text": "fun main() {\n val n = readLine()?.toInt() ?: return\n repeat(n) {\n val a = readLine()?.toLong() ?: return\n if(a % 2 == 1L){\n println(\"first\")\n return\n }\n }\n println(\"second\")\n}\n", "language": "Kotlin", "metadata": {"date": 1598131457, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p03197.html", "problem_id": "p03197", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03197/input.txt", "sample_output_relpath": "derived/input_output/data/p03197/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03197/Kotlin/s170631592.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s170631592", "user_id": "u979429407"}, "prompt_components": {"gold_output": "first\n", "input_to_evaluate": "fun main() {\n val n = readLine()?.toInt() ?: return\n repeat(n) {\n val a = readLine()?.toLong() ?: return\n if(a % 2 == 1L){\n println(\"first\")\n return\n }\n }\n println(\"second\")\n}\n", "problem_context": "Score : 500 points\n\nProblem Statement\n\nThere is an apple tree that bears apples of N colors. The N colors of these apples are numbered 1 to N, and there are a_i apples of Color i.\n\nYou and Lunlun the dachshund alternately perform the following operation (starting from you):\n\nChoose one or more apples from the tree and eat them. Here, the apples chosen at the same time must all have different colors.\n\nThe one who eats the last apple from the tree will be declared winner. If both you and Lunlun play optimally, which will win?\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\na_2\n:\na_N\n\nOutput\n\nIf you will win, print first; if Lunlun will win, print second.\n\nSample Input 1\n\n2\n1\n2\n\nSample Output 1\n\nfirst\n\nLet Color 1 be red, and Color 2 be blue. In this case, the tree bears one red apple and two blue apples.\n\nYou should eat the red apple in your first turn. Lunlun is then forced to eat one of the blue apples, and you can win by eating the other in your next turn.\n\nNote that you are also allowed to eat two apples in your first turn, one red and one blue (not a winning move, though).\n\nSample Input 2\n\n3\n100000\n30000\n20000\n\nSample Output 2\n\nsecond", "sample_input": "2\n1\n2\n"}, "reference_outputs": ["first\n"], "source_document_id": "p03197", "source_text": "Score : 500 points\n\nProblem Statement\n\nThere is an apple tree that bears apples of N colors. The N colors of these apples are numbered 1 to N, and there are a_i apples of Color i.\n\nYou and Lunlun the dachshund alternately perform the following operation (starting from you):\n\nChoose one or more apples from the tree and eat them. Here, the apples chosen at the same time must all have different colors.\n\nThe one who eats the last apple from the tree will be declared winner. If both you and Lunlun play optimally, which will win?\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\na_2\n:\na_N\n\nOutput\n\nIf you will win, print first; if Lunlun will win, print second.\n\nSample Input 1\n\n2\n1\n2\n\nSample Output 1\n\nfirst\n\nLet Color 1 be red, and Color 2 be blue. In this case, the tree bears one red apple and two blue apples.\n\nYou should eat the red apple in your first turn. Lunlun is then forced to eat one of the blue apples, and you can win by eating the other in your next turn.\n\nNote that you are also allowed to eat two apples in your first turn, one red and one blue (not a winning move, though).\n\nSample Input 2\n\n3\n100000\n30000\n20000\n\nSample Output 2\n\nsecond", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 313, "memory_kb": 56512}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s049090271", "group_id": "codeNet:p03200", "input_text": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val s = sc.next()\n\n var count = 0L\n var ans = 0L\n\n for (c in s) {\n if (c == 'B') {\n count++\n } else {\n ans += count\n }\n }\n\n println(ans)\n}\n", "language": "Kotlin", "metadata": {"date": 1592670520, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p03200.html", "problem_id": "p03200", "resource_group": "medium_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/Kotlin/s049090271.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s049090271", "user_id": "u323522006"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val s = sc.next()\n\n var count = 0L\n var ans = 0L\n\n for (c in s) {\n if (c == 'B') {\n count++\n } else {\n ans += count\n }\n }\n\n println(ans)\n}\n", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 202, "memory_kb": 40960}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s134312815", "group_id": "codeNet:p03200", "input_text": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val s = sc.next()\n\n var count = 0\n val array = s.toCharArray()\n while (array.joinToString(\"\").contains(\"BW\")) {\n count += replace(array)\n }\n\n println(count)\n\n}\n\nprivate fun replace(s: CharArray): Int {\n val n = s.size\n var count = 0\n for (i in 0 until n - 1 ) {\n if (s[i] == 'B' && s[i+1] == 'W') {\n count++\n s[i] = 'W'\n s[i+1] = 'B'\n }\n }\n\n return count\n}\n", "language": "Kotlin", "metadata": {"date": 1592626577, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p03200.html", "problem_id": "p03200", "resource_group": "medium_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/Kotlin/s134312815.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s134312815", "user_id": "u323522006"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val s = sc.next()\n\n var count = 0\n val array = s.toCharArray()\n while (array.joinToString(\"\").contains(\"BW\")) {\n count += replace(array)\n }\n\n println(count)\n\n}\n\nprivate fun replace(s: CharArray): Int {\n val n = s.size\n var count = 0\n for (i in 0 until n - 1 ) {\n if (s[i] == 'B' && s[i+1] == 'W') {\n count++\n s[i] = 'W'\n s[i+1] = 'B'\n }\n }\n\n return count\n}\n", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 2208, "memory_kb": 63236}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s815555063", "group_id": "codeNet:p03200", "input_text": "fun a1(args: Array) {\n var bcnt = 0\n var ans = 0\n args[0].forEach {\n if (it == 'B') {\n bcnt++\n } else {\n ans += bcnt\n }\n }\n println(ans)\n}\n\nfun main(args: Array) {\n a1(readLineList())\n}\n\nfun readLineList(): Array {\n val lineList = mutableListOf()\n while (true) {\n val line = readLine()\n if (line.isNullOrBlank()) {\n break\n } else {\n lineList.add(line!!)\n }\n }\n return lineList.toTypedArray()\n}", "language": "Kotlin", "metadata": {"date": 1552348563, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03200.html", "problem_id": "p03200", "resource_group": "medium_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/Kotlin/s815555063.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s815555063", "user_id": "u241874341"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "fun a1(args: Array) {\n var bcnt = 0\n var ans = 0\n args[0].forEach {\n if (it == 'B') {\n bcnt++\n } else {\n ans += bcnt\n }\n }\n println(ans)\n}\n\nfun main(args: Array) {\n a1(readLineList())\n}\n\nfun readLineList(): Array {\n val lineList = mutableListOf()\n while (true) {\n val line = readLine()\n if (line.isNullOrBlank()) {\n break\n } else {\n lineList.add(line!!)\n }\n }\n return lineList.toTypedArray()\n}", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 548, "cpu_time_ms": 269, "memory_kb": 34564}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s155964929", "group_id": "codeNet:p03200", "input_text": "fun main(args: Array) {\n val s = readLine()!!.toCharArray()\n val pairs = s.mapIndexed { index, c -> Pair(index, c) }.filter { it.second == 'W' }\n\n print((0..(pairs.size - 1)).fold(0) {acc, i -> acc + pairs[i].first - i })\n}", "language": "Kotlin", "metadata": {"date": 1544928592, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03200.html", "problem_id": "p03200", "resource_group": "medium_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/Kotlin/s155964929.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s155964929", "user_id": "u349222099"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "fun main(args: Array) {\n val s = readLine()!!.toCharArray()\n val pairs = s.mapIndexed { index, c -> Pair(index, c) }.filter { it.second == 'W' }\n\n print((0..(pairs.size - 1)).fold(0) {acc, i -> acc + pairs[i].first - i })\n}", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 317, "memory_kb": 49224}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s723042424", "group_id": "codeNet:p03200", "input_text": "fun main(args: Array) {\n val s = readLine()!!\n var bCount = 0L\n var total = 0L\n for (c in s) {\n if (c == 'B') {\n bCount++\n } else {\n total += bCount\n }\n }\n println(total)\n}", "language": "Kotlin", "metadata": {"date": 1544925752, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03200.html", "problem_id": "p03200", "resource_group": "medium_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/Kotlin/s723042424.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s723042424", "user_id": "u099066216"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "fun main(args: Array) {\n val s = readLine()!!\n var bCount = 0L\n var total = 0L\n for (c in s) {\n if (c == 'B') {\n bCount++\n } else {\n total += bCount\n }\n }\n println(total)\n}", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 241, "cpu_time_ms": 272, "memory_kb": 34276}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s350539888", "group_id": "codeNet:p03208", "input_text": "fun main(args: Array) {\n\n val (n, k) = readLine()!!.split(\" \").map { it.toInt() }\n val h = (1..n).map { readLine()!!.toInt() }\n\n val selectedTree = h.sortedDescending().toTypedArray()\n\n var ans = Int.MAX_VALUE\n for (i in 0 .. n - k) {\n val max = selectedTree[i]\n val min = selectedTree[i + k - 1]\n\n if (max - min < ans) ans = max - min\n }\n\n println(ans)\n}", "language": "Kotlin", "metadata": {"date": 1564955636, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03208.html", "problem_id": "p03208", "resource_group": "medium_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/Kotlin/s350539888.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s350539888", "user_id": "u108272327"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "fun main(args: Array) {\n\n val (n, k) = readLine()!!.split(\" \").map { it.toInt() }\n val h = (1..n).map { readLine()!!.toInt() }\n\n val selectedTree = h.sortedDescending().toTypedArray()\n\n var ans = Int.MAX_VALUE\n for (i in 0 .. n - k) {\n val max = selectedTree[i]\n val min = selectedTree[i + k - 1]\n\n if (max - min < ans) ans = max - min\n }\n\n println(ans)\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 521, "memory_kb": 48492}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s211557092", "group_id": "codeNet:p03208", "input_text": "fun main(args: Array) {\n val (n,k) = readLine()!!.split(\" \").map { num ->num.toInt() }; \n val h = Array(n, {readLine()!!.toInt() })\n \n h.sort();\n var ret = h[h.size-1] - h[0];\n \n for (i in 0..n-k){\n \t val r = h[i + k - 1] - h[i];\n if(r < ret){\n ret = r;\n }\n }\n \n println(ret);\n}", "language": "Kotlin", "metadata": {"date": 1554660136, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03208.html", "problem_id": "p03208", "resource_group": "medium_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/Kotlin/s211557092.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s211557092", "user_id": "u099124596"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "fun main(args: Array) {\n val (n,k) = readLine()!!.split(\" \").map { num ->num.toInt() }; \n val h = Array(n, {readLine()!!.toInt() })\n \n h.sort();\n var ret = h[h.size-1] - h[0];\n \n for (i in 0..n-k){\n \t val r = h[i + k - 1] - h[i];\n if(r < ret){\n ret = r;\n }\n }\n \n println(ret);\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 332, "cpu_time_ms": 665, "memory_kb": 43952}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s168118424", "group_id": "codeNet:p03208", "input_text": "fun main(args : Array) {\n val (N, K) = readLine()!!.split(\" \").map { it.toInt() }\n val h = mutableListOf()\n (1..N).forEach {\n val num = readLine()!!.toLong()\n h.add(num)\n }\n\n val lastIndex = N - 1\n h.sort()\n val ans = (0..(lastIndex - K + 1)).map {\n val max = h[it + K - 1]\n val min = h[it]\n max - min\n }.min()\n\n println(ans)\n}", "language": "Kotlin", "metadata": {"date": 1546126443, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03208.html", "problem_id": "p03208", "resource_group": "medium_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/Kotlin/s168118424.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s168118424", "user_id": "u861095163"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "fun main(args : Array) {\n val (N, K) = readLine()!!.split(\" \").map { it.toInt() }\n val h = mutableListOf()\n (1..N).forEach {\n val num = readLine()!!.toLong()\n h.add(num)\n }\n\n val lastIndex = N - 1\n h.sort()\n val ans = (0..(lastIndex - K + 1)).map {\n val max = h[it + K - 1]\n val min = h[it]\n max - min\n }.min()\n\n println(ans)\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 403, "cpu_time_ms": 542, "memory_kb": 46016}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s043951728", "group_id": "codeNet:p03209", "input_text": "fun main(args: Array) {\n val (N, X) = readInputLine().split(\" \").map{it.toLong()}\n \n val a = LongArray(N.toInt() + 1)\n val p = LongArray(N.toInt() + 1)\n \n a[0] = 1L\n p[0] = 1L\n \n for (i in 1..N.toInt()) {\n a[i] = a[i - 1] * 2L + 3L\n p[i] = p[i - 1] * 2L + 1L\n }\n \n println(dfs(a, p, N.toInt(), X))\n}\n\nfun readInputLine(): String {\n return readLine()!!\n}\n\nfun dfs(a: LongArray, p: LongArray, N: Int, X: Long): Long {\n return when {\n X == 1L -> 0L\n 1L < X && X <= a[N - 1] + 1L -> dfs(a, p, N - 1, X - 1)\n X == a[N - 1] + 2L -> p[N - 1] + 1L\n a[N - 1] + 2L < X && X <= a[N - 1] * 2L + 2L -> p[N - 1] + 1L + dfs(a, p, N - 1, X - a[N - 1] - 2L)\n else -> p[N - 1] * 2L + 1L\n }\n}\n", "language": "Kotlin", "metadata": {"date": 1565410027, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03209.html", "problem_id": "p03209", "resource_group": "medium_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/Kotlin/s043951728.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s043951728", "user_id": "u505558493"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "fun main(args: Array) {\n val (N, X) = readInputLine().split(\" \").map{it.toLong()}\n \n val a = LongArray(N.toInt() + 1)\n val p = LongArray(N.toInt() + 1)\n \n a[0] = 1L\n p[0] = 1L\n \n for (i in 1..N.toInt()) {\n a[i] = a[i - 1] * 2L + 3L\n p[i] = p[i - 1] * 2L + 1L\n }\n \n println(dfs(a, p, N.toInt(), X))\n}\n\nfun readInputLine(): String {\n return readLine()!!\n}\n\nfun dfs(a: LongArray, p: LongArray, N: Int, X: Long): Long {\n return when {\n X == 1L -> 0L\n 1L < X && X <= a[N - 1] + 1L -> dfs(a, p, N - 1, X - 1)\n X == a[N - 1] + 2L -> p[N - 1] + 1L\n a[N - 1] + 2L < X && X <= a[N - 1] * 2L + 2L -> p[N - 1] + 1L + dfs(a, p, N - 1, X - a[N - 1] - 2L)\n else -> p[N - 1] * 2L + 1L\n }\n}\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 776, "cpu_time_ms": 238, "memory_kb": 37680}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s090282156", "group_id": "codeNet:p03209", "input_text": "fun burger_count(lv:Int):Pair{\n if(lv == 0){\n return Pair(1L, 1L);\n }\n val (patty,all) = burger_count(lv - 1);\n return Pair(patty * 2 + 1L, all * 2 + 3L);\n}\nfun eat_patty(lv:Int,remain_eat:Long):Pair{\n if (remain_eat == 0L){\n return Pair(0,0);\n }\n if(lv == 0){\n println(\"\" + lv +\"all\");\n return Pair(1,remain_eat-1);\n }\n else{\n if (remain_eat < 1){\n return Pair(0,0);\n }else{\n val (p,a) = burger_count(lv - 1);\n if(a * 2 < remain_eat - 3){\n return Pair(p * 2 + 1,remain_eat - 3 - (a * 2));\n }else if(a <= remain_eat - 2){\n val (peatedd,rd) = eat_patty(lv - 1,remain_eat - 2 - a);\n return Pair(p + peatedd + 1,rd);\n }else{\n return eat_patty(lv - 1,remain_eat - 1);\n }\n }\n } \n}\n\n\nfun main(args: Array) {\n val (n,x) = readLine()!!.split(\" \").map { num ->num.toLong() }; \n \n val (eat,all) = eat_patty(n.toInt(),x);\n \n println(eat);\n}", "language": "Kotlin", "metadata": {"date": 1554670041, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03209.html", "problem_id": "p03209", "resource_group": "medium_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/Kotlin/s090282156.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s090282156", "user_id": "u099124596"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "fun burger_count(lv:Int):Pair{\n if(lv == 0){\n return Pair(1L, 1L);\n }\n val (patty,all) = burger_count(lv - 1);\n return Pair(patty * 2 + 1L, all * 2 + 3L);\n}\nfun eat_patty(lv:Int,remain_eat:Long):Pair{\n if (remain_eat == 0L){\n return Pair(0,0);\n }\n if(lv == 0){\n println(\"\" + lv +\"all\");\n return Pair(1,remain_eat-1);\n }\n else{\n if (remain_eat < 1){\n return Pair(0,0);\n }else{\n val (p,a) = burger_count(lv - 1);\n if(a * 2 < remain_eat - 3){\n return Pair(p * 2 + 1,remain_eat - 3 - (a * 2));\n }else if(a <= remain_eat - 2){\n val (peatedd,rd) = eat_patty(lv - 1,remain_eat - 2 - a);\n return Pair(p + peatedd + 1,rd);\n }else{\n return eat_patty(lv - 1,remain_eat - 1);\n }\n }\n } \n}\n\n\nfun main(args: Array) {\n val (n,x) = readLine()!!.split(\" \").map { num ->num.toLong() }; \n \n val (eat,all) = eat_patty(n.toInt(),x);\n \n println(eat);\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 241, "memory_kb": 37960}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s329144021", "group_id": "codeNet:p03210", "input_text": "fun main(args: Array) {\n when (readLine()!!.toInt()) { 3, 5, 7 -> print(\"YES\"); else -> print(\"NO\") }\n}", "language": "Kotlin", "metadata": {"date": 1548455011, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03210.html", "problem_id": "p03210", "resource_group": "medium_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/Kotlin/s329144021.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s329144021", "user_id": "u384476909"}, "prompt_components": {"gold_output": "YES\n", "input_to_evaluate": "fun main(args: Array) {\n when (readLine()!!.toInt()) { 3, 5, 7 -> print(\"YES\"); else -> print(\"NO\") }\n}", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 206, "memory_kb": 31832}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s542796232", "group_id": "codeNet:p03214", "input_text": "fun no1(args: Array) {\n val numList = args[1].split(\" \").map { it.toInt() }\n val mean = numList.average()\n val diff = numList.map { Math.abs(it - mean) }\n val min = diff.min()\n println(diff.indexOfFirst{ it == min })\n}\n\nfun main(args: Array) {\n no1(readLineList())\n}\n\nfun readLineList(): Array {\n val lineList = mutableListOf()\n while (true) {\n val line = readLine()\n if (line.isNullOrBlank()) {\n break\n } else {\n lineList.add(line!!)\n }\n }\n return lineList.toTypedArray()\n}", "language": "Kotlin", "metadata": {"date": 1543107973, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03214.html", "problem_id": "p03214", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03214/input.txt", "sample_output_relpath": "derived/input_output/data/p03214/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03214/Kotlin/s542796232.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s542796232", "user_id": "u227166381"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "fun no1(args: Array) {\n val numList = args[1].split(\" \").map { it.toInt() }\n val mean = numList.average()\n val diff = numList.map { Math.abs(it - mean) }\n val min = diff.min()\n println(diff.indexOfFirst{ it == min })\n}\n\nfun main(args: Array) {\n no1(readLineList())\n}\n\nfun readLineList(): Array {\n val lineList = mutableListOf()\n while (true) {\n val line = readLine()\n if (line.isNullOrBlank()) {\n break\n } else {\n lineList.add(line!!)\n }\n }\n return lineList.toTypedArray()\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nNiwango-kun is an employee of Dwango Co., Ltd.\n\nOne day, he is asked to generate a thumbnail from a video a user submitted.\n\nTo generate a thumbnail, he needs to select a frame of the video according to the following procedure:\n\nGet an integer N and N integers a_0, a_1, ..., a_{N-1} as inputs. N denotes the number of the frames of the video, and each a_i denotes the representation of the i-th frame of the video.\n\nSelect t-th frame whose representation a_t is nearest to the average of all frame representations.\n\nIf there are multiple such frames, select the frame with the smallest index.\n\nFind the index t of the frame he should select to generate a thumbnail.\n\nConstraints\n\n1 \\leq N \\leq 100\n\n1 \\leq a_i \\leq 100\n\nAll numbers given 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}\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n3\n1 2 3\n\nSample Output 1\n\n1\n\nSince the average of frame representations is 2, Niwango-kun needs to select the index 1, whose representation is 2, that is, the nearest value to the average.\n\nSample Input 2\n\n4\n2 5 2 5\n\nSample Output 2\n\n0\n\nThe average of frame representations is 3.5.\n\nIn this case, every frame has the same distance from its representation to the average.\n\nTherefore, Niwango-kun should select index 0, the smallest index among them.", "sample_input": "3\n1 2 3\n"}, "reference_outputs": ["1\n"], "source_document_id": "p03214", "source_text": "Score : 200 points\n\nProblem Statement\n\nNiwango-kun is an employee of Dwango Co., Ltd.\n\nOne day, he is asked to generate a thumbnail from a video a user submitted.\n\nTo generate a thumbnail, he needs to select a frame of the video according to the following procedure:\n\nGet an integer N and N integers a_0, a_1, ..., a_{N-1} as inputs. N denotes the number of the frames of the video, and each a_i denotes the representation of the i-th frame of the video.\n\nSelect t-th frame whose representation a_t is nearest to the average of all frame representations.\n\nIf there are multiple such frames, select the frame with the smallest index.\n\nFind the index t of the frame he should select to generate a thumbnail.\n\nConstraints\n\n1 \\leq N \\leq 100\n\n1 \\leq a_i \\leq 100\n\nAll numbers given 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}\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n3\n1 2 3\n\nSample Output 1\n\n1\n\nSince the average of frame representations is 2, Niwango-kun needs to select the index 1, whose representation is 2, that is, the nearest value to the average.\n\nSample Input 2\n\n4\n2 5 2 5\n\nSample Output 2\n\n0\n\nThe average of frame representations is 3.5.\n\nIn this case, every frame has the same distance from its representation to the average.\n\nTherefore, Niwango-kun should select index 0, the smallest index among them.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 240, "memory_kb": 37904}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s979920236", "group_id": "codeNet:p03221", "input_text": "fun main(args : Array) {\n val (N, M) = readLine()!!.split(\" \").map { it.toInt() }\n val pAndY = mutableListOf>()\n (1..M).forEachIndexed { index, i ->\n val (p, y) = readLine()!!.split(\" \").map { it.toInt() }\n val pair = Triple(index, p.toString().padStart(6, '0'), y)\n pAndY.add(pair)\n }\n\n pAndY.sortBy { it.third }\n\n val nums: MutableList> = mutableListOf()\n val pToCountMap : MutableMap = mutableMapOf()\n pAndY.forEach {\n val index = it.first\n val p = it.second\n val preCount = pToCountMap.get(p)\n var count: Int\n if (preCount == null) {\n count = 0\n } else {\n count = preCount + 1\n }\n pToCountMap.set(p, count)\n\n val num = p + count.toString().padStart(6, '0')\n nums.add(Pair(index, num))\n }\n\n nums.sortBy { it.first }\n nums.forEach {\n println(it.second)\n }\n}", "language": "Kotlin", "metadata": {"date": 1541390042, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03221.html", "problem_id": "p03221", "resource_group": "medium_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/Kotlin/s979920236.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s979920236", "user_id": "u861095163"}, "prompt_components": {"gold_output": "000001000002\n000002000001\n000001000001\n", "input_to_evaluate": "fun main(args : Array) {\n val (N, M) = readLine()!!.split(\" \").map { it.toInt() }\n val pAndY = mutableListOf>()\n (1..M).forEachIndexed { index, i ->\n val (p, y) = readLine()!!.split(\" \").map { it.toInt() }\n val pair = Triple(index, p.toString().padStart(6, '0'), y)\n pAndY.add(pair)\n }\n\n pAndY.sortBy { it.third }\n\n val nums: MutableList> = mutableListOf()\n val pToCountMap : MutableMap = mutableMapOf()\n pAndY.forEach {\n val index = it.first\n val p = it.second\n val preCount = pToCountMap.get(p)\n var count: Int\n if (preCount == null) {\n count = 0\n } else {\n count = preCount + 1\n }\n pToCountMap.set(p, count)\n\n val num = p + count.toString().padStart(6, '0')\n nums.add(Pair(index, num))\n }\n\n nums.sortBy { it.first }\n nums.forEach {\n println(it.second)\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 2111, "memory_kb": 152776}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s165596317", "group_id": "codeNet:p03221", "input_text": "\nfun main(args : Array) {\n val (N, M) = readLine()!!.split(\" \").map { it.toInt() }\n val pAndY = mutableListOf>()\n (1..M).forEachIndexed { index, i ->\n val (p, y) = readLine()!!.split(\" \").map { it.toInt() }\n val pair = Triple(index, p, y)\n pAndY.add(pair)\n }\n\n pAndY.sortBy { it.third }\n\n val nums: MutableList> = mutableListOf()\n val pToCountMap : MutableMap = mutableMapOf()\n (1..N).map {\n val p = it\n pToCountMap.set(p, 0)\n }\n\n pAndY.forEach {\n val index = it.first\n val p = it.second\n val count = pToCountMap.get(p)!! + 1\n pToCountMap.set(p, count)\n\n val num = p.toString().padStart(6, '0') + count.toString().padStart(6, '0')\n nums.add(Pair(index, num))\n }\n\n nums.sortBy { it.first }\n nums.forEach {\n println(it.second)\n }\n}\n", "language": "Kotlin", "metadata": {"date": 1541389566, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03221.html", "problem_id": "p03221", "resource_group": "medium_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/Kotlin/s165596317.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s165596317", "user_id": "u861095163"}, "prompt_components": {"gold_output": "000001000002\n000002000001\n000001000001\n", "input_to_evaluate": "\nfun main(args : Array) {\n val (N, M) = readLine()!!.split(\" \").map { it.toInt() }\n val pAndY = mutableListOf>()\n (1..M).forEachIndexed { index, i ->\n val (p, y) = readLine()!!.split(\" \").map { it.toInt() }\n val pair = Triple(index, p, y)\n pAndY.add(pair)\n }\n\n pAndY.sortBy { it.third }\n\n val nums: MutableList> = mutableListOf()\n val pToCountMap : MutableMap = mutableMapOf()\n (1..N).map {\n val p = it\n pToCountMap.set(p, 0)\n }\n\n pAndY.forEach {\n val index = it.first\n val p = it.second\n val count = pToCountMap.get(p)!! + 1\n pToCountMap.set(p, count)\n\n val num = p.toString().padStart(6, '0') + count.toString().padStart(6, '0')\n nums.add(Pair(index, num))\n }\n\n nums.sortBy { it.first }\n nums.forEach {\n println(it.second)\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 914, "cpu_time_ms": 2110, "memory_kb": 145016}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s598691227", "group_id": "codeNet:p03221", "input_text": "private fun readInts() = readLine()!!.split(\" \").map { it.toInt() }\n\nfun main(args: Array) {\n val (N, M) = readInts()\n val pys = (0 until M).map { readInts() }\n\n val numbers = pys.mapIndexed { index, py -> CityNumber(py[0], py[1], index) }\n\n val inputtedRankMap = mutableMapOf()\n numbers\n .sortedBy { cityNumber -> cityNumber.pref * 10000 + cityNumber.year }\n .asSequence()\n .map { cityNumber ->\n cityNumber.copy(formatNumber = \"%06d\".format(cityNumber.pref) + \"%06d\".format(inputtedRankMap.getOrElse(cityNumber.pref, { 1 }).apply {\n inputtedRankMap[cityNumber.pref] = this + 1\n }))\n }\n .sortedBy { cityNumber -> cityNumber.inputRank }\n .forEach { cityNumber ->\n println(cityNumber.formatNumber)\n }\n}\n\nprivate data class CityNumber(\n val pref: Int,\n internal val year: Int,\n val inputRank: Int,\n var formatNumber: String = \"\"\n)", "language": "Kotlin", "metadata": {"date": 1541385748, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03221.html", "problem_id": "p03221", "resource_group": "medium_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/Kotlin/s598691227.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s598691227", "user_id": "u963316883"}, "prompt_components": {"gold_output": "000001000002\n000002000001\n000001000001\n", "input_to_evaluate": "private fun readInts() = readLine()!!.split(\" \").map { it.toInt() }\n\nfun main(args: Array) {\n val (N, M) = readInts()\n val pys = (0 until M).map { readInts() }\n\n val numbers = pys.mapIndexed { index, py -> CityNumber(py[0], py[1], index) }\n\n val inputtedRankMap = mutableMapOf()\n numbers\n .sortedBy { cityNumber -> cityNumber.pref * 10000 + cityNumber.year }\n .asSequence()\n .map { cityNumber ->\n cityNumber.copy(formatNumber = \"%06d\".format(cityNumber.pref) + \"%06d\".format(inputtedRankMap.getOrElse(cityNumber.pref, { 1 }).apply {\n inputtedRankMap[cityNumber.pref] = this + 1\n }))\n }\n .sortedBy { cityNumber -> cityNumber.inputRank }\n .forEach { cityNumber ->\n println(cityNumber.formatNumber)\n }\n}\n\nprivate data class CityNumber(\n val pref: Int,\n internal val year: Int,\n val inputRank: Int,\n var formatNumber: String = \"\"\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 2115, "memory_kb": 157824}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s460129066", "group_id": "codeNet:p03228", "input_text": "fun main(arr: Array) {\n val inpt = readLine()!!.split(\" \").map { it.toLong() }\n var ab = inpt.take(2).toMutableList()\n val k = inpt[2].toInt()\n for(i in (0 until k)) {\n val idx1 = i%2\n val idx2 = (idx1+1)%2\n\n if(ab[idx1]%2!=0L) {\n ab[idx1]--\n }\n ab[idx2] += ab[idx1]/2\n ab[idx1] = ab[idx1]/2\n }\n println(ab.joinToString(\" \"))\n}\n", "language": "Kotlin", "metadata": {"date": 1600622869, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p03228.html", "problem_id": "p03228", "resource_group": "medium_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/Kotlin/s460129066.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s460129066", "user_id": "u269969976"}, "prompt_components": {"gold_output": "5 3\n", "input_to_evaluate": "fun main(arr: Array) {\n val inpt = readLine()!!.split(\" \").map { it.toLong() }\n var ab = inpt.take(2).toMutableList()\n val k = inpt[2].toInt()\n for(i in (0 until k)) {\n val idx1 = i%2\n val idx2 = (idx1+1)%2\n\n if(ab[idx1]%2!=0L) {\n ab[idx1]--\n }\n ab[idx2] += ab[idx1]/2\n ab[idx1] = ab[idx1]/2\n }\n println(ab.joinToString(\" \"))\n}\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 407, "cpu_time_ms": 117, "memory_kb": 36460}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s129238427", "group_id": "codeNet:p03231", "input_text": "import java.util.*\nimport kotlin.math.acos\nimport kotlin.math.cos\nimport kotlin.math.round\nimport kotlin.math.sin\n\nfun main(args: Array) {\n val (n, m) = readIntList()\n val s = readString()\n val t = readString()\n\n val l = lcm(n.toLong(), m.toLong()).toInt()\n val tmp = mutableMapOf()\n s.forEachIndexed { index, c ->\n tmp[index * l / n + 1] = c\n }\n\n t.forEachIndexed { index, c ->\n if(tmp[index * l / m + 1]?.equals(c)?.not() == true) {\n println(-1)\n return\n }\n }\n println(l)\n}\n\n// read\nfun readString() = readLine()!!\nfun readInt() = readLine()!!.toInt()\nfun readLong() = readLine()!!.toLong()\nfun readStringList() = readLine()!!.split(\" \")\nfun readIntList() = readLine()!!.split(\" \").map(String::toInt)\nfun readLongList() = readLine()!!.split(\" \").map(String::toLong)\n\n\n// 最大公約数\nfun gcd(p: Long, q: Long): Long = if (p % q == 0L) q else gcd(q, p % q)\n\n// 最小公倍数\nfun lcm(p: Long, q: Long): Long = p / gcd(p, q) * q\n", "language": "Kotlin", "metadata": {"date": 1599446835, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p03231.html", "problem_id": "p03231", "resource_group": "medium_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/Kotlin/s129238427.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s129238427", "user_id": "u697467902"}, "prompt_components": {"gold_output": "6\n", "input_to_evaluate": "import java.util.*\nimport kotlin.math.acos\nimport kotlin.math.cos\nimport kotlin.math.round\nimport kotlin.math.sin\n\nfun main(args: Array) {\n val (n, m) = readIntList()\n val s = readString()\n val t = readString()\n\n val l = lcm(n.toLong(), m.toLong()).toInt()\n val tmp = mutableMapOf()\n s.forEachIndexed { index, c ->\n tmp[index * l / n + 1] = c\n }\n\n t.forEachIndexed { index, c ->\n if(tmp[index * l / m + 1]?.equals(c)?.not() == true) {\n println(-1)\n return\n }\n }\n println(l)\n}\n\n// read\nfun readString() = readLine()!!\nfun readInt() = readLine()!!.toInt()\nfun readLong() = readLine()!!.toLong()\nfun readStringList() = readLine()!!.split(\" \")\nfun readIntList() = readLine()!!.split(\" \").map(String::toInt)\nfun readLongList() = readLine()!!.split(\" \").map(String::toLong)\n\n\n// 最大公約数\nfun gcd(p: Long, q: Long): Long = if (p % q == 0L) q else gcd(q, p % q)\n\n// 最小公倍数\nfun lcm(p: Long, q: Long): Long = p / gcd(p, q) * q\n", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1025, "cpu_time_ms": 238, "memory_kb": 45748}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s167774290", "group_id": "codeNet:p03231", "input_text": "import java.io.BufferedReader\nimport java.io.InputStreamReader\nimport java.io.PrintWriter\nimport java.util.ArrayDeque\nimport kotlin.math.min\n\nval br = BufferedReader(InputStreamReader(System.`in`))\nval out = PrintWriter(System.out)\n\nfun main() {\n br.use { out.use {\n solve()\n out.flush()\n } }\n}\n\nfun solve() {\n val (n, m) = readIntegerList()\n val s = br.readLine()!!\n val t = br.readLine()!!\n\n val l = lcm(n.toLong(), m.toLong())\n val g = gcd(n.toLong(), m.toLong()).toInt()\n for (i in 0 until g) {\n if (s[i * n / g] != t[i * m / g]) {\n out.println(-1)\n return\n }\n }\n\n out.println(l)\n}\n\n/** O(log(n)): n = min(a, b) */\ntailrec fun gcd(a: Long, b: Long): Long = if (b == 0L) a else gcd(b, a % b)\n\n/** O(log(n)): n = min(a, b) */\nfun lcm(a: Long, b: Long)= a / gcd(a, b) * b\n\nfun readInteger() = Integer.parseInt(br.readLine())\nfun readLong() = java.lang.Long.parseLong(br.readLine())\nfun readStringList() = br.readLine()!!.split(' ')\nfun readIntegerList() = readStringList().map(Integer::parseInt)\nfun readLongList() = readStringList().map(java.lang.Long::parseLong)\nfun readDoubleList() = readStringList().map(java.lang.Double::parseDouble)\n", "language": "Kotlin", "metadata": {"date": 1595550003, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p03231.html", "problem_id": "p03231", "resource_group": "medium_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/Kotlin/s167774290.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s167774290", "user_id": "u784448849"}, "prompt_components": {"gold_output": "6\n", "input_to_evaluate": "import java.io.BufferedReader\nimport java.io.InputStreamReader\nimport java.io.PrintWriter\nimport java.util.ArrayDeque\nimport kotlin.math.min\n\nval br = BufferedReader(InputStreamReader(System.`in`))\nval out = PrintWriter(System.out)\n\nfun main() {\n br.use { out.use {\n solve()\n out.flush()\n } }\n}\n\nfun solve() {\n val (n, m) = readIntegerList()\n val s = br.readLine()!!\n val t = br.readLine()!!\n\n val l = lcm(n.toLong(), m.toLong())\n val g = gcd(n.toLong(), m.toLong()).toInt()\n for (i in 0 until g) {\n if (s[i * n / g] != t[i * m / g]) {\n out.println(-1)\n return\n }\n }\n\n out.println(l)\n}\n\n/** O(log(n)): n = min(a, b) */\ntailrec fun gcd(a: Long, b: Long): Long = if (b == 0L) a else gcd(b, a % b)\n\n/** O(log(n)): n = min(a, b) */\nfun lcm(a: Long, b: Long)= a / gcd(a, b) * b\n\nfun readInteger() = Integer.parseInt(br.readLine())\nfun readLong() = java.lang.Long.parseLong(br.readLine())\nfun readStringList() = br.readLine()!!.split(' ')\nfun readIntegerList() = readStringList().map(Integer::parseInt)\nfun readLongList() = readStringList().map(java.lang.Long::parseLong)\nfun readDoubleList() = readStringList().map(java.lang.Double::parseDouble)\n", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1221, "cpu_time_ms": 149, "memory_kb": 39820}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s242320193", "group_id": "codeNet:p03238", "input_text": "fun main(args: Array){\n val age = readLine()!!.toInt()\n\n when(age){\n 1 -> { ageIsOne() }\n 2 -> { ageIsTwo() }\n else -> throw\n IllegalArgumentException(\"1歳か2歳のみ許容します\")\n }\n \n}\n\nfun ageIsOne(){\n println(\"Hello World\")\n}\n\nfun ageIsTwo(){\n val num1 = readLine()!!.toInt()\n val num2 = readLine()!!.toInt()\n println(num1 + num2)\n}", "language": "Kotlin", "metadata": {"date": 1556783214, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03238.html", "problem_id": "p03238", "resource_group": "medium_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/Kotlin/s242320193.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s242320193", "user_id": "u165999673"}, "prompt_components": {"gold_output": "Hello World\n", "input_to_evaluate": "fun main(args: Array){\n val age = readLine()!!.toInt()\n\n when(age){\n 1 -> { ageIsOne() }\n 2 -> { ageIsTwo() }\n else -> throw\n IllegalArgumentException(\"1歳か2歳のみ許容します\")\n }\n \n}\n\nfun ageIsOne(){\n println(\"Hello World\")\n}\n\nfun ageIsTwo(){\n val num1 = readLine()!!.toInt()\n val num2 = readLine()!!.toInt()\n println(num1 + num2)\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 399, "cpu_time_ms": 207, "memory_kb": 31696}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s045407119", "group_id": "codeNet:p03238", "input_text": "import java.util.*\n\nobject MainKt {\n @JvmStatic\n fun main(args: Array) {\n val scanner = Scanner(System.`in`)\n val n = scanner.nextInt()\n\n when(n){\n 1 -> println(\"Hello World\")\n 2 -> {\n val a = scanner.nextInt()\n val b = scanner.nextInt()\n println(a+b)\n }\n }\n\n }\n}", "language": "Kotlin", "metadata": {"date": 1555716687, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03238.html", "problem_id": "p03238", "resource_group": "medium_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/Kotlin/s045407119.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s045407119", "user_id": "u914590612"}, "prompt_components": {"gold_output": "Hello World\n", "input_to_evaluate": "import java.util.*\n\nobject MainKt {\n @JvmStatic\n fun main(args: Array) {\n val scanner = Scanner(System.`in`)\n val n = scanner.nextInt()\n\n when(n){\n 1 -> println(\"Hello World\")\n 2 -> {\n val a = scanner.nextInt()\n val b = scanner.nextInt()\n println(a+b)\n }\n }\n\n }\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 182, "memory_kb": 31256}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s859391528", "group_id": "codeNet:p03238", "input_text": "fun main(args : Array) {\n val year = readLine()!!.toInt()\n\n if (year == 1) {\n println(\"Hello World\")\n return\n }\n\n val A = readLine()!!.toInt()\n val B = readLine()!!.toInt()\n println(A + B)\n}", "language": "Kotlin", "metadata": {"date": 1538874261, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03238.html", "problem_id": "p03238", "resource_group": "medium_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/Kotlin/s859391528.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s859391528", "user_id": "u861095163"}, "prompt_components": {"gold_output": "Hello World\n", "input_to_evaluate": "fun main(args : Array) {\n val year = readLine()!!.toInt()\n\n if (year == 1) {\n println(\"Hello World\")\n return\n }\n\n val A = readLine()!!.toInt()\n val B = readLine()!!.toInt()\n println(A + B)\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 292, "memory_kb": 31844}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s177225934", "group_id": "codeNet:p03239", "input_text": "import java.io.PrintWriter\nimport java.util.*\nimport java.math.*\nimport java.lang.*\nimport kotlin.comparisons.*\n\nval pw = PrintWriter(System.out)\nval MOD: Long = (1e+9 + 7).toLong()\n\ndata class Route(val c: Int, val t: Int)\nfun main(args: Array) {\n val (n, t) = readListOfInt()\n\n val routes = (0 until n).map {\n val (c, t) = readListOfInt()\n Route(c, t)\n }.filter { it.t <= t }.sortedBy { it.c }\n println(if(routes.isNotEmpty()) routes.first().c else \"TLE\")\n \n pw.flush()\n}\n\n/****** Declared Functions and Data Structures ******/\n// IO\nfun read() = readLine()!!\nfun readInt() = read().toInt()\nfun readLong() = read().toLong()\nfun readDouble() = read().toDouble()\nfun readListOfString() = read().split(\" \")\nfun readListOfInt() = readListOfString().map { it.toInt() }\nfun readListOfLong() = readListOfString().map { it.toLong() }\nfun readListOfDouble() = readListOfString().map { it.toDouble() }\n\nfun Double.format(digits: Int) = String.format(\"%.${digits}f\", this)\nfun Float.format(digits: Int) = String.format(\"%.${digits}f\", this)\n\nfun print(value: Any) { pw.print(value) }\nfun println(value : Any) { pw.println(value) }\n\n\n// Extensions\nfun List.toBuckets(bucketKeys: List): Map {\n val buckets = bucketKeys.associate { t -> Pair(t, 0) }.toMutableMap()\n this.forEach { t ->\n buckets[t] = buckets[t]!! + 1\n }\n return buckets\n}\n\nfun Map.toMutableMap(): MutableMap = HashMap(this)\n\n// Util Functions\nfun permutations(src: List): List> {\n if(src.size == 1) return listOf(src)\n val perms = mutableListOf>()\n val insertElement = src[0]\n permutations(src.drop(1)).forEach { perm ->\n for(i in 0..perm.size) {\n val newPerm = perm.toMutableList()\n newPerm.add(i, insertElement)\n perms.add(newPerm.toList())\n }\n }\n return perms\n}\n\n// return nCr, if you want nCr, please access v[n][r]\nfun combinations(n: Long): List> {\n val v = (0..n).map { (0..n).map{0L}.toMutableList() }.toMutableList()\n for(i in 0 until v.size) {\n v[i][0] = 1L\n v[i][i] = 1L\n }\n for(i in 0 until v.size) {\n for(j in 1 until i) {\n v[i][j] = (v[i-1][j-1] + v[i-1][j]) % MOD\n }\n }\n return v.map { it.toList() }.toList()\n}\n\n// should be a >= b\nfun gcd(a: Long, b: Long): Long = \n if(b == 0L) a else gcd(b, a % b)\n\n// shoud be a >= b\nfun lcm(a: Long, b: Long): Long = \n a / gcd(a, b) * b\n\nfun sumDigits(num_: Long): Long {\n var num = num_\n var rtn: Long = 0\n while(num != 0.toLong()) {\n val tmp = num % 10\n rtn += tmp\n num /= 10\n }\n return rtn\n}\n\nfun Double.isDecimal(): Boolean = ((this - Math.floor(this)) != 0.0)\n\n// Data Structures\nclass Stack(private var st: MutableList = mutableListOf()) {\n fun isEmpty() = st.isEmpty()\n fun top(): T = st.last()\n fun push(e: T) { st.add(e) }\n fun pop() { st = st.dropLast(1).toMutableList() }\n}\n\nclass Queue(private var que: MutableList = mutableListOf()) {\n fun isEmpty() = que.isEmpty()\n fun top(): T = que.first()\n fun push(e: T) { que.add(e) }\n fun pop() { que = que.drop(1).toMutableList() }\n}\n", "language": "Kotlin", "metadata": {"date": 1567307335, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03239.html", "problem_id": "p03239", "resource_group": "medium_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/Kotlin/s177225934.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s177225934", "user_id": "u026686258"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "import java.io.PrintWriter\nimport java.util.*\nimport java.math.*\nimport java.lang.*\nimport kotlin.comparisons.*\n\nval pw = PrintWriter(System.out)\nval MOD: Long = (1e+9 + 7).toLong()\n\ndata class Route(val c: Int, val t: Int)\nfun main(args: Array) {\n val (n, t) = readListOfInt()\n\n val routes = (0 until n).map {\n val (c, t) = readListOfInt()\n Route(c, t)\n }.filter { it.t <= t }.sortedBy { it.c }\n println(if(routes.isNotEmpty()) routes.first().c else \"TLE\")\n \n pw.flush()\n}\n\n/****** Declared Functions and Data Structures ******/\n// IO\nfun read() = readLine()!!\nfun readInt() = read().toInt()\nfun readLong() = read().toLong()\nfun readDouble() = read().toDouble()\nfun readListOfString() = read().split(\" \")\nfun readListOfInt() = readListOfString().map { it.toInt() }\nfun readListOfLong() = readListOfString().map { it.toLong() }\nfun readListOfDouble() = readListOfString().map { it.toDouble() }\n\nfun Double.format(digits: Int) = String.format(\"%.${digits}f\", this)\nfun Float.format(digits: Int) = String.format(\"%.${digits}f\", this)\n\nfun print(value: Any) { pw.print(value) }\nfun println(value : Any) { pw.println(value) }\n\n\n// Extensions\nfun List.toBuckets(bucketKeys: List): Map {\n val buckets = bucketKeys.associate { t -> Pair(t, 0) }.toMutableMap()\n this.forEach { t ->\n buckets[t] = buckets[t]!! + 1\n }\n return buckets\n}\n\nfun Map.toMutableMap(): MutableMap = HashMap(this)\n\n// Util Functions\nfun permutations(src: List): List> {\n if(src.size == 1) return listOf(src)\n val perms = mutableListOf>()\n val insertElement = src[0]\n permutations(src.drop(1)).forEach { perm ->\n for(i in 0..perm.size) {\n val newPerm = perm.toMutableList()\n newPerm.add(i, insertElement)\n perms.add(newPerm.toList())\n }\n }\n return perms\n}\n\n// return nCr, if you want nCr, please access v[n][r]\nfun combinations(n: Long): List> {\n val v = (0..n).map { (0..n).map{0L}.toMutableList() }.toMutableList()\n for(i in 0 until v.size) {\n v[i][0] = 1L\n v[i][i] = 1L\n }\n for(i in 0 until v.size) {\n for(j in 1 until i) {\n v[i][j] = (v[i-1][j-1] + v[i-1][j]) % MOD\n }\n }\n return v.map { it.toList() }.toList()\n}\n\n// should be a >= b\nfun gcd(a: Long, b: Long): Long = \n if(b == 0L) a else gcd(b, a % b)\n\n// shoud be a >= b\nfun lcm(a: Long, b: Long): Long = \n a / gcd(a, b) * b\n\nfun sumDigits(num_: Long): Long {\n var num = num_\n var rtn: Long = 0\n while(num != 0.toLong()) {\n val tmp = num % 10\n rtn += tmp\n num /= 10\n }\n return rtn\n}\n\nfun Double.isDecimal(): Boolean = ((this - Math.floor(this)) != 0.0)\n\n// Data Structures\nclass Stack(private var st: MutableList = mutableListOf()) {\n fun isEmpty() = st.isEmpty()\n fun top(): T = st.last()\n fun push(e: T) { st.add(e) }\n fun pop() { st = st.dropLast(1).toMutableList() }\n}\n\nclass Queue(private var que: MutableList = mutableListOf()) {\n fun isEmpty() = que.isEmpty()\n fun top(): T = que.first()\n fun push(e: T) { que.add(e) }\n fun pop() { que = que.drop(1).toMutableList() }\n}\n", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 3230, "cpu_time_ms": 252, "memory_kb": 36080}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s769398412", "group_id": "codeNet:p03239", "input_text": "fun main(args: Array) {\n val (N, T) = readLine()!!.split(' ').map { it.toInt() }\n val routes = (0 until N).map {\n val (c, t) = readLine()!!.split(' ').map { it.toInt() }\n Pair(c, t)\n }\n val min = routes.filter { it.second <= T }.map { it.first }.min()\n println(min ?: \"TLE\")\n}\n", "language": "Kotlin", "metadata": {"date": 1550723335, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03239.html", "problem_id": "p03239", "resource_group": "medium_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/Kotlin/s769398412.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s769398412", "user_id": "u863309603"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "fun main(args: Array) {\n val (N, T) = readLine()!!.split(' ').map { it.toInt() }\n val routes = (0 until N).map {\n val (c, t) = readLine()!!.split(' ').map { it.toInt() }\n Pair(c, t)\n }\n val min = routes.filter { it.second <= T }.map { it.first }.min()\n println(min ?: \"TLE\")\n}\n", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 314, "cpu_time_ms": 238, "memory_kb": 38176}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s812032336", "group_id": "codeNet:p03241", "input_text": "fun main(args: Array){\n val (n, m) = readLine()!!.split(\" \").map { it.toLong() }\n for (i in m downTo 0){\n if((m - i*(n-1)) % i == 0L && m - i*(n-1) > 0L){\n println(i)\n return\n }\n }\n}", "language": "Kotlin", "metadata": {"date": 1590024845, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03241.html", "problem_id": "p03241", "resource_group": "medium_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/Kotlin/s812032336.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s812032336", "user_id": "u531770859"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "fun main(args: Array){\n val (n, m) = readLine()!!.split(\" \").map { it.toLong() }\n for (i in m downTo 0){\n if((m - i*(n-1)) % i == 0L && m - i*(n-1) > 0L){\n println(i)\n return\n }\n }\n}", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 2111, "memory_kb": 38016}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s228567552", "group_id": "codeNet:p03241", "input_text": "fun main(args: Array){\n val (n, m) = readLine()!!.split(\" \").map { it.toLong() }\n for (i in 10000 downTo 0){\n if((m - i*(n-1)) % i == 0L && m - i*(n-1) > 0L){\n println(i)\n return\n }\n }\n}", "language": "Kotlin", "metadata": {"date": 1590024611, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03241.html", "problem_id": "p03241", "resource_group": "medium_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/Kotlin/s228567552.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s228567552", "user_id": "u531770859"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "fun main(args: Array){\n val (n, m) = readLine()!!.split(\" \").map { it.toLong() }\n for (i in 10000 downTo 0){\n if((m - i*(n-1)) % i == 0L && m - i*(n-1) > 0L){\n println(i)\n return\n }\n }\n}", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 239, "cpu_time_ms": 233, "memory_kb": 37832}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s226754945", "group_id": "codeNet:p03241", "input_text": "fun main(args: Array) {\n abc112d()\n}\n\nfun abc112d() {\n val (n, m) = readLine()!!.split(' ').map { it.toLong() }\n\n for (i in Math.sqrt(m.toDouble()).toLong() downTo 1) {\n if (m % i == 0L && (m / i) / n >= 1) return println(i)\n }\n}\n", "language": "Kotlin", "metadata": {"date": 1577163248, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03241.html", "problem_id": "p03241", "resource_group": "medium_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/Kotlin/s226754945.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s226754945", "user_id": "u139478771"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "fun main(args: Array) {\n abc112d()\n}\n\nfun abc112d() {\n val (n, m) = readLine()!!.split(' ').map { it.toLong() }\n\n for (i in Math.sqrt(m.toDouble()).toLong() downTo 1) {\n if (m % i == 0L && (m / i) / n >= 1) return println(i)\n }\n}\n", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 257, "cpu_time_ms": 248, "memory_kb": 38232}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s423503092", "group_id": "codeNet:p03241", "input_text": "fun max(x: Int, y: Int): Int {\n return if(x > y) x else y\n}\n\n\nfun main(args: Array) {\n val (N, M) = readLine()!!.split(\" \").map { it.toInt() }\n\n var ans = 1\n var d = 1\n\n while (d * d <= M) {\n if (M%d==0) {\n val e = M/d\n if (M/N >= d)\n ans = max(ans, d)\n if (M/N >= e)\n ans = max(ans, e)\n }\n d += 1\n }\n println(ans)\n}", "language": "Kotlin", "metadata": {"date": 1546145236, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03241.html", "problem_id": "p03241", "resource_group": "medium_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/Kotlin/s423503092.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s423503092", "user_id": "u185034753"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "fun max(x: Int, y: Int): Int {\n return if(x > y) x else y\n}\n\n\nfun main(args: Array) {\n val (N, M) = readLine()!!.split(\" \").map { it.toInt() }\n\n var ans = 1\n var d = 1\n\n while (d * d <= M) {\n if (M%d==0) {\n val e = M/d\n if (M/N >= d)\n ans = max(ans, d)\n if (M/N >= e)\n ans = max(ans, e)\n }\n d += 1\n }\n println(ans)\n}", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 429, "cpu_time_ms": 244, "memory_kb": 38052}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s983345453", "group_id": "codeNet:p03241", "input_text": "fun main(args: Array) {\n val (N, M) = readLine()!!.split(\" \").map { it.toInt() }\n for (i in (M / 2) downTo 2) {\n if (M % i != 0) continue\n if (M / i >= N) {\n println(i)\n return\n }\n }\n}", "language": "Kotlin", "metadata": {"date": 1538876917, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03241.html", "problem_id": "p03241", "resource_group": "medium_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/Kotlin/s983345453.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s983345453", "user_id": "u771276989"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "fun main(args: Array) {\n val (N, M) = readLine()!!.split(\" \").map { it.toInt() }\n for (i in (M / 2) downTo 2) {\n if (M % i != 0) continue\n if (M / i >= N) {\n println(i)\n return\n }\n }\n}", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 2086, "memory_kb": 37868}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s739630877", "group_id": "codeNet:p03244", "input_text": "import java.io.PrintWriter\n\nfun next() = readLine()!!\nfun nextInt() = next().toInt()\nfun nextLong() = next().toLong()\nfun nextDouble() = next().toDouble()\nfun nextList() = next().split(\" \")\nfun nextIntList() = nextList().map(String::toInt)\nfun nextLongList() = nextList().map(String::toLong)\nfun nextDoubleList() = nextList().map(String::toDouble)\n\nval pw = PrintWriter(System.out)\nfun print(s: Any = \"\") = pw.print(s)\nfun println(s: Any = \"\") = pw.println(s)\n\nfun main(args: Array) {\n main()\n pw.flush()\n}\n\nfun main() {\n val N = nextInt()\n val V = nextIntList()\n val A = IntArray(N / 2 + 1)\n val B = IntArray(N / 2 + 1)\n for (i in 0 until N / 2) {\n A[i] = V[i * 2]\n B[i] = V[i * 2 + 1]\n }\n A[N / 2] = 0\n B[N / 2] = 0\n val C = A.toCountMap().toList().sortedByDescending { it.second }\n val D = B.toCountMap().toList().sortedByDescending { it.second }\n val (i, j) = when {\n C[0].first != D[0].first -> Pair(0, 0)\n C[0].second + D[1].second > C[1].second + D[0].second -> Pair(0, 1)\n else -> Pair(1, 0)\n }\n println(C.map { it.second }.sum() + D.map { it.second }.sum() - C[i].second - D[j].second)\n}\n\nfun IntArray.toCountMap(): Map {\n return this.groupBy { it }.mapValues { if (it.key != 0) it.value.size.toLong() else 0 }\n}", "language": "Kotlin", "metadata": {"date": 1590720667, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03244.html", "problem_id": "p03244", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03244/input.txt", "sample_output_relpath": "derived/input_output/data/p03244/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03244/Kotlin/s739630877.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s739630877", "user_id": "u860789370"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "import java.io.PrintWriter\n\nfun next() = readLine()!!\nfun nextInt() = next().toInt()\nfun nextLong() = next().toLong()\nfun nextDouble() = next().toDouble()\nfun nextList() = next().split(\" \")\nfun nextIntList() = nextList().map(String::toInt)\nfun nextLongList() = nextList().map(String::toLong)\nfun nextDoubleList() = nextList().map(String::toDouble)\n\nval pw = PrintWriter(System.out)\nfun print(s: Any = \"\") = pw.print(s)\nfun println(s: Any = \"\") = pw.println(s)\n\nfun main(args: Array) {\n main()\n pw.flush()\n}\n\nfun main() {\n val N = nextInt()\n val V = nextIntList()\n val A = IntArray(N / 2 + 1)\n val B = IntArray(N / 2 + 1)\n for (i in 0 until N / 2) {\n A[i] = V[i * 2]\n B[i] = V[i * 2 + 1]\n }\n A[N / 2] = 0\n B[N / 2] = 0\n val C = A.toCountMap().toList().sortedByDescending { it.second }\n val D = B.toCountMap().toList().sortedByDescending { it.second }\n val (i, j) = when {\n C[0].first != D[0].first -> Pair(0, 0)\n C[0].second + D[1].second > C[1].second + D[0].second -> Pair(0, 1)\n else -> Pair(1, 0)\n }\n println(C.map { it.second }.sum() + D.map { it.second }.sum() - C[i].second - D[j].second)\n}\n\nfun IntArray.toCountMap(): Map {\n return this.groupBy { it }.mapValues { if (it.key != 0) it.value.size.toLong() else 0 }\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nA sequence a_1,a_2,... ,a_n is said to be /\\/\\/\\/ when the following conditions are satisfied:\n\nFor each i = 1,2,..., n-2, a_i = a_{i+2}.\n\nExactly two different numbers appear in the sequence.\n\nYou are given a sequence v_1,v_2,...,v_n whose length is even.\nWe would like to make this sequence /\\/\\/\\/ by replacing some of its elements.\nFind the minimum number of elements that needs to be replaced.\n\nConstraints\n\n2 \\leq n \\leq 10^5\n\nn is even.\n\n1 \\leq v_i \\leq 10^5\n\nv_i is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nn\nv_1 v_2 ... v_n\n\nOutput\n\nPrint the minimum number of elements that needs to be replaced.\n\nSample Input 1\n\n4\n3 1 3 2\n\nSample Output 1\n\n1\n\nThe sequence 3,1,3,2 is not /\\/\\/\\/, but we can make it /\\/\\/\\/ by replacing one of its elements: for example, replace the fourth element to make it 3,1,3,1.\n\nSample Input 2\n\n6\n105 119 105 119 105 119\n\nSample Output 2\n\n0\n\nThe sequence 105,119,105,119,105,119 is /\\/\\/\\/.\n\nSample Input 3\n\n4\n1 1 1 1\n\nSample Output 3\n\n2\n\nThe elements of the sequence 1,1,1,1 are all the same, so it is not /\\/\\/\\/.", "sample_input": "4\n3 1 3 2\n"}, "reference_outputs": ["1\n"], "source_document_id": "p03244", "source_text": "Score : 300 points\n\nProblem Statement\n\nA sequence a_1,a_2,... ,a_n is said to be /\\/\\/\\/ when the following conditions are satisfied:\n\nFor each i = 1,2,..., n-2, a_i = a_{i+2}.\n\nExactly two different numbers appear in the sequence.\n\nYou are given a sequence v_1,v_2,...,v_n whose length is even.\nWe would like to make this sequence /\\/\\/\\/ by replacing some of its elements.\nFind the minimum number of elements that needs to be replaced.\n\nConstraints\n\n2 \\leq n \\leq 10^5\n\nn is even.\n\n1 \\leq v_i \\leq 10^5\n\nv_i is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nn\nv_1 v_2 ... v_n\n\nOutput\n\nPrint the minimum number of elements that needs to be replaced.\n\nSample Input 1\n\n4\n3 1 3 2\n\nSample Output 1\n\n1\n\nThe sequence 3,1,3,2 is not /\\/\\/\\/, but we can make it /\\/\\/\\/ by replacing one of its elements: for example, replace the fourth element to make it 3,1,3,1.\n\nSample Input 2\n\n6\n105 119 105 119 105 119\n\nSample Output 2\n\n0\n\nThe sequence 105,119,105,119,105,119 is /\\/\\/\\/.\n\nSample Input 3\n\n4\n1 1 1 1\n\nSample Output 3\n\n2\n\nThe elements of the sequence 1,1,1,1 are all the same, so it is not /\\/\\/\\/.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1323, "cpu_time_ms": 936, "memory_kb": 85684}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s726305715", "group_id": "codeNet:p03244", "input_text": "fun main(args: Array){\n val n = readLine()!!.toInt()\n val v = readLine()!!.split(\" \").map { it.toInt() }\n if(v.all { it == v[0] }){\n println(n/2)\n return\n }\n\n val aOdd = mutableMapOf()\n val aEven = mutableMapOf()\n for(i in 1..n){\n val a = v[i-1]\n if(i % 2 == 0){\n if(aEven.containsKey(a)){\n aEven[a] = aEven[a]!! + 1\n }else{\n aEven[a] = 1\n }\n }\n if(i % 2 == 1){\n if(aOdd.containsKey(a)){\n aOdd[a] = aOdd[a]!! + 1\n }else{\n aOdd[a] = 1\n }\n }\n }\n\n val maxEven = if(aEven.keys.size == 1) n/2 else aEven.toList().maxBy { it.second }!!.first\n val maxOdd = if(aOdd.keys.size == 1) n/2 else aOdd.toList().maxBy { it.second }!!.first\n println(n - maxEven - maxOdd)\n}", "language": "Kotlin", "metadata": {"date": 1589506020, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03244.html", "problem_id": "p03244", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03244/input.txt", "sample_output_relpath": "derived/input_output/data/p03244/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03244/Kotlin/s726305715.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s726305715", "user_id": "u531770859"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "fun main(args: Array){\n val n = readLine()!!.toInt()\n val v = readLine()!!.split(\" \").map { it.toInt() }\n if(v.all { it == v[0] }){\n println(n/2)\n return\n }\n\n val aOdd = mutableMapOf()\n val aEven = mutableMapOf()\n for(i in 1..n){\n val a = v[i-1]\n if(i % 2 == 0){\n if(aEven.containsKey(a)){\n aEven[a] = aEven[a]!! + 1\n }else{\n aEven[a] = 1\n }\n }\n if(i % 2 == 1){\n if(aOdd.containsKey(a)){\n aOdd[a] = aOdd[a]!! + 1\n }else{\n aOdd[a] = 1\n }\n }\n }\n\n val maxEven = if(aEven.keys.size == 1) n/2 else aEven.toList().maxBy { it.second }!!.first\n val maxOdd = if(aOdd.keys.size == 1) n/2 else aOdd.toList().maxBy { it.second }!!.first\n println(n - maxEven - maxOdd)\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nA sequence a_1,a_2,... ,a_n is said to be /\\/\\/\\/ when the following conditions are satisfied:\n\nFor each i = 1,2,..., n-2, a_i = a_{i+2}.\n\nExactly two different numbers appear in the sequence.\n\nYou are given a sequence v_1,v_2,...,v_n whose length is even.\nWe would like to make this sequence /\\/\\/\\/ by replacing some of its elements.\nFind the minimum number of elements that needs to be replaced.\n\nConstraints\n\n2 \\leq n \\leq 10^5\n\nn is even.\n\n1 \\leq v_i \\leq 10^5\n\nv_i is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nn\nv_1 v_2 ... v_n\n\nOutput\n\nPrint the minimum number of elements that needs to be replaced.\n\nSample Input 1\n\n4\n3 1 3 2\n\nSample Output 1\n\n1\n\nThe sequence 3,1,3,2 is not /\\/\\/\\/, but we can make it /\\/\\/\\/ by replacing one of its elements: for example, replace the fourth element to make it 3,1,3,1.\n\nSample Input 2\n\n6\n105 119 105 119 105 119\n\nSample Output 2\n\n0\n\nThe sequence 105,119,105,119,105,119 is /\\/\\/\\/.\n\nSample Input 3\n\n4\n1 1 1 1\n\nSample Output 3\n\n2\n\nThe elements of the sequence 1,1,1,1 are all the same, so it is not /\\/\\/\\/.", "sample_input": "4\n3 1 3 2\n"}, "reference_outputs": ["1\n"], "source_document_id": "p03244", "source_text": "Score : 300 points\n\nProblem Statement\n\nA sequence a_1,a_2,... ,a_n is said to be /\\/\\/\\/ when the following conditions are satisfied:\n\nFor each i = 1,2,..., n-2, a_i = a_{i+2}.\n\nExactly two different numbers appear in the sequence.\n\nYou are given a sequence v_1,v_2,...,v_n whose length is even.\nWe would like to make this sequence /\\/\\/\\/ by replacing some of its elements.\nFind the minimum number of elements that needs to be replaced.\n\nConstraints\n\n2 \\leq n \\leq 10^5\n\nn is even.\n\n1 \\leq v_i \\leq 10^5\n\nv_i is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nn\nv_1 v_2 ... v_n\n\nOutput\n\nPrint the minimum number of elements that needs to be replaced.\n\nSample Input 1\n\n4\n3 1 3 2\n\nSample Output 1\n\n1\n\nThe sequence 3,1,3,2 is not /\\/\\/\\/, but we can make it /\\/\\/\\/ by replacing one of its elements: for example, replace the fourth element to make it 3,1,3,1.\n\nSample Input 2\n\n6\n105 119 105 119 105 119\n\nSample Output 2\n\n0\n\nThe sequence 105,119,105,119,105,119 is /\\/\\/\\/.\n\nSample Input 3\n\n4\n1 1 1 1\n\nSample Output 3\n\n2\n\nThe elements of the sequence 1,1,1,1 are all the same, so it is not /\\/\\/\\/.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 893, "cpu_time_ms": 613, "memory_kb": 58384}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s898900282", "group_id": "codeNet:p03244", "input_text": "fun main(args: Array) {\n val n = readLine()!!.toInt()\n val v = readLine()!!.split(\" \").map(String::toInt)\n\n val odds = v.filterIndexed { i, e -> i % 2 == 1 }.groupBy { it }.mapValues { it.value.size }\n val evens = v.filterIndexed { i, e -> i % 2 == 0 }.groupBy { it }.mapValues { it.value.size }\n\n val half = n / 2\n var min = Integer.MAX_VALUE\n\n for ((oddNum, oddSize) in odds) {\n for ((evenNum, evenSize) in evens) {\n if (oddNum == evenNum) {\n continue\n }\n min = Math.min(min, half - oddSize + half - evenSize)\n }\n }\n\n if(min == Integer.MAX_VALUE){\n min = half\n }\n\n println(min)\n}\n", "language": "Kotlin", "metadata": {"date": 1569430674, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03244.html", "problem_id": "p03244", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03244/input.txt", "sample_output_relpath": "derived/input_output/data/p03244/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03244/Kotlin/s898900282.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s898900282", "user_id": "u085288971"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "fun main(args: Array) {\n val n = readLine()!!.toInt()\n val v = readLine()!!.split(\" \").map(String::toInt)\n\n val odds = v.filterIndexed { i, e -> i % 2 == 1 }.groupBy { it }.mapValues { it.value.size }\n val evens = v.filterIndexed { i, e -> i % 2 == 0 }.groupBy { it }.mapValues { it.value.size }\n\n val half = n / 2\n var min = Integer.MAX_VALUE\n\n for ((oddNum, oddSize) in odds) {\n for ((evenNum, evenSize) in evens) {\n if (oddNum == evenNum) {\n continue\n }\n min = Math.min(min, half - oddSize + half - evenSize)\n }\n }\n\n if(min == Integer.MAX_VALUE){\n min = half\n }\n\n println(min)\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nA sequence a_1,a_2,... ,a_n is said to be /\\/\\/\\/ when the following conditions are satisfied:\n\nFor each i = 1,2,..., n-2, a_i = a_{i+2}.\n\nExactly two different numbers appear in the sequence.\n\nYou are given a sequence v_1,v_2,...,v_n whose length is even.\nWe would like to make this sequence /\\/\\/\\/ by replacing some of its elements.\nFind the minimum number of elements that needs to be replaced.\n\nConstraints\n\n2 \\leq n \\leq 10^5\n\nn is even.\n\n1 \\leq v_i \\leq 10^5\n\nv_i is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nn\nv_1 v_2 ... v_n\n\nOutput\n\nPrint the minimum number of elements that needs to be replaced.\n\nSample Input 1\n\n4\n3 1 3 2\n\nSample Output 1\n\n1\n\nThe sequence 3,1,3,2 is not /\\/\\/\\/, but we can make it /\\/\\/\\/ by replacing one of its elements: for example, replace the fourth element to make it 3,1,3,1.\n\nSample Input 2\n\n6\n105 119 105 119 105 119\n\nSample Output 2\n\n0\n\nThe sequence 105,119,105,119,105,119 is /\\/\\/\\/.\n\nSample Input 3\n\n4\n1 1 1 1\n\nSample Output 3\n\n2\n\nThe elements of the sequence 1,1,1,1 are all the same, so it is not /\\/\\/\\/.", "sample_input": "4\n3 1 3 2\n"}, "reference_outputs": ["1\n"], "source_document_id": "p03244", "source_text": "Score : 300 points\n\nProblem Statement\n\nA sequence a_1,a_2,... ,a_n is said to be /\\/\\/\\/ when the following conditions are satisfied:\n\nFor each i = 1,2,..., n-2, a_i = a_{i+2}.\n\nExactly two different numbers appear in the sequence.\n\nYou are given a sequence v_1,v_2,...,v_n whose length is even.\nWe would like to make this sequence /\\/\\/\\/ by replacing some of its elements.\nFind the minimum number of elements that needs to be replaced.\n\nConstraints\n\n2 \\leq n \\leq 10^5\n\nn is even.\n\n1 \\leq v_i \\leq 10^5\n\nv_i is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nn\nv_1 v_2 ... v_n\n\nOutput\n\nPrint the minimum number of elements that needs to be replaced.\n\nSample Input 1\n\n4\n3 1 3 2\n\nSample Output 1\n\n1\n\nThe sequence 3,1,3,2 is not /\\/\\/\\/, but we can make it /\\/\\/\\/ by replacing one of its elements: for example, replace the fourth element to make it 3,1,3,1.\n\nSample Input 2\n\n6\n105 119 105 119 105 119\n\nSample Output 2\n\n0\n\nThe sequence 105,119,105,119,105,119 is /\\/\\/\\/.\n\nSample Input 3\n\n4\n1 1 1 1\n\nSample Output 3\n\n2\n\nThe elements of the sequence 1,1,1,1 are all the same, so it is not /\\/\\/\\/.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 692, "cpu_time_ms": 2111, "memory_kb": 84896}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s871778091", "group_id": "codeNet:p03244", "input_text": "fun main(args: Array) {\n val n = readInputLine().toInt()\n \n val evenCnt = mutableMapOf()\n val oddCnt = mutableMapOf()\n \n val vs = readInputLine().split(\" \").map{it.toInt()}\n \n for (i in 0 until n) {\n val num = vs[i]\n \n val useCnt = if (i % 2 == 0) oddCnt else evenCnt\n val cnt = useCnt.get(num) ?: 0\n useCnt.put(num, cnt + 1)\n }\n \n val evenList = evenCnt.toList().sortedByDescending{it.second}\n val oddList = oddCnt.toList().sortedByDescending{it.second}\n \n if (evenList.size == 1 && oddList.size == 1) {\n if (evenList.first().first != oddList.first().first) {\n println(0)\n } else {\n println(n / 2)\n }\n } else {\n if (evenList.first().first != oddList.first().first) {\n println(n - evenList.first().second - oddList.first().second)\n } else if (evenList.first().second < oddList.first().second) {\n println(n - evenList[1].second - oddList.first().second)\n } else {\n println(n - evenList.first().second - oddList[1].second)\n }\n }\n}\n\nfun readInputLine(): String {\n return readLine()!!\n}\n", "language": "Kotlin", "metadata": {"date": 1565465251, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03244.html", "problem_id": "p03244", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03244/input.txt", "sample_output_relpath": "derived/input_output/data/p03244/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03244/Kotlin/s871778091.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s871778091", "user_id": "u505558493"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "fun main(args: Array) {\n val n = readInputLine().toInt()\n \n val evenCnt = mutableMapOf()\n val oddCnt = mutableMapOf()\n \n val vs = readInputLine().split(\" \").map{it.toInt()}\n \n for (i in 0 until n) {\n val num = vs[i]\n \n val useCnt = if (i % 2 == 0) oddCnt else evenCnt\n val cnt = useCnt.get(num) ?: 0\n useCnt.put(num, cnt + 1)\n }\n \n val evenList = evenCnt.toList().sortedByDescending{it.second}\n val oddList = oddCnt.toList().sortedByDescending{it.second}\n \n if (evenList.size == 1 && oddList.size == 1) {\n if (evenList.first().first != oddList.first().first) {\n println(0)\n } else {\n println(n / 2)\n }\n } else {\n if (evenList.first().first != oddList.first().first) {\n println(n - evenList.first().second - oddList.first().second)\n } else if (evenList.first().second < oddList.first().second) {\n println(n - evenList[1].second - oddList.first().second)\n } else {\n println(n - evenList.first().second - oddList[1].second)\n }\n }\n}\n\nfun readInputLine(): String {\n return readLine()!!\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nA sequence a_1,a_2,... ,a_n is said to be /\\/\\/\\/ when the following conditions are satisfied:\n\nFor each i = 1,2,..., n-2, a_i = a_{i+2}.\n\nExactly two different numbers appear in the sequence.\n\nYou are given a sequence v_1,v_2,...,v_n whose length is even.\nWe would like to make this sequence /\\/\\/\\/ by replacing some of its elements.\nFind the minimum number of elements that needs to be replaced.\n\nConstraints\n\n2 \\leq n \\leq 10^5\n\nn is even.\n\n1 \\leq v_i \\leq 10^5\n\nv_i is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nn\nv_1 v_2 ... v_n\n\nOutput\n\nPrint the minimum number of elements that needs to be replaced.\n\nSample Input 1\n\n4\n3 1 3 2\n\nSample Output 1\n\n1\n\nThe sequence 3,1,3,2 is not /\\/\\/\\/, but we can make it /\\/\\/\\/ by replacing one of its elements: for example, replace the fourth element to make it 3,1,3,1.\n\nSample Input 2\n\n6\n105 119 105 119 105 119\n\nSample Output 2\n\n0\n\nThe sequence 105,119,105,119,105,119 is /\\/\\/\\/.\n\nSample Input 3\n\n4\n1 1 1 1\n\nSample Output 3\n\n2\n\nThe elements of the sequence 1,1,1,1 are all the same, so it is not /\\/\\/\\/.", "sample_input": "4\n3 1 3 2\n"}, "reference_outputs": ["1\n"], "source_document_id": "p03244", "source_text": "Score : 300 points\n\nProblem Statement\n\nA sequence a_1,a_2,... ,a_n is said to be /\\/\\/\\/ when the following conditions are satisfied:\n\nFor each i = 1,2,..., n-2, a_i = a_{i+2}.\n\nExactly two different numbers appear in the sequence.\n\nYou are given a sequence v_1,v_2,...,v_n whose length is even.\nWe would like to make this sequence /\\/\\/\\/ by replacing some of its elements.\nFind the minimum number of elements that needs to be replaced.\n\nConstraints\n\n2 \\leq n \\leq 10^5\n\nn is even.\n\n1 \\leq v_i \\leq 10^5\n\nv_i is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nn\nv_1 v_2 ... v_n\n\nOutput\n\nPrint the minimum number of elements that needs to be replaced.\n\nSample Input 1\n\n4\n3 1 3 2\n\nSample Output 1\n\n1\n\nThe sequence 3,1,3,2 is not /\\/\\/\\/, but we can make it /\\/\\/\\/ by replacing one of its elements: for example, replace the fourth element to make it 3,1,3,1.\n\nSample Input 2\n\n6\n105 119 105 119 105 119\n\nSample Output 2\n\n0\n\nThe sequence 105,119,105,119,105,119 is /\\/\\/\\/.\n\nSample Input 3\n\n4\n1 1 1 1\n\nSample Output 3\n\n2\n\nThe elements of the sequence 1,1,1,1 are all the same, so it is not /\\/\\/\\/.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1201, "cpu_time_ms": 750, "memory_kb": 58048}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s514281727", "group_id": "codeNet:p03244", "input_text": "fun c111(args: Array) {\n val numList = args[1].split(\" \").map { it.toInt() }\n val firstList = numList.filterIndexed { index, num -> index % 2 == 0 }\n val secondList = numList.filterIndexed { index, num -> index % 2 == 1 }\n\n var firstMap = mutableMapOf()\n var firstMostCommonCount = 0\n var firstSecondMostCommonCount = 0\n var firstMostCommonNum = 0\n firstList.forEach {\n if (!firstMap.containsKey(it)) {\n firstMap.put(it, 0)\n }\n firstMap.put(it, firstMap[it]!! + 1)\n if (firstMostCommonCount < firstMap.get(it)!!) {\n firstSecondMostCommonCount = firstMostCommonCount\n firstMostCommonCount = firstMap.get(it)!!\n firstMostCommonNum = it\n }\n }\n\n var secondMap = mutableMapOf()\n var secondMostCommonCount = 0\n var secondSecondMostCommonCount = 0\n var secondMostCommonNum = 0\n secondList.forEach {\n if (!secondMap.containsKey(it)) {\n secondMap.put(it, 0)\n }\n secondMap.put(it, secondMap[it]!! + 1)\n if (secondMostCommonCount < secondMap.get(it)!!) {\n secondSecondMostCommonCount = secondMostCommonCount\n secondMostCommonCount = secondMap.get(it)!!\n secondMostCommonNum = it\n }\n }\n\n if (firstMostCommonNum != secondMostCommonNum) {\n println((firstList.size - firstMostCommonCount) + (secondList.size - secondMostCommonCount))\n } else {\n println(Math.min(\n (firstList.size - firstSecondMostCommonCount) + (secondList.size - secondMostCommonCount),\n (firstList.size - firstMostCommonCount) + (secondList.size - secondSecondMostCommonCount)))\n\n }\n}\n\n\nfun main(args: Array) {\n c111(readLineList())\n}\n\nfun readLineList(): Array {\n val lineList = mutableListOf()\n while (true) {\n val line = readLine()\n if (line.isNullOrBlank()) {\n break\n } else {\n lineList.add(line!!)\n }\n }\n return lineList.toTypedArray()\n}", "language": "Kotlin", "metadata": {"date": 1541558280, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03244.html", "problem_id": "p03244", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03244/input.txt", "sample_output_relpath": "derived/input_output/data/p03244/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03244/Kotlin/s514281727.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s514281727", "user_id": "u227166381"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "fun c111(args: Array) {\n val numList = args[1].split(\" \").map { it.toInt() }\n val firstList = numList.filterIndexed { index, num -> index % 2 == 0 }\n val secondList = numList.filterIndexed { index, num -> index % 2 == 1 }\n\n var firstMap = mutableMapOf()\n var firstMostCommonCount = 0\n var firstSecondMostCommonCount = 0\n var firstMostCommonNum = 0\n firstList.forEach {\n if (!firstMap.containsKey(it)) {\n firstMap.put(it, 0)\n }\n firstMap.put(it, firstMap[it]!! + 1)\n if (firstMostCommonCount < firstMap.get(it)!!) {\n firstSecondMostCommonCount = firstMostCommonCount\n firstMostCommonCount = firstMap.get(it)!!\n firstMostCommonNum = it\n }\n }\n\n var secondMap = mutableMapOf()\n var secondMostCommonCount = 0\n var secondSecondMostCommonCount = 0\n var secondMostCommonNum = 0\n secondList.forEach {\n if (!secondMap.containsKey(it)) {\n secondMap.put(it, 0)\n }\n secondMap.put(it, secondMap[it]!! + 1)\n if (secondMostCommonCount < secondMap.get(it)!!) {\n secondSecondMostCommonCount = secondMostCommonCount\n secondMostCommonCount = secondMap.get(it)!!\n secondMostCommonNum = it\n }\n }\n\n if (firstMostCommonNum != secondMostCommonNum) {\n println((firstList.size - firstMostCommonCount) + (secondList.size - secondMostCommonCount))\n } else {\n println(Math.min(\n (firstList.size - firstSecondMostCommonCount) + (secondList.size - secondMostCommonCount),\n (firstList.size - firstMostCommonCount) + (secondList.size - secondSecondMostCommonCount)))\n\n }\n}\n\n\nfun main(args: Array) {\n c111(readLineList())\n}\n\nfun readLineList(): Array {\n val lineList = mutableListOf()\n while (true) {\n val line = readLine()\n if (line.isNullOrBlank()) {\n break\n } else {\n lineList.add(line!!)\n }\n }\n return lineList.toTypedArray()\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nA sequence a_1,a_2,... ,a_n is said to be /\\/\\/\\/ when the following conditions are satisfied:\n\nFor each i = 1,2,..., n-2, a_i = a_{i+2}.\n\nExactly two different numbers appear in the sequence.\n\nYou are given a sequence v_1,v_2,...,v_n whose length is even.\nWe would like to make this sequence /\\/\\/\\/ by replacing some of its elements.\nFind the minimum number of elements that needs to be replaced.\n\nConstraints\n\n2 \\leq n \\leq 10^5\n\nn is even.\n\n1 \\leq v_i \\leq 10^5\n\nv_i is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nn\nv_1 v_2 ... v_n\n\nOutput\n\nPrint the minimum number of elements that needs to be replaced.\n\nSample Input 1\n\n4\n3 1 3 2\n\nSample Output 1\n\n1\n\nThe sequence 3,1,3,2 is not /\\/\\/\\/, but we can make it /\\/\\/\\/ by replacing one of its elements: for example, replace the fourth element to make it 3,1,3,1.\n\nSample Input 2\n\n6\n105 119 105 119 105 119\n\nSample Output 2\n\n0\n\nThe sequence 105,119,105,119,105,119 is /\\/\\/\\/.\n\nSample Input 3\n\n4\n1 1 1 1\n\nSample Output 3\n\n2\n\nThe elements of the sequence 1,1,1,1 are all the same, so it is not /\\/\\/\\/.", "sample_input": "4\n3 1 3 2\n"}, "reference_outputs": ["1\n"], "source_document_id": "p03244", "source_text": "Score : 300 points\n\nProblem Statement\n\nA sequence a_1,a_2,... ,a_n is said to be /\\/\\/\\/ when the following conditions are satisfied:\n\nFor each i = 1,2,..., n-2, a_i = a_{i+2}.\n\nExactly two different numbers appear in the sequence.\n\nYou are given a sequence v_1,v_2,...,v_n whose length is even.\nWe would like to make this sequence /\\/\\/\\/ by replacing some of its elements.\nFind the minimum number of elements that needs to be replaced.\n\nConstraints\n\n2 \\leq n \\leq 10^5\n\nn is even.\n\n1 \\leq v_i \\leq 10^5\n\nv_i is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nn\nv_1 v_2 ... v_n\n\nOutput\n\nPrint the minimum number of elements that needs to be replaced.\n\nSample Input 1\n\n4\n3 1 3 2\n\nSample Output 1\n\n1\n\nThe sequence 3,1,3,2 is not /\\/\\/\\/, but we can make it /\\/\\/\\/ by replacing one of its elements: for example, replace the fourth element to make it 3,1,3,1.\n\nSample Input 2\n\n6\n105 119 105 119 105 119\n\nSample Output 2\n\n0\n\nThe sequence 105,119,105,119,105,119 is /\\/\\/\\/.\n\nSample Input 3\n\n4\n1 1 1 1\n\nSample Output 3\n\n2\n\nThe elements of the sequence 1,1,1,1 are all the same, so it is not /\\/\\/\\/.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2069, "cpu_time_ms": 674, "memory_kb": 58024}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s056804560", "group_id": "codeNet:p03246", "input_text": "fun ac103(args: Array) {\n val numList = args[1].split(\" \").map { it.toInt() }\n val evenNumToCount = mutableMapOf(0 to 0)\n val oddNumToCount = mutableMapOf(0 to 0)\n numList.forEachIndexed { index, num ->\n if (index % 2 == 0) {\n if (!evenNumToCount.containsKey(num)) {\n evenNumToCount[num] = 0\n }\n evenNumToCount[num] = evenNumToCount[num]!! + 1\n } else {\n if (!oddNumToCount.containsKey(num)) {\n oddNumToCount[num] = 0\n }\n oddNumToCount[num] = oddNumToCount[num]!! + 1\n }\n }\n\n val evenSorted = evenNumToCount.entries.sortedByDescending { it.value }\n val oddSorted = oddNumToCount.entries.sortedByDescending { it.value }\n if (evenSorted[0].key != oddSorted[0].key) {\n println(numList.size - evenSorted[0].value - oddSorted[0].value)\n } else {\n println(Math.min(numList.size - evenSorted[0].value - oddSorted[1].value,\n numList.size - evenSorted[1].value - oddSorted[0].value))\n\n }\n}\n\nfun main(args: Array) {\n ac103(readLineList())\n}\n\nfun readLineList(): Array {\n val lineList = mutableListOf()\n while (true) {\n val line = readLine()\n if (line.isNullOrBlank()) {\n break\n } else {\n lineList.add(line!!)\n }\n }\n return lineList.toTypedArray()\n}", "language": "Kotlin", "metadata": {"date": 1551928077, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03246.html", "problem_id": "p03246", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03246/input.txt", "sample_output_relpath": "derived/input_output/data/p03246/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03246/Kotlin/s056804560.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s056804560", "user_id": "u241874341"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "fun ac103(args: Array) {\n val numList = args[1].split(\" \").map { it.toInt() }\n val evenNumToCount = mutableMapOf(0 to 0)\n val oddNumToCount = mutableMapOf(0 to 0)\n numList.forEachIndexed { index, num ->\n if (index % 2 == 0) {\n if (!evenNumToCount.containsKey(num)) {\n evenNumToCount[num] = 0\n }\n evenNumToCount[num] = evenNumToCount[num]!! + 1\n } else {\n if (!oddNumToCount.containsKey(num)) {\n oddNumToCount[num] = 0\n }\n oddNumToCount[num] = oddNumToCount[num]!! + 1\n }\n }\n\n val evenSorted = evenNumToCount.entries.sortedByDescending { it.value }\n val oddSorted = oddNumToCount.entries.sortedByDescending { it.value }\n if (evenSorted[0].key != oddSorted[0].key) {\n println(numList.size - evenSorted[0].value - oddSorted[0].value)\n } else {\n println(Math.min(numList.size - evenSorted[0].value - oddSorted[1].value,\n numList.size - evenSorted[1].value - oddSorted[0].value))\n\n }\n}\n\nfun main(args: Array) {\n ac103(readLineList())\n}\n\nfun readLineList(): Array {\n val lineList = mutableListOf()\n while (true) {\n val line = readLine()\n if (line.isNullOrBlank()) {\n break\n } else {\n lineList.add(line!!)\n }\n }\n return lineList.toTypedArray()\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nA sequence a_1,a_2,... ,a_n is said to be /\\/\\/\\/ when the following conditions are satisfied:\n\nFor each i = 1,2,..., n-2, a_i = a_{i+2}.\n\nExactly two different numbers appear in the sequence.\n\nYou are given a sequence v_1,v_2,...,v_n whose length is even.\nWe would like to make this sequence /\\/\\/\\/ by replacing some of its elements.\nFind the minimum number of elements that needs to be replaced.\n\nConstraints\n\n2 \\leq n \\leq 10^5\n\nn is even.\n\n1 \\leq v_i \\leq 10^5\n\nv_i is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nn\nv_1 v_2 ... v_n\n\nOutput\n\nPrint the minimum number of elements that needs to be replaced.\n\nSample Input 1\n\n4\n3 1 3 2\n\nSample Output 1\n\n1\n\nThe sequence 3,1,3,2 is not /\\/\\/\\/, but we can make it /\\/\\/\\/ by replacing one of its elements: for example, replace the fourth element to make it 3,1,3,1.\n\nSample Input 2\n\n6\n105 119 105 119 105 119\n\nSample Output 2\n\n0\n\nThe sequence 105,119,105,119,105,119 is /\\/\\/\\/.\n\nSample Input 3\n\n4\n1 1 1 1\n\nSample Output 3\n\n2\n\nThe elements of the sequence 1,1,1,1 are all the same, so it is not /\\/\\/\\/.", "sample_input": "4\n3 1 3 2\n"}, "reference_outputs": ["1\n"], "source_document_id": "p03246", "source_text": "Score : 300 points\n\nProblem Statement\n\nA sequence a_1,a_2,... ,a_n is said to be /\\/\\/\\/ when the following conditions are satisfied:\n\nFor each i = 1,2,..., n-2, a_i = a_{i+2}.\n\nExactly two different numbers appear in the sequence.\n\nYou are given a sequence v_1,v_2,...,v_n whose length is even.\nWe would like to make this sequence /\\/\\/\\/ by replacing some of its elements.\nFind the minimum number of elements that needs to be replaced.\n\nConstraints\n\n2 \\leq n \\leq 10^5\n\nn is even.\n\n1 \\leq v_i \\leq 10^5\n\nv_i is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nn\nv_1 v_2 ... v_n\n\nOutput\n\nPrint the minimum number of elements that needs to be replaced.\n\nSample Input 1\n\n4\n3 1 3 2\n\nSample Output 1\n\n1\n\nThe sequence 3,1,3,2 is not /\\/\\/\\/, but we can make it /\\/\\/\\/ by replacing one of its elements: for example, replace the fourth element to make it 3,1,3,1.\n\nSample Input 2\n\n6\n105 119 105 119 105 119\n\nSample Output 2\n\n0\n\nThe sequence 105,119,105,119,105,119 is /\\/\\/\\/.\n\nSample Input 3\n\n4\n1 1 1 1\n\nSample Output 3\n\n2\n\nThe elements of the sequence 1,1,1,1 are all the same, so it is not /\\/\\/\\/.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1411, "cpu_time_ms": 772, "memory_kb": 60252}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s512998776", "group_id": "codeNet:p03252", "input_text": "fun main(args : Array) {\n val s = readLine()!!\n val t = readLine()!!\n\n val sPos = mutableMapOf>()\n val tPos = mutableMapOf>()\n\n s.forEachIndexed { idx, c ->\n val set = sPos[c] ?: mutableListOf()\n set.add(idx)\n sPos[c] = set\n }\n\n t.forEachIndexed { idx, c ->\n val set = tPos[c] ?: mutableListOf()\n set.add(idx)\n tPos[c] = set\n }\n\n for (i in s.indices) {\n if (sPos[s[i]] != tPos[t[i]]) {\n println(\"No\")\n return\n }\n }\n\n println(\"Yes\")\n}", "language": "Kotlin", "metadata": {"date": 1599213561, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p03252.html", "problem_id": "p03252", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03252/input.txt", "sample_output_relpath": "derived/input_output/data/p03252/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03252/Kotlin/s512998776.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s512998776", "user_id": "u262403099"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "fun main(args : Array) {\n val s = readLine()!!\n val t = readLine()!!\n\n val sPos = mutableMapOf>()\n val tPos = mutableMapOf>()\n\n s.forEachIndexed { idx, c ->\n val set = sPos[c] ?: mutableListOf()\n set.add(idx)\n sPos[c] = set\n }\n\n t.forEachIndexed { idx, c ->\n val set = tPos[c] ?: mutableListOf()\n set.add(idx)\n tPos[c] = set\n }\n\n for (i in s.indices) {\n if (sPos[s[i]] != tPos[t[i]]) {\n println(\"No\")\n return\n }\n }\n\n println(\"Yes\")\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nYou are given strings S and T consisting of lowercase English letters.\n\nYou can perform the following operation on S any number of times:\n\nOperation: Choose two distinct lowercase English letters c_1 and c_2, then replace every occurrence of c_1 with c_2, and every occurrence of c_2 with c_1.\n\nDetermine if S and T can be made equal by performing the operation zero or more times.\n\nConstraints\n\n1 \\leq |S| \\leq 2 \\times 10^5\n\n|S| = |T|\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 S and T can be made equal, print Yes; otherwise, print No.\n\nSample Input 1\n\nazzel\napple\n\nSample Output 1\n\nYes\n\nazzel can be changed to apple, as follows:\n\nChoose e as c_1 and l as c_2. azzel becomes azzle.\n\nChoose z as c_1 and p as c_2. azzle becomes apple.\n\nSample Input 2\n\nchokudai\nredcoder\n\nSample Output 2\n\nNo\n\nNo sequences of operation can change chokudai to redcoder.\n\nSample Input 3\n\nabcdefghijklmnopqrstuvwxyz\nibyhqfrekavclxjstdwgpzmonu\n\nSample Output 3\n\nYes", "sample_input": "azzel\napple\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03252", "source_text": "Score : 300 points\n\nProblem Statement\n\nYou are given strings S and T consisting of lowercase English letters.\n\nYou can perform the following operation on S any number of times:\n\nOperation: Choose two distinct lowercase English letters c_1 and c_2, then replace every occurrence of c_1 with c_2, and every occurrence of c_2 with c_1.\n\nDetermine if S and T can be made equal by performing the operation zero or more times.\n\nConstraints\n\n1 \\leq |S| \\leq 2 \\times 10^5\n\n|S| = |T|\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 S and T can be made equal, print Yes; otherwise, print No.\n\nSample Input 1\n\nazzel\napple\n\nSample Output 1\n\nYes\n\nazzel can be changed to apple, as follows:\n\nChoose e as c_1 and l as c_2. azzel becomes azzle.\n\nChoose z as c_1 and p as c_2. azzle becomes apple.\n\nSample Input 2\n\nchokudai\nredcoder\n\nSample Output 2\n\nNo\n\nNo sequences of operation can change chokudai to redcoder.\n\nSample Input 3\n\nabcdefghijklmnopqrstuvwxyz\nibyhqfrekavclxjstdwgpzmonu\n\nSample Output 3\n\nYes", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 2207, "memory_kb": 54184}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s022874108", "group_id": "codeNet:p03253", "input_text": "fun main(args: Array) {\n fun pow2(n: Int): ModInt {\n if (n == 0) return ModInt(1)\n var x = pow2(n / 2)\n x *= x\n if (n % 2 == 1) x *= 2\n return x\n }\n fun Combi(n: Int, a: Int): ModInt {\n var x = ModInt(1)\n var y = ModInt(1)\n repeat(a) { i ->\n x *= n - i\n y *= i + 1\n }\n return x / y\n }\n \n val (N, M) =listOfInt()\n var MNokori = M\n var ans = ModInt(1)\n var n = 2\n while (n * n <= MNokori) {\n if (MNokori % n == 0) {\n var cnt = 0\n while (MNokori % n == 0) {\n cnt++\n MNokori /= n\n }\n ans *= Combi(N + cnt - 1, N - 1)\n }\n n += 1\n }\n if (MNokori != 1) {\n ans *= Combi(N + 1 - 1, N - 1)\n }\n println(ans.toString())\n}\nfun next() = readLine()!!\nfun nextInt() = Integer.parseInt(next())\nfun listOfString() = next().split(\" \")\nfun listOfInt() = listOfString().map { Integer.parseInt(it) }\nfun listOfLong() = listOfString().map { java.lang.Long.parseLong(it) }\n\ndata class ModInt(private var v: Long) {\n companion object { private const val MOD = 1000000007L }\n init { this.v %= MOD }\n constructor(n: Int): this(n.toLong())\n operator fun plus(other: Int) = ModInt((this.v + other) % MOD)\n operator fun minus(other: Int) = ModInt((this.v + MOD - other) % MOD)\n operator fun minus(other: ModInt) = ModInt((this.v + MOD - other.v) % MOD)\n operator fun times(other: Int) = ModInt(this.v * other % MOD)\n operator fun times(other: ModInt) = ModInt(this.v * other.v % MOD)\n operator fun div(other: ModInt) = ModInt(this.v * pow(other.v, MOD - 2) % MOD)\n private fun pow(a: Long, b: Long): Long {\n if (b == 0L) return 1L\n if (b % 2 == 0L) {\n val d = pow(a, b / 2)\n return (d * d) % MOD\n }\n return a * pow(a, b - 1) % MOD\n }\n override fun toString() = this.v.toString()\n}\n", "language": "Kotlin", "metadata": {"date": 1583949043, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03253.html", "problem_id": "p03253", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03253/input.txt", "sample_output_relpath": "derived/input_output/data/p03253/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03253/Kotlin/s022874108.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s022874108", "user_id": "u043150661"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "fun main(args: Array) {\n fun pow2(n: Int): ModInt {\n if (n == 0) return ModInt(1)\n var x = pow2(n / 2)\n x *= x\n if (n % 2 == 1) x *= 2\n return x\n }\n fun Combi(n: Int, a: Int): ModInt {\n var x = ModInt(1)\n var y = ModInt(1)\n repeat(a) { i ->\n x *= n - i\n y *= i + 1\n }\n return x / y\n }\n \n val (N, M) =listOfInt()\n var MNokori = M\n var ans = ModInt(1)\n var n = 2\n while (n * n <= MNokori) {\n if (MNokori % n == 0) {\n var cnt = 0\n while (MNokori % n == 0) {\n cnt++\n MNokori /= n\n }\n ans *= Combi(N + cnt - 1, N - 1)\n }\n n += 1\n }\n if (MNokori != 1) {\n ans *= Combi(N + 1 - 1, N - 1)\n }\n println(ans.toString())\n}\nfun next() = readLine()!!\nfun nextInt() = Integer.parseInt(next())\nfun listOfString() = next().split(\" \")\nfun listOfInt() = listOfString().map { Integer.parseInt(it) }\nfun listOfLong() = listOfString().map { java.lang.Long.parseLong(it) }\n\ndata class ModInt(private var v: Long) {\n companion object { private const val MOD = 1000000007L }\n init { this.v %= MOD }\n constructor(n: Int): this(n.toLong())\n operator fun plus(other: Int) = ModInt((this.v + other) % MOD)\n operator fun minus(other: Int) = ModInt((this.v + MOD - other) % MOD)\n operator fun minus(other: ModInt) = ModInt((this.v + MOD - other.v) % MOD)\n operator fun times(other: Int) = ModInt(this.v * other % MOD)\n operator fun times(other: ModInt) = ModInt(this.v * other.v % MOD)\n operator fun div(other: ModInt) = ModInt(this.v * pow(other.v, MOD - 2) % MOD)\n private fun pow(a: Long, b: Long): Long {\n if (b == 0L) return 1L\n if (b % 2 == 0L) {\n val d = pow(a, b / 2)\n return (d * d) % MOD\n }\n return a * pow(a, b - 1) % MOD\n }\n override fun toString() = this.v.toString()\n}\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nYou are given positive integers N and M.\n\nHow many sequences a of length N consisting of positive integers satisfy a_1 \\times a_2 \\times ... \\times a_N = M? Find the count modulo 10^9+7.\n\nHere, two sequences a' and a'' are considered different when there exists some i such that a_i' \\neq a_i''.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^5\n\n1 \\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 number of the sequences consisting of positive integers that satisfy the condition, modulo 10^9 + 7.\n\nSample Input 1\n\n2 6\n\nSample Output 1\n\n4\n\nFour sequences satisfy the condition: \\{a_1, a_2\\} = \\{1, 6\\}, \\{2, 3\\}, \\{3, 2\\} and \\{6, 1\\}.\n\nSample Input 2\n\n3 12\n\nSample Output 2\n\n18\n\nSample Input 3\n\n100000 1000000000\n\nSample Output 3\n\n957870001", "sample_input": "2 6\n"}, "reference_outputs": ["4\n"], "source_document_id": "p03253", "source_text": "Score : 400 points\n\nProblem Statement\n\nYou are given positive integers N and M.\n\nHow many sequences a of length N consisting of positive integers satisfy a_1 \\times a_2 \\times ... \\times a_N = M? Find the count modulo 10^9+7.\n\nHere, two sequences a' and a'' are considered different when there exists some i such that a_i' \\neq a_i''.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^5\n\n1 \\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 number of the sequences consisting of positive integers that satisfy the condition, modulo 10^9 + 7.\n\nSample Input 1\n\n2 6\n\nSample Output 1\n\n4\n\nFour sequences satisfy the condition: \\{a_1, a_2\\} = \\{1, 6\\}, \\{2, 3\\}, \\{3, 2\\} and \\{6, 1\\}.\n\nSample Input 2\n\n3 12\n\nSample Output 2\n\n18\n\nSample Input 3\n\n100000 1000000000\n\nSample Output 3\n\n957870001", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1981, "cpu_time_ms": 290, "memory_kb": 50364}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s285928130", "group_id": "codeNet:p03254", "input_text": "fun main(args: Array) {\n var (n, x) = readInputLine().split(\" \").map { it.toInt() }\n \n val aList = readInputLine().split(\" \").map { it.toInt() }.toList().toIntArray()\n\n aList.sort()\n \n var ans = 0\n\n for ((i, a) in aList.withIndex()) {\n if (x < a) {\n break\n }\n ans++\n x -= a\n if (x == 0) {\n break\n }\n \n if (i == aList.size - 1) {\n ans--\n }\n }\n\n println(ans)\n}\n \nfun readInputLine(): String {\n return readLine()!!\n}\n", "language": "Kotlin", "metadata": {"date": 1562808829, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03254.html", "problem_id": "p03254", "resource_group": "medium_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/Kotlin/s285928130.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s285928130", "user_id": "u505558493"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "fun main(args: Array) {\n var (n, x) = readInputLine().split(\" \").map { it.toInt() }\n \n val aList = readInputLine().split(\" \").map { it.toInt() }.toList().toIntArray()\n\n aList.sort()\n \n var ans = 0\n\n for ((i, a) in aList.withIndex()) {\n if (x < a) {\n break\n }\n ans++\n x -= a\n if (x == 0) {\n break\n }\n \n if (i == aList.size - 1) {\n ans--\n }\n }\n\n println(ans)\n}\n \nfun readInputLine(): String {\n return readLine()!!\n}\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 548, "cpu_time_ms": 238, "memory_kb": 37940}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s574249774", "group_id": "codeNet:p03256", "input_text": "fun main(args:Array){\n val line1 = readLine()!!.trim().split(' ').map(String::toInt)\n val str = readLine()!!.trim()\n val n = line1[0]//頂点の個数\n val m = line1[1]//辺の本数\n val aList = arrayListOf()\n val aOK = hashSetOf()\n val bOK = hashSetOf()\n for(i in 1..n){\n if(str.get(i-1).equals('A'))aList.add(i)\n }\n for(i in 1..m){\n val list = readLine()!!.trim().split(' ').map(String::toInt)\n val x = list[0]\n val y = list[1]\n if(aList.contains(x)) aOK.add(y) else bOK.add(y)\n if(aList.contains(y)) aOK.add(x) else bOK.add(x)\n if(i%5==0){\n var calc = 0\n for(z in aOK){\n if(bOK.contains(z))calc++\n }\n if(calc>=2){\n println(\"YES\")\n return\n }\n }\n }\n var calc = 0\n for(z in aOK){\n if(bOK.contains(z))calc++\n }\n if(calc>=2){\n println(\"YES\")\n return\n }\n println(\"NO\")\n}", "language": "Kotlin", "metadata": {"date": 1537065058, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03256.html", "problem_id": "p03256", "resource_group": "medium_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/Kotlin/s574249774.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s574249774", "user_id": "u803479630"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "fun main(args:Array){\n val line1 = readLine()!!.trim().split(' ').map(String::toInt)\n val str = readLine()!!.trim()\n val n = line1[0]//頂点の個数\n val m = line1[1]//辺の本数\n val aList = arrayListOf()\n val aOK = hashSetOf()\n val bOK = hashSetOf()\n for(i in 1..n){\n if(str.get(i-1).equals('A'))aList.add(i)\n }\n for(i in 1..m){\n val list = readLine()!!.trim().split(' ').map(String::toInt)\n val x = list[0]\n val y = list[1]\n if(aList.contains(x)) aOK.add(y) else bOK.add(y)\n if(aList.contains(y)) aOK.add(x) else bOK.add(x)\n if(i%5==0){\n var calc = 0\n for(z in aOK){\n if(bOK.contains(z))calc++\n }\n if(calc>=2){\n println(\"YES\")\n return\n }\n }\n }\n var calc = 0\n for(z in aOK){\n if(bOK.contains(z))calc++\n }\n if(calc>=2){\n println(\"YES\")\n return\n }\n println(\"NO\")\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1019, "cpu_time_ms": 503, "memory_kb": 42016}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s958083521", "group_id": "codeNet:p03263", "input_text": "fun main(args: Array) {\n val (H, W) = listOfInt()\n val A = Array(H) { listOfInt() }.flatMap { it }.toIntArray()\n fun rc(v: Int) = \"${(v / W) + 1} ${(v % W) + 1}\" //row-col\n val wh = W * H\n val wh0 = W * (H - 1)\n var N = 0\n val ans = StringBuilder()\n for (src in 0 until wh - 1) {\n if (A[src] % 2 != 0) {\n val dst = if (src < wh0) src + W else src + 1\n A[src] -= 1\n A[dst] += 1\n ans.append(\"\\n${rc(src)} ${rc(dst)}\")\n N += 1\n }\n }\n println(\"${N}${ans.toString()}\")\n}\nfun next() = readLine()!!\nfun listOfString() = next().split(\" \")\nfun listOfInt() = listOfString().map { Integer.parseInt(it) }\n", "language": "Kotlin", "metadata": {"date": 1584021590, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03263.html", "problem_id": "p03263", "resource_group": "medium_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/Kotlin/s958083521.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s958083521", "user_id": "u043150661"}, "prompt_components": {"gold_output": "3\n2 2 2 3\n1 1 1 2\n1 3 1 2\n", "input_to_evaluate": "fun main(args: Array) {\n val (H, W) = listOfInt()\n val A = Array(H) { listOfInt() }.flatMap { it }.toIntArray()\n fun rc(v: Int) = \"${(v / W) + 1} ${(v % W) + 1}\" //row-col\n val wh = W * H\n val wh0 = W * (H - 1)\n var N = 0\n val ans = StringBuilder()\n for (src in 0 until wh - 1) {\n if (A[src] % 2 != 0) {\n val dst = if (src < wh0) src + W else src + 1\n A[src] -= 1\n A[dst] += 1\n ans.append(\"\\n${rc(src)} ${rc(dst)}\")\n N += 1\n }\n }\n println(\"${N}${ans.toString()}\")\n}\nfun next() = readLine()!!\nfun listOfString() = next().split(\" \")\nfun listOfInt() = listOfString().map { Integer.parseInt(it) }\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 701, "cpu_time_ms": 686, "memory_kb": 84052}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s011744976", "group_id": "codeNet:p03264", "input_text": "fun main(args:Array) {\n\tval n = readLine()!!.toInt()\n\tprintln((n/2)*((n+1)/2))\n\t\n}", "language": "Kotlin", "metadata": {"date": 1541565371, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03264.html", "problem_id": "p03264", "resource_group": "medium_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/Kotlin/s011744976.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s011744976", "user_id": "u914096045"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "fun main(args:Array) {\n\tval n = readLine()!!.toInt()\n\tprintln((n/2)*((n+1)/2))\n\t\n}", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 199, "memory_kb": 29852}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s826881097", "group_id": "codeNet:p03265", "input_text": "fun main(args: Array) {\n val (x1, y1, x2, y2) = readLine()!!.split(\" \").map(String::toInt)\n\n val x = x2 - x1\n val y = y2 - y1\n\n\n println(\"${x2 - y} ${y2 + x} ${x1 - y} ${y1 + x}\")\n}", "language": "Kotlin", "metadata": {"date": 1566615117, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03265.html", "problem_id": "p03265", "resource_group": "medium_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/Kotlin/s826881097.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s826881097", "user_id": "u085288971"}, "prompt_components": {"gold_output": "-1 1 -1 0\n", "input_to_evaluate": "fun main(args: Array) {\n val (x1, y1, x2, y2) = readLine()!!.split(\" \").map(String::toInt)\n\n val x = x2 - x1\n val y = y2 - y1\n\n\n println(\"${x2 - y} ${y2 + x} ${x1 - y} ${y1 + x}\")\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 234, "memory_kb": 36004}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s501958530", "group_id": "codeNet:p03265", "input_text": "import java.io.*\nimport java.util.*\n\n\nfun main(args: Array) {\n fun StringArray(size: Int, init: (Int) -> String = { \"\\u0000\" }): Array {\n return Array(size, init)\n }\n\n class Scanner(stream: InputStream) {\n private val reader = BufferedInputStream(stream).bufferedReader()\n private var st: StringTokenizer? = null\n fun next(): String {\n while (!(st?.hasMoreTokens() ?: false)) st = StringTokenizer(reader.readLine())\n return st!!.nextToken()\n }\n }\n val (x1, y1, x2, y2) = readLine()!!.split(' ').map { it.toInt() }\n val (a, b) = Pair(x2 - x1, y2 - y1)\n val (x3, y3) = Pair(x2 - b, y2 + a)\n val (x4, y4) = Pair(x1 - b, y1 + a)\n println(\"$x3 $y3 $x4 $y4\")\n}\n\n", "language": "Kotlin", "metadata": {"date": 1563559319, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03265.html", "problem_id": "p03265", "resource_group": "medium_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/Kotlin/s501958530.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s501958530", "user_id": "u329232967"}, "prompt_components": {"gold_output": "-1 1 -1 0\n", "input_to_evaluate": "import java.io.*\nimport java.util.*\n\n\nfun main(args: Array) {\n fun StringArray(size: Int, init: (Int) -> String = { \"\\u0000\" }): Array {\n return Array(size, init)\n }\n\n class Scanner(stream: InputStream) {\n private val reader = BufferedInputStream(stream).bufferedReader()\n private var st: StringTokenizer? = null\n fun next(): String {\n while (!(st?.hasMoreTokens() ?: false)) st = StringTokenizer(reader.readLine())\n return st!!.nextToken()\n }\n }\n val (x1, y1, x2, y2) = readLine()!!.split(' ').map { it.toInt() }\n val (a, b) = Pair(x2 - x1, y2 - y1)\n val (x3, y3) = Pair(x2 - b, y2 + a)\n val (x4, y4) = Pair(x1 - b, y1 + a)\n println(\"$x3 $y3 $x4 $y4\")\n}\n\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 237, "memory_kb": 38252}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s894627592", "group_id": "codeNet:p03265", "input_text": "import java.util.*\n\nfun main(args: Array) {\n val cin = Scanner(System.`in`)\n val x1: Int = cin.nextInt()\n val y1: Int = cin.nextInt()\n val x2: Int = cin.nextInt()\n val y2: Int = cin.nextInt()\n \n val x3: Int = x2 + y1 - y2\n val y3: Int = y2 + x2 - x1\n val x4: Int = x1 + y1 - y2\n val y4: Int = y1 + x2 -x1\n println(\"$x3 $y3 $x4 $y4\")\n}", "language": "Kotlin", "metadata": {"date": 1537540966, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03265.html", "problem_id": "p03265", "resource_group": "medium_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/Kotlin/s894627592.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s894627592", "user_id": "u426837411"}, "prompt_components": {"gold_output": "-1 1 -1 0\n", "input_to_evaluate": "import java.util.*\n\nfun main(args: Array) {\n val cin = Scanner(System.`in`)\n val x1: Int = cin.nextInt()\n val y1: Int = cin.nextInt()\n val x2: Int = cin.nextInt()\n val y2: Int = cin.nextInt()\n \n val x3: Int = x2 + y1 - y2\n val y3: Int = y2 + x2 - x1\n val x4: Int = x1 + y1 - y2\n val y4: Int = y1 + x2 -x1\n println(\"$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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 375, "cpu_time_ms": 174, "memory_kb": 29352}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s805073536", "group_id": "codeNet:p03266", "input_text": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val n = sc.nextInt()\n val k = sc.nextInt()\n println(problem108c(n, k))\n}\n\nfun problem108c(n: Int, k: Int): Int {\n var aCount = 0\n for (i in 1..n) {\n if (i % 2 == 0) aCount++\n }\n var bCount = 0\n for (i in 1..n) {\n if (i % k == k / 2) bCount\n }\n var ans = aCount * aCount * aCount\n if (k % 2 == 0) {\n ans += bCount * bCount * bCount\n }\n return ans\n}", "language": "Kotlin", "metadata": {"date": 1591753533, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03266.html", "problem_id": "p03266", "resource_group": "medium_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/Kotlin/s805073536.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s805073536", "user_id": "u073232808"}, "prompt_components": {"gold_output": "9\n", "input_to_evaluate": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val n = sc.nextInt()\n val k = sc.nextInt()\n println(problem108c(n, k))\n}\n\nfun problem108c(n: Int, k: Int): Int {\n var aCount = 0\n for (i in 1..n) {\n if (i % 2 == 0) aCount++\n }\n var bCount = 0\n for (i in 1..n) {\n if (i % k == k / 2) bCount\n }\n var ans = aCount * aCount * aCount\n if (k % 2 == 0) {\n ans += bCount * bCount * bCount\n }\n return ans\n}", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 494, "cpu_time_ms": 195, "memory_kb": 31404}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s232245075", "group_id": "codeNet:p03273", "input_text": "fun main(args:Array) {\n val (h,w) = readLine()!!.split(\" \").map { it.toInt() }\n val target = (1..h).map { readLine()!!.map { it }.toMutableList() }.toMutableList()\n\n var flag = true\n while (flag) {\n flag = false\n if(target.isNotEmpty()) {\n for(i in target[0].lastIndex downTo 0) {\n if(target.all { it[i] == '.' }) {\n target.forEach { it.removeAt(i) }\n flag = true\n }\n }\n for(i in target.lastIndex downTo 0) {\n if(target[i].all { it == '.' }) {\n target.removeAt(i)\n flag = true\n }\n }\n }\n }\n target.forEach { println(it.joinToString(\"\")) }\n}\n\n\n", "language": "Kotlin", "metadata": {"date": 1580489352, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03273.html", "problem_id": "p03273", "resource_group": "medium_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/Kotlin/s232245075.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s232245075", "user_id": "u269969976"}, "prompt_components": {"gold_output": "###\n###\n.##\n", "input_to_evaluate": "fun main(args:Array) {\n val (h,w) = readLine()!!.split(\" \").map { it.toInt() }\n val target = (1..h).map { readLine()!!.map { it }.toMutableList() }.toMutableList()\n\n var flag = true\n while (flag) {\n flag = false\n if(target.isNotEmpty()) {\n for(i in target[0].lastIndex downTo 0) {\n if(target.all { it[i] == '.' }) {\n target.forEach { it.removeAt(i) }\n flag = true\n }\n }\n for(i in target.lastIndex downTo 0) {\n if(target[i].all { it == '.' }) {\n target.removeAt(i)\n flag = true\n }\n }\n }\n }\n target.forEach { println(it.joinToString(\"\")) }\n}\n\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 769, "cpu_time_ms": 308, "memory_kb": 38628}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s980937574", "group_id": "codeNet:p03274", "input_text": "import java.lang.Math.*\n\nfun main(args: Array){\n val (N, K) = readLine()!!.split(\" \").map { it.toInt() }\n val X = readLine()!!.split(\" \").map { it.toLong() }\n\n var min = Long.MAX_VALUE / 10\n for(i in 0..N - K){\n min = min(min, abs(X[i]) + abs(X[i] - X[i + K - 1]))\n min = min(min, abs(X[i + K - 1]) + abs(X[i] - X[i + K - 1]))\n }\n println(min)\n}", "language": "Kotlin", "metadata": {"date": 1590838945, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03274.html", "problem_id": "p03274", "resource_group": "medium_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/Kotlin/s980937574.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s980937574", "user_id": "u531770859"}, "prompt_components": {"gold_output": "40\n", "input_to_evaluate": "import java.lang.Math.*\n\nfun main(args: Array){\n val (N, K) = readLine()!!.split(\" \").map { it.toInt() }\n val X = readLine()!!.split(\" \").map { it.toLong() }\n\n var min = Long.MAX_VALUE / 10\n for(i in 0..N - K){\n min = min(min, abs(X[i]) + abs(X[i] - X[i + K - 1]))\n min = min(min, abs(X[i + K - 1]) + abs(X[i] - X[i + K - 1]))\n }\n println(min)\n}", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 385, "cpu_time_ms": 523, "memory_kb": 51676}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s048390366", "group_id": "codeNet:p03274", "input_text": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val n = sc.nextInt()\n val k = sc.nextInt()\n val x = (0 until n).map { sc.next().toLong() }\n println(problem107c(n, k, x))\n}\n\nfun problem107c(n: Int, k: Int, x: List): Long {\n var min = Long.MAX_VALUE\n for (i in 0 .. n - k) {\n if (i < 0 && x[i + 1] < 0) continue\n if (i > 0 && x[i - 1] > 0) continue\n// debugLog(i, x[i], x[i + k - 1], Math.abs(x[i] - x[i + k - 1]) * 2, Math.abs(x[i] * 2 - x[i + k - 1]))\n if (x[i] > 0) {\n min = Math.min(min, x[i + k - 1])\n continue\n }\n min = listOf(min, Math.abs(x[i] - x[i + k - 1]) * 2, Math.abs(x[i] * 2 - x[i + k - 1])).min()!!\n }\n return min\n}", "language": "Kotlin", "metadata": {"date": 1586674227, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03274.html", "problem_id": "p03274", "resource_group": "medium_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/Kotlin/s048390366.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s048390366", "user_id": "u073232808"}, "prompt_components": {"gold_output": "40\n", "input_to_evaluate": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val n = sc.nextInt()\n val k = sc.nextInt()\n val x = (0 until n).map { sc.next().toLong() }\n println(problem107c(n, k, x))\n}\n\nfun problem107c(n: Int, k: Int, x: List): Long {\n var min = Long.MAX_VALUE\n for (i in 0 .. n - k) {\n if (i < 0 && x[i + 1] < 0) continue\n if (i > 0 && x[i - 1] > 0) continue\n// debugLog(i, x[i], x[i + k - 1], Math.abs(x[i] - x[i + k - 1]) * 2, Math.abs(x[i] * 2 - x[i + k - 1]))\n if (x[i] > 0) {\n min = Math.min(min, x[i + k - 1])\n continue\n }\n min = listOf(min, Math.abs(x[i] - x[i + k - 1]) * 2, Math.abs(x[i] * 2 - x[i + k - 1])).min()!!\n }\n return min\n}", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 758, "memory_kb": 52248}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s725552517", "group_id": "codeNet:p03276", "input_text": "fun ac105(args: Array) {\n val (N, K) = args[0].split(\" \").map { it.toInt() }\n val numList = args[1].split(\" \").map { it.toInt() }\n var ans = Int.MAX_VALUE\n (0 until N + 1 - K).forEach { start ->\n val first = numList[start]\n val last = numList[start + K - 1]\n ans = Math.min(ans, when {\n last <= 0 -> Math.abs(first)\n first >= 0 -> Math.abs(last)\n else -> Math.abs(last - first) + Math.min(Math.abs(last), Math.abs(first))\n })\n }\n println(ans)\n}\n\nfun main(args: Array) {\n ac105(readLineList())\n}\n\nfun readLineList(): Array {\n val lineList = mutableListOf()\n while (true) {\n val line = readLine()\n if (line.isNullOrBlank()) {\n break\n } else {\n lineList.add(line!!)\n }\n }\n return lineList.toTypedArray()\n}", "language": "Kotlin", "metadata": {"date": 1552013590, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03276.html", "problem_id": "p03276", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03276/input.txt", "sample_output_relpath": "derived/input_output/data/p03276/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03276/Kotlin/s725552517.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s725552517", "user_id": "u241874341"}, "prompt_components": {"gold_output": "40\n", "input_to_evaluate": "fun ac105(args: Array) {\n val (N, K) = args[0].split(\" \").map { it.toInt() }\n val numList = args[1].split(\" \").map { it.toInt() }\n var ans = Int.MAX_VALUE\n (0 until N + 1 - K).forEach { start ->\n val first = numList[start]\n val last = numList[start + K - 1]\n ans = Math.min(ans, when {\n last <= 0 -> Math.abs(first)\n first >= 0 -> Math.abs(last)\n else -> Math.abs(last - first) + Math.min(Math.abs(last), Math.abs(first))\n })\n }\n println(ans)\n}\n\nfun main(args: Array) {\n ac105(readLineList())\n}\n\nfun readLineList(): Array {\n val lineList = mutableListOf()\n while (true) {\n val line = readLine()\n if (line.isNullOrBlank()) {\n break\n } else {\n lineList.add(line!!)\n }\n }\n return lineList.toTypedArray()\n}", "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": "p03276", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 878, "cpu_time_ms": 525, "memory_kb": 51712}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s129826156", "group_id": "codeNet:p03280", "input_text": "fun main(args: Array) {\n val a = readLine()!!.toInt()\n val b = readLine()!!.toInt()\n val answer = a * b - a - b + 1\n println(answer)\n}", "language": "Kotlin", "metadata": {"date": 1534641150, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03280.html", "problem_id": "p03280", "resource_group": "medium_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/Kotlin/s129826156.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s129826156", "user_id": "u099066216"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "fun main(args: Array) {\n val a = readLine()!!.toInt()\n val b = readLine()!!.toInt()\n val answer = a * b - a - b + 1\n println(answer)\n}", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 241, "memory_kb": 29924}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s179356203", "group_id": "codeNet:p03282", "input_text": "import java.io.BufferedReader\nimport java.io.InputStreamReader\nimport java.io.PrintWriter\nimport java.util.*\nimport kotlin.math.abs\nimport kotlin.math.min\n\nval br = BufferedReader(InputStreamReader(System.`in`))\nval out = PrintWriter(System.out)\n\nfun main() {\n br.use { out.use {\n solve()\n out.flush()\n } }\n}\n\nfun solve() {\n val s = br.readLine()!!\n val k = readLong()\n val notOneIndex = s.indexOfFirst { it != '1' }\n val ans = if (k <= notOneIndex) {\n 1\n } else {\n s[notOneIndex]\n }\n out.println(ans)\n}\n\nfun readInteger() = Integer.parseInt(br.readLine())\nfun readLong() = java.lang.Long.parseLong(br.readLine())\nfun readStringList() = br.readLine()!!.split(' ')\nfun readIntegerList() = readStringList().map(Integer::parseInt)\nfun readLongList() = readStringList().map(java.lang.Long::parseLong)\nfun readDoubleList() = readStringList().map(java.lang.Double::parseDouble)\n", "language": "Kotlin", "metadata": {"date": 1598234894, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p03282.html", "problem_id": "p03282", "resource_group": "medium_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/Kotlin/s179356203.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s179356203", "user_id": "u784448849"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import java.io.BufferedReader\nimport java.io.InputStreamReader\nimport java.io.PrintWriter\nimport java.util.*\nimport kotlin.math.abs\nimport kotlin.math.min\n\nval br = BufferedReader(InputStreamReader(System.`in`))\nval out = PrintWriter(System.out)\n\nfun main() {\n br.use { out.use {\n solve()\n out.flush()\n } }\n}\n\nfun solve() {\n val s = br.readLine()!!\n val k = readLong()\n val notOneIndex = s.indexOfFirst { it != '1' }\n val ans = if (k <= notOneIndex) {\n 1\n } else {\n s[notOneIndex]\n }\n out.println(ans)\n}\n\nfun readInteger() = Integer.parseInt(br.readLine())\nfun readLong() = java.lang.Long.parseLong(br.readLine())\nfun readStringList() = br.readLine()!!.split(' ')\nfun readIntegerList() = readStringList().map(Integer::parseInt)\nfun readLongList() = readStringList().map(java.lang.Long::parseLong)\nfun readDoubleList() = readStringList().map(java.lang.Double::parseDouble)\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 94, "memory_kb": 34332}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s263052771", "group_id": "codeNet:p03282", "input_text": "fun main(args: Array) {\n val l = readLine()!!.toString().map { it.toInt() - 48}\n val n = readLine()!!.toInt()\n if(l.filter { it == 1 }.count() == l.count() || l.take(n).filter{ it == 1} == l.take(n) ) println(\"1\")\n else println(l.filter{ it != 1}.first())\n}\n", "language": "Kotlin", "metadata": {"date": 1555798341, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03282.html", "problem_id": "p03282", "resource_group": "medium_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/Kotlin/s263052771.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s263052771", "user_id": "u227189389"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "fun main(args: Array) {\n val l = readLine()!!.toString().map { it.toInt() - 48}\n val n = readLine()!!.toInt()\n if(l.filter { it == 1 }.count() == l.count() || l.take(n).filter{ it == 1} == l.take(n) ) println(\"1\")\n else println(l.filter{ it != 1}.first())\n}\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 214, "memory_kb": 33736}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s903962510", "group_id": "codeNet:p03282", "input_text": "fun main(args:Array) {\n\tval s= readLine()!!\n\tval k= readLine()!!.toLong()\n\tif(s.all{it=='1'}){\n\t\tprintln('1')\n\t}else if(k<=s.takeWhile {it=='1'}.length){\n\t\tprintln('1')\n\t}else{\n\t\tprintln(s.first{ it!='1'})\n\t}\n\t\n}", "language": "Kotlin", "metadata": {"date": 1541568745, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03282.html", "problem_id": "p03282", "resource_group": "medium_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/Kotlin/s903962510.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s903962510", "user_id": "u914096045"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "fun main(args:Array) {\n\tval s= readLine()!!\n\tval k= readLine()!!.toLong()\n\tif(s.all{it=='1'}){\n\t\tprintln('1')\n\t}else if(k<=s.takeWhile {it=='1'}.length){\n\t\tprintln('1')\n\t}else{\n\t\tprintln(s.first{ it!='1'})\n\t}\n\t\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 211, "memory_kb": 33708}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s771352473", "group_id": "codeNet:p03282", "input_text": "fun main(args: Array) {\n val s = readLine()!!\n val k = readLine()!!.toLong()\n\n for (i in 1..k) {\n if (s[i.toInt()] != '1') {\n val t = s.filter { it != '1' }\n println(t[0])\n return\n }\n }\n\n println(\"1\")\n}\n", "language": "Kotlin", "metadata": {"date": 1535102636, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03282.html", "problem_id": "p03282", "resource_group": "medium_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/Kotlin/s771352473.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s771352473", "user_id": "u471898432"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "fun main(args: Array) {\n val s = readLine()!!\n val k = readLine()!!.toLong()\n\n for (i in 1..k) {\n if (s[i.toInt()] != '1') {\n val t = s.filter { it != '1' }\n println(t[0])\n return\n }\n }\n\n println(\"1\")\n}\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 210, "memory_kb": 33680}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s046877439", "group_id": "codeNet:p03283", "input_text": "fun main(args: Array) {\n val (n, m, q) = readLine()!!.split(\" \").map(String::toInt)\n\n val lr = mutableListOf>()\n for (i in 1..m) {\n val (l, r) = readLine()!!.split(\" \").map(String::toInt)\n val pair = Pair(l, r)\n lr.add(pair)\n }\n\n val pq = mutableListOf>()\n for (i in 1..q) {\n val (l, r) = readLine()!!.split(\" \").map(String::toInt)\n val pair = Pair(l, r)\n pq.add(pair)\n }\n\n val memo = mutableMapOf, Int>()\n\n for (q in pq) {\n if (memo.containsKey(q)) {\n println(memo[q])\n continue\n }\n\n var count = 0\n for (express in lr) {\n if (q.first <= express.first && express.second <= q.second) {\n count++\n }\n }\n println(count)\n memo[q] = count\n }\n}", "language": "Kotlin", "metadata": {"date": 1534645579, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03283.html", "problem_id": "p03283", "resource_group": "medium_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/Kotlin/s046877439.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s046877439", "user_id": "u367259152"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "fun main(args: Array) {\n val (n, m, q) = readLine()!!.split(\" \").map(String::toInt)\n\n val lr = mutableListOf>()\n for (i in 1..m) {\n val (l, r) = readLine()!!.split(\" \").map(String::toInt)\n val pair = Pair(l, r)\n lr.add(pair)\n }\n\n val pq = mutableListOf>()\n for (i in 1..q) {\n val (l, r) = readLine()!!.split(\" \").map(String::toInt)\n val pair = Pair(l, r)\n pq.add(pair)\n }\n\n val memo = mutableMapOf, Int>()\n\n for (q in pq) {\n if (memo.containsKey(q)) {\n println(memo[q])\n continue\n }\n\n var count = 0\n for (express in lr) {\n if (q.first <= express.first && express.second <= q.second) {\n count++\n }\n }\n println(count)\n memo[q] = count\n }\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 870, "cpu_time_ms": 3163, "memory_kb": 108084}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s928198916", "group_id": "codeNet:p03284", "input_text": "fun main(args : Array) = readLine()!!.split(\" \").map{it.toInt()}.let { println(if (it[0] % it[1] == 0) 0 else 1) }", "language": "Kotlin", "metadata": {"date": 1567173715, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03284.html", "problem_id": "p03284", "resource_group": "medium_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/Kotlin/s928198916.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s928198916", "user_id": "u714769076"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "fun main(args : Array) = readLine()!!.split(\" \").map{it.toInt()}.let { println(if (it[0] % it[1] == 0) 0 else 1) }", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 245, "memory_kb": 37852}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s630734164", "group_id": "codeNet:p03285", "input_text": "fun main(args: Array) = println(run {\n val n = readLine()!!.toInt()\n\n val dp = BooleanArray(111)\n dp[0] = true\n repeat(100) {\n if(dp[it]) {\n dp[it+4] = true\n dp[it+7] = true\n }\n }\n if(dp[n]) \"Yes\" else \"No\"\n\n})\n", "language": "Kotlin", "metadata": {"date": 1588654695, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03285.html", "problem_id": "p03285", "resource_group": "medium_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/Kotlin/s630734164.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s630734164", "user_id": "u563556491"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "fun main(args: Array) = println(run {\n val n = readLine()!!.toInt()\n\n val dp = BooleanArray(111)\n dp[0] = true\n repeat(100) {\n if(dp[it]) {\n dp[it+4] = true\n dp[it+7] = true\n }\n }\n if(dp[n]) \"Yes\" else \"No\"\n\n})\n", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 205, "memory_kb": 31756}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s863261759", "group_id": "codeNet:p03285", "input_text": "fun main(args:Array) {\n val n = readLine()!!.trim().toInt()\n when(n){\n in 1..3-> println(\"No\")\n in 5..6-> println(\"No\")\n 4,7-> println(\"Yes\")\n else->{\n for(i in 0..(n + 6)/7){\n val dif = n - 7*i\n if(dif%4 == 0){\n println(\"Yes\")\n return\n }\n }\n println(\"No\")\n }\n }\n}", "language": "Kotlin", "metadata": {"date": 1534036840, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03285.html", "problem_id": "p03285", "resource_group": "medium_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/Kotlin/s863261759.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s863261759", "user_id": "u803479630"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "fun main(args:Array) {\n val n = readLine()!!.trim().toInt()\n when(n){\n in 1..3-> println(\"No\")\n in 5..6-> println(\"No\")\n 4,7-> println(\"Yes\")\n else->{\n for(i in 0..(n + 6)/7){\n val dif = n - 7*i\n if(dif%4 == 0){\n println(\"Yes\")\n return\n }\n }\n println(\"No\")\n }\n }\n}", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 207, "memory_kb": 33656}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s962435593", "group_id": "codeNet:p03286", "input_text": "fun main(args: Array) {\n val n = readLine()!!\n var numN = n.toLong()\n\n var ans = \"\"\n\n while(numN != 0L) {\n if(numN % 2 != 0L) {\n numN--;\n ans = \"1$ans\";\n } else {\n ans = \"0$ans\";\n }\n numN /= -2;\n }\n\n if(ans == \"\") {\n println(\"0\");\n }else {\n println(ans);\n }\n\n}\n\n", "language": "Kotlin", "metadata": {"date": 1586974534, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03286.html", "problem_id": "p03286", "resource_group": "medium_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/Kotlin/s962435593.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s962435593", "user_id": "u430710262"}, "prompt_components": {"gold_output": "1011\n", "input_to_evaluate": "fun main(args: Array) {\n val n = readLine()!!\n var numN = n.toLong()\n\n var ans = \"\"\n\n while(numN != 0L) {\n if(numN % 2 != 0L) {\n numN--;\n ans = \"1$ans\";\n } else {\n ans = \"0$ans\";\n }\n numN /= -2;\n }\n\n if(ans == \"\") {\n println(\"0\");\n }else {\n println(ans);\n }\n\n}\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 369, "cpu_time_ms": 199, "memory_kb": 31840}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s958122784", "group_id": "codeNet:p03289", "input_text": "fun main(arr:Array) {\n val s = readLine()!!\n println(if(isAc(s)) \"AC\" else \"WA\")\n}\n\n\nfun isAc(s:String):Boolean {\n if(s[0] != 'A') {\n return false\n }\n if(s.substring(2 until s.length-1).count { it == 'C' } != 1) {\n return false\n }\n if(s.count { it == 'C' } != 1) {\n return false\n }\n if(s.substring(1).filter { it != 'C' }.all { it in ('a'..'z') }) {\n return true\n }\n return false\n}", "language": "Kotlin", "metadata": {"date": 1592553577, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p03289.html", "problem_id": "p03289", "resource_group": "medium_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/Kotlin/s958122784.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s958122784", "user_id": "u269969976"}, "prompt_components": {"gold_output": "AC\n", "input_to_evaluate": "fun main(arr:Array) {\n val s = readLine()!!\n println(if(isAc(s)) \"AC\" else \"WA\")\n}\n\n\nfun isAc(s:String):Boolean {\n if(s[0] != 'A') {\n return false\n }\n if(s.substring(2 until s.length-1).count { it == 'C' } != 1) {\n return false\n }\n if(s.count { it == 'C' } != 1) {\n return false\n }\n if(s.substring(1).filter { it != 'C' }.all { it in ('a'..'z') }) {\n return true\n }\n return false\n}", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 110, "memory_kb": 36024}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s622544742", "group_id": "codeNet:p03289", "input_text": "import java.util.*\n\nval sc = Scanner(System.`in`)\nvar S: String = sc.next()\n\nfun main(args: Array) {\n println(if (judge(S)) \"AC\" else \"WA\")\n}\n\nfun judge(s: String): Boolean {\n if (s[0] != 'A') {\n return false\n }\n var flg = false\n for (i in 1 until s.length) {\n if (s[i].isUpperCase()) {\n if (s[i] != 'C' || i == 1 || i == s.length - 1 || flg) {\n return false\n }\n flg = true\n }\n }\n if (!flg) {\n return false\n }\n return true\n}\n", "language": "Kotlin", "metadata": {"date": 1541902924, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03289.html", "problem_id": "p03289", "resource_group": "medium_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/Kotlin/s622544742.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s622544742", "user_id": "u323680411"}, "prompt_components": {"gold_output": "AC\n", "input_to_evaluate": "import java.util.*\n\nval sc = Scanner(System.`in`)\nvar S: String = sc.next()\n\nfun main(args: Array) {\n println(if (judge(S)) \"AC\" else \"WA\")\n}\n\nfun judge(s: String): Boolean {\n if (s[0] != 'A') {\n return false\n }\n var flg = false\n for (i in 1 until s.length) {\n if (s[i].isUpperCase()) {\n if (s[i] != 'C' || i == 1 || i == s.length - 1 || flg) {\n return false\n }\n flg = true\n }\n }\n if (!flg) {\n return false\n }\n return true\n}\n", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 188, "memory_kb": 31268}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s723660913", "group_id": "codeNet:p03290", "input_text": "import java.math.*\n\nfun main(args: Array) {\n val (D, G) = readInputLine().split(\" \").map{it.toInt()}\n \n // (i, 問題数, ボーナス)\n val problems = mutableListOf>()\n \n for (i in 1..D) {\n val tmp = readInputLine().split(\" \").map{it.toInt()}\n problems.add(Triple(i, tmp[0], tmp[1]))\n }\n \n problems.sortByDescending{(it.second * it.first * 100 + it.third) / it.second.toDouble()}\n \n var ans = 0\n var score = 0\n \n for (e in problems) {\n if (score + e.second * e.first * 100 + e.third >= G) {\n ans += Math.min((G - score) / e.first / 100, e.second)\n break\n } else {\n ans += e.second\n score += e.second * e.first * 100 + e.third\n }\n }\n \n println(ans)\n}\n\nfun readInputLine(): String {\n return readLine()!!\n}\n", "language": "Kotlin", "metadata": {"date": 1565449369, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03290.html", "problem_id": "p03290", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03290/input.txt", "sample_output_relpath": "derived/input_output/data/p03290/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03290/Kotlin/s723660913.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s723660913", "user_id": "u505558493"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "import java.math.*\n\nfun main(args: Array) {\n val (D, G) = readInputLine().split(\" \").map{it.toInt()}\n \n // (i, 問題数, ボーナス)\n val problems = mutableListOf>()\n \n for (i in 1..D) {\n val tmp = readInputLine().split(\" \").map{it.toInt()}\n problems.add(Triple(i, tmp[0], tmp[1]))\n }\n \n problems.sortByDescending{(it.second * it.first * 100 + it.third) / it.second.toDouble()}\n \n var ans = 0\n var score = 0\n \n for (e in problems) {\n if (score + e.second * e.first * 100 + e.third >= G) {\n ans += Math.min((G - score) / e.first / 100, e.second)\n break\n } else {\n ans += e.second\n score += e.second * e.first * 100 + e.third\n }\n }\n \n println(ans)\n}\n\nfun readInputLine(): String {\n return readLine()!!\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nA programming competition site AtCode provides algorithmic problems.\nEach problem is allocated a score based on its difficulty.\nCurrently, for each integer i between 1 and D (inclusive), there are p_i problems with a score of 100i points.\nThese p_1 + … + p_D problems are all of the problems available on AtCode.\n\nA user of AtCode has a value called total score.\nThe total score of a user is the sum of the following two elements:\n\nBase score: the sum of the scores of all problems solved by the user.\n\nPerfect bonuses: when a user solves all problems with a score of 100i points, he/she earns the perfect bonus of c_i points, aside from the base score (1 ≤ i ≤ D).\n\nTakahashi, who is the new user of AtCode, has not solved any problem.\nHis objective is to have a total score of G or more points.\nAt least how many problems does he need to solve for this objective?\n\nConstraints\n\n1 ≤ D ≤ 10\n\n1 ≤ p_i ≤ 100\n\n100 ≤ c_i ≤ 10^6\n\n100 ≤ G\n\nAll values in input are integers.\n\nc_i and G are all multiples of 100.\n\nIt is possible to have a total score of G or more points.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nD G\np_1 c_1\n:\np_D c_D\n\nOutput\n\nPrint the minimum number of problems that needs to be solved in order to have a total score of G or more points. Note that this objective is always achievable (see Constraints).\n\nSample Input 1\n\n2 700\n3 500\n5 800\n\nSample Output 1\n\n3\n\nIn this case, there are three problems each with 100 points and five problems each with 200 points. The perfect bonus for solving all the 100-point problems is 500 points, and the perfect bonus for solving all the 200-point problems is 800 points. Takahashi's objective is to have a total score of 700 points or more.\n\nOne way to achieve this objective is to solve four 200-point problems and earn a base score of 800 points. However, if we solve three 100-point problems, we can earn the perfect bonus of 500 points in addition to the base score of 300 points, for a total score of 800 points, and we can achieve the objective with fewer problems.\n\nSample Input 2\n\n2 2000\n3 500\n5 800\n\nSample Output 2\n\n7\n\nThis case is similar to Sample Input 1, but the Takahashi's objective this time is 2000 points or more. In this case, we inevitably need to solve all five 200-point problems, and by solving two 100-point problems additionally we have the total score of 2000 points.\n\nSample Input 3\n\n2 400\n3 500\n5 800\n\nSample Output 3\n\n2\n\nThis case is again similar to Sample Input 1, but the Takahashi's objective this time is 400 points or more. In this case, we only need to solve two 200-point problems to achieve the objective.\n\nSample Input 4\n\n5 25000\n20 1000\n40 1000\n50 1000\n30 1000\n1 1000\n\nSample Output 4\n\n66\n\nThere is only one 500-point problem, but the perfect bonus can be earned even in such a case.", "sample_input": "2 700\n3 500\n5 800\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03290", "source_text": "Score : 300 points\n\nProblem Statement\n\nA programming competition site AtCode provides algorithmic problems.\nEach problem is allocated a score based on its difficulty.\nCurrently, for each integer i between 1 and D (inclusive), there are p_i problems with a score of 100i points.\nThese p_1 + … + p_D problems are all of the problems available on AtCode.\n\nA user of AtCode has a value called total score.\nThe total score of a user is the sum of the following two elements:\n\nBase score: the sum of the scores of all problems solved by the user.\n\nPerfect bonuses: when a user solves all problems with a score of 100i points, he/she earns the perfect bonus of c_i points, aside from the base score (1 ≤ i ≤ D).\n\nTakahashi, who is the new user of AtCode, has not solved any problem.\nHis objective is to have a total score of G or more points.\nAt least how many problems does he need to solve for this objective?\n\nConstraints\n\n1 ≤ D ≤ 10\n\n1 ≤ p_i ≤ 100\n\n100 ≤ c_i ≤ 10^6\n\n100 ≤ G\n\nAll values in input are integers.\n\nc_i and G are all multiples of 100.\n\nIt is possible to have a total score of G or more points.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nD G\np_1 c_1\n:\np_D c_D\n\nOutput\n\nPrint the minimum number of problems that needs to be solved in order to have a total score of G or more points. Note that this objective is always achievable (see Constraints).\n\nSample Input 1\n\n2 700\n3 500\n5 800\n\nSample Output 1\n\n3\n\nIn this case, there are three problems each with 100 points and five problems each with 200 points. The perfect bonus for solving all the 100-point problems is 500 points, and the perfect bonus for solving all the 200-point problems is 800 points. Takahashi's objective is to have a total score of 700 points or more.\n\nOne way to achieve this objective is to solve four 200-point problems and earn a base score of 800 points. However, if we solve three 100-point problems, we can earn the perfect bonus of 500 points in addition to the base score of 300 points, for a total score of 800 points, and we can achieve the objective with fewer problems.\n\nSample Input 2\n\n2 2000\n3 500\n5 800\n\nSample Output 2\n\n7\n\nThis case is similar to Sample Input 1, but the Takahashi's objective this time is 2000 points or more. In this case, we inevitably need to solve all five 200-point problems, and by solving two 100-point problems additionally we have the total score of 2000 points.\n\nSample Input 3\n\n2 400\n3 500\n5 800\n\nSample Output 3\n\n2\n\nThis case is again similar to Sample Input 1, but the Takahashi's objective this time is 400 points or more. In this case, we only need to solve two 200-point problems to achieve the objective.\n\nSample Input 4\n\n5 25000\n20 1000\n40 1000\n50 1000\n30 1000\n1 1000\n\nSample Output 4\n\n66\n\nThere is only one 500-point problem, but the perfect bonus can be earned even in such a case.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 868, "cpu_time_ms": 239, "memory_kb": 38004}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s191522280", "group_id": "codeNet:p03290", "input_text": "fun main(args: Array) {\n val (dt, g) = readLine()!!.split(' ').map(String::toLong)\n val d = dt.toInt()\n val pArray = Array(d + 1) { arrayOfNulls(101) }\n val scoreArray = Array(1001) { null }\n scoreArray[0] = 0L\n for (i in 1..d) {\n val (p, c) = readLine()!!.split(' ').map(String::toLong)\n for (j in 1..p.toInt()) {\n pArray[i][j] = (i.toLong() * 100) * j\n if (j == p.toInt()) pArray[i][j] = pArray[i][j]!! + c\n }\n }\n\n for (i in 1..d) {\n var selectNum = 1\n val scoreArrayBefore = scoreArray.copyOf()\n while (selectNum != 101 && pArray[i][selectNum] != null) {\n for (k in 1..1000) {\n if (selectNum > k) continue\n val value = scoreArrayBefore[k - selectNum] ?: break\n if (scoreArray[k] == null ||\n scoreArrayBefore[k] ?: 0 < (value + pArray[i][selectNum]!!)) {\n scoreArray[k] = value + pArray[i][selectNum]!!\n }\n if (scoreArray[k] ?: 0 >= g) break\n }\n selectNum++\n }\n }\n for (i in 1..1000) {\n if (scoreArray[i] ?: 0 >= g) {\n println(i)\n break\n }\n }\n}", "language": "Kotlin", "metadata": {"date": 1533523108, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03290.html", "problem_id": "p03290", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03290/input.txt", "sample_output_relpath": "derived/input_output/data/p03290/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03290/Kotlin/s191522280.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s191522280", "user_id": "u099066216"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "fun main(args: Array) {\n val (dt, g) = readLine()!!.split(' ').map(String::toLong)\n val d = dt.toInt()\n val pArray = Array(d + 1) { arrayOfNulls(101) }\n val scoreArray = Array(1001) { null }\n scoreArray[0] = 0L\n for (i in 1..d) {\n val (p, c) = readLine()!!.split(' ').map(String::toLong)\n for (j in 1..p.toInt()) {\n pArray[i][j] = (i.toLong() * 100) * j\n if (j == p.toInt()) pArray[i][j] = pArray[i][j]!! + c\n }\n }\n\n for (i in 1..d) {\n var selectNum = 1\n val scoreArrayBefore = scoreArray.copyOf()\n while (selectNum != 101 && pArray[i][selectNum] != null) {\n for (k in 1..1000) {\n if (selectNum > k) continue\n val value = scoreArrayBefore[k - selectNum] ?: break\n if (scoreArray[k] == null ||\n scoreArrayBefore[k] ?: 0 < (value + pArray[i][selectNum]!!)) {\n scoreArray[k] = value + pArray[i][selectNum]!!\n }\n if (scoreArray[k] ?: 0 >= g) break\n }\n selectNum++\n }\n }\n for (i in 1..1000) {\n if (scoreArray[i] ?: 0 >= g) {\n println(i)\n break\n }\n }\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nA programming competition site AtCode provides algorithmic problems.\nEach problem is allocated a score based on its difficulty.\nCurrently, for each integer i between 1 and D (inclusive), there are p_i problems with a score of 100i points.\nThese p_1 + … + p_D problems are all of the problems available on AtCode.\n\nA user of AtCode has a value called total score.\nThe total score of a user is the sum of the following two elements:\n\nBase score: the sum of the scores of all problems solved by the user.\n\nPerfect bonuses: when a user solves all problems with a score of 100i points, he/she earns the perfect bonus of c_i points, aside from the base score (1 ≤ i ≤ D).\n\nTakahashi, who is the new user of AtCode, has not solved any problem.\nHis objective is to have a total score of G or more points.\nAt least how many problems does he need to solve for this objective?\n\nConstraints\n\n1 ≤ D ≤ 10\n\n1 ≤ p_i ≤ 100\n\n100 ≤ c_i ≤ 10^6\n\n100 ≤ G\n\nAll values in input are integers.\n\nc_i and G are all multiples of 100.\n\nIt is possible to have a total score of G or more points.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nD G\np_1 c_1\n:\np_D c_D\n\nOutput\n\nPrint the minimum number of problems that needs to be solved in order to have a total score of G or more points. Note that this objective is always achievable (see Constraints).\n\nSample Input 1\n\n2 700\n3 500\n5 800\n\nSample Output 1\n\n3\n\nIn this case, there are three problems each with 100 points and five problems each with 200 points. The perfect bonus for solving all the 100-point problems is 500 points, and the perfect bonus for solving all the 200-point problems is 800 points. Takahashi's objective is to have a total score of 700 points or more.\n\nOne way to achieve this objective is to solve four 200-point problems and earn a base score of 800 points. However, if we solve three 100-point problems, we can earn the perfect bonus of 500 points in addition to the base score of 300 points, for a total score of 800 points, and we can achieve the objective with fewer problems.\n\nSample Input 2\n\n2 2000\n3 500\n5 800\n\nSample Output 2\n\n7\n\nThis case is similar to Sample Input 1, but the Takahashi's objective this time is 2000 points or more. In this case, we inevitably need to solve all five 200-point problems, and by solving two 100-point problems additionally we have the total score of 2000 points.\n\nSample Input 3\n\n2 400\n3 500\n5 800\n\nSample Output 3\n\n2\n\nThis case is again similar to Sample Input 1, but the Takahashi's objective this time is 400 points or more. In this case, we only need to solve two 200-point problems to achieve the objective.\n\nSample Input 4\n\n5 25000\n20 1000\n40 1000\n50 1000\n30 1000\n1 1000\n\nSample Output 4\n\n66\n\nThere is only one 500-point problem, but the perfect bonus can be earned even in such a case.", "sample_input": "2 700\n3 500\n5 800\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03290", "source_text": "Score : 300 points\n\nProblem Statement\n\nA programming competition site AtCode provides algorithmic problems.\nEach problem is allocated a score based on its difficulty.\nCurrently, for each integer i between 1 and D (inclusive), there are p_i problems with a score of 100i points.\nThese p_1 + … + p_D problems are all of the problems available on AtCode.\n\nA user of AtCode has a value called total score.\nThe total score of a user is the sum of the following two elements:\n\nBase score: the sum of the scores of all problems solved by the user.\n\nPerfect bonuses: when a user solves all problems with a score of 100i points, he/she earns the perfect bonus of c_i points, aside from the base score (1 ≤ i ≤ D).\n\nTakahashi, who is the new user of AtCode, has not solved any problem.\nHis objective is to have a total score of G or more points.\nAt least how many problems does he need to solve for this objective?\n\nConstraints\n\n1 ≤ D ≤ 10\n\n1 ≤ p_i ≤ 100\n\n100 ≤ c_i ≤ 10^6\n\n100 ≤ G\n\nAll values in input are integers.\n\nc_i and G are all multiples of 100.\n\nIt is possible to have a total score of G or more points.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nD G\np_1 c_1\n:\np_D c_D\n\nOutput\n\nPrint the minimum number of problems that needs to be solved in order to have a total score of G or more points. Note that this objective is always achievable (see Constraints).\n\nSample Input 1\n\n2 700\n3 500\n5 800\n\nSample Output 1\n\n3\n\nIn this case, there are three problems each with 100 points and five problems each with 200 points. The perfect bonus for solving all the 100-point problems is 500 points, and the perfect bonus for solving all the 200-point problems is 800 points. Takahashi's objective is to have a total score of 700 points or more.\n\nOne way to achieve this objective is to solve four 200-point problems and earn a base score of 800 points. However, if we solve three 100-point problems, we can earn the perfect bonus of 500 points in addition to the base score of 300 points, for a total score of 800 points, and we can achieve the objective with fewer problems.\n\nSample Input 2\n\n2 2000\n3 500\n5 800\n\nSample Output 2\n\n7\n\nThis case is similar to Sample Input 1, but the Takahashi's objective this time is 2000 points or more. In this case, we inevitably need to solve all five 200-point problems, and by solving two 100-point problems additionally we have the total score of 2000 points.\n\nSample Input 3\n\n2 400\n3 500\n5 800\n\nSample Output 3\n\n2\n\nThis case is again similar to Sample Input 1, but the Takahashi's objective this time is 400 points or more. In this case, we only need to solve two 200-point problems to achieve the objective.\n\nSample Input 4\n\n5 25000\n20 1000\n40 1000\n50 1000\n30 1000\n1 1000\n\nSample Output 4\n\n66\n\nThere is only one 500-point problem, but the perfect bonus can be earned even in such a case.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1257, "cpu_time_ms": 387, "memory_kb": 38668}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s333776429", "group_id": "codeNet:p03293", "input_text": "import java.io.PrintWriter\nval pw = PrintWriter(System.out)\n\nfun main(args : Array) {\n func()\n pw.flush()\n}\n\nfun func() {\n var s = next()\n val t = next()\n\n for (i in 1..s.length) {\n s = s.takeLast(1) + s.take(s.length-1)\n if (s == t) {\n println(\"Yes\")\n return\n }\n }\n\n println(\"No\")\n}\n\nfun next() = readLine()!!\n\nfun println(value : Any) {\n pw.println(value)\n}", "language": "Kotlin", "metadata": {"date": 1569664423, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03293.html", "problem_id": "p03293", "resource_group": "medium_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/Kotlin/s333776429.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s333776429", "user_id": "u262403099"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "import java.io.PrintWriter\nval pw = PrintWriter(System.out)\n\nfun main(args : Array) {\n func()\n pw.flush()\n}\n\nfun func() {\n var s = next()\n val t = next()\n\n for (i in 1..s.length) {\n s = s.takeLast(1) + s.take(s.length-1)\n if (s == t) {\n println(\"Yes\")\n return\n }\n }\n\n println(\"No\")\n}\n\nfun next() = readLine()!!\n\nfun println(value : Any) {\n pw.println(value)\n}", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 213, "memory_kb": 31852}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s115478065", "group_id": "codeNet:p03293", "input_text": "fun main(args: Array) {\n val s = readLine()!!\n val t = readLine()!!\n for (i in s.indices) {\n if (t == (s.substring(i) + s.substring(0, i))) {\n println(\"Yes\")\n return\n }\n }\n println(\"No\")\n}", "language": "Kotlin", "metadata": {"date": 1532225200, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03293.html", "problem_id": "p03293", "resource_group": "medium_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/Kotlin/s115478065.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s115478065", "user_id": "u562793957"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "fun main(args: Array) {\n val s = readLine()!!\n val t = readLine()!!\n for (i in s.indices) {\n if (t == (s.substring(i) + s.substring(0, i))) {\n println(\"Yes\")\n return\n }\n }\n println(\"No\")\n}", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 283, "memory_kb": 33776}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s785874788", "group_id": "codeNet:p03295", "input_text": "import java.util.*\n\nfun main(args: Array) {\n abc103d()\n}\n\n// これで間に合ったらなんやねん\nfun abc103d() {\n val (n, m) = readLine()!!.split(' ').map { it.toInt() }\n val abList = (1..m)\n .map { readLine()!!.split(' ').map { it.toInt() }.let { it[0] to it[1] } }\n .sortedBy { it.first }\n\n val queue = PriorityQueue(abList.size, Comparator> { o1, o2 -> o1.first - o2.first })\n queue.addAll(abList)\n\n var rightestList = abList.map { it.second }.sorted()\n var left: Int\n var answer = 0\n\n while (queue.isNotEmpty()) {\n left = rightestList.first()\n answer++\n while (queue.isNotEmpty() && queue.peek().first < left) queue.poll()\n rightestList = queue.map { it.second }.sorted()\n }\n\n println(answer)\n}\n", "language": "Kotlin", "metadata": {"date": 1580272206, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03295.html", "problem_id": "p03295", "resource_group": "medium_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/Kotlin/s785874788.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s785874788", "user_id": "u139478771"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "import java.util.*\n\nfun main(args: Array) {\n abc103d()\n}\n\n// これで間に合ったらなんやねん\nfun abc103d() {\n val (n, m) = readLine()!!.split(' ').map { it.toInt() }\n val abList = (1..m)\n .map { readLine()!!.split(' ').map { it.toInt() }.let { it[0] to it[1] } }\n .sortedBy { it.first }\n\n val queue = PriorityQueue(abList.size, Comparator> { o1, o2 -> o1.first - o2.first })\n queue.addAll(abList)\n\n var rightestList = abList.map { it.second }.sorted()\n var left: Int\n var answer = 0\n\n while (queue.isNotEmpty()) {\n left = rightestList.first()\n answer++\n while (queue.isNotEmpty() && queue.peek().first < left) queue.poll()\n rightestList = queue.map { it.second }.sorted()\n }\n\n println(answer)\n}\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 804, "cpu_time_ms": 2123, "memory_kb": 115656}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s189496515", "group_id": "codeNet:p03295", "input_text": "fun main(args: Array) {\n val (n, m) = readLine()!!.split(\" \").map(String::toInt)\n val xs: MutableList> = mutableListOf()\n for (i in 1..m) {\n val (a, b) = readLine()!!.split(\" \").map(String::toInt)\n xs.add(Pair(a, b))\n }\n\n xs.sortBy { it.second }\n\n var count = 0\n var prev = 0\n if (xs.isNotEmpty()) {\n count = 1\n prev = xs[0].second - 1\n }\n\n for (i in 1 until xs.size) {\n val pair = xs[i]\n if (pair.first <= prev) {\n continue\n }\n\n count++\n prev = pair.second - 1\n }\n\n println(count)\n}", "language": "Kotlin", "metadata": {"date": 1532385784, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03295.html", "problem_id": "p03295", "resource_group": "medium_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/Kotlin/s189496515.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s189496515", "user_id": "u367259152"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "fun main(args: Array) {\n val (n, m) = readLine()!!.split(\" \").map(String::toInt)\n val xs: MutableList> = mutableListOf()\n for (i in 1..m) {\n val (a, b) = readLine()!!.split(\" \").map(String::toInt)\n xs.add(Pair(a, b))\n }\n\n xs.sortBy { it.second }\n\n var count = 0\n var prev = 0\n if (xs.isNotEmpty()) {\n count = 1\n prev = xs[0].second - 1\n }\n\n for (i in 1 until xs.size) {\n val pair = xs[i]\n if (pair.first <= prev) {\n continue\n }\n\n count++\n prev = pair.second - 1\n }\n\n println(count)\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 616, "cpu_time_ms": 827, "memory_kb": 81628}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s048373921", "group_id": "codeNet:p03304", "input_text": "import java.io.*\nimport java.util.*\nimport java.lang.*\nimport java.lang.Math.*\n\n\nfun solve() {\n val (N, M, D) = rd.readListLong()\n\n var cnt = 0L\n if (D == 0L) {\n cnt = N\n } else {\n for (x in 1..N) {\n if (x - D >= 1) cnt++\n if (x + D <= N) cnt++\n }\n }\n cnt *= (M-1)\n\n val ans = cnt / (N*N).toDouble()\n println(\"%.10f\".format(ans))\n}\n\n\n//val rd = debug.Reader(\"etc\", \"soundhound2018-summer-qual\", \"c\", \"sample-2\")\nval rd = Reader()\n\n\nfun main(args: Array) {\n try {\n var exception: Throwable? = null\n val sth = Thread(null, SolveThread(), \"solveThread\", 128 * 1024 * 1024)\n sth.setUncaughtExceptionHandler { _, e -> exception = e }\n sth.start(); sth.join()\n if (exception != null) throw exception!! }\n catch (e: Exception) { throw e }\n finally { rd.close() }\n}\nconst val MOD = 1_000_000_007L; const val INF = Int.MAX_VALUE/2; const val LINF = Long.MAX_VALUE/2\nconst val EPS = 1e-9; fun DBLEQ(a: Double, b: Double): Boolean {return abs(a - b) < EPS}\ndata class IntPair(val first: Int, val second: Int)\ndata class To(val idx: Int, val cost: Long)\ntypealias ALI = ArrayList\nfun edge(V: Int): Array> { return Array(V){ArrayList()} }\nval errPrintln: (Any) -> Unit = { msg -> System.err.println(msg) }\nfun rAssert(exp: Boolean, lazyMsg: () -> String = {\"\"}) {\n if (!exp) { val msg = lazyMsg(); errPrintln(\"EAssert Error: $msg\"); throw Error(msg) }\n}\nfun tAssert(exp: Boolean, lazyMsg: () -> String = {\"\"}) {\n if (!exp) { val msg = lazyMsg(); errPrintln(\"TAssert Error: $msg\"); Thread.sleep(3000) }\n}\nclass SolveThread : Runnable {\n override fun run() { solve() }\n}\nclass Reader {\n private val br = BufferedReader(InputStreamReader(System.`in`))\n val readString: () -> String = { br.readLine() }\n val readInt: () -> Int = { br.readLine().toInt() }\n val readLong: () -> Long = { br.readLine().toLong() }\n val readIntArray: () -> IntArray = { br.readLine().split(' ').map { it.toInt() }.toIntArray() }\n val readLongArray: () -> LongArray = { br.readLine().split(' ').map { it.toLong() }.toLongArray() }\n val readListInt: () -> List = { br.readLine().split(' ').map { it.toInt() } }\n val readListLong: () -> List = { br.readLine().split(' ').map { it.toLong() } }\n val readListIntCol: (Int) -> List = { N -> (0 until N).map { readInt() } }\n val readListIntCols: (Int) -> List> = { N -> (0 until N).map { br.readLine().split(' ').map { it.toInt() } } }\n val readListLongCol: (Int) -> List = { N -> (0 until N).map { readLong() } }\n val readListLongCols: (Int) -> List> = { N -> (0 until N).map { br.readLine().split(' ').map { it.toLong() } } }\n val close: () -> Unit = { br.close() }\n protected fun finalize() { close() }\n}\n", "language": "Kotlin", "metadata": {"date": 1599536270, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p03304.html", "problem_id": "p03304", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03304/input.txt", "sample_output_relpath": "derived/input_output/data/p03304/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03304/Kotlin/s048373921.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s048373921", "user_id": "u404244809"}, "prompt_components": {"gold_output": "1.0000000000\n", "input_to_evaluate": "import java.io.*\nimport java.util.*\nimport java.lang.*\nimport java.lang.Math.*\n\n\nfun solve() {\n val (N, M, D) = rd.readListLong()\n\n var cnt = 0L\n if (D == 0L) {\n cnt = N\n } else {\n for (x in 1..N) {\n if (x - D >= 1) cnt++\n if (x + D <= N) cnt++\n }\n }\n cnt *= (M-1)\n\n val ans = cnt / (N*N).toDouble()\n println(\"%.10f\".format(ans))\n}\n\n\n//val rd = debug.Reader(\"etc\", \"soundhound2018-summer-qual\", \"c\", \"sample-2\")\nval rd = Reader()\n\n\nfun main(args: Array) {\n try {\n var exception: Throwable? = null\n val sth = Thread(null, SolveThread(), \"solveThread\", 128 * 1024 * 1024)\n sth.setUncaughtExceptionHandler { _, e -> exception = e }\n sth.start(); sth.join()\n if (exception != null) throw exception!! }\n catch (e: Exception) { throw e }\n finally { rd.close() }\n}\nconst val MOD = 1_000_000_007L; const val INF = Int.MAX_VALUE/2; const val LINF = Long.MAX_VALUE/2\nconst val EPS = 1e-9; fun DBLEQ(a: Double, b: Double): Boolean {return abs(a - b) < EPS}\ndata class IntPair(val first: Int, val second: Int)\ndata class To(val idx: Int, val cost: Long)\ntypealias ALI = ArrayList\nfun edge(V: Int): Array> { return Array(V){ArrayList()} }\nval errPrintln: (Any) -> Unit = { msg -> System.err.println(msg) }\nfun rAssert(exp: Boolean, lazyMsg: () -> String = {\"\"}) {\n if (!exp) { val msg = lazyMsg(); errPrintln(\"EAssert Error: $msg\"); throw Error(msg) }\n}\nfun tAssert(exp: Boolean, lazyMsg: () -> String = {\"\"}) {\n if (!exp) { val msg = lazyMsg(); errPrintln(\"TAssert Error: $msg\"); Thread.sleep(3000) }\n}\nclass SolveThread : Runnable {\n override fun run() { solve() }\n}\nclass Reader {\n private val br = BufferedReader(InputStreamReader(System.`in`))\n val readString: () -> String = { br.readLine() }\n val readInt: () -> Int = { br.readLine().toInt() }\n val readLong: () -> Long = { br.readLine().toLong() }\n val readIntArray: () -> IntArray = { br.readLine().split(' ').map { it.toInt() }.toIntArray() }\n val readLongArray: () -> LongArray = { br.readLine().split(' ').map { it.toLong() }.toLongArray() }\n val readListInt: () -> List = { br.readLine().split(' ').map { it.toInt() } }\n val readListLong: () -> List = { br.readLine().split(' ').map { it.toLong() } }\n val readListIntCol: (Int) -> List = { N -> (0 until N).map { readInt() } }\n val readListIntCols: (Int) -> List> = { N -> (0 until N).map { br.readLine().split(' ').map { it.toInt() } } }\n val readListLongCol: (Int) -> List = { N -> (0 until N).map { readLong() } }\n val readListLongCols: (Int) -> List> = { N -> (0 until N).map { br.readLine().split(' ').map { it.toLong() } } }\n val close: () -> Unit = { br.close() }\n protected fun finalize() { close() }\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nLet us define the beauty of a sequence (a_1,... ,a_n) as the number of pairs of two adjacent elements in it whose absolute differences are d.\nFor example, when d=1, the beauty of the sequence (3, 2, 3, 10, 9) is 3.\n\nThere are a total of n^m sequences of length m where each element is an integer between 1 and n (inclusive).\nFind the beauty of each of these n^m sequences, and print the average of those values.\n\nConstraints\n\n0 \\leq d < n \\leq 10^9\n\n2 \\leq m \\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 m d\n\nOutput\n\nPrint the average of the beauties of the sequences of length m where each element is an integer between 1 and n.\nThe output will be judged correct if the absolute or relative error is at most 10^{-6}.\n\nSample Input 1\n\n2 3 1\n\nSample Output 1\n\n1.0000000000\n\nThe beauty of (1,1,1) is 0.\n\nThe beauty of (1,1,2) is 1.\n\nThe beauty of (1,2,1) is 2.\n\nThe beauty of (1,2,2) is 1.\n\nThe beauty of (2,1,1) is 1.\n\nThe beauty of (2,1,2) is 2.\n\nThe beauty of (2,2,1) is 1.\n\nThe beauty of (2,2,2) is 0.\n\nThe answer is the average of these values: (0+1+2+1+1+2+1+0)/8=1.\n\nSample Input 2\n\n1000000000 180707 0\n\nSample Output 2\n\n0.0001807060", "sample_input": "2 3 1\n"}, "reference_outputs": ["1.0000000000\n"], "source_document_id": "p03304", "source_text": "Score : 300 points\n\nProblem Statement\n\nLet us define the beauty of a sequence (a_1,... ,a_n) as the number of pairs of two adjacent elements in it whose absolute differences are d.\nFor example, when d=1, the beauty of the sequence (3, 2, 3, 10, 9) is 3.\n\nThere are a total of n^m sequences of length m where each element is an integer between 1 and n (inclusive).\nFind the beauty of each of these n^m sequences, and print the average of those values.\n\nConstraints\n\n0 \\leq d < n \\leq 10^9\n\n2 \\leq m \\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 m d\n\nOutput\n\nPrint the average of the beauties of the sequences of length m where each element is an integer between 1 and n.\nThe output will be judged correct if the absolute or relative error is at most 10^{-6}.\n\nSample Input 1\n\n2 3 1\n\nSample Output 1\n\n1.0000000000\n\nThe beauty of (1,1,1) is 0.\n\nThe beauty of (1,1,2) is 1.\n\nThe beauty of (1,2,1) is 2.\n\nThe beauty of (1,2,2) is 1.\n\nThe beauty of (2,1,1) is 1.\n\nThe beauty of (2,1,2) is 2.\n\nThe beauty of (2,2,1) is 1.\n\nThe beauty of (2,2,2) is 0.\n\nThe answer is the average of these values: (0+1+2+1+1+2+1+0)/8=1.\n\nSample Input 2\n\n1000000000 180707 0\n\nSample Output 2\n\n0.0001807060", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2848, "cpu_time_ms": 525, "memory_kb": 38076}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s648864094", "group_id": "codeNet:p03307", "input_text": "fun main(args: Array) {\n val N = readInputLine().toLong()\n \n println(if (N % 2L == 0L) N else N * 2L)\n}\n\nfun readInputLine(): String {\n return readLine()!!\n}\n", "language": "Kotlin", "metadata": {"date": 1567959014, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03307.html", "problem_id": "p03307", "resource_group": "medium_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/Kotlin/s648864094.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s648864094", "user_id": "u505558493"}, "prompt_components": {"gold_output": "6\n", "input_to_evaluate": "fun main(args: Array) {\n val N = readInputLine().toLong()\n \n println(if (N % 2L == 0L) N else N * 2L)\n}\n\nfun readInputLine(): String {\n return readLine()!!\n}\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 202, "memory_kb": 31632}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s988475779", "group_id": "codeNet:p03307", "input_text": "fun main(args: Array) {\n val N = readLine()!!.toInt()\n \n if (N % 2 == 0) {\n println(N)\n } else {\n println(2 * N)\n }\n}\n", "language": "Kotlin", "metadata": {"date": 1567632173, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03307.html", "problem_id": "p03307", "resource_group": "medium_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/Kotlin/s988475779.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s988475779", "user_id": "u379804877"}, "prompt_components": {"gold_output": "6\n", "input_to_evaluate": "fun main(args: Array) {\n val N = readLine()!!.toInt()\n \n if (N % 2 == 0) {\n println(N)\n } else {\n println(2 * N)\n }\n}\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 201, "memory_kb": 31768}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s215407998", "group_id": "codeNet:p03307", "input_text": "import java.util.*\n\nfun main(args: Array) {\n multipleOf2AndN()\n}\n\nprivate const val TWO = 2L\n\nfun multipleOf2AndN() {\n val n = Scanner(System.`in`).nextLong()\n val result = n * TWO / gcd(n, TWO)\n\n println(result)\n}\n\nprivate tailrec fun gcd(m: Long, n: Long): Long {\n if (m < n) return gcd(n, m)\n if (n.toInt() == 0) return m\n return gcd(n, m % n)\n}\n", "language": "Kotlin", "metadata": {"date": 1531265417, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03307.html", "problem_id": "p03307", "resource_group": "medium_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/Kotlin/s215407998.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s215407998", "user_id": "u041246776"}, "prompt_components": {"gold_output": "6\n", "input_to_evaluate": "import java.util.*\n\nfun main(args: Array) {\n multipleOf2AndN()\n}\n\nprivate const val TWO = 2L\n\nfun multipleOf2AndN() {\n val n = Scanner(System.`in`).nextLong()\n val result = n * TWO / gcd(n, TWO)\n\n println(result)\n}\n\nprivate tailrec fun gcd(m: Long, n: Long): Long {\n if (m < n) return gcd(n, m)\n if (n.toInt() == 0) return m\n return gcd(n, m % n)\n}\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 378, "cpu_time_ms": 188, "memory_kb": 31400}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s650256366", "group_id": "codeNet:p03309", "input_text": "import java.io.PrintWriter\nimport kotlin.math.absoluteValue\nimport kotlin.math.min\n\nfun next() = readLine()!!\nfun nextInt() = next().toInt()\nfun nextLong() = next().toLong()\nfun nextDouble() = next().toDouble()\nfun nextList() = next().split(\" \")\nfun nextIntList() = nextList().map(String::toInt)\nfun nextLongList() = nextList().map(String::toLong)\nfun nextDoubleList() = nextList().map(String::toDouble)\n\nval pw = PrintWriter(System.out)\nfun print(s: Any = \"\") = pw.print(s)\nfun println(s: Any = \"\") = pw.println(s)\n\nfun Iterable.join(separator: CharSequence = \", \", prefix: CharSequence = \"\", postfix: CharSequence = \"\") = joinToString(separator, prefix, postfix)\nfun Array.join(separator: CharSequence = \", \", prefix: CharSequence = \"\", postfix: CharSequence = \"\") = joinToString(separator, prefix, postfix)\n\nfun main(args: Array) {\n main()\n pw.flush()\n}\n\nfun main() {\n val N = nextInt()\n val A = nextLongList()\n val B = A.mapIndexed { index, a -> a - index - 1 }\n val ans = searchMin(B.min()!!, B.max()!!) { v ->\n B.map { (it - v).absoluteValue }.sum()\n }\n println(ans)\n}\n\nfun searchMin(l: Long, r: Long, f: (Long) -> Long): Long {\n val c1 = l + (r - l) / 3\n val c2 = l + (r - l) * 2 / 3\n if (l == c1) return min(f(c1), f(c2))\n return if (f(c1) < f(c2)) searchMin(l, c2, f) else searchMin(c1, r, f)\n}", "language": "Kotlin", "metadata": {"date": 1592636218, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p03309.html", "problem_id": "p03309", "resource_group": "medium_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/Kotlin/s650256366.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s650256366", "user_id": "u860789370"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import java.io.PrintWriter\nimport kotlin.math.absoluteValue\nimport kotlin.math.min\n\nfun next() = readLine()!!\nfun nextInt() = next().toInt()\nfun nextLong() = next().toLong()\nfun nextDouble() = next().toDouble()\nfun nextList() = next().split(\" \")\nfun nextIntList() = nextList().map(String::toInt)\nfun nextLongList() = nextList().map(String::toLong)\nfun nextDoubleList() = nextList().map(String::toDouble)\n\nval pw = PrintWriter(System.out)\nfun print(s: Any = \"\") = pw.print(s)\nfun println(s: Any = \"\") = pw.println(s)\n\nfun Iterable.join(separator: CharSequence = \", \", prefix: CharSequence = \"\", postfix: CharSequence = \"\") = joinToString(separator, prefix, postfix)\nfun Array.join(separator: CharSequence = \", \", prefix: CharSequence = \"\", postfix: CharSequence = \"\") = joinToString(separator, prefix, postfix)\n\nfun main(args: Array) {\n main()\n pw.flush()\n}\n\nfun main() {\n val N = nextInt()\n val A = nextLongList()\n val B = A.mapIndexed { index, a -> a - index - 1 }\n val ans = searchMin(B.min()!!, B.max()!!) { v ->\n B.map { (it - v).absoluteValue }.sum()\n }\n println(ans)\n}\n\nfun searchMin(l: Long, r: Long, f: (Long) -> Long): Long {\n val c1 = l + (r - l) / 3\n val c2 = l + (r - l) * 2 / 3\n if (l == c1) return min(f(c1), f(c2))\n return if (f(c1) < f(c2)) searchMin(l, c2, f) else searchMin(c1, r, f)\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1368, "cpu_time_ms": 1039, "memory_kb": 104336}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s990817267", "group_id": "codeNet:p03309", "input_text": "import java.math.*\n\nfun main(args: Array) {\n val N = readInputLine().toInt()\n \n val diffCountMap = mutableMapOf()\n \n val As = readInputLine().split(\" \").mapIndexed{i, r -> val diff = r.toInt() - i - 1; diffCountMap.put(diff, (diffCountMap.get(diff) ?: 0) + 1); diff}\n \n val (diff, cnt) = diffCountMap.toList().sortedByDescending{it.second}.first()\n \n if (cnt > N / 2) {\n println(As.fold(0L, {R, T -> R + Math.abs(T - diff)}))\n } else {\n println(As.fold(0L, {R, T -> R + Math.abs(T)}))\n }\n}\n\nfun readInputLine(): String {\n return readLine()!!\n}\n", "language": "Kotlin", "metadata": {"date": 1565701630, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03309.html", "problem_id": "p03309", "resource_group": "medium_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/Kotlin/s990817267.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s990817267", "user_id": "u505558493"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import java.math.*\n\nfun main(args: Array) {\n val N = readInputLine().toInt()\n \n val diffCountMap = mutableMapOf()\n \n val As = readInputLine().split(\" \").mapIndexed{i, r -> val diff = r.toInt() - i - 1; diffCountMap.put(diff, (diffCountMap.get(diff) ?: 0) + 1); diff}\n \n val (diff, cnt) = diffCountMap.toList().sortedByDescending{it.second}.first()\n \n if (cnt > N / 2) {\n println(As.fold(0L, {R, T -> R + Math.abs(T - diff)}))\n } else {\n println(As.fold(0L, {R, T -> R + Math.abs(T)}))\n }\n}\n\nfun readInputLine(): String {\n return readLine()!!\n}\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1048, "memory_kb": 112936}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s509506691", "group_id": "codeNet:p03310", "input_text": "fun main(args: Array) {\n val N = readLine()!!.toInt()\n val A = readLine()!!.split(\" \").map { it.toLong() }\n val S = mutableListOf(A[0])\n A.forEachIndexed { index, l ->\n if (index > 0) S.add(S[index - 1] + l)\n }\n\n var d_min = Long.MAX_VALUE\n var p = 0; var r = 2\n for (q in 1 until N - 2) {\n\n var d_l = Long.MAX_VALUE\n left@ for (i in p until q) {\n val d = Math.abs((S[q] - S[i]) - S[i])\n if (d_l > d) {\n d_l = d\n p = i\n } else break@left\n }\n\n var d_r = Long.MAX_VALUE\n right@ for (i in r until N) {\n val d = Math.abs((S.last() - S[i]) - (S[i] - S[q]))\n if (d_r > d) {\n d_r = d\n r = i\n } else break@right\n }\n\n val d_p0 = S[p]; val d_qp = S[q] - S[p]; val d_rq = S[r] - S[q]; val d_Nr = S.last() - S[r]\n val max = Math.max(Math.max(d_p0, d_qp), Math.max(d_rq, d_Nr))\n val min = Math.min(Math.min(d_p0, d_qp), Math.min(d_rq, d_Nr))\n d_min = Math.min(d_min, max - min)\n }\n\n println(d_min)\n}", "language": "Kotlin", "metadata": {"date": 1532880935, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03310.html", "problem_id": "p03310", "resource_group": "medium_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/Kotlin/s509506691.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s509506691", "user_id": "u771276989"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "fun main(args: Array) {\n val N = readLine()!!.toInt()\n val A = readLine()!!.split(\" \").map { it.toLong() }\n val S = mutableListOf(A[0])\n A.forEachIndexed { index, l ->\n if (index > 0) S.add(S[index - 1] + l)\n }\n\n var d_min = Long.MAX_VALUE\n var p = 0; var r = 2\n for (q in 1 until N - 2) {\n\n var d_l = Long.MAX_VALUE\n left@ for (i in p until q) {\n val d = Math.abs((S[q] - S[i]) - S[i])\n if (d_l > d) {\n d_l = d\n p = i\n } else break@left\n }\n\n var d_r = Long.MAX_VALUE\n right@ for (i in r until N) {\n val d = Math.abs((S.last() - S[i]) - (S[i] - S[q]))\n if (d_r > d) {\n d_r = d\n r = i\n } else break@right\n }\n\n val d_p0 = S[p]; val d_qp = S[q] - S[p]; val d_rq = S[r] - S[q]; val d_Nr = S.last() - S[r]\n val max = Math.max(Math.max(d_p0, d_qp), Math.max(d_rq, d_Nr))\n val min = Math.min(Math.min(d_p0, d_qp), Math.min(d_rq, d_Nr))\n d_min = Math.min(d_min, max - min)\n }\n\n println(d_min)\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1133, "cpu_time_ms": 759, "memory_kb": 83932}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s740362906", "group_id": "codeNet:p03315", "input_text": "import java.util.*\nimport kotlin.*\n\nimport java.io.InputStream\nimport java.lang.NumberFormatException\nimport java.lang.StringBuilder\n\n\nfun main(args: Array) {\n Program().solve()\n}\n\nclass Program {\n fun solve() {\n val sc = FastScanner()\n val s = sc.next()\n var ans = 0\n for(i in 0 until 4){\n ans += if(s[i] =='+') 1 else -1\n\n }\n\n println(ans)\n }\n}\n\n\nclass FastScanner {\n companion object {\n val input: InputStream = System.`in`\n val buffer = ByteArray(1024) { 0 }\n fun isPrintableChar(c: Int): Boolean = c in 33..126\n }\n\n var ptr = 0\n var buflen = 0\n private fun hasNextByte(): Boolean {\n if (ptr < buflen) {\n return true\n } else {\n ptr = 0\n buflen = input.read(buffer)\n if (buflen <= 0) {\n return false\n }\n }\n return true\n }\n\n private fun readByte(): Int = if (hasNextByte()) buffer[ptr++].toInt() else -1\n\n private fun skipUnprintable() {\n while (hasNextByte() && !isPrintableChar(buffer[ptr].toInt())) ptr++\n }\n\n fun hasNext(): Boolean {\n skipUnprintable()\n return hasNextByte()\n }\n\n fun next(): String {\n if (!hasNext()) throw NoSuchElementException()\n val sb = StringBuilder()\n var b = readByte()\n while (isPrintableChar(b)) {\n sb.appendCodePoint(b)\n b = readByte()\n }\n return sb.toString()\n }\n\n fun nextInt(): Int {\n if (!hasNext()) throw NoSuchElementException()\n var n = 0\n var b = readByte()\n // '-' = 45\n val minus = b == 45\n if (minus) {\n b = readByte()\n }\n\n // '0' = 48 '9' = 57\n if (b !in 48..57) {\n throw NumberFormatException()\n }\n\n while (true) {\n if (b in 48..57) {\n n *= 10\n n += b - 48\n } else if (b == -1 || !isPrintableChar(b)) {\n return if (minus) -n else n\n } else {\n throw NumberFormatException()\n }\n b = readByte()\n }\n }\n\n fun nextLong(): Long {\n if (!hasNext()) throw NoSuchElementException()\n var n = 0L\n var b = readByte()\n // '-' = 45\n val minus = b == 45\n if (minus) {\n b = readByte()\n }\n\n // '0' = 48 '9' = 57\n if (b !in 48..57) {\n throw NumberFormatException()\n }\n\n while (true) {\n if (b in 48..57) {\n n *= 10\n n += b - 48\n } else if (b == -1 || !isPrintableChar(b)) {\n return if (minus) -n else n\n } else {\n throw NumberFormatException()\n }\n b = readByte()\n }\n }\n\n fun nextDouble(): Double = next().toDouble()\n}\n", "language": "Kotlin", "metadata": {"date": 1585827353, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03315.html", "problem_id": "p03315", "resource_group": "medium_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/Kotlin/s740362906.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s740362906", "user_id": "u194412908"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import java.util.*\nimport kotlin.*\n\nimport java.io.InputStream\nimport java.lang.NumberFormatException\nimport java.lang.StringBuilder\n\n\nfun main(args: Array) {\n Program().solve()\n}\n\nclass Program {\n fun solve() {\n val sc = FastScanner()\n val s = sc.next()\n var ans = 0\n for(i in 0 until 4){\n ans += if(s[i] =='+') 1 else -1\n\n }\n\n println(ans)\n }\n}\n\n\nclass FastScanner {\n companion object {\n val input: InputStream = System.`in`\n val buffer = ByteArray(1024) { 0 }\n fun isPrintableChar(c: Int): Boolean = c in 33..126\n }\n\n var ptr = 0\n var buflen = 0\n private fun hasNextByte(): Boolean {\n if (ptr < buflen) {\n return true\n } else {\n ptr = 0\n buflen = input.read(buffer)\n if (buflen <= 0) {\n return false\n }\n }\n return true\n }\n\n private fun readByte(): Int = if (hasNextByte()) buffer[ptr++].toInt() else -1\n\n private fun skipUnprintable() {\n while (hasNextByte() && !isPrintableChar(buffer[ptr].toInt())) ptr++\n }\n\n fun hasNext(): Boolean {\n skipUnprintable()\n return hasNextByte()\n }\n\n fun next(): String {\n if (!hasNext()) throw NoSuchElementException()\n val sb = StringBuilder()\n var b = readByte()\n while (isPrintableChar(b)) {\n sb.appendCodePoint(b)\n b = readByte()\n }\n return sb.toString()\n }\n\n fun nextInt(): Int {\n if (!hasNext()) throw NoSuchElementException()\n var n = 0\n var b = readByte()\n // '-' = 45\n val minus = b == 45\n if (minus) {\n b = readByte()\n }\n\n // '0' = 48 '9' = 57\n if (b !in 48..57) {\n throw NumberFormatException()\n }\n\n while (true) {\n if (b in 48..57) {\n n *= 10\n n += b - 48\n } else if (b == -1 || !isPrintableChar(b)) {\n return if (minus) -n else n\n } else {\n throw NumberFormatException()\n }\n b = readByte()\n }\n }\n\n fun nextLong(): Long {\n if (!hasNext()) throw NoSuchElementException()\n var n = 0L\n var b = readByte()\n // '-' = 45\n val minus = b == 45\n if (minus) {\n b = readByte()\n }\n\n // '0' = 48 '9' = 57\n if (b !in 48..57) {\n throw NumberFormatException()\n }\n\n while (true) {\n if (b in 48..57) {\n n *= 10\n n += b - 48\n } else if (b == -1 || !isPrintableChar(b)) {\n return if (minus) -n else n\n } else {\n throw NumberFormatException()\n }\n b = readByte()\n }\n }\n\n fun nextDouble(): Double = next().toDouble()\n}\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2914, "cpu_time_ms": 170, "memory_kb": 31388}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s232877249", "group_id": "codeNet:p03317", "input_text": "/**\n * Created by karayuu on 2018/06/23\n */\nfun main(args: Array) {\n val (n, k) = readLine()!!.split(\" \").map { it.toInt() }\n print(Math.ceil(n.toDouble() / k.toDouble()).toInt() + 1)\n}\n", "language": "Kotlin", "metadata": {"date": 1529807611, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03317.html", "problem_id": "p03317", "resource_group": "medium_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/Kotlin/s232877249.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s232877249", "user_id": "u598902504"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "/**\n * Created by karayuu on 2018/06/23\n */\nfun main(args: Array) {\n val (n, k) = readLine()!!.split(\" \").map { it.toInt() }\n print(Math.ceil(n.toDouble() / k.toDouble()).toInt() + 1)\n}\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": "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 200, "cpu_time_ms": 237, "memory_kb": 38176}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s999968525", "group_id": "codeNet:p03318", "input_text": "import java.util.*\nimport kotlin.*\n\nimport java.io.InputStream\nimport java.lang.NumberFormatException\nimport java.lang.StringBuilder\n\n\nfun main(args: Array) {\n Program().solve()\n}\n\nclass Program {\n fun solve() {\n val sc = FastScanner()\n val k = sc.nextInt()\n\n val l = ArrayList()\n l.add(1L)\n // 桁和\n var sum = 2\n\n fun dSum(l: Long): Long = if (l < 10) l else dSum(l / 10) + l % 10\n\n fun min(s: Int): Long {\n val d = s / 9\n val m = s % 9\n var t = m.toLong()\n for (i in 0 until d) {\n t *= 10\n t += 9\n }\n return t\n }\n\n fun next(sum: Int): ArrayList {\n val t = min(sum)\n val s = if (sum % 9 == 0) \"0${t}\" else t.toString()\n val ss = s.toCharArray()\n val res = ArrayList()\n res.add(t)\n for (i in 0 until ss.size - 1) {\n ss[i]++\n ss[i + 1]--\n res.add(String(ss).toLong())\n }\n return res\n }\n\n while (l.size < k) {\n val next = min(sum + 1)\n // 桁和+1 より小さい 桁和sumの値を小さい順に列挙\n val nn = next(sum)\n for (i in 0 until nn.size) {\n if(l.size >= k) break\n l.add(nn[i])\n }\n sum++\n\n }\n println(l.joinToString(\"\\n\"))\n }\n\n\n}\n\n\nclass FastScanner {\n companion object {\n val input: InputStream = System.`in`\n val buffer = ByteArray(1024) { 0 }\n fun isPrintableChar(c: Int): Boolean = c in 33..126\n }\n\n var ptr = 0\n var buflen = 0\n private fun hasNextByte(): Boolean {\n if (ptr < buflen) {\n return true\n } else {\n ptr = 0\n buflen = input.read(buffer)\n if (buflen <= 0) {\n return false\n }\n }\n return true\n }\n\n private fun readByte(): Int = if (hasNextByte()) buffer[ptr++].toInt() else -1\n\n private fun skipUnprintable() {\n while (hasNextByte() && !isPrintableChar(buffer[ptr].toInt())) ptr++\n }\n\n fun hasNext(): Boolean {\n skipUnprintable()\n return hasNextByte()\n }\n\n fun next(): String {\n if (!hasNext()) throw NoSuchElementException()\n val sb = StringBuilder()\n var b = readByte()\n while (isPrintableChar(b)) {\n sb.appendCodePoint(b)\n b = readByte()\n }\n return sb.toString()\n }\n\n fun nextInt(): Int {\n if (!hasNext()) throw NoSuchElementException()\n var n = 0\n var b = readByte()\n // '-' = 45\n val minus = b == 45\n if (minus) {\n b = readByte()\n }\n\n // '0' = 48 '9' = 57\n if (b !in 48..57) {\n throw NumberFormatException()\n }\n\n while (true) {\n if (b in 48..57) {\n n *= 10\n n += b - 48\n } else if (b == -1 || !isPrintableChar(b)) {\n return if (minus) -n else n\n } else {\n throw NumberFormatException()\n }\n b = readByte()\n }\n }\n\n fun nextLong(): Long {\n if (!hasNext()) throw NoSuchElementException()\n var n = 0L\n var b = readByte()\n // '-' = 45\n val minus = b == 45\n if (minus) {\n b = readByte()\n }\n\n // '0' = 48 '9' = 57\n if (b !in 48..57) {\n throw NumberFormatException()\n }\n\n while (true) {\n if (b in 48..57) {\n n *= 10\n n += b - 48\n } else if (b == -1 || !isPrintableChar(b)) {\n return if (minus) -n else n\n } else {\n throw NumberFormatException()\n }\n b = readByte()\n }\n }\n\n fun nextDouble(): Double = next().toDouble()\n}\n", "language": "Kotlin", "metadata": {"date": 1583901780, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03318.html", "problem_id": "p03318", "resource_group": "medium_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/Kotlin/s999968525.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s999968525", "user_id": "u194412908"}, "prompt_components": {"gold_output": "1\n2\n3\n4\n5\n6\n7\n8\n9\n19\n", "input_to_evaluate": "import java.util.*\nimport kotlin.*\n\nimport java.io.InputStream\nimport java.lang.NumberFormatException\nimport java.lang.StringBuilder\n\n\nfun main(args: Array) {\n Program().solve()\n}\n\nclass Program {\n fun solve() {\n val sc = FastScanner()\n val k = sc.nextInt()\n\n val l = ArrayList()\n l.add(1L)\n // 桁和\n var sum = 2\n\n fun dSum(l: Long): Long = if (l < 10) l else dSum(l / 10) + l % 10\n\n fun min(s: Int): Long {\n val d = s / 9\n val m = s % 9\n var t = m.toLong()\n for (i in 0 until d) {\n t *= 10\n t += 9\n }\n return t\n }\n\n fun next(sum: Int): ArrayList {\n val t = min(sum)\n val s = if (sum % 9 == 0) \"0${t}\" else t.toString()\n val ss = s.toCharArray()\n val res = ArrayList()\n res.add(t)\n for (i in 0 until ss.size - 1) {\n ss[i]++\n ss[i + 1]--\n res.add(String(ss).toLong())\n }\n return res\n }\n\n while (l.size < k) {\n val next = min(sum + 1)\n // 桁和+1 より小さい 桁和sumの値を小さい順に列挙\n val nn = next(sum)\n for (i in 0 until nn.size) {\n if(l.size >= k) break\n l.add(nn[i])\n }\n sum++\n\n }\n println(l.joinToString(\"\\n\"))\n }\n\n\n}\n\n\nclass FastScanner {\n companion object {\n val input: InputStream = System.`in`\n val buffer = ByteArray(1024) { 0 }\n fun isPrintableChar(c: Int): Boolean = c in 33..126\n }\n\n var ptr = 0\n var buflen = 0\n private fun hasNextByte(): Boolean {\n if (ptr < buflen) {\n return true\n } else {\n ptr = 0\n buflen = input.read(buffer)\n if (buflen <= 0) {\n return false\n }\n }\n return true\n }\n\n private fun readByte(): Int = if (hasNextByte()) buffer[ptr++].toInt() else -1\n\n private fun skipUnprintable() {\n while (hasNextByte() && !isPrintableChar(buffer[ptr].toInt())) ptr++\n }\n\n fun hasNext(): Boolean {\n skipUnprintable()\n return hasNextByte()\n }\n\n fun next(): String {\n if (!hasNext()) throw NoSuchElementException()\n val sb = StringBuilder()\n var b = readByte()\n while (isPrintableChar(b)) {\n sb.appendCodePoint(b)\n b = readByte()\n }\n return sb.toString()\n }\n\n fun nextInt(): Int {\n if (!hasNext()) throw NoSuchElementException()\n var n = 0\n var b = readByte()\n // '-' = 45\n val minus = b == 45\n if (minus) {\n b = readByte()\n }\n\n // '0' = 48 '9' = 57\n if (b !in 48..57) {\n throw NumberFormatException()\n }\n\n while (true) {\n if (b in 48..57) {\n n *= 10\n n += b - 48\n } else if (b == -1 || !isPrintableChar(b)) {\n return if (minus) -n else n\n } else {\n throw NumberFormatException()\n }\n b = readByte()\n }\n }\n\n fun nextLong(): Long {\n if (!hasNext()) throw NoSuchElementException()\n var n = 0L\n var b = readByte()\n // '-' = 45\n val minus = b == 45\n if (minus) {\n b = readByte()\n }\n\n // '0' = 48 '9' = 57\n if (b !in 48..57) {\n throw NumberFormatException()\n }\n\n while (true) {\n if (b in 48..57) {\n n *= 10\n n += b - 48\n } else if (b == -1 || !isPrintableChar(b)) {\n return if (minus) -n else n\n } else {\n throw NumberFormatException()\n }\n b = readByte()\n }\n }\n\n fun nextDouble(): Double = next().toDouble()\n}\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 3998, "cpu_time_ms": 191, "memory_kb": 31484}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s207665843", "group_id": "codeNet:p03318", "input_text": "fun main(args: Array) {\n val K = readLine()!!.toLong()\n\n var outputAmount = 0L\n\n for (i in 1 until 10) {\n if (K <= outputAmount) return\n\n println(i)\n outputAmount++\n }\n\n var i = 20L\n while (true) {\n if (K <= outputAmount) return\n if (100 < i && i.toString().length % 2 == 0) {\n i = (i.toString() + \"0\").toLong()\n continue\n }\n\n println(i - 1)\n outputAmount++\n\n i += 10L\n }\n}", "language": "Kotlin", "metadata": {"date": 1529807323, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03318.html", "problem_id": "p03318", "resource_group": "medium_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/Kotlin/s207665843.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s207665843", "user_id": "u963316883"}, "prompt_components": {"gold_output": "1\n2\n3\n4\n5\n6\n7\n8\n9\n19\n", "input_to_evaluate": "fun main(args: Array) {\n val K = readLine()!!.toLong()\n\n var outputAmount = 0L\n\n for (i in 1 until 10) {\n if (K <= outputAmount) return\n\n println(i)\n outputAmount++\n }\n\n var i = 20L\n while (true) {\n if (K <= outputAmount) return\n if (100 < i && i.toString().length % 2 == 0) {\n i = (i.toString() + \"0\").toLong()\n continue\n }\n\n println(i - 1)\n outputAmount++\n\n i += 10L\n }\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 231, "memory_kb": 30020}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s655143010", "group_id": "codeNet:p03323", "input_text": "fun main(args: Array) {\n val (a, b) = readLine()!!.split(' ').map(String::toInt)\n println(if (a > 8 || b > 8) \":(\" else \"Yay!\")\n}", "language": "Kotlin", "metadata": {"date": 1529197566, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03323.html", "problem_id": "p03323", "resource_group": "medium_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/Kotlin/s655143010.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s655143010", "user_id": "u863309603"}, "prompt_components": {"gold_output": "Yay!\n", "input_to_evaluate": "fun main(args: Array) {\n val (a, b) = readLine()!!.split(' ').map(String::toInt)\n println(if (a > 8 || b > 8) \":(\" else \"Yay!\")\n}", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 358, "memory_kb": 36364}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s820348806", "group_id": "codeNet:p03325", "input_text": "fun main(args: Array) = yorukatsu21b()\n\nfun yorukatsu21b() {\n val n = readLine()!!.toInt()\n val aList = readLine()!!.split(' ').map { it.toLong() }\n\n val answer = aList.map {\n var curr = it\n var count = 0\n while (curr % 2 == 0L && curr > 0) {\n curr /= 2\n count++\n }\n count.toLong()\n }.sum()\n\n println(answer)\n}\n", "language": "Kotlin", "metadata": {"date": 1587517571, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03325.html", "problem_id": "p03325", "resource_group": "medium_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/Kotlin/s820348806.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s820348806", "user_id": "u139478771"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "fun main(args: Array) = yorukatsu21b()\n\nfun yorukatsu21b() {\n val n = readLine()!!.toInt()\n val aList = readLine()!!.split(' ').map { it.toLong() }\n\n val answer = aList.map {\n var curr = it\n var count = 0\n while (curr % 2 == 0L && curr > 0) {\n curr /= 2\n count++\n }\n count.toLong()\n }.sum()\n\n println(answer)\n}\n", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 391, "cpu_time_ms": 418, "memory_kb": 40156}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s034708637", "group_id": "codeNet:p03326", "input_text": "fun main(args: Array) {\n val (N,M) = readLine()!!.split(\" \").map { it.toInt() }\n val a = (1..N).map { readLine()!!.split(\" \").map { it.toLong() } }\n val b = (0..7).map {\n val xp: Int = it % 2\n val yp: Int = (it/2)%2\n val zp: Int = (it/4)%2\n\n a.map {\n val x = if(xp==0) it[0] else -it[0]\n val y = if(yp==0) it[1] else -it[1]\n val z = if(zp==0) it[2] else -it[2]\n x + y + z\n }\n .sortedDescending()\n .subList(0, M)\n .sum()\n }.max()\n println(b)\n}", "language": "Kotlin", "metadata": {"date": 1529205000, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03326.html", "problem_id": "p03326", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03326/input.txt", "sample_output_relpath": "derived/input_output/data/p03326/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03326/Kotlin/s034708637.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s034708637", "user_id": "u185034753"}, "prompt_components": {"gold_output": "56\n", "input_to_evaluate": "fun main(args: Array) {\n val (N,M) = readLine()!!.split(\" \").map { it.toInt() }\n val a = (1..N).map { readLine()!!.split(\" \").map { it.toLong() } }\n val b = (0..7).map {\n val xp: Int = it % 2\n val yp: Int = (it/2)%2\n val zp: Int = (it/4)%2\n\n a.map {\n val x = if(xp==0) it[0] else -it[0]\n val y = if(yp==0) it[1] else -it[1]\n val z = if(zp==0) it[2] else -it[2]\n x + y + z\n }\n .sortedDescending()\n .subList(0, M)\n .sum()\n }.max()\n println(b)\n}", "problem_context": "Score: 400 points\n\nProblem Statement\n\nTakahashi became a pastry chef and opened a shop La Confiserie d'ABC to celebrate AtCoder Beginner Contest 100.\n\nThe shop sells N kinds of cakes.\n\nEach kind of cake has three parameters \"beauty\", \"tastiness\" and \"popularity\". The i-th kind of cake has the beauty of x_i, the tastiness of y_i and the popularity of z_i.\n\nThese values may be zero or negative.\n\nRingo has decided to have M pieces of cakes here. He will choose the set of cakes as follows:\n\nDo not have two or more pieces of the same kind of cake.\n\nUnder the condition above, choose the set of cakes to maximize (the absolute value of the total beauty) + (the absolute value of the total tastiness) + (the absolute value of the total popularity).\n\nFind the maximum possible value of (the absolute value of the total beauty) + (the absolute value of the total tastiness) + (the absolute value of the total popularity) for the set of cakes that Ringo chooses.\n\nConstraints\n\nN is an integer between 1 and 1 \\ 000 (inclusive).\n\nM is an integer between 0 and N (inclusive).\n\nx_i, y_i, z_i \\ (1 \\leq i \\leq N) are integers between -10 \\ 000 \\ 000 \\ 000 and 10 \\ 000 \\ 000 \\ 000 (inclusive).\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: :\nx_N y_N z_N\n\nOutput\n\nPrint the maximum possible value of (the absolute value of the total beauty) + (the absolute value of the total tastiness) + (the absolute value of the total popularity) for the set of cakes that Ringo chooses.\n\nSample Input 1\n\n5 3\n3 1 4\n1 5 9\n2 6 5\n3 5 8\n9 7 9\n\nSample Output 1\n\n56\n\nConsider having the 2-nd, 4-th and 5-th kinds of cakes. The total beauty, tastiness and popularity will be as follows:\n\nBeauty: 1 + 3 + 9 = 13\n\nTastiness: 5 + 5 + 7 = 17\n\nPopularity: 9 + 8 + 9 = 26\n\nThe value (the absolute value of the total beauty) + (the absolute value of the total tastiness) + (the absolute value of the total popularity) here is 13 + 17 + 26 = 56. This is the maximum value.\n\nSample Input 2\n\n5 3\n1 -2 3\n-4 5 -6\n7 -8 -9\n-10 11 -12\n13 -14 15\n\nSample Output 2\n\n54\n\nConsider having the 1-st, 3-rd and 5-th kinds of cakes. The total beauty, tastiness and popularity will be as follows:\n\nBeauty: 1 + 7 + 13 = 21\n\nTastiness: (-2) + (-8) + (-14) = -24\n\nPopularity: 3 + (-9) + 15 = 9\n\nThe value (the absolute value of the total beauty) + (the absolute value of the total tastiness) + (the absolute value of the total popularity) here is 21 + 24 + 9 = 54. This is the maximum value.\n\nSample Input 3\n\n10 5\n10 -80 21\n23 8 38\n-94 28 11\n-26 -2 18\n-69 72 79\n-26 -86 -54\n-72 -50 59\n21 65 -32\n40 -94 87\n-62 18 82\n\nSample Output 3\n\n638\n\nIf we have the 3-rd, 4-th, 5-th, 7-th and 10-th kinds of cakes, the total beauty, tastiness and popularity will be -323, 66 and 249, respectively.\n\nThe value (the absolute value of the total beauty) + (the absolute value of the total tastiness) + (the absolute value of the total popularity) here is 323 + 66 + 249 = 638. This is the maximum value.\n\nSample Input 4\n\n3 2\n2000000000 -9000000000 4000000000\n7000000000 -5000000000 3000000000\n6000000000 -1000000000 8000000000\n\nSample Output 4\n\n30000000000\n\nThe values of the beauty, tastiness and popularity of the cakes and the value to be printed may not fit into 32-bit integers.", "sample_input": "5 3\n3 1 4\n1 5 9\n2 6 5\n3 5 8\n9 7 9\n"}, "reference_outputs": ["56\n"], "source_document_id": "p03326", "source_text": "Score: 400 points\n\nProblem Statement\n\nTakahashi became a pastry chef and opened a shop La Confiserie d'ABC to celebrate AtCoder Beginner Contest 100.\n\nThe shop sells N kinds of cakes.\n\nEach kind of cake has three parameters \"beauty\", \"tastiness\" and \"popularity\". The i-th kind of cake has the beauty of x_i, the tastiness of y_i and the popularity of z_i.\n\nThese values may be zero or negative.\n\nRingo has decided to have M pieces of cakes here. He will choose the set of cakes as follows:\n\nDo not have two or more pieces of the same kind of cake.\n\nUnder the condition above, choose the set of cakes to maximize (the absolute value of the total beauty) + (the absolute value of the total tastiness) + (the absolute value of the total popularity).\n\nFind the maximum possible value of (the absolute value of the total beauty) + (the absolute value of the total tastiness) + (the absolute value of the total popularity) for the set of cakes that Ringo chooses.\n\nConstraints\n\nN is an integer between 1 and 1 \\ 000 (inclusive).\n\nM is an integer between 0 and N (inclusive).\n\nx_i, y_i, z_i \\ (1 \\leq i \\leq N) are integers between -10 \\ 000 \\ 000 \\ 000 and 10 \\ 000 \\ 000 \\ 000 (inclusive).\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: :\nx_N y_N z_N\n\nOutput\n\nPrint the maximum possible value of (the absolute value of the total beauty) + (the absolute value of the total tastiness) + (the absolute value of the total popularity) for the set of cakes that Ringo chooses.\n\nSample Input 1\n\n5 3\n3 1 4\n1 5 9\n2 6 5\n3 5 8\n9 7 9\n\nSample Output 1\n\n56\n\nConsider having the 2-nd, 4-th and 5-th kinds of cakes. The total beauty, tastiness and popularity will be as follows:\n\nBeauty: 1 + 3 + 9 = 13\n\nTastiness: 5 + 5 + 7 = 17\n\nPopularity: 9 + 8 + 9 = 26\n\nThe value (the absolute value of the total beauty) + (the absolute value of the total tastiness) + (the absolute value of the total popularity) here is 13 + 17 + 26 = 56. This is the maximum value.\n\nSample Input 2\n\n5 3\n1 -2 3\n-4 5 -6\n7 -8 -9\n-10 11 -12\n13 -14 15\n\nSample Output 2\n\n54\n\nConsider having the 1-st, 3-rd and 5-th kinds of cakes. The total beauty, tastiness and popularity will be as follows:\n\nBeauty: 1 + 7 + 13 = 21\n\nTastiness: (-2) + (-8) + (-14) = -24\n\nPopularity: 3 + (-9) + 15 = 9\n\nThe value (the absolute value of the total beauty) + (the absolute value of the total tastiness) + (the absolute value of the total popularity) here is 21 + 24 + 9 = 54. This is the maximum value.\n\nSample Input 3\n\n10 5\n10 -80 21\n23 8 38\n-94 28 11\n-26 -2 18\n-69 72 79\n-26 -86 -54\n-72 -50 59\n21 65 -32\n40 -94 87\n-62 18 82\n\nSample Output 3\n\n638\n\nIf we have the 3-rd, 4-th, 5-th, 7-th and 10-th kinds of cakes, the total beauty, tastiness and popularity will be -323, 66 and 249, respectively.\n\nThe value (the absolute value of the total beauty) + (the absolute value of the total tastiness) + (the absolute value of the total popularity) here is 323 + 66 + 249 = 638. This is the maximum value.\n\nSample Input 4\n\n3 2\n2000000000 -9000000000 4000000000\n7000000000 -5000000000 3000000000\n6000000000 -1000000000 8000000000\n\nSample Output 4\n\n30000000000\n\nThe values of the beauty, tastiness and popularity of the cakes and the value to be printed may not fit into 32-bit integers.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 411, "memory_kb": 41160}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s571162999", "group_id": "codeNet:p03327", "input_text": "fun main(args: Array) {\n val n = readLine()!!.toInt()\n println(if(n<1000)\"ABC\" else \"ABD\")\n}", "language": "Kotlin", "metadata": {"date": 1541729389, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03327.html", "problem_id": "p03327", "resource_group": "medium_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/Kotlin/s571162999.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s571162999", "user_id": "u914096045"}, "prompt_components": {"gold_output": "ABC\n", "input_to_evaluate": "fun main(args: Array) {\n val n = readLine()!!.toInt()\n println(if(n<1000)\"ABC\" else \"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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 202, "memory_kb": 31748}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s665674783", "group_id": "codeNet:p03329", "input_text": "fun main(args: Array) {\n var N = readLine()!!.toInt()\n\n var dp = Array(110000) {N}\n dp[0] = 0\n\n for (i in 1..N) {\n var pow6 = 1\n while (pow6 <= i && pow6 <= N) {\n dp[i] = Math.min(dp[i], 1 + dp[i - pow6])\n pow6 *= 6\n }\n\n var pow9 = 1\n while (pow9 <= i && pow9 <= N) {\n dp[i] = Math.min(dp[i], 1 + dp[i - pow9])\n pow9 *= 9\n }\n }\n\n println(dp[N])\n}", "language": "Kotlin", "metadata": {"date": 1542055097, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03329.html", "problem_id": "p03329", "resource_group": "medium_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/Kotlin/s665674783.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s665674783", "user_id": "u367259152"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "fun main(args: Array) {\n var N = readLine()!!.toInt()\n\n var dp = Array(110000) {N}\n dp[0] = 0\n\n for (i in 1..N) {\n var pow6 = 1\n while (pow6 <= i && pow6 <= N) {\n dp[i] = Math.min(dp[i], 1 + dp[i - pow6])\n pow6 *= 6\n }\n\n var pow9 = 1\n while (pow9 <= i && pow9 <= N) {\n dp[i] = Math.min(dp[i], 1 + dp[i - pow9])\n pow9 *= 9\n }\n }\n\n println(dp[N])\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 458, "cpu_time_ms": 245, "memory_kb": 33604}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s498773302", "group_id": "codeNet:p03329", "input_text": "fun main(args: Array) {\n var n = readLine()!!.toInt()\n var count = n\n for (i in 0..n) {\n var cc = 0\n var t = i\n while (t > 0) {\n cc += t % 6\n t /= 6\n }\n t = n - i\n while (t > 0) {\n cc += t % 9\n t /= 9\n }\n if (count > cc) count = cc\n }\n println(count)\n}\n\n", "language": "Kotlin", "metadata": {"date": 1528688113, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03329.html", "problem_id": "p03329", "resource_group": "medium_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/Kotlin/s498773302.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s498773302", "user_id": "u099066216"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "fun main(args: Array) {\n var n = readLine()!!.toInt()\n var count = n\n for (i in 0..n) {\n var cc = 0\n var t = i\n while (t > 0) {\n cc += t % 6\n t /= 6\n }\n t = n - i\n while (t > 0) {\n cc += t % 9\n t /= 9\n }\n if (count > cc) count = cc\n }\n println(count)\n}\n\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 377, "cpu_time_ms": 213, "memory_kb": 31692}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s697787452", "group_id": "codeNet:p03338", "input_text": "import java.io.PrintWriter\nimport java.util.*\nimport java.math.*\nimport java.lang.*\n\nval pw = PrintWriter(System.out)\nval MOD: Long = (1e+9 + 7).toLong()\n\nfun main(args: Array) {\n val n = readInt() \n val s = read()\n\n var count = 0\n for(i in 0 until n-1) {\n val j = i+1\n val s1 = s.slice(0..i).toList().distinct()\n val s2 = s.slice(j until n).toList().distinct()\n val tmpCount = s1.count { s2.contains(it) }\n count = Math.max(count, tmpCount)\n }\n println(count)\n pw.flush()\n}\n\n/****** Declared Functions and Data Structures ******/\n// IO\nfun read() = readLine()!!\nfun readInt() = read().toInt()\nfun readLong() = read().toLong()\nfun readDouble() = read().toDouble()\nfun readListOfString() = read().split(\" \")\nfun readListOfInt() = readListOfString().map { it.toInt() }\nfun readListOfLong() = readListOfString().map { it.toLong() }\nfun readListOfDouble() = readListOfString().map { it.toDouble() }\n\nfun Double.format(digits: Int) = String.format(\"%.${digits}f\", this)\nfun Float.format(digits: Int) = String.format(\"%.${digits}f\", this)\n\nfun print(value: Any) { pw.print(value) }\nfun println(value : Any) { pw.println(value) }\n\nfun permutations(src: List): List> {\n if(src.size == 1) return listOf(src)\n val perms = mutableListOf>()\n val insertElement = src[0]\n permutations(src.drop(1)).forEach { perm ->\n for(i in 0..perm.size) {\n val newPerm = perm.toMutableList()\n newPerm.add(i, insertElement)\n perms.add(newPerm.toList())\n }\n }\n return perms\n}\n\n// return nCr, if you want nCr, please access v[n][r]\nfun combinations(n: Long): List> {\n val v = (0..n).map { (0..n).map{0L}.toMutableList() }.toMutableList()\n for(i in 0 until v.size) {\n v[i][0] = 1L\n v[i][i] = 1L\n }\n for(i in 0 until v.size) {\n for(j in 1 until i) {\n v[i][j] = (v[i-1][j-1] + v[i-1][j] % MOD)\n }\n }\n return v.map { it.toList() }.toList()\n}\n\n// should be a >= b\nfun gcd(a: Long, b: Long): Long = \n if(b == 0L) a else gcd(b, a % b)\n\n// shoud be a >= b\nfun lcm(a: Long, b: Long): Long = \n a / gcd(a, b) * b\n\nfun sumDigits(num_: Long): Long {\n var num = num_\n var rtn: Long = 0\n while(num != 0.toLong()) {\n val tmp = num % 10\n rtn += tmp\n num /= 10\n }\n return rtn\n}\n\nfun isDecimal(v: Double): Boolean = ((v - Math.floor(v)) != 0.0)\n\n// Data Structures\nclass Stack(private var st: MutableList = mutableListOf()) {\n fun isEmpty() = st.isEmpty()\n fun top(): T = st.last()\n fun push(e: T) { st.add(e) }\n fun pop() { st = st.dropLast(1).toMutableList() }\n}\n\nclass Queue(private var que: MutableList = mutableListOf()) {\n fun isEmpty() = que.isEmpty()\n fun top(): T = que.first()\n fun push(e: T) { que.add(e) }\n fun pop() { que = que.drop(1).toMutableList() }\n}\n", "language": "Kotlin", "metadata": {"date": 1564765688, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03338.html", "problem_id": "p03338", "resource_group": "medium_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/Kotlin/s697787452.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s697787452", "user_id": "u026686258"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import java.io.PrintWriter\nimport java.util.*\nimport java.math.*\nimport java.lang.*\n\nval pw = PrintWriter(System.out)\nval MOD: Long = (1e+9 + 7).toLong()\n\nfun main(args: Array) {\n val n = readInt() \n val s = read()\n\n var count = 0\n for(i in 0 until n-1) {\n val j = i+1\n val s1 = s.slice(0..i).toList().distinct()\n val s2 = s.slice(j until n).toList().distinct()\n val tmpCount = s1.count { s2.contains(it) }\n count = Math.max(count, tmpCount)\n }\n println(count)\n pw.flush()\n}\n\n/****** Declared Functions and Data Structures ******/\n// IO\nfun read() = readLine()!!\nfun readInt() = read().toInt()\nfun readLong() = read().toLong()\nfun readDouble() = read().toDouble()\nfun readListOfString() = read().split(\" \")\nfun readListOfInt() = readListOfString().map { it.toInt() }\nfun readListOfLong() = readListOfString().map { it.toLong() }\nfun readListOfDouble() = readListOfString().map { it.toDouble() }\n\nfun Double.format(digits: Int) = String.format(\"%.${digits}f\", this)\nfun Float.format(digits: Int) = String.format(\"%.${digits}f\", this)\n\nfun print(value: Any) { pw.print(value) }\nfun println(value : Any) { pw.println(value) }\n\nfun permutations(src: List): List> {\n if(src.size == 1) return listOf(src)\n val perms = mutableListOf>()\n val insertElement = src[0]\n permutations(src.drop(1)).forEach { perm ->\n for(i in 0..perm.size) {\n val newPerm = perm.toMutableList()\n newPerm.add(i, insertElement)\n perms.add(newPerm.toList())\n }\n }\n return perms\n}\n\n// return nCr, if you want nCr, please access v[n][r]\nfun combinations(n: Long): List> {\n val v = (0..n).map { (0..n).map{0L}.toMutableList() }.toMutableList()\n for(i in 0 until v.size) {\n v[i][0] = 1L\n v[i][i] = 1L\n }\n for(i in 0 until v.size) {\n for(j in 1 until i) {\n v[i][j] = (v[i-1][j-1] + v[i-1][j] % MOD)\n }\n }\n return v.map { it.toList() }.toList()\n}\n\n// should be a >= b\nfun gcd(a: Long, b: Long): Long = \n if(b == 0L) a else gcd(b, a % b)\n\n// shoud be a >= b\nfun lcm(a: Long, b: Long): Long = \n a / gcd(a, b) * b\n\nfun sumDigits(num_: Long): Long {\n var num = num_\n var rtn: Long = 0\n while(num != 0.toLong()) {\n val tmp = num % 10\n rtn += tmp\n num /= 10\n }\n return rtn\n}\n\nfun isDecimal(v: Double): Boolean = ((v - Math.floor(v)) != 0.0)\n\n// Data Structures\nclass Stack(private var st: MutableList = mutableListOf()) {\n fun isEmpty() = st.isEmpty()\n fun top(): T = st.last()\n fun push(e: T) { st.add(e) }\n fun pop() { st = st.dropLast(1).toMutableList() }\n}\n\nclass Queue(private var que: MutableList = mutableListOf()) {\n fun isEmpty() = que.isEmpty()\n fun top(): T = que.first()\n fun push(e: T) { que.add(e) }\n fun pop() { que = que.drop(1).toMutableList() }\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.\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2922, "cpu_time_ms": 259, "memory_kb": 31992}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s538839135", "group_id": "codeNet:p03339", "input_text": "fun main(args: Array) {\n val N = readLine()!!.toInt()\n val S = readLine()!!\n\n\n val w = IntArray(N + 1) // [0, i) までのw数\n w[0] = 0\n val e = IntArray(N + 1) // [i, N) までのw数\n e[N] = 0\n for (i in 0 until N) {\n if (S[i] == 'W') {\n w[i + 1] = w[i] + 1\n } else {\n w[i+1] = w[i]\n }\n }\n for (i in N - 1 downTo 0) {\n if (S[i] == 'E') {\n e[i] = e[i + 1] + 1\n } else {\n e[i] = e[i + 1]\n }\n }\n\n\n var answer = Int.MAX_VALUE\n for (leader in 0 until N) {\n val num = w[(leader + 1) - 1] + e[leader + 1]\n answer = Math.min(answer, num)\n }\n println(answer)\n}\n", "language": "Kotlin", "metadata": {"date": 1569112545, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03339.html", "problem_id": "p03339", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03339/input.txt", "sample_output_relpath": "derived/input_output/data/p03339/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03339/Kotlin/s538839135.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s538839135", "user_id": "u861095163"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "fun main(args: Array) {\n val N = readLine()!!.toInt()\n val S = readLine()!!\n\n\n val w = IntArray(N + 1) // [0, i) までのw数\n w[0] = 0\n val e = IntArray(N + 1) // [i, N) までのw数\n e[N] = 0\n for (i in 0 until N) {\n if (S[i] == 'W') {\n w[i + 1] = w[i] + 1\n } else {\n w[i+1] = w[i]\n }\n }\n for (i in N - 1 downTo 0) {\n if (S[i] == 'E') {\n e[i] = e[i + 1] + 1\n } else {\n e[i] = e[i + 1]\n }\n }\n\n\n var answer = Int.MAX_VALUE\n for (leader in 0 until N) {\n val num = w[(leader + 1) - 1] + e[leader + 1]\n answer = Math.min(answer, num)\n }\n println(answer)\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere are N people standing in a row from west to east.\nEach person is facing east or west.\nThe directions of the people is given as a string S of length N.\nThe i-th person from the west is facing east if S_i = E, and west if S_i = W.\n\nYou will appoint one of the N people as the leader, then command the rest of them to face in the direction of the leader.\nHere, we do not care which direction the leader is facing.\n\nThe people in the row hate to change their directions, so you would like to select the leader so that the number of people who have to change their directions is minimized.\nFind the minimum number of people who have to change their directions.\n\nConstraints\n\n2 \\leq N \\leq 3 \\times 10^5\n\n|S| = N\n\nS_i is E or W.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS\n\nOutput\n\nPrint the minimum number of people who have to change their directions.\n\nSample Input 1\n\n5\nWEEWW\n\nSample Output 1\n\n1\n\nAssume that we appoint the third person from the west as the leader.\nThen, the first person from the west needs to face east and has to turn around.\nThe other people do not need to change their directions, so the number of people who have to change their directions is 1 in this case.\nIt is not possible to have 0 people who have to change their directions, so the answer is 1.\n\nSample Input 2\n\n12\nWEWEWEEEWWWE\n\nSample Output 2\n\n4\n\nSample Input 3\n\n8\nWWWWWEEE\n\nSample Output 3\n\n3", "sample_input": "5\nWEEWW\n"}, "reference_outputs": ["1\n"], "source_document_id": "p03339", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere are N people standing in a row from west to east.\nEach person is facing east or west.\nThe directions of the people is given as a string S of length N.\nThe i-th person from the west is facing east if S_i = E, and west if S_i = W.\n\nYou will appoint one of the N people as the leader, then command the rest of them to face in the direction of the leader.\nHere, we do not care which direction the leader is facing.\n\nThe people in the row hate to change their directions, so you would like to select the leader so that the number of people who have to change their directions is minimized.\nFind the minimum number of people who have to change their directions.\n\nConstraints\n\n2 \\leq N \\leq 3 \\times 10^5\n\n|S| = N\n\nS_i is E or W.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS\n\nOutput\n\nPrint the minimum number of people who have to change their directions.\n\nSample Input 1\n\n5\nWEEWW\n\nSample Output 1\n\n1\n\nAssume that we appoint the third person from the west as the leader.\nThen, the first person from the west needs to face east and has to turn around.\nThe other people do not need to change their directions, so the number of people who have to change their directions is 1 in this case.\nIt is not possible to have 0 people who have to change their directions, so the answer is 1.\n\nSample Input 2\n\n12\nWEWEWEEEWWWE\n\nSample Output 2\n\n4\n\nSample Input 3\n\n8\nWWWWWEEE\n\nSample Output 3\n\n3", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 705, "cpu_time_ms": 289, "memory_kb": 39424}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s557072609", "group_id": "codeNet:p03341", "input_text": "\nfun main(args:Array) {\n val itemCount = readLine()!!.toInt()\n val input = readLine()!!.trim()\n\n val toRight = (1..itemCount).map { 0 }.toMutableList()\n val toLeft = (1..itemCount).map { 0 }.toMutableList()\n\n for(i in input.indices) {\n var n = if(i>0) toRight[i-1] else 0\n if(input[i] == 'E') {\n n++\n }\n toRight[i] = n\n }\n\n for(i in input.indices.reversed()) {\n var n = if(i == input.lastIndex) 0 else toLeft[i+1]\n if(input[i] == 'W') {\n n++\n }\n toLeft[i] = n\n }\n\n var ans = 0\n for(i in input.indices) {\n var tmp = 1\n if(i > 0) {\n tmp += toRight[i-1]\n }\n if(i < input.lastIndex) {\n tmp += toLeft[i+1]\n }\n ans = Math.max(ans, tmp)\n }\n ans = itemCount - ans\n println(ans)\n}\n\n\n", "language": "Kotlin", "metadata": {"date": 1579814414, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03341.html", "problem_id": "p03341", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03341/input.txt", "sample_output_relpath": "derived/input_output/data/p03341/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03341/Kotlin/s557072609.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s557072609", "user_id": "u269969976"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "\nfun main(args:Array) {\n val itemCount = readLine()!!.toInt()\n val input = readLine()!!.trim()\n\n val toRight = (1..itemCount).map { 0 }.toMutableList()\n val toLeft = (1..itemCount).map { 0 }.toMutableList()\n\n for(i in input.indices) {\n var n = if(i>0) toRight[i-1] else 0\n if(input[i] == 'E') {\n n++\n }\n toRight[i] = n\n }\n\n for(i in input.indices.reversed()) {\n var n = if(i == input.lastIndex) 0 else toLeft[i+1]\n if(input[i] == 'W') {\n n++\n }\n toLeft[i] = n\n }\n\n var ans = 0\n for(i in input.indices) {\n var tmp = 1\n if(i > 0) {\n tmp += toRight[i-1]\n }\n if(i < input.lastIndex) {\n tmp += toLeft[i+1]\n }\n ans = Math.max(ans, tmp)\n }\n ans = itemCount - ans\n println(ans)\n}\n\n\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere are N people standing in a row from west to east.\nEach person is facing east or west.\nThe directions of the people is given as a string S of length N.\nThe i-th person from the west is facing east if S_i = E, and west if S_i = W.\n\nYou will appoint one of the N people as the leader, then command the rest of them to face in the direction of the leader.\nHere, we do not care which direction the leader is facing.\n\nThe people in the row hate to change their directions, so you would like to select the leader so that the number of people who have to change their directions is minimized.\nFind the minimum number of people who have to change their directions.\n\nConstraints\n\n2 \\leq N \\leq 3 \\times 10^5\n\n|S| = N\n\nS_i is E or W.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS\n\nOutput\n\nPrint the minimum number of people who have to change their directions.\n\nSample Input 1\n\n5\nWEEWW\n\nSample Output 1\n\n1\n\nAssume that we appoint the third person from the west as the leader.\nThen, the first person from the west needs to face east and has to turn around.\nThe other people do not need to change their directions, so the number of people who have to change their directions is 1 in this case.\nIt is not possible to have 0 people who have to change their directions, so the answer is 1.\n\nSample Input 2\n\n12\nWEWEWEEEWWWE\n\nSample Output 2\n\n4\n\nSample Input 3\n\n8\nWWWWWEEE\n\nSample Output 3\n\n3", "sample_input": "5\nWEEWW\n"}, "reference_outputs": ["1\n"], "source_document_id": "p03341", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere are N people standing in a row from west to east.\nEach person is facing east or west.\nThe directions of the people is given as a string S of length N.\nThe i-th person from the west is facing east if S_i = E, and west if S_i = W.\n\nYou will appoint one of the N people as the leader, then command the rest of them to face in the direction of the leader.\nHere, we do not care which direction the leader is facing.\n\nThe people in the row hate to change their directions, so you would like to select the leader so that the number of people who have to change their directions is minimized.\nFind the minimum number of people who have to change their directions.\n\nConstraints\n\n2 \\leq N \\leq 3 \\times 10^5\n\n|S| = N\n\nS_i is E or W.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS\n\nOutput\n\nPrint the minimum number of people who have to change their directions.\n\nSample Input 1\n\n5\nWEEWW\n\nSample Output 1\n\n1\n\nAssume that we appoint the third person from the west as the leader.\nThen, the first person from the west needs to face east and has to turn around.\nThe other people do not need to change their directions, so the number of people who have to change their directions is 1 in this case.\nIt is not possible to have 0 people who have to change their directions, so the answer is 1.\n\nSample Input 2\n\n12\nWEWEWEEEWWWE\n\nSample Output 2\n\n4\n\nSample Input 3\n\n8\nWWWWWEEE\n\nSample Output 3\n\n3", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 863, "cpu_time_ms": 357, "memory_kb": 53136}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s772032524", "group_id": "codeNet:p03348", "input_text": "import java.util.*\n\nfun getDistanceArray(graph: Array, s: Int): IntArray {\n val n = graph.size\n val distanceArray = IntArray(n, { -1 })\n fun dfs(v: Int, d: Int) {\n distanceArray[v] = d\n for (u in graph[v]) {\n if (distanceArray[u] >= 0) continue\n dfs(u, d + 1)\n }\n }\n dfs(s, 0)\n return distanceArray\n}\n\nfun getDistanceArray(graph: Array, cs: List): IntArray {\n val n = graph.size\n val distanceArray = IntArray(n, { -1 })\n data class BFSState(val v: Int, val d: Int)\n val queue = ArrayDeque()\n for (c in cs) {\n queue.offerLast(BFSState(c, 0))\n distanceArray[c] = 0\n }\n while (queue.isNotEmpty()) {\n val s = queue.pollFirst()\n for (u in graph[s.v]) {\n if (distanceArray[u] == -1) {\n queue.offerLast(BFSState(u, s.d + 1))\n distanceArray[u] = s.d + 1\n }\n }\n }\n return distanceArray\n}\n\nfun main(args: Array) {\n val n = readLine()!!.toInt()\n val mutableGraph = Array(n, { mutableListOf() })\n repeat(n - 1) {\n val (v1Raw, v2Raw) = readLine()!!.split(\" \").map { it.toInt() }\n val v1 = v1Raw - 1\n val v2 = v2Raw - 1\n mutableGraph[v1].add(v2)\n mutableGraph[v2].add(v1)\n }\n val graph = mutableGraph.map { it.toIntArray() }.toTypedArray()\n val x0 = 0\n val x0DistanceArray = getDistanceArray(graph, x0)\n val x1 = x0DistanceArray.indexOf(x0DistanceArray.max()!!)\n val x1DistanceArray = getDistanceArray(graph, x1)\n val x2 = x1DistanceArray.indexOf(x1DistanceArray.max()!!)\n val x2DistanceArray = getDistanceArray(graph, x2)\n\n val diameter = x2DistanceArray.max()!!\n val radius = diameter / 2\n // println(\"diameter: $diameter\")\n // println(\"radius: $radius\")\n val centroids = (0 until n).filter {\n if (diameter % 2 == 1) {\n (x1DistanceArray[it] == radius && x2DistanceArray[it] == radius + 1) ||\n (x1DistanceArray[it] == radius + 1 && x2DistanceArray[it] == radius)\n } else {\n x1DistanceArray[it] == radius && x2DistanceArray[it] == radius\n }\n }\n // println(\"centroids: $centroids\")\n\n fun leafCountForCentroids(inputCentroids: List): Long {\n val distanceArray = getDistanceArray(graph, inputCentroids)\n val maxChildren = IntArray(radius)\n for (v in 0 until n) {\n val d = distanceArray[v]\n if (d == radius) continue\n val childrenCount = graph[v].count { distanceArray[it] == d + 1 }\n maxChildren[d] = Math.max(maxChildren[d], childrenCount)\n }\n\n val leafCount = inputCentroids.size.toLong() *\n maxChildren.fold(1L, { l: Long, r: Int -> l * r.toLong() })\n return leafCount\n }\n\n val colorCount = radius + 1\n if (centroids.size == 2) {\n val leafCount = leafCountForCentroids(centroids)\n println(\"$colorCount $leafCount\")\n } else if (centroids.size == 1) {\n val c = centroids[0]\n var minLeafCount = leafCountForCentroids(centroids)\n for (v in graph[c]) {\n minLeafCount = Math.min(minLeafCount, leafCountForCentroids(listOf(c, v)))\n }\n println(\"$colorCount $minLeafCount\")\n } else {\n throw RuntimeException()\n }\n}\n", "language": "Kotlin", "metadata": {"date": 1526871622, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03348.html", "problem_id": "p03348", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03348/input.txt", "sample_output_relpath": "derived/input_output/data/p03348/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03348/Kotlin/s772032524.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s772032524", "user_id": "u771276542"}, "prompt_components": {"gold_output": "2 4\n", "input_to_evaluate": "import java.util.*\n\nfun getDistanceArray(graph: Array, s: Int): IntArray {\n val n = graph.size\n val distanceArray = IntArray(n, { -1 })\n fun dfs(v: Int, d: Int) {\n distanceArray[v] = d\n for (u in graph[v]) {\n if (distanceArray[u] >= 0) continue\n dfs(u, d + 1)\n }\n }\n dfs(s, 0)\n return distanceArray\n}\n\nfun getDistanceArray(graph: Array, cs: List): IntArray {\n val n = graph.size\n val distanceArray = IntArray(n, { -1 })\n data class BFSState(val v: Int, val d: Int)\n val queue = ArrayDeque()\n for (c in cs) {\n queue.offerLast(BFSState(c, 0))\n distanceArray[c] = 0\n }\n while (queue.isNotEmpty()) {\n val s = queue.pollFirst()\n for (u in graph[s.v]) {\n if (distanceArray[u] == -1) {\n queue.offerLast(BFSState(u, s.d + 1))\n distanceArray[u] = s.d + 1\n }\n }\n }\n return distanceArray\n}\n\nfun main(args: Array) {\n val n = readLine()!!.toInt()\n val mutableGraph = Array(n, { mutableListOf() })\n repeat(n - 1) {\n val (v1Raw, v2Raw) = readLine()!!.split(\" \").map { it.toInt() }\n val v1 = v1Raw - 1\n val v2 = v2Raw - 1\n mutableGraph[v1].add(v2)\n mutableGraph[v2].add(v1)\n }\n val graph = mutableGraph.map { it.toIntArray() }.toTypedArray()\n val x0 = 0\n val x0DistanceArray = getDistanceArray(graph, x0)\n val x1 = x0DistanceArray.indexOf(x0DistanceArray.max()!!)\n val x1DistanceArray = getDistanceArray(graph, x1)\n val x2 = x1DistanceArray.indexOf(x1DistanceArray.max()!!)\n val x2DistanceArray = getDistanceArray(graph, x2)\n\n val diameter = x2DistanceArray.max()!!\n val radius = diameter / 2\n // println(\"diameter: $diameter\")\n // println(\"radius: $radius\")\n val centroids = (0 until n).filter {\n if (diameter % 2 == 1) {\n (x1DistanceArray[it] == radius && x2DistanceArray[it] == radius + 1) ||\n (x1DistanceArray[it] == radius + 1 && x2DistanceArray[it] == radius)\n } else {\n x1DistanceArray[it] == radius && x2DistanceArray[it] == radius\n }\n }\n // println(\"centroids: $centroids\")\n\n fun leafCountForCentroids(inputCentroids: List): Long {\n val distanceArray = getDistanceArray(graph, inputCentroids)\n val maxChildren = IntArray(radius)\n for (v in 0 until n) {\n val d = distanceArray[v]\n if (d == radius) continue\n val childrenCount = graph[v].count { distanceArray[it] == d + 1 }\n maxChildren[d] = Math.max(maxChildren[d], childrenCount)\n }\n\n val leafCount = inputCentroids.size.toLong() *\n maxChildren.fold(1L, { l: Long, r: Int -> l * r.toLong() })\n return leafCount\n }\n\n val colorCount = radius + 1\n if (centroids.size == 2) {\n val leafCount = leafCountForCentroids(centroids)\n println(\"$colorCount $leafCount\")\n } else if (centroids.size == 1) {\n val c = centroids[0]\n var minLeafCount = leafCountForCentroids(centroids)\n for (v in graph[c]) {\n minLeafCount = Math.min(minLeafCount, leafCountForCentroids(listOf(c, v)))\n }\n println(\"$colorCount $minLeafCount\")\n } else {\n throw RuntimeException()\n }\n}\n", "problem_context": "Score : 1100 points\n\nProblem Statement\n\nColoring of the vertices of a tree G is called a good coloring when, for every pair of two vertices u and v painted in the same color, picking u as the root and picking v as the root would result in isomorphic rooted trees.\n\nAlso, the colorfulness of G is defined as the minimum possible number of different colors used in a good coloring of G.\n\nYou are given a tree with N vertices. The vertices are numbered 1 through N, and the i-th edge connects Vertex a_i and Vertex b_i. We will construct a new tree T by repeating the following operation on this tree some number of times:\n\nAdd a new vertex to the tree by connecting it to one of the vertices in the current tree with an edge.\n\nFind the minimum possible colorfulness of T.\nAdditionally, print the minimum number of leaves (vertices with degree 1) in a tree T that achieves the minimum colorfulness.\n\nNotes\n\nThe phrase \"picking u as the root and picking v as the root would result in isomorphic rooted trees\" for a tree G means that there exists a bijective function f_{uv} from the vertex set of G to itself such that both of the following conditions are met:\n\nf_{uv}(u)=v\n\nFor every pair of two vertices (a,b), edge (a,b) exists if and only if edge (f_{uv}(a),f_{uv}(b)) exists.\n\nConstraints\n\n2 \\leq N \\leq 100\n\n1 \\leq a_i,b_i \\leq N(1\\leq i\\leq N-1)\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\n:\na_{N-1} b_{N-1}\n\nOutput\n\nPrint two integers with a space in between.\nFirst, print the minimum possible colorfulness of a tree T that can be constructed.\nSecond, print the minimum number of leaves in a tree that achieves it.\n\nIt can be shown that, under the constraints of this problem, the values that should be printed fit into 64-bit signed integers.\n\nSample Input 1\n\n5\n1 2\n2 3\n3 4\n3 5\n\nSample Output 1\n\n2 4\n\nIf we connect a new vertex 6 to vertex 2, painting the vertices (1,4,5,6) red and painting the vertices (2,3) blue is a good coloring.\nSince painting all the vertices in a single color is not a good coloring, we can see that the colorfulness of this tree is 2.\nThis is actually the optimal solution. There are four leaves, so we should print 2 and 4.\n\nSample Input 2\n\n8\n1 2\n2 3\n4 3\n5 4\n6 7\n6 8\n3 6\n\nSample Output 2\n\n3 4\n\nSample Input 3\n\n10\n1 2\n2 3\n3 4\n4 5\n5 6\n6 7\n3 8\n5 9\n3 10\n\nSample Output 3\n\n4 6\n\nSample Input 4\n\n13\n5 6\n6 4\n2 8\n4 7\n8 9\n3 2\n10 4\n11 10\n2 4\n13 10\n1 8\n12 1\n\nSample Output 4\n\n4 12", "sample_input": "5\n1 2\n2 3\n3 4\n3 5\n"}, "reference_outputs": ["2 4\n"], "source_document_id": "p03348", "source_text": "Score : 1100 points\n\nProblem Statement\n\nColoring of the vertices of a tree G is called a good coloring when, for every pair of two vertices u and v painted in the same color, picking u as the root and picking v as the root would result in isomorphic rooted trees.\n\nAlso, the colorfulness of G is defined as the minimum possible number of different colors used in a good coloring of G.\n\nYou are given a tree with N vertices. The vertices are numbered 1 through N, and the i-th edge connects Vertex a_i and Vertex b_i. We will construct a new tree T by repeating the following operation on this tree some number of times:\n\nAdd a new vertex to the tree by connecting it to one of the vertices in the current tree with an edge.\n\nFind the minimum possible colorfulness of T.\nAdditionally, print the minimum number of leaves (vertices with degree 1) in a tree T that achieves the minimum colorfulness.\n\nNotes\n\nThe phrase \"picking u as the root and picking v as the root would result in isomorphic rooted trees\" for a tree G means that there exists a bijective function f_{uv} from the vertex set of G to itself such that both of the following conditions are met:\n\nf_{uv}(u)=v\n\nFor every pair of two vertices (a,b), edge (a,b) exists if and only if edge (f_{uv}(a),f_{uv}(b)) exists.\n\nConstraints\n\n2 \\leq N \\leq 100\n\n1 \\leq a_i,b_i \\leq N(1\\leq i\\leq N-1)\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\n:\na_{N-1} b_{N-1}\n\nOutput\n\nPrint two integers with a space in between.\nFirst, print the minimum possible colorfulness of a tree T that can be constructed.\nSecond, print the minimum number of leaves in a tree that achieves it.\n\nIt can be shown that, under the constraints of this problem, the values that should be printed fit into 64-bit signed integers.\n\nSample Input 1\n\n5\n1 2\n2 3\n3 4\n3 5\n\nSample Output 1\n\n2 4\n\nIf we connect a new vertex 6 to vertex 2, painting the vertices (1,4,5,6) red and painting the vertices (2,3) blue is a good coloring.\nSince painting all the vertices in a single color is not a good coloring, we can see that the colorfulness of this tree is 2.\nThis is actually the optimal solution. There are four leaves, so we should print 2 and 4.\n\nSample Input 2\n\n8\n1 2\n2 3\n4 3\n5 4\n6 7\n6 8\n3 6\n\nSample Output 2\n\n3 4\n\nSample Input 3\n\n10\n1 2\n2 3\n3 4\n4 5\n5 6\n6 7\n3 8\n5 9\n3 10\n\nSample Output 3\n\n4 6\n\nSample Input 4\n\n13\n5 6\n6 4\n2 8\n4 7\n8 9\n3 2\n10 4\n11 10\n2 4\n13 10\n1 8\n12 1\n\nSample Output 4\n\n4 12", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 3060, "cpu_time_ms": 320, "memory_kb": 37976}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s611428596", "group_id": "codeNet:p03353", "input_text": "fun main(args:Array) {\n val str = readLine()!!\n val n = readLine()!!.toInt()\n\n val strs = mutableSetOf()\n for( s in (0..str.length-1) ) {\n for( e in (0..str.length-1) ) {\n strs.add( str.slice(s..e) )\n }\n }\n\n val strs2 = strs.filter { it != \"\" }.toList().sorted()\n println(strs2[n-1])\n \n}", "language": "Kotlin", "metadata": {"date": 1526263752, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03353.html", "problem_id": "p03353", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03353/input.txt", "sample_output_relpath": "derived/input_output/data/p03353/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03353/Kotlin/s611428596.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s611428596", "user_id": "u693048766"}, "prompt_components": {"gold_output": "b\n", "input_to_evaluate": "fun main(args:Array) {\n val str = readLine()!!\n val n = readLine()!!.toInt()\n\n val strs = mutableSetOf()\n for( s in (0..str.length-1) ) {\n for( e in (0..str.length-1) ) {\n strs.add( str.slice(s..e) )\n }\n }\n\n val strs2 = strs.filter { it != \"\" }.toList().sorted()\n println(strs2[n-1])\n \n}", "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": "p03353", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 322, "cpu_time_ms": 2111, "memory_kb": 304284}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s454084234", "group_id": "codeNet:p03355", "input_text": "fun main() {\n val s= readLine()!!\n val n=s.length\n val k= readLine()!!.toInt()\n var subs= mutableSetOf()\n for (i in 0 until n){\n for (j in i until Math.min(n, i+k)){\n val sub=s.slice(i until j+1)\n subs.add(sub)\n }\n }\n println(subs.sorted()[k-1])\n}", "language": "Kotlin", "metadata": {"date": 1600490325, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p03355.html", "problem_id": "p03355", "resource_group": "medium_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/Kotlin/s454084234.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s454084234", "user_id": "u456173040"}, "prompt_components": {"gold_output": "b\n", "input_to_evaluate": "fun main() {\n val s= readLine()!!\n val n=s.length\n val k= readLine()!!.toInt()\n var subs= mutableSetOf()\n for (i in 0 until n){\n for (j in i until Math.min(n, i+k)){\n val sub=s.slice(i until j+1)\n subs.add(sub)\n }\n }\n println(subs.sorted()[k-1])\n}", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 220, "memory_kb": 45420}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s929260318", "group_id": "codeNet:p03359", "input_text": "fun main(args: Array) {\n a96(readLineList())\n}\n\nfun readLineList(): Array {\n val lineList = mutableListOf()\n while (true) {\n val line = readLine()\n if (line.isNullOrBlank()) {\n break\n } else {\n lineList.add(line!!)\n }\n }\n return lineList.toTypedArray()\n}\n\nfun a96(args: Array) {\n if (args.size != 1) {\n throw IllegalArgumentException()\n }\n val (month, day) = args[0].split(\" \").map { it.toInt() }\n println(if (month > day) month - 1 else day)\n}", "language": "Kotlin", "metadata": {"date": 1540512655, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03359.html", "problem_id": "p03359", "resource_group": "medium_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/Kotlin/s929260318.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s929260318", "user_id": "u227166381"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "fun main(args: Array) {\n a96(readLineList())\n}\n\nfun readLineList(): Array {\n val lineList = mutableListOf()\n while (true) {\n val line = readLine()\n if (line.isNullOrBlank()) {\n break\n } else {\n lineList.add(line!!)\n }\n }\n return lineList.toTypedArray()\n}\n\nfun a96(args: Array) {\n if (args.size != 1) {\n throw IllegalArgumentException()\n }\n val (month, day) = args[0].split(\" \").map { it.toInt() }\n println(if (month > day) month - 1 else day)\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 560, "cpu_time_ms": 237, "memory_kb": 38200}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s777632718", "group_id": "codeNet:p03359", "input_text": "fun main(args : Array) { \n print(readLine()!!.split(\" \").map { it.toInt() }.let { if (it[0] > it[1]) it[0] - 1 else it[0] })\n}", "language": "Kotlin", "metadata": {"date": 1533329896, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03359.html", "problem_id": "p03359", "resource_group": "medium_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/Kotlin/s777632718.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s777632718", "user_id": "u384476909"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "fun main(args : Array) { \n print(readLine()!!.split(\" \").map { it.toInt() }.let { if (it[0] > it[1]) it[0] - 1 else it[0] })\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 232, "memory_kb": 37748}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s771569932", "group_id": "codeNet:p03359", "input_text": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val a = sc.nextInt()\n val b = sc.nextInt()\n if (a < b) {\n println(a)\n } else {\n println(a - 1)\n }\n}", "language": "Kotlin", "metadata": {"date": 1525911422, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03359.html", "problem_id": "p03359", "resource_group": "medium_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/Kotlin/s771569932.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s771569932", "user_id": "u238734897"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val a = sc.nextInt()\n val b = sc.nextInt()\n if (a < b) {\n println(a)\n } else {\n println(a - 1)\n }\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 195, "cpu_time_ms": 180, "memory_kb": 29352}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s161985755", "group_id": "codeNet:p03360", "input_text": "fun pow(n:Int):Int {\n var res = 1\n for (i in 1..n) {\n res *= 2\n }\n return res\n}\n\nfun main(args: Array) {\n val v = readLine()!!.split(\" \").map {it.toInt()}\n val k : Int = readLine()!!.toInt()\n\n val m = v.max()!!\n\n val ans = pow(k) * m + v.filter { it != m }.sum()\n\n println(ans)\n}", "language": "Kotlin", "metadata": {"date": 1528601968, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03360.html", "problem_id": "p03360", "resource_group": "medium_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/Kotlin/s161985755.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s161985755", "user_id": "u185034753"}, "prompt_components": {"gold_output": "30\n", "input_to_evaluate": "fun pow(n:Int):Int {\n var res = 1\n for (i in 1..n) {\n res *= 2\n }\n return res\n}\n\nfun main(args: Array) {\n val v = readLine()!!.split(\" \").map {it.toInt()}\n val k : Int = readLine()!!.toInt()\n\n val m = v.max()!!\n\n val ans = pow(k) * m + v.filter { it != m }.sum()\n\n println(ans)\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 235, "memory_kb": 37768}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s122397564", "group_id": "codeNet:p03361", "input_text": "fun main(args: Array) {\n abc096c()\n}\n\n// 上下左右が`.`である`#`のマスが無ければ可\nfun abc096c() {\n val (h, w) = readLine()!!.split(\" \").map { it.toInt() }\n\n val sList = (1..h).map { readLine()!!.toCharArray().map { it == '#' }.toBooleanArray() }\n\n val answer = sList.mapIndexed { si, booleans ->\n booleans.mapIndexed { bi, b ->\n if (b) {\n val above = if (si - 1 >= 0) sList[si - 1][bi] else false\n val below = if (si + 1 <= h - 1) sList[si + 1][bi] else false\n val right = if (bi + 1 <= w - 1) booleans[bi + 1] else false\n val left = if (bi - 1 >= 0) booleans[bi - 1] else false\n above || below || right || left\n } else true\n }\n }.flatten().all { it }.let { if (it) \"Yes\" else \"No\" }\n\n println(answer)\n}\n", "language": "Kotlin", "metadata": {"date": 1569712955, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03361.html", "problem_id": "p03361", "resource_group": "medium_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/Kotlin/s122397564.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s122397564", "user_id": "u139478771"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "fun main(args: Array) {\n abc096c()\n}\n\n// 上下左右が`.`である`#`のマスが無ければ可\nfun abc096c() {\n val (h, w) = readLine()!!.split(\" \").map { it.toInt() }\n\n val sList = (1..h).map { readLine()!!.toCharArray().map { it == '#' }.toBooleanArray() }\n\n val answer = sList.mapIndexed { si, booleans ->\n booleans.mapIndexed { bi, b ->\n if (b) {\n val above = if (si - 1 >= 0) sList[si - 1][bi] else false\n val below = if (si + 1 <= h - 1) sList[si + 1][bi] else false\n val right = if (bi + 1 <= w - 1) booleans[bi + 1] else false\n val left = if (bi - 1 >= 0) booleans[bi - 1] else false\n above || below || right || left\n } else true\n }\n }.flatten().all { it }.let { if (it) \"Yes\" else \"No\" }\n\n println(answer)\n}\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 858, "cpu_time_ms": 244, "memory_kb": 37944}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s471663627", "group_id": "codeNet:p03362", "input_text": "fun main() {\n val n = readLine()!!.toInt()\n\n fun sieve(n: Int): List {\n val xs = BooleanArray(n + 1) { true }\n var i = 2\n while (i * i <= n) {\n if (xs[i]) {\n for (j in i + i..n step i) {\n xs[j] = false\n }\n }\n i++\n }\n return (2..n).filter { xs[it] }\n }\n\n val primes = sieve(55555)\n println(primes.filter { it % 5 == 1 }.take(n).joinToString(\" \"))\n}\n", "language": "Kotlin", "metadata": {"date": 1592676675, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p03362.html", "problem_id": "p03362", "resource_group": "medium_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/Kotlin/s471663627.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s471663627", "user_id": "u863309603"}, "prompt_components": {"gold_output": "3 5 7 11 31\n", "input_to_evaluate": "fun main() {\n val n = readLine()!!.toInt()\n\n fun sieve(n: Int): List {\n val xs = BooleanArray(n + 1) { true }\n var i = 2\n while (i * i <= n) {\n if (xs[i]) {\n for (j in i + i..n step i) {\n xs[j] = false\n }\n }\n i++\n }\n return (2..n).filter { xs[it] }\n }\n\n val primes = sieve(55555)\n println(primes.filter { it % 5 == 1 }.take(n).joinToString(\" \"))\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 485, "cpu_time_ms": 133, "memory_kb": 38568}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s628364627", "group_id": "codeNet:p03363", "input_text": "fun main(args: Array) {\n val n = readLine()!!.toInt()\n val a = readLine()!!.split(' ').map { it.toLong() }\n\n val s = LongArray(n + 1)\n for (i in 0 until n) {\n s[i + 1] = s[i] + a[i]\n }\n\n s.groupBy { it }\n .values\n .map { it.size }\n .map { it * (it - 1) / 2 }\n .sum()\n .let { println(it) }\n}\n", "language": "Kotlin", "metadata": {"date": 1582774193, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03363.html", "problem_id": "p03363", "resource_group": "medium_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/Kotlin/s628364627.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s628364627", "user_id": "u863309603"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "fun main(args: Array) {\n val n = readLine()!!.toInt()\n val a = readLine()!!.split(' ').map { it.toLong() }\n\n val s = LongArray(n + 1)\n for (i in 0 until n) {\n s[i + 1] = s[i] + a[i]\n }\n\n s.groupBy { it }\n .values\n .map { it.size }\n .map { it * (it - 1) / 2 }\n .sum()\n .let { println(it) }\n}\n", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 379, "cpu_time_ms": 845, "memory_kb": 109320}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s911806819", "group_id": "codeNet:p03365", "input_text": "\nimport com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type.Int\n\nconst val P = 1000000007L\n\n// Find (x, y, r) such that r = gcd(a,b) and ax + by = r.\nfun extendedGCD(a: Long, b: Long): Triple {\n var x0 = 1L\n var y0 = 0L\n var z0 = a\n var x1 = 0L\n var y1 = 1L\n var z1 = b\n while (true) {\n if (z1 == 0L) return Triple(x0, y0, z0)\n val q = z0 / z1\n val x2 = x0 - q * x1\n val y2 = y0 - q * y1\n val z2 = z0 - q * z1\n x0 = x1\n x1 = x2\n y0 = y1\n y1 = y2\n z0 = z1\n z1 = z2\n }\n}\n\nfun inverseMod(a: Long, m: Long): Long {\n val (x, y, r) = extendedGCD(a, m)\n if (r != 1L) return 0 // No inverse.\n\n return (x + m) % m\n}\n\nfun timesMod(x: Long, y: Long): Long {\n return x * y % P\n}\n\nfun plusMod(x: Long, y: Long): Long {\n return (x + y) % P\n}\n\nfun minusMod(x: Long, y: Long): Long {\n return (x - y + P) % P\n}\n\nfun main(args: Array) {\n val n = readLine()!!.toInt()\n val factorialTable = LongArray(n)\n factorialTable[0] = 1\n for (k in 1..(n - 1)) {\n factorialTable[k] = (factorialTable[k - 1] * k) % P\n }\n val inverseFactorialTable = factorialTable.map { inverseMod(it, P) }.toLongArray()\n\n val fTable = Array(n, { k ->\n if (2 * k < n) 0\n else timesMod(\n timesMod(factorialTable[k], factorialTable[k - 1]), inverseFactorialTable[2 * k - n])\n })\n\n var ans = 0L\n for (k in 1..(n - 1)) {\n val count = minusMod(fTable[k], fTable[k - 1])\n ans = plusMod(ans, timesMod(count, k.toLong()))\n }\n println(ans)\n}", "language": "Kotlin", "metadata": {"date": 1525900543, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03365.html", "problem_id": "p03365", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03365/input.txt", "sample_output_relpath": "derived/input_output/data/p03365/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03365/Kotlin/s911806819.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s911806819", "user_id": "u771276542"}, "prompt_components": {"gold_output": "16\n", "input_to_evaluate": "\nimport com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type.Int\n\nconst val P = 1000000007L\n\n// Find (x, y, r) such that r = gcd(a,b) and ax + by = r.\nfun extendedGCD(a: Long, b: Long): Triple {\n var x0 = 1L\n var y0 = 0L\n var z0 = a\n var x1 = 0L\n var y1 = 1L\n var z1 = b\n while (true) {\n if (z1 == 0L) return Triple(x0, y0, z0)\n val q = z0 / z1\n val x2 = x0 - q * x1\n val y2 = y0 - q * y1\n val z2 = z0 - q * z1\n x0 = x1\n x1 = x2\n y0 = y1\n y1 = y2\n z0 = z1\n z1 = z2\n }\n}\n\nfun inverseMod(a: Long, m: Long): Long {\n val (x, y, r) = extendedGCD(a, m)\n if (r != 1L) return 0 // No inverse.\n\n return (x + m) % m\n}\n\nfun timesMod(x: Long, y: Long): Long {\n return x * y % P\n}\n\nfun plusMod(x: Long, y: Long): Long {\n return (x + y) % P\n}\n\nfun minusMod(x: Long, y: Long): Long {\n return (x - y + P) % P\n}\n\nfun main(args: Array) {\n val n = readLine()!!.toInt()\n val factorialTable = LongArray(n)\n factorialTable[0] = 1\n for (k in 1..(n - 1)) {\n factorialTable[k] = (factorialTable[k - 1] * k) % P\n }\n val inverseFactorialTable = factorialTable.map { inverseMod(it, P) }.toLongArray()\n\n val fTable = Array(n, { k ->\n if (2 * k < n) 0\n else timesMod(\n timesMod(factorialTable[k], factorialTable[k - 1]), inverseFactorialTable[2 * k - n])\n })\n\n var ans = 0L\n for (k in 1..(n - 1)) {\n val count = minusMod(fTable[k], fTable[k - 1])\n ans = plusMod(ans, timesMod(count, k.toLong()))\n }\n println(ans)\n}", "problem_context": "Score : 800 points\n\nProblem Statement\n\nThere are N squares lining up in a row, numbered 1 through N from left to right.\nInitially, all squares are white.\nWe also have N-1 painting machines, numbered 1 through N-1.\nWhen operated, Machine i paints Square i and i+1 black.\n\nSnuke will operate these machines one by one.\nThe order in which he operates them is represented by a permutation of (1, 2, ..., N-1), P, which means that the i-th operated machine is Machine P_i.\n\nHere, the score of a permutation P is defined as the number of machines that are operated before all the squares are painted black for the first time, when the machines are operated in the order specified by P.\nSnuke has not decided what permutation P to use, but he is interested in the scores of possible permutations.\nFind the sum of the scores over all possible permutations for him.\nSince this can be extremely large, compute the sum modulo 10^9+7.\n\nConstraints\n\n2 \\leq N \\leq 10^6\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the sum of the scores over all possible permutations, modulo 10^9+7.\n\nSample Input 1\n\n4\n\nSample Output 1\n\n16\n\nThere are six possible permutations as P.\nAmong them, P = (1, 3, 2) and P = (3, 1, 2) have a score of 2, and the others have a score of 3.\nThus, the answer is 2 \\times 2 + 3 \\times 4 = 16.\n\nSample Input 2\n\n2\n\nSample Output 2\n\n1\n\nThere is only one possible permutation: P = (1), which has a score of 1.\n\nSample Input 3\n\n5\n\nSample Output 3\n\n84\n\nSample Input 4\n\n100000\n\nSample Output 4\n\n341429644", "sample_input": "4\n"}, "reference_outputs": ["16\n"], "source_document_id": "p03365", "source_text": "Score : 800 points\n\nProblem Statement\n\nThere are N squares lining up in a row, numbered 1 through N from left to right.\nInitially, all squares are white.\nWe also have N-1 painting machines, numbered 1 through N-1.\nWhen operated, Machine i paints Square i and i+1 black.\n\nSnuke will operate these machines one by one.\nThe order in which he operates them is represented by a permutation of (1, 2, ..., N-1), P, which means that the i-th operated machine is Machine P_i.\n\nHere, the score of a permutation P is defined as the number of machines that are operated before all the squares are painted black for the first time, when the machines are operated in the order specified by P.\nSnuke has not decided what permutation P to use, but he is interested in the scores of possible permutations.\nFind the sum of the scores over all possible permutations for him.\nSince this can be extremely large, compute the sum modulo 10^9+7.\n\nConstraints\n\n2 \\leq N \\leq 10^6\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the sum of the scores over all possible permutations, modulo 10^9+7.\n\nSample Input 1\n\n4\n\nSample Output 1\n\n16\n\nThere are six possible permutations as P.\nAmong them, P = (1, 3, 2) and P = (3, 1, 2) have a score of 2, and the others have a score of 3.\nThus, the answer is 2 \\times 2 + 3 \\times 4 = 16.\n\nSample Input 2\n\n2\n\nSample Output 2\n\n1\n\nThere is only one possible permutation: P = (1), which has a score of 1.\n\nSample Input 3\n\n5\n\nSample Output 3\n\n84\n\nSample Input 4\n\n100000\n\nSample Output 4\n\n341429644", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1498, "cpu_time_ms": 809, "memory_kb": 124180}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s573017886", "group_id": "codeNet:p03369", "input_text": "fun main(args: Array) {\n val num = readLine()!!.count{it == 'o'}\n println(700 + 100 * num)\n}", "language": "Kotlin", "metadata": {"date": 1554086635, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03369.html", "problem_id": "p03369", "resource_group": "medium_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/Kotlin/s573017886.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s573017886", "user_id": "u618112953"}, "prompt_components": {"gold_output": "900\n", "input_to_evaluate": "fun main(args: Array) {\n val num = readLine()!!.count{it == 'o'}\n println(700 + 100 * num)\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 210, "memory_kb": 33788}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s662689332", "group_id": "codeNet:p03370", "input_text": "fun main(args: Array) {\n val (n, x) = readLine()!!.split(\" \").map(String::toInt)\n val mList = mutableListOf()\n for (i in (0..(n - 1))) {\n mList.add(readLine()!!.toInt())\n }\n val count = mList.size + (x - mList.sum()) / mList.min()!!\n\n println(count)\n}", "language": "Kotlin", "metadata": {"date": 1527871168, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03370.html", "problem_id": "p03370", "resource_group": "medium_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/Kotlin/s662689332.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s662689332", "user_id": "u099066216"}, "prompt_components": {"gold_output": "9\n", "input_to_evaluate": "fun main(args: Array) {\n val (n, x) = readLine()!!.split(\" \").map(String::toInt)\n val mList = mutableListOf()\n for (i in (0..(n - 1))) {\n mList.add(readLine()!!.toInt())\n }\n val count = mList.size + (x - mList.sum()) / mList.min()!!\n\n println(count)\n}", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 289, "cpu_time_ms": 237, "memory_kb": 36016}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s789987218", "group_id": "codeNet:p03371", "input_text": "fun main(args: Array) {\n val (a, b, c, x, y) = readLine()!!.split(\" \").map(String::toInt)\n if (a + b < c * 2) {\n println(a * x + b * y)\n } else {\n when {\n (x <= y) -> {\n if (b < c * 2) {\n println(c * x * 2 + b * (y - x))\n } else {\n println(c * y * 2)\n }\n }\n (x > y) -> {\n if (a < c * 2) {\n println(c * y * 2 + a * (x - y))\n } else {\n println(c * x * 2)\n }\n }\n }\n }\n}", "language": "Kotlin", "metadata": {"date": 1527871753, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03371.html", "problem_id": "p03371", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03371/input.txt", "sample_output_relpath": "derived/input_output/data/p03371/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03371/Kotlin/s789987218.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s789987218", "user_id": "u099066216"}, "prompt_components": {"gold_output": "7900\n", "input_to_evaluate": "fun main(args: Array) {\n val (a, b, c, x, y) = readLine()!!.split(\" \").map(String::toInt)\n if (a + b < c * 2) {\n println(a * x + b * y)\n } else {\n when {\n (x <= y) -> {\n if (b < c * 2) {\n println(c * x * 2 + b * (y - x))\n } else {\n println(c * y * 2)\n }\n }\n (x > y) -> {\n if (a < c * 2) {\n println(c * y * 2 + a * (x - y))\n } else {\n println(c * x * 2)\n }\n }\n }\n }\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\n\"Pizza At\", a fast food chain, offers three kinds of pizza: \"A-pizza\", \"B-pizza\" and \"AB-pizza\". A-pizza and B-pizza are completely different pizzas, and AB-pizza is one half of A-pizza and one half of B-pizza combined together. The prices of one A-pizza, B-pizza and AB-pizza are A yen, B yen and C yen (yen is the currency of Japan), respectively.\n\nNakahashi needs to prepare X A-pizzas and Y B-pizzas for a party tonight. He can only obtain these pizzas by directly buying A-pizzas and B-pizzas, or buying two AB-pizzas and then rearrange them into one A-pizza and one B-pizza. At least how much money does he need for this? It is fine to have more pizzas than necessary by rearranging pizzas.\n\nConstraints\n\n1 ≤ A, B, C ≤ 5000\n\n1 ≤ X, Y ≤ 10^5\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C X Y\n\nOutput\n\nPrint the minimum amount of money required to prepare X A-pizzas and Y B-pizzas.\n\nSample Input 1\n\n1500 2000 1600 3 2\n\nSample Output 1\n\n7900\n\nIt is optimal to buy four AB-pizzas and rearrange them into two A-pizzas and two B-pizzas, then buy additional one A-pizza.\n\nSample Input 2\n\n1500 2000 1900 3 2\n\nSample Output 2\n\n8500\n\nIt is optimal to directly buy three A-pizzas and two B-pizzas.\n\nSample Input 3\n\n1500 2000 500 90000 100000\n\nSample Output 3\n\n100000000\n\nIt is optimal to buy 200000 AB-pizzas and rearrange them into 100000 A-pizzas and 100000 B-pizzas. We will have 10000 more A-pizzas than necessary, but that is fine.", "sample_input": "1500 2000 1600 3 2\n"}, "reference_outputs": ["7900\n"], "source_document_id": "p03371", "source_text": "Score : 300 points\n\nProblem Statement\n\n\"Pizza At\", a fast food chain, offers three kinds of pizza: \"A-pizza\", \"B-pizza\" and \"AB-pizza\". A-pizza and B-pizza are completely different pizzas, and AB-pizza is one half of A-pizza and one half of B-pizza combined together. The prices of one A-pizza, B-pizza and AB-pizza are A yen, B yen and C yen (yen is the currency of Japan), respectively.\n\nNakahashi needs to prepare X A-pizzas and Y B-pizzas for a party tonight. He can only obtain these pizzas by directly buying A-pizzas and B-pizzas, or buying two AB-pizzas and then rearrange them into one A-pizza and one B-pizza. At least how much money does he need for this? It is fine to have more pizzas than necessary by rearranging pizzas.\n\nConstraints\n\n1 ≤ A, B, C ≤ 5000\n\n1 ≤ X, Y ≤ 10^5\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C X Y\n\nOutput\n\nPrint the minimum amount of money required to prepare X A-pizzas and Y B-pizzas.\n\nSample Input 1\n\n1500 2000 1600 3 2\n\nSample Output 1\n\n7900\n\nIt is optimal to buy four AB-pizzas and rearrange them into two A-pizzas and two B-pizzas, then buy additional one A-pizza.\n\nSample Input 2\n\n1500 2000 1900 3 2\n\nSample Output 2\n\n8500\n\nIt is optimal to directly buy three A-pizzas and two B-pizzas.\n\nSample Input 3\n\n1500 2000 500 90000 100000\n\nSample Output 3\n\n100000000\n\nIt is optimal to buy 200000 AB-pizzas and rearrange them into 100000 A-pizzas and 100000 B-pizzas. We will have 10000 more A-pizzas than necessary, but that is fine.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 617, "cpu_time_ms": 241, "memory_kb": 37904}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s211740632", "group_id": "codeNet:p03381", "input_text": "//300\nfun ac095(args: Array) {\n val numList = args[1].split(\" \").map { it.toInt() }\n val sortedNumList = numList.sorted()\n val medIndex = (numList.size - 1) / 2\n val med = sortedNumList[medIndex]\n val even = numList.size % 2 == 0\n val buffer = StringBuilder()\n numList.forEach {\n if (even) {\n buffer.append(if (it > med) med else sortedNumList[medIndex + 1])\n } else {\n buffer.append(if (it < med) med else sortedNumList[medIndex - 1])\n }\n buffer.append(\"\\n\")\n }\n print(buffer)\n}\n\nfun main(args: Array) {\n ac095(readLineList())\n}\n\nfun readLineList(): Array {\n val lineList = mutableListOf()\n while (true) {\n val line = readLine()\n if (line.isNullOrBlank()) {\n break\n } else {\n lineList.add(line!!)\n }\n }\n return lineList.toTypedArray()\n}", "language": "Kotlin", "metadata": {"date": 1552176924, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03381.html", "problem_id": "p03381", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03381/input.txt", "sample_output_relpath": "derived/input_output/data/p03381/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03381/Kotlin/s211740632.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s211740632", "user_id": "u241874341"}, "prompt_components": {"gold_output": "4\n3\n3\n4\n", "input_to_evaluate": "//300\nfun ac095(args: Array) {\n val numList = args[1].split(\" \").map { it.toInt() }\n val sortedNumList = numList.sorted()\n val medIndex = (numList.size - 1) / 2\n val med = sortedNumList[medIndex]\n val even = numList.size % 2 == 0\n val buffer = StringBuilder()\n numList.forEach {\n if (even) {\n buffer.append(if (it > med) med else sortedNumList[medIndex + 1])\n } else {\n buffer.append(if (it < med) med else sortedNumList[medIndex - 1])\n }\n buffer.append(\"\\n\")\n }\n print(buffer)\n}\n\nfun main(args: Array) {\n ac095(readLineList())\n}\n\nfun readLineList(): Array {\n val lineList = mutableListOf()\n while (true) {\n val line = readLine()\n if (line.isNullOrBlank()) {\n break\n } else {\n lineList.add(line!!)\n }\n }\n return lineList.toTypedArray()\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": "p03381", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 911, "cpu_time_ms": 1150, "memory_kb": 94448}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s517977045", "group_id": "codeNet:p03385", "input_text": "import java.util.*\n\nfun main(args: Array) {\n val scanner = Scanner(System.`in`)\n val str = scanner.next()\n\n var aFlag = false\n var bFlag = false\n var cFlag = false\n if (str.length == 3) {\n str.forEach {it ->\n if (!aFlag && it == 'a') {\n aFlag = true\n }\n else if (!bFlag && it == 'b') {\n bFlag = true\n }\n else if (!cFlag && it == 'c') {\n cFlag = true\n }\n }\n\n if (aFlag && bFlag && cFlag) {\n println(\"Yes\")\n return\n }\n }\n println(\"No\")\n}", "language": "Kotlin", "metadata": {"date": 1523149752, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03385.html", "problem_id": "p03385", "resource_group": "medium_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/Kotlin/s517977045.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s517977045", "user_id": "u072767564"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "import java.util.*\n\nfun main(args: Array) {\n val scanner = Scanner(System.`in`)\n val str = scanner.next()\n\n var aFlag = false\n var bFlag = false\n var cFlag = false\n if (str.length == 3) {\n str.forEach {it ->\n if (!aFlag && it == 'a') {\n aFlag = true\n }\n else if (!bFlag && it == 'b') {\n bFlag = true\n }\n else if (!cFlag && it == 'c') {\n cFlag = true\n }\n }\n\n if (aFlag && bFlag && cFlag) {\n println(\"Yes\")\n return\n }\n }\n println(\"No\")\n}", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 628, "cpu_time_ms": 238, "memory_kb": 31260}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s408742706", "group_id": "codeNet:p03386", "input_text": "import java.io.*\nimport java.util.*\n\nvar pw = PrintWriter(System.out)\nfun solve(A: Long, B: Long, K: Long){\n if (2 * K >= B-A+1){ (A..B).forEach{println(it)}; return }\n (A until A+K).forEach{println(it)}\n (B - K+1..B).forEach{println(it)}\n return\n}\n\n\nfun main(args: Array) {\n fun StringArray(size: Int, init: (Int) -> String = { \"\\u0000\" }): Array {\n return Array(size, init)\n }\n class Scanner(stream: InputStream) {\n private val reader = BufferedInputStream(stream).bufferedReader()\n private var st: StringTokenizer? = null\n fun next(): String {\n while (!(st?.hasMoreTokens() ?: false)) st = StringTokenizer(reader.readLine())\n return st!!.nextToken()\n }\n }\n val sc = Scanner(System.`in`)\n val A = sc.next().toLong()\n val B = sc.next().toLong()\n val K = sc.next().toLong()\n solve(A, B, K)\n}\n\n", "language": "Kotlin", "metadata": {"date": 1564540676, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03386.html", "problem_id": "p03386", "resource_group": "medium_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/Kotlin/s408742706.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s408742706", "user_id": "u329232967"}, "prompt_components": {"gold_output": "3\n4\n7\n8\n", "input_to_evaluate": "import java.io.*\nimport java.util.*\n\nvar pw = PrintWriter(System.out)\nfun solve(A: Long, B: Long, K: Long){\n if (2 * K >= B-A+1){ (A..B).forEach{println(it)}; return }\n (A until A+K).forEach{println(it)}\n (B - K+1..B).forEach{println(it)}\n return\n}\n\n\nfun main(args: Array) {\n fun StringArray(size: Int, init: (Int) -> String = { \"\\u0000\" }): Array {\n return Array(size, init)\n }\n class Scanner(stream: InputStream) {\n private val reader = BufferedInputStream(stream).bufferedReader()\n private var st: StringTokenizer? = null\n fun next(): String {\n while (!(st?.hasMoreTokens() ?: false)) st = StringTokenizer(reader.readLine())\n return st!!.nextToken()\n }\n }\n val sc = Scanner(System.`in`)\n val A = sc.next().toLong()\n val B = sc.next().toLong()\n val K = sc.next().toLong()\n solve(A, B, K)\n}\n\n", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 913, "cpu_time_ms": 192, "memory_kb": 31392}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s891345320", "group_id": "codeNet:p03387", "input_text": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val t = (1..3).map { sc.nextInt() }\n val max = t.max()!!\n var sumDiff = t.map { max - it }.sum()\n if (sumDiff % 2 != 0) {\n sumDiff += 3\n }\n println(sumDiff / 2)\n}", "language": "Kotlin", "metadata": {"date": 1583366381, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03387.html", "problem_id": "p03387", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03387/input.txt", "sample_output_relpath": "derived/input_output/data/p03387/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03387/Kotlin/s891345320.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s891345320", "user_id": "u733811860"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val t = (1..3).map { sc.nextInt() }\n val max = t.max()!!\n var sumDiff = t.map { max - it }.sum()\n if (sumDiff % 2 != 0) {\n sumDiff += 3\n }\n println(sumDiff / 2)\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nYou are given three integers A, B and C. Find the minimum number of operations required to make A, B and C all equal by repeatedly performing the following two kinds of operations in any order:\n\nChoose two among A, B and C, then increase both by 1.\n\nChoose one among A, B and C, then increase it by 2.\n\nIt can be proved that we can always make A, B and C all equal by repeatedly performing these operations.\n\nConstraints\n\n0 \\leq A,B,C \\leq 50\n\nAll values in input 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 number of operations required to make A, B and C all equal.\n\nSample Input 1\n\n2 5 4\n\nSample Output 1\n\n2\n\nWe can make A, B and C all equal by the following operations:\n\nIncrease A and C by 1. Now, A, B, C are 3, 5, 5, respectively.\n\nIncrease A by 2. Now, A, B, C are 5, 5, 5, respectively.\n\nSample Input 2\n\n2 6 3\n\nSample Output 2\n\n5\n\nSample Input 3\n\n31 41 5\n\nSample Output 3\n\n23", "sample_input": "2 5 4\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03387", "source_text": "Score : 300 points\n\nProblem Statement\n\nYou are given three integers A, B and C. Find the minimum number of operations required to make A, B and C all equal by repeatedly performing the following two kinds of operations in any order:\n\nChoose two among A, B and C, then increase both by 1.\n\nChoose one among A, B and C, then increase it by 2.\n\nIt can be proved that we can always make A, B and C all equal by repeatedly performing these operations.\n\nConstraints\n\n0 \\leq A,B,C \\leq 50\n\nAll values in input 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 number of operations required to make A, B and C all equal.\n\nSample Input 1\n\n2 5 4\n\nSample Output 1\n\n2\n\nWe can make A, B and C all equal by the following operations:\n\nIncrease A and C by 1. Now, A, B, C are 3, 5, 5, respectively.\n\nIncrease A by 2. Now, A, B, C are 5, 5, 5, respectively.\n\nSample Input 2\n\n2 6 3\n\nSample Output 2\n\n5\n\nSample Input 3\n\n31 41 5\n\nSample Output 3\n\n23", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 186, "memory_kb": 31644}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s481544739", "group_id": "codeNet:p03388", "input_text": "fun main(args: Array) {\n var Q = nextInt()\n repeat(Q) {\n val (A, B) = listOfLong()\n val ans: Long\n if (A == B) {\n ans = 2 * A - 2\n } else if (A + 1 == B || B + 1 == A) {\n ans = 2 * Math.min(A, B) - 2\n } else {\n val ab = A * B\n var d = Math.sqrt(ab.toDouble()).toLong()\n if (d * d == ab) d--\n if (d * (d + 1) >= ab) {\n ans = 2 * d - 2\n } else {\n ans = 2 * d - 1\n }\n }\n println(ans)\n }\n}\n\nfun next() = readLine()!!\nfun nextInt() = next().toInt()\nfun listOfString() = next().split(\" \")\nfun listOfLong(d: Long = 0) = listOfString().map { it.toLong() + d }\n", "language": "Kotlin", "metadata": {"date": 1584464074, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03388.html", "problem_id": "p03388", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03388/input.txt", "sample_output_relpath": "derived/input_output/data/p03388/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03388/Kotlin/s481544739.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s481544739", "user_id": "u043150661"}, "prompt_components": {"gold_output": "1\n12\n4\n11\n14\n57\n31\n671644785\n", "input_to_evaluate": "fun main(args: Array) {\n var Q = nextInt()\n repeat(Q) {\n val (A, B) = listOfLong()\n val ans: Long\n if (A == B) {\n ans = 2 * A - 2\n } else if (A + 1 == B || B + 1 == A) {\n ans = 2 * Math.min(A, B) - 2\n } else {\n val ab = A * B\n var d = Math.sqrt(ab.toDouble()).toLong()\n if (d * d == ab) d--\n if (d * (d + 1) >= ab) {\n ans = 2 * d - 2\n } else {\n ans = 2 * d - 1\n }\n }\n println(ans)\n }\n}\n\nfun next() = readLine()!!\nfun nextInt() = next().toInt()\nfun listOfString() = next().split(\" \")\nfun listOfLong(d: Long = 0) = listOfString().map { it.toLong() + d }\n", "problem_context": "Score : 700 points\n\nProblem Statement\n\n10^{10^{10}} participants, including Takahashi, competed in two programming contests.\nIn each contest, all participants had distinct ranks from first through 10^{10^{10}}-th.\n\nThe score of a participant is the product of his/her ranks in the two contests.\n\nProcess the following Q queries:\n\nIn the i-th query, you are given two positive integers A_i and B_i. Assuming that Takahashi was ranked A_i-th in the first contest and B_i-th in the second contest, find the maximum possible number of participants whose scores are smaller than Takahashi's.\n\nConstraints\n\n1 \\leq Q \\leq 100\n\n1\\leq A_i,B_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\nQ\nA_1 B_1\n:\nA_Q B_Q\n\nOutput\n\nFor each query, print the maximum possible number of participants whose scores are smaller than Takahashi's.\n\nSample Input 1\n\n8\n1 4\n10 5\n3 3\n4 11\n8 9\n22 40\n8 36\n314159265 358979323\n\nSample Output 1\n\n1\n12\n4\n11\n14\n57\n31\n671644785\n\nLet us denote a participant who was ranked x-th in the first contest and y-th in the second contest as (x,y).\n\nIn the first query, (2,1) is a possible candidate of a participant whose score is smaller than Takahashi's. There are never two or more participants whose scores are smaller than Takahashi's, so we should print 1.", "sample_input": "8\n1 4\n10 5\n3 3\n4 11\n8 9\n22 40\n8 36\n314159265 358979323\n"}, "reference_outputs": ["1\n12\n4\n11\n14\n57\n31\n671644785\n"], "source_document_id": "p03388", "source_text": "Score : 700 points\n\nProblem Statement\n\n10^{10^{10}} participants, including Takahashi, competed in two programming contests.\nIn each contest, all participants had distinct ranks from first through 10^{10^{10}}-th.\n\nThe score of a participant is the product of his/her ranks in the two contests.\n\nProcess the following Q queries:\n\nIn the i-th query, you are given two positive integers A_i and B_i. Assuming that Takahashi was ranked A_i-th in the first contest and B_i-th in the second contest, find the maximum possible number of participants whose scores are smaller than Takahashi's.\n\nConstraints\n\n1 \\leq Q \\leq 100\n\n1\\leq A_i,B_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\nQ\nA_1 B_1\n:\nA_Q B_Q\n\nOutput\n\nFor each query, print the maximum possible number of participants whose scores are smaller than Takahashi's.\n\nSample Input 1\n\n8\n1 4\n10 5\n3 3\n4 11\n8 9\n22 40\n8 36\n314159265 358979323\n\nSample Output 1\n\n1\n12\n4\n11\n14\n57\n31\n671644785\n\nLet us denote a participant who was ranked x-th in the first contest and y-th in the second contest as (x,y).\n\nIn the first query, (2,1) is a possible candidate of a participant whose score is smaller than Takahashi's. There are never two or more participants whose scores are smaller than Takahashi's, so we should print 1.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 736, "cpu_time_ms": 244, "memory_kb": 37936}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s019308707", "group_id": "codeNet:p03392", "input_text": "import java.util.*\n\nconst val P = 998244353L\n\ndata class FiniteField(val x: Long) {\n constructor(xi: Int): this(xi.toLong())\n operator fun plus(o: FiniteField) = FiniteField((x + o.x) % P)\n operator fun plus(o: Int) = this + FiniteField(o)\n operator fun minus(o: FiniteField) = FiniteField((x + P - o.x) % P)\n operator fun minus(o: Int) = this - FiniteField(o)\n}\n\nfun solveBruteForce(s: String): Int {\n val q = ArrayDeque()\n q.offerLast(s)\n val set = mutableSetOf()\n set.add(s)\n while (q.isNotEmpty()) {\n val state = q.pollFirst()\n for (i in 0 until (state.length - 1)) {\n if (state[i] != state[i + 1]) {\n val c1 = state[i]\n val c2 = state[i + 1]\n ('a'..'c').forEach {\n if (c1 != it && c2 != it) {\n val nextBuilder = StringBuilder(state)\n nextBuilder[i] = it\n nextBuilder[i + 1] = it\n val next = nextBuilder.toString()\n if (!set.contains(next)) {\n q.offerLast(next)\n set.add(next)\n }\n }\n }\n }\n }\n }\n return set.size\n}\n\nfun cToI(c: Char) = c - 'a'\n\nfun main(args: Array) {\n val s = readLine()!!\n if (s.length <= 3) {\n println(solveBruteForce(s))\n return\n }\n val n = s.length\n // [element index][mod][last]\n val dp1 = Array(n, { Array(3, { LongArray(3, { 0L }) }) })\n val dp2 = Array(n, { Array(3, { LongArray(3, { 0L }) }) })\n for (x in 0..2) {\n dp1[0][x][x] = 1L\n dp2[0][x][x] = 1L\n }\n for (k in 0 until n - 1) {\n for (m in 0..2) {\n for (x in 0..2) {\n for (y in 0..2) {\n dp1[k + 1][(m + y) % 3][y] += dp1[k][m][x]\n dp1[k + 1][(m + y) % 3][y] %= P\n if (x != y) {\n dp2[k + 1][(m + y) % 3][y] += dp2[k][m][x]\n dp2[k + 1][(m + y) % 3][y] %= P\n }\n }\n }\n }\n }\n val sMod = s.map(::cToI).sum() % 3\n val t1 = dp1[n - 1][sMod].sum() % P\n val t2 = dp2[n - 1][sMod].sum() % P\n val sCount = !(0 until n - 1).any { s[it] == s[it + 1] }\n val ans = (t1 + P - t2 + if (sCount) 1 else 0) % P\n println(ans)\n}\n", "language": "Kotlin", "metadata": {"date": 1523217735, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03392.html", "problem_id": "p03392", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03392/input.txt", "sample_output_relpath": "derived/input_output/data/p03392/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03392/Kotlin/s019308707.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s019308707", "user_id": "u771276542"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "import java.util.*\n\nconst val P = 998244353L\n\ndata class FiniteField(val x: Long) {\n constructor(xi: Int): this(xi.toLong())\n operator fun plus(o: FiniteField) = FiniteField((x + o.x) % P)\n operator fun plus(o: Int) = this + FiniteField(o)\n operator fun minus(o: FiniteField) = FiniteField((x + P - o.x) % P)\n operator fun minus(o: Int) = this - FiniteField(o)\n}\n\nfun solveBruteForce(s: String): Int {\n val q = ArrayDeque()\n q.offerLast(s)\n val set = mutableSetOf()\n set.add(s)\n while (q.isNotEmpty()) {\n val state = q.pollFirst()\n for (i in 0 until (state.length - 1)) {\n if (state[i] != state[i + 1]) {\n val c1 = state[i]\n val c2 = state[i + 1]\n ('a'..'c').forEach {\n if (c1 != it && c2 != it) {\n val nextBuilder = StringBuilder(state)\n nextBuilder[i] = it\n nextBuilder[i + 1] = it\n val next = nextBuilder.toString()\n if (!set.contains(next)) {\n q.offerLast(next)\n set.add(next)\n }\n }\n }\n }\n }\n }\n return set.size\n}\n\nfun cToI(c: Char) = c - 'a'\n\nfun main(args: Array) {\n val s = readLine()!!\n if (s.length <= 3) {\n println(solveBruteForce(s))\n return\n }\n val n = s.length\n // [element index][mod][last]\n val dp1 = Array(n, { Array(3, { LongArray(3, { 0L }) }) })\n val dp2 = Array(n, { Array(3, { LongArray(3, { 0L }) }) })\n for (x in 0..2) {\n dp1[0][x][x] = 1L\n dp2[0][x][x] = 1L\n }\n for (k in 0 until n - 1) {\n for (m in 0..2) {\n for (x in 0..2) {\n for (y in 0..2) {\n dp1[k + 1][(m + y) % 3][y] += dp1[k][m][x]\n dp1[k + 1][(m + y) % 3][y] %= P\n if (x != y) {\n dp2[k + 1][(m + y) % 3][y] += dp2[k][m][x]\n dp2[k + 1][(m + y) % 3][y] %= P\n }\n }\n }\n }\n }\n val sMod = s.map(::cToI).sum() % 3\n val t1 = dp1[n - 1][sMod].sum() % P\n val t2 = dp2[n - 1][sMod].sum() % P\n val sCount = !(0 until n - 1).any { s[it] == s[it + 1] }\n val ans = (t1 + P - t2 + if (sCount) 1 else 0) % P\n println(ans)\n}\n", "problem_context": "Score : 700 points\n\nProblem Statement\n\nYou are given a string S consisting of a,b and c. Find the number of strings that can be possibly obtained by repeatedly performing the following operation zero or more times, modulo 998244353:\n\nChoose an integer i such that 1\\leq i\\leq |S|-1 and the i-th and (i+1)-th characters in S are different. Replace each of the i-th and (i+1)-th characters in S with the character that differs from both of them (among a, b and c).\n\nConstraints\n\n2 \\leq |S| \\leq 2 × 10^5\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\nPrint the number of strings that can be possibly obtained by repeatedly performing the operation, modulo 998244353.\n\nSample Input 1\n\nabc\n\nSample Output 1\n\n3\n\nabc, aaa and ccc can be obtained.\n\nSample Input 2\n\nabbac\n\nSample Output 2\n\n65\n\nSample Input 3\n\nbabacabac\n\nSample Output 3\n\n6310\n\nSample Input 4\n\nababacbcacbacacbcbbcbbacbaccacbacbacba\n\nSample Output 4\n\n148010497", "sample_input": "abc\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03392", "source_text": "Score : 700 points\n\nProblem Statement\n\nYou are given a string S consisting of a,b and c. Find the number of strings that can be possibly obtained by repeatedly performing the following operation zero or more times, modulo 998244353:\n\nChoose an integer i such that 1\\leq i\\leq |S|-1 and the i-th and (i+1)-th characters in S are different. Replace each of the i-th and (i+1)-th characters in S with the character that differs from both of them (among a, b and c).\n\nConstraints\n\n2 \\leq |S| \\leq 2 × 10^5\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\nPrint the number of strings that can be possibly obtained by repeatedly performing the operation, modulo 998244353.\n\nSample Input 1\n\nabc\n\nSample Output 1\n\n3\n\nabc, aaa and ccc can be obtained.\n\nSample Input 2\n\nabbac\n\nSample Output 2\n\n65\n\nSample Input 3\n\nbabacabac\n\nSample Output 3\n\n6310\n\nSample Input 4\n\nababacbcacbacacbcbbcbbacbaccacbacbacba\n\nSample Output 4\n\n148010497", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2100, "cpu_time_ms": 951, "memory_kb": 113752}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s195665972", "group_id": "codeNet:p03399", "input_text": "fun main(args: Array) {\n val a = readInt()\n val b = readInt()\n val c = readInt()\n val d = readInt()\n println((if (a >= b) a else b) + (if (c >= d) c else d))\n}\n\nfun printYesOrNo(flag: Boolean) {\n println(if (flag) \"Yes\" else \"No\")\n}\n\nfun readIntList(): List = readLine()!!.split(' ').map { it.toInt() }\n\nfun readInt(): Int = readLine()!!.toInt()\n\nfun err(print: Any) {\n System.err.println(print)\n}", "language": "Kotlin", "metadata": {"date": 1522026091, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03399.html", "problem_id": "p03399", "resource_group": "medium_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/Kotlin/s195665972.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s195665972", "user_id": "u166163326"}, "prompt_components": {"gold_output": "520\n", "input_to_evaluate": "fun main(args: Array) {\n val a = readInt()\n val b = readInt()\n val c = readInt()\n val d = readInt()\n println((if (a >= b) a else b) + (if (c >= d) c else d))\n}\n\nfun printYesOrNo(flag: Boolean) {\n println(if (flag) \"Yes\" else \"No\")\n}\n\nfun readIntList(): List = readLine()!!.split(' ').map { it.toInt() }\n\nfun readInt(): Int = readLine()!!.toInt()\n\nfun err(print: Any) {\n System.err.println(print)\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 246, "memory_kb": 31436}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s947059540", "group_id": "codeNet:p03400", "input_text": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val n = sc.nextInt()\n val d = sc.nextInt()\n val x = sc.nextInt()\n val a = (1..n).map { sc.nextInt() }\n\n println(abc092b(n, d, x, a))\n}\n\nprivate fun abc092b(n: Int, d: Int, x: Int, a: List): Int {\n var count = 0\n\n for (ai in a) {\n var tmp = 0\n while (ai * tmp + 1 <= d) {\n tmp++\n count++\n }\n }\n\n return count + x\n}\n", "language": "Kotlin", "metadata": {"date": 1590634306, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03400.html", "problem_id": "p03400", "resource_group": "medium_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/Kotlin/s947059540.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s947059540", "user_id": "u323522006"}, "prompt_components": {"gold_output": "8\n", "input_to_evaluate": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val n = sc.nextInt()\n val d = sc.nextInt()\n val x = sc.nextInt()\n val a = (1..n).map { sc.nextInt() }\n\n println(abc092b(n, d, x, a))\n}\n\nprivate fun abc092b(n: Int, d: Int, x: Int, a: List): Int {\n var count = 0\n\n for (ai in a) {\n var tmp = 0\n while (ai * tmp + 1 <= d) {\n tmp++\n count++\n }\n }\n\n return count + x\n}\n", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 200, "memory_kb": 31632}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s377484809", "group_id": "codeNet:p03400", "input_text": "fun main(args: Array) {\n val n = readLine()?.toInt() ?: return\n val (d, x) = readLine()?.split(\" \")?.map { it.toInt() } ?: return\n val aList = (0 until n).map {\n readLine()?.toInt()!!\n }\n\n var result = 0\n for (i in 0 until n) {\n var count = 1\n while (count <= d) {\n result++\n count += aList[i]\n }\n }\n\n result += x\n println(result)\n}", "language": "Kotlin", "metadata": {"date": 1585105410, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03400.html", "problem_id": "p03400", "resource_group": "medium_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/Kotlin/s377484809.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s377484809", "user_id": "u026352629"}, "prompt_components": {"gold_output": "8\n", "input_to_evaluate": "fun main(args: Array) {\n val n = readLine()?.toInt() ?: return\n val (d, x) = readLine()?.split(\" \")?.map { it.toInt() } ?: return\n val aList = (0 until n).map {\n readLine()?.toInt()!!\n }\n\n var result = 0\n for (i in 0 until n) {\n var count = 1\n while (count <= d) {\n result++\n count += aList[i]\n }\n }\n\n result += x\n println(result)\n}", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 250, "memory_kb": 36020}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s723028724", "group_id": "codeNet:p03400", "input_text": "fun main(args: Array) {\n\n val n = readLine()?.toInt()!!\n var d = 0\n var x = 0\n\n readLine()\n ?.split(\" \")\n ?.map { it.toInt() }\n .let {\n d = it!![0] - 1\n x = it[1]\n }\n\n print(\n mutableListOf()\n .apply {\n (0 until n).forEach {\n add((d / readLine()?.toInt()!!) + 1)\n }\n }.sum() + x\n )\n}", "language": "Kotlin", "metadata": {"date": 1522344168, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03400.html", "problem_id": "p03400", "resource_group": "medium_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/Kotlin/s723028724.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s723028724", "user_id": "u469197201"}, "prompt_components": {"gold_output": "8\n", "input_to_evaluate": "fun main(args: Array) {\n\n val n = readLine()?.toInt()!!\n var d = 0\n var x = 0\n\n readLine()\n ?.split(\" \")\n ?.map { it.toInt() }\n .let {\n d = it!![0] - 1\n x = it[1]\n }\n\n print(\n mutableListOf()\n .apply {\n (0 until n).forEach {\n add((d / readLine()?.toInt()!!) + 1)\n }\n }.sum() + x\n )\n}", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 510, "cpu_time_ms": 241, "memory_kb": 37800}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s337507817", "group_id": "codeNet:p03402", "input_text": "import java.util.*\n\nfun main(args:Array){\n val (a,b) = readLine()!!.split(\" \").map{it.toInt()}\n val ans = Array(100){CharArray(100)}\n for(i in 0 until 100){\n for(j in 0 until 100){\n ans[i][j] = if(i < 50) '.' else '#'\n }\n }\n var white = 1\n var black = 1\n for(i in 0 until 50 step 2){\n for(j in 0 until 100 step 2){\n if(black < b){\n ans[i][j] = '#'\n black++\n }\n }\n }\n for(i in 99 downTo 50 step 2){\n for(j in 0 until 100 step 2){\n if(white < a){\n ans[i][j] = '.'\n white++\n }\n }\n }\n println(\"100 100\")\n for(i in 0 until 100){\n for(j in 0 until 100){\n print(ans[i][j])\n }\n println()\n }\n}", "language": "Kotlin", "metadata": {"date": 1582601440, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03402.html", "problem_id": "p03402", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03402/input.txt", "sample_output_relpath": "derived/input_output/data/p03402/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03402/Kotlin/s337507817.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s337507817", "user_id": "u480831358"}, "prompt_components": {"gold_output": "3 3\n##.\n..#\n#.#\n", "input_to_evaluate": "import java.util.*\n\nfun main(args:Array){\n val (a,b) = readLine()!!.split(\" \").map{it.toInt()}\n val ans = Array(100){CharArray(100)}\n for(i in 0 until 100){\n for(j in 0 until 100){\n ans[i][j] = if(i < 50) '.' else '#'\n }\n }\n var white = 1\n var black = 1\n for(i in 0 until 50 step 2){\n for(j in 0 until 100 step 2){\n if(black < b){\n ans[i][j] = '#'\n black++\n }\n }\n }\n for(i in 99 downTo 50 step 2){\n for(j in 0 until 100 step 2){\n if(white < a){\n ans[i][j] = '.'\n white++\n }\n }\n }\n println(\"100 100\")\n for(i in 0 until 100){\n for(j in 0 until 100){\n print(ans[i][j])\n }\n println()\n }\n}", "problem_context": "Score : 500 points\n\nProblem Statement\n\nYou are given two integers A and B.\n\nPrint a grid where each square is painted white or black that satisfies the following conditions, in the format specified in Output section:\n\nLet the size of the grid be h \\times w (h vertical, w horizontal). Both h and w are at most 100.\n\nThe set of the squares painted white is divided into exactly A connected components.\n\nThe set of the squares painted black is divided into exactly B connected components.\n\nIt can be proved that there always exist one or more solutions under the conditions specified in Constraints section.\nIf there are multiple solutions, any of them may be printed.\n\nNotes\n\nTwo squares painted white, c_1 and c_2, are called connected when the square c_2 can be reached from the square c_1 passing only white squares by repeatedly moving up, down, left or right to an adjacent square.\n\nA set of squares painted white, S, forms a connected component when the following conditions are met:\n\nAny two squares in S are connected.\n\nNo pair of a square painted white that is not included in S and a square included in S is connected.\n\nA connected component of squares painted black is defined similarly.\n\nConstraints\n\n1 \\leq A \\leq 500\n\n1 \\leq B \\leq 500\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nOutput should be in the following format:\n\nIn the first line, print integers h and w representing the size of the grid you constructed, with a space in between.\n\nThen, print h more lines. The i-th (1 \\leq i \\leq h) of these lines should contain a string s_i as follows:\n\nIf the square at the i-th row and j-th column (1 \\leq j \\leq w) in the grid is painted white, the j-th character in s_i should be ..\n\nIf the square at the i-th row and j-th column (1 \\leq j \\leq w) in the grid is painted black, the j-th character in s_i should be #.\n\nSample Input 1\n\n2 3\n\nSample Output 1\n\n3 3\n##.\n..#\n#.#\n\nThis output corresponds to the grid below:\n\nSample Input 2\n\n7 8\n\nSample Output 2\n\n3 5\n#.#.#\n.#.#.\n#.#.#\n\nSample Input 3\n\n1 1\n\nSample Output 3\n\n4 2\n..\n#.\n##\n##\n\nSample Input 4\n\n3 14\n\nSample Output 4\n\n8 18\n..................\n..................\n....##.......####.\n....#.#.....#.....\n...#...#....#.....\n..#.###.#...#.....\n.#.......#..#.....\n#.........#..####.", "sample_input": "2 3\n"}, "reference_outputs": ["3 3\n##.\n..#\n#.#\n"], "source_document_id": "p03402", "source_text": "Score : 500 points\n\nProblem Statement\n\nYou are given two integers A and B.\n\nPrint a grid where each square is painted white or black that satisfies the following conditions, in the format specified in Output section:\n\nLet the size of the grid be h \\times w (h vertical, w horizontal). Both h and w are at most 100.\n\nThe set of the squares painted white is divided into exactly A connected components.\n\nThe set of the squares painted black is divided into exactly B connected components.\n\nIt can be proved that there always exist one or more solutions under the conditions specified in Constraints section.\nIf there are multiple solutions, any of them may be printed.\n\nNotes\n\nTwo squares painted white, c_1 and c_2, are called connected when the square c_2 can be reached from the square c_1 passing only white squares by repeatedly moving up, down, left or right to an adjacent square.\n\nA set of squares painted white, S, forms a connected component when the following conditions are met:\n\nAny two squares in S are connected.\n\nNo pair of a square painted white that is not included in S and a square included in S is connected.\n\nA connected component of squares painted black is defined similarly.\n\nConstraints\n\n1 \\leq A \\leq 500\n\n1 \\leq B \\leq 500\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nOutput should be in the following format:\n\nIn the first line, print integers h and w representing the size of the grid you constructed, with a space in between.\n\nThen, print h more lines. The i-th (1 \\leq i \\leq h) of these lines should contain a string s_i as follows:\n\nIf the square at the i-th row and j-th column (1 \\leq j \\leq w) in the grid is painted white, the j-th character in s_i should be ..\n\nIf the square at the i-th row and j-th column (1 \\leq j \\leq w) in the grid is painted black, the j-th character in s_i should be #.\n\nSample Input 1\n\n2 3\n\nSample Output 1\n\n3 3\n##.\n..#\n#.#\n\nThis output corresponds to the grid below:\n\nSample Input 2\n\n7 8\n\nSample Output 2\n\n3 5\n#.#.#\n.#.#.\n#.#.#\n\nSample Input 3\n\n1 1\n\nSample Output 3\n\n4 2\n..\n#.\n##\n##\n\nSample Input 4\n\n3 14\n\nSample Output 4\n\n8 18\n..................\n..................\n....##.......####.\n....#.#.....#.....\n...#...#....#.....\n..#.###.#...#.....\n.#.......#..#.....\n#.........#..####.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 820, "cpu_time_ms": 378, "memory_kb": 40632}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s295629456", "group_id": "codeNet:p03408", "input_text": "import kotlin.math.*\n\nfun str() = readLine()!!\nfun int() = readLine()!!.toInt()\n\nfun main() {\n\tval n = int()\n\tval blue = Array(n) {str()}\n\tval m = int()\n\tval red = Array(m) {str()}\n\n\tvar r = 0\n\tfor(i in 0 until n-1) {\n\t\tvar count = 1\n\t\tfor(j in i+1 until n)\n\t\t\tif(blue[i]==blue[j]) ++count\n\t\tfor(j in 0 until m)\n\t\t\tif(blue[i]==red[j]) --count\n\t\tr = max(r,count)\n\t}\n\n\tprintln(r)\n}\n", "language": "Kotlin", "metadata": {"date": 1599190492, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p03408.html", "problem_id": "p03408", "resource_group": "medium_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/Kotlin/s295629456.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s295629456", "user_id": "u059234158"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import kotlin.math.*\n\nfun str() = readLine()!!\nfun int() = readLine()!!.toInt()\n\nfun main() {\n\tval n = int()\n\tval blue = Array(n) {str()}\n\tval m = int()\n\tval red = Array(m) {str()}\n\n\tvar r = 0\n\tfor(i in 0 until n-1) {\n\t\tvar count = 1\n\t\tfor(j in i+1 until n)\n\t\t\tif(blue[i]==blue[j]) ++count\n\t\tfor(j in 0 until m)\n\t\t\tif(blue[i]==red[j]) --count\n\t\tr = max(r,count)\n\t}\n\n\tprintln(r)\n}\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 380, "cpu_time_ms": 112, "memory_kb": 36036}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s941029065", "group_id": "codeNet:p03411", "input_text": "import java.io.*\nimport java.lang.*\nimport java.util.*\n\n// Constant\nval sc = FastScanner()\nval pw = PrintWriter(System.out)\nconst val MOD = 1000000007L\nconst val INF = 9223372036854775807L\n\n// Main\nfun main(args: Array) {\n solve()\n pw.flush()\n}\n\nfun solve() {\n val n = nextLong()\n val red = longAry2(n, 2)\n val blue = longAry2(n, 2)\n\n for (i in 0 until n){\n red[i][0] = nextLong()\n red[i][1] = nextLong()\n }\n for (i in 0 until n){\n blue[i][0] = nextLong()\n blue[i][1] = nextLong()\n }\n\n val flag = boolAry(n)\n val stacks: Array> = Array(n.toInt()) { ArrayDeque() }\n for (i in 0 until n){\n for (j in 0 until n){\n if(blue[i][0] > red[j][0] && blue[i][1] > red[j][1]) {\n stacks[i].push(j)\n }\n }\n }\n stacks.sortBy { it.size }\n\n var ans = 0L\n for (i in stacks.indices){\n val stack = stacks[i]\n while(stack.isNotEmpty()){\n val point = stack.pop()\n if(flag[point]) continue\n ans++\n flag[point] = true\n break\n }\n }\n\n println(ans)\n\n\n}\n\n\n\n// Rule\noperator fun String.get(index: Long): Char {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun CharArray.get(index: Long): Char {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun CharArray.set(index: Long, value: Char) {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n this[index.toInt()] = value\n}\noperator fun LongArray.get(index: Long): Long {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun LongArray.set(index: Long, value: Long) {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n this[index.toInt()] = value\n}\noperator fun DoubleArray.get(index: Long): Double {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun DoubleArray.set(index: Long, value: Double) {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n this[index.toInt()] = value\n}\noperator fun Array.get(index: Long): T {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun Array.set(index: Long, value: T) {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n this[index.toInt()] = value\n}\noperator fun MutableList.get(index: Long): T {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun MutableList.set(index: Long, value: T) {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n this[index.toInt()] = value\n}\n\nval LongArray.siz: Long\n get() = size.toLong()\nval Array.siz: Long\n get() = size.toLong()\nval MutableList.siz: Long\n get() = size.toLong()\nval MutableSet.siz: Long\n get() = size.toLong()\nval String.len: Long\n get() = length.toLong()\n\n// Output\nfun println(v: String) {\n pw.println(v)\n}\nfun print(v: String) {\n pw.print(v)\n}\n\n// Input\nfun next() = sc.next()\nfun nextLong() = sc.nextLong()\nfun nextDouble() = next().toDouble()\nfun nextAry(n: Long): Array {\n val ary = ary(n)\n for (i in 0 until n) ary[i] = next()\n return ary\n}\nfun nextLongAry(n: Long): LongArray {\n val ary = longAry(n)\n for (i in 0 until n) ary[i] = nextLong()\n return ary\n}\nfun nextDoubleAry(n: Long): DoubleArray {\n val ary = doubleAry(n)\n for (i in 0 until n) ary[i] = nextDouble()\n return ary\n}\n\n// Statement\nfun ary(n: Long, init: String = \"\") = Array(n.toInt()) { init }\nfun longAry(n: Long, init: Long = 0L) = LongArray(n.toInt()) { init }\nfun doubleAry(n: Long, init: Double = 0.0) = DoubleArray(n.toInt()) { init }\nfun boolAry(n: Long, init: Boolean = false) = Array(n.toInt()) { init }\nfun ary2(n: Long, m: Long, init: String = \"\") = Array(n.toInt()) { ary(m, init) }\nfun longAry2(n: Long, m: Long, init: Long = 0) = Array(n.toInt()) { longAry(m, init) }\nfun doubleAry2(n: Long, m: Long, init: Double = 0.0) = Array(n.toInt()) { doubleAry(m, init) }\nfun boolAry2(n: Long, m: Long, init: Boolean = false) = Array(n.toInt()) { boolAry(m, init) }\nfun ary3(n: Long, m: Long, k: Long, init: String = \"\") = Array(n.toInt()) { ary2(m, k, init) }\nfun longAry3(n: Long, m: Long, k: Long, init: Long = 0L) = Array(n.toInt()) { longAry2(m, k, init) }\nfun doubleAry3(n: Long, m: Long, k: Long, init: Double = 0.0) = Array(n.toInt()) { doubleAry2(m, k, init) }\nfun boolAry3(n: Long, m: Long, k: Long, init: Boolean = false) = Array(n.toInt()) { boolAry2(m, k, init) }\nfun list() = mutableListOf()\nfun longList() = mutableListOf()\nfun doubleList() = mutableListOf()\nfun strSet() = mutableSetOf()\nfun longSet() = mutableSetOf()\nfun doubleSet() = mutableSetOf()\nfun map() = mutableMapOf()\n\n// Monoid\nval addFunc = {a: Long, b: Long -> a + b}\nval mulFunc = {a: Long, b: Long -> a * b}\nval maxFunc = {a: Long, b: Long -> max(a, b)}\nval minFunc = {a: Long, b: Long -> min(a, b)}\nval gcdFunc = {a: Long, b: Long -> gcd(a, b)}\nval lcmFunc = {a: Long, b: Long -> lcm(a, b)}\nval xorFunc = {a: Long, b: Long -> a xor b}\nfun calc(a: Long, b: Long, op: (Long, Long) -> Long) = op(a, b)\n\n// Extension\nfun LongArray.lowerBound(n: Long): Long {\n var ok = this.size.toLong()\n var ng = -1L\n while (abs(ok - ng) > 1) {\n val mid = (ok + ng) / 2\n if (this[mid] >= n) ok = mid\n else ng = mid\n }\n return ok\n}\nfun DoubleArray.lowerBound(n: Double): Long {\n var ok = this.size.toLong()\n var ng = -1L\n while (abs(ok - ng) > 1) {\n val mid = (ok + ng) / 2\n if (this[mid] >= n) ok = mid\n else ng = mid\n }\n return ok\n}\nfun MutableList.longLowerBound(n: Long): Long {\n var ok = this.size.toLong()\n var ng = -1L\n while (abs(ok - ng) > 1) {\n val mid = (ok + ng) / 2\n if (this[mid] >= n) ok = mid\n else ng = mid\n }\n return ok\n}\nfun MutableList.doubleLowerBound(n: Double): Long {\n var ok = this.size.toLong()\n var ng = -1L\n while (abs(ok - ng) > 1) {\n val mid = (ok + ng) / 2\n if (this[mid] >= n) ok = mid\n else ng = mid\n }\n return ok\n}\nfun LongArray.cumsum(op: (Long, Long) -> Long): LongArray {\n val s = longAry(this.size + 1L)\n s[1] = this[0]\n for (i in 1 until this.size) s[i + 1] = calc(s[i], this[i], op)\n return s\n}\nfun MutableMap.counting(n: Long) {\n repeat(n.toInt()) {\n val a = next()\n if (this.containsKey(a)) this[a] = this[a]!! + 1\n else this[a] = 1\n }\n}\nfun MutableMap.longCounting(n: Long) {\n repeat(n.toInt()) {\n val a = nextLong()\n if (this.containsKey(a)) this[a] = this[a]!! + 1\n else this[a] = 1\n }\n}\n\n// Mathematics\nfun abs(n: Long): Long = Math.abs(n)\nfun abs(n: Double): Double = Math.abs(n)\nfun max(vararg values: Long) = if (values.isEmpty()) -INF else values.max()!!\nfun min(vararg values: Long) = if (values.isEmpty()) INF else values.min()!!\ntailrec fun gcd(a: Long, b: Long): Long = if (b == 0L) a else if (a % b == 0L) b else gcd(b, (a % b))\nfun lcm(a: Long, b: Long): Long = a / gcd(a, b) * b\nfun modpow(a: Long, n: Long, p: Long = MOD): Long {\n var res = 1L\n var ar = a\n var nr = n\n while (nr > 0) {\n if ((nr and 1) == 1L) res = res * ar % p\n ar = ar * ar % p\n nr = nr shr 1\n }\n return res\n}\nfun modinv(a: Long, p: Long = MOD): Long = modpow(a, p - 2, p)\nfun ncr(n: Long, r: Long): Long {\n var a = 1L\n var b = 1L\n for (i in 1..r) {\n a = a * (n + 1 - i) % MOD\n b = b * i % MOD\n }\n return modinv(b, MOD) * a % MOD\n}\n\nclass Combination(private val max: Long) {\n private val fac = longAry(max)\n private val finv = longAry(max)\n private val inv = longAry(max)\n private val p = MOD\n fun init() {\n fac[0] = 1\n fac[1] = 1\n finv[0] = 1\n finv[1] = 1\n inv[1] = 1\n for (i in 2 until max) {\n fac[i] = fac[i - 1] * i % p\n inv[i] = p - inv[p % i] * (p / i) % p;\n finv[i] = finv[i - 1] * inv[i] % p\n }\n }\n\n fun com(n: Long, r: Long): Long = if (n < r || (n < 0 || r < 0)) 0L else fac[n] * (finv[r] * finv[n - r] % p) % p\n}\n\nclass Permutation(private val n: Long, private var searched: Long = 0L, private var nextIndex: Long = 0L) {\n private val size = fact(n)\n private val permList = longAry2(size, n)\n\n private tailrec fun fact(n: Long, ans: Long = 1L): Long {\n return if (n == 0L) ans\n else fact(n - 1, ans * n)\n }\n\n fun init() {\n create(0, longAry(n), boolAry(n))\n }\n\n private fun create(num: Long, list: LongArray, flag: Array) {\n if (num == n) {\n permList[searched] = list.copyOf()\n searched++\n }\n for (i in 0 until n) {\n if (flag[i]) continue\n list[num] = i\n flag[i] = true\n create(num + 1, list, flag)\n flag[i] = false\n }\n }\n\n fun hasNext(): Boolean {\n return if (nextIndex < size) {\n true\n } else {\n nextIndex = 0\n false\n }\n }\n\n fun nextPerm(): LongArray = permList[nextIndex++]\n}\n\n// Graph\ndata class Node(val id: Long, var past: Long = -1, val edges: MutableList = mutableListOf())\ndata class Edge(val from: Long, val to: Long, val cost: Long = 1L)\n\nfun dfs(nodes: Array, now: Long, seen: Array) {\n seen[now] = true\n for (edge in nodes[now].edges) {\n if (seen[edge.to]) continue\n dfs(nodes, edge.to, seen)\n }\n}\n\nfun bfs(nodes: Array, start: Long): LongArray {\n val queue = ArrayDeque()\n queue.add(start)\n val dist = longAry(nodes.size.toLong(), -1L)\n dist[start] = 0L\n while (queue.isNotEmpty()) {\n val now = queue.poll()\n for (edge in nodes[now].edges) {\n if (dist[edge.to] != -1L) continue\n dist[edge.to] = dist[now] + 1\n queue.add(edge.to)\n }\n }\n return dist\n}\n\nfun dijkstra(nodes: Array, start: Long): LongArray {\n val queue = PriorityQueue(16) { e1: Edge, e2: Edge ->\n return@PriorityQueue when {\n e1.cost < e2.cost -> -1\n e2.cost > e1.cost -> 1\n else -> 0\n }\n }\n queue.add(Edge(start, start, 0L))\n val dist = longAry(nodes.size.toLong(), INF / 2)\n dist[start] = 0\n while (queue.isNotEmpty()) {\n val now = queue.poll()\n if (dist[now.to] < now.cost) continue;\n for (edge in nodes[now.to].edges) {\n if (dist[edge.to] <= dist[edge.from] + edge.cost) continue\n dist[edge.to] = dist[edge.from] + edge.cost\n queue.add(Edge(edge.from, edge.to, dist[edge.to]))\n nodes[edge.to].past = edge.from\n }\n }\n return dist\n}\n\n// Data Structure\nclass UnionFind(size: Long) {\n private val par = LongArray(size.toInt()) { it.toLong() }\n private val size = longAry(size, 1L)\n fun root(x: Long): Long {\n return if (par[x] == x) {\n x\n } else {\n par[x] = root(par[x])\n par[x]\n }\n }\n\n fun same(x: Long, y: Long): Boolean = root(x) == root(y)\n fun unite(x: Long, y: Long) {\n var a = root(x)\n var b = root(y)\n if (a == b) return\n if (size[a] < size[b]) {\n var tmp = a\n a = b\n b = tmp\n }\n size[a] += size[b]\n par[b] = a\n }\n\n fun size(x: Long): Long = size[root(x)]\n}\n\nclass SegmentTree(\n private val a: LongArray,\n private val op: (Long, Long) -> Long,\n private val def: Long = 0,\n private val size: Int = a.size,\n private val n: Int = Integer.highestOneBit(size) shl 1\n) {\n private val nodes = longAry(2L * n - 1, def)\n\n fun init() {\n for (i in 0 until size) nodes[i + n - 1] = a[i]\n for (i in n - 2 downTo 0) nodes[i] = calc(nodes[2 * i + 1], nodes[2 * i + 2], op)\n }\n\n fun update(x: Long, value: Long) {\n var index = x + n - 1\n nodes[index] = value\n while (index > 0) {\n index = (index - 1) / 2\n nodes[index] = calc(nodes[2 * index + 1], nodes[2 * index + 2], op)\n }\n }\n\n fun get(a: Long, b: Long) = getSub(a, b, 0L, 0L, n.toLong())\n private fun getSub(a: Long, b: Long, k: Long, l: Long, r: Long): Long {\n return when {\n r <= a || b <= l -> def\n a <= l && r <= b -> nodes[k]\n else -> {\n val vl = getSub(a, b, k * 2 + 1, l, (l + r) / 2)\n val vr = getSub(a, b, k * 2 + 2, (l + r) / 2, r)\n calc(vl, vr, op)\n }\n }\n }\n\n fun joinToString(separator: String) = nodes.drop(n - 1).take(size).joinToString(separator)\n}\n\n// Scanner\nclass FastScanner {\n private val sin: InputStream = System.`in`\n private val buffer: ByteArray = ByteArray(1024) { 0 }\n private var ptr = 0\n private var buflen = 0\n\n private fun hasNextByte(): Boolean {\n return when {\n ptr < buflen -> true\n else -> {\n ptr = 0\n buflen = sin.read(buffer)\n if (buflen <= 0) false\n true\n }\n }\n }\n\n private fun readByte(): Int {\n return when {\n hasNextByte() -> buffer[ptr++].toInt()\n else -> -1\n }\n }\n\n private fun isPrintableChar(c: Int) = c in 33..126\n\n fun hasNext(): Boolean {\n while (hasNextByte() && !isPrintableChar(buffer[ptr].toInt())) ptr++\n return hasNextByte()\n }\n\n fun next(): String {\n if (!hasNext()) throw NoSuchElementException()\n val sb = StringBuilder()\n var b = readByte()\n while (isPrintableChar(b)) {\n sb.appendCodePoint(b)\n b = readByte()\n }\n return sb.toString()\n }\n\n fun nextLong(): Long {\n if (!hasNext()) throw NoSuchElementException()\n var n = 0L\n var minus = false\n var b = readByte()\n if (b.toChar() == '-') {\n minus = true\n b = readByte()\n }\n if (b.toChar() !in '0'..'9') throw NumberFormatException()\n while (true) {\n when {\n b.toChar() in '0'..'9' -> {\n n *= 10\n n += b.toChar() - '0'\n }\n b == -1 || !isPrintableChar(b) -> return if (minus) -n else n\n else -> throw NumberFormatException()\n }\n b = readByte()\n }\n }\n\n// \"The world doesn't need you.\"\n//\n// fun nextInt(): Int {\n// val nl = nextLong()\n// if (nl !in Int.MIN_VALUE..Int.MAX_VALUE) throw NumberFormatException()\n// return nl.toInt()\n// }\n}", "language": "Kotlin", "metadata": {"date": 1587522871, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03411.html", "problem_id": "p03411", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03411/input.txt", "sample_output_relpath": "derived/input_output/data/p03411/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03411/Kotlin/s941029065.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s941029065", "user_id": "u581625805"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import java.io.*\nimport java.lang.*\nimport java.util.*\n\n// Constant\nval sc = FastScanner()\nval pw = PrintWriter(System.out)\nconst val MOD = 1000000007L\nconst val INF = 9223372036854775807L\n\n// Main\nfun main(args: Array) {\n solve()\n pw.flush()\n}\n\nfun solve() {\n val n = nextLong()\n val red = longAry2(n, 2)\n val blue = longAry2(n, 2)\n\n for (i in 0 until n){\n red[i][0] = nextLong()\n red[i][1] = nextLong()\n }\n for (i in 0 until n){\n blue[i][0] = nextLong()\n blue[i][1] = nextLong()\n }\n\n val flag = boolAry(n)\n val stacks: Array> = Array(n.toInt()) { ArrayDeque() }\n for (i in 0 until n){\n for (j in 0 until n){\n if(blue[i][0] > red[j][0] && blue[i][1] > red[j][1]) {\n stacks[i].push(j)\n }\n }\n }\n stacks.sortBy { it.size }\n\n var ans = 0L\n for (i in stacks.indices){\n val stack = stacks[i]\n while(stack.isNotEmpty()){\n val point = stack.pop()\n if(flag[point]) continue\n ans++\n flag[point] = true\n break\n }\n }\n\n println(ans)\n\n\n}\n\n\n\n// Rule\noperator fun String.get(index: Long): Char {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun CharArray.get(index: Long): Char {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun CharArray.set(index: Long, value: Char) {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n this[index.toInt()] = value\n}\noperator fun LongArray.get(index: Long): Long {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun LongArray.set(index: Long, value: Long) {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n this[index.toInt()] = value\n}\noperator fun DoubleArray.get(index: Long): Double {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun DoubleArray.set(index: Long, value: Double) {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n this[index.toInt()] = value\n}\noperator fun Array.get(index: Long): T {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun Array.set(index: Long, value: T) {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n this[index.toInt()] = value\n}\noperator fun MutableList.get(index: Long): T {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun MutableList.set(index: Long, value: T) {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n this[index.toInt()] = value\n}\n\nval LongArray.siz: Long\n get() = size.toLong()\nval Array.siz: Long\n get() = size.toLong()\nval MutableList.siz: Long\n get() = size.toLong()\nval MutableSet.siz: Long\n get() = size.toLong()\nval String.len: Long\n get() = length.toLong()\n\n// Output\nfun println(v: String) {\n pw.println(v)\n}\nfun print(v: String) {\n pw.print(v)\n}\n\n// Input\nfun next() = sc.next()\nfun nextLong() = sc.nextLong()\nfun nextDouble() = next().toDouble()\nfun nextAry(n: Long): Array {\n val ary = ary(n)\n for (i in 0 until n) ary[i] = next()\n return ary\n}\nfun nextLongAry(n: Long): LongArray {\n val ary = longAry(n)\n for (i in 0 until n) ary[i] = nextLong()\n return ary\n}\nfun nextDoubleAry(n: Long): DoubleArray {\n val ary = doubleAry(n)\n for (i in 0 until n) ary[i] = nextDouble()\n return ary\n}\n\n// Statement\nfun ary(n: Long, init: String = \"\") = Array(n.toInt()) { init }\nfun longAry(n: Long, init: Long = 0L) = LongArray(n.toInt()) { init }\nfun doubleAry(n: Long, init: Double = 0.0) = DoubleArray(n.toInt()) { init }\nfun boolAry(n: Long, init: Boolean = false) = Array(n.toInt()) { init }\nfun ary2(n: Long, m: Long, init: String = \"\") = Array(n.toInt()) { ary(m, init) }\nfun longAry2(n: Long, m: Long, init: Long = 0) = Array(n.toInt()) { longAry(m, init) }\nfun doubleAry2(n: Long, m: Long, init: Double = 0.0) = Array(n.toInt()) { doubleAry(m, init) }\nfun boolAry2(n: Long, m: Long, init: Boolean = false) = Array(n.toInt()) { boolAry(m, init) }\nfun ary3(n: Long, m: Long, k: Long, init: String = \"\") = Array(n.toInt()) { ary2(m, k, init) }\nfun longAry3(n: Long, m: Long, k: Long, init: Long = 0L) = Array(n.toInt()) { longAry2(m, k, init) }\nfun doubleAry3(n: Long, m: Long, k: Long, init: Double = 0.0) = Array(n.toInt()) { doubleAry2(m, k, init) }\nfun boolAry3(n: Long, m: Long, k: Long, init: Boolean = false) = Array(n.toInt()) { boolAry2(m, k, init) }\nfun list() = mutableListOf()\nfun longList() = mutableListOf()\nfun doubleList() = mutableListOf()\nfun strSet() = mutableSetOf()\nfun longSet() = mutableSetOf()\nfun doubleSet() = mutableSetOf()\nfun map() = mutableMapOf()\n\n// Monoid\nval addFunc = {a: Long, b: Long -> a + b}\nval mulFunc = {a: Long, b: Long -> a * b}\nval maxFunc = {a: Long, b: Long -> max(a, b)}\nval minFunc = {a: Long, b: Long -> min(a, b)}\nval gcdFunc = {a: Long, b: Long -> gcd(a, b)}\nval lcmFunc = {a: Long, b: Long -> lcm(a, b)}\nval xorFunc = {a: Long, b: Long -> a xor b}\nfun calc(a: Long, b: Long, op: (Long, Long) -> Long) = op(a, b)\n\n// Extension\nfun LongArray.lowerBound(n: Long): Long {\n var ok = this.size.toLong()\n var ng = -1L\n while (abs(ok - ng) > 1) {\n val mid = (ok + ng) / 2\n if (this[mid] >= n) ok = mid\n else ng = mid\n }\n return ok\n}\nfun DoubleArray.lowerBound(n: Double): Long {\n var ok = this.size.toLong()\n var ng = -1L\n while (abs(ok - ng) > 1) {\n val mid = (ok + ng) / 2\n if (this[mid] >= n) ok = mid\n else ng = mid\n }\n return ok\n}\nfun MutableList.longLowerBound(n: Long): Long {\n var ok = this.size.toLong()\n var ng = -1L\n while (abs(ok - ng) > 1) {\n val mid = (ok + ng) / 2\n if (this[mid] >= n) ok = mid\n else ng = mid\n }\n return ok\n}\nfun MutableList.doubleLowerBound(n: Double): Long {\n var ok = this.size.toLong()\n var ng = -1L\n while (abs(ok - ng) > 1) {\n val mid = (ok + ng) / 2\n if (this[mid] >= n) ok = mid\n else ng = mid\n }\n return ok\n}\nfun LongArray.cumsum(op: (Long, Long) -> Long): LongArray {\n val s = longAry(this.size + 1L)\n s[1] = this[0]\n for (i in 1 until this.size) s[i + 1] = calc(s[i], this[i], op)\n return s\n}\nfun MutableMap.counting(n: Long) {\n repeat(n.toInt()) {\n val a = next()\n if (this.containsKey(a)) this[a] = this[a]!! + 1\n else this[a] = 1\n }\n}\nfun MutableMap.longCounting(n: Long) {\n repeat(n.toInt()) {\n val a = nextLong()\n if (this.containsKey(a)) this[a] = this[a]!! + 1\n else this[a] = 1\n }\n}\n\n// Mathematics\nfun abs(n: Long): Long = Math.abs(n)\nfun abs(n: Double): Double = Math.abs(n)\nfun max(vararg values: Long) = if (values.isEmpty()) -INF else values.max()!!\nfun min(vararg values: Long) = if (values.isEmpty()) INF else values.min()!!\ntailrec fun gcd(a: Long, b: Long): Long = if (b == 0L) a else if (a % b == 0L) b else gcd(b, (a % b))\nfun lcm(a: Long, b: Long): Long = a / gcd(a, b) * b\nfun modpow(a: Long, n: Long, p: Long = MOD): Long {\n var res = 1L\n var ar = a\n var nr = n\n while (nr > 0) {\n if ((nr and 1) == 1L) res = res * ar % p\n ar = ar * ar % p\n nr = nr shr 1\n }\n return res\n}\nfun modinv(a: Long, p: Long = MOD): Long = modpow(a, p - 2, p)\nfun ncr(n: Long, r: Long): Long {\n var a = 1L\n var b = 1L\n for (i in 1..r) {\n a = a * (n + 1 - i) % MOD\n b = b * i % MOD\n }\n return modinv(b, MOD) * a % MOD\n}\n\nclass Combination(private val max: Long) {\n private val fac = longAry(max)\n private val finv = longAry(max)\n private val inv = longAry(max)\n private val p = MOD\n fun init() {\n fac[0] = 1\n fac[1] = 1\n finv[0] = 1\n finv[1] = 1\n inv[1] = 1\n for (i in 2 until max) {\n fac[i] = fac[i - 1] * i % p\n inv[i] = p - inv[p % i] * (p / i) % p;\n finv[i] = finv[i - 1] * inv[i] % p\n }\n }\n\n fun com(n: Long, r: Long): Long = if (n < r || (n < 0 || r < 0)) 0L else fac[n] * (finv[r] * finv[n - r] % p) % p\n}\n\nclass Permutation(private val n: Long, private var searched: Long = 0L, private var nextIndex: Long = 0L) {\n private val size = fact(n)\n private val permList = longAry2(size, n)\n\n private tailrec fun fact(n: Long, ans: Long = 1L): Long {\n return if (n == 0L) ans\n else fact(n - 1, ans * n)\n }\n\n fun init() {\n create(0, longAry(n), boolAry(n))\n }\n\n private fun create(num: Long, list: LongArray, flag: Array) {\n if (num == n) {\n permList[searched] = list.copyOf()\n searched++\n }\n for (i in 0 until n) {\n if (flag[i]) continue\n list[num] = i\n flag[i] = true\n create(num + 1, list, flag)\n flag[i] = false\n }\n }\n\n fun hasNext(): Boolean {\n return if (nextIndex < size) {\n true\n } else {\n nextIndex = 0\n false\n }\n }\n\n fun nextPerm(): LongArray = permList[nextIndex++]\n}\n\n// Graph\ndata class Node(val id: Long, var past: Long = -1, val edges: MutableList = mutableListOf())\ndata class Edge(val from: Long, val to: Long, val cost: Long = 1L)\n\nfun dfs(nodes: Array, now: Long, seen: Array) {\n seen[now] = true\n for (edge in nodes[now].edges) {\n if (seen[edge.to]) continue\n dfs(nodes, edge.to, seen)\n }\n}\n\nfun bfs(nodes: Array, start: Long): LongArray {\n val queue = ArrayDeque()\n queue.add(start)\n val dist = longAry(nodes.size.toLong(), -1L)\n dist[start] = 0L\n while (queue.isNotEmpty()) {\n val now = queue.poll()\n for (edge in nodes[now].edges) {\n if (dist[edge.to] != -1L) continue\n dist[edge.to] = dist[now] + 1\n queue.add(edge.to)\n }\n }\n return dist\n}\n\nfun dijkstra(nodes: Array, start: Long): LongArray {\n val queue = PriorityQueue(16) { e1: Edge, e2: Edge ->\n return@PriorityQueue when {\n e1.cost < e2.cost -> -1\n e2.cost > e1.cost -> 1\n else -> 0\n }\n }\n queue.add(Edge(start, start, 0L))\n val dist = longAry(nodes.size.toLong(), INF / 2)\n dist[start] = 0\n while (queue.isNotEmpty()) {\n val now = queue.poll()\n if (dist[now.to] < now.cost) continue;\n for (edge in nodes[now.to].edges) {\n if (dist[edge.to] <= dist[edge.from] + edge.cost) continue\n dist[edge.to] = dist[edge.from] + edge.cost\n queue.add(Edge(edge.from, edge.to, dist[edge.to]))\n nodes[edge.to].past = edge.from\n }\n }\n return dist\n}\n\n// Data Structure\nclass UnionFind(size: Long) {\n private val par = LongArray(size.toInt()) { it.toLong() }\n private val size = longAry(size, 1L)\n fun root(x: Long): Long {\n return if (par[x] == x) {\n x\n } else {\n par[x] = root(par[x])\n par[x]\n }\n }\n\n fun same(x: Long, y: Long): Boolean = root(x) == root(y)\n fun unite(x: Long, y: Long) {\n var a = root(x)\n var b = root(y)\n if (a == b) return\n if (size[a] < size[b]) {\n var tmp = a\n a = b\n b = tmp\n }\n size[a] += size[b]\n par[b] = a\n }\n\n fun size(x: Long): Long = size[root(x)]\n}\n\nclass SegmentTree(\n private val a: LongArray,\n private val op: (Long, Long) -> Long,\n private val def: Long = 0,\n private val size: Int = a.size,\n private val n: Int = Integer.highestOneBit(size) shl 1\n) {\n private val nodes = longAry(2L * n - 1, def)\n\n fun init() {\n for (i in 0 until size) nodes[i + n - 1] = a[i]\n for (i in n - 2 downTo 0) nodes[i] = calc(nodes[2 * i + 1], nodes[2 * i + 2], op)\n }\n\n fun update(x: Long, value: Long) {\n var index = x + n - 1\n nodes[index] = value\n while (index > 0) {\n index = (index - 1) / 2\n nodes[index] = calc(nodes[2 * index + 1], nodes[2 * index + 2], op)\n }\n }\n\n fun get(a: Long, b: Long) = getSub(a, b, 0L, 0L, n.toLong())\n private fun getSub(a: Long, b: Long, k: Long, l: Long, r: Long): Long {\n return when {\n r <= a || b <= l -> def\n a <= l && r <= b -> nodes[k]\n else -> {\n val vl = getSub(a, b, k * 2 + 1, l, (l + r) / 2)\n val vr = getSub(a, b, k * 2 + 2, (l + r) / 2, r)\n calc(vl, vr, op)\n }\n }\n }\n\n fun joinToString(separator: String) = nodes.drop(n - 1).take(size).joinToString(separator)\n}\n\n// Scanner\nclass FastScanner {\n private val sin: InputStream = System.`in`\n private val buffer: ByteArray = ByteArray(1024) { 0 }\n private var ptr = 0\n private var buflen = 0\n\n private fun hasNextByte(): Boolean {\n return when {\n ptr < buflen -> true\n else -> {\n ptr = 0\n buflen = sin.read(buffer)\n if (buflen <= 0) false\n true\n }\n }\n }\n\n private fun readByte(): Int {\n return when {\n hasNextByte() -> buffer[ptr++].toInt()\n else -> -1\n }\n }\n\n private fun isPrintableChar(c: Int) = c in 33..126\n\n fun hasNext(): Boolean {\n while (hasNextByte() && !isPrintableChar(buffer[ptr].toInt())) ptr++\n return hasNextByte()\n }\n\n fun next(): String {\n if (!hasNext()) throw NoSuchElementException()\n val sb = StringBuilder()\n var b = readByte()\n while (isPrintableChar(b)) {\n sb.appendCodePoint(b)\n b = readByte()\n }\n return sb.toString()\n }\n\n fun nextLong(): Long {\n if (!hasNext()) throw NoSuchElementException()\n var n = 0L\n var minus = false\n var b = readByte()\n if (b.toChar() == '-') {\n minus = true\n b = readByte()\n }\n if (b.toChar() !in '0'..'9') throw NumberFormatException()\n while (true) {\n when {\n b.toChar() in '0'..'9' -> {\n n *= 10\n n += b.toChar() - '0'\n }\n b == -1 || !isPrintableChar(b) -> return if (minus) -n else n\n else -> throw NumberFormatException()\n }\n b = readByte()\n }\n }\n\n// \"The world doesn't need you.\"\n//\n// fun nextInt(): Int {\n// val nl = nextLong()\n// if (nl !in Int.MIN_VALUE..Int.MAX_VALUE) throw NumberFormatException()\n// return nl.toInt()\n// }\n}", "problem_context": "Score : 400 points\n\nProblem Statement\n\nOn a two-dimensional plane, there are N red points and N blue points.\nThe coordinates of the i-th red point are (a_i, b_i), and the coordinates of the i-th blue point are (c_i, d_i).\n\nA red point and a blue point can form a friendly pair when, the x-coordinate of the red point is smaller than that of the blue point, and the y-coordinate of the red point is also smaller than that of the blue point.\n\nAt most how many friendly pairs can you form? Note that a point cannot belong to multiple pairs.\n\nConstraints\n\nAll input values are integers.\n\n1 \\leq N \\leq 100\n\n0 \\leq a_i, b_i, c_i, d_i < 2N\n\na_1, a_2, ..., a_N, c_1, c_2, ..., c_N are all different.\n\nb_1, b_2, ..., b_N, d_1, d_2, ..., d_N are all different.\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\nc_1 d_1\nc_2 d_2\n:\nc_N d_N\n\nOutput\n\nPrint the maximum number of friendly pairs.\n\nSample Input 1\n\n3\n2 0\n3 1\n1 3\n4 2\n0 4\n5 5\n\nSample Output 1\n\n2\n\nFor example, you can pair (2, 0) and (4, 2), then (3, 1) and (5, 5).\n\nSample Input 2\n\n3\n0 0\n1 1\n5 2\n2 3\n3 4\n4 5\n\nSample Output 2\n\n2\n\nFor example, you can pair (0, 0) and (2, 3), then (1, 1) and (3, 4).\n\nSample Input 3\n\n2\n2 2\n3 3\n0 0\n1 1\n\nSample Output 3\n\n0\n\nIt is possible that no pair can be formed.\n\nSample Input 4\n\n5\n0 0\n7 3\n2 2\n4 8\n1 6\n8 5\n6 9\n5 4\n9 1\n3 7\n\nSample Output 4\n\n5\n\nSample Input 5\n\n5\n0 0\n1 1\n5 5\n6 6\n7 7\n2 2\n3 3\n4 4\n8 8\n9 9\n\nSample Output 5\n\n4", "sample_input": "3\n2 0\n3 1\n1 3\n4 2\n0 4\n5 5\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03411", "source_text": "Score : 400 points\n\nProblem Statement\n\nOn a two-dimensional plane, there are N red points and N blue points.\nThe coordinates of the i-th red point are (a_i, b_i), and the coordinates of the i-th blue point are (c_i, d_i).\n\nA red point and a blue point can form a friendly pair when, the x-coordinate of the red point is smaller than that of the blue point, and the y-coordinate of the red point is also smaller than that of the blue point.\n\nAt most how many friendly pairs can you form? Note that a point cannot belong to multiple pairs.\n\nConstraints\n\nAll input values are integers.\n\n1 \\leq N \\leq 100\n\n0 \\leq a_i, b_i, c_i, d_i < 2N\n\na_1, a_2, ..., a_N, c_1, c_2, ..., c_N are all different.\n\nb_1, b_2, ..., b_N, d_1, d_2, ..., d_N are all different.\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\nc_1 d_1\nc_2 d_2\n:\nc_N d_N\n\nOutput\n\nPrint the maximum number of friendly pairs.\n\nSample Input 1\n\n3\n2 0\n3 1\n1 3\n4 2\n0 4\n5 5\n\nSample Output 1\n\n2\n\nFor example, you can pair (2, 0) and (4, 2), then (3, 1) and (5, 5).\n\nSample Input 2\n\n3\n0 0\n1 1\n5 2\n2 3\n3 4\n4 5\n\nSample Output 2\n\n2\n\nFor example, you can pair (0, 0) and (2, 3), then (1, 1) and (3, 4).\n\nSample Input 3\n\n2\n2 2\n3 3\n0 0\n1 1\n\nSample Output 3\n\n0\n\nIt is possible that no pair can be formed.\n\nSample Input 4\n\n5\n0 0\n7 3\n2 2\n4 8\n1 6\n8 5\n6 9\n5 4\n9 1\n3 7\n\nSample Output 4\n\n5\n\nSample Input 5\n\n5\n0 0\n1 1\n5 5\n6 6\n7 7\n2 2\n3 3\n4 4\n8 8\n9 9\n\nSample Output 5\n\n4", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 15049, "cpu_time_ms": 220, "memory_kb": 32168}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s007928783", "group_id": "codeNet:p03415", "input_text": "private fun readInts() = readLine()!!.split(\" \").map { it.toInt() }.toList()\n\nfun main(args: Array) {\n val a = readLine()!!\n val b = readLine()!!\n val c = readLine()!!\n\n println(\"${a[0]}${b[1]}${c[2]}\")\n}", "language": "Kotlin", "metadata": {"date": 1539378909, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03415.html", "problem_id": "p03415", "resource_group": "medium_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/Kotlin/s007928783.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s007928783", "user_id": "u963316883"}, "prompt_components": {"gold_output": "abc\n", "input_to_evaluate": "private fun readInts() = readLine()!!.split(\" \").map { it.toInt() }.toList()\n\nfun main(args: Array) {\n val a = readLine()!!\n val b = readLine()!!\n val c = readLine()!!\n\n println(\"${a[0]}${b[1]}${c[2]}\")\n}", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 198, "memory_kb": 31928}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s017755270", "group_id": "codeNet:p03416", "input_text": "fun main(args: Array) {\n\n val list = readLine()!!.split(\" \").map(String::toInt)\n\n var result = mutableListOf()\n\n for (i in list[0]..list[1]) {\n\n // ロジックが汚い。やりたいことは剰余と商を求めること\n // 商と余りのPair型で返却するfunctionを作成してみる?\n // 冷静に考えると、順次割り算を再起的にする必要もなく(桁数が決まっているので)\n // 順次割って行かないと桁数おかしくなる。\n val one = devidePair(i)\n val two = devidePair(one.first)\n val three = devidePair(two.first)\n val four = devidePair(three.first)\n val five = devidePair(four.first)\n if (one.second == five.second && two.second == four.second)\n result.add(i)\n }\n println(result.size)\n}\n\nfun devidePair(num: Int): Pair {\n\n // LOOK Pairの初期化\n return Pair(num / 10, num % 10)\n}", "language": "Kotlin", "metadata": {"date": 1591120352, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03416.html", "problem_id": "p03416", "resource_group": "medium_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/Kotlin/s017755270.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s017755270", "user_id": "u048507231"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "fun main(args: Array) {\n\n val list = readLine()!!.split(\" \").map(String::toInt)\n\n var result = mutableListOf()\n\n for (i in list[0]..list[1]) {\n\n // ロジックが汚い。やりたいことは剰余と商を求めること\n // 商と余りのPair型で返却するfunctionを作成してみる?\n // 冷静に考えると、順次割り算を再起的にする必要もなく(桁数が決まっているので)\n // 順次割って行かないと桁数おかしくなる。\n val one = devidePair(i)\n val two = devidePair(one.first)\n val three = devidePair(two.first)\n val four = devidePair(three.first)\n val five = devidePair(four.first)\n if (one.second == five.second && two.second == four.second)\n result.add(i)\n }\n println(result.size)\n}\n\nfun devidePair(num: Int): Pair {\n\n // LOOK Pairの初期化\n return Pair(num / 10, num % 10)\n}", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 962, "cpu_time_ms": 282, "memory_kb": 39020}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s801563633", "group_id": "codeNet:p03419", "input_text": "private fun readStrings() = readLine()!!.split(\" \")\nprivate fun readInts() = readStrings().map { it.toInt() }\n\nfun main(args: Array) {\n val (N, M) = readInts()\n\n print(when {\n M > 1 && N > 1 -> (M - 2) * (N - 2)\n M == 1 && N > 1 -> N - 2\n N == 1 && M > 1 -> M - 2\n N == 1 && M == 1 -> 1\n else -> throw Error()\n })\n}", "language": "Kotlin", "metadata": {"date": 1520818381, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03419.html", "problem_id": "p03419", "resource_group": "medium_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/Kotlin/s801563633.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s801563633", "user_id": "u909304507"}, "prompt_components": {"gold_output": "0\n", "input_to_evaluate": "private fun readStrings() = readLine()!!.split(\" \")\nprivate fun readInts() = readStrings().map { it.toInt() }\n\nfun main(args: Array) {\n val (N, M) = readInts()\n\n print(when {\n M > 1 && N > 1 -> (M - 2) * (N - 2)\n M == 1 && N > 1 -> N - 2\n N == 1 && M > 1 -> M - 2\n N == 1 && M == 1 -> 1\n else -> throw Error()\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": "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 243, "memory_kb": 35948}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s349470761", "group_id": "codeNet:p03420", "input_text": "fun main(arr: Array) {\n val (n,k) = readLine()!!.split(\" \").map { it.toInt() }\n var ans = 0L\n for(i in (k+1..n)) {\n val min = 0\n var max = (n / i)\n if(max*i+k > n) {\n max--\n }\n ans += (max-min)*(i-k)\n ans += Math.min(i*(max+1)-1, n) - (i*max+k)+1\n }\n if(k == 0) {\n ans -= n\n }\n println(ans)\n}", "language": "Kotlin", "metadata": {"date": 1601294465, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p03420.html", "problem_id": "p03420", "resource_group": "medium_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/Kotlin/s349470761.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s349470761", "user_id": "u269969976"}, "prompt_components": {"gold_output": "7\n", "input_to_evaluate": "fun main(arr: Array) {\n val (n,k) = readLine()!!.split(\" \").map { it.toInt() }\n var ans = 0L\n for(i in (k+1..n)) {\n val min = 0\n var max = (n / i)\n if(max*i+k > n) {\n max--\n }\n ans += (max-min)*(i-k)\n ans += Math.min(i*(max+1)-1, n) - (i*max+k)+1\n }\n if(k == 0) {\n ans -= n\n }\n println(ans)\n}", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 124, "memory_kb": 36424}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s976990882", "group_id": "codeNet:p03420", "input_text": "fun main(args: Array) {\n arc091d()\n}\n\nfun arc091d() {\n val (n, k) = readLine()!!.split(' ').map { it.toLong() }\n\n if (k==0L) return println(n*n)\n \n var answer = 0L\n\n for (b in k + 1..n) {\n answer += (n / b) * (b - k) + max((n % b) - (k - 1), 0)\n }\n\n println(answer)\n}\n\nprivate fun max(a: Long, b: Long) = Math.max(a, b)\n", "language": "Kotlin", "metadata": {"date": 1576971792, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03420.html", "problem_id": "p03420", "resource_group": "medium_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/Kotlin/s976990882.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s976990882", "user_id": "u139478771"}, "prompt_components": {"gold_output": "7\n", "input_to_evaluate": "fun main(args: Array) {\n arc091d()\n}\n\nfun arc091d() {\n val (n, k) = readLine()!!.split(' ').map { it.toLong() }\n\n if (k==0L) return println(n*n)\n \n var answer = 0L\n\n for (b in k + 1..n) {\n answer += (n / b) * (b - k) + max((n % b) - (k - 1), 0)\n }\n\n println(answer)\n}\n\nprivate fun max(a: Long, b: Long) = Math.max(a, b)\n", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 359, "cpu_time_ms": 245, "memory_kb": 38296}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s445873588", "group_id": "codeNet:p03426", "input_text": "import java.io.PrintWriter\n\nfun main(args: Array) {\n PrintWriter(System.out).use { out ->\n solve(out)\n out.flush()\n }\n}\n\nfun solve(out: PrintWriter) {\n val (h, w, d) = readIntegerList()\n val pMap = mutableMapOf>()\n for (i in 1..h) {\n val aList = readIntegerList()\n for (j in 1..w) {\n pMap[aList[j - 1]] = Pair(i, j)\n }\n }\n\n // Dごとに累積和をとる\n val sum = LongArray(h * w + d + 1)\n for (i in 1..(h * w - d)) {\n sum[i + d] =\n sum[i] + Math.abs(pMap[i + d]!!.first - pMap[i]!!.first) + Math.abs(pMap[i + d]!!.second - pMap[i]!!.second)\n }\n\n val q = readInteger()\n repeat(q) {\n val (l, r) = readIntegerList()\n println(sum[r] - sum[l])\n }\n}\n\nfun readInteger() = readLine()!!.toInt()\nfun readLong() = readLine()!!.toLong()\nfun readStringList() = readLine()!!.split(\" \")\nfun readIntegerList() = readStringList().map(String::toInt)\nfun readLongList() = readStringList().map(String::toLong)\nfun readDoubleList() = readStringList().map(String::toDouble)\n", "language": "Kotlin", "metadata": {"date": 1584898799, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03426.html", "problem_id": "p03426", "resource_group": "medium_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/Kotlin/s445873588.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s445873588", "user_id": "u784448849"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "import java.io.PrintWriter\n\nfun main(args: Array) {\n PrintWriter(System.out).use { out ->\n solve(out)\n out.flush()\n }\n}\n\nfun solve(out: PrintWriter) {\n val (h, w, d) = readIntegerList()\n val pMap = mutableMapOf>()\n for (i in 1..h) {\n val aList = readIntegerList()\n for (j in 1..w) {\n pMap[aList[j - 1]] = Pair(i, j)\n }\n }\n\n // Dごとに累積和をとる\n val sum = LongArray(h * w + d + 1)\n for (i in 1..(h * w - d)) {\n sum[i + d] =\n sum[i] + Math.abs(pMap[i + d]!!.first - pMap[i]!!.first) + Math.abs(pMap[i + d]!!.second - pMap[i]!!.second)\n }\n\n val q = readInteger()\n repeat(q) {\n val (l, r) = readIntegerList()\n println(sum[r] - sum[l])\n }\n}\n\nfun readInteger() = readLine()!!.toInt()\nfun readLong() = readLine()!!.toLong()\nfun readStringList() = readLine()!!.split(\" \")\nfun readIntegerList() = readStringList().map(String::toInt)\nfun readLongList() = readStringList().map(String::toLong)\nfun readDoubleList() = readStringList().map(String::toDouble)\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1101, "cpu_time_ms": 1371, "memory_kb": 80948}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s699538227", "group_id": "codeNet:p03427", "input_text": "fun main(args: Array) {\n var n = readLine()!!\n if (n.toCharArray().drop(1).all { it == '9' }) {\n println((n.length - 1) * 9L + n.take(1).toLong())\n } else {\n println((n.length - 1) * 9L + n.take(1).toLong() - 1)\n }\n}\n\n\n\n", "language": "Kotlin", "metadata": {"date": 1589811565, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03427.html", "problem_id": "p03427", "resource_group": "medium_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/Kotlin/s699538227.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s699538227", "user_id": "u085288971"}, "prompt_components": {"gold_output": "18\n", "input_to_evaluate": "fun main(args: Array) {\n var n = readLine()!!\n if (n.toCharArray().drop(1).all { it == '9' }) {\n println((n.length - 1) * 9L + n.take(1).toLong())\n } else {\n println((n.length - 1) * 9L + n.take(1).toLong() - 1)\n }\n}\n\n\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 254, "cpu_time_ms": 223, "memory_kb": 35824}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s510235049", "group_id": "codeNet:p03428", "input_text": "data class Double2D(val x: Double, val y: Double) {\n operator fun plus(o: Double2D) = Double2D(x + o.x, y + o.y)\n operator fun minus(o: Double2D) = Double2D(x - o.x, y - o.y)\n operator fun times(o: Double) = Double2D(x * o, y * o)\n fun norm2() = x * x + y * y\n fun norm() = Math.sqrt(x * x + y * y)\n}\n\nfun cross(v1: Double2D, v2: Double2D) = v1.x * v2.y - v1.y * v2.x\n\nfun dot(v1: Double2D, v2: Double2D) = v1.x * v2.x + v1.y * v2.y\n\nfun ccw(p: Double2D, q: Double2D, r: Double2D): Int {\n val vq = q - p\n val vr = r - p\n if (cross(vq, vr) > 0) return +1 // counter clockwise\n if (cross(vq, vr) < 0) return -1 // clockwise\n if (dot(vq, vr) < 0) return +2 // r-p-q on line\n if (vq.norm2() < vr.norm2()) return -2 // p-q-r on line\n return 0\n}\n\nfun compareDouble2D(p1: Double2D, p2: Double2D): Int {\n if (p1.x != p2.x) {\n return java.lang.Double.compare(p1.x, p2.x)\n }\n return java.lang.Double.compare(p1.y, p2.y)\n}\n\nfun convexHull(inputPs: List): List {\n // Kotlin 1.0 workaround: Kotlin Comparator is not implemented. Use Java Comparator instead.\n val ps = inputPs.sortedWith(java.util.Comparator { p1, p2 -> compareDouble2D(p1, p2) })\n val n = ps.size\n val qs = mutableListOf()\n for (i in 0 until n) {\n while (qs.size >= 2 &&\n // Use \"<= 0\" here to exclude a point on an edge.\n ccw(qs[qs.size - 2], qs[qs.size - 1], ps[i]) == -1) {\n qs.removeAt(qs.size - 1)\n }\n qs.add(ps[i])\n }\n val lowerHullSize = qs.size\n for (i in n - 2 downTo 0) {\n while (qs.size >= lowerHullSize &&\n // Use \"<= 0\" here to exclude a point on an edge.\n ccw(qs[qs.size - 2], qs[qs.size - 1], ps[i]) == -1) {\n qs.removeAt(qs.size - 1)\n }\n qs.add(ps[i])\n }\n qs.removeAt(qs.size - 1)\n return qs\n}\n\nfun main(args: Array) {\n val n = readLine()!!.toInt()\n // Kotlin 1.0 workaround: List(size, init) doesn't work.\n val ps = Array(n, {\n val (x, y) = readLine()!!.split(\" \").map(String::toInt)\n Double2D(x.toDouble(), y.toDouble()) })\n .asList()\n val qs = convexHull(ps)\n val m = qs.size\n val args = mutableMapOf()\n for (i in qs.indices) {\n val q0 = qs[i]\n val q1 = qs[(i + 1) % m]\n val q2 = qs[(i + (m - 1)) % m]\n val v1 = q1 - q0\n val v2 = q2 - q0\n val cosTheta = dot(v1, v2) / v1.norm() / v2.norm()\n val theta = Math.acos(cosTheta)\n args[qs[i]] = Math.PI - theta\n }\n for (p in ps) {\n if (args.containsKey(p)) {\n val arg = args[p]!!\n println(String.format(\"%.9f\", arg / (2.0 * Math.PI)))\n } else {\n println(0.0)\n }\n }\n}", "language": "Kotlin", "metadata": {"date": 1519568799, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03428.html", "problem_id": "p03428", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03428/input.txt", "sample_output_relpath": "derived/input_output/data/p03428/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03428/Kotlin/s510235049.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s510235049", "user_id": "u771276542"}, "prompt_components": {"gold_output": "0.5\n0.5\n", "input_to_evaluate": "data class Double2D(val x: Double, val y: Double) {\n operator fun plus(o: Double2D) = Double2D(x + o.x, y + o.y)\n operator fun minus(o: Double2D) = Double2D(x - o.x, y - o.y)\n operator fun times(o: Double) = Double2D(x * o, y * o)\n fun norm2() = x * x + y * y\n fun norm() = Math.sqrt(x * x + y * y)\n}\n\nfun cross(v1: Double2D, v2: Double2D) = v1.x * v2.y - v1.y * v2.x\n\nfun dot(v1: Double2D, v2: Double2D) = v1.x * v2.x + v1.y * v2.y\n\nfun ccw(p: Double2D, q: Double2D, r: Double2D): Int {\n val vq = q - p\n val vr = r - p\n if (cross(vq, vr) > 0) return +1 // counter clockwise\n if (cross(vq, vr) < 0) return -1 // clockwise\n if (dot(vq, vr) < 0) return +2 // r-p-q on line\n if (vq.norm2() < vr.norm2()) return -2 // p-q-r on line\n return 0\n}\n\nfun compareDouble2D(p1: Double2D, p2: Double2D): Int {\n if (p1.x != p2.x) {\n return java.lang.Double.compare(p1.x, p2.x)\n }\n return java.lang.Double.compare(p1.y, p2.y)\n}\n\nfun convexHull(inputPs: List): List {\n // Kotlin 1.0 workaround: Kotlin Comparator is not implemented. Use Java Comparator instead.\n val ps = inputPs.sortedWith(java.util.Comparator { p1, p2 -> compareDouble2D(p1, p2) })\n val n = ps.size\n val qs = mutableListOf()\n for (i in 0 until n) {\n while (qs.size >= 2 &&\n // Use \"<= 0\" here to exclude a point on an edge.\n ccw(qs[qs.size - 2], qs[qs.size - 1], ps[i]) == -1) {\n qs.removeAt(qs.size - 1)\n }\n qs.add(ps[i])\n }\n val lowerHullSize = qs.size\n for (i in n - 2 downTo 0) {\n while (qs.size >= lowerHullSize &&\n // Use \"<= 0\" here to exclude a point on an edge.\n ccw(qs[qs.size - 2], qs[qs.size - 1], ps[i]) == -1) {\n qs.removeAt(qs.size - 1)\n }\n qs.add(ps[i])\n }\n qs.removeAt(qs.size - 1)\n return qs\n}\n\nfun main(args: Array) {\n val n = readLine()!!.toInt()\n // Kotlin 1.0 workaround: List(size, init) doesn't work.\n val ps = Array(n, {\n val (x, y) = readLine()!!.split(\" \").map(String::toInt)\n Double2D(x.toDouble(), y.toDouble()) })\n .asList()\n val qs = convexHull(ps)\n val m = qs.size\n val args = mutableMapOf()\n for (i in qs.indices) {\n val q0 = qs[i]\n val q1 = qs[(i + 1) % m]\n val q2 = qs[(i + (m - 1)) % m]\n val v1 = q1 - q0\n val v2 = q2 - q0\n val cosTheta = dot(v1, v2) / v1.norm() / v2.norm()\n val theta = Math.acos(cosTheta)\n args[qs[i]] = Math.PI - theta\n }\n for (p in ps) {\n if (args.containsKey(p)) {\n val arg = args[p]!!\n println(String.format(\"%.9f\", arg / (2.0 * Math.PI)))\n } else {\n println(0.0)\n }\n }\n}", "problem_context": "Score : 600 points\n\nProblem Statement\n\nThere are N holes in a two-dimensional plane. The coordinates of the i-th hole are (x_i,y_i).\n\nLet R=10^{10^{10^{10}}}. Ringo performs the following operation:\n\nRandomly choose a point from the interior of a circle of radius R centered at the origin, and put Snuke there. Snuke will move to the hole with the smallest Euclidean distance from the point, and fall into that hole. If there are multiple such holes, the hole with the smallest index will be chosen.\n\nFor every i (1 \\leq i \\leq N), find the probability that Snuke falls into the i-th hole.\n\nHere, the operation of randomly choosing a point from the interior of a circle of radius R is defined as follows:\n\nPick two real numbers x and y independently according to uniform distribution on [-R,R].\n\nIf x^2+y^2\\leq R^2, the point (x,y) is chosen. Otherwise, repeat picking the real numbers x,y until the condition is met.\n\nConstraints\n\n2 \\leq N \\leq 100\n\n|x_i|,|y_i| \\leq 10^6(1\\leq i\\leq N)\n\nAll given points are pairwise distinct.\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\n:\nx_N y_N\n\nOutput\n\nPrint N real numbers. The i-th real number must represent the probability that Snuke falls into the i-th hole.\n\nThe output will be judged correct when, for all output values, the absolute or relative error is at most 10^{-5}.\n\nSample Input 1\n\n2\n0 0\n1 1\n\nSample Output 1\n\n0.5\n0.5\n\nIf Ringo put Snuke in the region x+y\\leq 1, Snuke will fall into the first hole. The probability of this happening is very close to 0.5.\nOtherwise, Snuke will fall into the second hole, the probability of which happening is also very close to 0.5.\n\nSample Input 2\n\n5\n0 0\n2 8\n4 5\n2 6\n3 10\n\nSample Output 2\n\n0.43160120892732328768\n0.03480224363653196956\n0.13880483535586193855\n0.00000000000000000000\n0.39479171208028279727", "sample_input": "2\n0 0\n1 1\n"}, "reference_outputs": ["0.5\n0.5\n"], "source_document_id": "p03428", "source_text": "Score : 600 points\n\nProblem Statement\n\nThere are N holes in a two-dimensional plane. The coordinates of the i-th hole are (x_i,y_i).\n\nLet R=10^{10^{10^{10}}}. Ringo performs the following operation:\n\nRandomly choose a point from the interior of a circle of radius R centered at the origin, and put Snuke there. Snuke will move to the hole with the smallest Euclidean distance from the point, and fall into that hole. If there are multiple such holes, the hole with the smallest index will be chosen.\n\nFor every i (1 \\leq i \\leq N), find the probability that Snuke falls into the i-th hole.\n\nHere, the operation of randomly choosing a point from the interior of a circle of radius R is defined as follows:\n\nPick two real numbers x and y independently according to uniform distribution on [-R,R].\n\nIf x^2+y^2\\leq R^2, the point (x,y) is chosen. Otherwise, repeat picking the real numbers x,y until the condition is met.\n\nConstraints\n\n2 \\leq N \\leq 100\n\n|x_i|,|y_i| \\leq 10^6(1\\leq i\\leq N)\n\nAll given points are pairwise distinct.\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\n:\nx_N y_N\n\nOutput\n\nPrint N real numbers. The i-th real number must represent the probability that Snuke falls into the i-th hole.\n\nThe output will be judged correct when, for all output values, the absolute or relative error is at most 10^{-5}.\n\nSample Input 1\n\n2\n0 0\n1 1\n\nSample Output 1\n\n0.5\n0.5\n\nIf Ringo put Snuke in the region x+y\\leq 1, Snuke will fall into the first hole. The probability of this happening is very close to 0.5.\nOtherwise, Snuke will fall into the second hole, the probability of which happening is also very close to 0.5.\n\nSample Input 2\n\n5\n0 0\n2 8\n4 5\n2 6\n3 10\n\nSample Output 2\n\n0.43160120892732328768\n0.03480224363653196956\n0.13880483535586193855\n0.00000000000000000000\n0.39479171208028279727", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2612, "cpu_time_ms": 276, "memory_kb": 36076}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s404068780", "group_id": "codeNet:p03428", "input_text": "data class Double2D(val x: Double, val y: Double) {\n operator fun plus(o: Double2D): Double2D {\n return Double2D(x + o.x, y + o.y)\n }\n operator fun minus(o: Double2D): Double2D {\n return Double2D(x - o.x, y - o.y)\n }\n operator fun times(o: Double): Double2D {\n return Double2D(x * o, y * o)\n }\n fun norm2(): Double {\n return x * x + y * y\n }\n fun norm(): Double {\n return Math.sqrt(x * x + y * y)\n }\n}\n\nfun cross(v1: Double2D, v2: Double2D): Double {\n return v1.x * v2.y - v1.y * v2.x\n}\n\nfun dot(v1: Double2D, v2: Double2D): Double {\n return v1.x * v2.x + v1.y * v2.y\n}\n\nfun ccw(p: Double2D, q: Double2D, r: Double2D): Int {\n val vq = q - p\n val vr = r - p\n if (cross(vq, vr) > 0) return +1 // counter clockwise\n if (cross(vq, vr) < 0) return -1 // clockwise\n if (dot(vq, vr) < 0) return +2 // r-p-q on line\n if (vq.norm2() < vr.norm2()) return -2 // p-q-r on line\n return 0\n}\n\nfun compareDouble2D(p1: Double2D, p2: Double2D): Int {\n if (p1.x != p2.x) {\n return java.lang.Double.compare(p1.x, p2.x)\n }\n return java.lang.Double.compare(p1.y, p2.y)\n}\n\nfun convexHull(inputPs: List): List {\n val ps = inputPs.sortedWith(java.util.Comparator { p1, p2 -> compareDouble2D(p1, p2) })\n val n = ps.size\n val qs = mutableListOf()\n for (i in 0 until n) {\n while (qs.size >= 2 &&\n // Use \"<= 0\" here to exclude a point on an edge.\n ccw(qs[qs.size - 2], qs[qs.size - 1], ps[i]) == -1) {\n qs.removeAt(qs.size - 1)\n }\n qs.add(ps[i])\n }\n val lowerHullSize = qs.size\n for (i in n - 2 downTo 0) {\n while (qs.size >= lowerHullSize &&\n // Use \"<= 0\" here to exclude a point on an edge.\n ccw(qs[qs.size - 2], qs[qs.size - 1], ps[i]) == -1) {\n qs.removeAt(qs.size - 1)\n }\n qs.add(ps[i])\n }\n qs.removeAt(qs.size - 1)\n return qs\n}\n\nfun main(args: Array) {\n val n = readLine()!!.toInt()\n // No List(n, {}) constructor for Kotlin 1.0.\n val ps = Array(n, {\n val (x, y) = readLine()!!.split(\" \").map(String::toInt)\n Double2D(x.toDouble(), y.toDouble()) })\n .asList()\n val qs = convexHull(ps)\n val m = qs.size\n val args = mutableMapOf()\n for (i in 0 until m) {\n val qm = qs[i]\n val qp = qs[(i + (m - 1)) % m]\n val qn = qs[(i + 1) % m]\n val v1 = qn - qm\n val v2 = qp - qm\n val cos_theta = dot(v1, v2) / v1.norm() / v2.norm()\n val theta = Math.acos(cos_theta)\n args[qs[i]] = Math.PI - theta\n }\n for (p in ps) {\n if (args.containsKey(p)) {\n val arg = args[p]!!\n println(String.format(\"%.9f\", arg / (2.0 * Math.PI)))\n } else {\n println(0.0)\n }\n }\n}", "language": "Kotlin", "metadata": {"date": 1519534485, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03428.html", "problem_id": "p03428", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03428/input.txt", "sample_output_relpath": "derived/input_output/data/p03428/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03428/Kotlin/s404068780.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s404068780", "user_id": "u771276542"}, "prompt_components": {"gold_output": "0.5\n0.5\n", "input_to_evaluate": "data class Double2D(val x: Double, val y: Double) {\n operator fun plus(o: Double2D): Double2D {\n return Double2D(x + o.x, y + o.y)\n }\n operator fun minus(o: Double2D): Double2D {\n return Double2D(x - o.x, y - o.y)\n }\n operator fun times(o: Double): Double2D {\n return Double2D(x * o, y * o)\n }\n fun norm2(): Double {\n return x * x + y * y\n }\n fun norm(): Double {\n return Math.sqrt(x * x + y * y)\n }\n}\n\nfun cross(v1: Double2D, v2: Double2D): Double {\n return v1.x * v2.y - v1.y * v2.x\n}\n\nfun dot(v1: Double2D, v2: Double2D): Double {\n return v1.x * v2.x + v1.y * v2.y\n}\n\nfun ccw(p: Double2D, q: Double2D, r: Double2D): Int {\n val vq = q - p\n val vr = r - p\n if (cross(vq, vr) > 0) return +1 // counter clockwise\n if (cross(vq, vr) < 0) return -1 // clockwise\n if (dot(vq, vr) < 0) return +2 // r-p-q on line\n if (vq.norm2() < vr.norm2()) return -2 // p-q-r on line\n return 0\n}\n\nfun compareDouble2D(p1: Double2D, p2: Double2D): Int {\n if (p1.x != p2.x) {\n return java.lang.Double.compare(p1.x, p2.x)\n }\n return java.lang.Double.compare(p1.y, p2.y)\n}\n\nfun convexHull(inputPs: List): List {\n val ps = inputPs.sortedWith(java.util.Comparator { p1, p2 -> compareDouble2D(p1, p2) })\n val n = ps.size\n val qs = mutableListOf()\n for (i in 0 until n) {\n while (qs.size >= 2 &&\n // Use \"<= 0\" here to exclude a point on an edge.\n ccw(qs[qs.size - 2], qs[qs.size - 1], ps[i]) == -1) {\n qs.removeAt(qs.size - 1)\n }\n qs.add(ps[i])\n }\n val lowerHullSize = qs.size\n for (i in n - 2 downTo 0) {\n while (qs.size >= lowerHullSize &&\n // Use \"<= 0\" here to exclude a point on an edge.\n ccw(qs[qs.size - 2], qs[qs.size - 1], ps[i]) == -1) {\n qs.removeAt(qs.size - 1)\n }\n qs.add(ps[i])\n }\n qs.removeAt(qs.size - 1)\n return qs\n}\n\nfun main(args: Array) {\n val n = readLine()!!.toInt()\n // No List(n, {}) constructor for Kotlin 1.0.\n val ps = Array(n, {\n val (x, y) = readLine()!!.split(\" \").map(String::toInt)\n Double2D(x.toDouble(), y.toDouble()) })\n .asList()\n val qs = convexHull(ps)\n val m = qs.size\n val args = mutableMapOf()\n for (i in 0 until m) {\n val qm = qs[i]\n val qp = qs[(i + (m - 1)) % m]\n val qn = qs[(i + 1) % m]\n val v1 = qn - qm\n val v2 = qp - qm\n val cos_theta = dot(v1, v2) / v1.norm() / v2.norm()\n val theta = Math.acos(cos_theta)\n args[qs[i]] = Math.PI - theta\n }\n for (p in ps) {\n if (args.containsKey(p)) {\n val arg = args[p]!!\n println(String.format(\"%.9f\", arg / (2.0 * Math.PI)))\n } else {\n println(0.0)\n }\n }\n}", "problem_context": "Score : 600 points\n\nProblem Statement\n\nThere are N holes in a two-dimensional plane. The coordinates of the i-th hole are (x_i,y_i).\n\nLet R=10^{10^{10^{10}}}. Ringo performs the following operation:\n\nRandomly choose a point from the interior of a circle of radius R centered at the origin, and put Snuke there. Snuke will move to the hole with the smallest Euclidean distance from the point, and fall into that hole. If there are multiple such holes, the hole with the smallest index will be chosen.\n\nFor every i (1 \\leq i \\leq N), find the probability that Snuke falls into the i-th hole.\n\nHere, the operation of randomly choosing a point from the interior of a circle of radius R is defined as follows:\n\nPick two real numbers x and y independently according to uniform distribution on [-R,R].\n\nIf x^2+y^2\\leq R^2, the point (x,y) is chosen. Otherwise, repeat picking the real numbers x,y until the condition is met.\n\nConstraints\n\n2 \\leq N \\leq 100\n\n|x_i|,|y_i| \\leq 10^6(1\\leq i\\leq N)\n\nAll given points are pairwise distinct.\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\n:\nx_N y_N\n\nOutput\n\nPrint N real numbers. The i-th real number must represent the probability that Snuke falls into the i-th hole.\n\nThe output will be judged correct when, for all output values, the absolute or relative error is at most 10^{-5}.\n\nSample Input 1\n\n2\n0 0\n1 1\n\nSample Output 1\n\n0.5\n0.5\n\nIf Ringo put Snuke in the region x+y\\leq 1, Snuke will fall into the first hole. The probability of this happening is very close to 0.5.\nOtherwise, Snuke will fall into the second hole, the probability of which happening is also very close to 0.5.\n\nSample Input 2\n\n5\n0 0\n2 8\n4 5\n2 6\n3 10\n\nSample Output 2\n\n0.43160120892732328768\n0.03480224363653196956\n0.13880483535586193855\n0.00000000000000000000\n0.39479171208028279727", "sample_input": "2\n0 0\n1 1\n"}, "reference_outputs": ["0.5\n0.5\n"], "source_document_id": "p03428", "source_text": "Score : 600 points\n\nProblem Statement\n\nThere are N holes in a two-dimensional plane. The coordinates of the i-th hole are (x_i,y_i).\n\nLet R=10^{10^{10^{10}}}. Ringo performs the following operation:\n\nRandomly choose a point from the interior of a circle of radius R centered at the origin, and put Snuke there. Snuke will move to the hole with the smallest Euclidean distance from the point, and fall into that hole. If there are multiple such holes, the hole with the smallest index will be chosen.\n\nFor every i (1 \\leq i \\leq N), find the probability that Snuke falls into the i-th hole.\n\nHere, the operation of randomly choosing a point from the interior of a circle of radius R is defined as follows:\n\nPick two real numbers x and y independently according to uniform distribution on [-R,R].\n\nIf x^2+y^2\\leq R^2, the point (x,y) is chosen. Otherwise, repeat picking the real numbers x,y until the condition is met.\n\nConstraints\n\n2 \\leq N \\leq 100\n\n|x_i|,|y_i| \\leq 10^6(1\\leq i\\leq N)\n\nAll given points are pairwise distinct.\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\n:\nx_N y_N\n\nOutput\n\nPrint N real numbers. The i-th real number must represent the probability that Snuke falls into the i-th hole.\n\nThe output will be judged correct when, for all output values, the absolute or relative error is at most 10^{-5}.\n\nSample Input 1\n\n2\n0 0\n1 1\n\nSample Output 1\n\n0.5\n0.5\n\nIf Ringo put Snuke in the region x+y\\leq 1, Snuke will fall into the first hole. The probability of this happening is very close to 0.5.\nOtherwise, Snuke will fall into the second hole, the probability of which happening is also very close to 0.5.\n\nSample Input 2\n\n5\n0 0\n2 8\n4 5\n2 6\n3 10\n\nSample Output 2\n\n0.43160120892732328768\n0.03480224363653196956\n0.13880483535586193855\n0.00000000000000000000\n0.39479171208028279727", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2666, "cpu_time_ms": 272, "memory_kb": 38000}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s931922577", "group_id": "codeNet:p03435", "input_text": "fun main(args: Array) {\n val c = (1..3).map{readLine()!!.split(\" \").map{it.toInt()}}\n val rows = c.map{row ->\n (0..1).map{index ->\n row[index + 1] - row[index]\n }\n }\n\n val colums = (0..2).map{i ->\n (0..1).map{j ->\n c[i][j + 1] - c[i][j]\n }\n }\n if(judge(rows)&&judge(colums)) {\n println(\"Yes\")\n return\n }\n println(\"No\")\n}\n\nfun judge(list:List>): Boolean{\n return (0 until 2).all{index ->\n list[index] == list[index + 1]\n }\n}", "language": "Kotlin", "metadata": {"date": 1562250294, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03435.html", "problem_id": "p03435", "resource_group": "medium_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/Kotlin/s931922577.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s931922577", "user_id": "u169088512"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "fun main(args: Array) {\n val c = (1..3).map{readLine()!!.split(\" \").map{it.toInt()}}\n val rows = c.map{row ->\n (0..1).map{index ->\n row[index + 1] - row[index]\n }\n }\n\n val colums = (0..2).map{i ->\n (0..1).map{j ->\n c[i][j + 1] - c[i][j]\n }\n }\n if(judge(rows)&&judge(colums)) {\n println(\"Yes\")\n return\n }\n println(\"No\")\n}\n\nfun judge(list:List>): Boolean{\n return (0 until 2).all{index ->\n list[index] == list[index + 1]\n }\n}", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 236, "memory_kb": 38032}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s791617257", "group_id": "codeNet:p03435", "input_text": "fun main(args:Array) {\n\tval c = (1..3).map{ readLine()!!.split(\" \").map{ it.toInt() }}\n\tlistOf(\n\t\t\tc[0][0]-c[0][1]==c[1][0]-c[1][1],\n\t\t\tc[0][0]-c[0][1]==c[2][0]-c[2][1],\n\t\t\tc[0][1]-c[0][2]==c[1][1]-c[1][2],\n\t\t\tc[0][1]-c[0][2]==c[2][1]-c[2][2],\n\t\t\tc[0][0]-c[1][0]==c[0][1]-c[1][1],\n\t\t\tc[0][0]-c[1][0]==c[0][2]-c[1][2],\n\t\t\tc[1][0]-c[2][0]==c[1][1]-c[2][1],\n\t\t\tc[1][0]-c[2][0]==c[1][2]-c[2][2]\n\t).all{it}.let{\n\t\tprintln( if(it)\"Yes\" else \"No\")\n\t}\n\t\n}", "language": "Kotlin", "metadata": {"date": 1541647903, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03435.html", "problem_id": "p03435", "resource_group": "medium_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/Kotlin/s791617257.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s791617257", "user_id": "u914096045"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "fun main(args:Array) {\n\tval c = (1..3).map{ readLine()!!.split(\" \").map{ it.toInt() }}\n\tlistOf(\n\t\t\tc[0][0]-c[0][1]==c[1][0]-c[1][1],\n\t\t\tc[0][0]-c[0][1]==c[2][0]-c[2][1],\n\t\t\tc[0][1]-c[0][2]==c[1][1]-c[1][2],\n\t\t\tc[0][1]-c[0][2]==c[2][1]-c[2][2],\n\t\t\tc[0][0]-c[1][0]==c[0][1]-c[1][1],\n\t\t\tc[0][0]-c[1][0]==c[0][2]-c[1][2],\n\t\t\tc[1][0]-c[2][0]==c[1][1]-c[2][1],\n\t\t\tc[1][0]-c[2][0]==c[1][2]-c[2][2]\n\t).all{it}.let{\n\t\tprintln( if(it)\"Yes\" else \"No\")\n\t}\n\t\n}", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 246, "memory_kb": 37784}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s395767699", "group_id": "codeNet:p03436", "input_text": "import java.util.*\nimport java.math.*\nimport java.lang.Math.*\n\nprivate val readString: ()->String = {readLine()!!}\nprivate val readInt: ()->Int = { readLine()!!.toInt() }\nprivate val readLong: ()->Long = { readLine()!!.toLong() }\nprivate val readListInt: ()->List = { readLine()!!.split(' ').map(String::toInt) }\nprivate val readListLong: ()->List = { readLine()!!.split(' ').map(String::toLong) }\nprivate val errPrintln: (String)->Unit = { msg -> System.err.println(msg) }\nprivate val MOD = 1e9.toLong()+7\nprivate val INF = Int.MAX_VALUE/2\nprivate val LINF = Long.MAX_VALUE/2\n\n\nfun solveD(H: Int, W: Int, G: List): Int {\n val que = LinkedList>()\n que.addLast(Pair(0,0))\n val dx = intArrayOf(0,1,0,1)\n val dy = intArrayOf(1,0,-1,0)\n val step = Array(H){Array(W){INF}}\n step[0][0] = 0\n while(que.isNotEmpty()) {\n val (x, y) = que.removeFirst()\n\n for (i in dx.indices) {\n val nx = x + dx[i]; val ny = y + dy[i]\n if (nx<0 || H<=nx || ny<0 || W<=ny) {\n continue\n }\n if (G[nx][ny] == '#') {\n continue\n }\n\n assert(G[nx][ny] == '.'){\"(nx,ny) is white\"}\n\n if (!que.contains(Pair(nx,ny)) && step[nx][ny] == INF) {\n que.addLast(Pair(nx,ny))\n }\n if (step[x][y] + 1 < step[nx][ny]) {\n step[nx][ny] = step[x][y] + 1\n }\n }\n }\n\n if (step[H-1][W-1] == INF) {\n return -1\n }\n\n var white = 0\n for(i in 0 until H) {\n for (j in 0 until W) {\n if (G[i][j] == '.') white++\n }\n }\n\n val path = step[H-1][W-1] + 1\n\n return white - path\n}\n\n\nfun main(args: Array) {\n val (H, W) = readListInt()\n\n val S = Array(H){\"\"}\n for (i in 0 until H) {\n S[i] = readString()\n }\n\n val ans = solveD(H, W, S.toList())\n\n println(ans)\n}\n", "language": "Kotlin", "metadata": {"date": 1589816352, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03436.html", "problem_id": "p03436", "resource_group": "medium_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/Kotlin/s395767699.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s395767699", "user_id": "u404244809"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import java.util.*\nimport java.math.*\nimport java.lang.Math.*\n\nprivate val readString: ()->String = {readLine()!!}\nprivate val readInt: ()->Int = { readLine()!!.toInt() }\nprivate val readLong: ()->Long = { readLine()!!.toLong() }\nprivate val readListInt: ()->List = { readLine()!!.split(' ').map(String::toInt) }\nprivate val readListLong: ()->List = { readLine()!!.split(' ').map(String::toLong) }\nprivate val errPrintln: (String)->Unit = { msg -> System.err.println(msg) }\nprivate val MOD = 1e9.toLong()+7\nprivate val INF = Int.MAX_VALUE/2\nprivate val LINF = Long.MAX_VALUE/2\n\n\nfun solveD(H: Int, W: Int, G: List): Int {\n val que = LinkedList>()\n que.addLast(Pair(0,0))\n val dx = intArrayOf(0,1,0,1)\n val dy = intArrayOf(1,0,-1,0)\n val step = Array(H){Array(W){INF}}\n step[0][0] = 0\n while(que.isNotEmpty()) {\n val (x, y) = que.removeFirst()\n\n for (i in dx.indices) {\n val nx = x + dx[i]; val ny = y + dy[i]\n if (nx<0 || H<=nx || ny<0 || W<=ny) {\n continue\n }\n if (G[nx][ny] == '#') {\n continue\n }\n\n assert(G[nx][ny] == '.'){\"(nx,ny) is white\"}\n\n if (!que.contains(Pair(nx,ny)) && step[nx][ny] == INF) {\n que.addLast(Pair(nx,ny))\n }\n if (step[x][y] + 1 < step[nx][ny]) {\n step[nx][ny] = step[x][y] + 1\n }\n }\n }\n\n if (step[H-1][W-1] == INF) {\n return -1\n }\n\n var white = 0\n for(i in 0 until H) {\n for (j in 0 until W) {\n if (G[i][j] == '.') white++\n }\n }\n\n val path = step[H-1][W-1] + 1\n\n return white - path\n}\n\n\nfun main(args: Array) {\n val (H, W) = readListInt()\n\n val S = Array(H){\"\"}\n for (i in 0 until H) {\n S[i] = readString()\n }\n\n val ans = solveD(H, W, S.toList())\n\n println(ans)\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1938, "cpu_time_ms": 272, "memory_kb": 38132}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s687134731", "group_id": "codeNet:p03436", "input_text": "import java.util.*\n\nfun main(args: Array) {\n val (r, c) = readLine()!!.split(' ').map(String::toInt)\n val map = Array(r + 2) { CharArray(c + 2) { '#' } }\n (1..r).forEach {\n map[it] = readLine()!!\n .toMutableList()\n .apply { this.add(0, '#') }\n .apply { this.add(this.size, '#') }\n .toCharArray()\n }\n val branch = Array((r + 1) * (c + 1)) { mutableListOf() }\n for (i in 1..r) {\n for (j in 1..c) {\n val cur = j + (c * (i - 1))\n if (map[i][j] == '.' && map[i][j + 1] == '.') {\n branch[cur].add(cur + 1)\n branch[cur + 1].add(cur)\n }\n if (map[i][j] == '.' && map[i + 1][j] == '.') {\n branch[cur].add(cur + c)\n branch[cur + c].add(cur)\n }\n }\n }\n\n val minCost = Array((r + 1) * (c + 1)) { Int.MAX_VALUE }\n minCost[1] = 1\n\n val queue = ArrayDeque().apply { addFirst(1) }\n while (queue.isNotEmpty()) {\n val cur = queue.pollLast()!!\n for (to in branch[cur]) {\n if (minCost[to] > minCost[cur] + 1) {\n minCost[to] = minCost[cur] + 1\n queue.addFirst(to)\n }\n }\n }\n if (minCost[r * c] == Int.MAX_VALUE) {\n println(-1)\n } else {\n val pCount = map.map { it.count { it == '.' } }.sum()\n println(pCount - minCost[r * c])\n }\n}\n", "language": "Kotlin", "metadata": {"date": 1571447964, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03436.html", "problem_id": "p03436", "resource_group": "medium_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/Kotlin/s687134731.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s687134731", "user_id": "u099066216"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import java.util.*\n\nfun main(args: Array) {\n val (r, c) = readLine()!!.split(' ').map(String::toInt)\n val map = Array(r + 2) { CharArray(c + 2) { '#' } }\n (1..r).forEach {\n map[it] = readLine()!!\n .toMutableList()\n .apply { this.add(0, '#') }\n .apply { this.add(this.size, '#') }\n .toCharArray()\n }\n val branch = Array((r + 1) * (c + 1)) { mutableListOf() }\n for (i in 1..r) {\n for (j in 1..c) {\n val cur = j + (c * (i - 1))\n if (map[i][j] == '.' && map[i][j + 1] == '.') {\n branch[cur].add(cur + 1)\n branch[cur + 1].add(cur)\n }\n if (map[i][j] == '.' && map[i + 1][j] == '.') {\n branch[cur].add(cur + c)\n branch[cur + c].add(cur)\n }\n }\n }\n\n val minCost = Array((r + 1) * (c + 1)) { Int.MAX_VALUE }\n minCost[1] = 1\n\n val queue = ArrayDeque().apply { addFirst(1) }\n while (queue.isNotEmpty()) {\n val cur = queue.pollLast()!!\n for (to in branch[cur]) {\n if (minCost[to] > minCost[cur] + 1) {\n minCost[to] = minCost[cur] + 1\n queue.addFirst(to)\n }\n }\n }\n if (minCost[r * c] == Int.MAX_VALUE) {\n println(-1)\n } else {\n val pCount = map.map { it.count { it == '.' } }.sum()\n println(pCount - minCost[r * c])\n }\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 266, "memory_kb": 38332}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s206843172", "group_id": "codeNet:p03436", "input_text": "import java.util.*\n\n\nfun main(args: Array) {\n val (h, w) = readIntList()\n val s = (1..h).map { readLine()!! }\n val map = (1..w).mapIndexed { index, i -> s.map { it[index] }.joinToString(\"\").map { it == '.' } }\n val dist = (1..w).map { (1..h).map { -1 }.toMutableList() }\n val queue = LinkedList>()\n queue.offer(0 to 0)\n val end = Pair(h, w)\n val moveX = listOf(0, 0, 1, -1)\n val moveY = listOf(1, -1, 0, 0)\n while (queue.size > 0) {\n val point = queue.poll()\n if (point == end) {\n break\n }\n for (i in 0..3) {\n val tempX = point.first + moveX[i]\n val tempY = point.second + moveY[i]\n if (tempX >= 0 && tempY >= 0 && tempX < w && tempY < h && map[tempX][tempY] && dist[tempX][tempY] == -1) {\n queue.offer(tempX to tempY)\n dist[tempX][tempY] = dist[point.first][point.second] + 1\n }\n }\n }\n val out = dist[w - 1][h - 1] + 2\n if (out == -1) {\n println(-1)\n } else {\n println(s.sumBy { it.count { it == '.' } } - out)\n }\n}\n\nfun printYesOrNo(flag: Boolean) {\n println(if (flag) \"Yes\" else \"No\")\n}\n\nfun readIntList(): List = readLine()!!.split(' ').map { it.toInt() }\n\nfun readInt(): Int = readLine()!!.toInt()\n\nfun err(print: Any) {\n System.err.println(print)\n}", "language": "Kotlin", "metadata": {"date": 1519010977, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03436.html", "problem_id": "p03436", "resource_group": "medium_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/Kotlin/s206843172.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s206843172", "user_id": "u166163326"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import java.util.*\n\n\nfun main(args: Array) {\n val (h, w) = readIntList()\n val s = (1..h).map { readLine()!! }\n val map = (1..w).mapIndexed { index, i -> s.map { it[index] }.joinToString(\"\").map { it == '.' } }\n val dist = (1..w).map { (1..h).map { -1 }.toMutableList() }\n val queue = LinkedList>()\n queue.offer(0 to 0)\n val end = Pair(h, w)\n val moveX = listOf(0, 0, 1, -1)\n val moveY = listOf(1, -1, 0, 0)\n while (queue.size > 0) {\n val point = queue.poll()\n if (point == end) {\n break\n }\n for (i in 0..3) {\n val tempX = point.first + moveX[i]\n val tempY = point.second + moveY[i]\n if (tempX >= 0 && tempY >= 0 && tempX < w && tempY < h && map[tempX][tempY] && dist[tempX][tempY] == -1) {\n queue.offer(tempX to tempY)\n dist[tempX][tempY] = dist[point.first][point.second] + 1\n }\n }\n }\n val out = dist[w - 1][h - 1] + 2\n if (out == -1) {\n println(-1)\n } else {\n println(s.sumBy { it.count { it == '.' } } - out)\n }\n}\n\nfun printYesOrNo(flag: Boolean) {\n println(if (flag) \"Yes\" else \"No\")\n}\n\nfun readIntList(): List = readLine()!!.split(' ').map { it.toInt() }\n\nfun readInt(): Int = readLine()!!.toInt()\n\nfun err(print: Any) {\n System.err.println(print)\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1367, "cpu_time_ms": 263, "memory_kb": 38248}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s393950347", "group_id": "codeNet:p03437", "input_text": "import java.io.*\nimport java.lang.*\nimport java.math.BigDecimal\nimport java.util.*\n\n// Constant\nval sc = FastScanner()\nval pw = PrintWriter(System.out)\nconst val MOD = 1000000007L\nconst val INF = 9223372036854775807L\n\n// Main\nfun main(args: Array) {\n solve()\n pw.flush()\n}\n\nfun solve() {\n val x = nextLong()\n val y = nextLong()\n\n when {\n x % y == 0L -> println(-1)\n else -> println(x)\n }\n\n\n}\n\n\n\n// Rule\noperator fun String.get(index: Long): Char {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun CharArray.get(index: Long): Char {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun CharArray.set(index: Long, value: Char) {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n this[index.toInt()] = value\n}\noperator fun LongArray.get(index: Long): Long {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun LongArray.set(index: Long, value: Long) {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n this[index.toInt()] = value\n}\noperator fun DoubleArray.get(index: Long): Double {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun DoubleArray.set(index: Long, value: Double) {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n this[index.toInt()] = value\n}\noperator fun Array.get(index: Long): T {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun Array.set(index: Long, value: T) {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n this[index.toInt()] = value\n}\noperator fun MutableList.get(index: Long): T {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun MutableList.set(index: Long, value: T) {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n this[index.toInt()] = value\n}\n\nval LongArray.siz: Long\n get() = size.toLong()\nval Array.siz: Long\n get() = size.toLong()\nval MutableList.siz: Long\n get() = size.toLong()\nval MutableSet.siz: Long\n get() = size.toLong()\nval String.len: Long\n get() = length.toLong()\n\n// Output\nfun println(v: String) {\n pw.println(v)\n}\nfun print(v: String) {\n pw.print(v)\n}\n\n// Input\nfun next() = sc.next()\nfun nextLong() = sc.nextLong()\nfun nextDouble() = next().toDouble()\nfun nextAry(n: Long): Array {\n val ary = ary(n)\n for (i in 0 until n) ary[i] = next()\n return ary\n}\nfun nextLongAry(n: Long): LongArray {\n val ary = longAry(n)\n for (i in 0 until n) ary[i] = nextLong()\n return ary\n}\nfun nextDoubleAry(n: Long): DoubleArray {\n val ary = doubleAry(n)\n for (i in 0 until n) ary[i] = nextDouble()\n return ary\n}\n\n// Statement\nfun ary(n: Long, init: String = \"\") = Array(n.toInt()) { init }\nfun longAry(n: Long, init: Long = 0L) = LongArray(n.toInt()) { init }\nfun doubleAry(n: Long, init: Double = 0.0) = DoubleArray(n.toInt()) { init }\nfun boolAry(n: Long, init: Boolean = false) = Array(n.toInt()) { init }\nfun ary2(n: Long, m: Long, init: String = \"\") = Array(n.toInt()) { ary(m, init) }\nfun longAry2(n: Long, m: Long, init: Long = 0) = Array(n.toInt()) { longAry(m, init) }\nfun doubleAry2(n: Long, m: Long, init: Double = 0.0) = Array(n.toInt()) { doubleAry(m, init) }\nfun boolAry2(n: Long, m: Long, init: Boolean = false) = Array(n.toInt()) { boolAry(m, init) }\nfun ary3(n: Long, m: Long, k: Long, init: String = \"\") = Array(n.toInt()) { ary2(m, k, init) }\nfun longAry3(n: Long, m: Long, k: Long, init: Long = 0L) = Array(n.toInt()) { longAry2(m, k, init) }\nfun doubleAry3(n: Long, m: Long, k: Long, init: Double = 0.0) = Array(n.toInt()) { doubleAry2(m, k, init) }\nfun boolAry3(n: Long, m: Long, k: Long, init: Boolean = false) = Array(n.toInt()) { boolAry2(m, k, init) }\nfun list() = mutableListOf()\nfun longList() = mutableListOf()\nfun doubleList() = mutableListOf()\nfun strSet() = mutableSetOf()\nfun longSet() = mutableSetOf()\nfun doubleSet() = mutableSetOf()\nfun map() = mutableMapOf()\n\n// Monoid\nval addFunc = {a: Long, b: Long -> a + b}\nval mulFunc = {a: Long, b: Long -> a * b}\nval maxFunc = {a: Long, b: Long -> max(a, b)}\nval minFunc = {a: Long, b: Long -> min(a, b)}\nval gcdFunc = {a: Long, b: Long -> gcd(a, b)}\nval lcmFunc = {a: Long, b: Long -> lcm(a, b)}\nval xorFunc = {a: Long, b: Long -> a xor b}\nfun calc(a: Long, b: Long, op: (Long, Long) -> Long) = op(a, b)\n\n// Extension\nfun LongArray.lowerBound(n: Long): Long {\n var ok = this.size.toLong()\n var ng = -1L\n while (abs(ok - ng) > 1) {\n val mid = (ok + ng) / 2\n if (this[mid] >= n) ok = mid\n else ng = mid\n }\n return ok\n}\nfun DoubleArray.lowerBound(n: Double): Long {\n var ok = this.size.toLong()\n var ng = -1L\n while (abs(ok - ng) > 1) {\n val mid = (ok + ng) / 2\n if (this[mid] >= n) ok = mid\n else ng = mid\n }\n return ok\n}\nfun MutableList.longLowerBound(n: Long): Long {\n var ok = this.size.toLong()\n var ng = -1L\n while (abs(ok - ng) > 1) {\n val mid = (ok + ng) / 2\n if (this[mid] >= n) ok = mid\n else ng = mid\n }\n return ok\n}\nfun MutableList.doubleLowerBound(n: Double): Long {\n var ok = this.size.toLong()\n var ng = -1L\n while (abs(ok - ng) > 1) {\n val mid = (ok + ng) / 2\n if (this[mid] >= n) ok = mid\n else ng = mid\n }\n return ok\n}\nfun LongArray.cumsum(op: (Long, Long) -> Long): LongArray {\n val s = longAry(this.size + 1L)\n s[1] = this[0]\n for (i in 1 until this.size) s[i + 1] = calc(s[i], this[i], op)\n return s\n}\nfun MutableMap.counting(n: Long) {\n repeat(n.toInt()) {\n val a = next()\n if (this.containsKey(a)) this[a] = this[a]!! + 1\n else this[a] = 1\n }\n}\nfun MutableMap.longCounting(n: Long) {\n repeat(n.toInt()) {\n val a = nextLong()\n if (this.containsKey(a)) this[a] = this[a]!! + 1\n else this[a] = 1\n }\n}\n\n// Mathematics\nfun abs(n: Long): Long = Math.abs(n)\nfun abs(n: Double): Double = Math.abs(n)\nfun max(vararg values: Long) = if (values.isEmpty()) -INF else values.max()!!\nfun min(vararg values: Long) = if (values.isEmpty()) INF else values.min()!!\ntailrec fun gcd(a: Long, b: Long): Long = if (b == 0L) a else if (a % b == 0L) b else gcd(b, (a % b))\nfun lcm(a: Long, b: Long): Long = a / gcd(a, b) * b\nfun modpow(a: Long, n: Long, p: Long = MOD): Long {\n var res = 1L\n var ar = a\n var nr = n\n while (nr > 0) {\n if ((nr and 1) == 1L) res = res * ar % p\n ar = ar * ar % p\n nr = nr shr 1\n }\n return res\n}\nfun modinv(a: Long, p: Long = MOD): Long = modpow(a, p - 2, p)\nfun ncr(n: Long, r: Long): Long {\n var a = 1L\n var b = 1L\n for (i in 1..r) {\n a = a * (n + 1 - i) % MOD\n b = b * i % MOD\n }\n return modinv(b, MOD) * a % MOD\n}\n\nclass Combination(private val max: Long) {\n private val fac = longAry(max)\n private val finv = longAry(max)\n private val inv = longAry(max)\n private val p = MOD\n fun init() {\n fac[0] = 1\n fac[1] = 1\n finv[0] = 1\n finv[1] = 1\n inv[1] = 1\n for (i in 2 until max) {\n fac[i] = fac[i - 1] * i % p\n inv[i] = p - inv[p % i] * (p / i) % p;\n finv[i] = finv[i - 1] * inv[i] % p\n }\n }\n\n fun com(n: Long, r: Long): Long = if (n < r || (n < 0 || r < 0)) 0L else fac[n] * (finv[r] * finv[n - r] % p) % p\n}\n\nclass Permutation(private val n: Long, private var searched: Long = 0L, private var nextIndex: Long = 0L) {\n private val size = fact(n)\n private val permList = longAry2(size, n)\n\n private tailrec fun fact(n: Long, ans: Long = 1L): Long {\n return if (n == 0L) ans\n else fact(n - 1, ans * n)\n }\n\n fun init() {\n create(0, longAry(n), boolAry(n))\n }\n\n private fun create(num: Long, list: LongArray, flag: Array) {\n if (num == n) {\n permList[searched] = list.copyOf()\n searched++\n }\n for (i in 0 until n) {\n if (flag[i]) continue\n list[num] = i\n flag[i] = true\n create(num + 1, list, flag)\n flag[i] = false\n }\n }\n\n fun hasNext(): Boolean {\n return if (nextIndex < size) {\n true\n } else {\n nextIndex = 0\n false\n }\n }\n\n fun nextPerm(): LongArray = permList[nextIndex++]\n}\n\n// Graph\ndata class Node(val id: Long, var past: Long = -1, val edges: MutableList = mutableListOf())\ndata class Edge(val from: Long, val to: Long, val cost: Long = 1L)\n\nfun dfs(nodes: Array, now: Long, seen: Array) {\n seen[now] = true\n for (edge in nodes[now].edges) {\n if (seen[edge.to]) continue\n dfs(nodes, edge.to, seen)\n }\n}\n\nfun bfs(nodes: Array, start: Long): LongArray {\n val queue = ArrayDeque()\n queue.add(start)\n val dist = longAry(nodes.size.toLong(), -1L)\n dist[start] = 0L\n while (queue.isNotEmpty()) {\n val now = queue.poll()\n for (edge in nodes[now].edges) {\n if (dist[edge.to] != -1L) continue\n dist[edge.to] = dist[now] + 1\n queue.add(edge.to)\n }\n }\n return dist\n}\n\nfun dijkstra(nodes: Array, start: Long): LongArray {\n val queue = PriorityQueue(16) { e1: Edge, e2: Edge ->\n return@PriorityQueue when {\n e1.cost < e2.cost -> -1\n e2.cost > e1.cost -> 1\n else -> 0\n }\n }\n queue.add(Edge(start, start, 0L))\n val dist = longAry(nodes.size.toLong(), INF / 2)\n dist[start] = 0\n while (queue.isNotEmpty()) {\n val now = queue.poll()\n if (dist[now.to] < now.cost) continue;\n for (edge in nodes[now.to].edges) {\n if (dist[edge.to] <= dist[edge.from] + edge.cost) continue\n dist[edge.to] = dist[edge.from] + edge.cost\n queue.add(Edge(edge.from, edge.to, dist[edge.to]))\n nodes[edge.to].past = edge.from\n }\n }\n return dist\n}\n\n// Data Structure\nclass UnionFind(size: Long) {\n private val par = LongArray(size.toInt()) { it.toLong() }\n private val size = longAry(size, 1L)\n fun root(x: Long): Long {\n return if (par[x] == x) {\n x\n } else {\n par[x] = root(par[x])\n par[x]\n }\n }\n\n fun same(x: Long, y: Long): Boolean = root(x) == root(y)\n fun unite(x: Long, y: Long) {\n var a = root(x)\n var b = root(y)\n if (a == b) return\n if (size[a] < size[b]) {\n var tmp = a\n a = b\n b = tmp\n }\n size[a] += size[b]\n par[b] = a\n }\n\n fun size(x: Long): Long = size[root(x)]\n}\n\nclass SegmentTree(\n private val a: LongArray,\n private val op: (Long, Long) -> Long,\n private val def: Long = 0,\n private val size: Int = a.size,\n private val n: Int = Integer.highestOneBit(size) shl 1\n) {\n private val nodes = longAry(2L * n - 1, def)\n\n fun init() {\n for (i in 0 until size) nodes[i + n - 1] = a[i]\n for (i in n - 2 downTo 0) nodes[i] = calc(nodes[2 * i + 1], nodes[2 * i + 2], op)\n }\n\n fun update(x: Long, value: Long) {\n var index = x + n - 1\n nodes[index] = value\n while (index > 0) {\n index = (index - 1) / 2\n nodes[index] = calc(nodes[2 * index + 1], nodes[2 * index + 2], op)\n }\n }\n\n fun get(a: Long, b: Long) = getSub(a, b, 0L, 0L, n.toLong())\n private fun getSub(a: Long, b: Long, k: Long, l: Long, r: Long): Long {\n return when {\n r <= a || b <= l -> def\n a <= l && r <= b -> nodes[k]\n else -> {\n val vl = getSub(a, b, k * 2 + 1, l, (l + r) / 2)\n val vr = getSub(a, b, k * 2 + 2, (l + r) / 2, r)\n calc(vl, vr, op)\n }\n }\n }\n\n fun joinToString(separator: String) = nodes.drop(n - 1).take(size).joinToString(separator)\n}\n\n// Scanner\nclass FastScanner {\n private val sin: InputStream = System.`in`\n private val buffer: ByteArray = ByteArray(1024) { 0 }\n private var ptr = 0\n private var buflen = 0\n\n private fun hasNextByte(): Boolean {\n return when {\n ptr < buflen -> true\n else -> {\n ptr = 0\n buflen = sin.read(buffer)\n if (buflen <= 0) false\n true\n }\n }\n }\n\n private fun readByte(): Int {\n return when {\n hasNextByte() -> buffer[ptr++].toInt()\n else -> -1\n }\n }\n\n private fun isPrintableChar(c: Int) = c in 33..126\n\n fun hasNext(): Boolean {\n while (hasNextByte() && !isPrintableChar(buffer[ptr].toInt())) ptr++\n return hasNextByte()\n }\n\n fun next(): String {\n if (!hasNext()) throw NoSuchElementException()\n val sb = StringBuilder()\n var b = readByte()\n while (isPrintableChar(b)) {\n sb.appendCodePoint(b)\n b = readByte()\n }\n return sb.toString()\n }\n\n fun nextLong(): Long {\n if (!hasNext()) throw NoSuchElementException()\n var n = 0L\n var minus = false\n var b = readByte()\n if (b.toChar() == '-') {\n minus = true\n b = readByte()\n }\n if (b.toChar() !in '0'..'9') throw NumberFormatException()\n while (true) {\n when {\n b.toChar() in '0'..'9' -> {\n n *= 10\n n += b.toChar() - '0'\n }\n b == -1 || !isPrintableChar(b) -> return if (minus) -n else n\n else -> throw NumberFormatException()\n }\n b = readByte()\n }\n }\n\n// \"The world doesn't need you.\"\n//\n// fun nextInt(): Int {\n// val nl = nextLong()\n// if (nl !in Int.MIN_VALUE..Int.MAX_VALUE) throw NumberFormatException()\n// return nl.toInt()\n// }\n}\n", "language": "Kotlin", "metadata": {"date": 1588511040, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03437.html", "problem_id": "p03437", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03437/input.txt", "sample_output_relpath": "derived/input_output/data/p03437/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03437/Kotlin/s393950347.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s393950347", "user_id": "u581625805"}, "prompt_components": {"gold_output": "16\n", "input_to_evaluate": "import java.io.*\nimport java.lang.*\nimport java.math.BigDecimal\nimport java.util.*\n\n// Constant\nval sc = FastScanner()\nval pw = PrintWriter(System.out)\nconst val MOD = 1000000007L\nconst val INF = 9223372036854775807L\n\n// Main\nfun main(args: Array) {\n solve()\n pw.flush()\n}\n\nfun solve() {\n val x = nextLong()\n val y = nextLong()\n\n when {\n x % y == 0L -> println(-1)\n else -> println(x)\n }\n\n\n}\n\n\n\n// Rule\noperator fun String.get(index: Long): Char {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun CharArray.get(index: Long): Char {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun CharArray.set(index: Long, value: Char) {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n this[index.toInt()] = value\n}\noperator fun LongArray.get(index: Long): Long {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun LongArray.set(index: Long, value: Long) {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n this[index.toInt()] = value\n}\noperator fun DoubleArray.get(index: Long): Double {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun DoubleArray.set(index: Long, value: Double) {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n this[index.toInt()] = value\n}\noperator fun Array.get(index: Long): T {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun Array.set(index: Long, value: T) {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n this[index.toInt()] = value\n}\noperator fun MutableList.get(index: Long): T {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun MutableList.set(index: Long, value: T) {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n this[index.toInt()] = value\n}\n\nval LongArray.siz: Long\n get() = size.toLong()\nval Array.siz: Long\n get() = size.toLong()\nval MutableList.siz: Long\n get() = size.toLong()\nval MutableSet.siz: Long\n get() = size.toLong()\nval String.len: Long\n get() = length.toLong()\n\n// Output\nfun println(v: String) {\n pw.println(v)\n}\nfun print(v: String) {\n pw.print(v)\n}\n\n// Input\nfun next() = sc.next()\nfun nextLong() = sc.nextLong()\nfun nextDouble() = next().toDouble()\nfun nextAry(n: Long): Array {\n val ary = ary(n)\n for (i in 0 until n) ary[i] = next()\n return ary\n}\nfun nextLongAry(n: Long): LongArray {\n val ary = longAry(n)\n for (i in 0 until n) ary[i] = nextLong()\n return ary\n}\nfun nextDoubleAry(n: Long): DoubleArray {\n val ary = doubleAry(n)\n for (i in 0 until n) ary[i] = nextDouble()\n return ary\n}\n\n// Statement\nfun ary(n: Long, init: String = \"\") = Array(n.toInt()) { init }\nfun longAry(n: Long, init: Long = 0L) = LongArray(n.toInt()) { init }\nfun doubleAry(n: Long, init: Double = 0.0) = DoubleArray(n.toInt()) { init }\nfun boolAry(n: Long, init: Boolean = false) = Array(n.toInt()) { init }\nfun ary2(n: Long, m: Long, init: String = \"\") = Array(n.toInt()) { ary(m, init) }\nfun longAry2(n: Long, m: Long, init: Long = 0) = Array(n.toInt()) { longAry(m, init) }\nfun doubleAry2(n: Long, m: Long, init: Double = 0.0) = Array(n.toInt()) { doubleAry(m, init) }\nfun boolAry2(n: Long, m: Long, init: Boolean = false) = Array(n.toInt()) { boolAry(m, init) }\nfun ary3(n: Long, m: Long, k: Long, init: String = \"\") = Array(n.toInt()) { ary2(m, k, init) }\nfun longAry3(n: Long, m: Long, k: Long, init: Long = 0L) = Array(n.toInt()) { longAry2(m, k, init) }\nfun doubleAry3(n: Long, m: Long, k: Long, init: Double = 0.0) = Array(n.toInt()) { doubleAry2(m, k, init) }\nfun boolAry3(n: Long, m: Long, k: Long, init: Boolean = false) = Array(n.toInt()) { boolAry2(m, k, init) }\nfun list() = mutableListOf()\nfun longList() = mutableListOf()\nfun doubleList() = mutableListOf()\nfun strSet() = mutableSetOf()\nfun longSet() = mutableSetOf()\nfun doubleSet() = mutableSetOf()\nfun map() = mutableMapOf()\n\n// Monoid\nval addFunc = {a: Long, b: Long -> a + b}\nval mulFunc = {a: Long, b: Long -> a * b}\nval maxFunc = {a: Long, b: Long -> max(a, b)}\nval minFunc = {a: Long, b: Long -> min(a, b)}\nval gcdFunc = {a: Long, b: Long -> gcd(a, b)}\nval lcmFunc = {a: Long, b: Long -> lcm(a, b)}\nval xorFunc = {a: Long, b: Long -> a xor b}\nfun calc(a: Long, b: Long, op: (Long, Long) -> Long) = op(a, b)\n\n// Extension\nfun LongArray.lowerBound(n: Long): Long {\n var ok = this.size.toLong()\n var ng = -1L\n while (abs(ok - ng) > 1) {\n val mid = (ok + ng) / 2\n if (this[mid] >= n) ok = mid\n else ng = mid\n }\n return ok\n}\nfun DoubleArray.lowerBound(n: Double): Long {\n var ok = this.size.toLong()\n var ng = -1L\n while (abs(ok - ng) > 1) {\n val mid = (ok + ng) / 2\n if (this[mid] >= n) ok = mid\n else ng = mid\n }\n return ok\n}\nfun MutableList.longLowerBound(n: Long): Long {\n var ok = this.size.toLong()\n var ng = -1L\n while (abs(ok - ng) > 1) {\n val mid = (ok + ng) / 2\n if (this[mid] >= n) ok = mid\n else ng = mid\n }\n return ok\n}\nfun MutableList.doubleLowerBound(n: Double): Long {\n var ok = this.size.toLong()\n var ng = -1L\n while (abs(ok - ng) > 1) {\n val mid = (ok + ng) / 2\n if (this[mid] >= n) ok = mid\n else ng = mid\n }\n return ok\n}\nfun LongArray.cumsum(op: (Long, Long) -> Long): LongArray {\n val s = longAry(this.size + 1L)\n s[1] = this[0]\n for (i in 1 until this.size) s[i + 1] = calc(s[i], this[i], op)\n return s\n}\nfun MutableMap.counting(n: Long) {\n repeat(n.toInt()) {\n val a = next()\n if (this.containsKey(a)) this[a] = this[a]!! + 1\n else this[a] = 1\n }\n}\nfun MutableMap.longCounting(n: Long) {\n repeat(n.toInt()) {\n val a = nextLong()\n if (this.containsKey(a)) this[a] = this[a]!! + 1\n else this[a] = 1\n }\n}\n\n// Mathematics\nfun abs(n: Long): Long = Math.abs(n)\nfun abs(n: Double): Double = Math.abs(n)\nfun max(vararg values: Long) = if (values.isEmpty()) -INF else values.max()!!\nfun min(vararg values: Long) = if (values.isEmpty()) INF else values.min()!!\ntailrec fun gcd(a: Long, b: Long): Long = if (b == 0L) a else if (a % b == 0L) b else gcd(b, (a % b))\nfun lcm(a: Long, b: Long): Long = a / gcd(a, b) * b\nfun modpow(a: Long, n: Long, p: Long = MOD): Long {\n var res = 1L\n var ar = a\n var nr = n\n while (nr > 0) {\n if ((nr and 1) == 1L) res = res * ar % p\n ar = ar * ar % p\n nr = nr shr 1\n }\n return res\n}\nfun modinv(a: Long, p: Long = MOD): Long = modpow(a, p - 2, p)\nfun ncr(n: Long, r: Long): Long {\n var a = 1L\n var b = 1L\n for (i in 1..r) {\n a = a * (n + 1 - i) % MOD\n b = b * i % MOD\n }\n return modinv(b, MOD) * a % MOD\n}\n\nclass Combination(private val max: Long) {\n private val fac = longAry(max)\n private val finv = longAry(max)\n private val inv = longAry(max)\n private val p = MOD\n fun init() {\n fac[0] = 1\n fac[1] = 1\n finv[0] = 1\n finv[1] = 1\n inv[1] = 1\n for (i in 2 until max) {\n fac[i] = fac[i - 1] * i % p\n inv[i] = p - inv[p % i] * (p / i) % p;\n finv[i] = finv[i - 1] * inv[i] % p\n }\n }\n\n fun com(n: Long, r: Long): Long = if (n < r || (n < 0 || r < 0)) 0L else fac[n] * (finv[r] * finv[n - r] % p) % p\n}\n\nclass Permutation(private val n: Long, private var searched: Long = 0L, private var nextIndex: Long = 0L) {\n private val size = fact(n)\n private val permList = longAry2(size, n)\n\n private tailrec fun fact(n: Long, ans: Long = 1L): Long {\n return if (n == 0L) ans\n else fact(n - 1, ans * n)\n }\n\n fun init() {\n create(0, longAry(n), boolAry(n))\n }\n\n private fun create(num: Long, list: LongArray, flag: Array) {\n if (num == n) {\n permList[searched] = list.copyOf()\n searched++\n }\n for (i in 0 until n) {\n if (flag[i]) continue\n list[num] = i\n flag[i] = true\n create(num + 1, list, flag)\n flag[i] = false\n }\n }\n\n fun hasNext(): Boolean {\n return if (nextIndex < size) {\n true\n } else {\n nextIndex = 0\n false\n }\n }\n\n fun nextPerm(): LongArray = permList[nextIndex++]\n}\n\n// Graph\ndata class Node(val id: Long, var past: Long = -1, val edges: MutableList = mutableListOf())\ndata class Edge(val from: Long, val to: Long, val cost: Long = 1L)\n\nfun dfs(nodes: Array, now: Long, seen: Array) {\n seen[now] = true\n for (edge in nodes[now].edges) {\n if (seen[edge.to]) continue\n dfs(nodes, edge.to, seen)\n }\n}\n\nfun bfs(nodes: Array, start: Long): LongArray {\n val queue = ArrayDeque()\n queue.add(start)\n val dist = longAry(nodes.size.toLong(), -1L)\n dist[start] = 0L\n while (queue.isNotEmpty()) {\n val now = queue.poll()\n for (edge in nodes[now].edges) {\n if (dist[edge.to] != -1L) continue\n dist[edge.to] = dist[now] + 1\n queue.add(edge.to)\n }\n }\n return dist\n}\n\nfun dijkstra(nodes: Array, start: Long): LongArray {\n val queue = PriorityQueue(16) { e1: Edge, e2: Edge ->\n return@PriorityQueue when {\n e1.cost < e2.cost -> -1\n e2.cost > e1.cost -> 1\n else -> 0\n }\n }\n queue.add(Edge(start, start, 0L))\n val dist = longAry(nodes.size.toLong(), INF / 2)\n dist[start] = 0\n while (queue.isNotEmpty()) {\n val now = queue.poll()\n if (dist[now.to] < now.cost) continue;\n for (edge in nodes[now.to].edges) {\n if (dist[edge.to] <= dist[edge.from] + edge.cost) continue\n dist[edge.to] = dist[edge.from] + edge.cost\n queue.add(Edge(edge.from, edge.to, dist[edge.to]))\n nodes[edge.to].past = edge.from\n }\n }\n return dist\n}\n\n// Data Structure\nclass UnionFind(size: Long) {\n private val par = LongArray(size.toInt()) { it.toLong() }\n private val size = longAry(size, 1L)\n fun root(x: Long): Long {\n return if (par[x] == x) {\n x\n } else {\n par[x] = root(par[x])\n par[x]\n }\n }\n\n fun same(x: Long, y: Long): Boolean = root(x) == root(y)\n fun unite(x: Long, y: Long) {\n var a = root(x)\n var b = root(y)\n if (a == b) return\n if (size[a] < size[b]) {\n var tmp = a\n a = b\n b = tmp\n }\n size[a] += size[b]\n par[b] = a\n }\n\n fun size(x: Long): Long = size[root(x)]\n}\n\nclass SegmentTree(\n private val a: LongArray,\n private val op: (Long, Long) -> Long,\n private val def: Long = 0,\n private val size: Int = a.size,\n private val n: Int = Integer.highestOneBit(size) shl 1\n) {\n private val nodes = longAry(2L * n - 1, def)\n\n fun init() {\n for (i in 0 until size) nodes[i + n - 1] = a[i]\n for (i in n - 2 downTo 0) nodes[i] = calc(nodes[2 * i + 1], nodes[2 * i + 2], op)\n }\n\n fun update(x: Long, value: Long) {\n var index = x + n - 1\n nodes[index] = value\n while (index > 0) {\n index = (index - 1) / 2\n nodes[index] = calc(nodes[2 * index + 1], nodes[2 * index + 2], op)\n }\n }\n\n fun get(a: Long, b: Long) = getSub(a, b, 0L, 0L, n.toLong())\n private fun getSub(a: Long, b: Long, k: Long, l: Long, r: Long): Long {\n return when {\n r <= a || b <= l -> def\n a <= l && r <= b -> nodes[k]\n else -> {\n val vl = getSub(a, b, k * 2 + 1, l, (l + r) / 2)\n val vr = getSub(a, b, k * 2 + 2, (l + r) / 2, r)\n calc(vl, vr, op)\n }\n }\n }\n\n fun joinToString(separator: String) = nodes.drop(n - 1).take(size).joinToString(separator)\n}\n\n// Scanner\nclass FastScanner {\n private val sin: InputStream = System.`in`\n private val buffer: ByteArray = ByteArray(1024) { 0 }\n private var ptr = 0\n private var buflen = 0\n\n private fun hasNextByte(): Boolean {\n return when {\n ptr < buflen -> true\n else -> {\n ptr = 0\n buflen = sin.read(buffer)\n if (buflen <= 0) false\n true\n }\n }\n }\n\n private fun readByte(): Int {\n return when {\n hasNextByte() -> buffer[ptr++].toInt()\n else -> -1\n }\n }\n\n private fun isPrintableChar(c: Int) = c in 33..126\n\n fun hasNext(): Boolean {\n while (hasNextByte() && !isPrintableChar(buffer[ptr].toInt())) ptr++\n return hasNextByte()\n }\n\n fun next(): String {\n if (!hasNext()) throw NoSuchElementException()\n val sb = StringBuilder()\n var b = readByte()\n while (isPrintableChar(b)) {\n sb.appendCodePoint(b)\n b = readByte()\n }\n return sb.toString()\n }\n\n fun nextLong(): Long {\n if (!hasNext()) throw NoSuchElementException()\n var n = 0L\n var minus = false\n var b = readByte()\n if (b.toChar() == '-') {\n minus = true\n b = readByte()\n }\n if (b.toChar() !in '0'..'9') throw NumberFormatException()\n while (true) {\n when {\n b.toChar() in '0'..'9' -> {\n n *= 10\n n += b.toChar() - '0'\n }\n b == -1 || !isPrintableChar(b) -> return if (minus) -n else n\n else -> throw NumberFormatException()\n }\n b = readByte()\n }\n }\n\n// \"The world doesn't need you.\"\n//\n// fun nextInt(): Int {\n// val nl = nextLong()\n// if (nl !in Int.MIN_VALUE..Int.MAX_VALUE) throw NumberFormatException()\n// return nl.toInt()\n// }\n}\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nYou are given positive integers X and Y.\nIf there exists a positive integer not greater than 10^{18} that is a multiple of X but not a multiple of Y, choose one such integer and print it.\nIf it does not exist, print -1.\n\nConstraints\n\n1 ≤ X,Y ≤ 10^9\n\nX and Y are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX Y\n\nOutput\n\nPrint a positive integer not greater than 10^{18} that is a multiple of X but not a multiple of Y, or print -1 if it does not exist.\n\nSample Input 1\n\n8 6\n\nSample Output 1\n\n16\n\nFor example, 16 is a multiple of 8 but not a multiple of 6.\n\nSample Input 2\n\n3 3\n\nSample Output 2\n\n-1\n\nA multiple of 3 is a multiple of 3.", "sample_input": "8 6\n"}, "reference_outputs": ["16\n"], "source_document_id": "p03437", "source_text": "Score : 100 points\n\nProblem Statement\n\nYou are given positive integers X and Y.\nIf there exists a positive integer not greater than 10^{18} that is a multiple of X but not a multiple of Y, choose one such integer and print it.\nIf it does not exist, print -1.\n\nConstraints\n\n1 ≤ X,Y ≤ 10^9\n\nX and Y are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX Y\n\nOutput\n\nPrint a positive integer not greater than 10^{18} that is a multiple of X but not a multiple of Y, or print -1 if it does not exist.\n\nSample Input 1\n\n8 6\n\nSample Output 1\n\n16\n\nFor example, 16 is a multiple of 8 but not a multiple of 6.\n\nSample Input 2\n\n3 3\n\nSample Output 2\n\n-1\n\nA multiple of 3 is a multiple of 3.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 14318, "cpu_time_ms": 183, "memory_kb": 29604}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s227114789", "group_id": "codeNet:p03450", "input_text": "import java.util.*\nimport java.io.PrintWriter\n\nval pw = PrintWriter(System.out)\nval MOD = 1000000007L\nval INF = 2147483647\nval LINF = 9223372036854775807L\n\nfun main(args: Array){\n solve()\n pw.flush() \n}\n\nfun solve(){\n val (n, m) = nextIntList()\n val nodes: Array = Array(n) { i -> Node(i)}\n repeat(m) { \n val (l, r, d) = nextIntList()\n nodes[l - 1].edges.add(Edge(l - 1, r - 1, d.toLong()))\n nodes[r - 1].edges.add(Edge(r - 1, l - 1, -1L * d))\n }\n\n val seen: Array = Array(n) { false }\n for (node in nodes) {\n if(seen[node.id]) continue\n node.past = 0\n if(dfs(nodes, node.id, seen)){\n println(\"No\")\n return\n }\n }\n println(\"Yes\")\n}\n\nfun dfs(nodes: Array, now: Int, seen: Array) : Boolean {\n seen[now] = true\n for (edge in nodes[now].edges) {\n if(nodes[edge.to].past != -LINF && nodes[edge.to].past - nodes[now].past != edge.cost){\n return true\n }\n if(seen[edge.to]) continue\n nodes[edge.to].past = nodes[now].past + edge.cost\n dfs(nodes, edge.to, seen)\n }\n return false\n}\n\n// Print\nfun println(v: String){\n pw.println(v)\n}\nfun print(v: String){\n pw.print(v)\n}\n\n// Read\nfun next() = readLine()!!\nfun nextInt() = next().toInt()\nfun nextLong() = next().toLong()\nfun nextDouble() = next().toDouble()\nfun nextList() = next().split(\" \")\nfun nextIntList() = next().split(\" \").map{ it.toInt() }\nfun nextLongList() = next().split(\" \").map{ it.toLong() }\nfun nextDoubleList() = next().split(\" \").map{ it.toDouble() }\nfun nextAryln(n: Int) = Array(n){ next() }\nfun nextIntAryln(n: Int) = IntArray(n){ nextInt() }\nfun nextLongAryln(n: Int) = LongArray(n){ nextLong() }\nfun nextDoubleAryln(n: Int) = DoubleArray(n) { nextDouble() }\n\n// Math\nfun abs(n: Long) : Long = Math.abs(n)\nfun max(a: Long = -LINF, b: Long = -LINF, c: Long = -LINF, d: Long = -LINF, e: Long = -LINF): Long = listOf(a, b, c, d, e).max()!!.toLong()\nfun min(a: Long = LINF, b: Long = LINF, c: Long = LINF, d: Long = LINF, e: Long = LINF): Long = listOf(a, b, c, d, e).min()!!.toLong()\nfun prime(from: Long, to: Long = from) : List{\n return (from..to).filter{ i ->\n val max = Math.sqrt(i.toDouble()).toLong()\n (2..max).all{ j -> i % j != 0L}\n }\n}\nfun gcd(a: Long, b: Long) : Long = if(a % b == 0L) b else gcd(b, (a % b))\nfun lcm(a: Long, b: Long) : Long = a / gcd(a, b) * b\nfun modpow(a: Long, n: Long, p:Long = MOD) : Long {\n var res = 1L\n var ar = a\n var nr = n\n while(nr > 0){\n if((nr and 1) == 1L) res = res * ar % p\n ar = ar * ar % p\n nr = nr shr 1\n }\n return res\n}\nfun modinv(a: Long, p: Long = MOD) : Long = modpow(a, p - 2, p)\nfun ncr(n: Long, r: Long) : Long {\n var a = 1L\n var b = 1L\n for (i in 1..r) {\n a = a * (n + 1 - i) % MOD\n b = b * i % MOD\n }\n return modinv(b, MOD) * a % MOD\n}\n\ndata class Node(val id: Int, var past: Long = -LINF, var edges: MutableList = mutableListOf())\ndata class Edge(val from: Int, val to: Int, val cost: Long = 1L)", "language": "Kotlin", "metadata": {"date": 1584750417, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03450.html", "problem_id": "p03450", "resource_group": "medium_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/Kotlin/s227114789.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s227114789", "user_id": "u581625805"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "import java.util.*\nimport java.io.PrintWriter\n\nval pw = PrintWriter(System.out)\nval MOD = 1000000007L\nval INF = 2147483647\nval LINF = 9223372036854775807L\n\nfun main(args: Array){\n solve()\n pw.flush() \n}\n\nfun solve(){\n val (n, m) = nextIntList()\n val nodes: Array = Array(n) { i -> Node(i)}\n repeat(m) { \n val (l, r, d) = nextIntList()\n nodes[l - 1].edges.add(Edge(l - 1, r - 1, d.toLong()))\n nodes[r - 1].edges.add(Edge(r - 1, l - 1, -1L * d))\n }\n\n val seen: Array = Array(n) { false }\n for (node in nodes) {\n if(seen[node.id]) continue\n node.past = 0\n if(dfs(nodes, node.id, seen)){\n println(\"No\")\n return\n }\n }\n println(\"Yes\")\n}\n\nfun dfs(nodes: Array, now: Int, seen: Array) : Boolean {\n seen[now] = true\n for (edge in nodes[now].edges) {\n if(nodes[edge.to].past != -LINF && nodes[edge.to].past - nodes[now].past != edge.cost){\n return true\n }\n if(seen[edge.to]) continue\n nodes[edge.to].past = nodes[now].past + edge.cost\n dfs(nodes, edge.to, seen)\n }\n return false\n}\n\n// Print\nfun println(v: String){\n pw.println(v)\n}\nfun print(v: String){\n pw.print(v)\n}\n\n// Read\nfun next() = readLine()!!\nfun nextInt() = next().toInt()\nfun nextLong() = next().toLong()\nfun nextDouble() = next().toDouble()\nfun nextList() = next().split(\" \")\nfun nextIntList() = next().split(\" \").map{ it.toInt() }\nfun nextLongList() = next().split(\" \").map{ it.toLong() }\nfun nextDoubleList() = next().split(\" \").map{ it.toDouble() }\nfun nextAryln(n: Int) = Array(n){ next() }\nfun nextIntAryln(n: Int) = IntArray(n){ nextInt() }\nfun nextLongAryln(n: Int) = LongArray(n){ nextLong() }\nfun nextDoubleAryln(n: Int) = DoubleArray(n) { nextDouble() }\n\n// Math\nfun abs(n: Long) : Long = Math.abs(n)\nfun max(a: Long = -LINF, b: Long = -LINF, c: Long = -LINF, d: Long = -LINF, e: Long = -LINF): Long = listOf(a, b, c, d, e).max()!!.toLong()\nfun min(a: Long = LINF, b: Long = LINF, c: Long = LINF, d: Long = LINF, e: Long = LINF): Long = listOf(a, b, c, d, e).min()!!.toLong()\nfun prime(from: Long, to: Long = from) : List{\n return (from..to).filter{ i ->\n val max = Math.sqrt(i.toDouble()).toLong()\n (2..max).all{ j -> i % j != 0L}\n }\n}\nfun gcd(a: Long, b: Long) : Long = if(a % b == 0L) b else gcd(b, (a % b))\nfun lcm(a: Long, b: Long) : Long = a / gcd(a, b) * b\nfun modpow(a: Long, n: Long, p:Long = MOD) : Long {\n var res = 1L\n var ar = a\n var nr = n\n while(nr > 0){\n if((nr and 1) == 1L) res = res * ar % p\n ar = ar * ar % p\n nr = nr shr 1\n }\n return res\n}\nfun modinv(a: Long, p: Long = MOD) : Long = modpow(a, p - 2, p)\nfun ncr(n: Long, r: Long) : Long {\n var a = 1L\n var b = 1L\n for (i in 1..r) {\n a = a * (n + 1 - i) % MOD\n b = b * i % MOD\n }\n return modinv(b, MOD) * a % MOD\n}\n\ndata class Node(val id: Int, var past: Long = -LINF, var edges: MutableList = mutableListOf())\ndata class Edge(val from: Int, val to: Int, val cost: Long = 1L)", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 3115, "cpu_time_ms": 1175, "memory_kb": 120736}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s071349159", "group_id": "codeNet:p03453", "input_text": "import java.util.*\n\nval DEBUG = false\n\ndata class FiniteField(val x: Long) {\n val p = 1000000007L\n operator fun plus(o: FiniteField) = FiniteField((x + o.x) % p)\n operator fun minus(o: FiniteField) = FiniteField((x + p - o.x) % p)\n operator fun times(o: FiniteField) = FiniteField((x * o.x) % p)\n}\n\ndata class Edge(val from: Int, val to: Int, val cost: Long)\n\ndata class State(val v: Int, val cost: Long)\n\nfun compareState(s1: State, s2: State): Int {\n if (s1.cost > s2.cost) return 1\n if (s1.cost < s2.cost) return -1\n return 0\n}\n\nfun main(args: Array) {\n val (n, m) = readLine()!!.split(\" \").map(String::toInt)\n val (sRaw, tRaw) = readLine()!!.split(\" \").map(String::toInt)\n val s = sRaw - 1\n val t = tRaw - 1\n val graph = Array(n, { mutableListOf() })\n repeat(m) {\n val (uRaw, vRaw, dInt) = readLine()!!.split(\" \").map(String::toInt)\n val u = uRaw - 1\n val v = vRaw - 1\n val d = dInt.toLong()\n graph[u].add(Edge(u, v, d))\n graph[v].add(Edge(v, u, d))\n }\n\n // Dijkstra from s\n val pq = PriorityQueue(11, { s1: State, s2: State -> compareState(s1, s2) })\n val dist = LongArray(n, { -1L })\n pq.add(State(s, 0L))\n while (pq.isNotEmpty()) {\n val state = pq.poll()!!\n if (dist[state.v] >= 0) continue\n dist[state.v] = state.cost\n for (e in graph[state.v]) {\n if (dist[e.to] < 0) {\n pq.add(State(e.to, state.cost + e.cost))\n }\n }\n }\n if (DEBUG) println(\"dist: ${dist.toList()}\")\n\n val sGraph = Array(n, { mutableListOf() })\n val tGraph = Array(n, { mutableListOf() })\n\n val stack = Stack()\n stack.push(t)\n val visited = BooleanArray(n)\n while (stack.isNotEmpty()) {\n val v = stack.pop()!!\n if (visited[v]) continue\n visited[v] = true\n if (DEBUG) println(\"v: $v\")\n for (e in graph[v]) {\n if (dist[v] == dist[e.to] + e.cost) {\n tGraph[v].add(e.to)\n sGraph[e.to].add(v)\n stack.push(e.to)\n }\n }\n }\n// for (v in 0 until n) {\n// for (e in graph[v]) {\n// if (dist[v] + e.cost == dist[e.to]) {\n// tGraph[e.to].add(v)\n// sGraph[v].add(e.to)\n// }\n// }\n// }\n if (DEBUG) println(\"sGraph: ${sGraph.toList()}\")\n if (DEBUG) println(\"tGraph: ${tGraph.toList()}\")\n\n val sCount = Array(n, { FiniteField(0) })\n sCount[s] = FiniteField(1)\n val sSorted = dist.withIndex().sortedBy { it.value }.map { it.index }\n fillCount(s, sGraph, sSorted, sCount)\n if (DEBUG) println(\"sCount: ${sCount.toList()}\")\n\n val tCount = Array(n, { FiniteField(0) })\n tCount[t] = FiniteField(1)\n val tSorted = sSorted.reversed()\n fillCount(t, tGraph, tSorted, tCount)\n if (DEBUG) println(\"tCount: ${tCount.toList()}\")\n\n var ans = sCount[t] * tCount[s]\n if (DEBUG) println(\"ans STEP 1: $ans\")\n val totalDist = dist[t]\n // Meet on vertex\n for (v in 0 until n) {\n if (dist[v] * 2 == totalDist) {\n ans -= sCount[v] * sCount[v] * tCount[v] * tCount[v]\n }\n }\n if (DEBUG) println(\"ans STEP 2: $ans\")\n\n // Meet on edge\n for (v in 0 until n) {\n for (e in graph[v]) {\n if (dist[v] + e.cost == dist[e.to] && dist[v] * 2 < totalDist && dist[e.to] * 2 > totalDist) {\n ans -= sCount[v] * sCount[v] * tCount[e.to] * tCount[e.to]\n }\n }\n }\n if (DEBUG) println(\"ans STEP 3: $ans\")\n\n println(ans.x)\n}\n\nfun fillCount(r: Int, graph: Array>, tSorted: List, count: Array) {\n for (v in tSorted) {\n for (u in graph[v]) {\n count[u] += count[v]\n }\n }\n}", "language": "Kotlin", "metadata": {"date": 1519251789, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03453.html", "problem_id": "p03453", "resource_group": "medium_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/Kotlin/s071349159.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s071349159", "user_id": "u771276542"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import java.util.*\n\nval DEBUG = false\n\ndata class FiniteField(val x: Long) {\n val p = 1000000007L\n operator fun plus(o: FiniteField) = FiniteField((x + o.x) % p)\n operator fun minus(o: FiniteField) = FiniteField((x + p - o.x) % p)\n operator fun times(o: FiniteField) = FiniteField((x * o.x) % p)\n}\n\ndata class Edge(val from: Int, val to: Int, val cost: Long)\n\ndata class State(val v: Int, val cost: Long)\n\nfun compareState(s1: State, s2: State): Int {\n if (s1.cost > s2.cost) return 1\n if (s1.cost < s2.cost) return -1\n return 0\n}\n\nfun main(args: Array) {\n val (n, m) = readLine()!!.split(\" \").map(String::toInt)\n val (sRaw, tRaw) = readLine()!!.split(\" \").map(String::toInt)\n val s = sRaw - 1\n val t = tRaw - 1\n val graph = Array(n, { mutableListOf() })\n repeat(m) {\n val (uRaw, vRaw, dInt) = readLine()!!.split(\" \").map(String::toInt)\n val u = uRaw - 1\n val v = vRaw - 1\n val d = dInt.toLong()\n graph[u].add(Edge(u, v, d))\n graph[v].add(Edge(v, u, d))\n }\n\n // Dijkstra from s\n val pq = PriorityQueue(11, { s1: State, s2: State -> compareState(s1, s2) })\n val dist = LongArray(n, { -1L })\n pq.add(State(s, 0L))\n while (pq.isNotEmpty()) {\n val state = pq.poll()!!\n if (dist[state.v] >= 0) continue\n dist[state.v] = state.cost\n for (e in graph[state.v]) {\n if (dist[e.to] < 0) {\n pq.add(State(e.to, state.cost + e.cost))\n }\n }\n }\n if (DEBUG) println(\"dist: ${dist.toList()}\")\n\n val sGraph = Array(n, { mutableListOf() })\n val tGraph = Array(n, { mutableListOf() })\n\n val stack = Stack()\n stack.push(t)\n val visited = BooleanArray(n)\n while (stack.isNotEmpty()) {\n val v = stack.pop()!!\n if (visited[v]) continue\n visited[v] = true\n if (DEBUG) println(\"v: $v\")\n for (e in graph[v]) {\n if (dist[v] == dist[e.to] + e.cost) {\n tGraph[v].add(e.to)\n sGraph[e.to].add(v)\n stack.push(e.to)\n }\n }\n }\n// for (v in 0 until n) {\n// for (e in graph[v]) {\n// if (dist[v] + e.cost == dist[e.to]) {\n// tGraph[e.to].add(v)\n// sGraph[v].add(e.to)\n// }\n// }\n// }\n if (DEBUG) println(\"sGraph: ${sGraph.toList()}\")\n if (DEBUG) println(\"tGraph: ${tGraph.toList()}\")\n\n val sCount = Array(n, { FiniteField(0) })\n sCount[s] = FiniteField(1)\n val sSorted = dist.withIndex().sortedBy { it.value }.map { it.index }\n fillCount(s, sGraph, sSorted, sCount)\n if (DEBUG) println(\"sCount: ${sCount.toList()}\")\n\n val tCount = Array(n, { FiniteField(0) })\n tCount[t] = FiniteField(1)\n val tSorted = sSorted.reversed()\n fillCount(t, tGraph, tSorted, tCount)\n if (DEBUG) println(\"tCount: ${tCount.toList()}\")\n\n var ans = sCount[t] * tCount[s]\n if (DEBUG) println(\"ans STEP 1: $ans\")\n val totalDist = dist[t]\n // Meet on vertex\n for (v in 0 until n) {\n if (dist[v] * 2 == totalDist) {\n ans -= sCount[v] * sCount[v] * tCount[v] * tCount[v]\n }\n }\n if (DEBUG) println(\"ans STEP 2: $ans\")\n\n // Meet on edge\n for (v in 0 until n) {\n for (e in graph[v]) {\n if (dist[v] + e.cost == dist[e.to] && dist[v] * 2 < totalDist && dist[e.to] * 2 > totalDist) {\n ans -= sCount[v] * sCount[v] * tCount[e.to] * tCount[e.to]\n }\n }\n }\n if (DEBUG) println(\"ans STEP 3: $ans\")\n\n println(ans.x)\n}\n\nfun fillCount(r: Int, graph: Array>, tSorted: List, count: Array) {\n for (v in tSorted) {\n for (u in graph[v]) {\n count[u] += count[v]\n }\n }\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 3478, "cpu_time_ms": 2100, "memory_kb": 185304}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s150518005", "group_id": "codeNet:p03463", "input_text": "//300\nfun a020(args: Array) {\n val (N, A, B) = args[0].split(\" \").map { it.toInt() }\n when {\n A == 1 && B == 2 -> println(\"Borys\")\n A == N && B == N - 1 -> println(\"Borys\")\n Math.abs(A - B) % 2 == 1 -> println(\"Borys\")\n else -> println(\"Alice\")\n }\n}\n\nfun main(args: Array) {\n a020(readLineList())\n}\n\nfun readLineList(): Array {\n val lineList = mutableListOf()\n while (true) {\n val line = readLine()\n if (line.isNullOrBlank()) {\n break\n } else {\n lineList.add(line!!)\n }\n }\n return lineList.toTypedArray()\n}", "language": "Kotlin", "metadata": {"date": 1552355645, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03463.html", "problem_id": "p03463", "resource_group": "medium_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/Kotlin/s150518005.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s150518005", "user_id": "u241874341"}, "prompt_components": {"gold_output": "Alice\n", "input_to_evaluate": "//300\nfun a020(args: Array) {\n val (N, A, B) = args[0].split(\" \").map { it.toInt() }\n when {\n A == 1 && B == 2 -> println(\"Borys\")\n A == N && B == N - 1 -> println(\"Borys\")\n Math.abs(A - B) % 2 == 1 -> println(\"Borys\")\n else -> println(\"Alice\")\n }\n}\n\nfun main(args: Array) {\n a020(readLineList())\n}\n\nfun readLineList(): Array {\n val lineList = mutableListOf()\n while (true) {\n val line = readLine()\n if (line.isNullOrBlank()) {\n break\n } else {\n lineList.add(line!!)\n }\n }\n return lineList.toTypedArray()\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 640, "cpu_time_ms": 245, "memory_kb": 38056}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s274081035", "group_id": "codeNet:p03464", "input_text": "fun main(args: Array) {\n val N = readLine()!!.toInt()\n val A = readLine()!!.split(\" \").map { it.toInt() }\n var s = setOf(2)\n for (i in N - 1 downTo 0) {\n s = s.filter { it >= A[i] }\n .map { (it..it + A[i] - 1).toList() }\n .flatten()\n .toSet()\n if (i > 0) {\n s = s.filter { it % A[i - 1] == 0 }.toSet()\n s = setOf(s.min()!!, s.max()!!)\n }\n// println(s)\n if (s.size == 0) {\n println(\"-1\")\n return\n }\n }\n println(\"${s.min()} ${s.max()}\")\n}\n", "language": "Kotlin", "metadata": {"date": 1518578308, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03464.html", "problem_id": "p03464", "resource_group": "medium_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/Kotlin/s274081035.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s274081035", "user_id": "u668726177"}, "prompt_components": {"gold_output": "6 8\n", "input_to_evaluate": "fun main(args: Array) {\n val N = readLine()!!.toInt()\n val A = readLine()!!.split(\" \").map { it.toInt() }\n var s = setOf(2)\n for (i in N - 1 downTo 0) {\n s = s.filter { it >= A[i] }\n .map { (it..it + A[i] - 1).toList() }\n .flatten()\n .toSet()\n if (i > 0) {\n s = s.filter { it % A[i - 1] == 0 }.toSet()\n s = setOf(s.min()!!, s.max()!!)\n }\n// println(s)\n if (s.size == 0) {\n println(\"-1\")\n return\n }\n }\n println(\"${s.min()} ${s.max()}\")\n}\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 594, "cpu_time_ms": 2120, "memory_kb": 230712}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s813504389", "group_id": "codeNet:p03469", "input_text": "\nimport java.util.*\n\nfun main(args: Array) {\n val scanner= Scanner(System.`in`)\n val str= scanner.next()\n println(str.replace(\"2017/01/\",\"2018/01/\"))\n scanner.close()\n}", "language": "Kotlin", "metadata": {"date": 1515436311, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03469.html", "problem_id": "p03469", "resource_group": "medium_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/Kotlin/s813504389.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s813504389", "user_id": "u957575129"}, "prompt_components": {"gold_output": "2018/01/07\n", "input_to_evaluate": "\nimport java.util.*\n\nfun main(args: Array) {\n val scanner= Scanner(System.`in`)\n val str= scanner.next()\n println(str.replace(\"2017/01/\",\"2018/01/\"))\n scanner.close()\n}", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 236, "memory_kb": 34172}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s042140278", "group_id": "codeNet:p03470", "input_text": "fun main(args: Array) {\n val n = readLine()?.toInt() ?: return\n val mochi = mutableSetOf()\n for (i in 0 until n) {\n val input = readLine()?.toInt() ?: return\n mochi.add(input)\n }\n println(mochi.size)\n}", "language": "Kotlin", "metadata": {"date": 1569923023, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03470.html", "problem_id": "p03470", "resource_group": "medium_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/Kotlin/s042140278.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s042140278", "user_id": "u605053892"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "fun main(args: Array) {\n val n = readLine()?.toInt() ?: return\n val mochi = mutableSetOf()\n for (i in 0 until n) {\n val input = readLine()?.toInt() ?: return\n mochi.add(input)\n }\n println(mochi.size)\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 223, "memory_kb": 35824}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s175290605", "group_id": "codeNet:p03473", "input_text": "fun main(args: Array) {\n abc084a()\n}\n\nfun abc084a() {\n val m = readLine()!!.toInt()\n \n println(48 - m)\n}\n", "language": "Kotlin", "metadata": {"date": 1568669305, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03473.html", "problem_id": "p03473", "resource_group": "medium_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/Kotlin/s175290605.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s175290605", "user_id": "u139478771"}, "prompt_components": {"gold_output": "27\n", "input_to_evaluate": "fun main(args: Array) {\n abc084a()\n}\n\nfun abc084a() {\n val m = readLine()!!.toInt()\n \n println(48 - m)\n}\n", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 125, "cpu_time_ms": 200, "memory_kb": 31788}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s529439868", "group_id": "codeNet:p03474", "input_text": "import java.io.PrintWriter\nimport java.util.*\nimport java.math.*\nimport java.lang.*\nimport kotlin.comparisons.*\n\nval pw = PrintWriter(System.out)\nval MOD: Long = (1e+9 + 7).toLong()\n\nfun main(args: Array) {\n val (a, b) = readListOfInt()\n val s = read()\n val r = Regex(\"\"\"[0-9]{$a}-[0-9]{$b}\"\"\")\n val isValid = if(r.matches(s)) \"Yes\" else \"No\"\n //val isValid = if(r.matches(s.slice(0 until a))\n // && r.matches(s.slice(a+1 until a+b+1))) \"Yes\" else \"No\"\n println(isValid)\n pw.flush()\n}\n\n/****** Declared Functions and Data Structures ******/\n// IO\nfun read() = readLine()!!\nfun readInt() = read().toInt()\nfun readLong() = read().toLong()\nfun readDouble() = read().toDouble()\nfun readListOfString() = read().split(\" \")\nfun readListOfInt() = readListOfString().map { it.toInt() }\nfun readListOfLong() = readListOfString().map { it.toLong() }\nfun readListOfDouble() = readListOfString().map { it.toDouble() }\n\nfun Double.format(digits: Int) = String.format(\"%.${digits}f\", this)\nfun Float.format(digits: Int) = String.format(\"%.${digits}f\", this)\n\nfun print(value: Any) { pw.print(value) }\nfun println(value : Any) { pw.println(value) }\n\n// Extensions\nfun List.toBuckets(): Map\n = this.groupBy { it }.mapValues { it.value.size }\n\nfun> List.upperBound(element: T, fromIndex: Int=0, toIndex: Int=this.size): Int {\n var l = fromIndex\n var r = toIndex\n while(l < r) {\n val mid = (l+r) / 2\n if(element >= this[mid]) { \n l = mid + 1\n } else {\n r = mid\n }\n }\n return l\n}\n\nfun> List.lowerBound(element: T, fromIndex: Int=0, toIndex: Int=this.size): Int {\n var l = fromIndex\n var r = toIndex\n while(l < r) {\n val mid = (l+r) / 2\n if(element <= this[mid]) { \n r = mid\n } else {\n l = mid + 1\n }\n }\n return r \n}\n\nfun Map.toMutableMap(): MutableMap = HashMap(this)\n\n// Util Functions\nfun makeDivisors(n: Long): List {\n val divisors = mutableListOf()\n for(i in 1L .. Math.sqrt(n.toDouble()).toLong()+1L) {\n if(n % i == 0L) {\n divisors.add(i)\n if(i != n/i) {\n divisors.add(n/i)\n }\n }\n }\n return divisors.distinct().sorted()\n}\n\nfun permutations(src: List): List> {\n if(src.size == 1) return listOf(src)\n val perms = mutableListOf>()\n val insertElement = src[0]\n permutations(src.drop(1)).forEach { perm ->\n for(i in 0..perm.size) {\n val newPerm = perm.toMutableList()\n newPerm.add(i, insertElement)\n perms.add(newPerm.toList())\n }\n }\n return perms\n}\n\n// return nCr, if you want nCr, please access v[n][r]\nfun combinations(n: Long): List> {\n val v = (0..n).map { (0..n).map{0L}.toMutableList() }.toMutableList()\n for(i in 0 until v.size) {\n v[i][0] = 1L\n v[i][i] = 1L\n }\n for(i in 0 until v.size) {\n for(j in 1 until i) {\n v[i][j] = (v[i-1][j-1] + v[i-1][j]) % MOD\n }\n }\n return v.map { it.toList() }.toList()\n}\n\n// should be a >= b\nfun gcd(a: Long, b: Long): Long = \n if(b == 0L) a else gcd(b, a % b)\n\n// shoud be a >= b\nfun lcm(a: Long, b: Long): Long = \n a / gcd(a, b) * b\n\nfun sumDigits(num_: Long): Long {\n var num = num_\n var rtn: Long = 0\n while(num != 0.toLong()) {\n val tmp = num % 10\n rtn += tmp\n num /= 10\n }\n return rtn\n}\n\nfun Double.isDecimal(): Boolean = ((this - Math.floor(this)) != 0.0)\n\n// Data Structures\nclass Stack(private var st: MutableList = mutableListOf()) {\n fun isEmpty() = st.isEmpty()\n fun top(): T = st.last()\n fun push(e: T) { st.add(e) }\n fun pop() { st = st.dropLast(1).toMutableList() }\n}\n\nclass Queue(private var que: MutableList = mutableListOf()) {\n fun isEmpty() = que.isEmpty()\n fun top(): T = que.first()\n fun push(e: T) { que.add(e) }\n fun pop() { que = que.drop(1).toMutableList() }\n}\n", "language": "Kotlin", "metadata": {"date": 1571179546, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03474.html", "problem_id": "p03474", "resource_group": "medium_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/Kotlin/s529439868.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s529439868", "user_id": "u026686258"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "import java.io.PrintWriter\nimport java.util.*\nimport java.math.*\nimport java.lang.*\nimport kotlin.comparisons.*\n\nval pw = PrintWriter(System.out)\nval MOD: Long = (1e+9 + 7).toLong()\n\nfun main(args: Array) {\n val (a, b) = readListOfInt()\n val s = read()\n val r = Regex(\"\"\"[0-9]{$a}-[0-9]{$b}\"\"\")\n val isValid = if(r.matches(s)) \"Yes\" else \"No\"\n //val isValid = if(r.matches(s.slice(0 until a))\n // && r.matches(s.slice(a+1 until a+b+1))) \"Yes\" else \"No\"\n println(isValid)\n pw.flush()\n}\n\n/****** Declared Functions and Data Structures ******/\n// IO\nfun read() = readLine()!!\nfun readInt() = read().toInt()\nfun readLong() = read().toLong()\nfun readDouble() = read().toDouble()\nfun readListOfString() = read().split(\" \")\nfun readListOfInt() = readListOfString().map { it.toInt() }\nfun readListOfLong() = readListOfString().map { it.toLong() }\nfun readListOfDouble() = readListOfString().map { it.toDouble() }\n\nfun Double.format(digits: Int) = String.format(\"%.${digits}f\", this)\nfun Float.format(digits: Int) = String.format(\"%.${digits}f\", this)\n\nfun print(value: Any) { pw.print(value) }\nfun println(value : Any) { pw.println(value) }\n\n// Extensions\nfun List.toBuckets(): Map\n = this.groupBy { it }.mapValues { it.value.size }\n\nfun> List.upperBound(element: T, fromIndex: Int=0, toIndex: Int=this.size): Int {\n var l = fromIndex\n var r = toIndex\n while(l < r) {\n val mid = (l+r) / 2\n if(element >= this[mid]) { \n l = mid + 1\n } else {\n r = mid\n }\n }\n return l\n}\n\nfun> List.lowerBound(element: T, fromIndex: Int=0, toIndex: Int=this.size): Int {\n var l = fromIndex\n var r = toIndex\n while(l < r) {\n val mid = (l+r) / 2\n if(element <= this[mid]) { \n r = mid\n } else {\n l = mid + 1\n }\n }\n return r \n}\n\nfun Map.toMutableMap(): MutableMap = HashMap(this)\n\n// Util Functions\nfun makeDivisors(n: Long): List {\n val divisors = mutableListOf()\n for(i in 1L .. Math.sqrt(n.toDouble()).toLong()+1L) {\n if(n % i == 0L) {\n divisors.add(i)\n if(i != n/i) {\n divisors.add(n/i)\n }\n }\n }\n return divisors.distinct().sorted()\n}\n\nfun permutations(src: List): List> {\n if(src.size == 1) return listOf(src)\n val perms = mutableListOf>()\n val insertElement = src[0]\n permutations(src.drop(1)).forEach { perm ->\n for(i in 0..perm.size) {\n val newPerm = perm.toMutableList()\n newPerm.add(i, insertElement)\n perms.add(newPerm.toList())\n }\n }\n return perms\n}\n\n// return nCr, if you want nCr, please access v[n][r]\nfun combinations(n: Long): List> {\n val v = (0..n).map { (0..n).map{0L}.toMutableList() }.toMutableList()\n for(i in 0 until v.size) {\n v[i][0] = 1L\n v[i][i] = 1L\n }\n for(i in 0 until v.size) {\n for(j in 1 until i) {\n v[i][j] = (v[i-1][j-1] + v[i-1][j]) % MOD\n }\n }\n return v.map { it.toList() }.toList()\n}\n\n// should be a >= b\nfun gcd(a: Long, b: Long): Long = \n if(b == 0L) a else gcd(b, a % b)\n\n// shoud be a >= b\nfun lcm(a: Long, b: Long): Long = \n a / gcd(a, b) * b\n\nfun sumDigits(num_: Long): Long {\n var num = num_\n var rtn: Long = 0\n while(num != 0.toLong()) {\n val tmp = num % 10\n rtn += tmp\n num /= 10\n }\n return rtn\n}\n\nfun Double.isDecimal(): Boolean = ((this - Math.floor(this)) != 0.0)\n\n// Data Structures\nclass Stack(private var st: MutableList = mutableListOf()) {\n fun isEmpty() = st.isEmpty()\n fun top(): T = st.last()\n fun push(e: T) { st.add(e) }\n fun pop() { st = st.dropLast(1).toMutableList() }\n}\n\nclass Queue(private var que: MutableList = mutableListOf()) {\n fun isEmpty() = que.isEmpty()\n fun top(): T = que.first()\n fun push(e: T) { que.add(e) }\n fun pop() { que = que.drop(1).toMutableList() }\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 4073, "cpu_time_ms": 243, "memory_kb": 37608}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s425058237", "group_id": "codeNet:p03474", "input_text": "fun main(args: Array) {\n val (f, s) = readLine()!!.split(\" \").map(String::toInt)\n val r = \"[0-9]{$f}-[0-9]{$s}\".toRegex()\n val a = if(r.matches(readLine()!!)) \"Yes\" else \"No\"\n println(a)\n}", "language": "Kotlin", "metadata": {"date": 1543948907, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03474.html", "problem_id": "p03474", "resource_group": "medium_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/Kotlin/s425058237.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s425058237", "user_id": "u227189389"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "fun main(args: Array) {\n val (f, s) = readLine()!!.split(\" \").map(String::toInt)\n val r = \"[0-9]{$f}-[0-9]{$s}\".toRegex()\n val a = if(r.matches(readLine()!!)) \"Yes\" else \"No\"\n println(a)\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 238, "memory_kb": 37744}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s159928573", "group_id": "codeNet:p03474", "input_text": "fun main(args: Array) {\n val sc = java.util.Scanner(System.`in`)\n val A = sc.next().toInt()\n val B = sc.next().toInt()\n val S = sc.next()\n\n if (S.filter({c -> c == '-' }).length == 1) {\n if (S[A] == '-'){\n println(\"Yes\")\n return\n }\n }\n println(\"No\")\n}", "language": "Kotlin", "metadata": {"date": 1521296429, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03474.html", "problem_id": "p03474", "resource_group": "medium_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/Kotlin/s159928573.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s159928573", "user_id": "u509457191"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "fun main(args: Array) {\n val sc = java.util.Scanner(System.`in`)\n val A = sc.next().toInt()\n val B = sc.next().toInt()\n val S = sc.next()\n\n if (S.filter({c -> c == '-' }).length == 1) {\n if (S[A] == '-'){\n println(\"Yes\")\n return\n }\n }\n println(\"No\")\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 173, "memory_kb": 29360}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s917318184", "group_id": "codeNet:p03474", "input_text": "fun main(args: Array) {\n var (A, B) = readLine()!!.split(\" \").map{it.toInt()}\n val S = readLine()!!\n if (Regex(\"\"\"\\d{$A}-\\d{$B}\"\"\").matches(S)) println(\"Yes\")\n else println(\"No\")\n}\n", "language": "Kotlin", "metadata": {"date": 1518469682, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03474.html", "problem_id": "p03474", "resource_group": "medium_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/Kotlin/s917318184.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s917318184", "user_id": "u668726177"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "fun main(args: Array) {\n var (A, B) = readLine()!!.split(\" \").map{it.toInt()}\n val S = readLine()!!\n if (Regex(\"\"\"\\d{$A}-\\d{$B}\"\"\").matches(S)) println(\"Yes\")\n else println(\"No\")\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 241, "memory_kb": 37720}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s751668021", "group_id": "codeNet:p03475", "input_text": "fun main(args: Array) {\n val inputN = readLine().orEmpty().toInt()\n val diagram = mutableListOf>()\n val ansList = mutableListOf()\n\n for(i in 0 until inputN - 1){\n val dia = readLine()?.split(\" \").orEmpty()\n\n val c = dia[0].toInt()\n val s = dia[1].toInt()\n val f = dia[2].toInt()\n diagram.add(Triple(c,s,f))\n }\n var j = inputN -1\n var k = 0\n while(j > - 1){\n if(j == inputN - 1){\n ansList.add(0)\n }else if(j == inputN - 2){\n ansList.add(diagram[j].second + diagram[j].first)\n }else{\n val nextWaitTime = diagram[j + 1].second\n val nextInterval = diagram[j + 1].third\n var time = diagram[j].second + diagram[j].first\n\n if(time <= nextWaitTime){\n time = ansList[k - 1]\n }else{\n var delay = (time - nextWaitTime) / nextInterval\n if((time - nextWaitTime) % nextInterval == 0){\n time = ansList[k - 1] + (nextInterval * delay)\n }else{\n delay += 1\n time = ansList[k - 1] + (nextInterval * delay)\n }\n }\n ansList.add(time)\n }\n j -= 1\n k += 1\n }\n\n val showList = ansList.reversed()\n showList.forEach{\n println(it)\n }\n\n}", "language": "Kotlin", "metadata": {"date": 1585166371, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03475.html", "problem_id": "p03475", "resource_group": "medium_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/Kotlin/s751668021.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s751668021", "user_id": "u430710262"}, "prompt_components": {"gold_output": "12\n11\n0\n", "input_to_evaluate": "fun main(args: Array) {\n val inputN = readLine().orEmpty().toInt()\n val diagram = mutableListOf>()\n val ansList = mutableListOf()\n\n for(i in 0 until inputN - 1){\n val dia = readLine()?.split(\" \").orEmpty()\n\n val c = dia[0].toInt()\n val s = dia[1].toInt()\n val f = dia[2].toInt()\n diagram.add(Triple(c,s,f))\n }\n var j = inputN -1\n var k = 0\n while(j > - 1){\n if(j == inputN - 1){\n ansList.add(0)\n }else if(j == inputN - 2){\n ansList.add(diagram[j].second + diagram[j].first)\n }else{\n val nextWaitTime = diagram[j + 1].second\n val nextInterval = diagram[j + 1].third\n var time = diagram[j].second + diagram[j].first\n\n if(time <= nextWaitTime){\n time = ansList[k - 1]\n }else{\n var delay = (time - nextWaitTime) / nextInterval\n if((time - nextWaitTime) % nextInterval == 0){\n time = ansList[k - 1] + (nextInterval * delay)\n }else{\n delay += 1\n time = ansList[k - 1] + (nextInterval * delay)\n }\n }\n ansList.add(time)\n }\n j -= 1\n k += 1\n }\n\n val showList = ansList.reversed()\n showList.forEach{\n println(it)\n }\n\n}", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1390, "cpu_time_ms": 275, "memory_kb": 36564}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s134083660", "group_id": "codeNet:p03479", "input_text": "fun main(args: Array) {\n val (x, y) = readLine()!!.split(\" \").map { it.toLong() }\n var count = 0\n while ((x shl count) <= y) {\n count += 1\n }\n println(count)\n}\n", "language": "Kotlin", "metadata": {"date": 1565719803, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03479.html", "problem_id": "p03479", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03479/input.txt", "sample_output_relpath": "derived/input_output/data/p03479/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03479/Kotlin/s134083660.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s134083660", "user_id": "u043150661"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "fun main(args: Array) {\n val (x, y) = readLine()!!.split(\" \").map { it.toLong() }\n var count = 0\n while ((x shl count) <= y) {\n count += 1\n }\n println(count)\n}\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": "p03479", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 244, "memory_kb": 37696}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s584970258", "group_id": "codeNet:p03486", "input_text": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val s = sc.next()\n val t = sc.next()\n\n (if (judge(calc(s), calc(t).reversed())) \"Yes\" else \"No\")\n .let(::println)\n}\n\nfun calc(s: String): List {\n return s.toCharArray().sorted()\n}\n\nfun judge(s: List, t: List): Boolean {\n for (i in 0 until Math.max(s.size, t.size)) {\n if (i >= s.size) {\n return true\n }\n if (i >= t.size) {\n return false\n }\n if (s[i] < t[i]) {\n return true\n }\n if (s[i] > t[i]) {\n return false\n }\n }\n return false\n}\n", "language": "Kotlin", "metadata": {"date": 1541682730, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03486.html", "problem_id": "p03486", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03486/input.txt", "sample_output_relpath": "derived/input_output/data/p03486/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03486/Kotlin/s584970258.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s584970258", "user_id": "u323680411"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val s = sc.next()\n val t = sc.next()\n\n (if (judge(calc(s), calc(t).reversed())) \"Yes\" else \"No\")\n .let(::println)\n}\n\nfun calc(s: String): List {\n return s.toCharArray().sorted()\n}\n\nfun judge(s: List, t: List): Boolean {\n for (i in 0 until Math.max(s.size, t.size)) {\n if (i >= s.size) {\n return true\n }\n if (i >= t.size) {\n return false\n }\n if (s[i] < t[i]) {\n return true\n }\n if (s[i] > t[i]) {\n return false\n }\n }\n return false\n}\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nYou are given strings s and t, consisting of lowercase English letters.\nYou will create a string s' by freely rearranging the characters in s.\nYou will also create a string t' by freely rearranging the characters in t.\nDetermine whether it is possible to satisfy s' < t' for the lexicographic order.\n\nNotes\n\nFor a string a = a_1 a_2 ... a_N of length N and a string b = b_1 b_2 ... b_M of length M, we say a < b for the lexicographic order if either one of the following two conditions holds true:\n\nN < M and a_1 = b_1, a_2 = b_2, ..., a_N = b_N.\n\nThere exists i (1 \\leq i \\leq N, M) such that a_1 = b_1, a_2 = b_2, ..., a_{i - 1} = b_{i - 1} and a_i < b_i. Here, letters are compared using alphabetical order.\n\nFor example, xy < xya and atcoder < atlas.\n\nConstraints\n\nThe lengths of s and t are between 1 and 100 (inclusive).\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 it is possible to satisfy s' < t', print Yes; if it is not, print No.\n\nSample Input 1\n\nyx\naxy\n\nSample Output 1\n\nYes\n\nWe can, for example, rearrange yx into xy and axy into yxa. Then, xy < yxa.\n\nSample Input 2\n\nratcode\natlas\n\nSample Output 2\n\nYes\n\nWe can, for example, rearrange ratcode into acdeort and atlas into tslaa. Then, acdeort < tslaa.\n\nSample Input 3\n\ncd\nabc\n\nSample Output 3\n\nNo\n\nNo matter how we rearrange cd and abc, we cannot achieve our objective.\n\nSample Input 4\n\nw\nww\n\nSample Output 4\n\nYes\n\nSample Input 5\n\nzzz\nzzz\n\nSample Output 5\n\nNo", "sample_input": "yx\naxy\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03486", "source_text": "Score : 200 points\n\nProblem Statement\n\nYou are given strings s and t, consisting of lowercase English letters.\nYou will create a string s' by freely rearranging the characters in s.\nYou will also create a string t' by freely rearranging the characters in t.\nDetermine whether it is possible to satisfy s' < t' for the lexicographic order.\n\nNotes\n\nFor a string a = a_1 a_2 ... a_N of length N and a string b = b_1 b_2 ... b_M of length M, we say a < b for the lexicographic order if either one of the following two conditions holds true:\n\nN < M and a_1 = b_1, a_2 = b_2, ..., a_N = b_N.\n\nThere exists i (1 \\leq i \\leq N, M) such that a_1 = b_1, a_2 = b_2, ..., a_{i - 1} = b_{i - 1} and a_i < b_i. Here, letters are compared using alphabetical order.\n\nFor example, xy < xya and atcoder < atlas.\n\nConstraints\n\nThe lengths of s and t are between 1 and 100 (inclusive).\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 it is possible to satisfy s' < t', print Yes; if it is not, print No.\n\nSample Input 1\n\nyx\naxy\n\nSample Output 1\n\nYes\n\nWe can, for example, rearrange yx into xy and axy into yxa. Then, xy < yxa.\n\nSample Input 2\n\nratcode\natlas\n\nSample Output 2\n\nYes\n\nWe can, for example, rearrange ratcode into acdeort and atlas into tslaa. Then, acdeort < tslaa.\n\nSample Input 3\n\ncd\nabc\n\nSample Output 3\n\nNo\n\nNo matter how we rearrange cd and abc, we cannot achieve our objective.\n\nSample Input 4\n\nw\nww\n\nSample Output 4\n\nYes\n\nSample Input 5\n\nzzz\nzzz\n\nSample Output 5\n\nNo", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 669, "cpu_time_ms": 213, "memory_kb": 35832}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s592575484", "group_id": "codeNet:p03487", "input_text": "fun main(args : Array) {\n val n = readLine()!!.toInt()\n val aa = readLine()!!.split(\" \").map { it.toInt() }.groupBy { it }\n\n var cnt = 0\n\n aa.entries.forEach {\n if (it.value.size < it.key) {\n cnt += it.value.size\n } else if (it.value.size > it.key) {\n cnt += it.value.size - it.key\n }\n }\n\n println(cnt)\n}\n", "language": "Kotlin", "metadata": {"date": 1589102605, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03487.html", "problem_id": "p03487", "resource_group": "medium_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/Kotlin/s592575484.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s592575484", "user_id": "u262403099"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "fun main(args : Array) {\n val n = readLine()!!.toInt()\n val aa = readLine()!!.split(\" \").map { it.toInt() }.groupBy { it }\n\n var cnt = 0\n\n aa.entries.forEach {\n if (it.value.size < it.key) {\n cnt += it.value.size\n } else if (it.value.size > it.key) {\n cnt += it.value.size - it.key\n }\n }\n\n println(cnt)\n}\n", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 590, "memory_kb": 59660}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s480006511", "group_id": "codeNet:p03488", "input_text": "fun main(args: Array) {\n val s = readLine()!!\n val (gx, gy) = readLine()!!.split(' ').map { it.toInt() }\n\n val dx = mutableListOf()\n val dy = mutableListOf()\n s.split('T').forEachIndexed { i, sub ->\n if (i % 2 == 0) dx.add(sub.length) else dy.add(sub.length)\n }\n\n val x = dx.slice(1 until dx.size).sortedDescending()\n .fold(gx - dx[0]) { acc, i -> acc + if (acc > 0) -i else i }\n\n val y = dy.sortedDescending()\n .fold(gy) { acc, i -> acc + if (acc > 0) -i else i }\n\n println(if (x == 0 && y == 0) \"Yes\" else \"No\")\n}\n", "language": "Kotlin", "metadata": {"date": 1591298471, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03488.html", "problem_id": "p03488", "resource_group": "medium_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/Kotlin/s480006511.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s480006511", "user_id": "u863309603"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "fun main(args: Array) {\n val s = readLine()!!\n val (gx, gy) = readLine()!!.split(' ').map { it.toInt() }\n\n val dx = mutableListOf()\n val dy = mutableListOf()\n s.split('T').forEachIndexed { i, sub ->\n if (i % 2 == 0) dx.add(sub.length) else dy.add(sub.length)\n }\n\n val x = dx.slice(1 until dx.size).sortedDescending()\n .fold(gx - dx[0]) { acc, i -> acc + if (acc > 0) -i else i }\n\n val y = dy.sortedDescending()\n .fold(gy) { acc, i -> acc + if (acc > 0) -i else i }\n\n println(if (x == 0 && y == 0) \"Yes\" else \"No\")\n}\n", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 590, "cpu_time_ms": 311, "memory_kb": 40300}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s576258219", "group_id": "codeNet:p03494", "input_text": "fun count(x: Int): Int {\n var cnt = 0\n var tmp = x\n while(tmp%2==0) {\n cnt++\n tmp /= 2\n }\n return cnt\n// val res = cnt\n// return res\n}\n\nfun main(args: Array) {\n val N = readLine()!!\n val As = readLine()!!.split(\" \").map(String::toInt)\n val counts = As.map { count(it) }\n\n println(counts.min())\n}", "language": "Kotlin", "metadata": {"date": 1528080616, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03494.html", "problem_id": "p03494", "resource_group": "medium_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/Kotlin/s576258219.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s576258219", "user_id": "u185034753"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "fun count(x: Int): Int {\n var cnt = 0\n var tmp = x\n while(tmp%2==0) {\n cnt++\n tmp /= 2\n }\n return cnt\n// val res = cnt\n// return res\n}\n\nfun main(args: Array) {\n val N = readLine()!!\n val As = readLine()!!.split(\" \").map(String::toInt)\n val counts = As.map { count(it) }\n\n println(counts.min())\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 288, "memory_kb": 36076}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s689691841", "group_id": "codeNet:p03495", "input_text": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val n = sc.nextInt()\n val k = sc.nextInt()\n val a = (0 until n).map { sc.next().toInt() }\n println(problem081c(n, k, a))\n}\n\nfun problem081c(n: Int, k: Int, a: List): Int {\n val numbers = hashMapOf()\n for (i in 0 until n) {\n if (!numbers.contains(a[i])) {\n numbers[a[i]] = 1\n } else {\n numbers[a[i]] = numbers[a[i]]!!.plus(1)\n }\n }\n val counts = numbers.values.sorted().toMutableList()\n if (numbers.size <= k) return 0\n var ans = 0\n for (i in counts.indices) {\n ans += counts[0]\n counts.removeAt(0)\n if (counts.size <= k) {\n return ans\n }\n }\n return ans\n}", "language": "Kotlin", "metadata": {"date": 1568219760, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03495.html", "problem_id": "p03495", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03495/input.txt", "sample_output_relpath": "derived/input_output/data/p03495/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03495/Kotlin/s689691841.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s689691841", "user_id": "u073232808"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val n = sc.nextInt()\n val k = sc.nextInt()\n val a = (0 until n).map { sc.next().toInt() }\n println(problem081c(n, k, a))\n}\n\nfun problem081c(n: Int, k: Int, a: List): Int {\n val numbers = hashMapOf()\n for (i in 0 until n) {\n if (!numbers.contains(a[i])) {\n numbers[a[i]] = 1\n } else {\n numbers[a[i]] = numbers[a[i]]!!.plus(1)\n }\n }\n val counts = numbers.values.sorted().toMutableList()\n if (numbers.size <= k) return 0\n var ans = 0\n for (i in counts.indices) {\n ans += counts[0]\n counts.removeAt(0)\n if (counts.size <= k) {\n return ans\n }\n }\n return 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": "p03495", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 777, "cpu_time_ms": 2111, "memory_kb": 61348}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s408502922", "group_id": "codeNet:p03501", "input_text": "fun main(args: Array) {\n val (n, a, b) = readLine()!!.split(' ').map(String::toInt)\n println(Math.min(n * a, b))\n}\n", "language": "Kotlin", "metadata": {"date": 1555467632, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03501.html", "problem_id": "p03501", "resource_group": "medium_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/Kotlin/s408502922.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s408502922", "user_id": "u051841332"}, "prompt_components": {"gold_output": "119\n", "input_to_evaluate": "fun main(args: Array) {\n val (n, a, b) = readLine()!!.split(' ').map(String::toInt)\n println(Math.min(n * a, b))\n}\n", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 242, "memory_kb": 36256}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s481182951", "group_id": "codeNet:p03503", "input_text": "fun main(args: Array) {\n val n = readLine()!!.toInt()\n val fs = (0 until n).map {\n val f = readLine()!!.split(' ').map { it.toInt() }\n f.mapIndexed { i, v -> v shl i }.sum()\n }.toIntArray()\n val ps = (0 until n).map {\n readLine()!!.split(' ').map { it.toInt() }.toIntArray()\n }.toTypedArray()\n\n val dp = IntArray((1 shl 10)) { Int.MIN_VALUE }\n for (i in 1 until (1 shl 10)) {\n var p = 0\n for (j in 0 until n) {\n var x = fs[j] and i\n var cnt = 0\n while (x > 0) {\n cnt += x and 1\n x = x shr 1\n }\n p += ps[j][cnt]\n }\n dp[i] = Math.max(p, dp[i - 1])\n }\n\n println(dp.last())\n}\n", "language": "Kotlin", "metadata": {"date": 1582927042, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03503.html", "problem_id": "p03503", "resource_group": "medium_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/Kotlin/s481182951.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s481182951", "user_id": "u863309603"}, "prompt_components": {"gold_output": "8\n", "input_to_evaluate": "fun main(args: Array) {\n val n = readLine()!!.toInt()\n val fs = (0 until n).map {\n val f = readLine()!!.split(' ').map { it.toInt() }\n f.mapIndexed { i, v -> v shl i }.sum()\n }.toIntArray()\n val ps = (0 until n).map {\n readLine()!!.split(' ').map { it.toInt() }.toIntArray()\n }.toTypedArray()\n\n val dp = IntArray((1 shl 10)) { Int.MIN_VALUE }\n for (i in 1 until (1 shl 10)) {\n var p = 0\n for (j in 0 until n) {\n var x = fs[j] and i\n var cnt = 0\n while (x > 0) {\n cnt += x and 1\n x = x shr 1\n }\n p += ps[j][cnt]\n }\n dp[i] = Math.max(p, dp[i - 1])\n }\n\n println(dp.last())\n}\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 741, "cpu_time_ms": 308, "memory_kb": 38372}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s899109710", "group_id": "codeNet:p03504", "input_text": "import java.util.*\n\n//PriorityQueue\nfun main(args: Array) {\n val (n, _c) = readLine()!!.split(' ').map(String::toInt)\n val stcList = mutableListOf>()\n (1..n).forEach {\n val (s, t, c) = readLine()!!.split(' ').map(String::toInt)\n stcList.add(Triple(s, t, c))\n }\n stcList.sortBy { it.first }\n val stQueue = ArrayDeque(stcList)\n val curQueue = PriorityQueue>(n, Comparator { o1: Triple?, o2: Triple? ->\n if (o1!!.second > o2!!.second) 1 else -1\n })\n var ans = 0\n while (stQueue.isNotEmpty()) {\n val pair = stQueue.pop()\n val limit = pair.first\n val tempList = mutableListOf>()\n while (curQueue.isNotEmpty() && curQueue.peek().second <= limit) {\n val poll = curQueue.poll()\n if (pair.third != poll.third && poll.second == limit) tempList.add(poll)\n }\n curQueue.add(pair)\n curQueue.addAll(tempList)\n ans = Math.max(ans, curQueue.size)\n }\n println(ans)\n}\n", "language": "Kotlin", "metadata": {"date": 1576031081, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03504.html", "problem_id": "p03504", "resource_group": "medium_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/Kotlin/s899109710.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s899109710", "user_id": "u099066216"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import java.util.*\n\n//PriorityQueue\nfun main(args: Array) {\n val (n, _c) = readLine()!!.split(' ').map(String::toInt)\n val stcList = mutableListOf>()\n (1..n).forEach {\n val (s, t, c) = readLine()!!.split(' ').map(String::toInt)\n stcList.add(Triple(s, t, c))\n }\n stcList.sortBy { it.first }\n val stQueue = ArrayDeque(stcList)\n val curQueue = PriorityQueue>(n, Comparator { o1: Triple?, o2: Triple? ->\n if (o1!!.second > o2!!.second) 1 else -1\n })\n var ans = 0\n while (stQueue.isNotEmpty()) {\n val pair = stQueue.pop()\n val limit = pair.first\n val tempList = mutableListOf>()\n while (curQueue.isNotEmpty() && curQueue.peek().second <= limit) {\n val poll = curQueue.poll()\n if (pair.third != poll.third && poll.second == limit) tempList.add(poll)\n }\n curQueue.add(pair)\n curQueue.addAll(tempList)\n ans = Math.max(ans, curQueue.size)\n }\n println(ans)\n}\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) {\n val sc = Scanner(System.`in`)\n val n = sc.nextInt()\n val c = sc.nextInt()\n\n val stc = Array(n) { Triple(sc.nextInt(), sc.nextInt(), sc.nextInt()) }\n\n val p = stc.groupBy { it.third }\n .map { it.value.sortedBy { it.first } }\n .flatMap {\n it.fold(mutableListOf()) { acc: List>, tri ->\n val last = acc.lastOrNull() ?: return@fold acc + tri\n\n if (last.second == tri.first)\n acc.dropLast(1) + last.copy(second = tri.second)\n else\n acc + tri\n }\n }\n\n var cur = 0\n val ret = (p.map { it.first to true } + p.map { it.second to false })\n .sortedBy { it.first }\n .map {\n if (it.second) {\n cur += 1\n } else {\n cur -= 1\n }\n cur\n }\n .max()\n\n println(ret)\n}", "language": "Kotlin", "metadata": {"date": 1513799661, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03504.html", "problem_id": "p03504", "resource_group": "medium_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/Kotlin/s892699858.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s892699858", "user_id": "u153537680"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "\nimport java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val n = sc.nextInt()\n val c = sc.nextInt()\n\n val stc = Array(n) { Triple(sc.nextInt(), sc.nextInt(), sc.nextInt()) }\n\n val p = stc.groupBy { it.third }\n .map { it.value.sortedBy { it.first } }\n .flatMap {\n it.fold(mutableListOf()) { acc: List>, tri ->\n val last = acc.lastOrNull() ?: return@fold acc + tri\n\n if (last.second == tri.first)\n acc.dropLast(1) + last.copy(second = tri.second)\n else\n acc + tri\n }\n }\n\n var cur = 0\n val ret = (p.map { it.first to true } + p.map { it.second to false })\n .sortedBy { it.first }\n .map {\n if (it.second) {\n cur += 1\n } else {\n cur -= 1\n }\n cur\n }\n .max()\n\n println(ret)\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) {\n val s = readLine()!!\n val regex = \"\"\"^(A)?KIH(A)?B(A)?R(A)?$\"\"\"\n println(if (regex.toRegex().matches(s)) \"YES\" else \"NO\")\n}", "language": "Kotlin", "metadata": {"date": 1573215443, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03523.html", "problem_id": "p03523", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03523/input.txt", "sample_output_relpath": "derived/input_output/data/p03523/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03523/Kotlin/s854582909.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s854582909", "user_id": "u262403099"}, "prompt_components": {"gold_output": "YES\n", "input_to_evaluate": "fun main(args : Array) {\n val s = readLine()!!\n val regex = \"\"\"^(A)?KIH(A)?B(A)?R(A)?$\"\"\"\n println(if (regex.toRegex().matches(s)) \"YES\" else \"NO\")\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nYou are given a string S.\n\nTakahashi can insert the character A at any position in this string any number of times.\n\nCan he change S into AKIHABARA?\n\nConstraints\n\n1 \\leq |S| \\leq 50\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 it is possible to change S into AKIHABARA, print YES; otherwise, print NO.\n\nSample Input 1\n\nKIHBR\n\nSample Output 1\n\nYES\n\nInsert one A at each of the four positions: the beginning, immediately after H, immediately after B and the end.\n\nSample Input 2\n\nAKIBAHARA\n\nSample Output 2\n\nNO\n\nThe correct spell is AKIHABARA.\n\nSample Input 3\n\nAAKIAHBAARA\n\nSample Output 3\n\nNO", "sample_input": "KIHBR\n"}, "reference_outputs": ["YES\n"], "source_document_id": "p03523", "source_text": "Score : 300 points\n\nProblem Statement\n\nYou are given a string S.\n\nTakahashi can insert the character A at any position in this string any number of times.\n\nCan he change S into AKIHABARA?\n\nConstraints\n\n1 \\leq |S| \\leq 50\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 it is possible to change S into AKIHABARA, print YES; otherwise, print NO.\n\nSample Input 1\n\nKIHBR\n\nSample Output 1\n\nYES\n\nInsert one A at each of the four positions: the beginning, immediately after H, immediately after B and the end.\n\nSample Input 2\n\nAKIBAHARA\n\nSample Output 2\n\nNO\n\nThe correct spell is AKIHABARA.\n\nSample Input 3\n\nAAKIAHBAARA\n\nSample Output 3\n\nNO", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 166, "cpu_time_ms": 209, "memory_kb": 33660}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s952785444", "group_id": "codeNet:p03543", "input_text": "\nfun main(args:Array) {\n val N = readLine()!!\n println(if(N[1]==N[2] && (N[0]==N[1] || N[2]==N[3])) {\"Yes\"} else {\"No\"})\n}\n\n", "language": "Kotlin", "metadata": {"date": 1511056975, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03543.html", "problem_id": "p03543", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03543/input.txt", "sample_output_relpath": "derived/input_output/data/p03543/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03543/Kotlin/s952785444.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s952785444", "user_id": "u181807786"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "\nfun main(args:Array) {\n val N = readLine()!!\n println(if(N[1]==N[2] && (N[0]==N[1] || N[2]==N[3])) {\"Yes\"} else {\"No\"})\n}\n\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nWe call a 4-digit integer with three or more consecutive same digits, such as 1118, good.\n\nYou are given a 4-digit integer N. Answer the question: Is N good?\n\nConstraints\n\n1000 ≤ N ≤ 9999\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 good, print Yes; otherwise, print No.\n\nSample Input 1\n\n1118\n\nSample Output 1\n\nYes\n\nN is good, since it contains three consecutive 1.\n\nSample Input 2\n\n7777\n\nSample Output 2\n\nYes\n\nAn integer is also good when all the digits are the same.\n\nSample Input 3\n\n1234\n\nSample Output 3\n\nNo", "sample_input": "1118\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03543", "source_text": "Score : 100 points\n\nProblem Statement\n\nWe call a 4-digit integer with three or more consecutive same digits, such as 1118, good.\n\nYou are given a 4-digit integer N. Answer the question: Is N good?\n\nConstraints\n\n1000 ≤ N ≤ 9999\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 good, print Yes; otherwise, print No.\n\nSample Input 1\n\n1118\n\nSample Output 1\n\nYes\n\nN is good, since it contains three consecutive 1.\n\nSample Input 2\n\n7777\n\nSample Output 2\n\nYes\n\nAn integer is also good when all the digits are the same.\n\nSample Input 3\n\n1234\n\nSample Output 3\n\nNo", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 337, "memory_kb": 29916}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s020814164", "group_id": "codeNet:p03545", "input_text": "import java.io.PrintWriter\nimport java.util.*\nimport java.math.*\nimport java.lang.*\nimport kotlin.comparisons.*\n\nval pw = PrintWriter(System.out)\nval MOD: Long = (1e+9 + 7).toLong()\n\nfun dfs(i: Int, result: Int, nums: List, formula: String): String {\n\tif(i == 4) {\n\t\treturn if(result == 7) formula + \"=7\" else \"\"\n\t}\n\tval num = nums[i]\n\tval ansPlus = dfs(i+1, result + num, nums, formula + \"+$num\")\n\tval ansMinus = dfs(i+1, result - num, nums, formula + \"-$num\")\n\treturn if(ansPlus.isEmpty()) ansMinus else ansPlus\n}\n\nfun main(args: Array) {\n\tval nums = read().map { it.toString().toInt() }\n\tval ans = dfs(1, nums[0], nums, \"${nums[0]}\")\n\t\n\tprintln(ans)\n\n\tpw.flush()\n}\n\n/****** Declared Functions and Data Structures ******/\n// IO\nfun read() = readLine()!!\nfun readInt() = read().toInt()\nfun readLong() = read().toLong()\nfun readDouble() = read().toDouble()\nfun readListOfString() = read().split(\" \")\nfun readListOfInt() = readListOfString().map { it.toInt() }\nfun readListOfLong() = readListOfString().map { it.toLong() }\nfun readListOfDouble() = readListOfString().map { it.toDouble() }\n\nfun Double.format(digits: Int) = String.format(\"%.${digits}f\", this)\nfun Float.format(digits: Int) = String.format(\"%.${digits}f\", this)\n\nfun print(value: Any) { pw.print(value) }\nfun println(value : Any) { pw.println(value) }\n\n// Extensions\nfun List.toBuckets(): Map\n\t= this.groupBy { it }.mapValues { it.value.size }\n\nfun> Array.upperBound(element: T, fromIndex: Int=0, toIndex: Int=this.size): Int\n\t= this.toList().upperBound(element, fromIndex, toIndex)\n\nfun> List.upperBound(element: T, fromIndex: Int=0, toIndex: Int=this.size): Int {\n\tvar l = fromIndex\n\tvar r = toIndex\n\twhile(l < r) {\n\t\tval mid = (l+r) / 2\n\t\tif(element >= this[mid]) { \n\t\t\tl = mid + 1\n\t\t} else {\n\t\t\tr = mid\n\t\t}\n\t}\n\treturn l\n}\n\nfun> Array.lowerBound(element: T, fromIndex: Int=0, toIndex: Int=this.size): Int\n\t= this.toList().lowerBound(element, fromIndex, toIndex)\n\nfun> List.lowerBound(element: T, fromIndex: Int=0, toIndex: Int=this.size): Int {\n\tvar l = fromIndex\n\tvar r = toIndex\n\twhile(l < r) {\n\t\tval mid = (l+r) / 2\n\t\tif(element > this[mid]) { \n\t\t\tl = mid + 1\n\t\t} else {\n\t\t\tr = mid\n\t\t}\n\t}\n\treturn r \n}\n\nfun Map.toMutableMap(): MutableMap = HashMap(this)\n\n// Util Functions\nfun Long.makeDivisors(): List {\n\tval divisors = mutableListOf()\n\tfor(i in 1L .. Math.sqrt(this.toDouble()).toLong()+1L) {\n\t\tif(this % i == 0L) {\n\t\t\tdivisors.add(i)\n\t\t\tif(i != this/i) {\n\t\t\t\tdivisors.add(this/i)\n\t\t\t}\n\t\t}\n\t}\n\treturn divisors.distinct().sorted()\n}\n\nfun Long.isPrime(): Boolean {\n\tif(this==1L) return false\n\tfor(i in 2L .. Math.sqrt(this.toDouble()).toLong() + 1L) {\n\t\tif(this % i == 0L && this != i) {\n\t\t\treturn false\n\t\t}\n\t}\n\treturn true\n}\n\nfun Long.primeFactorize(): Map {\n\tval factors = mutableMapOf()\n\tvar num = this\n\tvar i = 2L\n\twhile(i * i <= num) {\n\t\t\twhile(num % i == 0L) {\n\t\t\t\tfactors[i] = (factors[i]?:0L) + 1L\n\t\t\t\tnum /= i\n\t\t\t}\n\t\t\ti++\n\t}\n\tif(num > 1L) {\n\t\tfactors[num] = 1L\n\t}\n\treturn factors\n}\n\nfun permutations(src: List): List> {\n\tif(src.size == 1) return listOf(src)\n\tval perms = mutableListOf>()\n\tval insertElement = src[0]\n\tpermutations(src.drop(1)).forEach { perm ->\n\t\tfor(i in 0..perm.size) {\n\t\t\tval newPerm = perm.toMutableList()\n\t\t\tnewPerm.add(i, insertElement)\n\t\t\tperms.add(newPerm.toList())\n\t\t}\n\t}\n\treturn perms\n}\n\n// return nCr, if you want nCr, please access v[n][r]\nfun combinations(n: Long): List> {\n\tval v = (0..n).map { (0..n).map{0L}.toMutableList() }.toMutableList()\n\tfor(i in 0 until v.size) {\n\t\tv[i][0] = 1L\n\t\tv[i][i] = 1L\n\t}\n\tfor(i in 0 until v.size) {\n\t\tfor(j in 1 until i) {\n\t\t\tv[i][j] = (v[i-1][j-1] + v[i-1][j]) % MOD\n\t\t}\n\t}\n\treturn v.map { it.toList() }.toList()\n}\n\nfun repeatedModPow(a: Long, n: Long, mod: Long): Long = \n\twhen {\n\t\tn == 0L -> 1L\n\t\tn == 1L -> a % mod\n\t\tn % 2L == 1L -> (a * repeatedModPow(a, n-1L, mod)) % mod\n\t\telse -> {\n\t\t\tval tmp = repeatedModPow(a, n / 2L, mod)\n\t\t\t(tmp * tmp) % mod\n\t\t}\n\t}\n\n// return nCr % MOD\nfun modnCkWithoutArray(n: Long, k: Long, mod: Long): Long {\n\tvar ret = 1L\n\tval min = Math.min(k, n-k)\n\t// まず分母の計算\n\tfor(i in n downTo (n - min + 1)) {\n\t\tret = ret * i % mod\n\t}\n\tfor(i in min downTo 1) {\n\t\tret = ret * repeatedModPow(i, (mod - 2L), mod) % mod\n\t}\n\treturn ret\n}\n\n// return nCr % MOD\nfun modnCk(n: Int, k: Int, mod: Long): Long {\n\tval factorials = Array(n+1) { 0L }.apply {\n\t\tthis[0] = 1L\n\t\tif(this.size > 1) this[1] = 1L\n\t}\n\tval inverses = Array(n+1) { 0L }.apply {\n\t\tthis[0] = 1L\n\t\tif(this.size > 1) this[1] = 1L\n\t}\n\tval factorialInverses = Array(n+1) { 0L }.apply {\n\t\tthis[0] = 1L\n\t\tif(this.size > 1) this[1] = 1L\n\t}\n\tfor(i in 2 .. n) {\n\t\tfactorials[i] = (factorials[i-1] * i.toLong() % mod)\n\t\tinverses[i] = (mod - inverses[mod.toInt() % i] * (mod / i.toLong()) % mod)\n\t\tfactorialInverses[i] = (factorialInverses[i-1] * inverses[i] % mod)\n\t}\n\n\treturn factorials[n] % mod * (factorialInverses[k] * factorialInverses[n-k] % mod) % mod\n}\n\n// should be a >= b\nfun gcd(a: Long, b: Long): Long = \n\tif(b == 0L) a else gcd(b, a % b)\n\n// shoud be a >= b\nfun lcm(a: Long, b: Long): Long = \n\ta / gcd(a, b) * b\n\nfun sumDigits(num_: Long): Long {\n\tvar num = num_\n\tvar rtn: Long = 0\n\twhile(num != 0.toLong()) {\n\t\tval tmp = num % 10\n\t\trtn += tmp\n\t\tnum /= 10\n\t}\n\treturn rtn\n}\n\nfun Double.isDecimal(): Boolean = ((this - Math.floor(this)) != 0.0)\n\n// Data Structures\n\nclass UnionFind(private val n: Int) {\n\tprivate val parent: Array = Array(n) { 0 }\n\tprivate val rank: Array = Array(n) { 0 }\n\tprivate val size: Array = Array(n) { 0 }\n\n\tinit {\n\t\tfor(i in 0 until n) {\n\t\t\tparent[i] = i\n\t\t\trank[i] = 1\n\t\t\tsize[i] = 1\n\t\t}\n\t}\n\n\tfun union(u: Int, v: Int) {\n\t\tvar x = root(u)\n\t\tvar y = root(v)\n\t\tif(x != y) {\n\t\t\tif(rank[y] < rank[x]) {\n\t\t\t\tval tmp = y \n\t\t\t\ty = x\n\t\t\t\tx = tmp \n\t\t\t}\n\t\t\tparent[x] = y\n\t\t\trank[y] += rank[x]\n\t\t\trank[x] = -1\n\t\t\tval totalSize = size[x] + size[y]\n\t\t\tsize[x] = totalSize\n\t\t\tsize[y] = totalSize\n\t\t}\n\t}\n\n\tfun root(u: Int): Int {\n\t\tvar x = u\n\t\twhile(parent[x] != x) {\n\t\t\tx = parent[x]\n\t\t}\n\t\treturn x \n\t}\n\n\tfun size(u: Int): Int = size[root(u)]\n}\n", "language": "Kotlin", "metadata": {"date": 1599016868, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p03545.html", "problem_id": "p03545", "resource_group": "medium_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/Kotlin/s020814164.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s020814164", "user_id": "u026686258"}, "prompt_components": {"gold_output": "1+2+2+2=7\n", "input_to_evaluate": "import java.io.PrintWriter\nimport java.util.*\nimport java.math.*\nimport java.lang.*\nimport kotlin.comparisons.*\n\nval pw = PrintWriter(System.out)\nval MOD: Long = (1e+9 + 7).toLong()\n\nfun dfs(i: Int, result: Int, nums: List, formula: String): String {\n\tif(i == 4) {\n\t\treturn if(result == 7) formula + \"=7\" else \"\"\n\t}\n\tval num = nums[i]\n\tval ansPlus = dfs(i+1, result + num, nums, formula + \"+$num\")\n\tval ansMinus = dfs(i+1, result - num, nums, formula + \"-$num\")\n\treturn if(ansPlus.isEmpty()) ansMinus else ansPlus\n}\n\nfun main(args: Array) {\n\tval nums = read().map { it.toString().toInt() }\n\tval ans = dfs(1, nums[0], nums, \"${nums[0]}\")\n\t\n\tprintln(ans)\n\n\tpw.flush()\n}\n\n/****** Declared Functions and Data Structures ******/\n// IO\nfun read() = readLine()!!\nfun readInt() = read().toInt()\nfun readLong() = read().toLong()\nfun readDouble() = read().toDouble()\nfun readListOfString() = read().split(\" \")\nfun readListOfInt() = readListOfString().map { it.toInt() }\nfun readListOfLong() = readListOfString().map { it.toLong() }\nfun readListOfDouble() = readListOfString().map { it.toDouble() }\n\nfun Double.format(digits: Int) = String.format(\"%.${digits}f\", this)\nfun Float.format(digits: Int) = String.format(\"%.${digits}f\", this)\n\nfun print(value: Any) { pw.print(value) }\nfun println(value : Any) { pw.println(value) }\n\n// Extensions\nfun List.toBuckets(): Map\n\t= this.groupBy { it }.mapValues { it.value.size }\n\nfun> Array.upperBound(element: T, fromIndex: Int=0, toIndex: Int=this.size): Int\n\t= this.toList().upperBound(element, fromIndex, toIndex)\n\nfun> List.upperBound(element: T, fromIndex: Int=0, toIndex: Int=this.size): Int {\n\tvar l = fromIndex\n\tvar r = toIndex\n\twhile(l < r) {\n\t\tval mid = (l+r) / 2\n\t\tif(element >= this[mid]) { \n\t\t\tl = mid + 1\n\t\t} else {\n\t\t\tr = mid\n\t\t}\n\t}\n\treturn l\n}\n\nfun> Array.lowerBound(element: T, fromIndex: Int=0, toIndex: Int=this.size): Int\n\t= this.toList().lowerBound(element, fromIndex, toIndex)\n\nfun> List.lowerBound(element: T, fromIndex: Int=0, toIndex: Int=this.size): Int {\n\tvar l = fromIndex\n\tvar r = toIndex\n\twhile(l < r) {\n\t\tval mid = (l+r) / 2\n\t\tif(element > this[mid]) { \n\t\t\tl = mid + 1\n\t\t} else {\n\t\t\tr = mid\n\t\t}\n\t}\n\treturn r \n}\n\nfun Map.toMutableMap(): MutableMap = HashMap(this)\n\n// Util Functions\nfun Long.makeDivisors(): List {\n\tval divisors = mutableListOf()\n\tfor(i in 1L .. Math.sqrt(this.toDouble()).toLong()+1L) {\n\t\tif(this % i == 0L) {\n\t\t\tdivisors.add(i)\n\t\t\tif(i != this/i) {\n\t\t\t\tdivisors.add(this/i)\n\t\t\t}\n\t\t}\n\t}\n\treturn divisors.distinct().sorted()\n}\n\nfun Long.isPrime(): Boolean {\n\tif(this==1L) return false\n\tfor(i in 2L .. Math.sqrt(this.toDouble()).toLong() + 1L) {\n\t\tif(this % i == 0L && this != i) {\n\t\t\treturn false\n\t\t}\n\t}\n\treturn true\n}\n\nfun Long.primeFactorize(): Map {\n\tval factors = mutableMapOf()\n\tvar num = this\n\tvar i = 2L\n\twhile(i * i <= num) {\n\t\t\twhile(num % i == 0L) {\n\t\t\t\tfactors[i] = (factors[i]?:0L) + 1L\n\t\t\t\tnum /= i\n\t\t\t}\n\t\t\ti++\n\t}\n\tif(num > 1L) {\n\t\tfactors[num] = 1L\n\t}\n\treturn factors\n}\n\nfun permutations(src: List): List> {\n\tif(src.size == 1) return listOf(src)\n\tval perms = mutableListOf>()\n\tval insertElement = src[0]\n\tpermutations(src.drop(1)).forEach { perm ->\n\t\tfor(i in 0..perm.size) {\n\t\t\tval newPerm = perm.toMutableList()\n\t\t\tnewPerm.add(i, insertElement)\n\t\t\tperms.add(newPerm.toList())\n\t\t}\n\t}\n\treturn perms\n}\n\n// return nCr, if you want nCr, please access v[n][r]\nfun combinations(n: Long): List> {\n\tval v = (0..n).map { (0..n).map{0L}.toMutableList() }.toMutableList()\n\tfor(i in 0 until v.size) {\n\t\tv[i][0] = 1L\n\t\tv[i][i] = 1L\n\t}\n\tfor(i in 0 until v.size) {\n\t\tfor(j in 1 until i) {\n\t\t\tv[i][j] = (v[i-1][j-1] + v[i-1][j]) % MOD\n\t\t}\n\t}\n\treturn v.map { it.toList() }.toList()\n}\n\nfun repeatedModPow(a: Long, n: Long, mod: Long): Long = \n\twhen {\n\t\tn == 0L -> 1L\n\t\tn == 1L -> a % mod\n\t\tn % 2L == 1L -> (a * repeatedModPow(a, n-1L, mod)) % mod\n\t\telse -> {\n\t\t\tval tmp = repeatedModPow(a, n / 2L, mod)\n\t\t\t(tmp * tmp) % mod\n\t\t}\n\t}\n\n// return nCr % MOD\nfun modnCkWithoutArray(n: Long, k: Long, mod: Long): Long {\n\tvar ret = 1L\n\tval min = Math.min(k, n-k)\n\t// まず分母の計算\n\tfor(i in n downTo (n - min + 1)) {\n\t\tret = ret * i % mod\n\t}\n\tfor(i in min downTo 1) {\n\t\tret = ret * repeatedModPow(i, (mod - 2L), mod) % mod\n\t}\n\treturn ret\n}\n\n// return nCr % MOD\nfun modnCk(n: Int, k: Int, mod: Long): Long {\n\tval factorials = Array(n+1) { 0L }.apply {\n\t\tthis[0] = 1L\n\t\tif(this.size > 1) this[1] = 1L\n\t}\n\tval inverses = Array(n+1) { 0L }.apply {\n\t\tthis[0] = 1L\n\t\tif(this.size > 1) this[1] = 1L\n\t}\n\tval factorialInverses = Array(n+1) { 0L }.apply {\n\t\tthis[0] = 1L\n\t\tif(this.size > 1) this[1] = 1L\n\t}\n\tfor(i in 2 .. n) {\n\t\tfactorials[i] = (factorials[i-1] * i.toLong() % mod)\n\t\tinverses[i] = (mod - inverses[mod.toInt() % i] * (mod / i.toLong()) % mod)\n\t\tfactorialInverses[i] = (factorialInverses[i-1] * inverses[i] % mod)\n\t}\n\n\treturn factorials[n] % mod * (factorialInverses[k] * factorialInverses[n-k] % mod) % mod\n}\n\n// should be a >= b\nfun gcd(a: Long, b: Long): Long = \n\tif(b == 0L) a else gcd(b, a % b)\n\n// shoud be a >= b\nfun lcm(a: Long, b: Long): Long = \n\ta / gcd(a, b) * b\n\nfun sumDigits(num_: Long): Long {\n\tvar num = num_\n\tvar rtn: Long = 0\n\twhile(num != 0.toLong()) {\n\t\tval tmp = num % 10\n\t\trtn += tmp\n\t\tnum /= 10\n\t}\n\treturn rtn\n}\n\nfun Double.isDecimal(): Boolean = ((this - Math.floor(this)) != 0.0)\n\n// Data Structures\n\nclass UnionFind(private val n: Int) {\n\tprivate val parent: Array = Array(n) { 0 }\n\tprivate val rank: Array = Array(n) { 0 }\n\tprivate val size: Array = Array(n) { 0 }\n\n\tinit {\n\t\tfor(i in 0 until n) {\n\t\t\tparent[i] = i\n\t\t\trank[i] = 1\n\t\t\tsize[i] = 1\n\t\t}\n\t}\n\n\tfun union(u: Int, v: Int) {\n\t\tvar x = root(u)\n\t\tvar y = root(v)\n\t\tif(x != y) {\n\t\t\tif(rank[y] < rank[x]) {\n\t\t\t\tval tmp = y \n\t\t\t\ty = x\n\t\t\t\tx = tmp \n\t\t\t}\n\t\t\tparent[x] = y\n\t\t\trank[y] += rank[x]\n\t\t\trank[x] = -1\n\t\t\tval totalSize = size[x] + size[y]\n\t\t\tsize[x] = totalSize\n\t\t\tsize[y] = totalSize\n\t\t}\n\t}\n\n\tfun root(u: Int): Int {\n\t\tvar x = u\n\t\twhile(parent[x] != x) {\n\t\t\tx = parent[x]\n\t\t}\n\t\treturn x \n\t}\n\n\tfun size(u: Int): Int = size[root(u)]\n}\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 6207, "cpu_time_ms": 99, "memory_kb": 34556}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s747609093", "group_id": "codeNet:p03545", "input_text": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val abcd = sc.next()\n\n var array = BooleanArray(3) { false }\n\n for (bit in 0..7) {\n if (bit and 0b100 > 0) {\n array[0] = true\n }\n if (bit and 0b010 > 0) {\n array[1] = true\n }\n if (bit and 0b001 > 0) {\n array[2] = true\n }\n\n var tmp = Character.getNumericValue(abcd[0])\n for (i in 1..3) {\n val c = Character.getNumericValue(abcd[i])\n if (array[i - 1]) {\n tmp += c\n } else {\n tmp -= c\n }\n }\n if (tmp == 7) {\n break\n }\n array = BooleanArray(4) { false }\n }\n\n val ans = mutableListOf()\n ans.add(abcd[0])\n for (i in 1..3) {\n if (array[i - 1]) {\n ans.add('+')\n } else {\n ans.add('-')\n }\n ans.add(abcd[i])\n }\n println(ans.joinToString(\"\") + \"=7\")\n\n\n}\n", "language": "Kotlin", "metadata": {"date": 1592055855, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03545.html", "problem_id": "p03545", "resource_group": "medium_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/Kotlin/s747609093.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s747609093", "user_id": "u323522006"}, "prompt_components": {"gold_output": "1+2+2+2=7\n", "input_to_evaluate": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val abcd = sc.next()\n\n var array = BooleanArray(3) { false }\n\n for (bit in 0..7) {\n if (bit and 0b100 > 0) {\n array[0] = true\n }\n if (bit and 0b010 > 0) {\n array[1] = true\n }\n if (bit and 0b001 > 0) {\n array[2] = true\n }\n\n var tmp = Character.getNumericValue(abcd[0])\n for (i in 1..3) {\n val c = Character.getNumericValue(abcd[i])\n if (array[i - 1]) {\n tmp += c\n } else {\n tmp -= c\n }\n }\n if (tmp == 7) {\n break\n }\n array = BooleanArray(4) { false }\n }\n\n val ans = mutableListOf()\n ans.add(abcd[0])\n for (i in 1..3) {\n if (array[i - 1]) {\n ans.add('+')\n } else {\n ans.add('-')\n }\n ans.add(abcd[i])\n }\n println(ans.joinToString(\"\") + \"=7\")\n\n\n}\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 184, "memory_kb": 31532}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s427633972", "group_id": "codeNet:p03545", "input_text": "fun main(args: Array) {\n val l = readLine()!!.split(\"\").subList(1,5).map { it.toInt() }\n val res =\n if (l[0]+l[1]+l[2]+l[3] == 7) \"${l[0]}+${l[1]}+${l[2]}+${l[3]}=7\"\n else if (l[0]-l[1]+l[2]+l[3] == 7) \"${l[0]}-${l[1]}+${l[2]}+${l[3]}=7\"\n else if (l[0]+l[1]-l[2]+l[3] == 7) \"${l[0]}+${l[1]}-${l[2]}+${l[3]}=7\"\n else if (l[0]+l[1]+l[2]-l[3] == 7) \"${l[0]}+${l[1]}+${l[2]}-${l[3]}=7\"\n else if (l[0]+l[1]-l[2]-l[3] == 7) \"${l[0]}+${l[1]}-${l[2]}-${l[3]}=7\"\n else if (l[0]-l[1]+l[2]-l[3] == 7) \"${l[0]}-${l[1]}+${l[2]}-${l[3]}=7\"\n else if (l[0]-l[1]-l[2]+l[3] == 7) \"${l[0]}-${l[1]}-${l[2]}+${l[3]}=7\"\n else \"${l[0]}-${l[1]}-${l[2]}-${l[3]}=7\"\n println(res)\n}\n", "language": "Kotlin", "metadata": {"date": 1589219615, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03545.html", "problem_id": "p03545", "resource_group": "medium_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/Kotlin/s427633972.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s427633972", "user_id": "u213256030"}, "prompt_components": {"gold_output": "1+2+2+2=7\n", "input_to_evaluate": "fun main(args: Array) {\n val l = readLine()!!.split(\"\").subList(1,5).map { it.toInt() }\n val res =\n if (l[0]+l[1]+l[2]+l[3] == 7) \"${l[0]}+${l[1]}+${l[2]}+${l[3]}=7\"\n else if (l[0]-l[1]+l[2]+l[3] == 7) \"${l[0]}-${l[1]}+${l[2]}+${l[3]}=7\"\n else if (l[0]+l[1]-l[2]+l[3] == 7) \"${l[0]}+${l[1]}-${l[2]}+${l[3]}=7\"\n else if (l[0]+l[1]+l[2]-l[3] == 7) \"${l[0]}+${l[1]}+${l[2]}-${l[3]}=7\"\n else if (l[0]+l[1]-l[2]-l[3] == 7) \"${l[0]}+${l[1]}-${l[2]}-${l[3]}=7\"\n else if (l[0]-l[1]+l[2]-l[3] == 7) \"${l[0]}-${l[1]}+${l[2]}-${l[3]}=7\"\n else if (l[0]-l[1]-l[2]+l[3] == 7) \"${l[0]}-${l[1]}-${l[2]}+${l[3]}=7\"\n else \"${l[0]}-${l[1]}-${l[2]}-${l[3]}=7\"\n println(res)\n}\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 729, "cpu_time_ms": 232, "memory_kb": 38072}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s330842213", "group_id": "codeNet:p03545", "input_text": "fun main(args: Array) {\n Program().solve()\n}\n\nclass Program {\n fun solve() {\n val sc = MyScanner()\n val s = sc.next()\n\n for (i in 0 until 8) {\n var ss = s[0] - '0'\n val op1 = if (i and 1 > 0) '+' else '-'\n val op2 = if (i and 2 > 0) '+' else '-'\n val op3 = if (i and 4 > 0) '+' else '-'\n ss += (s[1] - '0') * (if (i and 1 > 0) 1 else -1)\n ss += (s[2] - '0') * (if (i and 2 > 0) 1 else -1)\n ss += (s[3] - '0') * (if (i and 4 > 0) 1 else -1)\n if (ss == 7) {\n println(\"${s[0]}$op1${s[1]}$op2${s[2]}$op3${s[3]}=7\")\n return\n }\n }\n }\n}\n\n\nclass MyScanner() {\n private var index = 0\n private var line = listOf()\n\n fun next(): String {\n while (line.size <= index) {\n line = readLine()!!.split(' ')\n index = 0\n }\n return line[index++]\n }\n\n fun nextInt() = next().toInt()\n fun nextLong() = next().toLong()\n fun nextDouble() = next().toDouble()\n fun nextCharArray() = next().toCharArray()\n fun nextChar() = next()[0]\n\n fun strList(): List {\n index = line.size\n return readLine()!!.split(' ')\n }\n\n fun intList() = strList().map { it.toInt() }\n fun longList() = strList().map { it.toLong() }\n fun doubleList() = strList().map { it.toDouble() }\n}", "language": "Kotlin", "metadata": {"date": 1586519734, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03545.html", "problem_id": "p03545", "resource_group": "medium_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/Kotlin/s330842213.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s330842213", "user_id": "u194412908"}, "prompt_components": {"gold_output": "1+2+2+2=7\n", "input_to_evaluate": "fun main(args: Array) {\n Program().solve()\n}\n\nclass Program {\n fun solve() {\n val sc = MyScanner()\n val s = sc.next()\n\n for (i in 0 until 8) {\n var ss = s[0] - '0'\n val op1 = if (i and 1 > 0) '+' else '-'\n val op2 = if (i and 2 > 0) '+' else '-'\n val op3 = if (i and 4 > 0) '+' else '-'\n ss += (s[1] - '0') * (if (i and 1 > 0) 1 else -1)\n ss += (s[2] - '0') * (if (i and 2 > 0) 1 else -1)\n ss += (s[3] - '0') * (if (i and 4 > 0) 1 else -1)\n if (ss == 7) {\n println(\"${s[0]}$op1${s[1]}$op2${s[2]}$op3${s[3]}=7\")\n return\n }\n }\n }\n}\n\n\nclass MyScanner() {\n private var index = 0\n private var line = listOf()\n\n fun next(): String {\n while (line.size <= index) {\n line = readLine()!!.split(' ')\n index = 0\n }\n return line[index++]\n }\n\n fun nextInt() = next().toInt()\n fun nextLong() = next().toLong()\n fun nextDouble() = next().toDouble()\n fun nextCharArray() = next().toCharArray()\n fun nextChar() = next()[0]\n\n fun strList(): List {\n index = line.size\n return readLine()!!.split(' ')\n }\n\n fun intList() = strList().map { it.toInt() }\n fun longList() = strList().map { it.toLong() }\n fun doubleList() = strList().map { it.toDouble() }\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1420, "cpu_time_ms": 232, "memory_kb": 38088}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s199995073", "group_id": "codeNet:p03545", "input_text": "fun main(args: Array) {\n Program().solve()\n}\n\nclass Program {\n fun solve() {\n val sc = MyScanner()\n val s = sc.next()\n\n for (i in 0 until 8) {\n var ss = s[0] - '0'\n val op1 = if (i and 1 > 0) '+' else '-'\n val op2 = if (i and 2 > 0) '+' else '-'\n val op3 = if (i and 4 > 0) '+' else '-'\n ss += (s[1] - '0') * (if (i and 1 > 0) 1 else -1)\n ss += (s[2] - '0') * (if (i and 2 > 0) 1 else -1)\n ss += (s[3] - '0') * (if (i and 4 > 0) 1 else -1)\n if (ss == 7) {\n println(\"${s[0]}$op1${s[1]}$op2${s[2]}$op3${s[3]}\")\n return\n }\n }\n }\n}\n\n\nclass MyScanner() {\n private var index = 0\n private var line = listOf()\n\n fun next(): String {\n while (line.size <= index) {\n line = readLine()!!.split(' ')\n index = 0\n }\n return line[index++]\n }\n\n fun nextInt() = next().toInt()\n fun nextLong() = next().toLong()\n fun nextDouble() = next().toDouble()\n fun nextCharArray() = next().toCharArray()\n fun nextChar() = next()[0]\n\n fun strList(): List {\n index = line.size\n return readLine()!!.split(' ')\n }\n\n fun intList() = strList().map { it.toInt() }\n fun longList() = strList().map { it.toLong() }\n fun doubleList() = strList().map { it.toDouble() }\n}", "language": "Kotlin", "metadata": {"date": 1586519691, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03545.html", "problem_id": "p03545", "resource_group": "medium_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/Kotlin/s199995073.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s199995073", "user_id": "u194412908"}, "prompt_components": {"gold_output": "1+2+2+2=7\n", "input_to_evaluate": "fun main(args: Array) {\n Program().solve()\n}\n\nclass Program {\n fun solve() {\n val sc = MyScanner()\n val s = sc.next()\n\n for (i in 0 until 8) {\n var ss = s[0] - '0'\n val op1 = if (i and 1 > 0) '+' else '-'\n val op2 = if (i and 2 > 0) '+' else '-'\n val op3 = if (i and 4 > 0) '+' else '-'\n ss += (s[1] - '0') * (if (i and 1 > 0) 1 else -1)\n ss += (s[2] - '0') * (if (i and 2 > 0) 1 else -1)\n ss += (s[3] - '0') * (if (i and 4 > 0) 1 else -1)\n if (ss == 7) {\n println(\"${s[0]}$op1${s[1]}$op2${s[2]}$op3${s[3]}\")\n return\n }\n }\n }\n}\n\n\nclass MyScanner() {\n private var index = 0\n private var line = listOf()\n\n fun next(): String {\n while (line.size <= index) {\n line = readLine()!!.split(' ')\n index = 0\n }\n return line[index++]\n }\n\n fun nextInt() = next().toInt()\n fun nextLong() = next().toLong()\n fun nextDouble() = next().toDouble()\n fun nextCharArray() = next().toCharArray()\n fun nextChar() = next()[0]\n\n fun strList(): List {\n index = line.size\n return readLine()!!.split(' ')\n }\n\n fun intList() = strList().map { it.toInt() }\n fun longList() = strList().map { it.toLong() }\n fun doubleList() = strList().map { it.toDouble() }\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1418, "cpu_time_ms": 238, "memory_kb": 38340}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s158432078", "group_id": "codeNet:p03545", "input_text": "import kotlin.system.exitProcess\n\nfun main(args: Array) {\n val input = readLine()!!\n var numbers = mutableListOf()\n for (i in 0..input.length - 1){\n numbers.add(Integer.parseInt(input[i].toString()))\n }\n solve(1, numbers, numbers[0], \"${numbers[0]}\")\n}\n\nfun solve(index: Int, numbers: List, answer: Int, expr: String) {\n when {\n answer == 7 -> {\n println(\"$expr=7\")\n exitProcess(0)\n }\n index == numbers.size -> return\n else -> {\n solve(index + 1, numbers, answer + numbers[index], \"$expr+${numbers[index]}\")\n solve(index + 1, numbers, answer - numbers[index], \"$expr-${numbers[index]}\")\n }\n }\n}\n", "language": "Kotlin", "metadata": {"date": 1550718899, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03545.html", "problem_id": "p03545", "resource_group": "medium_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/Kotlin/s158432078.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s158432078", "user_id": "u562388762"}, "prompt_components": {"gold_output": "1+2+2+2=7\n", "input_to_evaluate": "import kotlin.system.exitProcess\n\nfun main(args: Array) {\n val input = readLine()!!\n var numbers = mutableListOf()\n for (i in 0..input.length - 1){\n numbers.add(Integer.parseInt(input[i].toString()))\n }\n solve(1, numbers, numbers[0], \"${numbers[0]}\")\n}\n\nfun solve(index: Int, numbers: List, answer: Int, expr: String) {\n when {\n answer == 7 -> {\n println(\"$expr=7\")\n exitProcess(0)\n }\n index == numbers.size -> return\n else -> {\n solve(index + 1, numbers, answer + numbers[index], \"$expr+${numbers[index]}\")\n solve(index + 1, numbers, answer - numbers[index], \"$expr-${numbers[index]}\")\n }\n }\n}\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 720, "cpu_time_ms": 213, "memory_kb": 33696}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s983416241", "group_id": "codeNet:p03547", "input_text": "import java.io.PrintWriter\nimport java.util.*\nimport java.math.*\nimport java.lang.*\n\nval pw = PrintWriter(System.out)\nval MOD: Long = (1e+9 + 7).toLong()\n\nfun main(args: Array) {\n val (x, y) = readListOfString()\n println(if(x == y) \"=\" else if(x > y) \">\" else \"<\")\n pw.flush()\n}\n\n/****** Decrared Functions and Data Structures ******/\n// IO\nfun read() = readLine()!!\nfun readInt() = read().toInt()\nfun readLong() = read().toLong()\nfun readDouble() = read().toDouble()\nfun readListOfString() = read().split(\" \")\nfun readListOfInt() = readListOfString().map { it.toInt() }\nfun readListOfLong() = readListOfString().map { it.toLong() }\nfun readListOfDouble() = readListOfString().map { it.toDouble() }\n\nfun Double.format(digits: Int) = String.format(\"%.${digits}f\", this)\nfun Float.format(digits: Int) = String.format(\"%.${digits}f\", this)\n\nfun print(value: Any) { pw.print(value) }\nfun println(value : Any) { pw.println(value) }\n\nfun permutations(src: List): List> {\n if(src.size == 1) return listOf(src)\n val perms = mutableListOf>()\n val insertElement = src[0]\n permutations(src.drop(1)).forEach { perm ->\n for(i in 0..perm.size) {\n val newPerm = perm.toMutableList()\n newPerm.add(i, insertElement)\n perms.add(newPerm.toList())\n }\n }\n return perms\n}\n\n// return nCr, if you want nCr, please access v[n][r]\nfun combinations(n: Long): List> {\n val v = (0..n).map { (0..n).map{0L}.toMutableList() }.toMutableList()\n for(i in 0 until v.size) {\n v[i][0] = 1L\n v[i][i] = 1L\n }\n for(i in 0 until v.size) {\n for(j in 1 until i) {\n v[i][j] = (v[i-1][j-1] + v[i-1][j] % MOD)\n }\n }\n return v.map { it.toList() }.toList()\n}\n\nfun gcd(a: Long, b: Long): Long = \n if(b != 0L) a else gcd(b, a % b)\n\nfun lcm(a: Long, b: Long) = \n if(b==0L) a else gcd(b, a % b)\n\nfun sumDigits(num_: Long): Long {\n var num = num_\n var rtn: Long = 0\n while(num != 0.toLong()) {\n val tmp = num % 10\n rtn += tmp\n num /= 10\n }\n return rtn\n}\n\nfun isDecimal(v: Double): Boolean = ((v - Math.floor(v)) != 0.0)\n\n// Data Structures\nclass Stack(private var st: MutableList = mutableListOf()) {\n fun isEmpty() = st.isEmpty()\n fun top(): T = st.last()\n fun push(e: T) { st.add(e) }\n fun pop() { st = st.dropLast(1).toMutableList() }\n}\n\nclass Queue(private var que: MutableList = mutableListOf()) {\n fun isEmpty() = que.isEmpty()\n fun top(): T = que.first()\n fun push(e: T) { que.add(e) }\n fun pop() { que = que.drop(1).toMutableList() }\n}\n", "language": "Kotlin", "metadata": {"date": 1564021049, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03547.html", "problem_id": "p03547", "resource_group": "medium_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/Kotlin/s983416241.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s983416241", "user_id": "u026686258"}, "prompt_components": {"gold_output": "<\n", "input_to_evaluate": "import java.io.PrintWriter\nimport java.util.*\nimport java.math.*\nimport java.lang.*\n\nval pw = PrintWriter(System.out)\nval MOD: Long = (1e+9 + 7).toLong()\n\nfun main(args: Array) {\n val (x, y) = readListOfString()\n println(if(x == y) \"=\" else if(x > y) \">\" else \"<\")\n pw.flush()\n}\n\n/****** Decrared Functions and Data Structures ******/\n// IO\nfun read() = readLine()!!\nfun readInt() = read().toInt()\nfun readLong() = read().toLong()\nfun readDouble() = read().toDouble()\nfun readListOfString() = read().split(\" \")\nfun readListOfInt() = readListOfString().map { it.toInt() }\nfun readListOfLong() = readListOfString().map { it.toLong() }\nfun readListOfDouble() = readListOfString().map { it.toDouble() }\n\nfun Double.format(digits: Int) = String.format(\"%.${digits}f\", this)\nfun Float.format(digits: Int) = String.format(\"%.${digits}f\", this)\n\nfun print(value: Any) { pw.print(value) }\nfun println(value : Any) { pw.println(value) }\n\nfun permutations(src: List): List> {\n if(src.size == 1) return listOf(src)\n val perms = mutableListOf>()\n val insertElement = src[0]\n permutations(src.drop(1)).forEach { perm ->\n for(i in 0..perm.size) {\n val newPerm = perm.toMutableList()\n newPerm.add(i, insertElement)\n perms.add(newPerm.toList())\n }\n }\n return perms\n}\n\n// return nCr, if you want nCr, please access v[n][r]\nfun combinations(n: Long): List> {\n val v = (0..n).map { (0..n).map{0L}.toMutableList() }.toMutableList()\n for(i in 0 until v.size) {\n v[i][0] = 1L\n v[i][i] = 1L\n }\n for(i in 0 until v.size) {\n for(j in 1 until i) {\n v[i][j] = (v[i-1][j-1] + v[i-1][j] % MOD)\n }\n }\n return v.map { it.toList() }.toList()\n}\n\nfun gcd(a: Long, b: Long): Long = \n if(b != 0L) a else gcd(b, a % b)\n\nfun lcm(a: Long, b: Long) = \n if(b==0L) a else gcd(b, a % b)\n\nfun sumDigits(num_: Long): Long {\n var num = num_\n var rtn: Long = 0\n while(num != 0.toLong()) {\n val tmp = num % 10\n rtn += tmp\n num /= 10\n }\n return rtn\n}\n\nfun isDecimal(v: Double): Boolean = ((v - Math.floor(v)) != 0.0)\n\n// Data Structures\nclass Stack(private var st: MutableList = mutableListOf()) {\n fun isEmpty() = st.isEmpty()\n fun top(): T = st.last()\n fun push(e: T) { st.add(e) }\n fun pop() { st = st.dropLast(1).toMutableList() }\n}\n\nclass Queue(private var que: MutableList = mutableListOf()) {\n fun isEmpty() = que.isEmpty()\n fun top(): T = que.first()\n fun push(e: T) { que.add(e) }\n fun pop() { que = que.drop(1).toMutableList() }\n}\n", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2643, "cpu_time_ms": 235, "memory_kb": 37840}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s087056741", "group_id": "codeNet:p03549", "input_text": "fun main(args : Array) {\n val (N, M) = readLine()!!.split(\" \").map { it.toInt() }\n val timePerTry = 100 * (N-M) + 1900 * M\n\n\n var anser = 0.0\n val X = 1.0 / Math.pow(2.0, M.toDouble())\n (1..10000).forEach {\n anser += it * timePerTry * Math.pow((1.0-X), (it - 1).toDouble()) * X\n }\n println(Math.round(anser).toInt())\n}", "language": "Kotlin", "metadata": {"date": 1564731411, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03549.html", "problem_id": "p03549", "resource_group": "medium_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/Kotlin/s087056741.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s087056741", "user_id": "u861095163"}, "prompt_components": {"gold_output": "3800\n", "input_to_evaluate": "fun main(args : Array) {\n val (N, M) = readLine()!!.split(\" \").map { it.toInt() }\n val timePerTry = 100 * (N-M) + 1900 * M\n\n\n var anser = 0.0\n val X = 1.0 / Math.pow(2.0, M.toDouble())\n (1..10000).forEach {\n anser += it * timePerTry * Math.pow((1.0-X), (it - 1).toDouble()) * X\n }\n println(Math.round(anser).toInt())\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 257, "memory_kb": 37844}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s224813726", "group_id": "codeNet:p03550", "input_text": "import java.lang.Math\nimport kotlin.comparisons.*\n\nval MOD: Int = 1000000000 + 7\nval MODL: Long = MOD.toLong()\n\nfun main(args: Array)\n{\n val (n, z, w) = read().split().toInt()\n val a = read().split().toInt()\n\n val score1 = Math.abs(w - a[n-1])\n val score2 = Math.abs(a[n-2] - a[n-1])\n\n println(Math.max(score1, score2))\n}\n\nfun read(): String = readLine()!!\nfun CharSequence.split(): List = this.split(\" \")\nfun Iterable.toInt(): List = this.map{it.toInt()}\n", "language": "Kotlin", "metadata": {"date": 1578865917, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03550.html", "problem_id": "p03550", "resource_group": "medium_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/Kotlin/s224813726.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s224813726", "user_id": "u118477733"}, "prompt_components": {"gold_output": "900\n", "input_to_evaluate": "import java.lang.Math\nimport kotlin.comparisons.*\n\nval MOD: Int = 1000000000 + 7\nval MODL: Long = MOD.toLong()\n\nfun main(args: Array)\n{\n val (n, z, w) = read().split().toInt()\n val a = read().split().toInt()\n\n val score1 = Math.abs(w - a[n-1])\n val score2 = Math.abs(a[n-2] - a[n-1])\n\n println(Math.max(score1, score2))\n}\n\nfun read(): String = readLine()!!\nfun CharSequence.split(): List = this.split(\" \")\nfun Iterable.toInt(): List = this.map{it.toInt()}\n", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 500, "cpu_time_ms": 300, "memory_kb": 38776}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s635228668", "group_id": "codeNet:p03555", "input_text": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val c1 = sc.next()\n val c2 = sc.next()\n println(problem077a(c1, c2))\n}\n\nfun problem077a(c1: String, c2: String): String {\n return if (c1 == c2.reversed() && c1.reversed() == c2) \"Yes\" else \"No\"\n}", "language": "Kotlin", "metadata": {"date": 1592006685, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03555.html", "problem_id": "p03555", "resource_group": "medium_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/Kotlin/s635228668.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s635228668", "user_id": "u073232808"}, "prompt_components": {"gold_output": "YES\n", "input_to_evaluate": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val c1 = sc.next()\n val c2 = sc.next()\n println(problem077a(c1, c2))\n}\n\nfun problem077a(c1: String, c2: String): String {\n return if (c1 == c2.reversed() && c1.reversed() == c2) \"Yes\" else \"No\"\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 294, "cpu_time_ms": 176, "memory_kb": 29484}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s085305142", "group_id": "codeNet:p03556", "input_text": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val p = Math.floor(Math.sqrt(sc.nextDouble())).toInt()\n println(p * p)\n}", "language": "Kotlin", "metadata": {"date": 1583199759, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03556.html", "problem_id": "p03556", "resource_group": "medium_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/Kotlin/s085305142.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s085305142", "user_id": "u733811860"}, "prompt_components": {"gold_output": "9\n", "input_to_evaluate": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val p = Math.floor(Math.sqrt(sc.nextDouble())).toInt()\n println(p * p)\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 189, "memory_kb": 29596}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s504097914", "group_id": "codeNet:p03556", "input_text": "fun main(args: Array) {\n val n = readInputLine().toLong()\n\n for (i in 1 until Int.MAX_VALUE) {\n if (i * i > n) {\n println((i - 1) * (i - 1))\n break\n }\n }\n}\n \nfun readInputLine(): String {\n return readLine()!!\n}\n", "language": "Kotlin", "metadata": {"date": 1561308433, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03556.html", "problem_id": "p03556", "resource_group": "medium_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/Kotlin/s504097914.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s504097914", "user_id": "u505558493"}, "prompt_components": {"gold_output": "9\n", "input_to_evaluate": "fun main(args: Array) {\n val n = readInputLine().toLong()\n\n for (i in 1 until Int.MAX_VALUE) {\n if (i * i > n) {\n println((i - 1) * (i - 1))\n break\n }\n }\n}\n \nfun readInputLine(): String {\n return readLine()!!\n}\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 214, "memory_kb": 33812}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s013707347", "group_id": "codeNet:p03556", "input_text": "fun main(args: Array) {\n val n= readLine()!!.toInt()\n val rtn = Math.sqrt(n.toDouble()).toLong()\n println(rtn*rtn)\n}", "language": "Kotlin", "metadata": {"date": 1543159880, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03556.html", "problem_id": "p03556", "resource_group": "medium_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/Kotlin/s013707347.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s013707347", "user_id": "u227189389"}, "prompt_components": {"gold_output": "9\n", "input_to_evaluate": "fun main(args: Array) {\n val n= readLine()!!.toInt()\n val rtn = Math.sqrt(n.toDouble()).toLong()\n println(rtn*rtn)\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 210, "memory_kb": 33468}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s391449168", "group_id": "codeNet:p03557", "input_text": "fun main(args: Array) {\n val n = readInteger()\n val aList = readIntegerList().sorted()\n val bList = readIntegerList().sorted()\n val cList = readIntegerList().sorted()\n\n var ans = 0L\n for (i in bList) {\n val aCount = lowerBound(aList, i)\n val cCount = cList.size - lowerBound(cList, i + 1)\n\n ans += aCount.toLong() * cCount\n }\n\n println(ans)\n}\n\nfun lowerBound(aList: List, i: Int): Int {\n var left = -1\n var right = aList.size\n while (right - left > 1) {\n var center = (right + left) / 2\n if (i <= aList[center]) {\n right = center\n } else {\n left = center\n }\n }\n\n return right\n}\n\nfun readInteger() = readLine()!!.toInt()\nfun readLong() = readLine()!!.toLong()\nfun readStringList() = readLine()!!.split(\" \")\nfun readIntegerList() = readStringList().map(String::toInt)\nfun readLongList() = readStringList().map(String::toLong)\n", "language": "Kotlin", "metadata": {"date": 1582605540, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03557.html", "problem_id": "p03557", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03557/input.txt", "sample_output_relpath": "derived/input_output/data/p03557/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03557/Kotlin/s391449168.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s391449168", "user_id": "u784448849"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "fun main(args: Array) {\n val n = readInteger()\n val aList = readIntegerList().sorted()\n val bList = readIntegerList().sorted()\n val cList = readIntegerList().sorted()\n\n var ans = 0L\n for (i in bList) {\n val aCount = lowerBound(aList, i)\n val cCount = cList.size - lowerBound(cList, i + 1)\n\n ans += aCount.toLong() * cCount\n }\n\n println(ans)\n}\n\nfun lowerBound(aList: List, i: Int): Int {\n var left = -1\n var right = aList.size\n while (right - left > 1) {\n var center = (right + left) / 2\n if (i <= aList[center]) {\n right = center\n } else {\n left = center\n }\n }\n\n return right\n}\n\nfun readInteger() = readLine()!!.toInt()\nfun readLong() = readLine()!!.toLong()\nfun readStringList() = readLine()!!.split(\" \")\nfun readIntegerList() = readStringList().map(String::toInt)\nfun readLongList() = readStringList().map(String::toLong)\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": "p03557", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 948, "cpu_time_ms": 1359, "memory_kb": 100108}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s241097353", "group_id": "codeNet:p03557", "input_text": "fun main(args: Array) {\n abc077c()\n}\n\nfun abc077c() {\n val n = readLine()!!.toInt()\n val aList = readLine()!!.split(\" \").map { it.toInt() }\n .sorted()\n val bList = readLine()!!.split(\" \").map { it.toInt() }\n .sorted()\n val cList = readLine()!!.split(\" \").map { it.toInt() }\n .sorted()\n\n val patterns = bList.map { b ->\n val subA = binarySearch(aList, b)\n val subC = cList.size - binarySearch(cList, b + 1)\n subA * subC\n }.sum()\n\n println(patterns)\n}\n\n// list must be sorted\nprivate fun binarySearch(list: List, key: Int): Int {\n var ng = -1\n var ok = list.size\n\n while (Math.abs(ok - ng) > 1) {\n val mid = (ok + ng) / 2\n if (list[mid] >= key) ok = mid else ng = mid\n }\n return ok\n}\n", "language": "Kotlin", "metadata": {"date": 1571375468, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03557.html", "problem_id": "p03557", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03557/input.txt", "sample_output_relpath": "derived/input_output/data/p03557/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03557/Kotlin/s241097353.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s241097353", "user_id": "u139478771"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "fun main(args: Array) {\n abc077c()\n}\n\nfun abc077c() {\n val n = readLine()!!.toInt()\n val aList = readLine()!!.split(\" \").map { it.toInt() }\n .sorted()\n val bList = readLine()!!.split(\" \").map { it.toInt() }\n .sorted()\n val cList = readLine()!!.split(\" \").map { it.toInt() }\n .sorted()\n\n val patterns = bList.map { b ->\n val subA = binarySearch(aList, b)\n val subC = cList.size - binarySearch(cList, b + 1)\n subA * subC\n }.sum()\n\n println(patterns)\n}\n\n// list must be sorted\nprivate fun binarySearch(list: List, key: Int): Int {\n var ng = -1\n var ok = list.size\n\n while (Math.abs(ok - ng) > 1) {\n val mid = (ok + ng) / 2\n if (list[mid] >= key) ok = mid else ng = mid\n }\n return ok\n}\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": "p03557", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 790, "cpu_time_ms": 1496, "memory_kb": 110336}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s246852951", "group_id": "codeNet:p03557", "input_text": "import java.io.PrintWriter\nimport java.util.*\nimport java.math.*\nimport java.lang.*\n\nval pw = PrintWriter(System.out)\nval MOD: Long = (1e+9 + 7).toLong()\n\n\nfun> List.upperBound(fromIndex: Int=0, toIndex: Int=this.size-1, num: T): Int {\n var l = fromIndex\n var r = toIndex\n if(this[r] < num) return this.size\n while((r - l) > 1) {\n val mid = (r+l) / 2\n if(this[mid] > num) { \n r = mid\n } else {\n l = mid\n }\n }\n return if(this[l] <= num) r else l\n}\n\nfun> List.lowerBound(fromIndex: Int=0, toIndex: Int=this.size-1, num: T): Int {\n var l = fromIndex\n var r = toIndex\n if(this[l] > num) return -1\n while((r - l) > 1) {\n val mid = (r+l) / 2\n if(this[mid] >= num) { \n r = mid\n } else {\n l = mid\n }\n }\n return if(this[r] >= num) l else r\n}\n\nfun main(args: Array) {\n val n = readInt()\n val nl = n.toLong()\n val a = readListOfLong().sorted()\n val b = readListOfLong().sorted()\n val c = readListOfLong().sorted()\n\n var cnt = 0L\n b.forEach {\n val aIdx = a.lowerBound(num=it).toLong()\n val cIdx = c.upperBound(num=it).toLong()\n cnt += (aIdx+1L) * (nl - cIdx)\n }\n println(cnt)\n \n pw.flush()\n}\n\n/****** Decrared Functions and Data Structures ******/\n// IO\nfun read() = readLine()!!\nfun readInt() = read().toInt()\nfun readLong() = read().toLong()\nfun readDouble() = read().toDouble()\nfun readListOfString() = read().split(\" \")\nfun readListOfInt() = readListOfString().map { it.toInt() }\nfun readListOfLong() = readListOfString().map { it.toLong() }\nfun readListOfDouble() = readListOfString().map { it.toDouble() }\n\nfun Double.format(digits: Int) = String.format(\"%.${digits}f\", this)\nfun Float.format(digits: Int) = String.format(\"%.${digits}f\", this)\n\nfun print(value: Any) { pw.print(value) }\nfun println(value : Any) { pw.println(value) }\n\nfun permutations(src: List): List> {\n if(src.size == 1) return listOf(src)\n val perms = mutableListOf>()\n val insertElement = src[0]\n permutations(src.drop(1)).forEach { perm ->\n for(i in 0..perm.size) {\n val newPerm = perm.toMutableList()\n newPerm.add(i, insertElement)\n perms.add(newPerm.toList())\n }\n }\n return perms\n}\n\n// return nCr, if you want nCr, please access v[n][r]\nfun combinations(n: Long): List> {\n val v = (0..n).map { (0..n).map{0L}.toMutableList() }.toMutableList()\n for(i in 0 until v.size) {\n v[i][0] = 1L\n v[i][i] = 1L\n }\n for(i in 0 until v.size) {\n for(j in 1 until i) {\n v[i][j] = (v[i-1][j-1] + v[i-1][j] % MOD)\n }\n }\n return v.map { it.toList() }.toList()\n}\n\nfun gcd(a: Long, b: Long): Long = \n if(b != 0L) a else gcd(b, a % b)\n\nfun lcm(a: Long, b: Long) = \n if(b==0L) a else gcd(b, a % b)\n\nfun sumDigits(num_: Long): Long {\n var num = num_\n var rtn: Long = 0\n while(num != 0.toLong()) {\n val tmp = num % 10\n rtn += tmp\n num /= 10\n }\n return rtn\n}\n\nfun isDecimal(v: Double): Boolean = ((v - Math.floor(v)) != 0.0)\n\n// Data Structures\nclass Stack(private var st: MutableList = mutableListOf()) {\n fun isEmpty() = st.isEmpty()\n fun top(): T = st.last()\n fun push(e: T) { st.add(e) }\n fun pop() { st = st.dropLast(1).toMutableList() }\n}\n\nclass Queue(private var que: MutableList = mutableListOf()) {\n fun isEmpty() = que.isEmpty()\n fun top(): T = que.first()\n fun push(e: T) { que.add(e) }\n fun pop() { que = que.drop(1).toMutableList() }\n}\n", "language": "Kotlin", "metadata": {"date": 1569299234, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03557.html", "problem_id": "p03557", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03557/input.txt", "sample_output_relpath": "derived/input_output/data/p03557/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03557/Kotlin/s246852951.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s246852951", "user_id": "u026686258"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "import java.io.PrintWriter\nimport java.util.*\nimport java.math.*\nimport java.lang.*\n\nval pw = PrintWriter(System.out)\nval MOD: Long = (1e+9 + 7).toLong()\n\n\nfun> List.upperBound(fromIndex: Int=0, toIndex: Int=this.size-1, num: T): Int {\n var l = fromIndex\n var r = toIndex\n if(this[r] < num) return this.size\n while((r - l) > 1) {\n val mid = (r+l) / 2\n if(this[mid] > num) { \n r = mid\n } else {\n l = mid\n }\n }\n return if(this[l] <= num) r else l\n}\n\nfun> List.lowerBound(fromIndex: Int=0, toIndex: Int=this.size-1, num: T): Int {\n var l = fromIndex\n var r = toIndex\n if(this[l] > num) return -1\n while((r - l) > 1) {\n val mid = (r+l) / 2\n if(this[mid] >= num) { \n r = mid\n } else {\n l = mid\n }\n }\n return if(this[r] >= num) l else r\n}\n\nfun main(args: Array) {\n val n = readInt()\n val nl = n.toLong()\n val a = readListOfLong().sorted()\n val b = readListOfLong().sorted()\n val c = readListOfLong().sorted()\n\n var cnt = 0L\n b.forEach {\n val aIdx = a.lowerBound(num=it).toLong()\n val cIdx = c.upperBound(num=it).toLong()\n cnt += (aIdx+1L) * (nl - cIdx)\n }\n println(cnt)\n \n pw.flush()\n}\n\n/****** Decrared Functions and Data Structures ******/\n// IO\nfun read() = readLine()!!\nfun readInt() = read().toInt()\nfun readLong() = read().toLong()\nfun readDouble() = read().toDouble()\nfun readListOfString() = read().split(\" \")\nfun readListOfInt() = readListOfString().map { it.toInt() }\nfun readListOfLong() = readListOfString().map { it.toLong() }\nfun readListOfDouble() = readListOfString().map { it.toDouble() }\n\nfun Double.format(digits: Int) = String.format(\"%.${digits}f\", this)\nfun Float.format(digits: Int) = String.format(\"%.${digits}f\", this)\n\nfun print(value: Any) { pw.print(value) }\nfun println(value : Any) { pw.println(value) }\n\nfun permutations(src: List): List> {\n if(src.size == 1) return listOf(src)\n val perms = mutableListOf>()\n val insertElement = src[0]\n permutations(src.drop(1)).forEach { perm ->\n for(i in 0..perm.size) {\n val newPerm = perm.toMutableList()\n newPerm.add(i, insertElement)\n perms.add(newPerm.toList())\n }\n }\n return perms\n}\n\n// return nCr, if you want nCr, please access v[n][r]\nfun combinations(n: Long): List> {\n val v = (0..n).map { (0..n).map{0L}.toMutableList() }.toMutableList()\n for(i in 0 until v.size) {\n v[i][0] = 1L\n v[i][i] = 1L\n }\n for(i in 0 until v.size) {\n for(j in 1 until i) {\n v[i][j] = (v[i-1][j-1] + v[i-1][j] % MOD)\n }\n }\n return v.map { it.toList() }.toList()\n}\n\nfun gcd(a: Long, b: Long): Long = \n if(b != 0L) a else gcd(b, a % b)\n\nfun lcm(a: Long, b: Long) = \n if(b==0L) a else gcd(b, a % b)\n\nfun sumDigits(num_: Long): Long {\n var num = num_\n var rtn: Long = 0\n while(num != 0.toLong()) {\n val tmp = num % 10\n rtn += tmp\n num /= 10\n }\n return rtn\n}\n\nfun isDecimal(v: Double): Boolean = ((v - Math.floor(v)) != 0.0)\n\n// Data Structures\nclass Stack(private var st: MutableList = mutableListOf()) {\n fun isEmpty() = st.isEmpty()\n fun top(): T = st.last()\n fun push(e: T) { st.add(e) }\n fun pop() { st = st.dropLast(1).toMutableList() }\n}\n\nclass Queue(private var que: MutableList = mutableListOf()) {\n fun isEmpty() = que.isEmpty()\n fun top(): T = que.first()\n fun push(e: T) { que.add(e) }\n fun pop() { que = que.drop(1).toMutableList() }\n}\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": "p03557", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 3665, "cpu_time_ms": 1550, "memory_kb": 104044}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s497243023", "group_id": "codeNet:p03558", "input_text": "fun main(arg: Array) {\n val k = readLine()!!.toInt()\n if (k == 1) {\n println(1)\n return\n }\n val po: Array = Array(k) { null }\n po[1] = 1\n var searchSet = setOf(1)\n while (searchSet.isNotEmpty()) {\n val newSet: MutableSet = mutableSetOf()\n searchSet.forEach {\n val next1 = (it * 10) % k\n val next2 = (it + 1) % k\n if (po[next1] == null) {\n po[next1] = po[it]\n newSet.add(next1)\n } else if (po[next1]!! > po[it]!!) {\n po[next1] = po[it]\n }\n if (po[next2] == null) {\n po[next2] = po[it]!! + 1\n newSet.add(next2)\n } else if (po[next2]!! > po[it]!! + 1) {\n po[next2] = po[it]!! + 1\n }\n }\n searchSet = newSet\n }\n println(po[0])\n}\n", "language": "Kotlin", "metadata": {"date": 1559261080, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03558.html", "problem_id": "p03558", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03558/input.txt", "sample_output_relpath": "derived/input_output/data/p03558/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03558/Kotlin/s497243023.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s497243023", "user_id": "u880126159"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "fun main(arg: Array) {\n val k = readLine()!!.toInt()\n if (k == 1) {\n println(1)\n return\n }\n val po: Array = Array(k) { null }\n po[1] = 1\n var searchSet = setOf(1)\n while (searchSet.isNotEmpty()) {\n val newSet: MutableSet = mutableSetOf()\n searchSet.forEach {\n val next1 = (it * 10) % k\n val next2 = (it + 1) % k\n if (po[next1] == null) {\n po[next1] = po[it]\n newSet.add(next1)\n } else if (po[next1]!! > po[it]!!) {\n po[next1] = po[it]\n }\n if (po[next2] == null) {\n po[next2] = po[it]!! + 1\n newSet.add(next2)\n } else if (po[next2]!! > po[it]!! + 1) {\n po[next2] = po[it]!! + 1\n }\n }\n searchSet = newSet\n }\n println(po[0])\n}\n", "problem_context": "Score : 700 points\n\nProblem Statement\n\nFind the smallest possible sum of the digits in the decimal notation of a positive multiple of K.\n\nConstraints\n\n2 \\leq K \\leq 10^5\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 smallest possible sum of the digits in the decimal notation of a positive multiple of K.\n\nSample Input 1\n\n6\n\nSample Output 1\n\n3\n\n12=6×2 yields the smallest sum.\n\nSample Input 2\n\n41\n\nSample Output 2\n\n5\n\n11111=41×271 yields the smallest sum.\n\nSample Input 3\n\n79992\n\nSample Output 3\n\n36", "sample_input": "6\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03558", "source_text": "Score : 700 points\n\nProblem Statement\n\nFind the smallest possible sum of the digits in the decimal notation of a positive multiple of K.\n\nConstraints\n\n2 \\leq K \\leq 10^5\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 smallest possible sum of the digits in the decimal notation of a positive multiple of K.\n\nSample Input 1\n\n6\n\nSample Output 1\n\n3\n\n12=6×2 yields the smallest sum.\n\nSample Input 2\n\n41\n\nSample Output 2\n\n5\n\n11111=41×271 yields the smallest sum.\n\nSample Input 3\n\n79992\n\nSample Output 3\n\n36", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 890, "cpu_time_ms": 320, "memory_kb": 40580}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s603707186", "group_id": "codeNet:p03559", "input_text": "fun main(args: Array) {\n val n = readLine()!!.toInt()\n val an = readLine()!!.split(\" \").map(String::toInt).sorted()\n val bn = readLine()!!.split(\" \").map(String::toInt).sorted()\n val cn = readLine()!!.split(\" \").map(String::toInt).sorted()\n\n// an.joinToString(\",\").let(::println)\n// bn.joinToString(\",\").let(::println)\n// cn.joinToString(\",\").let(::println)\n\n fun lowerBound(list: List, key: Int): Int {\n var left = -1\n var right = list.size\n\n while (right - left > 1) {\n val mid = left + (right - left) / 2\n if (list[mid] >= key) {\n right = mid\n } else {\n left = mid\n }\n }\n return right\n\n }\n\n\n /**\n * key より大きい値の中から最小の index を返す\n * 該当するものがない場合、-1を返す\n */\n fun upperBound(list: List, key: Int): Int {\n\n var left = -1\n var right = list.size\n\n while (right - left > 1) {\n val mid = left + (right - left) / 2\n if (list[mid] > key) {\n right = mid\n } else {\n left = mid\n }\n }\n return right\n\n }\n\n\n var sum = 0L\n bn.forEach { b ->\n val a = lowerBound(an, b)\n val c = n - upperBound(cn, b)\n// println(b)\n// println(a)\n// println(c)\n sum += a.toLong() * c.toLong()\n }\n println(sum)\n}\n\n", "language": "Kotlin", "metadata": {"date": 1575228033, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03559.html", "problem_id": "p03559", "resource_group": "medium_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/Kotlin/s603707186.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s603707186", "user_id": "u085288971"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "fun main(args: Array) {\n val n = readLine()!!.toInt()\n val an = readLine()!!.split(\" \").map(String::toInt).sorted()\n val bn = readLine()!!.split(\" \").map(String::toInt).sorted()\n val cn = readLine()!!.split(\" \").map(String::toInt).sorted()\n\n// an.joinToString(\",\").let(::println)\n// bn.joinToString(\",\").let(::println)\n// cn.joinToString(\",\").let(::println)\n\n fun lowerBound(list: List, key: Int): Int {\n var left = -1\n var right = list.size\n\n while (right - left > 1) {\n val mid = left + (right - left) / 2\n if (list[mid] >= key) {\n right = mid\n } else {\n left = mid\n }\n }\n return right\n\n }\n\n\n /**\n * key より大きい値の中から最小の index を返す\n * 該当するものがない場合、-1を返す\n */\n fun upperBound(list: List, key: Int): Int {\n\n var left = -1\n var right = list.size\n\n while (right - left > 1) {\n val mid = left + (right - left) / 2\n if (list[mid] > key) {\n right = mid\n } else {\n left = mid\n }\n }\n return right\n\n }\n\n\n var sum = 0L\n bn.forEach { b ->\n val a = lowerBound(an, b)\n val c = n - upperBound(cn, b)\n// println(b)\n// println(a)\n// println(c)\n sum += a.toLong() * c.toLong()\n }\n println(sum)\n}\n\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1475, "cpu_time_ms": 1467, "memory_kb": 112456}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s054573009", "group_id": "codeNet:p03563", "input_text": "fun main(args: Array) {\n val r = readLine()!!.toInt()\n val g = readLine()!!.toInt()\n println(g * 2 - r)\n}\n", "language": "Kotlin", "metadata": {"date": 1579813891, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03563.html", "problem_id": "p03563", "resource_group": "medium_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/Kotlin/s054573009.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s054573009", "user_id": "u863309603"}, "prompt_components": {"gold_output": "2032\n", "input_to_evaluate": "fun main(args: Array) {\n val r = readLine()!!.toInt()\n val g = readLine()!!.toInt()\n println(g * 2 - r)\n}\n", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 207, "memory_kb": 31744}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s856580482", "group_id": "codeNet:p03564", "input_text": "fun main(args: Array) {\n val n = readLine()!!.toInt()\n val k = readLine()!!.toInt()\n var x=1\n repeat(n){\n x = Math.min(x*2,x+k)\n }\n println(x)\n}\n", "language": "Kotlin", "metadata": {"date": 1543019826, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03564.html", "problem_id": "p03564", "resource_group": "medium_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/Kotlin/s856580482.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s856580482", "user_id": "u227189389"}, "prompt_components": {"gold_output": "10\n", "input_to_evaluate": "fun main(args: Array) {\n val n = readLine()!!.toInt()\n val k = readLine()!!.toInt()\n var x=1\n repeat(n){\n x = Math.min(x*2,x+k)\n }\n println(x)\n}\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 207, "memory_kb": 29864}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s352410350", "group_id": "codeNet:p03566", "input_text": "import java.util.*\nimport kotlin.*\n\nimport java.io.InputStream\nimport java.lang.NumberFormatException\nimport java.lang.StringBuilder\n\n\nfun main(args: Array) {\n Program().solve()\n}\n\nclass Program {\n fun solve() {\n val sc = FastScanner()\n val n = sc.nextInt()\n val t = Array(n) { sc.nextInt() }\n val tSum = t.sum()\n val v = Array(n) { sc.nextInt() }\n val dp = Array(tSum + 1) { Array(101) { Double.MIN_VALUE } }\n val flag = Array(tSum + 1) { Array(101) { false } }\n dp[0][0] = 0.0\n flag[0][0] = true\n var index = 0\n var cnt = 0\n for (i in 0 until tSum) {\n for (j in 0..100) {\n if (!flag[i][j]) continue\n if (j + 1 <= v[index]) {\n dp[i + 1][j + 1] = Math.max(dp[i + 1][j + 1], dp[i][j] + j + 0.5)\n flag[i + 1][j + 1] = true\n }\n if (j - 1 >= 0) {\n dp[i + 1][j - 1] = Math.max(dp[i + 1][j - 1], dp[i][j] + j - 0.5)\n flag[i + 1][j - 1] = true\n }\n dp[i + 1][j] = Math.max(dp[i + 1][j], dp[i][j] + j + if (j < v[index]) 0.25 else 0.0)\n flag[i + 1][j] = true\n }\n cnt ++\n if(cnt >= t[index]) {\n index++\n cnt = 0\n }\n }\n println(dp[tSum][0])\n }\n}\n\n\nclass FastScanner {\n companion object {\n val input: InputStream = System.`in`\n val buffer = ByteArray(1024) { 0 }\n fun isPrintableChar(c: Int): Boolean = c in 33..126\n }\n\n var ptr = 0\n var buflen = 0\n private fun hasNextByte(): Boolean {\n if (ptr < buflen) {\n return true\n } else {\n ptr = 0\n buflen = input.read(buffer)\n if (buflen <= 0) {\n return false\n }\n }\n return true\n }\n\n private fun readByte(): Int = if (hasNextByte()) buffer[ptr++].toInt() else -1\n\n private fun skipUnprintable() {\n while (hasNextByte() && !isPrintableChar(buffer[ptr].toInt())) ptr++\n }\n\n fun hasNext(): Boolean {\n skipUnprintable()\n return hasNextByte()\n }\n\n fun next(): String {\n if (!hasNext()) throw NoSuchElementException()\n val sb = StringBuilder()\n var b = readByte()\n while (isPrintableChar(b)) {\n sb.appendCodePoint(b)\n b = readByte()\n }\n return sb.toString()\n }\n\n fun nextInt(): Int {\n if (!hasNext()) throw NoSuchElementException()\n var n = 0\n var b = readByte()\n // '-' = 45\n val minus = b == 45\n if (minus) {\n b = readByte()\n }\n\n // '0' = 48 '9' = 57\n if (b !in 48..57) {\n throw NumberFormatException()\n }\n\n while (true) {\n if (b in 48..57) {\n n *= 10\n n += b - 48\n } else if (b == -1 || !isPrintableChar(b)) {\n return if (minus) -n else n\n } else {\n throw NumberFormatException()\n }\n b = readByte()\n }\n }\n\n fun nextLong(): Long {\n if (!hasNext()) throw NoSuchElementException()\n var n = 0L\n var b = readByte()\n // '-' = 45\n val minus = b == 45\n if (minus) {\n b = readByte()\n }\n\n // '0' = 48 '9' = 57\n if (b !in 48..57) {\n throw NumberFormatException()\n }\n\n while (true) {\n if (b in 48..57) {\n n *= 10\n n += b - 48\n } else if (b == -1 || !isPrintableChar(b)) {\n return if (minus) -n else n\n } else {\n throw NumberFormatException()\n }\n b = readByte()\n }\n }\n\n fun nextDouble(): Double = next().toDouble()\n}\n", "language": "Kotlin", "metadata": {"date": 1585831972, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03566.html", "problem_id": "p03566", "resource_group": "medium_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/Kotlin/s352410350.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s352410350", "user_id": "u194412908"}, "prompt_components": {"gold_output": "2100.000000000000000\n", "input_to_evaluate": "import java.util.*\nimport kotlin.*\n\nimport java.io.InputStream\nimport java.lang.NumberFormatException\nimport java.lang.StringBuilder\n\n\nfun main(args: Array) {\n Program().solve()\n}\n\nclass Program {\n fun solve() {\n val sc = FastScanner()\n val n = sc.nextInt()\n val t = Array(n) { sc.nextInt() }\n val tSum = t.sum()\n val v = Array(n) { sc.nextInt() }\n val dp = Array(tSum + 1) { Array(101) { Double.MIN_VALUE } }\n val flag = Array(tSum + 1) { Array(101) { false } }\n dp[0][0] = 0.0\n flag[0][0] = true\n var index = 0\n var cnt = 0\n for (i in 0 until tSum) {\n for (j in 0..100) {\n if (!flag[i][j]) continue\n if (j + 1 <= v[index]) {\n dp[i + 1][j + 1] = Math.max(dp[i + 1][j + 1], dp[i][j] + j + 0.5)\n flag[i + 1][j + 1] = true\n }\n if (j - 1 >= 0) {\n dp[i + 1][j - 1] = Math.max(dp[i + 1][j - 1], dp[i][j] + j - 0.5)\n flag[i + 1][j - 1] = true\n }\n dp[i + 1][j] = Math.max(dp[i + 1][j], dp[i][j] + j + if (j < v[index]) 0.25 else 0.0)\n flag[i + 1][j] = true\n }\n cnt ++\n if(cnt >= t[index]) {\n index++\n cnt = 0\n }\n }\n println(dp[tSum][0])\n }\n}\n\n\nclass FastScanner {\n companion object {\n val input: InputStream = System.`in`\n val buffer = ByteArray(1024) { 0 }\n fun isPrintableChar(c: Int): Boolean = c in 33..126\n }\n\n var ptr = 0\n var buflen = 0\n private fun hasNextByte(): Boolean {\n if (ptr < buflen) {\n return true\n } else {\n ptr = 0\n buflen = input.read(buffer)\n if (buflen <= 0) {\n return false\n }\n }\n return true\n }\n\n private fun readByte(): Int = if (hasNextByte()) buffer[ptr++].toInt() else -1\n\n private fun skipUnprintable() {\n while (hasNextByte() && !isPrintableChar(buffer[ptr].toInt())) ptr++\n }\n\n fun hasNext(): Boolean {\n skipUnprintable()\n return hasNextByte()\n }\n\n fun next(): String {\n if (!hasNext()) throw NoSuchElementException()\n val sb = StringBuilder()\n var b = readByte()\n while (isPrintableChar(b)) {\n sb.appendCodePoint(b)\n b = readByte()\n }\n return sb.toString()\n }\n\n fun nextInt(): Int {\n if (!hasNext()) throw NoSuchElementException()\n var n = 0\n var b = readByte()\n // '-' = 45\n val minus = b == 45\n if (minus) {\n b = readByte()\n }\n\n // '0' = 48 '9' = 57\n if (b !in 48..57) {\n throw NumberFormatException()\n }\n\n while (true) {\n if (b in 48..57) {\n n *= 10\n n += b - 48\n } else if (b == -1 || !isPrintableChar(b)) {\n return if (minus) -n else n\n } else {\n throw NumberFormatException()\n }\n b = readByte()\n }\n }\n\n fun nextLong(): Long {\n if (!hasNext()) throw NoSuchElementException()\n var n = 0L\n var b = readByte()\n // '-' = 45\n val minus = b == 45\n if (minus) {\n b = readByte()\n }\n\n // '0' = 48 '9' = 57\n if (b !in 48..57) {\n throw NumberFormatException()\n }\n\n while (true) {\n if (b in 48..57) {\n n *= 10\n n += b - 48\n } else if (b == -1 || !isPrintableChar(b)) {\n return if (minus) -n else n\n } else {\n throw NumberFormatException()\n }\n b = readByte()\n }\n }\n\n fun nextDouble(): Double = next().toDouble()\n}\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 3913, "cpu_time_ms": 1348, "memory_kb": 136872}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s112620470", "group_id": "codeNet:p03569", "input_text": "import java.io.PrintWriter\nimport java.util.*\n\nfun main(args: Array) = IO().exec {\n val s = string()\n var i = 0\n var j = s.length - 1\n var cnt = 0\n while (i < j) {\n if (s[i] == s[j]) {\n i++\n j--\n } else if (s[i] == 'x' && s[j] != 'x') {\n cnt++\n i++\n } else if (s[i] != 'x' && s[j] == 'x') {\n cnt++\n j--\n } else {\n cnt = -1\n break\n }\n }\n println(cnt)\n}\n\nclass IO {\n val printable = 33..126\n val buffer = ByteArray(1024)\n var ptr = 0\n var buflen = 0\n val out = PrintWriter(System.out)\n fun hasNextByte(): Boolean {\n if (ptr < buflen) {\n return true\n } else {\n ptr = 0\n buflen = System.`in`.read(buffer)\n if (buflen <= 0) {\n return false\n }\n }\n return true\n }\n fun readByte(): Byte {\n return if (hasNextByte()) buffer[ptr++] else return -1\n }\n fun hasNext(): Boolean {\n while (hasNextByte() && buffer[ptr] !in printable) ptr++\n return hasNextByte()\n }\n fun string(): String {\n if (!hasNext()) throw NoSuchElementException()\n val sb = StringBuilder()\n var b = readByte()\n while (b in printable) {\n sb.appendCodePoint(b.toInt())\n b = readByte()\n }\n return sb.toString()\n }\n fun long(): Long {\n if (!hasNext()) throw NoSuchElementException()\n var n = 0L\n var minus = false\n var b = readByte()\n if (b == '-'.toByte()) {\n minus = true\n b = readByte()\n }\n if (b !in '0'.toByte()..'9'.toByte()) {\n throw NumberFormatException()\n }\n while (true) {\n if (b in '0'.toByte()..'9'.toByte()) {\n n *= 10\n n += b - '0'.toByte()\n } else if (b == (-1).toByte() || b !in printable) {\n return if (minus) -n else n\n } else {\n throw NumberFormatException()\n }\n b = readByte()\n }\n }\n fun int(): Int {\n val nl = long()\n if (nl !in Integer.MIN_VALUE..Integer.MAX_VALUE) throw NumberFormatException()\n return nl.toInt()\n }\n fun double(): Double {\n return string().toDouble()\n }\n fun print(obj: Any) = out.print(obj)\n fun print(i: Int) = out.print(i)\n fun print(l: Long) = out.print(l)\n fun println(obj: Any) = out.println(obj)\n fun println(i: Int) = out.println(i)\n fun println(l: Long) = out.println(l)\n inline fun exec(block: IO.() -> Unit) {\n block()\n out.flush()\n }\n}", "language": "Kotlin", "metadata": {"date": 1565056911, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03569.html", "problem_id": "p03569", "resource_group": "medium_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/Kotlin/s112620470.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s112620470", "user_id": "u095834727"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import java.io.PrintWriter\nimport java.util.*\n\nfun main(args: Array) = IO().exec {\n val s = string()\n var i = 0\n var j = s.length - 1\n var cnt = 0\n while (i < j) {\n if (s[i] == s[j]) {\n i++\n j--\n } else if (s[i] == 'x' && s[j] != 'x') {\n cnt++\n i++\n } else if (s[i] != 'x' && s[j] == 'x') {\n cnt++\n j--\n } else {\n cnt = -1\n break\n }\n }\n println(cnt)\n}\n\nclass IO {\n val printable = 33..126\n val buffer = ByteArray(1024)\n var ptr = 0\n var buflen = 0\n val out = PrintWriter(System.out)\n fun hasNextByte(): Boolean {\n if (ptr < buflen) {\n return true\n } else {\n ptr = 0\n buflen = System.`in`.read(buffer)\n if (buflen <= 0) {\n return false\n }\n }\n return true\n }\n fun readByte(): Byte {\n return if (hasNextByte()) buffer[ptr++] else return -1\n }\n fun hasNext(): Boolean {\n while (hasNextByte() && buffer[ptr] !in printable) ptr++\n return hasNextByte()\n }\n fun string(): String {\n if (!hasNext()) throw NoSuchElementException()\n val sb = StringBuilder()\n var b = readByte()\n while (b in printable) {\n sb.appendCodePoint(b.toInt())\n b = readByte()\n }\n return sb.toString()\n }\n fun long(): Long {\n if (!hasNext()) throw NoSuchElementException()\n var n = 0L\n var minus = false\n var b = readByte()\n if (b == '-'.toByte()) {\n minus = true\n b = readByte()\n }\n if (b !in '0'.toByte()..'9'.toByte()) {\n throw NumberFormatException()\n }\n while (true) {\n if (b in '0'.toByte()..'9'.toByte()) {\n n *= 10\n n += b - '0'.toByte()\n } else if (b == (-1).toByte() || b !in printable) {\n return if (minus) -n else n\n } else {\n throw NumberFormatException()\n }\n b = readByte()\n }\n }\n fun int(): Int {\n val nl = long()\n if (nl !in Integer.MIN_VALUE..Integer.MAX_VALUE) throw NumberFormatException()\n return nl.toInt()\n }\n fun double(): Double {\n return string().toDouble()\n }\n fun print(obj: Any) = out.print(obj)\n fun print(i: Int) = out.print(i)\n fun print(l: Long) = out.print(l)\n fun println(obj: Any) = out.println(obj)\n fun println(i: Int) = out.println(i)\n fun println(l: Long) = out.println(l)\n inline fun exec(block: IO.() -> Unit) {\n block()\n out.flush()\n }\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2718, "cpu_time_ms": 214, "memory_kb": 31520}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s927065587", "group_id": "codeNet:p03575", "input_text": "fun main(args: Array) {\n val (n, m) = readLine()!!.split(' ').map { it.toInt() }\n val edges = mutableListOf>()\n val g = Array(n + 1) { mutableListOf() }\n repeat(m) {\n val (a, b) = readLine()!!.split(' ').map { it.toInt() }\n edges.add(a to b)\n g[a].add(b)\n g[b].add(a)\n }\n\n fun dfs(i: Int): Boolean {\n val ignore = edges[i].let { setOf(it.first, it.second) }\n val visited = BooleanArray(n + 1) { false }\n\n fun rec(u: Int): Int {\n visited[u] = true\n var cnt = 1\n for (v in g[u]) {\n if (visited[v]) continue\n if (ignore.contains(u) && ignore.contains(v)) continue\n cnt += rec(v)\n }\n return cnt\n }\n\n return rec(1) < n\n }\n\n println((0 until m).count { dfs(it) })\n}", "language": "Kotlin", "metadata": {"date": 1592060693, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03575.html", "problem_id": "p03575", "resource_group": "medium_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/Kotlin/s927065587.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s927065587", "user_id": "u863309603"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "fun main(args: Array) {\n val (n, m) = readLine()!!.split(' ').map { it.toInt() }\n val edges = mutableListOf>()\n val g = Array(n + 1) { mutableListOf() }\n repeat(m) {\n val (a, b) = readLine()!!.split(' ').map { it.toInt() }\n edges.add(a to b)\n g[a].add(b)\n g[b].add(a)\n }\n\n fun dfs(i: Int): Boolean {\n val ignore = edges[i].let { setOf(it.first, it.second) }\n val visited = BooleanArray(n + 1) { false }\n\n fun rec(u: Int): Int {\n visited[u] = true\n var cnt = 1\n for (v in g[u]) {\n if (visited[v]) continue\n if (ignore.contains(u) && ignore.contains(v)) continue\n cnt += rec(v)\n }\n return cnt\n }\n\n return rec(1) < n\n }\n\n println((0 until m).count { dfs(it) })\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 i) {\n solve()\n pw.flush()\n}\n\nfun solve() {\n val (n, k) = nextIntList()\n val point = longAry2(n, 2)\n repeat(n) {\n val (x, y) = nextLongList()\n point[it][0] = x\n point[it][1] = y\n }\n val x = longAry(n)\n val y = longAry(n)\n for (i in 0 until n) {\n x[i] = point[i][0]\n y[i] = point[i][1]\n }\n x.sort()\n y.sort()\n var ans = LINF\n for (a in 0 until n - 1) {\n val leftX = x[a]\n for (b in 0 until n - 1) {\n val leftY = y[a]\n for (c in a + 1 until n) {\n val rightX = x[c]\n for (d in b + 1 until n) {\n val rightY = y[d]\n var count = 0\n for (i in 0 until n) {\n val nowX = point[i][0]\n val nowY = point[i][1]\n if (nowX in min(leftX, rightX)..max(leftX, rightX) && nowY in min(leftY, rightY)..max(leftY,rightY)) count++\n }\n if (count >= k) {\n val area = abs(rightX - leftX) * abs(rightY - leftY)\n ans = min(ans, area)\n }\n }\n }\n }\n }\n\n println(ans)\n\n\n}\n\n\nfun println(v: String) {\n pw.println(v)\n}\n\nfun print(v: String) {\n pw.print(v)\n}\n\nfun next() = readLine()!!\nfun nextInt() = next().toInt()\nfun nextLong() = next().toLong()\nfun nextDouble() = next().toDouble()\nfun nextList() = next().split(\" \").toMutableList()\nfun nextIntList(index: Int = 0) = next().split(\" \").map { it.toInt() + index }.toMutableList()\nfun nextLongList(index: Long = 0L) = next().split(\" \").map { it.toLong() + index }.toMutableList()\nfun nextDoubleList() = next().split(\" \").map { it.toDouble() }.toMutableList()\n\nfun ary(n: Int, init: String = \"\") = Array(n) { init }\nfun intAry(n: Int, init: Int = 0) = IntArray(n) { init }\nfun longAry(n: Int, init: Long = 0L) = LongArray(n) { init }\nfun doubleAry(n: Int, init: Double = 0.0) = DoubleArray(n) { init }\nfun ary2(n: Int, m: Int, init: String = \"\") = Array(n) { Array(m) { init } }\nfun intAry2(n: Int, m: Int, init: Int = 0) = Array(n) { IntArray(m) { init } }\nfun longAry2(n: Int, m: Int, init: Long = 0) = Array(n) { LongArray(m) { init } }\nfun doubleAry2(n: Int, m: Int, init: Double = 0.0) = Array(n) { DoubleArray(m) { init } }\nfun ary3(n: Int, m: Int, k: Int, init: String = \"\") = Array(n) { Array(m) { Array(k) { init } } }\nfun intAry3(n: Int, m: Int, k: Int, init: Int = 0) = Array(n) { Array(m) { IntArray(k) { init } } }\nfun longAry3(n: Int, m: Int, k: Int, init: Long = 0L) = Array(n) { Array(m) { LongArray(k) { init } } }\nfun doubleAry3(n: Int, m: Int, k: Int, init: Double = 0.0) = Array(n) { Array(m) { DoubleArray(k) { init } } }\n\nfun abs(n: Int): Int = Math.abs(n)\nfun abs(n: Long): Long = Math.abs(n)\nfun abs(n: Double): Double = Math.abs(n)\nfun max(a: Int = -INF, b: Int = -INF, c: Int = -INF, d: Int = -INF, e: Int = -INF): Int = listOf(a, b, c, d, e).max()!!\nfun max(a: Long = -LINF, b: Long = -LINF, c: Long = -LINF, d: Long = -LINF, e: Long = -LINF): Long =\n listOf(a, b, c, d, e).max()!!.toLong()\n\nfun min(a: Int = INF, b: Int = INF, c: Int = INF, d: Int = INF, e: Int = INF): Int = listOf(a, b, c, d, e).min()!!\nfun min(a: Long = LINF, b: Long = LINF, c: Long = LINF, d: Long = LINF, e: Long = LINF): Long =\n listOf(a, b, c, d, e).min()!!.toLong()\n\nfun gcd(a: Long, b: Long): Long = if (a % b == 0L) b else gcd(b, (a % b))\nfun lcm(a: Long, b: Long): Long = a / gcd(a, b) * b", "language": "Kotlin", "metadata": {"date": 1585965645, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03576.html", "problem_id": "p03576", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03576/input.txt", "sample_output_relpath": "derived/input_output/data/p03576/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03576/Kotlin/s507834064.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s507834064", "user_id": "u581625805"}, "prompt_components": {"gold_output": "21\n", "input_to_evaluate": "import java.io.*\nimport java.util.*\n\nval pw = PrintWriter(System.out)\nconst val MOD = 1000000007L\nconst val INF = 2147483647\nconst val LINF = 9223372036854775807L\n\nfun main(args: Array) {\n solve()\n pw.flush()\n}\n\nfun solve() {\n val (n, k) = nextIntList()\n val point = longAry2(n, 2)\n repeat(n) {\n val (x, y) = nextLongList()\n point[it][0] = x\n point[it][1] = y\n }\n val x = longAry(n)\n val y = longAry(n)\n for (i in 0 until n) {\n x[i] = point[i][0]\n y[i] = point[i][1]\n }\n x.sort()\n y.sort()\n var ans = LINF\n for (a in 0 until n - 1) {\n val leftX = x[a]\n for (b in 0 until n - 1) {\n val leftY = y[a]\n for (c in a + 1 until n) {\n val rightX = x[c]\n for (d in b + 1 until n) {\n val rightY = y[d]\n var count = 0\n for (i in 0 until n) {\n val nowX = point[i][0]\n val nowY = point[i][1]\n if (nowX in min(leftX, rightX)..max(leftX, rightX) && nowY in min(leftY, rightY)..max(leftY,rightY)) count++\n }\n if (count >= k) {\n val area = abs(rightX - leftX) * abs(rightY - leftY)\n ans = min(ans, area)\n }\n }\n }\n }\n }\n\n println(ans)\n\n\n}\n\n\nfun println(v: String) {\n pw.println(v)\n}\n\nfun print(v: String) {\n pw.print(v)\n}\n\nfun next() = readLine()!!\nfun nextInt() = next().toInt()\nfun nextLong() = next().toLong()\nfun nextDouble() = next().toDouble()\nfun nextList() = next().split(\" \").toMutableList()\nfun nextIntList(index: Int = 0) = next().split(\" \").map { it.toInt() + index }.toMutableList()\nfun nextLongList(index: Long = 0L) = next().split(\" \").map { it.toLong() + index }.toMutableList()\nfun nextDoubleList() = next().split(\" \").map { it.toDouble() }.toMutableList()\n\nfun ary(n: Int, init: String = \"\") = Array(n) { init }\nfun intAry(n: Int, init: Int = 0) = IntArray(n) { init }\nfun longAry(n: Int, init: Long = 0L) = LongArray(n) { init }\nfun doubleAry(n: Int, init: Double = 0.0) = DoubleArray(n) { init }\nfun ary2(n: Int, m: Int, init: String = \"\") = Array(n) { Array(m) { init } }\nfun intAry2(n: Int, m: Int, init: Int = 0) = Array(n) { IntArray(m) { init } }\nfun longAry2(n: Int, m: Int, init: Long = 0) = Array(n) { LongArray(m) { init } }\nfun doubleAry2(n: Int, m: Int, init: Double = 0.0) = Array(n) { DoubleArray(m) { init } }\nfun ary3(n: Int, m: Int, k: Int, init: String = \"\") = Array(n) { Array(m) { Array(k) { init } } }\nfun intAry3(n: Int, m: Int, k: Int, init: Int = 0) = Array(n) { Array(m) { IntArray(k) { init } } }\nfun longAry3(n: Int, m: Int, k: Int, init: Long = 0L) = Array(n) { Array(m) { LongArray(k) { init } } }\nfun doubleAry3(n: Int, m: Int, k: Int, init: Double = 0.0) = Array(n) { Array(m) { DoubleArray(k) { init } } }\n\nfun abs(n: Int): Int = Math.abs(n)\nfun abs(n: Long): Long = Math.abs(n)\nfun abs(n: Double): Double = Math.abs(n)\nfun max(a: Int = -INF, b: Int = -INF, c: Int = -INF, d: Int = -INF, e: Int = -INF): Int = listOf(a, b, c, d, e).max()!!\nfun max(a: Long = -LINF, b: Long = -LINF, c: Long = -LINF, d: Long = -LINF, e: Long = -LINF): Long =\n listOf(a, b, c, d, e).max()!!.toLong()\n\nfun min(a: Int = INF, b: Int = INF, c: Int = INF, d: Int = INF, e: Int = INF): Int = listOf(a, b, c, d, e).min()!!\nfun min(a: Long = LINF, b: Long = LINF, c: Long = LINF, d: Long = LINF, e: Long = LINF): Long =\n listOf(a, b, c, d, e).min()!!.toLong()\n\nfun gcd(a: Long, b: Long): Long = if (a % b == 0L) b else gcd(b, (a % b))\nfun lcm(a: Long, b: Long): Long = a / gcd(a, b) * b", "problem_context": "Score : 400 points\n\nProblem Statement\n\nWe have N points in a two-dimensional plane.\n\nThe coordinates of the i-th point (1 \\leq i \\leq N) are (x_i,y_i).\n\nLet us consider a rectangle whose sides are parallel to the coordinate axes that contains K or more of the N points in its interior.\n\nHere, points on the sides of the rectangle are considered to be in the interior.\n\nFind the minimum possible area of such a rectangle.\n\nConstraints\n\n2 \\leq K \\leq N \\leq 50\n\n-10^9 \\leq x_i,y_i \\leq 10^9 (1 \\leq i \\leq N)\n\nx_i≠x_j (1 \\leq i) {\n val (n, k) = readStrings().map(String::toInt)\n val pointList = arrayListOf()\n for (i in 1..n) {\n val (x, y) = readStrings().map(String::toInt)\n pointList.add(Point(x, y))\n }\n\n val verticalSorted = pointList.sortedBy { it.y }\n val horizontalSorted = pointList.sortedBy { it.x }\n\n var ans = Long.MAX_VALUE\n for (left in horizontalSorted) {\n for (right in horizontalSorted) {\n if (left.x >= right.x) {\n continue\n }\n\n for (top in verticalSorted) {\n if (!(top.x in left.x..right.x)) {\n continue\n }\n\n for (bottom in verticalSorted) {\n if (top.y >= bottom.y ||\n !(bottom.x in left.x..right.x)) {\n continue\n }\n\n val includedCount = pointList.count {\n it.x in left.x..right.x\n && it.y in top.y..bottom.y\n }\n\n if (includedCount < k) {\n continue\n }\n\n ans = Math.min(ans, (right.x - left.x).toLong() * (bottom.y - top.y).toLong())\n }\n }\n }\n }\n\n println(ans)\n}\n\nfun readStrings() = readLine()!!.split(\" \")\n\n\ndata class Point(val x: Int, val y: Int)\n", "language": "Kotlin", "metadata": {"date": 1573102017, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03576.html", "problem_id": "p03576", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03576/input.txt", "sample_output_relpath": "derived/input_output/data/p03576/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03576/Kotlin/s726948574.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s726948574", "user_id": "u784448849"}, "prompt_components": {"gold_output": "21\n", "input_to_evaluate": "fun main(args: Array) {\n val (n, k) = readStrings().map(String::toInt)\n val pointList = arrayListOf()\n for (i in 1..n) {\n val (x, y) = readStrings().map(String::toInt)\n pointList.add(Point(x, y))\n }\n\n val verticalSorted = pointList.sortedBy { it.y }\n val horizontalSorted = pointList.sortedBy { it.x }\n\n var ans = Long.MAX_VALUE\n for (left in horizontalSorted) {\n for (right in horizontalSorted) {\n if (left.x >= right.x) {\n continue\n }\n\n for (top in verticalSorted) {\n if (!(top.x in left.x..right.x)) {\n continue\n }\n\n for (bottom in verticalSorted) {\n if (top.y >= bottom.y ||\n !(bottom.x in left.x..right.x)) {\n continue\n }\n\n val includedCount = pointList.count {\n it.x in left.x..right.x\n && it.y in top.y..bottom.y\n }\n\n if (includedCount < k) {\n continue\n }\n\n ans = Math.min(ans, (right.x - left.x).toLong() * (bottom.y - top.y).toLong())\n }\n }\n }\n }\n\n println(ans)\n}\n\nfun readStrings() = readLine()!!.split(\" \")\n\n\ndata class Point(val x: Int, val y: Int)\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nWe have N points in a two-dimensional plane.\n\nThe coordinates of the i-th point (1 \\leq i \\leq N) are (x_i,y_i).\n\nLet us consider a rectangle whose sides are parallel to the coordinate axes that contains K or more of the N points in its interior.\n\nHere, points on the sides of the rectangle are considered to be in the interior.\n\nFind the minimum possible area of such a rectangle.\n\nConstraints\n\n2 \\leq K \\leq N \\leq 50\n\n-10^9 \\leq x_i,y_i \\leq 10^9 (1 \\leq i \\leq N)\n\nx_i≠x_j (1 \\leq i) {\n val (h, w, k) = readLine()!!.split(\" \").map { it.toInt() }\n for (y in 0..h) {\n for (x in 0..w) {\n if (y * (w - x) + (h - y) * x == k) {\n println(\"Yes\")\n return\n }\n }\n }\n println(\"No\")\n}\n", "language": "Kotlin", "metadata": {"date": 1523570082, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03592.html", "problem_id": "p03592", "resource_group": "medium_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/Kotlin/s933572771.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s933572771", "user_id": "u771276542"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "fun main(args: Array) {\n val (h, w, k) = readLine()!!.split(\" \").map { it.toInt() }\n for (y in 0..h) {\n for (x in 0..w) {\n if (y * (w - x) + (h - y) * x == k) {\n println(\"Yes\")\n return\n }\n }\n }\n println(\"No\")\n}\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 253, "cpu_time_ms": 241, "memory_kb": 36076}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s659803283", "group_id": "codeNet:p03593", "input_text": "fun main(arr: Array) {\n println(if(getAns()) \"Yes\" else \"No\")\n}\n\nfun getAns():Boolean {\n val (h,w) = readLine()!!.split(\" \").map { it.toInt() }\n val map = (1..h).map { readLine()!! }\n val cnt = mutableMapOf()\n map.forEach { line -> line.forEach { cnt[it] = (cnt[it]?:0)+1 } }\n if(h%2==0) {\n if(w%2==0) {\n return cnt.values.all { it%4==0 }\n } else {\n if(cnt.values.any{it%2!=0}) {\n return false\n }\n return cnt.values.filter { it%4!=0 && it%2==0 }.count()*2 <= h\n }\n } else {\n if(w%2==0) {\n if(cnt.values.any{it%2!=0}) {\n return false\n }\n return cnt.values.filter { it%4!=0 && it%2==0 }.count()*2 <= w\n } else {\n if(cnt.values.count { it%2!=0 } != 1) {\n return false\n }\n return cnt.values.filter { it%4!=0&&it%2==0 }.count()*2 <= w+h-2\n }\n }\n}\n", "language": "Kotlin", "metadata": {"date": 1600910315, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p03593.html", "problem_id": "p03593", "resource_group": "medium_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/Kotlin/s659803283.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s659803283", "user_id": "u269969976"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "fun main(arr: Array) {\n println(if(getAns()) \"Yes\" else \"No\")\n}\n\nfun getAns():Boolean {\n val (h,w) = readLine()!!.split(\" \").map { it.toInt() }\n val map = (1..h).map { readLine()!! }\n val cnt = mutableMapOf()\n map.forEach { line -> line.forEach { cnt[it] = (cnt[it]?:0)+1 } }\n if(h%2==0) {\n if(w%2==0) {\n return cnt.values.all { it%4==0 }\n } else {\n if(cnt.values.any{it%2!=0}) {\n return false\n }\n return cnt.values.filter { it%4!=0 && it%2==0 }.count()*2 <= h\n }\n } else {\n if(w%2==0) {\n if(cnt.values.any{it%2!=0}) {\n return false\n }\n return cnt.values.filter { it%4!=0 && it%2==0 }.count()*2 <= w\n } else {\n if(cnt.values.count { it%2!=0 } != 1) {\n return false\n }\n return cnt.values.filter { it%4!=0&&it%2==0 }.count()*2 <= w+h-2\n }\n }\n}\n", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 982, "cpu_time_ms": 154, "memory_kb": 38684}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s717265379", "group_id": "codeNet:p03599", "input_text": "\nfun main(arr:Array) {\n val ans = Proc(readLine()!!.split(\" \").map { it.toInt() }).getAns(0,0)\n println(\"%d %d\".format(ans.water + ans.sugar, ans.sugar))\n}\n\n\nclass Proc(inpt:List) {\n val water1 = inpt[0]\n val water2 = inpt[1]\n val sugar1 = inpt[2]\n val sugar2 = inpt[3]\n val maxSugarWater = inpt[4]\n val maxTotal = inpt[5]\n val dic = mutableMapOf>()\n fun getAns(sugar:Int, water:Int): SugarWater {\n if(!dic.containsKey(sugar)) {\n dic[sugar] = mutableMapOf()\n }\n dic[sugar]!![water]?.let { return it }\n if(sugar + water > maxTotal) {\n return SugarWater(0, water1)\n }\n if(sugar > maxSugarWater * (water / 100)) {\n return SugarWater(0, water1)\n }\n var ans = SugarWater(sugar, water)\n val ret = listOf(getAns(sugar+sugar1, water), getAns(sugar+sugar2, water), getAns(sugar, water +water1), getAns(sugar, water + water2)).sortedByDescending { it.getNoudo() }\n if(ret[0].getNoudo() > ans.getNoudo()) {\n ans = ret[0]\n }\n dic[sugar]!![water] = ans\n return ans\n }\n}\n\nclass SugarWater(val sugar:Int, val water:Int) {\n fun getNoudo():Double {\n if(sugar == 0 || water == 0) {\n return 0.toDouble()\n }\n return sugar.toDouble() / (water + sugar).toDouble()\n }\n}\n", "language": "Kotlin", "metadata": {"date": 1582594938, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03599.html", "problem_id": "p03599", "resource_group": "medium_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/Kotlin/s717265379.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s717265379", "user_id": "u269969976"}, "prompt_components": {"gold_output": "110 10\n", "input_to_evaluate": "\nfun main(arr:Array) {\n val ans = Proc(readLine()!!.split(\" \").map { it.toInt() }).getAns(0,0)\n println(\"%d %d\".format(ans.water + ans.sugar, ans.sugar))\n}\n\n\nclass Proc(inpt:List) {\n val water1 = inpt[0]\n val water2 = inpt[1]\n val sugar1 = inpt[2]\n val sugar2 = inpt[3]\n val maxSugarWater = inpt[4]\n val maxTotal = inpt[5]\n val dic = mutableMapOf>()\n fun getAns(sugar:Int, water:Int): SugarWater {\n if(!dic.containsKey(sugar)) {\n dic[sugar] = mutableMapOf()\n }\n dic[sugar]!![water]?.let { return it }\n if(sugar + water > maxTotal) {\n return SugarWater(0, water1)\n }\n if(sugar > maxSugarWater * (water / 100)) {\n return SugarWater(0, water1)\n }\n var ans = SugarWater(sugar, water)\n val ret = listOf(getAns(sugar+sugar1, water), getAns(sugar+sugar2, water), getAns(sugar, water +water1), getAns(sugar, water + water2)).sortedByDescending { it.getNoudo() }\n if(ret[0].getNoudo() > ans.getNoudo()) {\n ans = ret[0]\n }\n dic[sugar]!![water] = ans\n return ans\n }\n}\n\nclass SugarWater(val sugar:Int, val water:Int) {\n fun getNoudo():Double {\n if(sugar == 0 || water == 0) {\n return 0.toDouble()\n }\n return sugar.toDouble() / (water + sugar).toDouble()\n }\n}\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1397, "cpu_time_ms": 1092, "memory_kb": 146824}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s941370621", "group_id": "codeNet:p03602", "input_text": "import java.io.BufferedReader\nimport java.io.InputStreamReader\nimport java.io.StreamTokenizer\nimport java.util.*\n\nfun main(args: Array ) {\n val st = StreamTokenizer( BufferedReader( InputStreamReader( System.`in` ) ) )\n val n = st.nextInt()\n val e = Array( n, { IntArray( n ) } )\n val queue = PriorityQueue( n * n / 2 )\n for ( i in 0 until n ) {\n for ( j in 0 until n ) {\n e[i][j] = st.nextInt()\n if ( i < j ) queue.add( Edge( i, j, e[i][j] ) )\n }\n }\n val dist = Array( n, { LongArray( n, { Long.MAX_VALUE / 4 } ) } )\n for ( i in 0 until n ) dist[i][i] = 0\n var r = 0L\n while ( queue.isNotEmpty() ) {\n val edge = queue.poll()\n if ( dist[edge.u][edge.v] < edge.d ) {\n println( -1 )\n return\n }\n if ( dist[edge.u][edge.v] > edge.d ) {\n r += edge.d\n for ( i in 0 until n ) {\n for ( j in 0 until n ) {\n dist[i][j] = Math.min( dist[i][j],\n Math.min(\n dist[i][edge.u] + edge.d + dist[edge.v][j],\n dist[i][edge.v] + edge.d + dist[edge.u][j]\n )\n )\n }\n }\n }\n }\n for ( i in 0 until n ) {\n for ( j in 0 until n ) {\n if ( e[i][j].toLong() != dist[i][j] ) {\n println( -1 )\n return\n }\n }\n }\n println( r )\n}\n\ndata class Edge( val u: Int, val v: Int, val d: Int ) : Comparable {\n override fun compareTo( e: Edge ): Int {\n if ( d != e.d ) return Integer.compare( d, e.d )\n if ( u != e.u ) return Integer.compare( u, e.u )\n return Integer.compare( v, e.v )\n }\n}\n\nprivate fun StreamTokenizer.nextInt(): Int {\n nextToken()\n return nval.toInt()\n}\n", "language": "Kotlin", "metadata": {"date": 1505614235, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03602.html", "problem_id": "p03602", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03602/input.txt", "sample_output_relpath": "derived/input_output/data/p03602/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03602/Kotlin/s941370621.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s941370621", "user_id": "u088410567"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "import java.io.BufferedReader\nimport java.io.InputStreamReader\nimport java.io.StreamTokenizer\nimport java.util.*\n\nfun main(args: Array ) {\n val st = StreamTokenizer( BufferedReader( InputStreamReader( System.`in` ) ) )\n val n = st.nextInt()\n val e = Array( n, { IntArray( n ) } )\n val queue = PriorityQueue( n * n / 2 )\n for ( i in 0 until n ) {\n for ( j in 0 until n ) {\n e[i][j] = st.nextInt()\n if ( i < j ) queue.add( Edge( i, j, e[i][j] ) )\n }\n }\n val dist = Array( n, { LongArray( n, { Long.MAX_VALUE / 4 } ) } )\n for ( i in 0 until n ) dist[i][i] = 0\n var r = 0L\n while ( queue.isNotEmpty() ) {\n val edge = queue.poll()\n if ( dist[edge.u][edge.v] < edge.d ) {\n println( -1 )\n return\n }\n if ( dist[edge.u][edge.v] > edge.d ) {\n r += edge.d\n for ( i in 0 until n ) {\n for ( j in 0 until n ) {\n dist[i][j] = Math.min( dist[i][j],\n Math.min(\n dist[i][edge.u] + edge.d + dist[edge.v][j],\n dist[i][edge.v] + edge.d + dist[edge.u][j]\n )\n )\n }\n }\n }\n }\n for ( i in 0 until n ) {\n for ( j in 0 until n ) {\n if ( e[i][j].toLong() != dist[i][j] ) {\n println( -1 )\n return\n }\n }\n }\n println( r )\n}\n\ndata class Edge( val u: Int, val v: Int, val d: Int ) : Comparable {\n override fun compareTo( e: Edge ): Int {\n if ( d != e.d ) return Integer.compare( d, e.d )\n if ( u != e.u ) return Integer.compare( u, e.u )\n return Integer.compare( v, e.v )\n }\n}\n\nprivate fun StreamTokenizer.nextInt(): Int {\n nextToken()\n return nval.toInt()\n}\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": "p03602", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1904, "cpu_time_ms": 599, "memory_kb": 41244}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s227757896", "group_id": "codeNet:p03605", "input_text": "fun main(args: Array) {\n println(if (readLine()!!.contains('9')) \"Yes\" else \"No\")\n}\n", "language": "Kotlin", "metadata": {"date": 1553830788, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03605.html", "problem_id": "p03605", "resource_group": "medium_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/Kotlin/s227757896.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s227757896", "user_id": "u051841332"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "fun main(args: Array) {\n println(if (readLine()!!.contains('9')) \"Yes\" else \"No\")\n}\n", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 214, "memory_kb": 33788}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s782108977", "group_id": "codeNet:p03605", "input_text": "fun main(args: Array) {println(readLine()!!.contains(\"9\"))}\n", "language": "Kotlin", "metadata": {"date": 1506911715, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03605.html", "problem_id": "p03605", "resource_group": "medium_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/Kotlin/s782108977.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s782108977", "user_id": "u566924053"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "fun main(args: Array) {println(readLine()!!.contains(\"9\"))}\n", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 214, "memory_kb": 31920}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s358472312", "group_id": "codeNet:p03607", "input_text": "fun main(args: Array) {\n val n= readLine()!!.toInt()\n (1..n).map{ readLine()!!.toLong() }\n .groupBy { it }.map { it.value.size }\n .filter { it%2==1 }\n .count()\n .let{ println(it) }\n}", "language": "Kotlin", "metadata": {"date": 1541337379, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03607.html", "problem_id": "p03607", "resource_group": "medium_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/Kotlin/s358472312.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s358472312", "user_id": "u914096045"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "fun main(args: Array) {\n val n= readLine()!!.toInt()\n (1..n).map{ readLine()!!.toLong() }\n .groupBy { it }.map { it.value.size }\n .filter { it%2==1 }\n .count()\n .let{ println(it) }\n}", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 430, "memory_kb": 51452}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s347320464", "group_id": "codeNet:p03608", "input_text": "//package Qd\nimport java.util.*\nimport java.math.*\nimport java.lang.Math.*\nimport java.nio.IntBuffer\n\n\nprivate val readString: ()->String = {readLine()!!}\nprivate val readInt: ()->Int = {readLine()!!.toInt()}\nprivate val readLong: ()->Long = {readLine()!!.toLong()}\nprivate val readIntArray: ()->IntArray = {readLine()!!.split(' ').map{it.toInt()}.toIntArray()}\nprivate val readLongArray: ()->LongArray = {readLine()!!.split(' ').map{it.toLong()}.toLongArray()}\nprivate val errPrintln: (String)->Unit = {msg -> System.err.println(msg)}\nprivate val MOD = 1e9.toLong()+7\nprivate val INF = Int.MAX_VALUE/2\nprivate val LINF = Long.MAX_VALUE/2\n\nprivate fun permutation(A: IntArray): List {\n val ary = A.sorted()\n val N = ary.size\n val used = BooleanArray(N){false}\n val hm = HashMap()\n val ptn = ArrayList(0)\n fun dfs(n: Int) {\n if (n >= N) {\n val value = ptn.toIntArray()\n val key = IntBuffer.wrap(value)\n hm[key] = value\n }\n for (i in 0 until N) {\n if (used[i]) continue\n used[i] = true\n ptn.add(ary[i])\n dfs(n+1)\n ptn.removeAt(ptn.lastIndex)\n used[i] = false\n }\n }\n dfs(0)\n val res = ArrayList()\n for (key in hm.keys.sorted()) {\n res.add(hm[key]!!)\n }\n return res.toList()\n}\n\ndata class To(val idx: Int, val cost: Long)\nprivate class Warshall(val eg: Array>) {\n private var dist = Array(0){LongArray(0)}\n init {\n val N = eg.size\n dist = Array(N){LongArray(N){LINF}}\n for (i in 0 until N) {\n dist[i][i] = 0\n }\n for (s in 0 until N) {\n for (t in eg[s]) {\n dist[s][t.idx] = t.cost\n dist[t.idx][s] = t.cost\n }\n }\n for (k in 0 until N) {\n for (i in 0 until N) {\n if (dist[i][k] == LINF) continue\n for (j in 0 until N) {\n if (dist[k][j] == LINF) continue\n if (dist[i][j] > dist[i][k] + dist[k][j]) {\n dist[i][j] = dist[i][k] + dist[k][j]\n }\n }\n }\n }\n }\n fun distance(i: Int, j: Int): Long {\n return dist[i][j]\n }\n fun hasNegativeCycle(): Boolean {\n val N = dist.size\n var res = false\n for(i in 0 until N) {\n if (dist[i][i] < 0) {\n res = true\n break\n }\n }\n return res\n }\n}\n\nprivate fun solveD(R: IntArray, eg: Array>): Long {\n val patterns = permutation(R)\n\n val ws = Warshall(eg)\n\n var res = LINF\n for (cities in patterns) {\n var distSum = 0L\n val K = cities.size\n for (i in 0 until K-1) {\n distSum += ws.distance(cities[i], cities[i+1])\n }\n res = min(res, distSum)\n }\n\n return res\n}\n\n\nfun main(args: Array) {\n val (N, M, K) = readIntArray()\n val R = readIntArray().map{ it-1 }\n val eg = Array(N) {ArrayList()}\n for (i in 0 until M) {\n var (a, b, c) = readIntArray()\n a--; b--;\n eg[a].add(To(b, c.toLong()))\n eg[b].add(To(a, c.toLong()))\n }\n\n val ans = solveD(R.toIntArray(), eg)\n\n println(ans)\n}\n", "language": "Kotlin", "metadata": {"date": 1590888996, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03608.html", "problem_id": "p03608", "resource_group": "medium_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/Kotlin/s347320464.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s347320464", "user_id": "u404244809"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "//package Qd\nimport java.util.*\nimport java.math.*\nimport java.lang.Math.*\nimport java.nio.IntBuffer\n\n\nprivate val readString: ()->String = {readLine()!!}\nprivate val readInt: ()->Int = {readLine()!!.toInt()}\nprivate val readLong: ()->Long = {readLine()!!.toLong()}\nprivate val readIntArray: ()->IntArray = {readLine()!!.split(' ').map{it.toInt()}.toIntArray()}\nprivate val readLongArray: ()->LongArray = {readLine()!!.split(' ').map{it.toLong()}.toLongArray()}\nprivate val errPrintln: (String)->Unit = {msg -> System.err.println(msg)}\nprivate val MOD = 1e9.toLong()+7\nprivate val INF = Int.MAX_VALUE/2\nprivate val LINF = Long.MAX_VALUE/2\n\nprivate fun permutation(A: IntArray): List {\n val ary = A.sorted()\n val N = ary.size\n val used = BooleanArray(N){false}\n val hm = HashMap()\n val ptn = ArrayList(0)\n fun dfs(n: Int) {\n if (n >= N) {\n val value = ptn.toIntArray()\n val key = IntBuffer.wrap(value)\n hm[key] = value\n }\n for (i in 0 until N) {\n if (used[i]) continue\n used[i] = true\n ptn.add(ary[i])\n dfs(n+1)\n ptn.removeAt(ptn.lastIndex)\n used[i] = false\n }\n }\n dfs(0)\n val res = ArrayList()\n for (key in hm.keys.sorted()) {\n res.add(hm[key]!!)\n }\n return res.toList()\n}\n\ndata class To(val idx: Int, val cost: Long)\nprivate class Warshall(val eg: Array>) {\n private var dist = Array(0){LongArray(0)}\n init {\n val N = eg.size\n dist = Array(N){LongArray(N){LINF}}\n for (i in 0 until N) {\n dist[i][i] = 0\n }\n for (s in 0 until N) {\n for (t in eg[s]) {\n dist[s][t.idx] = t.cost\n dist[t.idx][s] = t.cost\n }\n }\n for (k in 0 until N) {\n for (i in 0 until N) {\n if (dist[i][k] == LINF) continue\n for (j in 0 until N) {\n if (dist[k][j] == LINF) continue\n if (dist[i][j] > dist[i][k] + dist[k][j]) {\n dist[i][j] = dist[i][k] + dist[k][j]\n }\n }\n }\n }\n }\n fun distance(i: Int, j: Int): Long {\n return dist[i][j]\n }\n fun hasNegativeCycle(): Boolean {\n val N = dist.size\n var res = false\n for(i in 0 until N) {\n if (dist[i][i] < 0) {\n res = true\n break\n }\n }\n return res\n }\n}\n\nprivate fun solveD(R: IntArray, eg: Array>): Long {\n val patterns = permutation(R)\n\n val ws = Warshall(eg)\n\n var res = LINF\n for (cities in patterns) {\n var distSum = 0L\n val K = cities.size\n for (i in 0 until K-1) {\n distSum += ws.distance(cities[i], cities[i+1])\n }\n res = min(res, distSum)\n }\n\n return res\n}\n\n\nfun main(args: Array) {\n val (N, M, K) = readIntArray()\n val R = readIntArray().map{ it-1 }\n val eg = Array(N) {ArrayList()}\n for (i in 0 until M) {\n var (a, b, c) = readIntArray()\n a--; b--;\n eg[a].add(To(b, c.toLong()))\n eg[b].add(To(a, c.toLong()))\n }\n\n val ans = solveD(R.toIntArray(), eg)\n\n println(ans)\n}\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 3339, "cpu_time_ms": 902, "memory_kb": 57284}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s491665435", "group_id": "codeNet:p03608", "input_text": "fun main(args: Array){\n val (n, m, rr) = readLine()!!.split(\" \").map { it.toInt() }\n val r = readLine()!!.split(\" \").map { it.toInt() }.toIntArray().sortedArray()\n val g = Array(n+1){LongArray(n+1){1e20.toLong()} }\n repeat(m){\n val (a, b, c) = readLine()!!.split(\" \").map { it.toInt() }\n g[a][b] = c.toLong()\n g[b][a] = c.toLong()\n }\n for (i in 1..n){\n g[i][i] = 0\n }\n\n for(k in 1..n){\n for(i in 1..n){\n for(j in 1..n){\n g[i][j] = Math.min(g[i][j], g[i][k] + g[k][j])\n }\n }\n }\n\n val list = mutableListOf()\n permutation(r, IntArray(0), list)\n\n var min = Long.MAX_VALUE\n list.forEach {\n var ans = 0L\n for(i in 1 until it.size){\n ans += g[it[i]][it[i-1]]\n }\n min = Math.min(min, ans)\n }\n\n println(min)\n}\n\nfun permutation(r1: IntArray, r2: IntArray, list: MutableList){\n if(r1.size <= 1){\n list.add(r2 + r1)\n }else{\n for(i in r1.indices){\n permutation(r1.sliceArray(0 until i) + r1.sliceArray(i+1 until r1.size), r2 + r1[i], list)\n }\n }\n}", "language": "Kotlin", "metadata": {"date": 1588910499, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03608.html", "problem_id": "p03608", "resource_group": "medium_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/Kotlin/s491665435.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s491665435", "user_id": "u531770859"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "fun main(args: Array){\n val (n, m, rr) = readLine()!!.split(\" \").map { it.toInt() }\n val r = readLine()!!.split(\" \").map { it.toInt() }.toIntArray().sortedArray()\n val g = Array(n+1){LongArray(n+1){1e20.toLong()} }\n repeat(m){\n val (a, b, c) = readLine()!!.split(\" \").map { it.toInt() }\n g[a][b] = c.toLong()\n g[b][a] = c.toLong()\n }\n for (i in 1..n){\n g[i][i] = 0\n }\n\n for(k in 1..n){\n for(i in 1..n){\n for(j in 1..n){\n g[i][j] = Math.min(g[i][j], g[i][k] + g[k][j])\n }\n }\n }\n\n val list = mutableListOf()\n permutation(r, IntArray(0), list)\n\n var min = Long.MAX_VALUE\n list.forEach {\n var ans = 0L\n for(i in 1 until it.size){\n ans += g[it[i]][it[i-1]]\n }\n min = Math.min(min, ans)\n }\n\n println(min)\n}\n\nfun permutation(r1: IntArray, r2: IntArray, list: MutableList){\n if(r1.size <= 1){\n list.add(r2 + r1)\n }else{\n for(i in r1.indices){\n permutation(r1.sliceArray(0 until i) + r1.sliceArray(i+1 until r1.size), r2 + r1[i], list)\n }\n }\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1166, "cpu_time_ms": 890, "memory_kb": 57352}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s579934953", "group_id": "codeNet:p03610", "input_text": "fun main(args: Array) {\n val s = readInputLine().filterIndexed { i, c -> i % 2 == 0 }\n \n println(s)\n}\n\nfun readInputLine(): String {\n return readLine()!!\n}\n", "language": "Kotlin", "metadata": {"date": 1569159321, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03610.html", "problem_id": "p03610", "resource_group": "medium_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/Kotlin/s579934953.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s579934953", "user_id": "u505558493"}, "prompt_components": {"gold_output": "acdr\n", "input_to_evaluate": "fun main(args: Array) {\n val s = readInputLine().filterIndexed { i, c -> i % 2 == 0 }\n \n println(s)\n}\n\nfun readInputLine(): String {\n return readLine()!!\n}\n", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 176, "cpu_time_ms": 265, "memory_kb": 32420}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s633011723", "group_id": "codeNet:p03610", "input_text": "import java.util.Scanner\n\nfun main(args: Array) {\n val cin = Scanner(System.`in`)\n val str = cin.next()\n val m = str.length - 1\n\n for (i in 0..m step 2) {\n print(str[i])\n }\n println(\"\")\n\n cin.close()\n}", "language": "Kotlin", "metadata": {"date": 1504668348, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03610.html", "problem_id": "p03610", "resource_group": "medium_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/Kotlin/s633011723.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s633011723", "user_id": "u194575259"}, "prompt_components": {"gold_output": "acdr\n", "input_to_evaluate": "import java.util.Scanner\n\nfun main(args: Array) {\n val cin = Scanner(System.`in`)\n val str = cin.next()\n val m = str.length - 1\n\n for (i in 0..m step 2) {\n print(str[i])\n }\n println(\"\")\n\n cin.close()\n}", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 580, "memory_kb": 40924}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s605043251", "group_id": "codeNet:p03611", "input_text": "import java.util.*\n\nclass Scanner(`in`: java.io.InputStream) {\n private val reader = java.io.BufferedReader(java.io.InputStreamReader(`in`))\n private var tokenizer: StringTokenizer? = null\n\n fun next(): String {\n if (tokenizer?.hasMoreTokens() != true) {\n tokenizer = StringTokenizer(reader.readLine())\n }\n return tokenizer!!.nextToken()\n }\n\n fun nextLine(): String {\n return if (tokenizer?.hasMoreTokens() != true) {\n reader.readLine()\n } else tokenizer!!.nextToken(\"\\n\")\n }\n}\n\nfun main(args: Array) {\n val pw = java.io.PrintWriter(System.out)\n Problem.solve(Scanner(System.`in`), pw)\n pw.flush()\n}\n\n////////////////////////////////////////////////////////////////////////\n\nobject Problem {\n fun solve(sc: Scanner, pw: java.io.PrintWriter) {\n val N = sc.next().toInt()\n val A = IntArray(N) { sc.next().toInt() }.sorted()\n var i1 = 0\n var i2 = 0\n var n = 0\n var ans = 0\n while (i1 < N) {\n while (i2 < N && A[i2] - A[i1] <= 2) {\n n++\n if (ans < n) ans = n\n i2++\n }\n n--\n i1++\n }\n pw.println(ans)\n }\n}\n", "language": "Kotlin", "metadata": {"date": 1588641501, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03611.html", "problem_id": "p03611", "resource_group": "medium_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/Kotlin/s605043251.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s605043251", "user_id": "u297767059"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "import java.util.*\n\nclass Scanner(`in`: java.io.InputStream) {\n private val reader = java.io.BufferedReader(java.io.InputStreamReader(`in`))\n private var tokenizer: StringTokenizer? = null\n\n fun next(): String {\n if (tokenizer?.hasMoreTokens() != true) {\n tokenizer = StringTokenizer(reader.readLine())\n }\n return tokenizer!!.nextToken()\n }\n\n fun nextLine(): String {\n return if (tokenizer?.hasMoreTokens() != true) {\n reader.readLine()\n } else tokenizer!!.nextToken(\"\\n\")\n }\n}\n\nfun main(args: Array) {\n val pw = java.io.PrintWriter(System.out)\n Problem.solve(Scanner(System.`in`), pw)\n pw.flush()\n}\n\n////////////////////////////////////////////////////////////////////////\n\nobject Problem {\n fun solve(sc: Scanner, pw: java.io.PrintWriter) {\n val N = sc.next().toInt()\n val A = IntArray(N) { sc.next().toInt() }.sorted()\n var i1 = 0\n var i2 = 0\n var n = 0\n var ans = 0\n while (i1 < N) {\n while (i2 < N && A[i2] - A[i1] <= 2) {\n n++\n if (ans < n) ans = n\n i2++\n }\n n--\n i1++\n }\n pw.println(ans)\n }\n}\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1250, "cpu_time_ms": 714, "memory_kb": 45340}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s096372112", "group_id": "codeNet:p03612", "input_text": "import java.io.BufferedReader\nimport java.io.InputStreamReader\nimport java.io.PrintWriter\n\nval br = BufferedReader(InputStreamReader(System.`in`))\nval out = PrintWriter(System.out)\n\nfun main() {\n br.use { out.use {\n solve()\n out.flush()\n } }\n}\n\nfun solve() {\n val n = readInteger()\n val ps = readIntegerList().map { it - 1 }\n var ans = 0\n var last = ps.first()\n for (i in 0 until (n - 1)) {\n if (last == i) {\n ans++\n } else {\n last = ps[i + 1]\n }\n }\n if (last == n - 1) ans++\n out.println(ans)\n}\n\nfun readInteger() = Integer.parseInt(br.readLine())\nfun readLong() = java.lang.Long.parseLong(br.readLine())\nfun readStringList() = br.readLine()!!.split(' ')\nfun readIntegerList() = readStringList().map(Integer::parseInt)\nfun readLongList() = readStringList().map(java.lang.Long::parseLong)\nfun readDoubleList() = readStringList().map(java.lang.Double::parseDouble)\n", "language": "Kotlin", "metadata": {"date": 1594589258, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p03612.html", "problem_id": "p03612", "resource_group": "medium_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/Kotlin/s096372112.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s096372112", "user_id": "u784448849"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import java.io.BufferedReader\nimport java.io.InputStreamReader\nimport java.io.PrintWriter\n\nval br = BufferedReader(InputStreamReader(System.`in`))\nval out = PrintWriter(System.out)\n\nfun main() {\n br.use { out.use {\n solve()\n out.flush()\n } }\n}\n\nfun solve() {\n val n = readInteger()\n val ps = readIntegerList().map { it - 1 }\n var ans = 0\n var last = ps.first()\n for (i in 0 until (n - 1)) {\n if (last == i) {\n ans++\n } else {\n last = ps[i + 1]\n }\n }\n if (last == n - 1) ans++\n out.println(ans)\n}\n\nfun readInteger() = Integer.parseInt(br.readLine())\nfun readLong() = java.lang.Long.parseLong(br.readLine())\nfun readStringList() = br.readLine()!!.split(' ')\nfun readIntegerList() = readStringList().map(Integer::parseInt)\nfun readLongList() = readStringList().map(java.lang.Long::parseLong)\nfun readDoubleList() = readStringList().map(java.lang.Double::parseDouble)\n", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 951, "cpu_time_ms": 254, "memory_kb": 52000}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s875564928", "group_id": "codeNet:p03612", "input_text": "fun main(args: Array) {\n val n = readLine()!!.toInt()\n val p = readLine()!!.split(\" \").map { it.toInt() }.toIntArray()\n var ans = 0\n for (i in 0 until n-1) {\n if (p[i]-1 == i) {\n val temp = p[i]\n p[i] = p[i+1]\n p[i+1] = temp\n ans++\n }\n }\n if (p[n-1] == n) ans++\n println(ans)\n}", "language": "Kotlin", "metadata": {"date": 1577989994, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03612.html", "problem_id": "p03612", "resource_group": "medium_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/Kotlin/s875564928.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s875564928", "user_id": "u777283665"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "fun main(args: Array) {\n val n = readLine()!!.toInt()\n val p = readLine()!!.split(\" \").map { it.toInt() }.toIntArray()\n var ans = 0\n for (i in 0 until n-1) {\n if (p[i]-1 == i) {\n val temp = p[i]\n p[i] = p[i+1]\n p[i+1] = temp\n ans++\n }\n }\n if (p[n-1] == n) ans++\n println(ans)\n}", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 498, "memory_kb": 51844}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s084980304", "group_id": "codeNet:p03617", "input_text": "import java.util.*\n\nfun main(args: Array) {\n val pw = java.io.PrintWriter(System.out)\n Problem.solve(Scanner(System.`in`), pw)\n pw.flush()\n}\n\nfun > min(a: A, b: A) = if (a < b) a else b\nfun > minOf(vararg a: A) = a.reduce { acc, x -> min(acc, x) }\n\nobject Problem {\n fun solve(sc: Scanner, pw: java.io.PrintWriter) {\n val Q = sc.next().toLong()\n val H = sc.next().toLong()\n val S = sc.next().toLong()\n val D = sc.next().toLong()\n val N = sc.next().toLong()\n val q1 = minOf(4 * Q, 2 * H, S)\n val q2 = minOf(2 * q1, D)\n pw.println((N / 2) * q2 + (N % 2) * q1)\n }\n}\n", "language": "Kotlin", "metadata": {"date": 1590537809, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03617.html", "problem_id": "p03617", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03617/input.txt", "sample_output_relpath": "derived/input_output/data/p03617/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03617/Kotlin/s084980304.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s084980304", "user_id": "u297767059"}, "prompt_components": {"gold_output": "150\n", "input_to_evaluate": "import java.util.*\n\nfun main(args: Array) {\n val pw = java.io.PrintWriter(System.out)\n Problem.solve(Scanner(System.`in`), pw)\n pw.flush()\n}\n\nfun > min(a: A, b: A) = if (a < b) a else b\nfun > minOf(vararg a: A) = a.reduce { acc, x -> min(acc, x) }\n\nobject Problem {\n fun solve(sc: Scanner, pw: java.io.PrintWriter) {\n val Q = sc.next().toLong()\n val H = sc.next().toLong()\n val S = sc.next().toLong()\n val D = sc.next().toLong()\n val N = sc.next().toLong()\n val q1 = minOf(4 * Q, 2 * H, S)\n val q2 = minOf(2 * q1, D)\n pw.println((N / 2) * q2 + (N % 2) * q1)\n }\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nYou've come to your favorite store Infinitesco to buy some ice tea.\n\nThe store sells ice tea in bottles of different volumes at different costs.\nSpecifically, a 0.25-liter bottle costs Q yen, a 0.5-liter bottle costs H yen, a 1-liter bottle costs S yen, and a 2-liter bottle costs D yen.\nThe store has an infinite supply of bottles of each type.\n\nYou want to buy exactly N liters of ice tea. How many yen do you have to spend?\n\nConstraints\n\n1 \\leq Q, H, S, D \\leq 10^8\n\n1 \\leq N \\leq 10^9\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nQ H S D\nN\n\nOutput\n\nPrint the smallest number of yen you have to spend to buy exactly N liters of ice tea.\n\nSample Input 1\n\n20 30 70 90\n3\n\nSample Output 1\n\n150\n\nBuy one 2-liter bottle and two 0.5-liter bottles. You'll get 3 liters for 90 + 30 + 30 = 150 yen.\n\nSample Input 2\n\n10000 1000 100 10\n1\n\nSample Output 2\n\n100\n\nEven though a 2-liter bottle costs just 10 yen, you need only 1 liter.\nThus, you have to buy a 1-liter bottle for 100 yen.\n\nSample Input 3\n\n10 100 1000 10000\n1\n\nSample Output 3\n\n40\n\nNow it's better to buy four 0.25-liter bottles for 10 + 10 + 10 + 10 = 40 yen.\n\nSample Input 4\n\n12345678 87654321 12345678 87654321\n123456789\n\nSample Output 4\n\n1524157763907942", "sample_input": "20 30 70 90\n3\n"}, "reference_outputs": ["150\n"], "source_document_id": "p03617", "source_text": "Score : 300 points\n\nProblem Statement\n\nYou've come to your favorite store Infinitesco to buy some ice tea.\n\nThe store sells ice tea in bottles of different volumes at different costs.\nSpecifically, a 0.25-liter bottle costs Q yen, a 0.5-liter bottle costs H yen, a 1-liter bottle costs S yen, and a 2-liter bottle costs D yen.\nThe store has an infinite supply of bottles of each type.\n\nYou want to buy exactly N liters of ice tea. How many yen do you have to spend?\n\nConstraints\n\n1 \\leq Q, H, S, D \\leq 10^8\n\n1 \\leq N \\leq 10^9\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nQ H S D\nN\n\nOutput\n\nPrint the smallest number of yen you have to spend to buy exactly N liters of ice tea.\n\nSample Input 1\n\n20 30 70 90\n3\n\nSample Output 1\n\n150\n\nBuy one 2-liter bottle and two 0.5-liter bottles. You'll get 3 liters for 90 + 30 + 30 = 150 yen.\n\nSample Input 2\n\n10000 1000 100 10\n1\n\nSample Output 2\n\n100\n\nEven though a 2-liter bottle costs just 10 yen, you need only 1 liter.\nThus, you have to buy a 1-liter bottle for 100 yen.\n\nSample Input 3\n\n10 100 1000 10000\n1\n\nSample Output 3\n\n40\n\nNow it's better to buy four 0.25-liter bottles for 10 + 10 + 10 + 10 = 40 yen.\n\nSample Input 4\n\n12345678 87654321 12345678 87654321\n123456789\n\nSample Output 4\n\n1524157763907942", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 678, "cpu_time_ms": 181, "memory_kb": 31264}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s823145110", "group_id": "codeNet:p03617", "input_text": "fun main(args : Array) {\n val (q, h, s, d) = readLine()!!.split(\" \").map { it.toInt() }\n val n = readLine()!!.toInt()\n\n val q2 = 8*q\n val h2 = 4*h\n val s2 = 2*s\n val d2 = d\n\n val q1 = 4*q\n val h1 = 2*h\n val s1 = s\n\n val min1 = Math.min(Math.min(q1, h1), s1)\n val min2 = Math.min(Math.min(q2, h2), Math.min(s2, d2))\n\n println((n / 2) * min2.toLong() + (n % 2) * min1.toLong())\n}", "language": "Kotlin", "metadata": {"date": 1574245699, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03617.html", "problem_id": "p03617", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03617/input.txt", "sample_output_relpath": "derived/input_output/data/p03617/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03617/Kotlin/s823145110.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s823145110", "user_id": "u262403099"}, "prompt_components": {"gold_output": "150\n", "input_to_evaluate": "fun main(args : Array) {\n val (q, h, s, d) = readLine()!!.split(\" \").map { it.toInt() }\n val n = readLine()!!.toInt()\n\n val q2 = 8*q\n val h2 = 4*h\n val s2 = 2*s\n val d2 = d\n\n val q1 = 4*q\n val h1 = 2*h\n val s1 = s\n\n val min1 = Math.min(Math.min(q1, h1), s1)\n val min2 = Math.min(Math.min(q2, h2), Math.min(s2, d2))\n\n println((n / 2) * min2.toLong() + (n % 2) * min1.toLong())\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nYou've come to your favorite store Infinitesco to buy some ice tea.\n\nThe store sells ice tea in bottles of different volumes at different costs.\nSpecifically, a 0.25-liter bottle costs Q yen, a 0.5-liter bottle costs H yen, a 1-liter bottle costs S yen, and a 2-liter bottle costs D yen.\nThe store has an infinite supply of bottles of each type.\n\nYou want to buy exactly N liters of ice tea. How many yen do you have to spend?\n\nConstraints\n\n1 \\leq Q, H, S, D \\leq 10^8\n\n1 \\leq N \\leq 10^9\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nQ H S D\nN\n\nOutput\n\nPrint the smallest number of yen you have to spend to buy exactly N liters of ice tea.\n\nSample Input 1\n\n20 30 70 90\n3\n\nSample Output 1\n\n150\n\nBuy one 2-liter bottle and two 0.5-liter bottles. You'll get 3 liters for 90 + 30 + 30 = 150 yen.\n\nSample Input 2\n\n10000 1000 100 10\n1\n\nSample Output 2\n\n100\n\nEven though a 2-liter bottle costs just 10 yen, you need only 1 liter.\nThus, you have to buy a 1-liter bottle for 100 yen.\n\nSample Input 3\n\n10 100 1000 10000\n1\n\nSample Output 3\n\n40\n\nNow it's better to buy four 0.25-liter bottles for 10 + 10 + 10 + 10 = 40 yen.\n\nSample Input 4\n\n12345678 87654321 12345678 87654321\n123456789\n\nSample Output 4\n\n1524157763907942", "sample_input": "20 30 70 90\n3\n"}, "reference_outputs": ["150\n"], "source_document_id": "p03617", "source_text": "Score : 300 points\n\nProblem Statement\n\nYou've come to your favorite store Infinitesco to buy some ice tea.\n\nThe store sells ice tea in bottles of different volumes at different costs.\nSpecifically, a 0.25-liter bottle costs Q yen, a 0.5-liter bottle costs H yen, a 1-liter bottle costs S yen, and a 2-liter bottle costs D yen.\nThe store has an infinite supply of bottles of each type.\n\nYou want to buy exactly N liters of ice tea. How many yen do you have to spend?\n\nConstraints\n\n1 \\leq Q, H, S, D \\leq 10^8\n\n1 \\leq N \\leq 10^9\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nQ H S D\nN\n\nOutput\n\nPrint the smallest number of yen you have to spend to buy exactly N liters of ice tea.\n\nSample Input 1\n\n20 30 70 90\n3\n\nSample Output 1\n\n150\n\nBuy one 2-liter bottle and two 0.5-liter bottles. You'll get 3 liters for 90 + 30 + 30 = 150 yen.\n\nSample Input 2\n\n10000 1000 100 10\n1\n\nSample Output 2\n\n100\n\nEven though a 2-liter bottle costs just 10 yen, you need only 1 liter.\nThus, you have to buy a 1-liter bottle for 100 yen.\n\nSample Input 3\n\n10 100 1000 10000\n1\n\nSample Output 3\n\n40\n\nNow it's better to buy four 0.25-liter bottles for 10 + 10 + 10 + 10 = 40 yen.\n\nSample Input 4\n\n12345678 87654321 12345678 87654321\n123456789\n\nSample Output 4\n\n1524157763907942", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 240, "memory_kb": 36040}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s997474428", "group_id": "codeNet:p03618", "input_text": "import java.io.*\nimport java.util.*\nimport java.lang.*\nimport java.lang.Math.*\n\n\nfun solve() {\n val S = rd.readString()\n val N = S.length\n val R = S.reversed()\n\n val st = mutableSetOf()\n st.add(S)\n for (i in 0 until N-1) {\n for (j in i+1 until N) {\n st.add(S.slice(0 until i)\n + R.slice(N-1-j .. N-1-i)\n + S.slice(j+1 until N))\n }\n }\n\n val ans = st.size\n println(ans)\n}\n\n\n//val rd = debug.Reader(\"agc\", \"019\", \"b\", \"sample-1\")\nval rd = Reader()\n\n\nfun main(args: Array) {\n try {\n var exception: Throwable? = null\n val sth = Thread(null, SolveThread(), \"solveThread\", 128 * 1024 * 1024)\n sth.setUncaughtExceptionHandler { _, e -> exception = e }\n sth.start(); sth.join()\n if (exception != null) throw exception!!\n } catch (e: Exception) { throw e }\n}\nconst val MOD = 1_000_000_007L; const val INF = Int.MAX_VALUE/2; const val LINF = Long.MAX_VALUE/2\ndata class IntPair(val first: Int, val second: Int); data class LongPair(val first: Long, val second: Long)\nval errPrintln: (Any) -> Unit = { msg -> System.err.println(msg) }\nfun rAssert(exp: Boolean, lazyMsg: () -> String = {\"\"}) {\n if (!exp) { val msg = lazyMsg(); errPrintln(\"EAssert Error: $msg\"); throw Error(msg) }\n}\nfun tAssert(exp: Boolean, lazyMsg: () -> String = {\"\"}) {\n if (!exp) { val msg = lazyMsg(); errPrintln(\"TAssert Error: $msg\"); Thread.sleep(3000) }\n}\nclass SolveThread : Runnable {\n override fun run() { solve() }\n}\nclass Reader {\n private val br = BufferedReader(InputStreamReader(System.`in`))\n val readString: () -> String = { br.readLine() }\n val readInt: () -> Int = { br.readLine().toInt() }\n val readLong: () -> Long = { br.readLine().toLong() }\n val readIntArray: () -> IntArray = { br.readLine().split(' ').map { it.toInt() }.toIntArray() }\n val readLongArray: () -> LongArray = { br.readLine().split(' ').map { it.toLong() }.toLongArray() }\n val readListInt: () -> List = { br.readLine().split(' ').map { it.toInt() } }\n val readListLong: () -> List = { br.readLine().split(' ').map { it.toLong() } }\n}\n", "language": "Kotlin", "metadata": {"date": 1596680485, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p03618.html", "problem_id": "p03618", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03618/input.txt", "sample_output_relpath": "derived/input_output/data/p03618/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03618/Kotlin/s997474428.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s997474428", "user_id": "u404244809"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "import java.io.*\nimport java.util.*\nimport java.lang.*\nimport java.lang.Math.*\n\n\nfun solve() {\n val S = rd.readString()\n val N = S.length\n val R = S.reversed()\n\n val st = mutableSetOf()\n st.add(S)\n for (i in 0 until N-1) {\n for (j in i+1 until N) {\n st.add(S.slice(0 until i)\n + R.slice(N-1-j .. N-1-i)\n + S.slice(j+1 until N))\n }\n }\n\n val ans = st.size\n println(ans)\n}\n\n\n//val rd = debug.Reader(\"agc\", \"019\", \"b\", \"sample-1\")\nval rd = Reader()\n\n\nfun main(args: Array) {\n try {\n var exception: Throwable? = null\n val sth = Thread(null, SolveThread(), \"solveThread\", 128 * 1024 * 1024)\n sth.setUncaughtExceptionHandler { _, e -> exception = e }\n sth.start(); sth.join()\n if (exception != null) throw exception!!\n } catch (e: Exception) { throw e }\n}\nconst val MOD = 1_000_000_007L; const val INF = Int.MAX_VALUE/2; const val LINF = Long.MAX_VALUE/2\ndata class IntPair(val first: Int, val second: Int); data class LongPair(val first: Long, val second: Long)\nval errPrintln: (Any) -> Unit = { msg -> System.err.println(msg) }\nfun rAssert(exp: Boolean, lazyMsg: () -> String = {\"\"}) {\n if (!exp) { val msg = lazyMsg(); errPrintln(\"EAssert Error: $msg\"); throw Error(msg) }\n}\nfun tAssert(exp: Boolean, lazyMsg: () -> String = {\"\"}) {\n if (!exp) { val msg = lazyMsg(); errPrintln(\"TAssert Error: $msg\"); Thread.sleep(3000) }\n}\nclass SolveThread : Runnable {\n override fun run() { solve() }\n}\nclass Reader {\n private val br = BufferedReader(InputStreamReader(System.`in`))\n val readString: () -> String = { br.readLine() }\n val readInt: () -> Int = { br.readLine().toInt() }\n val readLong: () -> Long = { br.readLine().toLong() }\n val readIntArray: () -> IntArray = { br.readLine().split(' ').map { it.toInt() }.toIntArray() }\n val readLongArray: () -> LongArray = { br.readLine().split(' ').map { it.toLong() }.toLongArray() }\n val readListInt: () -> List = { br.readLine().split(' ').map { it.toInt() } }\n val readListLong: () -> List = { br.readLine().split(' ').map { it.toLong() } }\n}\n", "problem_context": "Score : 500 points\n\nProblem Statement\n\nYou have a string A = A_1 A_2 ... A_n consisting of lowercase English letters.\n\nYou can choose any two indices i and j such that 1 \\leq i \\leq j \\leq n and reverse substring A_i A_{i+1} ... A_j.\n\nYou can perform this operation at most once.\n\nHow many different strings can you obtain?\n\nConstraints\n\n1 \\leq |A| \\leq 200,000\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 number of different strings you can obtain by reversing any substring in A at most once.\n\nSample Input 1\n\naatt\n\nSample Output 1\n\n5\n\nYou can obtain aatt (don't do anything), atat (reverse A[2..3]), atta (reverse A[2..4]), ttaa (reverse A[1..4]) and taat (reverse A[1..3]).\n\nSample Input 2\n\nxxxxxxxxxx\n\nSample Output 2\n\n1\n\nWhatever substring you reverse, you'll always get xxxxxxxxxx.\n\nSample Input 3\n\nabracadabra\n\nSample Output 3\n\n44", "sample_input": "aatt\n"}, "reference_outputs": ["5\n"], "source_document_id": "p03618", "source_text": "Score : 500 points\n\nProblem Statement\n\nYou have a string A = A_1 A_2 ... A_n consisting of lowercase English letters.\n\nYou can choose any two indices i and j such that 1 \\leq i \\leq j \\leq n and reverse substring A_i A_{i+1} ... A_j.\n\nYou can perform this operation at most once.\n\nHow many different strings can you obtain?\n\nConstraints\n\n1 \\leq |A| \\leq 200,000\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 number of different strings you can obtain by reversing any substring in A at most once.\n\nSample Input 1\n\naatt\n\nSample Output 1\n\n5\n\nYou can obtain aatt (don't do anything), atat (reverse A[2..3]), atta (reverse A[2..4]), ttaa (reverse A[1..4]) and taat (reverse A[1..3]).\n\nSample Input 2\n\nxxxxxxxxxx\n\nSample Output 2\n\n1\n\nWhatever substring you reverse, you'll always get xxxxxxxxxx.\n\nSample Input 3\n\nabracadabra\n\nSample Output 3\n\n44", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2174, "cpu_time_ms": 2231, "memory_kb": 995452}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s082900265", "group_id": "codeNet:p03623", "input_text": "import java.io.InputStreamReader\nimport java.io.BufferedReader\nimport java.io.PrintWriter\n\nfun main(args: Array) {\n val br = BufferedReader(InputStreamReader(System.`in`))\n\n val (x, a, b) = br.readLine().split(\" \").map { it.toInt() }\n\n val ans = if(Math.abs(a - x) < Math.abs(b - x)) \"A\" else \"B\"\n\n println(ans)\n}", "language": "Kotlin", "metadata": {"date": 1576979375, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03623.html", "problem_id": "p03623", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03623/input.txt", "sample_output_relpath": "derived/input_output/data/p03623/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03623/Kotlin/s082900265.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s082900265", "user_id": "u217010036"}, "prompt_components": {"gold_output": "B\n", "input_to_evaluate": "import java.io.InputStreamReader\nimport java.io.BufferedReader\nimport java.io.PrintWriter\n\nfun main(args: Array) {\n val br = BufferedReader(InputStreamReader(System.`in`))\n\n val (x, a, b) = br.readLine().split(\" \").map { it.toInt() }\n\n val ans = if(Math.abs(a - x) < Math.abs(b - x)) \"A\" else \"B\"\n\n println(ans)\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nSnuke lives at position x on a number line.\nOn this line, there are two stores A and B, respectively at position a and b, that offer food for delivery.\n\nSnuke decided to get food delivery from the closer of stores A and B.\nFind out which store is closer to Snuke's residence.\n\nHere, the distance between two points s and t on a number line is represented by |s-t|.\n\nConstraints\n\n1 \\leq x \\leq 1000\n\n1 \\leq a \\leq 1000\n\n1 \\leq b \\leq 1000\n\nx, a and b are pairwise distinct.\n\nThe distances between Snuke's residence and stores A and B are different.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nx a b\n\nOutput\n\nIf store A is closer, print A; if store B is closer, print B.\n\nSample Input 1\n\n5 2 7\n\nSample Output 1\n\nB\n\nThe distances between Snuke's residence and stores A and B are 3 and 2, respectively.\nSince store B is closer, print B.\n\nSample Input 2\n\n1 999 1000\n\nSample Output 2\n\nA", "sample_input": "5 2 7\n"}, "reference_outputs": ["B\n"], "source_document_id": "p03623", "source_text": "Score : 100 points\n\nProblem Statement\n\nSnuke lives at position x on a number line.\nOn this line, there are two stores A and B, respectively at position a and b, that offer food for delivery.\n\nSnuke decided to get food delivery from the closer of stores A and B.\nFind out which store is closer to Snuke's residence.\n\nHere, the distance between two points s and t on a number line is represented by |s-t|.\n\nConstraints\n\n1 \\leq x \\leq 1000\n\n1 \\leq a \\leq 1000\n\n1 \\leq b \\leq 1000\n\nx, a and b are pairwise distinct.\n\nThe distances between Snuke's residence and stores A and B are different.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nx a b\n\nOutput\n\nIf store A is closer, print A; if store B is closer, print B.\n\nSample Input 1\n\n5 2 7\n\nSample Output 1\n\nB\n\nThe distances between Snuke's residence and stores A and B are 3 and 2, respectively.\nSince store B is closer, print B.\n\nSample Input 2\n\n1 999 1000\n\nSample Output 2\n\nA", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 325, "cpu_time_ms": 208, "memory_kb": 35528}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s804100519", "group_id": "codeNet:p03633", "input_text": "fun main(args : Array) {\n val n = readLine()!!.toInt()\n\n var lcm = 1L\n\n repeat(n) {\n val t = readLine()!!.toLong()\n lcm = lcm(lcm, t)\n }\n\n println(lcm)\n}\n\nfun gcd(a : Long, b : Long) : Long {\n return if (a % b == 0L) b else gcd(b, a % b)\n}\n\nfun lcm(a : Long, b : Long) : Long {\n return (a / gcd(a, b)) * b\n}\n", "language": "Kotlin", "metadata": {"date": 1590054959, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03633.html", "problem_id": "p03633", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03633/input.txt", "sample_output_relpath": "derived/input_output/data/p03633/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03633/Kotlin/s804100519.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s804100519", "user_id": "u262403099"}, "prompt_components": {"gold_output": "6\n", "input_to_evaluate": "fun main(args : Array) {\n val n = readLine()!!.toInt()\n\n var lcm = 1L\n\n repeat(n) {\n val t = readLine()!!.toLong()\n lcm = lcm(lcm, t)\n }\n\n println(lcm)\n}\n\nfun gcd(a : Long, b : Long) : Long {\n return if (a % b == 0L) b else gcd(b, a % b)\n}\n\nfun lcm(a : Long, b : Long) : Long {\n return (a / gcd(a, b)) * b\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nWe have N clocks. The hand of the i-th clock (1≤i≤N) rotates through 360° in exactly T_i seconds.\n\nInitially, the hand of every clock stands still, pointing directly upward.\n\nNow, Dolphin starts all the clocks simultaneously.\n\nIn how many seconds will the hand of every clock point directly upward again?\n\nConstraints\n\n1≤N≤100\n\n1≤T_i≤10^{18}\n\nAll input values are integers.\n\nThe correct answer is at most 10^{18} seconds.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nT_1\n:\nT_N\n\nOutput\n\nPrint the number of seconds after which the hand of every clock point directly upward again.\n\nSample Input 1\n\n2\n2\n3\n\nSample Output 1\n\n6\n\nWe have two clocks. The time when the hand of each clock points upward is as follows:\n\nClock 1: 2, 4, 6, ... seconds after the beginning\n\nClock 2: 3, 6, 9, ... seconds after the beginning\n\nTherefore, it takes 6 seconds until the hands of both clocks point directly upward.\n\nSample Input 2\n\n5\n2\n5\n10\n1000000000000000000\n1000000000000000000\n\nSample Output 2\n\n1000000000000000000", "sample_input": "2\n2\n3\n"}, "reference_outputs": ["6\n"], "source_document_id": "p03633", "source_text": "Score : 300 points\n\nProblem Statement\n\nWe have N clocks. The hand of the i-th clock (1≤i≤N) rotates through 360° in exactly T_i seconds.\n\nInitially, the hand of every clock stands still, pointing directly upward.\n\nNow, Dolphin starts all the clocks simultaneously.\n\nIn how many seconds will the hand of every clock point directly upward again?\n\nConstraints\n\n1≤N≤100\n\n1≤T_i≤10^{18}\n\nAll input values are integers.\n\nThe correct answer is at most 10^{18} seconds.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nT_1\n:\nT_N\n\nOutput\n\nPrint the number of seconds after which the hand of every clock point directly upward again.\n\nSample Input 1\n\n2\n2\n3\n\nSample Output 1\n\n6\n\nWe have two clocks. The time when the hand of each clock points upward is as follows:\n\nClock 1: 2, 4, 6, ... seconds after the beginning\n\nClock 2: 3, 6, 9, ... seconds after the beginning\n\nTherefore, it takes 6 seconds until the hands of both clocks point directly upward.\n\nSample Input 2\n\n5\n2\n5\n10\n1000000000000000000\n1000000000000000000\n\nSample Output 2\n\n1000000000000000000", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 351, "cpu_time_ms": 207, "memory_kb": 31528}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s066056208", "group_id": "codeNet:p03634", "input_text": "import java.io.*\nimport java.util.*\n\nvar pw = PrintWriter(System.out)\nfun solve(N: Int, a: IntArray, b: IntArray, c: LongArray, Q: Int, K: Int, x: IntArray, y: IntArray){\n val tree = AdjacentListGraph(Array(N){ Vertex() }.toMutableList())\n for(i in 0 until N - 1){\n tree.addEdge(a[i] - 1, b[i] - 1, c[i])\n tree.addEdge(b[i] - 1, a[i] - 1, c[i])\n }\n val distances = tree.getDistances(K - 1)\n // println(distances.toList())\n repeat(Q){\n val ans = distances[x[it] - 1] + distances[y[it] - 1]\n println(ans)\n }\n return\n}\n\nfun AdjacentListGraph.getDistances(from: Int): LongArray{\n // Breadth First Search\n val distances = LongArray(vertices.size){ -1L }\n distances[from] = 0\n val queue = ArrayDeque()\n queue.add(from)\n while(queue.size > 0){\n val node = queue.removeFirst()\n val curDist = distances[node]\n vertices[node].edges.filter{ distances[it.to] == -1L }.forEach{\n val delta = it.weight?: 1L\n distances[it.to] = curDist + delta\n queue.add(it.to)\n }\n }\n return distances\n}\ndata class Vertex, E : Comparable>(val data: T? = null) {\n data class Edge>(val to: Int, val weight: T? = null)\n\n val edges = mutableListOf>()\n\n fun addEdge(to: Int, weight: E?) = when (edges.find { it.to == to }) {\n null -> {\n edges.add(Edge(to, weight))\n true\n }\n else -> false\n }\n\n fun removeEdge(to: Int): Boolean{\n for ((i, edge) in edges.withIndex()){\n if (edge.to == to){\n edges.removeAt(i)\n return true\n }\n }\n return false\n }\n}\n\nclass AdjacentListGraph, E : Comparable>(\n val vertices: MutableList>\n) {\n // T = data of Vertex, E = weight of Edge\n fun getWeight(from: Int, to: Int): E? = vertices[from].edges.find { it.to == to }?.weight\n fun addEdge(from: Int, to: Int, weight: E? = null) = vertices[from].addEdge(to, weight)\n fun removeEdge(from: Int, to: Int) = vertices[from].removeEdge(to)\n fun isAdjacent(from: Int, to: Int) = vertices[from].edges.find { it.to == to } != null\n}\n\nfun main(args: Array) {\n fun StringArray(size: Int, init: (Int) -> String = { \"\\u0000\" }): Array {\n return Array(size, init)\n }\n class Scanner(stream: InputStream) {\n private val reader = BufferedInputStream(stream).bufferedReader()\n private var st: StringTokenizer? = null\n fun next(): String {\n while (!(st?.hasMoreTokens() ?: false)) st = StringTokenizer(reader.readLine())\n return st!!.nextToken()\n }\n }\n val sc = Scanner(System.`in`)\n val N = sc.next().toInt()\n val a = IntArray(N-1)\n val b = IntArray(N-1)\n val c = LongArray(N-1)\n for (i in 0 until N-1) {\n a[i] = sc.next().toInt()\n b[i] = sc.next().toInt()\n c[i] = sc.next().toLong()\n }\n val Q = sc.next().toInt()\n val K = sc.next().toInt()\n val x = IntArray(Q.toInt())\n val y = IntArray(Q.toInt())\n for (i in 0 until Q.toInt()) {\n x[i] = sc.next().toInt()\n y[i] = sc.next().toInt()\n }\n solve(N, a, b, c, Q, K, x, y)\n}\n\n", "language": "Kotlin", "metadata": {"date": 1576726740, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03634.html", "problem_id": "p03634", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03634/input.txt", "sample_output_relpath": "derived/input_output/data/p03634/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03634/Kotlin/s066056208.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s066056208", "user_id": "u329232967"}, "prompt_components": {"gold_output": "3\n2\n4\n", "input_to_evaluate": "import java.io.*\nimport java.util.*\n\nvar pw = PrintWriter(System.out)\nfun solve(N: Int, a: IntArray, b: IntArray, c: LongArray, Q: Int, K: Int, x: IntArray, y: IntArray){\n val tree = AdjacentListGraph(Array(N){ Vertex() }.toMutableList())\n for(i in 0 until N - 1){\n tree.addEdge(a[i] - 1, b[i] - 1, c[i])\n tree.addEdge(b[i] - 1, a[i] - 1, c[i])\n }\n val distances = tree.getDistances(K - 1)\n // println(distances.toList())\n repeat(Q){\n val ans = distances[x[it] - 1] + distances[y[it] - 1]\n println(ans)\n }\n return\n}\n\nfun AdjacentListGraph.getDistances(from: Int): LongArray{\n // Breadth First Search\n val distances = LongArray(vertices.size){ -1L }\n distances[from] = 0\n val queue = ArrayDeque()\n queue.add(from)\n while(queue.size > 0){\n val node = queue.removeFirst()\n val curDist = distances[node]\n vertices[node].edges.filter{ distances[it.to] == -1L }.forEach{\n val delta = it.weight?: 1L\n distances[it.to] = curDist + delta\n queue.add(it.to)\n }\n }\n return distances\n}\ndata class Vertex, E : Comparable>(val data: T? = null) {\n data class Edge>(val to: Int, val weight: T? = null)\n\n val edges = mutableListOf>()\n\n fun addEdge(to: Int, weight: E?) = when (edges.find { it.to == to }) {\n null -> {\n edges.add(Edge(to, weight))\n true\n }\n else -> false\n }\n\n fun removeEdge(to: Int): Boolean{\n for ((i, edge) in edges.withIndex()){\n if (edge.to == to){\n edges.removeAt(i)\n return true\n }\n }\n return false\n }\n}\n\nclass AdjacentListGraph, E : Comparable>(\n val vertices: MutableList>\n) {\n // T = data of Vertex, E = weight of Edge\n fun getWeight(from: Int, to: Int): E? = vertices[from].edges.find { it.to == to }?.weight\n fun addEdge(from: Int, to: Int, weight: E? = null) = vertices[from].addEdge(to, weight)\n fun removeEdge(from: Int, to: Int) = vertices[from].removeEdge(to)\n fun isAdjacent(from: Int, to: Int) = vertices[from].edges.find { it.to == to } != null\n}\n\nfun main(args: Array) {\n fun StringArray(size: Int, init: (Int) -> String = { \"\\u0000\" }): Array {\n return Array(size, init)\n }\n class Scanner(stream: InputStream) {\n private val reader = BufferedInputStream(stream).bufferedReader()\n private var st: StringTokenizer? = null\n fun next(): String {\n while (!(st?.hasMoreTokens() ?: false)) st = StringTokenizer(reader.readLine())\n return st!!.nextToken()\n }\n }\n val sc = Scanner(System.`in`)\n val N = sc.next().toInt()\n val a = IntArray(N-1)\n val b = IntArray(N-1)\n val c = LongArray(N-1)\n for (i in 0 until N-1) {\n a[i] = sc.next().toInt()\n b[i] = sc.next().toInt()\n c[i] = sc.next().toLong()\n }\n val Q = sc.next().toInt()\n val K = sc.next().toInt()\n val x = IntArray(Q.toInt())\n val y = IntArray(Q.toInt())\n for (i in 0 until Q.toInt()) {\n x[i] = sc.next().toInt()\n y[i] = sc.next().toInt()\n }\n solve(N, a, b, c, Q, K, x, y)\n}\n\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nYou are given a tree with N vertices.\n\nHere, a tree is a kind of graph, and more specifically, a connected undirected graph with N-1 edges, where N is the number of its vertices.\n\nThe i-th edge (1≤i≤N-1) connects Vertices a_i and b_i, and has a length of c_i.\n\nYou are also given Q queries and an integer K. In the j-th query (1≤j≤Q):\n\nfind the length of the shortest path from Vertex x_j and Vertex y_j via Vertex K.\n\nConstraints\n\n3≤N≤10^5\n\n1≤a_i,b_i≤N (1≤i≤N-1)\n\n1≤c_i≤10^9 (1≤i≤N-1)\n\nThe given graph is a tree.\n\n1≤Q≤10^5\n\n1≤K≤N\n\n1≤x_j,y_j≤N (1≤j≤Q)\n\nx_j≠y_j (1≤j≤Q)\n\nx_j≠K,y_j≠K (1≤j≤Q)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 b_1 c_1\n:\na_{N-1} b_{N-1} c_{N-1}\nQ K\nx_1 y_1\n:\nx_{Q} y_{Q}\n\nOutput\n\nPrint the responses to the queries in Q lines.\n\nIn the j-th line j(1≤j≤Q), print the response to the j-th query.\n\nSample Input 1\n\n5\n1 2 1\n1 3 1\n2 4 1\n3 5 1\n3 1\n2 4\n2 3\n4 5\n\nSample Output 1\n\n3\n2\n4\n\nThe shortest paths for the three queries are as follows:\n\nQuery 1: Vertex 2 → Vertex 1 → Vertex 2 → Vertex 4 : Length 1+1+1=3\n\nQuery 2: Vertex 2 → Vertex 1 → Vertex 3 : Length 1+1=2\n\nQuery 3: Vertex 4 → Vertex 2 → Vertex 1 → Vertex 3 → Vertex 5 : Length 1+1+1+1=4\n\nSample Input 2\n\n7\n1 2 1\n1 3 3\n1 4 5\n1 5 7\n1 6 9\n1 7 11\n3 2\n1 3\n4 5\n6 7\n\nSample Output 2\n\n5\n14\n22\n\nThe path for each query must pass Vertex K=2.\n\nSample Input 3\n\n10\n1 2 1000000000\n2 3 1000000000\n3 4 1000000000\n4 5 1000000000\n5 6 1000000000\n6 7 1000000000\n7 8 1000000000\n8 9 1000000000\n9 10 1000000000\n1 1\n9 10\n\nSample Output 3\n\n17000000000", "sample_input": "5\n1 2 1\n1 3 1\n2 4 1\n3 5 1\n3 1\n2 4\n2 3\n4 5\n"}, "reference_outputs": ["3\n2\n4\n"], "source_document_id": "p03634", "source_text": "Score : 400 points\n\nProblem Statement\n\nYou are given a tree with N vertices.\n\nHere, a tree is a kind of graph, and more specifically, a connected undirected graph with N-1 edges, where N is the number of its vertices.\n\nThe i-th edge (1≤i≤N-1) connects Vertices a_i and b_i, and has a length of c_i.\n\nYou are also given Q queries and an integer K. In the j-th query (1≤j≤Q):\n\nfind the length of the shortest path from Vertex x_j and Vertex y_j via Vertex K.\n\nConstraints\n\n3≤N≤10^5\n\n1≤a_i,b_i≤N (1≤i≤N-1)\n\n1≤c_i≤10^9 (1≤i≤N-1)\n\nThe given graph is a tree.\n\n1≤Q≤10^5\n\n1≤K≤N\n\n1≤x_j,y_j≤N (1≤j≤Q)\n\nx_j≠y_j (1≤j≤Q)\n\nx_j≠K,y_j≠K (1≤j≤Q)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 b_1 c_1\n:\na_{N-1} b_{N-1} c_{N-1}\nQ K\nx_1 y_1\n:\nx_{Q} y_{Q}\n\nOutput\n\nPrint the responses to the queries in Q lines.\n\nIn the j-th line j(1≤j≤Q), print the response to the j-th query.\n\nSample Input 1\n\n5\n1 2 1\n1 3 1\n2 4 1\n3 5 1\n3 1\n2 4\n2 3\n4 5\n\nSample Output 1\n\n3\n2\n4\n\nThe shortest paths for the three queries are as follows:\n\nQuery 1: Vertex 2 → Vertex 1 → Vertex 2 → Vertex 4 : Length 1+1+1=3\n\nQuery 2: Vertex 2 → Vertex 1 → Vertex 3 : Length 1+1=2\n\nQuery 3: Vertex 4 → Vertex 2 → Vertex 1 → Vertex 3 → Vertex 5 : Length 1+1+1+1=4\n\nSample Input 2\n\n7\n1 2 1\n1 3 3\n1 4 5\n1 5 7\n1 6 9\n1 7 11\n3 2\n1 3\n4 5\n6 7\n\nSample Output 2\n\n5\n14\n22\n\nThe path for each query must pass Vertex K=2.\n\nSample Input 3\n\n10\n1 2 1000000000\n2 3 1000000000\n3 4 1000000000\n4 5 1000000000\n5 6 1000000000\n6 7 1000000000\n7 8 1000000000\n8 9 1000000000\n9 10 1000000000\n1 1\n9 10\n\nSample Output 3\n\n17000000000", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 3321, "cpu_time_ms": 2111, "memory_kb": 100964}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s644981433", "group_id": "codeNet:p03636", "input_text": "fun main(args: Array) {\n val s = readLine()!!\n println(s.first() + (s.count() - 2).toString() + s.last())\n}", "language": "Kotlin", "metadata": {"date": 1542827096, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03636.html", "problem_id": "p03636", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03636/input.txt", "sample_output_relpath": "derived/input_output/data/p03636/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03636/Kotlin/s644981433.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s644981433", "user_id": "u227189389"}, "prompt_components": {"gold_output": "i18n\n", "input_to_evaluate": "fun main(args: Array) {\n val s = readLine()!!\n println(s.first() + (s.count() - 2).toString() + s.last())\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nThe word internationalization is sometimes abbreviated to i18n.\nThis comes from the fact that there are 18 letters between the first i and the last n.\n\nYou are given a string s of length at least 3 consisting of lowercase English letters.\nAbbreviate s in the same way.\n\nConstraints\n\n3 ≤ |s| ≤ 100 (|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\nPrint the abbreviation of s.\n\nSample Input 1\n\ninternationalization\n\nSample Output 1\n\ni18n\n\nSample Input 2\n\nsmiles\n\nSample Output 2\n\ns4s\n\nSample Input 3\n\nxyz\n\nSample Output 3\n\nx1z", "sample_input": "internationalization\n"}, "reference_outputs": ["i18n\n"], "source_document_id": "p03636", "source_text": "Score : 200 points\n\nProblem Statement\n\nThe word internationalization is sometimes abbreviated to i18n.\nThis comes from the fact that there are 18 letters between the first i and the last n.\n\nYou are given a string s of length at least 3 consisting of lowercase English letters.\nAbbreviate s in the same way.\n\nConstraints\n\n3 ≤ |s| ≤ 100 (|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\nPrint the abbreviation of s.\n\nSample Input 1\n\ninternationalization\n\nSample Output 1\n\ni18n\n\nSample Input 2\n\nsmiles\n\nSample Output 2\n\ns4s\n\nSample Input 3\n\nxyz\n\nSample Output 3\n\nx1z", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 206, "memory_kb": 33576}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s611846782", "group_id": "codeNet:p03638", "input_text": "fun main(args: Array) {\n val (H, W) = readLine()!!.split(\" \").map { it.toInt() }\n val N = readLine()!!.toInt()\n val a = readLine()!!.split(\" \").map { it.toInt() }.toIntArray()\n\n val result = Array(H, { IntArray(W, { 0 })})\n\n var i = 0\n var cur = 0\n while (i < H) {\n val indices = if (i % 2 == 0) (0..W-1) else (0..W-1).reversed()\n\n indices.forEach {j ->\n result[i][j] = cur + 1\n a[cur]--\n if (cur < N && a[cur] == 0) {\n cur++\n }\n }\n if (cur < N && a[cur] == 0) {\n cur++\n }\n i++\n }\n\n result.forEach {\n println(it.joinToString(\" \"))\n }\n}", "language": "Kotlin", "metadata": {"date": 1569981354, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03638.html", "problem_id": "p03638", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03638/input.txt", "sample_output_relpath": "derived/input_output/data/p03638/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03638/Kotlin/s611846782.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s611846782", "user_id": "u861095163"}, "prompt_components": {"gold_output": "1 1\n2 3\n", "input_to_evaluate": "fun main(args: Array) {\n val (H, W) = readLine()!!.split(\" \").map { it.toInt() }\n val N = readLine()!!.toInt()\n val a = readLine()!!.split(\" \").map { it.toInt() }.toIntArray()\n\n val result = Array(H, { IntArray(W, { 0 })})\n\n var i = 0\n var cur = 0\n while (i < H) {\n val indices = if (i % 2 == 0) (0..W-1) else (0..W-1).reversed()\n\n indices.forEach {j ->\n result[i][j] = cur + 1\n a[cur]--\n if (cur < N && a[cur] == 0) {\n cur++\n }\n }\n if (cur < N && a[cur] == 0) {\n cur++\n }\n i++\n }\n\n result.forEach {\n println(it.joinToString(\" \"))\n }\n}", "problem_context": "Score : 400 points\n\nProblem Statement\n\nWe have a grid with H rows and W columns of squares.\nSnuke is painting these squares in colors 1, 2, ..., N.\nHere, the following conditions should be satisfied:\n\nFor each i (1 ≤ i ≤ N), there are exactly a_i squares painted in Color i. Here, a_1 + a_2 + ... + a_N = H W.\n\nFor each i (1 ≤ i ≤ N), the squares painted in Color i are 4-connected. That is, every square painted in Color i can be reached from every square painted in Color i by repeatedly traveling to a horizontally or vertically adjacent square painted in Color i.\n\nFind a way to paint the squares so that the conditions are satisfied.\nIt can be shown that a solution always exists.\n\nConstraints\n\n1 ≤ H, W ≤ 100\n\n1 ≤ N ≤ H W\n\na_i ≥ 1\n\na_1 + a_2 + ... + a_N = H W\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\nN\na_1 a_2 ... a_N\n\nOutput\n\nPrint one way to paint the squares that satisfies the conditions.\nOutput in the following format:\n\nc_{1 1} ... c_{1 W}\n:\nc_{H 1} ... c_{H W}\n\nHere, c_{i j} is the color of the square at the i-th row from the top and j-th column from the left.\n\nSample Input 1\n\n2 2\n3\n2 1 1\n\nSample Output 1\n\n1 1\n2 3\n\nBelow is an example of an invalid solution:\n\n1 2\n3 1\n\nThis is because the squares painted in Color 1 are not 4-connected.\n\nSample Input 2\n\n3 5\n5\n1 2 3 4 5\n\nSample Output 2\n\n1 4 4 4 3\n2 5 4 5 3\n2 5 5 5 3\n\nSample Input 3\n\n1 1\n1\n1\n\nSample Output 3\n\n1", "sample_input": "2 2\n3\n2 1 1\n"}, "reference_outputs": ["1 1\n2 3\n"], "source_document_id": "p03638", "source_text": "Score : 400 points\n\nProblem Statement\n\nWe have a grid with H rows and W columns of squares.\nSnuke is painting these squares in colors 1, 2, ..., N.\nHere, the following conditions should be satisfied:\n\nFor each i (1 ≤ i ≤ N), there are exactly a_i squares painted in Color i. Here, a_1 + a_2 + ... + a_N = H W.\n\nFor each i (1 ≤ i ≤ N), the squares painted in Color i are 4-connected. That is, every square painted in Color i can be reached from every square painted in Color i by repeatedly traveling to a horizontally or vertically adjacent square painted in Color i.\n\nFind a way to paint the squares so that the conditions are satisfied.\nIt can be shown that a solution always exists.\n\nConstraints\n\n1 ≤ H, W ≤ 100\n\n1 ≤ N ≤ H W\n\na_i ≥ 1\n\na_1 + a_2 + ... + a_N = H W\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\nN\na_1 a_2 ... a_N\n\nOutput\n\nPrint one way to paint the squares that satisfies the conditions.\nOutput in the following format:\n\nc_{1 1} ... c_{1 W}\n:\nc_{H 1} ... c_{H W}\n\nHere, c_{i j} is the color of the square at the i-th row from the top and j-th column from the left.\n\nSample Input 1\n\n2 2\n3\n2 1 1\n\nSample Output 1\n\n1 1\n2 3\n\nBelow is an example of an invalid solution:\n\n1 2\n3 1\n\nThis is because the squares painted in Color 1 are not 4-connected.\n\nSample Input 2\n\n3 5\n5\n1 2 3 4 5\n\nSample Output 2\n\n1 4 4 4 3\n2 5 4 5 3\n2 5 5 5 3\n\nSample Input 3\n\n1 1\n1\n1\n\nSample Output 3\n\n1", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 692, "cpu_time_ms": 453, "memory_kb": 39696}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s727329274", "group_id": "codeNet:p03645", "input_text": "\nfun main(args: Array) {\n val (n, m) = readListInt()\n val ab = readMatrixInt(m)\n var boxA = mutableSetOf()\n var boxB = mutableSetOf()\n ab.forEach {\n if (it[0] == 1) boxA.add(it[1])\n if (it[1] == n) boxB.add(it[0])\n }\n\n if (boxA.find { boxB.contains(it) } != null) {\n println(\"POSSIBLE\")\n } else {\n println(\"IMPOSSIBLE\")\n }\n}\n\nprivate fun read() = readLine()!!\n\nprivate fun readInt() = Integer.parseInt(read())\n\nprivate fun readLong() = read().toLong()\n\nprivate fun readDouble() = read().toDouble()\n\nprivate fun readListString() = read().split(\" \")\n\nprivate fun readListInt() = readListString().map { Integer.parseInt(it) }\n\nprivate fun readListLong() = readListString().map { it.toLong() }\n\nprivate fun readListDouble() = readListString().map { it.toDouble() }\n\nprivate fun readMatrixString(n: Int): List> {\n val matrix = mutableListOf>()\n for (i in 0 until n) {\n val list = readListString()\n matrix.add(list)\n }\n return matrix\n}\n\nprivate fun readMatrixInt(n: Int): List> {\n val matrix = mutableListOf>()\n for (i in 0 until n) {\n val list = readListInt()\n matrix.add(list)\n }\n return matrix\n}\n\nprivate fun readMatrixDouble(n: Int): List> {\n val matrix = mutableListOf>()\n for (i in 0 until n) {\n val list = readListDouble()\n matrix.add(list)\n }\n return matrix\n}\n\nprivate fun readMatrixLong(n: Int): List> {\n val matrix = mutableListOf>()\n for (i in 0 until n) {\n val list = readListLong()\n matrix.add(list)\n }\n return matrix\n}\n\n", "language": "Kotlin", "metadata": {"date": 1592121938, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03645.html", "problem_id": "p03645", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03645/input.txt", "sample_output_relpath": "derived/input_output/data/p03645/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03645/Kotlin/s727329274.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s727329274", "user_id": "u698000453"}, "prompt_components": {"gold_output": "POSSIBLE\n", "input_to_evaluate": "\nfun main(args: Array) {\n val (n, m) = readListInt()\n val ab = readMatrixInt(m)\n var boxA = mutableSetOf()\n var boxB = mutableSetOf()\n ab.forEach {\n if (it[0] == 1) boxA.add(it[1])\n if (it[1] == n) boxB.add(it[0])\n }\n\n if (boxA.find { boxB.contains(it) } != null) {\n println(\"POSSIBLE\")\n } else {\n println(\"IMPOSSIBLE\")\n }\n}\n\nprivate fun read() = readLine()!!\n\nprivate fun readInt() = Integer.parseInt(read())\n\nprivate fun readLong() = read().toLong()\n\nprivate fun readDouble() = read().toDouble()\n\nprivate fun readListString() = read().split(\" \")\n\nprivate fun readListInt() = readListString().map { Integer.parseInt(it) }\n\nprivate fun readListLong() = readListString().map { it.toLong() }\n\nprivate fun readListDouble() = readListString().map { it.toDouble() }\n\nprivate fun readMatrixString(n: Int): List> {\n val matrix = mutableListOf>()\n for (i in 0 until n) {\n val list = readListString()\n matrix.add(list)\n }\n return matrix\n}\n\nprivate fun readMatrixInt(n: Int): List> {\n val matrix = mutableListOf>()\n for (i in 0 until n) {\n val list = readListInt()\n matrix.add(list)\n }\n return matrix\n}\n\nprivate fun readMatrixDouble(n: Int): List> {\n val matrix = mutableListOf>()\n for (i in 0 until n) {\n val list = readListDouble()\n matrix.add(list)\n }\n return matrix\n}\n\nprivate fun readMatrixLong(n: Int): List> {\n val matrix = mutableListOf>()\n for (i in 0 until n) {\n val list = readListLong()\n matrix.add(list)\n }\n return matrix\n}\n\n", "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": "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1699, "cpu_time_ms": 719, "memory_kb": 89144}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s722076225", "group_id": "codeNet:p03645", "input_text": "fun main(args: Array) {\n val (n, m) = readListInt()\n val ab = readMatrixInt(m)\n var boxA: MutableList = mutableListOf()\n var boxB = mutableListOf()\n ab.forEach {\n if (it[0] == 1) boxA.add(it[1])\n if (it[1] == n) boxB.add(it[0])\n }\n\n val flag = boxA.any { boxB.contains(it) }\n if (flag) println(\"POSSIBLE\") else println(\"IMPOSSIBLE\")\n\n}\n\nprivate fun read() = readLine()!!\n\nprivate fun readInt() = read().toInt()\n\nprivate fun readLong() = read().toLong()\n\nprivate fun readDouble() = read().toDouble()\n\nprivate fun readListString() = read().split(\" \")\n\nprivate fun readListInt() = readListString().map { it.toInt() }\n\nprivate fun readListLong() = readListString().map { it.toLong() }\n\nprivate fun readListDouble() = readListString().map { it.toDouble() }\n\nprivate fun readMatrixString(n: Int): List> {\n val matrix = mutableListOf>()\n for (i in 0 until n) {\n val list = readListString()\n matrix.add(list)\n }\n return matrix\n}\n\nprivate fun readMatrixInt(n: Int): List> {\n val matrix = mutableListOf>()\n for (i in 0 until n) {\n val list = readListInt()\n matrix.add(list)\n }\n return matrix\n}\n\nprivate fun readMatrixDouble(n: Int): List> {\n val matrix = mutableListOf>()\n for (i in 0 until n) {\n val list = readListDouble()\n matrix.add(list)\n }\n return matrix\n}\n\nprivate fun readMatrixLong(n: Int): List> {\n val matrix = mutableListOf>()\n for (i in 0 until n) {\n val list = readListLong()\n matrix.add(list)\n }\n return matrix\n}\n\n", "language": "Kotlin", "metadata": {"date": 1592119739, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03645.html", "problem_id": "p03645", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03645/input.txt", "sample_output_relpath": "derived/input_output/data/p03645/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03645/Kotlin/s722076225.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s722076225", "user_id": "u698000453"}, "prompt_components": {"gold_output": "POSSIBLE\n", "input_to_evaluate": "fun main(args: Array) {\n val (n, m) = readListInt()\n val ab = readMatrixInt(m)\n var boxA: MutableList = mutableListOf()\n var boxB = mutableListOf()\n ab.forEach {\n if (it[0] == 1) boxA.add(it[1])\n if (it[1] == n) boxB.add(it[0])\n }\n\n val flag = boxA.any { boxB.contains(it) }\n if (flag) println(\"POSSIBLE\") else println(\"IMPOSSIBLE\")\n\n}\n\nprivate fun read() = readLine()!!\n\nprivate fun readInt() = read().toInt()\n\nprivate fun readLong() = read().toLong()\n\nprivate fun readDouble() = read().toDouble()\n\nprivate fun readListString() = read().split(\" \")\n\nprivate fun readListInt() = readListString().map { it.toInt() }\n\nprivate fun readListLong() = readListString().map { it.toLong() }\n\nprivate fun readListDouble() = readListString().map { it.toDouble() }\n\nprivate fun readMatrixString(n: Int): List> {\n val matrix = mutableListOf>()\n for (i in 0 until n) {\n val list = readListString()\n matrix.add(list)\n }\n return matrix\n}\n\nprivate fun readMatrixInt(n: Int): List> {\n val matrix = mutableListOf>()\n for (i in 0 until n) {\n val list = readListInt()\n matrix.add(list)\n }\n return matrix\n}\n\nprivate fun readMatrixDouble(n: Int): List> {\n val matrix = mutableListOf>()\n for (i in 0 until n) {\n val list = readListDouble()\n matrix.add(list)\n }\n return matrix\n}\n\nprivate fun readMatrixLong(n: Int): List> {\n val matrix = mutableListOf>()\n for (i in 0 until n) {\n val list = readListLong()\n matrix.add(list)\n }\n return matrix\n}\n\n", "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": "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 2111, "memory_kb": 91444}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s420396601", "group_id": "codeNet:p03645", "input_text": "fun main(arg: Array) {\n val (N, M) = listOfInt()\n val G = Array>(N) { mutableListOf() }\n repeat(M) {\n val (a, b) = listOfInt(-1)\n G[a].add(b); G[b].add(a)\n }\n for (n in 0 until N) G[n].sort()\n var ans = false\n for (x in 1 until N - 1) {\n if (G[0].binarySearch(x) > -1 && G[x].binarySearch(N - 1) > -1) {\n ans = true; break\n }\n }\n println(if (ans) \"POSSIBLE\" else \"IMPOSSIBLE\")\n}\nfun next() = readLine()!!\nfun nextInt() = next().toInt()\nfun nextLong() = next().toLong()\nfun listOfString() = next().split(\" \")\nfun listOfInt() = listOfString().map(String::toInt)\nfun listOfInt(vararg deltas: Int) = listOfString().map { Integer.parseInt(it) }.mapIndexed { index, int -> int + deltas[index % deltas.size] }\n\n", "language": "Kotlin", "metadata": {"date": 1585665704, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03645.html", "problem_id": "p03645", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03645/input.txt", "sample_output_relpath": "derived/input_output/data/p03645/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03645/Kotlin/s420396601.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s420396601", "user_id": "u043150661"}, "prompt_components": {"gold_output": "POSSIBLE\n", "input_to_evaluate": "fun main(arg: Array) {\n val (N, M) = listOfInt()\n val G = Array>(N) { mutableListOf() }\n repeat(M) {\n val (a, b) = listOfInt(-1)\n G[a].add(b); G[b].add(a)\n }\n for (n in 0 until N) G[n].sort()\n var ans = false\n for (x in 1 until N - 1) {\n if (G[0].binarySearch(x) > -1 && G[x].binarySearch(N - 1) > -1) {\n ans = true; break\n }\n }\n println(if (ans) \"POSSIBLE\" else \"IMPOSSIBLE\")\n}\nfun next() = readLine()!!\nfun nextInt() = next().toInt()\nfun nextLong() = next().toLong()\nfun listOfString() = next().split(\" \")\nfun listOfInt() = listOfString().map(String::toInt)\nfun listOfInt(vararg deltas: Int) = listOfString().map { Integer.parseInt(it) }.mapIndexed { index, int -> int + deltas[index % deltas.size] }\n\n", "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": "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 800, "cpu_time_ms": 942, "memory_kb": 106836}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s826349917", "group_id": "codeNet:p03645", "input_text": "fun main(args: Array) {\n val (n, m) = readLine()!!.split(\" \").map { it.toInt() }\n val x = (1..m).map { readLine()!!.split(\" \").map { it.toInt() } }\n .map { Pair(it[0], it[1]) }\n val from1 = x.filter { it.first == 1 }.map { it.second }\n val toN = x.filter { it.second == n }.map { it.first }\n val ans = if ((from1.intersect(toN)).isNotEmpty()) \"POSSIBLE\" else \"IMPOSSIBLE\"\n println(ans)\n}", "language": "Kotlin", "metadata": {"date": 1577929093, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03645.html", "problem_id": "p03645", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03645/input.txt", "sample_output_relpath": "derived/input_output/data/p03645/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03645/Kotlin/s826349917.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s826349917", "user_id": "u777283665"}, "prompt_components": {"gold_output": "POSSIBLE\n", "input_to_evaluate": "fun main(args: Array) {\n val (n, m) = readLine()!!.split(\" \").map { it.toInt() }\n val x = (1..m).map { readLine()!!.split(\" \").map { it.toInt() } }\n .map { Pair(it[0], it[1]) }\n val from1 = x.filter { it.first == 1 }.map { it.second }\n val toN = x.filter { it.second == n }.map { it.first }\n val ans = if ((from1.intersect(toN)).isNotEmpty()) \"POSSIBLE\" else \"IMPOSSIBLE\"\n println(ans)\n}", "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": "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1126, "memory_kb": 110580}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s670138997", "group_id": "codeNet:p03645", "input_text": "fun main(args: Array) {\n var (N,M) = readLine()!!.split(\" \").map(String::toInt)\n var pair:MutableList> = mutableListOf()\n (1..M).map{i->\n var (a,b) = readLine()!!.split(\" \").map(String::toInt)\n pair.add(Pair(a,b))\n }\n for(p in pair){\n if(p.second == N && pair.contains(Pair(1,p.first))){\n println(\"POSSIBLE\")\n return\n }\n }\n \n println(\"INPOSSIBLE\")\n}\n", "language": "Kotlin", "metadata": {"date": 1552151728, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03645.html", "problem_id": "p03645", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03645/input.txt", "sample_output_relpath": "derived/input_output/data/p03645/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03645/Kotlin/s670138997.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s670138997", "user_id": "u399261731"}, "prompt_components": {"gold_output": "POSSIBLE\n", "input_to_evaluate": "fun main(args: Array) {\n var (N,M) = readLine()!!.split(\" \").map(String::toInt)\n var pair:MutableList> = mutableListOf()\n (1..M).map{i->\n var (a,b) = readLine()!!.split(\" \").map(String::toInt)\n pair.add(Pair(a,b))\n }\n for(p in pair){\n if(p.second == N && pair.contains(Pair(1,p.first))){\n println(\"POSSIBLE\")\n return\n }\n }\n \n println(\"INPOSSIBLE\")\n}\n", "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": "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 2111, "memory_kb": 84412}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s766957469", "group_id": "codeNet:p03645", "input_text": "fun main(args: Array) {\n val(n,m)= readLine()!!.split(\" \").map{it.toInt()}\n val a= readEdgesAsAdjList(n,m)\n\n if(a[0].toHashSet().any{ a[n-1].toHashSet().contains(it) }){\n println(\"POSSIBLE\")\n }else{\n println(\"IMPOSSIBLE\")\n }\n\n}\n\nfun readEdgesAsAdjList(n:Int, m:Int):Array>{\n val e=(1..m).map {\n readLine()!!.split(\" \").map{it.toInt()-1}\n }\n val adj=Array>(n, {mutableListOf()})\n e.forEach {\n adj[it[0]].add(it[1])\n adj[it[1]].add(it[0])\n }\n return adj\n}\n", "language": "Kotlin", "metadata": {"date": 1541225755, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03645.html", "problem_id": "p03645", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03645/input.txt", "sample_output_relpath": "derived/input_output/data/p03645/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03645/Kotlin/s766957469.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s766957469", "user_id": "u914096045"}, "prompt_components": {"gold_output": "POSSIBLE\n", "input_to_evaluate": "fun main(args: Array) {\n val(n,m)= readLine()!!.split(\" \").map{it.toInt()}\n val a= readEdgesAsAdjList(n,m)\n\n if(a[0].toHashSet().any{ a[n-1].toHashSet().contains(it) }){\n println(\"POSSIBLE\")\n }else{\n println(\"IMPOSSIBLE\")\n }\n\n}\n\nfun readEdgesAsAdjList(n:Int, m:Int):Array>{\n val e=(1..m).map {\n readLine()!!.split(\" \").map{it.toInt()-1}\n }\n val adj=Array>(n, {mutableListOf()})\n e.forEach {\n adj[it[0]].add(it[1])\n adj[it[1]].add(it[0])\n }\n return adj\n}\n", "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": "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 569, "cpu_time_ms": 2116, "memory_kb": 161904}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s899858209", "group_id": "codeNet:p03646", "input_text": "fun main(args: Array){\n val k = readLine()!!.toLong()\n val a = LongArray(50)\n for(i in a.indices){\n a[i] = i + 1L\n }\n repeat((50 - k % 50).toInt()){\n val maxIndex = a.indexOf(a.max()!!)\n for(i in a.indices){\n if(i == maxIndex){\n a[i] = a[i] - 50\n }else{\n a[i] = a[i] + 1\n }\n }\n }\n for(i in a.indices){\n a[i] = a[i] + k / 50\n }\n println(50)\n println(a.joinToString(separator = \" \"))\n}", "language": "Kotlin", "metadata": {"date": 1589425035, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p03646.html", "problem_id": "p03646", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03646/input.txt", "sample_output_relpath": "derived/input_output/data/p03646/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03646/Kotlin/s899858209.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s899858209", "user_id": "u531770859"}, "prompt_components": {"gold_output": "4\n3 3 3 3\n", "input_to_evaluate": "fun main(args: Array){\n val k = readLine()!!.toLong()\n val a = LongArray(50)\n for(i in a.indices){\n a[i] = i + 1L\n }\n repeat((50 - k % 50).toInt()){\n val maxIndex = a.indexOf(a.max()!!)\n for(i in a.indices){\n if(i == maxIndex){\n a[i] = a[i] - 50\n }else{\n a[i] = a[i] + 1\n }\n }\n }\n for(i in a.indices){\n a[i] = a[i] + k / 50\n }\n println(50)\n println(a.joinToString(separator = \" \"))\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.\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 an integer K. Find an integer sequence a_i such that the number of times we will perform the above operation is exactly K. It can be shown that there is always such a sequence under the constraints on input and output in this problem.\n\nConstraints\n\n0 ≤ K ≤ 50 \\times 10^{16}\n\nInput\n\nInput is given from Standard Input in the following format:\n\nK\n\nOutput\n\nPrint a solution in the following format:\n\nN\na_1 a_2 ... a_N\n\nHere, 2 ≤ N ≤ 50 and 0 ≤ a_i ≤ 10^{16} + 1000 must hold.\n\nSample Input 1\n\n0\n\nSample Output 1\n\n4\n3 3 3 3\n\nSample Input 2\n\n1\n\nSample Output 2\n\n3\n1 0 3\n\nSample Input 3\n\n2\n\nSample Output 3\n\n2\n2 2\n\nThe operation will be performed twice: [2, 2] -> [0, 3] -> [1, 1].\n\nSample Input 4\n\n3\n\nSample Output 4\n\n7\n27 0 0 0 0 0 0\n\nSample Input 5\n\n1234567894848\n\nSample Output 5\n\n10\n1000 193 256 777 0 1 1192 1234567891011 48 425", "sample_input": "0\n"}, "reference_outputs": ["4\n3 3 3 3\n"], "source_document_id": "p03646", "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.\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 an integer K. Find an integer sequence a_i such that the number of times we will perform the above operation is exactly K. It can be shown that there is always such a sequence under the constraints on input and output in this problem.\n\nConstraints\n\n0 ≤ K ≤ 50 \\times 10^{16}\n\nInput\n\nInput is given from Standard Input in the following format:\n\nK\n\nOutput\n\nPrint a solution in the following format:\n\nN\na_1 a_2 ... a_N\n\nHere, 2 ≤ N ≤ 50 and 0 ≤ a_i ≤ 10^{16} + 1000 must hold.\n\nSample Input 1\n\n0\n\nSample Output 1\n\n4\n3 3 3 3\n\nSample Input 2\n\n1\n\nSample Output 2\n\n3\n1 0 3\n\nSample Input 3\n\n2\n\nSample Output 3\n\n2\n2 2\n\nThe operation will be performed twice: [2, 2] -> [0, 3] -> [1, 1].\n\nSample Input 4\n\n3\n\nSample Output 4\n\n7\n27 0 0 0 0 0 0\n\nSample Input 5\n\n1234567894848\n\nSample Output 5\n\n10\n1000 193 256 777 0 1 1192 1234567891011 48 425", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 104, "memory_kb": 38276}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s258843916", "group_id": "codeNet:p03647", "input_text": "fun main(args: Array) {\n val (n, m) = readLine()!!.split(' ').map(String::toLong)\n val abList = mutableListOf>()\n for (i in 0 until m) {\n val (a, b) = readLine()!!.split(' ').map(String::toLong)\n abList.add(Pair(a,b))\n }\n val point1List = abList.filter{it.first == 1L}.map { it.second }\n if(abList.filter{it.second == n}.any{point1List.contains(it.first)}){\n println(\"POSSIBLE\")\n }else{\n println(\"IMPOSSIBLE\")\n }\n}", "language": "Kotlin", "metadata": {"date": 1530802738, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03647.html", "problem_id": "p03647", "resource_group": "medium_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/Kotlin/s258843916.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s258843916", "user_id": "u099066216"}, "prompt_components": {"gold_output": "POSSIBLE\n", "input_to_evaluate": "fun main(args: Array) {\n val (n, m) = readLine()!!.split(' ').map(String::toLong)\n val abList = mutableListOf>()\n for (i in 0 until m) {\n val (a, b) = readLine()!!.split(' ').map(String::toLong)\n abList.add(Pair(a,b))\n }\n val point1List = abList.filter{it.first == 1L}.map { it.second }\n if(abList.filter{it.second == n}.any{point1List.contains(it.first)}){\n println(\"POSSIBLE\")\n }else{\n println(\"IMPOSSIBLE\")\n }\n}", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 490, "cpu_time_ms": 2111, "memory_kb": 84648}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s371062115", "group_id": "codeNet:p03651", "input_text": "fun main(args: Array) {\n agc018a()\n}\n\nfun agc018a() {\n val (n, k) = readLine()!!.split(\" \").map { it.toLong() }\n val aSet = readLine()!!.split(\" \").map { it.toLong() }.distinct()\n\n val max = aSet.max()!!\n val gcd = aSet.fold(aSet.first()) { acc, l -> gcd(acc, l) }\n\n val answer = if (k <= max && k % gcd == 0L) \"POSSIBLE\" else \"IMPOSSIBLE\"\n\n println(answer)\n}\n\nprivate tailrec fun gcd(a: Long, b: Long): Long {\n return if (b == 0L) a else gcd(b, a % b)\n}\n", "language": "Kotlin", "metadata": {"date": 1572837289, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03651.html", "problem_id": "p03651", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03651/input.txt", "sample_output_relpath": "derived/input_output/data/p03651/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03651/Kotlin/s371062115.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s371062115", "user_id": "u139478771"}, "prompt_components": {"gold_output": "POSSIBLE\n", "input_to_evaluate": "fun main(args: Array) {\n agc018a()\n}\n\nfun agc018a() {\n val (n, k) = readLine()!!.split(\" \").map { it.toLong() }\n val aSet = readLine()!!.split(\" \").map { it.toLong() }.distinct()\n\n val max = aSet.max()!!\n val gcd = aSet.fold(aSet.first()) { acc, l -> gcd(acc, l) }\n\n val answer = if (k <= max && k % gcd == 0L) \"POSSIBLE\" else \"IMPOSSIBLE\"\n\n println(answer)\n}\n\nprivate tailrec fun gcd(a: Long, b: Long): Long {\n return if (b == 0L) a else gcd(b, a % b)\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere is a box containing N balls. The i-th ball has the integer A_i written on it.\nSnuke can perform the following operation any number of times:\n\nTake out two balls from the box. Then, return them to the box along with a new ball, on which the absolute difference of the integers written on the two balls is written.\n\nDetermine whether it is possible for Snuke to reach the state where the box contains a ball on which the integer K is written.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n1 \\leq A_i \\leq 10^9\n\n1 \\leq K \\leq 10^9\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\nIf it is possible for Snuke to reach the state where the box contains a ball on which the integer K is written, print POSSIBLE; if it is not possible, print IMPOSSIBLE.\n\nSample Input 1\n\n3 7\n9 3 4\n\nSample Output 1\n\nPOSSIBLE\n\nFirst, take out the two balls 9 and 4, and return them back along with a new ball, abs(9-4)=5.\nNext, take out 3 and 5, and return them back along with abs(3-5)=2.\nFinally, take out 9 and 2, and return them back along with abs(9-2)=7.\nNow we have 7 in the box, and the answer is therefore POSSIBLE.\n\nSample Input 2\n\n3 5\n6 9 3\n\nSample Output 2\n\nIMPOSSIBLE\n\nNo matter what we do, it is not possible to have 5 in the box. The answer is therefore IMPOSSIBLE.\n\nSample Input 3\n\n4 11\n11 3 7 15\n\nSample Output 3\n\nPOSSIBLE\n\nThe box already contains 11 before we do anything. The answer is therefore POSSIBLE.\n\nSample Input 4\n\n5 12\n10 2 8 6 4\n\nSample Output 4\n\nIMPOSSIBLE", "sample_input": "3 7\n9 3 4\n"}, "reference_outputs": ["POSSIBLE\n"], "source_document_id": "p03651", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere is a box containing N balls. The i-th ball has the integer A_i written on it.\nSnuke can perform the following operation any number of times:\n\nTake out two balls from the box. Then, return them to the box along with a new ball, on which the absolute difference of the integers written on the two balls is written.\n\nDetermine whether it is possible for Snuke to reach the state where the box contains a ball on which the integer K is written.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n1 \\leq A_i \\leq 10^9\n\n1 \\leq K \\leq 10^9\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\nIf it is possible for Snuke to reach the state where the box contains a ball on which the integer K is written, print POSSIBLE; if it is not possible, print IMPOSSIBLE.\n\nSample Input 1\n\n3 7\n9 3 4\n\nSample Output 1\n\nPOSSIBLE\n\nFirst, take out the two balls 9 and 4, and return them back along with a new ball, abs(9-4)=5.\nNext, take out 3 and 5, and return them back along with abs(3-5)=2.\nFinally, take out 9 and 2, and return them back along with abs(9-2)=7.\nNow we have 7 in the box, and the answer is therefore POSSIBLE.\n\nSample Input 2\n\n3 5\n6 9 3\n\nSample Output 2\n\nIMPOSSIBLE\n\nNo matter what we do, it is not possible to have 5 in the box. The answer is therefore IMPOSSIBLE.\n\nSample Input 3\n\n4 11\n11 3 7 15\n\nSample Output 3\n\nPOSSIBLE\n\nThe box already contains 11 before we do anything. The answer is therefore POSSIBLE.\n\nSample Input 4\n\n5 12\n10 2 8 6 4\n\nSample Output 4\n\nIMPOSSIBLE", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 687, "memory_kb": 72964}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s374140810", "group_id": "codeNet:p03671", "input_text": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n var arr = mutableListOf(0,0,0)\n for (i in 0..2) arr[i] = sc.nextInt()\n arr.sort()\n println(arr[0] + arr[1])\n}\n\n\n", "language": "Kotlin", "metadata": {"date": 1530139632, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03671.html", "problem_id": "p03671", "resource_group": "medium_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/Kotlin/s374140810.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s374140810", "user_id": "u396701320"}, "prompt_components": {"gold_output": "1300\n", "input_to_evaluate": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n var arr = mutableListOf(0,0,0)\n for (i in 0..2) arr[i] = sc.nextInt()\n arr.sort()\n println(arr[0] + arr[1])\n}\n\n\n", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 182, "memory_kb": 31384}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s014148249", "group_id": "codeNet:p03673", "input_text": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val n = sc.nextInt()\n val a = (1..n).map { sc.nextInt() }\n\n val aa = a.reversed()\n val b = mutableListOf()\n\n for ((i, ai) in aa.withIndex()) {\n if (i % 2 == 0) {\n b.add(ai)\n }\n }\n if (n % 2 == 0) {\n for ((i, ai) in a.withIndex()) {\n if (i % 2 == 0) b.add(ai)\n }\n } else {\n for ((i, ai) in a.withIndex()) {\n if (i % 2 != 0) b.add(ai)\n }\n }\n\n println(b.joinToString(\" \"))\n\n}", "language": "Kotlin", "metadata": {"date": 1596383224, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p03673.html", "problem_id": "p03673", "resource_group": "medium_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/Kotlin/s014148249.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s014148249", "user_id": "u323522006"}, "prompt_components": {"gold_output": "4 2 1 3\n", "input_to_evaluate": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val n = sc.nextInt()\n val a = (1..n).map { sc.nextInt() }\n\n val aa = a.reversed()\n val b = mutableListOf()\n\n for ((i, ai) in aa.withIndex()) {\n if (i % 2 == 0) {\n b.add(ai)\n }\n }\n if (n % 2 == 0) {\n for ((i, ai) in a.withIndex()) {\n if (i % 2 == 0) b.add(ai)\n }\n } else {\n for ((i, ai) in a.withIndex()) {\n if (i % 2 != 0) b.add(ai)\n }\n }\n\n println(b.joinToString(\" \"))\n\n}", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 785, "memory_kb": 74876}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s885889450", "group_id": "codeNet:p03675", "input_text": "import java.util.*\n\nfun main(args: Array) {\n val n = readLine()!!.toInt()\n val aQueue = ArrayDeque(readLine()!!.split(' ').map(String::toInt))\n val result = ArrayDeque()\n\n if (n % 2 == 1) {\n result.addFirst(aQueue.pop())\n }\n while (!aQueue.isEmpty()) {\n if (n % 2 == 1) {\n result.addLast(aQueue.pop())\n result.addFirst(aQueue.pop())\n } else {\n result.addLast(aQueue.pop())\n result.addFirst(aQueue.pop())\n }\n }\n println(result.toMutableList().joinToString(\" \"))\n}", "language": "Kotlin", "metadata": {"date": 1530804561, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03675.html", "problem_id": "p03675", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03675/input.txt", "sample_output_relpath": "derived/input_output/data/p03675/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03675/Kotlin/s885889450.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s885889450", "user_id": "u099066216"}, "prompt_components": {"gold_output": "4 2 1 3\n", "input_to_evaluate": "import java.util.*\n\nfun main(args: Array) {\n val n = readLine()!!.toInt()\n val aQueue = ArrayDeque(readLine()!!.split(' ').map(String::toInt))\n val result = ArrayDeque()\n\n if (n % 2 == 1) {\n result.addFirst(aQueue.pop())\n }\n while (!aQueue.isEmpty()) {\n if (n % 2 == 1) {\n result.addLast(aQueue.pop())\n result.addFirst(aQueue.pop())\n } else {\n result.addLast(aQueue.pop())\n result.addFirst(aQueue.pop())\n }\n }\n println(result.toMutableList().joinToString(\" \"))\n}", "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": "p03675", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 742, "memory_kb": 103180}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s627884661", "group_id": "codeNet:p03680", "input_text": "fun main(args: Array) = println(run {\n val n = readLine()!!.toInt()\n val a = (1..n).map { readLine()!!.toInt() }\n\n val visit = mutableSetOf(1)\n var b = 1\n var count = 0\n while (true) {\n b = a[b-1]\n if(b in visit) return@run -1\n visit.add(b)\n count++\n if(b == 2) return@run count\n }\n\n})\n", "language": "Kotlin", "metadata": {"date": 1588714352, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03680.html", "problem_id": "p03680", "resource_group": "medium_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/Kotlin/s627884661.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s627884661", "user_id": "u563556491"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "fun main(args: Array) = println(run {\n val n = readLine()!!.toInt()\n val a = (1..n).map { readLine()!!.toInt() }\n\n val visit = mutableSetOf(1)\n var b = 1\n var count = 0\n while (true) {\n b = a[b-1]\n if(b in visit) return@run -1\n visit.add(b)\n count++\n if(b == 2) return@run count\n }\n\n})\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 460, "memory_kb": 48108}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s026367029", "group_id": "codeNet:p03680", "input_text": "import java.io.PrintWriter\n\nval pw = PrintWriter(System.out)\nfun main(args: Array) {\n func()\n pw.flush()\n}\n\nfun func() {\n val n = nextInt()\n val xs = (1..n).map{ nextInt() - 1}\n var t = 0\n var current = 0\n while(current != 1 && t++ < n){\n current = xs[current]\n }\n print(if (current == 1) t else -1)\n}\n\n// 入力取得\nfun next() = readLine()!!\n\nfun nextInt() = next().toInt()\nfun nextLong() = next().toLong()\nfun nextDouble() = next().toDouble()\nfun listOfString() = next().split(\" \")\nfun listOfInt() = listOfString().map { it.toInt() }\nfun listOfLong() = listOfString().map { it.toLong() }\nfun listOfDouble() = listOfString().map { it.toDouble() }\n\n// 約数のList\nfun divisor(value: Long): List {\n val max = Math.sqrt(value.toDouble()).toLong()\n return (1..max)\n .filter { value % it == 0L }\n .map { listOf(it, value / it) }\n .flatten()\n .sorted()\n}\n\n// 範囲内の素数を取得\n// fromだけ指定すると戻り値の個数で素数判定ができる\nfun prime(from: Long, to: Long = from): List {\n return (from..to).filter { i ->\n val max = Math.sqrt(i.toDouble()).toLong()\n (2..max).all { j -> i % j != 0L }\n }\n}\n\n// 素因数分解\nfun decom(value: Long): List {\n if (value == 1L) return listOf(1)\n val max = Math.sqrt(value.toDouble()).toLong()\n return prime(2, max).filter { value % it == 0L }\n}\n\n// 最大公約数\nfun gcd(a: Long, b: Long): Long {\n return if (a % b == 0L) b else gcd(b, a % b)\n}\n\n// 文字列を入れ替え\nfun swap(base: String, a: String, b: String): String {\n return base.map {\n when (it) {\n a.toCharArray()[0] -> b\n b.toCharArray()[0] -> a\n else -> it.toString()\n }\n }.joinToString()\n}\n\nfun println(value: Any) {\n pw.println(value)\n}\n\nfun print(value: Any){\n pw.print(value)\n}", "language": "Kotlin", "metadata": {"date": 1562460266, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03680.html", "problem_id": "p03680", "resource_group": "medium_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/Kotlin/s026367029.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s026367029", "user_id": "u526818046"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import java.io.PrintWriter\n\nval pw = PrintWriter(System.out)\nfun main(args: Array) {\n func()\n pw.flush()\n}\n\nfun func() {\n val n = nextInt()\n val xs = (1..n).map{ nextInt() - 1}\n var t = 0\n var current = 0\n while(current != 1 && t++ < n){\n current = xs[current]\n }\n print(if (current == 1) t else -1)\n}\n\n// 入力取得\nfun next() = readLine()!!\n\nfun nextInt() = next().toInt()\nfun nextLong() = next().toLong()\nfun nextDouble() = next().toDouble()\nfun listOfString() = next().split(\" \")\nfun listOfInt() = listOfString().map { it.toInt() }\nfun listOfLong() = listOfString().map { it.toLong() }\nfun listOfDouble() = listOfString().map { it.toDouble() }\n\n// 約数のList\nfun divisor(value: Long): List {\n val max = Math.sqrt(value.toDouble()).toLong()\n return (1..max)\n .filter { value % it == 0L }\n .map { listOf(it, value / it) }\n .flatten()\n .sorted()\n}\n\n// 範囲内の素数を取得\n// fromだけ指定すると戻り値の個数で素数判定ができる\nfun prime(from: Long, to: Long = from): List {\n return (from..to).filter { i ->\n val max = Math.sqrt(i.toDouble()).toLong()\n (2..max).all { j -> i % j != 0L }\n }\n}\n\n// 素因数分解\nfun decom(value: Long): List {\n if (value == 1L) return listOf(1)\n val max = Math.sqrt(value.toDouble()).toLong()\n return prime(2, max).filter { value % it == 0L }\n}\n\n// 最大公約数\nfun gcd(a: Long, b: Long): Long {\n return if (a % b == 0L) b else gcd(b, a % b)\n}\n\n// 文字列を入れ替え\nfun swap(base: String, a: String, b: String): String {\n return base.map {\n when (it) {\n a.toCharArray()[0] -> b\n b.toCharArray()[0] -> a\n else -> it.toString()\n }\n }.joinToString()\n}\n\nfun println(value: Any) {\n pw.println(value)\n}\n\nfun print(value: Any){\n pw.print(value)\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1915, "cpu_time_ms": 424, "memory_kb": 39208}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s241458672", "group_id": "codeNet:p03680", "input_text": "fun main(args: Array) {\n val n= readLine()!!.toInt()\n val a=(1..n).map { readLine()!!.toInt()-1 }\n val visited = BooleanArray(n){ false }\n visited[0]=true\n\n var light=0\n var count=0\n while (light!=1){\n\n light=a[light]\n count++\n if(visited[light]){\n println(-1)\n return\n }else{\n visited[light]=true\n }\n }\n println(count)\n}", "language": "Kotlin", "metadata": {"date": 1542214786, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03680.html", "problem_id": "p03680", "resource_group": "medium_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/Kotlin/s241458672.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s241458672", "user_id": "u914096045"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "fun main(args: Array) {\n val n= readLine()!!.toInt()\n val a=(1..n).map { readLine()!!.toInt()-1 }\n val visited = BooleanArray(n){ false }\n visited[0]=true\n\n var light=0\n var count=0\n while (light!=1){\n\n light=a[light]\n count++\n if(visited[light]){\n println(-1)\n return\n }else{\n visited[light]=true\n }\n }\n println(count)\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 417, "memory_kb": 41016}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s084947697", "group_id": "codeNet:p03684", "input_text": "import java.io.InputStream\n\nval input = FastScanner()\n\nfun main(args: Array) = input.run {\n val n = nextInt()\n val a = Array>(n) { nextInt() to nextInt() }\n\n val xi = a.indices.sortedBy { a[it].first }\n val yi = a.indices.sortedBy { a[it].second }\n\n val edges = mutableListOf>()\n\n (1 until n).forEach { edges += xi[it - 1] to xi[it] }\n (1 until n).forEach { edges += yi[it - 1] to yi[it] }\n\n fun Pair.dist(): Int {\n val (x1, y1) = a[first]\n val (x2, y2) = a[second]\n return Math.min(Math.abs(x1 - x2), Math.abs(y1 - y2))\n }\n\n edges.sortBy { it.dist() }\n\n val ds = UnionFind(n)\n\n var ans = 0L\n\n edges.forEach {\n val (s, t) = it\n if (ds.find(s) != ds.find(t)) {\n ans += it.dist()\n ds.union(s, t)\n }\n }\n\n println(ans)\n}\n\nclass FastScanner(private val input: InputStream = System.`in`) {\n private val sb = StringBuilder()\n private val buffer = ByteArray(4096)\n private var pos = 0\n private var size = 0\n\n fun nextLong(): Long {\n var c = skipWhitespace()\n\n val sign = if (c == '-'.toInt()) {\n c = read()\n -1\n } else 1\n\n var ans = 0L\n\n while (c > ' '.toInt()) {\n ans = ans * 10 + c - '0'.toInt()\n c = read()\n }\n\n return sign * ans\n }\n\n fun nextInt() = nextLong().toInt()\n\n private fun skipWhitespace(): Int {\n while (true) {\n val c = read()\n if (c > ' '.toInt() || c < 0) return c\n }\n }\n\n private fun read(): Int {\n while (pos >= size) {\n if (size < 0) return -1\n size = input.read(buffer, 0, buffer.size)\n pos = 0\n }\n return buffer[pos++].toInt()\n }\n}\n\nclass UnionFind(size: Int) {\n private val parent: IntArray = IntArray(size) { it }\n private val rank = IntArray(size)\n\n fun find(u: Int): Int {\n if (parent[u] != u) {\n parent[u] = find(parent[u])\n }\n return parent[u]\n }\n\n fun union(u: Int, v: Int): Int {\n val uRoot = find(u)\n val vRoot = find(v)\n if (uRoot == vRoot) {\n return uRoot\n }\n if (rank[uRoot] == rank[vRoot]) {\n rank[uRoot]++\n }\n return if (rank[uRoot] < rank[vRoot]) {\n parent[uRoot] = vRoot\n vRoot\n } else {\n parent[vRoot] = uRoot\n uRoot\n }\n }\n}", "language": "Kotlin", "metadata": {"date": 1498356001, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03684.html", "problem_id": "p03684", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03684/input.txt", "sample_output_relpath": "derived/input_output/data/p03684/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03684/Kotlin/s084947697.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s084947697", "user_id": "u110651993"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "import java.io.InputStream\n\nval input = FastScanner()\n\nfun main(args: Array) = input.run {\n val n = nextInt()\n val a = Array>(n) { nextInt() to nextInt() }\n\n val xi = a.indices.sortedBy { a[it].first }\n val yi = a.indices.sortedBy { a[it].second }\n\n val edges = mutableListOf>()\n\n (1 until n).forEach { edges += xi[it - 1] to xi[it] }\n (1 until n).forEach { edges += yi[it - 1] to yi[it] }\n\n fun Pair.dist(): Int {\n val (x1, y1) = a[first]\n val (x2, y2) = a[second]\n return Math.min(Math.abs(x1 - x2), Math.abs(y1 - y2))\n }\n\n edges.sortBy { it.dist() }\n\n val ds = UnionFind(n)\n\n var ans = 0L\n\n edges.forEach {\n val (s, t) = it\n if (ds.find(s) != ds.find(t)) {\n ans += it.dist()\n ds.union(s, t)\n }\n }\n\n println(ans)\n}\n\nclass FastScanner(private val input: InputStream = System.`in`) {\n private val sb = StringBuilder()\n private val buffer = ByteArray(4096)\n private var pos = 0\n private var size = 0\n\n fun nextLong(): Long {\n var c = skipWhitespace()\n\n val sign = if (c == '-'.toInt()) {\n c = read()\n -1\n } else 1\n\n var ans = 0L\n\n while (c > ' '.toInt()) {\n ans = ans * 10 + c - '0'.toInt()\n c = read()\n }\n\n return sign * ans\n }\n\n fun nextInt() = nextLong().toInt()\n\n private fun skipWhitespace(): Int {\n while (true) {\n val c = read()\n if (c > ' '.toInt() || c < 0) return c\n }\n }\n\n private fun read(): Int {\n while (pos >= size) {\n if (size < 0) return -1\n size = input.read(buffer, 0, buffer.size)\n pos = 0\n }\n return buffer[pos++].toInt()\n }\n}\n\nclass UnionFind(size: Int) {\n private val parent: IntArray = IntArray(size) { it }\n private val rank = IntArray(size)\n\n fun find(u: Int): Int {\n if (parent[u] != u) {\n parent[u] = find(parent[u])\n }\n return parent[u]\n }\n\n fun union(u: Int, v: Int): Int {\n val uRoot = find(u)\n val vRoot = find(v)\n if (uRoot == vRoot) {\n return uRoot\n }\n if (rank[uRoot] == rank[vRoot]) {\n rank[uRoot]++\n }\n return if (rank[uRoot] < rank[vRoot]) {\n parent[uRoot] = vRoot\n vRoot\n } else {\n parent[vRoot] = uRoot\n uRoot\n }\n }\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": "p03684", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2508, "cpu_time_ms": 1210, "memory_kb": 129288}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s466651597", "group_id": "codeNet:p03687", "input_text": "fun main(args: Array) {\n val s = readLine() ?: return\n val count = s.groupBy { it }\n .map { entry ->\n val c = entry.key\n var count = 0\n var t = s.toCharArray().toMutableList()\n while (!t.all { a -> a == c }) {\n 0.until(t.size - 1).forEach { i ->\n if (t[i] == c || t[i + 1] == c) {\n t[i] = c\n }\n }\n count++\n t = t.dropLast(1).toMutableList()\n }\n count\n }.min()\n println(count.toString())\n}", "language": "Kotlin", "metadata": {"date": 1592312392, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03687.html", "problem_id": "p03687", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03687/input.txt", "sample_output_relpath": "derived/input_output/data/p03687/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03687/Kotlin/s466651597.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s466651597", "user_id": "u979429407"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "fun main(args: Array) {\n val s = readLine() ?: return\n val count = s.groupBy { it }\n .map { entry ->\n val c = entry.key\n var count = 0\n var t = s.toCharArray().toMutableList()\n while (!t.all { a -> a == c }) {\n 0.until(t.size - 1).forEach { i ->\n if (t[i] == c || t[i + 1] == c) {\n t[i] = c\n }\n }\n count++\n t = t.dropLast(1).toMutableList()\n }\n count\n }.min()\n println(count.toString())\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nSnuke can change a string t of length N into a string t' of length N - 1 under the following rule:\n\nFor each i (1 ≤ i ≤ N - 1), the i-th character of t' must be either the i-th or (i + 1)-th character of t.\n\nThere is a string s consisting of lowercase English letters.\nSnuke's objective is to apply the above operation to s repeatedly so that all the characters in s are the same.\nFind the minimum necessary number of operations.\n\nConstraints\n\n1 ≤ |s| ≤ 100\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 the minimum necessary number of operations to achieve the objective.\n\nSample Input 1\n\nserval\n\nSample Output 1\n\n3\n\nOne solution is: serval → srvvl → svvv → vvv.\n\nSample Input 2\n\njackal\n\nSample Output 2\n\n2\n\nOne solution is: jackal → aacaa → aaaa.\n\nSample Input 3\n\nzzz\n\nSample Output 3\n\n0\n\nAll the characters in s are the same from the beginning.\n\nSample Input 4\n\nwhbrjpjyhsrywlqjxdbrbaomnw\n\nSample Output 4\n\n8\n\nIn 8 operations, he can change s to rrrrrrrrrrrrrrrrrr.", "sample_input": "serval\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03687", "source_text": "Score : 300 points\n\nProblem Statement\n\nSnuke can change a string t of length N into a string t' of length N - 1 under the following rule:\n\nFor each i (1 ≤ i ≤ N - 1), the i-th character of t' must be either the i-th or (i + 1)-th character of t.\n\nThere is a string s consisting of lowercase English letters.\nSnuke's objective is to apply the above operation to s repeatedly so that all the characters in s are the same.\nFind the minimum necessary number of operations.\n\nConstraints\n\n1 ≤ |s| ≤ 100\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 the minimum necessary number of operations to achieve the objective.\n\nSample Input 1\n\nserval\n\nSample Output 1\n\n3\n\nOne solution is: serval → srvvl → svvv → vvv.\n\nSample Input 2\n\njackal\n\nSample Output 2\n\n2\n\nOne solution is: jackal → aacaa → aaaa.\n\nSample Input 3\n\nzzz\n\nSample Output 3\n\n0\n\nAll the characters in s are the same from the beginning.\n\nSample Input 4\n\nwhbrjpjyhsrywlqjxdbrbaomnw\n\nSample Output 4\n\n8\n\nIn 8 operations, he can change s to rrrrrrrrrrrrrrrrrr.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 322, "memory_kb": 37804}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s815350315", "group_id": "codeNet:p03687", "input_text": "fun main(args : Array) {\n val s = readLine()!!\n val lCnt = mutableMapOf()\n\n for (i in 1 until s.length) {\n lCnt[s[i]] = (lCnt[s[i]] ?: 0) + 1\n }\n\n val target = lCnt.maxBy { it.value }?.key\n var ss = s\n var cnt = 0\n\n while (ss != target.toString().repeat(s.length-cnt)) {\n var tmp = \"\"\n for (i in 0 until ss.length-1) {\n if (ss[i+1] == target) {\n tmp += ss[i+1]\n } else {\n tmp += ss[i]\n }\n }\n ss = tmp\n cnt++\n }\n\n println(cnt)\n}\n\n", "language": "Kotlin", "metadata": {"date": 1587949098, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03687.html", "problem_id": "p03687", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03687/input.txt", "sample_output_relpath": "derived/input_output/data/p03687/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03687/Kotlin/s815350315.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s815350315", "user_id": "u262403099"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "fun main(args : Array) {\n val s = readLine()!!\n val lCnt = mutableMapOf()\n\n for (i in 1 until s.length) {\n lCnt[s[i]] = (lCnt[s[i]] ?: 0) + 1\n }\n\n val target = lCnt.maxBy { it.value }?.key\n var ss = s\n var cnt = 0\n\n while (ss != target.toString().repeat(s.length-cnt)) {\n var tmp = \"\"\n for (i in 0 until ss.length-1) {\n if (ss[i+1] == target) {\n tmp += ss[i+1]\n } else {\n tmp += ss[i]\n }\n }\n ss = tmp\n cnt++\n }\n\n println(cnt)\n}\n\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nSnuke can change a string t of length N into a string t' of length N - 1 under the following rule:\n\nFor each i (1 ≤ i ≤ N - 1), the i-th character of t' must be either the i-th or (i + 1)-th character of t.\n\nThere is a string s consisting of lowercase English letters.\nSnuke's objective is to apply the above operation to s repeatedly so that all the characters in s are the same.\nFind the minimum necessary number of operations.\n\nConstraints\n\n1 ≤ |s| ≤ 100\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 the minimum necessary number of operations to achieve the objective.\n\nSample Input 1\n\nserval\n\nSample Output 1\n\n3\n\nOne solution is: serval → srvvl → svvv → vvv.\n\nSample Input 2\n\njackal\n\nSample Output 2\n\n2\n\nOne solution is: jackal → aacaa → aaaa.\n\nSample Input 3\n\nzzz\n\nSample Output 3\n\n0\n\nAll the characters in s are the same from the beginning.\n\nSample Input 4\n\nwhbrjpjyhsrywlqjxdbrbaomnw\n\nSample Output 4\n\n8\n\nIn 8 operations, he can change s to rrrrrrrrrrrrrrrrrr.", "sample_input": "serval\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03687", "source_text": "Score : 300 points\n\nProblem Statement\n\nSnuke can change a string t of length N into a string t' of length N - 1 under the following rule:\n\nFor each i (1 ≤ i ≤ N - 1), the i-th character of t' must be either the i-th or (i + 1)-th character of t.\n\nThere is a string s consisting of lowercase English letters.\nSnuke's objective is to apply the above operation to s repeatedly so that all the characters in s are the same.\nFind the minimum necessary number of operations.\n\nConstraints\n\n1 ≤ |s| ≤ 100\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 the minimum necessary number of operations to achieve the objective.\n\nSample Input 1\n\nserval\n\nSample Output 1\n\n3\n\nOne solution is: serval → srvvl → svvv → vvv.\n\nSample Input 2\n\njackal\n\nSample Output 2\n\n2\n\nOne solution is: jackal → aacaa → aaaa.\n\nSample Input 3\n\nzzz\n\nSample Output 3\n\n0\n\nAll the characters in s are the same from the beginning.\n\nSample Input 4\n\nwhbrjpjyhsrywlqjxdbrbaomnw\n\nSample Output 4\n\n8\n\nIn 8 operations, he can change s to rrrrrrrrrrrrrrrrrr.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 583, "cpu_time_ms": 235, "memory_kb": 33760}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s106956769", "group_id": "codeNet:p03687", "input_text": "fun main(args: Array) {\n val s = readLine()!!\n s.toList().distinct().map {\n s.split(it).map { it.length }.max()!!\n }.min()!!.let { println(it) }\n\n}", "language": "Kotlin", "metadata": {"date": 1561328671, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03687.html", "problem_id": "p03687", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03687/input.txt", "sample_output_relpath": "derived/input_output/data/p03687/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03687/Kotlin/s106956769.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s106956769", "user_id": "u914096045"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "fun main(args: Array) {\n val s = readLine()!!\n s.toList().distinct().map {\n s.split(it).map { it.length }.max()!!\n }.min()!!.let { println(it) }\n\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nSnuke can change a string t of length N into a string t' of length N - 1 under the following rule:\n\nFor each i (1 ≤ i ≤ N - 1), the i-th character of t' must be either the i-th or (i + 1)-th character of t.\n\nThere is a string s consisting of lowercase English letters.\nSnuke's objective is to apply the above operation to s repeatedly so that all the characters in s are the same.\nFind the minimum necessary number of operations.\n\nConstraints\n\n1 ≤ |s| ≤ 100\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 the minimum necessary number of operations to achieve the objective.\n\nSample Input 1\n\nserval\n\nSample Output 1\n\n3\n\nOne solution is: serval → srvvl → svvv → vvv.\n\nSample Input 2\n\njackal\n\nSample Output 2\n\n2\n\nOne solution is: jackal → aacaa → aaaa.\n\nSample Input 3\n\nzzz\n\nSample Output 3\n\n0\n\nAll the characters in s are the same from the beginning.\n\nSample Input 4\n\nwhbrjpjyhsrywlqjxdbrbaomnw\n\nSample Output 4\n\n8\n\nIn 8 operations, he can change s to rrrrrrrrrrrrrrrrrr.", "sample_input": "serval\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03687", "source_text": "Score : 300 points\n\nProblem Statement\n\nSnuke can change a string t of length N into a string t' of length N - 1 under the following rule:\n\nFor each i (1 ≤ i ≤ N - 1), the i-th character of t' must be either the i-th or (i + 1)-th character of t.\n\nThere is a string s consisting of lowercase English letters.\nSnuke's objective is to apply the above operation to s repeatedly so that all the characters in s are the same.\nFind the minimum necessary number of operations.\n\nConstraints\n\n1 ≤ |s| ≤ 100\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 the minimum necessary number of operations to achieve the objective.\n\nSample Input 1\n\nserval\n\nSample Output 1\n\n3\n\nOne solution is: serval → srvvl → svvv → vvv.\n\nSample Input 2\n\njackal\n\nSample Output 2\n\n2\n\nOne solution is: jackal → aacaa → aaaa.\n\nSample Input 3\n\nzzz\n\nSample Output 3\n\n0\n\nAll the characters in s are the same from the beginning.\n\nSample Input 4\n\nwhbrjpjyhsrywlqjxdbrbaomnw\n\nSample Output 4\n\n8\n\nIn 8 operations, he can change s to rrrrrrrrrrrrrrrrrr.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 171, "cpu_time_ms": 236, "memory_kb": 38304}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s948012503", "group_id": "codeNet:p03688", "input_text": "import java.util.*\nfun main(args: Array){\n\tval cin = Scanner(System.`in`)\n val n = cin.nextInt()\n val a = Array(n, { cin.nextInt() })\n\n var t = a[0]\n var less = 0\n var same = 0\n var more = 0\n var ok = true\n\n for (i in 0..n-1) {\n if (a[i] == t + 1) {\n more += 1\n } else if (a[i] == t - 1) {\n less += 1\n } else if (a[i] == t) {\n same += 1\n } else {\n ok = false\n break\n }\n }\n\n var major = t\n var key = t\n \n var major_cats = same\n var key_cats = same\n\n if (more == 0) {\n key = t - 1\n key_cats = less\n } else if (less == 0) {\n major = t + 1\n major_cats = more\n } else {\n ok = false\n }\n\n if (more == 0 && less == 0) {\n major = t\n key = t \n } \n\n if (major != key) {\n val ex = major - key_cats\n if (0 >= ex || ex*2 > major_cats) {\n ok = false\n }\n } else {\n if (major != n - 1 && major*2 > n) {\n ok = false\n }\n }\n\n if (ok == false) {\n println(\"No\")\n } else {\n println(\"Yes\")\n }\n}", "language": "Kotlin", "metadata": {"date": 1551919313, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03688.html", "problem_id": "p03688", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03688/input.txt", "sample_output_relpath": "derived/input_output/data/p03688/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03688/Kotlin/s948012503.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s948012503", "user_id": "u111421568"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "import java.util.*\nfun main(args: Array){\n\tval cin = Scanner(System.`in`)\n val n = cin.nextInt()\n val a = Array(n, { cin.nextInt() })\n\n var t = a[0]\n var less = 0\n var same = 0\n var more = 0\n var ok = true\n\n for (i in 0..n-1) {\n if (a[i] == t + 1) {\n more += 1\n } else if (a[i] == t - 1) {\n less += 1\n } else if (a[i] == t) {\n same += 1\n } else {\n ok = false\n break\n }\n }\n\n var major = t\n var key = t\n \n var major_cats = same\n var key_cats = same\n\n if (more == 0) {\n key = t - 1\n key_cats = less\n } else if (less == 0) {\n major = t + 1\n major_cats = more\n } else {\n ok = false\n }\n\n if (more == 0 && less == 0) {\n major = t\n key = t \n } \n\n if (major != key) {\n val ex = major - key_cats\n if (0 >= ex || ex*2 > major_cats) {\n ok = false\n }\n } else {\n if (major != n - 1 && major*2 > n) {\n ok = false\n }\n }\n\n if (ok == false) {\n println(\"No\")\n } else {\n println(\"Yes\")\n }\n}", "problem_context": "Score : 700 points\n\nProblem Statement\n\nThere are N cats.\nWe number them from 1 through N.\n\nEach of the cats wears a hat.\nCat i says: \"there are exactly a_i different colors among the N - 1 hats worn by the cats except me.\"\n\nDetermine whether there exists a sequence of colors of the hats that is consistent with the remarks of the cats.\n\nConstraints\n\n2 ≤ N ≤ 10^5\n\n1 ≤ a_i ≤ N-1\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 Yes if there exists a sequence of colors of the hats that is consistent with the remarks of the cats; print No otherwise.\n\nSample Input 1\n\n3\n1 2 2\n\nSample Output 1\n\nYes\n\nFor example, if cat 1, 2 and 3 wears red, blue and blue hats, respectively, it is consistent with the remarks of the cats.\n\nSample Input 2\n\n3\n1 1 2\n\nSample Output 2\n\nNo\n\nFrom the remark of cat 1, we can see that cat 2 and 3 wear hats of the same color.\nAlso, from the remark of cat 2, we can see that cat 1 and 3 wear hats of the same color.\nTherefore, cat 1 and 2 wear hats of the same color, which contradicts the remark of cat 3.\n\nSample Input 3\n\n5\n4 3 4 3 4\n\nSample Output 3\n\nNo\n\nSample Input 4\n\n3\n2 2 2\n\nSample Output 4\n\nYes\n\nSample Input 5\n\n4\n2 2 2 2\n\nSample Output 5\n\nYes\n\nSample Input 6\n\n5\n3 3 3 3 3\n\nSample Output 6\n\nNo", "sample_input": "3\n1 2 2\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03688", "source_text": "Score : 700 points\n\nProblem Statement\n\nThere are N cats.\nWe number them from 1 through N.\n\nEach of the cats wears a hat.\nCat i says: \"there are exactly a_i different colors among the N - 1 hats worn by the cats except me.\"\n\nDetermine whether there exists a sequence of colors of the hats that is consistent with the remarks of the cats.\n\nConstraints\n\n2 ≤ N ≤ 10^5\n\n1 ≤ a_i ≤ N-1\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 Yes if there exists a sequence of colors of the hats that is consistent with the remarks of the cats; print No otherwise.\n\nSample Input 1\n\n3\n1 2 2\n\nSample Output 1\n\nYes\n\nFor example, if cat 1, 2 and 3 wears red, blue and blue hats, respectively, it is consistent with the remarks of the cats.\n\nSample Input 2\n\n3\n1 1 2\n\nSample Output 2\n\nNo\n\nFrom the remark of cat 1, we can see that cat 2 and 3 wear hats of the same color.\nAlso, from the remark of cat 2, we can see that cat 1 and 3 wear hats of the same color.\nTherefore, cat 1 and 2 wear hats of the same color, which contradicts the remark of cat 3.\n\nSample Input 3\n\n5\n4 3 4 3 4\n\nSample Output 3\n\nNo\n\nSample Input 4\n\n3\n2 2 2\n\nSample Output 4\n\nYes\n\nSample Input 5\n\n4\n2 2 2 2\n\nSample Output 5\n\nYes\n\nSample Input 6\n\n5\n3 3 3 3 3\n\nSample Output 6\n\nNo", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 518, "memory_kb": 53756}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s535623922", "group_id": "codeNet:p03695", "input_text": "\nfun main(arr:Array) {\n val count = readLine()!!.toInt()\n val rates = readLine()!!.split(\" \").map { it.toInt() }\n val underRed = rates.filter { it < 3200 }.map { it / 400 }.distinct()\n val overRed = rates.count { it >= 3200 }\n val min = underRed.size\n val max = Math.min(underRed.size + overRed, 8)\n println(\"%d %d\".format(min,max))\n}", "language": "Kotlin", "metadata": {"date": 1582442922, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03695.html", "problem_id": "p03695", "resource_group": "medium_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/Kotlin/s535623922.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s535623922", "user_id": "u269969976"}, "prompt_components": {"gold_output": "2 2\n", "input_to_evaluate": "\nfun main(arr:Array) {\n val count = readLine()!!.toInt()\n val rates = readLine()!!.split(\" \").map { it.toInt() }\n val underRed = rates.filter { it < 3200 }.map { it / 400 }.distinct()\n val overRed = rates.count { it >= 3200 }\n val min = underRed.size\n val max = Math.min(underRed.size + overRed, 8)\n println(\"%d %d\".format(min,max))\n}", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 239, "memory_kb": 35984}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s381564295", "group_id": "codeNet:p03695", "input_text": "fun main(args: Array) {\n val n = readLine()!!.toInt()\n val l = readLine()!!.split(\" \").map { it.toInt() }\n var variable = 0\n var colors = mutableListOf(0, 0, 0, 0, 0, 0, 0, 0)\n for (i in 0 until n){\n when(l[i]){\n in 1 .. 399 -> colors[0] = 1\n in 400 .. 799 -> colors[1] = 1\n in 800 .. 1199 -> colors[2] = 1\n in 1200 .. 1599 -> colors[3] = 1\n in 1600 .. 1999 -> colors[4] = 1\n in 2000 .. 2399 -> colors[5] = 1\n in 2400 .. 2799 -> colors[6] = 1\n in 2800 .. 3199 -> colors[7] = 1\n else -> variable += 1\n }\n }\n if (colors.sum() == 0){\n println(\"1 \" + Math.min(variable, 8))\n }\n else {\n println(colors.sum().toString() + \" \" + Math.min((colors.sum() + variable), 8))\n }\n}", "language": "Kotlin", "metadata": {"date": 1557369190, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03695.html", "problem_id": "p03695", "resource_group": "medium_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/Kotlin/s381564295.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s381564295", "user_id": "u227189389"}, "prompt_components": {"gold_output": "2 2\n", "input_to_evaluate": "fun main(args: Array) {\n val n = readLine()!!.toInt()\n val l = readLine()!!.split(\" \").map { it.toInt() }\n var variable = 0\n var colors = mutableListOf(0, 0, 0, 0, 0, 0, 0, 0)\n for (i in 0 until n){\n when(l[i]){\n in 1 .. 399 -> colors[0] = 1\n in 400 .. 799 -> colors[1] = 1\n in 800 .. 1199 -> colors[2] = 1\n in 1200 .. 1599 -> colors[3] = 1\n in 1600 .. 1999 -> colors[4] = 1\n in 2000 .. 2399 -> colors[5] = 1\n in 2400 .. 2799 -> colors[6] = 1\n in 2800 .. 3199 -> colors[7] = 1\n else -> variable += 1\n }\n }\n if (colors.sum() == 0){\n println(\"1 \" + Math.min(variable, 8))\n }\n else {\n println(colors.sum().toString() + \" \" + Math.min((colors.sum() + variable), 8))\n }\n}", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 238, "memory_kb": 37876}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s073614196", "group_id": "codeNet:p03695", "input_text": "\nfun readInts(separator: Char = ' ') = readLine()!!.split(separator).map(String::toInt)\nfun readSplit(separator: Char = ' ') = readLine()!!.split(separator)\nfun main(args: Array) {\n val N=readInts()[0]\n var sum=0\n var a=Array(110,{i->false})\n var arr=readInts()\n for (i in 0..N-1){\n var temp=arr[i]\n if(temp<3200)\n a[temp/400]=true\n else sum++\n }\n print(\"${if(a.count{it}==0) 1 else a.count{it}} ${a.count{it}+sum}\")\n}\n\n", "language": "Kotlin", "metadata": {"date": 1502573216, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03695.html", "problem_id": "p03695", "resource_group": "medium_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/Kotlin/s073614196.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s073614196", "user_id": "u101225820"}, "prompt_components": {"gold_output": "2 2\n", "input_to_evaluate": "\nfun readInts(separator: Char = ' ') = readLine()!!.split(separator).map(String::toInt)\nfun readSplit(separator: Char = ' ') = readLine()!!.split(separator)\nfun main(args: Array) {\n val N=readInts()[0]\n var sum=0\n var a=Array(110,{i->false})\n var arr=readInts()\n for (i in 0..N-1){\n var temp=arr[i]\n if(temp<3200)\n a[temp/400]=true\n else sum++\n }\n print(\"${if(a.count{it}==0) 1 else a.count{it}} ${a.count{it}+sum}\")\n}\n\n", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 241, "memory_kb": 38244}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s748113734", "group_id": "codeNet:p03695", "input_text": "fun main(args: Array) {\n val N = readLine()!!.toInt()\n val a = readLine()!!.split(' ').map(String::toInt)\n\n var any = 0\n var col = 0\n val exist = Array(8, {i -> false})\n for (ai in a) {\n when(ai) {\n in 1..3199 -> {\n val idx = ai / 400\n if (exist[idx] == false) {\n exist[idx] = true\n col++\n }\n }\n else -> any++\n }\n }\n val min = Math.max(1, col)\n val max = Math.min(8, col + any)\n println(\"$min $max\")\n}", "language": "Kotlin", "metadata": {"date": 1497249786, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03695.html", "problem_id": "p03695", "resource_group": "medium_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/Kotlin/s748113734.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s748113734", "user_id": "u057916330"}, "prompt_components": {"gold_output": "2 2\n", "input_to_evaluate": "fun main(args: Array) {\n val N = readLine()!!.toInt()\n val a = readLine()!!.split(' ').map(String::toInt)\n\n var any = 0\n var col = 0\n val exist = Array(8, {i -> false})\n for (ai in a) {\n when(ai) {\n in 1..3199 -> {\n val idx = ai / 400\n if (exist[idx] == false) {\n exist[idx] = true\n col++\n }\n }\n else -> any++\n }\n }\n val min = Math.max(1, col)\n val max = Math.min(8, col + any)\n println(\"$min $max\")\n}", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 569, "cpu_time_ms": 234, "memory_kb": 38288}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s471882411", "group_id": "codeNet:p03695", "input_text": "enum class Rate {\n GRAY,BROWN,GREEN,SKY,BLUE,YELLOW,ORANGE,RED,ANY\n}\nobject MainKt {\n @JvmStatic fun main(args:Array) {\n val N=readLine()!!.toInt()\n\n val rates=readLine()!!.split(\" \").map(String::toInt).map{\n when(it) {\n in 1..399 ->Rate.GRAY\n in 400..799 -> Rate.BROWN\n in 800..1199 -> Rate.GREEN\n in 1200..1599 -> Rate.SKY\n in 1600..1999 -> Rate.BLUE\n in 2000..2399 -> Rate.YELLOW\n in 2400..2799 -> Rate.ORANGE\n in 2800..3199 -> Rate.RED\n else-> Rate.ANY\n }\n }\n val colors=rates.filter{it!=Rate.ANY}\n val anies=rates.filter{it==Rate.ANY}\n var kinds_min=colors.toSet().size\n val kinds_max=kinds_min+arrayOf(8,anies.size).min()!!\n kinds_min+=arrayOf(0,anies.size-kinds_min).max()!!\n kinds_min=if(kinds_min==0) {1} else {kinds_min}\n \n println(\"${kinds_min} ${kinds_max}\")\n }\n}\n", "language": "Kotlin", "metadata": {"date": 1497146510, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03695.html", "problem_id": "p03695", "resource_group": "medium_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/Kotlin/s471882411.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s471882411", "user_id": "u181807786"}, "prompt_components": {"gold_output": "2 2\n", "input_to_evaluate": "enum class Rate {\n GRAY,BROWN,GREEN,SKY,BLUE,YELLOW,ORANGE,RED,ANY\n}\nobject MainKt {\n @JvmStatic fun main(args:Array) {\n val N=readLine()!!.toInt()\n\n val rates=readLine()!!.split(\" \").map(String::toInt).map{\n when(it) {\n in 1..399 ->Rate.GRAY\n in 400..799 -> Rate.BROWN\n in 800..1199 -> Rate.GREEN\n in 1200..1599 -> Rate.SKY\n in 1600..1999 -> Rate.BLUE\n in 2000..2399 -> Rate.YELLOW\n in 2400..2799 -> Rate.ORANGE\n in 2800..3199 -> Rate.RED\n else-> Rate.ANY\n }\n }\n val colors=rates.filter{it!=Rate.ANY}\n val anies=rates.filter{it==Rate.ANY}\n var kinds_min=colors.toSet().size\n val kinds_max=kinds_min+arrayOf(8,anies.size).min()!!\n kinds_min+=arrayOf(0,anies.size-kinds_min).max()!!\n kinds_min=if(kinds_min==0) {1} else {kinds_min}\n \n println(\"${kinds_min} ${kinds_max}\")\n }\n}\n", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 870, "cpu_time_ms": 244, "memory_kb": 35976}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s459468046", "group_id": "codeNet:p03695", "input_text": "import java.io.*\nimport java.util.InputMismatchException\nimport java.io.IOException\nimport kotlin.system.measureTimeMillis\nvar out = PrintWriter(System.out)\n/*---------------------------------------------------------------------------------------------------\n            ∧_∧\n      ∧_∧  (´<_` )  Welcome to My Coding Space!\n     ( ´_ゝ`) /  ⌒i\n    /   \    | |\n    /   / ̄ ̄ ̄ ̄/  |\n  __(__ニつ/  _/ .| .|____\n     \/____/ (u ⊃\n---------------------------------------------------------------------------------------------------*/\n\nvar line = intArrayOf(1, 400, 800, 1200, 1600, 2000, 2400, 2800, 5050)\nfun solve() {\n var N = ni()\n var A = na(N)\n A.sort()\n\n var color:MutableSet = mutableSetOf()\n var non = 0\n for(a in A) {\n if(3200 <= a) {\n non++\n continue\n }\n\n for(j in 0..7) {\n if(a in line[j] until line[j + 1]) color.add(j)\n }\n }\n\n var max = color.size + non\n var min = Math.max(color.size, 1)\n out.println(\"$min $max\")\n}\n\n\n\n\n\n\n\n\n\n//---------------------------------------------------------------------------------------------------\nfun main(args: Array) {\n var time = measureTimeMillis {\n solve()\n out.flush()\n }\n //println(\"$time ms\")\n}\n//---------------------------------------------------------------------------------------------------\nprivate var inbuf = ByteArray(1024)\nprivate var lenbuf = 0\nvar ptrbuf = 0\n\nvar `is` = System.`in`\n\nfun readByte(): Byte {\n if (lenbuf === -1) throw InputMismatchException()\n if (ptrbuf >= lenbuf) {\n ptrbuf = 0\n try {\n lenbuf = `is`.read(inbuf)\n } catch (e: IOException) {\n throw InputMismatchException()\n }\n\n if (lenbuf <= 0) return -1\n }\n return inbuf[ptrbuf++]\n}\n\n\nprivate fun isSpaceChar(c: Byte): Boolean {\n return !(c >= 33 && c <= 126)\n}\n\nprivate fun skip(): Byte {\n var b: Byte\n while (true) {\n b = readByte()\n if(b < 0 && isSpaceChar(b)) break\n }\n return b\n}\n\nprivate fun ns(): String {\n var b = skip()\n val sb = StringBuilder()\n while (!isSpaceChar(b)) {\n sb.appendCodePoint(b.toInt())\n b = readByte()\n }\n return sb.toString()\n}\n\nfun na(n: Int) = IntArray(n, {ni()})\n\nfun ni(): Int {\n var num = 0\n var b: Byte\n var minus = false\n while (true) {\n b = readByte()\n if(b < 0) break\n if(b >= '0'.toByte() && b <= '9'.toByte() || b == '-'.toByte()) break\n\n if (b == '-'.toByte()) {\n minus = true\n b = readByte()\n }\n }\n\n while (true) {\n if (b >= '0'.toByte() && b <= '9'.toByte()) {\n num = num * 10 + (b - '0'.toByte())\n } else {\n return if (minus) -num else num\n }\n b = readByte()\n }\n}", "language": "Kotlin", "metadata": {"date": 1497143365, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03695.html", "problem_id": "p03695", "resource_group": "medium_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/Kotlin/s459468046.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s459468046", "user_id": "u141378465"}, "prompt_components": {"gold_output": "2 2\n", "input_to_evaluate": "import java.io.*\nimport java.util.InputMismatchException\nimport java.io.IOException\nimport kotlin.system.measureTimeMillis\nvar out = PrintWriter(System.out)\n/*---------------------------------------------------------------------------------------------------\n            ∧_∧\n      ∧_∧  (´<_` )  Welcome to My Coding Space!\n     ( ´_ゝ`) /  ⌒i\n    /   \    | |\n    /   / ̄ ̄ ̄ ̄/  |\n  __(__ニつ/  _/ .| .|____\n     \/____/ (u ⊃\n---------------------------------------------------------------------------------------------------*/\n\nvar line = intArrayOf(1, 400, 800, 1200, 1600, 2000, 2400, 2800, 5050)\nfun solve() {\n var N = ni()\n var A = na(N)\n A.sort()\n\n var color:MutableSet = mutableSetOf()\n var non = 0\n for(a in A) {\n if(3200 <= a) {\n non++\n continue\n }\n\n for(j in 0..7) {\n if(a in line[j] until line[j + 1]) color.add(j)\n }\n }\n\n var max = color.size + non\n var min = Math.max(color.size, 1)\n out.println(\"$min $max\")\n}\n\n\n\n\n\n\n\n\n\n//---------------------------------------------------------------------------------------------------\nfun main(args: Array) {\n var time = measureTimeMillis {\n solve()\n out.flush()\n }\n //println(\"$time ms\")\n}\n//---------------------------------------------------------------------------------------------------\nprivate var inbuf = ByteArray(1024)\nprivate var lenbuf = 0\nvar ptrbuf = 0\n\nvar `is` = System.`in`\n\nfun readByte(): Byte {\n if (lenbuf === -1) throw InputMismatchException()\n if (ptrbuf >= lenbuf) {\n ptrbuf = 0\n try {\n lenbuf = `is`.read(inbuf)\n } catch (e: IOException) {\n throw InputMismatchException()\n }\n\n if (lenbuf <= 0) return -1\n }\n return inbuf[ptrbuf++]\n}\n\n\nprivate fun isSpaceChar(c: Byte): Boolean {\n return !(c >= 33 && c <= 126)\n}\n\nprivate fun skip(): Byte {\n var b: Byte\n while (true) {\n b = readByte()\n if(b < 0 && isSpaceChar(b)) break\n }\n return b\n}\n\nprivate fun ns(): String {\n var b = skip()\n val sb = StringBuilder()\n while (!isSpaceChar(b)) {\n sb.appendCodePoint(b.toInt())\n b = readByte()\n }\n return sb.toString()\n}\n\nfun na(n: Int) = IntArray(n, {ni()})\n\nfun ni(): Int {\n var num = 0\n var b: Byte\n var minus = false\n while (true) {\n b = readByte()\n if(b < 0) break\n if(b >= '0'.toByte() && b <= '9'.toByte() || b == '-'.toByte()) break\n\n if (b == '-'.toByte()) {\n minus = true\n b = readByte()\n }\n }\n\n while (true) {\n if (b >= '0'.toByte() && b <= '9'.toByte()) {\n num = num * 10 + (b - '0'.toByte())\n } else {\n return if (minus) -num else num\n }\n b = readByte()\n }\n}", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2979, "cpu_time_ms": 183, "memory_kb": 31692}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s131560921", "group_id": "codeNet:p03696", "input_text": "\nobject MainKt {\n \n @JvmStatic fun main(args:Array) {\n val N=readLine()!!.toInt()\n val S=readLine()!!\n assert(S.length==N)\n var ins_front=\"\"\n \n var correspond=0\n \n for(i in S.indices) {\n if(S[i]=='(') {\n correspond+=1\n }\n else {\n if(correspond==0) {\n ins_front+=\"(\"\n }\n else{\n correspond-=1\n }\n }\n }\n val ins_back=if(correspond==0) {\"\"} else { (1..correspond).map{')'}.joinToString(\"\")}\n println(ins_front+S+ins_back)\n }\n}\n", "language": "Kotlin", "metadata": {"date": 1497150438, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03696.html", "problem_id": "p03696", "resource_group": "medium_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/Kotlin/s131560921.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s131560921", "user_id": "u181807786"}, "prompt_components": {"gold_output": "(())\n", "input_to_evaluate": "\nobject MainKt {\n \n @JvmStatic fun main(args:Array) {\n val N=readLine()!!.toInt()\n val S=readLine()!!\n assert(S.length==N)\n var ins_front=\"\"\n \n var correspond=0\n \n for(i in S.indices) {\n if(S[i]=='(') {\n correspond+=1\n }\n else {\n if(correspond==0) {\n ins_front+=\"(\"\n }\n else{\n correspond-=1\n }\n }\n }\n val ins_back=if(correspond==0) {\"\"} else { (1..correspond).map{')'}.joinToString(\"\")}\n println(ins_front+S+ins_back)\n }\n}\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 218, "memory_kb": 31864}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s447711212", "group_id": "codeNet:p03698", "input_text": "import java.io.PrintWriter\nval pw = PrintWriter(System.out)\n\nfun main(args : Array) {\n func()\n pw.flush()\n}\n\nfun func() {\n val s = next()\n val ss = mutableMapOf()\n\n for (i in 0 until s.length) {\n if (ss[s[i]] == null) {\n ss[s[i]] = s[i]\n } else {\n println(\"no\")\n return\n }\n }\n\n println(\"yes\")\n}\n\nfun next() = readLine()!!\n\nfun println(value : Any) {\n pw.println(value)\n}", "language": "Kotlin", "metadata": {"date": 1568702122, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03698.html", "problem_id": "p03698", "resource_group": "medium_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/Kotlin/s447711212.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s447711212", "user_id": "u262403099"}, "prompt_components": {"gold_output": "yes\n", "input_to_evaluate": "import java.io.PrintWriter\nval pw = PrintWriter(System.out)\n\nfun main(args : Array) {\n func()\n pw.flush()\n}\n\nfun func() {\n val s = next()\n val ss = mutableMapOf()\n\n for (i in 0 until s.length) {\n if (ss[s[i]] == null) {\n ss[s[i]] = s[i]\n } else {\n println(\"no\")\n return\n }\n }\n\n println(\"yes\")\n}\n\nfun next() = readLine()!!\n\nfun println(value : Any) {\n pw.println(value)\n}", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 468, "cpu_time_ms": 209, "memory_kb": 35828}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s701583506", "group_id": "codeNet:p03698", "input_text": "fun main(args: Array) {\n val s= readLine()!!\n val ans = if(s.length==s.toSet().size)\"yes\" else \"no\"\n println(ans)\n}", "language": "Kotlin", "metadata": {"date": 1542215176, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03698.html", "problem_id": "p03698", "resource_group": "medium_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/Kotlin/s701583506.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s701583506", "user_id": "u914096045"}, "prompt_components": {"gold_output": "yes\n", "input_to_evaluate": "fun main(args: Array) {\n val s= readLine()!!\n val ans = if(s.length==s.toSet().size)\"yes\" else \"no\"\n println(ans)\n}", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 217, "memory_kb": 31928}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s772156913", "group_id": "codeNet:p03698", "input_text": "import java.util.*\n\nobject MainKt {\n @JvmStatic fun main(args:Array) {\n val S=readLine()!!\n\n println(if(S.length==S.toSet().size) {\"yes\"} else {\"no\"}) \n }\n\n}", "language": "Kotlin", "metadata": {"date": 1496538353, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03698.html", "problem_id": "p03698", "resource_group": "medium_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/Kotlin/s772156913.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s772156913", "user_id": "u181807786"}, "prompt_components": {"gold_output": "yes\n", "input_to_evaluate": "import java.util.*\n\nobject MainKt {\n @JvmStatic fun main(args:Array) {\n val S=readLine()!!\n\n println(if(S.length==S.toSet().size) {\"yes\"} else {\"no\"}) \n }\n\n}", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 176, "cpu_time_ms": 318, "memory_kb": 33788}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s224766725", "group_id": "codeNet:p03699", "input_text": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val n = sc.nextInt()\n val s = (1..n).map { sc.nextInt() }\n\n if (s.all { it % 10 == 0 }) {\n println(0)\n return\n }\n\n val min = s.filter { it % 10 != 0 }.min() ?: 0\n\n var ans = s.sum()\n if (ans % 10 == 0) {\n ans -= min\n }\n\n println(ans)\n}\n", "language": "Kotlin", "metadata": {"date": 1594267003, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p03699.html", "problem_id": "p03699", "resource_group": "medium_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/Kotlin/s224766725.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s224766725", "user_id": "u323522006"}, "prompt_components": {"gold_output": "25\n", "input_to_evaluate": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val n = sc.nextInt()\n val s = (1..n).map { sc.nextInt() }\n\n if (s.all { it % 10 == 0 }) {\n println(0)\n return\n }\n\n val min = s.filter { it % 10 != 0 }.min() ?: 0\n\n var ans = s.sum()\n if (ans % 10 == 0) {\n ans -= min\n }\n\n println(ans)\n}\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 339, "cpu_time_ms": 142, "memory_kb": 37644}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s651515387", "group_id": "codeNet:p03700", "input_text": "import java.util.*\nimport java.io.PrintWriter\n\nval pw = PrintWriter(System.out)\nval MOD = 1000000007L\nval INF = 2147483647\nval LINF = 9223372036854775807L\n\nfun main(args: Array){\n solve()\n pw.flush() \n}\n\nfun solve(){\n val (n, a, b) = nextLongList()\n val h: Array = Array(n.toInt()){\n nextLong()\n }\n \n var ng = -1L\n var ok = 1000000000L\n while(Math.abs(ok - ng) > 1L){\n var mid = (ok + ng) / 2\n if(check(mid, h, a, b)){\n ok = mid\n } else {\n ng = mid\n }\n }\n\n println(ok)\n}\n\nfun check(k: Long, h: Array, a: Long, b: Long) : Boolean {\n var count = 0L\n for (i in h.indices) {\n if(h[i] <= b * k) continue\n var n = (Math.ceil((h[i] - b * k).toDouble() / (a - b))).toLong()\n count += n\n }\n if(count <= k) return true else return false\n}\n\n// Print\nfun println(v: String){\n pw.println(v)\n}\nfun print(v: String){\n pw.print(v)\n}\n\n// Read\nfun next() = readLine()!!\nfun nextInt() = next().toInt()\nfun nextLong() = next().toLong()\nfun nextDouble() = next().toDouble()\nfun nextList() = next().split(\" \")\nfun nextIntList() = next().split(\" \").map{ it.toInt() }\nfun nextLongList() = next().split(\" \").map{ it.toLong() }\nfun nextDoubleList() = next().split(\" \").map{ it.toDouble() }\nfun nextAryln(n: Int) = Array(n){ next() }\nfun nextIntAryln(n: Int) = IntArray(n){ nextInt() }\nfun nextLongAryln(n: Int) = LongArray(n){ nextLong() }\nfun nextDoubleAryln(n: Int) = DoubleArray(n) { nextDouble() }\n\n// Math\nfun max(a: Long = -LINF, b: Long = -LINF, c: Long = -LINF, d: Long = -LINF, e: Long = -LINF): Long = listOf(a, b, c, d, e).max()!!.toLong()\nfun min(a: Long = LINF, b: Long = LINF, c: Long = LINF, d: Long = LINF, e: Long = LINF): Long = listOf(a, b, c, d, e).min()!!.toLong()\nfun prime(from: Long, to: Long = from) : List{\n return (from..to).filter{ i ->\n val max = Math.sqrt(i.toDouble()).toLong()\n (2..max).all{ j -> i % j != 0L}\n }\n}\nfun gcd(a: Long, b: Long) : Long = if(a % b == 0L) b else gcd(b, (a % b))\nfun lcm(a: Long, b: Long) : Long = a / gcd(a, b) * b\nfun modpow(a: Long, n: Long, p:Long = MOD) : Long {\n var res = 1L\n var ar = a\n var nr = n\n while(nr > 0){\n if((nr and 1) == 1L) res = res * ar % p\n ar = ar * ar % p\n nr = nr shr 1\n }\n return res\n}\nfun modinv(a: Long, p: Long = MOD) : Long = modpow(a, p - 2, p)\nfun ncr(n: Long, r: Long) : Long {\n var a = 1L\n var b = 1L\n for (i in 1..r) {\n a = a * (n + 1 - i) % MOD\n b = b * i % MOD\n }\n return modinv(b, MOD) * a % MOD\n}\n\n// Algorithm\nfun dfs(nodes: Array, now: Int, seen: Array){\n seen[now] = true\n for (edge in nodes[now].edges) {\n if(seen[edge.to]) continue\n dfs(nodes, edge.to, seen)\n }\n}\nfun bfs(nodes: Array, start: Int) : Array {\n val queue = ArrayDeque()\n queue.add(start)\n val dist: Array = Array(nodes.size) { -1L }\n dist[start] = 0\n while(queue.isNotEmpty()){\n val now = queue.poll()\n for (edge in nodes[now].edges) {\n if(dist[edge.to] != -1L) continue\n dist[edge.to] = dist[now] + 1\n queue.add(edge.to)\n }\n }\n return dist\n}\nfun dijkstra(nodes: Array, start: Int) : Array {\n val queue = PriorityQueue(16) { e1: Edge, e2: Edge ->\n if(e1.cost < e2.cost){\n return@PriorityQueue -1\n } else if (e2.cost > e1.cost) {\n return@PriorityQueue 1\n } else {\n return@PriorityQueue 0\n }\n }\n queue.add(Edge(start, start, 0))\n val dist: Array = Array(nodes.size) { LINF / 2 }\n dist[start] = 0\n while(queue.isNotEmpty()){\n val now = queue.poll()\n if(dist[now.to] < now.cost) continue;\n for (edge in nodes[now.to].edges) {\n if(dist[edge.to] <= dist[edge.from] + edge.cost) continue\n dist[edge.to] = dist[edge.from] + edge.cost\n queue.add(Edge(edge.from, edge.to, dist[edge.to]))\n nodes[edge.to].past = edge.from\n }\n }\n return dist\n}\n\n\n// Class\ndata class Node(val id: Int, var past: Int = -1, var edges: MutableList = mutableListOf())\ndata class Edge(val from: Int, val to: Int, val cost: Long = 1L)\nclass UnionFind(size: Int){\n val par = IntArray(size) { i -> i }\n val size = IntArray(size) { 1 }\n fun root(x: Int) : Int {\n if(par[x] == x){\n return x\n } else {\n par[x] = root(par[x])\n return par[x]\n }\n }\n fun same(x: Int, y: Int) : Boolean = root(x) == root(y)\n fun unite(x: Int, y: Int){\n var a = root(x)\n var b = root(y)\n if(a == b) return\n if(size[a] < size[b]){\n var tmp = a\n a = b\n b = tmp\n }\n size[a] += size[b]\n par[b] = a\n }\n fun size(x: Int) : Int = size[root(x)]\n}\nclass Permutation(val n: Int, var searched: Int = 0, var nextIndex: Int = 0){\n val size = fact(n)\n val permList = Array(size) { IntArray(n){ 0 } }\n\n fun fact(n: Int) : Int = if(n == 0) 1 else n * fact(n - 1)\n fun init(){\n create(0, IntArray(n) { 0 }, Array(n){ false })\n }\n fun create(num: Int, list: IntArray, flag: Array){\n if(num == n){\n permList[searched] = list.copyOf()\n searched++\n }\n for (i in 0 until n) {\n if(flag[i]) continue\n list[num] = i\n flag[i] = true\n create(num + 1, list, flag)\n flag[i] = false\n }\n }\n fun hasNext() : Boolean {\n if(nextIndex < size){\n return true\n } else {\n nextIndex = 0\n return false\n }\n }\n fun nextPerm() : IntArray = permList[nextIndex++]\n}\nclass Combination(val max: Int){\n val fac = LongArray(max)\n val finv = LongArray(max)\n val inv = LongArray(max)\n val p = MOD.toInt()\n fun init(){\n fac[0] = 1\n fac[1] = 1\n finv[0] = 1\n finv[1] = 1\n inv[1] = 1\n for (i in 2 until max) {\n fac[i] = fac[i - 1] * i % p\n inv[i] = p - inv[p % i] * (p / i) % p;\n finv[i] = finv[i - 1] * inv[i] % p\n }\n }\n fun com(n: Int, r: Int) : Long = if(n < r || (n < 0 || r < 0)) 0 else fac[n] * (finv[r] * finv[n - r] % p) % p\n}", "language": "Kotlin", "metadata": {"date": 1584733400, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03700.html", "problem_id": "p03700", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03700/input.txt", "sample_output_relpath": "derived/input_output/data/p03700/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03700/Kotlin/s651515387.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s651515387", "user_id": "u581625805"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import java.util.*\nimport java.io.PrintWriter\n\nval pw = PrintWriter(System.out)\nval MOD = 1000000007L\nval INF = 2147483647\nval LINF = 9223372036854775807L\n\nfun main(args: Array){\n solve()\n pw.flush() \n}\n\nfun solve(){\n val (n, a, b) = nextLongList()\n val h: Array = Array(n.toInt()){\n nextLong()\n }\n \n var ng = -1L\n var ok = 1000000000L\n while(Math.abs(ok - ng) > 1L){\n var mid = (ok + ng) / 2\n if(check(mid, h, a, b)){\n ok = mid\n } else {\n ng = mid\n }\n }\n\n println(ok)\n}\n\nfun check(k: Long, h: Array, a: Long, b: Long) : Boolean {\n var count = 0L\n for (i in h.indices) {\n if(h[i] <= b * k) continue\n var n = (Math.ceil((h[i] - b * k).toDouble() / (a - b))).toLong()\n count += n\n }\n if(count <= k) return true else return false\n}\n\n// Print\nfun println(v: String){\n pw.println(v)\n}\nfun print(v: String){\n pw.print(v)\n}\n\n// Read\nfun next() = readLine()!!\nfun nextInt() = next().toInt()\nfun nextLong() = next().toLong()\nfun nextDouble() = next().toDouble()\nfun nextList() = next().split(\" \")\nfun nextIntList() = next().split(\" \").map{ it.toInt() }\nfun nextLongList() = next().split(\" \").map{ it.toLong() }\nfun nextDoubleList() = next().split(\" \").map{ it.toDouble() }\nfun nextAryln(n: Int) = Array(n){ next() }\nfun nextIntAryln(n: Int) = IntArray(n){ nextInt() }\nfun nextLongAryln(n: Int) = LongArray(n){ nextLong() }\nfun nextDoubleAryln(n: Int) = DoubleArray(n) { nextDouble() }\n\n// Math\nfun max(a: Long = -LINF, b: Long = -LINF, c: Long = -LINF, d: Long = -LINF, e: Long = -LINF): Long = listOf(a, b, c, d, e).max()!!.toLong()\nfun min(a: Long = LINF, b: Long = LINF, c: Long = LINF, d: Long = LINF, e: Long = LINF): Long = listOf(a, b, c, d, e).min()!!.toLong()\nfun prime(from: Long, to: Long = from) : List{\n return (from..to).filter{ i ->\n val max = Math.sqrt(i.toDouble()).toLong()\n (2..max).all{ j -> i % j != 0L}\n }\n}\nfun gcd(a: Long, b: Long) : Long = if(a % b == 0L) b else gcd(b, (a % b))\nfun lcm(a: Long, b: Long) : Long = a / gcd(a, b) * b\nfun modpow(a: Long, n: Long, p:Long = MOD) : Long {\n var res = 1L\n var ar = a\n var nr = n\n while(nr > 0){\n if((nr and 1) == 1L) res = res * ar % p\n ar = ar * ar % p\n nr = nr shr 1\n }\n return res\n}\nfun modinv(a: Long, p: Long = MOD) : Long = modpow(a, p - 2, p)\nfun ncr(n: Long, r: Long) : Long {\n var a = 1L\n var b = 1L\n for (i in 1..r) {\n a = a * (n + 1 - i) % MOD\n b = b * i % MOD\n }\n return modinv(b, MOD) * a % MOD\n}\n\n// Algorithm\nfun dfs(nodes: Array, now: Int, seen: Array){\n seen[now] = true\n for (edge in nodes[now].edges) {\n if(seen[edge.to]) continue\n dfs(nodes, edge.to, seen)\n }\n}\nfun bfs(nodes: Array, start: Int) : Array {\n val queue = ArrayDeque()\n queue.add(start)\n val dist: Array = Array(nodes.size) { -1L }\n dist[start] = 0\n while(queue.isNotEmpty()){\n val now = queue.poll()\n for (edge in nodes[now].edges) {\n if(dist[edge.to] != -1L) continue\n dist[edge.to] = dist[now] + 1\n queue.add(edge.to)\n }\n }\n return dist\n}\nfun dijkstra(nodes: Array, start: Int) : Array {\n val queue = PriorityQueue(16) { e1: Edge, e2: Edge ->\n if(e1.cost < e2.cost){\n return@PriorityQueue -1\n } else if (e2.cost > e1.cost) {\n return@PriorityQueue 1\n } else {\n return@PriorityQueue 0\n }\n }\n queue.add(Edge(start, start, 0))\n val dist: Array = Array(nodes.size) { LINF / 2 }\n dist[start] = 0\n while(queue.isNotEmpty()){\n val now = queue.poll()\n if(dist[now.to] < now.cost) continue;\n for (edge in nodes[now.to].edges) {\n if(dist[edge.to] <= dist[edge.from] + edge.cost) continue\n dist[edge.to] = dist[edge.from] + edge.cost\n queue.add(Edge(edge.from, edge.to, dist[edge.to]))\n nodes[edge.to].past = edge.from\n }\n }\n return dist\n}\n\n\n// Class\ndata class Node(val id: Int, var past: Int = -1, var edges: MutableList = mutableListOf())\ndata class Edge(val from: Int, val to: Int, val cost: Long = 1L)\nclass UnionFind(size: Int){\n val par = IntArray(size) { i -> i }\n val size = IntArray(size) { 1 }\n fun root(x: Int) : Int {\n if(par[x] == x){\n return x\n } else {\n par[x] = root(par[x])\n return par[x]\n }\n }\n fun same(x: Int, y: Int) : Boolean = root(x) == root(y)\n fun unite(x: Int, y: Int){\n var a = root(x)\n var b = root(y)\n if(a == b) return\n if(size[a] < size[b]){\n var tmp = a\n a = b\n b = tmp\n }\n size[a] += size[b]\n par[b] = a\n }\n fun size(x: Int) : Int = size[root(x)]\n}\nclass Permutation(val n: Int, var searched: Int = 0, var nextIndex: Int = 0){\n val size = fact(n)\n val permList = Array(size) { IntArray(n){ 0 } }\n\n fun fact(n: Int) : Int = if(n == 0) 1 else n * fact(n - 1)\n fun init(){\n create(0, IntArray(n) { 0 }, Array(n){ false })\n }\n fun create(num: Int, list: IntArray, flag: Array){\n if(num == n){\n permList[searched] = list.copyOf()\n searched++\n }\n for (i in 0 until n) {\n if(flag[i]) continue\n list[num] = i\n flag[i] = true\n create(num + 1, list, flag)\n flag[i] = false\n }\n }\n fun hasNext() : Boolean {\n if(nextIndex < size){\n return true\n } else {\n nextIndex = 0\n return false\n }\n }\n fun nextPerm() : IntArray = permList[nextIndex++]\n}\nclass Combination(val max: Int){\n val fac = LongArray(max)\n val finv = LongArray(max)\n val inv = LongArray(max)\n val p = MOD.toInt()\n fun init(){\n fac[0] = 1\n fac[1] = 1\n finv[0] = 1\n finv[1] = 1\n inv[1] = 1\n for (i in 2 until max) {\n fac[i] = fac[i - 1] * i % p\n inv[i] = p - inv[p % i] * (p / i) % p;\n finv[i] = finv[i - 1] * inv[i] % p\n }\n }\n fun com(n: Int, r: Int) : Long = if(n < r || (n < 0 || r < 0)) 0 else fac[n] * (finv[r] * finv[n - r] % p) % p\n}", "problem_context": "Score : 400 points\n\nProblem Statement\n\nYou are going out for a walk, when you suddenly encounter N monsters. Each monster has a parameter called health, and the health of the i-th monster is h_i at the moment of encounter. A monster will vanish immediately when its health drops to 0 or below.\n\nFortunately, you are a skilled magician, capable of causing explosions that damage monsters. In one explosion, you can damage monsters as follows:\n\nSelect an alive monster, and cause an explosion centered at that monster. The health of the monster at the center of the explosion will decrease by A, and the health of each of the other monsters will decrease by B. Here, A and B are predetermined parameters, and A > B holds.\n\nAt least how many explosions do you need to cause in order to vanish all the monsters?\n\nConstraints\n\nAll input values are integers.\n\n1 ≤ N ≤ 10^5\n\n1 ≤ B < A ≤ 10^9\n\n1 ≤ h_i ≤ 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN A B\nh_1\nh_2\n:\nh_N\n\nOutput\n\nPrint the minimum number of explosions that needs to be caused in order to vanish all the monsters.\n\nSample Input 1\n\n4 5 3\n8\n7\n4\n2\n\nSample Output 1\n\n2\n\nYou can vanish all the monsters in two explosion, as follows:\n\nFirst, cause an explosion centered at the monster with 8 health. The healths of the four monsters become 3, 4, 1 and -1, respectively, and the last monster vanishes.\n\nSecond, cause an explosion centered at the monster with 4 health remaining. The healths of the three remaining monsters become 0, -1 and -2, respectively, and all the monsters are now vanished.\n\nSample Input 2\n\n2 10 4\n20\n20\n\nSample Output 2\n\n4\n\nYou need to cause two explosions centered at each monster, for a total of four.\n\nSample Input 3\n\n5 2 1\n900000000\n900000000\n1000000000\n1000000000\n1000000000\n\nSample Output 3\n\n800000000", "sample_input": "4 5 3\n8\n7\n4\n2\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03700", "source_text": "Score : 400 points\n\nProblem Statement\n\nYou are going out for a walk, when you suddenly encounter N monsters. Each monster has a parameter called health, and the health of the i-th monster is h_i at the moment of encounter. A monster will vanish immediately when its health drops to 0 or below.\n\nFortunately, you are a skilled magician, capable of causing explosions that damage monsters. In one explosion, you can damage monsters as follows:\n\nSelect an alive monster, and cause an explosion centered at that monster. The health of the monster at the center of the explosion will decrease by A, and the health of each of the other monsters will decrease by B. Here, A and B are predetermined parameters, and A > B holds.\n\nAt least how many explosions do you need to cause in order to vanish all the monsters?\n\nConstraints\n\nAll input values are integers.\n\n1 ≤ N ≤ 10^5\n\n1 ≤ B < A ≤ 10^9\n\n1 ≤ h_i ≤ 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN A B\nh_1\nh_2\n:\nh_N\n\nOutput\n\nPrint the minimum number of explosions that needs to be caused in order to vanish all the monsters.\n\nSample Input 1\n\n4 5 3\n8\n7\n4\n2\n\nSample Output 1\n\n2\n\nYou can vanish all the monsters in two explosion, as follows:\n\nFirst, cause an explosion centered at the monster with 8 health. The healths of the four monsters become 3, 4, 1 and -1, respectively, and the last monster vanishes.\n\nSecond, cause an explosion centered at the monster with 4 health remaining. The healths of the three remaining monsters become 0, -1 and -2, respectively, and all the monsters are now vanished.\n\nSample Input 2\n\n2 10 4\n20\n20\n\nSample Output 2\n\n4\n\nYou need to cause two explosions centered at each monster, for a total of four.\n\nSample Input 3\n\n5 2 1\n900000000\n900000000\n1000000000\n1000000000\n1000000000\n\nSample Output 3\n\n800000000", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 6407, "cpu_time_ms": 373, "memory_kb": 39288}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s907205943", "group_id": "codeNet:p03713", "input_text": "import java.math.*\n\nfun main(args: Array) {\n val (H, W) = readInputLine().split(\" \").map { it.toLong() }\n \n // HまたはWが3の倍数の場合は縦方向または横方向に切るだけで等分可能\n if (H % 3L == 0L || W % 3L == 0L) {\n println(0)\n return\n }\n\n // それ以外の場合はどこか1点を指定して3分割\n var ans = Long.MAX_VALUE\n \n // 縦方向に分割した後、残りを横方向に分割\n for(w in LongRange(W / 3L, W / 3L + if (W % 3L != 0L) 1L else 0L)) {\n val S1 = H * w\n val S2 = (H / 2L) * (W - w)\n val S3 = (H / 2L + if (H % 2L != 0L) 1L else 0L) * (W - w)\n val max = Math.max(S1, Math.max(S2, S3))\n val min = Math.min(S1, Math.min(S2, S3))\n ans = Math.min(ans, max - min)\n }\n\n // 横方向に分割した後、残りを縦方向に分割\n for(h in LongRange(H / 3L, H / 3L + if (H % 3L != 0L) 1L else 0L)) {\n val S1 = h * W\n val S2 = (H - h) * (W / 2L)\n val S3 = (H - h) * (W / 2L + if (W % 2L != 0L) 1L else 0L)\n val max = Math.max(S1, Math.max(S2, S3))\n val min = Math.min(S1, Math.min(S2, S3))\n ans = Math.min(ans, max - min)\n }\n\n println(ans)\n}\n\nfun readInputLine(): String {\n return readLine()!!\n}\n", "language": "Kotlin", "metadata": {"date": 1567258361, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03713.html", "problem_id": "p03713", "resource_group": "medium_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/Kotlin/s907205943.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s907205943", "user_id": "u505558493"}, "prompt_components": {"gold_output": "0\n", "input_to_evaluate": "import java.math.*\n\nfun main(args: Array) {\n val (H, W) = readInputLine().split(\" \").map { it.toLong() }\n \n // HまたはWが3の倍数の場合は縦方向または横方向に切るだけで等分可能\n if (H % 3L == 0L || W % 3L == 0L) {\n println(0)\n return\n }\n\n // それ以外の場合はどこか1点を指定して3分割\n var ans = Long.MAX_VALUE\n \n // 縦方向に分割した後、残りを横方向に分割\n for(w in LongRange(W / 3L, W / 3L + if (W % 3L != 0L) 1L else 0L)) {\n val S1 = H * w\n val S2 = (H / 2L) * (W - w)\n val S3 = (H / 2L + if (H % 2L != 0L) 1L else 0L) * (W - w)\n val max = Math.max(S1, Math.max(S2, S3))\n val min = Math.min(S1, Math.min(S2, S3))\n ans = Math.min(ans, max - min)\n }\n\n // 横方向に分割した後、残りを縦方向に分割\n for(h in LongRange(H / 3L, H / 3L + if (H % 3L != 0L) 1L else 0L)) {\n val S1 = h * W\n val S2 = (H - h) * (W / 2L)\n val S3 = (H - h) * (W / 2L + if (W % 2L != 0L) 1L else 0L)\n val max = Math.max(S1, Math.max(S2, S3))\n val min = Math.min(S1, Math.min(S2, S3))\n ans = Math.min(ans, max - min)\n }\n\n println(ans)\n}\n\nfun readInputLine(): String {\n return readLine()!!\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 242, "memory_kb": 37824}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s919709581", "group_id": "codeNet:p03717", "input_text": "import java.io.BufferedReader\nimport java.io.InputStreamReader\n\nconst val MOD = 1000000009L\n\nfun main(omkar: Array) {\n val jin = BufferedReader(InputStreamReader(System.`in`))\n val line = jin.readLine().split(\" \")\n val n = line[0].toInt()\n val m = line[1].toInt()\n val earliest = Array(4) { IntArray(n + 1) { Int.MAX_VALUE } }\n val latest = Array(4) { IntArray(n + 1) }\n for (j in 1..m) {\n val line = jin.readLine().split(\" \")\n val l = line[0].toInt()\n val r = line[1].toInt()\n val x = line[2].toInt()\n earliest[x][r] = Math.min(earliest[x][r], l)\n latest[x][r] = Math.max(latest[x][r], l)\n }\n val dp = Array(n + 1) { Array(n + 1) { LongArray(n + 1) } }\n dp[0][0][0] = 1L\n for (j1 in 0 until n) {\n for (j2 in 0 until n) {\n for (j3 in 0 until n) {\n if (earliest[1][j1] > j2 && latest[2][j1] <= j2 && earliest[2][j1] > j3 && latest[3][j1] <= j3) {\n // same as j1\n dp[j1 + 1][j2][j3] += dp[j1][j2][j3]\n dp[j1 + 1][j2][j3] %= MOD\n // same as j2\n dp[j1 + 1][j1][j3] += dp[j1][j2][j3]\n dp[j1 + 1][j1][j3] %= MOD\n // same as j3\n dp[j1 + 1][j1][j2] += dp[j1][j2][j3]\n dp[j1 + 1][j1][j2] %= MOD\n }\n }\n }\n }\n var answer = 0L\n for (j2 in 0 until n) {\n for (j3 in 0 until n) {\n if (earliest[1][n] > j2 && latest[2][n] <= j2 && earliest[2][n] > j3 && latest[3][n] <= j3) {\n answer += dp[n][j2][j3]\n answer %= MOD\n }\n }\n }\n println(answer)\n}\n", "language": "Kotlin", "metadata": {"date": 1588760645, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03717.html", "problem_id": "p03717", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03717/input.txt", "sample_output_relpath": "derived/input_output/data/p03717/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03717/Kotlin/s919709581.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Memory Limit Exceeded", "submission_id": "s919709581", "user_id": "u590243733"}, "prompt_components": {"gold_output": "6\n", "input_to_evaluate": "import java.io.BufferedReader\nimport java.io.InputStreamReader\n\nconst val MOD = 1000000009L\n\nfun main(omkar: Array) {\n val jin = BufferedReader(InputStreamReader(System.`in`))\n val line = jin.readLine().split(\" \")\n val n = line[0].toInt()\n val m = line[1].toInt()\n val earliest = Array(4) { IntArray(n + 1) { Int.MAX_VALUE } }\n val latest = Array(4) { IntArray(n + 1) }\n for (j in 1..m) {\n val line = jin.readLine().split(\" \")\n val l = line[0].toInt()\n val r = line[1].toInt()\n val x = line[2].toInt()\n earliest[x][r] = Math.min(earliest[x][r], l)\n latest[x][r] = Math.max(latest[x][r], l)\n }\n val dp = Array(n + 1) { Array(n + 1) { LongArray(n + 1) } }\n dp[0][0][0] = 1L\n for (j1 in 0 until n) {\n for (j2 in 0 until n) {\n for (j3 in 0 until n) {\n if (earliest[1][j1] > j2 && latest[2][j1] <= j2 && earliest[2][j1] > j3 && latest[3][j1] <= j3) {\n // same as j1\n dp[j1 + 1][j2][j3] += dp[j1][j2][j3]\n dp[j1 + 1][j2][j3] %= MOD\n // same as j2\n dp[j1 + 1][j1][j3] += dp[j1][j2][j3]\n dp[j1 + 1][j1][j3] %= MOD\n // same as j3\n dp[j1 + 1][j1][j2] += dp[j1][j2][j3]\n dp[j1 + 1][j1][j2] %= MOD\n }\n }\n }\n }\n var answer = 0L\n for (j2 in 0 until n) {\n for (j3 in 0 until n) {\n if (earliest[1][n] > j2 && latest[2][n] <= j2 && earliest[2][n] > j3 && latest[3][n] <= j3) {\n answer += dp[n][j2][j3]\n answer %= MOD\n }\n }\n }\n println(answer)\n}\n", "problem_context": "Score : 800 points\n\nProblem Statement\n\nThere are N squares arranged in a row.\nThe squares are numbered 1, 2, ..., N, from left to right.\n\nSnuke is painting each square in red, green or blue.\nAccording to his aesthetic sense, the following M conditions must all be satisfied.\nThe i-th condition is:\n\nThere are exactly x_i different colors among squares l_i, l_i + 1, ..., r_i.\n\nIn how many ways can the squares be painted to satisfy all the conditions?\nFind the count modulo 10^9+7.\n\nConstraints\n\n1 ≤ N ≤ 300\n\n1 ≤ M ≤ 300\n\n1 ≤ l_i ≤ r_i ≤ N\n\n1 ≤ x_i ≤ 3\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nl_1 r_1 x_1\nl_2 r_2 x_2\n:\nl_M r_M x_M\n\nOutput\n\nPrint the number of ways to paint the squares to satisfy all the conditions, modulo 10^9+7.\n\nSample Input 1\n\n3 1\n1 3 3\n\nSample Output 1\n\n6\n\nThe six ways are:\n\nRGB\n\nRBG\n\nGRB\n\nGBR\n\nBRG\n\nBGR\n\nwhere R, G and B correspond to red, green and blue squares, respectively.\n\nSample Input 2\n\n4 2\n1 3 1\n2 4 2\n\nSample Output 2\n\n6\n\nThe six ways are:\n\nRRRG\n\nRRRB\n\nGGGR\n\nGGGB\n\nBBBR\n\nBBBG\n\nSample Input 3\n\n1 3\n1 1 1\n1 1 2\n1 1 3\n\nSample Output 3\n\n0\n\nThere are zero ways.\n\nSample Input 4\n\n8 10\n2 6 2\n5 5 1\n3 5 2\n4 7 3\n4 4 1\n2 3 1\n7 7 1\n1 5 2\n1 7 3\n3 4 2\n\nSample Output 4\n\n108", "sample_input": "3 1\n1 3 3\n"}, "reference_outputs": ["6\n"], "source_document_id": "p03717", "source_text": "Score : 800 points\n\nProblem Statement\n\nThere are N squares arranged in a row.\nThe squares are numbered 1, 2, ..., N, from left to right.\n\nSnuke is painting each square in red, green or blue.\nAccording to his aesthetic sense, the following M conditions must all be satisfied.\nThe i-th condition is:\n\nThere are exactly x_i different colors among squares l_i, l_i + 1, ..., r_i.\n\nIn how many ways can the squares be painted to satisfy all the conditions?\nFind the count modulo 10^9+7.\n\nConstraints\n\n1 ≤ N ≤ 300\n\n1 ≤ M ≤ 300\n\n1 ≤ l_i ≤ r_i ≤ N\n\n1 ≤ x_i ≤ 3\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nl_1 r_1 x_1\nl_2 r_2 x_2\n:\nl_M r_M x_M\n\nOutput\n\nPrint the number of ways to paint the squares to satisfy all the conditions, modulo 10^9+7.\n\nSample Input 1\n\n3 1\n1 3 3\n\nSample Output 1\n\n6\n\nThe six ways are:\n\nRGB\n\nRBG\n\nGRB\n\nGBR\n\nBRG\n\nBGR\n\nwhere R, G and B correspond to red, green and blue squares, respectively.\n\nSample Input 2\n\n4 2\n1 3 1\n2 4 2\n\nSample Output 2\n\n6\n\nThe six ways are:\n\nRRRG\n\nRRRB\n\nGGGR\n\nGGGB\n\nBBBR\n\nBBBG\n\nSample Input 3\n\n1 3\n1 1 1\n1 1 2\n1 1 3\n\nSample Output 3\n\n0\n\nThere are zero ways.\n\nSample Input 4\n\n8 10\n2 6 2\n5 5 1\n3 5 2\n4 7 3\n4 4 1\n2 3 1\n7 7 1\n1 5 2\n1 7 3\n3 4 2\n\nSample Output 4\n\n108", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1729, "cpu_time_ms": 950, "memory_kb": 304624}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s230424225", "group_id": "codeNet:p03719", "input_text": "fun main(args: Array) {\n val (A, B, C) = readLine()!!.split(\" \").map(String::toInt)\n if (C in A..B) {\n println(\"Yes\")\n } else {\n println(\"No\")\n }\n}\n", "language": "Kotlin", "metadata": {"date": 1494724941, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03719.html", "problem_id": "p03719", "resource_group": "medium_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/Kotlin/s230424225.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s230424225", "user_id": "u857067005"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "fun main(args: Array) {\n val (A, B, C) = readLine()!!.split(\" \").map(String::toInt)\n if (C in A..B) {\n println(\"Yes\")\n } else {\n println(\"No\")\n }\n}\n", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 182, "cpu_time_ms": 251, "memory_kb": 38000}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s813736679", "group_id": "codeNet:p03720", "input_text": "fun main(array: Array) {\n val (n, m) = readLine()!!.split(\" \").map { it.toInt() }\n val arr = Array(n+1){0}\n repeat(m) {\n val (a, b) = readLine()!!.split(\" \").map { it.toInt() }\n arr[a] += 1\n arr[b] += 1\n }\n for(i in 1..n) {\n println(arr[i])\n }\n}", "language": "Kotlin", "metadata": {"date": 1589836930, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03720.html", "problem_id": "p03720", "resource_group": "medium_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/Kotlin/s813736679.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s813736679", "user_id": "u124119858"}, "prompt_components": {"gold_output": "2\n2\n1\n1\n", "input_to_evaluate": "fun main(array: Array) {\n val (n, m) = readLine()!!.split(\" \").map { it.toInt() }\n val arr = Array(n+1){0}\n repeat(m) {\n val (a, b) = readLine()!!.split(\" \").map { it.toInt() }\n arr[a] += 1\n arr[b] += 1\n }\n for(i in 1..n) {\n println(arr[i])\n }\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 237, "memory_kb": 37564}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s603095860", "group_id": "codeNet:p03721", "input_text": "fun main(args: Array){\n val (N, K) = readLine()!!.split(\" \").map { it.toInt() }\n val ab = Array(N){ readLine()!!.split(\" \").map { it.toInt() } }\n ab.sortBy { it[0] }\n var x = K\n var i = 0\n while (x > 0){\n x -= ab[i][1]\n i++\n }\n println(ab[i - 1][0])\n}", "language": "Kotlin", "metadata": {"date": 1591391591, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03721.html", "problem_id": "p03721", "resource_group": "medium_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/Kotlin/s603095860.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s603095860", "user_id": "u531770859"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "fun main(args: Array){\n val (N, K) = readLine()!!.split(\" \").map { it.toInt() }\n val ab = Array(N){ readLine()!!.split(\" \").map { it.toInt() } }\n ab.sortBy { it[0] }\n var x = K\n var i = 0\n while (x > 0){\n x -= ab[i][1]\n i++\n }\n println(ab[i - 1][0])\n}", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 995, "memory_kb": 82640}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s929570335", "group_id": "codeNet:p03721", "input_text": "import java.io.PrintWriter\nimport java.util.*\nimport java.math.*\nimport java.lang.*\nimport kotlin.comparisons.*\n\nval pw = PrintWriter(System.out)\nval MOD: Long = (1e+9 + 7).toLong()\n\nfun main(args: Array) {\n\tval (nl, k) = readListOfLong()\n\tval n = nl.toInt()\n\tval inserted = Array(n) { Pair(0L, 0L) }\n\tfor(i in 0 until n) {\n\t\tval (a, b) = readListOfLong()\n\t\tinserted[i] = Pair(a, b)\n\t}\n\tinserted.sortBy { it.first }\n\tvar cnt = 0L\n\tvar i = 0\n\tvar ans = inserted[0].first\n\twhile(cnt < k) {\n\t\tval (a, b) = inserted[i]\n\t\tif(cnt + b >= k) {\n\t\t\tans = a\n\t\t\tbreak\n\t\t}\n\t\tcnt += b\n\t\ti++\n\t}\n\tprintln(ans)\n\tpw.flush()\n}\n\n/****** Declared Functions and Data Structures ******/\n// IO\nfun read() = readLine()!!\nfun readInt() = read().toInt()\nfun readLong() = read().toLong()\nfun readDouble() = read().toDouble()\nfun readListOfString() = read().split(\" \")\nfun readListOfInt() = readListOfString().map { it.toInt() }\nfun readListOfLong() = readListOfString().map { it.toLong() }\nfun readListOfDouble() = readListOfString().map { it.toDouble() }\n\nfun Double.format(digits: Int) = String.format(\"%.${digits}f\", this)\nfun Float.format(digits: Int) = String.format(\"%.${digits}f\", this)\n\nfun print(value: Any) { pw.print(value) }\nfun println(value : Any) { pw.println(value) }\n\n// Extensions\nfun List.toBuckets(): Map\n\t= this.groupBy { it }.mapValues { it.value.size }\n\nfun> List.upperBound(element: T, fromIndex: Int=0, toIndex: Int=this.size): Int {\n\tvar l = fromIndex\n\tvar r = toIndex\n\twhile(l < r) {\n\t\tval mid = (l+r) / 2\n\t\tif(element >= this[mid]) { \n\t\t\tl = mid + 1\n\t\t} else {\n\t\t\tr = mid\n\t\t}\n\t}\n\treturn l\n}\n\nfun> List.lowerBound(element: T, fromIndex: Int=0, toIndex: Int=this.size): Int {\n\tvar l = fromIndex\n\tvar r = toIndex\n\twhile(l < r) {\n\t\tval mid = (l+r) / 2\n\t\tif(element <= this[mid]) { \n\t\t\tr = mid\n\t\t} else {\n\t\t\tl = mid + 1\n\t\t}\n\t}\n\treturn r \n}\n\nfun Map.toMutableMap(): MutableMap = HashMap(this)\n\n// Util Functions\nfun Long.makeDivisors(): List {\n\tval divisors = mutableListOf()\n\tfor(i in 1L .. Math.sqrt(this.toDouble()).toLong()+1L) {\n\t\tif(this % i == 0L) {\n\t\t\tdivisors.add(i)\n\t\t\tif(i != this/i) {\n\t\t\t\tdivisors.add(this/i)\n\t\t\t}\n\t\t}\n\t}\n\treturn divisors.distinct().sorted()\n}\n\nfun Long.isPrime(): Boolean {\n\tif(this==1L) return false\n\tfor(i in 2L .. Math.sqrt(this.toDouble()).toLong() + 1L) {\n\t\tif(this % i == 0L && this != i) {\n\t\t\treturn false\n\t\t}\n\t}\n\treturn true\n}\n\n\nfun permutations(src: List): List> {\n\tif(src.size == 1) return listOf(src)\n\tval perms = mutableListOf>()\n\tval insertElement = src[0]\n\tpermutations(src.drop(1)).forEach { perm ->\n\t\tfor(i in 0..perm.size) {\n\t\t\tval newPerm = perm.toMutableList()\n\t\t\tnewPerm.add(i, insertElement)\n\t\t\tperms.add(newPerm.toList())\n\t\t}\n\t}\n\treturn perms\n}\n\n// return nCr, if you want nCr, please access v[n][r]\nfun combinations(n: Long): List> {\n\tval v = (0..n).map { (0..n).map{0L}.toMutableList() }.toMutableList()\n\tfor(i in 0 until v.size) {\n\t\tv[i][0] = 1L\n\t\tv[i][i] = 1L\n\t}\n\tfor(i in 0 until v.size) {\n\t\tfor(j in 1 until i) {\n\t\t\tv[i][j] = (v[i-1][j-1] + v[i-1][j]) % MOD\n\t\t}\n\t}\n\treturn v.map { it.toList() }.toList()\n}\n\nfun repeatedModPow(a: Long, n: Long, mod: Long): Long = \n\twhen {\n\t\tn == 1L -> a % mod\n\t\tn % 2L == 1L -> (a * repeatedModPow(a, n-1L, mod)) % mod\n\t\telse -> {\n\t\t\tval tmp = repeatedModPow(a, n / 2L, mod)\n\t\t\t(tmp * tmp) % mod\n\t\t}\n\t}\n\n// return nCr % MOD\nfun modnCkWithoutArray(n: Long, k: Long, mod: Long): Long {\n\tvar ret = 1L\n\tval min = Math.min(k, n-k)\n\t// まず分母の計算\n\tfor(i in n downTo (n - min + 1)) {\n\t\tret = ret * i % mod\n\t}\n\tfor(i in min downTo 1) {\n\t\tret = ret * repeatedModPow(i, (mod - 2L), mod) % mod\n\t}\n\treturn ret\n}\n\n// return nCr % MOD\nfun modnCk(n: Int, k: Int, mod: Long): Long {\n\tval factorials = Array(n+1) { 0L }.apply {\n\t\tthis[0] = 1L\n\t\tif(this.size > 1) this[1] = 1L\n\t}\n\tval inverses = Array(n+1) { 0L }.apply {\n\t\tthis[0] = 1L\n\t\tif(this.size > 1) this[1] = 1L\n\t}\n\tval factorialInverses = Array(n+1) { 0L }.apply {\n\t\tthis[0] = 1L\n\t\tif(this.size > 1) this[1] = 1L\n\t}\n\tfor(i in 2 .. n) {\n\t\tfactorials[i] = (factorials[i-1] * i.toLong() % mod)\n\t\tinverses[i] = (mod - inverses[mod.toInt() % i] * (mod / i.toLong()) % mod)\n\t\tfactorialInverses[i] = (factorialInverses[i-1] * inverses[i] % mod)\n\t}\n\n\treturn factorials[n] % mod * (factorialInverses[k] * factorialInverses[n-k] % mod) % mod\n}\n\n// should be a >= b\nfun gcd(a: Long, b: Long): Long = \n\tif(b == 0L) a else gcd(b, a % b)\n\n// shoud be a >= b\nfun lcm(a: Long, b: Long): Long = \n\ta / gcd(a, b) * b\n\nfun sumDigits(num_: Long): Long {\n\tvar num = num_\n\tvar rtn: Long = 0\n\twhile(num != 0.toLong()) {\n\t\tval tmp = num % 10\n\t\trtn += tmp\n\t\tnum /= 10\n\t}\n\treturn rtn\n}\n\nfun Double.isDecimal(): Boolean = ((this - Math.floor(this)) != 0.0)\n\n// Data Structures\n\nclass UnionFind(private val n: Int) {\n\tprivate val parent: Array = Array(n) { 0 }\n\tprivate val rank: Array = Array(n) { 0 }\n\tprivate val size: Array = Array(n) { 0 }\n\n\tinit {\n\t\tfor(i in 0 until n) {\n\t\t\tparent[i] = i\n\t\t\trank[i] = 1\n\t\t\tsize[i] = 1\n\t\t}\n\t}\n\n\tfun union(u: Int, v: Int) {\n\t\tvar x = root(u)\n\t\tvar y = root(v)\n\t\tif(x != y) {\n\t\t\tif(rank[y] < rank[x]) {\n\t\t\t\tval tmp = y \n\t\t\t\ty = x\n\t\t\t\tx = tmp \n\t\t\t}\n\t\t\tparent[x] = y\n\t\t\trank[y] += rank[x]\n\t\t\trank[x] = -1\n\t\t\tval totalSize = size[x] + size[y]\n\t\t\tsize[x] = totalSize\n\t\t\tsize[y] = totalSize\n\t\t}\n\t}\n\n\tfun root(u: Int): Int {\n\t\tvar x = u\n\t\twhile(parent[x] != x) {\n\t\t\tx = parent[x]\n\t\t}\n\t\treturn x \n\t}\n\n\tfun size(u: Int): Int = size[root(u)]\n}\n", "language": "Kotlin", "metadata": {"date": 1586997730, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03721.html", "problem_id": "p03721", "resource_group": "medium_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/Kotlin/s929570335.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s929570335", "user_id": "u026686258"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "import java.io.PrintWriter\nimport java.util.*\nimport java.math.*\nimport java.lang.*\nimport kotlin.comparisons.*\n\nval pw = PrintWriter(System.out)\nval MOD: Long = (1e+9 + 7).toLong()\n\nfun main(args: Array) {\n\tval (nl, k) = readListOfLong()\n\tval n = nl.toInt()\n\tval inserted = Array(n) { Pair(0L, 0L) }\n\tfor(i in 0 until n) {\n\t\tval (a, b) = readListOfLong()\n\t\tinserted[i] = Pair(a, b)\n\t}\n\tinserted.sortBy { it.first }\n\tvar cnt = 0L\n\tvar i = 0\n\tvar ans = inserted[0].first\n\twhile(cnt < k) {\n\t\tval (a, b) = inserted[i]\n\t\tif(cnt + b >= k) {\n\t\t\tans = a\n\t\t\tbreak\n\t\t}\n\t\tcnt += b\n\t\ti++\n\t}\n\tprintln(ans)\n\tpw.flush()\n}\n\n/****** Declared Functions and Data Structures ******/\n// IO\nfun read() = readLine()!!\nfun readInt() = read().toInt()\nfun readLong() = read().toLong()\nfun readDouble() = read().toDouble()\nfun readListOfString() = read().split(\" \")\nfun readListOfInt() = readListOfString().map { it.toInt() }\nfun readListOfLong() = readListOfString().map { it.toLong() }\nfun readListOfDouble() = readListOfString().map { it.toDouble() }\n\nfun Double.format(digits: Int) = String.format(\"%.${digits}f\", this)\nfun Float.format(digits: Int) = String.format(\"%.${digits}f\", this)\n\nfun print(value: Any) { pw.print(value) }\nfun println(value : Any) { pw.println(value) }\n\n// Extensions\nfun List.toBuckets(): Map\n\t= this.groupBy { it }.mapValues { it.value.size }\n\nfun> List.upperBound(element: T, fromIndex: Int=0, toIndex: Int=this.size): Int {\n\tvar l = fromIndex\n\tvar r = toIndex\n\twhile(l < r) {\n\t\tval mid = (l+r) / 2\n\t\tif(element >= this[mid]) { \n\t\t\tl = mid + 1\n\t\t} else {\n\t\t\tr = mid\n\t\t}\n\t}\n\treturn l\n}\n\nfun> List.lowerBound(element: T, fromIndex: Int=0, toIndex: Int=this.size): Int {\n\tvar l = fromIndex\n\tvar r = toIndex\n\twhile(l < r) {\n\t\tval mid = (l+r) / 2\n\t\tif(element <= this[mid]) { \n\t\t\tr = mid\n\t\t} else {\n\t\t\tl = mid + 1\n\t\t}\n\t}\n\treturn r \n}\n\nfun Map.toMutableMap(): MutableMap = HashMap(this)\n\n// Util Functions\nfun Long.makeDivisors(): List {\n\tval divisors = mutableListOf()\n\tfor(i in 1L .. Math.sqrt(this.toDouble()).toLong()+1L) {\n\t\tif(this % i == 0L) {\n\t\t\tdivisors.add(i)\n\t\t\tif(i != this/i) {\n\t\t\t\tdivisors.add(this/i)\n\t\t\t}\n\t\t}\n\t}\n\treturn divisors.distinct().sorted()\n}\n\nfun Long.isPrime(): Boolean {\n\tif(this==1L) return false\n\tfor(i in 2L .. Math.sqrt(this.toDouble()).toLong() + 1L) {\n\t\tif(this % i == 0L && this != i) {\n\t\t\treturn false\n\t\t}\n\t}\n\treturn true\n}\n\n\nfun permutations(src: List): List> {\n\tif(src.size == 1) return listOf(src)\n\tval perms = mutableListOf>()\n\tval insertElement = src[0]\n\tpermutations(src.drop(1)).forEach { perm ->\n\t\tfor(i in 0..perm.size) {\n\t\t\tval newPerm = perm.toMutableList()\n\t\t\tnewPerm.add(i, insertElement)\n\t\t\tperms.add(newPerm.toList())\n\t\t}\n\t}\n\treturn perms\n}\n\n// return nCr, if you want nCr, please access v[n][r]\nfun combinations(n: Long): List> {\n\tval v = (0..n).map { (0..n).map{0L}.toMutableList() }.toMutableList()\n\tfor(i in 0 until v.size) {\n\t\tv[i][0] = 1L\n\t\tv[i][i] = 1L\n\t}\n\tfor(i in 0 until v.size) {\n\t\tfor(j in 1 until i) {\n\t\t\tv[i][j] = (v[i-1][j-1] + v[i-1][j]) % MOD\n\t\t}\n\t}\n\treturn v.map { it.toList() }.toList()\n}\n\nfun repeatedModPow(a: Long, n: Long, mod: Long): Long = \n\twhen {\n\t\tn == 1L -> a % mod\n\t\tn % 2L == 1L -> (a * repeatedModPow(a, n-1L, mod)) % mod\n\t\telse -> {\n\t\t\tval tmp = repeatedModPow(a, n / 2L, mod)\n\t\t\t(tmp * tmp) % mod\n\t\t}\n\t}\n\n// return nCr % MOD\nfun modnCkWithoutArray(n: Long, k: Long, mod: Long): Long {\n\tvar ret = 1L\n\tval min = Math.min(k, n-k)\n\t// まず分母の計算\n\tfor(i in n downTo (n - min + 1)) {\n\t\tret = ret * i % mod\n\t}\n\tfor(i in min downTo 1) {\n\t\tret = ret * repeatedModPow(i, (mod - 2L), mod) % mod\n\t}\n\treturn ret\n}\n\n// return nCr % MOD\nfun modnCk(n: Int, k: Int, mod: Long): Long {\n\tval factorials = Array(n+1) { 0L }.apply {\n\t\tthis[0] = 1L\n\t\tif(this.size > 1) this[1] = 1L\n\t}\n\tval inverses = Array(n+1) { 0L }.apply {\n\t\tthis[0] = 1L\n\t\tif(this.size > 1) this[1] = 1L\n\t}\n\tval factorialInverses = Array(n+1) { 0L }.apply {\n\t\tthis[0] = 1L\n\t\tif(this.size > 1) this[1] = 1L\n\t}\n\tfor(i in 2 .. n) {\n\t\tfactorials[i] = (factorials[i-1] * i.toLong() % mod)\n\t\tinverses[i] = (mod - inverses[mod.toInt() % i] * (mod / i.toLong()) % mod)\n\t\tfactorialInverses[i] = (factorialInverses[i-1] * inverses[i] % mod)\n\t}\n\n\treturn factorials[n] % mod * (factorialInverses[k] * factorialInverses[n-k] % mod) % mod\n}\n\n// should be a >= b\nfun gcd(a: Long, b: Long): Long = \n\tif(b == 0L) a else gcd(b, a % b)\n\n// shoud be a >= b\nfun lcm(a: Long, b: Long): Long = \n\ta / gcd(a, b) * b\n\nfun sumDigits(num_: Long): Long {\n\tvar num = num_\n\tvar rtn: Long = 0\n\twhile(num != 0.toLong()) {\n\t\tval tmp = num % 10\n\t\trtn += tmp\n\t\tnum /= 10\n\t}\n\treturn rtn\n}\n\nfun Double.isDecimal(): Boolean = ((this - Math.floor(this)) != 0.0)\n\n// Data Structures\n\nclass UnionFind(private val n: Int) {\n\tprivate val parent: Array = Array(n) { 0 }\n\tprivate val rank: Array = Array(n) { 0 }\n\tprivate val size: Array = Array(n) { 0 }\n\n\tinit {\n\t\tfor(i in 0 until n) {\n\t\t\tparent[i] = i\n\t\t\trank[i] = 1\n\t\t\tsize[i] = 1\n\t\t}\n\t}\n\n\tfun union(u: Int, v: Int) {\n\t\tvar x = root(u)\n\t\tvar y = root(v)\n\t\tif(x != y) {\n\t\t\tif(rank[y] < rank[x]) {\n\t\t\t\tval tmp = y \n\t\t\t\ty = x\n\t\t\t\tx = tmp \n\t\t\t}\n\t\t\tparent[x] = y\n\t\t\trank[y] += rank[x]\n\t\t\trank[x] = -1\n\t\t\tval totalSize = size[x] + size[y]\n\t\t\tsize[x] = totalSize\n\t\t\tsize[y] = totalSize\n\t\t}\n\t}\n\n\tfun root(u: Int): Int {\n\t\tvar x = u\n\t\twhile(parent[x] != x) {\n\t\t\tx = parent[x]\n\t\t}\n\t\treturn x \n\t}\n\n\tfun size(u: Int): Int = size[root(u)]\n}\n", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 5521, "cpu_time_ms": 1051, "memory_kb": 87948}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s767568813", "group_id": "codeNet:p03721", "input_text": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val n = sc.nextInt()\n val k = sc.nextLong()\n val a = (0 until n).map { Class016c(sc.next().toLong(), sc.next().toLong()) }\n println(problem061c(n, k, a))\n}\n\nfun problem061c(n: Int, k: Long, a: List): Long {\n var k2 = k\n var ans = 0L\n for (i in 0 until n) {\n val tmp = a[i].b\n if (tmp < k2) {\n k2 -= tmp\n } else {\n ans = a[i].a\n break\n }\n }\n return ans\n}\n\ndata class Class016c(var a: Long, var b: Long)\n", "language": "Kotlin", "metadata": {"date": 1567989028, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03721.html", "problem_id": "p03721", "resource_group": "medium_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/Kotlin/s767568813.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s767568813", "user_id": "u874644572"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val n = sc.nextInt()\n val k = sc.nextLong()\n val a = (0 until n).map { Class016c(sc.next().toLong(), sc.next().toLong()) }\n println(problem061c(n, k, a))\n}\n\nfun problem061c(n: Int, k: Long, a: List): Long {\n var k2 = k\n var ans = 0L\n for (i in 0 until n) {\n val tmp = a[i].b\n if (tmp < k2) {\n k2 -= tmp\n } else {\n ans = a[i].a\n break\n }\n }\n return ans\n}\n\ndata class Class016c(var a: Long, var b: Long)\n", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 588, "cpu_time_ms": 705, "memory_kb": 57476}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s524211267", "group_id": "codeNet:p03721", "input_text": "import java.util.Arrays\nimport java.util.ArrayList\n\nconst val MOD: Long = (1e9+7).toLong()\nfun Double.format(digits: Int) = String.format(\"%.${digits}f\", this)\nfun > Iterable.argmax(): Int? = withIndex().maxBy{it.value}?.index\nfun > Iterable.argmin(): Int? = withIndex().minBy{it.value}?.index\n\nfun main(args: Array) {\n val reader = System.`in`.bufferedReader()\n val (N, k) = reader.readLine()!!.split(\" \").map{it.toLong()}\n val n = N.toInt()\n val c = Array(n, {\n val (a, b) = reader.readLine()!!.split(\" \").map{it.toLong()}\n Pair(a, b)\n })\n\n c.sortBy {it.first}\n\n var sum = 0L\n for (i in 0..n-1) {\n sum += c[i].second\n if (sum >= k) {\n println(c[i].first)\n return\n }\n }\n}\n", "language": "Kotlin", "metadata": {"date": 1558313904, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03721.html", "problem_id": "p03721", "resource_group": "medium_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/Kotlin/s524211267.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s524211267", "user_id": "u868099754"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "import java.util.Arrays\nimport java.util.ArrayList\n\nconst val MOD: Long = (1e9+7).toLong()\nfun Double.format(digits: Int) = String.format(\"%.${digits}f\", this)\nfun > Iterable.argmax(): Int? = withIndex().maxBy{it.value}?.index\nfun > Iterable.argmin(): Int? = withIndex().minBy{it.value}?.index\n\nfun main(args: Array) {\n val reader = System.`in`.bufferedReader()\n val (N, k) = reader.readLine()!!.split(\" \").map{it.toLong()}\n val n = N.toInt()\n val c = Array(n, {\n val (a, b) = reader.readLine()!!.split(\" \").map{it.toLong()}\n Pair(a, b)\n })\n\n c.sortBy {it.first}\n\n var sum = 0L\n for (i in 0..n-1) {\n sum += c[i].second\n if (sum >= k) {\n println(c[i].first)\n return\n }\n }\n}\n", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 996, "memory_kb": 87464}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s357250435", "group_id": "codeNet:p03721", "input_text": "import java.util.TreeMap\n\nfun main(args: Array) {\n val (n, k) = readLine()!!.split(' ').map(String::toInt)\n val tm = TreeMap()\n repeat(n) {\n val (a, b) = readLine()!!.split(' ').map(String::toInt)\n val qty = tm[a]\n tm[a] = if (qty == null) b.toLong() else qty + b\n }\n var i = 0L\n for ((a, b) in tm) {\n i += b\n if (k <= i) {\n println(a)\n break\n }\n }\n}\n", "language": "Kotlin", "metadata": {"date": 1552282611, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03721.html", "problem_id": "p03721", "resource_group": "medium_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/Kotlin/s357250435.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s357250435", "user_id": "u051841332"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "import java.util.TreeMap\n\nfun main(args: Array) {\n val (n, k) = readLine()!!.split(' ').map(String::toInt)\n val tm = TreeMap()\n repeat(n) {\n val (a, b) = readLine()!!.split(' ').map(String::toInt)\n val qty = tm[a]\n tm[a] = if (qty == null) b.toLong() else qty + b\n }\n var i = 0L\n for ((a, b) in tm) {\n i += b\n if (k <= i) {\n println(a)\n break\n }\n }\n}\n", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 670, "memory_kb": 56760}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s527950385", "group_id": "codeNet:p03722", "input_text": "import java.util.*\nimport java.math.*\nimport java.lang.Math.*\n\nval readString: ()->String = {readLine()!!}\nval readInt: ()->Int = {readLine()!!.toInt()}\nval readLong: ()->Long = {readLine()!!.toLong()}\nval readIntArray: ()->IntArray = {readLine()!!.split(' ').map{it.toInt()}.toIntArray()}\nval readLongArray: ()->LongArray = {readLine()!!.split(' ').map{it.toLong()}.toLongArray()}\nval errPrintln: (String)->Unit = {msg -> System.err.println(msg)}\nval MOD = 1e9.toLong()+7\nval INF = Int.MAX_VALUE/2\nval LINF = Long.MAX_VALUE/2\ndata class IntPair(val first: Int, val second: Int)\ndata class To(val idx: Int, val cost: Long)\n\n\nclass Bellman(val eg: Array>, val start: Int) {\n private var dist = LongArray(0)\n //var hasNegativeCycle = false\n var hasPositiveCycle = false\n private set\n\n init {\n val N = eg.size\n //dist = LongArray(N){LINF}\n dist = LongArray(N){-LINF}\n dist[start] = 0L\n hasPositiveCycle = false\n\n loop@for (i in 0 until N*2) {\n var updating = false\n for (x in 0 until N) {\n for (t in eg[x]) {\n val y = t.idx\n //if (dist[x] + t.cost < dist[y]) {\n if (dist[x] + t.cost > dist[y]) {\n dist[y] = dist[x] + t.cost\n updating = true\n if (i >= N-1) {\n //hasNegativeCycle = true\n hasPositiveCycle = true\n break@loop\n }\n }\n }\n }\n if (!updating) break\n }\n }\n fun distance(i: Int): Long {\n //return if(hasNegativeCycle) LINF else dist[i]\n return if(hasPositiveCycle) LINF else dist[i]\n }\n}\n\n\nfun solve(eg: Array>): Long {\n val N = eg.size\n\n val bm = Bellman(eg, 0)\n\n return bm.distance(N-1)\n}\n\n\nfun main(args: Array) {\n val (N, M) = readIntArray()\n val eg = Array(N){ArrayList()}\n for (i in 0 until M) {\n var (a, b, c) = readLongArray()\n a--;b--;\n eg[a.toInt()].add(To(b.toInt(), c)) // 有向グラフ\n }\n\n val ans = solve(eg)\n\n if (ans == LINF) println(\"inf\")\n else println(ans)\n}\n", "language": "Kotlin", "metadata": {"date": 1591047820, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03722.html", "problem_id": "p03722", "resource_group": "medium_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/Kotlin/s527950385.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s527950385", "user_id": "u404244809"}, "prompt_components": {"gold_output": "7\n", "input_to_evaluate": "import java.util.*\nimport java.math.*\nimport java.lang.Math.*\n\nval readString: ()->String = {readLine()!!}\nval readInt: ()->Int = {readLine()!!.toInt()}\nval readLong: ()->Long = {readLine()!!.toLong()}\nval readIntArray: ()->IntArray = {readLine()!!.split(' ').map{it.toInt()}.toIntArray()}\nval readLongArray: ()->LongArray = {readLine()!!.split(' ').map{it.toLong()}.toLongArray()}\nval errPrintln: (String)->Unit = {msg -> System.err.println(msg)}\nval MOD = 1e9.toLong()+7\nval INF = Int.MAX_VALUE/2\nval LINF = Long.MAX_VALUE/2\ndata class IntPair(val first: Int, val second: Int)\ndata class To(val idx: Int, val cost: Long)\n\n\nclass Bellman(val eg: Array>, val start: Int) {\n private var dist = LongArray(0)\n //var hasNegativeCycle = false\n var hasPositiveCycle = false\n private set\n\n init {\n val N = eg.size\n //dist = LongArray(N){LINF}\n dist = LongArray(N){-LINF}\n dist[start] = 0L\n hasPositiveCycle = false\n\n loop@for (i in 0 until N*2) {\n var updating = false\n for (x in 0 until N) {\n for (t in eg[x]) {\n val y = t.idx\n //if (dist[x] + t.cost < dist[y]) {\n if (dist[x] + t.cost > dist[y]) {\n dist[y] = dist[x] + t.cost\n updating = true\n if (i >= N-1) {\n //hasNegativeCycle = true\n hasPositiveCycle = true\n break@loop\n }\n }\n }\n }\n if (!updating) break\n }\n }\n fun distance(i: Int): Long {\n //return if(hasNegativeCycle) LINF else dist[i]\n return if(hasPositiveCycle) LINF else dist[i]\n }\n}\n\n\nfun solve(eg: Array>): Long {\n val N = eg.size\n\n val bm = Bellman(eg, 0)\n\n return bm.distance(N-1)\n}\n\n\nfun main(args: Array) {\n val (N, M) = readIntArray()\n val eg = Array(N){ArrayList()}\n for (i in 0 until M) {\n var (a, b, c) = readLongArray()\n a--;b--;\n eg[a.toInt()].add(To(b.toInt(), c)) // 有向グラフ\n }\n\n val ans = solve(eg)\n\n if (ans == LINF) println(\"inf\")\n else println(ans)\n}\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≤i() }\n}\n\nval INF = 1e+15.toLong()\n\nfun bellmanFord(g: Graph, s: Int): Triple, Array, Array> {\n val N = g.n\n val dist = Array(N) {INF}\n val prev = Array(N) {-1}\n\n dist[0] = 0\n\n for (k in 1 .. N) {\n for (v in 0 until N) {\n for (e in g.edges[v]) {\n if (dist[e.from] != INF && dist[e.to] > dist[e.from] + e.weight) {\n dist[e.to] = dist[e.from] + e.weight\n prev[e.to] = e.from\n }\n }\n }\n }\n\n val dist2 = dist.copyOf()\n for (k in 1 .. 3 * N) {\n for (v in 0 until N) {\n for (e in g.edges[v]) {\n if (dist2[e.from] != INF && dist2[e.to] > dist2[e.from] + e.weight) {\n dist2[e.to] = dist2[e.from] + e.weight\n }\n }\n }\n }\n\n val affectedByNegativeLoop = Array(N) { idx -> dist[idx] != dist2[idx] }\n\n return Triple(dist, prev, affectedByNegativeLoop)\n}\n\nfun main(args: Array) {\n val (N, M) = readLine()!!.split(\" \").map { s -> s.toInt() }\n val g = Graph(N)\n\n for (i in 1 .. M) {\n val (a, b, c) = readLine()!!.split(\" \").map {s -> s.toLong()}\n g.edges[(a - 1).toInt()].add(Edge(a - 1, b - 1, -c))\n }\n\n val (dist, prev, affectedByNegativeLoop) = bellmanFord(g, 0)\n\n if (affectedByNegativeLoop[N - 1]) {\n println(\"inf\")\n } else {\n println(-dist[N - 1])\n }\n}", "language": "Kotlin", "metadata": {"date": 1570586951, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03722.html", "problem_id": "p03722", "resource_group": "medium_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/Kotlin/s708769133.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s708769133", "user_id": "u183530284"}, "prompt_components": {"gold_output": "7\n", "input_to_evaluate": "import java.util.ArrayList\n\ndata class Edge(val from: Int, val to: Int, val weight: Long) {\n constructor(from: Long, to: Long, weight: Long) : this(from.toInt(), to.toInt(), weight)\n}\n\nclass Graph(val n: Int) {\n val edges = Array(n) { ArrayList() }\n}\n\nval INF = 1e+15.toLong()\n\nfun bellmanFord(g: Graph, s: Int): Triple, Array, Array> {\n val N = g.n\n val dist = Array(N) {INF}\n val prev = Array(N) {-1}\n\n dist[0] = 0\n\n for (k in 1 .. N) {\n for (v in 0 until N) {\n for (e in g.edges[v]) {\n if (dist[e.from] != INF && dist[e.to] > dist[e.from] + e.weight) {\n dist[e.to] = dist[e.from] + e.weight\n prev[e.to] = e.from\n }\n }\n }\n }\n\n val dist2 = dist.copyOf()\n for (k in 1 .. 3 * N) {\n for (v in 0 until N) {\n for (e in g.edges[v]) {\n if (dist2[e.from] != INF && dist2[e.to] > dist2[e.from] + e.weight) {\n dist2[e.to] = dist2[e.from] + e.weight\n }\n }\n }\n }\n\n val affectedByNegativeLoop = Array(N) { idx -> dist[idx] != dist2[idx] }\n\n return Triple(dist, prev, affectedByNegativeLoop)\n}\n\nfun main(args: Array) {\n val (N, M) = readLine()!!.split(\" \").map { s -> s.toInt() }\n val g = Graph(N)\n\n for (i in 1 .. M) {\n val (a, b, c) = readLine()!!.split(\" \").map {s -> s.toLong()}\n g.edges[(a - 1).toInt()].add(Edge(a - 1, b - 1, -c))\n }\n\n val (dist, prev, affectedByNegativeLoop) = bellmanFord(g, 0)\n\n if (affectedByNegativeLoop[N - 1]) {\n println(\"inf\")\n } else {\n println(-dist[N - 1])\n }\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≤i) {\n var (a, b, c) = readLine()!!.split(\" \").map { it.toInt() }\n var cnt = 0\n var tempA = 0\n var tempB = 0\n var tempC = 0\n\n if(a % 2 != 0 || b % 2 != 0 || c % 2 != 0) {\n print(1)\n return\n }\n if(a == b && b == c) {\n print(-1)\n return\n }\n while (true) {\n if(a % 2 != 0 || b % 2 != 0 || c % 2 != 0) {\n print(cnt)\n return\n }\n tempA = b/2 + c/2\n tempB = a/2 + c/2\n tempC = a/2 + b/2\n a = tempA\n b = tempB\n c = tempC\n cnt++\n\n }\n print(cnt)\n}", "language": "Kotlin", "metadata": {"date": 1588646855, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03723.html", "problem_id": "p03723", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03723/input.txt", "sample_output_relpath": "derived/input_output/data/p03723/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03723/Kotlin/s751012574.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s751012574", "user_id": "u124119858"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "fun main(array: Array) {\n var (a, b, c) = readLine()!!.split(\" \").map { it.toInt() }\n var cnt = 0\n var tempA = 0\n var tempB = 0\n var tempC = 0\n\n if(a % 2 != 0 || b % 2 != 0 || c % 2 != 0) {\n print(1)\n return\n }\n if(a == b && b == c) {\n print(-1)\n return\n }\n while (true) {\n if(a % 2 != 0 || b % 2 != 0 || c % 2 != 0) {\n print(cnt)\n return\n }\n tempA = b/2 + c/2\n tempB = a/2 + c/2\n tempC = a/2 + b/2\n a = tempA\n b = tempB\n c = tempC\n cnt++\n\n }\n print(cnt)\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nTakahashi, Aoki and Snuke love cookies. They have A, B and C cookies, respectively. Now, they will exchange those cookies by repeating the action below:\n\nEach person simultaneously divides his cookies in half and gives one half to each of the other two persons.\n\nThis action will be repeated until there is a person with odd number of cookies in hand.\n\nHow many times will they repeat this action?\nNote that the answer may not be finite.\n\nConstraints\n\n1 ≤ A,B,C ≤ 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C\n\nOutput\n\nPrint the number of times the action will be performed by the three people, if this number is finite.\nIf it is infinite, print -1 instead.\n\nSample Input 1\n\n4 12 20\n\nSample Output 1\n\n3\n\nInitially, Takahashi, Aoki and Snuke have 4, 12 and 20 cookies. Then,\n\nAfter the first action, they have 16, 12 and 8.\n\nAfter the second action, they have 10, 12 and 14.\n\nAfter the third action, they have 13, 12 and 11.\n\nNow, Takahashi and Snuke have odd number of cookies, and therefore the answer is 3.\n\nSample Input 2\n\n14 14 14\n\nSample Output 2\n\n-1\n\nSample Input 3\n\n454 414 444\n\nSample Output 3\n\n1", "sample_input": "4 12 20\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03723", "source_text": "Score : 300 points\n\nProblem Statement\n\nTakahashi, Aoki and Snuke love cookies. They have A, B and C cookies, respectively. Now, they will exchange those cookies by repeating the action below:\n\nEach person simultaneously divides his cookies in half and gives one half to each of the other two persons.\n\nThis action will be repeated until there is a person with odd number of cookies in hand.\n\nHow many times will they repeat this action?\nNote that the answer may not be finite.\n\nConstraints\n\n1 ≤ A,B,C ≤ 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C\n\nOutput\n\nPrint the number of times the action will be performed by the three people, if this number is finite.\nIf it is infinite, print -1 instead.\n\nSample Input 1\n\n4 12 20\n\nSample Output 1\n\n3\n\nInitially, Takahashi, Aoki and Snuke have 4, 12 and 20 cookies. Then,\n\nAfter the first action, they have 16, 12 and 8.\n\nAfter the second action, they have 10, 12 and 14.\n\nAfter the third action, they have 13, 12 and 11.\n\nNow, Takahashi and Snuke have odd number of cookies, and therefore the answer is 3.\n\nSample Input 2\n\n14 14 14\n\nSample Output 2\n\n-1\n\nSample Input 3\n\n454 414 444\n\nSample Output 3\n\n1", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 633, "cpu_time_ms": 231, "memory_kb": 37932}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s576272993", "group_id": "codeNet:p03723", "input_text": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n\n var a = sc.nextInt()\n var b = sc.nextInt()\n var c = sc.nextInt()\n var ans = 0\n val dic = arrayListOf>()\n var flg = false\n\n while (true) {\n val abc = listOf(a, b, c).sorted()\n if (abc in dic) {\n ans = -1\n }\n for (v in abc) {\n if (v % 2 != 0) {\n flg = true\n }\n }\n if (flg || ans < 0) {\n break\n }\n ans++\n dic.add(abc)\n val x = b / 2 + c / 2\n val y = c / 2 + a / 2\n val z = a / 2 + b / 2\n a = x\n b = y\n c = z\n }\n println(ans)\n}\n", "language": "Kotlin", "metadata": {"date": 1543209316, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03723.html", "problem_id": "p03723", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03723/input.txt", "sample_output_relpath": "derived/input_output/data/p03723/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03723/Kotlin/s576272993.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s576272993", "user_id": "u323680411"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n\n var a = sc.nextInt()\n var b = sc.nextInt()\n var c = sc.nextInt()\n var ans = 0\n val dic = arrayListOf>()\n var flg = false\n\n while (true) {\n val abc = listOf(a, b, c).sorted()\n if (abc in dic) {\n ans = -1\n }\n for (v in abc) {\n if (v % 2 != 0) {\n flg = true\n }\n }\n if (flg || ans < 0) {\n break\n }\n ans++\n dic.add(abc)\n val x = b / 2 + c / 2\n val y = c / 2 + a / 2\n val z = a / 2 + b / 2\n a = x\n b = y\n c = z\n }\n println(ans)\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nTakahashi, Aoki and Snuke love cookies. They have A, B and C cookies, respectively. Now, they will exchange those cookies by repeating the action below:\n\nEach person simultaneously divides his cookies in half and gives one half to each of the other two persons.\n\nThis action will be repeated until there is a person with odd number of cookies in hand.\n\nHow many times will they repeat this action?\nNote that the answer may not be finite.\n\nConstraints\n\n1 ≤ A,B,C ≤ 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C\n\nOutput\n\nPrint the number of times the action will be performed by the three people, if this number is finite.\nIf it is infinite, print -1 instead.\n\nSample Input 1\n\n4 12 20\n\nSample Output 1\n\n3\n\nInitially, Takahashi, Aoki and Snuke have 4, 12 and 20 cookies. Then,\n\nAfter the first action, they have 16, 12 and 8.\n\nAfter the second action, they have 10, 12 and 14.\n\nAfter the third action, they have 13, 12 and 11.\n\nNow, Takahashi and Snuke have odd number of cookies, and therefore the answer is 3.\n\nSample Input 2\n\n14 14 14\n\nSample Output 2\n\n-1\n\nSample Input 3\n\n454 414 444\n\nSample Output 3\n\n1", "sample_input": "4 12 20\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03723", "source_text": "Score : 300 points\n\nProblem Statement\n\nTakahashi, Aoki and Snuke love cookies. They have A, B and C cookies, respectively. Now, they will exchange those cookies by repeating the action below:\n\nEach person simultaneously divides his cookies in half and gives one half to each of the other two persons.\n\nThis action will be repeated until there is a person with odd number of cookies in hand.\n\nHow many times will they repeat this action?\nNote that the answer may not be finite.\n\nConstraints\n\n1 ≤ A,B,C ≤ 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C\n\nOutput\n\nPrint the number of times the action will be performed by the three people, if this number is finite.\nIf it is infinite, print -1 instead.\n\nSample Input 1\n\n4 12 20\n\nSample Output 1\n\n3\n\nInitially, Takahashi, Aoki and Snuke have 4, 12 and 20 cookies. Then,\n\nAfter the first action, they have 16, 12 and 8.\n\nAfter the second action, they have 10, 12 and 14.\n\nAfter the third action, they have 13, 12 and 11.\n\nNow, Takahashi and Snuke have odd number of cookies, and therefore the answer is 3.\n\nSample Input 2\n\n14 14 14\n\nSample Output 2\n\n-1\n\nSample Input 3\n\n454 414 444\n\nSample Output 3\n\n1", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 713, "cpu_time_ms": 205, "memory_kb": 36036}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s869140188", "group_id": "codeNet:p03724", "input_text": "import java.io.*\nimport java.util.*\nimport java.lang.*\nimport java.lang.Math.*\n\n\nfun solve() {\n val (N, Q) = rd.readIntArray()\n val hs = IntArray(N){0}\n for (i in 0 until Q) {\n val (a, b) = rd.readIntArray().map{ it-1 }\n hs[a]++\n hs[b]++\n }\n\n var ans = \"YES\"\n for (i in 0 until N) {\n if (hs[i]%2 != 0) {\n ans = \"NO\"\n break\n }\n }\n\n println(ans)\n}\n\n\n//val rd = debug.Reader(\"agc\", \"014\", \"b\", \"sample-1\")\nval rd = Reader()\n\n\nfun main(args: Array) {\n try {\n var exception: Throwable? = null\n val sth = Thread(null, SolveThread(), \"solveThread\", 128 * 1024 * 1024)\n sth.setUncaughtExceptionHandler { _, e -> exception = e }\n sth.start(); sth.join()\n if (exception != null) throw exception!!\n } catch (e: Exception) { throw e }\n}\nconst val MOD = 1_000_000_007L; const val INF = Int.MAX_VALUE/2; const val LINF = Long.MAX_VALUE/2\ndata class IntPair(val first: Int, val second: Int); data class LongPair(val first: Long, val second: Long)\nval errPrintln: (Any) -> Unit = { msg -> System.err.println(msg) }\nfun rAssert(exp: Boolean, lazyMsg: () -> String = {\"\"}) {\n if (!exp) { val msg = lazyMsg(); errPrintln(\"EAssert Error: $msg\"); throw Error(msg) }\n}\nfun tAssert(exp: Boolean, lazyMsg: () -> String = {\"\"}) {\n if (!exp) { val msg = lazyMsg(); errPrintln(\"TAssert Error: $msg\"); Thread.sleep(3000) }\n}\nclass SolveThread : Runnable {\n override fun run() { solve() }\n}\nclass Reader {\n private val br = BufferedReader(InputStreamReader(System.`in`))\n val readString: () -> String = { br.readLine() }\n val readInt: () -> Int = { br.readLine().toInt() }\n val readLong: () -> Long = { br.readLine().toLong() }\n val readIntArray: () -> IntArray = { br.readLine().split(' ').map { it.toInt() }.toIntArray() }\n val readLongArray: () -> LongArray = { br.readLine().split(' ').map { it.toLong() }.toLongArray() }\n val readListInt: () -> List = { br.readLine().split(' ').map { it.toInt() } }\n val readListLong: () -> List = { br.readLine().split(' ').map { it.toLong() } }\n}\n", "language": "Kotlin", "metadata": {"date": 1598041461, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p03724.html", "problem_id": "p03724", "resource_group": "medium_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/Kotlin/s869140188.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s869140188", "user_id": "u404244809"}, "prompt_components": {"gold_output": "YES\n", "input_to_evaluate": "import java.io.*\nimport java.util.*\nimport java.lang.*\nimport java.lang.Math.*\n\n\nfun solve() {\n val (N, Q) = rd.readIntArray()\n val hs = IntArray(N){0}\n for (i in 0 until Q) {\n val (a, b) = rd.readIntArray().map{ it-1 }\n hs[a]++\n hs[b]++\n }\n\n var ans = \"YES\"\n for (i in 0 until N) {\n if (hs[i]%2 != 0) {\n ans = \"NO\"\n break\n }\n }\n\n println(ans)\n}\n\n\n//val rd = debug.Reader(\"agc\", \"014\", \"b\", \"sample-1\")\nval rd = Reader()\n\n\nfun main(args: Array) {\n try {\n var exception: Throwable? = null\n val sth = Thread(null, SolveThread(), \"solveThread\", 128 * 1024 * 1024)\n sth.setUncaughtExceptionHandler { _, e -> exception = e }\n sth.start(); sth.join()\n if (exception != null) throw exception!!\n } catch (e: Exception) { throw e }\n}\nconst val MOD = 1_000_000_007L; const val INF = Int.MAX_VALUE/2; const val LINF = Long.MAX_VALUE/2\ndata class IntPair(val first: Int, val second: Int); data class LongPair(val first: Long, val second: Long)\nval errPrintln: (Any) -> Unit = { msg -> System.err.println(msg) }\nfun rAssert(exp: Boolean, lazyMsg: () -> String = {\"\"}) {\n if (!exp) { val msg = lazyMsg(); errPrintln(\"EAssert Error: $msg\"); throw Error(msg) }\n}\nfun tAssert(exp: Boolean, lazyMsg: () -> String = {\"\"}) {\n if (!exp) { val msg = lazyMsg(); errPrintln(\"TAssert Error: $msg\"); Thread.sleep(3000) }\n}\nclass SolveThread : Runnable {\n override fun run() { solve() }\n}\nclass Reader {\n private val br = BufferedReader(InputStreamReader(System.`in`))\n val readString: () -> String = { br.readLine() }\n val readInt: () -> Int = { br.readLine().toInt() }\n val readLong: () -> Long = { br.readLine().toLong() }\n val readIntArray: () -> IntArray = { br.readLine().split(' ').map { it.toInt() }.toIntArray() }\n val readLongArray: () -> LongArray = { br.readLine().split(' ').map { it.toLong() }.toLongArray() }\n val readListInt: () -> List = { br.readLine().split(' ').map { it.toInt() } }\n val readListLong: () -> List = { br.readLine().split(' ').map { it.toLong() } }\n}\n", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2133, "cpu_time_ms": 329, "memory_kb": 59476}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s606458646", "group_id": "codeNet:p03729", "input_text": "import java.io.PrintWriter\nimport kotlin.math.pow\n\nfun next() = readLine()!!\nfun nextInt() = next().toInt()\nfun nextLong() = next().toLong()\nfun nextDouble() = next().toDouble()\nfun nextList() = next().split(\" \")\nfun nextIntList() = nextList().map(String::toInt)\nfun nextLongList() = nextList().map(String::toLong)\nfun nextDoubleList() = nextList().map(String::toDouble)\n\nval pw = PrintWriter(System.out)\nfun print(s: Any = \"\") = pw.print(s)\nfun println(s: Any = \"\") = pw.println(s)\n\nfun Iterable.join(separator: CharSequence = \", \", prefix: CharSequence = \"\", postfix: CharSequence = \"\") = joinToString(separator, prefix, postfix)\nfun Array.join(separator: CharSequence = \", \", prefix: CharSequence = \"\", postfix: CharSequence = \"\") = joinToString(separator, prefix, postfix)\nfun Int.pow(n: Int) = pow(n.toLong())\nfun Int.pow(n: Long) = toDouble().pow(n.toDouble()).toLong()\nfun Long.pow(n: Int) = pow(n.toLong())\nfun Long.pow(n: Long) = toDouble().pow(n.toDouble()).toLong()\n\nfun main(args: Array) {\n main()\n pw.flush()\n}\n\nfun main() {\n val (A, B, C) = nextList()\n println(if (A.last() == B[0] && B.last() == C[0]) \"YES\" else \"NO\")\n}", "language": "Kotlin", "metadata": {"date": 1595729299, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p03729.html", "problem_id": "p03729", "resource_group": "medium_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/Kotlin/s606458646.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s606458646", "user_id": "u860789370"}, "prompt_components": {"gold_output": "YES\n", "input_to_evaluate": "import java.io.PrintWriter\nimport kotlin.math.pow\n\nfun next() = readLine()!!\nfun nextInt() = next().toInt()\nfun nextLong() = next().toLong()\nfun nextDouble() = next().toDouble()\nfun nextList() = next().split(\" \")\nfun nextIntList() = nextList().map(String::toInt)\nfun nextLongList() = nextList().map(String::toLong)\nfun nextDoubleList() = nextList().map(String::toDouble)\n\nval pw = PrintWriter(System.out)\nfun print(s: Any = \"\") = pw.print(s)\nfun println(s: Any = \"\") = pw.println(s)\n\nfun Iterable.join(separator: CharSequence = \", \", prefix: CharSequence = \"\", postfix: CharSequence = \"\") = joinToString(separator, prefix, postfix)\nfun Array.join(separator: CharSequence = \", \", prefix: CharSequence = \"\", postfix: CharSequence = \"\") = joinToString(separator, prefix, postfix)\nfun Int.pow(n: Int) = pow(n.toLong())\nfun Int.pow(n: Long) = toDouble().pow(n.toDouble()).toLong()\nfun Long.pow(n: Int) = pow(n.toLong())\nfun Long.pow(n: Long) = toDouble().pow(n.toDouble()).toLong()\n\nfun main(args: Array) {\n main()\n pw.flush()\n}\n\nfun main() {\n val (A, B, C) = nextList()\n println(if (A.last() == B[0] && B.last() == C[0]) \"YES\" else \"NO\")\n}", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1169, "cpu_time_ms": 161, "memory_kb": 35756}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s583189656", "group_id": "codeNet:p03729", "input_text": "fun main(args: Array) {\n val words = readLine()!!.split(\" \").map { it.toString() }.toMutableList()\n val a = words[0]\n val b= words[1]\n val c = words[2]\n\n if(a.last() == b.first() && b.last() == c.first()){\n println(\"YES\")\n }else{\n println(\"NO\")\n }\n}", "language": "Kotlin", "metadata": {"date": 1566144914, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03729.html", "problem_id": "p03729", "resource_group": "medium_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/Kotlin/s583189656.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s583189656", "user_id": "u482066761"}, "prompt_components": {"gold_output": "YES\n", "input_to_evaluate": "fun main(args: Array) {\n val words = readLine()!!.split(\" \").map { it.toString() }.toMutableList()\n val a = words[0]\n val b= words[1]\n val c = words[2]\n\n if(a.last() == b.first() && b.last() == c.first()){\n println(\"YES\")\n }else{\n println(\"NO\")\n }\n}", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 292, "cpu_time_ms": 243, "memory_kb": 36008}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s494802426", "group_id": "codeNet:p03731", "input_text": "import java.io.PrintWriter\nimport java.util.*\nimport java.math.*\nimport java.lang.*\nimport kotlin.comparisons.*\n\nval pw = PrintWriter(System.out)\nval MOD: Long = (1e+9 + 7).toLong()\n\nfun main(args: Array) {\n\tval (n, t) = readListOfInt()\n\tval tl = t.toLong()\n\n\tval tList = readListOfLong()\n\tvar total = 0L\n\tvar currentEnd = 0L\n\tfor(i in 0 until n) {\n\t\tval ct = tList[i]\n\t\ttotal += if(currentEnd <= ct) tl else tl - (currentEnd - ct) \n\t\tcurrentEnd = ct + tl\n\t}\n\tprintln(total)\n\tpw.flush()\n}\n\n/****** Declared Functions and Data Structures ******/\n// IO\nfun read() = readLine()!!\nfun readInt() = read().toInt()\nfun readLong() = read().toLong()\nfun readDouble() = read().toDouble()\nfun readListOfString() = read().split(\" \")\nfun readListOfInt() = readListOfString().map { it.toInt() }\nfun readListOfLong() = readListOfString().map { it.toLong() }\nfun readListOfDouble() = readListOfString().map { it.toDouble() }\n\nfun Double.format(digits: Int) = String.format(\"%.${digits}f\", this)\nfun Float.format(digits: Int) = String.format(\"%.${digits}f\", this)\n\nfun print(value: Any) { pw.print(value) }\nfun println(value : Any) { pw.println(value) }\n\n// Extensions\nfun List.toBuckets(): Map\n\t= this.groupBy { it }.mapValues { it.value.size }\n\nfun> List.upperBound(element: T, fromIndex: Int=0, toIndex: Int=this.size): Int {\n\tvar l = fromIndex\n\tvar r = toIndex\n\twhile(l < r) {\n\t\tval mid = (l+r) / 2\n\t\tif(element >= this[mid]) { \n\t\t\tl = mid + 1\n\t\t} else {\n\t\t\tr = mid\n\t\t}\n\t}\n\treturn l\n}\n\nfun> List.lowerBound(element: T, fromIndex: Int=0, toIndex: Int=this.size): Int {\n\tvar l = fromIndex\n\tvar r = toIndex\n\twhile(l < r) {\n\t\tval mid = (l+r) / 2\n\t\tif(element <= this[mid]) { \n\t\t\tr = mid\n\t\t} else {\n\t\t\tl = mid + 1\n\t\t}\n\t}\n\treturn r \n}\n\nfun Map.toMutableMap(): MutableMap = HashMap(this)\n\n// Util Functions\nfun Long.makeDivisors(): List {\n\tval divisors = mutableListOf()\n\tfor(i in 1L .. Math.sqrt(this.toDouble()).toLong()+1L) {\n\t\tif(this % i == 0L) {\n\t\t\tdivisors.add(i)\n\t\t\tif(i != this/i) {\n\t\t\t\tdivisors.add(this/i)\n\t\t\t}\n\t\t}\n\t}\n\treturn divisors.distinct().sorted()\n}\n\nfun Long.isPrime(): Boolean {\n\tif(this==1L) return false\n\tfor(i in 2L .. Math.sqrt(this.toDouble()).toLong() + 1L) {\n\t\tif(this % i == 0L && this != i) {\n\t\t\treturn false\n\t\t}\n\t}\n\treturn true\n}\n\n\nfun permutations(src: List): List> {\n\tif(src.size == 1) return listOf(src)\n\tval perms = mutableListOf>()\n\tval insertElement = src[0]\n\tpermutations(src.drop(1)).forEach { perm ->\n\t\tfor(i in 0..perm.size) {\n\t\t\tval newPerm = perm.toMutableList()\n\t\t\tnewPerm.add(i, insertElement)\n\t\t\tperms.add(newPerm.toList())\n\t\t}\n\t}\n\treturn perms\n}\n\n// return nCr, if you want nCr, please access v[n][r]\nfun combinations(n: Long): List> {\n\tval v = (0..n).map { (0..n).map{0L}.toMutableList() }.toMutableList()\n\tfor(i in 0 until v.size) {\n\t\tv[i][0] = 1L\n\t\tv[i][i] = 1L\n\t}\n\tfor(i in 0 until v.size) {\n\t\tfor(j in 1 until i) {\n\t\t\tv[i][j] = (v[i-1][j-1] + v[i-1][j]) % MOD\n\t\t}\n\t}\n\treturn v.map { it.toList() }.toList()\n}\n\nfun repeatedModPow(a: Long, n: Long, mod: Long): Long = \n\twhen {\n\t\tn == 1L -> a % mod\n\t\tn % 2L == 1L -> (a * repeatedModPow(a, n-1L, mod)) % mod\n\t\telse -> {\n\t\t\tval tmp = repeatedModPow(a, n / 2L, mod)\n\t\t\t(tmp * tmp) % mod\n\t\t}\n\t}\n\n// return nCr % MOD\nfun modnCkWithoutArray(n: Long, k: Long, mod: Long): Long {\n\tvar ret = 1L\n\tval min = Math.min(k, n-k)\n\t// まず分母の計算\n\tfor(i in n downTo (n - min + 1)) {\n\t\tret = ret * i % mod\n\t}\n\tfor(i in min downTo 1) {\n\t\tret = ret * repeatedModPow(i, (mod - 2L), mod) % mod\n\t}\n\treturn ret\n}\n\n// return nCr % MOD\nfun modnCk(n: Int, k: Int, mod: Long): Long {\n\tval factorials = Array(n+1) { 0L }.apply {\n\t\tthis[0] = 1L\n\t\tif(this.size > 1) this[1] = 1L\n\t}\n\tval inverses = Array(n+1) { 0L }.apply {\n\t\tthis[0] = 1L\n\t\tif(this.size > 1) this[1] = 1L\n\t}\n\tval factorialInverses = Array(n+1) { 0L }.apply {\n\t\tthis[0] = 1L\n\t\tif(this.size > 1) this[1] = 1L\n\t}\n\tfor(i in 2 .. n) {\n\t\tfactorials[i] = (factorials[i-1] * i.toLong() % mod)\n\t\tinverses[i] = (mod - inverses[mod.toInt() % i] * (mod / i.toLong()) % mod)\n\t\tfactorialInverses[i] = (factorialInverses[i-1] * inverses[i] % mod)\n\t}\n\n\treturn factorials[n] % mod * (factorialInverses[k] * factorialInverses[n-k] % mod) % mod\n}\n\n// should be a >= b\nfun gcd(a: Long, b: Long): Long = \n\tif(b == 0L) a else gcd(b, a % b)\n\n// shoud be a >= b\nfun lcm(a: Long, b: Long): Long = \n\ta / gcd(a, b) * b\n\nfun sumDigits(num_: Long): Long {\n\tvar num = num_\n\tvar rtn: Long = 0\n\twhile(num != 0.toLong()) {\n\t\tval tmp = num % 10\n\t\trtn += tmp\n\t\tnum /= 10\n\t}\n\treturn rtn\n}\n\nfun Double.isDecimal(): Boolean = ((this - Math.floor(this)) != 0.0)\n\n// Data Structures\n\nclass UnionFind(private val n: Int) {\n\tprivate val parent: Array = Array(n) { 0 }\n\tprivate val rank: Array = Array(n) { 0 }\n\tprivate val size: Array = Array(n) { 0 }\n\n\tinit {\n\t\tfor(i in 0 until n) {\n\t\t\tparent[i] = i\n\t\t\trank[i] = 1\n\t\t\tsize[i] = 1\n\t\t}\n\t}\n\n\tfun union(u: Int, v: Int) {\n\t\tvar x = root(u)\n\t\tvar y = root(v)\n\t\tif(x != y) {\n\t\t\tif(rank[y] < rank[x]) {\n\t\t\t\tval tmp = y \n\t\t\t\ty = x\n\t\t\t\tx = tmp \n\t\t\t}\n\t\t\tparent[x] = y\n\t\t\trank[y] += rank[x]\n\t\t\trank[x] = -1\n\t\t\tval totalSize = size[x] + size[y]\n\t\t\tsize[x] = totalSize\n\t\t\tsize[y] = totalSize\n\t\t}\n\t}\n\n\tfun root(u: Int): Int {\n\t\tvar x = u\n\t\twhile(parent[x] != x) {\n\t\t\tx = parent[x]\n\t\t}\n\t\treturn x \n\t}\n\n\tfun size(u: Int): Int = size[root(u)]\n}\n", "language": "Kotlin", "metadata": {"date": 1586915473, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03731.html", "problem_id": "p03731", "resource_group": "medium_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/Kotlin/s494802426.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s494802426", "user_id": "u026686258"}, "prompt_components": {"gold_output": "7\n", "input_to_evaluate": "import java.io.PrintWriter\nimport java.util.*\nimport java.math.*\nimport java.lang.*\nimport kotlin.comparisons.*\n\nval pw = PrintWriter(System.out)\nval MOD: Long = (1e+9 + 7).toLong()\n\nfun main(args: Array) {\n\tval (n, t) = readListOfInt()\n\tval tl = t.toLong()\n\n\tval tList = readListOfLong()\n\tvar total = 0L\n\tvar currentEnd = 0L\n\tfor(i in 0 until n) {\n\t\tval ct = tList[i]\n\t\ttotal += if(currentEnd <= ct) tl else tl - (currentEnd - ct) \n\t\tcurrentEnd = ct + tl\n\t}\n\tprintln(total)\n\tpw.flush()\n}\n\n/****** Declared Functions and Data Structures ******/\n// IO\nfun read() = readLine()!!\nfun readInt() = read().toInt()\nfun readLong() = read().toLong()\nfun readDouble() = read().toDouble()\nfun readListOfString() = read().split(\" \")\nfun readListOfInt() = readListOfString().map { it.toInt() }\nfun readListOfLong() = readListOfString().map { it.toLong() }\nfun readListOfDouble() = readListOfString().map { it.toDouble() }\n\nfun Double.format(digits: Int) = String.format(\"%.${digits}f\", this)\nfun Float.format(digits: Int) = String.format(\"%.${digits}f\", this)\n\nfun print(value: Any) { pw.print(value) }\nfun println(value : Any) { pw.println(value) }\n\n// Extensions\nfun List.toBuckets(): Map\n\t= this.groupBy { it }.mapValues { it.value.size }\n\nfun> List.upperBound(element: T, fromIndex: Int=0, toIndex: Int=this.size): Int {\n\tvar l = fromIndex\n\tvar r = toIndex\n\twhile(l < r) {\n\t\tval mid = (l+r) / 2\n\t\tif(element >= this[mid]) { \n\t\t\tl = mid + 1\n\t\t} else {\n\t\t\tr = mid\n\t\t}\n\t}\n\treturn l\n}\n\nfun> List.lowerBound(element: T, fromIndex: Int=0, toIndex: Int=this.size): Int {\n\tvar l = fromIndex\n\tvar r = toIndex\n\twhile(l < r) {\n\t\tval mid = (l+r) / 2\n\t\tif(element <= this[mid]) { \n\t\t\tr = mid\n\t\t} else {\n\t\t\tl = mid + 1\n\t\t}\n\t}\n\treturn r \n}\n\nfun Map.toMutableMap(): MutableMap = HashMap(this)\n\n// Util Functions\nfun Long.makeDivisors(): List {\n\tval divisors = mutableListOf()\n\tfor(i in 1L .. Math.sqrt(this.toDouble()).toLong()+1L) {\n\t\tif(this % i == 0L) {\n\t\t\tdivisors.add(i)\n\t\t\tif(i != this/i) {\n\t\t\t\tdivisors.add(this/i)\n\t\t\t}\n\t\t}\n\t}\n\treturn divisors.distinct().sorted()\n}\n\nfun Long.isPrime(): Boolean {\n\tif(this==1L) return false\n\tfor(i in 2L .. Math.sqrt(this.toDouble()).toLong() + 1L) {\n\t\tif(this % i == 0L && this != i) {\n\t\t\treturn false\n\t\t}\n\t}\n\treturn true\n}\n\n\nfun permutations(src: List): List> {\n\tif(src.size == 1) return listOf(src)\n\tval perms = mutableListOf>()\n\tval insertElement = src[0]\n\tpermutations(src.drop(1)).forEach { perm ->\n\t\tfor(i in 0..perm.size) {\n\t\t\tval newPerm = perm.toMutableList()\n\t\t\tnewPerm.add(i, insertElement)\n\t\t\tperms.add(newPerm.toList())\n\t\t}\n\t}\n\treturn perms\n}\n\n// return nCr, if you want nCr, please access v[n][r]\nfun combinations(n: Long): List> {\n\tval v = (0..n).map { (0..n).map{0L}.toMutableList() }.toMutableList()\n\tfor(i in 0 until v.size) {\n\t\tv[i][0] = 1L\n\t\tv[i][i] = 1L\n\t}\n\tfor(i in 0 until v.size) {\n\t\tfor(j in 1 until i) {\n\t\t\tv[i][j] = (v[i-1][j-1] + v[i-1][j]) % MOD\n\t\t}\n\t}\n\treturn v.map { it.toList() }.toList()\n}\n\nfun repeatedModPow(a: Long, n: Long, mod: Long): Long = \n\twhen {\n\t\tn == 1L -> a % mod\n\t\tn % 2L == 1L -> (a * repeatedModPow(a, n-1L, mod)) % mod\n\t\telse -> {\n\t\t\tval tmp = repeatedModPow(a, n / 2L, mod)\n\t\t\t(tmp * tmp) % mod\n\t\t}\n\t}\n\n// return nCr % MOD\nfun modnCkWithoutArray(n: Long, k: Long, mod: Long): Long {\n\tvar ret = 1L\n\tval min = Math.min(k, n-k)\n\t// まず分母の計算\n\tfor(i in n downTo (n - min + 1)) {\n\t\tret = ret * i % mod\n\t}\n\tfor(i in min downTo 1) {\n\t\tret = ret * repeatedModPow(i, (mod - 2L), mod) % mod\n\t}\n\treturn ret\n}\n\n// return nCr % MOD\nfun modnCk(n: Int, k: Int, mod: Long): Long {\n\tval factorials = Array(n+1) { 0L }.apply {\n\t\tthis[0] = 1L\n\t\tif(this.size > 1) this[1] = 1L\n\t}\n\tval inverses = Array(n+1) { 0L }.apply {\n\t\tthis[0] = 1L\n\t\tif(this.size > 1) this[1] = 1L\n\t}\n\tval factorialInverses = Array(n+1) { 0L }.apply {\n\t\tthis[0] = 1L\n\t\tif(this.size > 1) this[1] = 1L\n\t}\n\tfor(i in 2 .. n) {\n\t\tfactorials[i] = (factorials[i-1] * i.toLong() % mod)\n\t\tinverses[i] = (mod - inverses[mod.toInt() % i] * (mod / i.toLong()) % mod)\n\t\tfactorialInverses[i] = (factorialInverses[i-1] * inverses[i] % mod)\n\t}\n\n\treturn factorials[n] % mod * (factorialInverses[k] * factorialInverses[n-k] % mod) % mod\n}\n\n// should be a >= b\nfun gcd(a: Long, b: Long): Long = \n\tif(b == 0L) a else gcd(b, a % b)\n\n// shoud be a >= b\nfun lcm(a: Long, b: Long): Long = \n\ta / gcd(a, b) * b\n\nfun sumDigits(num_: Long): Long {\n\tvar num = num_\n\tvar rtn: Long = 0\n\twhile(num != 0.toLong()) {\n\t\tval tmp = num % 10\n\t\trtn += tmp\n\t\tnum /= 10\n\t}\n\treturn rtn\n}\n\nfun Double.isDecimal(): Boolean = ((this - Math.floor(this)) != 0.0)\n\n// Data Structures\n\nclass UnionFind(private val n: Int) {\n\tprivate val parent: Array = Array(n) { 0 }\n\tprivate val rank: Array = Array(n) { 0 }\n\tprivate val size: Array = Array(n) { 0 }\n\n\tinit {\n\t\tfor(i in 0 until n) {\n\t\t\tparent[i] = i\n\t\t\trank[i] = 1\n\t\t\tsize[i] = 1\n\t\t}\n\t}\n\n\tfun union(u: Int, v: Int) {\n\t\tvar x = root(u)\n\t\tvar y = root(v)\n\t\tif(x != y) {\n\t\t\tif(rank[y] < rank[x]) {\n\t\t\t\tval tmp = y \n\t\t\t\ty = x\n\t\t\t\tx = tmp \n\t\t\t}\n\t\t\tparent[x] = y\n\t\t\trank[y] += rank[x]\n\t\t\trank[x] = -1\n\t\t\tval totalSize = size[x] + size[y]\n\t\t\tsize[x] = totalSize\n\t\t\tsize[y] = totalSize\n\t\t}\n\t}\n\n\tfun root(u: Int): Int {\n\t\tvar x = u\n\t\twhile(parent[x] != x) {\n\t\t\tx = parent[x]\n\t\t}\n\t\treturn x \n\t}\n\n\tfun size(u: Int): Int = size[root(u)]\n}\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": "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 5402, "cpu_time_ms": 580, "memory_kb": 83148}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s103877973", "group_id": "codeNet:p03732", "input_text": "import java.io.PrintWriter\nimport java.util.*\nimport java.math.*\nimport java.lang.*\nimport kotlin.comparisons.*\n\nval pw = PrintWriter(System.out)\nval MOD: Long = (1e+9 + 7).toLong()\n\nfun main(args: Array) {\n\tval (n, bagWeight) = readListOfInt()\n\tval wv = Array(4) { mutableListOf() }\n\tval (fw, fv) = readListOfLong()\n\tval minW = fw.toInt()\n\twv[fw.toInt()- minW].add(fv)\n\tfor(i in 0 until n-1) {\n\t\tval (w, v) = readListOfLong()\n\t\twv[w.toInt()-minW].add(v)\n\t}\n\t\n\twv.forEach {\n\t\tit.sortDescending()\n\t\tit.add(0, 0)\n\t}\n\n\tvar ans = 0L\n\tfor(n0 in wv[0].indices) {\n\t\tfor(n1 in wv[1].indices) {\n\t\t\tfor(n2 in wv[2].indices) {\n\t\t\t\tfor(n3 in wv[3].indices) {\n\t\t\t\t\tval w0 = (minW + 0L) * n0\n\t\t\t\t\tval w1 = (minW + 1L) * n1\n\t\t\t\t\tval w2 = (minW + 2L) * n2\n\t\t\t\t\tval w3 = (minW + 3L) * n3\n\t\t\t\t\tif(w0 + w1 + w2 + w3 > bagWeight) continue \n\t\t\t\t\tval v0 = wv[0].subList(0, n0 + 1).sum()\n\t\t\t\t\tval v1 = wv[1].subList(0, n1 + 1).sum()\n\t\t\t\t\tval v2 = wv[2].subList(0, n2 + 1).sum()\n\t\t\t\t\tval v3 = wv[3].subList(0, n3 + 1).sum()\n\t\t\t\t\tans = Math.max(ans, v0 + v1 + v2 + v3)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tprintln(ans)\n\tpw.flush()\n}\n\n/****** Declared Functions and Data Structures ******/\n// IO\nfun read() = readLine()!!\nfun readInt() = read().toInt()\nfun readLong() = read().toLong()\nfun readDouble() = read().toDouble()\nfun readListOfString() = read().split(\" \")\nfun readListOfInt() = readListOfString().map { it.toInt() }\nfun readListOfLong() = readListOfString().map { it.toLong() }\nfun readListOfDouble() = readListOfString().map { it.toDouble() }\n\nfun Double.format(digits: Int) = String.format(\"%.${digits}f\", this)\nfun Float.format(digits: Int) = String.format(\"%.${digits}f\", this)\n\nfun print(value: Any) { pw.print(value) }\nfun println(value : Any) { pw.println(value) }\n\n// Extensions\nfun List.toBuckets(): Map\n\t= this.groupBy { it }.mapValues { it.value.size }\n\nfun> List.upperBound(element: T, fromIndex: Int=0, toIndex: Int=this.size): Int {\n\tvar l = fromIndex\n\tvar r = toIndex\n\twhile(l < r) {\n\t\tval mid = (l+r) / 2\n\t\tif(element >= this[mid]) { \n\t\t\tl = mid + 1\n\t\t} else {\n\t\t\tr = mid\n\t\t}\n\t}\n\treturn l\n}\n\nfun> List.lowerBound(element: T, fromIndex: Int=0, toIndex: Int=this.size): Int {\n\tvar l = fromIndex\n\tvar r = toIndex\n\twhile(l < r) {\n\t\tval mid = (l+r) / 2\n\t\tif(element <= this[mid]) { \n\t\t\tr = mid\n\t\t} else {\n\t\t\tl = mid + 1\n\t\t}\n\t}\n\treturn r \n}\n\nfun Map.toMutableMap(): MutableMap = HashMap(this)\n\n// Util Functions\nfun Long.makeDivisors(): List {\n\tval divisors = mutableListOf()\n\tfor(i in 1L .. Math.sqrt(this.toDouble()).toLong()+1L) {\n\t\tif(this % i == 0L) {\n\t\t\tdivisors.add(i)\n\t\t\tif(i != this/i) {\n\t\t\t\tdivisors.add(this/i)\n\t\t\t}\n\t\t}\n\t}\n\treturn divisors.distinct().sorted()\n}\n\nfun Long.isPrime(): Boolean {\n\tif(this==1L) return false\n\tfor(i in 2L .. Math.sqrt(this.toDouble()).toLong() + 1L) {\n\t\tif(this % i == 0L && this != i) {\n\t\t\treturn false\n\t\t}\n\t}\n\treturn true\n}\n\n\nfun permutations(src: List): List> {\n\tif(src.size == 1) return listOf(src)\n\tval perms = mutableListOf>()\n\tval insertElement = src[0]\n\tpermutations(src.drop(1)).forEach { perm ->\n\t\tfor(i in 0..perm.size) {\n\t\t\tval newPerm = perm.toMutableList()\n\t\t\tnewPerm.add(i, insertElement)\n\t\t\tperms.add(newPerm.toList())\n\t\t}\n\t}\n\treturn perms\n}\n\n// return nCr, if you want nCr, please access v[n][r]\nfun combinations(n: Long): List> {\n\tval v = (0..n).map { (0..n).map{0L}.toMutableList() }.toMutableList()\n\tfor(i in 0 until v.size) {\n\t\tv[i][0] = 1L\n\t\tv[i][i] = 1L\n\t}\n\tfor(i in 0 until v.size) {\n\t\tfor(j in 1 until i) {\n\t\t\tv[i][j] = (v[i-1][j-1] + v[i-1][j]) % MOD\n\t\t}\n\t}\n\treturn v.map { it.toList() }.toList()\n}\n\nfun repeatedModPow(a: Long, n: Long, mod: Long): Long = \n\twhen {\n\t\tn == 1L -> a % mod\n\t\tn % 2L == 1L -> (a * repeatedModPow(a, n-1L, mod)) % mod\n\t\telse -> {\n\t\t\tval tmp = repeatedModPow(a, n / 2L, mod)\n\t\t\t(tmp * tmp) % mod\n\t\t}\n\t}\n\n// return nCr % MOD\nfun modnCkWithoutArray(n: Long, k: Long, mod: Long): Long {\n\tvar ret = 1L\n\tval min = Math.min(k, n-k)\n\t// まず分母の計算\n\tfor(i in n downTo (n - min + 1)) {\n\t\tret = ret * i % mod\n\t}\n\tfor(i in min downTo 1) {\n\t\tret = ret * repeatedModPow(i, (mod - 2L), mod) % mod\n\t}\n\treturn ret\n}\n\n// return nCr % MOD\nfun modnCk(n: Int, k: Int, mod: Long): Long {\n\tval factorials = Array(n+1) { 0L }.apply {\n\t\tthis[0] = 1L\n\t\tif(this.size > 1) this[1] = 1L\n\t}\n\tval inverses = Array(n+1) { 0L }.apply {\n\t\tthis[0] = 1L\n\t\tif(this.size > 1) this[1] = 1L\n\t}\n\tval factorialInverses = Array(n+1) { 0L }.apply {\n\t\tthis[0] = 1L\n\t\tif(this.size > 1) this[1] = 1L\n\t}\n\tfor(i in 2 .. n) {\n\t\tfactorials[i] = (factorials[i-1] * i.toLong() % mod)\n\t\tinverses[i] = (mod - inverses[mod.toInt() % i] * (mod / i.toLong()) % mod)\n\t\tfactorialInverses[i] = (factorialInverses[i-1] * inverses[i] % mod)\n\t}\n\n\treturn factorials[n] % mod * (factorialInverses[k] * factorialInverses[n-k] % mod) % mod\n}\n\n// should be a >= b\nfun gcd(a: Long, b: Long): Long = \n\tif(b == 0L) a else gcd(b, a % b)\n\n// shoud be a >= b\nfun lcm(a: Long, b: Long): Long = \n\ta / gcd(a, b) * b\n\nfun sumDigits(num_: Long): Long {\n\tvar num = num_\n\tvar rtn: Long = 0\n\twhile(num != 0.toLong()) {\n\t\tval tmp = num % 10\n\t\trtn += tmp\n\t\tnum /= 10\n\t}\n\treturn rtn\n}\n\nfun Double.isDecimal(): Boolean = ((this - Math.floor(this)) != 0.0)\n\n// Data Structures\n\nclass UnionFind(private val n: Int) {\n\tprivate val parent: Array = Array(n) { 0 }\n\tprivate val rank: Array = Array(n) { 0 }\n\tprivate val size: Array = Array(n) { 0 }\n\n\tinit {\n\t\tfor(i in 0 until n) {\n\t\t\tparent[i] = i\n\t\t\trank[i] = 1\n\t\t\tsize[i] = 1\n\t\t}\n\t}\n\n\tfun union(u: Int, v: Int) {\n\t\tvar x = root(u)\n\t\tvar y = root(v)\n\t\tif(x != y) {\n\t\t\tif(rank[y] < rank[x]) {\n\t\t\t\tval tmp = y \n\t\t\t\ty = x\n\t\t\t\tx = tmp \n\t\t\t}\n\t\t\tparent[x] = y\n\t\t\trank[y] += rank[x]\n\t\t\trank[x] = -1\n\t\t\tval totalSize = size[x] + size[y]\n\t\t\tsize[x] = totalSize\n\t\t\tsize[y] = totalSize\n\t\t}\n\t}\n\n\tfun root(u: Int): Int {\n\t\tvar x = u\n\t\twhile(parent[x] != x) {\n\t\t\tx = parent[x]\n\t\t}\n\t\treturn x \n\t}\n\n\tfun size(u: Int): Int = size[root(u)]\n}\n", "language": "Kotlin", "metadata": {"date": 1586920614, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03732.html", "problem_id": "p03732", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03732/input.txt", "sample_output_relpath": "derived/input_output/data/p03732/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03732/Kotlin/s103877973.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s103877973", "user_id": "u026686258"}, "prompt_components": {"gold_output": "11\n", "input_to_evaluate": "import java.io.PrintWriter\nimport java.util.*\nimport java.math.*\nimport java.lang.*\nimport kotlin.comparisons.*\n\nval pw = PrintWriter(System.out)\nval MOD: Long = (1e+9 + 7).toLong()\n\nfun main(args: Array) {\n\tval (n, bagWeight) = readListOfInt()\n\tval wv = Array(4) { mutableListOf() }\n\tval (fw, fv) = readListOfLong()\n\tval minW = fw.toInt()\n\twv[fw.toInt()- minW].add(fv)\n\tfor(i in 0 until n-1) {\n\t\tval (w, v) = readListOfLong()\n\t\twv[w.toInt()-minW].add(v)\n\t}\n\t\n\twv.forEach {\n\t\tit.sortDescending()\n\t\tit.add(0, 0)\n\t}\n\n\tvar ans = 0L\n\tfor(n0 in wv[0].indices) {\n\t\tfor(n1 in wv[1].indices) {\n\t\t\tfor(n2 in wv[2].indices) {\n\t\t\t\tfor(n3 in wv[3].indices) {\n\t\t\t\t\tval w0 = (minW + 0L) * n0\n\t\t\t\t\tval w1 = (minW + 1L) * n1\n\t\t\t\t\tval w2 = (minW + 2L) * n2\n\t\t\t\t\tval w3 = (minW + 3L) * n3\n\t\t\t\t\tif(w0 + w1 + w2 + w3 > bagWeight) continue \n\t\t\t\t\tval v0 = wv[0].subList(0, n0 + 1).sum()\n\t\t\t\t\tval v1 = wv[1].subList(0, n1 + 1).sum()\n\t\t\t\t\tval v2 = wv[2].subList(0, n2 + 1).sum()\n\t\t\t\t\tval v3 = wv[3].subList(0, n3 + 1).sum()\n\t\t\t\t\tans = Math.max(ans, v0 + v1 + v2 + v3)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tprintln(ans)\n\tpw.flush()\n}\n\n/****** Declared Functions and Data Structures ******/\n// IO\nfun read() = readLine()!!\nfun readInt() = read().toInt()\nfun readLong() = read().toLong()\nfun readDouble() = read().toDouble()\nfun readListOfString() = read().split(\" \")\nfun readListOfInt() = readListOfString().map { it.toInt() }\nfun readListOfLong() = readListOfString().map { it.toLong() }\nfun readListOfDouble() = readListOfString().map { it.toDouble() }\n\nfun Double.format(digits: Int) = String.format(\"%.${digits}f\", this)\nfun Float.format(digits: Int) = String.format(\"%.${digits}f\", this)\n\nfun print(value: Any) { pw.print(value) }\nfun println(value : Any) { pw.println(value) }\n\n// Extensions\nfun List.toBuckets(): Map\n\t= this.groupBy { it }.mapValues { it.value.size }\n\nfun> List.upperBound(element: T, fromIndex: Int=0, toIndex: Int=this.size): Int {\n\tvar l = fromIndex\n\tvar r = toIndex\n\twhile(l < r) {\n\t\tval mid = (l+r) / 2\n\t\tif(element >= this[mid]) { \n\t\t\tl = mid + 1\n\t\t} else {\n\t\t\tr = mid\n\t\t}\n\t}\n\treturn l\n}\n\nfun> List.lowerBound(element: T, fromIndex: Int=0, toIndex: Int=this.size): Int {\n\tvar l = fromIndex\n\tvar r = toIndex\n\twhile(l < r) {\n\t\tval mid = (l+r) / 2\n\t\tif(element <= this[mid]) { \n\t\t\tr = mid\n\t\t} else {\n\t\t\tl = mid + 1\n\t\t}\n\t}\n\treturn r \n}\n\nfun Map.toMutableMap(): MutableMap = HashMap(this)\n\n// Util Functions\nfun Long.makeDivisors(): List {\n\tval divisors = mutableListOf()\n\tfor(i in 1L .. Math.sqrt(this.toDouble()).toLong()+1L) {\n\t\tif(this % i == 0L) {\n\t\t\tdivisors.add(i)\n\t\t\tif(i != this/i) {\n\t\t\t\tdivisors.add(this/i)\n\t\t\t}\n\t\t}\n\t}\n\treturn divisors.distinct().sorted()\n}\n\nfun Long.isPrime(): Boolean {\n\tif(this==1L) return false\n\tfor(i in 2L .. Math.sqrt(this.toDouble()).toLong() + 1L) {\n\t\tif(this % i == 0L && this != i) {\n\t\t\treturn false\n\t\t}\n\t}\n\treturn true\n}\n\n\nfun permutations(src: List): List> {\n\tif(src.size == 1) return listOf(src)\n\tval perms = mutableListOf>()\n\tval insertElement = src[0]\n\tpermutations(src.drop(1)).forEach { perm ->\n\t\tfor(i in 0..perm.size) {\n\t\t\tval newPerm = perm.toMutableList()\n\t\t\tnewPerm.add(i, insertElement)\n\t\t\tperms.add(newPerm.toList())\n\t\t}\n\t}\n\treturn perms\n}\n\n// return nCr, if you want nCr, please access v[n][r]\nfun combinations(n: Long): List> {\n\tval v = (0..n).map { (0..n).map{0L}.toMutableList() }.toMutableList()\n\tfor(i in 0 until v.size) {\n\t\tv[i][0] = 1L\n\t\tv[i][i] = 1L\n\t}\n\tfor(i in 0 until v.size) {\n\t\tfor(j in 1 until i) {\n\t\t\tv[i][j] = (v[i-1][j-1] + v[i-1][j]) % MOD\n\t\t}\n\t}\n\treturn v.map { it.toList() }.toList()\n}\n\nfun repeatedModPow(a: Long, n: Long, mod: Long): Long = \n\twhen {\n\t\tn == 1L -> a % mod\n\t\tn % 2L == 1L -> (a * repeatedModPow(a, n-1L, mod)) % mod\n\t\telse -> {\n\t\t\tval tmp = repeatedModPow(a, n / 2L, mod)\n\t\t\t(tmp * tmp) % mod\n\t\t}\n\t}\n\n// return nCr % MOD\nfun modnCkWithoutArray(n: Long, k: Long, mod: Long): Long {\n\tvar ret = 1L\n\tval min = Math.min(k, n-k)\n\t// まず分母の計算\n\tfor(i in n downTo (n - min + 1)) {\n\t\tret = ret * i % mod\n\t}\n\tfor(i in min downTo 1) {\n\t\tret = ret * repeatedModPow(i, (mod - 2L), mod) % mod\n\t}\n\treturn ret\n}\n\n// return nCr % MOD\nfun modnCk(n: Int, k: Int, mod: Long): Long {\n\tval factorials = Array(n+1) { 0L }.apply {\n\t\tthis[0] = 1L\n\t\tif(this.size > 1) this[1] = 1L\n\t}\n\tval inverses = Array(n+1) { 0L }.apply {\n\t\tthis[0] = 1L\n\t\tif(this.size > 1) this[1] = 1L\n\t}\n\tval factorialInverses = Array(n+1) { 0L }.apply {\n\t\tthis[0] = 1L\n\t\tif(this.size > 1) this[1] = 1L\n\t}\n\tfor(i in 2 .. n) {\n\t\tfactorials[i] = (factorials[i-1] * i.toLong() % mod)\n\t\tinverses[i] = (mod - inverses[mod.toInt() % i] * (mod / i.toLong()) % mod)\n\t\tfactorialInverses[i] = (factorialInverses[i-1] * inverses[i] % mod)\n\t}\n\n\treturn factorials[n] % mod * (factorialInverses[k] * factorialInverses[n-k] % mod) % mod\n}\n\n// should be a >= b\nfun gcd(a: Long, b: Long): Long = \n\tif(b == 0L) a else gcd(b, a % b)\n\n// shoud be a >= b\nfun lcm(a: Long, b: Long): Long = \n\ta / gcd(a, b) * b\n\nfun sumDigits(num_: Long): Long {\n\tvar num = num_\n\tvar rtn: Long = 0\n\twhile(num != 0.toLong()) {\n\t\tval tmp = num % 10\n\t\trtn += tmp\n\t\tnum /= 10\n\t}\n\treturn rtn\n}\n\nfun Double.isDecimal(): Boolean = ((this - Math.floor(this)) != 0.0)\n\n// Data Structures\n\nclass UnionFind(private val n: Int) {\n\tprivate val parent: Array = Array(n) { 0 }\n\tprivate val rank: Array = Array(n) { 0 }\n\tprivate val size: Array = Array(n) { 0 }\n\n\tinit {\n\t\tfor(i in 0 until n) {\n\t\t\tparent[i] = i\n\t\t\trank[i] = 1\n\t\t\tsize[i] = 1\n\t\t}\n\t}\n\n\tfun union(u: Int, v: Int) {\n\t\tvar x = root(u)\n\t\tvar y = root(v)\n\t\tif(x != y) {\n\t\t\tif(rank[y] < rank[x]) {\n\t\t\t\tval tmp = y \n\t\t\t\ty = x\n\t\t\t\tx = tmp \n\t\t\t}\n\t\t\tparent[x] = y\n\t\t\trank[y] += rank[x]\n\t\t\trank[x] = -1\n\t\t\tval totalSize = size[x] + size[y]\n\t\t\tsize[x] = totalSize\n\t\t\tsize[y] = totalSize\n\t\t}\n\t}\n\n\tfun root(u: Int): Int {\n\t\tvar x = u\n\t\twhile(parent[x] != x) {\n\t\t\tx = parent[x]\n\t\t}\n\t\treturn x \n\t}\n\n\tfun size(u: Int): Int = size[root(u)]\n}\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nYou have N items and a bag of strength W.\nThe i-th item has a weight of w_i and a value of v_i.\n\nYou will select some of the items and put them in the bag.\nHere, the total weight of the selected items needs to be at most W.\n\nYour objective is to maximize the total value of the selected items.\n\nConstraints\n\n1 ≤ N ≤ 100\n\n1 ≤ W ≤ 10^9\n\n1 ≤ w_i ≤ 10^9\n\nFor each i = 2,3,...,N, w_1 ≤ w_i ≤ w_1 + 3.\n\n1 ≤ v_i ≤ 10^7\n\nW, each w_i and v_i are integers.\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 total value of the selected items.\n\nSample Input 1\n\n4 6\n2 1\n3 4\n4 10\n3 4\n\nSample Output 1\n\n11\n\nThe first and third items should be selected.\n\nSample Input 2\n\n4 6\n2 1\n3 7\n4 10\n3 6\n\nSample Output 2\n\n13\n\nThe second and fourth items should be selected.\n\nSample Input 3\n\n4 10\n1 100\n1 100\n1 100\n1 100\n\nSample Output 3\n\n400\n\nYou can take everything.\n\nSample Input 4\n\n4 1\n10 100\n10 100\n10 100\n10 100\n\nSample Output 4\n\n0\n\nYou can take nothing.", "sample_input": "4 6\n2 1\n3 4\n4 10\n3 4\n"}, "reference_outputs": ["11\n"], "source_document_id": "p03732", "source_text": "Score : 400 points\n\nProblem Statement\n\nYou have N items and a bag of strength W.\nThe i-th item has a weight of w_i and a value of v_i.\n\nYou will select some of the items and put them in the bag.\nHere, the total weight of the selected items needs to be at most W.\n\nYour objective is to maximize the total value of the selected items.\n\nConstraints\n\n1 ≤ N ≤ 100\n\n1 ≤ W ≤ 10^9\n\n1 ≤ w_i ≤ 10^9\n\nFor each i = 2,3,...,N, w_1 ≤ w_i ≤ w_1 + 3.\n\n1 ≤ v_i ≤ 10^7\n\nW, each w_i and v_i are integers.\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 total value of the selected items.\n\nSample Input 1\n\n4 6\n2 1\n3 4\n4 10\n3 4\n\nSample Output 1\n\n11\n\nThe first and third items should be selected.\n\nSample Input 2\n\n4 6\n2 1\n3 7\n4 10\n3 6\n\nSample Output 2\n\n13\n\nThe second and fourth items should be selected.\n\nSample Input 3\n\n4 10\n1 100\n1 100\n1 100\n1 100\n\nSample Output 3\n\n400\n\nYou can take everything.\n\nSample Input 4\n\n4 1\n10 100\n10 100\n10 100\n10 100\n\nSample Output 4\n\n0\n\nYou can take nothing.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 6009, "cpu_time_ms": 332, "memory_kb": 46640}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s178226446", "group_id": "codeNet:p03732", "input_text": "import java.io.IOException\nfun main(args: Array) {\n val fs = FastScanner()\n val N = fs.nextInt()\n val W = fs.nextLong()\n val w = IntArray(N)\n val v = LongArray(N)\n\n for (i in 0 until N) {\n w[i] = fs.nextInt()\n v[i] = fs.nextLong()\n }\n val w0 = w[0]\n for (i in 0 until N) {\n w[i] -= w0\n }\n\n val dp = Array(N + 1) { Array(N +1) { LongArray( N * 3 + 1) { 0 }} }\n\n for (i in 0 until N) {\n for (k in 0 until N) {\n for (j in 0..(N * 3)) {\n if (j - w[i] >= 0) {\n dp[i+1][k+1][j] = Math.max(dp[i][k][j - w[i]] + v[i], dp[i][k+1][j])\n } else {\n dp[i+1][k+1][j] = dp[i][k+1][j]\n }\n }\n }\n }\n\n var max = 0L\n for (i in 0..N) {\n for (j in 0..(N * 3)) {\n if (w0 * i + j <= W) {\n max = Math.max(\n dp[N][i][j], max\n )\n }\n }\n }\n println(max)\n}\n\ninternal class FastScanner {\n private val `in` = System.`in`\n private val buffer = ByteArray(1024)\n private var ptr = 0\n private var buflen = 0\n private fun hasNextByte(): Boolean {\n if (ptr < buflen) {\n return true\n } else {\n ptr = 0\n try {\n buflen = `in`.read(buffer)\n } catch (e: IOException) {\n e.printStackTrace()\n }\n\n if (buflen <= 0) {\n return false\n }\n }\n return true\n }\n\n private fun readByte(): Int {\n return if (hasNextByte()) buffer[ptr++].toInt() else -1\n }\n\n private fun isPrintableChar(c: Int): Boolean {\n return 33 <= c && c <= 126\n }\n\n private fun skipUnprintable() {\n while (hasNextByte() && !isPrintableChar(buffer[ptr].toInt())) ptr++\n }\n\n operator fun hasNext(): Boolean {\n skipUnprintable()\n return hasNextByte()\n }\n\n operator fun next(): String {\n if (!hasNext()) return \"\"\n val sb = StringBuilder()\n var b = readByte()\n while (isPrintableChar(b)) {\n sb.appendCodePoint(b)\n b = readByte()\n }\n return sb.toString()\n }\n\n fun nextLong(): Long {\n if (!hasNext()) return -1\n var n: Long = 0\n var minus = false\n var b = readByte()\n if (b == '-'.toInt()) {\n minus = true\n b = readByte()\n }\n if (b < '0'.toInt() || '9'.toInt() < b) {\n throw NumberFormatException()\n }\n while (true) {\n if ('0'.toInt() <= b && b <= '9'.toInt()) {\n n *= 10\n n += (b - '0'.toInt()).toLong()\n } else return if (b == -1 || !isPrintableChar(b)) {\n if (minus) -n else n\n } else {\n throw NumberFormatException()\n }\n b = readByte()\n }\n }\n\n fun nextInt(): Int {\n val set = hashSetOf()\n set.add('3')\n set.clear()\n\n if (!hasNext()) return -1\n var n: Int = 0\n var minus = false\n var b = readByte()\n if (b == '-'.toInt()) {\n minus = true\n b = readByte()\n }\n if (b < '0'.toInt() || '9'.toInt() < b) {\n throw NumberFormatException()\n }\n while (true) {\n if ('0'.toInt() <= b && b <= '9'.toInt()) {\n n *= 10\n n += (b - '0'.toInt()).toInt()\n } else return if (b == -1 || !isPrintableChar(b)) {\n if (minus) -n else n\n } else {\n throw NumberFormatException()\n }\n b = readByte()\n }\n }\n}\n\n\n\n\n/*\nfun main(args: Array) {\n val fs = FastScanner()\n val N = fs.nextInt()\n val W = fs.nextLong()\n val w = IntArray(N)\n val v = LongArray(N)\n\n for (i in 0 until N) {\n w[i] = fs.nextInt()\n v[i] = fs.nextLong()\n }\n\n val items = listOf(mutableListOf(0), mutableListOf(0), mutableListOf(0), mutableListOf(0))\n val w1 = w[0]\n for (i in 0 until N) {\n w[i] -= w1\n items[w[i] % 4].add(v[i])\n }\n\n items.forEach {\n it.sort()\n for (i in 0 until it.size - 1) {\n it[i + 1] += it[i]\n }\n }\n val size0 = items[0].size - 1\n val size1 = items[1].size - 1\n val size2 = items[2].size - 1\n val size3 = items[3].size - 1\n\n var max = 0L\n val longW1 = w1.toLong()\n for (i0 in 0 .. size0) {\n for (i1 in 0 .. size1) {\n for (i2 in 0 .. size2) {\n for (i3 in 0 .. size3) {\n val total = i0 + i1 + i2 + i3\n if (total <= N && total * longW1 + i1 + 2L * i2 + 3L * i3 <= W) {\n max = Math.max(max,\n items[0][size0] - items[0][size0 - i0] +\n items[1][size1] - items[1][size1 - i1] +\n items[2][size2] - items[2][size2 - i2] +\n items[3][size3] - items[3][size3 - i3]\n )\n\n }\n }\n }\n }\n }\n println(max)\n}\n */\n\n", "language": "Kotlin", "metadata": {"date": 1569811557, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03732.html", "problem_id": "p03732", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03732/input.txt", "sample_output_relpath": "derived/input_output/data/p03732/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03732/Kotlin/s178226446.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s178226446", "user_id": "u861095163"}, "prompt_components": {"gold_output": "11\n", "input_to_evaluate": "import java.io.IOException\nfun main(args: Array) {\n val fs = FastScanner()\n val N = fs.nextInt()\n val W = fs.nextLong()\n val w = IntArray(N)\n val v = LongArray(N)\n\n for (i in 0 until N) {\n w[i] = fs.nextInt()\n v[i] = fs.nextLong()\n }\n val w0 = w[0]\n for (i in 0 until N) {\n w[i] -= w0\n }\n\n val dp = Array(N + 1) { Array(N +1) { LongArray( N * 3 + 1) { 0 }} }\n\n for (i in 0 until N) {\n for (k in 0 until N) {\n for (j in 0..(N * 3)) {\n if (j - w[i] >= 0) {\n dp[i+1][k+1][j] = Math.max(dp[i][k][j - w[i]] + v[i], dp[i][k+1][j])\n } else {\n dp[i+1][k+1][j] = dp[i][k+1][j]\n }\n }\n }\n }\n\n var max = 0L\n for (i in 0..N) {\n for (j in 0..(N * 3)) {\n if (w0 * i + j <= W) {\n max = Math.max(\n dp[N][i][j], max\n )\n }\n }\n }\n println(max)\n}\n\ninternal class FastScanner {\n private val `in` = System.`in`\n private val buffer = ByteArray(1024)\n private var ptr = 0\n private var buflen = 0\n private fun hasNextByte(): Boolean {\n if (ptr < buflen) {\n return true\n } else {\n ptr = 0\n try {\n buflen = `in`.read(buffer)\n } catch (e: IOException) {\n e.printStackTrace()\n }\n\n if (buflen <= 0) {\n return false\n }\n }\n return true\n }\n\n private fun readByte(): Int {\n return if (hasNextByte()) buffer[ptr++].toInt() else -1\n }\n\n private fun isPrintableChar(c: Int): Boolean {\n return 33 <= c && c <= 126\n }\n\n private fun skipUnprintable() {\n while (hasNextByte() && !isPrintableChar(buffer[ptr].toInt())) ptr++\n }\n\n operator fun hasNext(): Boolean {\n skipUnprintable()\n return hasNextByte()\n }\n\n operator fun next(): String {\n if (!hasNext()) return \"\"\n val sb = StringBuilder()\n var b = readByte()\n while (isPrintableChar(b)) {\n sb.appendCodePoint(b)\n b = readByte()\n }\n return sb.toString()\n }\n\n fun nextLong(): Long {\n if (!hasNext()) return -1\n var n: Long = 0\n var minus = false\n var b = readByte()\n if (b == '-'.toInt()) {\n minus = true\n b = readByte()\n }\n if (b < '0'.toInt() || '9'.toInt() < b) {\n throw NumberFormatException()\n }\n while (true) {\n if ('0'.toInt() <= b && b <= '9'.toInt()) {\n n *= 10\n n += (b - '0'.toInt()).toLong()\n } else return if (b == -1 || !isPrintableChar(b)) {\n if (minus) -n else n\n } else {\n throw NumberFormatException()\n }\n b = readByte()\n }\n }\n\n fun nextInt(): Int {\n val set = hashSetOf()\n set.add('3')\n set.clear()\n\n if (!hasNext()) return -1\n var n: Int = 0\n var minus = false\n var b = readByte()\n if (b == '-'.toInt()) {\n minus = true\n b = readByte()\n }\n if (b < '0'.toInt() || '9'.toInt() < b) {\n throw NumberFormatException()\n }\n while (true) {\n if ('0'.toInt() <= b && b <= '9'.toInt()) {\n n *= 10\n n += (b - '0'.toInt()).toInt()\n } else return if (b == -1 || !isPrintableChar(b)) {\n if (minus) -n else n\n } else {\n throw NumberFormatException()\n }\n b = readByte()\n }\n }\n}\n\n\n\n\n/*\nfun main(args: Array) {\n val fs = FastScanner()\n val N = fs.nextInt()\n val W = fs.nextLong()\n val w = IntArray(N)\n val v = LongArray(N)\n\n for (i in 0 until N) {\n w[i] = fs.nextInt()\n v[i] = fs.nextLong()\n }\n\n val items = listOf(mutableListOf(0), mutableListOf(0), mutableListOf(0), mutableListOf(0))\n val w1 = w[0]\n for (i in 0 until N) {\n w[i] -= w1\n items[w[i] % 4].add(v[i])\n }\n\n items.forEach {\n it.sort()\n for (i in 0 until it.size - 1) {\n it[i + 1] += it[i]\n }\n }\n val size0 = items[0].size - 1\n val size1 = items[1].size - 1\n val size2 = items[2].size - 1\n val size3 = items[3].size - 1\n\n var max = 0L\n val longW1 = w1.toLong()\n for (i0 in 0 .. size0) {\n for (i1 in 0 .. size1) {\n for (i2 in 0 .. size2) {\n for (i3 in 0 .. size3) {\n val total = i0 + i1 + i2 + i3\n if (total <= N && total * longW1 + i1 + 2L * i2 + 3L * i3 <= W) {\n max = Math.max(max,\n items[0][size0] - items[0][size0 - i0] +\n items[1][size1] - items[1][size1 - i1] +\n items[2][size2] - items[2][size2 - i2] +\n items[3][size3] - items[3][size3 - i3]\n )\n\n }\n }\n }\n }\n }\n println(max)\n}\n */\n\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nYou have N items and a bag of strength W.\nThe i-th item has a weight of w_i and a value of v_i.\n\nYou will select some of the items and put them in the bag.\nHere, the total weight of the selected items needs to be at most W.\n\nYour objective is to maximize the total value of the selected items.\n\nConstraints\n\n1 ≤ N ≤ 100\n\n1 ≤ W ≤ 10^9\n\n1 ≤ w_i ≤ 10^9\n\nFor each i = 2,3,...,N, w_1 ≤ w_i ≤ w_1 + 3.\n\n1 ≤ v_i ≤ 10^7\n\nW, each w_i and v_i are integers.\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 total value of the selected items.\n\nSample Input 1\n\n4 6\n2 1\n3 4\n4 10\n3 4\n\nSample Output 1\n\n11\n\nThe first and third items should be selected.\n\nSample Input 2\n\n4 6\n2 1\n3 7\n4 10\n3 6\n\nSample Output 2\n\n13\n\nThe second and fourth items should be selected.\n\nSample Input 3\n\n4 10\n1 100\n1 100\n1 100\n1 100\n\nSample Output 3\n\n400\n\nYou can take everything.\n\nSample Input 4\n\n4 1\n10 100\n10 100\n10 100\n10 100\n\nSample Output 4\n\n0\n\nYou can take nothing.", "sample_input": "4 6\n2 1\n3 4\n4 10\n3 4\n"}, "reference_outputs": ["11\n"], "source_document_id": "p03732", "source_text": "Score : 400 points\n\nProblem Statement\n\nYou have N items and a bag of strength W.\nThe i-th item has a weight of w_i and a value of v_i.\n\nYou will select some of the items and put them in the bag.\nHere, the total weight of the selected items needs to be at most W.\n\nYour objective is to maximize the total value of the selected items.\n\nConstraints\n\n1 ≤ N ≤ 100\n\n1 ≤ W ≤ 10^9\n\n1 ≤ w_i ≤ 10^9\n\nFor each i = 2,3,...,N, w_1 ≤ w_i ≤ w_1 + 3.\n\n1 ≤ v_i ≤ 10^7\n\nW, each w_i and v_i are integers.\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 total value of the selected items.\n\nSample Input 1\n\n4 6\n2 1\n3 4\n4 10\n3 4\n\nSample Output 1\n\n11\n\nThe first and third items should be selected.\n\nSample Input 2\n\n4 6\n2 1\n3 7\n4 10\n3 6\n\nSample Output 2\n\n13\n\nThe second and fourth items should be selected.\n\nSample Input 3\n\n4 10\n1 100\n1 100\n1 100\n1 100\n\nSample Output 3\n\n400\n\nYou can take everything.\n\nSample Input 4\n\n4 1\n10 100\n10 100\n10 100\n10 100\n\nSample Output 4\n\n0\n\nYou can take nothing.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 5292, "cpu_time_ms": 354, "memory_kb": 66760}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s202207913", "group_id": "codeNet:p03734", "input_text": "import java.io.BufferedReader\nimport java.io.InputStream\nimport java.io.InputStreamReader\nimport java.io.PrintWriter\nimport java.lang.StringBuilder\nimport java.util.*\n\nfun PrintWriter.solve(sc: FastScanner) {\n val n = sc.nextInt()\n val s = sc.nextInt()\n val w = Array(n) { 0 }\n val v = Array(n) { 0 }\n for (i in 0 until n) {\n w[i] = sc.nextInt()\n v[i] = sc.nextInt()\n }\n val dp = Array(n + 1) { Array(n + 1) { Array(305) { 0 } } }\n for (i in 0 until n) {\n for (j in 0 until n) {\n for (k in 0..300) {\n dp[i + 1][j][k] = Math.max(dp[i + 1][j][k], dp[i][j][k])\n if (k + j * w[0].toLong() + w[i] <= s) {\n dp[i + 1][j + 1][k + w[i] - w[0]] = Math.max(dp[i + 1][j + 1][k + w[i] - w[0]], dp[i][j][k] + v[i])\n }\n }\n }\n }\n var max = 0\n for (j in 0..n) {\n for (k in 0..300) {\n max = Math.max(max, dp[n][j][k])\n }\n }\n println(max)\n}\n\nfun main(args: Array) {\n val writer = PrintWriter(System.out, false)\n writer.solve(FastScanner(System.`in`))\n writer.flush()\n}\n\nclass FastScanner(s: InputStream) {\n private var st = StringTokenizer(\"\")\n private val br = BufferedReader(InputStreamReader(s))\n\n fun next(): String {\n while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())\n\n return st.nextToken()\n }\n\n fun nextInt() = next().toInt()\n fun nextLong() = next().toLong()\n fun nextLine() = br.readLine()\n fun nextDouble() = next().toDouble()\n fun ready() = br.ready()\n}\n", "language": "Kotlin", "metadata": {"date": 1589716955, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03734.html", "problem_id": "p03734", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03734/input.txt", "sample_output_relpath": "derived/input_output/data/p03734/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03734/Kotlin/s202207913.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s202207913", "user_id": "u190507186"}, "prompt_components": {"gold_output": "11\n", "input_to_evaluate": "import java.io.BufferedReader\nimport java.io.InputStream\nimport java.io.InputStreamReader\nimport java.io.PrintWriter\nimport java.lang.StringBuilder\nimport java.util.*\n\nfun PrintWriter.solve(sc: FastScanner) {\n val n = sc.nextInt()\n val s = sc.nextInt()\n val w = Array(n) { 0 }\n val v = Array(n) { 0 }\n for (i in 0 until n) {\n w[i] = sc.nextInt()\n v[i] = sc.nextInt()\n }\n val dp = Array(n + 1) { Array(n + 1) { Array(305) { 0 } } }\n for (i in 0 until n) {\n for (j in 0 until n) {\n for (k in 0..300) {\n dp[i + 1][j][k] = Math.max(dp[i + 1][j][k], dp[i][j][k])\n if (k + j * w[0].toLong() + w[i] <= s) {\n dp[i + 1][j + 1][k + w[i] - w[0]] = Math.max(dp[i + 1][j + 1][k + w[i] - w[0]], dp[i][j][k] + v[i])\n }\n }\n }\n }\n var max = 0\n for (j in 0..n) {\n for (k in 0..300) {\n max = Math.max(max, dp[n][j][k])\n }\n }\n println(max)\n}\n\nfun main(args: Array) {\n val writer = PrintWriter(System.out, false)\n writer.solve(FastScanner(System.`in`))\n writer.flush()\n}\n\nclass FastScanner(s: InputStream) {\n private var st = StringTokenizer(\"\")\n private val br = BufferedReader(InputStreamReader(s))\n\n fun next(): String {\n while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())\n\n return st.nextToken()\n }\n\n fun nextInt() = next().toInt()\n fun nextLong() = next().toLong()\n fun nextLine() = br.readLine()\n fun nextDouble() = next().toDouble()\n fun ready() = br.ready()\n}\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nYou have N items and a bag of strength W.\nThe i-th item has a weight of w_i and a value of v_i.\n\nYou will select some of the items and put them in the bag.\nHere, the total weight of the selected items needs to be at most W.\n\nYour objective is to maximize the total value of the selected items.\n\nConstraints\n\n1 ≤ N ≤ 100\n\n1 ≤ W ≤ 10^9\n\n1 ≤ w_i ≤ 10^9\n\nFor each i = 2,3,...,N, w_1 ≤ w_i ≤ w_1 + 3.\n\n1 ≤ v_i ≤ 10^7\n\nW, each w_i and v_i are integers.\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 total value of the selected items.\n\nSample Input 1\n\n4 6\n2 1\n3 4\n4 10\n3 4\n\nSample Output 1\n\n11\n\nThe first and third items should be selected.\n\nSample Input 2\n\n4 6\n2 1\n3 7\n4 10\n3 6\n\nSample Output 2\n\n13\n\nThe second and fourth items should be selected.\n\nSample Input 3\n\n4 10\n1 100\n1 100\n1 100\n1 100\n\nSample Output 3\n\n400\n\nYou can take everything.\n\nSample Input 4\n\n4 1\n10 100\n10 100\n10 100\n10 100\n\nSample Output 4\n\n0\n\nYou can take nothing.", "sample_input": "4 6\n2 1\n3 4\n4 10\n3 4\n"}, "reference_outputs": ["11\n"], "source_document_id": "p03734", "source_text": "Score : 400 points\n\nProblem Statement\n\nYou have N items and a bag of strength W.\nThe i-th item has a weight of w_i and a value of v_i.\n\nYou will select some of the items and put them in the bag.\nHere, the total weight of the selected items needs to be at most W.\n\nYour objective is to maximize the total value of the selected items.\n\nConstraints\n\n1 ≤ N ≤ 100\n\n1 ≤ W ≤ 10^9\n\n1 ≤ w_i ≤ 10^9\n\nFor each i = 2,3,...,N, w_1 ≤ w_i ≤ w_1 + 3.\n\n1 ≤ v_i ≤ 10^7\n\nW, each w_i and v_i are integers.\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 total value of the selected items.\n\nSample Input 1\n\n4 6\n2 1\n3 4\n4 10\n3 4\n\nSample Output 1\n\n11\n\nThe first and third items should be selected.\n\nSample Input 2\n\n4 6\n2 1\n3 7\n4 10\n3 6\n\nSample Output 2\n\n13\n\nThe second and fourth items should be selected.\n\nSample Input 3\n\n4 10\n1 100\n1 100\n1 100\n1 100\n\nSample Output 3\n\n400\n\nYou can take everything.\n\nSample Input 4\n\n4 1\n10 100\n10 100\n10 100\n10 100\n\nSample Output 4\n\n0\n\nYou can take nothing.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1596, "cpu_time_ms": 789, "memory_kb": 125340}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s913634385", "group_id": "codeNet:p03734", "input_text": "fun main(args: Array) {\n val (n, totalW) = readLine()!!.split(' ').map(String::toLong)\n val things = Array(4) { mutableListOf() }\n var w1 = -1L\n (1..n).forEach {\n val (w, v) = readLine()!!.split(' ').map(String::toLong)\n if (w1 == -1L) w1 = w\n things[(w - w1).toInt() % 4].add(v)\n }\n (0..3).forEach { things[it].sortDescending() }\n\n var ans = 0L\n for (i0 in 0..things[0].size) {\n for (i1 in 0..things[1].size) {\n for (i2 in 0..things[2].size) {\n for (i3 in 0..things[3].size) {\n val curW = i0 * w1 + i1 * (w1 + 1) + i2 * (w1 + 2) + i3 * (w1 + 3)\n if (curW > totalW) break\n else ans = Math.max(ans,\n things[0].take(i0).sum()\n + things[1].take(i1).sum()\n + things[2].take(i2).sum()\n + things[3].take(i3).sum()\n )\n }\n }\n }\n }\n println(ans)\n}\n", "language": "Kotlin", "metadata": {"date": 1574822073, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03734.html", "problem_id": "p03734", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03734/input.txt", "sample_output_relpath": "derived/input_output/data/p03734/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03734/Kotlin/s913634385.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s913634385", "user_id": "u099066216"}, "prompt_components": {"gold_output": "11\n", "input_to_evaluate": "fun main(args: Array) {\n val (n, totalW) = readLine()!!.split(' ').map(String::toLong)\n val things = Array(4) { mutableListOf() }\n var w1 = -1L\n (1..n).forEach {\n val (w, v) = readLine()!!.split(' ').map(String::toLong)\n if (w1 == -1L) w1 = w\n things[(w - w1).toInt() % 4].add(v)\n }\n (0..3).forEach { things[it].sortDescending() }\n\n var ans = 0L\n for (i0 in 0..things[0].size) {\n for (i1 in 0..things[1].size) {\n for (i2 in 0..things[2].size) {\n for (i3 in 0..things[3].size) {\n val curW = i0 * w1 + i1 * (w1 + 1) + i2 * (w1 + 2) + i3 * (w1 + 3)\n if (curW > totalW) break\n else ans = Math.max(ans,\n things[0].take(i0).sum()\n + things[1].take(i1).sum()\n + things[2].take(i2).sum()\n + things[3].take(i3).sum()\n )\n }\n }\n }\n }\n println(ans)\n}\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nYou have N items and a bag of strength W.\nThe i-th item has a weight of w_i and a value of v_i.\n\nYou will select some of the items and put them in the bag.\nHere, the total weight of the selected items needs to be at most W.\n\nYour objective is to maximize the total value of the selected items.\n\nConstraints\n\n1 ≤ N ≤ 100\n\n1 ≤ W ≤ 10^9\n\n1 ≤ w_i ≤ 10^9\n\nFor each i = 2,3,...,N, w_1 ≤ w_i ≤ w_1 + 3.\n\n1 ≤ v_i ≤ 10^7\n\nW, each w_i and v_i are integers.\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 total value of the selected items.\n\nSample Input 1\n\n4 6\n2 1\n3 4\n4 10\n3 4\n\nSample Output 1\n\n11\n\nThe first and third items should be selected.\n\nSample Input 2\n\n4 6\n2 1\n3 7\n4 10\n3 6\n\nSample Output 2\n\n13\n\nThe second and fourth items should be selected.\n\nSample Input 3\n\n4 10\n1 100\n1 100\n1 100\n1 100\n\nSample Output 3\n\n400\n\nYou can take everything.\n\nSample Input 4\n\n4 1\n10 100\n10 100\n10 100\n10 100\n\nSample Output 4\n\n0\n\nYou can take nothing.", "sample_input": "4 6\n2 1\n3 4\n4 10\n3 4\n"}, "reference_outputs": ["11\n"], "source_document_id": "p03734", "source_text": "Score : 400 points\n\nProblem Statement\n\nYou have N items and a bag of strength W.\nThe i-th item has a weight of w_i and a value of v_i.\n\nYou will select some of the items and put them in the bag.\nHere, the total weight of the selected items needs to be at most W.\n\nYour objective is to maximize the total value of the selected items.\n\nConstraints\n\n1 ≤ N ≤ 100\n\n1 ≤ W ≤ 10^9\n\n1 ≤ w_i ≤ 10^9\n\nFor each i = 2,3,...,N, w_1 ≤ w_i ≤ w_1 + 3.\n\n1 ≤ v_i ≤ 10^7\n\nW, each w_i and v_i are integers.\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 total value of the selected items.\n\nSample Input 1\n\n4 6\n2 1\n3 4\n4 10\n3 4\n\nSample Output 1\n\n11\n\nThe first and third items should be selected.\n\nSample Input 2\n\n4 6\n2 1\n3 7\n4 10\n3 6\n\nSample Output 2\n\n13\n\nThe second and fourth items should be selected.\n\nSample Input 3\n\n4 10\n1 100\n1 100\n1 100\n1 100\n\nSample Output 3\n\n400\n\nYou can take everything.\n\nSample Input 4\n\n4 1\n10 100\n10 100\n10 100\n10 100\n\nSample Output 4\n\n0\n\nYou can take nothing.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1078, "cpu_time_ms": 424, "memory_kb": 57024}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s819145255", "group_id": "codeNet:p03734", "input_text": "import java.util.*\n\nfun main(args: Array) {\n val (n, w) = readLine()!!.split(' ').map(String::toInt)\n val wv = Array(n) {\n val (w0, v0) = readLine()!!.split(' ').map(String::toInt)\n Pair(w0, v0)\n }\n\n val w0 = wv[0].first\n //val dp = Array(n+1,n+1,4 *(n+1)){0}\n val dp = Array(n + 1) {\n Array(n + 1) {\n Array(4 * (n + 1)) { 0 }\n }\n }\n dp[0][0][0] = 0\n dp[0][1][0] = wv[0].second\n for (i in 1 until n) {\n for (c in 0..n) {\n for (d in 0 until 4 * (n + 1)) {\n if (c - 1 >= 0 && d - (wv[i].first - w0) >= 0) {\n dp[i][c][d] = Math.max(dp[i - 1][c][d], dp[i - 1][c - 1][d - (wv[i].first - w0)] + wv[i].second)\n } else {\n dp[i][c][d] = dp[i - 1][c][d]\n }\n\n\n }\n }\n }\n /*\n\n for (i in 0 until n) {\n for (c in 0..n) {\n for (d in 0 until 4 * (n + 1)) {\n print(dp[i][c][d].toString() + \" \")\n }\n println()\n }\n println()\n }\n */\n\n // Wいか\n val result = (0 .. n).map{c ->\n (0 until 4 *(n+1)).map{d->\n Pair(c * w0 + d, dp[n-1][c][d])\n }\n }.flatten().filter{\n it.first <= w\n }.map{it.second}.max()\n println(result)\n}", "language": "Kotlin", "metadata": {"date": 1561587777, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03734.html", "problem_id": "p03734", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03734/input.txt", "sample_output_relpath": "derived/input_output/data/p03734/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03734/Kotlin/s819145255.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s819145255", "user_id": "u494788559"}, "prompt_components": {"gold_output": "11\n", "input_to_evaluate": "import java.util.*\n\nfun main(args: Array) {\n val (n, w) = readLine()!!.split(' ').map(String::toInt)\n val wv = Array(n) {\n val (w0, v0) = readLine()!!.split(' ').map(String::toInt)\n Pair(w0, v0)\n }\n\n val w0 = wv[0].first\n //val dp = Array(n+1,n+1,4 *(n+1)){0}\n val dp = Array(n + 1) {\n Array(n + 1) {\n Array(4 * (n + 1)) { 0 }\n }\n }\n dp[0][0][0] = 0\n dp[0][1][0] = wv[0].second\n for (i in 1 until n) {\n for (c in 0..n) {\n for (d in 0 until 4 * (n + 1)) {\n if (c - 1 >= 0 && d - (wv[i].first - w0) >= 0) {\n dp[i][c][d] = Math.max(dp[i - 1][c][d], dp[i - 1][c - 1][d - (wv[i].first - w0)] + wv[i].second)\n } else {\n dp[i][c][d] = dp[i - 1][c][d]\n }\n\n\n }\n }\n }\n /*\n\n for (i in 0 until n) {\n for (c in 0..n) {\n for (d in 0 until 4 * (n + 1)) {\n print(dp[i][c][d].toString() + \" \")\n }\n println()\n }\n println()\n }\n */\n\n // Wいか\n val result = (0 .. n).map{c ->\n (0 until 4 *(n+1)).map{d->\n Pair(c * w0 + d, dp[n-1][c][d])\n }\n }.flatten().filter{\n it.first <= w\n }.map{it.second}.max()\n println(result)\n}", "problem_context": "Score : 400 points\n\nProblem Statement\n\nYou have N items and a bag of strength W.\nThe i-th item has a weight of w_i and a value of v_i.\n\nYou will select some of the items and put them in the bag.\nHere, the total weight of the selected items needs to be at most W.\n\nYour objective is to maximize the total value of the selected items.\n\nConstraints\n\n1 ≤ N ≤ 100\n\n1 ≤ W ≤ 10^9\n\n1 ≤ w_i ≤ 10^9\n\nFor each i = 2,3,...,N, w_1 ≤ w_i ≤ w_1 + 3.\n\n1 ≤ v_i ≤ 10^7\n\nW, each w_i and v_i are integers.\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 total value of the selected items.\n\nSample Input 1\n\n4 6\n2 1\n3 4\n4 10\n3 4\n\nSample Output 1\n\n11\n\nThe first and third items should be selected.\n\nSample Input 2\n\n4 6\n2 1\n3 7\n4 10\n3 6\n\nSample Output 2\n\n13\n\nThe second and fourth items should be selected.\n\nSample Input 3\n\n4 10\n1 100\n1 100\n1 100\n1 100\n\nSample Output 3\n\n400\n\nYou can take everything.\n\nSample Input 4\n\n4 1\n10 100\n10 100\n10 100\n10 100\n\nSample Output 4\n\n0\n\nYou can take nothing.", "sample_input": "4 6\n2 1\n3 4\n4 10\n3 4\n"}, "reference_outputs": ["11\n"], "source_document_id": "p03734", "source_text": "Score : 400 points\n\nProblem Statement\n\nYou have N items and a bag of strength W.\nThe i-th item has a weight of w_i and a value of v_i.\n\nYou will select some of the items and put them in the bag.\nHere, the total weight of the selected items needs to be at most W.\n\nYour objective is to maximize the total value of the selected items.\n\nConstraints\n\n1 ≤ N ≤ 100\n\n1 ≤ W ≤ 10^9\n\n1 ≤ w_i ≤ 10^9\n\nFor each i = 2,3,...,N, w_1 ≤ w_i ≤ w_1 + 3.\n\n1 ≤ v_i ≤ 10^7\n\nW, each w_i and v_i are integers.\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 total value of the selected items.\n\nSample Input 1\n\n4 6\n2 1\n3 4\n4 10\n3 4\n\nSample Output 1\n\n11\n\nThe first and third items should be selected.\n\nSample Input 2\n\n4 6\n2 1\n3 7\n4 10\n3 6\n\nSample Output 2\n\n13\n\nThe second and fourth items should be selected.\n\nSample Input 3\n\n4 10\n1 100\n1 100\n1 100\n1 100\n\nSample Output 3\n\n400\n\nYou can take everything.\n\nSample Input 4\n\n4 1\n10 100\n10 100\n10 100\n10 100\n\nSample Output 4\n\n0\n\nYou can take nothing.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1327, "cpu_time_ms": 2103, "memory_kb": 146252}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s578720732", "group_id": "codeNet:p03738", "input_text": "fun main(args: Array) {\n val x = readLine()!!\n val y = readLine()!!\n val r = when{\n x.count() < y.count() -> \"GREATER\"\n x.count() > y.count() -> \"LESS\"\n else -> when{\n x > y -> \"GREATER\"\n x < y -> \"LESS\"\n else -> \"EQUAL\"\n }\n }\n println(r)\n}", "language": "Kotlin", "metadata": {"date": 1542325725, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03738.html", "problem_id": "p03738", "resource_group": "medium_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/Kotlin/s578720732.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s578720732", "user_id": "u227189389"}, "prompt_components": {"gold_output": "GREATER\n", "input_to_evaluate": "fun main(args: Array) {\n val x = readLine()!!\n val y = readLine()!!\n val r = when{\n x.count() < y.count() -> \"GREATER\"\n x.count() > y.count() -> \"LESS\"\n else -> when{\n x > y -> \"GREATER\"\n x < y -> \"LESS\"\n else -> \"EQUAL\"\n }\n }\n println(r)\n}", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 210, "memory_kb": 31428}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s590585128", "group_id": "codeNet:p03739", "input_text": "fun main(args: Array) {\n Program().solve()\n}\n\nclass Program {\n fun solve() {\n val sc = MyScanner()\n val n = sc.nextInt()\n val a = sc.longList()\n // +-+-+-\n var p = 0L\n var m = 0L\n var tmpP = 0L\n var tmpM = 0L\n for (i in 0 until n) {\n tmpP += a[i]\n tmpM += a[i]\n if (i % 2 == 0) {\n // +\n if (tmpP <= 0) {\n p += -tmpP + 1\n tmpP = 1\n }\n\n if (tmpM >= 0) {\n m += tmpM + 1\n tmpM = -1\n }\n } else {\n // -\n if (tmpP >= 0) {\n p += tmpP + 1\n tmpP = -1\n }\n\n if (tmpM <= 0) {\n m += -tmpM + 1\n tmpM = 1\n }\n }\n }\n\n println(Math.min(p,m))\n }\n}\n\nclass MyScanner {\n private var ptr = 0\n private var l = listOf()\n\n fun next(): String {\n while (l.size <= ptr) {\n l = readLine()!!.split(' ')\n ptr = 0\n }\n return l[ptr++]\n }\n\n fun nextInt() = next().toInt()\n fun nextLong() = next().toLong()\n fun nextDouble() = next().toDouble()\n fun nextCharArray() = next().toCharArray()\n fun nextChar() = next()[0]\n\n fun list(): List {\n ptr = l.size\n return readLine()!!.split(' ')\n }\n\n fun intList() = list().map { s -> s.toInt() }\n fun longList() = list().map { s -> s.toLong() }\n fun doubleList() = list().map { s -> s.toDouble() }\n\n fun array() = list().toTypedArray()\n fun intArray() = intList().toIntArray()\n fun longArray() = longList().toLongArray()\n fun doubleArray() = doubleList().toDoubleArray()\n}\n", "language": "Kotlin", "metadata": {"date": 1596342663, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p03739.html", "problem_id": "p03739", "resource_group": "medium_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/Kotlin/s590585128.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s590585128", "user_id": "u194412908"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "fun main(args: Array) {\n Program().solve()\n}\n\nclass Program {\n fun solve() {\n val sc = MyScanner()\n val n = sc.nextInt()\n val a = sc.longList()\n // +-+-+-\n var p = 0L\n var m = 0L\n var tmpP = 0L\n var tmpM = 0L\n for (i in 0 until n) {\n tmpP += a[i]\n tmpM += a[i]\n if (i % 2 == 0) {\n // +\n if (tmpP <= 0) {\n p += -tmpP + 1\n tmpP = 1\n }\n\n if (tmpM >= 0) {\n m += tmpM + 1\n tmpM = -1\n }\n } else {\n // -\n if (tmpP >= 0) {\n p += tmpP + 1\n tmpP = -1\n }\n\n if (tmpM <= 0) {\n m += -tmpM + 1\n tmpM = 1\n }\n }\n }\n\n println(Math.min(p,m))\n }\n}\n\nclass MyScanner {\n private var ptr = 0\n private var l = listOf()\n\n fun next(): String {\n while (l.size <= ptr) {\n l = readLine()!!.split(' ')\n ptr = 0\n }\n return l[ptr++]\n }\n\n fun nextInt() = next().toInt()\n fun nextLong() = next().toLong()\n fun nextDouble() = next().toDouble()\n fun nextCharArray() = next().toCharArray()\n fun nextChar() = next()[0]\n\n fun list(): List {\n ptr = l.size\n return readLine()!!.split(' ')\n }\n\n fun intList() = list().map { s -> s.toInt() }\n fun longList() = list().map { s -> s.toLong() }\n fun doubleList() = list().map { s -> s.toDouble() }\n\n fun array() = list().toTypedArray()\n fun intArray() = intList().toIntArray()\n fun longArray() = longList().toLongArray()\n fun doubleArray() = doubleList().toDoubleArray()\n}\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1853, "cpu_time_ms": 320, "memory_kb": 53016}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s748254708", "group_id": "codeNet:p03745", "input_text": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val n = sc.nextInt()\n\n var way = 0\n var pre = 0\n var ans = 1\n\n for (i in 0 until n) {\n val now = sc.nextInt()\n if (i == 0 || now - pre == 0) {\n } else if (way == 0) {\n way = sgn(now - pre)\n } else if (sgn(now - pre) != way) {\n ans++\n way = 0\n }\n pre = now\n }\n println(ans)\n}\n\nfun sgn(x: Int): Int {\n if (x == 0) {\n return 0\n }\n if (x > 0) {\n return 1\n }\n return -1\n}\n", "language": "Kotlin", "metadata": {"date": 1543122112, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03745.html", "problem_id": "p03745", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03745/input.txt", "sample_output_relpath": "derived/input_output/data/p03745/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03745/Kotlin/s748254708.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s748254708", "user_id": "u323680411"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val n = sc.nextInt()\n\n var way = 0\n var pre = 0\n var ans = 1\n\n for (i in 0 until n) {\n val now = sc.nextInt()\n if (i == 0 || now - pre == 0) {\n } else if (way == 0) {\n way = sgn(now - pre)\n } else if (sgn(now - pre) != way) {\n ans++\n way = 0\n }\n pre = now\n }\n println(ans)\n}\n\nfun sgn(x: Int): Int {\n if (x == 0) {\n return 0\n }\n if (x > 0) {\n return 1\n }\n return -1\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nYou are given an array A of length N.\nYour task is to divide it into several contiguous subarrays.\nHere, all subarrays obtained must be sorted in either non-decreasing or non-increasing order.\nAt least how many subarrays do you need to divide A into?\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n1 \\leq A_i \\leq 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 possible number of subarrays after division of A.\n\nSample Input 1\n\n6\n1 2 3 2 2 1\n\nSample Output 1\n\n2\n\nOne optimal solution is to divide the array into [1,2,3] and [2,2,1].\n\nSample Input 2\n\n9\n1 2 1 2 1 2 1 2 1\n\nSample Output 2\n\n5\n\nSample Input 3\n\n7\n1 2 3 2 1 999999999 1000000000\n\nSample Output 3\n\n3", "sample_input": "6\n1 2 3 2 2 1\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03745", "source_text": "Score : 300 points\n\nProblem Statement\n\nYou are given an array A of length N.\nYour task is to divide it into several contiguous subarrays.\nHere, all subarrays obtained must be sorted in either non-decreasing or non-increasing order.\nAt least how many subarrays do you need to divide A into?\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n1 \\leq A_i \\leq 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 possible number of subarrays after division of A.\n\nSample Input 1\n\n6\n1 2 3 2 2 1\n\nSample Output 1\n\n2\n\nOne optimal solution is to divide the array into [1,2,3] and [2,2,1].\n\nSample Input 2\n\n9\n1 2 1 2 1 2 1 2 1\n\nSample Output 2\n\n5\n\nSample Input 3\n\n7\n1 2 3 2 1 999999999 1000000000\n\nSample Output 3\n\n3", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 579, "cpu_time_ms": 515, "memory_kb": 52908}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s716171593", "group_id": "codeNet:p03751", "input_text": "fun main(args: Array) = IO().exec {\n val n = int()\n val s = Array(n){string()}\n val t = string()\n var p = 0\n var q = 0\n for (u in s) {\n if (u == t) q++\n else if (!u.startsWith(t)) {\n var zflag = false\n for (j in Math.min(u.length, t.length)) {\n if (u[j] == '?') {\n if (t[j] == 'z') {\n zflag = true\n } else {\n q++\n break\n }\n } else if (u[j] < t[j]) {\n p++\n break\n } else if (u[j] > t[j]) {\n if (zflag) q++\n break\n }\n }\n }\n }\n println((p..p+q).map { it+1 }.joinToString(\" \"))\n}\n\n// region template\noperator fun Int.iterator() = 0.until(this).iterator()\n\nclass IO {\n val printable = 33..126\n val buffer = ByteArray(1024)\n var ptr = 0\n var buflen = 0\n val out = java.io.PrintWriter(System.out)\n fun hasNextByte(): Boolean = if (ptr < buflen) true else {\n ptr = 0\n buflen = System.`in`.read(buffer)\n buflen > 0\n }\n\n fun readByte(): Byte = if (hasNextByte()) buffer[ptr++] else -1\n fun hasNext(): Boolean {\n while (hasNextByte() && buffer[ptr] !in printable) ptr++\n return hasNextByte()\n }\n\n fun string(): String {\n if (!hasNext()) throw java.util.NoSuchElementException()\n val sb = StringBuilder()\n var b = readByte()\n while (b in printable) {\n sb.appendCodePoint(b.toInt())\n b = readByte()\n }\n return sb.toString()\n }\n\n fun long(): Long {\n if (!hasNext()) throw java.util.NoSuchElementException()\n var n = 0L\n var minus = false\n var b = readByte()\n if (b == '-'.toByte()) {\n minus = true\n b = readByte()\n }\n if (b !in '0'.toByte()..'9'.toByte()) {\n throw NumberFormatException()\n }\n while (true) {\n if (b in '0'.toByte()..'9'.toByte()) {\n n *= 10\n n += b - '0'.toByte()\n } else if (b == (-1).toByte() || b !in printable) {\n return if (minus) -n else n\n } else {\n throw NumberFormatException()\n }\n b = readByte()\n }\n }\n\n fun int(): Int {\n val nl = long()\n if (nl !in Integer.MIN_VALUE..Integer.MAX_VALUE) throw NumberFormatException()\n return nl.toInt()\n }\n\n fun double(): Double = string().toDouble()\n fun print(obj: Any) = out.print(obj)\n fun print(i: Int) = out.print(i)\n fun print(l: Long) = out.print(l)\n fun println(obj: Any) = out.println(obj)\n fun println(i: Int) = out.println(i)\n fun println(l: Long) = out.println(l)\n inline fun exec(block: IO.() -> Unit) {\n block()\n out.flush()\n }\n}\n// endregion", "language": "Kotlin", "metadata": {"date": 1565483789, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03751.html", "problem_id": "p03751", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03751/input.txt", "sample_output_relpath": "derived/input_output/data/p03751/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03751/Kotlin/s716171593.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s716171593", "user_id": "u648975072"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "fun main(args: Array) = IO().exec {\n val n = int()\n val s = Array(n){string()}\n val t = string()\n var p = 0\n var q = 0\n for (u in s) {\n if (u == t) q++\n else if (!u.startsWith(t)) {\n var zflag = false\n for (j in Math.min(u.length, t.length)) {\n if (u[j] == '?') {\n if (t[j] == 'z') {\n zflag = true\n } else {\n q++\n break\n }\n } else if (u[j] < t[j]) {\n p++\n break\n } else if (u[j] > t[j]) {\n if (zflag) q++\n break\n }\n }\n }\n }\n println((p..p+q).map { it+1 }.joinToString(\" \"))\n}\n\n// region template\noperator fun Int.iterator() = 0.until(this).iterator()\n\nclass IO {\n val printable = 33..126\n val buffer = ByteArray(1024)\n var ptr = 0\n var buflen = 0\n val out = java.io.PrintWriter(System.out)\n fun hasNextByte(): Boolean = if (ptr < buflen) true else {\n ptr = 0\n buflen = System.`in`.read(buffer)\n buflen > 0\n }\n\n fun readByte(): Byte = if (hasNextByte()) buffer[ptr++] else -1\n fun hasNext(): Boolean {\n while (hasNextByte() && buffer[ptr] !in printable) ptr++\n return hasNextByte()\n }\n\n fun string(): String {\n if (!hasNext()) throw java.util.NoSuchElementException()\n val sb = StringBuilder()\n var b = readByte()\n while (b in printable) {\n sb.appendCodePoint(b.toInt())\n b = readByte()\n }\n return sb.toString()\n }\n\n fun long(): Long {\n if (!hasNext()) throw java.util.NoSuchElementException()\n var n = 0L\n var minus = false\n var b = readByte()\n if (b == '-'.toByte()) {\n minus = true\n b = readByte()\n }\n if (b !in '0'.toByte()..'9'.toByte()) {\n throw NumberFormatException()\n }\n while (true) {\n if (b in '0'.toByte()..'9'.toByte()) {\n n *= 10\n n += b - '0'.toByte()\n } else if (b == (-1).toByte() || b !in printable) {\n return if (minus) -n else n\n } else {\n throw NumberFormatException()\n }\n b = readByte()\n }\n }\n\n fun int(): Int {\n val nl = long()\n if (nl !in Integer.MIN_VALUE..Integer.MAX_VALUE) throw NumberFormatException()\n return nl.toInt()\n }\n\n fun double(): Double = string().toDouble()\n fun print(obj: Any) = out.print(obj)\n fun print(i: Int) = out.print(i)\n fun print(l: Long) = out.print(l)\n fun println(obj: Any) = out.println(obj)\n fun println(i: Int) = out.println(i)\n fun println(l: Long) = out.println(l)\n inline fun exec(block: IO.() -> Unit) {\n block()\n out.flush()\n }\n}\n// endregion", "problem_context": "Max Score: 250 Points\n\nProblem Statement\n\nMr.X, who the handle name is T, looked at the list which written N handle names, S_1, S_2, ..., S_N.\n\nBut he couldn't see some parts of the list. Invisible part is denoted ?.\n\nPlease calculate all possible index of the handle name of Mr.X when you sort N+1 handle names (S_1, S_2, ..., S_N and T) in lexicographical order.\n\nNote: If there are pair of people with same handle name, either one may come first.\n\nInput\n\nThe input is given from standard input in the following format.\n\nN\nS_1\nS_2\n:\nS_N\nT\n\nOutput\n\nCalculate the possible index and print in sorted order. The output should be separated with a space. Don't print a space after last number.\n\nPut a line break in the end.\n\nConstraints\n\n1 ≤ N ≤ 10000\n\n1 ≤ |S_i|, |T| ≤ 20 (|A| is the length of A.)\n\nS_i consists from lower-case alphabet and ?.\n\nT consists from lower-case alphabet.\n\nScoring\n\nSubtask 1 [ 130 points ]\n\nThere are no ?'s.\n\nSubtask 2 [ 120 points ]\n\nThere are no additional constraints.\n\nSample Input 1\n\n2\ntourist\npetr\ne\n\nSample Output 1\n\n1\n\nThere are no invisible part, so there are only one possibility.\nThe sorted handle names are e, petr, tourist, so e comes first.\n\nSample Input 2\n\n2\n?o?r?s?\n?et?\ne", "sample_input": "2\ntourist\npetr\ne\n"}, "reference_outputs": ["1\n"], "source_document_id": "p03751", "source_text": "Max Score: 250 Points\n\nProblem Statement\n\nMr.X, who the handle name is T, looked at the list which written N handle names, S_1, S_2, ..., S_N.\n\nBut he couldn't see some parts of the list. Invisible part is denoted ?.\n\nPlease calculate all possible index of the handle name of Mr.X when you sort N+1 handle names (S_1, S_2, ..., S_N and T) in lexicographical order.\n\nNote: If there are pair of people with same handle name, either one may come first.\n\nInput\n\nThe input is given from standard input in the following format.\n\nN\nS_1\nS_2\n:\nS_N\nT\n\nOutput\n\nCalculate the possible index and print in sorted order. The output should be separated with a space. Don't print a space after last number.\n\nPut a line break in the end.\n\nConstraints\n\n1 ≤ N ≤ 10000\n\n1 ≤ |S_i|, |T| ≤ 20 (|A| is the length of A.)\n\nS_i consists from lower-case alphabet and ?.\n\nT consists from lower-case alphabet.\n\nScoring\n\nSubtask 1 [ 130 points ]\n\nThere are no ?'s.\n\nSubtask 2 [ 120 points ]\n\nThere are no additional constraints.\n\nSample Input 1\n\n2\ntourist\npetr\ne\n\nSample Output 1\n\n1\n\nThere are no invisible part, so there are only one possibility.\nThe sorted handle names are e, petr, tourist, so e comes first.\n\nSample Input 2\n\n2\n?o?r?s?\n?et?\ne", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2978, "cpu_time_ms": 289, "memory_kb": 32436}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s737657466", "group_id": "codeNet:p03760", "input_text": "import java.lang.Math.max\nimport java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val o = sc.next()\n val e = sc.next()\n\n for (i in 0 until max(o.length, e.length)) {\n if (i < o.length) {\n print(o[i])\n }\n if (i < e.length) {\n print(e[i])\n }\n }\n println()\n}\n", "language": "Kotlin", "metadata": {"date": 1541476501, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03760.html", "problem_id": "p03760", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03760/input.txt", "sample_output_relpath": "derived/input_output/data/p03760/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03760/Kotlin/s737657466.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s737657466", "user_id": "u323680411"}, "prompt_components": {"gold_output": "xaybzc\n", "input_to_evaluate": "import java.lang.Math.max\nimport java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val o = sc.next()\n val e = sc.next()\n\n for (i in 0 until max(o.length, e.length)) {\n if (i < o.length) {\n print(o[i])\n }\n if (i < e.length) {\n print(e[i])\n }\n }\n println()\n}\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nSnuke signed up for a new website which holds programming competitions.\nHe worried that he might forget his password, and he took notes of it.\nSince directly recording his password would cause him trouble if stolen,\nhe took two notes: one contains the characters at the odd-numbered positions, and the other contains the characters at the even-numbered positions.\n\nYou are given two strings O and E. O contains the characters at the odd-numbered positions retaining their relative order, and E contains the characters at the even-numbered positions retaining their relative order.\nRestore the original password.\n\nConstraints\n\nO and E consists of lowercase English letters (a - z).\n\n1 \\leq |O|,|E| \\leq 50\n\n|O| - |E| is either 0 or 1.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nO\nE\n\nOutput\n\nPrint the original password.\n\nSample Input 1\n\nxyz\nabc\n\nSample Output 1\n\nxaybzc\n\nThe original password is xaybzc. Extracting the characters at the odd-numbered positions results in xyz, and extracting the characters at the even-numbered positions results in abc.\n\nSample Input 2\n\natcoderbeginnercontest\natcoderregularcontest\n\nSample Output 2\n\naattccooddeerrbreeggiunlnaerrccoonntteesstt", "sample_input": "xyz\nabc\n"}, "reference_outputs": ["xaybzc\n"], "source_document_id": "p03760", "source_text": "Score : 200 points\n\nProblem Statement\n\nSnuke signed up for a new website which holds programming competitions.\nHe worried that he might forget his password, and he took notes of it.\nSince directly recording his password would cause him trouble if stolen,\nhe took two notes: one contains the characters at the odd-numbered positions, and the other contains the characters at the even-numbered positions.\n\nYou are given two strings O and E. O contains the characters at the odd-numbered positions retaining their relative order, and E contains the characters at the even-numbered positions retaining their relative order.\nRestore the original password.\n\nConstraints\n\nO and E consists of lowercase English letters (a - z).\n\n1 \\leq |O|,|E| \\leq 50\n\n|O| - |E| is either 0 or 1.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nO\nE\n\nOutput\n\nPrint the original password.\n\nSample Input 1\n\nxyz\nabc\n\nSample Output 1\n\nxaybzc\n\nThe original password is xaybzc. Extracting the characters at the odd-numbered positions results in xyz, and extracting the characters at the even-numbered positions results in abc.\n\nSample Input 2\n\natcoderbeginnercontest\natcoderregularcontest\n\nSample Output 2\n\naattccooddeerrbreeggiunlnaerrccoonntteesstt", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 352, "cpu_time_ms": 180, "memory_kb": 29472}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s380714376", "group_id": "codeNet:p03761", "input_text": "fun main(args: Array) {\n Program().solve()\n}\n\nclass Program {\n fun solve() {\n val sc = MyScanner()\n val n = sc.nextInt()\n val cnt = Array(26) { Int.MAX_VALUE }\n for (i in 0 until n) {\n val s = sc.next()\n val tmp = Array(26) { 0 }\n for (j in s.indices) {\n tmp[s[j] - 'a']++\n }\n for (j in 0 until 26) {\n cnt[j] = Math.min(cnt[j], tmp[j])\n }\n }\n\n val ans = StringBuilder()\n for(i in 'a'..'z'){\n ans.append(i.toString().repeat(cnt[i-'a']))\n }\n\n println(ans)\n }\n}\n\nclass MyScanner {\n private var ptr = 0\n private var l = listOf()\n\n fun next(): String {\n while (l.size <= ptr) {\n l = readLine()!!.split(' ')\n ptr = 0\n }\n return l[ptr++]\n }\n\n fun nextInt() = next().toInt()\n fun nextLong() = next().toLong()\n fun nextDouble() = next().toDouble()\n fun nextCharArray() = next().toCharArray()\n fun nextChar() = next()[0]\n\n fun list(): List {\n ptr = l.size\n return readLine()!!.split(' ')\n }\n\n fun intList() = list().map { s -> s.toInt() }\n fun longList() = list().map { s -> s.toLong() }\n fun doubleList() = list().map { s -> s.toDouble() }\n\n fun array() = list().toTypedArray()\n fun intArray() = intList().toIntArray()\n fun longArray() = longList().toLongArray()\n fun doubleArray() = doubleList().toDoubleArray()\n}\n", "language": "Kotlin", "metadata": {"date": 1596341157, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p03761.html", "problem_id": "p03761", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03761/input.txt", "sample_output_relpath": "derived/input_output/data/p03761/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03761/Kotlin/s380714376.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s380714376", "user_id": "u194412908"}, "prompt_components": {"gold_output": "aac\n", "input_to_evaluate": "fun main(args: Array) {\n Program().solve()\n}\n\nclass Program {\n fun solve() {\n val sc = MyScanner()\n val n = sc.nextInt()\n val cnt = Array(26) { Int.MAX_VALUE }\n for (i in 0 until n) {\n val s = sc.next()\n val tmp = Array(26) { 0 }\n for (j in s.indices) {\n tmp[s[j] - 'a']++\n }\n for (j in 0 until 26) {\n cnt[j] = Math.min(cnt[j], tmp[j])\n }\n }\n\n val ans = StringBuilder()\n for(i in 'a'..'z'){\n ans.append(i.toString().repeat(cnt[i-'a']))\n }\n\n println(ans)\n }\n}\n\nclass MyScanner {\n private var ptr = 0\n private var l = listOf()\n\n fun next(): String {\n while (l.size <= ptr) {\n l = readLine()!!.split(' ')\n ptr = 0\n }\n return l[ptr++]\n }\n\n fun nextInt() = next().toInt()\n fun nextLong() = next().toLong()\n fun nextDouble() = next().toDouble()\n fun nextCharArray() = next().toCharArray()\n fun nextChar() = next()[0]\n\n fun list(): List {\n ptr = l.size\n return readLine()!!.split(' ')\n }\n\n fun intList() = list().map { s -> s.toInt() }\n fun longList() = list().map { s -> s.toLong() }\n fun doubleList() = list().map { s -> s.toDouble() }\n\n fun array() = list().toTypedArray()\n fun intArray() = intList().toIntArray()\n fun longArray() = longList().toLongArray()\n fun doubleArray() = doubleList().toDoubleArray()\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nSnuke loves \"paper cutting\": he cuts out characters from a newspaper headline and rearranges them to form another string.\n\nHe will receive a headline which contains one of the strings S_1,...,S_n tomorrow.\nHe is excited and already thinking of what string he will create.\nSince he does not know the string on the headline yet, he is interested in strings that can be created regardless of which string the headline contains.\n\nFind the longest string that can be created regardless of which string among S_1,...,S_n the headline contains.\nIf there are multiple such strings, find the lexicographically smallest one among them.\n\nConstraints\n\n1 \\leq n \\leq 50\n\n1 \\leq |S_i| \\leq 50 for every i = 1, ..., n.\n\nS_i consists of lowercase English letters (a - z) for every i = 1, ..., n.\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 lexicographically smallest string among the longest strings that satisfy the condition.\nIf the answer is an empty string, print an empty line.\n\nSample Input 1\n\n3\ncbaa\ndaacc\nacacac\n\nSample Output 1\n\naac\n\nThe strings that can be created from each of cbaa, daacc and acacac, are aa, aac, aca, caa and so forth.\nAmong them, aac, aca and caa are the longest, and the lexicographically smallest of these three is aac.\n\nSample Input 2\n\n3\na\naa\nb\n\nSample Output 2\n\nThe answer is an empty string.", "sample_input": "3\ncbaa\ndaacc\nacacac\n"}, "reference_outputs": ["aac\n"], "source_document_id": "p03761", "source_text": "Score : 300 points\n\nProblem Statement\n\nSnuke loves \"paper cutting\": he cuts out characters from a newspaper headline and rearranges them to form another string.\n\nHe will receive a headline which contains one of the strings S_1,...,S_n tomorrow.\nHe is excited and already thinking of what string he will create.\nSince he does not know the string on the headline yet, he is interested in strings that can be created regardless of which string the headline contains.\n\nFind the longest string that can be created regardless of which string among S_1,...,S_n the headline contains.\nIf there are multiple such strings, find the lexicographically smallest one among them.\n\nConstraints\n\n1 \\leq n \\leq 50\n\n1 \\leq |S_i| \\leq 50 for every i = 1, ..., n.\n\nS_i consists of lowercase English letters (a - z) for every i = 1, ..., n.\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 lexicographically smallest string among the longest strings that satisfy the condition.\nIf the answer is an empty string, print an empty line.\n\nSample Input 1\n\n3\ncbaa\ndaacc\nacacac\n\nSample Output 1\n\naac\n\nThe strings that can be created from each of cbaa, daacc and acacac, are aa, aac, aca, caa and so forth.\nAmong them, aac, aca and caa are the longest, and the lexicographically smallest of these three is aac.\n\nSample Input 2\n\n3\na\naa\nb\n\nSample Output 2\n\nThe answer is an empty string.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1520, "cpu_time_ms": 126, "memory_kb": 37956}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s665401390", "group_id": "codeNet:p03762", "input_text": "fun main(args: Array) {\n val (N, M) = listOfInt()\n val X = listOfLong().map { ModInt(it) }.toTypedArray()\n val Y = listOfLong().map { ModInt(it) }.toTypedArray()\n var x = ModInt(0)\n for (n in 1 until N) {\n x += X[n] * n - X[n - 1]\n X[n] += X[n - 1]\n }\n var y = ModInt(0)\n for (m in 1 until M) {\n y += Y[m] * m - Y[m - 1]\n Y[m] += Y[m - 1]\n }\n println(x * y)\n} \n\nfun next() = readLine()!!\nfun nextInt(delta: Int = 0) = Integer.parseInt(next()) + delta\nfun listOfString() = next().split(\" \")\nfun listOfInt() = listOfString().map(String::toInt)\nfun listOfLong() = listOfString().map(String::toLong)\n\ndata class ModInt(private var v: Long) {\n companion object { private const val MOD = 1000000007L }\n init { this.v %= MOD }\n constructor(n: Int): this(n.toLong())\n operator fun plus(other: Int) = ModInt((this.v + other) % MOD)\n operator fun plus(other: ModInt) = ModInt((this.v + other.v) % MOD)\n operator fun minus(other: Int) = ModInt((this.v + MOD - other) % MOD)\n operator fun minus(other: ModInt) = ModInt((this.v + MOD - other.v) % MOD)\n operator fun times(other: Int) = ModInt(this.v * other % MOD)\n operator fun times(other: ModInt) = ModInt(this.v * other.v % MOD)\n operator fun div(other: ModInt) = ModInt(this.v * pow(other.v, MOD - 2) % MOD)\n private fun pow(a: Long, b: Long): Long {\n if (b == 0L) return 1L\n if (b % 2 == 0L) {\n val d = pow(a, b / 2)\n return (d * d) % MOD\n }\n return a * pow(a, b - 1) % MOD\n }\n override fun toString() = this.v.toString()\n}", "language": "Kotlin", "metadata": {"date": 1586015436, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03762.html", "problem_id": "p03762", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03762/input.txt", "sample_output_relpath": "derived/input_output/data/p03762/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03762/Kotlin/s665401390.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s665401390", "user_id": "u043150661"}, "prompt_components": {"gold_output": "60\n", "input_to_evaluate": "fun main(args: Array) {\n val (N, M) = listOfInt()\n val X = listOfLong().map { ModInt(it) }.toTypedArray()\n val Y = listOfLong().map { ModInt(it) }.toTypedArray()\n var x = ModInt(0)\n for (n in 1 until N) {\n x += X[n] * n - X[n - 1]\n X[n] += X[n - 1]\n }\n var y = ModInt(0)\n for (m in 1 until M) {\n y += Y[m] * m - Y[m - 1]\n Y[m] += Y[m - 1]\n }\n println(x * y)\n} \n\nfun next() = readLine()!!\nfun nextInt(delta: Int = 0) = Integer.parseInt(next()) + delta\nfun listOfString() = next().split(\" \")\nfun listOfInt() = listOfString().map(String::toInt)\nfun listOfLong() = listOfString().map(String::toLong)\n\ndata class ModInt(private var v: Long) {\n companion object { private const val MOD = 1000000007L }\n init { this.v %= MOD }\n constructor(n: Int): this(n.toLong())\n operator fun plus(other: Int) = ModInt((this.v + other) % MOD)\n operator fun plus(other: ModInt) = ModInt((this.v + other.v) % MOD)\n operator fun minus(other: Int) = ModInt((this.v + MOD - other) % MOD)\n operator fun minus(other: ModInt) = ModInt((this.v + MOD - other.v) % MOD)\n operator fun times(other: Int) = ModInt(this.v * other % MOD)\n operator fun times(other: ModInt) = ModInt(this.v * other.v % MOD)\n operator fun div(other: ModInt) = ModInt(this.v * pow(other.v, MOD - 2) % MOD)\n private fun pow(a: Long, b: Long): Long {\n if (b == 0L) return 1L\n if (b % 2 == 0L) {\n val d = pow(a, b / 2)\n return (d * d) % MOD\n }\n return a * pow(a, b - 1) % MOD\n }\n override fun toString() = this.v.toString()\n}", "problem_context": "Score : 500 points\n\nProblem Statement\n\nOn a two-dimensional plane, there are m lines drawn parallel to the x axis, and n lines drawn parallel to the y axis.\nAmong the lines parallel to the x axis, the i-th from the bottom is represented by y = y_i.\nSimilarly, among the lines parallel to the y axis, the i-th from the left is represented by x = x_i.\n\nFor every rectangle that is formed by these lines, find its area, and print the total area modulo 10^9+7.\n\nThat is, for every quadruple (i,j,k,l) satisfying 1\\leq i < j\\leq n and 1\\leq k < l\\leq m, find the area of the rectangle formed by the lines x=x_i, x=x_j, y=y_k and y=y_l, and print the sum of these areas modulo 10^9+7.\n\nConstraints\n\n2 \\leq n,m \\leq 10^5\n\n-10^9 \\leq x_1 < ... < x_n \\leq 10^9\n\n-10^9 \\leq y_1 < ... < y_m \\leq 10^9\n\nx_i and y_i are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nn m\nx_1 x_2 ... x_n\ny_1 y_2 ... y_m\n\nOutput\n\nPrint the total area of the rectangles, modulo 10^9+7.\n\nSample Input 1\n\n3 3\n1 3 4\n1 3 6\n\nSample Output 1\n\n60\n\nThe following figure illustrates this input:\n\nThe total area of the nine rectangles A, B, ..., I shown in the following figure, is 60.\n\nSample Input 2\n\n6 5\n-790013317 -192321079 95834122 418379342 586260100 802780784\n-253230108 193944314 363756450 712662868 735867677\n\nSample Output 2\n\n835067060", "sample_input": "3 3\n1 3 4\n1 3 6\n"}, "reference_outputs": ["60\n"], "source_document_id": "p03762", "source_text": "Score : 500 points\n\nProblem Statement\n\nOn a two-dimensional plane, there are m lines drawn parallel to the x axis, and n lines drawn parallel to the y axis.\nAmong the lines parallel to the x axis, the i-th from the bottom is represented by y = y_i.\nSimilarly, among the lines parallel to the y axis, the i-th from the left is represented by x = x_i.\n\nFor every rectangle that is formed by these lines, find its area, and print the total area modulo 10^9+7.\n\nThat is, for every quadruple (i,j,k,l) satisfying 1\\leq i < j\\leq n and 1\\leq k < l\\leq m, find the area of the rectangle formed by the lines x=x_i, x=x_j, y=y_k and y=y_l, and print the sum of these areas modulo 10^9+7.\n\nConstraints\n\n2 \\leq n,m \\leq 10^5\n\n-10^9 \\leq x_1 < ... < x_n \\leq 10^9\n\n-10^9 \\leq y_1 < ... < y_m \\leq 10^9\n\nx_i and y_i are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nn m\nx_1 x_2 ... x_n\ny_1 y_2 ... y_m\n\nOutput\n\nPrint the total area of the rectangles, modulo 10^9+7.\n\nSample Input 1\n\n3 3\n1 3 4\n1 3 6\n\nSample Output 1\n\n60\n\nThe following figure illustrates this input:\n\nThe total area of the nine rectangles A, B, ..., I shown in the following figure, is 60.\n\nSample Input 2\n\n6 5\n-790013317 -192321079 95834122 418379342 586260100 802780784\n-253230108 193944314 363756450 712662868 735867677\n\nSample Output 2\n\n835067060", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 788, "memory_kb": 90932}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s004365721", "group_id": "codeNet:p03767", "input_text": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n\n val n = sc.nextInt()\n val a = Array(3 * n) { sc.nextLong() }\n\n a.sort()\n var ans = 0L\n\n for (i in 0 until n) {\n ans += a[3 * n - 2 * i - 2]\n }\n println(ans)\n}\n", "language": "Kotlin", "metadata": {"date": 1543106248, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03767.html", "problem_id": "p03767", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03767/input.txt", "sample_output_relpath": "derived/input_output/data/p03767/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03767/Kotlin/s004365721.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s004365721", "user_id": "u323680411"}, "prompt_components": {"gold_output": "10\n", "input_to_evaluate": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n\n val n = sc.nextInt()\n val a = Array(3 * n) { sc.nextLong() }\n\n a.sort()\n var ans = 0L\n\n for (i in 0 until n) {\n ans += a[3 * n - 2 * i - 2]\n }\n println(ans)\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere are 3N participants in AtCoder Group Contest.\nThe strength of the i-th participant is represented by an integer a_i.\nThey will form N teams, each consisting of three participants.\nNo participant may belong to multiple teams.\n\nThe strength of a team is defined as the second largest strength among its members.\nFor example, a team of participants of strength 1, 5, 2 has a strength 2, and a team of three participants of strength 3, 2, 3 has a strength 3.\n\nFind the maximum possible sum of the strengths of N teams.\n\nConstraints\n\n1 ≤ N ≤ 10^5\n\n1 ≤ a_i ≤ 10^{9}\n\na_i are integers.\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 answer.\n\nSample Input 1\n\n2\n5 2 8 5 1 5\n\nSample Output 1\n\n10\n\nThe following is one formation of teams that maximizes the sum of the strengths of teams:\n\nTeam 1: consists of the first, fourth and fifth participants.\n\nTeam 2: consists of the second, third and sixth participants.\n\nSample Input 2\n\n10\n1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000\n\nSample Output 2\n\n10000000000\n\nThe sum of the strengths can be quite large.", "sample_input": "2\n5 2 8 5 1 5\n"}, "reference_outputs": ["10\n"], "source_document_id": "p03767", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere are 3N participants in AtCoder Group Contest.\nThe strength of the i-th participant is represented by an integer a_i.\nThey will form N teams, each consisting of three participants.\nNo participant may belong to multiple teams.\n\nThe strength of a team is defined as the second largest strength among its members.\nFor example, a team of participants of strength 1, 5, 2 has a strength 2, and a team of three participants of strength 3, 2, 3 has a strength 3.\n\nFind the maximum possible sum of the strengths of N teams.\n\nConstraints\n\n1 ≤ N ≤ 10^5\n\n1 ≤ a_i ≤ 10^{9}\n\na_i are integers.\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 answer.\n\nSample Input 1\n\n2\n5 2 8 5 1 5\n\nSample Output 1\n\n10\n\nThe following is one formation of teams that maximizes the sum of the strengths of teams:\n\nTeam 1: consists of the first, fourth and fifth participants.\n\nTeam 2: consists of the second, third and sixth participants.\n\nSample Input 2\n\n10\n1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000\n\nSample Output 2\n\n10000000000\n\nThe sum of the strengths can be quite large.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1332, "memory_kb": 118828}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s118344366", "group_id": "codeNet:p03774", "input_text": "import java.io.BufferedReader\nimport java.io.PrintWriter\nimport java.lang.StrictMath.abs\n\n\nvar out: PrintWriter = PrintWriter(System.out) // これを使って出力すると早い\nfun main(args: Array) {\n try {\n val nm = ReadLib.readIntArray()\n val abs = ReadLib.readNTimesIntArray(nm[0])\n\n val checkPoint = IntArray(nm[0])\n\n val cds = ReadLib.readNTimesIntArray(nm[1])\n\n for(i in 0 until nm[0]){\n var minD = Int.MAX_VALUE\n val ab = abs[i]\n for (j in 0 until nm[1]){\n val cd = cds[j]\n val d = abs(ab[0] - cd[0]) + abs(ab[1] - cd[1])\n if (minD > d){\n minD = d\n checkPoint[i] = j\n }\n }\n }\n checkPoint.forEach { out.println(it + 1) }\n } finally {\n out.flush() // 消さない\n }\n}\n\n/**\n * 読み取り\n */\nclass ReadLib {\n companion object {\n private var reader: BufferedReader = System.`in`.bufferedReader()\n\n fun reset() {\n reader = System.`in`.bufferedReader()\n }\n\n fun readInt(): Int {\n return Integer.parseInt(reader.readLine())\n }\n\n // Int\n fun readIntArray(delimiters: String = \" \"): IntArray {\n return reader\n .readLine()\n .split(delimiters)\n .map { s -> Integer.parseInt(s) }\n .toIntArray()\n }\n\n fun readNTimesInt(n: Int): IntArray {\n return (1..n).map { readInt() }.toIntArray()\n }\n\n fun readNTimesIntArray(n: Int): Array {\n return (1..n).map { readIntArray() }.toTypedArray()\n }\n\n // long\n // TODO 別の方法を考える\n fun readLong(): Long {\n return reader.readLine().toLong()\n }\n\n fun readLongArray(delimiters: String = \" \"): LongArray {\n return reader.readLine()\n .split(delimiters)\n .map { s -> s.toLong() }\n .toLongArray()\n }\n\n fun readNTimesLong(n: Int): LongArray {\n return (1..n).map { readLong() }.toLongArray()\n }\n\n fun readString(): String {\n return reader.readLine()\n }\n\n fun readStringArray(delimiters: String = \" \"): Array {\n return readString().split(delimiters).toTypedArray()\n }\n\n fun readNTimesCharArray(n: Int): Array {\n return (1..n).map { readString().toCharArray() }.toTypedArray()\n }\n\n fun readNTimesString(n: Int): Array {\n return (1..n).map { readString() }.toTypedArray()\n }\n\n }\n}\n\n/**\n * 要素とその個数を出力\n */\nfun Array.ofCountMap(): Map {\n return this.groupBy { it }.mapValues { it.value.count() }\n}\n\n/**\n * 文字とその個数を出力\n */\nfun String.ofCountMap(): Map {\n return this.toCharArray().ofCountMap()\n}\n\n/**\n * 文字とその個数を出力\n */\nfun CharArray.ofCountMap(): Map {\n return this.groupBy { it }.mapValues { it.value.count() }\n}\n\n/**\n * Combination, nCk mod p を求める\n * https://ja.wikipedia.org/wiki/%E3%83%A2%E3%82%B8%E3%83%A5%E3%83%A9%E9%80%86%E6%95%B0\n * http://drken1215.hatenablog.com/entry/2018/06/08/210000\n * @param maxN 最大のn\n * @param mod 素数p\n */\nclass ModCombination(private val maxN: Int, private val mod: Int = 1000000007) {\n val fac: IntArray = IntArray(maxN)\n val finv: IntArray = IntArray(maxN)\n\n init {\n val inv: IntArray = IntArray(maxN)\n fac[0] = 1\n fac[1] = 1\n\n inv[0] = 1\n inv[1] = 1\n for (i in 2..maxN) {\n fac[i] = fac[i - 1] * i % mod // 累積\n // mod % i < i\n inv[i] = mod - ((inv[mod % i].toLong()) * (mod / i) % mod).toInt()\n finv[i] = finv[i - 1] * inv[i] % mod\n }\n }\n\n /**\n * nCk mod p\n */\n fun Calc(n: Int, k: Int): Int {\n if (n < k || n < 0 || k < 0) {\n return 0\n }\n\n return ((fac[n].toLong() * finv[k] % mod) * finv[n - k] % mod).toInt()\n }\n}\n\nclass MyMath {\n companion object {\n fun gcd(m: Long, n: Long): Long {\n var M = m\n var N = n\n while (M % N > 0) {\n val pN = N\n N = M % N\n M = pN\n }\n return N\n }\n }\n}", "language": "Kotlin", "metadata": {"date": 1570998081, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03774.html", "problem_id": "p03774", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03774/input.txt", "sample_output_relpath": "derived/input_output/data/p03774/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03774/Kotlin/s118344366.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s118344366", "user_id": "u368201579"}, "prompt_components": {"gold_output": "2\n1\n", "input_to_evaluate": "import java.io.BufferedReader\nimport java.io.PrintWriter\nimport java.lang.StrictMath.abs\n\n\nvar out: PrintWriter = PrintWriter(System.out) // これを使って出力すると早い\nfun main(args: Array) {\n try {\n val nm = ReadLib.readIntArray()\n val abs = ReadLib.readNTimesIntArray(nm[0])\n\n val checkPoint = IntArray(nm[0])\n\n val cds = ReadLib.readNTimesIntArray(nm[1])\n\n for(i in 0 until nm[0]){\n var minD = Int.MAX_VALUE\n val ab = abs[i]\n for (j in 0 until nm[1]){\n val cd = cds[j]\n val d = abs(ab[0] - cd[0]) + abs(ab[1] - cd[1])\n if (minD > d){\n minD = d\n checkPoint[i] = j\n }\n }\n }\n checkPoint.forEach { out.println(it + 1) }\n } finally {\n out.flush() // 消さない\n }\n}\n\n/**\n * 読み取り\n */\nclass ReadLib {\n companion object {\n private var reader: BufferedReader = System.`in`.bufferedReader()\n\n fun reset() {\n reader = System.`in`.bufferedReader()\n }\n\n fun readInt(): Int {\n return Integer.parseInt(reader.readLine())\n }\n\n // Int\n fun readIntArray(delimiters: String = \" \"): IntArray {\n return reader\n .readLine()\n .split(delimiters)\n .map { s -> Integer.parseInt(s) }\n .toIntArray()\n }\n\n fun readNTimesInt(n: Int): IntArray {\n return (1..n).map { readInt() }.toIntArray()\n }\n\n fun readNTimesIntArray(n: Int): Array {\n return (1..n).map { readIntArray() }.toTypedArray()\n }\n\n // long\n // TODO 別の方法を考える\n fun readLong(): Long {\n return reader.readLine().toLong()\n }\n\n fun readLongArray(delimiters: String = \" \"): LongArray {\n return reader.readLine()\n .split(delimiters)\n .map { s -> s.toLong() }\n .toLongArray()\n }\n\n fun readNTimesLong(n: Int): LongArray {\n return (1..n).map { readLong() }.toLongArray()\n }\n\n fun readString(): String {\n return reader.readLine()\n }\n\n fun readStringArray(delimiters: String = \" \"): Array {\n return readString().split(delimiters).toTypedArray()\n }\n\n fun readNTimesCharArray(n: Int): Array {\n return (1..n).map { readString().toCharArray() }.toTypedArray()\n }\n\n fun readNTimesString(n: Int): Array {\n return (1..n).map { readString() }.toTypedArray()\n }\n\n }\n}\n\n/**\n * 要素とその個数を出力\n */\nfun Array.ofCountMap(): Map {\n return this.groupBy { it }.mapValues { it.value.count() }\n}\n\n/**\n * 文字とその個数を出力\n */\nfun String.ofCountMap(): Map {\n return this.toCharArray().ofCountMap()\n}\n\n/**\n * 文字とその個数を出力\n */\nfun CharArray.ofCountMap(): Map {\n return this.groupBy { it }.mapValues { it.value.count() }\n}\n\n/**\n * Combination, nCk mod p を求める\n * https://ja.wikipedia.org/wiki/%E3%83%A2%E3%82%B8%E3%83%A5%E3%83%A9%E9%80%86%E6%95%B0\n * http://drken1215.hatenablog.com/entry/2018/06/08/210000\n * @param maxN 最大のn\n * @param mod 素数p\n */\nclass ModCombination(private val maxN: Int, private val mod: Int = 1000000007) {\n val fac: IntArray = IntArray(maxN)\n val finv: IntArray = IntArray(maxN)\n\n init {\n val inv: IntArray = IntArray(maxN)\n fac[0] = 1\n fac[1] = 1\n\n inv[0] = 1\n inv[1] = 1\n for (i in 2..maxN) {\n fac[i] = fac[i - 1] * i % mod // 累積\n // mod % i < i\n inv[i] = mod - ((inv[mod % i].toLong()) * (mod / i) % mod).toInt()\n finv[i] = finv[i - 1] * inv[i] % mod\n }\n }\n\n /**\n * nCk mod p\n */\n fun Calc(n: Int, k: Int): Int {\n if (n < k || n < 0 || k < 0) {\n return 0\n }\n\n return ((fac[n].toLong() * finv[k] % mod) * finv[n - k] % mod).toInt()\n }\n}\n\nclass MyMath {\n companion object {\n fun gcd(m: Long, n: Long): Long {\n var M = m\n var N = n\n while (M % N > 0) {\n val pN = N\n N = M % N\n M = pN\n }\n return N\n }\n }\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nThere are N students and M checkpoints on the xy-plane.\n\nThe coordinates of the i-th student (1 \\leq i \\leq N) is (a_i,b_i), and the coordinates of the checkpoint numbered j (1 \\leq j \\leq M) is (c_j,d_j).\n\nWhen the teacher gives a signal, each student has to go to the nearest checkpoint measured in Manhattan distance.\n\nThe Manhattan distance between two points (x_1,y_1) and (x_2,y_2) is |x_1-x_2|+|y_1-y_2|.\n\nHere, |x| denotes the absolute value of x.\n\nIf there are multiple nearest checkpoints for a student, he/she will select the checkpoint with the smallest index.\n\nWhich checkpoint will each student go to?\n\nConstraints\n\n1 \\leq N,M \\leq 50\n\n-10^8 \\leq a_i,b_i,c_j,d_j \\leq 10^8\n\nAll input values are integers.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN M\na_1 b_1\n:\na_N b_N\nc_1 d_1\n:\nc_M d_M\n\nOutput\n\nPrint N lines.\n\nThe i-th line (1 \\leq i \\leq N) should contain the index of the checkpoint for the i-th student to go.\n\nSample Input 1\n\n2 2\n2 0\n0 0\n-1 0\n1 0\n\nSample Output 1\n\n2\n1\n\nThe Manhattan distance between the first student and each checkpoint is:\n\nFor checkpoint 1: |2-(-1)|+|0-0|=3\n\nFor checkpoint 2: |2-1|+|0-0|=1\n\nThe nearest checkpoint is checkpoint 2. Thus, the first line in the output should contain 2.\n\nThe Manhattan distance between the second student and each checkpoint is:\n\nFor checkpoint 1: |0-(-1)|+|0-0|=1\n\nFor checkpoint 2: |0-1|+|0-0|=1\n\nWhen there are multiple nearest checkpoints, the student will go to the checkpoint with the smallest index. Thus, the second line in the output should contain 1.\n\nSample Input 2\n\n3 4\n10 10\n-10 -10\n3 3\n1 2\n2 3\n3 5\n3 5\n\nSample Output 2\n\n3\n1\n2\n\nThere can be multiple checkpoints at the same coordinates.\n\nSample Input 3\n\n5 5\n-100000000 -100000000\n-100000000 100000000\n100000000 -100000000\n100000000 100000000\n0 0\n0 0\n100000000 100000000\n100000000 -100000000\n-100000000 100000000\n-100000000 -100000000\n\nSample Output 3\n\n5\n4\n3\n2\n1", "sample_input": "2 2\n2 0\n0 0\n-1 0\n1 0\n"}, "reference_outputs": ["2\n1\n"], "source_document_id": "p03774", "source_text": "Score : 200 points\n\nProblem Statement\n\nThere are N students and M checkpoints on the xy-plane.\n\nThe coordinates of the i-th student (1 \\leq i \\leq N) is (a_i,b_i), and the coordinates of the checkpoint numbered j (1 \\leq j \\leq M) is (c_j,d_j).\n\nWhen the teacher gives a signal, each student has to go to the nearest checkpoint measured in Manhattan distance.\n\nThe Manhattan distance between two points (x_1,y_1) and (x_2,y_2) is |x_1-x_2|+|y_1-y_2|.\n\nHere, |x| denotes the absolute value of x.\n\nIf there are multiple nearest checkpoints for a student, he/she will select the checkpoint with the smallest index.\n\nWhich checkpoint will each student go to?\n\nConstraints\n\n1 \\leq N,M \\leq 50\n\n-10^8 \\leq a_i,b_i,c_j,d_j \\leq 10^8\n\nAll input values are integers.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN M\na_1 b_1\n:\na_N b_N\nc_1 d_1\n:\nc_M d_M\n\nOutput\n\nPrint N lines.\n\nThe i-th line (1 \\leq i \\leq N) should contain the index of the checkpoint for the i-th student to go.\n\nSample Input 1\n\n2 2\n2 0\n0 0\n-1 0\n1 0\n\nSample Output 1\n\n2\n1\n\nThe Manhattan distance between the first student and each checkpoint is:\n\nFor checkpoint 1: |2-(-1)|+|0-0|=3\n\nFor checkpoint 2: |2-1|+|0-0|=1\n\nThe nearest checkpoint is checkpoint 2. Thus, the first line in the output should contain 2.\n\nThe Manhattan distance between the second student and each checkpoint is:\n\nFor checkpoint 1: |0-(-1)|+|0-0|=1\n\nFor checkpoint 2: |0-1|+|0-0|=1\n\nWhen there are multiple nearest checkpoints, the student will go to the checkpoint with the smallest index. Thus, the second line in the output should contain 1.\n\nSample Input 2\n\n3 4\n10 10\n-10 -10\n3 3\n1 2\n2 3\n3 5\n3 5\n\nSample Output 2\n\n3\n1\n2\n\nThere can be multiple checkpoints at the same coordinates.\n\nSample Input 3\n\n5 5\n-100000000 -100000000\n-100000000 100000000\n100000000 -100000000\n100000000 100000000\n0 0\n0 0\n100000000 100000000\n100000000 -100000000\n-100000000 100000000\n-100000000 -100000000\n\nSample Output 3\n\n5\n4\n3\n2\n1", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 4451, "cpu_time_ms": 237, "memory_kb": 35904}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s320254216", "group_id": "codeNet:p03775", "input_text": "import kotlin.math.sqrt\n\nfun main() {\n var n = readLine()!!.toLong()\n if (n < 10) {\n print(1)\n return\n }\n\n val x = sqrt(n.toDouble()).toInt()\n\n var i = 1L\n\n var divs = mutableListOf()\n var answer = Int.MAX_VALUE\n while (i <= x) {\n if ( n % i == 0L) {\n val a= i.toString().toCharArray().size\n val b= (n/i).toString().toCharArray().size\n val max = if (a < b ) b else a\n\n if (max < answer) {\n answer = max\n }\n }\n i+= 1\n }\n\n print(answer)\n\n}", "language": "Kotlin", "metadata": {"date": 1592965439, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p03775.html", "problem_id": "p03775", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03775/input.txt", "sample_output_relpath": "derived/input_output/data/p03775/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03775/Kotlin/s320254216.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s320254216", "user_id": "u542748657"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "import kotlin.math.sqrt\n\nfun main() {\n var n = readLine()!!.toLong()\n if (n < 10) {\n print(1)\n return\n }\n\n val x = sqrt(n.toDouble()).toInt()\n\n var i = 1L\n\n var divs = mutableListOf()\n var answer = Int.MAX_VALUE\n while (i <= x) {\n if ( n % i == 0L) {\n val a= i.toString().toCharArray().size\n val b= (n/i).toString().toCharArray().size\n val max = if (a < b ) b else a\n\n if (max < answer) {\n answer = max\n }\n }\n i+= 1\n }\n\n print(answer)\n\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nYou are given an integer N.\n\nFor two positive integers A and B, we will define F(A,B) as the larger of the following: the number of digits in the decimal notation of A, and the number of digits in the decimal notation of B.\n\nFor example, F(3,11) = 2 since 3 has one digit and 11 has two digits.\n\nFind the minimum value of F(A,B) as (A,B) ranges over all pairs of positive integers such that N = A \\times B.\n\nConstraints\n\n1 \\leq N \\leq 10^{10}\n\nN is an integer.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the minimum value of F(A,B) as (A,B) ranges over all pairs of positive integers such that N = A \\times B.\n\nSample Input 1\n\n10000\n\nSample Output 1\n\n3\n\nF(A,B) has a minimum value of 3 at (A,B)=(100,100).\n\nSample Input 2\n\n1000003\n\nSample Output 2\n\n7\n\nThere are two pairs (A,B) that satisfy the condition: (1,1000003) and (1000003,1). For these pairs, F(1,1000003)=F(1000003,1)=7.\n\nSample Input 3\n\n9876543210\n\nSample Output 3\n\n6", "sample_input": "10000\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03775", "source_text": "Score : 300 points\n\nProblem Statement\n\nYou are given an integer N.\n\nFor two positive integers A and B, we will define F(A,B) as the larger of the following: the number of digits in the decimal notation of A, and the number of digits in the decimal notation of B.\n\nFor example, F(3,11) = 2 since 3 has one digit and 11 has two digits.\n\nFind the minimum value of F(A,B) as (A,B) ranges over all pairs of positive integers such that N = A \\times B.\n\nConstraints\n\n1 \\leq N \\leq 10^{10}\n\nN is an integer.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the minimum value of F(A,B) as (A,B) ranges over all pairs of positive integers such that N = A \\times B.\n\nSample Input 1\n\n10000\n\nSample Output 1\n\n3\n\nF(A,B) has a minimum value of 3 at (A,B)=(100,100).\n\nSample Input 2\n\n1000003\n\nSample Output 2\n\n7\n\nThere are two pairs (A,B) that satisfy the condition: (1,1000003) and (1000003,1). For these pairs, F(1,1000003)=F(1000003,1)=7.\n\nSample Input 3\n\n9876543210\n\nSample Output 3\n\n6", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 577, "cpu_time_ms": 104, "memory_kb": 34616}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s751122897", "group_id": "codeNet:p03775", "input_text": "fun main(args: Array) {\n val n = readLine()!!.toLong()\n var a = 0\n var b = 0\n for(i in 1 .. Math.sqrt(n.toDouble()).toInt()){\n b = (n / i.toLong()).toInt()\n if((i * b).toLong() == n){\n a = Math.max(a, Math.max(i, b).toString().count())\n }\n }\n println(a)\n}", "language": "Kotlin", "metadata": {"date": 1556765790, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03775.html", "problem_id": "p03775", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03775/input.txt", "sample_output_relpath": "derived/input_output/data/p03775/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03775/Kotlin/s751122897.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s751122897", "user_id": "u227189389"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "fun main(args: Array) {\n val n = readLine()!!.toLong()\n var a = 0\n var b = 0\n for(i in 1 .. Math.sqrt(n.toDouble()).toInt()){\n b = (n / i.toLong()).toInt()\n if((i * b).toLong() == n){\n a = Math.max(a, Math.max(i, b).toString().count())\n }\n }\n println(a)\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nYou are given an integer N.\n\nFor two positive integers A and B, we will define F(A,B) as the larger of the following: the number of digits in the decimal notation of A, and the number of digits in the decimal notation of B.\n\nFor example, F(3,11) = 2 since 3 has one digit and 11 has two digits.\n\nFind the minimum value of F(A,B) as (A,B) ranges over all pairs of positive integers such that N = A \\times B.\n\nConstraints\n\n1 \\leq N \\leq 10^{10}\n\nN is an integer.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the minimum value of F(A,B) as (A,B) ranges over all pairs of positive integers such that N = A \\times B.\n\nSample Input 1\n\n10000\n\nSample Output 1\n\n3\n\nF(A,B) has a minimum value of 3 at (A,B)=(100,100).\n\nSample Input 2\n\n1000003\n\nSample Output 2\n\n7\n\nThere are two pairs (A,B) that satisfy the condition: (1,1000003) and (1000003,1). For these pairs, F(1,1000003)=F(1000003,1)=7.\n\nSample Input 3\n\n9876543210\n\nSample Output 3\n\n6", "sample_input": "10000\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03775", "source_text": "Score : 300 points\n\nProblem Statement\n\nYou are given an integer N.\n\nFor two positive integers A and B, we will define F(A,B) as the larger of the following: the number of digits in the decimal notation of A, and the number of digits in the decimal notation of B.\n\nFor example, F(3,11) = 2 since 3 has one digit and 11 has two digits.\n\nFind the minimum value of F(A,B) as (A,B) ranges over all pairs of positive integers such that N = A \\times B.\n\nConstraints\n\n1 \\leq N \\leq 10^{10}\n\nN is an integer.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the minimum value of F(A,B) as (A,B) ranges over all pairs of positive integers such that N = A \\times B.\n\nSample Input 1\n\n10000\n\nSample Output 1\n\n3\n\nF(A,B) has a minimum value of 3 at (A,B)=(100,100).\n\nSample Input 2\n\n1000003\n\nSample Output 2\n\n7\n\nThere are two pairs (A,B) that satisfy the condition: (1,1000003) and (1000003,1). For these pairs, F(1,1000003)=F(1000003,1)=7.\n\nSample Input 3\n\n9876543210\n\nSample Output 3\n\n6", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 313, "cpu_time_ms": 262, "memory_kb": 31740}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s125789745", "group_id": "codeNet:p03776", "input_text": "import java.io.PrintWriter\n\nfun main(args: Array) {\n PrintWriter(System.out).use { out ->\n solve(out)\n out.flush()\n }\n}\n\nfun solve(out: PrintWriter) {\n val (n, a, b) = readIntegerList()\n val vList = readLongList().sortedDescending()\n\n println(vList.take(a).average())\n\n val c =pascalTriangle()\n if (vList.first() == vList[a - 1]) {\n val maxCount = vList.count { it == vList.first() }\n var ans = 0L\n for (i in a..b) {\n ans += c[maxCount][i]\n }\n println(ans)\n } else {\n val count = vList.count { it == vList[a - 1] }\n val i = vList.lastIndexOf(vList[a - 1]) + 1\n println(c[count][count - (i - a)])\n }\n}\n\n/**\n * O(n^2): n <= 10000\n * table[n][m]: nCm\n */\nfun pascalTriangle(size: Int = 10000, MOD: Long = ((1L shl 62) - 1)): Array {\n val table = Array(size + 1) { LongArray(size + 1) }\n table[0][0] = 1L\n for (i in 0 until size) {\n for (j in 0..i) {\n val tmp = table[i][j]\n table[i + 1][j] = (table[i + 1][j] + tmp) % MOD\n table[i + 1][j + 1] = (table[i + 1][j + 1] + tmp) % MOD\n }\n }\n return table\n}\n\nfun readInteger() = readLine()!!.toInt()\nfun readLong() = readLine()!!.toLong()\nfun readStringList() = readLine()!!.split(\" \")\nfun readIntegerList() = readStringList().map(String::toInt)\nfun readLongList() = readStringList().map(String::toLong)\nfun readDoubleList() = readStringList().map(String::toDouble)\n", "language": "Kotlin", "metadata": {"date": 1591417768, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03776.html", "problem_id": "p03776", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03776/input.txt", "sample_output_relpath": "derived/input_output/data/p03776/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03776/Kotlin/s125789745.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Memory Limit Exceeded", "submission_id": "s125789745", "user_id": "u784448849"}, "prompt_components": {"gold_output": "4.500000\n1\n", "input_to_evaluate": "import java.io.PrintWriter\n\nfun main(args: Array) {\n PrintWriter(System.out).use { out ->\n solve(out)\n out.flush()\n }\n}\n\nfun solve(out: PrintWriter) {\n val (n, a, b) = readIntegerList()\n val vList = readLongList().sortedDescending()\n\n println(vList.take(a).average())\n\n val c =pascalTriangle()\n if (vList.first() == vList[a - 1]) {\n val maxCount = vList.count { it == vList.first() }\n var ans = 0L\n for (i in a..b) {\n ans += c[maxCount][i]\n }\n println(ans)\n } else {\n val count = vList.count { it == vList[a - 1] }\n val i = vList.lastIndexOf(vList[a - 1]) + 1\n println(c[count][count - (i - a)])\n }\n}\n\n/**\n * O(n^2): n <= 10000\n * table[n][m]: nCm\n */\nfun pascalTriangle(size: Int = 10000, MOD: Long = ((1L shl 62) - 1)): Array {\n val table = Array(size + 1) { LongArray(size + 1) }\n table[0][0] = 1L\n for (i in 0 until size) {\n for (j in 0..i) {\n val tmp = table[i][j]\n table[i + 1][j] = (table[i + 1][j] + tmp) % MOD\n table[i + 1][j + 1] = (table[i + 1][j + 1] + tmp) % MOD\n }\n }\n return table\n}\n\nfun readInteger() = readLine()!!.toInt()\nfun readLong() = readLine()!!.toLong()\nfun readStringList() = readLine()!!.split(\" \")\nfun readIntegerList() = readStringList().map(String::toInt)\nfun readLongList() = readStringList().map(String::toLong)\nfun readDoubleList() = readStringList().map(String::toDouble)\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nYou are given N items.\n\nThe value of the i-th item (1 \\leq i \\leq N) is v_i.\n\nYour have to select at least A and at most B of these items.\n\nUnder this condition, find the maximum possible arithmetic mean of the values of selected items.\n\nAdditionally, find the number of ways to select items so that the mean of the values of selected items is maximized.\n\nConstraints\n\n1 \\leq N \\leq 50\n\n1 \\leq A,B \\leq N\n\n1 \\leq v_i \\leq 10^{15}\n\nEach v_i is an integer.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN A B\nv_1\nv_2\n...\nv_N\n\nOutput\n\nPrint two lines.\n\nThe first line should contain the maximum possible arithmetic mean of the values of selected items. The output should be considered correct if the absolute or relative error is at most 10^{-6}.\n\nThe second line should contain the number of ways to select items so that the mean of the values of selected items is maximized.\n\nSample Input 1\n\n5 2 2\n1 2 3 4 5\n\nSample Output 1\n\n4.500000\n1\n\nThe mean of the values of selected items will be maximized when selecting the fourth and fifth items. Hence, the first line of the output should contain 4.5.\n\nThere is no other way to select items so that the mean of the values will be 4.5, and thus the second line of the output should contain 1.\n\nSample Input 2\n\n4 2 3\n10 20 10 10\n\nSample Output 2\n\n15.000000\n3\n\nThere can be multiple ways to select items so that the mean of the values will be maximized.\n\nSample Input 3\n\n5 1 5\n1000000000000000 999999999999999 999999999999998 999999999999997 999999999999996\n\nSample Output 3\n\n1000000000000000.000000\n1", "sample_input": "5 2 2\n1 2 3 4 5\n"}, "reference_outputs": ["4.500000\n1\n"], "source_document_id": "p03776", "source_text": "Score : 400 points\n\nProblem Statement\n\nYou are given N items.\n\nThe value of the i-th item (1 \\leq i \\leq N) is v_i.\n\nYour have to select at least A and at most B of these items.\n\nUnder this condition, find the maximum possible arithmetic mean of the values of selected items.\n\nAdditionally, find the number of ways to select items so that the mean of the values of selected items is maximized.\n\nConstraints\n\n1 \\leq N \\leq 50\n\n1 \\leq A,B \\leq N\n\n1 \\leq v_i \\leq 10^{15}\n\nEach v_i is an integer.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN A B\nv_1\nv_2\n...\nv_N\n\nOutput\n\nPrint two lines.\n\nThe first line should contain the maximum possible arithmetic mean of the values of selected items. The output should be considered correct if the absolute or relative error is at most 10^{-6}.\n\nThe second line should contain the number of ways to select items so that the mean of the values of selected items is maximized.\n\nSample Input 1\n\n5 2 2\n1 2 3 4 5\n\nSample Output 1\n\n4.500000\n1\n\nThe mean of the values of selected items will be maximized when selecting the fourth and fifth items. Hence, the first line of the output should contain 4.5.\n\nThere is no other way to select items so that the mean of the values will be 4.5, and thus the second line of the output should contain 1.\n\nSample Input 2\n\n4 2 3\n10 20 10 10\n\nSample Output 2\n\n15.000000\n3\n\nThere can be multiple ways to select items so that the mean of the values will be maximized.\n\nSample Input 3\n\n5 1 5\n1000000000000000 999999999999999 999999999999998 999999999999997 999999999999996\n\nSample Output 3\n\n1000000000000000.000000\n1", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1495, "cpu_time_ms": 468, "memory_kb": 304368}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s353349457", "group_id": "codeNet:p03776", "input_text": "import java.math.BigInteger\n\n//nCk\nfun main(args: Array) {\n fun nCk(n: Long, k: Long): Long {\n var mom = BigInteger.valueOf(1)\n var chi = BigInteger.valueOf(1)\n val min = Math.min(k, n - k)\n for (i in 0 until min) {\n mom *= BigInteger.valueOf((min - i))\n chi *= BigInteger.valueOf((n - i))\n }\n return (chi / mom).toLong()\n }\n val (n, a, b) = readLine()!!.split(' ').map(String::toInt)\n val vList = readLine()!!.split(' ').map(String::toLong).sortedDescending()\n\n val valList = mutableListOf>()\n for (i in a..b) {\n val take = vList.take(i)\n val average = take.average()\n valList.add(Pair(i, average))\n }\n val maxValue = valList.maxBy { it.second }!!.second\n val ansIndexes = valList.filter { it.second in maxValue - 0.0001..maxValue + 0.0001 }.map { it.first }\n var pattern = 0L\n for (i in ansIndexes) {\n val take = vList.take(i)\n val takeLastCount = take.count { it == take.last() }\n val vCount = vList.count { it == take.last() }\n pattern += nCk(vCount.toLong(), takeLastCount.toLong())\n }\n println(maxValue)\n println(pattern)\n}", "language": "Kotlin", "metadata": {"date": 1577238433, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03776.html", "problem_id": "p03776", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03776/input.txt", "sample_output_relpath": "derived/input_output/data/p03776/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03776/Kotlin/s353349457.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s353349457", "user_id": "u099066216"}, "prompt_components": {"gold_output": "4.500000\n1\n", "input_to_evaluate": "import java.math.BigInteger\n\n//nCk\nfun main(args: Array) {\n fun nCk(n: Long, k: Long): Long {\n var mom = BigInteger.valueOf(1)\n var chi = BigInteger.valueOf(1)\n val min = Math.min(k, n - k)\n for (i in 0 until min) {\n mom *= BigInteger.valueOf((min - i))\n chi *= BigInteger.valueOf((n - i))\n }\n return (chi / mom).toLong()\n }\n val (n, a, b) = readLine()!!.split(' ').map(String::toInt)\n val vList = readLine()!!.split(' ').map(String::toLong).sortedDescending()\n\n val valList = mutableListOf>()\n for (i in a..b) {\n val take = vList.take(i)\n val average = take.average()\n valList.add(Pair(i, average))\n }\n val maxValue = valList.maxBy { it.second }!!.second\n val ansIndexes = valList.filter { it.second in maxValue - 0.0001..maxValue + 0.0001 }.map { it.first }\n var pattern = 0L\n for (i in ansIndexes) {\n val take = vList.take(i)\n val takeLastCount = take.count { it == take.last() }\n val vCount = vList.count { it == take.last() }\n pattern += nCk(vCount.toLong(), takeLastCount.toLong())\n }\n println(maxValue)\n println(pattern)\n}", "problem_context": "Score : 400 points\n\nProblem Statement\n\nYou are given N items.\n\nThe value of the i-th item (1 \\leq i \\leq N) is v_i.\n\nYour have to select at least A and at most B of these items.\n\nUnder this condition, find the maximum possible arithmetic mean of the values of selected items.\n\nAdditionally, find the number of ways to select items so that the mean of the values of selected items is maximized.\n\nConstraints\n\n1 \\leq N \\leq 50\n\n1 \\leq A,B \\leq N\n\n1 \\leq v_i \\leq 10^{15}\n\nEach v_i is an integer.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN A B\nv_1\nv_2\n...\nv_N\n\nOutput\n\nPrint two lines.\n\nThe first line should contain the maximum possible arithmetic mean of the values of selected items. The output should be considered correct if the absolute or relative error is at most 10^{-6}.\n\nThe second line should contain the number of ways to select items so that the mean of the values of selected items is maximized.\n\nSample Input 1\n\n5 2 2\n1 2 3 4 5\n\nSample Output 1\n\n4.500000\n1\n\nThe mean of the values of selected items will be maximized when selecting the fourth and fifth items. Hence, the first line of the output should contain 4.5.\n\nThere is no other way to select items so that the mean of the values will be 4.5, and thus the second line of the output should contain 1.\n\nSample Input 2\n\n4 2 3\n10 20 10 10\n\nSample Output 2\n\n15.000000\n3\n\nThere can be multiple ways to select items so that the mean of the values will be maximized.\n\nSample Input 3\n\n5 1 5\n1000000000000000 999999999999999 999999999999998 999999999999997 999999999999996\n\nSample Output 3\n\n1000000000000000.000000\n1", "sample_input": "5 2 2\n1 2 3 4 5\n"}, "reference_outputs": ["4.500000\n1\n"], "source_document_id": "p03776", "source_text": "Score : 400 points\n\nProblem Statement\n\nYou are given N items.\n\nThe value of the i-th item (1 \\leq i \\leq N) is v_i.\n\nYour have to select at least A and at most B of these items.\n\nUnder this condition, find the maximum possible arithmetic mean of the values of selected items.\n\nAdditionally, find the number of ways to select items so that the mean of the values of selected items is maximized.\n\nConstraints\n\n1 \\leq N \\leq 50\n\n1 \\leq A,B \\leq N\n\n1 \\leq v_i \\leq 10^{15}\n\nEach v_i is an integer.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN A B\nv_1\nv_2\n...\nv_N\n\nOutput\n\nPrint two lines.\n\nThe first line should contain the maximum possible arithmetic mean of the values of selected items. The output should be considered correct if the absolute or relative error is at most 10^{-6}.\n\nThe second line should contain the number of ways to select items so that the mean of the values of selected items is maximized.\n\nSample Input 1\n\n5 2 2\n1 2 3 4 5\n\nSample Output 1\n\n4.500000\n1\n\nThe mean of the values of selected items will be maximized when selecting the fourth and fifth items. Hence, the first line of the output should contain 4.5.\n\nThere is no other way to select items so that the mean of the values will be 4.5, and thus the second line of the output should contain 1.\n\nSample Input 2\n\n4 2 3\n10 20 10 10\n\nSample Output 2\n\n15.000000\n3\n\nThere can be multiple ways to select items so that the mean of the values will be maximized.\n\nSample Input 3\n\n5 1 5\n1000000000000000 999999999999999 999999999999998 999999999999997 999999999999996\n\nSample Output 3\n\n1000000000000000.000000\n1", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1210, "cpu_time_ms": 253, "memory_kb": 38184}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s485029777", "group_id": "codeNet:p03777", "input_text": "fun main(args:Array) {\n val (a, b) = readLine()!!.split(\" \")\n when(a) {\n \"H\" -> {\n when(b) {\n \"H\" -> println(\"H\")\n \"D\" -> println(\"D\")\n }\n }\n \"D\" -> {\n when(b) {\n \"H\" -> println(\"D\")\n \"D\" -> println(\"H\")\n }\n }\n }\n}", "language": "Kotlin", "metadata": {"date": 1493117012, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03777.html", "problem_id": "p03777", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03777/input.txt", "sample_output_relpath": "derived/input_output/data/p03777/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03777/Kotlin/s485029777.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s485029777", "user_id": "u693048766"}, "prompt_components": {"gold_output": "H\n", "input_to_evaluate": "fun main(args:Array) {\n val (a, b) = readLine()!!.split(\" \")\n when(a) {\n \"H\" -> {\n when(b) {\n \"H\" -> println(\"H\")\n \"D\" -> println(\"D\")\n }\n }\n \"D\" -> {\n when(b) {\n \"H\" -> println(\"D\")\n \"D\" -> println(\"H\")\n }\n }\n }\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nTwo deer, AtCoDeer and TopCoDeer, are playing a game called Honest or Dishonest.\nIn this game, an honest player always tells the truth, and an dishonest player always tell lies.\nYou are given two characters a and b as the input. Each of them is either H or D, and carries the following information:\n\nIf a=H, AtCoDeer is honest; if a=D, AtCoDeer is dishonest.\nIf b=H, AtCoDeer is saying that TopCoDeer is honest; if b=D, AtCoDeer is saying that TopCoDeer is dishonest.\n\nGiven this information, determine whether TopCoDeer is honest.\n\nConstraints\n\na=H or a=D.\n\nb=H or b=D.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\na b\n\nOutput\n\nIf TopCoDeer is honest, print H. If he is dishonest, print D.\n\nSample Input 1\n\nH H\n\nSample Output 1\n\nH\n\nIn this input, AtCoDeer is honest. Hence, as he says, TopCoDeer is honest.\n\nSample Input 2\n\nD H\n\nSample Output 2\n\nD\n\nIn this input, AtCoDeer is dishonest. Hence, contrary to what he says, TopCoDeer is dishonest.\n\nSample Input 3\n\nD D\n\nSample Output 3\n\nH", "sample_input": "H H\n"}, "reference_outputs": ["H\n"], "source_document_id": "p03777", "source_text": "Score : 100 points\n\nProblem Statement\n\nTwo deer, AtCoDeer and TopCoDeer, are playing a game called Honest or Dishonest.\nIn this game, an honest player always tells the truth, and an dishonest player always tell lies.\nYou are given two characters a and b as the input. Each of them is either H or D, and carries the following information:\n\nIf a=H, AtCoDeer is honest; if a=D, AtCoDeer is dishonest.\nIf b=H, AtCoDeer is saying that TopCoDeer is honest; if b=D, AtCoDeer is saying that TopCoDeer is dishonest.\n\nGiven this information, determine whether TopCoDeer is honest.\n\nConstraints\n\na=H or a=D.\n\nb=H or b=D.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\na b\n\nOutput\n\nIf TopCoDeer is honest, print H. If he is dishonest, print D.\n\nSample Input 1\n\nH H\n\nSample Output 1\n\nH\n\nIn this input, AtCoDeer is honest. Hence, as he says, TopCoDeer is honest.\n\nSample Input 2\n\nD H\n\nSample Output 2\n\nD\n\nIn this input, AtCoDeer is dishonest. Hence, contrary to what he says, TopCoDeer is dishonest.\n\nSample Input 3\n\nD D\n\nSample Output 3\n\nH", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 233, "memory_kb": 28032}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s178186553", "group_id": "codeNet:p03778", "input_text": "import java.lang.Math.*\n\nfun main(args: Array) {\n val (w,a,b) =readLine()!!.split(\" \").map(String::toInt)\n println(max(max(a,b) - w - min(a,b),0))\n}", "language": "Kotlin", "metadata": {"date": 1542246168, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03778.html", "problem_id": "p03778", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03778/input.txt", "sample_output_relpath": "derived/input_output/data/p03778/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03778/Kotlin/s178186553.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s178186553", "user_id": "u227189389"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "import java.lang.Math.*\n\nfun main(args: Array) {\n val (w,a,b) =readLine()!!.split(\" \").map(String::toInt)\n println(max(max(a,b) - w - min(a,b),0))\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nAtCoDeer the deer found two rectangles lying on the table, each with height 1 and width W.\nIf we consider the surface of the desk as a two-dimensional plane, the first rectangle covers the vertical range of [0,1] and the horizontal range of [a,a+W], and the second rectangle covers the vertical range of [1,2] and the horizontal range of [b,b+W], as shown in the following figure:\n\nAtCoDeer will move the second rectangle horizontally so that it connects with the first rectangle.\nFind the minimum distance it needs to be moved.\n\nConstraints\n\nAll input values are integers.\n\n1≤W≤10^5\n\n1≤a,b≤10^5\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nW a b\n\nOutput\n\nPrint the minimum distance the second rectangle needs to be moved.\n\nSample Input 1\n\n3 2 6\n\nSample Output 1\n\n1\n\nThis input corresponds to the figure in the statement. In this case, the second rectangle should be moved to the left by a distance of 1.\n\nSample Input 2\n\n3 1 3\n\nSample Output 2\n\n0\n\nThe rectangles are already connected, and thus no move is needed.\n\nSample Input 3\n\n5 10 1\n\nSample Output 3\n\n4", "sample_input": "3 2 6\n"}, "reference_outputs": ["1\n"], "source_document_id": "p03778", "source_text": "Score : 200 points\n\nProblem Statement\n\nAtCoDeer the deer found two rectangles lying on the table, each with height 1 and width W.\nIf we consider the surface of the desk as a two-dimensional plane, the first rectangle covers the vertical range of [0,1] and the horizontal range of [a,a+W], and the second rectangle covers the vertical range of [1,2] and the horizontal range of [b,b+W], as shown in the following figure:\n\nAtCoDeer will move the second rectangle horizontally so that it connects with the first rectangle.\nFind the minimum distance it needs to be moved.\n\nConstraints\n\nAll input values are integers.\n\n1≤W≤10^5\n\n1≤a,b≤10^5\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nW a b\n\nOutput\n\nPrint the minimum distance the second rectangle needs to be moved.\n\nSample Input 1\n\n3 2 6\n\nSample Output 1\n\n1\n\nThis input corresponds to the figure in the statement. In this case, the second rectangle should be moved to the left by a distance of 1.\n\nSample Input 2\n\n3 1 3\n\nSample Output 2\n\n0\n\nThe rectangles are already connected, and thus no move is needed.\n\nSample Input 3\n\n5 10 1\n\nSample Output 3\n\n4", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 237, "memory_kb": 37624}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s422777902", "group_id": "codeNet:p03780", "input_text": "\nfun main() {\n val (n,k) = readLine()!!.split(\" \").map { it.toInt() }\n val arr = readLine()!!.split(\" \").map { it.toInt() }.sorted()\n\n val fdp = Array(n+1){BooleanArray(k)}\n val bdp = Array(n+1){BooleanArray(k)}\n\n\n for(i in 1..n) {\n fdp[i-1][0] = true\n val v = arr[i - 1]\n for(j in 1 until k) {\n if(j - v < 0) continue\n fdp[i][j] = fdp[i-1][j] or fdp[i-1][j-v]\n }\n }\n\n for(i in 1..n) {\n bdp[i-1][0] = true\n val v = arr[n - i]\n for(j in 1 until k) {\n if(j - v < 0) continue\n bdp[i][j] = bdp[i-1][j] or bdp[i-1][j-v]\n }\n }\n\n var ans = 0\n for(i in 0 until n) {\n if(arr[i] >= k)\n continue\n var fmin = 0\n var fmax = 0\n var bmin = 0\n var bmax = 0\n\n val f = fdp[i]\n val b = bdp[n - 1 - i]\n\n for(j in 1 until k){\n if(fmin == 0 && f[j]) {\n fmin = j\n }\n if(bmin == 0 && b[j]) {\n bmin = j\n }\n }\n for(j in k - 1 downTo 1) {\n if(fmax == 0 && f[j]) {\n fmax = j\n }\n if(bmax == 0 && b[j]) {\n bmax = j\n }\n }\n val l = fmin + bmin\n val r = fmax + bmax\n if(k - arr[i] > r || k - 1 < l) {\n ++ans\n }\n }\n print(ans)\n\n\n}", "language": "Kotlin", "metadata": {"date": 1596032402, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p03780.html", "problem_id": "p03780", "resource_group": "medium_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/Kotlin/s422777902.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s422777902", "user_id": "u682597394"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "\nfun main() {\n val (n,k) = readLine()!!.split(\" \").map { it.toInt() }\n val arr = readLine()!!.split(\" \").map { it.toInt() }.sorted()\n\n val fdp = Array(n+1){BooleanArray(k)}\n val bdp = Array(n+1){BooleanArray(k)}\n\n\n for(i in 1..n) {\n fdp[i-1][0] = true\n val v = arr[i - 1]\n for(j in 1 until k) {\n if(j - v < 0) continue\n fdp[i][j] = fdp[i-1][j] or fdp[i-1][j-v]\n }\n }\n\n for(i in 1..n) {\n bdp[i-1][0] = true\n val v = arr[n - i]\n for(j in 1 until k) {\n if(j - v < 0) continue\n bdp[i][j] = bdp[i-1][j] or bdp[i-1][j-v]\n }\n }\n\n var ans = 0\n for(i in 0 until n) {\n if(arr[i] >= k)\n continue\n var fmin = 0\n var fmax = 0\n var bmin = 0\n var bmax = 0\n\n val f = fdp[i]\n val b = bdp[n - 1 - i]\n\n for(j in 1 until k){\n if(fmin == 0 && f[j]) {\n fmin = j\n }\n if(bmin == 0 && b[j]) {\n bmin = j\n }\n }\n for(j in k - 1 downTo 1) {\n if(fmax == 0 && f[j]) {\n fmax = j\n }\n if(bmax == 0 && b[j]) {\n bmax = j\n }\n }\n val l = fmin + bmin\n val r = fmax + bmax\n if(k - arr[i] > r || k - 1 < l) {\n ++ans\n }\n }\n print(ans)\n\n\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1409, "cpu_time_ms": 483, "memory_kb": 103696}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s184085985", "group_id": "codeNet:p03780", "input_text": "fun main() {\n val (n,k) = readLine()!!.split(\" \").map { it.toInt() }\n val arr = readLine()!!.split(\" \").map { it.toInt() }\n\n fun isNecessary(idx:Int): Boolean {\n if(arr[idx] >= k)\n return true\n val a = arr.filterIndexed { index, i -> index != idx }.toIntArray()\n val dp = Array(2){BooleanArray(k+1){false} }\n var cur = 0\n var next = 1\n dp[cur][0] = true\n dp[next][0] = true\n\n for(i in a.indices) {\n val v = a[i]\n for(j in 1..k) {\n dp[next][j] = dp[cur][j]\n }\n for(j in 1..k) {\n if(j - v < 0) continue\n dp[next][j] = dp[next][j] or dp[cur][j-v]\n if(j >= k - arr[idx] && j <= k - 1 && dp[next][j])\n return true\n }\n cur = (cur + 1) % 2\n next = (next + 1) % 2\n }\n return false\n }\n var ans = 0\n for(i in 0 until n) {\n if(isNecessary(i))\n continue\n ++ans\n }\n print(ans)\n\n}", "language": "Kotlin", "metadata": {"date": 1595964210, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p03780.html", "problem_id": "p03780", "resource_group": "medium_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/Kotlin/s184085985.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s184085985", "user_id": "u682597394"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "fun main() {\n val (n,k) = readLine()!!.split(\" \").map { it.toInt() }\n val arr = readLine()!!.split(\" \").map { it.toInt() }\n\n fun isNecessary(idx:Int): Boolean {\n if(arr[idx] >= k)\n return true\n val a = arr.filterIndexed { index, i -> index != idx }.toIntArray()\n val dp = Array(2){BooleanArray(k+1){false} }\n var cur = 0\n var next = 1\n dp[cur][0] = true\n dp[next][0] = true\n\n for(i in a.indices) {\n val v = a[i]\n for(j in 1..k) {\n dp[next][j] = dp[cur][j]\n }\n for(j in 1..k) {\n if(j - v < 0) continue\n dp[next][j] = dp[next][j] or dp[cur][j-v]\n if(j >= k - arr[idx] && j <= k - 1 && dp[next][j])\n return true\n }\n cur = (cur + 1) % 2\n next = (next + 1) % 2\n }\n return false\n }\n var ans = 0\n for(i in 0 until n) {\n if(isNecessary(i))\n continue\n ++ans\n }\n print(ans)\n\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1053, "cpu_time_ms": 2207, "memory_kb": 58724}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s940518642", "group_id": "codeNet:p03780", "input_text": "import java.util.*\n\nfun main(args: Array) {\n val (N, K) = readLine()!!.split(\" \").map{it.toInt()}\n val a = readLine()!!.split(\" \").map{it.toInt()}\n\n fun func(a: List): Array {\n val dp = Array(N + 1) { IntArray(K + 1) { 0 } }\n\n dp[0][0] = 1\n\n for (i in a.indices) {\n for (j in dp[i].indices) {\n dp[i + 1][j] = Math.max(dp[i + 1][j], dp[i][j])\n\n val k = Math.min(K, j + a[i])\n dp[i + 1][k] = Math.max(dp[i + 1][k], dp[i][j])\n }\n }\n\n for (i in a.indices) {\n for (j in 1 .. K) {\n dp[i][j] += dp[i][j - 1]\n }\n }\n\n return dp\n }\n\n val dp = IntArray(K + 1)\n dp[0] = 1\n\n val rdp = func(a.reversed())\n\n var cnt = 0\n\n for (i in a.indices) {\n if (a[i] >= K) {\n cnt++\n continue\n }\n\n var r = false\n\n for (j in 0 .. K - 1) {\n if (dp[j] == 0)\n continue\n val l = Math.max(K - a[i] - j, 0)\n val u = K - j - 1\n\n r = r || (l == 0 && rdp[N - i - 1][l] > 0) || (rdp[N - i - 1][u] - rdp[N - i - 1][Math.max(l - 1, 0)] > 0)\n\n if (r) break\n }\n\n if (r) {\n cnt++\n }\n\n\n for (j in dp.indices.reversed()) {\n if (j - a[i] >= 0) {\n dp[j] = Math.max(dp[j], dp[j - a[i]])\n }\n }\n }\n\n println(N - cnt)\n}\n", "language": "Kotlin", "metadata": {"date": 1577857577, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03780.html", "problem_id": "p03780", "resource_group": "medium_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/Kotlin/s940518642.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s940518642", "user_id": "u183530284"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "import java.util.*\n\nfun main(args: Array) {\n val (N, K) = readLine()!!.split(\" \").map{it.toInt()}\n val a = readLine()!!.split(\" \").map{it.toInt()}\n\n fun func(a: List): Array {\n val dp = Array(N + 1) { IntArray(K + 1) { 0 } }\n\n dp[0][0] = 1\n\n for (i in a.indices) {\n for (j in dp[i].indices) {\n dp[i + 1][j] = Math.max(dp[i + 1][j], dp[i][j])\n\n val k = Math.min(K, j + a[i])\n dp[i + 1][k] = Math.max(dp[i + 1][k], dp[i][j])\n }\n }\n\n for (i in a.indices) {\n for (j in 1 .. K) {\n dp[i][j] += dp[i][j - 1]\n }\n }\n\n return dp\n }\n\n val dp = IntArray(K + 1)\n dp[0] = 1\n\n val rdp = func(a.reversed())\n\n var cnt = 0\n\n for (i in a.indices) {\n if (a[i] >= K) {\n cnt++\n continue\n }\n\n var r = false\n\n for (j in 0 .. K - 1) {\n if (dp[j] == 0)\n continue\n val l = Math.max(K - a[i] - j, 0)\n val u = K - j - 1\n\n r = r || (l == 0 && rdp[N - i - 1][l] > 0) || (rdp[N - i - 1][u] - rdp[N - i - 1][Math.max(l - 1, 0)] > 0)\n\n if (r) break\n }\n\n if (r) {\n cnt++\n }\n\n\n for (j in dp.indices.reversed()) {\n if (j - a[i] >= 0) {\n dp[j] = Math.max(dp[j], dp[j - a[i]])\n }\n }\n }\n\n println(N - cnt)\n}\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1480, "cpu_time_ms": 774, "memory_kb": 173324}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s119960873", "group_id": "codeNet:p03785", "input_text": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val n = sc.nextInt()\n val c = sc.nextLong()\n val k = sc.nextLong()\n val t = (0 until n).map { sc.next().toLong() }\n println(problem011a(n, c, k, t))\n}\n\nfun problem011a(n: Int, c: Long, k: Long, t: List): Int {\n val t = t.sorted()\n val bus = mutableListOf>()\n bus.add(mutableListOf())\n val queue = ArrayDeque()\n for (i in 0 until n) {\n// debugLog(bus, t[i])\n// if (bus.last().isNotEmpty()) {\n// debugLog(t[i] - bus.last()[0], k)\n// }\n if (bus.last().size.toLong() == c || (bus.last().isNotEmpty() && t[i] - bus.last()[0] > k)) {\n bus.add(mutableListOf())\n }\n bus.last().add(t[i])\n }\n return bus.count()\n}\n", "language": "Kotlin", "metadata": {"date": 1590802589, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03785.html", "problem_id": "p03785", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03785/input.txt", "sample_output_relpath": "derived/input_output/data/p03785/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03785/Kotlin/s119960873.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s119960873", "user_id": "u073232808"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val n = sc.nextInt()\n val c = sc.nextLong()\n val k = sc.nextLong()\n val t = (0 until n).map { sc.next().toLong() }\n println(problem011a(n, c, k, t))\n}\n\nfun problem011a(n: Int, c: Long, k: Long, t: List): Int {\n val t = t.sorted()\n val bus = mutableListOf>()\n bus.add(mutableListOf())\n val queue = ArrayDeque()\n for (i in 0 until n) {\n// debugLog(bus, t[i])\n// if (bus.last().isNotEmpty()) {\n// debugLog(t[i] - bus.last()[0], k)\n// }\n if (bus.last().size.toLong() == c || (bus.last().isNotEmpty() && t[i] - bus.last()[0] > k)) {\n bus.add(mutableListOf())\n }\n bus.last().add(t[i])\n }\n return bus.count()\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nEvery day, N passengers arrive at Takahashi Airport.\nThe i-th passenger arrives at time T_i.\n\nEvery passenger arrived at Takahashi airport travels to the city by bus. Each bus can accommodate up to C passengers.\nNaturally, a passenger cannot take a bus that departs earlier than the airplane arrives at the airport.\nAlso, a passenger will get angry if he/she is still unable to take a bus K units of time after the arrival of the airplane.\nFor that reason, it is necessary to arrange buses so that the i-th passenger can take a bus departing at time between T_i and T_i + K (inclusive).\n\nWhen setting the departure times for buses under this condition, find the minimum required number of buses.\nHere, the departure time for each bus does not need to be an integer, and there may be multiple buses that depart at the same time.\n\nConstraints\n\n2 \\leq N \\leq 100000\n\n1 \\leq C \\leq 10^9\n\n1 \\leq K \\leq 10^9\n\n1 \\leq T_i \\leq 10^9\n\nC, K and T_i are integers.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN C K\nT_1\nT_2\n:\nT_N\n\nOutput\n\nPrint the minimum required number of buses.\n\nSample Input 1\n\n5 3 5\n1\n2\n3\n6\n12\n\nSample Output 1\n\n3\n\nFor example, the following three buses are enough:\n\nA bus departing at time 4.5, that carries the passengers arriving at time 2 and 3.\n\nA bus departing at time 6, that carries the passengers arriving at time 1 and 6.\n\nA bus departing at time 12, that carries the passenger arriving at time 12.\n\nSample Input 2\n\n6 3 3\n7\n6\n2\n8\n10\n6\n\nSample Output 2\n\n3", "sample_input": "5 3 5\n1\n2\n3\n6\n12\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03785", "source_text": "Score : 300 points\n\nProblem Statement\n\nEvery day, N passengers arrive at Takahashi Airport.\nThe i-th passenger arrives at time T_i.\n\nEvery passenger arrived at Takahashi airport travels to the city by bus. Each bus can accommodate up to C passengers.\nNaturally, a passenger cannot take a bus that departs earlier than the airplane arrives at the airport.\nAlso, a passenger will get angry if he/she is still unable to take a bus K units of time after the arrival of the airplane.\nFor that reason, it is necessary to arrange buses so that the i-th passenger can take a bus departing at time between T_i and T_i + K (inclusive).\n\nWhen setting the departure times for buses under this condition, find the minimum required number of buses.\nHere, the departure time for each bus does not need to be an integer, and there may be multiple buses that depart at the same time.\n\nConstraints\n\n2 \\leq N \\leq 100000\n\n1 \\leq C \\leq 10^9\n\n1 \\leq K \\leq 10^9\n\n1 \\leq T_i \\leq 10^9\n\nC, K and T_i are integers.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN C K\nT_1\nT_2\n:\nT_N\n\nOutput\n\nPrint the minimum required number of buses.\n\nSample Input 1\n\n5 3 5\n1\n2\n3\n6\n12\n\nSample Output 1\n\n3\n\nFor example, the following three buses are enough:\n\nA bus departing at time 4.5, that carries the passengers arriving at time 2 and 3.\n\nA bus departing at time 6, that carries the passengers arriving at time 1 and 6.\n\nA bus departing at time 12, that carries the passenger arriving at time 12.\n\nSample Input 2\n\n6 3 3\n7\n6\n2\n8\n10\n6\n\nSample Output 2\n\n3", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 821, "cpu_time_ms": 1001, "memory_kb": 55012}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s442522517", "group_id": "codeNet:p03791", "input_text": "fun f(x: Int, m: Long): Long = if (x > 0) 1L * x * f(x - 1, m) % m else 1L\n\nfun main(args: Array) {\n val MOD = (1e9 + 7).toLong()\n val n = readLine()!!.toInt()\n val x = readLine()!!.split(\" \").map { it.toLong() }\n var ans = 1L\n var l = 0\n for (r in 1..n) {\n if (x[r - 1] >= 2 * (r - l) - 1) continue\n ans *= r - l\n ans %= MOD\n l++\n }\n println(ans * f(n - l, MOD) % MOD)\n}\n", "language": "Kotlin", "metadata": {"date": 1570916507, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03791.html", "problem_id": "p03791", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03791/input.txt", "sample_output_relpath": "derived/input_output/data/p03791/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03791/Kotlin/s442522517.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s442522517", "user_id": "u858748695"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "fun f(x: Int, m: Long): Long = if (x > 0) 1L * x * f(x - 1, m) % m else 1L\n\nfun main(args: Array) {\n val MOD = (1e9 + 7).toLong()\n val n = readLine()!!.toInt()\n val x = readLine()!!.split(\" \").map { it.toLong() }\n var ans = 1L\n var l = 0\n for (r in 1..n) {\n if (x[r - 1] >= 2 * (r - l) - 1) continue\n ans *= r - l\n ans %= MOD\n l++\n }\n println(ans * f(n - l, MOD) % MOD)\n}\n", "problem_context": "Score : 900 points\n\nProblem Statement\n\nYou are developing frog-shaped robots, and decided to race them against each other.\n\nFirst, you placed N robots onto a number line.\nThese robots are numbered 1 through N.\nThe current coordinate of robot i is x_i.\nHere, all x_i are integers, and 0 < x_1 < x_2 < ... < x_N.\n\nYou will repeatedly perform the following operation:\n\nSelect a robot on the number line. Let the coordinate of the robot be x. Select the destination coordinate, either x-1 or x-2, that is not occupied by another robot. The robot now jumps to the selected coordinate.\n\nWhen the coordinate of a robot becomes 0 or less, the robot is considered finished and will be removed from the number line immediately.\nYou will repeat the operation until all the robots finish the race.\n\nDepending on your choice in the operation, the N robots can finish the race in different orders.\nIn how many different orders can the N robots finish the race?\nFind the answer modulo 10^9+7.\n\nConstraints\n\n2 ≤ N ≤ 10^5\n\nx_i is an integer.\n\n0 < x_1 < x_2 < ... < x_N ≤ 10^9\n\nPartial Score\n\nIn a test set worth 500 points, N ≤ 8.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\nx_1 x_2 ... x_N\n\nOutput\n\nPrint the number of the different orders in which the N robots can finish the race, modulo 10^9+7.\n\nSample Input 1\n\n3\n1 2 3\n\nSample Output 1\n\n4\n\nThere are four different orders in which the three robots can finish the race:\n\n(Robot 1 → Robot 2 → Robot 3)\n\n(Robot 1 → Robot 3 → Robot 2)\n\n(Robot 2 → Robot 1 → Robot 3)\n\n(Robot 2 → Robot 3 → Robot 1)\n\nSample Input 2\n\n3\n2 3 4\n\nSample Output 2\n\n6\n\nThere are six different orders in which the three robots can finish the race:\n\n(Robot 1 → Robot 2 → Robot 3)\n\n(Robot 1 → Robot 3 → Robot 2)\n\n(Robot 2 → Robot 1 → Robot 3)\n\n(Robot 2 → Robot 3 → Robot 1)\n\n(Robot 3 → Robot 1 → Robot 2)\n\n(Robot 3 → Robot 2 → Robot 1)\n\nFor example, the order (Robot 3 → Robot 2 → Robot 1) can be achieved as shown in the figure below:\n\nSample Input 3\n\n8\n1 2 3 5 7 11 13 17\n\nSample Output 3\n\n10080\n\nSample Input 4\n\n13\n4 6 8 9 10 12 14 15 16 18 20 21 22\n\nSample Output 4\n\n311014372\n\nRemember to print the answer modulo 10^9+7.\nThis case is not included in the test set for the partial score.", "sample_input": "3\n1 2 3\n"}, "reference_outputs": ["4\n"], "source_document_id": "p03791", "source_text": "Score : 900 points\n\nProblem Statement\n\nYou are developing frog-shaped robots, and decided to race them against each other.\n\nFirst, you placed N robots onto a number line.\nThese robots are numbered 1 through N.\nThe current coordinate of robot i is x_i.\nHere, all x_i are integers, and 0 < x_1 < x_2 < ... < x_N.\n\nYou will repeatedly perform the following operation:\n\nSelect a robot on the number line. Let the coordinate of the robot be x. Select the destination coordinate, either x-1 or x-2, that is not occupied by another robot. The robot now jumps to the selected coordinate.\n\nWhen the coordinate of a robot becomes 0 or less, the robot is considered finished and will be removed from the number line immediately.\nYou will repeat the operation until all the robots finish the race.\n\nDepending on your choice in the operation, the N robots can finish the race in different orders.\nIn how many different orders can the N robots finish the race?\nFind the answer modulo 10^9+7.\n\nConstraints\n\n2 ≤ N ≤ 10^5\n\nx_i is an integer.\n\n0 < x_1 < x_2 < ... < x_N ≤ 10^9\n\nPartial Score\n\nIn a test set worth 500 points, N ≤ 8.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\nx_1 x_2 ... x_N\n\nOutput\n\nPrint the number of the different orders in which the N robots can finish the race, modulo 10^9+7.\n\nSample Input 1\n\n3\n1 2 3\n\nSample Output 1\n\n4\n\nThere are four different orders in which the three robots can finish the race:\n\n(Robot 1 → Robot 2 → Robot 3)\n\n(Robot 1 → Robot 3 → Robot 2)\n\n(Robot 2 → Robot 1 → Robot 3)\n\n(Robot 2 → Robot 3 → Robot 1)\n\nSample Input 2\n\n3\n2 3 4\n\nSample Output 2\n\n6\n\nThere are six different orders in which the three robots can finish the race:\n\n(Robot 1 → Robot 2 → Robot 3)\n\n(Robot 1 → Robot 3 → Robot 2)\n\n(Robot 2 → Robot 1 → Robot 3)\n\n(Robot 2 → Robot 3 → Robot 1)\n\n(Robot 3 → Robot 1 → Robot 2)\n\n(Robot 3 → Robot 2 → Robot 1)\n\nFor example, the order (Robot 3 → Robot 2 → Robot 1) can be achieved as shown in the figure below:\n\nSample Input 3\n\n8\n1 2 3 5 7 11 13 17\n\nSample Output 3\n\n10080\n\nSample Input 4\n\n13\n4 6 8 9 10 12 14 15 16 18 20 21 22\n\nSample Output 4\n\n311014372\n\nRemember to print the answer modulo 10^9+7.\nThis case is not included in the test set for the partial score.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 400, "cpu_time_ms": 506, "memory_kb": 58692}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s734937910", "group_id": "codeNet:p03795", "input_text": "import java.io.PrintWriter\n\nfun next() = readLine()!!\nfun nextInt() = next().toInt()\nfun nextLong() = next().toLong()\nfun nextDouble() = next().toDouble()\nfun nextList() = next().split(\" \")\nfun nextIntList() = nextList().map(String::toInt)\nfun nextLongList() = nextList().map(String::toLong)\nfun nextDoubleList() = nextList().map(String::toDouble)\n\nval pw = PrintWriter(System.out)\nfun print(s: Any = \"\") = pw.print(s)\nfun println(s: Any = \"\") = pw.println(s)\n\nfun main(args: Array) {\n main()\n pw.flush()\n}\n\nfun main() {\n val N = nextInt()\n val x = 800 * N\n val y = 200 * (N / 15)\n println(x - y)\n}", "language": "Kotlin", "metadata": {"date": 1591421572, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03795.html", "problem_id": "p03795", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03795/input.txt", "sample_output_relpath": "derived/input_output/data/p03795/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03795/Kotlin/s734937910.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s734937910", "user_id": "u860789370"}, "prompt_components": {"gold_output": "15800\n", "input_to_evaluate": "import java.io.PrintWriter\n\nfun next() = readLine()!!\nfun nextInt() = next().toInt()\nfun nextLong() = next().toLong()\nfun nextDouble() = next().toDouble()\nfun nextList() = next().split(\" \")\nfun nextIntList() = nextList().map(String::toInt)\nfun nextLongList() = nextList().map(String::toLong)\nfun nextDoubleList() = nextList().map(String::toDouble)\n\nval pw = PrintWriter(System.out)\nfun print(s: Any = \"\") = pw.print(s)\nfun println(s: Any = \"\") = pw.println(s)\n\nfun main(args: Array) {\n main()\n pw.flush()\n}\n\nfun main() {\n val N = nextInt()\n val x = 800 * N\n val y = 200 * (N / 15)\n println(x - y)\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nSnuke has a favorite restaurant.\n\nThe price of any meal served at the restaurant is 800 yen (the currency of Japan), and each time a customer orders 15 meals, the restaurant pays 200 yen back to the customer.\n\nSo far, Snuke has ordered N meals at the restaurant.\nLet the amount of money Snuke has paid to the restaurant be x yen, and let the amount of money the restaurant has paid back to Snuke be y yen.\nFind x-y.\n\nConstraints\n\n1 ≤ N ≤ 100\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n20\n\nSample Output 1\n\n15800\n\nSo far, Snuke has paid 16000 yen, and the restaurant has paid back 200 yen. Thus, the answer is 15800.\n\nSample Input 2\n\n60\n\nSample Output 2\n\n47200\n\nSnuke has paid 48000 yen for 60 meals, and the restaurant has paid back 800 yen.", "sample_input": "20\n"}, "reference_outputs": ["15800\n"], "source_document_id": "p03795", "source_text": "Score : 100 points\n\nProblem Statement\n\nSnuke has a favorite restaurant.\n\nThe price of any meal served at the restaurant is 800 yen (the currency of Japan), and each time a customer orders 15 meals, the restaurant pays 200 yen back to the customer.\n\nSo far, Snuke has ordered N meals at the restaurant.\nLet the amount of money Snuke has paid to the restaurant be x yen, and let the amount of money the restaurant has paid back to Snuke be y yen.\nFind x-y.\n\nConstraints\n\n1 ≤ N ≤ 100\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n20\n\nSample Output 1\n\n15800\n\nSo far, Snuke has paid 16000 yen, and the restaurant has paid back 200 yen. Thus, the answer is 15800.\n\nSample Input 2\n\n60\n\nSample Output 2\n\n47200\n\nSnuke has paid 48000 yen for 60 meals, and the restaurant has paid back 800 yen.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 200, "memory_kb": 31636}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s959428863", "group_id": "codeNet:p03795", "input_text": "fun main(args: Array) {\n val N = readLine()!!.toShort()\n println(N * 800 - (N / 15 * 200))\n}\n", "language": "Kotlin", "metadata": {"date": 1523490229, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03795.html", "problem_id": "p03795", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03795/input.txt", "sample_output_relpath": "derived/input_output/data/p03795/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03795/Kotlin/s959428863.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s959428863", "user_id": "u143977591"}, "prompt_components": {"gold_output": "15800\n", "input_to_evaluate": "fun main(args: Array) {\n val N = readLine()!!.toShort()\n println(N * 800 - (N / 15 * 200))\n}\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nSnuke has a favorite restaurant.\n\nThe price of any meal served at the restaurant is 800 yen (the currency of Japan), and each time a customer orders 15 meals, the restaurant pays 200 yen back to the customer.\n\nSo far, Snuke has ordered N meals at the restaurant.\nLet the amount of money Snuke has paid to the restaurant be x yen, and let the amount of money the restaurant has paid back to Snuke be y yen.\nFind x-y.\n\nConstraints\n\n1 ≤ N ≤ 100\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n20\n\nSample Output 1\n\n15800\n\nSo far, Snuke has paid 16000 yen, and the restaurant has paid back 200 yen. Thus, the answer is 15800.\n\nSample Input 2\n\n60\n\nSample Output 2\n\n47200\n\nSnuke has paid 48000 yen for 60 meals, and the restaurant has paid back 800 yen.", "sample_input": "20\n"}, "reference_outputs": ["15800\n"], "source_document_id": "p03795", "source_text": "Score : 100 points\n\nProblem Statement\n\nSnuke has a favorite restaurant.\n\nThe price of any meal served at the restaurant is 800 yen (the currency of Japan), and each time a customer orders 15 meals, the restaurant pays 200 yen back to the customer.\n\nSo far, Snuke has ordered N meals at the restaurant.\nLet the amount of money Snuke has paid to the restaurant be x yen, and let the amount of money the restaurant has paid back to Snuke be y yen.\nFind x-y.\n\nConstraints\n\n1 ≤ N ≤ 100\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n20\n\nSample Output 1\n\n15800\n\nSo far, Snuke has paid 16000 yen, and the restaurant has paid back 200 yen. Thus, the answer is 15800.\n\nSample Input 2\n\n60\n\nSample Output 2\n\n47200\n\nSnuke has paid 48000 yen for 60 meals, and the restaurant has paid back 800 yen.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 202, "memory_kb": 29820}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s344678125", "group_id": "codeNet:p03796", "input_text": "fun main(args: Array) {\n val N = readLine()!!.toInt()\n val w = 1000000000 + 7\n (1..N).fold(1L) { acc, elm ->\n acc * elm % w\n }.let(::println)\n}\n\n\n", "language": "Kotlin", "metadata": {"date": 1567442906, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03796.html", "problem_id": "p03796", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03796/input.txt", "sample_output_relpath": "derived/input_output/data/p03796/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03796/Kotlin/s344678125.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s344678125", "user_id": "u085288971"}, "prompt_components": {"gold_output": "6\n", "input_to_evaluate": "fun main(args: Array) {\n val N = readLine()!!.toInt()\n val w = 1000000000 + 7\n (1..N).fold(1L) { acc, elm ->\n acc * elm % w\n }.let(::println)\n}\n\n\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nSnuke loves working out. He is now exercising N times.\n\nBefore he starts exercising, his power is 1. After he exercises for the i-th time, his power gets multiplied by i.\n\nFind Snuke's power after he exercises N times. Since the answer can be extremely large, print the answer modulo 10^{9}+7.\n\nConstraints\n\n1 ≤ N ≤ 10^{5}\n\nInput\n\nThe input 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\n3\n\nSample Output 1\n\n6\n\nAfter Snuke exercises for the first time, his power gets multiplied by 1 and becomes 1.\n\nAfter Snuke exercises for the second time, his power gets multiplied by 2 and becomes 2.\n\nAfter Snuke exercises for the third time, his power gets multiplied by 3 and becomes 6.\n\nSample Input 2\n\n10\n\nSample Output 2\n\n3628800\n\nSample Input 3\n\n100000\n\nSample Output 3\n\n457992974\n\nPrint the answer modulo 10^{9}+7.", "sample_input": "3\n"}, "reference_outputs": ["6\n"], "source_document_id": "p03796", "source_text": "Score : 200 points\n\nProblem Statement\n\nSnuke loves working out. He is now exercising N times.\n\nBefore he starts exercising, his power is 1. After he exercises for the i-th time, his power gets multiplied by i.\n\nFind Snuke's power after he exercises N times. Since the answer can be extremely large, print the answer modulo 10^{9}+7.\n\nConstraints\n\n1 ≤ N ≤ 10^{5}\n\nInput\n\nThe input 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\n3\n\nSample Output 1\n\n6\n\nAfter Snuke exercises for the first time, his power gets multiplied by 1 and becomes 1.\n\nAfter Snuke exercises for the second time, his power gets multiplied by 2 and becomes 2.\n\nAfter Snuke exercises for the third time, his power gets multiplied by 3 and becomes 6.\n\nSample Input 2\n\n10\n\nSample Output 2\n\n3628800\n\nSample Input 3\n\n100000\n\nSample Output 3\n\n457992974\n\nPrint the answer modulo 10^{9}+7.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 221, "memory_kb": 33620}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s288029411", "group_id": "codeNet:p03797", "input_text": "import java.io.PrintWriter\n\nval pw = PrintWriter(System.out)\n\nfun main(args : Array) {\n func()\n pw.flush()\n}\n\nfun func() {\n val (n, m) = listOfLong()\n\n if (n >= m / 2) {\n println(m / 2)\n } else {\n println(n + (m - 2*n)/4)\n }\n}\n\nfun next() = readLine()!!\nfun listOfString() = next().split(\" \")\nfun listOfLong() = listOfString().map { it.toLong() }\n\nfun println(value : Any) {\n pw.println(value)\n}", "language": "Kotlin", "metadata": {"date": 1570780904, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03797.html", "problem_id": "p03797", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03797/input.txt", "sample_output_relpath": "derived/input_output/data/p03797/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03797/Kotlin/s288029411.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s288029411", "user_id": "u262403099"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import java.io.PrintWriter\n\nval pw = PrintWriter(System.out)\n\nfun main(args : Array) {\n func()\n pw.flush()\n}\n\nfun func() {\n val (n, m) = listOfLong()\n\n if (n >= m / 2) {\n println(m / 2)\n } else {\n println(n + (m - 2*n)/4)\n }\n}\n\nfun next() = readLine()!!\nfun listOfString() = next().split(\" \")\nfun listOfLong() = listOfString().map { it.toLong() }\n\nfun println(value : Any) {\n pw.println(value)\n}", "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": "p03797", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 438, "cpu_time_ms": 233, "memory_kb": 37732}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s555873452", "group_id": "codeNet:p03797", "input_text": "fun main(args:Array) {\n var (n, m) = readLine()!!.split(\" \").map(String::toInt)\n\n // n is S\n var snum = when { \n m >= 2*n -> { \n val ret = n\n m -= 2*n\n n = 0\n ret\n }\n else -> { \n n = n - m/2\n val ret = m/2\n m = 0\n ret \n }\n }\n //println(\"$snum $n $m\")\n val sofm = m / 4 \n \n snum += sofm\n println(snum)\n}\n", "language": "Kotlin", "metadata": {"date": 1529370859, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03797.html", "problem_id": "p03797", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03797/input.txt", "sample_output_relpath": "derived/input_output/data/p03797/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03797/Kotlin/s555873452.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s555873452", "user_id": "u693048766"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "fun main(args:Array) {\n var (n, m) = readLine()!!.split(\" \").map(String::toInt)\n\n // n is S\n var snum = when { \n m >= 2*n -> { \n val ret = n\n m -= 2*n\n n = 0\n ret\n }\n else -> { \n n = n - m/2\n val ret = m/2\n m = 0\n ret \n }\n }\n //println(\"$snum $n $m\")\n val sofm = m / 4 \n \n snum += sofm\n println(snum)\n}\n", "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": "p03797", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 502, "cpu_time_ms": 239, "memory_kb": 35992}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s638459177", "group_id": "codeNet:p03804", "input_text": "fun main(args: Array) = println(run {\n val (n,m) = readLine()!!.split(\" \").map { it.toInt() }\n val a = (1..n).map { readLine()!! }\n val b = (1..m).map { readLine()!! }\n\n (0..n-m).any { x ->\n (0..n-m).any { y ->\n b == a.slice(y..y+m-1).map { it.slice(x..x+m-1) }\n }\n }.let { if(it) \"Yes\" else \"No\" }\n})\n", "language": "Kotlin", "metadata": {"date": 1588718862, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03804.html", "problem_id": "p03804", "resource_group": "medium_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/Kotlin/s638459177.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s638459177", "user_id": "u563556491"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "fun main(args: Array) = println(run {\n val (n,m) = readLine()!!.split(\" \").map { it.toInt() }\n val a = (1..n).map { readLine()!! }\n val b = (1..m).map { readLine()!! }\n\n (0..n-m).any { x ->\n (0..n-m).any { y ->\n b == a.slice(y..y+m-1).map { it.slice(x..x+m-1) }\n }\n }.let { if(it) \"Yes\" else \"No\" }\n})\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 324, "memory_kb": 37876}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s422762646", "group_id": "codeNet:p03804", "input_text": "import java.io.BufferedReader\n\nfun main(args: Array) {\n /** comment in when you submit **/\n System.`in`.bufferedReader().use { println(getOutputString(it)) }\n\n /** delete below after your test **/\n //executeTest()\n}\n\nprivate fun getOutputString(reader: BufferedReader): String {\n val lines = reader.readLines()\n val m = lines.last()\n lines.subList(0, lines.lastIndex - 1).forEach {\n if (it.indexOf(m) >= 0) {\n return \"Yes\"\n }\n }\n return \"No\"\n}\n\n/** delete below after your test **/\nprivate fun String.mustBe(expected: String): Unit {\n if (this != expected) throw Exception(\"\\\"$this\\\" must be \\\"$expected\\\"\")\n\n println(\"ok\")\n}\n\nprivate fun executeTest() {\n getOutputString(\"3 2\\n#.#\\n.#.\\n#.#\\n#.\\n.#\".toByteArray(Charsets.UTF_8).inputStream().bufferedReader()).mustBe(\"Yes\")\n getOutputString(\"4 1\\n....\\n....\\n....\\n....\\n#\".toByteArray(Charsets.UTF_8).inputStream().bufferedReader()).mustBe(\"No\")\n}", "language": "Kotlin", "metadata": {"date": 1487288347, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03804.html", "problem_id": "p03804", "resource_group": "medium_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/Kotlin/s422762646.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s422762646", "user_id": "u144016208"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "import java.io.BufferedReader\n\nfun main(args: Array) {\n /** comment in when you submit **/\n System.`in`.bufferedReader().use { println(getOutputString(it)) }\n\n /** delete below after your test **/\n //executeTest()\n}\n\nprivate fun getOutputString(reader: BufferedReader): String {\n val lines = reader.readLines()\n val m = lines.last()\n lines.subList(0, lines.lastIndex - 1).forEach {\n if (it.indexOf(m) >= 0) {\n return \"Yes\"\n }\n }\n return \"No\"\n}\n\n/** delete below after your test **/\nprivate fun String.mustBe(expected: String): Unit {\n if (this != expected) throw Exception(\"\\\"$this\\\" must be \\\"$expected\\\"\")\n\n println(\"ok\")\n}\n\nprivate fun executeTest() {\n getOutputString(\"3 2\\n#.#\\n.#.\\n#.#\\n#.\\n.#\".toByteArray(Charsets.UTF_8).inputStream().bufferedReader()).mustBe(\"Yes\")\n getOutputString(\"4 1\\n....\\n....\\n....\\n....\\n#\".toByteArray(Charsets.UTF_8).inputStream().bufferedReader()).mustBe(\"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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 972, "cpu_time_ms": 187, "memory_kb": 21792}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s342577521", "group_id": "codeNet:p03805", "input_text": "import java.util.*\nclass SearchInfo(val nodeNumber: Int, val visitedNodes: Set)\nfun main(args : Array) {\n val (N, M) = readLine()!!.split(\" \").map { it.toInt() }\n val graph = Array(N, { Array(N, { false }) })\n\n (1..M).forEach {\n val (a, b) = readLine()!!.split(\" \").map { it.toInt() }\n graph[a-1][b-1] = true\n graph[b-1][a-1] = true\n }\n\n val queue : Queue = ArrayDeque()\n\n graph[0].forEachIndexed { nodeNum, exists ->\n if (exists) {\n queue.offer(SearchInfo(nodeNum, setOf(0, nodeNum)))\n }\n }\n\n var count = 0\n while (queue.isNotEmpty()) {\n val searchInfo = queue.poll()\n if (searchInfo.visitedNodes.size == N) {\n count++\n } else {\n val currentNodeNum = searchInfo.nodeNumber\n graph[currentNodeNum].forEachIndexed{ node, exists ->\n if (exists && !searchInfo.visitedNodes.contains(node)) {\n //println(searchInfo.visitedNodes.plus(node).toString())\n queue.offer(SearchInfo(node, searchInfo.visitedNodes.plus(node)))\n }\n }\n }\n }\n\n println(count)\n}", "language": "Kotlin", "metadata": {"date": 1558249639, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03805.html", "problem_id": "p03805", "resource_group": "medium_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/Kotlin/s342577521.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s342577521", "user_id": "u861095163"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import java.util.*\nclass SearchInfo(val nodeNumber: Int, val visitedNodes: Set)\nfun main(args : Array) {\n val (N, M) = readLine()!!.split(\" \").map { it.toInt() }\n val graph = Array(N, { Array(N, { false }) })\n\n (1..M).forEach {\n val (a, b) = readLine()!!.split(\" \").map { it.toInt() }\n graph[a-1][b-1] = true\n graph[b-1][a-1] = true\n }\n\n val queue : Queue = ArrayDeque()\n\n graph[0].forEachIndexed { nodeNum, exists ->\n if (exists) {\n queue.offer(SearchInfo(nodeNum, setOf(0, nodeNum)))\n }\n }\n\n var count = 0\n while (queue.isNotEmpty()) {\n val searchInfo = queue.poll()\n if (searchInfo.visitedNodes.size == N) {\n count++\n } else {\n val currentNodeNum = searchInfo.nodeNumber\n graph[currentNodeNum].forEachIndexed{ node, exists ->\n if (exists && !searchInfo.visitedNodes.contains(node)) {\n //println(searchInfo.visitedNodes.plus(node).toString())\n queue.offer(SearchInfo(node, searchInfo.visitedNodes.plus(node)))\n }\n }\n }\n }\n\n println(count)\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) {\n val (n, m) = readLine()!!.split(' ').map(String::toInt)\n val g = Array(n) { BooleanArray(n) }\n repeat(m) {\n val (a, b) = readLine()!!.split(' ').map(String::toInt)\n g[a - 1][b - 1] = true\n g[b - 1][a - 1] = true\n }\n val visited = BooleanArray(n)\n fun dfs(v: Int): Int {\n if (visited.all { it }) return 1\n var cnt = 0\n for (i in 0 until n) {\n // println(\"g[$v][$i] = ${g[v][i]}; visited[$i] = ${visited[i]}\")\n if (!g[v][i] || visited[i]) continue\n visited[i] = true\n cnt += dfs(i)\n visited[i] = false\n }\n return cnt\n }\n visited[0] = true\n println(dfs(0))\n}\n", "language": "Kotlin", "metadata": {"date": 1551757640, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03805.html", "problem_id": "p03805", "resource_group": "medium_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/Kotlin/s718869737.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s718869737", "user_id": "u051841332"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "fun main(args: Array) {\n val (n, m) = readLine()!!.split(' ').map(String::toInt)\n val g = Array(n) { BooleanArray(n) }\n repeat(m) {\n val (a, b) = readLine()!!.split(' ').map(String::toInt)\n g[a - 1][b - 1] = true\n g[b - 1][a - 1] = true\n }\n val visited = BooleanArray(n)\n fun dfs(v: Int): Int {\n if (visited.all { it }) return 1\n var cnt = 0\n for (i in 0 until n) {\n // println(\"g[$v][$i] = ${g[v][i]}; visited[$i] = ${visited[i]}\")\n if (!g[v][i] || visited[i]) continue\n visited[i] = true\n cnt += dfs(i)\n visited[i] = false\n }\n return cnt\n }\n visited[0] = true\n println(dfs(0))\n}\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) {\n val (n,m)=readLine()!!.split(\" \").map { it.toInt() }\n val es = (1..m).map{readLine()!!.split(\" \").map{ it.toInt()-1 }}\n val a=Array>(n,{ mutableListOf()})\n es.forEach {\n a[it[0]].add(it[1])\n a[it[1]].add(it[0])\n }\n\n var visit=BooleanArray(n)\n println(dfs(0,a,visit))\n}\n\nfun dfs(v:Int, a:Array>, visit:BooleanArray):Int{\n visit[v]=true\n if(visit.all{it==true}){\n visit[v]=false\n return 1\n }\n var count=0\n a[v].filter { !visit[it] }.forEach {\n count+=dfs(it,a,visit)\n }\n visit[v]=false\n return count\n}", "language": "Kotlin", "metadata": {"date": 1541183885, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03805.html", "problem_id": "p03805", "resource_group": "medium_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/Kotlin/s992531375.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s992531375", "user_id": "u914096045"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "fun main(args: Array) {\n val (n,m)=readLine()!!.split(\" \").map { it.toInt() }\n val es = (1..m).map{readLine()!!.split(\" \").map{ it.toInt()-1 }}\n val a=Array>(n,{ mutableListOf()})\n es.forEach {\n a[it[0]].add(it[1])\n a[it[1]].add(it[0])\n }\n\n var visit=BooleanArray(n)\n println(dfs(0,a,visit))\n}\n\nfun dfs(v:Int, a:Array>, visit:BooleanArray):Int{\n visit[v]=true\n if(visit.all{it==true}){\n visit[v]=false\n return 1\n }\n var count=0\n a[v].filter { !visit[it] }.forEach {\n count+=dfs(it,a,visit)\n }\n visit[v]=false\n return count\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){\n\tval cin = Scanner(System.`in`)\n val n = cin.nextInt()\n\n var sum: Long = 0\n val a: MutableList = mutableListOf()\n for (i in 1..n) {\n val ai = cin.nextLong()\n a.add(ai)\n sum += ai\n }\n\n var sum_one: Long = 0\n for (i in 1..n) {\n sum_one += i\n }\n \n var ok = 1\n var bye_n: Long = 0\n if (sum % sum_one == 0.toLong()) {\n bye_n = sum/sum_one\n } else {\n ok = 0\n }\n\n var real_bye_n: Long = 0\n\n if (ok == 1) {\n for (i in 1..n) {\n var sub: Long\n if (i == n) {\n sub = a[0] - a[n-1]\n } else {\n sub = a[i] - a[i-1]\n }\n var cut: Long = bye_n - sub\n if (cut % n == 0.toLong()) {\n cut = cut/n\n } else {\n ok = 0\n break\n }\n real_bye_n += cut\n }\n }\n\n if (real_bye_n != bye_n) {\n ok = 0\n }\n\n if (ok == 1) {\n println(\"YES\")\n } else {\n println(\"NO\")\n }\n}", "language": "Kotlin", "metadata": {"date": 1542851625, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03808.html", "problem_id": "p03808", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03808/input.txt", "sample_output_relpath": "derived/input_output/data/p03808/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03808/Kotlin/s978542514.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s978542514", "user_id": "u111421568"}, "prompt_components": {"gold_output": "YES\n", "input_to_evaluate": "import java.util.*\n\nfun main(args: Array){\n\tval cin = Scanner(System.`in`)\n val n = cin.nextInt()\n\n var sum: Long = 0\n val a: MutableList = mutableListOf()\n for (i in 1..n) {\n val ai = cin.nextLong()\n a.add(ai)\n sum += ai\n }\n\n var sum_one: Long = 0\n for (i in 1..n) {\n sum_one += i\n }\n \n var ok = 1\n var bye_n: Long = 0\n if (sum % sum_one == 0.toLong()) {\n bye_n = sum/sum_one\n } else {\n ok = 0\n }\n\n var real_bye_n: Long = 0\n\n if (ok == 1) {\n for (i in 1..n) {\n var sub: Long\n if (i == n) {\n sub = a[0] - a[n-1]\n } else {\n sub = a[i] - a[i-1]\n }\n var cut: Long = bye_n - sub\n if (cut % n == 0.toLong()) {\n cut = cut/n\n } else {\n ok = 0\n break\n }\n real_bye_n += cut\n }\n }\n\n if (real_bye_n != bye_n) {\n ok = 0\n }\n\n if (ok == 1) {\n println(\"YES\")\n } else {\n println(\"NO\")\n }\n}", "problem_context": "Score : 500 points\n\nProblem Statement\n\nThere are N boxes arranged in a circle. The i-th box contains A_i stones.\n\nDetermine whether it is possible to remove all the stones from the boxes by repeatedly performing the following operation:\n\nSelect one box. Let the box be the i-th box. Then, for each j from 1 through N, remove exactly j stones from the (i+j)-th box. Here, the (N+k)-th box is identified with the k-th box.\n\nNote that the operation cannot be performed if there is a box that does not contain enough number of stones to be removed.\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\nIf it is possible to remove all the stones from the boxes, print YES. Otherwise, print NO.\n\nSample Input 1\n\n5\n4 5 1 2 3\n\nSample Output 1\n\nYES\n\nAll the stones can be removed in one operation by selecting the second box.\n\nSample Input 2\n\n5\n6 9 12 10 8\n\nSample Output 2\n\nYES\n\nSample Input 3\n\n4\n1 2 3 1\n\nSample Output 3\n\nNO", "sample_input": "5\n4 5 1 2 3\n"}, "reference_outputs": ["YES\n"], "source_document_id": "p03808", "source_text": "Score : 500 points\n\nProblem Statement\n\nThere are N boxes arranged in a circle. The i-th box contains A_i stones.\n\nDetermine whether it is possible to remove all the stones from the boxes by repeatedly performing the following operation:\n\nSelect one box. Let the box be the i-th box. Then, for each j from 1 through N, remove exactly j stones from the (i+j)-th box. Here, the (N+k)-th box is identified with the k-th box.\n\nNote that the operation cannot be performed if there is a box that does not contain enough number of stones to be removed.\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\nIf it is possible to remove all the stones from the boxes, print YES. Otherwise, print NO.\n\nSample Input 1\n\n5\n4 5 1 2 3\n\nSample Output 1\n\nYES\n\nAll the stones can be removed in one operation by selecting the second box.\n\nSample Input 2\n\n5\n6 9 12 10 8\n\nSample Output 2\n\nYES\n\nSample Input 3\n\n4\n1 2 3 1\n\nSample Output 3\n\nNO", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1104, "cpu_time_ms": 549, "memory_kb": 57868}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s460713435", "group_id": "codeNet:p03808", "input_text": "import java.util.*\n\nfun main(args: Array) {\n val DEBUG = false\n val scanner = Scanner(System.`in`)\n val N = scanner.nextLong()\n var sum: Long = 0L\n val AN: LongArray = (0..N.toInt() - 1).map { val l = scanner.nextLong();sum += l;return@map l }.toLongArray()\n val once = (N * (N + 1)) / 2\n if (sum % once != 0L) {\n println(\"NO\")\n return\n }\n val k: Long = sum / once\n var count: Long = 0\n (0..N.toInt() - 1).forEach { index ->\n var di = AN[((index + 1) % N).toInt()] - AN[index] - k\n while ((di < 0)) {\n di += N\n count += 1\n }\n if (di != 0L) {\n println(\"NO\")\n return\n }\n }\n// val d = (1..N.toInt()).map { index -> AN[(index % N).toInt()] - AN[index - 1] - k }.toLongArray()\n// (0..N - 1).forEach { i ->\n// while (d[i.toInt()] < 0) {\n// d[i.toInt()] += N\n// count += 1\n// }\n// if (d[i.toInt()] != 0L) {\n// if (DEBUG) println(\"d[$i]=${d[i.toInt()]}\")\n// println(\"NO\")\n// return\n// }\n//\n// }\n if (k == count) println(\"YES\")\n else {\n if (DEBUG) println(\"k=$k ,count=$count\")\n println(\"NO\")\n }\n}\n", "language": "Kotlin", "metadata": {"date": 1486328378, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03808.html", "problem_id": "p03808", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03808/input.txt", "sample_output_relpath": "derived/input_output/data/p03808/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03808/Kotlin/s460713435.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s460713435", "user_id": "u957575129"}, "prompt_components": {"gold_output": "YES\n", "input_to_evaluate": "import java.util.*\n\nfun main(args: Array) {\n val DEBUG = false\n val scanner = Scanner(System.`in`)\n val N = scanner.nextLong()\n var sum: Long = 0L\n val AN: LongArray = (0..N.toInt() - 1).map { val l = scanner.nextLong();sum += l;return@map l }.toLongArray()\n val once = (N * (N + 1)) / 2\n if (sum % once != 0L) {\n println(\"NO\")\n return\n }\n val k: Long = sum / once\n var count: Long = 0\n (0..N.toInt() - 1).forEach { index ->\n var di = AN[((index + 1) % N).toInt()] - AN[index] - k\n while ((di < 0)) {\n di += N\n count += 1\n }\n if (di != 0L) {\n println(\"NO\")\n return\n }\n }\n// val d = (1..N.toInt()).map { index -> AN[(index % N).toInt()] - AN[index - 1] - k }.toLongArray()\n// (0..N - 1).forEach { i ->\n// while (d[i.toInt()] < 0) {\n// d[i.toInt()] += N\n// count += 1\n// }\n// if (d[i.toInt()] != 0L) {\n// if (DEBUG) println(\"d[$i]=${d[i.toInt()]}\")\n// println(\"NO\")\n// return\n// }\n//\n// }\n if (k == count) println(\"YES\")\n else {\n if (DEBUG) println(\"k=$k ,count=$count\")\n println(\"NO\")\n }\n}\n", "problem_context": "Score : 500 points\n\nProblem Statement\n\nThere are N boxes arranged in a circle. The i-th box contains A_i stones.\n\nDetermine whether it is possible to remove all the stones from the boxes by repeatedly performing the following operation:\n\nSelect one box. Let the box be the i-th box. Then, for each j from 1 through N, remove exactly j stones from the (i+j)-th box. Here, the (N+k)-th box is identified with the k-th box.\n\nNote that the operation cannot be performed if there is a box that does not contain enough number of stones to be removed.\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\nIf it is possible to remove all the stones from the boxes, print YES. Otherwise, print NO.\n\nSample Input 1\n\n5\n4 5 1 2 3\n\nSample Output 1\n\nYES\n\nAll the stones can be removed in one operation by selecting the second box.\n\nSample Input 2\n\n5\n6 9 12 10 8\n\nSample Output 2\n\nYES\n\nSample Input 3\n\n4\n1 2 3 1\n\nSample Output 3\n\nNO", "sample_input": "5\n4 5 1 2 3\n"}, "reference_outputs": ["YES\n"], "source_document_id": "p03808", "source_text": "Score : 500 points\n\nProblem Statement\n\nThere are N boxes arranged in a circle. The i-th box contains A_i stones.\n\nDetermine whether it is possible to remove all the stones from the boxes by repeatedly performing the following operation:\n\nSelect one box. Let the box be the i-th box. Then, for each j from 1 through N, remove exactly j stones from the (i+j)-th box. Here, the (N+k)-th box is identified with the k-th box.\n\nNote that the operation cannot be performed if there is a box that does not contain enough number of stones to be removed.\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\nIf it is possible to remove all the stones from the boxes, print YES. Otherwise, print NO.\n\nSample Input 1\n\n5\n4 5 1 2 3\n\nSample Output 1\n\nYES\n\nAll the stones can be removed in one operation by selecting the second box.\n\nSample Input 2\n\n5\n6 9 12 10 8\n\nSample Output 2\n\nYES\n\nSample Input 3\n\n4\n1 2 3 1\n\nSample Output 3\n\nNO", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 2102, "memory_kb": 40492}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s492377659", "group_id": "codeNet:p03813", "input_text": "fun main(args: Array) {\n val x: Int = readLine()!!.toInt()\n if (x < 1200) println(\"ABC\") else println(\"ARC\")\n}", "language": "Kotlin", "metadata": {"date": 1514327643, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03813.html", "problem_id": "p03813", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03813/input.txt", "sample_output_relpath": "derived/input_output/data/p03813/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03813/Kotlin/s492377659.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s492377659", "user_id": "u537963083"}, "prompt_components": {"gold_output": "ABC\n", "input_to_evaluate": "fun main(args: Array) {\n val x: Int = readLine()!!.toInt()\n if (x < 1200) println(\"ABC\") else println(\"ARC\")\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nSmeke has decided to participate in AtCoder Beginner Contest (ABC) if his current rating is less than 1200, and participate in AtCoder Regular Contest (ARC) otherwise.\n\nYou are given Smeke's current rating, x. Print ABC if Smeke will participate in ABC, and print ARC otherwise.\n\nConstraints\n\n1 ≦ x ≦ 3{,}000\n\nx is an integer.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nx\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n1000\n\nSample Output 1\n\nABC\n\nSmeke's current rating is less than 1200, thus the output should be ABC.\n\nSample Input 2\n\n2000\n\nSample Output 2\n\nARC\n\nSmeke's current rating is not less than 1200, thus the output should be ARC.", "sample_input": "1000\n"}, "reference_outputs": ["ABC\n"], "source_document_id": "p03813", "source_text": "Score : 100 points\n\nProblem Statement\n\nSmeke has decided to participate in AtCoder Beginner Contest (ABC) if his current rating is less than 1200, and participate in AtCoder Regular Contest (ARC) otherwise.\n\nYou are given Smeke's current rating, x. Print ABC if Smeke will participate in ABC, and print ARC otherwise.\n\nConstraints\n\n1 ≦ x ≦ 3{,}000\n\nx is an integer.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nx\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n1000\n\nSample Output 1\n\nABC\n\nSmeke's current rating is less than 1200, thus the output should be ABC.\n\nSample Input 2\n\n2000\n\nSample Output 2\n\nARC\n\nSmeke's current rating is not less than 1200, thus the output should be ARC.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 199, "memory_kb": 31496}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s053213628", "group_id": "codeNet:p03817", "input_text": "fun main(args: Array) {\n Program().solve()\n}\n\nclass Program {\n fun solve() {\n val sc = MyScanner()\n val x = sc.nextLong()\n\n // 5,6,\n val d = x / 11\n val m = x % 11\n var ans = d * 2\n ans += when {\n m == 0L -> 0\n m <= 5 -> 1\n else -> 2\n }\n println(ans)\n }\n}\n\n\nclass MyScanner() {\n private var index = 0\n private var line = listOf()\n\n fun next(): String {\n while (line.size <= index) {\n line = readLine()!!.split(' ')\n index = 0\n }\n return line[index++]\n }\n\n fun nextInt() = next().toInt()\n fun nextLong() = next().toLong()\n fun nextDouble() = next().toDouble()\n fun nextCharArray() = next().toCharArray()\n fun nextChar() = next()[0]\n\n fun strList(): List {\n index = line.size\n return readLine()!!.split(' ')\n }\n\n fun intList() = strList().map { it.toInt() }\n fun longList() = strList().map { it.toLong() }\n fun doubleList() = strList().map { it.toDouble() }\n}", "language": "Kotlin", "metadata": {"date": 1586345833, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03817.html", "problem_id": "p03817", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03817/input.txt", "sample_output_relpath": "derived/input_output/data/p03817/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03817/Kotlin/s053213628.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s053213628", "user_id": "u194412908"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "fun main(args: Array) {\n Program().solve()\n}\n\nclass Program {\n fun solve() {\n val sc = MyScanner()\n val x = sc.nextLong()\n\n // 5,6,\n val d = x / 11\n val m = x % 11\n var ans = d * 2\n ans += when {\n m == 0L -> 0\n m <= 5 -> 1\n else -> 2\n }\n println(ans)\n }\n}\n\n\nclass MyScanner() {\n private var index = 0\n private var line = listOf()\n\n fun next(): String {\n while (line.size <= index) {\n line = readLine()!!.split(' ')\n index = 0\n }\n return line[index++]\n }\n\n fun nextInt() = next().toInt()\n fun nextLong() = next().toLong()\n fun nextDouble() = next().toDouble()\n fun nextCharArray() = next().toCharArray()\n fun nextChar() = next()[0]\n\n fun strList(): List {\n index = line.size\n return readLine()!!.split(' ')\n }\n\n fun intList() = strList().map { it.toInt() }\n fun longList() = strList().map { it.toLong() }\n fun doubleList() = strList().map { it.toDouble() }\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nSnuke has decided to play with a six-sided die. Each of its six sides shows an integer 1 through 6, and two numbers on opposite sides always add up to 7.\n\nSnuke will first put the die on the table with an arbitrary side facing upward, then repeatedly perform the following operation:\n\nOperation: Rotate the die 90° toward one of the following directions: left, right, front (the die will come closer) and back (the die will go farther). Then, obtain y points where y is the number written in the side facing upward.\n\nFor example, let us consider the situation where the side showing 1 faces upward, the near side shows 5 and the right side shows 4, as illustrated in the figure.\nIf the die is rotated toward the right as shown in the figure, the side showing 3 will face upward.\nBesides, the side showing 4 will face upward if the die is rotated toward the left, the side showing 2 will face upward if the die is rotated toward the front, and the side showing 5 will face upward if the die is rotated toward the back.\n\nFind the minimum number of operation Snuke needs to perform in order to score at least x points in total.\n\nConstraints\n\n1 ≦ x ≦ 10^{15}\n\nx is an integer.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nx\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n7\n\nSample Output 1\n\n2\n\nSample Input 2\n\n149696127901\n\nSample Output 2\n\n27217477801", "sample_input": "7\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03817", "source_text": "Score : 300 points\n\nProblem Statement\n\nSnuke has decided to play with a six-sided die. Each of its six sides shows an integer 1 through 6, and two numbers on opposite sides always add up to 7.\n\nSnuke will first put the die on the table with an arbitrary side facing upward, then repeatedly perform the following operation:\n\nOperation: Rotate the die 90° toward one of the following directions: left, right, front (the die will come closer) and back (the die will go farther). Then, obtain y points where y is the number written in the side facing upward.\n\nFor example, let us consider the situation where the side showing 1 faces upward, the near side shows 5 and the right side shows 4, as illustrated in the figure.\nIf the die is rotated toward the right as shown in the figure, the side showing 3 will face upward.\nBesides, the side showing 4 will face upward if the die is rotated toward the left, the side showing 2 will face upward if the die is rotated toward the front, and the side showing 5 will face upward if the die is rotated toward the back.\n\nFind the minimum number of operation Snuke needs to perform in order to score at least x points in total.\n\nConstraints\n\n1 ≦ x ≦ 10^{15}\n\nx is an integer.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nx\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n7\n\nSample Output 1\n\n2\n\nSample Input 2\n\n149696127901\n\nSample Output 2\n\n27217477801", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1085, "cpu_time_ms": 242, "memory_kb": 38180}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s808176677", "group_id": "codeNet:p03818", "input_text": "fun main(args: Array) {\n arc068b()\n}\n\nfun arc068b() {\n val n = readLine()!!.toInt()\n val aList = readLine()!!.split(' ').map { it.toInt() }\n\n val count = aList.distinct().size\n\n val answer = count + if (count % 2 == 0) -1 else 0\n\n println(answer)\n}\n", "language": "Kotlin", "metadata": {"date": 1585883066, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03818.html", "problem_id": "p03818", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03818/input.txt", "sample_output_relpath": "derived/input_output/data/p03818/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03818/Kotlin/s808176677.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s808176677", "user_id": "u139478771"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "fun main(args: Array) {\n arc068b()\n}\n\nfun arc068b() {\n val n = readLine()!!.toInt()\n val aList = readLine()!!.split(' ').map { it.toInt() }\n\n val count = aList.distinct().size\n\n val answer = count + if (count % 2 == 0) -1 else 0\n\n println(answer)\n}\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nSnuke has decided to play a game using cards.\nHe has a deck consisting of N cards. On the i-th card from the top, an integer A_i is written.\n\nHe will perform the operation described below zero or more times, so that the values written on the remaining cards will be pairwise distinct. Find the maximum possible number of remaining cards. Here, N is odd, which guarantees that at least one card can be kept.\n\nOperation: Take out three arbitrary cards from the deck. Among those three cards, eat two: one with the largest value, and another with the smallest value. Then, return the remaining one card to the deck.\n\nConstraints\n\n3 ≦ N ≦ 10^{5}\n\nN is odd.\n\n1 ≦ A_i ≦ 10^{5}\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_3 ... A_{N}\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n5\n1 2 1 3 7\n\nSample Output 1\n\n3\n\nOne optimal solution is to perform the operation once, taking out two cards with 1 and one card with 2. One card with 1 and another with 2 will be eaten, and the remaining card with 1 will be returned to deck. Then, the values written on the remaining cards in the deck will be pairwise distinct: 1, 3 and 7.\n\nSample Input 2\n\n15\n1 3 5 2 1 3 2 8 8 6 2 6 11 1 1\n\nSample Output 2\n\n7", "sample_input": "5\n1 2 1 3 7\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03818", "source_text": "Score : 400 points\n\nProblem Statement\n\nSnuke has decided to play a game using cards.\nHe has a deck consisting of N cards. On the i-th card from the top, an integer A_i is written.\n\nHe will perform the operation described below zero or more times, so that the values written on the remaining cards will be pairwise distinct. Find the maximum possible number of remaining cards. Here, N is odd, which guarantees that at least one card can be kept.\n\nOperation: Take out three arbitrary cards from the deck. Among those three cards, eat two: one with the largest value, and another with the smallest value. Then, return the remaining one card to the deck.\n\nConstraints\n\n3 ≦ N ≦ 10^{5}\n\nN is odd.\n\n1 ≦ A_i ≦ 10^{5}\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_3 ... A_{N}\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n5\n1 2 1 3 7\n\nSample Output 1\n\n3\n\nOne optimal solution is to perform the operation once, taking out two cards with 1 and one card with 2. One card with 1 and another with 2 will be eaten, and the remaining card with 1 will be returned to deck. Then, the values written on the remaining cards in the deck will be pairwise distinct: 1, 3 and 7.\n\nSample Input 2\n\n15\n1 3 5 2 1 3 2 8 8 6 2 6 11 1 1\n\nSample Output 2\n\n7", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 631, "memory_kb": 72648}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s897622660", "group_id": "codeNet:p03827", "input_text": "fun main(args: Array) {\n readLine()\n val S = readLine()!!\n\n var x = 0\n var res = 0\n for (c in S.toCharArray()) {\n if (c == 'I') {\n x++\n } else {\n x--\n }\n res = Math.max(res, x)\n }\n println(res)\n}", "language": "Kotlin", "metadata": {"date": 1575681742, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03827.html", "problem_id": "p03827", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03827/input.txt", "sample_output_relpath": "derived/input_output/data/p03827/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03827/Kotlin/s897622660.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s897622660", "user_id": "u183530284"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "fun main(args: Array) {\n readLine()\n val S = readLine()!!\n\n var x = 0\n var res = 0\n for (c in S.toCharArray()) {\n if (c == 'I') {\n x++\n } else {\n x--\n }\n res = Math.max(res, x)\n }\n println(res)\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nYou have an integer variable x.\nInitially, x=0.\n\nSome person gave you a string S of length N, and using the string you performed the following operation N times.\nIn the i-th operation, you incremented the value of x by 1 if S_i=I, and decremented the value of x by 1 if S_i=D.\n\nFind the maximum value taken by x during the operations (including before the first operation, and after the last operation).\n\nConstraints\n\n1≤N≤100\n\n|S|=N\n\nNo characters except I and D occur in S.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\nS\n\nOutput\n\nPrint the maximum value taken by x during the operations.\n\nSample Input 1\n\n5\nIIDID\n\nSample Output 1\n\n2\n\nAfter each operation, the value of x becomes 1, 2, 1, 2 and 1, respectively. Thus, the output should be 2, the maximum value.\n\nSample Input 2\n\n7\nDDIDDII\n\nSample Output 2\n\n0\n\nThe initial value x=0 is the maximum value taken by x, thus the output should be 0.", "sample_input": "5\nIIDID\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03827", "source_text": "Score : 200 points\n\nProblem Statement\n\nYou have an integer variable x.\nInitially, x=0.\n\nSome person gave you a string S of length N, and using the string you performed the following operation N times.\nIn the i-th operation, you incremented the value of x by 1 if S_i=I, and decremented the value of x by 1 if S_i=D.\n\nFind the maximum value taken by x during the operations (including before the first operation, and after the last operation).\n\nConstraints\n\n1≤N≤100\n\n|S|=N\n\nNo characters except I and D occur in S.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\nS\n\nOutput\n\nPrint the maximum value taken by x during the operations.\n\nSample Input 1\n\n5\nIIDID\n\nSample Output 1\n\n2\n\nAfter each operation, the value of x becomes 1, 2, 1, 2 and 1, respectively. Thus, the output should be 2, the maximum value.\n\nSample Input 2\n\n7\nDDIDDII\n\nSample Output 2\n\n0\n\nThe initial value x=0 is the maximum value taken by x, thus the output should be 0.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 210, "memory_kb": 31564}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s026417802", "group_id": "codeNet:p03828", "input_text": "fun main(arg: Array) {\n val N = nextInt()\n val MOD = 1000000007L\n var P = IntArray(N + 1)\n for (i in 2 .. N)\n for (j in i + i .. N step i) P[j] = 1\n var ans = 1L\n for (i in 2 .. N)\n if (P[i] == 0) {\n var total = 1L\n var j = i\n while (j <= N) {\n total += N / j\n j *= i\n }\n ans = ans * total % MOD\n }\n println(ans)\n}\n\nfun next() = readLine()!!\nfun nextInt(offset: Int = 0) = Integer.parseInt(next()) + offset\nfun nextLong() = next().toLong()\nfun listOfString() = next().split(\" \")\nfun listOfInt() = listOfString().map(String::toInt)\nfun listOfInt(offset: Int = 0) = listOfString().map { Integer.parseInt(it) + offset }\n", "language": "Kotlin", "metadata": {"date": 1586208548, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03828.html", "problem_id": "p03828", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03828/input.txt", "sample_output_relpath": "derived/input_output/data/p03828/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03828/Kotlin/s026417802.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s026417802", "user_id": "u043150661"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "fun main(arg: Array) {\n val N = nextInt()\n val MOD = 1000000007L\n var P = IntArray(N + 1)\n for (i in 2 .. N)\n for (j in i + i .. N step i) P[j] = 1\n var ans = 1L\n for (i in 2 .. N)\n if (P[i] == 0) {\n var total = 1L\n var j = i\n while (j <= N) {\n total += N / j\n j *= i\n }\n ans = ans * total % MOD\n }\n println(ans)\n}\n\nfun next() = readLine()!!\nfun nextInt(offset: Int = 0) = Integer.parseInt(next()) + offset\nfun nextLong() = next().toLong()\nfun listOfString() = next().split(\" \")\nfun listOfInt() = listOfString().map(String::toInt)\nfun listOfInt(offset: Int = 0) = listOfString().map { Integer.parseInt(it) + offset }\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nYou are given an integer N.\nFind the number of the positive divisors of N!, modulo 10^9+7.\n\nConstraints\n\n1≤N≤10^3\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the number of the positive divisors of N!, modulo 10^9+7.\n\nSample Input 1\n\n3\n\nSample Output 1\n\n4\n\nThere are four divisors of 3! =6: 1, 2, 3 and 6. Thus, the output should be 4.\n\nSample Input 2\n\n6\n\nSample Output 2\n\n30\n\nSample Input 3\n\n1000\n\nSample Output 3\n\n972926972", "sample_input": "3\n"}, "reference_outputs": ["4\n"], "source_document_id": "p03828", "source_text": "Score : 300 points\n\nProblem Statement\n\nYou are given an integer N.\nFind the number of the positive divisors of N!, modulo 10^9+7.\n\nConstraints\n\n1≤N≤10^3\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the number of the positive divisors of N!, modulo 10^9+7.\n\nSample Input 1\n\n3\n\nSample Output 1\n\n4\n\nThere are four divisors of 3! =6: 1, 2, 3 and 6. Thus, the output should be 4.\n\nSample Input 2\n\n6\n\nSample Output 2\n\n30\n\nSample Input 3\n\n1000\n\nSample Output 3\n\n972926972", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 752, "cpu_time_ms": 205, "memory_kb": 33660}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s040134219", "group_id": "codeNet:p03829", "input_text": "fun main(args : Array) {\n val (n, a, b) = readLine()!!.split(\" \").map { it.toInt() }\n val l = readLine()!!.split(\" \").map { it.toInt() }\n print((1 until l.size).map { listOf(a * (l[it] - l[it - 1]), b).min()!! }.sum())\n}", "language": "Kotlin", "metadata": {"date": 1539301333, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03829.html", "problem_id": "p03829", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03829/input.txt", "sample_output_relpath": "derived/input_output/data/p03829/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03829/Kotlin/s040134219.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s040134219", "user_id": "u384476909"}, "prompt_components": {"gold_output": "11\n", "input_to_evaluate": "fun main(args : Array) {\n val (n, a, b) = readLine()!!.split(\" \").map { it.toInt() }\n val l = readLine()!!.split(\" \").map { it.toInt() }\n print((1 until l.size).map { listOf(a * (l[it] - l[it - 1]), b).min()!! }.sum())\n}", "problem_context": "Score : 500 points\n\nProblem Statement\n\nThere are N towns on a line running east-west.\nThe towns are numbered 1 through N, in order from west to east.\nEach point on the line has a one-dimensional coordinate, and a point that is farther east has a greater coordinate value.\nThe coordinate of town i is X_i.\n\nYou are now at town 1, and you want to visit all the other towns.\nYou have two ways to travel:\n\nWalk on the line.\nYour fatigue level increases by A each time you travel a distance of 1, regardless of direction.\n\nTeleport to any location of your choice.\nYour fatigue level increases by B, regardless of the distance covered.\n\nFind the minimum possible total increase of your fatigue level when you visit all the towns in these two ways.\n\nConstraints\n\nAll input values are integers.\n\n2≤N≤10^5\n\n1≤X_i≤10^9\n\nFor all i(1≤i≤N-1), X_i){\n\tval cin = Scanner(System.`in`)\n val n = cin.nextInt()\n val a = cin.nextInt()\n val b = cin.nextInt()\n val x = Array(n, { cin.nextInt() })\n\n var ans: Long = 0\n\n for (i in 0..n-2) {\n if (a*(x[i+1] - x[i]) > b) {\n ans += b\n } else {\n ans += a*(x[i+1] - x[i])\n }\n }\n println(ans)\n}", "language": "Kotlin", "metadata": {"date": 1559336082, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03831.html", "problem_id": "p03831", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03831/input.txt", "sample_output_relpath": "derived/input_output/data/p03831/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03831/Kotlin/s144705480.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s144705480", "user_id": "u111421568"}, "prompt_components": {"gold_output": "11\n", "input_to_evaluate": "import java.util.*\n\nfun rangesum(n: Int, m: Int): Int {\n return n * (n + 1) / 2 - m * (m + 1) / 2\n}\n\nfun main(args: Array){\n\tval cin = Scanner(System.`in`)\n val n = cin.nextInt()\n val a = cin.nextInt()\n val b = cin.nextInt()\n val x = Array(n, { cin.nextInt() })\n\n var ans: Long = 0\n\n for (i in 0..n-2) {\n if (a*(x[i+1] - x[i]) > b) {\n ans += b\n } else {\n ans += a*(x[i+1] - x[i])\n }\n }\n println(ans)\n}", "problem_context": "Score : 500 points\n\nProblem Statement\n\nThere are N towns on a line running east-west.\nThe towns are numbered 1 through N, in order from west to east.\nEach point on the line has a one-dimensional coordinate, and a point that is farther east has a greater coordinate value.\nThe coordinate of town i is X_i.\n\nYou are now at town 1, and you want to visit all the other towns.\nYou have two ways to travel:\n\nWalk on the line.\nYour fatigue level increases by A each time you travel a distance of 1, regardless of direction.\n\nTeleport to any location of your choice.\nYour fatigue level increases by B, regardless of the distance covered.\n\nFind the minimum possible total increase of your fatigue level when you visit all the towns in these two ways.\n\nConstraints\n\nAll input values are integers.\n\n2≤N≤10^5\n\n1≤X_i≤10^9\n\nFor all i(1≤i≤N-1), X_i) \n{\n val (sx, sy, tx, ty) = readLine()!!.split(\" \").map {x -> x.toInt()} //入力\n val dx = tx-sx\n val dy = ty-sy\n print(\"U\".repeat(dy)+\"R\".repeat(dx)+\"D\".repeat(dy)+\"L\".repeat(dx))//内側の一往復\n println(\"L\" + \"U\".repeat(dy + 1) + \"R\".repeat(dx + 1) + \"D\" + \n \"R\" + \"D\".repeat(dy + 1) + \"L\".repeat(dx + 1) + \"U\")//外側の一往復\n}", "language": "Kotlin", "metadata": {"date": 1522438580, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03836.html", "problem_id": "p03836", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03836/input.txt", "sample_output_relpath": "derived/input_output/data/p03836/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03836/Kotlin/s022216556.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s022216556", "user_id": "u562554924"}, "prompt_components": {"gold_output": "UURDDLLUUURRDRDDDLLU\n", "input_to_evaluate": "fun main(args: Array) \n{\n val (sx, sy, tx, ty) = readLine()!!.split(\" \").map {x -> x.toInt()} //入力\n val dx = tx-sx\n val dy = ty-sy\n print(\"U\".repeat(dy)+\"R\".repeat(dx)+\"D\".repeat(dy)+\"L\".repeat(dx))//内側の一往復\n println(\"L\" + \"U\".repeat(dy + 1) + \"R\".repeat(dx + 1) + \"D\" + \n \"R\" + \"D\".repeat(dy + 1) + \"L\".repeat(dx + 1) + \"U\")//外側の一往復\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nDolphin resides in two-dimensional Cartesian plane, with the positive x-axis pointing right and the positive y-axis pointing up.\n\nCurrently, he is located at the point (sx,sy). In each second, he can move up, down, left or right by a distance of 1.\n\nHere, both the x- and y-coordinates before and after each movement must be integers.\n\nHe will first visit the point (tx,ty) where sx < tx and sy < ty, then go back to the point (sx,sy), then visit the point (tx,ty) again, and lastly go back to the point (sx,sy).\n\nHere, during the whole travel, he is not allowed to pass through the same point more than once, except the points (sx,sy) and (tx,ty).\n\nUnder this condition, find a shortest path for him.\n\nConstraints\n\n-1000 ≤ sx < tx ≤ 1000\n\n-1000 ≤ sy < ty ≤ 1000\n\nsx,sy,tx and ty are integers.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nsx sy tx ty\n\nOutput\n\nPrint a string S that represents a shortest path for Dolphin.\n\nThe i-th character in S should correspond to his i-th movement.\n\nThe directions of the movements should be indicated by the following characters:\n\nU: Up\n\nD: Down\n\nL: Left\n\nR: Right\n\nIf there exist multiple shortest paths under the condition, print any of them.\n\nSample Input 1\n\n0 0 1 2\n\nSample Output 1\n\nUURDDLLUUURRDRDDDLLU\n\nOne possible shortest path is:\n\nGoing from (sx,sy) to (tx,ty) for the first time: (0,0) → (0,1) → (0,2) → (1,2)\n\nGoing from (tx,ty) to (sx,sy) for the first time: (1,2) → (1,1) → (1,0) → (0,0)\n\nGoing from (sx,sy) to (tx,ty) for the second time: (0,0) → (-1,0) → (-1,1) → (-1,2) → (-1,3) → (0,3) → (1,3) → (1,2)\n\nGoing from (tx,ty) to (sx,sy) for the second time: (1,2) → (2,2) → (2,1) → (2,0) → (2,-1) → (1,-1) → (0,-1) → (0,0)\n\nSample Input 2\n\n-2 -2 1 1\n\nSample Output 2\n\nUURRURRDDDLLDLLULUUURRURRDDDLLDL", "sample_input": "0 0 1 2\n"}, "reference_outputs": ["UURDDLLUUURRDRDDDLLU\n"], "source_document_id": "p03836", "source_text": "Score : 300 points\n\nProblem Statement\n\nDolphin resides in two-dimensional Cartesian plane, with the positive x-axis pointing right and the positive y-axis pointing up.\n\nCurrently, he is located at the point (sx,sy). In each second, he can move up, down, left or right by a distance of 1.\n\nHere, both the x- and y-coordinates before and after each movement must be integers.\n\nHe will first visit the point (tx,ty) where sx < tx and sy < ty, then go back to the point (sx,sy), then visit the point (tx,ty) again, and lastly go back to the point (sx,sy).\n\nHere, during the whole travel, he is not allowed to pass through the same point more than once, except the points (sx,sy) and (tx,ty).\n\nUnder this condition, find a shortest path for him.\n\nConstraints\n\n-1000 ≤ sx < tx ≤ 1000\n\n-1000 ≤ sy < ty ≤ 1000\n\nsx,sy,tx and ty are integers.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nsx sy tx ty\n\nOutput\n\nPrint a string S that represents a shortest path for Dolphin.\n\nThe i-th character in S should correspond to his i-th movement.\n\nThe directions of the movements should be indicated by the following characters:\n\nU: Up\n\nD: Down\n\nL: Left\n\nR: Right\n\nIf there exist multiple shortest paths under the condition, print any of them.\n\nSample Input 1\n\n0 0 1 2\n\nSample Output 1\n\nUURDDLLUUURRDRDDDLLU\n\nOne possible shortest path is:\n\nGoing from (sx,sy) to (tx,ty) for the first time: (0,0) → (0,1) → (0,2) → (1,2)\n\nGoing from (tx,ty) to (sx,sy) for the first time: (1,2) → (1,1) → (1,0) → (0,0)\n\nGoing from (sx,sy) to (tx,ty) for the second time: (0,0) → (-1,0) → (-1,1) → (-1,2) → (-1,3) → (0,3) → (1,3) → (1,2)\n\nGoing from (tx,ty) to (sx,sy) for the second time: (1,2) → (2,2) → (2,1) → (2,0) → (2,-1) → (1,-1) → (0,-1) → (0,0)\n\nSample Input 2\n\n-2 -2 1 1\n\nSample Output 2\n\nUURRURRDDDLLDLLULUUURRURRDDDLLDL", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 250, "memory_kb": 37680}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s773011092", "group_id": "codeNet:p03837", "input_text": "import java.io.PrintWriter\nimport java.util.*\nimport java.math.*\nimport java.lang.*\nimport kotlin.comparisons.*\n\nval pw = PrintWriter(System.out)\nval MOD: Long = (1e+9 + 7).toLong()\n\ndata class Point(val next: Int, val cost: Int)\nfun main(args: Array) {\n\tval (n, m) = readListOfInt()\n\tval edges = Array(n) { mutableListOf() }\n\tfor(i in 0 until m) {\n\t\tval (a, b, c) = readListOfInt().toMutableList().apply {\n\t\t\tthis[0]--\n\t\t\tthis[1]--\n\t\t}\n\t\tedges[a].add(Point(b, c))\n\t\tedges[b].add(Point(a, c))\n\t}\n\n\tval distances = Array(n) { Array(n) { 1000000 } }\n\tfor(i in 0 until n) {\n\t\tdistances[i][i] = 0\n\t}\n\tedges.forEachIndexed { a, nextEdges ->\n\t\tnextEdges.forEach { e ->\n\t\t\tval (b, c) = e\n\t\t\tdistances[a][b] = c \n\t\t\tdistances[b][a] = c \n\t\t}\n\t}\n\tfor(k in 0 until n) {\n\t\tfor(i in 0 until n) {\n\t\t\tfor(j in 0 until n) {\n\t\t\t\tdistances[i][j] = Math.min(distances[i][j], distances[i][k] + distances[k][j])\n\t\t\t}\n\t\t}\n\t}\n\n\tvar cnt = m * 2\n\tedges.forEachIndexed { a, nextEdges ->\n\t\tnextEdges.forEach { e ->\n\t\t\tval (b, c) = e\n\t\t\tvar isShortestPath = false\n\t\t\tfor(i in 0 until n) {\n\t\t\t\tif(distances[a][i] + c == distances[a][b]) {\n\t\t\t\t\tisShortestPath = true\t\n\t\t\t\t}\n\t\t\t}\n\t\t\tif(isShortestPath) {\n\t\t\t\tcnt--\n\t\t\t}\n\t\t}\n\n\t}\n\tprintln(cnt/2)\n\tpw.flush()\n}\n\n/****** Declared Functions and Data Structures ******/\n// IO\nfun read() = readLine()!!\nfun readInt() = read().toInt()\nfun readLong() = read().toLong()\nfun readDouble() = read().toDouble()\nfun readListOfString() = read().split(\" \")\nfun readListOfInt() = readListOfString().map { it.toInt() }\nfun readListOfLong() = readListOfString().map { it.toLong() }\nfun readListOfDouble() = readListOfString().map { it.toDouble() }\n\nfun Double.format(digits: Int) = String.format(\"%.${digits}f\", this)\nfun Float.format(digits: Int) = String.format(\"%.${digits}f\", this)\n\nfun print(value: Any) { pw.print(value) }\nfun println(value : Any) { pw.println(value) }\n\n// Extensions\nfun List.toBuckets(): Map\n\t= this.groupBy { it }.mapValues { it.value.size }\n\nfun> List.upperBound(element: T, fromIndex: Int=0, toIndex: Int=this.size): Int {\n\tvar l = fromIndex\n\tvar r = toIndex\n\twhile(l < r) {\n\t\tval mid = (l+r) / 2\n\t\tif(element >= this[mid]) { \n\t\t\tl = mid + 1\n\t\t} else {\n\t\t\tr = mid\n\t\t}\n\t}\n\treturn l\n}\n\nfun> List.lowerBound(element: T, fromIndex: Int=0, toIndex: Int=this.size): Int {\n\tvar l = fromIndex\n\tvar r = toIndex\n\twhile(l < r) {\n\t\tval mid = (l+r) / 2\n\t\tif(element <= this[mid]) { \n\t\t\tr = mid\n\t\t} else {\n\t\t\tl = mid + 1\n\t\t}\n\t}\n\treturn r \n}\n\nfun Map.toMutableMap(): MutableMap = HashMap(this)\n\n// Util Functions\nfun Long.makeDivisors(): List {\n\tval divisors = mutableListOf()\n\tfor(i in 1L .. Math.sqrt(this.toDouble()).toLong()+1L) {\n\t\tif(this % i == 0L) {\n\t\t\tdivisors.add(i)\n\t\t\tif(i != this/i) {\n\t\t\t\tdivisors.add(this/i)\n\t\t\t}\n\t\t}\n\t}\n\treturn divisors.distinct().sorted()\n}\n\nfun Long.isPrime(): Boolean {\n\tif(this==1L) return false\n\tfor(i in 2L .. Math.sqrt(this.toDouble()).toLong() + 1L) {\n\t\tif(this % i == 0L && this != i) {\n\t\t\treturn false\n\t\t}\n\t}\n\treturn true\n}\n\n\nfun permutations(src: List): List> {\n\tif(src.size == 1) return listOf(src)\n\tval perms = mutableListOf>()\n\tval insertElement = src[0]\n\tpermutations(src.drop(1)).forEach { perm ->\n\t\tfor(i in 0..perm.size) {\n\t\t\tval newPerm = perm.toMutableList()\n\t\t\tnewPerm.add(i, insertElement)\n\t\t\tperms.add(newPerm.toList())\n\t\t}\n\t}\n\treturn perms\n}\n\n// return nCr, if you want nCr, please access v[n][r]\nfun combinations(n: Long): List> {\n\tval v = (0..n).map { (0..n).map{0L}.toMutableList() }.toMutableList()\n\tfor(i in 0 until v.size) {\n\t\tv[i][0] = 1L\n\t\tv[i][i] = 1L\n\t}\n\tfor(i in 0 until v.size) {\n\t\tfor(j in 1 until i) {\n\t\t\tv[i][j] = (v[i-1][j-1] + v[i-1][j]) % MOD\n\t\t}\n\t}\n\treturn v.map { it.toList() }.toList()\n}\n\nfun repeatedModPow(a: Long, n: Long, mod: Long): Long = \n\twhen {\n\t\tn == 1L -> a % mod\n\t\tn % 2L == 1L -> (a * repeatedModPow(a, n-1L, mod)) % mod\n\t\telse -> {\n\t\t\tval tmp = repeatedModPow(a, n / 2L, mod)\n\t\t\t(tmp * tmp) % mod\n\t\t}\n\t}\n\n// return nCr % MOD\nfun modnCkWithoutArray(n: Long, k: Long, mod: Long): Long {\n\tvar ret = 1L\n\tval min = Math.min(k, n-k)\n\t// まず分母の計算\n\tfor(i in n downTo (n - min + 1)) {\n\t\tret = ret * i % mod\n\t}\n\tfor(i in min downTo 1) {\n\t\tret = ret * repeatedModPow(i, (mod - 2L), mod) % mod\n\t}\n\treturn ret\n}\n\n// return nCr % MOD\nfun modnCk(n: Int, k: Int, mod: Long): Long {\n\tval factorials = Array(n+1) { 0L }.apply {\n\t\tthis[0] = 1L\n\t\tif(this.size > 1) this[1] = 1L\n\t}\n\tval inverses = Array(n+1) { 0L }.apply {\n\t\tthis[0] = 1L\n\t\tif(this.size > 1) this[1] = 1L\n\t}\n\tval factorialInverses = Array(n+1) { 0L }.apply {\n\t\tthis[0] = 1L\n\t\tif(this.size > 1) this[1] = 1L\n\t}\n\tfor(i in 2 .. n) {\n\t\tfactorials[i] = (factorials[i-1] * i.toLong() % mod)\n\t\tinverses[i] = (mod - inverses[mod.toInt() % i] * (mod / i.toLong()) % mod)\n\t\tfactorialInverses[i] = (factorialInverses[i-1] * inverses[i] % mod)\n\t}\n\n\treturn factorials[n] % mod * (factorialInverses[k] * factorialInverses[n-k] % mod) % mod\n}\n\n// should be a >= b\nfun gcd(a: Long, b: Long): Long = \n\tif(b == 0L) a else gcd(b, a % b)\n\n// shoud be a >= b\nfun lcm(a: Long, b: Long): Long = \n\ta / gcd(a, b) * b\n\nfun sumDigits(num_: Long): Long {\n\tvar num = num_\n\tvar rtn: Long = 0\n\twhile(num != 0.toLong()) {\n\t\tval tmp = num % 10\n\t\trtn += tmp\n\t\tnum /= 10\n\t}\n\treturn rtn\n}\n\nfun Double.isDecimal(): Boolean = ((this - Math.floor(this)) != 0.0)\n\n// Data Structures\n\nclass UnionFind(private val n: Int) {\n\tprivate val parent: Array = Array(n) { 0 }\n\tprivate val rank: Array = Array(n) { 0 }\n\tprivate val size: Array = Array(n) { 0 }\n\n\tinit {\n\t\tfor(i in 0 until n) {\n\t\t\tparent[i] = i\n\t\t\trank[i] = 1\n\t\t\tsize[i] = 1\n\t\t}\n\t}\n\n\tfun union(u: Int, v: Int) {\n\t\tvar x = root(u)\n\t\tvar y = root(v)\n\t\tif(x != y) {\n\t\t\tif(rank[y] < rank[x]) {\n\t\t\t\tval tmp = y \n\t\t\t\ty = x\n\t\t\t\tx = tmp \n\t\t\t}\n\t\t\tparent[x] = y\n\t\t\trank[y] += rank[x]\n\t\t\trank[x] = -1\n\t\t\tval totalSize = size[x] + size[y]\n\t\t\tsize[x] = totalSize\n\t\t\tsize[y] = totalSize\n\t\t}\n\t}\n\n\tfun root(u: Int): Int {\n\t\tvar x = u\n\t\twhile(parent[x] != x) {\n\t\t\tx = parent[x]\n\t\t}\n\t\treturn x \n\t}\n\n\tfun size(u: Int): Int = size[root(u)]\n}\n", "language": "Kotlin", "metadata": {"date": 1586315311, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03837.html", "problem_id": "p03837", "resource_group": "medium_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/Kotlin/s773011092.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s773011092", "user_id": "u026686258"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "import java.io.PrintWriter\nimport java.util.*\nimport java.math.*\nimport java.lang.*\nimport kotlin.comparisons.*\n\nval pw = PrintWriter(System.out)\nval MOD: Long = (1e+9 + 7).toLong()\n\ndata class Point(val next: Int, val cost: Int)\nfun main(args: Array) {\n\tval (n, m) = readListOfInt()\n\tval edges = Array(n) { mutableListOf() }\n\tfor(i in 0 until m) {\n\t\tval (a, b, c) = readListOfInt().toMutableList().apply {\n\t\t\tthis[0]--\n\t\t\tthis[1]--\n\t\t}\n\t\tedges[a].add(Point(b, c))\n\t\tedges[b].add(Point(a, c))\n\t}\n\n\tval distances = Array(n) { Array(n) { 1000000 } }\n\tfor(i in 0 until n) {\n\t\tdistances[i][i] = 0\n\t}\n\tedges.forEachIndexed { a, nextEdges ->\n\t\tnextEdges.forEach { e ->\n\t\t\tval (b, c) = e\n\t\t\tdistances[a][b] = c \n\t\t\tdistances[b][a] = c \n\t\t}\n\t}\n\tfor(k in 0 until n) {\n\t\tfor(i in 0 until n) {\n\t\t\tfor(j in 0 until n) {\n\t\t\t\tdistances[i][j] = Math.min(distances[i][j], distances[i][k] + distances[k][j])\n\t\t\t}\n\t\t}\n\t}\n\n\tvar cnt = m * 2\n\tedges.forEachIndexed { a, nextEdges ->\n\t\tnextEdges.forEach { e ->\n\t\t\tval (b, c) = e\n\t\t\tvar isShortestPath = false\n\t\t\tfor(i in 0 until n) {\n\t\t\t\tif(distances[a][i] + c == distances[a][b]) {\n\t\t\t\t\tisShortestPath = true\t\n\t\t\t\t}\n\t\t\t}\n\t\t\tif(isShortestPath) {\n\t\t\t\tcnt--\n\t\t\t}\n\t\t}\n\n\t}\n\tprintln(cnt/2)\n\tpw.flush()\n}\n\n/****** Declared Functions and Data Structures ******/\n// IO\nfun read() = readLine()!!\nfun readInt() = read().toInt()\nfun readLong() = read().toLong()\nfun readDouble() = read().toDouble()\nfun readListOfString() = read().split(\" \")\nfun readListOfInt() = readListOfString().map { it.toInt() }\nfun readListOfLong() = readListOfString().map { it.toLong() }\nfun readListOfDouble() = readListOfString().map { it.toDouble() }\n\nfun Double.format(digits: Int) = String.format(\"%.${digits}f\", this)\nfun Float.format(digits: Int) = String.format(\"%.${digits}f\", this)\n\nfun print(value: Any) { pw.print(value) }\nfun println(value : Any) { pw.println(value) }\n\n// Extensions\nfun List.toBuckets(): Map\n\t= this.groupBy { it }.mapValues { it.value.size }\n\nfun> List.upperBound(element: T, fromIndex: Int=0, toIndex: Int=this.size): Int {\n\tvar l = fromIndex\n\tvar r = toIndex\n\twhile(l < r) {\n\t\tval mid = (l+r) / 2\n\t\tif(element >= this[mid]) { \n\t\t\tl = mid + 1\n\t\t} else {\n\t\t\tr = mid\n\t\t}\n\t}\n\treturn l\n}\n\nfun> List.lowerBound(element: T, fromIndex: Int=0, toIndex: Int=this.size): Int {\n\tvar l = fromIndex\n\tvar r = toIndex\n\twhile(l < r) {\n\t\tval mid = (l+r) / 2\n\t\tif(element <= this[mid]) { \n\t\t\tr = mid\n\t\t} else {\n\t\t\tl = mid + 1\n\t\t}\n\t}\n\treturn r \n}\n\nfun Map.toMutableMap(): MutableMap = HashMap(this)\n\n// Util Functions\nfun Long.makeDivisors(): List {\n\tval divisors = mutableListOf()\n\tfor(i in 1L .. Math.sqrt(this.toDouble()).toLong()+1L) {\n\t\tif(this % i == 0L) {\n\t\t\tdivisors.add(i)\n\t\t\tif(i != this/i) {\n\t\t\t\tdivisors.add(this/i)\n\t\t\t}\n\t\t}\n\t}\n\treturn divisors.distinct().sorted()\n}\n\nfun Long.isPrime(): Boolean {\n\tif(this==1L) return false\n\tfor(i in 2L .. Math.sqrt(this.toDouble()).toLong() + 1L) {\n\t\tif(this % i == 0L && this != i) {\n\t\t\treturn false\n\t\t}\n\t}\n\treturn true\n}\n\n\nfun permutations(src: List): List> {\n\tif(src.size == 1) return listOf(src)\n\tval perms = mutableListOf>()\n\tval insertElement = src[0]\n\tpermutations(src.drop(1)).forEach { perm ->\n\t\tfor(i in 0..perm.size) {\n\t\t\tval newPerm = perm.toMutableList()\n\t\t\tnewPerm.add(i, insertElement)\n\t\t\tperms.add(newPerm.toList())\n\t\t}\n\t}\n\treturn perms\n}\n\n// return nCr, if you want nCr, please access v[n][r]\nfun combinations(n: Long): List> {\n\tval v = (0..n).map { (0..n).map{0L}.toMutableList() }.toMutableList()\n\tfor(i in 0 until v.size) {\n\t\tv[i][0] = 1L\n\t\tv[i][i] = 1L\n\t}\n\tfor(i in 0 until v.size) {\n\t\tfor(j in 1 until i) {\n\t\t\tv[i][j] = (v[i-1][j-1] + v[i-1][j]) % MOD\n\t\t}\n\t}\n\treturn v.map { it.toList() }.toList()\n}\n\nfun repeatedModPow(a: Long, n: Long, mod: Long): Long = \n\twhen {\n\t\tn == 1L -> a % mod\n\t\tn % 2L == 1L -> (a * repeatedModPow(a, n-1L, mod)) % mod\n\t\telse -> {\n\t\t\tval tmp = repeatedModPow(a, n / 2L, mod)\n\t\t\t(tmp * tmp) % mod\n\t\t}\n\t}\n\n// return nCr % MOD\nfun modnCkWithoutArray(n: Long, k: Long, mod: Long): Long {\n\tvar ret = 1L\n\tval min = Math.min(k, n-k)\n\t// まず分母の計算\n\tfor(i in n downTo (n - min + 1)) {\n\t\tret = ret * i % mod\n\t}\n\tfor(i in min downTo 1) {\n\t\tret = ret * repeatedModPow(i, (mod - 2L), mod) % mod\n\t}\n\treturn ret\n}\n\n// return nCr % MOD\nfun modnCk(n: Int, k: Int, mod: Long): Long {\n\tval factorials = Array(n+1) { 0L }.apply {\n\t\tthis[0] = 1L\n\t\tif(this.size > 1) this[1] = 1L\n\t}\n\tval inverses = Array(n+1) { 0L }.apply {\n\t\tthis[0] = 1L\n\t\tif(this.size > 1) this[1] = 1L\n\t}\n\tval factorialInverses = Array(n+1) { 0L }.apply {\n\t\tthis[0] = 1L\n\t\tif(this.size > 1) this[1] = 1L\n\t}\n\tfor(i in 2 .. n) {\n\t\tfactorials[i] = (factorials[i-1] * i.toLong() % mod)\n\t\tinverses[i] = (mod - inverses[mod.toInt() % i] * (mod / i.toLong()) % mod)\n\t\tfactorialInverses[i] = (factorialInverses[i-1] * inverses[i] % mod)\n\t}\n\n\treturn factorials[n] % mod * (factorialInverses[k] * factorialInverses[n-k] % mod) % mod\n}\n\n// should be a >= b\nfun gcd(a: Long, b: Long): Long = \n\tif(b == 0L) a else gcd(b, a % b)\n\n// shoud be a >= b\nfun lcm(a: Long, b: Long): Long = \n\ta / gcd(a, b) * b\n\nfun sumDigits(num_: Long): Long {\n\tvar num = num_\n\tvar rtn: Long = 0\n\twhile(num != 0.toLong()) {\n\t\tval tmp = num % 10\n\t\trtn += tmp\n\t\tnum /= 10\n\t}\n\treturn rtn\n}\n\nfun Double.isDecimal(): Boolean = ((this - Math.floor(this)) != 0.0)\n\n// Data Structures\n\nclass UnionFind(private val n: Int) {\n\tprivate val parent: Array = Array(n) { 0 }\n\tprivate val rank: Array = Array(n) { 0 }\n\tprivate val size: Array = Array(n) { 0 }\n\n\tinit {\n\t\tfor(i in 0 until n) {\n\t\t\tparent[i] = i\n\t\t\trank[i] = 1\n\t\t\tsize[i] = 1\n\t\t}\n\t}\n\n\tfun union(u: Int, v: Int) {\n\t\tvar x = root(u)\n\t\tvar y = root(v)\n\t\tif(x != y) {\n\t\t\tif(rank[y] < rank[x]) {\n\t\t\t\tval tmp = y \n\t\t\t\ty = x\n\t\t\t\tx = tmp \n\t\t\t}\n\t\t\tparent[x] = y\n\t\t\trank[y] += rank[x]\n\t\t\trank[x] = -1\n\t\t\tval totalSize = size[x] + size[y]\n\t\t\tsize[x] = totalSize\n\t\t\tsize[y] = totalSize\n\t\t}\n\t}\n\n\tfun root(u: Int): Int {\n\t\tvar x = u\n\t\twhile(parent[x] != x) {\n\t\t\tx = parent[x]\n\t\t}\n\t\treturn x \n\t}\n\n\tfun size(u: Int): Int = size[root(u)]\n}\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≤i) {\n\tval (n, m) = readListOfInt()\n\tval edges = Array(n) { mutableListOf() }\n\tfor(i in 0 until m) {\n\t\tval (a, b, c) = readListOfInt().toMutableList().apply {\n\t\t\tthis[0]--\n\t\t\tthis[1]--\n\t\t}\n\t\tedges[a].add(Point(b, c))\n\t\tedges[b].add(Point(a, c))\n\t}\n\n\tval distances = Array(n) { Array(n) { 1000000 } }\n\tfor(i in 0 until n) {\n\t\tdistances[i][i] = 0\n\t}\n\tedges.forEachIndexed { a, nextEdges ->\n\t\tnextEdges.forEach { e ->\n\t\t\tval (b, c) = e\n\t\t\tdistances[a][b] = c \n\t\t\tdistances[b][a] = c \n\t\t}\n\t}\n\tfor(k in 0 until n) {\n\t\tfor(i in 0 until n) {\n\t\t\tfor(j in 0 until n) {\n\t\t\t\tdistances[i][j] = Math.min(distances[i][j], distances[i][k] + distances[k][j])\n\t\t\t}\n\t\t}\n\t}\n\n\tvar cnt = m * 2\n\tedges.forEachIndexed { a, nextEdges ->\n\t\tnextEdges.forEach { e ->\n\t\t\tval (b, c) = e\n\t\t\tvar isShortestPath = false\n\t\t\tfor(i in 0 until n) {\n\t\t\t\tif(distances[i][a] + c == distances[i][b]) {\n\t\t\t\t\tisShortestPath = true\t\n\t\t\t\t}\n\t\t\t}\n\t\t\tif(isShortestPath) {\n\t\t\t\tcnt--\n\t\t\t}\n\t\t}\n\n\t}\n\tprintln(cnt/2)\n\tpw.flush()\n}\n\n/****** Declared Functions and Data Structures ******/\n// IO\nfun read() = readLine()!!\nfun readInt() = read().toInt()\nfun readLong() = read().toLong()\nfun readDouble() = read().toDouble()\nfun readListOfString() = read().split(\" \")\nfun readListOfInt() = readListOfString().map { it.toInt() }\nfun readListOfLong() = readListOfString().map { it.toLong() }\nfun readListOfDouble() = readListOfString().map { it.toDouble() }\n\nfun Double.format(digits: Int) = String.format(\"%.${digits}f\", this)\nfun Float.format(digits: Int) = String.format(\"%.${digits}f\", this)\n\nfun print(value: Any) { pw.print(value) }\nfun println(value : Any) { pw.println(value) }\n\n// Extensions\nfun List.toBuckets(): Map\n\t= this.groupBy { it }.mapValues { it.value.size }\n\nfun> List.upperBound(element: T, fromIndex: Int=0, toIndex: Int=this.size): Int {\n\tvar l = fromIndex\n\tvar r = toIndex\n\twhile(l < r) {\n\t\tval mid = (l+r) / 2\n\t\tif(element >= this[mid]) { \n\t\t\tl = mid + 1\n\t\t} else {\n\t\t\tr = mid\n\t\t}\n\t}\n\treturn l\n}\n\nfun> List.lowerBound(element: T, fromIndex: Int=0, toIndex: Int=this.size): Int {\n\tvar l = fromIndex\n\tvar r = toIndex\n\twhile(l < r) {\n\t\tval mid = (l+r) / 2\n\t\tif(element <= this[mid]) { \n\t\t\tr = mid\n\t\t} else {\n\t\t\tl = mid + 1\n\t\t}\n\t}\n\treturn r \n}\n\nfun Map.toMutableMap(): MutableMap = HashMap(this)\n\n// Util Functions\nfun Long.makeDivisors(): List {\n\tval divisors = mutableListOf()\n\tfor(i in 1L .. Math.sqrt(this.toDouble()).toLong()+1L) {\n\t\tif(this % i == 0L) {\n\t\t\tdivisors.add(i)\n\t\t\tif(i != this/i) {\n\t\t\t\tdivisors.add(this/i)\n\t\t\t}\n\t\t}\n\t}\n\treturn divisors.distinct().sorted()\n}\n\nfun Long.isPrime(): Boolean {\n\tif(this==1L) return false\n\tfor(i in 2L .. Math.sqrt(this.toDouble()).toLong() + 1L) {\n\t\tif(this % i == 0L && this != i) {\n\t\t\treturn false\n\t\t}\n\t}\n\treturn true\n}\n\n\nfun permutations(src: List): List> {\n\tif(src.size == 1) return listOf(src)\n\tval perms = mutableListOf>()\n\tval insertElement = src[0]\n\tpermutations(src.drop(1)).forEach { perm ->\n\t\tfor(i in 0..perm.size) {\n\t\t\tval newPerm = perm.toMutableList()\n\t\t\tnewPerm.add(i, insertElement)\n\t\t\tperms.add(newPerm.toList())\n\t\t}\n\t}\n\treturn perms\n}\n\n// return nCr, if you want nCr, please access v[n][r]\nfun combinations(n: Long): List> {\n\tval v = (0..n).map { (0..n).map{0L}.toMutableList() }.toMutableList()\n\tfor(i in 0 until v.size) {\n\t\tv[i][0] = 1L\n\t\tv[i][i] = 1L\n\t}\n\tfor(i in 0 until v.size) {\n\t\tfor(j in 1 until i) {\n\t\t\tv[i][j] = (v[i-1][j-1] + v[i-1][j]) % MOD\n\t\t}\n\t}\n\treturn v.map { it.toList() }.toList()\n}\n\nfun repeatedModPow(a: Long, n: Long, mod: Long): Long = \n\twhen {\n\t\tn == 1L -> a % mod\n\t\tn % 2L == 1L -> (a * repeatedModPow(a, n-1L, mod)) % mod\n\t\telse -> {\n\t\t\tval tmp = repeatedModPow(a, n / 2L, mod)\n\t\t\t(tmp * tmp) % mod\n\t\t}\n\t}\n\n// return nCr % MOD\nfun modnCkWithoutArray(n: Long, k: Long, mod: Long): Long {\n\tvar ret = 1L\n\tval min = Math.min(k, n-k)\n\t// まず分母の計算\n\tfor(i in n downTo (n - min + 1)) {\n\t\tret = ret * i % mod\n\t}\n\tfor(i in min downTo 1) {\n\t\tret = ret * repeatedModPow(i, (mod - 2L), mod) % mod\n\t}\n\treturn ret\n}\n\n// return nCr % MOD\nfun modnCk(n: Int, k: Int, mod: Long): Long {\n\tval factorials = Array(n+1) { 0L }.apply {\n\t\tthis[0] = 1L\n\t\tif(this.size > 1) this[1] = 1L\n\t}\n\tval inverses = Array(n+1) { 0L }.apply {\n\t\tthis[0] = 1L\n\t\tif(this.size > 1) this[1] = 1L\n\t}\n\tval factorialInverses = Array(n+1) { 0L }.apply {\n\t\tthis[0] = 1L\n\t\tif(this.size > 1) this[1] = 1L\n\t}\n\tfor(i in 2 .. n) {\n\t\tfactorials[i] = (factorials[i-1] * i.toLong() % mod)\n\t\tinverses[i] = (mod - inverses[mod.toInt() % i] * (mod / i.toLong()) % mod)\n\t\tfactorialInverses[i] = (factorialInverses[i-1] * inverses[i] % mod)\n\t}\n\n\treturn factorials[n] % mod * (factorialInverses[k] * factorialInverses[n-k] % mod) % mod\n}\n\n// should be a >= b\nfun gcd(a: Long, b: Long): Long = \n\tif(b == 0L) a else gcd(b, a % b)\n\n// shoud be a >= b\nfun lcm(a: Long, b: Long): Long = \n\ta / gcd(a, b) * b\n\nfun sumDigits(num_: Long): Long {\n\tvar num = num_\n\tvar rtn: Long = 0\n\twhile(num != 0.toLong()) {\n\t\tval tmp = num % 10\n\t\trtn += tmp\n\t\tnum /= 10\n\t}\n\treturn rtn\n}\n\nfun Double.isDecimal(): Boolean = ((this - Math.floor(this)) != 0.0)\n\n// Data Structures\n\nclass UnionFind(private val n: Int) {\n\tprivate val parent: Array = Array(n) { 0 }\n\tprivate val rank: Array = Array(n) { 0 }\n\tprivate val size: Array = Array(n) { 0 }\n\n\tinit {\n\t\tfor(i in 0 until n) {\n\t\t\tparent[i] = i\n\t\t\trank[i] = 1\n\t\t\tsize[i] = 1\n\t\t}\n\t}\n\n\tfun union(u: Int, v: Int) {\n\t\tvar x = root(u)\n\t\tvar y = root(v)\n\t\tif(x != y) {\n\t\t\tif(rank[y] < rank[x]) {\n\t\t\t\tval tmp = y \n\t\t\t\ty = x\n\t\t\t\tx = tmp \n\t\t\t}\n\t\t\tparent[x] = y\n\t\t\trank[y] += rank[x]\n\t\t\trank[x] = -1\n\t\t\tval totalSize = size[x] + size[y]\n\t\t\tsize[x] = totalSize\n\t\t\tsize[y] = totalSize\n\t\t}\n\t}\n\n\tfun root(u: Int): Int {\n\t\tvar x = u\n\t\twhile(parent[x] != x) {\n\t\t\tx = parent[x]\n\t\t}\n\t\treturn x \n\t}\n\n\tfun size(u: Int): Int = size[root(u)]\n}\n", "language": "Kotlin", "metadata": {"date": 1586315096, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03837.html", "problem_id": "p03837", "resource_group": "medium_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/Kotlin/s644005937.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s644005937", "user_id": "u026686258"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "import java.io.PrintWriter\nimport java.util.*\nimport java.math.*\nimport java.lang.*\nimport kotlin.comparisons.*\n\nval pw = PrintWriter(System.out)\nval MOD: Long = (1e+9 + 7).toLong()\n\ndata class Point(val next: Int, val cost: Int)\nfun main(args: Array) {\n\tval (n, m) = readListOfInt()\n\tval edges = Array(n) { mutableListOf() }\n\tfor(i in 0 until m) {\n\t\tval (a, b, c) = readListOfInt().toMutableList().apply {\n\t\t\tthis[0]--\n\t\t\tthis[1]--\n\t\t}\n\t\tedges[a].add(Point(b, c))\n\t\tedges[b].add(Point(a, c))\n\t}\n\n\tval distances = Array(n) { Array(n) { 1000000 } }\n\tfor(i in 0 until n) {\n\t\tdistances[i][i] = 0\n\t}\n\tedges.forEachIndexed { a, nextEdges ->\n\t\tnextEdges.forEach { e ->\n\t\t\tval (b, c) = e\n\t\t\tdistances[a][b] = c \n\t\t\tdistances[b][a] = c \n\t\t}\n\t}\n\tfor(k in 0 until n) {\n\t\tfor(i in 0 until n) {\n\t\t\tfor(j in 0 until n) {\n\t\t\t\tdistances[i][j] = Math.min(distances[i][j], distances[i][k] + distances[k][j])\n\t\t\t}\n\t\t}\n\t}\n\n\tvar cnt = m * 2\n\tedges.forEachIndexed { a, nextEdges ->\n\t\tnextEdges.forEach { e ->\n\t\t\tval (b, c) = e\n\t\t\tvar isShortestPath = false\n\t\t\tfor(i in 0 until n) {\n\t\t\t\tif(distances[i][a] + c == distances[i][b]) {\n\t\t\t\t\tisShortestPath = true\t\n\t\t\t\t}\n\t\t\t}\n\t\t\tif(isShortestPath) {\n\t\t\t\tcnt--\n\t\t\t}\n\t\t}\n\n\t}\n\tprintln(cnt/2)\n\tpw.flush()\n}\n\n/****** Declared Functions and Data Structures ******/\n// IO\nfun read() = readLine()!!\nfun readInt() = read().toInt()\nfun readLong() = read().toLong()\nfun readDouble() = read().toDouble()\nfun readListOfString() = read().split(\" \")\nfun readListOfInt() = readListOfString().map { it.toInt() }\nfun readListOfLong() = readListOfString().map { it.toLong() }\nfun readListOfDouble() = readListOfString().map { it.toDouble() }\n\nfun Double.format(digits: Int) = String.format(\"%.${digits}f\", this)\nfun Float.format(digits: Int) = String.format(\"%.${digits}f\", this)\n\nfun print(value: Any) { pw.print(value) }\nfun println(value : Any) { pw.println(value) }\n\n// Extensions\nfun List.toBuckets(): Map\n\t= this.groupBy { it }.mapValues { it.value.size }\n\nfun> List.upperBound(element: T, fromIndex: Int=0, toIndex: Int=this.size): Int {\n\tvar l = fromIndex\n\tvar r = toIndex\n\twhile(l < r) {\n\t\tval mid = (l+r) / 2\n\t\tif(element >= this[mid]) { \n\t\t\tl = mid + 1\n\t\t} else {\n\t\t\tr = mid\n\t\t}\n\t}\n\treturn l\n}\n\nfun> List.lowerBound(element: T, fromIndex: Int=0, toIndex: Int=this.size): Int {\n\tvar l = fromIndex\n\tvar r = toIndex\n\twhile(l < r) {\n\t\tval mid = (l+r) / 2\n\t\tif(element <= this[mid]) { \n\t\t\tr = mid\n\t\t} else {\n\t\t\tl = mid + 1\n\t\t}\n\t}\n\treturn r \n}\n\nfun Map.toMutableMap(): MutableMap = HashMap(this)\n\n// Util Functions\nfun Long.makeDivisors(): List {\n\tval divisors = mutableListOf()\n\tfor(i in 1L .. Math.sqrt(this.toDouble()).toLong()+1L) {\n\t\tif(this % i == 0L) {\n\t\t\tdivisors.add(i)\n\t\t\tif(i != this/i) {\n\t\t\t\tdivisors.add(this/i)\n\t\t\t}\n\t\t}\n\t}\n\treturn divisors.distinct().sorted()\n}\n\nfun Long.isPrime(): Boolean {\n\tif(this==1L) return false\n\tfor(i in 2L .. Math.sqrt(this.toDouble()).toLong() + 1L) {\n\t\tif(this % i == 0L && this != i) {\n\t\t\treturn false\n\t\t}\n\t}\n\treturn true\n}\n\n\nfun permutations(src: List): List> {\n\tif(src.size == 1) return listOf(src)\n\tval perms = mutableListOf>()\n\tval insertElement = src[0]\n\tpermutations(src.drop(1)).forEach { perm ->\n\t\tfor(i in 0..perm.size) {\n\t\t\tval newPerm = perm.toMutableList()\n\t\t\tnewPerm.add(i, insertElement)\n\t\t\tperms.add(newPerm.toList())\n\t\t}\n\t}\n\treturn perms\n}\n\n// return nCr, if you want nCr, please access v[n][r]\nfun combinations(n: Long): List> {\n\tval v = (0..n).map { (0..n).map{0L}.toMutableList() }.toMutableList()\n\tfor(i in 0 until v.size) {\n\t\tv[i][0] = 1L\n\t\tv[i][i] = 1L\n\t}\n\tfor(i in 0 until v.size) {\n\t\tfor(j in 1 until i) {\n\t\t\tv[i][j] = (v[i-1][j-1] + v[i-1][j]) % MOD\n\t\t}\n\t}\n\treturn v.map { it.toList() }.toList()\n}\n\nfun repeatedModPow(a: Long, n: Long, mod: Long): Long = \n\twhen {\n\t\tn == 1L -> a % mod\n\t\tn % 2L == 1L -> (a * repeatedModPow(a, n-1L, mod)) % mod\n\t\telse -> {\n\t\t\tval tmp = repeatedModPow(a, n / 2L, mod)\n\t\t\t(tmp * tmp) % mod\n\t\t}\n\t}\n\n// return nCr % MOD\nfun modnCkWithoutArray(n: Long, k: Long, mod: Long): Long {\n\tvar ret = 1L\n\tval min = Math.min(k, n-k)\n\t// まず分母の計算\n\tfor(i in n downTo (n - min + 1)) {\n\t\tret = ret * i % mod\n\t}\n\tfor(i in min downTo 1) {\n\t\tret = ret * repeatedModPow(i, (mod - 2L), mod) % mod\n\t}\n\treturn ret\n}\n\n// return nCr % MOD\nfun modnCk(n: Int, k: Int, mod: Long): Long {\n\tval factorials = Array(n+1) { 0L }.apply {\n\t\tthis[0] = 1L\n\t\tif(this.size > 1) this[1] = 1L\n\t}\n\tval inverses = Array(n+1) { 0L }.apply {\n\t\tthis[0] = 1L\n\t\tif(this.size > 1) this[1] = 1L\n\t}\n\tval factorialInverses = Array(n+1) { 0L }.apply {\n\t\tthis[0] = 1L\n\t\tif(this.size > 1) this[1] = 1L\n\t}\n\tfor(i in 2 .. n) {\n\t\tfactorials[i] = (factorials[i-1] * i.toLong() % mod)\n\t\tinverses[i] = (mod - inverses[mod.toInt() % i] * (mod / i.toLong()) % mod)\n\t\tfactorialInverses[i] = (factorialInverses[i-1] * inverses[i] % mod)\n\t}\n\n\treturn factorials[n] % mod * (factorialInverses[k] * factorialInverses[n-k] % mod) % mod\n}\n\n// should be a >= b\nfun gcd(a: Long, b: Long): Long = \n\tif(b == 0L) a else gcd(b, a % b)\n\n// shoud be a >= b\nfun lcm(a: Long, b: Long): Long = \n\ta / gcd(a, b) * b\n\nfun sumDigits(num_: Long): Long {\n\tvar num = num_\n\tvar rtn: Long = 0\n\twhile(num != 0.toLong()) {\n\t\tval tmp = num % 10\n\t\trtn += tmp\n\t\tnum /= 10\n\t}\n\treturn rtn\n}\n\nfun Double.isDecimal(): Boolean = ((this - Math.floor(this)) != 0.0)\n\n// Data Structures\n\nclass UnionFind(private val n: Int) {\n\tprivate val parent: Array = Array(n) { 0 }\n\tprivate val rank: Array = Array(n) { 0 }\n\tprivate val size: Array = Array(n) { 0 }\n\n\tinit {\n\t\tfor(i in 0 until n) {\n\t\t\tparent[i] = i\n\t\t\trank[i] = 1\n\t\t\tsize[i] = 1\n\t\t}\n\t}\n\n\tfun union(u: Int, v: Int) {\n\t\tvar x = root(u)\n\t\tvar y = root(v)\n\t\tif(x != y) {\n\t\t\tif(rank[y] < rank[x]) {\n\t\t\t\tval tmp = y \n\t\t\t\ty = x\n\t\t\t\tx = tmp \n\t\t\t}\n\t\t\tparent[x] = y\n\t\t\trank[y] += rank[x]\n\t\t\trank[x] = -1\n\t\t\tval totalSize = size[x] + size[y]\n\t\t\tsize[x] = totalSize\n\t\t\tsize[y] = totalSize\n\t\t}\n\t}\n\n\tfun root(u: Int): Int {\n\t\tvar x = u\n\t\twhile(parent[x] != x) {\n\t\t\tx = parent[x]\n\t\t}\n\t\treturn x \n\t}\n\n\tfun size(u: Int): Int = size[root(u)]\n}\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≤i) {\n Program().solve()\n}\n\nclass Program {\n fun solve() {\n val sc = FastScanner()\n val n = sc.nextInt()\n val m = sc.nextInt()\n val edges = Array(m) { Triple(sc.nextInt() - 1, sc.nextInt() - 1, sc.nextInt()) }\n\n val dist = Array(n) { Array(n) { Int.MAX_VALUE / 2 } }\n\n edges.forEach {\n dist[it.first][it.second] = it.third\n dist[it.second][it.first] = it.third\n }\n\n for (k in 0 until n)\n for (i in 0 until n)\n for (j in 0 until n)\n dist[i][j] = Math.min(dist[i][j], dist[i][k] + dist[k][j])\n\n println(edges.count { dist[it.first][it.second] != it.third })\n }\n}\n\n\nclass FastScanner {\n companion object {\n val input: InputStream = System.`in`\n val buffer = ByteArray(1024) { 0 }\n fun isPrintableChar(c: Int): Boolean = c in 33..126\n }\n\n var ptr = 0\n var buflen = 0\n private fun hasNextByte(): Boolean {\n if (ptr < buflen) {\n return true\n } else {\n ptr = 0\n buflen = input.read(buffer)\n if (buflen <= 0) {\n return false\n }\n }\n return true\n }\n\n private fun readByte(): Int = if (hasNextByte()) buffer[ptr++].toInt() else -1\n\n private fun skipUnprintable() {\n while (hasNextByte() && !isPrintableChar(buffer[ptr].toInt())) ptr++\n }\n\n fun hasNext(): Boolean {\n skipUnprintable()\n return hasNextByte()\n }\n\n fun next(): String {\n if (!hasNext()) throw NoSuchElementException()\n val sb = StringBuilder()\n var b = readByte()\n while (isPrintableChar(b)) {\n sb.appendCodePoint(b)\n b = readByte()\n }\n return sb.toString()\n }\n\n fun nextInt(): Int {\n if (!hasNext()) throw NoSuchElementException()\n var n = 0\n var b = readByte()\n // '-' = 45\n val minus = b == 45\n if (minus) {\n b = readByte()\n }\n\n // '0' = 48 '9' = 57\n if (b !in 48..57) {\n throw NumberFormatException()\n }\n\n while (true) {\n if (b in 48..57) {\n n *= 10\n n += b - 48\n } else if (b == -1 || !isPrintableChar(b)) {\n return if (minus) -n else n\n } else {\n throw NumberFormatException()\n }\n b = readByte()\n }\n }\n\n fun nextLong(): Long {\n if (!hasNext()) throw NoSuchElementException()\n var n = 0L\n var b = readByte()\n // '-' = 45\n val minus = b == 45\n if (minus) {\n b = readByte()\n }\n\n // '0' = 48 '9' = 57\n if (b !in 48..57) {\n throw NumberFormatException()\n }\n\n while (true) {\n if (b in 48..57) {\n n *= 10\n n += b - 48\n } else if (b == -1 || !isPrintableChar(b)) {\n return if (minus) -n else n\n } else {\n throw NumberFormatException()\n }\n b = readByte()\n }\n }\n\n fun nextDouble(): Double = next().toDouble()\n}\n", "language": "Kotlin", "metadata": {"date": 1582384073, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03837.html", "problem_id": "p03837", "resource_group": "medium_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/Kotlin/s791477953.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s791477953", "user_id": "u194412908"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "import java.util.*\nimport kotlin.*\n\nimport java.io.InputStream\nimport java.lang.NumberFormatException\nimport java.lang.StringBuilder\n\n\nfun main(args: Array) {\n Program().solve()\n}\n\nclass Program {\n fun solve() {\n val sc = FastScanner()\n val n = sc.nextInt()\n val m = sc.nextInt()\n val edges = Array(m) { Triple(sc.nextInt() - 1, sc.nextInt() - 1, sc.nextInt()) }\n\n val dist = Array(n) { Array(n) { Int.MAX_VALUE / 2 } }\n\n edges.forEach {\n dist[it.first][it.second] = it.third\n dist[it.second][it.first] = it.third\n }\n\n for (k in 0 until n)\n for (i in 0 until n)\n for (j in 0 until n)\n dist[i][j] = Math.min(dist[i][j], dist[i][k] + dist[k][j])\n\n println(edges.count { dist[it.first][it.second] != it.third })\n }\n}\n\n\nclass FastScanner {\n companion object {\n val input: InputStream = System.`in`\n val buffer = ByteArray(1024) { 0 }\n fun isPrintableChar(c: Int): Boolean = c in 33..126\n }\n\n var ptr = 0\n var buflen = 0\n private fun hasNextByte(): Boolean {\n if (ptr < buflen) {\n return true\n } else {\n ptr = 0\n buflen = input.read(buffer)\n if (buflen <= 0) {\n return false\n }\n }\n return true\n }\n\n private fun readByte(): Int = if (hasNextByte()) buffer[ptr++].toInt() else -1\n\n private fun skipUnprintable() {\n while (hasNextByte() && !isPrintableChar(buffer[ptr].toInt())) ptr++\n }\n\n fun hasNext(): Boolean {\n skipUnprintable()\n return hasNextByte()\n }\n\n fun next(): String {\n if (!hasNext()) throw NoSuchElementException()\n val sb = StringBuilder()\n var b = readByte()\n while (isPrintableChar(b)) {\n sb.appendCodePoint(b)\n b = readByte()\n }\n return sb.toString()\n }\n\n fun nextInt(): Int {\n if (!hasNext()) throw NoSuchElementException()\n var n = 0\n var b = readByte()\n // '-' = 45\n val minus = b == 45\n if (minus) {\n b = readByte()\n }\n\n // '0' = 48 '9' = 57\n if (b !in 48..57) {\n throw NumberFormatException()\n }\n\n while (true) {\n if (b in 48..57) {\n n *= 10\n n += b - 48\n } else if (b == -1 || !isPrintableChar(b)) {\n return if (minus) -n else n\n } else {\n throw NumberFormatException()\n }\n b = readByte()\n }\n }\n\n fun nextLong(): Long {\n if (!hasNext()) throw NoSuchElementException()\n var n = 0L\n var b = readByte()\n // '-' = 45\n val minus = b == 45\n if (minus) {\n b = readByte()\n }\n\n // '0' = 48 '9' = 57\n if (b !in 48..57) {\n throw NumberFormatException()\n }\n\n while (true) {\n if (b in 48..57) {\n n *= 10\n n += b - 48\n } else if (b == -1 || !isPrintableChar(b)) {\n return if (minus) -n else n\n } else {\n throw NumberFormatException()\n }\n b = readByte()\n }\n }\n\n fun nextDouble(): Double = next().toDouble()\n}\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≤i()\n var cnt=IntArray(2){1}\n var f=true\n var tmp=mutableListOf(x[cnt[1]][0], x[cnt[1]][0]-1)\n for (i in 0 until n*n){\n if (tmp[1]==0){\n cnt[1]++\n for (j in 0 until n- x[cnt[1]-1][0]){\n que.addLast(x[cnt[1]-1][0])\n }\n if (cnt[1]<=n){\n tmp= mutableListOf(x[cnt[1]][0], x[cnt[1]][0]-1)\n }else{\n tmp= mutableListOf(-1,-1)\n }\n\n }\n if (cnt[1]>n){\n if (cnt[0]<=n&&x[cnt[0]][1]==i){\n cnt[0]++\n }else{\n if (que.isNotEmpty()){\n a[i]=que.removeFirst()\n }\n }\n }else{\n\n if (x[cnt[0]][1]>i && tmp[1]>0){\n a[i]=tmp[0]\n tmp[1]--\n }\n if (x[cnt[0]][1]==i){\n cnt[0]++\n }\n if (cnt[0]>cnt[1]){\n f=false\n break\n }\n }\n }\n var check=IntArray(n+1){0 }\n var ind=1\n// println(\"check start\")\n for (i in a.indices){\n check[a[i]]++\n if (a[i]==check[a[i]]){\n if (i!=x[ind][1]){\n f=false\n// break\n }else{\n// print(check[a[i]])\n// print(\" \")\n// println(i)\n ind++\n }\n }\n }\n// println(\"check end\")\n// println(a.joinToString(separator = \" \"))\n if (f){\n println(\"Yes\")\n println(a.joinToString(separator = \" \"))\n }else{\n println(\"No\")\n }\n\n}", "language": "Kotlin", "metadata": {"date": 1600576711, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p03841.html", "problem_id": "p03841", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03841/input.txt", "sample_output_relpath": "derived/input_output/data/p03841/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03841/Kotlin/s419267959.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s419267959", "user_id": "u456173040"}, "prompt_components": {"gold_output": "Yes\n1 1 1 2 2 2 3 3 3\n", "input_to_evaluate": "import java.util.*\n\nfun main() {\n val n= readLine()!!.toInt()\n var x=Array(n+1){IntArray(2){0} }\n val inp= readLine()!!.split(\" \").map { it.toInt() }\n var a=IntArray(n*n){0}\n for (i in 1..n){\n x[i][0]=i\n x[i][1]=inp[i-1]-1\n if (x[i][1]()\n var cnt=IntArray(2){1}\n var f=true\n var tmp=mutableListOf(x[cnt[1]][0], x[cnt[1]][0]-1)\n for (i in 0 until n*n){\n if (tmp[1]==0){\n cnt[1]++\n for (j in 0 until n- x[cnt[1]-1][0]){\n que.addLast(x[cnt[1]-1][0])\n }\n if (cnt[1]<=n){\n tmp= mutableListOf(x[cnt[1]][0], x[cnt[1]][0]-1)\n }else{\n tmp= mutableListOf(-1,-1)\n }\n\n }\n if (cnt[1]>n){\n if (cnt[0]<=n&&x[cnt[0]][1]==i){\n cnt[0]++\n }else{\n if (que.isNotEmpty()){\n a[i]=que.removeFirst()\n }\n }\n }else{\n\n if (x[cnt[0]][1]>i && tmp[1]>0){\n a[i]=tmp[0]\n tmp[1]--\n }\n if (x[cnt[0]][1]==i){\n cnt[0]++\n }\n if (cnt[0]>cnt[1]){\n f=false\n break\n }\n }\n }\n var check=IntArray(n+1){0 }\n var ind=1\n// println(\"check start\")\n for (i in a.indices){\n check[a[i]]++\n if (a[i]==check[a[i]]){\n if (i!=x[ind][1]){\n f=false\n// break\n }else{\n// print(check[a[i]])\n// print(\" \")\n// println(i)\n ind++\n }\n }\n }\n// println(\"check end\")\n// println(a.joinToString(separator = \" \"))\n if (f){\n println(\"Yes\")\n println(a.joinToString(separator = \" \"))\n }else{\n println(\"No\")\n }\n\n}", "problem_context": "Score : 800 points\n\nProblem Statement\n\nYou are given an integer sequence x of length N.\nDetermine if there exists an integer sequence a that satisfies all of the following conditions, and if it exists, construct an instance of a.\n\na is N^2 in length, containing N copies of each of the integers 1, 2, ..., N.\n\nFor each 1 ≤ i ≤ N, the i-th occurrence of the integer i from the left in a is the x_i-th element of a from the left.\n\nConstraints\n\n1 ≤ N ≤ 500\n\n1 ≤ x_i ≤ N^2\n\nAll x_i are distinct.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\nx_1 x_2 ... x_N\n\nOutput\n\nIf there does not exist an integer sequence a that satisfies all the conditions, print No.\nIf there does exist such an sequence a, print Yes in the first line, then print an instance of a in the second line, with spaces inbetween.\n\nSample Input 1\n\n3\n1 5 9\n\nSample Output 1\n\nYes\n1 1 1 2 2 2 3 3 3\n\nFor example, the second occurrence of the integer 2 from the left in a in the output is the fifth element of a from the left.\nSimilarly, the condition is satisfied for the integers 1 and 3.\n\nSample Input 2\n\n2\n4 1\n\nSample Output 2\n\nNo", "sample_input": "3\n1 5 9\n"}, "reference_outputs": ["Yes\n1 1 1 2 2 2 3 3 3\n"], "source_document_id": "p03841", "source_text": "Score : 800 points\n\nProblem Statement\n\nYou are given an integer sequence x of length N.\nDetermine if there exists an integer sequence a that satisfies all of the following conditions, and if it exists, construct an instance of a.\n\na is N^2 in length, containing N copies of each of the integers 1, 2, ..., N.\n\nFor each 1 ≤ i ≤ N, the i-th occurrence of the integer i from the left in a is the x_i-th element of a from the left.\n\nConstraints\n\n1 ≤ N ≤ 500\n\n1 ≤ x_i ≤ N^2\n\nAll x_i are distinct.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\nx_1 x_2 ... x_N\n\nOutput\n\nIf there does not exist an integer sequence a that satisfies all the conditions, print No.\nIf there does exist such an sequence a, print Yes in the first line, then print an instance of a in the second line, with spaces inbetween.\n\nSample Input 1\n\n3\n1 5 9\n\nSample Output 1\n\nYes\n1 1 1 2 2 2 3 3 3\n\nFor example, the second occurrence of the integer 2 from the left in a in the output is the fifth element of a from the left.\nSimilarly, the condition is satisfied for the integers 1 and 3.\n\nSample Input 2\n\n2\n4 1\n\nSample Output 2\n\nNo", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1942, "cpu_time_ms": 374, "memory_kb": 61052}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s955068253", "group_id": "codeNet:p03841", "input_text": "import java.util.*\n\nfun main() {\n val n= readLine()!!.toInt()\n var x=Array(n+1){IntArray(2){0} }\n val inp= readLine()!!.split(\" \").map { it.toInt() }\n var a=IntArray(n*n){0}\n for (i in 1..n){\n x[i][0]=i\n x[i][1]=inp[i-1]-1\n a[x[i][1]]=i\n }\n x.sortBy { it[1] }\n var que=ArrayDeque()\n var cnt=IntArray(2){1}\n var f=true\n var tmp=mutableListOf(x[cnt[1]][0], x[cnt[1]][0]-1)\n for (i in 0 until n*n){\n if (cnt[1]>n){\n if (x[cnt[0]][1]==i){\n cnt[0]++\n }else{\n a[i]=que.removeFirst()\n }\n }else{\n if (x[cnt[0]][1]>i){\n a[i]=tmp[0]\n tmp[1]--\n }\n if (tmp[1]==0){\n for (j in 0 until n-x[cnt[1]][0]){\n que.addFirst(x[cnt[1]][0])\n }\n if (cnt[1]++cnt[1]){\n f=false\n break\n }\n }\n }\n if (f){\n println(\"Yes\")\n println(a.joinToString(separator = \" \"))\n }else{\n println(\"No\")\n }\n\n}", "language": "Kotlin", "metadata": {"date": 1600501275, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p03841.html", "problem_id": "p03841", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03841/input.txt", "sample_output_relpath": "derived/input_output/data/p03841/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03841/Kotlin/s955068253.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s955068253", "user_id": "u456173040"}, "prompt_components": {"gold_output": "Yes\n1 1 1 2 2 2 3 3 3\n", "input_to_evaluate": "import java.util.*\n\nfun main() {\n val n= readLine()!!.toInt()\n var x=Array(n+1){IntArray(2){0} }\n val inp= readLine()!!.split(\" \").map { it.toInt() }\n var a=IntArray(n*n){0}\n for (i in 1..n){\n x[i][0]=i\n x[i][1]=inp[i-1]-1\n a[x[i][1]]=i\n }\n x.sortBy { it[1] }\n var que=ArrayDeque()\n var cnt=IntArray(2){1}\n var f=true\n var tmp=mutableListOf(x[cnt[1]][0], x[cnt[1]][0]-1)\n for (i in 0 until n*n){\n if (cnt[1]>n){\n if (x[cnt[0]][1]==i){\n cnt[0]++\n }else{\n a[i]=que.removeFirst()\n }\n }else{\n if (x[cnt[0]][1]>i){\n a[i]=tmp[0]\n tmp[1]--\n }\n if (tmp[1]==0){\n for (j in 0 until n-x[cnt[1]][0]){\n que.addFirst(x[cnt[1]][0])\n }\n if (cnt[1]++cnt[1]){\n f=false\n break\n }\n }\n }\n if (f){\n println(\"Yes\")\n println(a.joinToString(separator = \" \"))\n }else{\n println(\"No\")\n }\n\n}", "problem_context": "Score : 800 points\n\nProblem Statement\n\nYou are given an integer sequence x of length N.\nDetermine if there exists an integer sequence a that satisfies all of the following conditions, and if it exists, construct an instance of a.\n\na is N^2 in length, containing N copies of each of the integers 1, 2, ..., N.\n\nFor each 1 ≤ i ≤ N, the i-th occurrence of the integer i from the left in a is the x_i-th element of a from the left.\n\nConstraints\n\n1 ≤ N ≤ 500\n\n1 ≤ x_i ≤ N^2\n\nAll x_i are distinct.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\nx_1 x_2 ... x_N\n\nOutput\n\nIf there does not exist an integer sequence a that satisfies all the conditions, print No.\nIf there does exist such an sequence a, print Yes in the first line, then print an instance of a in the second line, with spaces inbetween.\n\nSample Input 1\n\n3\n1 5 9\n\nSample Output 1\n\nYes\n1 1 1 2 2 2 3 3 3\n\nFor example, the second occurrence of the integer 2 from the left in a in the output is the fifth element of a from the left.\nSimilarly, the condition is satisfied for the integers 1 and 3.\n\nSample Input 2\n\n2\n4 1\n\nSample Output 2\n\nNo", "sample_input": "3\n1 5 9\n"}, "reference_outputs": ["Yes\n1 1 1 2 2 2 3 3 3\n"], "source_document_id": "p03841", "source_text": "Score : 800 points\n\nProblem Statement\n\nYou are given an integer sequence x of length N.\nDetermine if there exists an integer sequence a that satisfies all of the following conditions, and if it exists, construct an instance of a.\n\na is N^2 in length, containing N copies of each of the integers 1, 2, ..., N.\n\nFor each 1 ≤ i ≤ N, the i-th occurrence of the integer i from the left in a is the x_i-th element of a from the left.\n\nConstraints\n\n1 ≤ N ≤ 500\n\n1 ≤ x_i ≤ N^2\n\nAll x_i are distinct.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\nx_1 x_2 ... x_N\n\nOutput\n\nIf there does not exist an integer sequence a that satisfies all the conditions, print No.\nIf there does exist such an sequence a, print Yes in the first line, then print an instance of a in the second line, with spaces inbetween.\n\nSample Input 1\n\n3\n1 5 9\n\nSample Output 1\n\nYes\n1 1 1 2 2 2 3 3 3\n\nFor example, the second occurrence of the integer 2 from the left in a in the output is the fifth element of a from the left.\nSimilarly, the condition is satisfied for the integers 1 and 3.\n\nSample Input 2\n\n2\n4 1\n\nSample Output 2\n\nNo", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1310, "cpu_time_ms": 303, "memory_kb": 60160}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s450608362", "group_id": "codeNet:p03844", "input_text": "fun main(arr:Array) {\n val inpt = readLine()!!.split(\" \")\n var ans = 0\n if(inpt[1] == \"+\") {\n ans = inpt[0].toInt() + inpt[2].toInt()\n } else {\n ans = inpt[0].toInt() - inpt[2].toInt()\n\n }\n println(ans)\n}", "language": "Kotlin", "metadata": {"date": 1583595756, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03844.html", "problem_id": "p03844", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03844/input.txt", "sample_output_relpath": "derived/input_output/data/p03844/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03844/Kotlin/s450608362.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s450608362", "user_id": "u269969976"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "fun main(arr:Array) {\n val inpt = readLine()!!.split(\" \")\n var ans = 0\n if(inpt[1] == \"+\") {\n ans = inpt[0].toInt() + inpt[2].toInt()\n } else {\n ans = inpt[0].toInt() - inpt[2].toInt()\n\n }\n println(ans)\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nJoisino wants to evaluate the formula \"A op B\".\nHere, A and B are integers, and the binary operator op is either + or -.\nYour task is to evaluate the formula instead of her.\n\nConstraints\n\n1≦A,B≦10^9\n\nop is either + or -.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nA op B\n\nOutput\n\nEvaluate the formula and print the result.\n\nSample Input 1\n\n1 + 2\n\nSample Output 1\n\n3\n\nSince 1 + 2 = 3, the output should be 3.\n\nSample Input 2\n\n5 - 7\n\nSample Output 2\n\n-2", "sample_input": "1 + 2\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03844", "source_text": "Score : 100 points\n\nProblem Statement\n\nJoisino wants to evaluate the formula \"A op B\".\nHere, A and B are integers, and the binary operator op is either + or -.\nYour task is to evaluate the formula instead of her.\n\nConstraints\n\n1≦A,B≦10^9\n\nop is either + or -.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nA op B\n\nOutput\n\nEvaluate the formula and print the result.\n\nSample Input 1\n\n1 + 2\n\nSample Output 1\n\n3\n\nSince 1 + 2 = 3, the output should be 3.\n\nSample Input 2\n\n5 - 7\n\nSample Output 2\n\n-2", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 245, "memory_kb": 36016}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s960649304", "group_id": "codeNet:p03845", "input_text": "import java.io.PrintWriter\nimport java.util.*\nimport java.math.*\nimport java.lang.*\nimport kotlin.comparisons.*\n\nval pw = PrintWriter(System.out)\nval MOD: Long = (1e+9 + 7).toLong()\n\nfun main(args: Array) {\n val n = readInt()\n val times = readListOfInt()\n val m = readInt()\n val drinks = (0 until m).map {\n val (p, x) =readListOfInt()\n Pair(p, x)\n }\n val totalTime = times.sum()\n drinks.forEach {\n val time = totalTime - times[it.first-1] + it.second\n println(time)\n }\n\n pw.flush()\n}\n\n/****** Declared Functions and Data Structures ******/\n// IO\nfun read() = readLine()!!\nfun readInt() = read().toInt()\nfun readLong() = read().toLong()\nfun readDouble() = read().toDouble()\nfun readListOfString() = read().split(\" \")\nfun readListOfInt() = readListOfString().map { it.toInt() }\nfun readListOfLong() = readListOfString().map { it.toLong() }\nfun readListOfDouble() = readListOfString().map { it.toDouble() }\n\nfun Double.format(digits: Int) = String.format(\"%.${digits}f\", this)\nfun Float.format(digits: Int) = String.format(\"%.${digits}f\", this)\n\nfun print(value: Any) { pw.print(value) }\nfun println(value : Any) { pw.println(value) }\n\n// Extensions\nfun List.toBuckets(): Map\n = this.groupBy { it }.mapValues { it.value.size }\n\nfun> List.upperBound(element: T, fromIndex: Int=0, toIndex: Int=this.size): Int {\n var l = fromIndex\n var r = toIndex\n while(l < r) {\n val mid = (l+r) / 2\n if(element >= this[mid]) { \n l = mid + 1\n } else {\n r = mid\n }\n }\n return l\n}\n\nfun> List.lowerBound(element: T, fromIndex: Int=0, toIndex: Int=this.size): Int {\n var l = fromIndex\n var r = toIndex\n while(l < r) {\n val mid = (l+r) / 2\n if(element <= this[mid]) { \n r = mid\n } else {\n l = mid + 1\n }\n }\n return r \n}\n\nfun Map.toMutableMap(): MutableMap = HashMap(this)\n\n// Util Functions\nfun Long.makeDivisors(): List {\n val divisors = mutableListOf()\n for(i in 1L .. Math.sqrt(this.toDouble()).toLong()+1L) {\n if(this % i == 0L) {\n divisors.add(i)\n if(i != this/i) {\n divisors.add(this/i)\n }\n }\n }\n return divisors.distinct().sorted()\n}\n\nfun Long.isPrime(): Boolean {\n if(this==1L) return false\n for(i in 2L .. Math.sqrt(this.toDouble()).toLong() + 1L) {\n if(this % i == 0L && this != i) {\n return false\n }\n }\n return true\n}\n\n\nfun permutations(src: List): List> {\n if(src.size == 1) return listOf(src)\n val perms = mutableListOf>()\n val insertElement = src[0]\n permutations(src.drop(1)).forEach { perm ->\n for(i in 0..perm.size) {\n val newPerm = perm.toMutableList()\n newPerm.add(i, insertElement)\n perms.add(newPerm.toList())\n }\n }\n return perms\n}\n\n// return nCr, if you want nCr, please access v[n][r]\nfun combinations(n: Long): List> {\n val v = (0..n).map { (0..n).map{0L}.toMutableList() }.toMutableList()\n for(i in 0 until v.size) {\n v[i][0] = 1L\n v[i][i] = 1L\n }\n for(i in 0 until v.size) {\n for(j in 1 until i) {\n v[i][j] = (v[i-1][j-1] + v[i-1][j]) % MOD\n }\n }\n return v.map { it.toList() }.toList()\n}\n\n// should be a >= b\nfun gcd(a: Long, b: Long): Long = \n if(b == 0L) a else gcd(b, a % b)\n\n// shoud be a >= b\nfun lcm(a: Long, b: Long): Long = \n a / gcd(a, b) * b\n\nfun sumDigits(num_: Long): Long {\n var num = num_\n var rtn: Long = 0\n while(num != 0.toLong()) {\n val tmp = num % 10\n rtn += tmp\n num /= 10\n }\n return rtn\n}\n\nfun Double.isDecimal(): Boolean = ((this - Math.floor(this)) != 0.0)\n\n// Data Structures\nclass Stack(private var st: MutableList = mutableListOf()) {\n fun isEmpty() = st.isEmpty()\n fun top(): T = st.last()\n fun push(e: T) { st.add(e) }\n fun pop() { st = st.dropLast(1).toMutableList() }\n}\n\nclass Queue(private var que: MutableList = mutableListOf()) {\n fun isEmpty() = que.isEmpty()\n fun top(): T = que.first()\n fun push(e: T) { que.add(e) }\n fun pop() { que = que.drop(1).toMutableList() }\n}\n", "language": "Kotlin", "metadata": {"date": 1572579103, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03845.html", "problem_id": "p03845", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03845/input.txt", "sample_output_relpath": "derived/input_output/data/p03845/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03845/Kotlin/s960649304.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s960649304", "user_id": "u026686258"}, "prompt_components": {"gold_output": "6\n9\n", "input_to_evaluate": "import java.io.PrintWriter\nimport java.util.*\nimport java.math.*\nimport java.lang.*\nimport kotlin.comparisons.*\n\nval pw = PrintWriter(System.out)\nval MOD: Long = (1e+9 + 7).toLong()\n\nfun main(args: Array) {\n val n = readInt()\n val times = readListOfInt()\n val m = readInt()\n val drinks = (0 until m).map {\n val (p, x) =readListOfInt()\n Pair(p, x)\n }\n val totalTime = times.sum()\n drinks.forEach {\n val time = totalTime - times[it.first-1] + it.second\n println(time)\n }\n\n pw.flush()\n}\n\n/****** Declared Functions and Data Structures ******/\n// IO\nfun read() = readLine()!!\nfun readInt() = read().toInt()\nfun readLong() = read().toLong()\nfun readDouble() = read().toDouble()\nfun readListOfString() = read().split(\" \")\nfun readListOfInt() = readListOfString().map { it.toInt() }\nfun readListOfLong() = readListOfString().map { it.toLong() }\nfun readListOfDouble() = readListOfString().map { it.toDouble() }\n\nfun Double.format(digits: Int) = String.format(\"%.${digits}f\", this)\nfun Float.format(digits: Int) = String.format(\"%.${digits}f\", this)\n\nfun print(value: Any) { pw.print(value) }\nfun println(value : Any) { pw.println(value) }\n\n// Extensions\nfun List.toBuckets(): Map\n = this.groupBy { it }.mapValues { it.value.size }\n\nfun> List.upperBound(element: T, fromIndex: Int=0, toIndex: Int=this.size): Int {\n var l = fromIndex\n var r = toIndex\n while(l < r) {\n val mid = (l+r) / 2\n if(element >= this[mid]) { \n l = mid + 1\n } else {\n r = mid\n }\n }\n return l\n}\n\nfun> List.lowerBound(element: T, fromIndex: Int=0, toIndex: Int=this.size): Int {\n var l = fromIndex\n var r = toIndex\n while(l < r) {\n val mid = (l+r) / 2\n if(element <= this[mid]) { \n r = mid\n } else {\n l = mid + 1\n }\n }\n return r \n}\n\nfun Map.toMutableMap(): MutableMap = HashMap(this)\n\n// Util Functions\nfun Long.makeDivisors(): List {\n val divisors = mutableListOf()\n for(i in 1L .. Math.sqrt(this.toDouble()).toLong()+1L) {\n if(this % i == 0L) {\n divisors.add(i)\n if(i != this/i) {\n divisors.add(this/i)\n }\n }\n }\n return divisors.distinct().sorted()\n}\n\nfun Long.isPrime(): Boolean {\n if(this==1L) return false\n for(i in 2L .. Math.sqrt(this.toDouble()).toLong() + 1L) {\n if(this % i == 0L && this != i) {\n return false\n }\n }\n return true\n}\n\n\nfun permutations(src: List): List> {\n if(src.size == 1) return listOf(src)\n val perms = mutableListOf>()\n val insertElement = src[0]\n permutations(src.drop(1)).forEach { perm ->\n for(i in 0..perm.size) {\n val newPerm = perm.toMutableList()\n newPerm.add(i, insertElement)\n perms.add(newPerm.toList())\n }\n }\n return perms\n}\n\n// return nCr, if you want nCr, please access v[n][r]\nfun combinations(n: Long): List> {\n val v = (0..n).map { (0..n).map{0L}.toMutableList() }.toMutableList()\n for(i in 0 until v.size) {\n v[i][0] = 1L\n v[i][i] = 1L\n }\n for(i in 0 until v.size) {\n for(j in 1 until i) {\n v[i][j] = (v[i-1][j-1] + v[i-1][j]) % MOD\n }\n }\n return v.map { it.toList() }.toList()\n}\n\n// should be a >= b\nfun gcd(a: Long, b: Long): Long = \n if(b == 0L) a else gcd(b, a % b)\n\n// shoud be a >= b\nfun lcm(a: Long, b: Long): Long = \n a / gcd(a, b) * b\n\nfun sumDigits(num_: Long): Long {\n var num = num_\n var rtn: Long = 0\n while(num != 0.toLong()) {\n val tmp = num % 10\n rtn += tmp\n num /= 10\n }\n return rtn\n}\n\nfun Double.isDecimal(): Boolean = ((this - Math.floor(this)) != 0.0)\n\n// Data Structures\nclass Stack(private var st: MutableList = mutableListOf()) {\n fun isEmpty() = st.isEmpty()\n fun top(): T = st.last()\n fun push(e: T) { st.add(e) }\n fun pop() { st = st.dropLast(1).toMutableList() }\n}\n\nclass Queue(private var que: MutableList = mutableListOf()) {\n fun isEmpty() = que.isEmpty()\n fun top(): T = que.first()\n fun push(e: T) { que.add(e) }\n fun pop() { que = que.drop(1).toMutableList() }\n}\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nJoisino is about to compete in the final round of a certain programming competition.\nIn this contest, there are N problems, numbered 1 through N.\nJoisino knows that it takes her T_i seconds to solve problem i(1≦i≦N).\n\nAlso, there are M kinds of drinks offered to the contestants, numbered 1 through M.\nIf Joisino takes drink i(1≦i≦M), her brain will be stimulated and the time it takes for her to solve problem P_i will become X_i seconds.\nIt does not affect the time to solve the other problems.\n\nA contestant is allowed to take exactly one of the drinks before the start of the contest.\nFor each drink, Joisino wants to know how many seconds it takes her to solve all the problems if she takes that drink.\nHere, assume that the time it takes her to solve all the problems is equal to the sum of the time it takes for her to solve individual problems.\nYour task is to write a program to calculate it instead of her.\n\nConstraints\n\nAll input values are integers.\n\n1≦N≦100\n\n1≦T_i≦10^5\n\n1≦M≦100\n\n1≦P_i≦N\n\n1≦X_i≦10^5\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\nT_1 T_2 ... T_N\nM\nP_1 X_1\nP_2 X_2\n:\nP_M X_M\n\nOutput\n\nFor each drink, calculate how many seconds it takes Joisino to solve all the problems if she takes that drink, and print the results, one per line.\n\nSample Input 1\n\n3\n2 1 4\n2\n1 1\n2 3\n\nSample Output 1\n\n6\n9\n\nIf Joisino takes drink 1, the time it takes her to solve each problem will be 1, 1 and 4 seconds, respectively, totaling 6 seconds.\n\nIf Joisino takes drink 2, the time it takes her to solve each problem will be 2, 3 and 4 seconds, respectively, totaling 9 seconds.\n\nSample Input 2\n\n5\n7 2 3 8 5\n3\n4 2\n1 7\n4 13\n\nSample Output 2\n\n19\n25\n30", "sample_input": "3\n2 1 4\n2\n1 1\n2 3\n"}, "reference_outputs": ["6\n9\n"], "source_document_id": "p03845", "source_text": "Score : 200 points\n\nProblem Statement\n\nJoisino is about to compete in the final round of a certain programming competition.\nIn this contest, there are N problems, numbered 1 through N.\nJoisino knows that it takes her T_i seconds to solve problem i(1≦i≦N).\n\nAlso, there are M kinds of drinks offered to the contestants, numbered 1 through M.\nIf Joisino takes drink i(1≦i≦M), her brain will be stimulated and the time it takes for her to solve problem P_i will become X_i seconds.\nIt does not affect the time to solve the other problems.\n\nA contestant is allowed to take exactly one of the drinks before the start of the contest.\nFor each drink, Joisino wants to know how many seconds it takes her to solve all the problems if she takes that drink.\nHere, assume that the time it takes her to solve all the problems is equal to the sum of the time it takes for her to solve individual problems.\nYour task is to write a program to calculate it instead of her.\n\nConstraints\n\nAll input values are integers.\n\n1≦N≦100\n\n1≦T_i≦10^5\n\n1≦M≦100\n\n1≦P_i≦N\n\n1≦X_i≦10^5\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\nT_1 T_2 ... T_N\nM\nP_1 X_1\nP_2 X_2\n:\nP_M X_M\n\nOutput\n\nFor each drink, calculate how many seconds it takes Joisino to solve all the problems if she takes that drink, and print the results, one per line.\n\nSample Input 1\n\n3\n2 1 4\n2\n1 1\n2 3\n\nSample Output 1\n\n6\n9\n\nIf Joisino takes drink 1, the time it takes her to solve each problem will be 1, 1 and 4 seconds, respectively, totaling 6 seconds.\n\nIf Joisino takes drink 2, the time it takes her to solve each problem will be 2, 3 and 4 seconds, respectively, totaling 9 seconds.\n\nSample Input 2\n\n5\n7 2 3 8 5\n3\n4 2\n1 7\n4 13\n\nSample Output 2\n\n19\n25\n30", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 4336, "cpu_time_ms": 243, "memory_kb": 36240}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s658272515", "group_id": "codeNet:p03846", "input_text": "import java.io.PrintWriter\nimport java.util.*\n\nfun next() = readLine()!!\nfun nextInt() = next().toInt()\nfun nextLong() = next().toLong()\nfun nextDouble() = next().toDouble()\nfun nextList() = next().split(\" \")\nfun nextIntList() = nextList().map(String::toInt)\nfun nextLongList() = nextList().map(String::toLong)\nfun nextDoubleList() = nextList().map(String::toDouble)\n\nval pw = PrintWriter(System.out)\nfun print(s: Any = \"\") = pw.print(s)\nfun println(s: Any = \"\") = pw.println(s)\n\nfun Iterable.join(separator: CharSequence = \", \", prefix: CharSequence = \"\", postfix: CharSequence = \"\") = joinToString(separator, prefix, postfix)\nfun Array.join(separator: CharSequence = \", \", prefix: CharSequence = \"\", postfix: CharSequence = \"\") = joinToString(separator, prefix, postfix)\n\nfun main(args: Array) {\n main()\n pw.flush()\n}\n\nfun main() {\n val N = nextInt()\n val A = nextIntList().groupBy { it }.mapValues { it.value.size }\n val B = ((N + 1) % 2 until N step 2).associate { Pair(it, if (it == 0) 1 else 2) }\n if (A == B) {\n println(A.values.fold(1L) { a, b -> (a * b) % 1000000007L })\n } else {\n println(0)\n }\n}", "language": "Kotlin", "metadata": {"date": 1591551800, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03846.html", "problem_id": "p03846", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03846/input.txt", "sample_output_relpath": "derived/input_output/data/p03846/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03846/Kotlin/s658272515.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s658272515", "user_id": "u860789370"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "import java.io.PrintWriter\nimport java.util.*\n\nfun next() = readLine()!!\nfun nextInt() = next().toInt()\nfun nextLong() = next().toLong()\nfun nextDouble() = next().toDouble()\nfun nextList() = next().split(\" \")\nfun nextIntList() = nextList().map(String::toInt)\nfun nextLongList() = nextList().map(String::toLong)\nfun nextDoubleList() = nextList().map(String::toDouble)\n\nval pw = PrintWriter(System.out)\nfun print(s: Any = \"\") = pw.print(s)\nfun println(s: Any = \"\") = pw.println(s)\n\nfun Iterable.join(separator: CharSequence = \", \", prefix: CharSequence = \"\", postfix: CharSequence = \"\") = joinToString(separator, prefix, postfix)\nfun Array.join(separator: CharSequence = \", \", prefix: CharSequence = \"\", postfix: CharSequence = \"\") = joinToString(separator, prefix, postfix)\n\nfun main(args: Array) {\n main()\n pw.flush()\n}\n\nfun main() {\n val N = nextInt()\n val A = nextIntList().groupBy { it }.mapValues { it.value.size }\n val B = ((N + 1) % 2 until N step 2).associate { Pair(it, if (it == 0) 1 else 2) }\n if (A == B) {\n println(A.values.fold(1L) { a, b -> (a * b) % 1000000007L })\n } else {\n println(0)\n }\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere are N people, conveniently numbered 1 through N.\nThey were standing in a row yesterday, but now they are unsure of the order in which they were standing.\nHowever, each person remembered the following fact: the absolute difference of the number of the people who were standing to the left of that person, and the number of the people who were standing to the right of that person.\nAccording to their reports, the difference above for person i is A_i.\n\nBased on these reports, find the number of the possible orders in which they were standing.\nSince it can be extremely large, print the answer modulo 10^9+7.\nNote that the reports may be incorrect and thus there may be no consistent order.\nIn such a case, print 0.\n\nConstraints\n\n1≦N≦10^5\n\n0≦A_i≦N-1\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 number of the possible orders in which they were standing, modulo 10^9+7.\n\nSample Input 1\n\n5\n2 4 4 0 2\n\nSample Output 1\n\n4\n\nThere are four possible orders, as follows:\n\n2,1,4,5,3\n\n2,5,4,1,3\n\n3,1,4,5,2\n\n3,5,4,1,2\n\nSample Input 2\n\n7\n6 4 0 2 4 0 2\n\nSample Output 2\n\n0\n\nAny order would be inconsistent with the reports, thus the answer is 0.\n\nSample Input 3\n\n8\n7 5 1 1 7 3 5 3\n\nSample Output 3\n\n16", "sample_input": "5\n2 4 4 0 2\n"}, "reference_outputs": ["4\n"], "source_document_id": "p03846", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere are N people, conveniently numbered 1 through N.\nThey were standing in a row yesterday, but now they are unsure of the order in which they were standing.\nHowever, each person remembered the following fact: the absolute difference of the number of the people who were standing to the left of that person, and the number of the people who were standing to the right of that person.\nAccording to their reports, the difference above for person i is A_i.\n\nBased on these reports, find the number of the possible orders in which they were standing.\nSince it can be extremely large, print the answer modulo 10^9+7.\nNote that the reports may be incorrect and thus there may be no consistent order.\nIn such a case, print 0.\n\nConstraints\n\n1≦N≦10^5\n\n0≦A_i≦N-1\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 number of the possible orders in which they were standing, modulo 10^9+7.\n\nSample Input 1\n\n5\n2 4 4 0 2\n\nSample Output 1\n\n4\n\nThere are four possible orders, as follows:\n\n2,1,4,5,3\n\n2,5,4,1,3\n\n3,1,4,5,2\n\n3,5,4,1,2\n\nSample Input 2\n\n7\n6 4 0 2 4 0 2\n\nSample Output 2\n\n0\n\nAny order would be inconsistent with the reports, thus the answer is 0.\n\nSample Input 3\n\n8\n7 5 1 1 7 3 5 3\n\nSample Output 3\n\n16", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1166, "cpu_time_ms": 658, "memory_kb": 61892}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s545050831", "group_id": "codeNet:p03846", "input_text": "import java.io.PrintWriter\nimport java.util.*\nimport java.math.*\nimport java.lang.*\n\nval pw = PrintWriter(System.out)\nval MOD: Long = (1e+9 + 7).toLong()\n\nfun solve(n: Int, a: List): Long {\n var isAble = true\n var pad = 0\n if(n % 2 == 1) {\n if(a[0] != 0) return 0L\n pad = 1\n } \n var ans = 1L\n for(i in 0 until n/2) {\n //println(\"i: $i\")\n val a1 = a[i*2 + pad]\n val a2 = a[i*2 + pad+1]\n val cNum = (i+1) * 2 - if(pad == 1) 0 else 1\n //println(\"$a1, $a2, $cNum\")\n if((a1 == cNum && a2 == cNum).not()) {\n isAble = false\n break\n }\n ans = (ans * 2L) % MOD\n }\n return if(isAble) ans else 0L\n}\n\nfun main(args: Array) {\n val n = readInt() \n val a = readListOfInt().sorted()\n\n //println(a)\n val ans = solve(n, a)\n println(ans)\n pw.flush()\n}\n\n/****** Declared Functions and Data Structures ******/\n// IO\nfun read() = readLine()!!\nfun readInt() = read().toInt()\nfun readLong() = read().toLong()\nfun readDouble() = read().toDouble()\nfun readListOfString() = read().split(\" \")\nfun readListOfInt() = readListOfString().map { it.toInt() }\nfun readListOfLong() = readListOfString().map { it.toLong() }\nfun readListOfDouble() = readListOfString().map { it.toDouble() }\n\nfun Double.format(digits: Int) = String.format(\"%.${digits}f\", this)\nfun Float.format(digits: Int) = String.format(\"%.${digits}f\", this)\n\nfun print(value: Any) { pw.print(value) }\nfun println(value : Any) { pw.println(value) }\n\nfun permutations(src: List): List> {\n if(src.size == 1) return listOf(src)\n val perms = mutableListOf>()\n val insertElement = src[0]\n permutations(src.drop(1)).forEach { perm ->\n for(i in 0..perm.size) {\n val newPerm = perm.toMutableList()\n newPerm.add(i, insertElement)\n perms.add(newPerm.toList())\n }\n }\n return perms\n}\n\n// return nCr, if you want nCr, please access v[n][r]\nfun combinations(n: Long): List> {\n val v = (0..n).map { (0..n).map{0L}.toMutableList() }.toMutableList()\n for(i in 0 until v.size) {\n v[i][0] = 1L\n v[i][i] = 1L\n }\n for(i in 0 until v.size) {\n for(j in 1 until i) {\n v[i][j] = (v[i-1][j-1] + v[i-1][j] % MOD)\n }\n }\n return v.map { it.toList() }.toList()\n}\n\n// should be a >= b\nfun gcd(a: Long, b: Long): Long = \n if(b == 0L) a else gcd(b, a % b)\n\n// shoud be a >= b\nfun lcm(a: Long, b: Long): Long = \n a / gcd(a, b) * b\n\nfun sumDigits(num_: Long): Long {\n var num = num_\n var rtn: Long = 0\n while(num != 0.toLong()) {\n val tmp = num % 10\n rtn += tmp\n num /= 10\n }\n return rtn\n}\n\nfun isDecimal(v: Double): Boolean = ((v - Math.floor(v)) != 0.0)\n\n// Data Structures\nclass Stack(private var st: MutableList = mutableListOf()) {\n fun isEmpty() = st.isEmpty()\n fun top(): T = st.last()\n fun push(e: T) { st.add(e) }\n fun pop() { st = st.dropLast(1).toMutableList() }\n}\n\nclass Queue(private var que: MutableList = mutableListOf()) {\n fun isEmpty() = que.isEmpty()\n fun top(): T = que.first()\n fun push(e: T) { que.add(e) }\n fun pop() { que = que.drop(1).toMutableList() }\n}\n", "language": "Kotlin", "metadata": {"date": 1564805061, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03846.html", "problem_id": "p03846", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03846/input.txt", "sample_output_relpath": "derived/input_output/data/p03846/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03846/Kotlin/s545050831.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s545050831", "user_id": "u026686258"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "import java.io.PrintWriter\nimport java.util.*\nimport java.math.*\nimport java.lang.*\n\nval pw = PrintWriter(System.out)\nval MOD: Long = (1e+9 + 7).toLong()\n\nfun solve(n: Int, a: List): Long {\n var isAble = true\n var pad = 0\n if(n % 2 == 1) {\n if(a[0] != 0) return 0L\n pad = 1\n } \n var ans = 1L\n for(i in 0 until n/2) {\n //println(\"i: $i\")\n val a1 = a[i*2 + pad]\n val a2 = a[i*2 + pad+1]\n val cNum = (i+1) * 2 - if(pad == 1) 0 else 1\n //println(\"$a1, $a2, $cNum\")\n if((a1 == cNum && a2 == cNum).not()) {\n isAble = false\n break\n }\n ans = (ans * 2L) % MOD\n }\n return if(isAble) ans else 0L\n}\n\nfun main(args: Array) {\n val n = readInt() \n val a = readListOfInt().sorted()\n\n //println(a)\n val ans = solve(n, a)\n println(ans)\n pw.flush()\n}\n\n/****** Declared Functions and Data Structures ******/\n// IO\nfun read() = readLine()!!\nfun readInt() = read().toInt()\nfun readLong() = read().toLong()\nfun readDouble() = read().toDouble()\nfun readListOfString() = read().split(\" \")\nfun readListOfInt() = readListOfString().map { it.toInt() }\nfun readListOfLong() = readListOfString().map { it.toLong() }\nfun readListOfDouble() = readListOfString().map { it.toDouble() }\n\nfun Double.format(digits: Int) = String.format(\"%.${digits}f\", this)\nfun Float.format(digits: Int) = String.format(\"%.${digits}f\", this)\n\nfun print(value: Any) { pw.print(value) }\nfun println(value : Any) { pw.println(value) }\n\nfun permutations(src: List): List> {\n if(src.size == 1) return listOf(src)\n val perms = mutableListOf>()\n val insertElement = src[0]\n permutations(src.drop(1)).forEach { perm ->\n for(i in 0..perm.size) {\n val newPerm = perm.toMutableList()\n newPerm.add(i, insertElement)\n perms.add(newPerm.toList())\n }\n }\n return perms\n}\n\n// return nCr, if you want nCr, please access v[n][r]\nfun combinations(n: Long): List> {\n val v = (0..n).map { (0..n).map{0L}.toMutableList() }.toMutableList()\n for(i in 0 until v.size) {\n v[i][0] = 1L\n v[i][i] = 1L\n }\n for(i in 0 until v.size) {\n for(j in 1 until i) {\n v[i][j] = (v[i-1][j-1] + v[i-1][j] % MOD)\n }\n }\n return v.map { it.toList() }.toList()\n}\n\n// should be a >= b\nfun gcd(a: Long, b: Long): Long = \n if(b == 0L) a else gcd(b, a % b)\n\n// shoud be a >= b\nfun lcm(a: Long, b: Long): Long = \n a / gcd(a, b) * b\n\nfun sumDigits(num_: Long): Long {\n var num = num_\n var rtn: Long = 0\n while(num != 0.toLong()) {\n val tmp = num % 10\n rtn += tmp\n num /= 10\n }\n return rtn\n}\n\nfun isDecimal(v: Double): Boolean = ((v - Math.floor(v)) != 0.0)\n\n// Data Structures\nclass Stack(private var st: MutableList = mutableListOf()) {\n fun isEmpty() = st.isEmpty()\n fun top(): T = st.last()\n fun push(e: T) { st.add(e) }\n fun pop() { st = st.dropLast(1).toMutableList() }\n}\n\nclass Queue(private var que: MutableList = mutableListOf()) {\n fun isEmpty() = que.isEmpty()\n fun top(): T = que.first()\n fun push(e: T) { que.add(e) }\n fun pop() { que = que.drop(1).toMutableList() }\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere are N people, conveniently numbered 1 through N.\nThey were standing in a row yesterday, but now they are unsure of the order in which they were standing.\nHowever, each person remembered the following fact: the absolute difference of the number of the people who were standing to the left of that person, and the number of the people who were standing to the right of that person.\nAccording to their reports, the difference above for person i is A_i.\n\nBased on these reports, find the number of the possible orders in which they were standing.\nSince it can be extremely large, print the answer modulo 10^9+7.\nNote that the reports may be incorrect and thus there may be no consistent order.\nIn such a case, print 0.\n\nConstraints\n\n1≦N≦10^5\n\n0≦A_i≦N-1\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 number of the possible orders in which they were standing, modulo 10^9+7.\n\nSample Input 1\n\n5\n2 4 4 0 2\n\nSample Output 1\n\n4\n\nThere are four possible orders, as follows:\n\n2,1,4,5,3\n\n2,5,4,1,3\n\n3,1,4,5,2\n\n3,5,4,1,2\n\nSample Input 2\n\n7\n6 4 0 2 4 0 2\n\nSample Output 2\n\n0\n\nAny order would be inconsistent with the reports, thus the answer is 0.\n\nSample Input 3\n\n8\n7 5 1 1 7 3 5 3\n\nSample Output 3\n\n16", "sample_input": "5\n2 4 4 0 2\n"}, "reference_outputs": ["4\n"], "source_document_id": "p03846", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere are N people, conveniently numbered 1 through N.\nThey were standing in a row yesterday, but now they are unsure of the order in which they were standing.\nHowever, each person remembered the following fact: the absolute difference of the number of the people who were standing to the left of that person, and the number of the people who were standing to the right of that person.\nAccording to their reports, the difference above for person i is A_i.\n\nBased on these reports, find the number of the possible orders in which they were standing.\nSince it can be extremely large, print the answer modulo 10^9+7.\nNote that the reports may be incorrect and thus there may be no consistent order.\nIn such a case, print 0.\n\nConstraints\n\n1≦N≦10^5\n\n0≦A_i≦N-1\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 number of the possible orders in which they were standing, modulo 10^9+7.\n\nSample Input 1\n\n5\n2 4 4 0 2\n\nSample Output 1\n\n4\n\nThere are four possible orders, as follows:\n\n2,1,4,5,3\n\n2,5,4,1,3\n\n3,1,4,5,2\n\n3,5,4,1,2\n\nSample Input 2\n\n7\n6 4 0 2 4 0 2\n\nSample Output 2\n\n0\n\nAny order would be inconsistent with the reports, thus the answer is 0.\n\nSample Input 3\n\n8\n7 5 1 1 7 3 5 3\n\nSample Output 3\n\n16", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 3265, "cpu_time_ms": 799, "memory_kb": 53908}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s225955648", "group_id": "codeNet:p03846", "input_text": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val n = sc.nextInt()\n val aList = mutableListOf()\n for (i in 0 until n) {\n aList.add(sc.nextInt())\n }\n\n var bList = mutableListOf()\n for (i in 1..n / 2) {\n bList.add(n - i * 2 + 1)\n }\n bList = (bList + bList.reversed()).toMutableList()\n if (n % 2 != 0) bList.add(bList.size / 2, 0)\n\n val answerList = mutableListOf()\n val aList2 = aList.toMutableList()\n bList.forEach {\n val indexOf = aList2.indexOf(it)\n if (indexOf != -1) {\n answerList.add(aList2[indexOf])\n aList2.removeAt(aList2.indexOf(it))\n }\n\n }\n if (bList != answerList) {\n println(0)\n return\n }\n\n println((1..(n / 2) + 1).reduce { acc, i -> acc * 2 })\n\n}\n", "language": "Kotlin", "metadata": {"date": 1563470085, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03846.html", "problem_id": "p03846", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03846/input.txt", "sample_output_relpath": "derived/input_output/data/p03846/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03846/Kotlin/s225955648.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s225955648", "user_id": "u073232808"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val n = sc.nextInt()\n val aList = mutableListOf()\n for (i in 0 until n) {\n aList.add(sc.nextInt())\n }\n\n var bList = mutableListOf()\n for (i in 1..n / 2) {\n bList.add(n - i * 2 + 1)\n }\n bList = (bList + bList.reversed()).toMutableList()\n if (n % 2 != 0) bList.add(bList.size / 2, 0)\n\n val answerList = mutableListOf()\n val aList2 = aList.toMutableList()\n bList.forEach {\n val indexOf = aList2.indexOf(it)\n if (indexOf != -1) {\n answerList.add(aList2[indexOf])\n aList2.removeAt(aList2.indexOf(it))\n }\n\n }\n if (bList != answerList) {\n println(0)\n return\n }\n\n println((1..(n / 2) + 1).reduce { acc, i -> acc * 2 })\n\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere are N people, conveniently numbered 1 through N.\nThey were standing in a row yesterday, but now they are unsure of the order in which they were standing.\nHowever, each person remembered the following fact: the absolute difference of the number of the people who were standing to the left of that person, and the number of the people who were standing to the right of that person.\nAccording to their reports, the difference above for person i is A_i.\n\nBased on these reports, find the number of the possible orders in which they were standing.\nSince it can be extremely large, print the answer modulo 10^9+7.\nNote that the reports may be incorrect and thus there may be no consistent order.\nIn such a case, print 0.\n\nConstraints\n\n1≦N≦10^5\n\n0≦A_i≦N-1\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 number of the possible orders in which they were standing, modulo 10^9+7.\n\nSample Input 1\n\n5\n2 4 4 0 2\n\nSample Output 1\n\n4\n\nThere are four possible orders, as follows:\n\n2,1,4,5,3\n\n2,5,4,1,3\n\n3,1,4,5,2\n\n3,5,4,1,2\n\nSample Input 2\n\n7\n6 4 0 2 4 0 2\n\nSample Output 2\n\n0\n\nAny order would be inconsistent with the reports, thus the answer is 0.\n\nSample Input 3\n\n8\n7 5 1 1 7 3 5 3\n\nSample Output 3\n\n16", "sample_input": "5\n2 4 4 0 2\n"}, "reference_outputs": ["4\n"], "source_document_id": "p03846", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere are N people, conveniently numbered 1 through N.\nThey were standing in a row yesterday, but now they are unsure of the order in which they were standing.\nHowever, each person remembered the following fact: the absolute difference of the number of the people who were standing to the left of that person, and the number of the people who were standing to the right of that person.\nAccording to their reports, the difference above for person i is A_i.\n\nBased on these reports, find the number of the possible orders in which they were standing.\nSince it can be extremely large, print the answer modulo 10^9+7.\nNote that the reports may be incorrect and thus there may be no consistent order.\nIn such a case, print 0.\n\nConstraints\n\n1≦N≦10^5\n\n0≦A_i≦N-1\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 number of the possible orders in which they were standing, modulo 10^9+7.\n\nSample Input 1\n\n5\n2 4 4 0 2\n\nSample Output 1\n\n4\n\nThere are four possible orders, as follows:\n\n2,1,4,5,3\n\n2,5,4,1,3\n\n3,1,4,5,2\n\n3,5,4,1,2\n\nSample Input 2\n\n7\n6 4 0 2 4 0 2\n\nSample Output 2\n\n0\n\nAny order would be inconsistent with the reports, thus the answer is 0.\n\nSample Input 3\n\n8\n7 5 1 1 7 3 5 3\n\nSample Output 3\n\n16", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 835, "cpu_time_ms": 2111, "memory_kb": 57956}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s554150446", "group_id": "codeNet:p03852", "input_text": "/**\n * Created by karayuu on 2018/10/06\n */\nfun main(args: Array) {\n val checkList = listOf('a', 'e', 'i', 'o', 'u')\n\n val c = readLine()!!.toCharArray().first()\n \n if (checkList.contains(c)) {\n println(\"vowel\")\n } else {\n println(\"consonant\")\n }\n}\n", "language": "Kotlin", "metadata": {"date": 1538931611, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03852.html", "problem_id": "p03852", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03852/input.txt", "sample_output_relpath": "derived/input_output/data/p03852/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03852/Kotlin/s554150446.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s554150446", "user_id": "u598902504"}, "prompt_components": {"gold_output": "vowel\n", "input_to_evaluate": "/**\n * Created by karayuu on 2018/10/06\n */\nfun main(args: Array) {\n val checkList = listOf('a', 'e', 'i', 'o', 'u')\n\n val c = readLine()!!.toCharArray().first()\n \n if (checkList.contains(c)) {\n println(\"vowel\")\n } else {\n println(\"consonant\")\n }\n}\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nGiven a lowercase English letter c, determine whether it is a vowel. Here, there are five vowels in the English alphabet: a, e, i, o and u.\n\nConstraints\n\nc is a lowercase English letter.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nc\n\nOutput\n\nIf c is a vowel, print vowel. Otherwise, print consonant.\n\nSample Input 1\n\na\n\nSample Output 1\n\nvowel\n\nSince a is a vowel, print vowel.\n\nSample Input 2\n\nz\n\nSample Output 2\n\nconsonant\n\nSample Input 3\n\ns\n\nSample Output 3\n\nconsonant", "sample_input": "a\n"}, "reference_outputs": ["vowel\n"], "source_document_id": "p03852", "source_text": "Score : 100 points\n\nProblem Statement\n\nGiven a lowercase English letter c, determine whether it is a vowel. Here, there are five vowels in the English alphabet: a, e, i, o and u.\n\nConstraints\n\nc is a lowercase English letter.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nc\n\nOutput\n\nIf c is a vowel, print vowel. Otherwise, print consonant.\n\nSample Input 1\n\na\n\nSample Output 1\n\nvowel\n\nSince a is a vowel, print vowel.\n\nSample Input 2\n\nz\n\nSample Output 2\n\nconsonant\n\nSample Input 3\n\ns\n\nSample Output 3\n\nconsonant", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 289, "cpu_time_ms": 222, "memory_kb": 34032}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s238595553", "group_id": "codeNet:p03855", "input_text": "import java.util.*\nimport kotlin.*\n\nimport java.io.InputStream\nimport java.lang.NumberFormatException\nimport java.lang.StringBuilder\n\n\nfun main(args: Array) {\n Program().solve()\n}\n\nclass Program {\n fun solve() {\n val sc = FastScanner()\n val n = sc.nextInt()\n val k = sc.nextInt()\n val l = sc.nextInt()\n\n val pq = Array(k) { sc.nextInt() - 1 to sc.nextInt() - 1 }\n val lr = Array(l) { sc.nextInt() - 1 to sc.nextInt() - 1 }\n\n // 道路でつながっているか\n val uf1 = UnionFind(n)\n pq.forEach {\n uf1.unite(it.first, it.second)\n }\n\n // 鉄道で繋がっているか\n val uf2 = UnionFind(n)\n lr.forEach {\n uf2.unite(it.first, it.second)\n }\n\n val map = mutableMapOf, Int>()\n\n for (i in 0 until n) {\n val p = uf1.find(i) to uf2.find(i)\n map[p] = (map[p] ?: 0) + 1\n }\n\n println((0 until n).map {\n val p = uf1.find(it) to uf2.find(it)\n map[p]\n }.joinToString(\" \"))\n }\n}\n\nclass UnionFind(private val v: Int) {\n // 頂点iの親 par[i] == iなら iは根\n private val par = Array(v) { it }\n // iを根とする部分木のサイズ\n private val size = Array(v) { 1 }\n\n // iが含まれる木の根\n fun find(i: Int): Int = if (par[i] == i) i else find(par[i])\n\n // xとyが同じグループに含まれるか?\n fun same(x: Int, y: Int) = find(x) == find(y)\n\n // iが含まれるグループのサイズ\n fun getSize(i: Int) = size[find(i)]\n\n // xとyを繋げる 元から同じグル���プならfalse\n fun unite(x: Int, y: Int): Boolean {\n val rootX = find(x)\n val rootY = find(y)\n\n if (rootX == rootY) return false\n\n // データ構造をマージする一般的なテク\n if (size[rootX] > size[rootY]) {\n par[rootY] = rootX\n size[rootX] += size[rootY]\n } else {\n par[rootX] = rootY\n size[rootY] += size[rootX]\n }\n\n return true\n }\n}\n\n\nclass FastScanner {\n companion object {\n val input: InputStream = System.`in`\n val buffer = ByteArray(1024) { 0 }\n fun isPrintableChar(c: Int): Boolean = c in 33..126\n }\n\n var ptr = 0\n var buflen = 0\n private fun hasNextByte(): Boolean {\n if (ptr < buflen) {\n return true\n } else {\n ptr = 0\n buflen = input.read(buffer)\n if (buflen <= 0) {\n return false\n }\n }\n return true\n }\n\n private fun readByte(): Int = if (hasNextByte()) buffer[ptr++].toInt() else -1\n\n private fun skipUnprintable() {\n while (hasNextByte() && !isPrintableChar(buffer[ptr].toInt())) ptr++\n }\n\n fun hasNext(): Boolean {\n skipUnprintable()\n return hasNextByte()\n }\n\n fun next(): String {\n if (!hasNext()) throw NoSuchElementException()\n val sb = StringBuilder()\n var b = readByte()\n while (isPrintableChar(b)) {\n sb.appendCodePoint(b)\n b = readByte()\n }\n return sb.toString()\n }\n\n fun nextInt(): Int {\n if (!hasNext()) throw NoSuchElementException()\n var n = 0\n var b = readByte()\n // '-' = 45\n val minus = b == 45\n if (minus) {\n b = readByte()\n }\n\n // '0' = 48 '9' = 57\n if (b !in 48..57) {\n throw NumberFormatException()\n }\n\n while (true) {\n if (b in 48..57) {\n n *= 10\n n += b - 48\n } else if (b == -1 || !isPrintableChar(b)) {\n return if (minus) -n else n\n } else {\n throw NumberFormatException()\n }\n b = readByte()\n }\n }\n\n fun nextLong(): Long {\n if (!hasNext()) throw NoSuchElementException()\n var n = 0L\n var b = readByte()\n // '-' = 45\n val minus = b == 45\n if (minus) {\n b = readByte()\n }\n\n // '0' = 48 '9' = 57\n if (b !in 48..57) {\n throw NumberFormatException()\n }\n\n while (true) {\n if (b in 48..57) {\n n *= 10\n n += b - 48\n } else if (b == -1 || !isPrintableChar(b)) {\n return if (minus) -n else n\n } else {\n throw NumberFormatException()\n }\n b = readByte()\n }\n }\n\n fun nextDouble(): Double = next().toDouble()\n}\n", "language": "Kotlin", "metadata": {"date": 1582382862, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03855.html", "problem_id": "p03855", "resource_group": "medium_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/Kotlin/s238595553.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s238595553", "user_id": "u194412908"}, "prompt_components": {"gold_output": "1 2 2 1\n", "input_to_evaluate": "import java.util.*\nimport kotlin.*\n\nimport java.io.InputStream\nimport java.lang.NumberFormatException\nimport java.lang.StringBuilder\n\n\nfun main(args: Array) {\n Program().solve()\n}\n\nclass Program {\n fun solve() {\n val sc = FastScanner()\n val n = sc.nextInt()\n val k = sc.nextInt()\n val l = sc.nextInt()\n\n val pq = Array(k) { sc.nextInt() - 1 to sc.nextInt() - 1 }\n val lr = Array(l) { sc.nextInt() - 1 to sc.nextInt() - 1 }\n\n // 道路でつながっているか\n val uf1 = UnionFind(n)\n pq.forEach {\n uf1.unite(it.first, it.second)\n }\n\n // 鉄道で繋がっているか\n val uf2 = UnionFind(n)\n lr.forEach {\n uf2.unite(it.first, it.second)\n }\n\n val map = mutableMapOf, Int>()\n\n for (i in 0 until n) {\n val p = uf1.find(i) to uf2.find(i)\n map[p] = (map[p] ?: 0) + 1\n }\n\n println((0 until n).map {\n val p = uf1.find(it) to uf2.find(it)\n map[p]\n }.joinToString(\" \"))\n }\n}\n\nclass UnionFind(private val v: Int) {\n // 頂点iの親 par[i] == iなら iは根\n private val par = Array(v) { it }\n // iを根とする部分木のサイズ\n private val size = Array(v) { 1 }\n\n // iが含まれる木の根\n fun find(i: Int): Int = if (par[i] == i) i else find(par[i])\n\n // xとyが同じグループに含まれるか?\n fun same(x: Int, y: Int) = find(x) == find(y)\n\n // iが含まれるグループのサイズ\n fun getSize(i: Int) = size[find(i)]\n\n // xとyを繋げる 元から同じグループならfalse\n fun unite(x: Int, y: Int): Boolean {\n val rootX = find(x)\n val rootY = find(y)\n\n if (rootX == rootY) return false\n\n // データ構造をマージする一般的なテク\n if (size[rootX] > size[rootY]) {\n par[rootY] = rootX\n size[rootX] += size[rootY]\n } else {\n par[rootX] = rootY\n size[rootY] += size[rootX]\n }\n\n return true\n }\n}\n\n\nclass FastScanner {\n companion object {\n val input: InputStream = System.`in`\n val buffer = ByteArray(1024) { 0 }\n fun isPrintableChar(c: Int): Boolean = c in 33..126\n }\n\n var ptr = 0\n var buflen = 0\n private fun hasNextByte(): Boolean {\n if (ptr < buflen) {\n return true\n } else {\n ptr = 0\n buflen = input.read(buffer)\n if (buflen <= 0) {\n return false\n }\n }\n return true\n }\n\n private fun readByte(): Int = if (hasNextByte()) buffer[ptr++].toInt() else -1\n\n private fun skipUnprintable() {\n while (hasNextByte() && !isPrintableChar(buffer[ptr].toInt())) ptr++\n }\n\n fun hasNext(): Boolean {\n skipUnprintable()\n return hasNextByte()\n }\n\n fun next(): String {\n if (!hasNext()) throw NoSuchElementException()\n val sb = StringBuilder()\n var b = readByte()\n while (isPrintableChar(b)) {\n sb.appendCodePoint(b)\n b = readByte()\n }\n return sb.toString()\n }\n\n fun nextInt(): Int {\n if (!hasNext()) throw NoSuchElementException()\n var n = 0\n var b = readByte()\n // '-' = 45\n val minus = b == 45\n if (minus) {\n b = readByte()\n }\n\n // '0' = 48 '9' = 57\n if (b !in 48..57) {\n throw NumberFormatException()\n }\n\n while (true) {\n if (b in 48..57) {\n n *= 10\n n += b - 48\n } else if (b == -1 || !isPrintableChar(b)) {\n return if (minus) -n else n\n } else {\n throw NumberFormatException()\n }\n b = readByte()\n }\n }\n\n fun nextLong(): Long {\n if (!hasNext()) throw NoSuchElementException()\n var n = 0L\n var b = readByte()\n // '-' = 45\n val minus = b == 45\n if (minus) {\n b = readByte()\n }\n\n // '0' = 48 '9' = 57\n if (b !in 48..57) {\n throw NumberFormatException()\n }\n\n while (true) {\n if (b in 48..57) {\n n *= 10\n n += b - 48\n } else if (b == -1 || !isPrintableChar(b)) {\n return if (minus) -n else n\n } else {\n throw NumberFormatException()\n }\n b = readByte()\n }\n }\n\n fun nextDouble(): Double = next().toDouble()\n}\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 4602, "cpu_time_ms": 1046, "memory_kb": 89600}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s589119235", "group_id": "codeNet:p03860", "input_text": "fun main(args: Array) {\n var s = readLine()!!.split(\" \").map{x->x.toString()}\n println(\"${s[0][0]}${s[1][0]}${s[2][0]}\")\n \n}\n", "language": "Kotlin", "metadata": {"date": 1549987048, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03860.html", "problem_id": "p03860", "resource_group": "medium_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/Kotlin/s589119235.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s589119235", "user_id": "u399261731"}, "prompt_components": {"gold_output": "ABC\n", "input_to_evaluate": "fun main(args: Array) {\n var s = readLine()!!.split(\" \").map{x->x.toString()}\n println(\"${s[0][0]}${s[1][0]}${s[2][0]}\")\n \n}\n", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 238, "memory_kb": 38000}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s758551283", "group_id": "codeNet:p03861", "input_text": "fun main(args: Array) = println(run {\n val (a,b,x) = readLine()!!.split(\" \").map { it.toLong() }\n\n if(a==0L) b/x\n else b/x - (a-1)/x\n\n})\n", "language": "Kotlin", "metadata": {"date": 1588741317, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03861.html", "problem_id": "p03861", "resource_group": "medium_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/Kotlin/s758551283.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s758551283", "user_id": "u563556491"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "fun main(args: Array) = println(run {\n val (a,b,x) = readLine()!!.split(\" \").map { it.toLong() }\n\n if(a==0L) b/x\n else b/x - (a-1)/x\n\n})\n", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 238, "memory_kb": 37864}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s966898470", "group_id": "codeNet:p03862", "input_text": "fun longList() = readLine()?.split(\" \")?.map(String::toLong) ?: TODO()\nfun main() {\n val (n, x) = longList()\n val a = longList()\n var p = 0L\n var e = 0L\n repeat(n.toInt()) { i ->\n val aa = a[i]\n if (aa + p > x) {\n val d = aa + p - x\n e += d\n p = aa - d\n } else {\n p = aa\n }\n }\n println(e.toString())\n}\n", "language": "Kotlin", "metadata": {"date": 1598417207, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p03862.html", "problem_id": "p03862", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03862/input.txt", "sample_output_relpath": "derived/input_output/data/p03862/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03862/Kotlin/s966898470.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s966898470", "user_id": "u979429407"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "fun longList() = readLine()?.split(\" \")?.map(String::toLong) ?: TODO()\nfun main() {\n val (n, x) = longList()\n val a = longList()\n var p = 0L\n var e = 0L\n repeat(n.toInt()) { i ->\n val aa = a[i]\n if (aa + p > x) {\n val d = aa + p - x\n e += d\n p = aa - d\n } else {\n p = aa\n }\n }\n println(e.toString())\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere are N boxes arranged in a row.\nInitially, the i-th box from the left contains a_i candies.\n\nSnuke can perform the following operation any number of times:\n\nChoose a box containing at least one candy, and eat one of the candies in the chosen box.\n\nHis objective is as follows:\n\nAny two neighboring boxes contain at most x candies in total.\n\nFind the minimum number of operations required to achieve the objective.\n\nConstraints\n\n2 ≤ N ≤ 10^5\n\n0 ≤ a_i ≤ 10^9\n\n0 ≤ x ≤ 10^9\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN x\na_1 a_2 ... a_N\n\nOutput\n\nPrint the minimum number of operations required to achieve the objective.\n\nSample Input 1\n\n3 3\n2 2 2\n\nSample Output 1\n\n1\n\nEat one candy in the second box.\nThen, the number of candies in each box becomes (2, 1, 2).\n\nSample Input 2\n\n6 1\n1 6 1 2 0 4\n\nSample Output 2\n\n11\n\nFor example, eat six candies in the second box, two in the fourth box, and three in the sixth box.\nThen, the number of candies in each box becomes (1, 0, 1, 0, 0, 1).\n\nSample Input 3\n\n5 9\n3 1 4 1 5\n\nSample Output 3\n\n0\n\nThe objective is already achieved without performing operations.\n\nSample Input 4\n\n2 0\n5 5\n\nSample Output 4\n\n10\n\nAll the candies need to be eaten.", "sample_input": "3 3\n2 2 2\n"}, "reference_outputs": ["1\n"], "source_document_id": "p03862", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere are N boxes arranged in a row.\nInitially, the i-th box from the left contains a_i candies.\n\nSnuke can perform the following operation any number of times:\n\nChoose a box containing at least one candy, and eat one of the candies in the chosen box.\n\nHis objective is as follows:\n\nAny two neighboring boxes contain at most x candies in total.\n\nFind the minimum number of operations required to achieve the objective.\n\nConstraints\n\n2 ≤ N ≤ 10^5\n\n0 ≤ a_i ≤ 10^9\n\n0 ≤ x ≤ 10^9\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN x\na_1 a_2 ... a_N\n\nOutput\n\nPrint the minimum number of operations required to achieve the objective.\n\nSample Input 1\n\n3 3\n2 2 2\n\nSample Output 1\n\n1\n\nEat one candy in the second box.\nThen, the number of candies in each box becomes (2, 1, 2).\n\nSample Input 2\n\n6 1\n1 6 1 2 0 4\n\nSample Output 2\n\n11\n\nFor example, eat six candies in the second box, two in the fourth box, and three in the sixth box.\nThen, the number of candies in each box becomes (1, 0, 1, 0, 0, 1).\n\nSample Input 3\n\n5 9\n3 1 4 1 5\n\nSample Output 3\n\n0\n\nThe objective is already achieved without performing operations.\n\nSample Input 4\n\n2 0\n5 5\n\nSample Output 4\n\n10\n\nAll the candies need to be eaten.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 395, "cpu_time_ms": 312, "memory_kb": 52996}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s669166372", "group_id": "codeNet:p03865", "input_text": "import java.util.*\n\nfun main(args: Array) {\n val s = readLine()!!\n val t = TreeSet(s.toList())\n\n if (t.size == 2) {\n println(\"Second\")\n return\n }\n\n if (s.first() == s.last()) {\n if (s.length % 2 != 0) {\n println(\"Second\")\n } else {\n println(\"First\")\n }\n } else {\n if (s.length % 2 == 0) {\n println(\"Second\")\n } else {\n println(\"First\")\n }\n }\n}\n", "language": "Kotlin", "metadata": {"date": 1577935510, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03865.html", "problem_id": "p03865", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03865/input.txt", "sample_output_relpath": "derived/input_output/data/p03865/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03865/Kotlin/s669166372.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s669166372", "user_id": "u183530284"}, "prompt_components": {"gold_output": "Second\n", "input_to_evaluate": "import java.util.*\n\nfun main(args: Array) {\n val s = readLine()!!\n val t = TreeSet(s.toList())\n\n if (t.size == 2) {\n println(\"Second\")\n return\n }\n\n if (s.first() == s.last()) {\n if (s.length % 2 != 0) {\n println(\"Second\")\n } else {\n println(\"First\")\n }\n } else {\n if (s.length % 2 == 0) {\n println(\"Second\")\n } else {\n println(\"First\")\n }\n }\n}\n", "problem_context": "Score : 500 points\n\nProblem Statement\n\nThere is a string s of length 3 or greater.\nNo two neighboring characters in s are equal.\n\nTakahashi and Aoki will play a game against each other.\nThe two players alternately performs the following operation, Takahashi going first:\n\nRemove one of the characters in s, excluding both ends. However, a character cannot be removed if removal of the character would result in two neighboring equal characters in s.\n\nThe player who becomes unable to perform the operation, loses the game. Determine which player will win when the two play optimally.\n\nConstraints\n\n3 ≤ |s| ≤ 10^5\n\ns consists of lowercase English letters.\n\nNo two neighboring characters in s are equal.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\ns\n\nOutput\n\nIf Takahashi will win, print First. If Aoki will win, print Second.\n\nSample Input 1\n\naba\n\nSample Output 1\n\nSecond\n\nTakahashi, who goes first, cannot perform the operation, since removal of the b, which is the only character not at either ends of s, would result in s becoming aa, with two as neighboring.\n\nSample Input 2\n\nabc\n\nSample Output 2\n\nFirst\n\nWhen Takahashi removes b from s, it becomes ac.\nThen, Aoki cannot perform the operation, since there is no character in s, excluding both ends.\n\nSample Input 3\n\nabcab\n\nSample Output 3\n\nFirst", "sample_input": "aba\n"}, "reference_outputs": ["Second\n"], "source_document_id": "p03865", "source_text": "Score : 500 points\n\nProblem Statement\n\nThere is a string s of length 3 or greater.\nNo two neighboring characters in s are equal.\n\nTakahashi and Aoki will play a game against each other.\nThe two players alternately performs the following operation, Takahashi going first:\n\nRemove one of the characters in s, excluding both ends. However, a character cannot be removed if removal of the character would result in two neighboring equal characters in s.\n\nThe player who becomes unable to perform the operation, loses the game. Determine which player will win when the two play optimally.\n\nConstraints\n\n3 ≤ |s| ≤ 10^5\n\ns consists of lowercase English letters.\n\nNo two neighboring characters in s are equal.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\ns\n\nOutput\n\nIf Takahashi will win, print First. If Aoki will win, print Second.\n\nSample Input 1\n\naba\n\nSample Output 1\n\nSecond\n\nTakahashi, who goes first, cannot perform the operation, since removal of the b, which is the only character not at either ends of s, would result in s becoming aa, with two as neighboring.\n\nSample Input 2\n\nabc\n\nSample Output 2\n\nFirst\n\nWhen Takahashi removes b from s, it becomes ac.\nThen, Aoki cannot perform the operation, since there is no character in s, excluding both ends.\n\nSample Input 3\n\nabcab\n\nSample Output 3\n\nFirst", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 473, "cpu_time_ms": 276, "memory_kb": 34656}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s786071957", "group_id": "codeNet:p03937", "input_text": "fun main(args: Array) {\n val (h, w) = readLine()!!.split(' ').map { it.toInt() }\n var a = Array(h) {\n readLine()!!\n }\n var i = 0\n var j = 0\n while (true) {\n if (i == h-1 && j == w-1) {\n println(\"Possible\")\n return\n }\n when {\n (a.getOrElse(i + 1) { \".\" }.getOrElse(j) { '.' } == '#' && a.getOrElse(i) { \".\" }.getOrElse(j + 1) { '.' } == '#') || (a.getOrElse(\n i + 1\n ) { \".\" }.getOrElse(j) { '.' } == '.' && a.getOrElse(i) { \".\" }.getOrElse(j + 1) { '.' } == '.') -> {\n println(\"Impossible\")\n return\n }\n a.getOrElse(i + 1, { \".\" }).getOrElse(j, { '.' }) == '#' -> i++\n a.getOrElse(i, { \".\" }).getOrElse(j + 1, { '.' }) == '#' -> j++\n else -> {\n println(\"Impossible\")\n return\n }\n }\n }\n}", "language": "Kotlin", "metadata": {"date": 1582921560, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03937.html", "problem_id": "p03937", "resource_group": "medium_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/Kotlin/s786071957.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s786071957", "user_id": "u455317716"}, "prompt_components": {"gold_output": "Possible\n", "input_to_evaluate": "fun main(args: Array) {\n val (h, w) = readLine()!!.split(' ').map { it.toInt() }\n var a = Array(h) {\n readLine()!!\n }\n var i = 0\n var j = 0\n while (true) {\n if (i == h-1 && j == w-1) {\n println(\"Possible\")\n return\n }\n when {\n (a.getOrElse(i + 1) { \".\" }.getOrElse(j) { '.' } == '#' && a.getOrElse(i) { \".\" }.getOrElse(j + 1) { '.' } == '#') || (a.getOrElse(\n i + 1\n ) { \".\" }.getOrElse(j) { '.' } == '.' && a.getOrElse(i) { \".\" }.getOrElse(j + 1) { '.' } == '.') -> {\n println(\"Impossible\")\n return\n }\n a.getOrElse(i + 1, { \".\" }).getOrElse(j, { '.' }) == '#' -> i++\n a.getOrElse(i, { \".\" }).getOrElse(j + 1, { '.' }) == '#' -> j++\n else -> {\n println(\"Impossible\")\n return\n }\n }\n }\n}", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 922, "cpu_time_ms": 229, "memory_kb": 38332}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s584211280", "group_id": "codeNet:p03943", "input_text": "fun main(args: Array) {\n val x= readLine()!!.split(\" \").map { it.toInt() }\n println(if(x.max()!!*2==x.sum())\"Yes\" else \"No\")\n}", "language": "Kotlin", "metadata": {"date": 1542244404, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03943.html", "problem_id": "p03943", "resource_group": "medium_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/Kotlin/s584211280.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s584211280", "user_id": "u914096045"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "fun main(args: Array) {\n val x= readLine()!!.split(\" \").map { it.toInt() }\n println(if(x.max()!!*2==x.sum())\"Yes\" else \"No\")\n}", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 254, "memory_kb": 36136}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s496709873", "group_id": "codeNet:p03943", "input_text": "fun main(args: Array) \n{\n val (a,b,c) = readLine()!!.split(\" \").map{x -> x.toInt()}\n println( if( a + b == c || a == b + c || b == a + c) \"Yes\" else \"No\")\n}\n", "language": "Kotlin", "metadata": {"date": 1516712674, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03943.html", "problem_id": "p03943", "resource_group": "medium_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/Kotlin/s496709873.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s496709873", "user_id": "u562554924"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "fun main(args: Array) \n{\n val (a,b,c) = readLine()!!.split(\" \").map{x -> x.toInt()}\n println( if( a + b == c || a == b + c || b == a + c) \"Yes\" else \"No\")\n}\n", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 172, "cpu_time_ms": 233, "memory_kb": 35944}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s548318697", "group_id": "codeNet:p03944", "input_text": "fun main(args: Array) {\n val (w, h, n) = readLine()!!.split(' ').map { it.toInt() }\n val field = Array(h) { BooleanArray(w) { true } }\n repeat (n) {\n val (x, y, a) = readLine()!!.split(' ').map { it.toInt() }\n when (a) {\n 1 -> {\n field.forEach {\n for (i in 0 until x) {\n it[i] = false\n }\n }\n }\n 2 -> {\n field.forEach {\n for (i in x until w) {\n it[i] = false\n }\n }\n }\n 3 -> {\n for (i in 0 until y) {\n for (j in 0 until w) {\n field[i][j] = false\n }\n }\n }\n 4 -> {\n for (i in y until h) {\n for (j in 0 until w) {\n field[i][j] = false\n }\n }\n }\n }\n\n }\n println(field.map{ it.count{ it } }.sum())\n}\n", "language": "Kotlin", "metadata": {"date": 1599513133, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p03944.html", "problem_id": "p03944", "resource_group": "medium_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/Kotlin/s548318697.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s548318697", "user_id": "u288435405"}, "prompt_components": {"gold_output": "9\n", "input_to_evaluate": "fun main(args: Array) {\n val (w, h, n) = readLine()!!.split(' ').map { it.toInt() }\n val field = Array(h) { BooleanArray(w) { true } }\n repeat (n) {\n val (x, y, a) = readLine()!!.split(' ').map { it.toInt() }\n when (a) {\n 1 -> {\n field.forEach {\n for (i in 0 until x) {\n it[i] = false\n }\n }\n }\n 2 -> {\n field.forEach {\n for (i in x until w) {\n it[i] = false\n }\n }\n }\n 3 -> {\n for (i in 0 until y) {\n for (j in 0 until w) {\n field[i][j] = false\n }\n }\n }\n 4 -> {\n for (i in y until h) {\n for (j in 0 until w) {\n field[i][j] = false\n }\n }\n }\n }\n\n }\n println(field.map{ it.count{ it } }.sum())\n}\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1088, "cpu_time_ms": 164, "memory_kb": 42148}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s393385820", "group_id": "codeNet:p03944", "input_text": "import java.util.*\n\nfun main(args:Array){\n solve()\n}\n\nfun solve(){\n val (w,h,n) = readints()\n var ya = h\n var yb = 0\n var xa = w\n var xb = 0\n for(i in 0 until n){\n val (x,y,a) = readints()\n if(a == 1){\n xb = Math.max(xb,x)\n }\n else if(a == 2){\n xa = Math.min(xa,x)\n }\n else if(a == 3){\n yb = Math.max(yb,y)\n }\n else{\n ya = Math.min(ya,y)\n }\n }\n if(ya - yb < 0 || xa - xb < 0) println(0)\n else println(Math.max(0, (ya - yb) * (xa - xb)))\n}\n\nfun read() = readLine()!!\nfun reads() = readLine()!!.split(\" \")\nfun readint() = readLine()!!.toInt()\nfun readints() = readLine()!!.split(\" \").map{it.toInt()}\nfun readlong() = readLine()!!.toLong()\nfun readlongs() = readLine()!!.split(\" \").map{it.toLong()}", "language": "Kotlin", "metadata": {"date": 1593286783, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p03944.html", "problem_id": "p03944", "resource_group": "medium_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/Kotlin/s393385820.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s393385820", "user_id": "u480831358"}, "prompt_components": {"gold_output": "9\n", "input_to_evaluate": "import java.util.*\n\nfun main(args:Array){\n solve()\n}\n\nfun solve(){\n val (w,h,n) = readints()\n var ya = h\n var yb = 0\n var xa = w\n var xb = 0\n for(i in 0 until n){\n val (x,y,a) = readints()\n if(a == 1){\n xb = Math.max(xb,x)\n }\n else if(a == 2){\n xa = Math.min(xa,x)\n }\n else if(a == 3){\n yb = Math.max(yb,y)\n }\n else{\n ya = Math.min(ya,y)\n }\n }\n if(ya - yb < 0 || xa - xb < 0) println(0)\n else println(Math.max(0, (ya - yb) * (xa - xb)))\n}\n\nfun read() = readLine()!!\nfun reads() = readLine()!!.split(\" \")\nfun readint() = readLine()!!.toInt()\nfun readints() = readLine()!!.split(\" \").map{it.toInt()}\nfun readlong() = readLine()!!.toLong()\nfun readlongs() = readLine()!!.split(\" \").map{it.toLong()}", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 840, "cpu_time_ms": 135, "memory_kb": 37916}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s611775581", "group_id": "codeNet:p03962", "input_text": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n var cnt = 0;\n var arr = arrayListOf(0,0,0)\n for (i in 0..2) {\n var t = sc.nextInt()\n if (!arr.contains(i)) cnt++\n arr[i] = t\n }\n println(cnt)\n}\n", "language": "Kotlin", "metadata": {"date": 1530854810, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03962.html", "problem_id": "p03962", "resource_group": "medium_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/Kotlin/s611775581.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s611775581", "user_id": "u396701320"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n var cnt = 0;\n var arr = arrayListOf(0,0,0)\n for (i in 0..2) {\n var t = sc.nextInt()\n if (!arr.contains(i)) cnt++\n arr[i] = t\n }\n println(cnt)\n}\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 176, "memory_kb": 29344}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s934772413", "group_id": "codeNet:p03964", "input_text": "fun main(args: Array) {\n val n = readLine()!!.toInt()\n var tt = 0\n var aa = 0\n for (i in 1..n) {\n val (t, a) = readLine()!!.split(\" \").map(String::toInt)\n if (i == 1) {\n tt = t\n aa = a\n }\n do {\n var tta = tt * a\n var aat = aa * t\n if (tta < aat) {\n tt++\n } else if (aat < tta) {\n aa++\n }\n } while (tta != aat)\n }\n println(tt + aa)\n}\n", "language": "Kotlin", "metadata": {"date": 1548626214, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03964.html", "problem_id": "p03964", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03964/input.txt", "sample_output_relpath": "derived/input_output/data/p03964/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03964/Kotlin/s934772413.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s934772413", "user_id": "u051841332"}, "prompt_components": {"gold_output": "10\n", "input_to_evaluate": "fun main(args: Array) {\n val n = readLine()!!.toInt()\n var tt = 0\n var aa = 0\n for (i in 1..n) {\n val (t, a) = readLine()!!.split(\" \").map(String::toInt)\n if (i == 1) {\n tt = t\n aa = a\n }\n do {\n var tta = tt * a\n var aat = aa * t\n if (tta < aat) {\n tt++\n } else if (aat < tta) {\n aa++\n }\n } while (tta != aat)\n }\n println(tt + aa)\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nAtCoDeer the deer is seeing a quick report of election results on TV.\nTwo candidates are standing for the election: Takahashi and Aoki.\nThe report shows the ratio of the current numbers of votes the two candidates have obtained, but not the actual numbers of votes.\nAtCoDeer has checked the report N times, and when he checked it for the i-th (1≦i≦N) time, the ratio was T_i:A_i.\nIt is known that each candidate had at least one vote when he checked the report for the first time.\n\nFind the minimum possible total number of votes obtained by the two candidates when he checked the report for the N-th time.\nIt can be assumed that the number of votes obtained by each candidate never decreases.\n\nConstraints\n\n1≦N≦1000\n\n1≦T_i,A_i≦1000 (1≦i≦N)\n\nT_i and A_i (1≦i≦N) are coprime.\n\nIt is guaranteed that the correct answer is at most 10^{18}.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\nT_1 A_1\nT_2 A_2\n:\nT_N A_N\n\nOutput\n\nPrint the minimum possible total number of votes obtained by Takahashi and Aoki when AtCoDeer checked the report for the N-th time.\n\nSample Input 1\n\n3\n2 3\n1 1\n3 2\n\nSample Output 1\n\n10\n\nWhen the numbers of votes obtained by the two candidates change as 2,3 → 3,3 → 6,4, the total number of votes at the end is 10, which is the minimum possible number.\n\nSample Input 2\n\n4\n1 1\n1 1\n1 5\n1 100\n\nSample Output 2\n\n101\n\nIt is possible that neither candidate obtained a vote between the moment when he checked the report, and the moment when he checked it for the next time.\n\nSample Input 3\n\n5\n3 10\n48 17\n31 199\n231 23\n3 2\n\nSample Output 3\n\n6930", "sample_input": "3\n2 3\n1 1\n3 2\n"}, "reference_outputs": ["10\n"], "source_document_id": "p03964", "source_text": "Score : 300 points\n\nProblem Statement\n\nAtCoDeer the deer is seeing a quick report of election results on TV.\nTwo candidates are standing for the election: Takahashi and Aoki.\nThe report shows the ratio of the current numbers of votes the two candidates have obtained, but not the actual numbers of votes.\nAtCoDeer has checked the report N times, and when he checked it for the i-th (1≦i≦N) time, the ratio was T_i:A_i.\nIt is known that each candidate had at least one vote when he checked the report for the first time.\n\nFind the minimum possible total number of votes obtained by the two candidates when he checked the report for the N-th time.\nIt can be assumed that the number of votes obtained by each candidate never decreases.\n\nConstraints\n\n1≦N≦1000\n\n1≦T_i,A_i≦1000 (1≦i≦N)\n\nT_i and A_i (1≦i≦N) are coprime.\n\nIt is guaranteed that the correct answer is at most 10^{18}.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\nT_1 A_1\nT_2 A_2\n:\nT_N A_N\n\nOutput\n\nPrint the minimum possible total number of votes obtained by Takahashi and Aoki when AtCoDeer checked the report for the N-th time.\n\nSample Input 1\n\n3\n2 3\n1 1\n3 2\n\nSample Output 1\n\n10\n\nWhen the numbers of votes obtained by the two candidates change as 2,3 → 3,3 → 6,4, the total number of votes at the end is 10, which is the minimum possible number.\n\nSample Input 2\n\n4\n1 1\n1 1\n1 5\n1 100\n\nSample Output 2\n\n101\n\nIt is possible that neither candidate obtained a vote between the moment when he checked the report, and the moment when he checked it for the next time.\n\nSample Input 3\n\n5\n3 10\n48 17\n31 199\n231 23\n3 2\n\nSample Output 3\n\n6930", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 2111, "memory_kb": 37916}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s718432532", "group_id": "codeNet:p03965", "input_text": "fun main(args: Array) {\n val s = readInputLine().toCharArray()\n \n val N = s.size\n \n var score = 0\n \n for (i in 0 until N) {\n if (i + 1 > (N + N % 2) / 2) {\n if (s[i] == 'g') {\n score++\n }\n } else {\n if (s[i] == 'p') {\n score--\n }\n }\n }\n \n println(score)\n}\n\nfun readInputLine(): String {\n return readLine()!!\n}\n", "language": "Kotlin", "metadata": {"date": 1570382501, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03965.html", "problem_id": "p03965", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03965/input.txt", "sample_output_relpath": "derived/input_output/data/p03965/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03965/Kotlin/s718432532.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s718432532", "user_id": "u505558493"}, "prompt_components": {"gold_output": "0\n", "input_to_evaluate": "fun main(args: Array) {\n val s = readInputLine().toCharArray()\n \n val N = s.size\n \n var score = 0\n \n for (i in 0 until N) {\n if (i + 1 > (N + N % 2) / 2) {\n if (s[i] == 'g') {\n score++\n }\n } else {\n if (s[i] == 'p') {\n score--\n }\n }\n }\n \n println(score)\n}\n\nfun readInputLine(): String {\n return readLine()!!\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nAtCoDeer the deer and his friend TopCoDeer is playing a game.\nThe game consists of N turns.\nIn each turn, each player plays one of the two gestures, Rock and Paper, as in Rock-paper-scissors, under the following condition:\n\n(※) After each turn, (the number of times the player has played Paper)≦(the number of times the player has played Rock).\n\nEach player's score is calculated by (the number of turns where the player wins) - (the number of turns where the player loses), where the outcome of each turn is determined by the rules of Rock-paper-scissors.\n\n(For those who are not familiar with Rock-paper-scissors: If one player plays Rock and the other plays Paper, the latter player will win and the former player will lose. If both players play the same gesture, the round is a tie and neither player will win nor lose.)\n\nWith his supernatural power, AtCoDeer was able to foresee the gesture that TopCoDeer will play in each of the N turns, before the game starts.\nPlan AtCoDeer's gesture in each turn to maximize AtCoDeer's score.\n\nThe gesture that TopCoDeer will play in each turn is given by a string s. If the i-th (1≦i≦N) character in s is g, TopCoDeer will play Rock in the i-th turn. Similarly, if the i-th (1≦i≦N) character of s in p, TopCoDeer will play Paper in the i-th turn.\n\nConstraints\n\n1≦N≦10^5\n\nN=|s|\n\nEach character in s is g or p.\n\nThe gestures represented by s satisfy the condition (※).\n\nInput\n\nThe input is given from Standard Input in the following format:\n\ns\n\nOutput\n\nPrint the AtCoDeer's maximum possible score.\n\nSample Input 1\n\ngpg\n\nSample Output 1\n\n0\n\nPlaying the same gesture as the opponent in each turn results in the score of 0, which is the maximum possible score.\n\nSample Input 2\n\nggppgggpgg\n\nSample Output 2\n\n2\n\nFor example, consider playing gestures in the following order: Rock, Paper, Rock, Paper, Rock, Rock, Paper, Paper, Rock, Paper. This strategy earns three victories and suffers one defeat, resulting in the score of 2, which is the maximum possible score.", "sample_input": "gpg\n"}, "reference_outputs": ["0\n"], "source_document_id": "p03965", "source_text": "Score : 300 points\n\nProblem Statement\n\nAtCoDeer the deer and his friend TopCoDeer is playing a game.\nThe game consists of N turns.\nIn each turn, each player plays one of the two gestures, Rock and Paper, as in Rock-paper-scissors, under the following condition:\n\n(※) After each turn, (the number of times the player has played Paper)≦(the number of times the player has played Rock).\n\nEach player's score is calculated by (the number of turns where the player wins) - (the number of turns where the player loses), where the outcome of each turn is determined by the rules of Rock-paper-scissors.\n\n(For those who are not familiar with Rock-paper-scissors: If one player plays Rock and the other plays Paper, the latter player will win and the former player will lose. If both players play the same gesture, the round is a tie and neither player will win nor lose.)\n\nWith his supernatural power, AtCoDeer was able to foresee the gesture that TopCoDeer will play in each of the N turns, before the game starts.\nPlan AtCoDeer's gesture in each turn to maximize AtCoDeer's score.\n\nThe gesture that TopCoDeer will play in each turn is given by a string s. If the i-th (1≦i≦N) character in s is g, TopCoDeer will play Rock in the i-th turn. Similarly, if the i-th (1≦i≦N) character of s in p, TopCoDeer will play Paper in the i-th turn.\n\nConstraints\n\n1≦N≦10^5\n\nN=|s|\n\nEach character in s is g or p.\n\nThe gestures represented by s satisfy the condition (※).\n\nInput\n\nThe input is given from Standard Input in the following format:\n\ns\n\nOutput\n\nPrint the AtCoDeer's maximum possible score.\n\nSample Input 1\n\ngpg\n\nSample Output 1\n\n0\n\nPlaying the same gesture as the opponent in each turn results in the score of 0, which is the maximum possible score.\n\nSample Input 2\n\nggppgggpgg\n\nSample Output 2\n\n2\n\nFor example, consider playing gestures in the following order: Rock, Paper, Rock, Paper, Rock, Rock, Paper, Paper, Rock, Paper. This strategy earns three victories and suffers one defeat, resulting in the score of 2, which is the maximum possible score.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 240, "memory_kb": 33916}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s991273483", "group_id": "codeNet:p03966", "input_text": "fun main(arr:Array) {\n val inputCount = readLine()!!.toInt()\n var (ansT, ansA) = listOf(1L, 1L)\n (1..inputCount).forEach {\n val (t, a) = readLine()!!.split(\" \").map { it.toLong() }\n val start = Math.max(ansT/t, ansA/a)\n for (i in (start..(ansT+ansA))) {\n if(t*i>=ansT && a*i>=ansA) {\n ansT = t*i\n ansA = a*i\n break\n }\n }\n }\n println(ansA+ansT)\n}\n\n", "language": "Kotlin", "metadata": {"date": 1569995603, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03966.html", "problem_id": "p03966", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03966/input.txt", "sample_output_relpath": "derived/input_output/data/p03966/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03966/Kotlin/s991273483.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s991273483", "user_id": "u269969976"}, "prompt_components": {"gold_output": "10\n", "input_to_evaluate": "fun main(arr:Array) {\n val inputCount = readLine()!!.toInt()\n var (ansT, ansA) = listOf(1L, 1L)\n (1..inputCount).forEach {\n val (t, a) = readLine()!!.split(\" \").map { it.toLong() }\n val start = Math.max(ansT/t, ansA/a)\n for (i in (start..(ansT+ansA))) {\n if(t*i>=ansT && a*i>=ansA) {\n ansT = t*i\n ansA = a*i\n break\n }\n }\n }\n println(ansA+ansT)\n}\n\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nAtCoDeer the deer is seeing a quick report of election results on TV.\nTwo candidates are standing for the election: Takahashi and Aoki.\nThe report shows the ratio of the current numbers of votes the two candidates have obtained, but not the actual numbers of votes.\nAtCoDeer has checked the report N times, and when he checked it for the i-th (1≦i≦N) time, the ratio was T_i:A_i.\nIt is known that each candidate had at least one vote when he checked the report for the first time.\n\nFind the minimum possible total number of votes obtained by the two candidates when he checked the report for the N-th time.\nIt can be assumed that the number of votes obtained by each candidate never decreases.\n\nConstraints\n\n1≦N≦1000\n\n1≦T_i,A_i≦1000 (1≦i≦N)\n\nT_i and A_i (1≦i≦N) are coprime.\n\nIt is guaranteed that the correct answer is at most 10^{18}.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\nT_1 A_1\nT_2 A_2\n:\nT_N A_N\n\nOutput\n\nPrint the minimum possible total number of votes obtained by Takahashi and Aoki when AtCoDeer checked the report for the N-th time.\n\nSample Input 1\n\n3\n2 3\n1 1\n3 2\n\nSample Output 1\n\n10\n\nWhen the numbers of votes obtained by the two candidates change as 2,3 → 3,3 → 6,4, the total number of votes at the end is 10, which is the minimum possible number.\n\nSample Input 2\n\n4\n1 1\n1 1\n1 5\n1 100\n\nSample Output 2\n\n101\n\nIt is possible that neither candidate obtained a vote between the moment when he checked the report, and the moment when he checked it for the next time.\n\nSample Input 3\n\n5\n3 10\n48 17\n31 199\n231 23\n3 2\n\nSample Output 3\n\n6930", "sample_input": "3\n2 3\n1 1\n3 2\n"}, "reference_outputs": ["10\n"], "source_document_id": "p03966", "source_text": "Score : 300 points\n\nProblem Statement\n\nAtCoDeer the deer is seeing a quick report of election results on TV.\nTwo candidates are standing for the election: Takahashi and Aoki.\nThe report shows the ratio of the current numbers of votes the two candidates have obtained, but not the actual numbers of votes.\nAtCoDeer has checked the report N times, and when he checked it for the i-th (1≦i≦N) time, the ratio was T_i:A_i.\nIt is known that each candidate had at least one vote when he checked the report for the first time.\n\nFind the minimum possible total number of votes obtained by the two candidates when he checked the report for the N-th time.\nIt can be assumed that the number of votes obtained by each candidate never decreases.\n\nConstraints\n\n1≦N≦1000\n\n1≦T_i,A_i≦1000 (1≦i≦N)\n\nT_i and A_i (1≦i≦N) are coprime.\n\nIt is guaranteed that the correct answer is at most 10^{18}.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\nT_1 A_1\nT_2 A_2\n:\nT_N A_N\n\nOutput\n\nPrint the minimum possible total number of votes obtained by Takahashi and Aoki when AtCoDeer checked the report for the N-th time.\n\nSample Input 1\n\n3\n2 3\n1 1\n3 2\n\nSample Output 1\n\n10\n\nWhen the numbers of votes obtained by the two candidates change as 2,3 → 3,3 → 6,4, the total number of votes at the end is 10, which is the minimum possible number.\n\nSample Input 2\n\n4\n1 1\n1 1\n1 5\n1 100\n\nSample Output 2\n\n101\n\nIt is possible that neither candidate obtained a vote between the moment when he checked the report, and the moment when he checked it for the next time.\n\nSample Input 3\n\n5\n3 10\n48 17\n31 199\n231 23\n3 2\n\nSample Output 3\n\n6930", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 271, "memory_kb": 37920}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s845369439", "group_id": "codeNet:p03971", "input_text": "fun main(args: Array) {\n Program().solve()\n}\n\nclass Program {\n fun solve() {\n val sc = MyScanner()\n val (n, a, b) = sc.intList()\n val s = sc.next()\n\n val sb = StringBuilder()\n var cnt = 0\n var cnt2 = 0\n for (i in 0 until n) {\n\n val f = when (s[i]) {\n 'a' -> {\n if (cnt < a + b) {\n cnt++\n true\n } else {\n false\n }\n }\n 'b' -> {\n if (cnt < a + b && cnt2 < b) {\n cnt++\n cnt2++\n true\n } else {\n false\n }\n }\n else -> {\n false\n }\n }\n sb.appendln(if (f) \"Yes\" else \"No\")\n }\n\n println(sb.toString())\n\n }\n}\n\n\nclass MyScanner() {\n private var index = 0\n private var line = listOf()\n\n fun next(): String {\n while (line.size <= index) {\n line = readLine()!!.split(' ')\n index = 0\n }\n return line[index++]\n }\n\n fun nextInt() = next().toInt()\n fun nextLong() = next().toLong()\n fun nextDouble() = next().toDouble()\n fun nextCharArray() = next().toCharArray()\n fun nextChar() = next()[0]\n\n fun strList(): List {\n index = line.size\n return readLine()!!.split(' ')\n }\n\n fun intList() = strList().map { it.toInt() }\n fun longList() = strList().map { it.toLong() }\n fun doubleList() = strList().map { it.toDouble() }\n}", "language": "Kotlin", "metadata": {"date": 1586691322, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03971.html", "problem_id": "p03971", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03971/input.txt", "sample_output_relpath": "derived/input_output/data/p03971/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03971/Kotlin/s845369439.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s845369439", "user_id": "u194412908"}, "prompt_components": {"gold_output": "Yes\nYes\nNo\nNo\nYes\nYes\nYes\nNo\nNo\nNo\n", "input_to_evaluate": "fun main(args: Array) {\n Program().solve()\n}\n\nclass Program {\n fun solve() {\n val sc = MyScanner()\n val (n, a, b) = sc.intList()\n val s = sc.next()\n\n val sb = StringBuilder()\n var cnt = 0\n var cnt2 = 0\n for (i in 0 until n) {\n\n val f = when (s[i]) {\n 'a' -> {\n if (cnt < a + b) {\n cnt++\n true\n } else {\n false\n }\n }\n 'b' -> {\n if (cnt < a + b && cnt2 < b) {\n cnt++\n cnt2++\n true\n } else {\n false\n }\n }\n else -> {\n false\n }\n }\n sb.appendln(if (f) \"Yes\" else \"No\")\n }\n\n println(sb.toString())\n\n }\n}\n\n\nclass MyScanner() {\n private var index = 0\n private var line = listOf()\n\n fun next(): String {\n while (line.size <= index) {\n line = readLine()!!.split(' ')\n index = 0\n }\n return line[index++]\n }\n\n fun nextInt() = next().toInt()\n fun nextLong() = next().toLong()\n fun nextDouble() = next().toDouble()\n fun nextCharArray() = next().toCharArray()\n fun nextChar() = next()[0]\n\n fun strList(): List {\n index = line.size\n return readLine()!!.split(' ')\n }\n\n fun intList() = strList().map { it.toInt() }\n fun longList() = strList().map { it.toLong() }\n fun doubleList() = strList().map { it.toDouble() }\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nThere are N participants in the CODE FESTIVAL 2016 Qualification contests. The participants are either students in Japan, students from overseas, or neither of these.\n\nOnly Japanese students or overseas students can pass the Qualification contests. The students pass when they satisfy the conditions listed below, from the top rank down. Participants who are not students cannot pass the Qualification contests.\n\nA Japanese student passes the Qualification contests if the number of the participants who have already definitively passed is currently fewer than A+B.\n\nAn overseas student passes the Qualification contests if the number of the participants who have already definitively passed is currently fewer than A+B and the student ranks B-th or above among all overseas students.\n\nA string S is assigned indicating attributes of all participants. If the i-th character of string S is a, this means the participant ranked i-th in the Qualification contests is a Japanese student; b means the participant ranked i-th is an overseas student; and c means the participant ranked i-th is neither of these.\n\nWrite a program that outputs for all the participants in descending rank either Yes if they passed the Qualification contests or No if they did not pass.\n\nConstraints\n\n1≦N,A,B≦100000\n\nA+B≦N\n\nS is N characters long.\n\nS consists only of the letters a, b and c.\n\nInput\n\nInputs are provided from Standard Input in the following form.\n\nN A B\nS\n\nOutput\n\nOutput N lines. On the i-th line, output Yes if the i-th participant passed the Qualification contests or No if that participant did not pass.\n\nSample Input 1\n\n10 2 3\nabccabaabb\n\nSample Output 1\n\nYes\nYes\nNo\nNo\nYes\nYes\nYes\nNo\nNo\nNo\n\nThe first, second, fifth, sixth, and seventh participants pass the Qualification contests.\n\nSample Input 2\n\n12 5 2\ncabbabaacaba\n\nSample Output 2\n\nNo\nYes\nYes\nYes\nYes\nNo\nYes\nYes\nNo\nYes\nNo\nNo\n\nThe sixth participant is third among overseas students and thus does not pass the Qualification contests.\n\nSample Input 3\n\n5 2 2\nccccc\n\nSample Output 3\n\nNo\nNo\nNo\nNo\nNo", "sample_input": "10 2 3\nabccabaabb\n"}, "reference_outputs": ["Yes\nYes\nNo\nNo\nYes\nYes\nYes\nNo\nNo\nNo\n"], "source_document_id": "p03971", "source_text": "Score : 200 points\n\nProblem Statement\n\nThere are N participants in the CODE FESTIVAL 2016 Qualification contests. The participants are either students in Japan, students from overseas, or neither of these.\n\nOnly Japanese students or overseas students can pass the Qualification contests. The students pass when they satisfy the conditions listed below, from the top rank down. Participants who are not students cannot pass the Qualification contests.\n\nA Japanese student passes the Qualification contests if the number of the participants who have already definitively passed is currently fewer than A+B.\n\nAn overseas student passes the Qualification contests if the number of the participants who have already definitively passed is currently fewer than A+B and the student ranks B-th or above among all overseas students.\n\nA string S is assigned indicating attributes of all participants. If the i-th character of string S is a, this means the participant ranked i-th in the Qualification contests is a Japanese student; b means the participant ranked i-th is an overseas student; and c means the participant ranked i-th is neither of these.\n\nWrite a program that outputs for all the participants in descending rank either Yes if they passed the Qualification contests or No if they did not pass.\n\nConstraints\n\n1≦N,A,B≦100000\n\nA+B≦N\n\nS is N characters long.\n\nS consists only of the letters a, b and c.\n\nInput\n\nInputs are provided from Standard Input in the following form.\n\nN A B\nS\n\nOutput\n\nOutput N lines. On the i-th line, output Yes if the i-th participant passed the Qualification contests or No if that participant did not pass.\n\nSample Input 1\n\n10 2 3\nabccabaabb\n\nSample Output 1\n\nYes\nYes\nNo\nNo\nYes\nYes\nYes\nNo\nNo\nNo\n\nThe first, second, fifth, sixth, and seventh participants pass the Qualification contests.\n\nSample Input 2\n\n12 5 2\ncabbabaacaba\n\nSample Output 2\n\nNo\nYes\nYes\nYes\nYes\nNo\nYes\nYes\nNo\nYes\nNo\nNo\n\nThe sixth participant is third among overseas students and thus does not pass the Qualification contests.\n\nSample Input 3\n\n5 2 2\nccccc\n\nSample Output 3\n\nNo\nNo\nNo\nNo\nNo", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1710, "cpu_time_ms": 327, "memory_kb": 42024}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s119986364", "group_id": "codeNet:p03987", "input_text": "import java.math.BigInteger;\nimport java.util.*;\nobject MainKt {\n @JvmStatic fun main(args:Array) {\n val N:Int=readLine()!!.toInt()\n val sc=Scanner(System.`in`)\n val a=Array(N) {sc.nextInt()}\n // a.forEach {println(it)}\n println((1..N).fold(BigInteger(\"0\")) {\n sum:BigInteger,l:Int -> sum + (l..N).fold(BigInteger(\"0\")) {\n part:BigInteger,r:Int -> \n val s=((l-1)..(r-1)).map{a[it]}.min()\n part + BigInteger(\"${s}\")\n }\n })\n }\n}\n", "language": "Kotlin", "metadata": {"date": 1475374095, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03987.html", "problem_id": "p03987", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03987/input.txt", "sample_output_relpath": "derived/input_output/data/p03987/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03987/Kotlin/s119986364.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s119986364", "user_id": "u181807786"}, "prompt_components": {"gold_output": "9\n", "input_to_evaluate": "import java.math.BigInteger;\nimport java.util.*;\nobject MainKt {\n @JvmStatic fun main(args:Array) {\n val N:Int=readLine()!!.toInt()\n val sc=Scanner(System.`in`)\n val a=Array(N) {sc.nextInt()}\n // a.forEach {println(it)}\n println((1..N).fold(BigInteger(\"0\")) {\n sum:BigInteger,l:Int -> sum + (l..N).fold(BigInteger(\"0\")) {\n part:BigInteger,r:Int -> \n val s=((l-1)..(r-1)).map{a[it]}.min()\n part + BigInteger(\"${s}\")\n }\n })\n }\n}\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nOne day, Snuke was given a permutation of length N, a_1, a_2, ..., a_N, from his friend.\n\nFind the following:\n\nConstraints\n\n1 ≦ N ≦ 200,000\n\n(a_1, a_2, ..., a_N) is a permutation of (1, 2, ..., N).\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 answer.\n\nNote that the answer may not fit into a 32-bit integer.\n\nSample Input 1\n\n3\n2 1 3\n\nSample Output 1\n\n9\n\nSample Input 2\n\n4\n1 3 2 4\n\nSample Output 2\n\n19\n\nSample Input 3\n\n8\n5 4 8 1 2 6 7 3\n\nSample Output 3\n\n85", "sample_input": "3\n2 1 3\n"}, "reference_outputs": ["9\n"], "source_document_id": "p03987", "source_text": "Score : 400 points\n\nProblem Statement\n\nOne day, Snuke was given a permutation of length N, a_1, a_2, ..., a_N, from his friend.\n\nFind the following:\n\nConstraints\n\n1 ≦ N ≦ 200,000\n\n(a_1, a_2, ..., a_N) is a permutation of (1, 2, ..., N).\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 answer.\n\nNote that the answer may not fit into a 32-bit integer.\n\nSample Input 1\n\n3\n2 1 3\n\nSample Output 1\n\n9\n\nSample Input 2\n\n4\n1 3 2 4\n\nSample Output 2\n\n19\n\nSample Input 3\n\n8\n5 4 8 1 2 6 7 3\n\nSample Output 3\n\n85", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 464, "cpu_time_ms": 732, "memory_kb": 62704}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s073031971", "group_id": "codeNet:p03993", "input_text": "fun main(args: Array) {\n val n = readLine()!!.toInt()\n val an = readLine()!!.split(\" \").map { it.toInt() - 1 }\n\n var array = Array(n) { mutableSetOf() }\n for ((i, a) in an.withIndex()) {\n array[a].add(i)\n }\n\n var c = 0\n for ((i, a) in an.withIndex()) {\n if(array[i].contains(a)){\n c++\n }\n }\n println(c/2)\n}", "language": "Kotlin", "metadata": {"date": 1589902521, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03993.html", "problem_id": "p03993", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03993/input.txt", "sample_output_relpath": "derived/input_output/data/p03993/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03993/Kotlin/s073031971.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s073031971", "user_id": "u085288971"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "fun main(args: Array) {\n val n = readLine()!!.toInt()\n val an = readLine()!!.split(\" \").map { it.toInt() - 1 }\n\n var array = Array(n) { mutableSetOf() }\n for ((i, a) in an.withIndex()) {\n array[a].add(i)\n }\n\n var c = 0\n for ((i, a) in an.withIndex()) {\n if(array[i].contains(a)){\n c++\n }\n }\n println(c/2)\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nThere are N rabbits, numbered 1 through N.\n\nThe i-th (1≤i≤N) rabbit likes rabbit a_i.\nNote that no rabbit can like itself, that is, a_i≠i.\n\nFor a pair of rabbits i and j (i<j), we call the pair (i,j) a friendly pair if the following condition is met.\n\nRabbit i likes rabbit j and rabbit j likes rabbit i.\n\nCalculate the number of the friendly pairs.\n\nConstraints\n\n2≤N≤10^5\n\n1≤a_i≤N\n\na_i≠i\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 number of the friendly pairs.\n\nSample Input 1\n\n4\n2 1 4 3\n\nSample Output 1\n\n2\n\nThere are two friendly pairs: (1,2) and (3,4).\n\nSample Input 2\n\n3\n2 3 1\n\nSample Output 2\n\n0\n\nThere are no friendly pairs.\n\nSample Input 3\n\n5\n5 5 5 5 1\n\nSample Output 3\n\n1\n\nThere is one friendly pair: (1,5).", "sample_input": "4\n2 1 4 3\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03993", "source_text": "Score : 200 points\n\nProblem Statement\n\nThere are N rabbits, numbered 1 through N.\n\nThe i-th (1≤i≤N) rabbit likes rabbit a_i.\nNote that no rabbit can like itself, that is, a_i≠i.\n\nFor a pair of rabbits i and j (i<j), we call the pair (i,j) a friendly pair if the following condition is met.\n\nRabbit i likes rabbit j and rabbit j likes rabbit i.\n\nCalculate the number of the friendly pairs.\n\nConstraints\n\n2≤N≤10^5\n\n1≤a_i≤N\n\na_i≠i\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 number of the friendly pairs.\n\nSample Input 1\n\n4\n2 1 4 3\n\nSample Output 1\n\n2\n\nThere are two friendly pairs: (1,2) and (3,4).\n\nSample Input 2\n\n3\n2 3 1\n\nSample Output 2\n\n0\n\nThere are no friendly pairs.\n\nSample Input 3\n\n5\n5 5 5 5 1\n\nSample Output 3\n\n1\n\nThere is one friendly pair: (1,5).", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 378, "cpu_time_ms": 987, "memory_kb": 85944}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s401437102", "group_id": "codeNet:p03993", "input_text": "import java.util.*\nobject MainKt {\n @JvmStatic fun main(args:Array) {\n val sc = Scanner(System.`in`)\n val N=sc.nextInt()\n val a=Array(N) {sc.nextInt()}\n var num=0\n val n=(N-(N%2))/2\n for (j in 1..n)\n {\n val i=a[j-1]\n num+=if(a[i-1]==j&&a[j-1]==i) 1 else 0\n }\n\n println(num)\n }\n}\n", "language": "Kotlin", "metadata": {"date": 1474767396, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03993.html", "problem_id": "p03993", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03993/input.txt", "sample_output_relpath": "derived/input_output/data/p03993/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03993/Kotlin/s401437102.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s401437102", "user_id": "u181807786"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import java.util.*\nobject MainKt {\n @JvmStatic fun main(args:Array) {\n val sc = Scanner(System.`in`)\n val N=sc.nextInt()\n val a=Array(N) {sc.nextInt()}\n var num=0\n val n=(N-(N%2))/2\n for (j in 1..n)\n {\n val i=a[j-1]\n num+=if(a[i-1]==j&&a[j-1]==i) 1 else 0\n }\n\n println(num)\n }\n}\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nThere are N rabbits, numbered 1 through N.\n\nThe i-th (1≤i≤N) rabbit likes rabbit a_i.\nNote that no rabbit can like itself, that is, a_i≠i.\n\nFor a pair of rabbits i and j (i<j), we call the pair (i,j) a friendly pair if the following condition is met.\n\nRabbit i likes rabbit j and rabbit j likes rabbit i.\n\nCalculate the number of the friendly pairs.\n\nConstraints\n\n2≤N≤10^5\n\n1≤a_i≤N\n\na_i≠i\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 number of the friendly pairs.\n\nSample Input 1\n\n4\n2 1 4 3\n\nSample Output 1\n\n2\n\nThere are two friendly pairs: (1,2) and (3,4).\n\nSample Input 2\n\n3\n2 3 1\n\nSample Output 2\n\n0\n\nThere are no friendly pairs.\n\nSample Input 3\n\n5\n5 5 5 5 1\n\nSample Output 3\n\n1\n\nThere is one friendly pair: (1,5).", "sample_input": "4\n2 1 4 3\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03993", "source_text": "Score : 200 points\n\nProblem Statement\n\nThere are N rabbits, numbered 1 through N.\n\nThe i-th (1≤i≤N) rabbit likes rabbit a_i.\nNote that no rabbit can like itself, that is, a_i≠i.\n\nFor a pair of rabbits i and j (i<j), we call the pair (i,j) a friendly pair if the following condition is met.\n\nRabbit i likes rabbit j and rabbit j likes rabbit i.\n\nCalculate the number of the friendly pairs.\n\nConstraints\n\n2≤N≤10^5\n\n1≤a_i≤N\n\na_i≠i\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 number of the friendly pairs.\n\nSample Input 1\n\n4\n2 1 4 3\n\nSample Output 1\n\n2\n\nThere are two friendly pairs: (1,2) and (3,4).\n\nSample Input 2\n\n3\n2 3 1\n\nSample Output 2\n\n0\n\nThere are no friendly pairs.\n\nSample Input 3\n\n5\n5 5 5 5 1\n\nSample Output 3\n\n1\n\nThere is one friendly pair: (1,5).", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 580, "memory_kb": 39444}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s034309805", "group_id": "codeNet:p03994", "input_text": "import java.io.*\nimport java.util.*\nimport java.lang.*\nimport java.lang.Math.*\n\n\nfun solve() {\n val S = rd.readString()\n val K = rd.readInt()\n\n val N = S.length\n\n var rest = K\n val ans = CharArray(N)\n\n for (i in 0 until N) {\n if (rest > 'z' - S[i]) {\n rest -= 'z' - S[i] + 1\n ans[i] = 'a'\n } else {\n ans[i] = S[i]\n }\n }\n\n rest %= 26\n for (i in N - 1 downTo 0) {\n\n while (rest>0 && ans[i] < 'z') {\n ans[i] = ans[i] + 1\n rest--\n }\n\n if (rest==0) break\n }\n\n println(ans)\n}\n\n\n//val rd = debug.Reader(\"etc\", \"code-festival-2016-quala\", \"c\", \"sample-1\")\nval rd = Reader()\n\n\nfun main(args: Array) {\n try {\n var exception: Throwable? = null\n val sth = Thread(null, SolveThread(), \"solveThread\", 128 * 1024 * 1024)\n sth.setUncaughtExceptionHandler { _, e -> exception = e }\n sth.start(); sth.join()\n if (exception != null) throw exception!! }\n catch (e: Exception) { throw e }\n finally { rd.close() }\n}\nconst val MOD = 1_000_000_007L; const val INF = Int.MAX_VALUE/2; const val LINF = Long.MAX_VALUE/2\nconst val EPS = 1e-9; fun DBLEQ(a: Double, b: Double): Boolean {return abs(a - b) < EPS}\ndata class IntPair(val first: Int, val second: Int)\ndata class To(val idx: Int, val cost: Long)\ntypealias ALI = ArrayList\nfun edge(V: Int): Array> { return Array(V){ArrayList()} }\nval errPrintln: (Any) -> Unit = { msg -> System.err.println(msg) }\nfun rAssert(exp: Boolean, lazyMsg: () -> String = {\"\"}) {\n if (!exp) { val msg = lazyMsg(); errPrintln(\"EAssert Error: $msg\"); throw Error(msg) }\n}\nfun tAssert(exp: Boolean, lazyMsg: () -> String = {\"\"}) {\n if (!exp) { val msg = lazyMsg(); errPrintln(\"TAssert Error: $msg\"); Thread.sleep(3000) }\n}\nclass SolveThread : Runnable {\n override fun run() { solve() }\n}\nclass Reader {\n private val br = BufferedReader(InputStreamReader(System.`in`))\n val readString: () -> String = { br.readLine() }\n val readInt: () -> Int = { br.readLine().toInt() }\n val readLong: () -> Long = { br.readLine().toLong() }\n val readIntArray: () -> IntArray = { br.readLine().split(' ').map { it.toInt() }.toIntArray() }\n val readLongArray: () -> LongArray = { br.readLine().split(' ').map { it.toLong() }.toLongArray() }\n val readListInt: () -> List = { br.readLine().split(' ').map { it.toInt() } }\n val readListLong: () -> List = { br.readLine().split(' ').map { it.toLong() } }\n val readListIntCol: (Int) -> List = { N -> (0 until N).map { readInt() } }\n val readListIntCols: (Int) -> List> = { N -> (0 until N).map { br.readLine().split(' ').map { it.toInt() } } }\n val readListLongCol: (Int) -> List = { N -> (0 until N).map { readLong() } }\n val close: () -> Unit = { br.close() }\n protected fun finalize() { close() }\n}\n", "language": "Kotlin", "metadata": {"date": 1599182760, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p03994.html", "problem_id": "p03994", "resource_group": "medium_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/Kotlin/s034309805.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s034309805", "user_id": "u404244809"}, "prompt_components": {"gold_output": "aya\n", "input_to_evaluate": "import java.io.*\nimport java.util.*\nimport java.lang.*\nimport java.lang.Math.*\n\n\nfun solve() {\n val S = rd.readString()\n val K = rd.readInt()\n\n val N = S.length\n\n var rest = K\n val ans = CharArray(N)\n\n for (i in 0 until N) {\n if (rest > 'z' - S[i]) {\n rest -= 'z' - S[i] + 1\n ans[i] = 'a'\n } else {\n ans[i] = S[i]\n }\n }\n\n rest %= 26\n for (i in N - 1 downTo 0) {\n\n while (rest>0 && ans[i] < 'z') {\n ans[i] = ans[i] + 1\n rest--\n }\n\n if (rest==0) break\n }\n\n println(ans)\n}\n\n\n//val rd = debug.Reader(\"etc\", \"code-festival-2016-quala\", \"c\", \"sample-1\")\nval rd = Reader()\n\n\nfun main(args: Array) {\n try {\n var exception: Throwable? = null\n val sth = Thread(null, SolveThread(), \"solveThread\", 128 * 1024 * 1024)\n sth.setUncaughtExceptionHandler { _, e -> exception = e }\n sth.start(); sth.join()\n if (exception != null) throw exception!! }\n catch (e: Exception) { throw e }\n finally { rd.close() }\n}\nconst val MOD = 1_000_000_007L; const val INF = Int.MAX_VALUE/2; const val LINF = Long.MAX_VALUE/2\nconst val EPS = 1e-9; fun DBLEQ(a: Double, b: Double): Boolean {return abs(a - b) < EPS}\ndata class IntPair(val first: Int, val second: Int)\ndata class To(val idx: Int, val cost: Long)\ntypealias ALI = ArrayList\nfun edge(V: Int): Array> { return Array(V){ArrayList()} }\nval errPrintln: (Any) -> Unit = { msg -> System.err.println(msg) }\nfun rAssert(exp: Boolean, lazyMsg: () -> String = {\"\"}) {\n if (!exp) { val msg = lazyMsg(); errPrintln(\"EAssert Error: $msg\"); throw Error(msg) }\n}\nfun tAssert(exp: Boolean, lazyMsg: () -> String = {\"\"}) {\n if (!exp) { val msg = lazyMsg(); errPrintln(\"TAssert Error: $msg\"); Thread.sleep(3000) }\n}\nclass SolveThread : Runnable {\n override fun run() { solve() }\n}\nclass Reader {\n private val br = BufferedReader(InputStreamReader(System.`in`))\n val readString: () -> String = { br.readLine() }\n val readInt: () -> Int = { br.readLine().toInt() }\n val readLong: () -> Long = { br.readLine().toLong() }\n val readIntArray: () -> IntArray = { br.readLine().split(' ').map { it.toInt() }.toIntArray() }\n val readLongArray: () -> LongArray = { br.readLine().split(' ').map { it.toLong() }.toLongArray() }\n val readListInt: () -> List = { br.readLine().split(' ').map { it.toInt() } }\n val readListLong: () -> List = { br.readLine().split(' ').map { it.toLong() } }\n val readListIntCol: (Int) -> List = { N -> (0 until N).map { readInt() } }\n val readListIntCols: (Int) -> List> = { N -> (0 until N).map { br.readLine().split(' ').map { it.toInt() } } }\n val readListLongCol: (Int) -> List = { N -> (0 until N).map { readLong() } }\n val close: () -> Unit = { br.close() }\n protected fun finalize() { close() }\n}\n", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2919, "cpu_time_ms": 132, "memory_kb": 36892}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s762242210", "group_id": "codeNet:p03999", "input_text": "fun main() {\n val s = readLine()!!.map { it.toString() }\n val length = s.size\n\n val pattern = 1.shl(length - 1)\n\n var answer = 0L\n for (i in 0 until pattern) {\n var tmp = s[0]\n for (j in 0 until (length - 1) ) {\n if (i.shr(j).and(1) == 0) {\n tmp += \"+\"\n }\n tmp += s[j + 1]\n }\n answer += calc(tmp)\n }\n println(answer)\n}\n\nfun calc(str: String): Long {\n return str.split(\"+\").map { it.toLong() }.sum()\n}\n", "language": "Kotlin", "metadata": {"date": 1594095535, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p03999.html", "problem_id": "p03999", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03999/input.txt", "sample_output_relpath": "derived/input_output/data/p03999/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03999/Kotlin/s762242210.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s762242210", "user_id": "u542748657"}, "prompt_components": {"gold_output": "176\n", "input_to_evaluate": "fun main() {\n val s = readLine()!!.map { it.toString() }\n val length = s.size\n\n val pattern = 1.shl(length - 1)\n\n var answer = 0L\n for (i in 0 until pattern) {\n var tmp = s[0]\n for (j in 0 until (length - 1) ) {\n if (i.shr(j).and(1) == 0) {\n tmp += \"+\"\n }\n tmp += s[j + 1]\n }\n answer += calc(tmp)\n }\n println(answer)\n}\n\nfun calc(str: String): Long {\n return str.split(\"+\").map { it.toLong() }.sum()\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nYou are given a string S consisting of digits between 1 and 9, inclusive.\nYou can insert the letter + into some of the positions (possibly none) between two letters in this string.\nHere, + must not occur consecutively after insertion.\n\nAll strings that can be obtained in this way can be evaluated as formulas.\n\nEvaluate all possible formulas, and print the sum of the results.\n\nConstraints\n\n1 \\leq |S| \\leq 10\n\nAll letters in S are digits between 1 and 9, inclusive.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the sum of the evaluated value over all possible formulas.\n\nSample Input 1\n\n125\n\nSample Output 1\n\n176\n\nThere are 4 formulas that can be obtained: 125, 1+25, 12+5 and 1+2+5. When each formula is evaluated,\n\n125\n\n1+25=26\n\n12+5=17\n\n1+2+5=8\n\nThus, the sum is 125+26+17+8=176.\n\nSample Input 2\n\n9999999999\n\nSample Output 2\n\n12656242944", "sample_input": "125\n"}, "reference_outputs": ["176\n"], "source_document_id": "p03999", "source_text": "Score : 300 points\n\nProblem Statement\n\nYou are given a string S consisting of digits between 1 and 9, inclusive.\nYou can insert the letter + into some of the positions (possibly none) between two letters in this string.\nHere, + must not occur consecutively after insertion.\n\nAll strings that can be obtained in this way can be evaluated as formulas.\n\nEvaluate all possible formulas, and print the sum of the results.\n\nConstraints\n\n1 \\leq |S| \\leq 10\n\nAll letters in S are digits between 1 and 9, inclusive.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the sum of the evaluated value over all possible formulas.\n\nSample Input 1\n\n125\n\nSample Output 1\n\n176\n\nThere are 4 formulas that can be obtained: 125, 1+25, 12+5 and 1+2+5. When each formula is evaluated,\n\n125\n\n1+25=26\n\n12+5=17\n\n1+2+5=8\n\nThus, the sum is 125+26+17+8=176.\n\nSample Input 2\n\n9999999999\n\nSample Output 2\n\n12656242944", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 136, "memory_kb": 38144}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s054894362", "group_id": "codeNet:p03999", "input_text": "fun main(args:Array) {\n\tval s= readLine()!!.toList().map {it.toString().toInt()}\n\tval n=s.size\n\t\n\tval bit = Math.pow(2.0,n-1.0).toInt()\n\t(0 until bit).map{\n\t\tval plus = Integer.toBinaryString(it).padStart(n-1,'0').map {it=='1'}\n\t\tval sb = StringBuilder(s[0])\n\t\tfor(i in 0..plus.lastIndex){\n\t\t\tsb.append(s[i])\n\t\t\tif(plus[i]) sb.append(\"+\")\n\t\t}\n\t\tsb.append(s.last())\n\t\treturn@map sb.split(\"+\").map {it.toLong()}.sum()\n\t}.sum().let {println(it)}\n}", "language": "Kotlin", "metadata": {"date": 1541822475, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03999.html", "problem_id": "p03999", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03999/input.txt", "sample_output_relpath": "derived/input_output/data/p03999/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03999/Kotlin/s054894362.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s054894362", "user_id": "u914096045"}, "prompt_components": {"gold_output": "176\n", "input_to_evaluate": "fun main(args:Array) {\n\tval s= readLine()!!.toList().map {it.toString().toInt()}\n\tval n=s.size\n\t\n\tval bit = Math.pow(2.0,n-1.0).toInt()\n\t(0 until bit).map{\n\t\tval plus = Integer.toBinaryString(it).padStart(n-1,'0').map {it=='1'}\n\t\tval sb = StringBuilder(s[0])\n\t\tfor(i in 0..plus.lastIndex){\n\t\t\tsb.append(s[i])\n\t\t\tif(plus[i]) sb.append(\"+\")\n\t\t}\n\t\tsb.append(s.last())\n\t\treturn@map sb.split(\"+\").map {it.toLong()}.sum()\n\t}.sum().let {println(it)}\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nYou are given a string S consisting of digits between 1 and 9, inclusive.\nYou can insert the letter + into some of the positions (possibly none) between two letters in this string.\nHere, + must not occur consecutively after insertion.\n\nAll strings that can be obtained in this way can be evaluated as formulas.\n\nEvaluate all possible formulas, and print the sum of the results.\n\nConstraints\n\n1 \\leq |S| \\leq 10\n\nAll letters in S are digits between 1 and 9, inclusive.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the sum of the evaluated value over all possible formulas.\n\nSample Input 1\n\n125\n\nSample Output 1\n\n176\n\nThere are 4 formulas that can be obtained: 125, 1+25, 12+5 and 1+2+5. When each formula is evaluated,\n\n125\n\n1+25=26\n\n12+5=17\n\n1+2+5=8\n\nThus, the sum is 125+26+17+8=176.\n\nSample Input 2\n\n9999999999\n\nSample Output 2\n\n12656242944", "sample_input": "125\n"}, "reference_outputs": ["176\n"], "source_document_id": "p03999", "source_text": "Score : 300 points\n\nProblem Statement\n\nYou are given a string S consisting of digits between 1 and 9, inclusive.\nYou can insert the letter + into some of the positions (possibly none) between two letters in this string.\nHere, + must not occur consecutively after insertion.\n\nAll strings that can be obtained in this way can be evaluated as formulas.\n\nEvaluate all possible formulas, and print the sum of the results.\n\nConstraints\n\n1 \\leq |S| \\leq 10\n\nAll letters in S are digits between 1 and 9, inclusive.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the sum of the evaluated value over all possible formulas.\n\nSample Input 1\n\n125\n\nSample Output 1\n\n176\n\nThere are 4 formulas that can be obtained: 125, 1+25, 12+5 and 1+2+5. When each formula is evaluated,\n\n125\n\n1+25=26\n\n12+5=17\n\n1+2+5=8\n\nThus, the sum is 125+26+17+8=176.\n\nSample Input 2\n\n9999999999\n\nSample Output 2\n\n12656242944", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 452, "cpu_time_ms": 316, "memory_kb": 38644}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s579261866", "group_id": "codeNet:p04001", "input_text": "import java.util.Scanner\n\nfun main(args: Array){\n val scn = Scanner(System.`in`)\n\n val str = scn.nextLine()\n val n = str.length - 1\n\n if(n==0){\n print(str)\n return\n }\n\n var sum = 0L\n var bit = 0\n while(bit < (1 shl n)){\n\n var st = StringBuilder(str)\n var count = 1\n (0 until n).forEach { i ->\n if ((1 and (bit shr i)) == 1){\n st.insert(i+count, '+')\n count++\n }\n }\n sum += st.split(\"+\").map(String::toLong).sum()\n\n bit++\n }\n\n print(sum)\n\n}", "language": "Kotlin", "metadata": {"date": 1585365414, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p04001.html", "problem_id": "p04001", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p04001/input.txt", "sample_output_relpath": "derived/input_output/data/p04001/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p04001/Kotlin/s579261866.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s579261866", "user_id": "u455957433"}, "prompt_components": {"gold_output": "176\n", "input_to_evaluate": "import java.util.Scanner\n\nfun main(args: Array){\n val scn = Scanner(System.`in`)\n\n val str = scn.nextLine()\n val n = str.length - 1\n\n if(n==0){\n print(str)\n return\n }\n\n var sum = 0L\n var bit = 0\n while(bit < (1 shl n)){\n\n var st = StringBuilder(str)\n var count = 1\n (0 until n).forEach { i ->\n if ((1 and (bit shr i)) == 1){\n st.insert(i+count, '+')\n count++\n }\n }\n sum += st.split(\"+\").map(String::toLong).sum()\n\n bit++\n }\n\n print(sum)\n\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nYou are given a string S consisting of digits between 1 and 9, inclusive.\nYou can insert the letter + into some of the positions (possibly none) between two letters in this string.\nHere, + must not occur consecutively after insertion.\n\nAll strings that can be obtained in this way can be evaluated as formulas.\n\nEvaluate all possible formulas, and print the sum of the results.\n\nConstraints\n\n1 \\leq |S| \\leq 10\n\nAll letters in S are digits between 1 and 9, inclusive.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the sum of the evaluated value over all possible formulas.\n\nSample Input 1\n\n125\n\nSample Output 1\n\n176\n\nThere are 4 formulas that can be obtained: 125, 1+25, 12+5 and 1+2+5. When each formula is evaluated,\n\n125\n\n1+25=26\n\n12+5=17\n\n1+2+5=8\n\nThus, the sum is 125+26+17+8=176.\n\nSample Input 2\n\n9999999999\n\nSample Output 2\n\n12656242944", "sample_input": "125\n"}, "reference_outputs": ["176\n"], "source_document_id": "p04001", "source_text": "Score : 300 points\n\nProblem Statement\n\nYou are given a string S consisting of digits between 1 and 9, inclusive.\nYou can insert the letter + into some of the positions (possibly none) between two letters in this string.\nHere, + must not occur consecutively after insertion.\n\nAll strings that can be obtained in this way can be evaluated as formulas.\n\nEvaluate all possible formulas, and print the sum of the results.\n\nConstraints\n\n1 \\leq |S| \\leq 10\n\nAll letters in S are digits between 1 and 9, inclusive.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the sum of the evaluated value over all possible formulas.\n\nSample Input 1\n\n125\n\nSample Output 1\n\n176\n\nThere are 4 formulas that can be obtained: 125, 1+25, 12+5 and 1+2+5. When each formula is evaluated,\n\n125\n\n1+25=26\n\n12+5=17\n\n1+2+5=8\n\nThus, the sum is 125+26+17+8=176.\n\nSample Input 2\n\n9999999999\n\nSample Output 2\n\n12656242944", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 292, "memory_kb": 36200}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s000424595", "group_id": "codeNet:p04005", "input_text": "fun main(args: Array) {\n val (a,b,c) = readLine()!!.split(\" \").map { it.toInt() }\n if(a and b and c and 1 == 1) {\n println(listOf(1L * a * b, 1L * a * c, 1L * c * b).min())\n } else {\n println(0)\n }\n}", "language": "Kotlin", "metadata": {"date": 1561331683, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p04005.html", "problem_id": "p04005", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p04005/input.txt", "sample_output_relpath": "derived/input_output/data/p04005/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p04005/Kotlin/s000424595.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s000424595", "user_id": "u914096045"}, "prompt_components": {"gold_output": "9\n", "input_to_evaluate": "fun main(args: Array) {\n val (a,b,c) = readLine()!!.split(\" \").map { it.toInt() }\n if(a and b and c and 1 == 1) {\n println(listOf(1L * a * b, 1L * a * c, 1L * c * b).min())\n } else {\n println(0)\n }\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nWe have a rectangular parallelepiped of size A×B×C, built with blocks of size 1×1×1. Snuke will paint each of the A×B×C blocks either red or blue, so that:\n\nThere is at least one red block and at least one blue block.\n\nThe union of all red blocks forms a rectangular parallelepiped.\n\nThe union of all blue blocks forms a rectangular parallelepiped.\n\nSnuke wants to minimize the difference between the number of red blocks and the number of blue blocks. Find the minimum possible difference.\n\nConstraints\n\n2≤A,B,C≤10^9\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nA B C\n\nOutput\n\nPrint the minimum possible difference between the number of red blocks and the number of blue blocks.\n\nSample Input 1\n\n3 3 3\n\nSample Output 1\n\n9\n\nFor example, Snuke can paint the blocks as shown in the diagram below.\nThere are 9 red blocks and 18 blue blocks, thus the difference is 9.\n\nSample Input 2\n\n2 2 4\n\nSample Output 2\n\n0\n\nFor example, Snuke can paint the blocks as shown in the diagram below.\nThere are 8 red blocks and 8 blue blocks, thus the difference is 0.\n\nSample Input 3\n\n5 3 5\n\nSample Output 3\n\n15\n\nFor example, Snuke can paint the blocks as shown in the diagram below.\nThere are 45 red blocks and 30 blue blocks, thus the difference is 9.", "sample_input": "3 3 3\n"}, "reference_outputs": ["9\n"], "source_document_id": "p04005", "source_text": "Score : 200 points\n\nProblem Statement\n\nWe have a rectangular parallelepiped of size A×B×C, built with blocks of size 1×1×1. Snuke will paint each of the A×B×C blocks either red or blue, so that:\n\nThere is at least one red block and at least one blue block.\n\nThe union of all red blocks forms a rectangular parallelepiped.\n\nThe union of all blue blocks forms a rectangular parallelepiped.\n\nSnuke wants to minimize the difference between the number of red blocks and the number of blue blocks. Find the minimum possible difference.\n\nConstraints\n\n2≤A,B,C≤10^9\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nA B C\n\nOutput\n\nPrint the minimum possible difference between the number of red blocks and the number of blue blocks.\n\nSample Input 1\n\n3 3 3\n\nSample Output 1\n\n9\n\nFor example, Snuke can paint the blocks as shown in the diagram below.\nThere are 9 red blocks and 18 blue blocks, thus the difference is 9.\n\nSample Input 2\n\n2 2 4\n\nSample Output 2\n\n0\n\nFor example, Snuke can paint the blocks as shown in the diagram below.\nThere are 8 red blocks and 8 blue blocks, thus the difference is 0.\n\nSample Input 3\n\n5 3 5\n\nSample Output 3\n\n15\n\nFor example, Snuke can paint the blocks as shown in the diagram below.\nThere are 45 red blocks and 30 blue blocks, thus the difference is 9.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 242, "memory_kb": 38004}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s545616226", "group_id": "codeNet:p04011", "input_text": "fun main(args: Array) {\n val n = readLine()!!.toInt()\n val k = readLine()!!.toInt()\n val x = readLine()!!.toInt()\n val y = readLine()!!.toInt()\n\n var cost = 0\n for (i in 0 until n) {\n if (i + 1 <= k) {\n cost += x\n } else {\n cost += y\n }\n }\n println(cost)\n}", "language": "Kotlin", "metadata": {"date": 1593288130, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p04011.html", "problem_id": "p04011", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p04011/input.txt", "sample_output_relpath": "derived/input_output/data/p04011/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p04011/Kotlin/s545616226.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s545616226", "user_id": "u621958170"}, "prompt_components": {"gold_output": "48000\n", "input_to_evaluate": "fun main(args: Array) {\n val n = readLine()!!.toInt()\n val k = readLine()!!.toInt()\n val x = readLine()!!.toInt()\n val y = readLine()!!.toInt()\n\n var cost = 0\n for (i in 0 until n) {\n if (i + 1 <= k) {\n cost += x\n } else {\n cost += y\n }\n }\n println(cost)\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nThere is a hotel with the following accommodation fee:\n\nX yen (the currency of Japan) per night, for the first K nights\n\nY yen per night, for the (K+1)-th and subsequent nights\n\nTak is staying at this hotel for N consecutive nights.\nFind his total accommodation fee.\n\nConstraints\n\n1 \\leq N, K \\leq 10000\n\n1 \\leq Y < X \\leq 10000\n\nN,\\,K,\\,X,\\,Y are integers.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\nK\nX\nY\n\nOutput\n\nPrint Tak's total accommodation fee.\n\nSample Input 1\n\n5\n3\n10000\n9000\n\nSample Output 1\n\n48000\n\nThe accommodation fee is as follows:\n\n10000 yen for the 1-st night\n\n10000 yen for the 2-nd night\n\n10000 yen for the 3-rd night\n\n9000 yen for the 4-th night\n\n9000 yen for the 5-th night\n\nThus, the total is 48000 yen.\n\nSample Input 2\n\n2\n3\n10000\n9000\n\nSample Output 2\n\n20000", "sample_input": "5\n3\n10000\n9000\n"}, "reference_outputs": ["48000\n"], "source_document_id": "p04011", "source_text": "Score : 100 points\n\nProblem Statement\n\nThere is a hotel with the following accommodation fee:\n\nX yen (the currency of Japan) per night, for the first K nights\n\nY yen per night, for the (K+1)-th and subsequent nights\n\nTak is staying at this hotel for N consecutive nights.\nFind his total accommodation fee.\n\nConstraints\n\n1 \\leq N, K \\leq 10000\n\n1 \\leq Y < X \\leq 10000\n\nN,\\,K,\\,X,\\,Y are integers.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\nK\nX\nY\n\nOutput\n\nPrint Tak's total accommodation fee.\n\nSample Input 1\n\n5\n3\n10000\n9000\n\nSample Output 1\n\n48000\n\nThe accommodation fee is as follows:\n\n10000 yen for the 1-st night\n\n10000 yen for the 2-nd night\n\n10000 yen for the 3-rd night\n\n9000 yen for the 4-th night\n\n9000 yen for the 5-th night\n\nThus, the total is 48000 yen.\n\nSample Input 2\n\n2\n3\n10000\n9000\n\nSample Output 2\n\n20000", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 100, "memory_kb": 34324}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s755461220", "group_id": "codeNet:p04011", "input_text": "fun main(args: Array) {\n val (n,k,x,y) = (1..4).map{readLine()!!.toInt()}\n if(n>k) println(k*x + y*(n-k))\n else println(n * x)\n}\n", "language": "Kotlin", "metadata": {"date": 1549469573, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p04011.html", "problem_id": "p04011", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p04011/input.txt", "sample_output_relpath": "derived/input_output/data/p04011/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p04011/Kotlin/s755461220.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s755461220", "user_id": "u399261731"}, "prompt_components": {"gold_output": "48000\n", "input_to_evaluate": "fun main(args: Array) {\n val (n,k,x,y) = (1..4).map{readLine()!!.toInt()}\n if(n>k) println(k*x + y*(n-k))\n else println(n * x)\n}\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nThere is a hotel with the following accommodation fee:\n\nX yen (the currency of Japan) per night, for the first K nights\n\nY yen per night, for the (K+1)-th and subsequent nights\n\nTak is staying at this hotel for N consecutive nights.\nFind his total accommodation fee.\n\nConstraints\n\n1 \\leq N, K \\leq 10000\n\n1 \\leq Y < X \\leq 10000\n\nN,\\,K,\\,X,\\,Y are integers.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\nK\nX\nY\n\nOutput\n\nPrint Tak's total accommodation fee.\n\nSample Input 1\n\n5\n3\n10000\n9000\n\nSample Output 1\n\n48000\n\nThe accommodation fee is as follows:\n\n10000 yen for the 1-st night\n\n10000 yen for the 2-nd night\n\n10000 yen for the 3-rd night\n\n9000 yen for the 4-th night\n\n9000 yen for the 5-th night\n\nThus, the total is 48000 yen.\n\nSample Input 2\n\n2\n3\n10000\n9000\n\nSample Output 2\n\n20000", "sample_input": "5\n3\n10000\n9000\n"}, "reference_outputs": ["48000\n"], "source_document_id": "p04011", "source_text": "Score : 100 points\n\nProblem Statement\n\nThere is a hotel with the following accommodation fee:\n\nX yen (the currency of Japan) per night, for the first K nights\n\nY yen per night, for the (K+1)-th and subsequent nights\n\nTak is staying at this hotel for N consecutive nights.\nFind his total accommodation fee.\n\nConstraints\n\n1 \\leq N, K \\leq 10000\n\n1 \\leq Y < X \\leq 10000\n\nN,\\,K,\\,X,\\,Y are integers.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\nK\nX\nY\n\nOutput\n\nPrint Tak's total accommodation fee.\n\nSample Input 1\n\n5\n3\n10000\n9000\n\nSample Output 1\n\n48000\n\nThe accommodation fee is as follows:\n\n10000 yen for the 1-st night\n\n10000 yen for the 2-nd night\n\n10000 yen for the 3-rd night\n\n9000 yen for the 4-th night\n\n9000 yen for the 5-th night\n\nThus, the total is 48000 yen.\n\nSample Input 2\n\n2\n3\n10000\n9000\n\nSample Output 2\n\n20000", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 209, "memory_kb": 31772}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s840230008", "group_id": "codeNet:p04011", "input_text": "fun main(args : Array) {\n val(n, k, x, y) = (1..4).map { readLine()!!.toInt() }\n\n if( n > k )\n println( k*x + y*(n - k) )\n else\n println( n*x )\n}\n", "language": "Kotlin", "metadata": {"date": 1494726612, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p04011.html", "problem_id": "p04011", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p04011/input.txt", "sample_output_relpath": "derived/input_output/data/p04011/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p04011/Kotlin/s840230008.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s840230008", "user_id": "u693048766"}, "prompt_components": {"gold_output": "48000\n", "input_to_evaluate": "fun main(args : Array) {\n val(n, k, x, y) = (1..4).map { readLine()!!.toInt() }\n\n if( n > k )\n println( k*x + y*(n - k) )\n else\n println( n*x )\n}\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nThere is a hotel with the following accommodation fee:\n\nX yen (the currency of Japan) per night, for the first K nights\n\nY yen per night, for the (K+1)-th and subsequent nights\n\nTak is staying at this hotel for N consecutive nights.\nFind his total accommodation fee.\n\nConstraints\n\n1 \\leq N, K \\leq 10000\n\n1 \\leq Y < X \\leq 10000\n\nN,\\,K,\\,X,\\,Y are integers.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\nK\nX\nY\n\nOutput\n\nPrint Tak's total accommodation fee.\n\nSample Input 1\n\n5\n3\n10000\n9000\n\nSample Output 1\n\n48000\n\nThe accommodation fee is as follows:\n\n10000 yen for the 1-st night\n\n10000 yen for the 2-nd night\n\n10000 yen for the 3-rd night\n\n9000 yen for the 4-th night\n\n9000 yen for the 5-th night\n\nThus, the total is 48000 yen.\n\nSample Input 2\n\n2\n3\n10000\n9000\n\nSample Output 2\n\n20000", "sample_input": "5\n3\n10000\n9000\n"}, "reference_outputs": ["48000\n"], "source_document_id": "p04011", "source_text": "Score : 100 points\n\nProblem Statement\n\nThere is a hotel with the following accommodation fee:\n\nX yen (the currency of Japan) per night, for the first K nights\n\nY yen per night, for the (K+1)-th and subsequent nights\n\nTak is staying at this hotel for N consecutive nights.\nFind his total accommodation fee.\n\nConstraints\n\n1 \\leq N, K \\leq 10000\n\n1 \\leq Y < X \\leq 10000\n\nN,\\,K,\\,X,\\,Y are integers.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\nK\nX\nY\n\nOutput\n\nPrint Tak's total accommodation fee.\n\nSample Input 1\n\n5\n3\n10000\n9000\n\nSample Output 1\n\n48000\n\nThe accommodation fee is as follows:\n\n10000 yen for the 1-st night\n\n10000 yen for the 2-nd night\n\n10000 yen for the 3-rd night\n\n9000 yen for the 4-th night\n\n9000 yen for the 5-th night\n\nThus, the total is 48000 yen.\n\nSample Input 2\n\n2\n3\n10000\n9000\n\nSample Output 2\n\n20000", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 204, "memory_kb": 33636}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s211894229", "group_id": "codeNet:p04012", "input_text": "fun main(args:Array) {\n val w = readLine()!!\n val ans = w.toSet().all {a-> w.count { it==a } % 2 == 0 }\n print(if(ans) \"Yes\" else \"No\")\n}", "language": "Kotlin", "metadata": {"date": 1592500007, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p04012.html", "problem_id": "p04012", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p04012/input.txt", "sample_output_relpath": "derived/input_output/data/p04012/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p04012/Kotlin/s211894229.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s211894229", "user_id": "u269969976"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "fun main(args:Array) {\n val w = readLine()!!\n val ans = w.toSet().all {a-> w.count { it==a } % 2 == 0 }\n print(if(ans) \"Yes\" else \"No\")\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nLet w be a string consisting of lowercase letters.\nWe will call w beautiful if the following condition is satisfied:\n\nEach lowercase letter of the English alphabet occurs even number of times in w.\n\nYou are given the string w. Determine if w is beautiful.\n\nConstraints\n\n1 \\leq |w| \\leq 100\n\nw consists of lowercase letters (a-z).\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nw\n\nOutput\n\nPrint Yes if w is beautiful. Print No otherwise.\n\nSample Input 1\n\nabaccaba\n\nSample Output 1\n\nYes\n\na occurs four times, b occurs twice, c occurs twice and the other letters occur zero times.\n\nSample Input 2\n\nhthth\n\nSample Output 2\n\nNo", "sample_input": "abaccaba\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p04012", "source_text": "Score : 200 points\n\nProblem Statement\n\nLet w be a string consisting of lowercase letters.\nWe will call w beautiful if the following condition is satisfied:\n\nEach lowercase letter of the English alphabet occurs even number of times in w.\n\nYou are given the string w. Determine if w is beautiful.\n\nConstraints\n\n1 \\leq |w| \\leq 100\n\nw consists of lowercase letters (a-z).\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nw\n\nOutput\n\nPrint Yes if w is beautiful. Print No otherwise.\n\nSample Input 1\n\nabaccaba\n\nSample Output 1\n\nYes\n\na occurs four times, b occurs twice, c occurs twice and the other letters occur zero times.\n\nSample Input 2\n\nhthth\n\nSample Output 2\n\nNo", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 211, "memory_kb": 33764}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s285856733", "group_id": "codeNet:p04012", "input_text": "fun main(args : Array ) { \n val m:MutableMap = mutableMapOf()\n readLine()!!.toList().map { x ->\n if( m.get(x) == null ) \n m[x] = 0\n m[x] = m[x]!! + 1\n }\n val r = m.all { xy ->\n val (x, y) = xy\n y%2 == 0\n }\n when(r) {\n true -> println(\"Yes\")\n false -> println(\"No\")\n }\n}\n", "language": "Kotlin", "metadata": {"date": 1549471254, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p04012.html", "problem_id": "p04012", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p04012/input.txt", "sample_output_relpath": "derived/input_output/data/p04012/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p04012/Kotlin/s285856733.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s285856733", "user_id": "u399261731"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "fun main(args : Array ) { \n val m:MutableMap = mutableMapOf()\n readLine()!!.toList().map { x ->\n if( m.get(x) == null ) \n m[x] = 0\n m[x] = m[x]!! + 1\n }\n val r = m.all { xy ->\n val (x, y) = xy\n y%2 == 0\n }\n when(r) {\n true -> println(\"Yes\")\n false -> println(\"No\")\n }\n}\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nLet w be a string consisting of lowercase letters.\nWe will call w beautiful if the following condition is satisfied:\n\nEach lowercase letter of the English alphabet occurs even number of times in w.\n\nYou are given the string w. Determine if w is beautiful.\n\nConstraints\n\n1 \\leq |w| \\leq 100\n\nw consists of lowercase letters (a-z).\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nw\n\nOutput\n\nPrint Yes if w is beautiful. Print No otherwise.\n\nSample Input 1\n\nabaccaba\n\nSample Output 1\n\nYes\n\na occurs four times, b occurs twice, c occurs twice and the other letters occur zero times.\n\nSample Input 2\n\nhthth\n\nSample Output 2\n\nNo", "sample_input": "abaccaba\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p04012", "source_text": "Score : 200 points\n\nProblem Statement\n\nLet w be a string consisting of lowercase letters.\nWe will call w beautiful if the following condition is satisfied:\n\nEach lowercase letter of the English alphabet occurs even number of times in w.\n\nYou are given the string w. Determine if w is beautiful.\n\nConstraints\n\n1 \\leq |w| \\leq 100\n\nw consists of lowercase letters (a-z).\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nw\n\nOutput\n\nPrint Yes if w is beautiful. Print No otherwise.\n\nSample Input 1\n\nabaccaba\n\nSample Output 1\n\nYes\n\na occurs four times, b occurs twice, c occurs twice and the other letters occur zero times.\n\nSample Input 2\n\nhthth\n\nSample Output 2\n\nNo", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 219, "memory_kb": 33804}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s935031538", "group_id": "codeNet:p04015", "input_text": "fun main(args: Array) {\n val (n, a) = readLine()!!.split(' ').map(String::toInt)\n val x = readLine()!!.split(' ').map(String::toInt)\n val dp = Array(n + 1) { LongArray(x.max()!! * n + 1) { 0L } }\n dp[0][0] = 1\n for (i in 0 until n)\n for (j in i downTo 0)\n for (k in 0..(50 * i))\n dp[j + 1][k + x[i]] += dp[j][k]\n\n var ans = 0L\n for (i in 1..n)\n ans += dp[i][i * a]\n println(ans)\n}\n", "language": "Kotlin", "metadata": {"date": 1535553630, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p04015.html", "problem_id": "p04015", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p04015/input.txt", "sample_output_relpath": "derived/input_output/data/p04015/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p04015/Kotlin/s935031538.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s935031538", "user_id": "u099066216"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "fun main(args: Array) {\n val (n, a) = readLine()!!.split(' ').map(String::toInt)\n val x = readLine()!!.split(' ').map(String::toInt)\n val dp = Array(n + 1) { LongArray(x.max()!! * n + 1) { 0L } }\n dp[0][0] = 1\n for (i in 0 until n)\n for (j in i downTo 0)\n for (k in 0..(50 * i))\n dp[j + 1][k + x[i]] += dp[j][k]\n\n var ans = 0L\n for (i in 1..n)\n ans += dp[i][i * a]\n println(ans)\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nTak has N cards. On the i-th (1 \\leq i \\leq N) card is written an integer x_i.\nHe is selecting one or more cards from these N cards, so that the average of the integers written on the selected cards is exactly A.\nIn how many ways can he make his selection?\n\nConstraints\n\n1 \\leq N \\leq 50\n\n1 \\leq A \\leq 50\n\n1 \\leq x_i \\leq 50\n\nN,\\,A,\\,x_i are integers.\n\nPartial Score\n\n200 points will be awarded for passing the test set satisfying 1 \\leq N \\leq 16.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN A\nx_1 x_2 ... x_N\n\nOutput\n\nPrint the number of ways to select cards such that the average of the written integers is exactly A.\n\nSample Input 1\n\n4 8\n7 9 8 9\n\nSample Output 1\n\n5\n\nThe following are the 5 ways to select cards such that the average is 8:\n\nSelect the 3-rd card.\n\nSelect the 1-st and 2-nd cards.\n\nSelect the 1-st and 4-th cards.\n\nSelect the 1-st, 2-nd and 3-rd cards.\n\nSelect the 1-st, 3-rd and 4-th cards.\n\nSample Input 2\n\n3 8\n6 6 9\n\nSample Output 2\n\n0\n\nSample Input 3\n\n8 5\n3 6 2 8 7 6 5 9\n\nSample Output 3\n\n19\n\nSample Input 4\n\n33 3\n3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3\n\nSample Output 4\n\n8589934591\n\nThe answer may not fit into a 32-bit integer.", "sample_input": "4 8\n7 9 8 9\n"}, "reference_outputs": ["5\n"], "source_document_id": "p04015", "source_text": "Score : 300 points\n\nProblem Statement\n\nTak has N cards. On the i-th (1 \\leq i \\leq N) card is written an integer x_i.\nHe is selecting one or more cards from these N cards, so that the average of the integers written on the selected cards is exactly A.\nIn how many ways can he make his selection?\n\nConstraints\n\n1 \\leq N \\leq 50\n\n1 \\leq A \\leq 50\n\n1 \\leq x_i \\leq 50\n\nN,\\,A,\\,x_i are integers.\n\nPartial Score\n\n200 points will be awarded for passing the test set satisfying 1 \\leq N \\leq 16.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN A\nx_1 x_2 ... x_N\n\nOutput\n\nPrint the number of ways to select cards such that the average of the written integers is exactly A.\n\nSample Input 1\n\n4 8\n7 9 8 9\n\nSample Output 1\n\n5\n\nThe following are the 5 ways to select cards such that the average is 8:\n\nSelect the 3-rd card.\n\nSelect the 1-st and 2-nd cards.\n\nSelect the 1-st and 4-th cards.\n\nSelect the 1-st, 2-nd and 3-rd cards.\n\nSelect the 1-st, 3-rd and 4-th cards.\n\nSample Input 2\n\n3 8\n6 6 9\n\nSample Output 2\n\n0\n\nSample Input 3\n\n8 5\n3 6 2 8 7 6 5 9\n\nSample Output 3\n\n19\n\nSample Input 4\n\n33 3\n3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3\n\nSample Output 4\n\n8589934591\n\nThe answer may not fit into a 32-bit integer.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 453, "cpu_time_ms": 284, "memory_kb": 40624}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s231207938", "group_id": "codeNet:p04017", "input_text": "import java.util.*\n\nfun main(args: Array) {\n val M = readLine()!!.toInt()\n var N = 1\n while (N < M) N *= 2\n val x = readLine()!!.split(\" \").map{it.toLong()}\n val L = readLine()!!.toLong()\n val Q = readLine()!!.toInt()\n val a = Array(Q) { 0 }\n val b = Array(Q) { 0 }\n\n for (i in a.indices) {\n val (A, B) = readLine()!!.split(\" \").map{it.toInt()}\n a[i] = Math.min(A, B) - 1\n b[i] = Math.max(A, B) - 1\n }\n\n val mp = TreeMap()\n x.forEachIndexed { index, l -> mp[l] = index }\n\n val doubling = Array(N) { Array(20) { N - 1 } }\n\n for (i in x.indices) {\n doubling[i][0] = mp.floorEntry(x[i] + L)?.value ?: mp.lastEntry().value\n }\n\n for (k in 1 until 20) {\n for (i in doubling.indices) {\n doubling[i][k] = doubling[doubling[i][k - 1]][k - 1]\n }\n }\n\n fun findNext(s: Int, t: Int): Pair {\n var k = doubling[s].indexOfFirst { it >= t }\n if (doubling[s][k] > t && k > 0) k--\n\n return Pair(doubling[s][k], 1 shl k)\n }\n\n for (l in a.indices) {\n var res = 0\n\n var v = a[l]\n while (v < b[l]) {\n val p = findNext(v, b[l])\n v = p.first\n res += p.second\n }\n println(res)\n }\n}\n", "language": "Kotlin", "metadata": {"date": 1575696761, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p04017.html", "problem_id": "p04017", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p04017/input.txt", "sample_output_relpath": "derived/input_output/data/p04017/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p04017/Kotlin/s231207938.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s231207938", "user_id": "u183530284"}, "prompt_components": {"gold_output": "4\n2\n1\n2\n", "input_to_evaluate": "import java.util.*\n\nfun main(args: Array) {\n val M = readLine()!!.toInt()\n var N = 1\n while (N < M) N *= 2\n val x = readLine()!!.split(\" \").map{it.toLong()}\n val L = readLine()!!.toLong()\n val Q = readLine()!!.toInt()\n val a = Array(Q) { 0 }\n val b = Array(Q) { 0 }\n\n for (i in a.indices) {\n val (A, B) = readLine()!!.split(\" \").map{it.toInt()}\n a[i] = Math.min(A, B) - 1\n b[i] = Math.max(A, B) - 1\n }\n\n val mp = TreeMap()\n x.forEachIndexed { index, l -> mp[l] = index }\n\n val doubling = Array(N) { Array(20) { N - 1 } }\n\n for (i in x.indices) {\n doubling[i][0] = mp.floorEntry(x[i] + L)?.value ?: mp.lastEntry().value\n }\n\n for (k in 1 until 20) {\n for (i in doubling.indices) {\n doubling[i][k] = doubling[doubling[i][k - 1]][k - 1]\n }\n }\n\n fun findNext(s: Int, t: Int): Pair {\n var k = doubling[s].indexOfFirst { it >= t }\n if (doubling[s][k] > t && k > 0) k--\n\n return Pair(doubling[s][k], 1 shl k)\n }\n\n for (l in a.indices) {\n var res = 0\n\n var v = a[l]\n while (v < b[l]) {\n val p = findNext(v, b[l])\n v = p.first\n res += p.second\n }\n println(res)\n }\n}\n", "problem_context": "Score : 700 points\n\nProblem Statement\n\nN hotels are located on a straight line. The coordinate of the i-th hotel (1 \\leq i \\leq N) is x_i.\n\nTak the traveler has the following two personal principles:\n\nHe never travels a distance of more than L in a single day.\n\nHe never sleeps in the open. That is, he must stay at a hotel at the end of a day.\n\nYou are given Q queries. The j-th (1 \\leq j \\leq Q) query is described by two distinct integers a_j and b_j.\nFor each query, find the minimum number of days that Tak needs to travel from the a_j-th hotel to the b_j-th hotel following his principles.\nIt is guaranteed that he can always travel from the a_j-th hotel to the b_j-th hotel, in any given input.\n\nConstraints\n\n2 \\leq N \\leq 10^5\n\n1 \\leq L \\leq 10^9\n\n1 \\leq Q \\leq 10^5\n\n1 \\leq x_i < x_2 < ... < x_N \\leq 10^9\n\nx_{i+1} - x_i \\leq L\n\n1 \\leq a_j,b_j \\leq N\n\na_j \\neq b_j\n\nN,\\,L,\\,Q,\\,x_i,\\,a_j,\\,b_j are integers.\n\nPartial Score\n\n200 points will be awarded for passing the test set satisfying N \\leq 10^3 and Q \\leq 10^3.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\nx_1 x_2 ... x_N\nL\nQ\na_1 b_1\na_2 b_2\n:\na_Q b_Q\n\nOutput\n\nPrint Q lines.\nThe j-th line (1 \\leq j \\leq Q) should contain the minimum number of days that Tak needs to travel from the a_j-th hotel to the b_j-th hotel.\n\nSample Input 1\n\n9\n1 3 6 13 15 18 19 29 31\n10\n4\n1 8\n7 3\n6 7\n8 5\n\nSample Output 1\n\n4\n2\n1\n2\n\nFor the 1-st query, he can travel from the 1-st hotel to the 8-th hotel in 4 days, as follows:\n\nDay 1: Travel from the 1-st hotel to the 2-nd hotel. The distance traveled is 2.\n\nDay 2: Travel from the 2-nd hotel to the 4-th hotel. The distance traveled is 10.\n\nDay 3: Travel from the 4-th hotel to the 7-th hotel. The distance traveled is 6.\n\nDay 4: Travel from the 7-th hotel to the 8-th hotel. The distance traveled is 10.", "sample_input": "9\n1 3 6 13 15 18 19 29 31\n10\n4\n1 8\n7 3\n6 7\n8 5\n"}, "reference_outputs": ["4\n2\n1\n2\n"], "source_document_id": "p04017", "source_text": "Score : 700 points\n\nProblem Statement\n\nN hotels are located on a straight line. The coordinate of the i-th hotel (1 \\leq i \\leq N) is x_i.\n\nTak the traveler has the following two personal principles:\n\nHe never travels a distance of more than L in a single day.\n\nHe never sleeps in the open. That is, he must stay at a hotel at the end of a day.\n\nYou are given Q queries. The j-th (1 \\leq j \\leq Q) query is described by two distinct integers a_j and b_j.\nFor each query, find the minimum number of days that Tak needs to travel from the a_j-th hotel to the b_j-th hotel following his principles.\nIt is guaranteed that he can always travel from the a_j-th hotel to the b_j-th hotel, in any given input.\n\nConstraints\n\n2 \\leq N \\leq 10^5\n\n1 \\leq L \\leq 10^9\n\n1 \\leq Q \\leq 10^5\n\n1 \\leq x_i < x_2 < ... < x_N \\leq 10^9\n\nx_{i+1} - x_i \\leq L\n\n1 \\leq a_j,b_j \\leq N\n\na_j \\neq b_j\n\nN,\\,L,\\,Q,\\,x_i,\\,a_j,\\,b_j are integers.\n\nPartial Score\n\n200 points will be awarded for passing the test set satisfying N \\leq 10^3 and Q \\leq 10^3.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\nx_1 x_2 ... x_N\nL\nQ\na_1 b_1\na_2 b_2\n:\na_Q b_Q\n\nOutput\n\nPrint Q lines.\nThe j-th line (1 \\leq j \\leq Q) should contain the minimum number of days that Tak needs to travel from the a_j-th hotel to the b_j-th hotel.\n\nSample Input 1\n\n9\n1 3 6 13 15 18 19 29 31\n10\n4\n1 8\n7 3\n6 7\n8 5\n\nSample Output 1\n\n4\n2\n1\n2\n\nFor the 1-st query, he can travel from the 1-st hotel to the 8-th hotel in 4 days, as follows:\n\nDay 1: Travel from the 1-st hotel to the 2-nd hotel. The distance traveled is 2.\n\nDay 2: Travel from the 2-nd hotel to the 4-th hotel. The distance traveled is 10.\n\nDay 3: Travel from the 4-th hotel to the 7-th hotel. The distance traveled is 6.\n\nDay 4: Travel from the 7-th hotel to the 8-th hotel. The distance traveled is 10.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1290, "cpu_time_ms": 2160, "memory_kb": 146120}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s949137383", "group_id": "codeNet:p04019", "input_text": "\nfun main(args: Array) {\n val s = readLine()!!\n val cnt = Array(4){0}\n for (i in 0 until s.length) {\n when (s[i]) {\n 'N' -> cnt[0]++\n 'S' -> cnt[1]++\n 'E' -> cnt[2]++\n else -> cnt[3]++\n }\n }\n if ((cnt[0] > 0 && cnt[1] > 0 || cnt[0] == cnt[1]) && (cnt[2] > 0 && cnt[3] > 0 || cnt[2] == cnt[3])) {\n println(\"Yes\")\n } else {\n println(\"No\")\n }\n}\n", "language": "Kotlin", "metadata": {"date": 1564336535, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p04019.html", "problem_id": "p04019", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p04019/input.txt", "sample_output_relpath": "derived/input_output/data/p04019/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p04019/Kotlin/s949137383.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s949137383", "user_id": "u095834727"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "\nfun main(args: Array) {\n val s = readLine()!!\n val cnt = Array(4){0}\n for (i in 0 until s.length) {\n when (s[i]) {\n 'N' -> cnt[0]++\n 'S' -> cnt[1]++\n 'E' -> cnt[2]++\n else -> cnt[3]++\n }\n }\n if ((cnt[0] > 0 && cnt[1] > 0 || cnt[0] == cnt[1]) && (cnt[2] > 0 && cnt[3] > 0 || cnt[2] == cnt[3])) {\n println(\"Yes\")\n } else {\n println(\"No\")\n }\n}\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nSnuke lives on an infinite two-dimensional plane. He is going on an N-day trip.\nAt the beginning of Day 1, he is at home. His plan is described in a string S of length N.\nOn Day i(1 ≦ i ≦ N), he will travel a positive distance in the following direction:\n\nNorth if the i-th letter of S is N\n\nWest if the i-th letter of S is W\n\nSouth if the i-th letter of S is S\n\nEast if the i-th letter of S is E\n\nHe has not decided each day's travel distance. Determine whether it is possible to set each day's travel distance so that he will be back at home at the end of Day N.\n\nConstraints\n\n1 ≦ | S | ≦ 1000\n\nS consists of the letters N, W, S, E.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint Yes if it is possible to set each day's travel distance so that he will be back at home at the end of Day N. Otherwise, print No.\n\nSample Input 1\n\nSENW\n\nSample Output 1\n\nYes\n\nIf Snuke travels a distance of 1 on each day, he will be back at home at the end of day 4.\n\nSample Input 2\n\nNSNNSNSN\n\nSample Output 2\n\nYes\n\nSample Input 3\n\nNNEW\n\nSample Output 3\n\nNo\n\nSample Input 4\n\nW\n\nSample Output 4\n\nNo", "sample_input": "SENW\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p04019", "source_text": "Score : 200 points\n\nProblem Statement\n\nSnuke lives on an infinite two-dimensional plane. He is going on an N-day trip.\nAt the beginning of Day 1, he is at home. His plan is described in a string S of length N.\nOn Day i(1 ≦ i ≦ N), he will travel a positive distance in the following direction:\n\nNorth if the i-th letter of S is N\n\nWest if the i-th letter of S is W\n\nSouth if the i-th letter of S is S\n\nEast if the i-th letter of S is E\n\nHe has not decided each day's travel distance. Determine whether it is possible to set each day's travel distance so that he will be back at home at the end of Day N.\n\nConstraints\n\n1 ≦ | S | ≦ 1000\n\nS consists of the letters N, W, S, E.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint Yes if it is possible to set each day's travel distance so that he will be back at home at the end of Day N. Otherwise, print No.\n\nSample Input 1\n\nSENW\n\nSample Output 1\n\nYes\n\nIf Snuke travels a distance of 1 on each day, he will be back at home at the end of day 4.\n\nSample Input 2\n\nNSNNSNSN\n\nSample Output 2\n\nYes\n\nSample Input 3\n\nNNEW\n\nSample Output 3\n\nNo\n\nSample Input 4\n\nW\n\nSample Output 4\n\nNo", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 443, "cpu_time_ms": 208, "memory_kb": 33728}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s791149409", "group_id": "codeNet:p04020", "input_text": "fun main() {\n val n = readInt()\n var pairs = 0L\n var rem = 0\n repeat(n) {\n val a = readInt()\n pairs += a/2\n if (a % 2 == 1 && rem == 1) pairs++\n rem = if (a % 2 == 1 && rem == 0) 1 else 0\n }\n println(pairs)\n}\n\n// Input Reader\nprivate fun readLn() = readLine()!!\n\nprivate fun readInt() = readLn().toInt()", "language": "Kotlin", "metadata": {"date": 1601106243, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p04020.html", "problem_id": "p04020", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p04020/input.txt", "sample_output_relpath": "derived/input_output/data/p04020/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p04020/Kotlin/s791149409.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s791149409", "user_id": "u984465701"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "fun main() {\n val n = readInt()\n var pairs = 0L\n var rem = 0\n repeat(n) {\n val a = readInt()\n pairs += a/2\n if (a % 2 == 1 && rem == 1) pairs++\n rem = if (a % 2 == 1 && rem == 0) 1 else 0\n }\n println(pairs)\n}\n\n// Input Reader\nprivate fun readLn() = readLine()!!\n\nprivate fun readInt() = readLn().toInt()", "problem_context": "Score : 400 points\n\nProblem Statement\n\nSnuke has a large collection of cards. Each card has an integer between 1 and N, inclusive, written on it.\nHe has A_i cards with an integer i.\n\nTwo cards can form a pair if the absolute value of the difference of the integers written on them is at most 1.\n\nSnuke wants to create the maximum number of pairs from his cards, on the condition that no card should be used in multiple pairs. Find the maximum number of pairs that he can create.\n\nConstraints\n\n1 ≦ N ≦ 10^5\n\n0 ≦ A_i ≦ 10^9 (1 ≦ i ≦ N)\n\nAll input values are integers.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\nA_1\n:\nA_N\n\nOutput\n\nPrint the maximum number of pairs that Snuke can create.\n\nSample Input 1\n\n4\n4\n0\n3\n2\n\nSample Output 1\n\n4\n\nFor example, Snuke can create the following four pairs: (1,1),(1,1),(3,4),(3,4).\n\nSample Input 2\n\n8\n2\n0\n1\n6\n0\n8\n2\n1\n\nSample Output 2\n\n9", "sample_input": "4\n4\n0\n3\n2\n"}, "reference_outputs": ["4\n"], "source_document_id": "p04020", "source_text": "Score : 400 points\n\nProblem Statement\n\nSnuke has a large collection of cards. Each card has an integer between 1 and N, inclusive, written on it.\nHe has A_i cards with an integer i.\n\nTwo cards can form a pair if the absolute value of the difference of the integers written on them is at most 1.\n\nSnuke wants to create the maximum number of pairs from his cards, on the condition that no card should be used in multiple pairs. Find the maximum number of pairs that he can create.\n\nConstraints\n\n1 ≦ N ≦ 10^5\n\n0 ≦ A_i ≦ 10^9 (1 ≦ i ≦ N)\n\nAll input values are integers.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\nA_1\n:\nA_N\n\nOutput\n\nPrint the maximum number of pairs that Snuke can create.\n\nSample Input 1\n\n4\n4\n0\n3\n2\n\nSample Output 1\n\n4\n\nFor example, Snuke can create the following four pairs: (1,1),(1,1),(3,4),(3,4).\n\nSample Input 2\n\n8\n2\n0\n1\n6\n0\n8\n2\n1\n\nSample Output 2\n\n9", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 349, "cpu_time_ms": 313, "memory_kb": 56792}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s803168695", "group_id": "codeNet:p04021", "input_text": "import java.io.BufferedReader\nimport java.io.InputStream\nimport java.io.InputStreamReader\nimport java.io.PrintWriter\nimport java.util.*\n\nfun compress(a: Array): Array {\n val n = a.count()\n val b = a.sorted().distinct().toTypedArray()\n val c = Array(n) { 0 }\n for (i in 0 until n) {\n c[i] = Arrays.binarySearch(b, a[i])\n }\n return c\n}\n\nfun PrintWriter.solve(sc: FastScanner) {\n val n = sc.nextInt()\n val a = Array(n) { sc.nextInt() }\n val b = compress(a)\n var count = 0\n for (i in 0 until n) {\n if (b[i] % 2 != i % 2) count++\n }\n println(count / 2)\n}\n\nfun main() {\n val writer = PrintWriter(System.out, false)\n writer.solve(FastScanner(System.`in`))\n writer.flush()\n}\n\nclass FastScanner(s: InputStream) {\n private var st = StringTokenizer(\"\")\n private val br = BufferedReader(InputStreamReader(s))\n\n fun next(): String {\n while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())\n\n return st.nextToken()\n }\n\n fun nextInt() = next().toInt()\n fun nextLong() = next().toLong()\n fun nextLine() = br.readLine()\n fun nextDouble() = next().toDouble()\n fun ready() = br.ready()\n}", "language": "Kotlin", "metadata": {"date": 1597052236, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p04021.html", "problem_id": "p04021", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p04021/input.txt", "sample_output_relpath": "derived/input_output/data/p04021/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p04021/Kotlin/s803168695.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s803168695", "user_id": "u190507186"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "import java.io.BufferedReader\nimport java.io.InputStream\nimport java.io.InputStreamReader\nimport java.io.PrintWriter\nimport java.util.*\n\nfun compress(a: Array): Array {\n val n = a.count()\n val b = a.sorted().distinct().toTypedArray()\n val c = Array(n) { 0 }\n for (i in 0 until n) {\n c[i] = Arrays.binarySearch(b, a[i])\n }\n return c\n}\n\nfun PrintWriter.solve(sc: FastScanner) {\n val n = sc.nextInt()\n val a = Array(n) { sc.nextInt() }\n val b = compress(a)\n var count = 0\n for (i in 0 until n) {\n if (b[i] % 2 != i % 2) count++\n }\n println(count / 2)\n}\n\nfun main() {\n val writer = PrintWriter(System.out, false)\n writer.solve(FastScanner(System.`in`))\n writer.flush()\n}\n\nclass FastScanner(s: InputStream) {\n private var st = StringTokenizer(\"\")\n private val br = BufferedReader(InputStreamReader(s))\n\n fun next(): String {\n while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())\n\n return st.nextToken()\n }\n\n fun nextInt() = next().toInt()\n fun nextLong() = next().toLong()\n fun nextLine() = br.readLine()\n fun nextDouble() = next().toDouble()\n fun ready() = br.ready()\n}", "problem_context": "Score : 600 points\n\nProblem Statement\n\nSnuke got an integer sequence of length N from his mother, as a birthday present. The i-th (1 ≦ i ≦ N) element of the sequence is a_i. The elements are pairwise distinct.\nHe is sorting this sequence in increasing order.\nWith supernatural power, he can perform the following two operations on the sequence in any order:\n\nOperation 1: choose 2 consecutive elements, then reverse the order of those elements.\n\nOperation 2: choose 3 consecutive elements, then reverse the order of those elements.\n\nSnuke likes Operation 2, but not Operation 1. Find the minimum number of Operation 1 that he has to perform in order to sort the sequence in increasing order.\n\nConstraints\n\n1 ≦ N ≦ 10^5\n\n0 ≦ A_i ≦ 10^9\n\nIf i ≠ j, then A_i ≠ A_j.\n\nAll input values are integers.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\nA_1\n:\nA_N\n\nOutput\n\nPrint the minimum number of times Operation 1 that Snuke has to perform.\n\nSample Input 1\n\n4\n2\n4\n3\n1\n\nSample Output 1\n\n1\n\nThe given sequence can be sorted as follows:\n\nFirst, reverse the order of the last three elements. The sequence is now: 2,1,3,4.\n\nThen, reverse the order of the first two elements. The sequence is now: 1,2,3,4.\n\nIn this sequence of operations, Operation 1 is performed once. It is not possible to sort the sequence with less number of Operation 1, thus the answer is 1.\n\nSample Input 2\n\n5\n10\n8\n5\n3\n2\n\nSample Output 2\n\n0", "sample_input": "4\n2\n4\n3\n1\n"}, "reference_outputs": ["1\n"], "source_document_id": "p04021", "source_text": "Score : 600 points\n\nProblem Statement\n\nSnuke got an integer sequence of length N from his mother, as a birthday present. The i-th (1 ≦ i ≦ N) element of the sequence is a_i. The elements are pairwise distinct.\nHe is sorting this sequence in increasing order.\nWith supernatural power, he can perform the following two operations on the sequence in any order:\n\nOperation 1: choose 2 consecutive elements, then reverse the order of those elements.\n\nOperation 2: choose 3 consecutive elements, then reverse the order of those elements.\n\nSnuke likes Operation 2, but not Operation 1. Find the minimum number of Operation 1 that he has to perform in order to sort the sequence in increasing order.\n\nConstraints\n\n1 ≦ N ≦ 10^5\n\n0 ≦ A_i ≦ 10^9\n\nIf i ≠ j, then A_i ≠ A_j.\n\nAll input values are integers.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\nA_1\n:\nA_N\n\nOutput\n\nPrint the minimum number of times Operation 1 that Snuke has to perform.\n\nSample Input 1\n\n4\n2\n4\n3\n1\n\nSample Output 1\n\n1\n\nThe given sequence can be sorted as follows:\n\nFirst, reverse the order of the last three elements. The sequence is now: 2,1,3,4.\n\nThen, reverse the order of the first two elements. The sequence is now: 1,2,3,4.\n\nIn this sequence of operations, Operation 1 is performed once. It is not possible to sort the sequence with less number of Operation 1, thus the answer is 1.\n\nSample Input 2\n\n5\n10\n8\n5\n3\n2\n\nSample Output 2\n\n0", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1189, "cpu_time_ms": 464, "memory_kb": 59108}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s193147063", "group_id": "codeNet:p04025", "input_text": "fun main(args: Array) {\n val n = readLine()!!.toInt()\n val an = readLine()!!.split(\" \").map(String::toInt)\n var min = Long.MAX_VALUE\n for (i in -100..100) {\n var num = 0L\n for (a in an) {\n num += (a - i) * (a - i)\n }\n min = Math.min(min, num)\n }\n println(min)\n}", "language": "Kotlin", "metadata": {"date": 1590036222, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p04025.html", "problem_id": "p04025", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p04025/input.txt", "sample_output_relpath": "derived/input_output/data/p04025/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p04025/Kotlin/s193147063.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s193147063", "user_id": "u085288971"}, "prompt_components": {"gold_output": "8\n", "input_to_evaluate": "fun main(args: Array) {\n val n = readLine()!!.toInt()\n val an = readLine()!!.split(\" \").map(String::toInt)\n var min = Long.MAX_VALUE\n for (i in -100..100) {\n var num = 0L\n for (a in an) {\n num += (a - i) * (a - i)\n }\n min = Math.min(min, num)\n }\n println(min)\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nEvi has N integers a_1,a_2,..,a_N. His objective is to have N equal integers by transforming some of them.\n\nHe may transform each integer at most once. Transforming an integer x into another integer y costs him (x-y)^2 dollars. Even if a_i=a_j (i≠j), he has to pay the cost separately for transforming each of them (See Sample 2).\n\nFind the minimum total cost to achieve his objective.\n\nConstraints\n\n1≦N≦100\n\n-100≦a_i≦100\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 minimum total cost to achieve Evi's objective.\n\nSample Input 1\n\n2\n4 8\n\nSample Output 1\n\n8\n\nTransforming the both into 6s will cost (4-6)^2+(8-6)^2=8 dollars, which is the minimum.\n\nSample Input 2\n\n3\n1 1 3\n\nSample Output 2\n\n3\n\nTransforming the all into 2s will cost (1-2)^2+(1-2)^2+(3-2)^2=3 dollars. Note that Evi has to pay (1-2)^2 dollar separately for transforming each of the two 1s.\n\nSample Input 3\n\n3\n4 2 5\n\nSample Output 3\n\n5\n\nLeaving the 4 as it is and transforming the 2 and the 5 into 4s will achieve the total cost of (2-4)^2+(5-4)^2=5 dollars, which is the minimum.\n\nSample Input 4\n\n4\n-100 -100 -100 -100\n\nSample Output 4\n\n0\n\nWithout transforming anything, Evi's objective is already achieved. Thus, the necessary cost is 0.", "sample_input": "2\n4 8\n"}, "reference_outputs": ["8\n"], "source_document_id": "p04025", "source_text": "Score : 200 points\n\nProblem Statement\n\nEvi has N integers a_1,a_2,..,a_N. His objective is to have N equal integers by transforming some of them.\n\nHe may transform each integer at most once. Transforming an integer x into another integer y costs him (x-y)^2 dollars. Even if a_i=a_j (i≠j), he has to pay the cost separately for transforming each of them (See Sample 2).\n\nFind the minimum total cost to achieve his objective.\n\nConstraints\n\n1≦N≦100\n\n-100≦a_i≦100\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 minimum total cost to achieve Evi's objective.\n\nSample Input 1\n\n2\n4 8\n\nSample Output 1\n\n8\n\nTransforming the both into 6s will cost (4-6)^2+(8-6)^2=8 dollars, which is the minimum.\n\nSample Input 2\n\n3\n1 1 3\n\nSample Output 2\n\n3\n\nTransforming the all into 2s will cost (1-2)^2+(1-2)^2+(3-2)^2=3 dollars. Note that Evi has to pay (1-2)^2 dollar separately for transforming each of the two 1s.\n\nSample Input 3\n\n3\n4 2 5\n\nSample Output 3\n\n5\n\nLeaving the 4 as it is and transforming the 2 and the 5 into 4s will achieve the total cost of (2-4)^2+(5-4)^2=5 dollars, which is the minimum.\n\nSample Input 4\n\n4\n-100 -100 -100 -100\n\nSample Output 4\n\n0\n\nWithout transforming anything, Evi's objective is already achieved. Thus, the necessary cost is 0.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 256, "memory_kb": 37684}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s643723648", "group_id": "codeNet:p04032", "input_text": "fun main() {\n val s = next()\n (0 until s.lastIndex).forEach { i ->\n when {\n s[i] == s[i + 1] -> {\n println(\"${i + 1} ${i + 2}\")\n return\n }\n i < s.lastIndex - 1 && s[i] == s[i + 2] -> {\n println(\"${i + 1} ${i + 3}\")\n return\n }\n }\n }\n println(\"-1 -1\")\n}\n\n// # Utils\n// ## Input\nfun next() = readLine()!!\nfun nextInt() = next().toInt()\nfun nextLong() = next().toLong()\nfun nextDouble() = next().toDouble()\nfun nextList() = next().split(\" \")\nfun nextIntList() = next().split(\" \").map(String::toInt)\nfun nextLongList() = next().split(\" \").map(String::toLong)\nfun nextDoubleList() = next().split(\" \").map(String::toDouble)\n\n// ## Array\ninline fun sizedArray(size: Int, default: T) = Array(size) { default }\ninline fun sized2DArray(row: Int, column: Int, default: T) = Array(row) { Array(column) { default } }\n\n// ## mod^-1\n// [NOTE] CANNOT use this for 0, mod, 2mod, 3mod ...(return wrong value)\nfun modinv(num: Long, mod: Long): Long {\n var a = num\n var b = mod\n var u = 1L\n var v = 0L\n while (b > 0) {\n val t = a.div(b)\n a -= t * b\n a = b.also { b = a } // swap a and b\n u -= t * v\n u = v.also { v = u } // swap u and v\n }\n u %= mod\n if (u < 0) u += mod\n return u\n}\n\nfun gcd(x: Int, y: Int): Int {\n fun innerGcd(x: Int, y: Int): Int {\n return if (x % y == 0) y else innerGcd(y, x % y)\n }\n return if (x >= y) innerGcd(x, y) else innerGcd(y, x)\n}\n\nfun gcd(x: Long, y: Long): Long {\n fun innerGcd(x: Long, y: Long): Long {\n return if (x % y == 0L) y else innerGcd(y, x % y)\n }\n return if (x >= y) innerGcd(x, y) else innerGcd(y, x)\n}\n\n// classes\nclass UnionFindTree(val size: Int) {\n private val r = sizedArray(size, -1)\n fun root(x: Int): Int {\n if (r[x] < 0) return x\n return root(r[x])\n }\n\n fun unite(x: Int, y: Int) {\n var rx = root(x)\n var ry = root(y)\n if (rx == ry) return\n if (r[rx] > r[ry]) {\n rx = ry.also { ry = rx }\n }\n r[rx] += r[ry]\n r[ry] = rx\n }\n\n fun size(x: Int) = -r[root(x)]\n\n override fun toString(): String {\n return r.joinToString(separator = \", \")\n }\n}", "language": "Kotlin", "metadata": {"date": 1601154770, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p04032.html", "problem_id": "p04032", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p04032/input.txt", "sample_output_relpath": "derived/input_output/data/p04032/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p04032/Kotlin/s643723648.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s643723648", "user_id": "u885556801"}, "prompt_components": {"gold_output": "2 5\n", "input_to_evaluate": "fun main() {\n val s = next()\n (0 until s.lastIndex).forEach { i ->\n when {\n s[i] == s[i + 1] -> {\n println(\"${i + 1} ${i + 2}\")\n return\n }\n i < s.lastIndex - 1 && s[i] == s[i + 2] -> {\n println(\"${i + 1} ${i + 3}\")\n return\n }\n }\n }\n println(\"-1 -1\")\n}\n\n// # Utils\n// ## Input\nfun next() = readLine()!!\nfun nextInt() = next().toInt()\nfun nextLong() = next().toLong()\nfun nextDouble() = next().toDouble()\nfun nextList() = next().split(\" \")\nfun nextIntList() = next().split(\" \").map(String::toInt)\nfun nextLongList() = next().split(\" \").map(String::toLong)\nfun nextDoubleList() = next().split(\" \").map(String::toDouble)\n\n// ## Array\ninline fun sizedArray(size: Int, default: T) = Array(size) { default }\ninline fun sized2DArray(row: Int, column: Int, default: T) = Array(row) { Array(column) { default } }\n\n// ## mod^-1\n// [NOTE] CANNOT use this for 0, mod, 2mod, 3mod ...(return wrong value)\nfun modinv(num: Long, mod: Long): Long {\n var a = num\n var b = mod\n var u = 1L\n var v = 0L\n while (b > 0) {\n val t = a.div(b)\n a -= t * b\n a = b.also { b = a } // swap a and b\n u -= t * v\n u = v.also { v = u } // swap u and v\n }\n u %= mod\n if (u < 0) u += mod\n return u\n}\n\nfun gcd(x: Int, y: Int): Int {\n fun innerGcd(x: Int, y: Int): Int {\n return if (x % y == 0) y else innerGcd(y, x % y)\n }\n return if (x >= y) innerGcd(x, y) else innerGcd(y, x)\n}\n\nfun gcd(x: Long, y: Long): Long {\n fun innerGcd(x: Long, y: Long): Long {\n return if (x % y == 0L) y else innerGcd(y, x % y)\n }\n return if (x >= y) innerGcd(x, y) else innerGcd(y, x)\n}\n\n// classes\nclass UnionFindTree(val size: Int) {\n private val r = sizedArray(size, -1)\n fun root(x: Int): Int {\n if (r[x] < 0) return x\n return root(r[x])\n }\n\n fun unite(x: Int, y: Int) {\n var rx = root(x)\n var ry = root(y)\n if (rx == ry) return\n if (r[rx] > r[ry]) {\n rx = ry.also { ry = rx }\n }\n r[rx] += r[ry]\n r[ry] = rx\n }\n\n fun size(x: Int) = -r[root(x)]\n\n override fun toString(): String {\n return r.joinToString(separator = \", \")\n }\n}", "problem_context": "Score : 400 points\n\nProblem Statement\n\nGiven a string t, we will call it unbalanced if and only if the length of t is at least 2, and more than half of the letters in t are the same. For example, both voodoo and melee are unbalanced, while neither noon nor a is.\n\nYou are given a string s consisting of lowercase letters. Determine if there exists a (contiguous) substring of s that is unbalanced. If the answer is positive, show a position where such a substring occurs in s.\n\nConstraints\n\n2 ≦ |s| ≦ 10^5\n\ns consists of lowercase letters.\n\nPartial Score\n\n200 points will be awarded for passing the test set satisfying 2 ≦ N ≦ 100.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\ns\n\nOutput\n\nIf there exists no unbalanced substring of s, print -1 -1.\n\nIf there exists an unbalanced substring of s, let one such substring be s_a s_{a+1} ... s_{b} (1 ≦ a < b ≦ |s|), and print a b. If there exists more than one such substring, any of them will be accepted.\n\nSample Input 1\n\nneeded\n\nSample Output 1\n\n2 5\n\nThe string s_2 s_3 s_4 s_5 = eede is unbalanced. There are also other unbalanced substrings. For example, the output 2 6 will also be accepted.\n\nSample Input 2\n\natcoder\n\nSample Output 2\n\n-1 -1\n\nThe string atcoder contains no unbalanced substring.", "sample_input": "needed\n"}, "reference_outputs": ["2 5\n"], "source_document_id": "p04032", "source_text": "Score : 400 points\n\nProblem Statement\n\nGiven a string t, we will call it unbalanced if and only if the length of t is at least 2, and more than half of the letters in t are the same. For example, both voodoo and melee are unbalanced, while neither noon nor a is.\n\nYou are given a string s consisting of lowercase letters. Determine if there exists a (contiguous) substring of s that is unbalanced. If the answer is positive, show a position where such a substring occurs in s.\n\nConstraints\n\n2 ≦ |s| ≦ 10^5\n\ns consists of lowercase letters.\n\nPartial Score\n\n200 points will be awarded for passing the test set satisfying 2 ≦ N ≦ 100.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\ns\n\nOutput\n\nIf there exists no unbalanced substring of s, print -1 -1.\n\nIf there exists an unbalanced substring of s, let one such substring be s_a s_{a+1} ... s_{b} (1 ≦ a < b ≦ |s|), and print a b. If there exists more than one such substring, any of them will be accepted.\n\nSample Input 1\n\nneeded\n\nSample Output 1\n\n2 5\n\nThe string s_2 s_3 s_4 s_5 = eede is unbalanced. There are also other unbalanced substrings. For example, the output 2 6 will also be accepted.\n\nSample Input 2\n\natcoder\n\nSample Output 2\n\n-1 -1\n\nThe string atcoder contains no unbalanced substring.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2325, "cpu_time_ms": 194, "memory_kb": 38396}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s190639104", "group_id": "codeNet:p04032", "input_text": "import java.util.*\nimport kotlin.*\n\nimport java.io.InputStream\nimport java.lang.NumberFormatException\nimport java.lang.StringBuilder\n\n\nfun main(args: Array) {\n Program().solve()\n}\n\nclass Program {\n fun solve() {\n val sc = FastScanner()\n val s = sc.next()\n\n // 部分文字列 t |t| >= 2がアンバランス\n // |t|が奇数 最低で1つおきに同じ文字\n // 偶数 同じ文字が連続する位置がある\n //\n // 同じ文字が連続する位置 or 間1つ空けて同じ文字がある位置\n\n for (i in 0..s.length - 2) {\n // 同じ文字が連続する\n if (s[i] == s[i + 1]) {\n println(\"${i + 1} ${i + 2}\")\n return\n }\n }\n\n if (s.length >= 3) {\n for (i in 0..s.length - 3) {\n // 間1つ空けて同じ文字\n if (s[i] == s[i + 2]) {\n println(\"${i + 1} ${i + 3}\")\n return\n }\n }\n }\n\n println(\"-1 -1\")\n }\n}\n\n\nclass FastScanner {\n companion object {\n val input: InputStream = System.`in`\n val buffer = ByteArray(1024) { 0 }\n fun isPrintableChar(c: Int): Boolean = c in 33..126\n }\n\n var ptr = 0\n var buflen = 0\n private fun hasNextByte(): Boolean {\n if (ptr < buflen) {\n return true\n } else {\n ptr = 0\n buflen = input.read(buffer)\n if (buflen <= 0) {\n return false\n }\n }\n return true\n }\n\n private fun readByte(): Int = if (hasNextByte()) buffer[ptr++].toInt() else -1\n\n private fun skipUnprintable() {\n while (hasNextByte() && !isPrintableChar(buffer[ptr].toInt())) ptr++\n }\n\n fun hasNext(): Boolean {\n skipUnprintable()\n return hasNextByte()\n }\n\n fun next(): String {\n if (!hasNext()) throw NoSuchElementException()\n val sb = StringBuilder()\n var b = readByte()\n while (isPrintableChar(b)) {\n sb.appendCodePoint(b)\n b = readByte()\n }\n return sb.toString()\n }\n\n fun nextInt(): Int {\n if (!hasNext()) throw NoSuchElementException()\n var n = 0\n var b = readByte()\n // '-' = 45\n val minus = b == 45\n if (minus) {\n b = readByte()\n }\n\n // '0' = 48 '9' = 57\n if (b !in 48..57) {\n throw NumberFormatException()\n }\n\n while (true) {\n if (b in 48..57) {\n n *= 10\n n += b - 48\n } else if (b == -1 || !isPrintableChar(b)) {\n return if (minus) -n else n\n } else {\n throw NumberFormatException()\n }\n b = readByte()\n }\n }\n\n fun nextLong(): Long {\n if (!hasNext()) throw NoSuchElementException()\n var n = 0L\n var b = readByte()\n // '-' = 45\n val minus = b == 45\n if (minus) {\n b = readByte()\n }\n\n // '0' = 48 '9' = 57\n if (b !in 48..57) {\n throw NumberFormatException()\n }\n\n while (true) {\n if (b in 48..57) {\n n *= 10\n n += b - 48\n } else if (b == -1 || !isPrintableChar(b)) {\n return if (minus) -n else n\n } else {\n throw NumberFormatException()\n }\n b = readByte()\n }\n }\n\n fun nextDouble(): Double = next().toDouble()\n}\n", "language": "Kotlin", "metadata": {"date": 1582212410, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p04032.html", "problem_id": "p04032", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p04032/input.txt", "sample_output_relpath": "derived/input_output/data/p04032/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p04032/Kotlin/s190639104.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s190639104", "user_id": "u194412908"}, "prompt_components": {"gold_output": "2 5\n", "input_to_evaluate": "import java.util.*\nimport kotlin.*\n\nimport java.io.InputStream\nimport java.lang.NumberFormatException\nimport java.lang.StringBuilder\n\n\nfun main(args: Array) {\n Program().solve()\n}\n\nclass Program {\n fun solve() {\n val sc = FastScanner()\n val s = sc.next()\n\n // 部分文字列 t |t| >= 2がアンバランス\n // |t|が奇数 最低で1つおきに同じ文字\n // 偶数 同じ文字が連続する位置がある\n //\n // 同じ文字が連続する位置 or 間1つ空けて同じ文字がある位置\n\n for (i in 0..s.length - 2) {\n // 同じ文字が連続する\n if (s[i] == s[i + 1]) {\n println(\"${i + 1} ${i + 2}\")\n return\n }\n }\n\n if (s.length >= 3) {\n for (i in 0..s.length - 3) {\n // 間1つ空けて同じ文字\n if (s[i] == s[i + 2]) {\n println(\"${i + 1} ${i + 3}\")\n return\n }\n }\n }\n\n println(\"-1 -1\")\n }\n}\n\n\nclass FastScanner {\n companion object {\n val input: InputStream = System.`in`\n val buffer = ByteArray(1024) { 0 }\n fun isPrintableChar(c: Int): Boolean = c in 33..126\n }\n\n var ptr = 0\n var buflen = 0\n private fun hasNextByte(): Boolean {\n if (ptr < buflen) {\n return true\n } else {\n ptr = 0\n buflen = input.read(buffer)\n if (buflen <= 0) {\n return false\n }\n }\n return true\n }\n\n private fun readByte(): Int = if (hasNextByte()) buffer[ptr++].toInt() else -1\n\n private fun skipUnprintable() {\n while (hasNextByte() && !isPrintableChar(buffer[ptr].toInt())) ptr++\n }\n\n fun hasNext(): Boolean {\n skipUnprintable()\n return hasNextByte()\n }\n\n fun next(): String {\n if (!hasNext()) throw NoSuchElementException()\n val sb = StringBuilder()\n var b = readByte()\n while (isPrintableChar(b)) {\n sb.appendCodePoint(b)\n b = readByte()\n }\n return sb.toString()\n }\n\n fun nextInt(): Int {\n if (!hasNext()) throw NoSuchElementException()\n var n = 0\n var b = readByte()\n // '-' = 45\n val minus = b == 45\n if (minus) {\n b = readByte()\n }\n\n // '0' = 48 '9' = 57\n if (b !in 48..57) {\n throw NumberFormatException()\n }\n\n while (true) {\n if (b in 48..57) {\n n *= 10\n n += b - 48\n } else if (b == -1 || !isPrintableChar(b)) {\n return if (minus) -n else n\n } else {\n throw NumberFormatException()\n }\n b = readByte()\n }\n }\n\n fun nextLong(): Long {\n if (!hasNext()) throw NoSuchElementException()\n var n = 0L\n var b = readByte()\n // '-' = 45\n val minus = b == 45\n if (minus) {\n b = readByte()\n }\n\n // '0' = 48 '9' = 57\n if (b !in 48..57) {\n throw NumberFormatException()\n }\n\n while (true) {\n if (b in 48..57) {\n n *= 10\n n += b - 48\n } else if (b == -1 || !isPrintableChar(b)) {\n return if (minus) -n else n\n } else {\n throw NumberFormatException()\n }\n b = readByte()\n }\n }\n\n fun nextDouble(): Double = next().toDouble()\n}\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nGiven a string t, we will call it unbalanced if and only if the length of t is at least 2, and more than half of the letters in t are the same. For example, both voodoo and melee are unbalanced, while neither noon nor a is.\n\nYou are given a string s consisting of lowercase letters. Determine if there exists a (contiguous) substring of s that is unbalanced. If the answer is positive, show a position where such a substring occurs in s.\n\nConstraints\n\n2 ≦ |s| ≦ 10^5\n\ns consists of lowercase letters.\n\nPartial Score\n\n200 points will be awarded for passing the test set satisfying 2 ≦ N ≦ 100.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\ns\n\nOutput\n\nIf there exists no unbalanced substring of s, print -1 -1.\n\nIf there exists an unbalanced substring of s, let one such substring be s_a s_{a+1} ... s_{b} (1 ≦ a < b ≦ |s|), and print a b. If there exists more than one such substring, any of them will be accepted.\n\nSample Input 1\n\nneeded\n\nSample Output 1\n\n2 5\n\nThe string s_2 s_3 s_4 s_5 = eede is unbalanced. There are also other unbalanced substrings. For example, the output 2 6 will also be accepted.\n\nSample Input 2\n\natcoder\n\nSample Output 2\n\n-1 -1\n\nThe string atcoder contains no unbalanced substring.", "sample_input": "needed\n"}, "reference_outputs": ["2 5\n"], "source_document_id": "p04032", "source_text": "Score : 400 points\n\nProblem Statement\n\nGiven a string t, we will call it unbalanced if and only if the length of t is at least 2, and more than half of the letters in t are the same. For example, both voodoo and melee are unbalanced, while neither noon nor a is.\n\nYou are given a string s consisting of lowercase letters. Determine if there exists a (contiguous) substring of s that is unbalanced. If the answer is positive, show a position where such a substring occurs in s.\n\nConstraints\n\n2 ≦ |s| ≦ 10^5\n\ns consists of lowercase letters.\n\nPartial Score\n\n200 points will be awarded for passing the test set satisfying 2 ≦ N ≦ 100.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\ns\n\nOutput\n\nIf there exists no unbalanced substring of s, print -1 -1.\n\nIf there exists an unbalanced substring of s, let one such substring be s_a s_{a+1} ... s_{b} (1 ≦ a < b ≦ |s|), and print a b. If there exists more than one such substring, any of them will be accepted.\n\nSample Input 1\n\nneeded\n\nSample Output 1\n\n2 5\n\nThe string s_2 s_3 s_4 s_5 = eede is unbalanced. There are also other unbalanced substrings. For example, the output 2 6 will also be accepted.\n\nSample Input 2\n\natcoder\n\nSample Output 2\n\n-1 -1\n\nThe string atcoder contains no unbalanced substring.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 3583, "cpu_time_ms": 182, "memory_kb": 31388}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s923098829", "group_id": "codeNet:p04033", "input_text": "fun main(args: Array) {\n agc002a()\n}\n\nfun agc002a() {\n val (a, b) = readLine()!!.split(' ').map { it.toLong() }\n\n if (0 in a..b) return println(\"Zero\")\n\n val answer = if (a < 0) if ((a - Math.min(0, b + 1)) % 2 == 0L) \"Positive\" else \"Negative\" else \"Positive\"\n\n println(answer)\n}\n", "language": "Kotlin", "metadata": {"date": 1575431411, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p04033.html", "problem_id": "p04033", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p04033/input.txt", "sample_output_relpath": "derived/input_output/data/p04033/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p04033/Kotlin/s923098829.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s923098829", "user_id": "u139478771"}, "prompt_components": {"gold_output": "Positive\n", "input_to_evaluate": "fun main(args: Array) {\n agc002a()\n}\n\nfun agc002a() {\n val (a, b) = readLine()!!.split(' ').map { it.toLong() }\n\n if (0 in a..b) return println(\"Zero\")\n\n val answer = if (a < 0) if ((a - Math.min(0, b + 1)) % 2 == 0L) \"Positive\" else \"Negative\" else \"Positive\"\n\n println(answer)\n}\n", "problem_context": "Problem Statement\n\nYou are given two integers a and b (a≤b). Determine if the product of the integers a, a+1, …, b is positive, negative or zero.\n\nConstraints\n\na and b are integers.\n\n-10^9≤a≤b≤10^9\n\nPartial Score\n\nIn test cases worth 100 points, -10≤a≤b≤10.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\na b\n\nOutput\n\nIf the product is positive, print Positive. If it is negative, print Negative. If it is zero, print Zero.\n\nSample Input 1\n\n1 3\n\nSample Output 1\n\nPositive\n\n1×2×3=6 is positive.\n\nSample Input 2\n\n-3 -1\n\nSample Output 2\n\nNegative\n\n(-3)×(-2)×(-1)=-6 is negative.\n\nSample Input 3\n\n-1 1\n\nSample Output 3\n\nZero\n\n(-1)×0×1=0.", "sample_input": "1 3\n"}, "reference_outputs": ["Positive\n"], "source_document_id": "p04033", "source_text": "Problem Statement\n\nYou are given two integers a and b (a≤b). Determine if the product of the integers a, a+1, …, b is positive, negative or zero.\n\nConstraints\n\na and b are integers.\n\n-10^9≤a≤b≤10^9\n\nPartial Score\n\nIn test cases worth 100 points, -10≤a≤b≤10.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\na b\n\nOutput\n\nIf the product is positive, print Positive. If it is negative, print Negative. If it is zero, print Zero.\n\nSample Input 1\n\n1 3\n\nSample Output 1\n\nPositive\n\n1×2×3=6 is positive.\n\nSample Input 2\n\n-3 -1\n\nSample Output 2\n\nNegative\n\n(-3)×(-2)×(-1)=-6 is negative.\n\nSample Input 3\n\n-1 1\n\nSample Output 3\n\nZero\n\n(-1)×0×1=0.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 304, "cpu_time_ms": 240, "memory_kb": 38128}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s134640265", "group_id": "codeNet:p04035", "input_text": "import java.util.*\nimport kotlin.*\n\nimport java.io.InputStream\nimport java.lang.NumberFormatException\nimport java.lang.StringBuilder\n\n\nfun main(args: Array) {\n Program().solve()\n}\n\nclass Program {\n fun solve() {\n val sc = FastScanner()\n val n = sc.nextInt()\n val l = sc.nextInt()\n val a = Array(n) { sc.nextInt() }\n\n for (i in 0 until n - 1) {\n if (a[i] + a[i + 1] >= l) {\n val sb = StringBuilder()\n sb.appendln(\"Possible\")\n for (j in 0 until i) {\n sb.appendln(j + 1)\n }\n for (j in i + 1 until n -1) {\n sb.appendln(j + 1)\n }\n sb.appendln(i + 1)\n print(sb.toString())\n return\n }\n }\n\n println(\"Impossible\")\n }\n}\n\n\nclass FastScanner {\n companion object {\n val input: InputStream = System.`in`\n val buffer = ByteArray(1024) { 0 }\n fun isPrintableChar(c: Int): Boolean = c in 33..126\n }\n\n var ptr = 0\n var buflen = 0\n private fun hasNextByte(): Boolean {\n if (ptr < buflen) {\n return true\n } else {\n ptr = 0\n buflen = input.read(buffer)\n if (buflen <= 0) {\n return false\n }\n }\n return true\n }\n\n private fun readByte(): Int = if (hasNextByte()) buffer[ptr++].toInt() else -1\n\n private fun skipUnprintable() {\n while (hasNextByte() && !isPrintableChar(buffer[ptr].toInt())) ptr++\n }\n\n fun hasNext(): Boolean {\n skipUnprintable()\n return hasNextByte()\n }\n\n fun next(): String {\n if (!hasNext()) throw NoSuchElementException()\n val sb = StringBuilder()\n var b = readByte()\n while (isPrintableChar(b)) {\n sb.appendCodePoint(b)\n b = readByte()\n }\n return sb.toString()\n }\n\n fun nextInt(): Int {\n if (!hasNext()) throw NoSuchElementException()\n var n = 0\n var b = readByte()\n // '-' = 45\n val minus = b == 45\n if (minus) {\n b = readByte()\n }\n\n // '0' = 48 '9' = 57\n if (b !in 48..57) {\n throw NumberFormatException()\n }\n\n while (true) {\n if (b in 48..57) {\n n *= 10\n n += b - 48\n } else if (b == -1 || !isPrintableChar(b)) {\n return if (minus) -n else n\n } else {\n throw NumberFormatException()\n }\n b = readByte()\n }\n }\n\n fun nextLong(): Long {\n if (!hasNext()) throw NoSuchElementException()\n var n = 0L\n var b = readByte()\n // '-' = 45\n val minus = b == 45\n if (minus) {\n b = readByte()\n }\n\n // '0' = 48 '9' = 57\n if (b !in 48..57) {\n throw NumberFormatException()\n }\n\n while (true) {\n if (b in 48..57) {\n n *= 10\n n += b - 48\n } else if (b == -1 || !isPrintableChar(b)) {\n return if (minus) -n else n\n } else {\n throw NumberFormatException()\n }\n b = readByte()\n }\n }\n\n fun nextDouble(): Double = next().toDouble()\n}\n", "language": "Kotlin", "metadata": {"date": 1584359415, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p04035.html", "problem_id": "p04035", "resource_group": "medium_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/Kotlin/s134640265.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s134640265", "user_id": "u194412908"}, "prompt_components": {"gold_output": "Possible\n2\n1\n", "input_to_evaluate": "import java.util.*\nimport kotlin.*\n\nimport java.io.InputStream\nimport java.lang.NumberFormatException\nimport java.lang.StringBuilder\n\n\nfun main(args: Array) {\n Program().solve()\n}\n\nclass Program {\n fun solve() {\n val sc = FastScanner()\n val n = sc.nextInt()\n val l = sc.nextInt()\n val a = Array(n) { sc.nextInt() }\n\n for (i in 0 until n - 1) {\n if (a[i] + a[i + 1] >= l) {\n val sb = StringBuilder()\n sb.appendln(\"Possible\")\n for (j in 0 until i) {\n sb.appendln(j + 1)\n }\n for (j in i + 1 until n -1) {\n sb.appendln(j + 1)\n }\n sb.appendln(i + 1)\n print(sb.toString())\n return\n }\n }\n\n println(\"Impossible\")\n }\n}\n\n\nclass FastScanner {\n companion object {\n val input: InputStream = System.`in`\n val buffer = ByteArray(1024) { 0 }\n fun isPrintableChar(c: Int): Boolean = c in 33..126\n }\n\n var ptr = 0\n var buflen = 0\n private fun hasNextByte(): Boolean {\n if (ptr < buflen) {\n return true\n } else {\n ptr = 0\n buflen = input.read(buffer)\n if (buflen <= 0) {\n return false\n }\n }\n return true\n }\n\n private fun readByte(): Int = if (hasNextByte()) buffer[ptr++].toInt() else -1\n\n private fun skipUnprintable() {\n while (hasNextByte() && !isPrintableChar(buffer[ptr].toInt())) ptr++\n }\n\n fun hasNext(): Boolean {\n skipUnprintable()\n return hasNextByte()\n }\n\n fun next(): String {\n if (!hasNext()) throw NoSuchElementException()\n val sb = StringBuilder()\n var b = readByte()\n while (isPrintableChar(b)) {\n sb.appendCodePoint(b)\n b = readByte()\n }\n return sb.toString()\n }\n\n fun nextInt(): Int {\n if (!hasNext()) throw NoSuchElementException()\n var n = 0\n var b = readByte()\n // '-' = 45\n val minus = b == 45\n if (minus) {\n b = readByte()\n }\n\n // '0' = 48 '9' = 57\n if (b !in 48..57) {\n throw NumberFormatException()\n }\n\n while (true) {\n if (b in 48..57) {\n n *= 10\n n += b - 48\n } else if (b == -1 || !isPrintableChar(b)) {\n return if (minus) -n else n\n } else {\n throw NumberFormatException()\n }\n b = readByte()\n }\n }\n\n fun nextLong(): Long {\n if (!hasNext()) throw NoSuchElementException()\n var n = 0L\n var b = readByte()\n // '-' = 45\n val minus = b == 45\n if (minus) {\n b = readByte()\n }\n\n // '0' = 48 '9' = 57\n if (b !in 48..57) {\n throw NumberFormatException()\n }\n\n while (true) {\n if (b in 48..57) {\n n *= 10\n n += b - 48\n } else if (b == -1 || !isPrintableChar(b)) {\n return if (minus) -n else n\n } else {\n throw NumberFormatException()\n }\n b = readByte()\n }\n }\n\n fun nextDouble(): Double = next().toDouble()\n}\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 3368, "cpu_time_ms": 351, "memory_kb": 41072}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s201480211", "group_id": "codeNet:p04043", "input_text": "fun main(args: Array) {\n val (A, B, C) = readInputLine().split(\" \").map { it.toInt() }\n \n val cnt = IntArray(11)\n \n cnt[A]++\n cnt[B]++\n cnt[C]++\n\n println(if (cnt[5] == 2 && cnt[7] == 1) \"YES\" else \"NO\")\n}\n\nfun readInputLine(): String {\n return readLine()!!\n}\n", "language": "Kotlin", "metadata": {"date": 1571072185, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p04043.html", "problem_id": "p04043", "resource_group": "medium_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/Kotlin/s201480211.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s201480211", "user_id": "u505558493"}, "prompt_components": {"gold_output": "YES\n", "input_to_evaluate": "fun main(args: Array) {\n val (A, B, C) = readInputLine().split(\" \").map { it.toInt() }\n \n val cnt = IntArray(11)\n \n cnt[A]++\n cnt[B]++\n cnt[C]++\n\n println(if (cnt[5] == 2 && cnt[7] == 1) \"YES\" else \"NO\")\n}\n\nfun readInputLine(): String {\n return readLine()!!\n}\n", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 236, "memory_kb": 37856}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s063299725", "group_id": "codeNet:p04045", "input_text": "import java.io.PrintWriter\n\nval pw = PrintWriter(System.out)\n\nfun main(args : Array) {\n func()\n pw.flush()\n}\n\nfun func() {\n var (n, k) = listOfInt()\n val dd = listOfInt()\n\n while (true) {\n var sn = n.toString()\n if (sn.all { it.toString().toInt() !in dd }) {\n println(n)\n return\n }\n n++\n }\n}\n\nfun next() = readLine()!!\nfun listOfString() = next().split(\" \")\nfun listOfInt() = listOfString().map { it.toInt() }\n\nfun println(value : Any) {\n pw.println(value)\n}", "language": "Kotlin", "metadata": {"date": 1570267528, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p04045.html", "problem_id": "p04045", "resource_group": "medium_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/Kotlin/s063299725.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s063299725", "user_id": "u262403099"}, "prompt_components": {"gold_output": "2000\n", "input_to_evaluate": "import java.io.PrintWriter\n\nval pw = PrintWriter(System.out)\n\nfun main(args : Array) {\n func()\n pw.flush()\n}\n\nfun func() {\n var (n, k) = listOfInt()\n val dd = listOfInt()\n\n while (true) {\n var sn = n.toString()\n if (sn.all { it.toString().toInt() !in dd }) {\n println(n)\n return\n }\n n++\n }\n}\n\nfun next() = readLine()!!\nfun listOfString() = next().split(\" \")\nfun listOfInt() = listOfString().map { it.toInt() }\n\nfun println(value : Any) {\n pw.println(value)\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 537, "cpu_time_ms": 343, "memory_kb": 40808}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s704789791", "group_id": "codeNet:p04045", "input_text": "/**\n * Created by karayuu on 2018/07/03\n */\nfun main(args: Array) {\n var (n, k) = readLine()!!.split(\" \").map { it.toInt() }\n val dislikeNums = readLine()!!.split(\" \")\n var n_s = n.toString().map { it.toString() }\n\n /* .none{}で指定された要素を含まないとき(.filter{}.isEmpty()と同じ)にtrueを返す */\n /* whileはtrueの間ループを回すので、含まなくなった->falseにするために真偽値を反転 */\n while (!n_s.none { dislikeNums.contains(it) }) {\n n++\n n_s = n.toString().map { it.toString() }\n }\n\n print(n)\n\n}", "language": "Kotlin", "metadata": {"date": 1530663978, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p04045.html", "problem_id": "p04045", "resource_group": "medium_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/Kotlin/s704789791.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s704789791", "user_id": "u598902504"}, "prompt_components": {"gold_output": "2000\n", "input_to_evaluate": "/**\n * Created by karayuu on 2018/07/03\n */\nfun main(args: Array) {\n var (n, k) = readLine()!!.split(\" \").map { it.toInt() }\n val dislikeNums = readLine()!!.split(\" \")\n var n_s = n.toString().map { it.toString() }\n\n /* .none{}で指定された要素を含まないとき(.filter{}.isEmpty()と同じ)にtrueを返す */\n /* whileはtrueの間ループを回すので、含まなくなった->falseにするために真偽値を反転 */\n while (!n_s.none { dislikeNums.contains(it) }) {\n n++\n n_s = n.toString().map { it.toString() }\n }\n\n print(n)\n\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 597, "cpu_time_ms": 382, "memory_kb": 40560}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s347198004", "group_id": "codeNet:p04045", "input_text": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val decimal = listOf(0,1,2,3,4,5,6,7,8,9)\n val N = sc.nextInt()\n val K = sc.nextInt()\n\n var D = listOf()\n for(i in 0..(K-1)){\n D += sc.nextInt()\n }\n D = D.distinct()\n var OK = decimal.filterNot{\n it in D\n }\n for(i in N..10000){\n if(i.toString().filterNot{\n it.toString().toInt() in OK\n }.isEmpty()){\n println(i)\n return\n }\n }\n}", "language": "Kotlin", "metadata": {"date": 1524893061, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p04045.html", "problem_id": "p04045", "resource_group": "medium_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/Kotlin/s347198004.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s347198004", "user_id": "u931756048"}, "prompt_components": {"gold_output": "2000\n", "input_to_evaluate": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val decimal = listOf(0,1,2,3,4,5,6,7,8,9)\n val N = sc.nextInt()\n val K = sc.nextInt()\n\n var D = listOf()\n for(i in 0..(K-1)){\n D += sc.nextInt()\n }\n D = D.distinct()\n var OK = decimal.filterNot{\n it in D\n }\n for(i in N..10000){\n if(i.toString().filterNot{\n it.toString().toInt() in OK\n }.isEmpty()){\n println(i)\n return\n }\n }\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 295, "memory_kb": 39880}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s812634113", "group_id": "codeNet:p04046", "input_text": "import java.util.*\nimport java.math.*\n\nprivate val readString: ()->String = {readLine()!!}\nprivate val readInt: ()->Int = { readLine()!!.toInt() }\nprivate val readLong: ()->Long = { readLine()!!.toLong() }\nprivate val readListInt: ()->List = { readLine()!!.split(' ').map(String::toInt) }\nprivate val readListLong: ()->List = { readLine()!!.split(' ').map(String::toLong) }\nprivate val errPrintln: (String)->Unit = { msg -> System.err.println(msg) }\nprivate val MOD = 1e9.toLong()+7\n\n\nclass LongMod(var num: Long, val MOD: Long = 1e9.toLong()+7) {\n init {\n this.num = (this.num%this.MOD + this.MOD)%this.MOD\n }\n constructor(numStr: String, MOD: Long = 1e9.toLong()+7) :\n this(0L, MOD) {\n if (numStr.isEmpty()) return\n var rv = numStr.reversed()\n var d = 1L\n rv.forEach{ c ->\n this.num += (c - '0') * d\n this.num %= MOD\n d *= 10\n d %= MOD\n }\n }\n override operator fun equals(other: Any?): Boolean {\n if (other !is LongMod) return false\n return this.num % this.MOD == other.num % this.MOD\n }\n operator fun unaryMinus(): LongMod {\n return LongMod(-this.num)\n }\n operator fun plusAssign(other: LongMod): Unit {\n if ((this.num + other.num) >= this.MOD) {\n this.num -= this.MOD\n }\n this.num += other.num\n }\n operator fun minusAssign(other: LongMod): Unit {\n if ((this.num + this.MOD - other.num) >= this.MOD) {\n this.num -= this.MOD\n }\n this.num += this.MOD - other.num\n }\n operator fun timesAssign(other: LongMod): Unit {\n this.num *= other.num\n this.num %= this.MOD\n }\n operator fun plus(other: LongMod): LongMod {\n val res = LongMod(this.num, this.MOD)\n res += other\n return res\n }\n operator fun minus(other: LongMod): LongMod {\n val res = LongMod(this.num, this.MOD)\n res -= other\n return res\n }\n operator fun times(other: LongMod): LongMod {\n val res = LongMod(this.num, this.MOD)\n res *= other\n return res\n }\n tailrec fun pow(n: Long): LongMod {\n if (n == 0L) return LongMod(1L, this.MOD)\n var x = this.pow(n / 2)\n x.timesAssign(x)\n if (n % 2 == 1L) x.timesAssign(this)\n return x\n }\n fun inv(): LongMod {\n return this.pow(this.MOD - 2)\n }\n operator fun divAssign(other: LongMod): Unit {\n this *= other.inv()\n }\n operator fun div(other: LongMod): LongMod {\n val res = LongMod(this.num, this.MOD)\n res /= other\n return res\n }\n}\nclass NckModLongTbl(val N: Int, val MOD: Long = 1e9.toLong()+7) {\n private var fact = arrayOf()\n private var iFact = arrayOf()\n init {\n this.fact = Array(N+1){LongMod(0L, MOD)}\n this.iFact = Array(N+1){LongMod(0L, MOD)}\n this.fact[0] = LongMod(1L, MOD)\n for (i in 1..N) {\n this.fact[i] = this.fact[i-1] * LongMod(i.toLong(), MOD)\n }\n this.iFact[N] = this.fact[N].inv()\n for (i in N downTo 1) {\n this.iFact[i-1] = this.iFact[i] * LongMod(i.toLong(), MOD)\n }\n }\n fun nCkMod(N: Int, K: Int): LongMod {\n if (K < 0 || N < K) return LongMod(0L, MOD)\n return this.fact[N] * this.iFact[K] * this.iFact[N-K]\n }\n}\n\n\nfun solveB(H: Int, W: Int, A: Int, B: Int): Long {\n val tbl = NckModLongTbl(H+W, MOD)\n\n var res = LongMod(0L, MOD)\n for (i in B until W) {\n res = res + tbl.nCkMod(H-A-1 + i, i) * tbl.nCkMod(A-1 + W-i-1, W-i-1)\n }\n\n return res.num\n}\n\n\nfun main(args: Array) {\n val (H,W,A,B) = readListInt()\n\n val ans = solveB(H, W, A, B)\n\n println(ans)\n}\n", "language": "Kotlin", "metadata": {"date": 1589335577, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p04046.html", "problem_id": "p04046", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p04046/input.txt", "sample_output_relpath": "derived/input_output/data/p04046/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p04046/Kotlin/s812634113.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s812634113", "user_id": "u404244809"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import java.util.*\nimport java.math.*\n\nprivate val readString: ()->String = {readLine()!!}\nprivate val readInt: ()->Int = { readLine()!!.toInt() }\nprivate val readLong: ()->Long = { readLine()!!.toLong() }\nprivate val readListInt: ()->List = { readLine()!!.split(' ').map(String::toInt) }\nprivate val readListLong: ()->List = { readLine()!!.split(' ').map(String::toLong) }\nprivate val errPrintln: (String)->Unit = { msg -> System.err.println(msg) }\nprivate val MOD = 1e9.toLong()+7\n\n\nclass LongMod(var num: Long, val MOD: Long = 1e9.toLong()+7) {\n init {\n this.num = (this.num%this.MOD + this.MOD)%this.MOD\n }\n constructor(numStr: String, MOD: Long = 1e9.toLong()+7) :\n this(0L, MOD) {\n if (numStr.isEmpty()) return\n var rv = numStr.reversed()\n var d = 1L\n rv.forEach{ c ->\n this.num += (c - '0') * d\n this.num %= MOD\n d *= 10\n d %= MOD\n }\n }\n override operator fun equals(other: Any?): Boolean {\n if (other !is LongMod) return false\n return this.num % this.MOD == other.num % this.MOD\n }\n operator fun unaryMinus(): LongMod {\n return LongMod(-this.num)\n }\n operator fun plusAssign(other: LongMod): Unit {\n if ((this.num + other.num) >= this.MOD) {\n this.num -= this.MOD\n }\n this.num += other.num\n }\n operator fun minusAssign(other: LongMod): Unit {\n if ((this.num + this.MOD - other.num) >= this.MOD) {\n this.num -= this.MOD\n }\n this.num += this.MOD - other.num\n }\n operator fun timesAssign(other: LongMod): Unit {\n this.num *= other.num\n this.num %= this.MOD\n }\n operator fun plus(other: LongMod): LongMod {\n val res = LongMod(this.num, this.MOD)\n res += other\n return res\n }\n operator fun minus(other: LongMod): LongMod {\n val res = LongMod(this.num, this.MOD)\n res -= other\n return res\n }\n operator fun times(other: LongMod): LongMod {\n val res = LongMod(this.num, this.MOD)\n res *= other\n return res\n }\n tailrec fun pow(n: Long): LongMod {\n if (n == 0L) return LongMod(1L, this.MOD)\n var x = this.pow(n / 2)\n x.timesAssign(x)\n if (n % 2 == 1L) x.timesAssign(this)\n return x\n }\n fun inv(): LongMod {\n return this.pow(this.MOD - 2)\n }\n operator fun divAssign(other: LongMod): Unit {\n this *= other.inv()\n }\n operator fun div(other: LongMod): LongMod {\n val res = LongMod(this.num, this.MOD)\n res /= other\n return res\n }\n}\nclass NckModLongTbl(val N: Int, val MOD: Long = 1e9.toLong()+7) {\n private var fact = arrayOf()\n private var iFact = arrayOf()\n init {\n this.fact = Array(N+1){LongMod(0L, MOD)}\n this.iFact = Array(N+1){LongMod(0L, MOD)}\n this.fact[0] = LongMod(1L, MOD)\n for (i in 1..N) {\n this.fact[i] = this.fact[i-1] * LongMod(i.toLong(), MOD)\n }\n this.iFact[N] = this.fact[N].inv()\n for (i in N downTo 1) {\n this.iFact[i-1] = this.iFact[i] * LongMod(i.toLong(), MOD)\n }\n }\n fun nCkMod(N: Int, K: Int): LongMod {\n if (K < 0 || N < K) return LongMod(0L, MOD)\n return this.fact[N] * this.iFact[K] * this.iFact[N-K]\n }\n}\n\n\nfun solveB(H: Int, W: Int, A: Int, B: Int): Long {\n val tbl = NckModLongTbl(H+W, MOD)\n\n var res = LongMod(0L, MOD)\n for (i in B until W) {\n res = res + tbl.nCkMod(H-A-1 + i, i) * tbl.nCkMod(A-1 + W-i-1, W-i-1)\n }\n\n return res.num\n}\n\n\nfun main(args: Array) {\n val (H,W,A,B) = readListInt()\n\n val ans = solveB(H, W, A, B)\n\n println(ans)\n}\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nWe have a large square grid with H rows and W columns.\nIroha is now standing in the top-left cell.\nShe will repeat going right or down to the adjacent cell, until she reaches the bottom-right cell.\n\nHowever, she cannot enter the cells in the intersection of the bottom A rows and the leftmost B columns. (That is, there are A×B forbidden cells.) There is no restriction on entering the other cells.\n\nFind the number of ways she can travel to the bottom-right cell.\n\nSince this number can be extremely large, print the number modulo 10^9+7.\n\nConstraints\n\n1 ≦ H, W ≦ 100,000\n\n1 ≦ A < H\n\n1 ≦ B < W\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nH W A B\n\nOutput\n\nPrint the number of ways she can travel to the bottom-right cell, modulo 10^9+7.\n\nSample Input 1\n\n2 3 1 1\n\nSample Output 1\n\n2\n\nWe have a 2×3 grid, but entering the bottom-left cell is forbidden. The number of ways to travel is two: \"Right, Right, Down\" and \"Right, Down, Right\".\n\nSample Input 2\n\n10 7 3 4\n\nSample Output 2\n\n3570\n\nThere are 12 forbidden cells.\n\nSample Input 3\n\n100000 100000 99999 99999\n\nSample Output 3\n\n1\n\nSample Input 4\n\n100000 100000 44444 55555\n\nSample Output 4\n\n738162020", "sample_input": "2 3 1 1\n"}, "reference_outputs": ["2\n"], "source_document_id": "p04046", "source_text": "Score : 400 points\n\nProblem Statement\n\nWe have a large square grid with H rows and W columns.\nIroha is now standing in the top-left cell.\nShe will repeat going right or down to the adjacent cell, until she reaches the bottom-right cell.\n\nHowever, she cannot enter the cells in the intersection of the bottom A rows and the leftmost B columns. (That is, there are A×B forbidden cells.) There is no restriction on entering the other cells.\n\nFind the number of ways she can travel to the bottom-right cell.\n\nSince this number can be extremely large, print the number modulo 10^9+7.\n\nConstraints\n\n1 ≦ H, W ≦ 100,000\n\n1 ≦ A < H\n\n1 ≦ B < W\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nH W A B\n\nOutput\n\nPrint the number of ways she can travel to the bottom-right cell, modulo 10^9+7.\n\nSample Input 1\n\n2 3 1 1\n\nSample Output 1\n\n2\n\nWe have a 2×3 grid, but entering the bottom-left cell is forbidden. The number of ways to travel is two: \"Right, Right, Down\" and \"Right, Down, Right\".\n\nSample Input 2\n\n10 7 3 4\n\nSample Output 2\n\n3570\n\nThere are 12 forbidden cells.\n\nSample Input 3\n\n100000 100000 99999 99999\n\nSample Output 3\n\n1\n\nSample Input 4\n\n100000 100000 44444 55555\n\nSample Output 4\n\n738162020", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 3778, "cpu_time_ms": 466, "memory_kb": 84044}, "variant": "medium_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s230028533", "group_id": "codeNet:p04047", "input_text": "fun main(args: Array){\n val n = readLine()!!.toInt()\n val spear = readLine()!!.split(\" \").map(String::toInt).sorted()\n var ans = 0\n for (i in 0 until n * 2 - 1 step 2) {\n ans += spear[i]\n }\n println(ans)\n}\n", "language": "Kotlin", "metadata": {"date": 1561589690, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p04047.html", "problem_id": "p04047", "resource_group": "medium_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/Kotlin/s230028533.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s230028533", "user_id": "u712822150"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "fun main(args: Array){\n val n = readLine()!!.toInt()\n val spear = readLine()!!.split(\" \").map(String::toInt).sorted()\n var ans = 0\n for (i in 0 until n * 2 - 1 step 2) {\n ans += spear[i]\n }\n println(ans)\n}\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 239, "cpu_time_ms": 249, "memory_kb": 37820}, "variant": "medium_resource"}